/*! * Stockfish copyright T. Romstad, M. Costalba, J. Kiiski, G. Linscott * and other contributors. * * Multi-variant support by Daniel Dugovic and contributors: * https://github.com/ddugovic/Stockfish * * Released under the GNU General Public License v3. * * Compiled to JavaScript and Webassembly by Niklas Fiekas * using Emscripten and Binaryen. * * https://github.com/niklasf/stockfish.js */ var Module=void 0!==Module?Module:{};Module=function(){var r=[];return onmessage=function(e){"quit"==e.data?close():null!==r?r.push(e.data):Module.ccall("uci_command","number",["string"],[e.data])},{locateFile:function(e){return e},print:function(e){postMessage(e)},postRun:function(){for(var e=0;e>2],t=r+e+15&-16;return t>_emscripten_get_heap_size()&&abort(),HEAP32[DYNAMICTOP_PTR>>2]=t,r}function getNativeTypeSize(e){switch(e){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:if("*"===e[e.length-1])return 4;if("i"!==e[0])return 0;var r=parseInt(e.substr(1));return assert(r%8==0,"getNativeTypeSize invalid bits "+r+", type "+e),r/8}}function warnOnce(e){warnOnce.shown||(warnOnce.shown={}),warnOnce.shown[e]||(warnOnce.shown[e]=1,err(e))}moduleOverrides=null,Module.arguments&&(arguments_=Module.arguments),Module.thisProgram&&(thisProgram=Module.thisProgram),Module.quit&&(quit_=Module.quit);var asm2wasmImports={"f64-rem":function(e,r){return e%r},debugger:function(){}},functionPointers=new Array(0),funcWrappers={};function getFuncWrapper(r,t){if(r){assert(t),funcWrappers[t]||(funcWrappers[t]={});var e=funcWrappers[t];return e[r]||(1===t.length?e[r]=function(){return dynCall(t,r)}:2===t.length?e[r]=function(e){return dynCall(t,r,[e])}:e[r]=function(){return dynCall(t,r,Array.prototype.slice.call(arguments))}),e[r]}}function dynCall(e,r,t){return t&&t.length?Module["dynCall_"+e].apply(null,[r].concat(t)):Module["dynCall_"+e].call(null,r)}var wasmBinary,wasmMemory,wasmTable,tempRet0=0,setTempRet0=function(e){tempRet0=e},getTempRet0=function(){return tempRet0};function setValue(e,r,t,n){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":HEAP8[e>>0]=r;break;case"i16":HEAP16[e>>1]=r;break;case"i32":HEAP32[e>>2]=r;break;case"i64":tempI64=[r>>>0,(tempDouble=r,1<=+Math_abs(tempDouble)?0>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[e>>2]=tempI64[0],HEAP32[e+4>>2]=tempI64[1];break;case"float":HEAPF32[e>>2]=r;break;case"double":HEAPF64[e>>3]=r;break;default:abort("invalid type for setValue: "+t)}}Module.wasmBinary&&(wasmBinary=Module.wasmBinary),"object"!=typeof WebAssembly&&err("no native wasm support detected");var ABORT=!1,EXITSTATUS=0;function assert(e,r){e||abort("Assertion failed: "+r)}function getCFunc(e){var r=Module["_"+e];return assert(r,"Cannot call unknown function "+e+", make sure it is exported"),r}function ccall(e,r,t,n,o){var i={string:function(e){var r=0;if(null!=e&&0!==e){var t=1+(e.length<<2);stringToUTF8(e,r=stackAlloc(t),t)}return r},array:function(e){var r=stackAlloc(e.length);return writeArrayToMemory(e,r),r}};var a=getCFunc(e),s=[],u=0;if(n)for(var l=0;l>2]=0;for(u=a+i;n>0]=0;return a}if("i8"===s)return e.subarray||e.slice?HEAPU8.set(e,a):HEAPU8.set(new Uint8Array(e),a),a;for(var l,c,d,f=0;f>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(!(0>6,r[t++]=128|63&s}else if(s<=65535){if(i<=t+2)break;r[t++]=224|s>>12,r[t++]=128|s>>6&63,r[t++]=128|63&s}else{if(i<=t+3)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>2]=DYNAMIC_BASE;var __ATPRERUN__=[],__ATINIT__=[],__ATMAIN__=[],__ATPOSTRUN__=[],runtimeInitialized=!1,runtimeExited=!1;function preRun(){if(Module.preRun)for("function"==typeof Module.preRun&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=!0,Module.noFSInit||FS.init.initialized||FS.init(),TTY.init(),callRuntimeCallbacks(__ATINIT__)}function preMain(){FS.ignorePermissions=!1,callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){runtimeExited=!0}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 addOnPostRun(e){__ATPOSTRUN__.unshift(e)}var Math_abs=Math.abs,Math_ceil=Math.ceil,Math_floor=Math.floor,Math_min=Math.min,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()}}Module.preloadedImages={},Module.preloadedAudios={};var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(e){return String.prototype.startsWith?e.startsWith(dataURIPrefix):0===e.indexOf(dataURIPrefix)}var tempDouble,tempI64,wasmBinaryFile="stockfish.wasm";function getBinary(){try{if(wasmBinary)return new Uint8Array(wasmBinary);if(readBinary)return readBinary(wasmBinaryFile);throw"both async and sync fetching of the wasm failed"}catch(e){abort(e)}}function getBinaryPromise(){return wasmBinary||!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER||"function"!=typeof fetch?new Promise(function(e,r){e(getBinary())}):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()})}function createWasm(e){var r={env:e,global:{NaN:NaN,Infinity:1/0},"global.Math":Math,asm2wasm:asm2wasmImports};function t(e,r){var t=e.exports;Module.asm=t,removeRunDependency("wasm-instantiate")}function n(e){t(e.instance)}function o(e){return getBinaryPromise().then(function(e){return WebAssembly.instantiate(e,r)}).then(e,function(e){err("failed to asynchronously prepare wasm: "+e),abort(e)})}if(addRunDependency("wasm-instantiate"),Module.instantiateWasm)try{return Module.instantiateWasm(r,t)}catch(e){return err("Module.instantiateWasm callback failed with error: "+e),!1}return function(){if(wasmBinary||"function"!=typeof WebAssembly.instantiateStreaming||isDataURI(wasmBinaryFile)||"function"!=typeof fetch)return o(n);fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,r).then(n,function(e){err("wasm streaming compile failed: "+e),err("falling back to ArrayBuffer instantiation"),o(n)})})}(),{}}function demangle(e){return e}function demangleAll(e){return e.replace(/__Z[\w\d_]+/g,function(e){var r=demangle(e);return e===r?e:r+" ["+e+"]"})}function jsStackTrace(){var r=new Error;if(!r.stack){try{throw new Error(0)}catch(e){r=e}if(!r.stack)return"(no stack trace available)"}return r.stack.toString()}function stackTrace(){var e=jsStackTrace();return Module.extraStackTrace&&(e+="\n"+Module.extraStackTrace()),demangleAll(e)}function ___atomic_fetch_add_8(e,r,t,n){var o=HEAP32[e>>2],i=HEAP32[e+4>>2];return HEAP32[e>>2]=_i64Add(o,i,r,t),HEAP32[e+4>>2]=getTempRet0(),0|(setTempRet0(i),o)}function ___cxa_allocate_exception(e){return _malloc(e)}isDataURI(wasmBinaryFile)||(wasmBinaryFile=locateFile(wasmBinaryFile)),Module.asm=function(e,r,t){return r.memory=wasmMemory,r.table=wasmTable=new WebAssembly.Table({initial:733,maximum:733,element:"anyfunc"}),r.__memory_base=1024,r.__table_base=0,createWasm(r)},__ATINIT__.push({func:function(){globalCtors()}});var ___exception_infos={},___exception_last=0;function ___cxa_throw(e,r,t){throw ___exception_infos[e]={ptr:e,adjusted:[e],type:r,destructor:t,refcount:0,caught:!1,rethrown:!1},___exception_last=e,"uncaught_exception"in __ZSt18uncaught_exceptionv?__ZSt18uncaught_exceptionv.uncaught_exceptions++:__ZSt18uncaught_exceptionv.uncaught_exceptions=1,e}function ___cxa_uncaught_exceptions(){return __ZSt18uncaught_exceptionv.uncaught_exceptions}function ___lock(){}function ___setErrNo(e){return Module.___errno_location&&(HEAP32[Module.___errno_location()>>2]=e),e}function ___map_file(e,r){return ___setErrNo(1),-1}var PATH={splitPath:function(e){return/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1)},normalizeArray:function(e,r){for(var t=0,n=e.length-1;0<=n;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:function(e){var r="/"===e.charAt(0),t="/"===e.substr(-1);return(e=PATH.normalizeArray(e.split("/").filter(function(e){return!!e}),!r).join("/"))||r||(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:function(e){var r=PATH.splitPath(e),t=r[0],n=r[1];return t||n?t+(n=n&&n.substr(0,n.length-1)):"."},basename:function(e){if("/"===e)return"/";var r=e.lastIndexOf("/");return-1===r?e:e.substr(r+1)},extname:function(e){return PATH.splitPath(e)[3]},join:function(){var e=Array.prototype.slice.call(arguments,0);return PATH.normalize(e.join("/"))},join2:function(e,r){return PATH.normalize(e+"/"+r)}},PATH_FS={resolve:function(){for(var e="",r=!1,t=arguments.length-1;-1<=t&&!r;t--){var n=0<=t?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="/"===n.charAt(0)}return(r?"/":"")+(e=PATH.normalizeArray(e.split("/").filter(function(e){return!!e}),!r).join("/"))||"."},relative:function(e,r){function t(e){for(var r=0;rr)e.contents.length=r;else for(;e.contents.length=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-o,n);if(8t.timestamp)&&(a.push(e),i++)});var t=[];if(Object.keys(o.entries).forEach(function(e){o.entries[e];n.entries[e]||(t.push(e),i++)}),!i)return r(null);var s=!1,e=("remote"===n.type?n.db:o.db).transaction([IDBFS.DB_STORE_NAME],"readwrite"),u=e.objectStore(IDBFS.DB_STORE_NAME);function l(e){if(e&&!s)return s=!0,r(e)}e.onerror=function(e){l(this.error),e.preventDefault()},e.oncomplete=function(e){s||r(null)},a.sort().forEach(function(t){"local"===o.type?IDBFS.loadRemoteEntry(u,t,function(e,r){if(e)return l(e);IDBFS.storeLocalEntry(t,r,l)}):IDBFS.loadLocalEntry(t,function(e,r){if(e)return l(e);IDBFS.storeRemoteEntry(u,t,r,l)})}),t.sort().reverse().forEach(function(e){"local"===o.type?IDBFS.removeLocalEntry(e,l):IDBFS.removeRemoteEntry(u,e,l)})}},NODEFS={isWindows:!1,staticInit:function(){NODEFS.isWindows=!!process.platform.match(/^win/);var e=process.binding("constants");e.fs&&(e=e.fs),NODEFS.flagsForNodeMap={1024:e.O_APPEND,64:e.O_CREAT,128:e.O_EXCL,0:e.O_RDONLY,2:e.O_RDWR,4096:e.O_SYNC,512:e.O_TRUNC,1:e.O_WRONLY}},bufferFrom:function(e){return Buffer.alloc?Buffer.from(e):new Buffer(e)},mount:function(e){return assert(ENVIRONMENT_HAS_NODE),NODEFS.createNode(null,"/",NODEFS.getMode(e.opts.root),0)},createNode:function(e,r,t,n){if(!FS.isDir(t)&&!FS.isFile(t)&&!FS.isLink(t))throw new FS.ErrnoError(22);var o=FS.createNode(e,r,t);return o.node_ops=NODEFS.node_ops,o.stream_ops=NODEFS.stream_ops,o},getMode:function(e){var r;try{r=fs.lstatSync(e),NODEFS.isWindows&&(r.mode=r.mode|(292&r.mode)>>2)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(-e.errno)}return r.mode},realPath:function(e){for(var r=[];e.parent!==e;)r.push(e.name),e=e.parent;return r.push(e.mount.opts.root),r.reverse(),PATH.join.apply(null,r)},flagsForNode:function(e){e&=-2097153,e&=-2049,e&=-32769,e&=-524289;var r=0;for(var t in NODEFS.flagsForNodeMap)e&t&&(r|=NODEFS.flagsForNodeMap[t],e^=t);if(e)throw new FS.ErrnoError(22);return r},node_ops:{getattr:function(e){var r,t=NODEFS.realPath(e);try{r=fs.lstatSync(t)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(-e.errno)}return NODEFS.isWindows&&!r.blksize&&(r.blksize=4096),NODEFS.isWindows&&!r.blocks&&(r.blocks=(r.size+r.blksize-1)/r.blksize|0),{dev:r.dev,ino:r.ino,mode:r.mode,nlink:r.nlink,uid:r.uid,gid:r.gid,rdev:r.rdev,size:r.size,atime:r.atime,mtime:r.mtime,ctime:r.ctime,blksize:r.blksize,blocks:r.blocks}},setattr:function(e,r){var t=NODEFS.realPath(e);try{if(void 0!==r.mode&&(fs.chmodSync(t,r.mode),e.mode=r.mode),void 0!==r.timestamp){var n=new Date(r.timestamp);fs.utimesSync(t,n,n)}void 0!==r.size&&fs.truncateSync(t,r.size)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(-e.errno)}},lookup:function(e,r){var t=PATH.join2(NODEFS.realPath(e),r),n=NODEFS.getMode(t);return NODEFS.createNode(e,r,n)},mknod:function(e,r,t,n){var o=NODEFS.createNode(e,r,t,n),i=NODEFS.realPath(o);try{FS.isDir(o.mode)?fs.mkdirSync(i,o.mode):fs.writeFileSync(i,"",{mode:o.mode})}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(-e.errno)}return o},rename:function(e,r,t){var n=NODEFS.realPath(e),o=PATH.join2(NODEFS.realPath(r),t);try{fs.renameSync(n,o)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(-e.errno)}},unlink:function(e,r){var t=PATH.join2(NODEFS.realPath(e),r);try{fs.unlinkSync(t)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(-e.errno)}},rmdir:function(e,r){var t=PATH.join2(NODEFS.realPath(e),r);try{fs.rmdirSync(t)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(-e.errno)}},readdir:function(e){var r=NODEFS.realPath(e);try{return fs.readdirSync(r)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(-e.errno)}},symlink:function(e,r,t){var n=PATH.join2(NODEFS.realPath(e),r);try{fs.symlinkSync(t,n)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(-e.errno)}},readlink:function(e){var r=NODEFS.realPath(e);try{return r=fs.readlinkSync(r),r=NODEJS_PATH.relative(NODEJS_PATH.resolve(e.mount.opts.root),r)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(-e.errno)}}},stream_ops:{open:function(e){var r=NODEFS.realPath(e.node);try{FS.isFile(e.node.mode)&&(e.nfd=fs.openSync(r,NODEFS.flagsForNode(e.flags)))}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(-e.errno)}},close:function(e){try{FS.isFile(e.node.mode)&&e.nfd&&fs.closeSync(e.nfd)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(-e.errno)}},read:function(e,r,t,n,o){if(0===n)return 0;try{return fs.readSync(e.nfd,NODEFS.bufferFrom(r.buffer),t,n,o)}catch(e){throw new FS.ErrnoError(-e.errno)}},write:function(e,r,t,n,o){try{return fs.writeSync(e.nfd,NODEFS.bufferFrom(r.buffer),t,n,o)}catch(e){throw new FS.ErrnoError(-e.errno)}},llseek:function(e,r,t){var n=r;if(1===t)n+=e.position;else if(2===t&&FS.isFile(e.node.mode))try{n+=fs.fstatSync(e.nfd).size}catch(e){throw new FS.ErrnoError(-e.errno)}if(n<0)throw new FS.ErrnoError(22);return n}}},WORKERFS={DIR_MODE:16895,FILE_MODE:33279,reader:null,mount:function(e){assert(ENVIRONMENT_IS_WORKER),WORKERFS.reader||(WORKERFS.reader=new FileReaderSync);var i=WORKERFS.createNode(null,"/",WORKERFS.DIR_MODE,0),a={};function n(e){for(var r=e.split("/"),t=i,n=0;n=e.node.size)return 0;var i=e.node.contents.slice(o,o+n),a=WORKERFS.reader.readAsArrayBuffer(i);return r.set(new Uint8Array(a),t),i.size},write:function(e,r,t,n,o){throw new FS.ErrnoError(5)},llseek:function(e,r,t){var n=r;if(1===t?n+=e.position:2===t&&FS.isFile(e.node.mode)&&(n+=e.node.size),n<0)throw new FS.ErrnoError(22);return n}}},FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,trackingDelegate:{},tracking:{openFlags:{READ:1,WRITE:2}},ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,handleFSError:function(e){if(!(e instanceof FS.ErrnoError))throw e+" : "+stackTrace();return ___setErrNo(e.errno)},lookupPath:function(e,r){if(r=r||{},!(e=PATH_FS.resolve(FS.cwd(),e)))return{path:"",node:null};var t={follow_mount:!0,recurse_count:0};for(var n in t)void 0===r[n]&&(r[n]=t[n]);if(8>>0)%FS.nameTable.length},hashAddNode:function(e){var r=FS.hashName(e.parent.id,e.name);e.name_next=FS.nameTable[r],FS.nameTable[r]=e},hashRemoveNode:function(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:function(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:function(e,r,t,n){if(!FS.FSNode){FS.FSNode=function(e,r,t,n){e=e||this,this.parent=e,this.mount=e.mount,this.mounted=null,this.id=FS.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n},FS.FSNode.prototype={};Object.defineProperties(FS.FSNode.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},isFolder:{get:function(){return FS.isDir(this.mode)}},isDevice:{get:function(){return FS.isChrdev(this.mode)}}})}var o=new FS.FSNode(e,r,t,n);return FS.hashAddNode(o),o},destroyNode:function(e){FS.hashRemoveNode(e)},isRoot:function(e){return e===e.parent},isMountpoint:function(e){return!!e.mounted},isFile:function(e){return 32768==(61440&e)},isDir:function(e){return 16384==(61440&e)},isLink:function(e){return 40960==(61440&e)},isChrdev:function(e){return 8192==(61440&e)},isBlkdev:function(e){return 24576==(61440&e)},isFIFO:function(e){return 4096==(61440&e)},isSocket:function(e){return 49152==(49152&e)},flagModes:{r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function(e){var r=FS.flagModes[e];if(void 0===r)throw new Error("Unknown file open mode: "+e);return r},flagsToPermissionString:function(e){var r=["r","w","rw"][3&e];return 512&e&&(r+="w"),r},nodePermissions:function(e,r){return FS.ignorePermissions?0:(-1===r.indexOf("r")||292&e.mode)&&(-1===r.indexOf("w")||146&e.mode)&&(-1===r.indexOf("x")||73&e.mode)?0:13},mayLookup:function(e){var r=FS.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:13)},mayCreate:function(e,r){try{FS.lookupNode(e,r);return 17}catch(e){}return FS.nodePermissions(e,"wx")},mayDelete:function(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 20;if(FS.isRoot(n)||FS.getPath(n)===FS.cwd())return 16}else if(FS.isDir(n.mode))return 21;return 0},mayOpen:function(e,r){return e?FS.isLink(e.mode)?40:FS.isDir(e.mode)&&("r"!==FS.flagsToPermissionString(r)||512&r)?21:FS.nodePermissions(e,FS.flagsToPermissionString(r)):2},MAX_OPEN_FDS:4096,nextfd:function(e,r){e=e||0,r=r||FS.MAX_OPEN_FDS;for(var t=e;t<=r;t++)if(!FS.streams[t])return t;throw new FS.ErrnoError(24)},getStream:function(e){return FS.streams[e]},createStream:function(e,r,t){FS.FSStream||(FS.FSStream=function(){},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}}}));var n=new FS.FSStream;for(var o in e)n[o]=e[o];e=n;var i=FS.nextfd(r,t);return e.fd=i,FS.streams[i]=e},closeStream:function(e){FS.streams[e]=null},chrdev_stream_ops:{open:function(e){var r=FS.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new FS.ErrnoError(29)}},major:function(e){return e>>8},minor:function(e){return 255&e},makedev:function(e,r){return e<<8|r},registerDevice:function(e,r){FS.devices[e]={stream_ops:r}},getDevice:function(e){return FS.devices[e]},getMounts:function(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push.apply(t,n.mounts)}return r},syncfs:function(r,t){"function"==typeof r&&(t=r,r=!1),FS.syncFSRequests++,1=n.length&&i(null)}n.forEach(function(e){if(!e.type.syncfs)return a(null);e.type.syncfs(e,r,a)})},mount:function(e,r,t){var n,o="/"===t,i=!t;if(o&&FS.root)throw new FS.ErrnoError(16);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(16);if(!FS.isDir(n.mode))throw new FS.ErrnoError(20)}var s={type:e,opts:r,mountpoint:t,mounts:[]},u=e.mount(s);return(u.mount=s).root=u,o?FS.root=u:n&&(n.mounted=s,n.mount&&n.mount.mounts.push(s)),u},unmount:function(e){var r=FS.lookupPath(e,{follow_mount:!1});if(!FS.isMountpoint(r.node))throw new FS.ErrnoError(22);var t=r.node,n=t.mounted,o=FS.getMounts(n);Object.keys(FS.nameTable).forEach(function(e){for(var r=FS.nameTable[e];r;){var t=r.name_next;-1!==o.indexOf(r.mount)&&FS.destroyNode(r),r=t}}),t.mounted=null;var i=t.mount.mounts.indexOf(n);t.mount.mounts.splice(i,1)},lookup:function(e,r){return e.node_ops.lookup(e,r)},mknod:function(e,r,t){var n=FS.lookupPath(e,{parent:!0}).node,o=PATH.basename(e);if(!o||"."===o||".."===o)throw new FS.ErrnoError(22);var i=FS.mayCreate(n,o);if(i)throw new FS.ErrnoError(i);if(!n.node_ops.mknod)throw new FS.ErrnoError(1);return n.node_ops.mknod(n,o,r,t)},create:function(e,r){return r=void 0!==r?r:438,r&=4095,r|=32768,FS.mknod(e,r,0)},mkdir:function(e,r){return r=void 0!==r?r:511,r&=1023,r|=16384,FS.mknod(e,r,0)},mkdirTree:function(e,r){for(var t=e.split("/"),n="",o=0;othis.length-1||e<0)){var r=e%this.chunkSize,t=e/this.chunkSize|0;return this.getter(t)[r]}},o.prototype.setDataGetter=function(e){this.getter=e},o.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",s,!1),e.send(null),!(200<=e.status&&e.status<300||304===e.status))throw new Error("Couldn't load "+s+". Status: "+e.status);var r,n=Number(e.getResponseHeader("Content-length")),t=(r=e.getResponseHeader("Accept-Ranges"))&&"bytes"===r,o=(r=e.getResponseHeader("Content-Encoding"))&&"gzip"===r,i=1048576;t||(i=n);var a=this;a.setDataGetter(function(e){var r=e*i,t=(e+1)*i-1;if(t=Math.min(t,n-1),void 0===a.chunks[e]&&(a.chunks[e]=function(e,r){if(r=i.length)return 0;var a=Math.min(i.length-o,n);if(i.slice)for(var s=0;s>2]=n.dev,HEAP32[t+4>>2]=0,HEAP32[t+8>>2]=n.ino,HEAP32[t+12>>2]=n.mode,HEAP32[t+16>>2]=n.nlink,HEAP32[t+20>>2]=n.uid,HEAP32[t+24>>2]=n.gid,HEAP32[t+28>>2]=n.rdev,HEAP32[t+32>>2]=0,tempI64=[n.size>>>0,(tempDouble=n.size,1<=+Math_abs(tempDouble)?0>>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,HEAP32[t+56>>2]=n.atime.getTime()/1e3|0,HEAP32[t+60>>2]=0,HEAP32[t+64>>2]=n.mtime.getTime()/1e3|0,HEAP32[t+68>>2]=0,HEAP32[t+72>>2]=n.ctime.getTime()/1e3|0,HEAP32[t+76>>2]=0,tempI64=[n.ino>>>0,(tempDouble=n.ino,1<=+Math_abs(tempDouble)?0>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[t+80>>2]=tempI64[0],HEAP32[t+84>>2]=tempI64[1],0},doMsync:function(e,r,t,n){var o=new Uint8Array(HEAPU8.subarray(e,e+t));FS.msync(r,o,0,t,n)},doMkdir:function(e,r){return"/"===(e=PATH.normalize(e))[e.length-1]&&(e=e.substr(0,e.length-1)),FS.mkdir(e,r,0),0},doMknod:function(e,r,t){switch(61440&r){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-22}return FS.mknod(e,r,t),0},doReadlink:function(e,r,t){if(t<=0)return-22;var n=FS.readlink(e),o=Math.min(t,lengthBytesUTF8(n)),i=HEAP8[r+o];return stringToUTF8(n,r,t+1),HEAP8[r+o]=i,o},doAccess:function(e,r){if(-8&r)return-22;var t;if(!(t=FS.lookupPath(e,{follow:!0}).node))return-2;var n="";return 4&r&&(n+="r"),2&r&&(n+="w"),1&r&&(n+="x"),n&&FS.nodePermissions(t,n)?-13:0},doDup:function(e,r,t){var n=FS.getStream(t);return n&&FS.close(n),FS.open(e,r,0,t,t).fd},doReadv:function(e,r,t,n){for(var o=0,i=0;i>2],s=HEAP32[r+(8*i+4)>>2],u=FS.read(e,HEAP8,a,s,n);if(u<0)return-1;if(o+=u,u>2],s=HEAP32[r+(8*i+4)>>2],u=FS.write(e,HEAP8,a,s,n);if(u<0)return-1;o+=u}return o},varargs:0,get:function(e){return SYSCALLS.varargs+=4,HEAP32[SYSCALLS.varargs-4>>2]},getStr:function(){return UTF8ToString(SYSCALLS.get())},getStreamFromFD:function(){var e=FS.getStream(SYSCALLS.get());if(!e)throw new FS.ErrnoError(9);return e},get64:function(){var e=SYSCALLS.get();SYSCALLS.get();return e},getZero:function(){SYSCALLS.get()}};function ___syscall140(e,r){SYSCALLS.varargs=r;try{var t=SYSCALLS.getStreamFromFD(),n=SYSCALLS.get(),o=SYSCALLS.get(),i=SYSCALLS.get(),a=SYSCALLS.get(),s=4294967296*n+(o>>>0),u=9007199254740992;return s<=-u||u<=s?-75:(FS.llseek(t,s,a),tempI64=[t.position>>>0,(tempDouble=t.position,1<=+Math_abs(tempDouble)?0>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[i>>2]=tempI64[0],HEAP32[i+4>>2]=tempI64[1],t.getdents&&0==s&&0===a&&(t.getdents=null),0)}catch(e){return void 0!==FS&&e instanceof FS.ErrnoError||abort(e),-e.errno}}function ___syscall145(e,r){SYSCALLS.varargs=r;try{var t=SYSCALLS.getStreamFromFD(),n=SYSCALLS.get(),o=SYSCALLS.get();return SYSCALLS.doReadv(t,n,o)}catch(e){return void 0!==FS&&e instanceof FS.ErrnoError||abort(e),-e.errno}}function ___syscall146(e,r){SYSCALLS.varargs=r;try{var t=SYSCALLS.getStreamFromFD(),n=SYSCALLS.get(),o=SYSCALLS.get();return SYSCALLS.doWritev(t,n,o)}catch(e){return void 0!==FS&&e instanceof FS.ErrnoError||abort(e),-e.errno}}function ___syscall221(e,r){SYSCALLS.varargs=r;try{var t=SYSCALLS.getStreamFromFD();switch(SYSCALLS.get()){case 0:return(n=SYSCALLS.get())<0?-22:FS.open(t.path,t.flags,0,n).fd;case 1:case 2:return 0;case 3:return t.flags;case 4:var n=SYSCALLS.get();return t.flags|=n,0;case 12:n=SYSCALLS.get();return HEAP16[n+0>>1]=2,0;case 13:case 14:return 0;case 16:case 8:return-22;case 9:return ___setErrNo(22),-1;default:return-22}}catch(e){return void 0!==FS&&e instanceof FS.ErrnoError||abort(e),-e.errno}}function ___syscall5(e,r){SYSCALLS.varargs=r;try{var t=SYSCALLS.getStr(),n=SYSCALLS.get(),o=SYSCALLS.get();return FS.open(t,n,o).fd}catch(e){return void 0!==FS&&e instanceof FS.ErrnoError||abort(e),-e.errno}}function ___syscall54(e,r){SYSCALLS.varargs=r;try{var t=SYSCALLS.getStreamFromFD(),n=SYSCALLS.get();switch(n){case 21509:case 21505:return t.tty?0:-25;case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:return t.tty?0:-25;case 21519:if(!t.tty)return-25;var o=SYSCALLS.get();return HEAP32[o>>2]=0;case 21520:return t.tty?-22:-25;case 21531:o=SYSCALLS.get();return FS.ioctl(t,n,o);case 21523:case 21524:return t.tty?0:-25;default:abort("bad ioctl syscall "+n)}}catch(e){return void 0!==FS&&e instanceof FS.ErrnoError||abort(e),-e.errno}}function ___syscall6(e,r){SYSCALLS.varargs=r;try{var t=SYSCALLS.getStreamFromFD();return FS.close(t),0}catch(e){return void 0!==FS&&e instanceof FS.ErrnoError||abort(e),-e.errno}}function __emscripten_syscall_munmap(e,r){if(-1===e||0===r)return-22;var t=SYSCALLS.mappings[e];if(!t)return 0;if(r===t.len){var n=FS.getStream(t.fd);SYSCALLS.doMsync(e,n,r,t.flags),FS.munmap(n),SYSCALLS.mappings[e]=null,t.allocated&&_free(t.malloc)}return 0}function ___syscall91(e,r){SYSCALLS.varargs=r;try{return __emscripten_syscall_munmap(SYSCALLS.get(),SYSCALLS.get())}catch(e){return void 0!==FS&&e instanceof FS.ErrnoError||abort(e),-e.errno}}function ___unlock(){}function _abort(){Module.abort()}function _emscripten_get_now(){abort()}function _emscripten_get_now_is_monotonic(){return ENVIRONMENT_IS_NODE||"undefined"!=typeof dateNow||"object"==typeof performance&&performance&&"function"==typeof performance.now}function _clock_gettime(e,r){var t;if(0===e)t=Date.now();else{if(1!==e||!_emscripten_get_now_is_monotonic())return ___setErrNo(22),-1;t=_emscripten_get_now()}return HEAP32[r>>2]=t/1e3|0,HEAP32[r+4>>2]=t%1e3*1e3*1e3|0,0}function _emscripten_set_main_loop_timing(e,r){if(Browser.mainLoop.timingMode=e,Browser.mainLoop.timingValue=r,!Browser.mainLoop.func)return 1;if(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",function(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 _emscripten_set_main_loop(e,r,t,n,o){var i;Module.noExitRuntime=!0,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,i=void 0!==n?function(){Module.dynCall_vi(e,n)}:function(){Module.dynCall_v(e)};var a=Browser.mainLoop.currentlyRunningMainloop;if(Browser.mainLoop.runner=function(){if(!ABORT)if(0>o-6&63;o-=6,t+=r[a]}return 2==o?(t+=r[(3&n)<<4],t+="=="):4==o&&(t+=r[(15&n)<<2],t+="="),t}(r),i(l))},l.src=u,Browser.safeSetTimeout(function(){i(l)},1e4)}};Module.preloadPlugins.push(r);var t=Module.canvas;t&&(t.requestPointerLock=t.requestPointerLock||t.mozRequestPointerLock||t.webkitRequestPointerLock||t.msRequestPointerLock||function(){},t.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||function(){},t.exitPointerLock=t.exitPointerLock.bind(document),document.addEventListener("pointerlockchange",n,!1),document.addEventListener("mozpointerlockchange",n,!1),document.addEventListener("webkitpointerlockchange",n,!1),document.addEventListener("mspointerlockchange",n,!1),Module.elementPointerLock&&t.addEventListener("click",function(e){!Browser.pointerLock&&Module.canvas.requestPointerLock&&(Module.canvas.requestPointerLock(),e.preventDefault())},!1))}function n(){Browser.pointerLock=document.pointerLockElement===Module.canvas||document.mozPointerLockElement===Module.canvas||document.webkitPointerLockElement===Module.canvas||document.msPointerLockElement===Module.canvas}},createContext:function(e,r,t,n){if(r&&Module.ctx&&e==Module.canvas)return Module.ctx;var o,i;if(r){var a={antialias:!1,alpha:!1,majorVersion:1};if(n)for(var s in n)a[s]=n[s];"undefined"!=typeof GL&&(i=GL.createContext(e,a))&&(o=GL.getContext(i).GLctx)}else o=e.getContext("2d");return o?(t&&(r||assert("undefined"==typeof GLctx,"cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),Module.ctx=o,r&&GL.makeContextCurrent(i),Module.useWebGL=r,Browser.moduleContextCreatedCallbacks.forEach(function(e){e()}),Browser.init()),o):null},destroyContext:function(e,r,t){},fullscreenHandlersInstalled:!1,lockPointer:void 0,resizeCanvas:void 0,requestFullscreen:function(e,r,t){Browser.lockPointer=e,Browser.resizeCanvas=r,Browser.vrDevice=t,void 0===Browser.lockPointer&&(Browser.lockPointer=!0),void 0===Browser.resizeCanvas&&(Browser.resizeCanvas=!1),void 0===Browser.vrDevice&&(Browser.vrDevice=null);var n=Module.canvas;function o(){Browser.isFullscreen=!1;var e=n.parentNode;(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===e?(n.exitFullscreen=Browser.exitFullscreen,Browser.lockPointer&&n.requestPointerLock(),Browser.isFullscreen=!0,Browser.resizeCanvas?Browser.setFullscreenCanvasSize():Browser.updateCanvasDimensions(n)):(e.parentNode.insertBefore(n,e),e.parentNode.removeChild(e),Browser.resizeCanvas?Browser.setWindowedCanvasSize():Browser.updateCanvasDimensions(n)),Module.onFullScreen&&Module.onFullScreen(Browser.isFullscreen),Module.onFullscreen&&Module.onFullscreen(Browser.isFullscreen)}Browser.fullscreenHandlersInstalled||(Browser.fullscreenHandlersInstalled=!0,document.addEventListener("fullscreenchange",o,!1),document.addEventListener("mozfullscreenchange",o,!1),document.addEventListener("webkitfullscreenchange",o,!1),document.addEventListener("MSFullscreenChange",o,!1));var i=document.createElement("div");n.parentNode.insertBefore(i,n),i.appendChild(n),i.requestFullscreen=i.requestFullscreen||i.mozRequestFullScreen||i.msRequestFullscreen||(i.webkitRequestFullscreen?function(){i.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)}:null)||(i.webkitRequestFullScreen?function(){i.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}:null),t?i.requestFullscreen({vrDisplay:t}):i.requestFullscreen()},requestFullScreen:function(e,r,t){return err("Browser.requestFullScreen() is deprecated. Please call Browser.requestFullscreen instead."),Browser.requestFullScreen=function(e,r,t){return Browser.requestFullscreen(e,r,t)},Browser.requestFullscreen(e,r,t)},exitFullscreen:function(){return!!Browser.isFullscreen&&((document.exitFullscreen||document.cancelFullScreen||document.mozCancelFullScreen||document.msExitFullscreen||document.webkitCancelFullScreen||function(){}).apply(document,[]),!0)},nextRAF:0,fakeRequestAnimationFrame:function(e){var r=Date.now();if(0===Browser.nextRAF)Browser.nextRAF=r+1e3/60;else for(;r+2>=Browser.nextRAF;)Browser.nextRAF+=1e3/60;var t=Math.max(Browser.nextRAF-r,0);setTimeout(e,t)},requestAnimationFrame:function(e){"function"!=typeof requestAnimationFrame?(0,Browser.fakeRequestAnimationFrame)(e):requestAnimationFrame(e)},safeCallback:function(e){return function(){if(!ABORT)return e.apply(null,arguments)}},allowAsyncCallbacks:!0,queuedAsyncCallbacks:[],pauseAsyncCallbacks:function(){Browser.allowAsyncCallbacks=!1},resumeAsyncCallbacks:function(){if(Browser.allowAsyncCallbacks=!0,0>2];e|=8388608,HEAP32[SDL.screen>>2]=e}Browser.updateCanvasDimensions(Module.canvas),Browser.updateResizeListeners()},setWindowedCanvasSize:function(){if("undefined"!=typeof SDL){var e=HEAPU32[SDL.screen>>2];e&=-8388609,HEAP32[SDL.screen>>2]=e}Browser.updateCanvasDimensions(Module.canvas),Browser.updateResizeListeners()},updateCanvasDimensions:function(e,r,t){r&&t?(e.widthNative=r,e.heightNative=t):(r=e.widthNative,t=e.heightNative);var n=r,o=t;if(Module.forcedAspectRatio&&0i-t.getDate()))return t.setDate(t.getDate()+r),t;r-=i-t.getDate()+1,t.setDate(1),o<11?t.setMonth(o+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return t}function _strftime(e,r,t,n){var o=HEAP32[n+40>>2],i={tm_sec:HEAP32[n>>2],tm_min:HEAP32[n+4>>2],tm_hour:HEAP32[n+8>>2],tm_mday:HEAP32[n+12>>2],tm_mon:HEAP32[n+16>>2],tm_year:HEAP32[n+20>>2],tm_wday:HEAP32[n+24>>2],tm_yday:HEAP32[n+28>>2],tm_isdst:HEAP32[n+32>>2],tm_gmtoff:HEAP32[n+36>>2],tm_zone:o?UTF8ToString(o):""},a=UTF8ToString(t),s={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var u in s)a=a.replace(new RegExp(u,"g"),s[u]);var l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],c=["January","February","March","April","May","June","July","August","September","October","November","December"];function d(e,r,t){for(var n="number"==typeof e?e.toString():e||"";n.lengthr?0:(writeArrayToMemory(F,e),F.length-1)}function _strftime_l(e,r,t,n){return _strftime(e,r,t,n)}if(FS.staticInit(),ENVIRONMENT_HAS_NODE){var fs=require("fs"),NODEJS_PATH=require("path");NODEFS.staticInit()}function intArrayFromString(e,r,t){var n=0>2]=allocateUTF8OnStack(thisProgram);for(var n=1;n>2)+n]=allocateUTF8OnStack(e[n-1]);HEAP32[(t>>2)+r]=0;try{exit(Module._main(r,t),!0)}catch(e){if(e instanceof ExitStatus)return;if("SimulateInfiniteLoop"==e)return void(Module.noExitRuntime=!0);var o=e;e&&"object"==typeof e&&e.stack&&(o=[e,e.stack]),err("exception thrown: "+o),quit_(1,e)}finally{calledMain=!0}}function run(e){function r(){Module.calledRun||(Module.calledRun=!0,ABORT||(initRuntime(),preMain(),Module.onRuntimeInitialized&&Module.onRuntimeInitialized(),shouldRunNow&&callMain(e),postRun()))}e=e||arguments_,0