forked from echamudi/opencv-wasm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopencv.min.js
9 lines (9 loc) · 82.5 KB
/
opencv.min.js
1
2
3
4
5
6
7
8
9
!function(){var e,t;e=this,t=function(){function e(e={}){var z,O,V,I,U,W,N,u=e,e=(new Promise((e,t)=>{z=e,O=t}),"object"==typeof window),B="function"==typeof importScripts,q="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,H=Object.assign({},u),Y="./this.program",X=(e,t)=>{throw t},t="";q?(V=require("fs"),I=require("path"),t=__dirname+"/",U=(e,t)=>(e=ge(e)?new URL(e):I.normalize(e),V.readFileSync(e,t?void 0:"utf8")),W=e=>{e=U(e,!0);return e=e.buffer?e:new Uint8Array(e)},N=(e,r,n,o=!0)=>{e=ge(e)?new URL(e):I.normalize(e),V.readFile(e,o?void 0:"utf8",(e,t)=>{e?n(e):r(o?t.buffer:t)})},!u.thisProgram&&1<process.argv.length&&(Y=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),X=(e,t)=>{throw process.exitCode=e,t}):(e||B)&&(B?t=self.location.href:"undefined"!=typeof document&&document.currentScript&&(t=document.currentScript.src),t=(t=Ar?Ar:t).startsWith("blob:")?"":t.substr(0,t.replace(/[?#].*/,"").lastIndexOf("/")+1),U=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},B&&(W=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),N=(e,t,r)=>{var n;ge(e)?((n=new XMLHttpRequest).open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?t(n.response):r()},n.onerror=r,n.send(null)):fetch(e,{credentials:"same-origin"}).then(e=>e.ok?e.arrayBuffer():Promise.reject(new Error(e.status+" : "+e.url))).then(t,r)});var G,K,J,h,d,p,Z,w,y,Q,ee,te=u.print||console.log.bind(console),l=u.printErr||console.error.bind(console),c=(Object.assign(u,H),u.arguments&&u.arguments,u.thisProgram&&(Y=u.thisProgram),u.quit&&(X=u.quit),u.wasmBinary&&(G=u.wasmBinary),!1);function re(){var e=K.buffer;u.HEAP8=h=new Int8Array(e),u.HEAP16=p=new Int16Array(e),u.HEAPU8=d=new Uint8Array(e),u.HEAPU16=Z=new Uint16Array(e),u.HEAP32=w=new Int32Array(e),u.HEAPU32=y=new Uint32Array(e),u.HEAPF32=Q=new Float32Array(e),u.HEAPF64=ee=new Float64Array(e)}var ne=[],oe=[],ae=[];function se(){if(u.preRun)for("function"==typeof u.preRun&&(u.preRun=[u.preRun]);u.preRun.length;)e=u.preRun.shift(),ne.unshift(e);var e;Te(ne)}function ie(){if(u.postRun)for("function"==typeof u.postRun&&(u.postRun=[u.postRun]);u.postRun.length;)e=u.postRun.shift(),ae.unshift(e);var e;Te(ae)}var r=0,ue=null,le=null;function de(e){r++,u.monitorRunDependencies?.(r)}function ce(e){var t;r--,u.monitorRunDependencies?.(r),0==r&&(null!==ue&&(clearInterval(ue),ue=null),le)&&(t=le,le=null,t())}function me(e){u.onAbort?.(e),l(e="Aborted("+e+")"),c=!0,J=1,e+=". Build with -sASSERTIONS for more info.";e=new WebAssembly.RuntimeError(e);throw O(e),e}var he,s,i,pe="data:application/octet-stream;base64,",fe=e=>e.startsWith(pe),ge=e=>e.startsWith("file://");function ve(){var e="opencv_js.wasm";return fe(e)?e:(e=e,u.locateFile?u.locateFile(e,t):t+e)}function we(e,t){e=function(e){if(e==he&&G)return new Uint8Array(G);if(W)return W(e);throw'sync fetching of the wasm failed: you can preload it to Module["wasmBinary"] manually, or emcc.py will do that for you when generating HTML (but not JS)'}(e),e=new WebAssembly.Module(e);return[new WebAssembly.Instance(e,t),e]}var ye=(e,t)=>{var r,n;return v.mainLoop.timingMode=e,v.mainLoop.timingValue=t,v.mainLoop.func?(v.mainLoop.running||(v.mainLoop.running=!0),0==e?(v.mainLoop.scheduler=function(){var e=0|Math.max(0,v.mainLoop.tickStartTime+t-Ee());setTimeout(v.mainLoop.runner,e)},v.mainLoop.method="timeout"):1==e?(v.mainLoop.scheduler=function(){v.requestAnimationFrame(v.mainLoop.runner)},v.mainLoop.method="rAF"):2==e&&(void 0===v.setImmediate&&("undefined"==typeof setImmediate?(r=[],n="setimmediate",addEventListener("message",e=>{e.data!==n&&e.data.target!==n||(e.stopPropagation(),r.shift()())},!0),v.setImmediate=function(e){r.push(e),B?(void 0===u.setImmediates&&(u.setImmediates=[]),u.setImmediates.push(e),postMessage({target:n})):postMessage(n,"*")}):v.setImmediate=setImmediate),v.mainLoop.scheduler=function(){v.setImmediate(v.mainLoop.runner)},v.mainLoop.method="immediate"),0):1},Ee=()=>performance.now(),_e=e=>{if(e instanceof be||"unwind"==e)return J;X(1,e)};function be(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var Ce=0,ke=()=>Re||0<Ce,Fe=(e,t)=>{J=e=J=e,ke()||(u.onExit?.(e),c=!0),X(e,new be(e))},Pe=e=>{if(!c)try{if(e(),!ke())try{Fe(J)}catch(e){_e(e)}}catch(e){_e(e)}},Se=(e,t)=>setTimeout(()=>{Pe(e)},t),Me=u.preloadPlugins||[],v={mainLoop:{running:!1,scheduler:null,method:"",currentlyRunningMainloop:0,func:null,arg:0,timingMode:0,timingValue:0,currentFrameNumber:0,queue:[],pause(){v.mainLoop.scheduler=null,v.mainLoop.currentlyRunningMainloop++},resume(){v.mainLoop.currentlyRunningMainloop++;var e=v.mainLoop.timingMode,t=v.mainLoop.timingValue,r=v.mainLoop.func,n=(v.mainLoop.func=null,r),r=0,o=!1,a=v.mainLoop.arg,s=!0,i=(v.mainLoop.func=n,v.mainLoop.arg=a,v.mainLoop.currentlyRunningMainloop);function u(){return!(i<v.mainLoop.currentlyRunningMainloop)}if(v.mainLoop.running=!1,v.mainLoop.runner=function(){var e,t,r;if(!c)return 0<v.mainLoop.queue.length?(Date.now(),(e=v.mainLoop.queue.shift()).func(e.arg),v.mainLoop.remainingBlockers&&(r=(t=v.mainLoop.remainingBlockers)%1==0?t-1:Math.floor(t),e.counted?v.mainLoop.remainingBlockers=r:v.mainLoop.remainingBlockers=(8*t+(r+=.5))/9),v.mainLoop.updateStatus(),u()?void setTimeout(v.mainLoop.runner,0):void 0):void(u()&&(v.mainLoop.currentFrameNumber=v.mainLoop.currentFrameNumber+1|0,1==v.mainLoop.timingMode&&1<v.mainLoop.timingValue&&v.mainLoop.currentFrameNumber%v.mainLoop.timingValue!=0?v.mainLoop.scheduler():(0==v.mainLoop.timingMode&&(v.mainLoop.tickStartTime=Ee()),v.mainLoop.runIter(n),u()&&("object"==typeof SDL&&SDL.audio?.queueNewAudioData?.(),v.mainLoop.scheduler()))))},s||(r&&0<r?ye(0,1e3/r):ye(1,1),v.mainLoop.scheduler()),o)throw"unwind";ye(e,t),v.mainLoop.scheduler()},updateStatus(){var e,t,r;u.setStatus&&(e=u.statusMessage||"Please wait...",t=v.mainLoop.remainingBlockers,r=v.mainLoop.expectedBlockers,t?t<r?u.setStatus("{message} ({expected - remaining}/{expected})"):u.setStatus(e):u.setStatus(""))},runIter(e){if(!c){if(u.preMainLoop)if(!1===u.preMainLoop())return;Pe(e),u.postMainLoop?.()}}},isFullscreen:!1,pointerLock:!1,moduleContextCreatedCallbacks:[],workers:[],init(){var e;function t(){v.pointerLock=document.pointerLockElement===u.canvas||document.mozPointerLockElement===u.canvas||document.webkitPointerLockElement===u.canvas||document.msPointerLockElement===u.canvas}v.initted||(v.initted=!0,Me.push({canHandle:function(e){return!u.noImageDecoding&&/\.(jpg|jpeg|png|bmp)$/i.test(e)},handle:function(t,r,n,o){var e=new Blob([t],{type:v.getMimetype(r)}),a=(e.size!==t.length&&(e=new Blob([new Uint8Array(t).buffer],{type:v.getMimetype(r)})),URL.createObjectURL(e)),s=new Image;s.onload=()=>{var e=document.createElement("canvas");e.width=s.width,e.height=s.height,e.getContext("2d").drawImage(s,0,0),yr[r]=e,URL.revokeObjectURL(a),n?.(t)},s.onerror=e=>{l(`Image ${a} could not be decoded`),o?.()},s.src=a}}),(e={canHandle:function(e){return!u.noAudioDecoding&&e.substr(-4)in{".ogg":1,".wav":1,".mp3":1}}}).handle=function(t,r,n,e){var o=!1;function a(e){o||(o=!0,Er[r]=e,n?.(t))}var s=new Blob([t],{type:v.getMimetype(r)}),s=URL.createObjectURL(s),i=new Audio;i.addEventListener("canplaythrough",()=>a(i),!1),i.onerror=function(e){o||(l(`warning: browser could not fully decode audio ${r}, trying slower base64 approach`),i.src="data:audio/x-"+r.substr(-3)+";base64,"+function(e){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r="",n=0,o=0,a=0;a<e.length;a++)for(n=n<<8|e[a],o+=8;6<=o;){var s=n>>o-6&63;o-=6,r+=t[s]}return 2==o?r=r+t[(3&n)<<4]+"==":4==o&&(r=r+t[(15&n)<<2]+"="),r}(t),a(i))},i.src=s,Se(()=>{a(i)},1e4)},Me.push(e),(e=u.canvas)&&(e.requestPointerLock=e.requestPointerLock||e.mozRequestPointerLock||e.webkitRequestPointerLock||e.msRequestPointerLock||(()=>{}),e.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||(()=>{}),e.exitPointerLock=e.exitPointerLock.bind(document),document.addEventListener("pointerlockchange",t,!1),document.addEventListener("mozpointerlockchange",t,!1),document.addEventListener("webkitpointerlockchange",t,!1),document.addEventListener("mspointerlockchange",t,!1),u.elementPointerLock)&&e.addEventListener("click",e=>{!v.pointerLock&&u.canvas.requestPointerLock&&(u.canvas.requestPointerLock(),e.preventDefault())},!1))},createContext(e,t,r,n){if(t&&u.ctx&&e==u.canvas)return u.ctx;var o,a;if(t){var s={antialias:!1,alpha:!1,majorVersion:1};if(n)for(var i in n)s[i]=n[i];"undefined"!=typeof GL&&(a=GL.createContext(e,s))&&(o=GL.getContext(a).GLctx)}else o=e.getContext("2d");return o?(r&&(u.ctx=o,t&&GL.makeContextCurrent(a),u.useWebGL=t,v.moduleContextCreatedCallbacks.forEach(e=>e()),v.init()),o):null},destroyContext(e,t,r){},fullscreenHandlersInstalled:!1,lockPointer:void 0,resizeCanvas:void 0,requestFullscreen(e,t){v.lockPointer=e,v.resizeCanvas=t,void 0===v.lockPointer&&(v.lockPointer=!0),void 0===v.resizeCanvas&&(v.resizeCanvas=!1);var r=u.canvas;function n(){v.isFullscreen=!1;var e=r.parentNode;(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===e?(r.exitFullscreen=v.exitFullscreen,v.lockPointer&&r.requestPointerLock(),v.isFullscreen=!0,v.resizeCanvas?v.setFullscreenCanvasSize():v.updateCanvasDimensions(r)):(e.parentNode.insertBefore(r,e),e.parentNode.removeChild(e),v.resizeCanvas?v.setWindowedCanvasSize():v.updateCanvasDimensions(r)),u.onFullScreen?.(v.isFullscreen),u.onFullscreen?.(v.isFullscreen)}v.fullscreenHandlersInstalled||(v.fullscreenHandlersInstalled=!0,document.addEventListener("fullscreenchange",n,!1),document.addEventListener("mozfullscreenchange",n,!1),document.addEventListener("webkitfullscreenchange",n,!1),document.addEventListener("MSFullscreenChange",n,!1));var o=document.createElement("div");r.parentNode.insertBefore(o,r),o.appendChild(r),o.requestFullscreen=o.requestFullscreen||o.mozRequestFullScreen||o.msRequestFullscreen||(o.webkitRequestFullscreen?()=>o.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT):null)||(o.webkitRequestFullScreen?()=>o.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT):null),o.requestFullscreen()},exitFullscreen(){return!!v.isFullscreen&&((document.exitFullscreen||document.cancelFullScreen||document.mozCancelFullScreen||document.msExitFullscreen||document.webkitCancelFullScreen||(()=>{})).apply(document,[]),!0)},nextRAF:0,fakeRequestAnimationFrame(e){var t=Date.now();if(0===v.nextRAF)v.nextRAF=t+1e3/60;else for(;t+2>=v.nextRAF;)v.nextRAF+=1e3/60;var r=Math.max(v.nextRAF-t,0);setTimeout(e,r)},requestAnimationFrame(e){("function"==typeof requestAnimationFrame?requestAnimationFrame:v.fakeRequestAnimationFrame)(e)},safeSetTimeout(e,t){return Se(e,t)},safeRequestAnimationFrame(e){return v.requestAnimationFrame(()=>{Pe(e)})},getMimetype(e){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[e.substr(e.lastIndexOf(".")+1)]},getUserMedia(e){window.getUserMedia||=navigator.getUserMedia||navigator.mozGetUserMedia,window.getUserMedia(e)},getMovementX(e){return e.movementX||e.mozMovementX||e.webkitMovementX||0},getMovementY(e){return e.movementY||e.mozMovementY||e.webkitMovementY||0},getMouseWheelDelta(e){var t=0;switch(e.type){case"DOMMouseScroll":t=e.detail/3;break;case"mousewheel":t=e.wheelDelta/120;break;case"wheel":switch(t=e.deltaY,e.deltaMode){case 0:t/=100;break;case 1:t/=3;break;case 2:t*=80;break;default:throw"unrecognized mouse wheel delta mode: "+e.deltaMode}break;default:throw"unrecognized mouse wheel event: "+e.type}return t},mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,touches:{},lastTouches:{},calculateMouseCoords(e,t){var r=u.canvas.getBoundingClientRect(),n=u.canvas.width,o=u.canvas.height,a=void 0!==window.scrollX?window.scrollX:window.pageXOffset,s=void 0!==window.scrollY?window.scrollY:window.pageYOffset,e=e-(a+r.left),a=t-(s+r.top);return{x:e*=n/r.width,y:a*=o/r.height}},setMouseCoords(e,t){var{x:e,y:t}=v.calculateMouseCoords(e,t);v.mouseMovementX=e-v.mouseX,v.mouseMovementY=t-v.mouseY,v.mouseX=e,v.mouseY=t},calculateMouseEvent(e){if(v.pointerLock)"mousemove"!=e.type&&"mozMovementX"in e?v.mouseMovementX=v.mouseMovementY=0:(v.mouseMovementX=v.getMovementX(e),v.mouseMovementY=v.getMovementY(e)),v.mouseX+=v.mouseMovementX,v.mouseY+=v.mouseMovementY;else{var t,r,n;if("touchstart"===e.type||"touchend"===e.type||"touchmove"===e.type)return void 0===(t=e.touch)?void 0:(r=v.calculateMouseCoords(t.pageX,t.pageY),void("touchstart"===e.type?(v.lastTouches[t.identifier]=r,v.touches[t.identifier]=r):"touchend"!==e.type&&"touchmove"!==e.type||(n=v.touches[t.identifier],v.lastTouches[t.identifier]=n||=r,v.touches[t.identifier]=r)));v.setMouseCoords(e.pageX,e.pageY)}},resizeListeners:[],updateResizeListeners(){var t=u.canvas;v.resizeListeners.forEach(e=>e(t.width,t.height))},setCanvasSize(e,t,r){var n=u.canvas;v.updateCanvasDimensions(n,e,t),r||v.updateResizeListeners()},windowedWidth:0,windowedHeight:0,setFullscreenCanvasSize(){var e;"undefined"!=typeof SDL&&(e=y[SDL.screen>>2],w[SDL.screen>>2]=e|=8388608),v.updateCanvasDimensions(u.canvas),v.updateResizeListeners()},setWindowedCanvasSize(){var e;"undefined"!=typeof SDL&&(e=y[SDL.screen>>2],w[SDL.screen>>2]=e&=-8388609),v.updateCanvasDimensions(u.canvas),v.updateResizeListeners()},updateCanvasDimensions(e,t,r){t&&r?(e.widthNative=t,e.heightNative=r):(t=e.widthNative,r=e.heightNative);var n,o=t,a=r;u.forcedAspectRatio&&0<u.forcedAspectRatio&&(o/a<u.forcedAspectRatio?o=Math.round(a*u.forcedAspectRatio):a=Math.round(o/u.forcedAspectRatio)),(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===e.parentNode&&"undefined"!=typeof screen&&(n=Math.min(screen.width/o,screen.height/a),o=Math.round(o*n),a=Math.round(a*n)),v.resizeCanvas?(e.width!=o&&(e.width=o),e.height!=a&&(e.height=a),void 0!==e.style&&(e.style.removeProperty("width"),e.style.removeProperty("height"))):(e.width!=t&&(e.width=t),e.height!=r&&(e.height=r),void 0!==e.style&&(o!=t||a!=r?(e.style.setProperty("width",o+"px","important"),e.style.setProperty("height",a+"px","important")):(e.style.removeProperty("width"),e.style.removeProperty("height"))))}},Te=e=>{for(;0<e.length;)e.shift()(u)},Le=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n<=127?t++:n<=2047?t+=2:55296<=n&&n<=57343?(t+=4,++r):t+=3}return t},$e=(e,t,r,n)=>{if(!(0<n))return 0;for(var o=r,a=r+n-1,s=0;s<e.length;++s){var i=e.charCodeAt(s);if((i=55296<=i&&i<=57343?65536+((1023&i)<<10)|1023&e.charCodeAt(++s):i)<=127){if(a<=r)break;t[r++]=i}else{if(i<=2047){if(a<=r+1)break;t[r++]=192|i>>6}else{if(i<=65535){if(a<=r+2)break;t[r++]=224|i>>12}else{if(a<=r+3)break;t[r++]=240|i>>18,t[r++]=128|i>>12&63}t[r++]=128|i>>6&63}t[r++]=128|63&i}}return t[r]=0,r-o},De=(e,t,r)=>$e(e,d,t,r),Ae="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,a=(e,t,r)=>{for(var n=t+r,o=t;e[o]&&!(n<=o);)++o;if(16<o-t&&e.buffer&&Ae)return Ae.decode(e.subarray(t,o));for(var a="";t<o;){var s,i,u=e[t++];128&u?(i=63&e[t++],192==(224&u)?a+=String.fromCharCode((31&u)<<6|i):(s=63&e[t++],(u=224==(240&u)?(15&u)<<12|i<<6|s:(7&u)<<18|i<<12|s<<6|63&e[t++])<65536?a+=String.fromCharCode(u):(i=u-65536,a+=String.fromCharCode(55296|i>>10,56320|1023&i)))):a+=String.fromCharCode(u)}return a},xe=(e,t)=>e?a(d,e,t):"",Re=u.noExitRuntime||!0;class je{constructor(e){this.excPtr=e,this.ptr=e-24}set_type(e){y[this.ptr+4>>2]=e}get_type(){return y[this.ptr+4>>2]}set_destructor(e){y[this.ptr+8>>2]=e}get_destructor(){return y[this.ptr+8>>2]}set_caught(e){h[this.ptr+12]=e=e?1:0}get_caught(){return 0!=h[this.ptr+12]}set_rethrown(e){h[this.ptr+13]=e=e?1:0}get_rethrown(){return 0!=h[this.ptr+13]}init(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)}set_adjusted_ptr(e){y[this.ptr+16>>2]=e}get_adjusted_ptr(){return y[this.ptr+16>>2]}get_exception_ptr(){var e;return Mr(this.get_type())?y[this.excPtr>>2]:0!==(e=this.get_adjusted_ptr())?e:this.excPtr}}function ze(){var e=w[+b.varargs>>2];return b.varargs+=4,e}var f=ze,E={isAbs:e=>"/"===e.charAt(0),splitPath:e=>{return/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1)},normalizeArray:(e,t)=>{for(var r=0,n=e.length-1;0<=n;n--){var o=e[n];"."===o?e.splice(n,1):".."===o?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r;r--)e.unshift("..");return e},normalize:e=>{var t=E.isAbs(e),r="/"===e.substr(-1);return(e=(e=E.normalizeArray(e.split("/").filter(e=>!!e),!t).join("/"))||t?e:".")&&r&&(e+="/"),(t?"/":"")+e},dirname:e=>{var e=E.splitPath(e),t=e[0],e=e[1];return t||e?t+(e=e&&e.substr(0,e.length-1)):"."},basename:e=>{var t;return"/"===e?"/":-1===(t=(e=(e=E.normalize(e)).replace(/\/$/,"")).lastIndexOf("/"))?e:e.substr(t+1)},join:(...e)=>E.normalize(e.join("/")),join2:(e,t)=>E.normalize(e+"/"+t)},Oe=()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>crypto.getRandomValues(e);if(q)try{var t,r=require("crypto");return r.randomFillSync?e=>r.randomFillSync(e):(t=r.randomBytes,e=>(e.set(t(e.byteLength)),e))}catch(e){}me("initRandomDevice")},Ve=e=>(Ve=Oe())(e),_={resolve:(...e)=>{for(var t="",r=!1,n=e.length-1;-1<=n&&!r;n--){var o=0<=n?e[n]:g.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");if(!o)return"";t=o+"/"+t,r=E.isAbs(o)}return(r?"/":"")+(t=E.normalizeArray(t.split("/").filter(e=>!!e),!r).join("/"))||"."},relative:(e,t)=>{function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;0<=r&&""===e[r];r--);return r<t?[]:e.slice(t,r-t+1)}e=_.resolve(e).substr(1),t=_.resolve(t).substr(1);for(var n=r(e.split("/")),o=r(t.split("/")),a=Math.min(n.length,o.length),s=a,i=0;i<a;i++)if(n[i]!==o[i]){s=i;break}for(var u=[],i=s;i<n.length;i++)u.push("..");return(u=u.concat(o.slice(s))).join("/")}},Ie=[];function Ue(e,t,r){r=0<r?r:Le(e)+1,r=new Array(r),e=$e(e,r,0,r.length);return t&&(r.length=e),r}var n={ttys:[],init(){},shutdown(){},register(e,t){n.ttys[e]={input:[],output:[],ops:t},g.registerDevice(e,n.stream_ops)},stream_ops:{open(e){var t=n.ttys[e.node.rdev];if(!t)throw new g.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,o){if(!e.tty||!e.tty.ops.get_char)throw new g.ErrnoError(60);for(var a,s=0,i=0;i<n;i++){try{a=e.tty.ops.get_char(e.tty)}catch(e){throw new g.ErrnoError(29)}if(void 0===a&&0===s)throw new g.ErrnoError(6);if(null==a)break;s++,t[r+i]=a}return s&&(e.node.timestamp=Date.now()),s},write(e,t,r,n,o){if(!e.tty||!e.tty.ops.put_char)throw new g.ErrnoError(60);try{for(var a=0;a<n;a++)e.tty.ops.put_char(e.tty,t[r+a])}catch(e){throw new g.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),a}},default_tty_ops:{get_char(e){if(!Ie.length){var t=null;if(q){var r=Buffer.alloc(256),n=0,o=process.stdin.fd;try{n=V.readSync(o,r,0,256)}catch(e){if(!e.toString().includes("EOF"))throw e;n=0}0<n&&(t=r.slice(0,n).toString("utf-8"))}else"undefined"!=typeof window&&"function"==typeof window.prompt&&null!==(t=window.prompt("Input: "))&&(t+="\n");if(!t)return null;Ie=Ue(t,!0)}return Ie.shift()},put_char(e,t){null===t||10===t?(te(a(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync(e){e.output&&0<e.output.length&&(te(a(e.output,0)),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){null===t||10===t?(l(a(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync(e){e.output&&0<e.output.length&&(l(a(e.output,0)),e.output=[])}}},We=e=>{me()},m={ops_table:null,mount(e){return m.createNode(null,"/",16895,0)},createNode(e,t,r,n){if(g.isBlkdev(r)||g.isFIFO(r))throw new g.ErrnoError(63);m.ops_table||={dir:{node:{getattr:m.node_ops.getattr,setattr:m.node_ops.setattr,lookup:m.node_ops.lookup,mknod:m.node_ops.mknod,rename:m.node_ops.rename,unlink:m.node_ops.unlink,rmdir:m.node_ops.rmdir,readdir:m.node_ops.readdir,symlink:m.node_ops.symlink},stream:{llseek:m.stream_ops.llseek}},file:{node:{getattr:m.node_ops.getattr,setattr:m.node_ops.setattr},stream:{llseek:m.stream_ops.llseek,read:m.stream_ops.read,write:m.stream_ops.write,allocate:m.stream_ops.allocate,mmap:m.stream_ops.mmap,msync:m.stream_ops.msync}},link:{node:{getattr:m.node_ops.getattr,setattr:m.node_ops.setattr,readlink:m.node_ops.readlink},stream:{}},chrdev:{node:{getattr:m.node_ops.getattr,setattr:m.node_ops.setattr},stream:g.chrdev_stream_ops}};r=g.createNode(e,t,r,n);return g.isDir(r.mode)?(r.node_ops=m.ops_table.dir.node,r.stream_ops=m.ops_table.dir.stream,r.contents={}):g.isFile(r.mode)?(r.node_ops=m.ops_table.file.node,r.stream_ops=m.ops_table.file.stream,r.usedBytes=0,r.contents=null):g.isLink(r.mode)?(r.node_ops=m.ops_table.link.node,r.stream_ops=m.ops_table.link.stream):g.isChrdev(r.mode)&&(r.node_ops=m.ops_table.chrdev.node,r.stream_ops=m.ops_table.chrdev.stream),r.timestamp=Date.now(),e&&(e.contents[t]=r,e.timestamp=r.timestamp),r},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;t<=r||(t=Math.max(t,r*(r<1048576?2:1.125)>>>0),0!=r&&(t=Math.max(t,256)),r=e.contents,e.contents=new Uint8Array(t),0<e.usedBytes&&e.contents.set(r.subarray(0,e.usedBytes),0))},resizeFileStorage(e,t){var r;e.usedBytes!=t&&(0==t?(e.contents=null,e.usedBytes=0):(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=g.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,g.isDir(e.mode)?t.size=4096:g.isFile(e.mode)?t.size=e.usedBytes:g.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){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&m.resizeFileStorage(e,t.size)},lookup(e,t){throw g.genericErrors[44]},mknod(e,t,r,n){return m.createNode(e,t,r,n)},rename(e,t,r){if(g.isDir(e.mode)){var n;try{n=g.lookupNode(t,r)}catch(e){}if(n)for(var o in n.contents)throw new g.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){for(var r in g.lookupNode(e,t).contents)throw new g.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir(e){var t,r=[".",".."];for(t of Object.keys(e.contents))r.push(t);return r},symlink(e,t,r){e=m.createNode(e,t,41471,0);return e.link=r,e},readlink(e){if(g.isLink(e.mode))return e.link;throw new g.ErrnoError(28)}},stream_ops:{read(e,t,r,n,o){var a=e.node.contents;if(o>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-o,n);if(8<s&&a.subarray)t.set(a.subarray(o,o+s),r);else for(var i=0;i<s;i++)t[r+i]=a[o+i];return s},write(e,t,r,n,o,a){if(t.buffer===h.buffer&&(a=!1),!n)return 0;var s=e.node;if(s.timestamp=Date.now(),t.subarray&&(!s.contents||s.contents.subarray)){if(a)return s.contents=t.subarray(r,r+n),s.usedBytes=n;if(0===s.usedBytes&&0===o)return s.contents=t.slice(r,r+n),s.usedBytes=n;if(o+n<=s.usedBytes)return s.contents.set(t.subarray(r,r+n),o),n}if(m.expandFileStorage(s,o+n),s.contents.subarray&&t.subarray)s.contents.set(t.subarray(r,r+n),o);else for(var i=0;i<n;i++)s.contents[o+i]=t[r+i];return s.usedBytes=Math.max(s.usedBytes,o+n),n},llseek(e,t,r){if(1===r?t+=e.position:2===r&&g.isFile(e.node.mode)&&(t+=e.node.usedBytes),t<0)throw new g.ErrnoError(28);return t},allocate(e,t,r){m.expandFileStorage(e.node,t+r),e.node.usedBytes=Math.max(e.node.usedBytes,t+r)},mmap(e,t,r,n,o){if(!g.isFile(e.node.mode))throw new g.ErrnoError(43);var a,s,e=e.node.contents;if(2&o||e.buffer!==h.buffer){if((0<r||r+t<e.length)&&(e=e.subarray?e.subarray(r,r+t):Array.prototype.slice.call(e,r,r+t)),s=!0,!(a=We()))throw new g.ErrnoError(48);h.set(e,a)}else s=!1,a=e.byteOffset;return{ptr:a,allocated:s}},msync(e,t,r,n,o){return m.stream_ops.write(e,t,0,n,r,!1),0}}},Ne=(e,t,r,n,o,a)=>{g.createDataFile(e,t,r,n,o,a)},e=(i,u,e,l,d,c,m,h,p,f)=>{var t,r,n,o,a,g=u?_.resolve(E.join2(i,u)):i;function s(e){function t(e){f?.(),h||Ne(i,u,e,l,d,p),c?.(),ce()}var r,n,o,a,s;r=e,n=g,o=t,a=()=>{m?.(),ce()},void 0!==v&&v.init(),s=!1,Me.forEach(e=>{s||e.canHandle(n)&&(e.handle(r,n,o,a),s=!0)}),s||t(e)}de(),"string"==typeof e?(t=e,r=s,n=m,a=o?"":"al "+t,N(t,e=>{r(new Uint8Array(e)),a&&ce()},e=>{if(!n)throw`Loading data file "${t}" failed.`;n()}),a&&de()):s(e)},Be=(e,t)=>{var r=0;return e&&(r|=365),t&&(r|=146),r},g={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:class{constructor(e){this.name="ErrnoError",this.errno=e}},genericErrors:{},filesystems:null,syncFSRequests:0,FSStream:class{constructor(){this.shared={}}get object(){return this.node}set object(e){this.node=e}get isRead(){return 1!=(2097155&this.flags)}get isWrite(){return 0!=(2097155&this.flags)}get isAppend(){return 1024&this.flags}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){this.parent=e=e||this,this.mount=e.mount,this.mounted=null,this.id=g.nextInode++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=n,this.readMode=365,this.writeMode=146}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 g.isDir(this.mode)}get isDevice(){return g.isChrdev(this.mode)}},lookupPath(e,t={}){if(!(e=_.resolve(e)))return{path:"",node:null};if(8<(t=Object.assign({follow_mount:!0,recurse_count:0},t)).recurse_count)throw new g.ErrnoError(32);for(var r=e.split("/").filter(e=>!!e),n=g.root,o="/",a=0;a<r.length;a++){var s=a===r.length-1;if(s&&t.parent)break;if(n=g.lookupNode(n,r[a]),o=E.join2(o,r[a]),!g.isMountpoint(n)||s&&!t.follow_mount||(n=n.mounted.root),!s||t.follow)for(var i=0;g.isLink(n.mode);){var u=g.readlink(o),o=_.resolve(E.dirname(o),u),n=g.lookupPath(o,{recurse_count:t.recurse_count+1}).node;if(40<i++)throw new g.ErrnoError(32)}}return{path:o,node:n}},getPath(e){for(var t,r;;){if(g.isRoot(e))return r=e.mount.mountpoint,t?"/"!==r[r.length-1]?r+"/"+t:r+t:r;t=t?e.name+"/"+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)%g.nameTable.length},hashAddNode(e){var t=g.hashName(e.parent.id,e.name);e.name_next=g.nameTable[t],g.nameTable[t]=e},hashRemoveNode(e){var t=g.hashName(e.parent.id,e.name);if(g.nameTable[t]===e)g.nameTable[t]=e.name_next;else for(var r=g.nameTable[t];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode(e,t){var r=g.mayLookup(e);if(r)throw new g.ErrnoError(r);for(var r=g.hashName(e.id,t),n=g.nameTable[r];n;n=n.name_next){var o=n.name;if(n.parent.id===e.id&&o===t)return n}return g.lookup(e,t)},createNode(e,t,r,n){e=new g.FSNode(e,t,r,n);return g.hashAddNode(e),e},destroyNode(e){g.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return 32768==(61440&e)},isDir(e){return 16384==(61440&e)},isLink(e){return 40960==(61440&e)},isChrdev(e){return 8192==(61440&e)},isBlkdev(e){return 24576==(61440&e)},isFIFO(e){return 4096==(61440&e)},isSocket(e){return 49152==(49152&e)},flagsToPermissionString(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions(e,t){return g.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2},mayLookup(e){return g.isDir(e.mode)?g.nodePermissions(e,"x")||(e.node_ops.lookup?0:2):54},mayCreate(e,t){try{g.lookupNode(e,t);return 20}catch(e){}return g.nodePermissions(e,"wx")},mayDelete(e,t,r){var n;try{n=g.lookupNode(e,t)}catch(e){return e.errno}t=g.nodePermissions(e,"wx");if(t)return t;if(r){if(!g.isDir(n.mode))return 54;if(g.isRoot(n)||g.getPath(n)===g.cwd())return 10}else if(g.isDir(n.mode))return 31;return 0},mayOpen(e,t){return e?g.isLink(e.mode)?32:g.isDir(e.mode)&&("r"!==g.flagsToPermissionString(t)||512&t)?31:g.nodePermissions(e,g.flagsToPermissionString(t)):44},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=g.MAX_OPEN_FDS;e++)if(!g.streams[e])return e;throw new g.ErrnoError(33)},getStreamChecked(e){e=g.getStream(e);if(e)return e;throw new g.ErrnoError(8)},getStream:e=>g.streams[e],createStream(e,t=-1){return e=Object.assign(new g.FSStream,e),-1==t&&(t=g.nextfd()),e.fd=t,g.streams[t]=e},closeStream(e){g.streams[e]=null},dupStream(e,t=-1){e=g.createStream(e,t);return e.stream_ops?.dup?.(e),e},chrdev_stream_ops:{open(e){var t=g.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new g.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,t)=>e<<8|t,registerDevice(e,t){g.devices[e]={stream_ops:t}},getDevice:e=>g.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(t,r){"function"==typeof t&&(r=t,t=!1),g.syncFSRequests++,1<g.syncFSRequests&&l(`warning: ${g.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var n=g.getMounts(g.root.mount),o=0;function a(e){return g.syncFSRequests--,r(e)}function s(e){if(e)return s.errored?void 0:(s.errored=!0,a(e));++o>=n.length&&a(null)}n.forEach(e=>{if(!e.type.syncfs)return s(null);e.type.syncfs(e,t,s)})},mount(e,t,r){var n,o="/"===r,a=!r;if(o&&g.root)throw new g.ErrnoError(10);if(!o&&!a){a=g.lookupPath(r,{follow_mount:!1});if(r=a.path,n=a.node,g.isMountpoint(n))throw new g.ErrnoError(10);if(!g.isDir(n.mode))throw new g.ErrnoError(54)}a={type:e,opts:t,mountpoint:r,mounts:[]},t=e.mount(a);return(t.mount=a).root=t,o?g.root=t:n&&(n.mounted=a,n.mount)&&n.mount.mounts.push(a),t},unmount(e){e=g.lookupPath(e,{follow_mount:!1});if(!g.isMountpoint(e.node))throw new g.ErrnoError(28);var e=e.node,t=e.mounted,n=g.getMounts(t),t=(Object.keys(g.nameTable).forEach(e=>{for(var t=g.nameTable[e];t;){var r=t.name_next;n.includes(t.mount)&&g.destroyNode(t),t=r}}),e.mounted=null,e.mount.mounts.indexOf(t));e.mount.mounts.splice(t,1)},lookup(e,t){return e.node_ops.lookup(e,t)},mknod(e,t,r){var n=g.lookupPath(e,{parent:!0}).node,e=E.basename(e);if(!e||"."===e||".."===e)throw new g.ErrnoError(28);var o=g.mayCreate(n,e);if(o)throw new g.ErrnoError(o);if(n.node_ops.mknod)return n.node_ops.mknod(n,e,t,r);throw new g.ErrnoError(63)},create(e,t){return g.mknod(e,t=(t=void 0!==t?t:438)&4095|32768,0)},mkdir(e,t){return g.mknod(e,t=(t=void 0!==t?t:511)&1023|16384,0)},mkdirTree(e,t){for(var r=e.split("/"),n="",o=0;o<r.length;++o)if(r[o]){n+="/"+r[o];try{g.mkdir(n,t)}catch(e){if(20!=e.errno)throw e}}},mkdev(e,t,r){return void 0===r&&(r=t,t=438),g.mknod(e,t|=8192,r)},symlink(e,t){if(!_.resolve(e))throw new g.ErrnoError(44);var r=g.lookupPath(t,{parent:!0}).node;if(!r)throw new g.ErrnoError(44);var t=E.basename(t),n=g.mayCreate(r,t);if(n)throw new g.ErrnoError(n);if(r.node_ops.symlink)return r.node_ops.symlink(r,t,e);throw new g.ErrnoError(63)},rename(e,t){var r=E.dirname(e),n=E.dirname(t),o=E.basename(e),a=E.basename(t),s=g.lookupPath(e,{parent:!0}),s=s.node,i=g.lookupPath(t,{parent:!0}).node;if(!s||!i)throw new g.ErrnoError(44);if(s.mount!==i.mount)throw new g.ErrnoError(75);var u,l=g.lookupNode(s,o),e=_.relative(e,n);if("."!==e.charAt(0))throw new g.ErrnoError(28);if("."!==(e=_.relative(t,r)).charAt(0))throw new g.ErrnoError(55);try{u=g.lookupNode(i,a)}catch(e){}if(l!==u){n=g.isDir(l.mode),t=g.mayDelete(s,o,n);if(t)throw new g.ErrnoError(t);if(t=u?g.mayDelete(i,a,n):g.mayCreate(i,a))throw new g.ErrnoError(t);if(!s.node_ops.rename)throw new g.ErrnoError(63);if(g.isMountpoint(l)||u&&g.isMountpoint(u))throw new g.ErrnoError(10);if(i!==s&&(t=g.nodePermissions(s,"w")))throw new g.ErrnoError(t);g.hashRemoveNode(l);try{s.node_ops.rename(l,i,a),l.parent=i}catch(e){throw e}finally{g.hashAddNode(l)}}},rmdir(e){var t=g.lookupPath(e,{parent:!0}).node,e=E.basename(e),r=g.lookupNode(t,e),n=g.mayDelete(t,e,!0);if(n)throw new g.ErrnoError(n);if(!t.node_ops.rmdir)throw new g.ErrnoError(63);if(g.isMountpoint(r))throw new g.ErrnoError(10);t.node_ops.rmdir(t,e),g.destroyNode(r)},readdir(e){e=g.lookupPath(e,{follow:!0}).node;if(e.node_ops.readdir)return e.node_ops.readdir(e);throw new g.ErrnoError(54)},unlink(e){var t=g.lookupPath(e,{parent:!0}).node;if(!t)throw new g.ErrnoError(44);var e=E.basename(e),r=g.lookupNode(t,e),n=g.mayDelete(t,e,!1);if(n)throw new g.ErrnoError(n);if(!t.node_ops.unlink)throw new g.ErrnoError(63);if(g.isMountpoint(r))throw new g.ErrnoError(10);t.node_ops.unlink(t,e),g.destroyNode(r)},readlink(e){e=g.lookupPath(e).node;if(!e)throw new g.ErrnoError(44);if(e.node_ops.readlink)return _.resolve(g.getPath(e.parent),e.node_ops.readlink(e));throw new g.ErrnoError(28)},stat(e,t){e=g.lookupPath(e,{follow:!t}).node;if(!e)throw new g.ErrnoError(44);if(e.node_ops.getattr)return e.node_ops.getattr(e);throw new g.ErrnoError(63)},lstat(e){return g.stat(e,!0)},chmod(e,t,r){if(!(r="string"==typeof e?g.lookupPath(e,{follow:!r}).node:e).node_ops.setattr)throw new g.ErrnoError(63);r.node_ops.setattr(r,{mode:4095&t|-4096&r.mode,timestamp:Date.now()})},lchmod(e,t){g.chmod(e,t,!0)},fchmod(e,t){e=g.getStreamChecked(e);g.chmod(e.node,t)},chown(e,t,r,n){if(!(n="string"==typeof e?g.lookupPath(e,{follow:!n}).node:e).node_ops.setattr)throw new g.ErrnoError(63);n.node_ops.setattr(n,{timestamp:Date.now()})},lchown(e,t,r){g.chown(e,t,r,!0)},fchown(e,t,r){e=g.getStreamChecked(e);g.chown(e.node,t,r)},truncate(e,t){if(t<0)throw new g.ErrnoError(28);if(!(e="string"==typeof e?g.lookupPath(e,{follow:!0}).node:e).node_ops.setattr)throw new g.ErrnoError(63);if(g.isDir(e.mode))throw new g.ErrnoError(31);if(!g.isFile(e.mode))throw new g.ErrnoError(28);var r=g.nodePermissions(e,"w");if(r)throw new g.ErrnoError(r);e.node_ops.setattr(e,{size:t,timestamp:Date.now()})},ftruncate(e,t){e=g.getStreamChecked(e);if(0==(2097155&e.flags))throw new g.ErrnoError(28);g.truncate(e.node,t)},utime(e,t,r){e=g.lookupPath(e,{follow:!0}).node;e.node_ops.setattr(e,{timestamp:Math.max(t,r)})},open(e,t,r){if(""===e)throw new g.ErrnoError(44);if(r=64&(t="string"==typeof t?(e=>{var t={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(void 0===t)throw new Error("Unknown file open mode: "+e);return t})(t):t)?4095&(r=void 0===r?438:r)|32768:0,"object"==typeof e)n=e;else{e=E.normalize(e);try{var n=g.lookupPath(e,{follow:!(131072&t)}).node}catch(e){}}var o=!1;if(64&t)if(n){if(128&t)throw new g.ErrnoError(20)}else n=g.mknod(e,r,0),o=!0;if(!n)throw new g.ErrnoError(44);if(g.isChrdev(n.mode)&&(t&=-513),65536&t&&!g.isDir(n.mode))throw new g.ErrnoError(54);if(!o){r=g.mayOpen(n,t);if(r)throw new g.ErrnoError(r)}512&t&&!o&&g.truncate(n,0),t&=-131713;r=g.createStream({node:n,path:g.getPath(n),flags:t,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return r.stream_ops.open&&r.stream_ops.open(r),!u.logReadFiles||1&t||(g.readFiles||(g.readFiles={}),e in g.readFiles)||(g.readFiles[e]=1),r},close(e){if(g.isClosed(e))throw new g.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{g.closeStream(e.fd)}e.fd=null},isClosed(e){return null===e.fd},llseek(e,t,r){if(g.isClosed(e))throw new g.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new g.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new g.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.ungotten=[],e.position},read(e,t,r,n,o){if(n<0||o<0)throw new g.ErrnoError(28);if(g.isClosed(e))throw new g.ErrnoError(8);if(1==(2097155&e.flags))throw new g.ErrnoError(8);if(g.isDir(e.node.mode))throw new g.ErrnoError(31);if(!e.stream_ops.read)throw new g.ErrnoError(28);var a=void 0!==o;if(a){if(!e.seekable)throw new g.ErrnoError(70)}else o=e.position;t=e.stream_ops.read(e,t,r,n,o);return a||(e.position+=t),t},write(e,t,r,n,o,a){if(n<0||o<0)throw new g.ErrnoError(28);if(g.isClosed(e))throw new g.ErrnoError(8);if(0==(2097155&e.flags))throw new g.ErrnoError(8);if(g.isDir(e.node.mode))throw new g.ErrnoError(31);if(!e.stream_ops.write)throw new g.ErrnoError(28);e.seekable&&1024&e.flags&&g.llseek(e,0,2);var s=void 0!==o;if(s){if(!e.seekable)throw new g.ErrnoError(70)}else o=e.position;t=e.stream_ops.write(e,t,r,n,o,a);return s||(e.position+=t),t},allocate(e,t,r){if(g.isClosed(e))throw new g.ErrnoError(8);if(t<0||r<=0)throw new g.ErrnoError(28);if(0==(2097155&e.flags))throw new g.ErrnoError(8);if(!g.isFile(e.node.mode)&&!g.isDir(e.node.mode))throw new g.ErrnoError(43);if(!e.stream_ops.allocate)throw new g.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap(e,t,r,n,o){if(0!=(2&n)&&0==(2&o)&&2!=(2097155&e.flags))throw new g.ErrnoError(2);if(1==(2097155&e.flags))throw new g.ErrnoError(2);if(e.stream_ops.mmap)return e.stream_ops.mmap(e,t,r,n,o);throw new g.ErrnoError(43)},msync(e,t,r,n,o){return e.stream_ops.msync?e.stream_ops.msync(e,t,r,n,o):0},ioctl(e,t,r){if(e.stream_ops.ioctl)return e.stream_ops.ioctl(e,t,r);throw new g.ErrnoError(59)},readFile(e,t={}){if(t.flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw new Error(`Invalid encoding type "${t.encoding}"`);var r,n=g.open(e,t.flags),e=g.stat(e).size,o=new Uint8Array(e);return g.read(n,o,0,e,0),"utf8"===t.encoding?r=a(o,0):"binary"===t.encoding&&(r=o),g.close(n),r},writeFile(e,t,r={}){r.flags=r.flags||577;e=g.open(e,r.flags,r.mode);if("string"==typeof t){var n=new Uint8Array(Le(t)+1),o=$e(t,n,0,n.length);g.write(e,n,0,o,void 0,r.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");g.write(e,t,0,t.byteLength,void 0,r.canOwn)}g.close(e)},cwd:()=>g.currentPath,chdir(e){e=g.lookupPath(e,{follow:!0});if(null===e.node)throw new g.ErrnoError(44);if(!g.isDir(e.node.mode))throw new g.ErrnoError(54);var t=g.nodePermissions(e.node,"x");if(t)throw new g.ErrnoError(t);g.currentPath=e.path},createDefaultDirectories(){g.mkdir("/tmp"),g.mkdir("/home"),g.mkdir("/home/web_user")},createDefaultDevices(){g.mkdir("/dev"),g.registerDevice(g.makedev(1,3),{read:()=>0,write:(e,t,r,n,o)=>n}),g.mkdev("/dev/null",g.makedev(1,3)),n.register(g.makedev(5,0),n.default_tty_ops),n.register(g.makedev(6,0),n.default_tty1_ops),g.mkdev("/dev/tty",g.makedev(5,0)),g.mkdev("/dev/tty1",g.makedev(6,0));var e=new Uint8Array(1024),t=0,r=()=>(0===t&&(t=Ve(e).byteLength),e[--t]);g.createDevice("/dev","random",r),g.createDevice("/dev","urandom",r),g.mkdir("/dev/shm"),g.mkdir("/dev/shm/tmp")},createSpecialDirectories(){g.mkdir("/proc");var t=g.mkdir("/proc/self");g.mkdir("/proc/self/fd"),g.mount({mount(){var e=g.createNode(t,"fd",16895,73);return e.node_ops={lookup(e,t){var r=g.getStreamChecked(+t),t={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>r.path}};return t.parent=t}},e}},{},"/proc/self/fd")},createStandardStreams(){u.stdin?g.createDevice("/dev","stdin",u.stdin):g.symlink("/dev/tty","/dev/stdin"),u.stdout?g.createDevice("/dev","stdout",null,u.stdout):g.symlink("/dev/tty","/dev/stdout"),u.stderr?g.createDevice("/dev","stderr",null,u.stderr):g.symlink("/dev/tty1","/dev/stderr");g.open("/dev/stdin",0),g.open("/dev/stdout",1),g.open("/dev/stderr",1)},staticInit(){[44].forEach(e=>{g.genericErrors[e]=new g.ErrnoError(e),g.genericErrors[e].stack="<generic error, no stack>"}),g.nameTable=new Array(4096),g.mount(m,{},"/"),g.createDefaultDirectories(),g.createDefaultDevices(),g.createSpecialDirectories(),g.filesystems={MEMFS:m}},init(e,t,r){g.init.initialized=!0,u.stdin=e||u.stdin,u.stdout=t||u.stdout,u.stderr=r||u.stderr,g.createStandardStreams()},quit(){g.init.initialized=!1;for(var e=0;e<g.streams.length;e++){var t=g.streams[e];t&&g.close(t)}},findObject(e,t){e=g.analyzePath(e,t);return e.exists?e.object:null},analyzePath(e,t){try{e=(n=g.lookupPath(e,{follow:!t})).path}catch(e){}var r={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var n=g.lookupPath(e,{parent:!0});r.parentExists=!0,r.parentPath=n.path,r.parentObject=n.node,r.name=E.basename(e),n=g.lookupPath(e,{follow:!t}),r.exists=!0,r.path=n.path,r.object=n.node,r.name=n.node.name,r.isRoot="/"===n.path}catch(e){r.error=e.errno}return r},createPath(e,t,r,n){e="string"==typeof e?e:g.getPath(e);for(var o=t.split("/").reverse();o.length;){var a=o.pop();if(a){var s=E.join2(e,a);try{g.mkdir(s)}catch(e){}e=s}}return s},createFile(e,t,r,n,o){e=E.join2("string"==typeof e?e:g.getPath(e),t),t=Be(n,o);return g.create(e,t)},createDataFile(e,t,r,n,o,a){var s=t,t=(e&&(e="string"==typeof e?e:g.getPath(e),s=t?E.join2(e,t):e),Be(n,o)),e=g.create(s,t);if(r){if("string"==typeof r){for(var i=new Array(r.length),u=0,l=r.length;u<l;++u)i[u]=r.charCodeAt(u);r=i}g.chmod(e,146|t);n=g.open(e,577);g.write(n,r,0,r.length,0,a),g.close(n),g.chmod(e,t)}},createDevice(e,t,u,s){var e=E.join2("string"==typeof e?e:g.getPath(e),t),t=Be(!!u,!!s),r=(g.createDevice.major||(g.createDevice.major=64),g.makedev(g.createDevice.major++,0));return g.registerDevice(r,{open(e){e.seekable=!1},close(e){s?.buffer?.length&&s(10)},read(e,t,r,n,o){for(var a,s=0,i=0;i<n;i++){try{a=u()}catch(e){throw new g.ErrnoError(29)}if(void 0===a&&0===s)throw new g.ErrnoError(6);if(null==a)break;s++,t[r+i]=a}return s&&(e.node.timestamp=Date.now()),s},write(e,t,r,n,o){for(var a=0;a<n;a++)try{s(t[r+a])}catch(e){throw new g.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),a}}),g.mkdev(e,t,r)},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(!U)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=Ue(U(e.url),!0),e.usedBytes=e.contents.length}catch(e){throw new g.ErrnoError(29)}},createLazyFile(e,t,s,r,n){class o{constructor(){this.lengthKnown=!1,this.chunks=[]}get(e){var t;if(!(e>this.length-1||e<0))return t=e%this.chunkSize,e=e/this.chunkSize|0,this.getter(e)[t]}setDataGetter(e){this.getter=e}cacheLength(){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 t,n=Number(e.getResponseHeader("Content-length")),r=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t,e=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t,o=1048576,a=(r||(o=n),this);a.setDataGetter(e=>{var t=e*o,r=(e+1)*o-1,r=Math.min(r,n-1);if(void 0===a.chunks[e]&&(a.chunks[e]=((e,t)=>{if(t<e)throw new Error("invalid range ("+e+", "+t+") or no bytes requested!");if(n-1<t)throw new Error("only "+n+" bytes available! programmer error!");var r=new XMLHttpRequest;if(r.open("GET",s,!1),n!==o&&r.setRequestHeader("Range","bytes="+e+"-"+t),r.responseType="arraybuffer",r.overrideMimeType&&r.overrideMimeType("text/plain; charset=x-user-defined"),r.send(null),200<=r.status&&r.status<300||304===r.status)return void 0!==r.response?new Uint8Array(r.response||[]):Ue(r.responseText||"",!0);throw new Error("Couldn't load "+s+". Status: "+r.status)})(t,r)),void 0===a.chunks[e])throw new Error("doXHR failed!");return a.chunks[e]}),!e&&n||(o=n=1,n=this.getter(0).length,o=n,te("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=n,this._chunkSize=o,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if("undefined"!=typeof XMLHttpRequest){if(!B)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var a={isDevice:!1,contents:new o}}else a={isDevice:!1,url:s};var i=g.createFile(e,t,a,r,n),u=(a.contents?i.contents=a.contents:a.url&&(i.contents=null,i.url=a.url),Object.defineProperties(i,{usedBytes:{get:function(){return this.contents.length}}}),{});function l(e,t,r,n,o){var a=e.node.contents;if(o>=a.length)return 0;var s=Math.min(a.length-o,n);if(a.slice)for(var i=0;i<s;i++)t[r+i]=a[o+i];else for(i=0;i<s;i++)t[r+i]=a.get(o+i);return s}return Object.keys(i.stream_ops).forEach(e=>{var t=i.stream_ops[e];u[e]=(...e)=>(g.forceLoadFile(i),t(...e))}),u.read=(e,t,r,n,o)=>(g.forceLoadFile(i),l(e,t,r,n,o)),u.mmap=(e,t,r,n,o)=>{g.forceLoadFile(i);We();throw new g.ErrnoError(48)},i.stream_ops=u,i}},b={DEFAULT_POLLMASK:5,calculateAt(e,t,r){if(E.isAbs(t))return t;if(e=-100===e?g.cwd():b.getStreamFromFD(e).path,0!=t.length)return E.join2(e,t);if(r)return e;throw new g.ErrnoError(44)},doStat(e,t,r){var e=e(t),t=(w[r>>2]=e.dev,w[r+4>>2]=e.mode,y[r+8>>2]=e.nlink,w[r+12>>2]=e.uid,w[r+16>>2]=e.gid,w[r+20>>2]=e.rdev,i=[e.size>>>0,(s=e.size,1<=+Math.abs(s)?0<s?+Math.floor(s/4294967296)>>>0:~~+Math.ceil((s-(~~s>>>0))/4294967296)>>>0:0)],w[r+24>>2]=i[0],w[r+28>>2]=i[1],w[r+32>>2]=4096,w[r+36>>2]=e.blocks,e.atime.getTime()),n=e.mtime.getTime(),o=e.ctime.getTime();return i=[Math.floor(t/1e3)>>>0,(s=Math.floor(t/1e3),1<=+Math.abs(s)?0<s?+Math.floor(s/4294967296)>>>0:~~+Math.ceil((s-(~~s>>>0))/4294967296)>>>0:0)],w[r+40>>2]=i[0],w[r+44>>2]=i[1],y[r+48>>2]=t%1e3*1e3,i=[Math.floor(n/1e3)>>>0,(s=Math.floor(n/1e3),1<=+Math.abs(s)?0<s?+Math.floor(s/4294967296)>>>0:~~+Math.ceil((s-(~~s>>>0))/4294967296)>>>0:0)],w[r+56>>2]=i[0],w[r+60>>2]=i[1],y[r+64>>2]=n%1e3*1e3,i=[Math.floor(o/1e3)>>>0,(s=Math.floor(o/1e3),1<=+Math.abs(s)?0<s?+Math.floor(s/4294967296)>>>0:~~+Math.ceil((s-(~~s>>>0))/4294967296)>>>0:0)],w[r+72>>2]=i[0],w[r+76>>2]=i[1],y[r+80>>2]=o%1e3*1e3,i=[e.ino>>>0,(s=e.ino,1<=+Math.abs(s)?0<s?+Math.floor(s/4294967296)>>>0:~~+Math.ceil((s-(~~s>>>0))/4294967296)>>>0:0)],w[r+88>>2]=i[0],w[r+92>>2]=i[1],0},doMsync(e,t,r,n,o){if(!g.isFile(t.node.mode))throw new g.ErrnoError(43);if(2&n)return 0;e=d.slice(e,e+r);g.msync(t,e,o,r,n)},getStreamFromFD(e){return g.getStreamChecked(e)},varargs:void 0,getStr(e){return xe(e)}},qe={},He=e=>{for(;e.length;){var t=e.pop();e.pop()(t)}};function C(e){return this.fromWireType(y[e>>2])}var Ye,k,F={},P={},Xe={},Ge=e=>{throw new _r(e)},S=(n,t,o)=>{function r(e){var t=o(e);t.length!==n.length&&Ge("Mismatched type converter count");for(var r=0;r<n.length;++r)L(n[r],t[r])}n.forEach(function(e){Xe[e]=t});var a=new Array(t.length),s=[],i=0;t.forEach((e,t)=>{P.hasOwnProperty(e)?a[t]=P[e]:(s.push(e),F.hasOwnProperty(e)||(F[e]=[]),F[e].push(()=>{a[t]=P[e],++i===s.length&&r(a)}))}),0===s.length&&r(a)},Ke={},M=e=>{for(var t="",r=e;d[r];)t+=Ye[d[r++]];return t},T=e=>{throw new k(e)};function L(e,t,r={}){if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");var[e,t,r={}]=[e,t,r],n=t.name;if(e||T(`type "${n}" must have a positive integer typeid pointer`),P.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;T(`Cannot register type '${n}' twice`)}P[e]=t,delete Xe[e],F.hasOwnProperty(e)&&(r=F[e],delete F[e],r.forEach(e=>e()))}var Je,Ze=e=>{T(e.$$.ptrType.registeredClass.name+" instance already deleted")},Qe=!1,et=e=>{},tt=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)},rt=e=>{--e.count.value,0===e.count.value&&tt(e)},nt=(e,t,r)=>{return t===r?e:void 0===r.baseClass||null===(e=nt(e,t,r.baseClass))?null:r.downcast(e)},ot={},H=()=>Object.keys(lt).length,at=()=>{var e,t=[];for(e in lt)lt.hasOwnProperty(e)&&t.push(lt[e]);return t},st=[],it=()=>{for(;st.length;){var e=st.pop();e.$$.deleteScheduled=!1,e.delete()}},ut=e=>{Je=e,st.length&&Je&&Je(it)},lt={},dt=(e,t)=>{for(void 0===t&&T("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t},ct=(e,t)=>(t=dt(e,t),lt[t]),mt=(e,t)=>{return t.ptrType&&t.ptr||Ge("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!=!!t.smartPtr&&Ge("Both smartPtrType and smartPtr must be specified"),t.count={value:1},pt(Object.create(e,{$$:{value:t,writable:!0}}))};function ht(e){var t,r,n=this.getPointee(e);return n?void 0!==(t=ct(this.registeredClass,n))?0===t.$$.count.value?(t.$$.ptr=n,t.$$.smartPtr=e,t.clone()):(t=t.clone(),this.destructor(e),t):(t=this.registeredClass.getActualType(n),!(t=ot[t])||(t=this.isConst?t.constPointerType:t.pointerType,null===(r=nt(n,this.registeredClass,t.registeredClass)))?o.call(this):this.isSmartPointer?mt(t.registeredClass.instancePrototype,{ptrType:t,ptr:r,smartPtrType:this,smartPtr:e}):mt(t.registeredClass.instancePrototype,{ptrType:t,ptr:r})):(this.destructor(e),null);function o(){return this.isSmartPointer?mt(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:n,smartPtrType:this,smartPtr:e}):mt(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}}var pt=e=>"undefined"==typeof FinalizationRegistry?(pt=e=>e,e):(Qe=new FinalizationRegistry(e=>{rt(e.$$)}),et=e=>Qe.unregister(e),(pt=e=>{var t=e.$$;return!!t.smartPtr&&Qe.register(e,{$$:t},e),e})(e));function ft(){}var gt=(e,t)=>Object.defineProperty(t,"name",{value:e}),vt=(t,r,n)=>{var e;void 0===t[r].overloadTable&&(e=t[r],t[r]=function(...e){return t[r].overloadTable.hasOwnProperty(e.length)||T(`Function '${n}' called with an invalid number of arguments (${e.length}) - expects one of (${t[r].overloadTable})!`),t[r].overloadTable[e.length].apply(this,e)},t[r].overloadTable=[],t[r].overloadTable[e.argCount]=e)},wt=(e,t,r)=>{u.hasOwnProperty(e)?((void 0===r||void 0!==u[e].overloadTable&&void 0!==u[e].overloadTable[r])&&T(`Cannot register public name '${e}' twice`),vt(u,e,e),u.hasOwnProperty(r)&&T(`Cannot register multiple overloads of a function with the same number of arguments (${r})!`),u[e].overloadTable[r]=t):(u[e]=t,void 0!==r&&(u[e].numArguments=r))},yt=48,Et=57;function _t(e,t,r,n,o,a,s,i){this.name=e,this.constructor=t,this.instancePrototype=r,this.rawDestructor=n,this.baseClass=o,this.getActualType=a,this.upcast=s,this.downcast=i,this.pureVirtualFunctions=[]}var bt=(e,t,r)=>{for(;t!==r;)t.upcast||T(`Expected null or instance of ${r.name}, got an instance of `+t.name),e=t.upcast(e),t=t.baseClass;return e};function Ct(e,t){if(null===t)return this.isReference&&T("null is not a valid "+this.name),0;t.$$||T(`Cannot pass "${Yt(t)}" as a `+this.name),t.$$.ptr||T("Cannot pass deleted object as a pointer of type "+this.name);var r=t.$$.ptrType.registeredClass;return bt(t.$$.ptr,r,this.registeredClass)}function kt(e,t){if(null===t)return this.isReference&&T("null is not a valid "+this.name),this.isSmartPointer?(n=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,n),n):0;t&&t.$$||T(`Cannot pass "${Yt(t)}" as a `+this.name),t.$$.ptr||T("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&t.$$.ptrType.isConst&&T(`Cannot convert argument of type ${(t.$$.smartPtrType||t.$$.ptrType).name} to parameter type `+this.name);var r,n,o=t.$$.ptrType.registeredClass;if(n=bt(t.$$.ptr,o,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&T("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?n=t.$$.smartPtr:T(`Cannot convert argument of type ${(t.$$.smartPtrType||t.$$.ptrType).name} to parameter type `+this.name);break;case 1:n=t.$$.smartPtr;break;case 2:t.$$.smartPtrType===this?n=t.$$.smartPtr:(r=t.clone(),n=this.rawShare(n,A.toHandle(()=>r.delete())),null!==e&&e.push(this.rawDestructor,n));break;default:T("Unsupporting sharing policy")}return n}function Ft(e,t){if(null===t)return this.isReference&&T("null is not a valid "+this.name),0;t.$$||T(`Cannot pass "${Yt(t)}" as a `+this.name),t.$$.ptr||T("Cannot pass deleted object as a pointer of type "+this.name),t.$$.ptrType.isConst&&T(`Cannot convert argument of type ${t.$$.ptrType.name} to parameter type `+this.name);var r=t.$$.ptrType.registeredClass;return bt(t.$$.ptr,r,this.registeredClass)}function Pt(e,t,r,n,o,a,s,i,u,l,d){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=n,this.isSmartPointer=o,this.pointeeType=a,this.sharingPolicy=s,this.rawGetPointee=i,this.rawConstructor=u,this.rawShare=l,this.rawDestructor=d,o||void 0!==t.baseClass?this.toWireType=kt:(this.toWireType=n?Ct:Ft,this.destructorFunction=null)}var St,Mt,Tt=(e,t,r)=>{u.hasOwnProperty(e)||Ge("Replacing nonexistent public symbol"),void 0!==u[e].overloadTable&&void 0!==r?u[e].overloadTable[r]=t:(u[e]=t,u[e].argCount=r)},Lt=(e,t,r)=>{return e=e.replace(/p/g,"i"),(0,u["dynCall_"+e])(t,...r)},$t=[],Dt=e=>{var t=$t[e];return t||(e>=$t.length&&($t.length=e+1),$t[e]=t=St.get(e)),t},At=(e,t,r=[])=>{return e.includes("j")?Lt(e,t,r):Dt(t)(...r)},xt=(t,r)=>(...e)=>At(t,r,e),$=(e,t)=>{var r=(e=M(e)).includes("j")?xt(e,t):Dt(t);return"function"!=typeof r&&T(`unknown function pointer with signature ${e}: `+t),r},Rt=e=>{var e=Pr(e),t=M(e);return j(e),t},D=(e,t)=>{var r=[],n={};throw t.forEach(function e(t){n[t]||P[t]||(Xe[t]?Xe[t].forEach(e):(r.push(t),n[t]=!0))}),new Mt(e+": "+r.map(Rt).join([", "]))};function jt(e){for(var t=1;t<e.length;++t)if(null!==e[t]&&void 0===e[t].destructorFunction)return!0;return!1}function zt(e,t){var r;if(e instanceof Function)return(r=gt(e.name||"unknownFunctionName",function(){})).prototype=e.prototype,r=new r,(t=e.apply(r,t))instanceof Object?t:r;throw new TypeError(`new_ called with constructor type ${typeof e} which is not a function`)}function Ot(e,t,r,n,o,a){for(var s=t.length,r=(s<2&&T("argTypes array size mismatch! Must at least get return value and 'this' types!"),null!==t[1]&&null!==r),i=jt(t),u="void"!==t[0].name,l=[e,T,n,o,He,t[0],t[1]],d=0;d<s-2;++d)l.push(t[d+2]);if(!i)for(d=r?1:2;d<t.length;++d)null!==t[d].destructorFunction&&l.push(t[d].destructorFunction);var[n,o]=function(e,t,r,n){for(var o=jt(e),a=e.length,s="",i="",u=0;u<a-2;++u)s+=(0!==u?", ":"")+"arg"+u,i+=(0!==u?", ":"")+"arg"+u+"Wired";var l=`
return function (${s}) {
if (arguments.length !== ${a-2}) {
throwBindingError('function ' + humanName + ' called with ' + arguments.length + ' arguments, expected ${a-2}');
}`,d=(o&&(l+="var destructors = [];\n"),o?"destructors":"null"),c=["humanName","throwBindingError","invoker","fn","runDestructors","retType","classParam"];for(t&&(l+="var thisWired = classParam['toWireType']("+d+", this);\n"),u=0;u<a-2;++u)l+="var arg"+u+"Wired = argType"+u+"['toWireType']("+d+", arg"+u+");\n",c.push("argType"+u);if(l+=(r||n?"var rv = ":"")+"invoker(fn"+(0<(i=t?"thisWired"+(0<i.length?", ":"")+i:i).length?", ":"")+i+");\n",o)l+="runDestructors(destructors);\n";else for(u=t?1:2;u<e.length;++u){var m=1===u?"thisWired":"arg"+(u-2)+"Wired";null!==e[u].destructorFunction&&(l+=m+`_dtor(${m});
`,c.push(m+"_dtor"))}return r&&(l+="var ret = retType['fromWireType'](rv);\nreturn ret;\n"),[c,l+="}\n"]}(t,r,u,a),i=(n.push(o),zt(Function,n)(...l));return gt(e,i)}var Vt,It=(e,t)=>{for(var r=[],n=0;n<e;n++)r.push(y[t+4*n>>2]);return r},Ut=e=>{var t=(e=e.trim()).indexOf("(");return-1!==t?e.substr(0,t):e},Wt=(e,t,r)=>(e instanceof Object||T(r+' with invalid "this": '+e),e instanceof t.registeredClass.constructor||T(r+' incompatible with "this" of type '+e.constructor.name),e.$$.ptr||T(`cannot call emscripten binding method ${r} on deleted object`),bt(e.$$.ptr,e.$$.ptrType.registeredClass,t.registeredClass)),Nt=[],o=[],Bt=e=>{9<e&&0==--o[e+1]&&(o[e]=void 0,Nt.push(e))},qt=()=>o.length/2-5-Nt.length,A={toValue:e=>(e||T("Cannot use deleted val. handle = "+e),o[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:var t=Nt.pop()||o.length;return o[t]=e,o[t+1]=1,t}}},Ht={name:"emscripten::val",fromWireType:e=>{var t=A.toValue(e);return Bt(e),t},toWireType:(e,t)=>A.toHandle(t),argPackAdvance:8,readValueFromPointer:C,destructorFunction:null},Yt=e=>{var t;return null===e?"null":"object"==(t=typeof e)||"array"==t||"function"==t?e.toString():""+e},Xt="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,Gt=(e,t)=>{for(var r,n=e>>1,o=n+t/2;!(o<=n)&&Z[n];)++n;if(32<(r=n<<1)-e&&Xt)return Xt.decode(d.subarray(e,r));for(var a="",s=0;!(t/2<=s);++s){var i=p[e+2*s>>1];if(0==i)break;a+=String.fromCharCode(i)}return a},Kt=(e,t,r)=>{if((r??=2147483647)<2)return 0;for(var n=t,o=(r-=2)<2*e.length?r/2:e.length,a=0;a<o;++a){var s=e.charCodeAt(a);p[t>>1]=s,t+=2}return p[t>>1]=0,t-n},Jt=e=>2*e.length,Zt=(e,t)=>{for(var r=0,n="";!(t/4<=r);){var o,a=w[e+4*r>>2];if(0==a)break;++r,65536<=a?(o=a-65536,n+=String.fromCharCode(55296|o>>10,56320|1023&o)):n+=String.fromCharCode(a)}return n},Qt=(e,t,r)=>{if((r??=2147483647)<4)return 0;for(var n=t,o=n+r-4,a=0;a<e.length;++a){var s=e.charCodeAt(a);if(55296<=s&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++a)),w[t>>2]=s,o<(t+=4)+4)break}return w[t>>2]=0,t-n},er=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);55296<=n&&n<=57343&&++r,t+=4}return t},tr=(e,t)=>{var r=P[e];return void 0===r&&T(t+" has unknown type "+Rt(e)),r},rr=(e,t,r)=>{var n=[],e=e.toWireType(n,r);return n.length&&(y[t>>2]=A.toHandle(n)),e},nr={},or=e=>{var t=nr[e];return void 0===t?M(e):t},ar=[],sr=(Reflect.construct,()=>1073741824),ir={},ur=()=>Y||"./this.program",lr=()=>{if(!lr.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:ur()};for(t in ir)void 0===ir[t]?delete e[t]:e[t]=ir[t];var t,r=[];for(t in e)r.push(t+"="+e[t]);lr.strings=r}return lr.strings},dr=e=>e%4==0&&(e%100!=0||e%400==0),cr=(e,t)=>{for(var r=0,n=0;n<=t;r+=e[n++]);return r},mr=[31,29,31,30,31,30,31,31,30,31,30,31],hr=[31,28,31,30,31,30,31,31,30,31,30,31],pr=(e,t)=>{for(var r=new Date(e.getTime());0<t;){var n=dr(r.getFullYear()),o=r.getMonth(),n=(n?mr:hr)[o];if(!(t>n-r.getDate()))return r.setDate(r.getDate()+t),r;t-=n-r.getDate()+1,r.setDate(1),o<11?r.setMonth(o+1):(r.setMonth(0),r.setFullYear(r.getFullYear()+1))}return r},fr=(e,t)=>{h.set(e,t)},gr=g.createPath,vr=g.createLazyFile,wr=g.createDevice,yr=(u.requestFullscreen=v.requestFullscreen,u.requestAnimationFrame=v.requestAnimationFrame,u.setCanvasSize=v.setCanvasSize,u.pauseMainLoop=v.mainLoop.pause,u.resumeMainLoop=v.mainLoop.resume,u.getUserMedia=v.getUserMedia,u.createContext=v.createContext,{}),Er={};g.createPreloadedFile=e,g.staticInit(),u.FS_createPath=g.createPath,u.FS_createDataFile=g.createDataFile,u.FS_createPreloadedFile=g.createPreloadedFile,u.FS_unlink=g.unlink,u.FS_createLazyFile=g.createLazyFile,u.FS_createDevice=g.createDevice;for(var _r=u.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},br=new Array(256),Cr=0;Cr<256;++Cr)br[Cr]=String.fromCharCode(Cr);Ye=br,k=u.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},Object.assign(ft.prototype,{isAliasOf(e){if(!(this instanceof ft))return!1;if(!(e instanceof ft))return!1;for(var t=this.$$.ptrType.registeredClass,r=this.$$.ptr,n=(e.$$=e.$$,e.$$.ptrType.registeredClass),o=e.$$.ptr;t.baseClass;)r=t.upcast(r),t=t.baseClass;for(;n.baseClass;)o=n.upcast(o),n=n.baseClass;return t===n&&r===o},clone(){var e;return this.$$.ptr||Ze(this),this.$$.preservePointerOnDelete?(this.$$.count.value+=1,this):((e=pt(Object.create(Object.getPrototypeOf(this),{$$:{value:{count:(e=this.$$).count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}}}))).$$.count.value+=1,e.$$.deleteScheduled=!1,e)},delete(){this.$$.ptr||Ze(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&T("Object already scheduled for deletion"),et(this),rt(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Ze(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&T("Object already scheduled for deletion"),st.push(this),1===st.length&&Je&&Je(it),this.$$.deleteScheduled=!0,this}}),u.getInheritedInstanceCount=H,u.getLiveInheritedInstances=at,u.flushPendingDeletes=it,u.setDelayFunction=ut,Object.assign(Pt.prototype,{getPointee(e){return e=this.rawGetPointee?this.rawGetPointee(e):e},destructor(e){this.rawDestructor?.(e)},argPackAdvance:8,readValueFromPointer:C,fromWireType:ht}),Mt=u.UnboundTypeError=(H=Error,(at=gt(Vt="UnboundTypeError",function(e){this.name=Vt,this.message=e;e=new Error(e).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.replace(/^Error(:[^\n]*)?\n/,""))})).prototype=Object.create(H.prototype),(at.prototype.constructor=at).prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},at),o.push(0,1,void 0,1,null,1,!0,1,!1,1),u.count_emval_handles=qt;var kr,x,Fr={e:(e,t,r)=>{throw new je(e).init(t,r),e},F:function(e,t,r){b.varargs=r;try{var n=b.getStreamFromFD(e);switch(t){case 0:if((o=ze())<0)return-28;for(;g.streams[o];)o++;return g.dupStream(n,o).fd;case 1:case 2:return 0;case 3:return n.flags;case 4:var o=ze();return n.flags|=o,0;case 12:o=f();return p[o+0>>1]=2,0;case 13:case 14:return 0}return-28}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return-e.errno}},S:function(e,t,r){b.varargs=r;try{var n,o=b.getStreamFromFD(e);switch(t){case 21509:return o.tty?0:-59;case 21505:if(!o.tty)return-59;if(o.tty.ops.ioctl_tcgets){var a=o.tty.ops.ioctl_tcgets(o),s=f();w[s>>2]=a.c_iflag||0,w[s+4>>2]=a.c_oflag||0,w[s+8>>2]=a.c_cflag||0,w[s+12>>2]=a.c_lflag||0;for(var i=0;i<32;i++)h[s+i+17]=a.c_cc[i]||0}return 0;case 21510:case 21511:case 21512:return o.tty?0:-59;case 21506:case 21507:case 21508:if(!o.tty)return-59;if(o.tty.ops.ioctl_tcsets){for(var s=f(),u=w[s>>2],l=w[s+4>>2],d=w[s+8>>2],c=w[s+12>>2],m=[],i=0;i<32;i++)m.push(h[s+i+17]);return o.tty.ops.ioctl_tcsets(o.tty,t,{c_iflag:u,c_oflag:l,c_cflag:d,c_lflag:c,c_cc:m})}return 0;case 21519:return o.tty?(s=f(),w[s>>2]=0):-59;case 21520:return o.tty?-28:-59;case 21531:s=f();return g.ioctl(o,t,s);case 21523:return o.tty?(o.tty.ops.ioctl_tiocgwinsz&&(n=o.tty.ops.ioctl_tiocgwinsz(o.tty),s=f(),p[s>>1]=n[0],p[s+2>>1]=n[1]),0):-59;case 21524:case 21515:return o.tty?0:-59;default:return-28}}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return-e.errno}},E:function(e,t,r,n){b.varargs=n;try{t=b.getStr(t),t=b.calculateAt(e,t);var o=n?ze():0;return g.open(t,r,o).fd}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return-e.errno}},L:()=>{me("")},X:e=>{var o=qe[e],a=(delete qe[e],o.elements),l=a.length,t=a.map(e=>e.getterReturnType).concat(a.map(e=>e.setterArgumentType)),s=o.rawConstructor,i=o.rawDestructor;S([e],t,u=>(a.forEach((e,t)=>{var r=u[t],n=e.getter,o=e.getterContext,a=u[t+l],s=e.setter,i=e.setterContext;e.read=e=>r.fromWireType(n(o,e)),e.write=(e,t)=>{var r=[];s(i,e,a.toWireType(r,t)),He(r)}}),[{name:o.name,fromWireType:e=>{for(var t=new Array(l),r=0;r<l;++r)t[r]=a[r].read(e);return i(e),t},toWireType:(e,t)=>{if(l!==t.length)throw new TypeError(`Incorrect number of tuple elements for ${o.name}: expected=${l}, actual=`+t.length);for(var r=s(),n=0;n<l;++n)a[n].write(r,t[n]);return null!==e&&e.push(i,r),r},argPackAdvance:8,readValueFromPointer:C,destructorFunction:i}]))},n:e=>{var t=Ke[e],o=(delete Ke[e],t.rawConstructor),a=t.rawDestructor,c=t.fields,r=c.map(e=>e.getterReturnType).concat(c.map(e=>e.setterArgumentType));S([e],r,l=>{var d={};return c.forEach((e,t)=>{var r=e.fieldName,n=l[t],o=e.getter,a=e.getterContext,s=l[t+c.length],i=e.setter,u=e.setterContext;d[r]={read:e=>n.fromWireType(o(a,e)),write:(e,t)=>{var r=[];i(u,e,s.toWireType(r,t)),He(r)}}}),[{name:t.name,fromWireType:e=>{var t,r={};for(t in d)r[t]=d[t].read(e);return a(e),r},toWireType:(e,t)=>{for(var r in d)if(!(r in t))throw new TypeError(`Missing field: "${r}"`);var n=o();for(r in d)d[r].write(n,t[r]);return null!==e&&e.push(a,n),n},argPackAdvance:8,readValueFromPointer:C,destructorFunction:a}]})},J:(e,t,r,n,o)=>{},V:(e,t,r,n)=>{L(e,{name:t=M(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?r:n},argPackAdvance:8,readValueFromPointer:function(e){return this.fromWireType(d[e])},destructorFunction:null})},i:(s,e,t,i,r,u,n,l,o,d,c,a,m)=>{c=M(c),u=$(r,u),l&&=$(n,l),d&&=$(o,d),m=$(a,m);var h=void 0===(r=c)?"_unknown":(n=(r=r.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0),yt<=n&&n<=Et?"_"+r:r);wt(h,function(){D(`Cannot construct ${c} due to unbound types`,[i])}),S([s,e,t],i?[i]:[],e=>{e=e[0],e=i?(o=e.registeredClass).instancePrototype:ft.prototype;var t=gt(c,function(...e){if(Object.getPrototypeOf(this)!==r)throw new k("Use 'new' to construct "+c);if(void 0===n.constructor_body)throw new k(c+" has no accessible constructor");var t=n.constructor_body[e.length];if(void 0===t)throw new k(`Tried to invoke ctor of ${c} with invalid number of parameters (${e.length}) - expected (${Object.keys(n.constructor_body).toString()}) parameters instead!`);return t.apply(this,e)}),r=Object.create(e,{constructor:{value:t}}),n=(t.prototype=r,new _t(c,t,r,m,o,u,l,d)),e=(n.baseClass&&(n.baseClass.__derivedClasses??=[],n.baseClass.__derivedClasses.push(n)),new Pt(c,n,!0,!1,!1)),o=new Pt(c+"*",n,!1,!1,!1),a=new Pt(c+" const*",n,!1,!0,!1);return ot[s]={pointerType:o,constPointerType:a},Tt(h,t),[e,o,a]})},s:(e,s,i,t,r,u,l,d)=>{var c=It(i,t);s=M(s),s=Ut(s),u=$(r,u),S([],[e],n=>{var o=(n=n[0]).name+"."+s;function e(){D(`Cannot call ${o} due to unbound types`,c)}s.startsWith("@@")&&(s=Symbol[s.substring(2)]);var a=n.registeredClass.constructor;return void 0===a[s]?(e.argCount=i-1,a[s]=e):(vt(a,s,o),a[s].overloadTable[i-1]=e),S([],c,e=>{var e=[e[0],null].concat(e.slice(1)),t=Ot(o,e,null,u,l,d);if(void 0===a[s].overloadTable?(t.argCount=i-1,a[s]=t):a[s].overloadTable[i-1]=t,n.registeredClass.__derivedClasses)for(var r of n.registeredClass.__derivedClasses)r.constructor.hasOwnProperty(s)||(r.constructor[s]=t);return[]}),[]})},d:(e,n,t,r,o,a)=>{var s=It(n,t);o=$(r,o),S([],[e],t=>{var r="constructor "+(t=t[0]).name;if(void 0===t.registeredClass.constructor_body&&(t.registeredClass.constructor_body=[]),void 0!==t.registeredClass.constructor_body[n-1])throw new k(`Cannot register multiple constructors with identical number of parameters (${n-1}) for class '${t.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return t.registeredClass.constructor_body[n-1]=()=>{D(`Cannot construct ${t.name} due to unbound types`,s)},S([],s,e=>(e.splice(1,0,null),t.registeredClass.constructor_body[n-1]=Ot(r,e,null,o,a),[])),[]})},c:(e,a,s,t,r,i,u,l,d)=>{var c=It(s,t);a=M(a),a=Ut(a),i=$(r,i),S([],[e],t=>{var r=(t=t[0]).name+"."+a;function e(){D(`Cannot call ${r} due to unbound types`,c)}a.startsWith("@@")&&(a=Symbol[a.substring(2)]),l&&t.registeredClass.pureVirtualFunctions.push(a);var n=t.registeredClass.instancePrototype,o=n[a];return void 0===o||void 0===o.overloadTable&&o.className!==t.name&&o.argCount===s-2?(e.argCount=s-2,e.className=t.name,n[a]=e):(vt(n,a,r),n[a].overloadTable[s-2]=e),S([],c,e=>{e=Ot(r,e,t,i,u,d);return void 0===n[a].overloadTable?(e.argCount=s-2,n[a]=e):n[a].overloadTable[s-2]=e,[]}),[]})},f:(e,s,t,r,i,u,n,l,d,c)=>{s=M(s),i=$(r,i),S([],[e],o=>{var a=(o=o[0]).name+"."+s,e={get(){D(`Cannot access ${a} due to unbound types`,[t,n])},enumerable:!0,configurable:!0};return e.set=d?()=>D(`Cannot access ${a} due to unbound types`,[t,n]):e=>T(a+" is a read-only property"),Object.defineProperty(o.registeredClass.instancePrototype,s,e),S([],d?[t,n]:[t],e=>{var n,t=e[0],r={get(){var e=Wt(this,o,a+" getter");return t.fromWireType(i(u,e))},enumerable:!0};return d&&(d=$(l,d),n=e[1],r.set=function(e){var t=Wt(this,o,a+" setter"),r=[];d(c,t,n.toWireType(r,e)),He(r)}),Object.defineProperty(o.registeredClass.instancePrototype,s,r),[]}),[]})},a:(t,e,r)=>{t=M(t),S([],[e],e=>(e=e[0],u[t]=e.fromWireType(r),[]))},U:e=>L(e,Ht),H:(e,t,r)=>{L(e,{name:t=M(t),fromWireType:e=>e,toWireType:(e,t)=>t,argPackAdvance:8,readValueFromPointer:((e,t)=>{switch(t){case 4:return function(e){return this.fromWireType(Q[e>>2])};case 8:return function(e){return this.fromWireType(ee[e>>3])};default:throw new TypeError(`invalid float width (${t}): `+e)}})(t,r),destructorFunction:null})},b:(t,r,e,n,o,a,s)=>{var i=It(r,e);t=M(t),t=Ut(t),o=$(n,o),wt(t,function(){D(`Cannot call ${t} due to unbound types`,i)},r-1),S([],i,e=>{e=[e[0],null].concat(e.slice(1));return Tt(t,Ot(t,e,null,o,a,s),r-1),[]})},v:(e,t,r,n,o)=>{t=M(t),-1===o&&(o=4294967295);var a,o=e=>e,s=(0===n&&(a=32-8*r,o=e=>e<<a>>>a),t.includes("unsigned")),s=s?function(e,t){return this.name,t>>>0}:function(e,t){return this.name,t};L(e,{name:t,fromWireType:o,toWireType:s,argPackAdvance:8,readValueFromPointer:((e,t,r)=>{switch(t){case 1:return r?e=>h[e]:e=>d[e];case 2:return r?e=>p[e>>1]:e=>Z[e>>1];case 4:return r?e=>w[e>>2]:e=>y[e>>2];default:throw new TypeError(`invalid integer width (${t}): `+e)}})(t,r,0!==n),destructorFunction:null})},m:(e,t,r)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function o(e){var t=y[e>>2],e=y[e+4>>2];return new n(h.buffer,e,t)}L(e,{name:r=M(r),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},k:(e,t,r,n,o,a,s,i,u,l,d,c)=>{r=M(r),a=$(o,a),i=$(s,i),l=$(u,l),c=$(d,c),S([e],[t],e=>{return e=e[0],[new Pt(r,e.registeredClass,!1,!1,!0,e,n,a,i,l,c)]})},G:(e,t)=>{var l="std::string"===(t=M(t));L(e,{name:t,fromWireType(e){var t=y[e>>2],r=e+4;if(l)for(var n=r,o=0;o<=t;++o){var a,s,i=r+o;o!=t&&0!=d[i]||(a=xe(n,i-n),s=void 0===s?a:s+String.fromCharCode(0)+a,n=i+1)}else{for(var u=new Array(t),o=0;o<t;++o)u[o]=String.fromCharCode(d[r+o]);s=u.join("")}return j(e),s},toWireType(e,t){var r,n="string"==typeof(t=t instanceof ArrayBuffer?new Uint8Array(t):t),o=(n||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||T("Cannot pass non-string to std::string"),r=l&&n?Le(t):t.length,Sr(4+r+1)),a=o+4;if(y[o>>2]=r,l&&n)De(t,a,r+1);else if(n)for(var s=0;s<r;++s){var i=t.charCodeAt(s);255<i&&(j(a),T("String has UTF-16 code units that do not fit in 8 bits")),d[a+s]=i}else for(s=0;s<r;++s)d[a+s]=t[s];return null!==e&&e.push(j,o),o},argPackAdvance:8,readValueFromPointer:C,destructorFunction(e){j(e)}})},C:(e,i,o)=>{var u,a,l,s;o=M(o),2===i?(u=Gt,a=Kt,s=Jt,l=e=>Z[e>>1]):4===i&&(u=Zt,a=Qt,s=er,l=e=>y[e>>2]),L(e,{name:o,fromWireType:e=>{for(var t=y[e>>2],r=e+4,n=0;n<=t;++n){var o,a,s=e+4+n*i;n!=t&&0!=l(s)||(o=u(r,s-r),a=void 0===a?o:a+String.fromCharCode(0)+o,r=s+i)}return j(e),a},toWireType:(e,t)=>{"string"!=typeof t&&T("Cannot pass non-string to C++ string type "+o);var r=s(t),n=Sr(4+r+i);return y[n>>2]=r/i,a(t,n+4,r+i),null!==e&&e.push(j,n),n},argPackAdvance:8,readValueFromPointer:C,destructorFunction(e){j(e)}})},Y:(e,t,r,n,o,a)=>{qe[e]={name:M(t),rawConstructor:$(r,n),rawDestructor:$(o,a),elements:[]}},z:(e,t,r,n,o,a,s,i,u)=>{qe[e].elements.push({getterReturnType:t,getter:$(r,n),getterContext:o,setterArgumentType:a,setter:$(s,i),setterContext:u})},o:(e,t,r,n,o,a)=>{Ke[e]={name:M(t),rawConstructor:$(r,n),rawDestructor:$(o,a),fields:[]}},h:(e,t,r,n,o,a,s,i,u,l)=>{Ke[e].fields.push({fieldName:M(t),getterReturnType:r,getter:$(n,o),getterContext:a,setterArgumentType:s,setter:$(i,u),setterContext:l})},W:(e,t)=>{L(e,{isVoid:!0,name:t=M(t),argPackAdvance:0,fromWireType:()=>{},toWireType:(e,t)=>{}})},M:()=>1,T:(e,t,r)=>d.copyWithin(e,t,t+r),t:(e,t,r)=>(e=A.toValue(e),t=tr(t,"emval::as"),rr(t,r,e)),p:(e,t,r,n,o)=>(e=ar[e])(t=A.toValue(t),t[r=or(r)],n,o),g:Bt,q:(e,t,r)=>{for(var n=((e,t)=>{for(var r=new Array(e),n=0;n<e;++n)r[n]=tr(y[t+4*n>>2],"parameter "+n);return r})(e,t),t=n.shift(),o=(e--,`return function (obj, func, destructorsRef, args) {
`),a=0,s=[],i=(0===r&&s.push("obj"),["retType"]),u=[t],l=0;l<e;++l)s.push("arg"+l),i.push("argType"+l),u.push(n[l]),o+=` var arg${l} = argType${l}.readValueFromPointer(args${a?"+"+a:""});
`,a+=n[l].argPackAdvance;o+=` var rv = ${1===r?"new func":"func.call"}(${s.join(", ")});
`,t.isVoid||(i.push("emval_returnValue"),u.push(rr),o+=" return emval_returnValue(retType, destructorsRef, rv);\n"),i.push(o+="};\n");var r=zt(Function,i)(...u),t=`methodCaller<(${n.map(e=>e.name).join(", ")}) => ${t.name}>`;return t=gt(t,r),r=ar.length,ar.push(t),r},r:(e,t)=>(e=A.toValue(e),t=A.toValue(t),A.toHandle(e[t])),x:e=>{9<e&&(o[e+1]+=1)},w:()=>A.toHandle([]),u:e=>A.toHandle(or(e)),l:e=>{var t=A.toValue(e);He(t),Bt(e)},y:(e,t,r)=>{e=A.toValue(e),t=A.toValue(t),r=A.toValue(r),e[t]=r},j:(e,t)=>{e=(e=tr(e,"_emval_take_value")).readValueFromPointer(t);return A.toHandle(e)},O:()=>sr(),P:Ee,N:e=>{var t=d.length,r=(e>>>=0,sr());if(!(r<e))for(var n,o=1;o<=4;o*=2){var a=t*(1+.2/o),a=Math.min(a,e+100663296);if((e=>{e=(e-K.buffer.byteLength+65535)/65536;try{return K.grow(e),re(),1}catch(e){}})(Math.min(r,(a=Math.max(e,a))+((n=65536)-a%n)%n)))return!0}return!1},Q:(s,i)=>{var u=0;return lr().forEach((e,t)=>{for(var r=i+u,n=(y[s+4*t>>2]=r,e),o=r,a=0;a<n.length;++a)h[o++]=n.charCodeAt(a);h[o]=0,u+=e.length+1}),0},R:(e,t)=>{var r=lr(),n=(y[e>>2]=r.length,0);return r.forEach(e=>n+=e.length+1),y[t>>2]=n,0},B:function(e){try{var t=b.getStreamFromFD(e);return g.close(t),0}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return e.errno}},D:function(e,t,r,n){try{var o=((e,t,r,n)=>{for(var o=0,a=0;a<r;a++){var s=y[t>>2],i=y[t+4>>2],s=(t+=8,g.read(e,h,s,i,n));if(s<0)return-1;if(o+=s,s<i)break;void 0!==n&&(n+=s)}return o})(b.getStreamFromFD(e),t,r);return y[n>>2]=o,0}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return e.errno}},I:function(e,t,r,n,o){var a,t=(r=r)+2097152>>>0<4194305-!!(t=t)?(t>>>0)+4294967296*r:NaN;try{return isNaN(t)?61:(a=b.getStreamFromFD(e),g.llseek(a,t,n),i=[a.position>>>0,(s=a.position,1<=+Math.abs(s)?0<s?+Math.floor(s/4294967296)>>>0:~~+Math.ceil((s-(~~s>>>0))/4294967296)>>>0:0)],w[o>>2]=i[0],w[o+4>>2]=i[1],a.getdents&&0===t&&0===n&&(a.getdents=null),0)}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return e.errno}},A:function(e,t,r,n){try{var o=((e,t,r,n)=>{for(var o=0,a=0;a<r;a++){var s=y[t>>2],i=y[t+4>>2],s=(t+=8,g.write(e,h,s,i,n));if(s<0)return-1;o+=s,void 0!==n&&(n+=s)}return o})(b.getStreamFromFD(e),t,r);return y[n>>2]=o,0}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return e.errno}},K:(e,t,r,n,o)=>{var a=y[n+40>>2],s={tm_sec:w[n>>2],tm_min:w[n+4>>2],tm_hour:w[n+8>>2],tm_mday:w[n+12>>2],tm_mon:w[n+16>>2],tm_year:w[n+20>>2],tm_wday:w[n+24>>2],tm_yday:w[n+28>>2],tm_isdst:w[n+32>>2],tm_gmtoff:w[n+36>>2],tm_zone:a?xe(a):""},i=xe(r),u={"%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(g in u)i=i.replace(new RegExp(g,"g"),u[g]);var l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],d=["January","February","March","April","May","June","July","August","September","October","November","December"];function c(e,t,r){for(var n="number"==typeof e?e.toString():e||"";n.length<t;)n=r[0]+n;return n}function m(e,t){return c(e,t,"0")}function h(e,t){function r(e){return e<0?-1:0<e?1:0}var n;return n=0===(n=r(e.getFullYear()-t.getFullYear()))&&0===(n=r(e.getMonth()-t.getMonth()))?r(e.getDate()-t.getDate()):n}function p(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function f(e){var e=pr(new Date(e.tm_year+1900,0,1),e.tm_yday),t=new Date(e.getFullYear(),0,4),r=new Date(e.getFullYear()+1,0,4),t=p(t),r=p(r);return h(t,e)<=0?h(r,e)<=0?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}var g,v={"%a":e=>l[e.tm_wday].substring(0,3),"%A":e=>l[e.tm_wday],"%b":e=>d[e.tm_mon].substring(0,3),"%B":e=>d[e.tm_mon],"%C":e=>{return m((e.tm_year+1900)/100|0,2)},"%d":e=>m(e.tm_mday,2),"%e":e=>c(e.tm_mday,2," "),"%g":e=>f(e).toString().substring(2),"%G":f,"%H":e=>m(e.tm_hour,2),"%I":e=>{e=e.tm_hour;return 0==e?e=12:12<e&&(e-=12),m(e,2)},"%j":e=>m(e.tm_mday+cr(dr(e.tm_year+1900)?mr:hr,e.tm_mon-1),3),"%m":e=>m(e.tm_mon+1,2),"%M":e=>m(e.tm_min,2),"%n":()=>"\n","%p":e=>0<=e.tm_hour&&e.tm_hour<12?"AM":"PM","%S":e=>m(e.tm_sec,2),"%t":()=>"\t","%u":e=>e.tm_wday||7,"%U":e=>{e=e.tm_yday+7-e.tm_wday;return m(Math.floor(e/7),2)},"%V":e=>{var t,r=Math.floor((e.tm_yday+7-(e.tm_wday+6)%7)/7);return(e.tm_wday+371-e.tm_yday-2)%7<=2&&r++,r?53!=r||4==(t=(e.tm_wday+371-e.tm_yday)%7)||3==t&&dr(e.tm_year)||(r=1):(r=52,(4==(t=(e.tm_wday+7-e.tm_yday-1)%7)||5==t&&dr(e.tm_year%400-1))&&r++),m(r,2)},"%w":e=>e.tm_wday,"%W":e=>{e=e.tm_yday+7-(e.tm_wday+6)%7;return m(Math.floor(e/7),2)},"%y":e=>(e.tm_year+1900).toString().substring(2),"%Y":e=>e.tm_year+1900,"%z":e=>{var t=0<=(e=e.tm_gmtoff),e=Math.abs(e)/60;return(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":e=>e.tm_zone,"%%":()=>"%"},i=i.replace(/%%/g,"\0\0");for(g in v)i.includes(g)&&(i=i.replace(new RegExp(g,"g"),v[g](s)));return(n=Ue(i=i.replace(/\0\0/g,"%"),!1)).length>t?0:(fr(n,e),n.length-1)}},R=function(){var e={a:Fr};function t(e,t){return R=e.exports,K=R.Z,re(),St=R.ba,e=R._,oe.unshift(e),ce(),R}if(de(),u.instantiateWasm)try{return u.instantiateWasm(e,t)}catch(e){l("Module.instantiateWasm callback failed with error: "+e),O(e)}return t(we(he=he||ve(),e)[0])}(),Pr=(R._,R.$),Sr=u._malloc=R.aa,j=u._free=R.ca,Mr=(R.da,R.ea,R.fa,R.ga,R.ha);function Tr(){function e(){kr||(kr=!0,u.calledRun=!0,c)||(u.noFSInit||g.init.initialized||g.init(),g.ignorePermissions=!1,n.init(),Te(oe),z(u),u.onRuntimeInitialized&&u.onRuntimeInitialized(),ie())}0<r||(se(),0<r)||(u.setStatus?(u.setStatus("Running..."),setTimeout(function(){setTimeout(function(){u.setStatus("")},1),e()},1)):e())}if(u.dynCall_ji=R.ia,u.dynCall_viijii=R.ja,u.dynCall_jiii=R.ka,u.dynCall_vij=R.la,u.dynCall_jii=R.ma,u.dynCall_viji=R.na,u.dynCall_jiji=R.oa,u.dynCall_iiiiij=R.pa,u.dynCall_iiiiijj=R.qa,u.dynCall_iiiiiijj=R.ra,u.addRunDependency=de,u.removeRunDependency=ce,u.FS_createPreloadedFile=e,u.FS_unlink=e=>g.unlink(e),u.FS_createPath=gr,u.FS_createDevice=wr,u.FS_createDataFile=Ne,u.FS_createLazyFile=vr,le=function e(){kr||Tr(),kr||(le=e)},u.preInit)for("function"==typeof u.preInit&&(u.preInit=[u.preInit]);0<u.preInit.length;)u.preInit.pop()();function Lr(e,t){this.x=void 0===e?0:e,this.y=void 0===t?0:t}function $r(){switch(arguments.length){case 0:this.center={x:0,y:0},this.size={width:0,height:0},this.angle=0;break;case 3:this.center=arguments[0],this.size=arguments[1],this.angle=arguments[2];break;default:throw new Error("Invalid arguments")}}function Dr(e,t,r,n){this.push(void 0===e?0:e),this.push(void 0===t?0:t),this.push(void 0===r?0:r),this.push(void 0===n?0:n)}return Tr(),void 0===u.FS&&void 0!==g&&(u.FS=g),void 0===x&&(x=u),u.imread=function(e){var t=null,r=null,n=null;if((t="string"==typeof e?document.getElementById(e):e)instanceof HTMLImageElement)(r=document.createElement("canvas")).width=t.width,r.height=t.height,(n=r.getContext("2d",{willReadFrequently:!0})).drawImage(t,0,0,t.width,t.height);else{if(!(t instanceof HTMLCanvasElement||t instanceof OffscreenCanvas))throw new Error("Please input the valid canvas or img id.");n=(r=t).getContext("2d")}e=n.getImageData(0,0,r.width,r.height);return x.matFromImageData(e)},u.imshow=function(e,t){var r=null;if(!((r="string"==typeof e?document.getElementById(e):e)instanceof HTMLCanvasElement))throw new Error("Please input the valid canvas element or id.");if(!(t instanceof x.Mat))throw new Error("Please input the valid cv.Mat instance.");var n=new x.Mat,e=t.type()%8,o=e<=x.CV_8S?1:e<=x.CV_32S?1/256:255,e=e===x.CV_8S||e===x.CV_16S?128:0;switch(t.convertTo(n,x.CV_8U,o,e),n.type()){case x.CV_8UC1:x.cvtColor(n,n,x.COLOR_GRAY2RGBA);break;case x.CV_8UC3:x.cvtColor(n,n,x.COLOR_RGB2RGBA);break;case x.CV_8UC4:break;default:throw new Error("Bad number of channels (Source image must have 1, 3 or 4 channels)")}t=new ImageData(new Uint8ClampedArray(n.data),n.cols,n.rows),o=r.getContext("2d");o.clearRect(0,0,r.width,r.height),r.width=t.width,r.height=t.height,o.putImageData(t,0,0),n.delete()},u.VideoCapture=function(e){var t=null;if(!((t="string"==typeof e?document.getElementById(e):e)instanceof HTMLVideoElement))throw new Error("Please input the valid video element or id.");var e=document.createElement("canvas"),r=(e.width=t.width,e.height=t.height,e.getContext("2d"));this.video=t,this.read=function(e){if(!(e instanceof x.Mat))throw new Error("Please input the valid cv.Mat instance.");if(e.type()!==x.CV_8UC4)throw new Error("Bad type of input mat: the type should be cv.CV_8UC4.");if(e.cols!==t.width||e.rows!==t.height)throw new Error("Bad size of input mat: the size should be same as the video.");r.drawImage(t,0,0,t.width,t.height),e.data.set(r.getImageData(0,0,t.width,t.height).data)}},u.Range=function(e,t){this.start=void 0===e?0:e,this.end=void 0===t?0:t},u.Point=Lr,u.Size=function(e,t){this.width=void 0===e?0:e,this.height=void 0===t?0:t},u.Rect=function(){switch(arguments.length){case 0:this.x=0,this.y=0,this.width=0,this.height=0;break;case 1:var e=arguments[0];this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height;break;case 2:var e=arguments[0],t=arguments[1];this.x=e.x,this.y=e.y,this.width=t.width,this.height=t.height;break;case 4:this.x=arguments[0],this.y=arguments[1],this.width=arguments[2],this.height=arguments[3];break;default:throw new Error("Invalid arguments")}},$r.points=function(e){return u.rotatedRectPoints(e)},$r.boundingRect=function(e){return u.rotatedRectBoundingRect(e)},$r.boundingRect2f=function(e){return u.rotatedRectBoundingRect2f(e)},u.RotatedRect=$r,Dr.prototype=new Array,Dr.all=function(e){return new Dr(e,e,e,e)},u.Scalar=Dr,u.MinMaxLoc=function(){switch(arguments.length){case 0:this.minVal=0,this.maxVal=0,this.minLoc=new Lr,this.maxLoc=new Lr;break;case 4:this.minVal=arguments[0],this.maxVal=arguments[1],this.minLoc=arguments[2],this.maxLoc=arguments[3];break;default:throw new Error("Invalid arguments")}},u.Circle=function(){switch(arguments.length){case 0:this.center=new Lr,this.radius=0;break;case 2:this.center=arguments[0],this.radius=arguments[1];break;default:throw new Error("Invalid arguments")}},u.TermCriteria=function(){switch(arguments.length){case 0:this.type=0,this.maxCount=0,this.epsilon=0;break;case 3:this.type=arguments[0],this.maxCount=arguments[1],this.epsilon=arguments[2];break;default:throw new Error("Invalid arguments")}},u.matFromArray=function(e,t,r,n){var o=new x.Mat(e,t,r);switch(r){case x.CV_8U:case x.CV_8UC1:case x.CV_8UC2:case x.CV_8UC3:case x.CV_8UC4:o.data.set(n);break;case x.CV_8S:case x.CV_8SC1:case x.CV_8SC2:case x.CV_8SC3:case x.CV_8SC4:o.data8S.set(n);break;case x.CV_16U:case x.CV_16UC1:case x.CV_16UC2:case x.CV_16UC3:case x.CV_16UC4:o.data16U.set(n);break;case x.CV_16S:case x.CV_16SC1:case x.CV_16SC2:case x.CV_16SC3:case x.CV_16SC4:o.data16S.set(n);break;case x.CV_32S:case x.CV_32SC1:case x.CV_32SC2:case x.CV_32SC3:case x.CV_32SC4:o.data32S.set(n);break;case x.CV_32F:case x.CV_32FC1:case x.CV_32FC2:case x.CV_32FC3:case x.CV_32FC4:o.data32F.set(n);break;case x.CV_64F:case x.CV_64FC1:case x.CV_64FC2:case x.CV_64FC3:case x.CV_64FC4:o.data64F.set(n);break;default:throw new Error("Type is unsupported")}return o},u.matFromImageData=function(e){var t=new x.Mat(e.height,e.width,x.CV_8UC4);return t.data.set(e.data),t},u}var Ar;Ar="undefined"!=typeof document?document.currentScript?.src:void 0,"undefined"!=typeof __filename&&(Ar||=__filename);return"object"==typeof exports&&"object"==typeof module?module.exports=e:"function"==typeof define&&define.amd&&define([],()=>e),e},"function"==typeof define&&define.amd?define(function(){return e.cv=t()}):"object"==typeof module&&module.exports?module.exports=t():e.cv=t()}();