UNPKG

@duckdb/duckdb-wasm

Version:
1 lines 765 kB
"use strict";var duckdb=(()=>{var jc=Object.create;var Pn=Object.defineProperty;var $c=Object.getOwnPropertyDescriptor;var qc=Object.getOwnPropertyNames;var Xc=Object.getPrototypeOf,Qc=Object.prototype.hasOwnProperty;var ba=(o,e)=>(e=Symbol[o])?e:Symbol.for("Symbol."+o);var Yc=(o,e,t)=>e in o?Pn(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var Cn=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var pr=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports),mr=(o,e)=>{for(var t in e)Pn(o,t,{get:e[t],enumerable:!0})},ko=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qc(e))!Qc.call(o,n)&&n!==t&&Pn(o,n,{get:()=>e[n],enumerable:!(r=$c(e,n))||r.enumerable});return o};var Bo=(o,e,t)=>(t=o!=null?jc(Xc(o)):{},ko(e||!o||!o.__esModule?Pn(t,"default",{value:o,enumerable:!0}):t,o)),Jc=o=>ko(Pn({},"__esModule",{value:!0}),o);var Qe=(o,e,t)=>(Yc(o,typeof e!="symbol"?e+"":e,t),t);var Kc=function(o,e){this[0]=o,this[1]=e};var Mr=o=>{var e=o[ba("asyncIterator")],t=!1,r,n={};return e==null?(e=o[ba("iterator")](),r=a=>n[a]=l=>e[a](l)):(e=e.call(o),r=a=>n[a]=l=>{if(t){if(t=!1,a==="throw")throw l;return l}return t=!0,{done:!1,value:new Kc(new Promise(c=>{var u=e[a](l);if(!(u instanceof Object))throw TypeError("Object expected");c(u)}),1)}}),n[ba("iterator")]=()=>n,r("next"),"throw"in e?r("throw"):n.throw=a=>{throw a},"return"in e&&r("return"),n};var Do=pr(()=>{});var Fo=pr(()=>{});var Mc=pr(()=>{});var To=pr((ES,kc)=>{"use strict";kc.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var Bc=pr((exports,module)=>{"use strict";var DuckDB=(()=>{var o;var _scriptName=typeof document<"u"?(o=document.currentScript)==null?void 0:o.src:void 0;return typeof __filename<"u"&&(_scriptName=_scriptName||__filename),function(moduleArg={}){var moduleRtn,Module=moduleArg,readyPromiseResolve,readyPromiseReject,readyPromise=new Promise((e,t)=>{readyPromiseResolve=e,readyPromiseReject=t}),ENVIRONMENT_IS_WEB=typeof window=="object",ENVIRONMENT_IS_WORKER=typeof WorkerGlobalScope<"u",ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer",ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER,moduleOverrides=Object.assign({},Module),arguments_=[],thisProgram="./this.program",quit_=(e,t)=>{throw t},scriptDirectory="";function locateFile(e){return Module.locateFile?Module.locateFile(e,scriptDirectory):scriptDirectory+e}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=Do(),nodePath=Fo();scriptDirectory=__dirname+"/",readBinary=e=>{e=isFileURI(e)?new URL(e):nodePath.normalize(e);var t=fs.readFileSync(e);return t},readAsync=(e,t=!0)=>(e=isFileURI(e)?new URL(e):nodePath.normalize(e),new Promise((r,n)=>{fs.readFile(e,t?void 0:"utf8",(a,l)=>{a?n(a):r(t?l.buffer:l)})})),!Module.thisProgram&&process.argv.length>1&&(thisProgram=process.argv[1].replace(/\\/g,"/")),arguments_=process.argv.slice(2),quit_=(e,t)=>{throw process.exitCode=e,t}}else(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&(ENVIRONMENT_IS_WORKER?scriptDirectory=self.location.href:typeof document<"u"&&document.currentScript&&(scriptDirectory=document.currentScript.src),_scriptName&&(scriptDirectory=_scriptName),scriptDirectory.startsWith("blob:")?scriptDirectory="":scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1),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=>fetch(e,{credentials:"same-origin"}).then(t=>t.ok?t.arrayBuffer():Promise.reject(new Error(t.status+" : "+t.url))));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);var dynamicLibraries=Module.dynamicLibraries||[],wasmBinary=Module.wasmBinary,wasmMemory,ABORT=!1,EXITSTATUS;function assert(e,t){e||abort(t)}var HEAP,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)}if(Module.wasmMemory)wasmMemory=Module.wasmMemory;else{var INITIAL_MEMORY=Module.INITIAL_MEMORY||16777216;wasmMemory=new WebAssembly.Memory({initial:INITIAL_MEMORY/65536,maximum:65536})}updateMemoryViews();var __ATPRERUN__=[],__ATINIT__=[],__ATMAIN__=[],__ATEXIT__=[],__ATPOSTRUN__=[],__RELOC_FUNCS__=[],runtimeInitialized=!1;function preRun(){if(Module.preRun)for(typeof Module.preRun=="function"&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=!0,callRuntimeCallbacks(__RELOC_FUNCS__),!Module.noFSInit&&!FS.initialized&&FS.init(),FS.ignorePermissions=!1,TTY.init(),SOCKFS.root=FS.mount(SOCKFS,{},null),PIPEFS.root=FS.mount(PIPEFS,{},null),callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function postRun(){if(Module.postRun)for(typeof Module.postRun=="function"&&(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 addOnPreMain(e){__ATMAIN__.unshift(e)}function addOnExit(e){}function addOnPostRun(e){__ATPOSTRUN__.unshift(e)}var runDependencies=0,runDependencyWatcher=null,dependenciesFulfilled=null;function getUniqueRunDependency(e){return e}function addRunDependency(e){var t;runDependencies++,(t=Module.monitorRunDependencies)==null||t.call(Module,runDependencies)}function removeRunDependency(e){var r;if(runDependencies--,(r=Module.monitorRunDependencies)==null||r.call(Module,runDependencies),runDependencies==0&&(runDependencyWatcher!==null&&(clearInterval(runDependencyWatcher),runDependencyWatcher=null),dependenciesFulfilled)){var t=dependenciesFulfilled;dependenciesFulfilled=null,t()}}function abort(e){var r;(r=Module.onAbort)==null||r.call(Module,e),e="Aborted("+e+")",err(e),ABORT=!0,e+=". Build with -sASSERTIONS for more info.",runtimeInitialized&&___trap();var t=new WebAssembly.RuntimeError(e);throw readyPromiseReject(t),t}var dataURIPrefix="data:application/octet-stream;base64,",isDataURI=e=>e.startsWith(dataURIPrefix),isFileURI=e=>e.startsWith("file://");function findWasmBinary(){var e="./duckdb-eh.wasm";return isDataURI(e)?e:locateFile(e)}var 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){return wasmBinary?Promise.resolve().then(()=>getBinarySync(e)):readAsync(e).then(t=>new Uint8Array(t),()=>getBinarySync(e))}function instantiateArrayBuffer(e,t,r){return getBinaryPromise(e).then(n=>WebAssembly.instantiate(n,t)).then(r,n=>{err("failed to asynchronously prepare wasm: ".concat(n)),abort(n)})}function instantiateAsync(e,t,r,n){return!e&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(t)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"?fetch(t,{credentials:"same-origin"}).then(a=>{var l=WebAssembly.instantiateStreaming(a,r);return l.then(n,function(c){return err("wasm streaming compile failed: ".concat(c)),err("falling back to ArrayBuffer instantiation"),instantiateArrayBuffer(t,r,n)})}):instantiateArrayBuffer(t,r,n)}function getWasmImports(){return{env:wasmImports,wasi_snapshot_preview1:wasmImports,"GOT.mem":new Proxy(wasmImports,GOTHandler),"GOT.func":new Proxy(wasmImports,GOTHandler)}}function createWasm(){var e=getWasmImports();function t(n,a){wasmExports=n.exports,wasmExports=relocateExports(wasmExports,1024);var l=getDylinkMetadata(a);return l.neededDynlibs&&(dynamicLibraries=l.neededDynlibs.concat(dynamicLibraries)),mergeLibSymbols(wasmExports,"main"),LDSO.init(),loadDylibs(),wasmExports=applySignatureConversions(wasmExports),addOnInit(wasmExports.__wasm_call_ctors),__RELOC_FUNCS__.push(wasmExports.__wasm_apply_data_relocs),removeRunDependency("wasm-instantiate"),wasmExports}addRunDependency("wasm-instantiate");function r(n){t(n.instance,n.module)}if(Module.instantiateWasm)try{return Module.instantiateWasm(e,t)}catch(n){err("Module.instantiateWasm callback failed with error: ".concat(n)),readyPromiseReject(n)}return wasmBinaryFile!=null||(wasmBinaryFile=findWasmBinary()),instantiateAsync(wasmBinary,wasmBinaryFile,e,r).catch(readyPromiseReject),{}}var tempDouble,tempI64,ASM_CONSTS={2316216:(e,t)=>{var r=typeof runtime=="object"&&runtime&&typeof runtime.whereToLoad=="function"&&runtime.whereToLoad?runtime.whereToLoad(UTF8ToString(e)):UTF8ToString(t),n=lengthBytesUTF8(r)+1,a=_malloc(n);return stringToUTF8(r,a,n),a},2316582:(e,t)=>{var r=UTF8ToString(e);if(typeof XMLHttpRequest>"u"){let A=Mc(),F=Fo(),C=Do();var n=r.split("/"),a=n.length,l=F.join(A.homedir(),".duckdb/extensions/"+n[a-4]+"/"+n[a-3]+"/"+n[a-2]+"/"),c=F.join(l,n[a-1]);try{if(C.existsSync(l)||C.mkdirSync(l,{recursive:!0}),C.existsSync(c))d=C.readFileSync(c);else{let x=new Int32Array(new SharedArrayBuffer(8));var u=Cn("node:worker_threads").Worker,_=new u("const {Worker,isMainThread,parentPort,workerData,} = require('node:worker_threads');var times = 0;var SAB = 23;var Z = 0; async function ZZZ(e) {var x = await fetch(e);var res = await x.arrayBuffer();Atomics.store(SAB, 1, res.byteLength);Atomics.store(SAB, 0, 1);Atomics.notify(SAB, 1);Atomics.notify(SAB, 0);Z = res;};parentPort.on('message', function(event) {if (times == 0) {times++;SAB = event;} else if (times == 1) {times++; ZZZ(event);} else {const a = new Uint8Array(Z);const b = new Uint8Array(event.buffer);var K = Z.byteLength;for (var i = 0; i < K; i++) {b[i] = a[i];}Atomics.notify(event, 0);Atomics.store(SAB, 0, 2);Atomics.notify(SAB, 0);}});",{eval:!0}),d;x[0]=0,x[2]=4,_.postMessage(x),_.postMessage(r),Atomics.wait(x,0,0);let S=new Int32Array(new SharedArrayBuffer(x[1]+3-(x[1]+3)%4));_.postMessage(S),Atomics.wait(x,0,1);var f=new Uint8Array(S.buffer,0,x[1]);d=f,_.terminate(),C.writeFileSync(c,d)}}catch(x){return console.log("Error fetching module",x),0}}else{let A=new XMLHttpRequest;if(A.open("GET",r,!1),A.responseType="arraybuffer",A.send(null),A.status!=200)return 0;d=A.response}for(var p=WebAssembly.validate(d),m=d.byteLength,g=_malloc(m+4),h=new Uint8Array(d),b=0;b<m;b++)Module.HEAPU8[b+g+4]=h[b];var y=new Uint8Array(4);return y[0]=m%256,m-=y[0],m/=256,y[1]=m%256,m-=y[1],m/=256,y[2]=m%256,m-=y[2],m/=256,y[3]=m%256,m-=y[3],m/=256,Module.HEAPU8.set(y,g),FS.writeFile(UTF8ToString(t),new Uint8Array(d)),g},2319223:e=>{if(!e)return AL.alcErr=40964,1},2319271:e=>{if(!AL.currentCtx)return err("alGetProcAddress() called without a valid context"),1;if(!e)return AL.currentCtx.err=40963,1}};class ExitStatus{constructor(t){Qe(this,"name","ExitStatus");this.message="Program terminated with exit(".concat(t,")"),this.status=t}}var GOT={},currentModuleWeakSymbols=new Set([]),GOTHandler={get(e,t){var r=GOT[t];return r||(r=GOT[t]=new WebAssembly.Global({value:"i32",mutable:!0})),currentModuleWeakSymbols.has(t)||(r.required=!0),r}},callRuntimeCallbacks=e=>{for(;e.length>0;)e.shift()(Module)},UTF8Decoder=typeof TextDecoder<"u"?new TextDecoder:void 0,UTF8ArrayToString=(e,t=0,r=NaN)=>{t>>>=0;for(var n=t+r,a=t;e[a]&&!(a>=n);)++a;if(a-t>16&&e.buffer&&UTF8Decoder)return UTF8Decoder.decode(e.subarray(t,a));for(var l="";t<a;){var c=e[t++];if(!(c&128)){l+=String.fromCharCode(c);continue}var u=e[t++]&63;if((c&224)==192){l+=String.fromCharCode((c&31)<<6|u);continue}var _=e[t++]&63;if((c&240)==224?c=(c&15)<<12|u<<6|_:c=(c&7)<<18|u<<12|_<<6|e[t++]&63,c<65536)l+=String.fromCharCode(c);else{var d=c-65536;l+=String.fromCharCode(55296|d>>10,56320|d&1023)}}return l},getDylinkMetadata=e=>{var t=0,r=0;function n(){return e[t++]}function a(){for(var I=0,k=1;;){var Q=e[t++];if(I+=(Q&127)*k,k*=128,!(Q&128))break}return I}function l(){var I=a();return t+=I,UTF8ArrayToString(e,t-I,I)}function c(I,k){if(I)throw new Error(k)}var u="dylink.0";if(e instanceof WebAssembly.Module){var _=WebAssembly.Module.customSections(e,u);_.length===0&&(u="dylink",_=WebAssembly.Module.customSections(e,u)),c(_.length===0,"need dylink section"),e=new Uint8Array(_[0]),r=e.length}else{var d=new Uint32Array(new Uint8Array(e.subarray(0,24)).buffer),f=d[0]==1836278016;c(!f,"need to see wasm magic number"),c(e[8]!==0,"need the dylink section to be first"),t=9;var p=a();r=t+p,u=l()}var m={neededDynlibs:[],tlsExports:new Set,weakImports:new Set};if(u=="dylink"){m.memorySize=a(),m.memoryAlign=a(),m.tableSize=a(),m.tableAlign=a();for(var g=a(),h=0;h<g;++h){var b=l();m.neededDynlibs.push(b)}}else{c(u!=="dylink.0");for(var y=1,A=2,F=3,C=4,x=256,S=3,T=1;t<r;){var E=n(),w=a();if(E===y)m.memorySize=a(),m.memoryAlign=a(),m.tableSize=a(),m.tableAlign=a();else if(E===A)for(var g=a(),h=0;h<g;++h)b=l(),m.neededDynlibs.push(b);else if(E===F)for(var P=a();P--;){var L=l(),M=a();M&x&&m.tlsExports.add(L)}else if(E===C)for(var P=a();P--;){var D=l(),L=l(),M=a();(M&S)==T&&m.weakImports.add(L)}else t+=w}}return m};function getValue(e,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":return HEAP8[e>>>0];case"i8":return HEAP8[e>>>0];case"i16":return HEAP16[e>>>1>>>0];case"i32":return HEAP32[e>>>2>>>0];case"i64":abort("to do getValue(i64) use WASM_BIGINT");case"float":return HEAPF32[e>>>2>>>0];case"double":return HEAPF64[e>>>3>>>0];case"*":return HEAPU32[e>>>2>>>0];default:abort("invalid type for getValue: ".concat(t))}}var newDSO=(e,t,r)=>{var n={refcount:1/0,name:e,exports:r,global:!0};return LDSO.loadedLibsByName[e]=n,t!=null&&(LDSO.loadedLibsByHandle[t]=n),n},LDSO={loadedLibsByName:{},loadedLibsByHandle:{},init(){newDSO("__main__",0,wasmImports)}},___heap_base=2457664,alignMemory=(e,t)=>Math.ceil(e/t)*t,getMemory=e=>{if(runtimeInitialized)return _calloc(e,1);var t=___heap_base,r=t+alignMemory(e,16);return ___heap_base=r,GOT.__heap_base.value=r,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"},r={parameters:[],results:e[0]=="v"?[]:[t[e[0]]]},n=1;n<e.length;++n)r.parameters.push(t[e[n]]);return r},generateFuncType=(e,t)=>{var r=e.slice(0,1),n=e.slice(1),a={i:127,p:127,j:126,f:125,d:124,e:111};t.push(96),uleb128Encode(n.length,t);for(var l=0;l<n.length;++l)t.push(a[n[l]]);r=="v"?t.push(0):t.push(1,a[r])},convertJsFunctionToWasm=(e,t)=>{if(typeof WebAssembly.Function=="function")return new WebAssembly.Function(sigToWasmTypes(t),e);var r=[1];generateFuncType(t,r);var n=[0,97,115,109,1,0,0,0,1];uleb128Encode(r.length,n),n.push(...r),n.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var a=new WebAssembly.Module(new Uint8Array(n)),l=new WebAssembly.Instance(a,{e:{f:e}}),c=l.exports.f;return c},wasmTable=new WebAssembly.Table({initial:23326,element:"anyfunc"}),getWasmTableEntry=e=>wasmTable.get(e),updateTableMap=(e,t)=>{if(functionsInTableMap)for(var r=e;r<e+t;r++){var n=getWasmTableEntry(r);n&&functionsInTableMap.set(n,r)}},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){throw e instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":e}return wasmTable.length-1},setWasmTableEntry=(e,t)=>wasmTable.set(e,t),addFunction=(e,t)=>{var r=getFunctionAddress(e);if(r)return r;var n=getEmptyTableSlot();try{setWasmTableEntry(n,e)}catch(l){if(!(l instanceof TypeError))throw l;var a=convertJsFunctionToWasm(e,t);setWasmTableEntry(n,a)}return functionsInTableMap.set(e,n),n},updateGOT=(e,t)=>{for(var r in e)if(!isInternalSym(r)){var n=e[r];r.startsWith("orig$")&&(r=r.split("$")[1],t=!0),GOT[r]||(GOT[r]=new WebAssembly.Global({value:"i32",mutable:!0})),(t||GOT[r].value==0)&&(typeof n=="function"?GOT[r].value=addFunction(n):typeof n=="number"?GOT[r].value=n:err("unhandled export type for '".concat(r,"': ").concat(typeof n)))}},relocateExports=(e,t,r)=>{var n={};for(var a in e){var l=e[a];typeof l=="object"&&(l=l.value),typeof l=="number"&&(l+=t),n[a]=l}return updateGOT(n,r),n},isSymbolDefined=e=>{var t=wasmImports[e];return!(!t||t.stub)},resolveGlobalSymbol=(e,t=!1)=>{var r;return t&&"orig$"+e in wasmImports&&(e="orig$"+e),isSymbolDefined(e)&&(r=wasmImports[e]),{sym:r,name:e}},UTF8ToString=(e,t)=>(e>>>=0,e?UTF8ArrayToString(HEAPU8,e,t):""),loadWebAssemblyModule=(binary,flags,libName,localScope,handle)=>{var metadata=getDylinkMetadata(binary);currentModuleWeakSymbols=metadata.weakImports;function loadModule(){var firstLoad=!handle||!HEAP8[handle+8>>>0];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>>>0]=1,HEAPU32[handle+12>>>2>>>0]=memoryBase,HEAP32[handle+16>>>2>>>0]=metadata.memorySize,HEAPU32[handle+20>>>2>>>0]=tableBase,HEAP32[handle+24>>>2>>>0]=metadata.tableSize)}else memoryBase=HEAPU32[handle+12>>>2>>>0],tableBase=HEAPU32[handle+20>>>2>>>0];var tableGrowthNeeded=tableBase+metadata.tableSize-wasmTable.length;tableGrowthNeeded>0&&wasmTable.grow(tableGrowthNeeded);var moduleExports;function resolveSymbol(e){var t=resolveGlobalSymbol(e).sym;return!t&&localScope&&(t=localScope[e]),t||(t=moduleExports[e]),t}var proxyHandler={get(e,t){if(t.startsWith("invoke_"))return createDyncallWrapper(t.substring(7));switch(t){case"__memory_base":return memoryBase;case"__table_base":return tableBase}if(t in wasmImports&&!wasmImports[t].stub)return wasmImports[t];if(!(t in e)){var r;e[t]=(...n)=>(r||(r=resolveSymbol(t)),r(...n))}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){updateTableMap(tableBase,metadata.tableSize),moduleExports=relocateExports(instance.exports,memoryBase),flags.allowUndefined||reportUndefinedSymbols();function addEmAsm(addr,body){for(var args=[],arity=0;arity<16&&body.indexOf("$"+arity)!=-1;arity++)args.push("$"+arity);args=args.join(",");var func="(".concat(args,") => { ").concat(body," };");ASM_CONSTS[start]=eval(func)}if("__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),cSig!="void"){cSig=cSig.split(",");for(var i in cSig){var jsArg=cSig[i].split(" ").pop();jsArgs.push(jsArg.replace("*",""))}}var func="(".concat(jsArgs,") => ").concat(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 flags.loadAsync?metadata.neededDynlibs.reduce((e,t)=>e.then(()=>loadDynamicLibrary(t,flags,localScope)),Promise.resolve()).then(loadModule):(metadata.neededDynlibs.forEach(e=>loadDynamicLibrary(e,flags,localScope)),loadModule())},mergeLibSymbols=(e,t)=>{registerDynCallSymbols(e);for(var[r,n]of Object.entries(e))(l=>{isSymbolDefined(l)||(wasmImports[l]=n)})(r)},asyncLoad=(e,t,r,n)=>{var a=n?"":"al ".concat(e);readAsync(e).then(l=>{t(new Uint8Array(l)),a&&removeRunDependency(a)},l=>{if(r)r();else throw'Loading data file "'.concat(e,'" failed.')}),a&&addRunDependency(a)},preloadPlugins=Module.preloadPlugins||[],registerWasmPlugin=()=>{var e={promiseChainEnd:Promise.resolve(),canHandle:t=>!Module.noWasmDecoding&&t.endsWith(".so"),handle:(t,r,n,a)=>{e.promiseChainEnd=e.promiseChainEnd.then(()=>loadWebAssemblyModule(t,{loadAsync:!0,nodelete:!0},r,{})).then(l=>{preloadedWasm[r]=l,n(t)},l=>{err("failed to instantiate wasm: ".concat(r,": ").concat(l)),a()})}};preloadPlugins.push(e)},preloadedWasm={},registerDynCallSymbols=e=>{for(var[t,r]of Object.entries(e))t.startsWith("dynCall_")&&!Module.hasOwnProperty(t)&&(Module[t]=r)};function loadDynamicLibrary(e,t={global:!0,nodelete:!0},r,n){var a=LDSO.loadedLibsByName[e];if(a)return t.global?a.global||(a.global=!0,mergeLibSymbols(a.exports,e)):(r&&Object.assign(r,a.exports),registerDynCallSymbols(a.exports)),t.nodelete&&a.refcount!==1/0&&(a.refcount=1/0),a.refcount++,n&&(LDSO.loadedLibsByHandle[n]=a),t.loadAsync?Promise.resolve(!0):!0;a=newDSO(e,n,"loading"),a.refcount=t.nodelete?1/0:1,a.global=t.global;function l(){if(n){var _=HEAPU32[n+28>>>2>>>0],d=HEAPU32[n+32>>>2>>>0];if(_&&d){var f=HEAP8.slice(_,_+d);return t.loadAsync?Promise.resolve(f):f}}var p=locateFile(e);if(t.loadAsync)return new Promise((m,g)=>asyncLoad(p,m,g));if(!readBinary)throw new Error("".concat(p,": file not found, and synchronous loading of external files is not available"));return readBinary(p)}function c(){var _=preloadedWasm[e];return _?t.loadAsync?Promise.resolve(_):_:t.loadAsync?l().then(d=>loadWebAssemblyModule(d,t,e,r,n)):loadWebAssemblyModule(l(),t,e,r,n)}function u(_){a.global?mergeLibSymbols(_,e):r&&(Object.assign(r,_),registerDynCallSymbols(_)),a.exports=_}return t.loadAsync?c().then(_=>(u(_),!0)):(u(c()),!0)}var reportUndefinedSymbols=()=>{for(var[e,t]of Object.entries(GOT))if(t.value==0){var r=resolveGlobalSymbol(e,!0).sym;if(!r&&!t.required)continue;if(typeof r=="function")t.value=addFunction(r,r.sig);else if(typeof r=="number")t.value=r;else throw new Error("bad export type for '".concat(e,"': ").concat(typeof r))}},loadDylibs=()=>{if(!dynamicLibraries.length){reportUndefinedSymbols();return}addRunDependency("loadDylibs"),dynamicLibraries.reduce((e,t)=>e.then(()=>loadDynamicLibrary(t,{loadAsync:!0,global:!0,nodelete:!0,allowUndefined:!0})),Promise.resolve()).then(()=>{reportUndefinedSymbols(),removeRunDependency("loadDylibs")})},noExitRuntime=Module.noExitRuntime||!0;function setValue(e,t,r="i8"){switch(r.endsWith("*")&&(r="*"),r){case"i1":HEAP8[e>>>0]=t;break;case"i8":HEAP8[e>>>0]=t;break;case"i16":HEAP16[e>>>1>>>0]=t;break;case"i32":HEAP32[e>>>2>>>0]=t;break;case"i64":abort("to do setValue(i64) use WASM_BIGINT");case"float":HEAPF32[e>>>2>>>0]=t;break;case"double":HEAPF64[e>>>3>>>0]=t;break;case"*":HEAPU32[e>>>2>>>0]=t;break;default:abort("invalid type for setValue: ".concat(r))}}var convertI32PairToI53Checked=(e,t)=>t+2097152>>>0<4194305-!!e?(e>>>0)+t*4294967296:NaN;function ___assert_fail(e,t,r,n){e>>>=0,t>>>=0,n>>>=0,abort("Assertion failed: ".concat(UTF8ToString(e),", at: ")+[t?UTF8ToString(t):"unknown filename",r,n?UTF8ToString(n):"unknown function"])}___assert_fail.sig="vppip";var ___c_longjmp=new WebAssembly.Tag({parameters:["i32"]});function ___call_sighandler(e,t){return e>>>=0,getWasmTableEntry(e)(t)}___call_sighandler.sig="vpi";var ___cpp_exception=new WebAssembly.Tag({parameters:["i32"]}),___memory_base=new WebAssembly.Global({value:"i32",mutable:!1},1024),___stack_high=2457664,___stack_low=2392128,___stack_pointer=new WebAssembly.Global({value:"i32",mutable:!0},2457664),PATH={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return t.exec(e).slice(1)},normalizeArray:(e,t)=>{for(var r=0,n=e.length-1;n>=0;n--){var a=e[n];a==="."?e.splice(n,1):a===".."?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r;r--)e.unshift("..");return e},normalize:e=>{var t=PATH.isAbs(e),r=e.substr(-1)==="/";return e=PATH.normalizeArray(e.split("/").filter(n=>!!n),!t).join("/"),!e&&!t&&(e="."),e&&r&&(e+="/"),(t?"/":"")+e},dirname:e=>{var t=PATH.splitPath(e),r=t[0],n=t[1];return!r&&!n?".":(n&&(n=n.substr(0,n.length-1)),r+n)},basename:e=>{if(e==="/")return"/";e=PATH.normalize(e),e=e.replace(/\/$/,"");var t=e.lastIndexOf("/");return t===-1?e:e.substr(t+1)},join:(...e)=>PATH.normalize(e.join("/")),join2:(e,t)=>PATH.normalize(e+"/"+t)},initRandomFill=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return n=>crypto.getRandomValues(n);if(ENVIRONMENT_IS_NODE)try{var e=Cn("crypto"),t=e.randomFillSync;if(t)return n=>e.randomFillSync(n);var r=e.randomBytes;return n=>(n.set(r(n.byteLength)),n)}catch(n){}abort("initRandomDevice")},randomFill=e=>(randomFill=initRandomFill())(e),PATH_FS={resolve:(...e)=>{for(var t="",r=!1,n=e.length-1;n>=-1&&!r;n--){var a=n>=0?e[n]:FS.cwd();if(typeof a!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!a)return"";t=a+"/"+t,r=PATH.isAbs(a)}return t=PATH.normalizeArray(t.split("/").filter(l=>!!l),!r).join("/"),(r?"/":"")+t||"."},relative:(e,t)=>{e=PATH_FS.resolve(e).substr(1),t=PATH_FS.resolve(t).substr(1);function r(d){for(var f=0;f<d.length&&d[f]==="";f++);for(var p=d.length-1;p>=0&&d[p]==="";p--);return f>p?[]:d.slice(f,p-f+1)}for(var n=r(e.split("/")),a=r(t.split("/")),l=Math.min(n.length,a.length),c=l,u=0;u<l;u++)if(n[u]!==a[u]){c=u;break}for(var _=[],u=c;u<n.length;u++)_.push("..");return _=_.concat(a.slice(c)),_.join("/")}},FS_stdin_getChar_buffer=[],lengthBytesUTF8=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n<=127?t++:n<=2047?t+=2:n>=55296&&n<=57343?(t+=4,++r):t+=3}return t},stringToUTF8Array=(e,t,r,n)=>{if(r>>>=0,!(n>0))return 0;for(var a=r,l=r+n-1,c=0;c<e.length;++c){var u=e.charCodeAt(c);if(u>=55296&&u<=57343){var _=e.charCodeAt(++c);u=65536+((u&1023)<<10)|_&1023}if(u<=127){if(r>=l)break;t[r++>>>0]=u}else if(u<=2047){if(r+1>=l)break;t[r++>>>0]=192|u>>6,t[r++>>>0]=128|u&63}else if(u<=65535){if(r+2>=l)break;t[r++>>>0]=224|u>>12,t[r++>>>0]=128|u>>6&63,t[r++>>>0]=128|u&63}else{if(r+3>=l)break;t[r++>>>0]=240|u>>18,t[r++>>>0]=128|u>>12&63,t[r++>>>0]=128|u>>6&63,t[r++>>>0]=128|u&63}}return t[r>>>0]=0,r-a};function intArrayFromString(e,t,r){var n=r>0?r:lengthBytesUTF8(e)+1,a=new Array(n),l=stringToUTF8Array(e,a,0,a.length);return t&&(a.length=l),a}var FS_stdin_getChar=()=>{if(!FS_stdin_getChar_buffer.length){var e=null;if(ENVIRONMENT_IS_NODE){var t=256,r=Buffer.alloc(t),n=0,a=process.stdin.fd;try{n=fs.readSync(a,r,0,t)}catch(l){if(l.toString().includes("EOF"))n=0;else throw l}n>0&&(e=r.slice(0,n).toString("utf-8"))}else typeof window<"u"&&typeof window.prompt=="function"&&(e=window.prompt("Input: "),e!==null&&(e+="\n"));if(!e)return null;FS_stdin_getChar_buffer=intArrayFromString(e,!0)}return FS_stdin_getChar_buffer.shift()},TTY={ttys:[],init(){},shutdown(){},register(e,t){TTY.ttys[e]={input:[],output:[],ops:t},FS.registerDevice(e,TTY.stream_ops)},stream_ops:{open(e){var t=TTY.ttys[e.node.rdev];if(!t)throw new FS.ErrnoError(43);e.tty=t,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,t,r,n,a){if(!e.tty||!e.tty.ops.get_char)throw new FS.ErrnoError(60);for(var l=0,c=0;c<n;c++){var u;try{u=e.tty.ops.get_char(e.tty)}catch(_){throw new FS.ErrnoError(29)}if(u===void 0&&l===0)throw new FS.ErrnoError(6);if(u==null)break;l++,t[r+c]=u}return l&&(e.node.timestamp=Date.now()),l},write(e,t,r,n,a){if(!e.tty||!e.tty.ops.put_char)throw new FS.ErrnoError(60);try{for(var l=0;l<n;l++)e.tty.ops.put_char(e.tty,t[r+l])}catch(c){throw new FS.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),l}},default_tty_ops:{get_char(e){return FS_stdin_getChar()},put_char(e,t){t===null||t===10?(out(UTF8ArrayToString(e.output)),e.output=[]):t!=0&&e.output.push(t)},fsync(e){e.output&&e.output.length>0&&(out(UTF8ArrayToString(e.output)),e.output=[])},ioctl_tcgets(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(e,t,r){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,t){t===null||t===10?(err(UTF8ArrayToString(e.output)),e.output=[]):t!=0&&e.output.push(t)},fsync(e){e.output&&e.output.length>0&&(err(UTF8ArrayToString(e.output)),e.output=[])}}},zeroMemory=(e,t)=>{HEAPU8.fill(0,e,e+t)},mmapAlloc=e=>{e=alignMemory(e,65536);var t=_emscripten_builtin_memalign(65536,e);return t&&zeroMemory(t,e),t},MEMFS={ops_table:null,mount(e){return MEMFS.createNode(null,"/",16895,0)},createNode(e,t,r,n){if(FS.isBlkdev(r)||FS.isFIFO(r))throw new FS.ErrnoError(63);MEMFS.ops_table||(MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}});var a=FS.createNode(e,t,r,n);return FS.isDir(a.mode)?(a.node_ops=MEMFS.ops_table.dir.node,a.stream_ops=MEMFS.ops_table.dir.stream,a.contents={}):FS.isFile(a.mode)?(a.node_ops=MEMFS.ops_table.file.node,a.stream_ops=MEMFS.ops_table.file.stream,a.usedBytes=0,a.contents=null):FS.isLink(a.mode)?(a.node_ops=MEMFS.ops_table.link.node,a.stream_ops=MEMFS.ops_table.link.stream):FS.isChrdev(a.mode)&&(a.node_ops=MEMFS.ops_table.chrdev.node,a.stream_ops=MEMFS.ops_table.chrdev.stream),a.timestamp=Date.now(),e&&(e.contents[t]=a,e.timestamp=a.timestamp),a},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,t){var r=e.contents?e.contents.length:0;if(!(r>=t)){var n=1024*1024;t=Math.max(t,r*(r<n?2:1.125)>>>0),r!=0&&(t=Math.max(t,256));var a=e.contents;e.contents=new Uint8Array(t),e.usedBytes>0&&e.contents.set(a.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,t){if(e.usedBytes!=t)if(t==0)e.contents=null,e.usedBytes=0;else{var r=e.contents;e.contents=new Uint8Array(t),r&&e.contents.set(r.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr(e){var t={};return t.dev=FS.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,FS.isDir(e.mode)?t.size=4096:FS.isFile(e.mode)?t.size=e.usedBytes:FS.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr(e,t){t.mode!==void 0&&(e.mode=t.mode),t.timestamp!==void 0&&(e.timestamp=t.timestamp),t.size!==void 0&&MEMFS.resizeFileStorage(e,t.size)},lookup(e,t){throw FS.genericErrors[44]},mknod(e,t,r,n){return MEMFS.createNode(e,t,r,n)},rename(e,t,r){if(FS.isDir(e.mode)){var n;try{n=FS.lookupNode(t,r)}catch(l){}if(n)for(var a in n.contents)throw new FS.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=r,t.contents[r]=e,t.timestamp=e.parent.timestamp},unlink(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir(e,t){var r=FS.lookupNode(e,t);for(var n in r.contents)throw new FS.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir(e){var t=[".",".."];for(var r of Object.keys(e.contents))t.push(r);return t},symlink(e,t,r){var n=MEMFS.createNode(e,t,41471,0);return n.link=r,n},readlink(e){if(!FS.isLink(e.mode))throw new FS.ErrnoError(28);return e.link}},stream_ops:{read(e,t,r,n,a){var l=e.node.contents;if(a>=e.node.usedBytes)return 0;var c=Math.min(e.node.usedBytes-a,n);if(c>8&&l.subarray)t.set(l.subarray(a,a+c),r);else for(var u=0;u<c;u++)t[r+u]=l[a+u];return c},write(e,t,r,n,a,l){if(t.buffer===HEAP8.buffer&&(l=!1),!n)return 0;var c=e.node;if(c.timestamp=Date.now(),t.subarray&&(!c.contents||c.contents.subarray)){if(l)return c.contents=t.subarray(r,r+n),c.usedBytes=n,n;if(c.usedBytes===0&&a===0)return c.contents=t.slice(r,r+n),c.usedBytes=n,n;if(a+n<=c.usedBytes)return c.contents.set(t.subarray(r,r+n),a),n}if(MEMFS.expandFileStorage(c,a+n),c.contents.subarray&&t.subarray)c.contents.set(t.subarray(r,r+n),a);else for(var u=0;u<n;u++)c.contents[a+u]=t[r+u];return c.usedBytes=Math.max(c.usedBytes,a+n),n},llseek(e,t,r){var n=t;if(r===1?n+=e.position:r===2&&FS.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new FS.ErrnoError(28);return n},allocate(e,t,r){MEMFS.expandFileStorage(e.node,t+r),e.node.usedBytes=Math.max(e.node.usedBytes,t+r)},mmap(e,t,r,n,a){if(!FS.isFile(e.node.mode))throw new FS.ErrnoError(43);var l,c,u=e.node.contents;if(!(a&2)&&u&&u.buffer===HEAP8.buffer)c=!1,l=u.byteOffset;else{if(c=!0,l=mmapAlloc(t),!l)throw new FS.ErrnoError(48);u&&((r>0||r+t<u.length)&&(u.subarray?u=u.subarray(r,r+t):u=Array.prototype.slice.call(u,r,r+t)),HEAP8.set(u,l>>>0))}return{ptr:l,allocated:c}},msync(e,t,r,n,a){return MEMFS.stream_ops.write(e,t,0,n,r,!1),0}}},FS_createDataFile=(e,t,r,n,a,l)=>{FS.createDataFile(e,t,r,n,a,l)},FS_handledByPreloadPlugin=(e,t,r,n)=>{typeof Browser<"u"&&Browser.init();var a=!1;return preloadPlugins.forEach(l=>{a||l.canHandle(t)&&(l.handle(e,t,r,n),a=!0)}),a},FS_createPreloadedFile=(e,t,r,n,a,l,c,u,_,d)=>{var f=t?PATH_FS.resolve(PATH.join2(e,t)):e,p="cp ".concat(f);function m(g){function h(b){d==null||d(),u||FS_createDataFile(e,t,b,n,a,_),l==null||l(),removeRunDependency(p)}FS_handledByPreloadPlugin(g,f,h,()=>{c==null||c(),removeRunDependency(p)})||h(g)}addRunDependency(p),typeof r=="string"?asyncLoad(r,m,c):m(r)},FS_modeStringToFlags=e=>{var t={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},r=t[e];if(typeof r>"u")throw new Error("Unknown file open mode: ".concat(e));return r},FS_getMode=(e,t)=>{var r=0;return e&&(r|=365),t&&(r|=146),r},FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:class{constructor(e){Qe(this,"name","ErrnoError");this.errno=e}},genericErrors:{},filesystems:null,syncFSRequests:0,readFiles:{},FSStream:class{constructor(){Qe(this,"shared",{})}get object(){return this.node}set object(e){this.node=e}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{constructor(e,t,r,n){Qe(this,"node_ops",{});Qe(this,"stream_ops",{});Qe(this,"readMode",365);Qe(this,"writeMode",146);Qe(this,"mounted",null);e||(e=this),this.parent=e,this.mount=e.mount,this.id=FS.nextInode++,this.name=t,this.mode=r,this.rdev=n}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return FS.isDir(this.mode)}get isDevice(){return FS.isChrdev(this.mode)}},lookupPath(e,t={}){if(e=PATH_FS.resolve(e),!e)return{path:"",node:null};var r={follow_mount:!0,recurse_count:0};if(t=Object.assign(r,t),t.recurse_count>8)throw new FS.ErrnoError(32);for(var n=e.split("/").filter(p=>!!p),a=FS.root,l="/",c=0;c<n.length;c++){var u=c===n.length-1;if(u&&t.parent)break;if(a=FS.lookupNode(a,n[c]),l=PATH.join2(l,n[c]),FS.isMountpoint(a)&&(!u||u&&t.follow_mount)&&(a=a.mounted.root),!u||t.follow)for(var _=0;FS.isLink(a.mode);){var d=FS.readlink(l);l=PATH_FS.resolve(PATH.dirname(l),d);var f=FS.lookupPath(l,{recurse_count:t.recurse_count+1});if(a=f.node,_++>40)throw new FS.ErrnoError(32)}}return{path:l,node:a}},getPath(e){for(var t;;){if(FS.isRoot(e)){var r=e.mount.mountpoint;return t?r[r.length-1]!=="/"?"".concat(r,"/").concat(t):r+t:r}t=t?"".concat(e.name,"/").concat(t):e.name,e=e.parent}},hashName(e,t){for(var r=0,n=0;n<t.length;n++)r=(r<<5)-r+t.charCodeAt(n)|0;return(e+r>>>0)%FS.nameTable.length},hashAddNode(e){var t=FS.hashName(e.parent.id,e.name);e.name_next=FS.nameTable[t],FS.nameTable[t]=e},hashRemoveNode(e){var t=FS.hashName(e.parent.id,e.name);if(FS.nameTable[t]===e)FS.nameTable[t]=e.name_next;else for(var r=FS.nameTable[t];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode(e,t){var r=FS.mayLookup(e);if(r)throw new FS.ErrnoError(r);for(var n=FS.hashName(e.id,t),a=FS.nameTable[n];a;a=a.name_next){var l=a.name;if(a.parent.id===e.id&&l===t)return a}return FS.lookup(e,t)},createNode(e,t,r,n){var a=new FS.FSNode(e,t,r,n);return FS.hashAddNode(a),a},destroyNode(e){FS.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return(e&61440)===32768},isDir(e){return(e&61440)===16384},isLink(e){return(e&61440)===40960},isChrdev(e){return(e&61440)===8192},isBlkdev(e){return(e&61440)===24576},isFIFO(e){return(e&61440)===4096},isSocket(e){return(e&49152)===49152},flagsToPermissionString(e){var t=["r","w","rw"][e&3];return e&512&&(t+="w"),t},nodePermissions(e,t){return FS.ignorePermissions?0:t.includes("r")&&!(e.mode&292)||t.includes("w")&&!(e.mode&146)||t.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!FS.isDir(e.mode))return 54;var t=FS.nodePermissions(e,"x");return t||(e.node_ops.lookup?0:2)},mayCreate(e,t){try{var r=FS.lookupNode(e,t);return 20}catch(n){}return FS.nodePermissions(e,"wx")},mayDelete(e,t,r){var n;try{n=FS.lookupNode(e,t)}catch(l){return l.errno}var a=FS.nodePermissions(e,"wx");if(a)return a;if(r){if(!FS.isDir(n.mode))return 54;if(FS.isRoot(n)||FS.getPath(n)===FS.cwd())return 10}else if(FS.isDir(n.mode))return 31;return 0},mayOpen(e,t){return e?FS.isLink(e.mode)?32:FS.isDir(e.mode)&&(FS.flagsToPermissionString(t)!=="r"||t&512)?31:FS.nodePermissions(e,FS.flagsToPermissionString(t)):44},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=FS.MAX_OPEN_FDS;e++)if(!FS.streams[e])return e;throw new FS.ErrnoError(33)},getStreamChecked(e){var t=FS.getStream(e);if(!t)throw new FS.ErrnoError(8);return t},getStream:e=>FS.streams[e],createStream(e,t=-1){return e=Object.assign(new FS.FSStream,e),t==-1&&(t=FS.nextfd()),e.fd=t,FS.streams[t]=e,e},closeStream(e){FS.streams[e]=null},dupStream(e,t=-1){var n,a;var r=FS.createStream(e,t);return(a=(n=r.stream_ops)==null?void 0:n.dup)==null||a.call(n,r),r},chrdev_stream_ops:{open(e){var r,n;var t=FS.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,(n=(r=e.stream_ops).open)==null||n.call(r,e)},llseek(){throw new FS.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,t)=>e<<8|t,registerDevice(e,t){FS.devices[e]={stream_ops:t}},getDevice:e=>FS.devices[e],getMounts(e){for(var t=[],r=[e];r.length;){var n=r.pop();t.push(n),r.push(...n.mounts)}return t},syncfs(e,t){typeof e=="function"&&(t=e,e=!1),FS.syncFSRequests++,FS.syncFSRequests>1&&err("warning: ".concat(FS.syncFSRequests," FS.syncfs operations in flight at once, probably just doing extra work"));var r=FS.getMounts(FS.root.mount),n=0;function a(c){return FS.syncFSRequests--,t(c)}function l(c){if(c)return l.errored?void 0:(l.errored=!0,a(c));++n>=r.length&&a(null)}r.forEach(c=>{if(!c.type.syncfs)return l(null);c.type.syncfs(c,e,l)})},mount(e,t,r){var n=r==="/",a=!r,l;if(n&&FS.root)throw new FS.ErrnoError(10);if(!n&&!a){var c=FS.lookupPath(r,{follow_mount:!1});if(r=c.path,l=c.node,FS.isMountpoint(l))throw new FS.ErrnoError(10);if(!FS.isDir(l.mode))throw new FS.ErrnoError(54)}var u={type:e,opts:t,mountpoint:r,mounts:[]},_=e.mount(u);return _.mount=u,u.root=_,n?FS.root=_:l&&(l.mounted=u,l.mount&&l.mount.mounts.push(u)),_},unmount(e){var t=FS.lookupPath(e,{follow_mount:!1});if(!FS.isMountpoint(t.node))throw new FS.ErrnoError(28);var r=t.node,n=r.mounted,a=FS.getMounts(n);Object.keys(FS.nameTable).forEach(c=>{for(var u=FS.nameTable[c];u;){var _=u.name_next;a.includes(u.mount)&&FS.destroyNode(u),u=_}}),r.mounted=null;var l=r.mount.mounts.indexOf(n);r.mount.mounts.splice(l,1)},lookup(e,t){return e.node_ops.lookup(e,t)},mknod(e,t,r){var n=FS.lookupPath(e,{parent:!0}),a=n.node,l=PATH.basename(e);if(!l||l==="."||l==="..")throw new FS.ErrnoError(28);var c=FS.mayCreate(a,l);if(c)throw new FS.ErrnoError(c);if(!a.node_ops.mknod)throw new FS.ErrnoError(63);return a.node_ops.mknod(a,l,t,r)},create(e,t){return t=t!==void 0?t:438,t&=4095,t|=32768,FS.mknod(e,t,0)},mkdir(e,t){return t=t!==void 0?t:511,t&=1023,t|=16384,FS.mknod(e,t,0)},mkdirTree(e,t){for(var r=e.split("/"),n="",a=0;a<r.length;++a)if(r[a]){n+="/"+r[a];try{FS.mkdir(n,t)}catch(l){if(l.errno!=20)throw l}}},mkdev(e,t,r){return typeof r>"u"&&(r=t,t=438),t|=8192,FS.mknod(e,t,r)},symlink(e,t){if(!PATH_FS.resolve(e))throw new FS.ErrnoError(44);var r=FS.lookupPath(t,{parent:!0}),n=r.node;if(!n)throw new FS.ErrnoError(44);var a=PATH.basename(t),l=FS.mayCreate(n,a);if(l)throw new FS.ErrnoError(l);if(!n.node_ops.symlink)throw new FS.ErrnoError(63);return n.node_ops.symlink(n,a,e)},rename(e,t){var r=PATH.dirname(e),n=PATH.dirname(t),a=PATH.basename(e),l=PATH.basename(t),c,u,_;if(c=FS.lookupPath(e,{parent:!0}),u=c.node,c=FS.lookupPath(t,{parent:!0}),_=c.node,!u||!_)throw new FS.ErrnoError(44);if(u.mount!==_.mount)throw new FS.ErrnoError(75);var d=FS.lookupNode(u,a),f=PATH_FS.relative(e,n);if(f.charAt(0)!==".")throw new FS.ErrnoError(28);if(f=PATH_FS.relative(t,r),f.charAt(0)!==".")throw new FS.ErrnoError(55);var p;try{p=FS.lookupNode(_,l)}catch(h){}if(d!==p){var m=FS.isDir(d.mode),g=FS.mayDelete(u,a,m);if(g)throw new FS.ErrnoError(g);if(g=p?FS.mayDelete(_,l,m):FS.mayCreate(_,l),g)throw new FS.ErrnoError(g);if(!u.node_ops.rename)throw new FS.ErrnoError(63);if(FS.isMountpoint(d)||p&&FS.isMountpoint(p))throw new FS.ErrnoError(10);if(_!==u&&(g=FS.nodePermissions(u,"w"),g))throw new FS.ErrnoError(g);FS.hashRemoveNode(d);try{u.node_ops.rename(d,_,l),d.parent=_}catch(h){throw h}finally{FS.hashAddNode(d)}}},rmdir(e){var t=FS.lookupPath(e,{parent:!0}),r=t.node,n=PATH.basename(e),a=FS.lookupNode(r,n),l=FS.mayDelete(r,n,!0);if(l)throw new FS.ErrnoError(l);if(!r.node_ops.rmdir)throw new FS.ErrnoError(63);if(FS.isMountpoint(a))throw new FS.ErrnoError(10);r.node_ops.rmdir(r,n),FS.destroyNode(a)},readdir(e){var t=FS.lookupPath(e,{follow:!0}),r=t.node;if(!r.node_ops.readdir)throw new FS.ErrnoError(54);return r.node_ops.readdir(r)},unlink(e){var t=FS.lookupPath(e,{parent:!0}),r=t.node;if(!r)throw new FS.ErrnoError(44);var n=PATH.basename(e),a=FS.lookupNode(r,n),l=FS.mayDelete(r,n,!1);if(l)throw new FS.ErrnoError(l);if(!r.node_ops.unlink)throw new FS.ErrnoError(63);if(FS.isMountpoint(a))throw new FS.ErrnoError(10);r.node_ops.unlink(r,n),FS.destroyNode(a)},readlink(e){var t=FS.lookupPath(e),r=t.node;if(!r)throw new FS.ErrnoError(44);if(!r.node_ops.readlink)throw new FS.ErrnoError(28);return PATH_FS.resolve(FS.getPath(r.parent),r.node_ops.readlink(r))},stat(e,t){var r=FS.lookupPath(e,{follow:!t}),n=r.node;if(!n)throw new FS.ErrnoError(44);if(!n.node_ops.getattr)throw new FS.ErrnoError(63);return n.node_ops.getattr(n)},lstat(e){return FS.stat(e,!0)},chmod(e,t,r){var n;if(typeof e=="string"){var a=FS.lookupPath(e,{follow:!r});n=a.node}else n=e;if(!n.node_ops.setattr)throw new FS.ErrnoError(63);n.node_ops.setattr(n,{mode:t&4095|n.mode&-4096,timestamp:Date.now()})},lchmod(e,t){FS.chmod(e,t,!0)},fchmod(e,t){var r=FS.getStreamChecked(e);FS.chmod(r.node,t)},chown(e,t,r,n){var a;if(typeof e=="string"){var l=FS.lookupPath(e,{follow:!n});a=l.node}else a=e;if(!a.node_ops.setattr)throw new FS.ErrnoError(63);a.node_ops.setattr(a,{timestamp:Date.now()})},lchown(e,t,r){FS.chown(e,t,r,!0)},fchown(e,t,r){var n=FS.getStreamChecked(e);FS.chown(n.node,t,r)},truncate(e,t){if(t<0)throw new FS.ErrnoError(28);var r;if(typeof e=="string"){var n=FS.lookupPath(e,{follow:!0});r=n.node}else r=e;if(!r.node_ops.setattr)throw new FS.ErrnoError(63);if(FS.isDir(r.mode))throw new FS.ErrnoError(31);if(!FS.isFile(r.mode))throw new FS.ErrnoError(28);var a=FS.nodePermissions(r,"w");if(a)throw new FS.ErrnoError(a);r.node_ops.setattr(r,{size:t,timestamp:Date.now()})},ftruncate(e,t){var r=FS.getStreamChecked(e);if(!(r.flags&2097155))throw new FS.ErrnoError(28);FS.truncate(r.node,t)},utime(e,t,r){var n=FS.lookupPath(e,{follow:!0}),a=n.node;a.node_ops.setattr(a,{timestamp:Math.max(t,r)})},open(e,t,r){if(e==="")throw new FS.ErrnoError(44);t=typeof t=="string"?FS_modeStringToFlags(t):t,t&64?(r=typeof r>"u"?438:r,r=r&4095|32768):r=0;var n;if(typeof e=="object")n=e;else{e=PATH.normalize(e);try{var a=FS.lookupPath(e,{follow:!(t&131072)});n=a.node}catch(_){}}var l=!1;if(t&64)if(n){if(t&128)throw new FS.ErrnoError(20)}else n=FS.mknod(e,r,0),l=!0;if(!n)throw new FS.ErrnoError(44);if(FS.isChrdev(n.mode)&&(t&=-513),t&65536&&!FS.isDir(n.mode))throw new FS.ErrnoError(54);if(!l){var c=FS.mayOpen(n,t);if(c)throw new FS.ErrnoError(c)}t&512&&!l&&FS.truncate(n,0),t&=-131713;var u=FS.createStream({node:n,path:FS.getPath(n),flags:t,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return u.stream_ops.open&&u.stream_ops.open(u),Module.logReadFiles&&!(t&1)&&(e in FS.readFiles||(FS.readFiles[e]=1)),u},close(e){if(FS.isClosed(e))throw new FS.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(t){throw t}finally{FS.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,t,r){if(FS.isClosed(e))throw new FS.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new FS.ErrnoError(70);if(r!=0&&r!=1&&r!=2)throw new FS.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.ungotten=[],e.position},read(e,t,r,n,a){if(n<0||a<0)throw new FS.ErrnoError(28);if(FS.isClosed(e))throw new FS.ErrnoError(8);if((e.flags&2097155)===1)throw new FS.ErrnoError(8);if(FS.isDir(e.node.mode))throw new FS.ErrnoError(31);if(!e.stream_ops.read)throw new FS.ErrnoError(28);var l=typeof a<"u";if(!l)a=e.position;else if(!e.seekable)throw new FS.ErrnoError(70);var c=e.stream_ops.read(e,t,r,n,a);return l||(e.position+=c),c},write(e,t,r,n,a,l){if(n<0||a<0)throw new FS.ErrnoError(28);if(FS.isClosed(e))throw new FS.ErrnoError(8);if(!(e.flags&2097155))throw new FS.ErrnoError(8);if(FS.isDir(e.node.mode))throw new FS.ErrnoError(31);if(!e.stream_ops.write)throw new FS.ErrnoError(28);e.seekable&&e.flags&1024&&FS.llseek(e,0,2);var c=typeof a<"u";if(!c)a=e.position;else if(!e.seekable)throw new FS.ErrnoError(70);var u=e.stream_ops.write(e,t,r,n,a,l);return c||(e.position+=u),u},allocate(e,t,r){if(FS.isClosed(e))throw new FS.ErrnoError(8);if(t<0||r<=0)throw new FS.ErrnoError(28);if(!(e.flags&2097155))throw new FS.ErrnoError(8);if(!FS.isFile(e.node.mode)&&!FS.isDir(e.node.mode))throw new FS.ErrnoError(43);if(!e.stream_ops.allocate)throw new FS.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap(e,t,r,n,a){if(n&2&&!(a&2)&&(e.flags&2097155)!==2)throw new FS.ErrnoError(2);if((e.flags&2097155)===1)throw new FS.ErrnoError(2);if(!e.stream_ops.mmap)throw new FS.ErrnoError(43);if(!t)throw new FS.ErrnoError(28);return e.stream_ops.mmap(e,t,r,n,a)},msync(e,t,r,n,a){return e.stream_ops.msync?e.stream_ops.msync(e,t,r,n,a):0},ioctl(e,t,r){if(!e.stream_ops.ioctl)throw new FS.ErrnoError(59);return e.stream_ops.ioctl(e,t,r)},readFile(e,t={}){if(t.flags=t.flags||0,t.encoding=t.encoding||"binary",t.encoding!=="utf8"&&t.encoding!=="binary")throw new Error('Invalid encoding type "'.concat(t.encoding,'"'));var r,n=FS.open(e,t.flags),a=FS.stat(e),l=a.size,c=new Uint8Array(l);return FS.read(n,c,0,l,0),t.encoding==="utf8"?r=UTF8ArrayToString(c):t.encoding==="binary"&&(r=c),FS.close(n),r},writeFile(e,t,r={}){r.flags=r.flags||577;var n=FS.open(e,r.flags,r.mode);if(typeof t=="string"){var a=new Uint8Array(lengthBytesUTF8(t)+1),l=stringToUTF8Array(t,a,0,a.length);FS.write(n,a,0,l,void 0,r.canOwn)}else if(ArrayBuffer.isView(t))FS.write(n,t,0,t.byteLength,void 0,r.canOwn);else throw new Error("Unsupported data type");FS.close(n)},cwd:()=>FS.currentPath,chdir(e){var t=FS.lookupPath(e,{follow:!0});if(t.node===null)throw new FS.ErrnoError(44);if(!FS.isDir(t.node.mode))throw new FS.ErrnoError(54);var r=FS.nodePermissions(t.node,"x");if(r)throw new FS.ErrnoError(r);FS.currentPath=t.path},createDefaultDirectories(){FS.mkdir("/tmp"),FS.mkdir("/home"),FS.mkdir("/home/web_user")},createDefaultDevices(){FS.mkdir("/dev"),FS.registerDevice(FS.makedev(1,3),{read:()=>0,write:(n,a,l,c,u)=>c}),FS.mkdev("/dev/null",FS.makedev(1,3)),TTY.register(FS.makedev(5,0),TTY.default_tty_ops),TTY.register(FS.makedev(6,0),TTY.default_tty1_ops),FS.mkdev("/dev/tty",FS.makedev(5,0)),FS.mkdev