UNPKG

@pdftron/webviewer-bim-client

Version:

Addon for WebViewer that allows you to view, annotate, and collaborate on 3D models.

1 lines 133 kB
var Module=void 0!==Module?Module:{};window.getVisualizeLibInst=function(e){e=e||{};var r=void 0!==r?r:{};r.postRun=[],r.TOTAL_MEMORY=e.TOTAL_MEMORY>16777216?e.TOTAL_MEMORY:16777216,r.locateFile=function(r){return e.urlMemFile||"./Visualize.js.wasm"},r.print=function(e){(window.Logger||console).log(e)},r.printErr=function(e){},r.loadWasmError=function(e){},r.instantiateWasm=function(t,n){return Promise.resolve().then((function(){return function(e,r){class t{constructor(e,r){this.loaded=0,this.progressCallback=e,this.total=r}write(e){this.loaded+=e.byteLength;const{loaded:r,total:t}=this;this.progressCallback({loaded:r,total:t})}close(){const{loaded:e,total:r}=this;this.progressCallback({loaded:e,total:r})}}return fetch(e).then((function(e){return r&&e.clone().body.pipeTo(new WritableStream(new t(r,Number(e.headers.get("Content-Length"))))),e}))}(r.locateFile(),e.onprogress||function(){})})).then((function(e){return WebAssembly.instantiateStreaming(e,t).then((function(e){n(e.instance)}))})).catch((function(e){r.loadWasmError(e)})),{}};var t,n,i,o=Object.assign({},r),a=[],s="./this.program",u=(e,r)=>{throw r},l="object"==typeof window,c="function"==typeof importScripts,f="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,d="";if(f){var m=require("fs"),p=require("path");d=c?p.dirname(d)+"/":__dirname+"/",t=(e,r)=>(e=ne(e)?new URL(e):p.normalize(e),m.readFileSync(e,r?void 0:"utf8")),i=e=>{var r=t(e,!0);return r.buffer||(r=new Uint8Array(r)),r},n=(e,r,t)=>{e=ne(e)?new URL(e):p.normalize(e),m.readFile(e,(function(e,n){e?t(e):r(n.buffer)}))},process.argv.length>1&&(s=process.argv[1].replace(/\\/g,"/")),a=process.argv.slice(2),"undefined"!=typeof module&&(module.exports=r),process.on("uncaughtException",(function(e){if(!(e instanceof ae))throw e})),process.on("unhandledRejection",(function(e){throw e})),u=(e,r)=>{if(V())throw process.exitCode=e,r;var t;(t=r)instanceof ae||h("exiting due to exception: "+t),process.exit(e)},r.inspect=function(){return"[Emscripten Module object]"}}else(l||c)&&(c?d=self.location.href:"undefined"!=typeof document&&document.currentScript&&(d=document.currentScript.src),d=0!==d.indexOf("blob:")?d.substr(0,d.replace(/[?#].*/,"").lastIndexOf("/")+1):"",t=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},c&&(i=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),n=(e,r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?r(n.response):t()},n.onerror=t,n.send(null)});var v,g=r.print||console.log.bind(console),h=r.printErr||console.warn.bind(console);Object.assign(r,o),o=null,r.arguments&&(a=r.arguments),r.thisProgram&&(s=r.thisProgram),r.quit&&(u=r.quit),r.wasmBinary&&(v=r.wasmBinary);var y,_=r.noExitRuntime||!0;"object"!=typeof WebAssembly&&re("no native wasm support detected");var w,b=!1;function E(e,r){e||re(r)}var C,j,T,x,k,S,P,A,D,F="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function M(e,r,t){for(var n=(r>>>=0)+t,i=r;e[i]&&!(i>=n);)++i;if(i-r>16&&e.buffer&&F)return F.decode(e.subarray(r,i));for(var o="";r<i;){var a=e[r++];if(128&a){var s=63&e[r++];if(192!=(224&a)){var u=63&e[r++];if((a=224==(240&a)?(15&a)<<12|s<<6|u:(7&a)<<18|s<<12|u<<6|63&e[r++])<65536)o+=String.fromCharCode(a);else{var l=a-65536;o+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else o+=String.fromCharCode((31&a)<<6|s)}else o+=String.fromCharCode(a)}return o}function L(e,r){return(e>>>=0)?M(T,e,r):""}function R(e,r,t,n){if(!(n>0))return 0;for(var i=t>>>=0,o=t+n-1,a=0;a<e.length;++a){var s=e.charCodeAt(a);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++a)),s<=127){if(t>=o)break;r[t++>>>0]=s}else if(s<=2047){if(t+1>=o)break;r[t++>>>0]=192|s>>6,r[t++>>>0]=128|63&s}else if(s<=65535){if(t+2>=o)break;r[t++>>>0]=224|s>>12,r[t++>>>0]=128|s>>6&63,r[t++>>>0]=128|63&s}else{if(t+3>=o)break;r[t++>>>0]=240|s>>18,r[t++>>>0]=128|s>>12&63,r[t++>>>0]=128|s>>6&63,r[t++>>>0]=128|63&s}}return r[t>>>0]=0,t-i}function B(e,r,t){return R(e,T,r,t)}function U(e){for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r}function O(e){C=e,r.HEAP8=j=new Int8Array(e),r.HEAP16=x=new Int16Array(e),r.HEAP32=S=new Int32Array(e),r.HEAPU8=T=new Uint8Array(e),r.HEAPU16=k=new Uint16Array(e),r.HEAPU32=P=new Uint32Array(e),r.HEAPF32=A=new Float32Array(e),r.HEAPF64=D=new Float64Array(e)}r.INITIAL_MEMORY;var N,I=[],$=[],G=[],H=[],W=[];function V(){return _}var z,q,X,Y,Q=0,K=null,J=null;function Z(e){Q++,r.monitorRunDependencies&&r.monitorRunDependencies(Q)}function ee(e){if(Q--,r.monitorRunDependencies&&r.monitorRunDependencies(Q),0==Q&&(null!==K&&(clearInterval(K),K=null),J)){var t=J;J=null,t()}}function re(e){throw r.onAbort&&r.onAbort(e),h(e="Aborted("+e+")"),b=!0,w=1,e+=". Build with -sASSERTIONS for more info.",new WebAssembly.RuntimeError(e)}function te(e){return e.startsWith("data:application/octet-stream;base64,")}function ne(e){return e.startsWith("file://")}function ie(e){try{if(e==z&&v)return new Uint8Array(v);if(i)return i(e);throw"both async and sync fetching of the wasm failed"}catch(e){re(e)}}te(z="VisualizeJSWasm.wasm")||(q=z,z=r.locateFile?r.locateFile(q,d):d+q);var oe={3206572:()=>r.HpTrc.Usd,3206596:()=>r.HEAP8.byteLength,3206627:()=>{r.Viewer.prototype.captureScreen=function(e,t,n){try{var i=r.ctx,o=r.canvas.width||r.canvas.clientWidth,a=r.canvas.height||r.canvas.clientHeight;this.resize(0,e,t,0);var s=i.createFramebuffer(),u=i.createRenderbuffer(),l=i.createTexture();i.bindFramebuffer(i.FRAMEBUFFER,s),s.width=e,s.height=t,function(e,r,t,n){e.bindTexture(e.TEXTURE_2D,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_NEAREST),e.generateMipmap(e.TEXTURE_2D),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,r.width,r.height,0,e.RGBA,e.UNSIGNED_BYTE,null),e.bindRenderbuffer(e.RENDERBUFFER,t),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,r.width,r.height),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t),e.bindTexture(e.TEXTURE_2D,null),e.bindRenderbuffer(e.RENDERBUFFER,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.FRAMEBUFFER,r)}(i,s,u,l),this.update();var c=function(e,r){var t=new Uint8Array(4*r.width*r.height);return e.readPixels(0,0,r.width,r.height,e.RGBA,e.UNSIGNED_BYTE,t),t}(i,s);!function(e,r,t,n){e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteFramebuffer(r),e.deleteRenderbuffer(t),e.deleteTexture(n)}(i,s,u,l),this.resize(0,o,a,0),this.update(),n(null,c)}catch(e){n(e)}},r.Viewer.prototype.saveVsfx=function(e){return this.saveVsfxWrapper((function(t,n){e(r.HEAP8.subarray(t,t+n))}))},r.OdTvRasterImage.prototype.setBinaryData=function(e,t,n,i,o){return this.setBinaryData(e,t,n,i,o.byteLength,(function(e,t,n){r.HEAP8.set(o.subarray(e,e+n),t)}))},r.Viewer.prototype.openUrl=function(e,t){return r.openUrl(this,e,t)}},3209515:e=>(r.canvas||console.error("Canvas is not set to module, please use vsLib.canvas = document.querySelector('#canvas');"),r.canvas&&(r.canvas.width||canvas.clientWidth)||e),3209738:e=>(r.canvas||console.error("Canvas is not set to module, please use vsLib.canvas = document.querySelector('#canvas');"),r.canvas&&(r.canvas.height||canvas.clientHeight)||e),3209963:(e,t)=>{r.HpTrc.Usd+=t,r.HpTrc.P2N[e]=t},3210011:e=>{r.HpTrc.Usd-=r.HpTrc.P2N[e]||0,delete r.HpTrc.P2N[e]},3210089:(e,t)=>{r.HpTrc.Usd+=t,r.HpTrc.P2N[e]=t},3210137:e=>{r.HpTrc.Usd-=r.HpTrc.P2N[e]||0,delete r.HpTrc.P2N[e]},3210215:(e,t)=>{r.HpTrc.Usd+=t,r.HpTrc.P2N[e]=t},3210263:e=>{r.HpTrc.Usd-=r.HpTrc.P2N[e]||0,delete r.HpTrc.P2N[e]},3210341:(e,t)=>{r.HpTrc.Usd+=t,r.HpTrc.P2N[e]=t},3210389:e=>{r.HpTrc.Usd-=r.HpTrc.P2N[e]||0,delete r.HpTrc.P2N[e]},3210467:()=>r.HpTrc.Usd,3210491:()=>{r.HpTrc={},r.HpTrc.P2N={},r.HpTrc.Usd=0},3210548:()=>{if(!r.canvas)return console.error("Canvas is not set to module, please use module.canvas = document.querySelector('#canvas');"),0;var e="#canvas";r.canvas.id&&(e="#"+r.canvas.id);var t=U(e)+1,n=At(t);return B(e,n,t),n}};function ae(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function se(e){for(;e.length>0;)e.shift()(r)}var ue=[];function le(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){P[this.ptr+4>>>2]=e},this.get_type=function(){return P[this.ptr+4>>>2]},this.set_destructor=function(e){P[this.ptr+8>>>2]=e},this.get_destructor=function(){return P[this.ptr+8>>>2]},this.set_refcount=function(e){S[this.ptr>>>2]=e},this.set_caught=function(e){e=e?1:0,j[this.ptr+12>>>0]=e},this.get_caught=function(){return 0!=j[this.ptr+12>>>0]},this.set_rethrown=function(e){e=e?1:0,j[this.ptr+13>>>0]=e},this.get_rethrown=function(){return 0!=j[this.ptr+13>>>0]},this.init=function(e,r){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(r),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var e=S[this.ptr>>>2];S[this.ptr>>>2]=e+1},this.release_ref=function(){var e=S[this.ptr>>>2];return S[this.ptr>>>2]=e-1,1===e},this.set_adjusted_ptr=function(e){P[this.ptr+16>>>2]=e},this.get_adjusted_ptr=function(){return P[this.ptr+16>>>2]},this.get_exception_ptr=function(){if(Ut(this.get_type()))return P[this.excPtr>>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}var ce={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var i=e[n];"."===i?e.splice(n,1):".."===i?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=ce.isAbs(e),t="/"===e.substr(-1);return(e=ce.normalizeArray(e.split("/").filter((e=>!!e)),!r).join("/"))||r||(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=ce.splitPath(e),t=r[0],n=r[1];return t||n?(n&&(n=n.substr(0,n.length-1)),t+n):"."},basename:e=>{if("/"===e)return"/";var r=(e=(e=ce.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===r?e:e.substr(r+1)},join:function(){var e=Array.prototype.slice.call(arguments);return ce.normalize(e.join("/"))},join2:(e,r)=>ce.normalize(e+"/"+r)};function fe(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return()=>(crypto.getRandomValues(e),e[0])}if(f)try{var r=require("crypto");return()=>r.randomBytes(1)[0]}catch(e){}return()=>re("randomDevice")}var de={resolve:function(){for(var e="",r=!1,t=arguments.length-1;t>=-1&&!r;t--){var n=t>=0?arguments[t]:he.cwd();if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,r=ce.isAbs(n)}return(r?"/":"")+(e=ce.normalizeArray(e.split("/").filter((e=>!!e)),!r).join("/"))||"."},relative:(e,r)=>{function t(e){for(var r=0;r<e.length&&""===e[r];r++);for(var t=e.length-1;t>=0&&""===e[t];t--);return r>t?[]:e.slice(r,t-r+1)}e=de.resolve(e).substr(1),r=de.resolve(r).substr(1);for(var n=t(e.split("/")),i=t(r.split("/")),o=Math.min(n.length,i.length),a=o,s=0;s<o;s++)if(n[s]!==i[s]){a=s;break}var u=[];for(s=a;s<n.length;s++)u.push("..");return(u=u.concat(i.slice(a))).join("/")}};function me(e,r,t){var n=t>0?t:U(e)+1,i=new Array(n),o=R(e,i,0,i.length);return r&&(i.length=o),i}var pe={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){pe.ttys[e]={input:[],output:[],ops:r},he.registerDevice(e,pe.stream_ops)},stream_ops:{open:function(e){var r=pe.ttys[e.node.rdev];if(!r)throw new he.ErrnoError(43);e.tty=r,e.seekable=!1},close:function(e){e.tty.ops.fsync(e.tty)},fsync:function(e){e.tty.ops.fsync(e.tty)},read:function(e,r,t,n,i){if(!e.tty||!e.tty.ops.get_char)throw new he.ErrnoError(60);for(var o=0,a=0;a<n;a++){var s;try{s=e.tty.ops.get_char(e.tty)}catch(e){throw new he.ErrnoError(29)}if(void 0===s&&0===o)throw new he.ErrnoError(6);if(null==s)break;o++,r[t+a]=s}return o&&(e.node.timestamp=Date.now()),o},write:function(e,r,t,n,i){if(!e.tty||!e.tty.ops.put_char)throw new he.ErrnoError(60);try{for(var o=0;o<n;o++)e.tty.ops.put_char(e.tty,r[t+o])}catch(e){throw new he.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),o}},default_tty_ops:{get_char:function(e){if(!e.input.length){var r=null;if(f){var t=Buffer.alloc(256),n=0;try{n=m.readSync(process.stdin.fd,t,0,256,-1)}catch(e){if(!e.toString().includes("EOF"))throw e;n=0}r=n>0?t.slice(0,n).toString("utf-8"):null}else"undefined"!=typeof window&&"function"==typeof window.prompt?null!==(r=window.prompt("Input: "))&&(r+="\n"):"function"==typeof readline&&null!==(r=readline())&&(r+="\n");if(!r)return null;e.input=me(r,!0)}return e.input.shift()},put_char:function(e,r){null===r||10===r?(g(M(e.output,0)),e.output=[]):0!=r&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(g(M(e.output,0)),e.output=[])}},default_tty1_ops:{put_char:function(e,r){null===r||10===r?(h(M(e.output,0)),e.output=[]):0!=r&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(h(M(e.output,0)),e.output=[])}}};function ve(e){re()}var ge={ops_table:null,mount:function(e){return ge.createNode(null,"/",16895,0)},createNode:function(e,r,t,n){if(he.isBlkdev(t)||he.isFIFO(t))throw new he.ErrnoError(63);ge.ops_table||(ge.ops_table={dir:{node:{getattr:ge.node_ops.getattr,setattr:ge.node_ops.setattr,lookup:ge.node_ops.lookup,mknod:ge.node_ops.mknod,rename:ge.node_ops.rename,unlink:ge.node_ops.unlink,rmdir:ge.node_ops.rmdir,readdir:ge.node_ops.readdir,symlink:ge.node_ops.symlink},stream:{llseek:ge.stream_ops.llseek}},file:{node:{getattr:ge.node_ops.getattr,setattr:ge.node_ops.setattr},stream:{llseek:ge.stream_ops.llseek,read:ge.stream_ops.read,write:ge.stream_ops.write,allocate:ge.stream_ops.allocate,mmap:ge.stream_ops.mmap,msync:ge.stream_ops.msync}},link:{node:{getattr:ge.node_ops.getattr,setattr:ge.node_ops.setattr,readlink:ge.node_ops.readlink},stream:{}},chrdev:{node:{getattr:ge.node_ops.getattr,setattr:ge.node_ops.setattr},stream:he.chrdev_stream_ops}});var i=he.createNode(e,r,t,n);return he.isDir(i.mode)?(i.node_ops=ge.ops_table.dir.node,i.stream_ops=ge.ops_table.dir.stream,i.contents={}):he.isFile(i.mode)?(i.node_ops=ge.ops_table.file.node,i.stream_ops=ge.ops_table.file.stream,i.usedBytes=0,i.contents=null):he.isLink(i.mode)?(i.node_ops=ge.ops_table.link.node,i.stream_ops=ge.ops_table.link.stream):he.isChrdev(i.mode)&&(i.node_ops=ge.ops_table.chrdev.node,i.stream_ops=ge.ops_table.chrdev.stream),i.timestamp=Date.now(),e&&(e.contents[r]=i,e.timestamp=i.timestamp),i},getFileDataAsTypedArray:function(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage:function(e,r){r>>>=0;var t=e.contents?e.contents.length:0;if(!(t>=r)){r=Math.max(r,t*(t<1048576?2:1.125)>>>0),0!=t&&(r=Math.max(r,256));var n=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(n.subarray(0,e.usedBytes),0)}},resizeFileStorage:function(e,r){if(r>>>=0,e.usedBytes!=r)if(0==r)e.contents=null,e.usedBytes=0;else{var t=e.contents;e.contents=new Uint8Array(r),t&&e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r}},node_ops:{getattr:function(e){var r={};return r.dev=he.isChrdev(e.mode)?e.id:1,r.ino=e.id,r.mode=e.mode,r.nlink=1,r.uid=0,r.gid=0,r.rdev=e.rdev,he.isDir(e.mode)?r.size=4096:he.isFile(e.mode)?r.size=e.usedBytes:he.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr:function(e,r){void 0!==r.mode&&(e.mode=r.mode),void 0!==r.timestamp&&(e.timestamp=r.timestamp),void 0!==r.size&&ge.resizeFileStorage(e,r.size)},lookup:function(e,r){throw he.genericErrors[44]},mknod:function(e,r,t,n){return ge.createNode(e,r,t,n)},rename:function(e,r,t){if(he.isDir(e.mode)){var n;try{n=he.lookupNode(r,t)}catch(e){}if(n)for(var i in n.contents)throw new he.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp,e.parent=r},unlink:function(e,r){delete e.contents[r],e.timestamp=Date.now()},rmdir:function(e,r){var t=he.lookupNode(e,r);for(var n in t.contents)throw new he.ErrnoError(55);delete e.contents[r],e.timestamp=Date.now()},readdir:function(e){var r=[".",".."];for(var t in e.contents)e.contents.hasOwnProperty(t)&&r.push(t);return r},symlink:function(e,r,t){var n=ge.createNode(e,r,41471,0);return n.link=t,n},readlink:function(e){if(!he.isLink(e.mode))throw new he.ErrnoError(28);return e.link}},stream_ops:{read:function(e,r,t,n,i){var o=e.node.contents;if(i>=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-i,n);if(a>8&&o.subarray)r.set(o.subarray(i,i+a),t);else for(var s=0;s<a;s++)r[t+s]=o[i+s];return a},write:function(e,r,t,n,i,o){if(r.buffer===j.buffer&&(o=!1),!n)return 0;var a=e.node;if(a.timestamp=Date.now(),r.subarray&&(!a.contents||a.contents.subarray)){if(o)return a.contents=r.subarray(t,t+n),a.usedBytes=n,n;if(0===a.usedBytes&&0===i)return a.contents=r.slice(t,t+n),a.usedBytes=n,n;if(i+n<=a.usedBytes)return a.contents.set(r.subarray(t,t+n),i),n}if(ge.expandFileStorage(a,i+n),a.contents.subarray&&r.subarray)a.contents.set(r.subarray(t,t+n),i);else for(var s=0;s<n;s++)a.contents[i+s]=r[t+s];return a.usedBytes=Math.max(a.usedBytes,i+n),n},llseek:function(e,r,t){var n=r;if(1===t?n+=e.position:2===t&&he.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new he.ErrnoError(28);return n},allocate:function(e,r,t){ge.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t)},mmap:function(e,r,t,n,i){if(!he.isFile(e.node.mode))throw new he.ErrnoError(43);var o,a,s=e.node.contents;if(2&i||s.buffer!==C){if((t>0||t+r<s.length)&&(s=s.subarray?s.subarray(t,t+r):Array.prototype.slice.call(s,t,t+r)),a=!0,!(o=ve()))throw new he.ErrnoError(48);o>>>=0,j.set(s,o>>>0)}else a=!1,o=s.byteOffset;return{ptr:o,allocated:a}},msync:function(e,r,t,n,i){return ge.stream_ops.write(e,r,0,n,t,!1),0}}},he={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(e,r={})=>{if(!(e=de.resolve(e)))return{path:"",node:null};if((r=Object.assign({follow_mount:!0,recurse_count:0},r)).recurse_count>8)throw new he.ErrnoError(32);for(var t=e.split("/").filter((e=>!!e)),n=he.root,i="/",o=0;o<t.length;o++){var a=o===t.length-1;if(a&&r.parent)break;if(n=he.lookupNode(n,t[o]),i=ce.join2(i,t[o]),he.isMountpoint(n)&&(!a||a&&r.follow_mount)&&(n=n.mounted.root),!a||r.follow)for(var s=0;he.isLink(n.mode);){var u=he.readlink(i);if(i=de.resolve(ce.dirname(i),u),n=he.lookupPath(i,{recurse_count:r.recurse_count+1}).node,s++>40)throw new he.ErrnoError(32)}}return{path:i,node:n}},getPath:e=>{for(var r;;){if(he.isRoot(e)){var t=e.mount.mountpoint;return r?"/"!==t[t.length-1]?t+"/"+r:t+r:t}r=r?e.name+"/"+r:e.name,e=e.parent}},hashName:(e,r)=>{for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return(e+t>>>0)%he.nameTable.length},hashAddNode:e=>{var r=he.hashName(e.parent.id,e.name);e.name_next=he.nameTable[r],he.nameTable[r]=e},hashRemoveNode:e=>{var r=he.hashName(e.parent.id,e.name);if(he.nameTable[r]===e)he.nameTable[r]=e.name_next;else for(var t=he.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode:(e,r)=>{var t=he.mayLookup(e);if(t)throw new he.ErrnoError(t,e);for(var n=he.hashName(e.id,r),i=he.nameTable[n];i;i=i.name_next){var o=i.name;if(i.parent.id===e.id&&o===r)return i}return he.lookup(e,r)},createNode:(e,r,t,n)=>{var i=new he.FSNode(e,r,t,n);return he.hashAddNode(i),i},destroyNode:e=>{he.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),isFIFO:e=>4096==(61440&e),isSocket:e=>49152==(49152&e),flagModes:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},modeStringToFlags:e=>{var r=he.flagModes[e];if(void 0===r)throw new Error("Unknown file open mode: "+e);return r},flagsToPermissionString:e=>{var r=["r","w","rw"][3&e];return 512&e&&(r+="w"),r},nodePermissions:(e,r)=>he.ignorePermissions||(!r.includes("r")||292&e.mode)&&(!r.includes("w")||146&e.mode)&&(!r.includes("x")||73&e.mode)?0:2,mayLookup:e=>he.nodePermissions(e,"x")||(e.node_ops.lookup?0:2),mayCreate:(e,r)=>{try{return he.lookupNode(e,r),20}catch(e){}return he.nodePermissions(e,"wx")},mayDelete:(e,r,t)=>{var n;try{n=he.lookupNode(e,r)}catch(e){return e.errno}var i=he.nodePermissions(e,"wx");if(i)return i;if(t){if(!he.isDir(n.mode))return 54;if(he.isRoot(n)||he.getPath(n)===he.cwd())return 10}else if(he.isDir(n.mode))return 31;return 0},mayOpen:(e,r)=>e?he.isLink(e.mode)?32:he.isDir(e.mode)&&("r"!==he.flagsToPermissionString(r)||512&r)?31:he.nodePermissions(e,he.flagsToPermissionString(r)):44,MAX_OPEN_FDS:4096,nextfd:(e=0,r=he.MAX_OPEN_FDS)=>{for(var t=e;t<=r;t++)if(!he.streams[t])return t;throw new he.ErrnoError(33)},getStream:e=>he.streams[e],createStream:(e,r,t)=>{he.FSStream||(he.FSStream=function(){this.shared={}},he.FSStream.prototype={},Object.defineProperties(he.FSStream.prototype,{object:{get:function(){return this.node},set:function(e){this.node=e}},isRead:{get:function(){return 1!=(2097155&this.flags)}},isWrite:{get:function(){return 0!=(2097155&this.flags)}},isAppend:{get:function(){return 1024&this.flags}},flags:{get:function(){return this.shared.flags},set:function(e){this.shared.flags=e}},position:{get:function(){return this.shared.position},set:function(e){this.shared.position=e}}})),e=Object.assign(new he.FSStream,e);var n=he.nextfd(r,t);return e.fd=n,he.streams[n]=e,e},closeStream:e=>{he.streams[e]=null},chrdev_stream_ops:{open:e=>{var r=he.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new he.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,r)=>e<<8|r,registerDevice:(e,r)=>{he.devices[e]={stream_ops:r}},getDevice:e=>he.devices[e],getMounts:e=>{for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push.apply(t,n.mounts)}return r},syncfs:(e,r)=>{"function"==typeof e&&(r=e,e=!1),he.syncFSRequests++,he.syncFSRequests>1&&h("warning: "+he.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work");var t=he.getMounts(he.root.mount),n=0;function i(e){return he.syncFSRequests--,r(e)}function o(e){if(e)return o.errored?void 0:(o.errored=!0,i(e));++n>=t.length&&i(null)}t.forEach((r=>{if(!r.type.syncfs)return o(null);r.type.syncfs(r,e,o)}))},mount:(e,r,t)=>{var n,i="/"===t,o=!t;if(i&&he.root)throw new he.ErrnoError(10);if(!i&&!o){var a=he.lookupPath(t,{follow_mount:!1});if(t=a.path,n=a.node,he.isMountpoint(n))throw new he.ErrnoError(10);if(!he.isDir(n.mode))throw new he.ErrnoError(54)}var s={type:e,opts:r,mountpoint:t,mounts:[]},u=e.mount(s);return u.mount=s,s.root=u,i?he.root=u:n&&(n.mounted=s,n.mount&&n.mount.mounts.push(s)),u},unmount:e=>{var r=he.lookupPath(e,{follow_mount:!1});if(!he.isMountpoint(r.node))throw new he.ErrnoError(28);var t=r.node,n=t.mounted,i=he.getMounts(n);Object.keys(he.nameTable).forEach((e=>{for(var r=he.nameTable[e];r;){var t=r.name_next;i.includes(r.mount)&&he.destroyNode(r),r=t}})),t.mounted=null;var o=t.mount.mounts.indexOf(n);t.mount.mounts.splice(o,1)},lookup:(e,r)=>e.node_ops.lookup(e,r),mknod:(e,r,t)=>{var n=he.lookupPath(e,{parent:!0}).node,i=ce.basename(e);if(!i||"."===i||".."===i)throw new he.ErrnoError(28);var o=he.mayCreate(n,i);if(o)throw new he.ErrnoError(o);if(!n.node_ops.mknod)throw new he.ErrnoError(63);return n.node_ops.mknod(n,i,r,t)},create:(e,r)=>(r=void 0!==r?r:438,r&=4095,r|=32768,he.mknod(e,r,0)),mkdir:(e,r)=>(r=void 0!==r?r:511,r&=1023,r|=16384,he.mknod(e,r,0)),mkdirTree:(e,r)=>{for(var t=e.split("/"),n="",i=0;i<t.length;++i)if(t[i]){n+="/"+t[i];try{he.mkdir(n,r)}catch(e){if(20!=e.errno)throw e}}},mkdev:(e,r,t)=>(void 0===t&&(t=r,r=438),r|=8192,he.mknod(e,r,t)),symlink:(e,r)=>{if(!de.resolve(e))throw new he.ErrnoError(44);var t=he.lookupPath(r,{parent:!0}).node;if(!t)throw new he.ErrnoError(44);var n=ce.basename(r),i=he.mayCreate(t,n);if(i)throw new he.ErrnoError(i);if(!t.node_ops.symlink)throw new he.ErrnoError(63);return t.node_ops.symlink(t,n,e)},rename:(e,r)=>{var t,n,i=ce.dirname(e),o=ce.dirname(r),a=ce.basename(e),s=ce.basename(r);if(t=he.lookupPath(e,{parent:!0}).node,n=he.lookupPath(r,{parent:!0}).node,!t||!n)throw new he.ErrnoError(44);if(t.mount!==n.mount)throw new he.ErrnoError(75);var u,l=he.lookupNode(t,a),c=de.relative(e,o);if("."!==c.charAt(0))throw new he.ErrnoError(28);if("."!==(c=de.relative(r,i)).charAt(0))throw new he.ErrnoError(55);try{u=he.lookupNode(n,s)}catch(e){}if(l!==u){var f=he.isDir(l.mode),d=he.mayDelete(t,a,f);if(d)throw new he.ErrnoError(d);if(d=u?he.mayDelete(n,s,f):he.mayCreate(n,s))throw new he.ErrnoError(d);if(!t.node_ops.rename)throw new he.ErrnoError(63);if(he.isMountpoint(l)||u&&he.isMountpoint(u))throw new he.ErrnoError(10);if(n!==t&&(d=he.nodePermissions(t,"w")))throw new he.ErrnoError(d);he.hashRemoveNode(l);try{t.node_ops.rename(l,n,s)}catch(e){throw e}finally{he.hashAddNode(l)}}},rmdir:e=>{var r=he.lookupPath(e,{parent:!0}).node,t=ce.basename(e),n=he.lookupNode(r,t),i=he.mayDelete(r,t,!0);if(i)throw new he.ErrnoError(i);if(!r.node_ops.rmdir)throw new he.ErrnoError(63);if(he.isMountpoint(n))throw new he.ErrnoError(10);r.node_ops.rmdir(r,t),he.destroyNode(n)},readdir:e=>{var r=he.lookupPath(e,{follow:!0}).node;if(!r.node_ops.readdir)throw new he.ErrnoError(54);return r.node_ops.readdir(r)},unlink:e=>{var r=he.lookupPath(e,{parent:!0}).node;if(!r)throw new he.ErrnoError(44);var t=ce.basename(e),n=he.lookupNode(r,t),i=he.mayDelete(r,t,!1);if(i)throw new he.ErrnoError(i);if(!r.node_ops.unlink)throw new he.ErrnoError(63);if(he.isMountpoint(n))throw new he.ErrnoError(10);r.node_ops.unlink(r,t),he.destroyNode(n)},readlink:e=>{var r=he.lookupPath(e).node;if(!r)throw new he.ErrnoError(44);if(!r.node_ops.readlink)throw new he.ErrnoError(28);return de.resolve(he.getPath(r.parent),r.node_ops.readlink(r))},stat:(e,r)=>{var t=he.lookupPath(e,{follow:!r}).node;if(!t)throw new he.ErrnoError(44);if(!t.node_ops.getattr)throw new he.ErrnoError(63);return t.node_ops.getattr(t)},lstat:e=>he.stat(e,!0),chmod:(e,r,t)=>{var n;if(!(n="string"==typeof e?he.lookupPath(e,{follow:!t}).node:e).node_ops.setattr)throw new he.ErrnoError(63);n.node_ops.setattr(n,{mode:4095&r|-4096&n.mode,timestamp:Date.now()})},lchmod:(e,r)=>{he.chmod(e,r,!0)},fchmod:(e,r)=>{var t=he.getStream(e);if(!t)throw new he.ErrnoError(8);he.chmod(t.node,r)},chown:(e,r,t,n)=>{var i;if(!(i="string"==typeof e?he.lookupPath(e,{follow:!n}).node:e).node_ops.setattr)throw new he.ErrnoError(63);i.node_ops.setattr(i,{timestamp:Date.now()})},lchown:(e,r,t)=>{he.chown(e,r,t,!0)},fchown:(e,r,t)=>{var n=he.getStream(e);if(!n)throw new he.ErrnoError(8);he.chown(n.node,r,t)},truncate:(e,r)=>{if(r<0)throw new he.ErrnoError(28);var t;if(!(t="string"==typeof e?he.lookupPath(e,{follow:!0}).node:e).node_ops.setattr)throw new he.ErrnoError(63);if(he.isDir(t.mode))throw new he.ErrnoError(31);if(!he.isFile(t.mode))throw new he.ErrnoError(28);var n=he.nodePermissions(t,"w");if(n)throw new he.ErrnoError(n);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate:(e,r)=>{var t=he.getStream(e);if(!t)throw new he.ErrnoError(8);if(0==(2097155&t.flags))throw new he.ErrnoError(28);he.truncate(t.node,r)},utime:(e,r,t)=>{var n=he.lookupPath(e,{follow:!0}).node;n.node_ops.setattr(n,{timestamp:Math.max(r,t)})},open:(e,t,n)=>{if(""===e)throw new he.ErrnoError(44);var i;if(n=void 0===n?438:n,n=64&(t="string"==typeof t?he.modeStringToFlags(t):t)?4095&n|32768:0,"object"==typeof e)i=e;else{e=ce.normalize(e);try{i=he.lookupPath(e,{follow:!(131072&t)}).node}catch(e){}}var o=!1;if(64&t)if(i){if(128&t)throw new he.ErrnoError(20)}else i=he.mknod(e,n,0),o=!0;if(!i)throw new he.ErrnoError(44);if(he.isChrdev(i.mode)&&(t&=-513),65536&t&&!he.isDir(i.mode))throw new he.ErrnoError(54);if(!o){var a=he.mayOpen(i,t);if(a)throw new he.ErrnoError(a)}512&t&&!o&&he.truncate(i,0),t&=-131713;var s=he.createStream({node:i,path:he.getPath(i),flags:t,seekable:!0,position:0,stream_ops:i.stream_ops,ungotten:[],error:!1});return s.stream_ops.open&&s.stream_ops.open(s),!r.logReadFiles||1&t||(he.readFiles||(he.readFiles={}),e in he.readFiles||(he.readFiles[e]=1)),s},close:e=>{if(he.isClosed(e))throw new he.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{he.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek:(e,r,t)=>{if(he.isClosed(e))throw new he.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new he.ErrnoError(70);if(0!=t&&1!=t&&2!=t)throw new he.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read:(e,r,t,n,i)=>{if(t>>>=0,n<0||i<0)throw new he.ErrnoError(28);if(he.isClosed(e))throw new he.ErrnoError(8);if(1==(2097155&e.flags))throw new he.ErrnoError(8);if(he.isDir(e.node.mode))throw new he.ErrnoError(31);if(!e.stream_ops.read)throw new he.ErrnoError(28);var o=void 0!==i;if(o){if(!e.seekable)throw new he.ErrnoError(70)}else i=e.position;var a=e.stream_ops.read(e,r,t,n,i);return o||(e.position+=a),a},write:(e,r,t,n,i,o)=>{if(t>>>=0,n<0||i<0)throw new he.ErrnoError(28);if(he.isClosed(e))throw new he.ErrnoError(8);if(0==(2097155&e.flags))throw new he.ErrnoError(8);if(he.isDir(e.node.mode))throw new he.ErrnoError(31);if(!e.stream_ops.write)throw new he.ErrnoError(28);e.seekable&&1024&e.flags&&he.llseek(e,0,2);var a=void 0!==i;if(a){if(!e.seekable)throw new he.ErrnoError(70)}else i=e.position;var s=e.stream_ops.write(e,r,t,n,i,o);return a||(e.position+=s),s},allocate:(e,r,t)=>{if(he.isClosed(e))throw new he.ErrnoError(8);if(r<0||t<=0)throw new he.ErrnoError(28);if(0==(2097155&e.flags))throw new he.ErrnoError(8);if(!he.isFile(e.node.mode)&&!he.isDir(e.node.mode))throw new he.ErrnoError(43);if(!e.stream_ops.allocate)throw new he.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap:(e,r,t,n,i)=>{if(0!=(2&n)&&0==(2&i)&&2!=(2097155&e.flags))throw new he.ErrnoError(2);if(1==(2097155&e.flags))throw new he.ErrnoError(2);if(!e.stream_ops.mmap)throw new he.ErrnoError(43);return e.stream_ops.mmap(e,r,t,n,i)},msync:(e,r,t,n,i)=>(t>>>=0,e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,i):0),munmap:e=>0,ioctl:(e,r,t)=>{if(!e.stream_ops.ioctl)throw new he.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile:(e,r={})=>{if(r.flags=r.flags||0,r.encoding=r.encoding||"binary","utf8"!==r.encoding&&"binary"!==r.encoding)throw new Error('Invalid encoding type "'+r.encoding+'"');var t,n=he.open(e,r.flags),i=he.stat(e).size,o=new Uint8Array(i);return he.read(n,o,0,i,0),"utf8"===r.encoding?t=M(o,0):"binary"===r.encoding&&(t=o),he.close(n),t},writeFile:(e,r,t={})=>{t.flags=t.flags||577;var n=he.open(e,t.flags,t.mode);if("string"==typeof r){var i=new Uint8Array(U(r)+1),o=R(r,i,0,i.length);he.write(n,i,0,o,void 0,t.canOwn)}else{if(!ArrayBuffer.isView(r))throw new Error("Unsupported data type");he.write(n,r,0,r.byteLength,void 0,t.canOwn)}he.close(n)},cwd:()=>he.currentPath,chdir:e=>{var r=he.lookupPath(e,{follow:!0});if(null===r.node)throw new he.ErrnoError(44);if(!he.isDir(r.node.mode))throw new he.ErrnoError(54);var t=he.nodePermissions(r.node,"x");if(t)throw new he.ErrnoError(t);he.currentPath=r.path},createDefaultDirectories:()=>{he.mkdir("/tmp"),he.mkdir("/home"),he.mkdir("/home/web_user")},createDefaultDevices:()=>{he.mkdir("/dev"),he.registerDevice(he.makedev(1,3),{read:()=>0,write:(e,r,t,n,i)=>n}),he.mkdev("/dev/null",he.makedev(1,3)),pe.register(he.makedev(5,0),pe.default_tty_ops),pe.register(he.makedev(6,0),pe.default_tty1_ops),he.mkdev("/dev/tty",he.makedev(5,0)),he.mkdev("/dev/tty1",he.makedev(6,0));var e=fe();he.createDevice("/dev","random",e),he.createDevice("/dev","urandom",e),he.mkdir("/dev/shm"),he.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{he.mkdir("/proc");var e=he.mkdir("/proc/self");he.mkdir("/proc/self/fd"),he.mount({mount:()=>{var r=he.createNode(e,"fd",16895,73);return r.node_ops={lookup:(e,r)=>{var t=+r,n=he.getStream(t);if(!n)throw new he.ErrnoError(8);var i={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>n.path}};return i.parent=i,i}},r}},{},"/proc/self/fd")},createStandardStreams:()=>{r.stdin?he.createDevice("/dev","stdin",r.stdin):he.symlink("/dev/tty","/dev/stdin"),r.stdout?he.createDevice("/dev","stdout",null,r.stdout):he.symlink("/dev/tty","/dev/stdout"),r.stderr?he.createDevice("/dev","stderr",null,r.stderr):he.symlink("/dev/tty1","/dev/stderr"),he.open("/dev/stdin",0),he.open("/dev/stdout",1),he.open("/dev/stderr",1)},ensureErrnoError:()=>{he.ErrnoError||(he.ErrnoError=function(e,r){this.node=r,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},he.ErrnoError.prototype=new Error,he.ErrnoError.prototype.constructor=he.ErrnoError,[44].forEach((e=>{he.genericErrors[e]=new he.ErrnoError(e),he.genericErrors[e].stack="<generic error, no stack>"})))},staticInit:()=>{he.ensureErrnoError(),he.nameTable=new Array(4096),he.mount(ge,{},"/"),he.createDefaultDirectories(),he.createDefaultDevices(),he.createSpecialDirectories(),he.filesystems={MEMFS:ge}},init:(e,t,n)=>{he.init.initialized=!0,he.ensureErrnoError(),r.stdin=e||r.stdin,r.stdout=t||r.stdout,r.stderr=n||r.stderr,he.createStandardStreams()},quit:()=>{he.init.initialized=!1;for(var e=0;e<he.streams.length;e++){var r=he.streams[e];r&&he.close(r)}},getMode:(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},findObject:(e,r)=>{var t=he.analyzePath(e,r);return t.exists?t.object:null},analyzePath:(e,r)=>{try{e=(n=he.lookupPath(e,{follow:!r})).path}catch(e){}var t={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var n=he.lookupPath(e,{parent:!0});t.parentExists=!0,t.parentPath=n.path,t.parentObject=n.node,t.name=ce.basename(e),n=he.lookupPath(e,{follow:!r}),t.exists=!0,t.path=n.path,t.object=n.node,t.name=n.node.name,t.isRoot="/"===n.path}catch(e){t.error=e.errno}return t},createPath:(e,r,t,n)=>{e="string"==typeof e?e:he.getPath(e);for(var i=r.split("/").reverse();i.length;){var o=i.pop();if(o){var a=ce.join2(e,o);try{he.mkdir(a)}catch(e){}e=a}}return a},createFile:(e,r,t,n,i)=>{var o=ce.join2("string"==typeof e?e:he.getPath(e),r),a=he.getMode(n,i);return he.create(o,a)},createDataFile:(e,r,t,n,i,o)=>{var a=r;e&&(e="string"==typeof e?e:he.getPath(e),a=r?ce.join2(e,r):e);var s=he.getMode(n,i),u=he.create(a,s);if(t){if("string"==typeof t){for(var l=new Array(t.length),c=0,f=t.length;c<f;++c)l[c]=t.charCodeAt(c);t=l}he.chmod(u,146|s);var d=he.open(u,577);he.write(d,t,0,t.length,0,o),he.close(d),he.chmod(u,s)}return u},createDevice:(e,r,t,n)=>{var i=ce.join2("string"==typeof e?e:he.getPath(e),r),o=he.getMode(!!t,!!n);he.createDevice.major||(he.createDevice.major=64);var a=he.makedev(he.createDevice.major++,0);return he.registerDevice(a,{open:e=>{e.seekable=!1},close:e=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(e,r,n,i,o)=>{for(var a=0,s=0;s<i;s++){var u;try{u=t()}catch(e){throw new he.ErrnoError(29)}if(void 0===u&&0===a)throw new he.ErrnoError(6);if(null==u)break;a++,r[n+s]=u}return a&&(e.node.timestamp=Date.now()),a},write:(e,r,t,i,o)=>{for(var a=0;a<i;a++)try{n(r[t+a])}catch(e){throw new he.ErrnoError(29)}return i&&(e.node.timestamp=Date.now()),a}}),he.mkdev(i,o,a)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!t)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=me(t(e.url),!0),e.usedBytes=e.contents.length}catch(e){throw new he.ErrnoError(29)}},createLazyFile:(e,r,t,n,i)=>{function o(){this.lengthKnown=!1,this.chunks=[]}if(o.prototype.get=function(e){if(!(e>this.length-1||e<0)){var r=e%this.chunkSize,t=e/this.chunkSize|0;return this.getter(t)[r]}},o.prototype.setDataGetter=function(e){this.getter=e},o.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",t,!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+t+". Status: "+e.status);var r,n=Number(e.getResponseHeader("Content-length")),i=(r=e.getResponseHeader("Accept-Ranges"))&&"bytes"===r,o=(r=e.getResponseHeader("Content-Encoding"))&&"gzip"===r,a=1048576;i||(a=n);var s=this;s.setDataGetter((e=>{var r=e*a,i=(e+1)*a-1;if(i=Math.min(i,n-1),void 0===s.chunks[e]&&(s.chunks[e]=((e,r)=>{if(e>r)throw new Error("invalid range ("+e+", "+r+") or no bytes requested!");if(r>n-1)throw new Error("only "+n+" bytes available! programmer error!");var i=new XMLHttpRequest;if(i.open("GET",t,!1),n!==a&&i.setRequestHeader("Range","bytes="+e+"-"+r),i.responseType="arraybuffer",i.overrideMimeType&&i.overrideMimeType("text/plain; charset=x-user-defined"),i.send(null),!(i.status>=200&&i.status<300||304===i.status))throw new Error("Couldn't load "+t+". Status: "+i.status);return void 0!==i.response?new Uint8Array(i.response||[]):me(i.responseText||"",!0)})(r,i)),void 0===s.chunks[e])throw new Error("doXHR failed!");return s.chunks[e]})),!o&&n||(a=n=1,n=this.getter(0).length,a=n,g("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=n,this._chunkSize=a,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest){if(!c)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var a=new o;Object.defineProperties(a,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var s={isDevice:!1,contents:a}}else s={isDevice:!1,url:t};var u=he.createFile(e,r,s,n,i);s.contents?u.contents=s.contents:s.url&&(u.contents=null,u.url=s.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var l={};function f(e,r,t,n,i){var o=e.node.contents;if(i>=o.length)return 0;var a=Math.min(o.length-i,n);if(o.slice)for(var s=0;s<a;s++)r[t+s]=o[i+s];else for(s=0;s<a;s++)r[t+s]=o.get(i+s);return a}return Object.keys(u.stream_ops).forEach((e=>{var r=u.stream_ops[e];l[e]=function(){return he.forceLoadFile(u),r.apply(null,arguments)}})),l.read=(e,r,t,n,i)=>(he.forceLoadFile(u),f(e,r,t,n,i)),l.mmap=(e,r,t,n,i)=>{he.forceLoadFile(u);var o=ve();if(!o)throw new he.ErrnoError(48);return f(e,j,o,r,t),{ptr:o,allocated:!0}},u.stream_ops=l,u},createPreloadedFile:(e,r,t,i,o,a,s,u,l,c)=>{var f=r?de.resolve(ce.join2(e,r)):e;function d(t){function n(t){c&&c(),u||he.createDataFile(e,r,t,i,o,l),a&&a(),ee()}Browser.handledByPreloadPlugin(t,f,n,(()=>{s&&s(),ee()}))||n(t)}Z(),"string"==typeof t?function(e,r,t,i){var o="al "+e;n(e,(r=>{E(r,'Loading data file "'+e+'" failed (no arrayBuffer).'),d(new Uint8Array(r)),o&&ee()}),(r=>{if(!t)throw'Loading data file "'+e+'" failed.';t()})),o&&Z()}(t,0,s):d(t)},indexedDB:()=>window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,DB_NAME:()=>"EM_FS_"+window.location.pathname,DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:(e,r,t)=>{r=r||(()=>{}),t=t||(()=>{});var n=he.indexedDB();try{var i=n.open(he.DB_NAME(),he.DB_VERSION)}catch(e){return t(e)}i.onupgradeneeded=()=>{g("creating db"),i.result.createObjectStore(he.DB_STORE_NAME)},i.onsuccess=()=>{var n=i.result.transaction([he.DB_STORE_NAME],"readwrite"),o=n.objectStore(he.DB_STORE_NAME),a=0,s=0,u=e.length;function l(){0==s?r():t()}e.forEach((e=>{var r=o.put(he.analyzePath(e).object.contents,e);r.onsuccess=()=>{++a+s==u&&l()},r.onerror=()=>{s++,a+s==u&&l()}})),n.onerror=t},i.onerror=t},loadFilesFromDB:(e,r,t)=>{r=r||(()=>{}),t=t||(()=>{});var n=he.indexedDB();try{var i=n.open(he.DB_NAME(),he.DB_VERSION)}catch(e){return t(e)}i.onupgradeneeded=t,i.onsuccess=()=>{var n=i.result;try{var o=n.transaction([he.DB_STORE_NAME],"readonly")}catch(e){return void t(e)}var a=o.objectStore(he.DB_STORE_NAME),s=0,u=0,l=e.length;function c(){0==u?r():t()}e.forEach((e=>{var r=a.get(e);r.onsuccess=()=>{he.analyzePath(e).exists&&he.unlink(e),he.createDataFile(ce.dirname(e),ce.basename(e),r.result,!0,!0,!0),++s+u==l&&c()},r.onerror=()=>{u++,s+u==l&&c()}})),o.onerror=t},i.onerror=t}},ye={DEFAULT_POLLMASK:5,calculateAt:function(e,r,t){if(ce.isAbs(r))return r;var n;if(n=-100===e?he.cwd():ye.getStreamFromFD(e).path,0==r.length){if(!t)throw new he.ErrnoError(44);return n}return ce.join2(n,r)},doStat:function(e,r,t){try{var n=e(r)}catch(e){if(e&&e.node&&ce.normalize(r)!==ce.normalize(he.getPath(e.node)))return-54;throw e}S[t>>>2]=n.dev,S[t+8>>>2]=n.ino,S[t+12>>>2]=n.mode,P[t+16>>>2]=n.nlink,S[t+20>>>2]=n.uid,S[t+24>>>2]=n.gid,S[t+28>>>2]=n.rdev,Y=[n.size>>>0,(X=n.size,+Math.abs(X)>=1?X>0?(0|Math.min(+Math.floor(X/4294967296),4294967295))>>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],S[t+40>>>2]=Y[0],S[t+44>>>2]=Y[1],S[t+48>>>2]=4096,S[t+52>>>2]=n.blocks;var i=n.atime.getTime(),o=n.mtime.getTime(),a=n.ctime.getTime();return Y=[Math.floor(i/1e3)>>>0,(X=Math.floor(i/1e3),+Math.abs(X)>=1?X>0?(0|Math.min(+Math.floor(X/4294967296),4294967295))>>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],S[t+56>>>2]=Y[0],S[t+60>>>2]=Y[1],P[t+64>>>2]=i%1e3*1e3,Y=[Math.floor(o/1e3)>>>0,(X=Math.floor(o/1e3),+Math.abs(X)>=1?X>0?(0|Math.min(+Math.floor(X/4294967296),4294967295))>>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],S[t+72>>>2]=Y[0],S[t+76>>>2]=Y[1],P[t+80>>>2]=o%1e3*1e3,Y=[Math.floor(a/1e3)>>>0,(X=Math.floor(a/1e3),+Math.abs(X)>=1?X>0?(0|Math.min(+Math.floor(X/4294967296),4294967295))>>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],S[t+88>>>2]=Y[0],S[t+92>>>2]=Y[1],P[t+96>>>2]=a%1e3*1e3,Y=[n.ino>>>0,(X=n.ino,+Math.abs(X)>=1?X>0?(0|Math.min(+Math.floor(X/4294967296),4294967295))>>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],S[t+104>>>2]=Y[0],S[t+108>>>2]=Y[1],0},doMsync:function(e,r,t,n,i){if(!he.isFile(r.node.mode))throw new he.ErrnoError(43);if(2&n)return 0;e>>>=0;var o=T.slice(e,e+t);he.msync(r,o,i,t,n)},varargs:void 0,get:function(){return ye.varargs+=4,S[ye.varargs-4>>>2]},getStr:function(e){return L(e)},getStreamFromFD:function(e){var r=he.getStream(e);if(!r)throw new he.ErrnoError(8);return r}};function _e(e,r){return r+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*r:NaN}var we={};function be(e){for(;e.length;){var r=e.pop();e.pop()(r)}}function Ee(e){return this.fromWireType(S[e>>>2])}var Ce={},je={},Te={};function xe(e){if(void 0===e)return"_unknown";var r=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return r>=48&&r<=57?"_"+e:e}function ke(e,r){return e=xe(e),new Function("body","return function "+e+'() {\n "use strict"; return body.apply(this, arguments);\n};\n')(r)}function Se(e,r){var t=ke(r,(function(e){this.name=r,this.message=e;var t=new Error(e).stack;void 0!==t&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))}));return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},t}var Pe=void 0;function Ae(e){throw new Pe(e)}function De(e,r,t){function n(r){var n=t(r);n.length!==e.length&&Ae("Mismatched type converter count");for(var i=0;i<e.length;++i)Oe(e[i],n[i])}e.forEach((function(e){Te[e]=r}));var i=new Array(r.length),o=[],a=0;r.forEach(((e,r)=>{je.hasOwnProperty(e)?i[r]=je[e]:(o.push(e),Ce.hasOwnProperty(e)||(Ce[e]=[]),Ce[e].push((()=>{i[r]=je[e],++a===o.length&&n(i)})))})),0===o.length&&n(i)}var Fe={};function Me(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+e)}}var Le=void 0;function Re(e){for(var r="",t=e;T[t>>>0];)r+=Le[T[t++>>>0]];return r}var Be=void 0;function Ue(e){throw new Be(e)}function Oe(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");var n=r.name;if(e||Ue('type "'+n+'" must have a positive integer typeid pointer'),je.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;Ue("Cannot register type '"+n+"' twice")}if(je[e]=r,delete Te[e],Ce.hasOwnProperty(e)){var i=Ce[e];delete Ce[e],i.forEach((e=>e()))}}function Ne(e){Ue(e.$$.ptrType.registeredClass.name+" instance already deleted")}var Ie=!1;function $e(e){}function Ge(e){e.count.value-=1,0===e.count.value&&function(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}(e)}function He(e,r,t){if(r===t)return e;if(void 0===t.baseClass)return null;var n=He(e,r,t.baseClass);return null===n?null:t.downcast(n)}var We={};var Ve=[];function ze(){for(;Ve.length;){var e=Ve.pop();e.$$.deleteScheduled=!1,e.delete()}}var qe=void 0;var Xe={};function Ye(e,r){return r.ptrType&&r.ptr||Ae("makeClassHandle requires ptr and ptrType"),!!r.smartPtrType!=!!r.smartPtr&&Ae("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Qe(Object.create(e,{$$:{value:r}}))}function Qe(e){return"undefined"==typeof FinalizationRegistry?(Qe=e=>e,e):(Ie=new FinalizationRegistry((e=>{Ge(e.$$)})),Qe=e=>{var r=e.$$;if(r.smartPtr){var t={$$:r};Ie.register(e,t,e)}return e},$e=e=>Ie.unregister(e),Qe(e))}function Ke(){}function Je(e,r,t){if(void 0===e[r].overloadTable){var n=e[r];e[r]=function(){return e[r].overloadTable.hasOwnProperty(arguments.length)||Ue("Function '"+t+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+e[r].overloadTable+")!"),e[r].overloadTable[arguments.length].apply(this,arguments)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n}}function Ze(e,t,n){r.hasOwnProperty(e)?((void 0===n||void 0!==r[e].overloadTable&&void 0!==r[e].overloadTable[n])&&Ue("Cannot register public name '"+e+"' twice"),Je(r,e,e),r.hasOwnProperty(n)&&Ue("Cannot register multiple overloads of a function with the same number of arguments ("+n+")!"),r[e].overloadTable[n]=t):(r[e]=t,void 0!==n&&(r[e].numArguments=n))}function er(e,r,t,n,i,o,a,s){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=i,this.getActualType=o,this.upcast=a,this.downcast=s,this.pureVirtualFunctions=[]}function rr(e,r,t){for(;r!==t;)r.upcast||Ue("Expected null or instance of "+t.name+", got an instance of "+r.name),e=r.upcast(e),r=r.baseClass;return e}function tr(e,r){if(null===r)return this.isReference&&Ue("null is not a valid "+this.name),0;r.$$||Ue('Cannot pass "'+jr(r)+'" as a '+this.name),r.$$.ptr||Ue("Cannot pass deleted object as a pointer of type "+this.name);var t=r.$$.ptrType.registeredClass;return rr(r.$$.ptr,t,this.registeredClass)}function nr(e,r){var t;if(null===r)return this.isReference&&Ue("null is not a valid "+this.name),this.isSmartPointer?(t=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,t),t):0;r.$$||Ue('Cannot pass "'+jr(r)+'" as a '+this.name),r.$$.ptr||Ue("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&r.$$.ptrType.isConst&&Ue("Cannot convert argument of type "+(r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name)+" to parameter type "+this.name);var n=r.$$.ptrType.registeredClass;if(t=rr(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===r.$$.smartPtr&&Ue("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:Ue("Cannot convert argument of type "+(r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name)+" to parameter type "+this.name);break;case 1:t=r.$$.smartPtr;break;case 2:if(r.$$.smartPtrType===this)t=r.$$.smartPtr;else{var i=r.clone();t=this.rawShare(t,br.toHandle((function(){i.delete()}))),null!==e&&e.push(this.rawDestructor,t)}break;default:Ue("Unsupporting sharing policy")}return t}function ir(e,r){if(null===r)return this.isReference&&Ue("null is not a valid "+this.name),0;r.$$||Ue('Cannot pass "'+jr(r)+'" as a '+this.name),r.$$.ptr||Ue("Cannot pass deleted object as a pointer of type "+this.name),r.$$.ptrType.isConst&&Ue("Cannot convert argument of type "+r.$$.ptrType.name+" to parameter type "+this.name);var t=r.$$.ptrType.registeredClass;return rr(r.$$.ptr,t,this.registeredClass)}function or(e,r,t,n,i,o,a,s,u,l,c){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=i,this.pointeeType=o,this.sharingPolicy=a,this.rawGetPointee=s,this.rawConstructor=u,this.rawShare=l,this.rawDestructor=c,i||void 0!==r.baseClass?this.toWireType=nr:n?(this.toWireType=tr,this.destructorFunction=null):(this.toWireType=ir,this.destructorFunction=null)}function ar(e,t,n){r.hasOwnProperty(e)||Ae("Replacing nonexistant public symbol"),void 0!==r[e].overloadTable&&void 0!==n?r[e].overloadTable[n]=t:(r[e]=t,r[e].argCount=n)}var sr=[];function ur(e){var r=sr[e];return r||(e>=sr.length&&(sr.length=e+1),sr[e]=r=N.get(e)),r}function lr(e,t,n){return e.includes("j")?function(e,t,n){var i=r["dynCall_"+e];return n&&n.length?i.apply(null,[t].concat(n)):i.call(null,t)}(e,t,n):ur(t).apply(null,n)}function cr(e,r){var t,n,i,o=(e=Re(e)).includes("j")?(t=e,n=r,i=[],function(){return i.length=0,Object.assign(i,arguments),lr(t,n,i)}):ur(r);return"function"!=typeof o&&Ue("unknown function pointer with signature "+e+": "+r),o}var fr=void 0;function dr(e){var r=Mt(e),t=Re(r);return Dt(r),t}function mr(e,r){var t=[],n={};throw r.forEach((function e(r){n[r]||je[r]||(Te[r]?Te[r].forEach(e):(t.push(r),n[r]=!0))})),new fr(e+": "+t.map(dr).join([", "]))}function pr(e,r){if(!(e instanceof Function))throw new TypeError("new_ called with constructor type "+typeof e+" which is not a function");var t=ke(e.name||"unknownFunctionName",(function(){}));t.prototype=e.prototype;var n=new t,i=e.apply(n,r);return i instanceof Object?i:n}function vr(e,r,t,n