UNPKG

wechat-qrcode-ocr-wasm

Version:
1 lines 121 kB
!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var t=r();for(var n in t)("object"==typeof exports?exports:e)[n]=t[n]}}(globalThis,(()=>(()=>{"use strict";var __webpack_modules__={925:(__unused_webpack_module,exports,__webpack_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0}),exports.Module=void 0,exports.fetchRemotePackage=fetchRemotePackage,exports.getModule=getModule,exports.initModule=initModule;var _index=__webpack_require__(643),Module={};function getModule(){return Module}function fetchRemotePackage(packageName,packageSize,callback,errback){if(Module.expectedDataFileDownloads++,"object"!=typeof process||"object"!=typeof process.versions||"string"!=typeof process.versions.node){var xhr=new XMLHttpRequest;xhr.open("GET",packageName,!0),xhr.responseType="arraybuffer",xhr.withCredentials=_index.httpConfig.withCredentials;for(const e in _index.httpConfig.headers)xhr.setRequestHeader(e,_index.httpConfig.headers[e]);xhr.onprogress=function(e){var r=packageName,t=packageSize;if(e.total&&(t=e.total),e.loaded){xhr.addedTotal?Module.dataFileDownloads[r].loaded=e.loaded:(xhr.addedTotal=!0,Module.dataFileDownloads||(Module.dataFileDownloads={}),Module.dataFileDownloads[r]={loaded:e.loaded,total:t});var n=0,o=0,i=0;for(var a in Module.dataFileDownloads){var s=Module.dataFileDownloads[a];n+=s.total,o+=s.loaded,i++}n=Math.ceil(n*Module.expectedDataFileDownloads/i),Module.setStatus&&Module.setStatus({loaded:o,total:n})}else Module.dataFileDownloads||Module.setStatus&&Module.setStatus({loaded:o,total:n})},xhr.onerror=function(e){throw new Error("NetworkError for: "+packageName)},xhr.onload=function(e){if(!(200==xhr.status||304==xhr.status||206==xhr.status||0==xhr.status&&xhr.response))throw new Error(xhr.statusText+" : "+xhr.responseURL);var r=xhr.response;callback(r)},xhr.send(null)}else eval('require("fs").readFile(packageName, function (err, contents) {\n if (err) {\n errback(err);\n } else {\n callback(contents.buffer);\n }\n })')}function initModule(){return Module.expectedDataFileDownloads||(Module.expectedDataFileDownloads=0),Module.ENVIRONMENT_IS_PTHREAD||function(e){"object"==typeof window?window.encodeURIComponent(window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/"):"undefined"==typeof process&&"undefined"!=typeof location&&encodeURIComponent(location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/");var r=_index.source.wechatQRcodeFile,t=_index.source.wechatQRcodeFile;"function"!=typeof Module.locateFilePackage||Module.locateFile||(Module.locateFile=Module.locateFilePackage,err("warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)"));var n=Module.locateFile?Module.locateFile(t,""):t,o=e.remote_package_size,i=null,a=Module.getPreloadedPackage?Module.getPreloadedPackage(n,o):null;function s(){function t(e,r){if(!e)throw r+(new Error).stack}function n(e,r,t){this.start=e,this.end=r,this.audio=t}n.prototype={requests:{},open:function(e,r){this.name=r,this.requests[r]=this,Module.addRunDependency("fp "+this.name)},send:function(){},onload:function(){var e=this.byteArray.subarray(this.start,this.end);this.finish(e)},finish:function(e){Module.FS_createDataFile(this.name,null,e,!0,!0,!0),Module.removeRunDependency("fp "+this.name),this.requests[this.name]=null}};for(var o=e.files,s=0;s<o.length;++s)new n(o[s].start,o[s].end,o[s].audio||0).open("GET",o[s].filename);function u(r){t(r,"Loading data file failed."),t(r.constructor.name===ArrayBuffer.name,"bad input to processPackageData");var o=new Uint8Array(r);n.prototype.byteArray=o;for(var i=e.files,a=0;a<i.length;++a)n.prototype.requests[i[a].filename].onload()}Module.preloadResults||(Module.preloadResults={}),Module.preloadResults[r]={fromCache:!1},a?(u(a),a=null):i=u}a||fetchRemotePackage(n,o,(function(e){i?(i(e),i=null):a=e}),(function(e){console.error("package error:",e)})),Module.calledRun?s():(Module.preRun||(Module.preRun=[]),Module.preRun.push(s))}({files:[{filename:"detect.caffemodel",start:338,end:965768},{filename:"detect.prototxt",start:965768,end:1008424},{filename:"sr.caffemodel",start:1008424,end:1032353},{filename:"sr.prototxt",start:1032353,end:1038337}],remote_package_size:1038337}),Module}exports.Module=Module},436:(__unused_webpack_module,exports,__webpack_require__)=>{var __filename="/index.js",__dirname="/";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _index=__webpack_require__(643),_loadingWeChatQRcodeModel=__webpack_require__(925),cv=async(Module={})=>{var _scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0;_scriptDir=_scriptDir||__filename;var wasmBinaryFile=await new Promise(((e,r)=>{(0,_loadingWeChatQRcodeModel.fetchRemotePackage)(_index.source.wasmBinaryFile,3664551,(r=>{e(new Uint8Array(r))}),r)}));return function(cv){var readyPromiseResolve,readyPromiseReject;cv=Module||{},Module.ready=new Promise((function(e,r){readyPromiseResolve=e,readyPromiseReject=r}));var moduleOverrides=Object.assign({},Module),arguments_=[],thisProgram="./this.program",quit_=(e,r)=>{throw r},ENVIRONMENT_IS_WEB="object"==typeof window,ENVIRONMENT_IS_WORKER="function"==typeof importScripts,ENVIRONMENT_IS_NODE="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,scriptDirectory="",read_,readAsync,readBinary,setWindowTitle,fs,nodePath;function locateFile(e){return Module.locateFile?Module.locateFile(e,scriptDirectory):scriptDirectory+e}function logExceptionOnExit(e){e instanceof ExitStatus||err("exiting due to exception: "+e)}ENVIRONMENT_IS_NODE?(ENVIRONMENT_IS_WORKER?eval('scriptDirectory = require("path").dirname(scriptDirectory) + "/";'):scriptDirectory=__dirname+"/",eval('fs = require("fs");'),eval('nodePath = require("path");'),read_=(e,r)=>{var t=tryParseAsDataURI(e);return t?r?t:t.toString():(e=nodePath.normalize(e),fs.readFileSync(e,r?void 0:"utf8"))},readBinary=e=>{var r=read_(e,!0);return r.buffer||(r=new Uint8Array(r)),r},readAsync=(e,r,t)=>{var n=tryParseAsDataURI(e);n&&r(n),e=nodePath.normalize(e),fs.readFile(e,(function(e,n){e?t(e):r(n.buffer)}))},process.argv.length>1&&(thisProgram=process.argv[1].replace(/\\/g,"/")),arguments_=process.argv.slice(2),process.on("uncaughtException",(function(e){if(!(e instanceof ExitStatus))throw e})),process.on("unhandledRejection",(function(e){throw e})),quit_=(e,r)=>{if(keepRuntimeAlive())throw process.exitCode=e,r;logExceptionOnExit(r),process.exit(e)},Module.inspect=function(){return"[Emscripten Module object]"}):(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&(ENVIRONMENT_IS_WORKER?scriptDirectory=self.location.href:"undefined"!=typeof document&&document.currentScript&&(scriptDirectory=document.currentScript.src),_scriptDir&&(scriptDirectory=_scriptDir),scriptDirectory=0!==scriptDirectory.indexOf("blob:")?scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1):"",read_=e=>{try{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText}catch(r){var t=tryParseAsDataURI(e);if(t)return intArrayToString(t);throw r}},ENVIRONMENT_IS_WORKER&&(readBinary=e=>{try{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}catch(r){var t=tryParseAsDataURI(e);if(t)return t;throw r}}),readAsync=(e,r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{if(200==n.status||0==n.status&&n.response)r(n.response);else{var o=tryParseAsDataURI(e);o?r(o.buffer):t()}},n.onerror=t,n.send(null)},setWindowTitle=e=>document.title=e);var out=Module.print||console.log.bind(console),err=Module.printErr||console.warn.bind(console);Object.assign(Module,moduleOverrides),moduleOverrides=null,Module.arguments&&(arguments_=Module.arguments),Module.thisProgram&&(thisProgram=Module.thisProgram),Module.quit&&(quit_=Module.quit);var POINTER_SIZE=4,wasmBinary;Module.wasmBinary&&(wasmBinary=Module.wasmBinary);var noExitRuntime=Module.noExitRuntime||!0,wasmMemory;"object"!=typeof WebAssembly&&abort("no native wasm support detected");var ABORT=!1,EXITSTATUS;function assert(e,r){e||abort(r)}var UTF8Decoder="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function UTF8ArrayToString(e,r,t){for(var n=r+t,o=r;e[o]&&!(o>=n);)++o;if(o-r>16&&e.buffer&&UTF8Decoder)return UTF8Decoder.decode(e.subarray(r,o));for(var i="";r<o;){var a=e[r++];if(128&a){var s=63&e[r++];if(192!=(224&a)){var u=63&e[r++];if((a=224==(240&a)?(15&a)<<12|s<<6|u:(7&a)<<18|s<<12|u<<6|63&e[r++])<65536)i+=String.fromCharCode(a);else{var l=a-65536;i+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else i+=String.fromCharCode((31&a)<<6|s)}else i+=String.fromCharCode(a)}return i}function UTF8ToString(e,r){return e?UTF8ArrayToString(HEAPU8,e,r):""}function stringToUTF8Array(e,r,t,n){if(!(n>0))return 0;for(var o=t,i=t+n-1,a=0;a<e.length;++a){var s=e.charCodeAt(a);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++a)),s<=127){if(t>=i)break;r[t++]=s}else if(s<=2047){if(t+1>=i)break;r[t++]=192|s>>6,r[t++]=128|63&s}else if(s<=65535){if(t+2>=i)break;r[t++]=224|s>>12,r[t++]=128|s>>6&63,r[t++]=128|63&s}else{if(t+3>=i)break;r[t++]=240|s>>18,r[t++]=128|s>>12&63,r[t++]=128|s>>6&63,r[t++]=128|63&s}}return r[t]=0,t-o}function stringToUTF8(e,r,t){return stringToUTF8Array(e,HEAPU8,r,t)}function lengthBytesUTF8(e){for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r}function updateGlobalBufferAndViews(e){buffer=e,Module.HEAP8=HEAP8=new Int8Array(e),Module.HEAP16=HEAP16=new Int16Array(e),Module.HEAP32=HEAP32=new Int32Array(e),Module.HEAPU8=HEAPU8=new Uint8Array(e),Module.HEAPU16=HEAPU16=new Uint16Array(e),Module.HEAPU32=HEAPU32=new Uint32Array(e),Module.HEAPF32=HEAPF32=new Float32Array(e),Module.HEAPF64=HEAPF64=new Float64Array(e)}var INITIAL_MEMORY=Module.INITIAL_MEMORY||134217728,wasmTable,__ATPRERUN__=[],__ATINIT__=[],__ATPOSTRUN__=[],runtimeInitialized=!1;function keepRuntimeAlive(){return noExitRuntime}function preRun(){if(Module.preRun)for("function"==typeof Module.preRun&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=!0,Module.noFSInit||FS.init.initialized||FS.init(),FS.ignorePermissions=!1,TTY.init(),callRuntimeCallbacks(__ATINIT__)}function postRun(){if(Module.postRun)for("function"==typeof Module.postRun&&(Module.postRun=[Module.postRun]);Module.postRun.length;)addOnPostRun(Module.postRun.shift());callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(e){__ATPRERUN__.unshift(e)}function addOnInit(e){__ATINIT__.unshift(e)}function addOnPostRun(e){__ATPOSTRUN__.unshift(e)}var runDependencies=0,runDependencyWatcher=null,dependenciesFulfilled=null;function getUniqueRunDependency(e){return e}function addRunDependency(e){runDependencies++,Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies)}function removeRunDependency(e){if(runDependencies--,Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies),0==runDependencies&&(null!==runDependencyWatcher&&(clearInterval(runDependencyWatcher),runDependencyWatcher=null),dependenciesFulfilled)){var r=dependenciesFulfilled;dependenciesFulfilled=null,r()}}function abort(e){Module.onAbort&&Module.onAbort(e),err(e="Aborted("+e+")"),ABORT=!0,EXITSTATUS=1,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw readyPromiseReject(r),r}var dataURIPrefix="data:application/octet-stream;base64,",tempDouble,tempI64,_emscripten_get_now;function isDataURI(e){return!0}function isFileURI(e){return!1}function getBinary(e){try{if(e==wasmBinaryFile&&wasmBinary)return new Uint8Array(wasmBinary);var r=tryParseAsDataURI(e);if(r)return r;if(readBinary)return readBinary(e);throw"both async and sync fetching of the wasm failed"}catch(e){abort(e)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if("function"==typeof fetch&&!isFileURI(wasmBinaryFile))return fetch(wasmBinaryFile,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+wasmBinaryFile+"'";return e.arrayBuffer()})).catch((function(){return getBinary(wasmBinaryFile)}));if(readAsync)return new Promise((function(e,r){readAsync(wasmBinaryFile,(function(r){e(new Uint8Array(r))}),r)}))}return Promise.resolve().then((function(){return getBinary(wasmBinaryFile)}))}function createWasm(){var e={a:asmLibraryArg};function r(e,r){var t=e.exports;Module.asm=t,updateGlobalBufferAndViews((wasmMemory=Module.asm.X).buffer),wasmTable=Module.asm._,addOnInit(Module.asm.Y),removeRunDependency("wasm-instantiate")}function t(e){r(e.instance)}function n(r){return Promise.resolve().then((function(){return WebAssembly.instantiate(wasmBinaryFile,e)})).then(r)}if(addRunDependency("wasm-instantiate"),Module.instantiateWasm)try{return Module.instantiateWasm(e,r)}catch(e){err("Module.instantiateWasm callback failed with error: "+e),readyPromiseReject(e)}return(wasmBinary||"function"!=typeof WebAssembly.instantiateStreaming||isDataURI(wasmBinaryFile)||isFileURI(wasmBinaryFile)||ENVIRONMENT_IS_NODE||"function"!=typeof fetch?n(t):fetch(wasmBinaryFile,{credentials:"same-origin"}).then((function(r){return WebAssembly.instantiateStreaming(r,e).then(t,(function(e){return err("wasm streaming compile failed: "+e),err("falling back to ArrayBuffer instantiation"),n(t)}))}))).catch(readyPromiseReject),{}}function _emscripten_set_main_loop_timing(e,r){if(Browser.mainLoop.timingMode=e,Browser.mainLoop.timingValue=r,!Browser.mainLoop.func)return 1;if(Browser.mainLoop.running||(Browser.mainLoop.running=!0),0==e)Browser.mainLoop.scheduler=function(){var e=0|Math.max(0,Browser.mainLoop.tickStartTime+r-_emscripten_get_now());setTimeout(Browser.mainLoop.runner,e)},Browser.mainLoop.method="timeout";else if(1==e)Browser.mainLoop.scheduler=function(){Browser.requestAnimationFrame(Browser.mainLoop.runner)},Browser.mainLoop.method="rAF";else if(2==e){if("undefined"==typeof setImmediate){var t=[],n="setimmediate";addEventListener("message",(e=>{e.data!==n&&e.data.target!==n||(e.stopPropagation(),t.shift()())}),!0),setImmediate=function(e){t.push(e),ENVIRONMENT_IS_WORKER?(void 0===Module.setImmediates&&(Module.setImmediates=[]),Module.setImmediates.push(e),postMessage({target:n})):postMessage(n,"*")}}Browser.mainLoop.scheduler=function(){setImmediate(Browser.mainLoop.runner)},Browser.mainLoop.method="immediate"}return 0}function ExitStatus(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}isDataURI(wasmBinaryFile)||(wasmBinaryFile=locateFile(wasmBinaryFile)),_emscripten_get_now=ENVIRONMENT_IS_NODE?()=>{var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:()=>performance.now();var PATH={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var o=e[n];"."===o?e.splice(n,1):".."===o?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=PATH.isAbs(e),t="/"===e.substr(-1);return(e=PATH.normalizeArray(e.split("/").filter((e=>!!e)),!r).join("/"))||r||(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=PATH.splitPath(e),t=r[0],n=r[1];return t||n?(n&&(n=n.substr(0,n.length-1)),t+n):"."},basename:e=>{if("/"===e)return"/";var r=(e=(e=PATH.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===r?e:e.substr(r+1)},join:function(){var e=Array.prototype.slice.call(arguments);return PATH.normalize(e.join("/"))},join2:(e,r)=>PATH.normalize(e+"/"+r)};function getRandomDevice(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var randomBuffer=new Uint8Array(1);return()=>(crypto.getRandomValues(randomBuffer),randomBuffer[0])}if(ENVIRONMENT_IS_NODE)try{return eval('var crypto_module = require("crypto");'),()=>crypto_module.randomBytes(1)[0]}catch(e){}return()=>abort("randomDevice")}var PATH_FS={resolve:function(){for(var e="",r=!1,t=arguments.length-1;t>=-1&&!r;t--){var n=t>=0?arguments[t]:FS.cwd();if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,r=PATH.isAbs(n)}return(r?"/":"")+(e=PATH.normalizeArray(e.split("/").filter((e=>!!e)),!r).join("/"))||"."},relative:(e,r)=>{function t(e){for(var r=0;r<e.length&&""===e[r];r++);for(var t=e.length-1;t>=0&&""===e[t];t--);return r>t?[]:e.slice(r,t-r+1)}e=PATH_FS.resolve(e).substr(1),r=PATH_FS.resolve(r).substr(1);for(var n=t(e.split("/")),o=t(r.split("/")),i=Math.min(n.length,o.length),a=i,s=0;s<i;s++)if(n[s]!==o[s]){a=s;break}var u=[];for(s=a;s<n.length;s++)u.push("..");return(u=u.concat(o.slice(a))).join("/")}};function intArrayFromString(e,r,t){var n=t>0?t:lengthBytesUTF8(e)+1,o=new Array(n),i=stringToUTF8Array(e,o,0,o.length);return r&&(o.length=i),o}var TTY={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){TTY.ttys[e]={input:[],output:[],ops:r},FS.registerDevice(e,TTY.stream_ops)},stream_ops:{open:function(e){var r=TTY.ttys[e.node.rdev];if(!r)throw new FS.ErrnoError(43);e.tty=r,e.seekable=!1},close:function(e){e.tty.ops.fsync(e.tty)},fsync:function(e){e.tty.ops.fsync(e.tty)},read:function(e,r,t,n,o){if(!e.tty||!e.tty.ops.get_char)throw new FS.ErrnoError(60);for(var i=0,a=0;a<n;a++){var s;try{s=e.tty.ops.get_char(e.tty)}catch(e){throw new FS.ErrnoError(29)}if(void 0===s&&0===i)throw new FS.ErrnoError(6);if(null==s)break;i++,r[t+a]=s}return i&&(e.node.timestamp=Date.now()),i},write:function(e,r,t,n,o){if(!e.tty||!e.tty.ops.put_char)throw new FS.ErrnoError(60);try{for(var i=0;i<n;i++)e.tty.ops.put_char(e.tty,r[t+i])}catch(e){throw new FS.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}},default_tty_ops:{get_char:function(e){if(!e.input.length){var r=null;if(ENVIRONMENT_IS_NODE){var t=Buffer.alloc(256),n=0;try{n=fs.readSync(process.stdin.fd,t,0,256,-1)}catch(e){if(!e.toString().includes("EOF"))throw e;n=0}r=n>0?t.slice(0,n).toString("utf-8"):null}else"undefined"!=typeof window&&"function"==typeof window.prompt?null!==(r=window.prompt("Input: "))&&(r+="\n"):"function"==typeof readline&&null!==(r=readline())&&(r+="\n");if(!r)return null;e.input=intArrayFromString(r,!0)}return e.input.shift()},put_char:function(e,r){null===r||10===r?(out(UTF8ArrayToString(e.output,0)),e.output=[]):0!=r&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(out(UTF8ArrayToString(e.output,0)),e.output=[])}},default_tty1_ops:{put_char:function(e,r){null===r||10===r?(err(UTF8ArrayToString(e.output,0)),e.output=[]):0!=r&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(err(UTF8ArrayToString(e.output,0)),e.output=[])}}};function mmapAlloc(e){abort()}var MEMFS={ops_table:null,mount:function(e){return MEMFS.createNode(null,"/",16895,0)},createNode:function(e,r,t,n){if(FS.isBlkdev(t)||FS.isFIFO(t))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 o=FS.createNode(e,r,t,n);return FS.isDir(o.mode)?(o.node_ops=MEMFS.ops_table.dir.node,o.stream_ops=MEMFS.ops_table.dir.stream,o.contents={}):FS.isFile(o.mode)?(o.node_ops=MEMFS.ops_table.file.node,o.stream_ops=MEMFS.ops_table.file.stream,o.usedBytes=0,o.contents=null):FS.isLink(o.mode)?(o.node_ops=MEMFS.ops_table.link.node,o.stream_ops=MEMFS.ops_table.link.stream):FS.isChrdev(o.mode)&&(o.node_ops=MEMFS.ops_table.chrdev.node,o.stream_ops=MEMFS.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[r]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray:function(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage:function(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){r=Math.max(r,t*(t<1048576?2:1.125)>>>0),0!=t&&(r=Math.max(r,256));var n=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(n.subarray(0,e.usedBytes),0)}},resizeFileStorage:function(e,r){if(e.usedBytes!=r)if(0==r)e.contents=null,e.usedBytes=0;else{var t=e.contents;e.contents=new Uint8Array(r),t&&e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r}},node_ops:{getattr:function(e){var r={};return r.dev=FS.isChrdev(e.mode)?e.id:1,r.ino=e.id,r.mode=e.mode,r.nlink=1,r.uid=0,r.gid=0,r.rdev=e.rdev,FS.isDir(e.mode)?r.size=4096:FS.isFile(e.mode)?r.size=e.usedBytes:FS.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr:function(e,r){void 0!==r.mode&&(e.mode=r.mode),void 0!==r.timestamp&&(e.timestamp=r.timestamp),void 0!==r.size&&MEMFS.resizeFileStorage(e,r.size)},lookup:function(e,r){throw FS.genericErrors[44]},mknod:function(e,r,t,n){return MEMFS.createNode(e,r,t,n)},rename:function(e,r,t){if(FS.isDir(e.mode)){var n;try{n=FS.lookupNode(r,t)}catch(e){}if(n)for(var o in n.contents)throw new FS.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp,e.parent=r},unlink:function(e,r){delete e.contents[r],e.timestamp=Date.now()},rmdir:function(e,r){var t=FS.lookupNode(e,r);for(var n in t.contents)throw new FS.ErrnoError(55);delete e.contents[r],e.timestamp=Date.now()},readdir:function(e){var r=[".",".."];for(var t in e.contents)e.contents.hasOwnProperty(t)&&r.push(t);return r},symlink:function(e,r,t){var n=MEMFS.createNode(e,r,41471,0);return n.link=t,n},readlink:function(e){if(!FS.isLink(e.mode))throw new FS.ErrnoError(28);return e.link}},stream_ops:{read:function(e,r,t,n,o){var i=e.node.contents;if(o>=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-o,n);if(a>8&&i.subarray)r.set(i.subarray(o,o+a),t);else for(var s=0;s<a;s++)r[t+s]=i[o+s];return a},write:function(e,r,t,n,o,i){if(r.buffer===HEAP8.buffer&&(i=!1),!n)return 0;var a=e.node;if(a.timestamp=Date.now(),r.subarray&&(!a.contents||a.contents.subarray)){if(i)return a.contents=r.subarray(t,t+n),a.usedBytes=n,n;if(0===a.usedBytes&&0===o)return a.contents=r.slice(t,t+n),a.usedBytes=n,n;if(o+n<=a.usedBytes)return a.contents.set(r.subarray(t,t+n),o),n}if(MEMFS.expandFileStorage(a,o+n),a.contents.subarray&&r.subarray)a.contents.set(r.subarray(t,t+n),o);else for(var s=0;s<n;s++)a.contents[o+s]=r[t+s];return a.usedBytes=Math.max(a.usedBytes,o+n),n},llseek:function(e,r,t){var n=r;if(1===t?n+=e.position:2===t&&FS.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new FS.ErrnoError(28);return n},allocate:function(e,r,t){MEMFS.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t)},mmap:function(e,r,t,n,o){if(!FS.isFile(e.node.mode))throw new FS.ErrnoError(43);var i,a,s=e.node.contents;if(2&o||s.buffer!==buffer){if((t>0||t+r<s.length)&&(s=s.subarray?s.subarray(t,t+r):Array.prototype.slice.call(s,t,t+r)),a=!0,!(i=mmapAlloc(r)))throw new FS.ErrnoError(48);HEAP8.set(s,i)}else a=!1,i=s.byteOffset;return{ptr:i,allocated:a}},msync:function(e,r,t,n,o){return MEMFS.stream_ops.write(e,r,0,n,t,!1),0}}};function asyncLoad(e,r,t,n){var o=n?"":getUniqueRunDependency("al "+e);readAsync(e,(t=>{assert(t,'Loading data file "'+e+'" failed (no arrayBuffer).'),r(new Uint8Array(t)),o&&removeRunDependency(o)}),(r=>{if(!t)throw'Loading data file "'+e+'" failed.';t()})),o&&addRunDependency(o)}var FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(e,r={})=>{if(!(e=PATH_FS.resolve(FS.cwd(),e)))return{path:"",node:null};if((r=Object.assign({follow_mount:!0,recurse_count:0},r)).recurse_count>8)throw new FS.ErrnoError(32);for(var t=PATH.normalizeArray(e.split("/").filter((e=>!!e)),!1),n=FS.root,o="/",i=0;i<t.length;i++){var a=i===t.length-1;if(a&&r.parent)break;if(n=FS.lookupNode(n,t[i]),o=PATH.join2(o,t[i]),FS.isMountpoint(n)&&(!a||a&&r.follow_mount)&&(n=n.mounted.root),!a||r.follow)for(var s=0;FS.isLink(n.mode);){var u=FS.readlink(o);if(o=PATH_FS.resolve(PATH.dirname(o),u),n=FS.lookupPath(o,{recurse_count:r.recurse_count+1}).node,s++>40)throw new FS.ErrnoError(32)}}return{path:o,node:n}},getPath:e=>{for(var r;;){if(FS.isRoot(e)){var t=e.mount.mountpoint;return r?"/"!==t[t.length-1]?t+"/"+r:t+r:t}r=r?e.name+"/"+r:e.name,e=e.parent}},hashName:(e,r)=>{for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return(e+t>>>0)%FS.nameTable.length},hashAddNode:e=>{var r=FS.hashName(e.parent.id,e.name);e.name_next=FS.nameTable[r],FS.nameTable[r]=e},hashRemoveNode:e=>{var r=FS.hashName(e.parent.id,e.name);if(FS.nameTable[r]===e)FS.nameTable[r]=e.name_next;else for(var t=FS.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode:(e,r)=>{var t=FS.mayLookup(e);if(t)throw new FS.ErrnoError(t,e);for(var n=FS.hashName(e.id,r),o=FS.nameTable[n];o;o=o.name_next){var i=o.name;if(o.parent.id===e.id&&i===r)return o}return FS.lookup(e,r)},createNode:(e,r,t,n)=>{var o=new FS.FSNode(e,r,t,n);return FS.hashAddNode(o),o},destroyNode:e=>{FS.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),isFIFO:e=>4096==(61440&e),isSocket:e=>49152==(49152&e),flagModes:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},modeStringToFlags:e=>{var r=FS.flagModes[e];if(void 0===r)throw new Error("Unknown file open mode: "+e);return r},flagsToPermissionString:e=>{var r=["r","w","rw"][3&e];return 512&e&&(r+="w"),r},nodePermissions:(e,r)=>FS.ignorePermissions||(!r.includes("r")||292&e.mode)&&(!r.includes("w")||146&e.mode)&&(!r.includes("x")||73&e.mode)?0:2,mayLookup:e=>FS.nodePermissions(e,"x")||(e.node_ops.lookup?0:2),mayCreate:(e,r)=>{try{return FS.lookupNode(e,r),20}catch(e){}return FS.nodePermissions(e,"wx")},mayDelete:(e,r,t)=>{var n;try{n=FS.lookupNode(e,r)}catch(e){return e.errno}var o=FS.nodePermissions(e,"wx");if(o)return o;if(t){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,r)=>e?FS.isLink(e.mode)?32:FS.isDir(e.mode)&&("r"!==FS.flagsToPermissionString(r)||512&r)?31:FS.nodePermissions(e,FS.flagsToPermissionString(r)):44,MAX_OPEN_FDS:4096,nextfd:(e=0,r=FS.MAX_OPEN_FDS)=>{for(var t=e;t<=r;t++)if(!FS.streams[t])return t;throw new FS.ErrnoError(33)},getStream:e=>FS.streams[e],createStream:(e,r,t)=>{FS.FSStream||(FS.FSStream=function(){this.shared={}},FS.FSStream.prototype={},Object.defineProperties(FS.FSStream.prototype,{object:{get:function(){return this.node},set:function(e){this.node=e}},isRead:{get:function(){return 1!=(2097155&this.flags)}},isWrite:{get:function(){return 0!=(2097155&this.flags)}},isAppend:{get:function(){return 1024&this.flags}},flags:{get:function(){return this.shared.flags},set:function(e){this.shared.flags=e}},position:{get:function(){return this.shared.position},set:function(e){this.shared.position=e}}})),e=Object.assign(new FS.FSStream,e);var n=FS.nextfd(r,t);return e.fd=n,FS.streams[n]=e,e},closeStream:e=>{FS.streams[e]=null},chrdev_stream_ops:{open:e=>{var r=FS.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new FS.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,r)=>e<<8|r,registerDevice:(e,r)=>{FS.devices[e]={stream_ops:r}},getDevice:e=>FS.devices[e],getMounts:e=>{for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push.apply(t,n.mounts)}return r},syncfs:(e,r)=>{"function"==typeof e&&(r=e,e=!1),FS.syncFSRequests++,FS.syncFSRequests>1&&err("warning: "+FS.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work");var t=FS.getMounts(FS.root.mount),n=0;function o(e){return FS.syncFSRequests--,r(e)}function i(e){if(e)return i.errored?void 0:(i.errored=!0,o(e));++n>=t.length&&o(null)}t.forEach((r=>{if(!r.type.syncfs)return i(null);r.type.syncfs(r,e,i)}))},mount:(e,r,t)=>{var n,o="/"===t,i=!t;if(o&&FS.root)throw new FS.ErrnoError(10);if(!o&&!i){var a=FS.lookupPath(t,{follow_mount:!1});if(t=a.path,n=a.node,FS.isMountpoint(n))throw new FS.ErrnoError(10);if(!FS.isDir(n.mode))throw new FS.ErrnoError(54)}var s={type:e,opts:r,mountpoint:t,mounts:[]},u=e.mount(s);return u.mount=s,s.root=u,o?FS.root=u:n&&(n.mounted=s,n.mount&&n.mount.mounts.push(s)),u},unmount:e=>{var r=FS.lookupPath(e,{follow_mount:!1});if(!FS.isMountpoint(r.node))throw new FS.ErrnoError(28);var t=r.node,n=t.mounted,o=FS.getMounts(n);Object.keys(FS.nameTable).forEach((e=>{for(var r=FS.nameTable[e];r;){var t=r.name_next;o.includes(r.mount)&&FS.destroyNode(r),r=t}})),t.mounted=null;var i=t.mount.mounts.indexOf(n);t.mount.mounts.splice(i,1)},lookup:(e,r)=>e.node_ops.lookup(e,r),mknod:(e,r,t)=>{var n=FS.lookupPath(e,{parent:!0}).node,o=PATH.basename(e);if(!o||"."===o||".."===o)throw new FS.ErrnoError(28);var i=FS.mayCreate(n,o);if(i)throw new FS.ErrnoError(i);if(!n.node_ops.mknod)throw new FS.ErrnoError(63);return n.node_ops.mknod(n,o,r,t)},create:(e,r)=>(r=void 0!==r?r:438,r&=4095,r|=32768,FS.mknod(e,r,0)),mkdir:(e,r)=>(r=void 0!==r?r:511,r&=1023,r|=16384,FS.mknod(e,r,0)),mkdirTree:(e,r)=>{for(var t=e.split("/"),n="",o=0;o<t.length;++o)if(t[o]){n+="/"+t[o];try{FS.mkdir(n,r)}catch(e){if(20!=e.errno)throw e}}},mkdev:(e,r,t)=>(void 0===t&&(t=r,r=438),r|=8192,FS.mknod(e,r,t)),symlink:(e,r)=>{if(!PATH_FS.resolve(e))throw new FS.ErrnoError(44);var t=FS.lookupPath(r,{parent:!0}).node;if(!t)throw new FS.ErrnoError(44);var n=PATH.basename(r),o=FS.mayCreate(t,n);if(o)throw new FS.ErrnoError(o);if(!t.node_ops.symlink)throw new FS.ErrnoError(63);return t.node_ops.symlink(t,n,e)},rename:(e,r)=>{var t,n,o=PATH.dirname(e),i=PATH.dirname(r),a=PATH.basename(e),s=PATH.basename(r);if(t=FS.lookupPath(e,{parent:!0}).node,n=FS.lookupPath(r,{parent:!0}).node,!t||!n)throw new FS.ErrnoError(44);if(t.mount!==n.mount)throw new FS.ErrnoError(75);var u,l=FS.lookupNode(t,a),d=PATH_FS.relative(e,i);if("."!==d.charAt(0))throw new FS.ErrnoError(28);if("."!==(d=PATH_FS.relative(r,o)).charAt(0))throw new FS.ErrnoError(55);try{u=FS.lookupNode(n,s)}catch(e){}if(l!==u){var c=FS.isDir(l.mode),m=FS.mayDelete(t,a,c);if(m)throw new FS.ErrnoError(m);if(m=u?FS.mayDelete(n,s,c):FS.mayCreate(n,s))throw new FS.ErrnoError(m);if(!t.node_ops.rename)throw new FS.ErrnoError(63);if(FS.isMountpoint(l)||u&&FS.isMountpoint(u))throw new FS.ErrnoError(10);if(n!==t&&(m=FS.nodePermissions(t,"w")))throw new FS.ErrnoError(m);FS.hashRemoveNode(l);try{t.node_ops.rename(l,n,s)}catch(e){throw e}finally{FS.hashAddNode(l)}}},rmdir:e=>{var r=FS.lookupPath(e,{parent:!0}).node,t=PATH.basename(e),n=FS.lookupNode(r,t),o=FS.mayDelete(r,t,!0);if(o)throw new FS.ErrnoError(o);if(!r.node_ops.rmdir)throw new FS.ErrnoError(63);if(FS.isMountpoint(n))throw new FS.ErrnoError(10);r.node_ops.rmdir(r,t),FS.destroyNode(n)},readdir:e=>{var r=FS.lookupPath(e,{follow:!0}).node;if(!r.node_ops.readdir)throw new FS.ErrnoError(54);return r.node_ops.readdir(r)},unlink:e=>{var r=FS.lookupPath(e,{parent:!0}).node;if(!r)throw new FS.ErrnoError(44);var t=PATH.basename(e),n=FS.lookupNode(r,t),o=FS.mayDelete(r,t,!1);if(o)throw new FS.ErrnoError(o);if(!r.node_ops.unlink)throw new FS.ErrnoError(63);if(FS.isMountpoint(n))throw new FS.ErrnoError(10);r.node_ops.unlink(r,t),FS.destroyNode(n)},readlink:e=>{var r=FS.lookupPath(e).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,r)=>{var t=FS.lookupPath(e,{follow:!r}).node;if(!t)throw new FS.ErrnoError(44);if(!t.node_ops.getattr)throw new FS.ErrnoError(63);return t.node_ops.getattr(t)},lstat:e=>FS.stat(e,!0),chmod:(e,r,t)=>{var n;if(!(n="string"==typeof e?FS.lookupPath(e,{follow:!t}).node:e).node_ops.setattr)throw new FS.ErrnoError(63);n.node_ops.setattr(n,{mode:4095&r|-4096&n.mode,timestamp:Date.now()})},lchmod:(e,r)=>{FS.chmod(e,r,!0)},fchmod:(e,r)=>{var t=FS.getStream(e);if(!t)throw new FS.ErrnoError(8);FS.chmod(t.node,r)},chown:(e,r,t,n)=>{var o;if(!(o="string"==typeof e?FS.lookupPath(e,{follow:!n}).node:e).node_ops.setattr)throw new FS.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown:(e,r,t)=>{FS.chown(e,r,t,!0)},fchown:(e,r,t)=>{var n=FS.getStream(e);if(!n)throw new FS.ErrnoError(8);FS.chown(n.node,r,t)},truncate:(e,r)=>{if(r<0)throw new FS.ErrnoError(28);var t;if(!(t="string"==typeof e?FS.lookupPath(e,{follow:!0}).node:e).node_ops.setattr)throw new FS.ErrnoError(63);if(FS.isDir(t.mode))throw new FS.ErrnoError(31);if(!FS.isFile(t.mode))throw new FS.ErrnoError(28);var n=FS.nodePermissions(t,"w");if(n)throw new FS.ErrnoError(n);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate:(e,r)=>{var t=FS.getStream(e);if(!t)throw new FS.ErrnoError(8);if(0==(2097155&t.flags))throw new FS.ErrnoError(28);FS.truncate(t.node,r)},utime:(e,r,t)=>{var n=FS.lookupPath(e,{follow:!0}).node;n.node_ops.setattr(n,{timestamp:Math.max(r,t)})},open:(e,r,t)=>{if(""===e)throw new FS.ErrnoError(44);var n;if(t=void 0===t?438:t,t=64&(r="string"==typeof r?FS.modeStringToFlags(r):r)?4095&t|32768:0,"object"==typeof e)n=e;else{e=PATH.normalize(e);try{n=FS.lookupPath(e,{follow:!(131072&r)}).node}catch(e){}}var o=!1;if(64&r)if(n){if(128&r)throw new FS.ErrnoError(20)}else n=FS.mknod(e,t,0),o=!0;if(!n)throw new FS.ErrnoError(44);if(FS.isChrdev(n.mode)&&(r&=-513),65536&r&&!FS.isDir(n.mode))throw new FS.ErrnoError(54);if(!o){var i=FS.mayOpen(n,r);if(i)throw new FS.ErrnoError(i)}512&r&&!o&&FS.truncate(n,0),r&=-131713;var a=FS.createStream({node:n,path:FS.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return a.stream_ops.open&&a.stream_ops.open(a),!Module.logReadFiles||1&r||(FS.readFiles||(FS.readFiles={}),e in FS.readFiles||(FS.readFiles[e]=1)),a},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(e){throw e}finally{FS.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek:(e,r,t)=>{if(FS.isClosed(e))throw new FS.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new FS.ErrnoError(70);if(0!=t&&1!=t&&2!=t)throw new FS.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read:(e,r,t,n,o)=>{if(n<0||o<0)throw new FS.ErrnoError(28);if(FS.isClosed(e))throw new FS.ErrnoError(8);if(1==(2097155&e.flags))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 i=void 0!==o;if(i){if(!e.seekable)throw new FS.ErrnoError(70)}else o=e.position;var a=e.stream_ops.read(e,r,t,n,o);return i||(e.position+=a),a},write:(e,r,t,n,o,i)=>{if(n<0||o<0)throw new FS.ErrnoError(28);if(FS.isClosed(e))throw new FS.ErrnoError(8);if(0==(2097155&e.flags))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&&1024&e.flags&&FS.llseek(e,0,2);var a=void 0!==o;if(a){if(!e.seekable)throw new FS.ErrnoError(70)}else o=e.position;var s=e.stream_ops.write(e,r,t,n,o,i);return a||(e.position+=s),s},allocate:(e,r,t)=>{if(FS.isClosed(e))throw new FS.ErrnoError(8);if(r<0||t<=0)throw new FS.ErrnoError(28);if(0==(2097155&e.flags))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,r,t)},mmap:(e,r,t,n,o)=>{if(0!=(2&n)&&0==(2&o)&&2!=(2097155&e.flags))throw new FS.ErrnoError(2);if(1==(2097155&e.flags))throw new FS.ErrnoError(2);if(!e.stream_ops.mmap)throw new FS.ErrnoError(43);return e.stream_ops.mmap(e,r,t,n,o)},msync:(e,r,t,n,o)=>e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,o):0,munmap:e=>0,ioctl:(e,r,t)=>{if(!e.stream_ops.ioctl)throw new FS.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile:(e,r={})=>{if(r.flags=r.flags||0,r.encoding=r.encoding||"binary","utf8"!==r.encoding&&"binary"!==r.encoding)throw new Error('Invalid encoding type "'+r.encoding+'"');var t,n=FS.open(e,r.flags),o=FS.stat(e).size,i=new Uint8Array(o);return FS.read(n,i,0,o,0),"utf8"===r.encoding?t=UTF8ArrayToString(i,0):"binary"===r.encoding&&(t=i),FS.close(n),t},writeFile:(e,r,t={})=>{t.flags=t.flags||577;var n=FS.open(e,t.flags,t.mode);if("string"==typeof r){var o=new Uint8Array(lengthBytesUTF8(r)+1),i=stringToUTF8Array(r,o,0,o.length);FS.write(n,o,0,i,void 0,t.canOwn)}else{if(!ArrayBuffer.isView(r))throw new Error("Unsupported data type");FS.write(n,r,0,r.byteLength,void 0,t.canOwn)}FS.close(n)},cwd:()=>FS.currentPath,chdir:e=>{var r=FS.lookupPath(e,{follow:!0});if(null===r.node)throw new FS.ErrnoError(44);if(!FS.isDir(r.node.mode))throw new FS.ErrnoError(54);var t=FS.nodePermissions(r.node,"x");if(t)throw new FS.ErrnoError(t);FS.currentPath=r.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:(e,r,t,n,o)=>n}),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("/dev/tty1",FS.makedev(6,0));var e=getRandomDevice();FS.createDevice("/dev","random",e),FS.createDevice("/dev","urandom",e),FS.mkdir("/dev/shm"),FS.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{FS.mkdir("/proc");var e=FS.mkdir("/proc/self");FS.mkdir("/proc/self/fd"),FS.mount({mount:()=>{var r=FS.createNode(e,"fd",16895,73);return r.node_ops={lookup:(e,r)=>{var t=+r,n=FS.getStream(t);if(!n)throw new FS.ErrnoError(8);var o={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>n.path}};return o.parent=o,o}},r}},{},"/proc/self/fd")},createStandardStreams:()=>{Module.stdin?FS.createDevice("/dev","stdin",Module.stdin):FS.symlink("/dev/tty","/dev/stdin"),Module.stdout?FS.createDevice("/dev","stdout",null,Module.stdout):FS.symlink("/dev/tty","/dev/stdout"),Module.stderr?FS.createDevice("/dev","stderr",null,Module.stderr):FS.symlink("/dev/tty1","/dev/stderr"),FS.open("/dev/stdin",0),FS.open("/dev/stdout",1),FS.open("/dev/stderr",1)},ensureErrnoError:()=>{FS.ErrnoError||(FS.ErrnoError=function(e,r){this.node=r,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},FS.ErrnoError.prototype=new Error,FS.ErrnoError.prototype.constructor=FS.ErrnoError,[44].forEach((e=>{FS.genericErrors[e]=new FS.ErrnoError(e),FS.genericErrors[e].stack="<generic error, no stack>"})))},staticInit:()=>{FS.ensureErrnoError(),FS.nameTable=new Array(4096),FS.mount(MEMFS,{},"/"),FS.createDefaultDirectories(),FS.createDefaultDevices(),FS.createSpecialDirectories(),FS.filesystems={MEMFS}},init:(e,r,t)=>{FS.init.initialized=!0,FS.ensureErrnoError(),Module.stdin=e||Module.stdin,Module.stdout=r||Module.stdout,Module.stderr=t||Module.stderr,FS.createStandardStreams()},quit:()=>{FS.init.initialized=!1;for(var e=0;e<FS.streams.length;e++){var r=FS.streams[e];r&&FS.close(r)}},getMode:(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},findObject:(e,r)=>{var t=FS.analyzePath(e,r);return t.exists?t.object:null},analyzePath:(e,r)=>{try{e=(n=FS.lookupPath(e,{follow:!r})).path}catch(e){}var t={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var n=FS.lookupPath(e,{parent:!0});t.parentExists=!0,t.parentPath=n.path,t.parentObject=n.node,t.name=PATH.basename(e),n=FS.lookupPath(e,{follow:!r}),t.exists=!0,t.path=n.path,t.object=n.node,t.name=n.node.name,t.isRoot="/"===n.path}catch(e){t.error=e.errno}return t},createPath:(e,r,t,n)=>{e="string"==typeof e?e:FS.getPath(e);for(var o=r.split("/").reverse();o.length;){var i=o.pop();if(i){var a=PATH.join2(e,i);try{FS.mkdir(a)}catch(e){}e=a}}return a},createFile:(e,r,t,n,o)=>{var i=PATH.join2("string"==typeof e?e:FS.getPath(e),r),a=FS.getMode(n,o);return FS.create(i,a)},createDataFile:(e,r,t,n,o,i)=>{var a=r;e&&(e="string"==typeof e?e:FS.getPath(e),a=r?PATH.join2(e,r):e);var s=FS.getMode(n,o),u=FS.create(a,s);if(t){if("string"==typeof t){for(var l=new Array(t.length),d=0,c=t.length;d<c;++d)l[d]=t.charCodeAt(d);t=l}FS.chmod(u,146|s);var m=FS.open(u,577);FS.write(m,t,0,t.length,0,i),FS.close(m),FS.chmod(u,s)}return u},createDevice:(e,r,t,n)=>{var o=PATH.join2("string"==typeof e?e:FS.getPath(e),r),i=FS.getMode(!!t,!!n);FS.createDevice.major||(FS.createDevice.major=64);var a=FS.makedev(FS.createDevice.major++,0);return FS.registerDevice(a,{open:e=>{e.seekable=!1},close:e=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(e,r,n,o,i)=>{for(var a=0,s=0;s<o;s++){var u;try{u=t()}catch(e){throw new FS.ErrnoError(29)}if(void 0===u&&0===a)throw new FS.ErrnoError(6);if(null==u)break;a++,r[n+s]=u}return a&&(e.node.timestamp=Date.now()),a},write:(e,r,t,o,i)=>{for(var a=0;a<o;a++)try{n(r[t+a])}catch(e){throw new FS.ErrnoError(29)}return o&&(e.node.timestamp=Date.now()),a}}),FS.mkdev(o,i,a)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!read_)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=intArrayFromString(read_(e.url),!0),e.usedBytes=e.contents.length}catch(e){throw new FS.ErrnoError(29)}},createLazyFile:(e,r,t,n,o)=>{function i(){this.lengthKnown=!1,this.chunks=[]}if(i.prototype.get=function(e){if(!(e>this.length-1||e<0)){var r=e%this.chunkSize,t=e/this.chunkSize|0;return this.getter(t)[r]}},i.prototype.setDataGetter=function(e){this.getter=e},i.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",t,!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+t+". Status: "+e.status);var r,n=Number(e.getResponseHeader("Content-length")),o=(r=e.getResponseHeader("Accept-Ranges"))&&"bytes"===r,i=(r=e.getResponseHeader("Content-Encoding"))&&"gzip"===r,a=1048576;o||(a=n);var s=this;s.setDataGetter((e=>{var r=e*a,o=(e+1)*a-1;if(o=Math.min(o,n-1),void 0===s.chunks[e]&&(s.chunks[e]=((e,r)=>{if(e>r)throw new Error("invalid range ("+e+", "+r+") or no bytes requested!");if(r>n-1)throw new Error("only "+n+" bytes available! programmer error!");var o=new XMLHttpRequest;if(o.open("GET",t,!1),n!==a&&o.setRequestHeader("Range","bytes="+e+"-"+r),o.responseType="arraybuffer",o.overrideMimeType&&o.overrideMimeType("text/plain; charset=x-user-defined"),o.send(null),!(o.status>=200&&o.status<300||304===o.status))throw new Error("Couldn't load "+t+". Status: "+o.status);return void 0!==o.response?new Uint8Array(o.response||[]):intArrayFromString(o.responseText||"",!0)})(r,o)),void 0===s.chunks[e])throw new Error("doXHR failed!");return s.chunks[e]})),!i&&n||(a=n=1,n=this.getter(0).length,a=n,out("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=n,this._chunkSize=a,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest){if(!ENVIRONMENT_IS_WORKER)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var a=new i;Object.defineProperties(a,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var s={isDevice:!1,contents:a}}else s={isDevice:!1,url:t};var u=FS.createFile(e,r,s,n,o);s.contents?u.contents=s.contents:s.url&&(u.contents=null,u.url=s.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var l={};function d(e,r,t,n,o){var i=e.node.contents;if(o>=i.length)return 0;var a=Math.min(i.length-o,n);if(i.slice)for(var s=0;s<a;s++)r[t+s]=i[o+s];else for(s=0;s<a;s++)r[t+s]=i.get(o+s);return a}return Object.keys(u.stream_ops).forEach((e=>{var r=u.stream_ops[e];l[e]=function(){return FS.forceLoadFile(u),r.apply(null,arguments)}})),l.read=(e,r,t,n,o)=>(FS.forceLoadFile(u),d(e,r,t,n,o)),l.mmap=(e,r,t,n,o)=>{FS.forceLoadFile(u);var i=mmapAlloc(r);if(!i)throw new FS.ErrnoError(48);return d(e,HEAP8,i,r,t),{ptr:i,allocated:!0}},u.stream_ops=l,u},createPreloadedFile:(e,r,t,n,o,i,a,s,u,l)=>{var d=r?PATH_FS.resolve(PATH.join2(e,r)):e,c=getUniqueRunDependency("cp "+d);function m(t){function m(t){l&&l(),s||FS.createDataFile(e,r,t,n,o,u),i&&i(),removeRunDependency(c)}Browser.handledByPreloadPlugin(t,d,m,(()=>{a&&a(),removeRunDependency(c)}))||m(t)}addRunDependency(c),"string"==typeof t?asyncLoad(t,(e=>m(e)),a):m(t)},indexedDB:()=>window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,DB_NAME:()=>"EM_FS_"+window.location.pathname,DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:(e,r,t)=>{r=r||(()=>{}),t=t||(()=>{});var n=FS.indexedDB();try{var o=n.open(FS.DB_NAME(),FS.DB_VERSION)}catch(e){return t(e)}o.onupgradeneeded=()=>{out("creating db"),o.result.createObjectStore(FS.DB_STORE_NAME)},o.onsuccess=()=>{var n=o.result.transaction([FS.DB_STORE_NAME],"readwrite"),i=n.objectStore(FS.DB_STORE_NAME),a=0,s=0,u=e.length;function l(){0==s?r():t()}e.forEach((e=>{var r=i.put(FS.analyzePath(e).object.contents,e);r.onsuccess=()=>{++a+s==u&&l()},r.onerror=()=>{s++,a+s==u&&l()}})),n.onerror=t},o.onerror=t},loadFilesFromDB:(e,r,t)=>{r=r||(()=>{}),t=t||(()=>{});var n=FS.indexedDB();try{var o=n.open(FS.DB_NAME(),FS.DB_VERSION)}catch(e){return t(e)}o.onupgradeneeded=t,o.onsuccess=()=>{var n=o.result;try{var i=n.transaction([FS.DB_STORE_NAME],"readonly")}catch(e){return void t(e)}var a=i.objectStore(FS.DB_STORE_NAME),s=0,u=0,l=e.length;function d(){0==u?r():t()}e.forEach((e=>{var r=a.get(e);r.onsuccess=()=>{FS.analyzePath(e).exists&&FS.unlink(e),FS.createDataFile(PATH.dirname(e),PATH.basename(e),r.result,!0,!0,!0),++s+u==l&&d()},r.onerror=()=>{u++,s+u==l&&d()}})),i.onerror=t},o.onerror=t}},SYSCALLS={DEFAULT_POLLMASK:5,calculateAt:function(e,r,t){if(PATH.isAbs(r))return r;var n;if(n=-100===e?FS.cwd():SYSCALLS.getStreamFromFD(e).path,0==r.length){if(!t)throw new FS.ErrnoError(44);return n}return PATH.join2(n,r)},doStat:function(e,r,t){try{var n=e(r)}catch(e){if(e&&e.node&&PATH.normalize(r)!==PATH.normalize(FS.getPath(e.node)))return-54;throw e}return HEAP32[t>>2]=n.dev,HEAP32[t+8>>2]=n.ino,HEAP32[t+12>>2]=n.mode,HEAPU32[t+16>>2]=n.nlink,HEAP32[t+20>>2]=n.uid,HEAP32[t+24>>2]=n.gid,HEAP32[t+28>>2]=n.rdev,tempI64=[n.size>>>0,(tempDouble=n.size,+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[t+40>>2]=tempI64[0],HEAP32[t+44>>2]=tempI64[1],HEAP32[t+48>>2]=4096,HEAP32[t+52>>2]=n.blocks,tempI64=[Math.floor(n.atime.getTime()/1e3)>>>0,(tempDouble=Math.floor(n.atime.getTime()/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[t+56>>2]=tempI64[0],HEAP32[t+60>>2]=tempI64[1],HEAPU32[t+64>>2]=0,tempI64=[Math.floor(n.mtime.getTime()/1e3)>>>0,(tempDouble=Math.floor(n.mtime.getTime()/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[t+72>>2]=tempI64[0],HEAP32[t+76>>2]=tempI64[1],HEAPU32[t+80>>2]=0,tempI64=[Math.floor(n.ctime.getTime()/1e3)>>>0,(tempDouble=Math.floor(n.ctime.getTime()/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[t+88>>2]=tempI64[0],HEAP32[t+92>>2]=tempI64[1],HEAPU32[t+96>>2]=0,tempI64=[n.ino>>>0,(tempDouble=n.ino,+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[t+104>>2]=tempI64[0],HEAP32[t+108>>2]=tempI64[1],0},doMsync:function(e,r,t,n,o){if(!FS.isFile(r.node.mode))throw new FS.ErrnoError(43);if(2&n)return 0;var i=HEAPU8.slice(e,e+t);FS.msync(r,i,o,t,n)},varargs:void 0,get:function(){return SYSCALLS.varargs+=4,HEAP32[SYSCALLS.varargs-4>>2]},getStr:function(e){return UTF8ToString(e)},getStreamFromFD:function(e){var r=FS.getStream(e);if(!r)throw new FS.ErrnoError(8);return r}};function handleException(e){if(e instanceof ExitStatus||"unwind"==e)return EXITSTATUS;quit_(1,e)}function maybeExit(){}function setMainLoop(e,r,t,n,o){assert(!Browser.mainLoop.func,"emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters."),Browser.mainLoop.func=e,Browser.mainLoop.arg=n;var i=Browser.mainLoop.curren