diff --git a/astro.config.ts b/astro.config.ts index 14db7bf..05678a3 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -4,6 +4,8 @@ import rawFiles from "./astro/raw-files"; // https://astro.build/config export default defineConfig({ + site: 'https://sethp.github.io', + base: 'learn-gpgpu', srcDir: ".", integrations: [rawFiles(".spvasm", ".tcf")], server: (_) => ({ diff --git a/dist/_astro/hoisted.cc73fd08.js b/dist/_astro/hoisted.e1c927ac.js similarity index 83% rename from dist/_astro/hoisted.cc73fd08.js rename to dist/_astro/hoisted.e1c927ac.js index 023ac49..39264ed 100644 --- a/dist/_astro/hoisted.cc73fd08.js +++ b/dist/_astro/hoisted.e1c927ac.js @@ -1,8 +1,8 @@ -const We=document.querySelector("#talvos svg"),He=We.querySelector("tspan.physical"),Ir=We.querySelector("tspan.logical"),cn=We.querySelectorAll(".lane");for(const f of cn)f.addEventListener("mouseenter",function(){He.textContent=this.dataset.phyCoords,Ir.textContent=this.dataset.logCoords??"N/A"}),f.addEventListener("mouseleave",function(){He.textContent="N/A",Ir.textContent="N/A"}),f.addEventListener("click",function(){this.classList.contains(".disabled")||this.classList.toggle("selected")});const un=We.querySelectorAll(".ctrl");for(const[f,u]of un.entries())u.addEventListener("mouseenter",function(){He.textContent=`{ ${f}, [${f*8}-${f*8+7}] }`}),u.addEventListener("mouseleave",function(){He.textContent="N/A"}),u.addEventListener("click",function(){if(!!!this.parentNode.querySelector('.lane[data-state="active"], .lane[data-state="inactive"]'))return;const h=!this.parentNode.querySelector(".lane.selected");this.parentNode.querySelectorAll(".lane").forEach(v=>{v.classList.toggle("selected",h)})});class dn{next;dtor;constructor(u,i){this.next=u,this.dtor=i??(()=>{})}alloc(u){if(u>this.size)throw new Error(`OOM: Arena out of memory: requested ${u} bytes but only ${this.size} bytes remain`);const[i,h]=this.next.reslice(u);return this.next=h,i}free(u){}get size(){return this.next.byteLength}__destroy__(){this.dtor()}}class ${data;constructor(u,i,h){this.data=new DataView(u,i,h)}get addr(){return this.data.byteOffset}get byteLength(){return this.data.byteLength}reslice(u){return[this.slice(0,u),this.slice(u)]}slice(u,i){u=u??0,u=u<0?this.byteLength+u:u,i=i??this.byteLength,i=i<0?this.byteLength+i:i;const h=Math.min(this.addr+u,this.addr+this.byteLength),v=Math.min(Math.max(0,i-u),this.byteLength);return new $(this.data.buffer,h,v)}asRef(){return this.addr}as(u){return new u(this.data.buffer,this.addr,this.byteLength)}static get SIZE(){return 4}getUsize(u,i){return this.data.getUint32(u,i)}deref(u,i,h){return new $(this.data.buffer,this.getUsize(u,h),i)}}const fn=6,mn=await WebAssembly.instantiateStreaming(fetch("data:application/wasm;base64,AGFzbQEAAAABBgFgAX4BfwMCAQAHDgEKaTY0LnBvcGNudAAACggBBgAgAHunCwAKBG5hbWUCAwEAAA=="),{}),hn=mn.instance,vn=hn.exports["i64.popcnt"];class Ye{words;growable;constructor(u,{data:i}={}){this.words=new BigUint64Array(i.buffer,i.byteOffset,i.byteLength>>3),this.growable=!1;for(const h of u??[])this.add(h)}asRef(){return this.words.byteOffset}#e(u){const i=this.words;if(i.length<<6>u)return;if(!this.growable)throw new Error("TODO message");const h=u+64>>>fn,v=Math.max(h<<3,i.byteLength<<4);var b=new BigUint64Array(new ArrayBuffer(v));b.set(this.words),this.words=b}add(u){this.#e(u);const i=u>>>6,h=1n<>>6,h=1n<({size:u.size*f})}function gn(...f){return{size:f.reduce((u,i)=>u+i.size,0)}}class qe{constructor(u){if(this.ptr=u,u.byteLength!=qe.SIZE)throw new Error(`bad size! got ${u.byteLength} wanted ${qe.SIZE}`)}static get SIZE(){return 12}get X(){return this.ptr.data.getUint32(0,ze)}get Y(){return this.ptr.data.getUint32(4,ze)}get Z(){return this.ptr.data.getUint32(8,ze)}}class Ge{constructor(u){if(this.ptr=u,u.byteLength!=Ge.SIZE)throw new Error(`bad size! got ${u.byteLength} wanted ${Ge.SIZE}`)}static get SIZE(){return 2}get Core(){return this.ptr.data.getUint8(0)}get Lane(){return this.ptr.data.getUint8(1)}}var ne=(f=>(f[f.Active=0]="Active",f[f.Inactive=1]="Inactive",f[f.AtBarrier=2]="AtBarrier",f[f.AtBreakpoint=3]="AtBreakpoint",f[f.AtAssert=4]="AtAssert",f[f.AtException=5]="AtException",f[f.NotLaunched=6]="NotLaunched",f[f.Exited=7]="Exited",f[f.UNKNOWN=8]="UNKNOWN",f))(ne||{});class W{constructor(u){if(this.ptr=u,u.byteLength!=W.SIZE)throw new Error(`bad size! got ${u.byteLength} wanted ${W.SIZE}`)}static get SIZE(){return 1304}static get OFFSETS(){return{cores:0,lanes:1,result:2,steppedCores:8,steppedLanes:16,laneStates:24}}static get TYPES(){return{cores:xr,lanes:xr,steppedCores:Ur,steppedLanes:Ur,laneStates:pn(Br)(gn())}}asRef(){return this.ptr.asRef()}get Cores(){return W.TYPES.cores.get(this.ptr,W.OFFSETS.cores)}get Lanes(){return W.TYPES.lanes.get(this.ptr,W.OFFSETS.lanes)}get SteppedCores(){return new Ye(void 0,{data:this.ptr.slice(W.OFFSETS.steppedCores,W.OFFSETS.steppedCores+W.TYPES.steppedCores.size).data})}get SteppedLanes(){return new Ye(void 0,{data:this.ptr.slice(W.OFFSETS.steppedLanes,W.OFFSETS.steppedLanes+W.TYPES.steppedLanes.size).data})}get LaneStates(){var u=Math.min(this.Cores*this.Lanes,Br);const i=this.ptr.slice(24),h={get(v){const b=i.slice(20*v,20*v+20);return{get PhyCoord(){return new Ge(b.slice(0,2))},get LogCoord(){return new qe(b.slice(4,16))},get State(){return b.data.getInt32(16,ze)}}},[Symbol.iterator]:()=>{var v=0;return{next(){return v>=u?{done:!0,value:void 0}:{done:!1,value:h.get(v++)}}}}};return h}}const Br=64;var En=new TextEncoder,yn=(f,u,i,h)=>{if(!(h>0))return 0;if(f.length>16){const{written:I}=En.encodeInto(f,u.subarray(i,h));return I}for(var v=i,b=i+h-1,N=0;N=55296&&p<=57343){var P=f.charCodeAt(++N);p=65536+((p&1023)<<10)|P&1023}if(p<=127){if(i>=b)break;u[i++]=p}else if(p<=2047){if(i+1>=b)break;u[i++]=192|p>>6,u[i++]=128|p&63}else if(p<=65535){if(i+2>=b)break;u[i++]=224|p>>12,u[i++]=128|p>>6&63,u[i++]=128|p&63}else{if(i+3>=b)break;if(p>1114111)throw new Error("Invalid Unicode code point");u[i++]=240|p>>18,u[i++]=128|p>>12&63,u[i++]=128|p>>6&63,u[i++]=128|p&63}}return u[i]=0,i-v},zr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,_n=(f,u,i,h)=>{const v=u+i,b=h?u+h:(()=>{let ce=u;for(;f[ce]&&!(ce>=v);)++ce;return ce})();if(b-u>16&&f.buffer&&zr)return zr.decode(f.subarray(u,b));for(var N="";u>10,56320|le&1023)}}return N},wn=new TextDecoder("utf8");class Hr{constructor(u){this.ptr=u}static get SIZE(){return 12}get __is_long(){return!!(this.ptr.data.getUint8(11)&128)}get data(){return this.__is_long?this.ptr.deref(0,this.length,!0):this.ptr.slice(0,this.length)}get length(){return this.__is_long?this.ptr.data.getUint32(4,!0):this.ptr.data.getUint8(11)&127}get capacity(){return this.__is_long?this.ptr.data.getUint32(8,!0)^2147483648:10}asString(){return wn.decode(this.data.as(Uint8Array))}get[Symbol.toStringTag](){return`std::string(${this.asString})`}}class Yr{constructor(u){this.ptr=u}static get SIZE(){return 64}get EntryName(){return _n(this.ptr.slice(0,64).as(Uint8Array),0,64)}set EntryName(u){if(yn(u,this.ptr.slice(0,64).as(Uint8Array),0,64)b)throw new Error(`out of bounds access: for index ${u} with elements [0, ${b}]`);return new Be(i.deref(u*$.SIZE,Be.SIZE,!0))}[Symbol.iterator](){const[u,i]=[this.ptr.deref(0*$.SIZE,void 0,!0),this.ptr.deref(1*$.SIZE,0,!0)],h=$.SIZE;var v=u;return{next(){if(v.addr>=i.addr)return{done:!0,value:void 0};const b={done:!1,value:new Be(v.deref(0,Be.SIZE,!0))};return v=v.slice(h),b}}}}class Gr{constructor(u){this.ptr=u}static get SIZE(){return 104}get EntryPoints(){return new qr(this.ptr.slice(40,40+qr.SIZE))}}var Sn=(()=>{var f=import.meta.url;return function(u={}){var i=u,h,v;i.ready=new Promise((e,r)=>{h=e,v=r}),["_malloc","_free","getExceptionMessage","___get_exception_message","___cpp_exception","___cxa_increment_exception_refcount","___cxa_decrement_exception_refcount","___thrown_object_from_unwind_exception","_memory","_Session__create__","_Session__destroy__","_Session__params_ref","_Session__module_ref","_Session_run","_Session_start","_Session_printContext","_Session_step","_Session_continue","_Session_print","_Session_switch","_validate_wasm","_run_wasm","_debug_wasm","_Session_fetch_shrubbery","_exception","_assertion","___indirect_function_table","_fflush","onRuntimeInitialized"].forEach(e=>{Object.getOwnPropertyDescriptor(i.ready,e)||Object.defineProperty(i.ready,e,{get:()=>z("You are getting "+e+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js"),set:()=>z("You are setting "+e+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")})});var b=Object.assign({},i),N="./this.program",p=(e,r)=>{throw r},P=!0,I=!1,le=!1,ce=!1;if(i.ENVIRONMENT)throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");var X="";function Ve(e){return i.locateFile?i.locateFile(e,X):X+e}var we,Ee;{if(typeof document<"u"&&document.currentScript&&(X=document.currentScript.src),f&&(X=f),X.indexOf("blob:")!==0?X=X.substr(0,X.replace(/[?#].*/,"").lastIndexOf("/")+1):X="",!(typeof window=="object"||typeof importScripts=="function"))throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");we=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},Ee=(e,r,t)=>{var o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType="arraybuffer",o.onload=()=>{if(o.status==200||o.status==0&&o.response){r(o.response);return}t()},o.onerror=t,o.send(null)}}var ee=i.print||console.log.bind(console),B=i.printErr||console.error.bind(console);Object.assign(i,b),b=null,Qt(),i.arguments&&i.arguments,re("arguments","arguments_"),i.thisProgram&&(N=i.thisProgram),re("thisProgram","thisProgram"),i.quit&&(p=i.quit),re("quit","quit_"),g(typeof i.memoryInitializerPrefixURL>"u","Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),g(typeof i.pthreadMainPrefixURL>"u","Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),g(typeof i.cdInitializerPrefixURL>"u","Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),g(typeof i.filePackagePrefixURL>"u","Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),g(typeof i.read>"u","Module.read option was removed (modify read_ in JS)"),g(typeof i.readAsync>"u","Module.readAsync option was removed (modify readAsync in JS)"),g(typeof i.readBinary>"u","Module.readBinary option was removed (modify readBinary in JS)"),g(typeof i.setWindowTitle>"u","Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),g(typeof i.TOTAL_MEMORY>"u","Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),re("asm","wasmExports"),re("read","read_"),re("readAsync","readAsync"),re("readBinary","readBinary"),re("setWindowTitle","setWindowTitle"),g(!I,"worker environment detected but not enabled at build time. Add 'worker' to `-sENVIRONMENT` to enable."),g(!le,"node environment detected but not enabled at build time. Add 'node' to `-sENVIRONMENT` to enable."),g(!ce,"shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable.");var fe;i.wasmBinary&&(fe=i.wasmBinary),re("wasmBinary","wasmBinary");var Se=i.noExitRuntime||!0;re("noExitRuntime","noExitRuntime"),typeof WebAssembly!="object"&&z("no native wasm support detected");var me,he=!1;function g(e,r){e||z("Assertion failed"+(r?": "+r:""))}var q,ue,oe,F,S,O;function j(){var e=me.buffer;i.HEAP8=q=new Int8Array(e),i.HEAP16=oe=new Int16Array(e),i.HEAPU8=ue=new Uint8Array(e),i.HEAPU16=new Uint16Array(e),i.HEAP32=F=new Int32Array(e),i.HEAPU32=S=new Uint32Array(e),i.HEAPF32=new Float32Array(e),i.HEAPF64=new Float64Array(e),i.HEAP64=O=new BigInt64Array(e),i.HEAPU64=new BigUint64Array(e)}g(!i.STACK_SIZE,"STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),g(typeof Int32Array<"u"&&typeof Float64Array<"u"&&Int32Array.prototype.subarray!=null&&Int32Array.prototype.set!=null,"JS engine does not provide full typed array support"),g(!i.wasmMemory,"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),g(!i.INITIAL_MEMORY,"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically");function be(){var e=or();g((e&3)==0),e==0&&(e+=4),S[e>>2]=34821223,S[e+4>>2]=2310721022,S[0]=1668509029}function ke(){if(!he){var e=or();e==0&&(e+=4);var r=S[e>>2],t=S[e+4>>2];(r!=34821223||t!=2310721022)&&z(`Stack overflow! Stack cookie has been overwritten at ${Te(e)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${Te(t)} ${Te(r)}`),S[0]!=1668509029&&z("Runtime error: The application has corrupted its heap memory area (address zero)!")}}(function(){var e=new Int16Array(1),r=new Int8Array(e.buffer);if(e[0]=25459,r[0]!==115||r[1]!==99)throw"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)"})();var De=[],cr=[],ur=[],Me=!1,dr=0;function fr(){return Se||dr>0}function Wr(){if(i.preRun)for(typeof i.preRun=="function"&&(i.preRun=[i.preRun]);i.preRun.length;)Vr(i.preRun.shift());Xe(De)}function $r(){g(!Me),Me=!0,ke(),!i.noFSInit&&!n.init.initialized&&n.init(),n.ignorePermissions=!1,Xe(cr)}function jr(){if(ke(),i.postRun)for(typeof i.postRun=="function"&&(i.postRun=[i.postRun]);i.postRun.length;)Xr(i.postRun.shift());Xe(ur)}function Vr(e){De.unshift(e)}function Zr(e){cr.unshift(e)}function Xr(e){ur.unshift(e)}g(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),g(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),g(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),g(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill");var ve=0,pe=null,Ae=null,ye={};function mr(e){for(var r=e;;){if(!ye[e])return e;e=r+Math.random()}}function Ze(e){ve++,i.monitorRunDependencies&&i.monitorRunDependencies(ve),e?(g(!ye[e]),ye[e]=1,pe===null&&typeof setInterval<"u"&&(pe=setInterval(()=>{if(he){clearInterval(pe),pe=null;return}var r=!1;for(var t in ye)r||(r=!0,B("still waiting on run dependencies:")),B(`dependency: ${t}`);r&&B("(end of list)")},1e4))):B("warning: run dependency added without ID")}function Le(e){if(ve--,i.monitorRunDependencies&&i.monitorRunDependencies(ve),e?(g(ye[e]),delete ye[e]):B("warning: run dependency removed without ID"),ve==0&&(pe!==null&&(clearInterval(pe),pe=null),Ae)){var r=Ae;Ae=null,r()}}function z(e){i.onAbort&&i.onAbort(e),e="Aborted("+e+")",B(e),he=!0,Me&&Pr();var r=new WebAssembly.RuntimeError(e);throw v(r),r}var Kr="data:application/octet-stream;base64,";function hr(e){return e.startsWith(Kr)}function Jr(e){return e.startsWith("file://")}function L(e){return function(){g(Me,`native function \`${e}\` called before runtime initialization`);var r=K[e];return g(r,`exported native function \`${e}\` not found`),r.apply(null,arguments)}}var ae;i.locateFile?(ae="talvos-wasm.wasm",hr(ae)||(ae=Ve(ae))):ae=new URL("/_astro/talvos-wasm.5ecfa9a2.wasm",self.location).href;function vr(e){if(e==ae&&fe)return new Uint8Array(fe);throw"both async and sync fetching of the wasm failed"}function Qr(e){return!fe&&P&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw"failed to load wasm binary file at '"+e+"'";return r.arrayBuffer()}).catch(()=>vr(e)):Promise.resolve().then(()=>vr(e))}function pr(e,r,t){return Qr(e).then(o=>WebAssembly.instantiate(o,r)).then(o=>o).then(t,o=>{B(`failed to asynchronously prepare wasm: ${o}`),Jr(ae)&&B(`warning: Loading from a file URI (${ae}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`),z(o)})}function et(e,r,t,o){return!e&&typeof WebAssembly.instantiateStreaming=="function"&&!hr(r)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(a=>{var s=WebAssembly.instantiateStreaming(a,t);return s.then(o,function(l){return B(`wasm streaming compile failed: ${l}`),B("falling back to ArrayBuffer instantiation"),pr(r,t,o)})}):pr(r,t,o)}function rt(){var e={env:Dr,wasi_snapshot_preview1:Dr};function r(a,s){return K=a.exports,i.wasmExports=K,me=K.memory,i.wasmMemory=me,g(me,"memory not found in wasm exports"),j(),Zr(K.__wasm_call_ctors),Le("wasm-instantiate"),K}Ze("wasm-instantiate");var t=i;function o(a){g(i===t,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),t=null,r(a.instance)}if(i.instantiateWasm)try{return i.instantiateWasm(e,r)}catch(a){B(`Module.instantiateWasm callback failed with error: ${a}`),v(a)}return et(fe,ae,e,o).catch(v),{}}function re(e,r,t=!0){Object.getOwnPropertyDescriptor(i,e)||Object.defineProperty(i,e,{configurable:!0,get(){let o=t?" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)":"";z(`\`Module.${e}\` has been replaced by \`${r}\``+o)}})}function tt(e){Object.getOwnPropertyDescriptor(i,e)&&z(`\`Module.${e}\` was supplied but \`${e}\` not included in INCOMING_MODULE_JS_API`)}function gr(e){return e==="FS_createPath"||e==="FS_createDataFile"||e==="FS_createPreloadedFile"||e==="FS_unlink"||e==="addRunDependency"||e==="FS_createLazyFile"||e==="FS_createDevice"||e==="removeRunDependency"}function Er(e,r){typeof globalThis<"u"&&Object.defineProperty(globalThis,e,{configurable:!0,get(){te("`"+e+"` is not longer defined by emscripten. "+r)}})}Er("buffer","Please use HEAP8.buffer or wasmMemory.buffer"),Er("asm","Please use wasmExports instead");function nt(e){typeof globalThis<"u"&&!Object.getOwnPropertyDescriptor(globalThis,e)&&Object.defineProperty(globalThis,e,{configurable:!0,get(){var r="`"+e+"` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line",t=e;t.startsWith("_")||(t="$"+e),r+=" (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='"+t+"')",gr(e)&&(r+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),te(r)}}),yr(e)}function yr(e){Object.getOwnPropertyDescriptor(i,e)||Object.defineProperty(i,e,{configurable:!0,get(){var r="'"+e+"' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)";gr(e)&&(r+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),z(r)}})}function ot(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var Xe=e=>{for(;e.length>0;)e.shift()(i)},Ke=()=>K.__cpp_exception,_r=e=>{var r=e.getArg(Ke(),0);return tn(r)},at=e=>{var r=_r(e);rn(r)},it=e=>{var r=ar(),t=e();return ir(r),t},wr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,ge=(e,r,t)=>{for(var o=r+t,a=r;e[a]&&!(a>=o);)++a;if(a-r>16&&e.buffer&&wr)return wr.decode(e.subarray(r,a));for(var s="";r>10,56320|A&1023)}}return s},ie=(e,r)=>(g(typeof e=="number"),e?ge(ue,e,r):""),st=e=>it(()=>{var r=Oe(4),t=Oe(4);nn(e,r,t);var o=S[r>>2],a=S[t>>2],s=ie(o);Lr(o);var l;return a&&(l=ie(a),Lr(a)),[s,l]}),Sr=e=>{var r=_r(e);return st(r)};i.getExceptionMessage=Sr;var Te=e=>(g(typeof e=="number"),e>>>=0,"0x"+e.toString(16).padStart(8,"0")),te=e=>{te.shown||(te.shown={}),te.shown[e]||(te.shown[e]=1,B(e))},lt=(e,r,t,o)=>{z(`Assertion failed: ${ie(e)}, at: `+[r?ie(r):"unknown filename",t,o?ie(o):"unknown function"])},ct=e=>(F[en()>>2]=e,e),M={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:(e,r)=>{for(var t=0,o=e.length-1;o>=0;o--){var a=e[o];a==="."?e.splice(o,1):a===".."?(e.splice(o,1),t++):t&&(e.splice(o,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=M.isAbs(e),t=e.substr(-1)==="/";return e=M.normalizeArray(e.split("/").filter(o=>!!o),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=M.splitPath(e),t=r[0],o=r[1];return!t&&!o?".":(o&&(o=o.substr(0,o.length-1)),t+o)},basename:e=>{if(e==="/")return"/";e=M.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:function(){var e=Array.prototype.slice.call(arguments);return M.normalize(e.join("/"))},join2:(e,r)=>M.normalize(e+"/"+r)},ut=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return e=>crypto.getRandomValues(e);z("no cryptographic support found for randomDevice. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: (array) => { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };")},br=e=>(br=ut())(e),se={resolve:function(){for(var e="",r=!1,t=arguments.length-1;t>=-1&&!r;t--){var o=t>=0?arguments[t]:n.cwd();if(typeof o!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!o)return"";e=o+"/"+e,r=M.isAbs(o)}return e=M.normalizeArray(e.split("/").filter(a=>!!a),!r).join("/"),(r?"/":"")+e||"."},relative:(e,r)=>{e=se.resolve(e).substr(1),r=se.resolve(r).substr(1);function t(A){for(var T=0;T=0&&A[D]==="";D--);return T>D?[]:A.slice(T,D-T+1)}for(var o=t(e.split("/")),a=t(r.split("/")),s=Math.min(o.length,a.length),l=s,c=0;c{for(var r=0,t=0;t=55296&&o<=57343?(r+=4,++t):r+=3}return r},Pe=(e,r,t,o)=>{if(g(typeof e=="string"),!(o>0))return 0;for(var a=t,s=t+o-1,l=0;l=55296&&c<=57343){var m=e.charCodeAt(++l);c=65536+((c&1023)<<10)|m&1023}if(c<=127){if(t>=s)break;r[t++]=c}else if(c<=2047){if(t+1>=s)break;r[t++]=192|c>>6,r[t++]=128|c&63}else if(c<=65535){if(t+2>=s)break;r[t++]=224|c>>12,r[t++]=128|c>>6&63,r[t++]=128|c&63}else{if(t+3>=s)break;c>1114111&&te("Invalid Unicode code point "+Te(c)+" encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF)."),r[t++]=240|c>>18,r[t++]=128|c>>12&63,r[t++]=128|c>>6&63,r[t++]=128|c&63}}return r[t]=0,t-a};function Ce(e,r,t){var o=t>0?t:Qe(e)+1,a=new Array(o),s=Pe(e,a,0,a.length);return r&&(a.length=s),a}var dt=()=>{if(!Je.length){var e=null;if(typeof window<"u"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=` +const We=document.querySelector("#talvos svg"),He=We.querySelector("tspan.physical"),Ir=We.querySelector("tspan.logical"),cn=We.querySelectorAll(".lane");for(const f of cn)f.addEventListener("mouseenter",function(){He.textContent=this.dataset.phyCoords,Ir.textContent=this.dataset.logCoords??"N/A"}),f.addEventListener("mouseleave",function(){He.textContent="N/A",Ir.textContent="N/A"}),f.addEventListener("click",function(){this.classList.contains(".disabled")||this.classList.toggle("selected")});const un=We.querySelectorAll(".ctrl");for(const[f,u]of un.entries())u.addEventListener("mouseenter",function(){He.textContent=`{ ${f}, [${f*8}-${f*8+7}] }`}),u.addEventListener("mouseleave",function(){He.textContent="N/A"}),u.addEventListener("click",function(){if(!!!this.parentNode.querySelector('.lane[data-state="active"], .lane[data-state="inactive"]'))return;const h=!this.parentNode.querySelector(".lane.selected");this.parentNode.querySelectorAll(".lane").forEach(p=>{p.classList.toggle("selected",h)})});class dn{next;dtor;constructor(u,i){this.next=u,this.dtor=i??(()=>{})}alloc(u){if(u>this.size)throw new Error(`OOM: Arena out of memory: requested ${u} bytes but only ${this.size} bytes remain`);const[i,h]=this.next.reslice(u);return this.next=h,i}free(u){}get size(){return this.next.byteLength}__destroy__(){this.dtor()}}class ${data;constructor(u,i,h){this.data=new DataView(u,i,h)}get addr(){return this.data.byteOffset}get byteLength(){return this.data.byteLength}reslice(u){return[this.slice(0,u),this.slice(u)]}slice(u,i){u=u??0,u=u<0?this.byteLength+u:u,i=i??this.byteLength,i=i<0?this.byteLength+i:i;const h=Math.min(this.addr+u,this.addr+this.byteLength),p=Math.min(Math.max(0,i-u),this.byteLength);return new $(this.data.buffer,h,p)}asRef(){return this.addr}as(u){return new u(this.data.buffer,this.addr,this.byteLength)}static get SIZE(){return 4}getUsize(u,i){return this.data.getUint32(u,i)}deref(u,i,h){return new $(this.data.buffer,this.getUsize(u,h),i)}}const fn=6,mn=await WebAssembly.instantiateStreaming(fetch("data:application/wasm;base64,AGFzbQEAAAABBgFgAX4BfwMCAQAHDgEKaTY0LnBvcGNudAAACggBBgAgAHunCwAKBG5hbWUCAwEAAA=="),{}),hn=mn.instance,pn=hn.exports["i64.popcnt"];class Ye{words;growable;constructor(u,{data:i}={}){this.words=new BigUint64Array(i.buffer,i.byteOffset,i.byteLength>>3),this.growable=!1;for(const h of u??[])this.add(h)}asRef(){return this.words.byteOffset}#e(u){const i=this.words;if(i.length<<6>u)return;if(!this.growable)throw new Error("TODO message");const h=u+64>>>fn,p=Math.max(h<<3,i.byteLength<<4);var b=new BigUint64Array(new ArrayBuffer(p));b.set(this.words),this.words=b}add(u){this.#e(u);const i=u>>>6,h=1n<>>6,h=1n<({size:u.size*f})}function gn(...f){return{size:f.reduce((u,i)=>u+i.size,0)}}class qe{constructor(u){if(this.ptr=u,u.byteLength!=qe.SIZE)throw new Error(`bad size! got ${u.byteLength} wanted ${qe.SIZE}`)}static get SIZE(){return 12}get X(){return this.ptr.data.getUint32(0,ze)}get Y(){return this.ptr.data.getUint32(4,ze)}get Z(){return this.ptr.data.getUint32(8,ze)}}class Ge{constructor(u){if(this.ptr=u,u.byteLength!=Ge.SIZE)throw new Error(`bad size! got ${u.byteLength} wanted ${Ge.SIZE}`)}static get SIZE(){return 2}get Core(){return this.ptr.data.getUint8(0)}get Lane(){return this.ptr.data.getUint8(1)}}var ne=(f=>(f[f.Active=0]="Active",f[f.Inactive=1]="Inactive",f[f.AtBarrier=2]="AtBarrier",f[f.AtBreakpoint=3]="AtBreakpoint",f[f.AtAssert=4]="AtAssert",f[f.AtException=5]="AtException",f[f.NotLaunched=6]="NotLaunched",f[f.Exited=7]="Exited",f[f.UNKNOWN=8]="UNKNOWN",f))(ne||{});class W{constructor(u){if(this.ptr=u,u.byteLength!=W.SIZE)throw new Error(`bad size! got ${u.byteLength} wanted ${W.SIZE}`)}static get SIZE(){return 1304}static get OFFSETS(){return{cores:0,lanes:1,result:2,steppedCores:8,steppedLanes:16,laneStates:24}}static get TYPES(){return{cores:xr,lanes:xr,steppedCores:Ur,steppedLanes:Ur,laneStates:vn(Br)(gn())}}asRef(){return this.ptr.asRef()}get Cores(){return W.TYPES.cores.get(this.ptr,W.OFFSETS.cores)}get Lanes(){return W.TYPES.lanes.get(this.ptr,W.OFFSETS.lanes)}get SteppedCores(){return new Ye(void 0,{data:this.ptr.slice(W.OFFSETS.steppedCores,W.OFFSETS.steppedCores+W.TYPES.steppedCores.size).data})}get SteppedLanes(){return new Ye(void 0,{data:this.ptr.slice(W.OFFSETS.steppedLanes,W.OFFSETS.steppedLanes+W.TYPES.steppedLanes.size).data})}get LaneStates(){var u=Math.min(this.Cores*this.Lanes,Br);const i=this.ptr.slice(24),h={get(p){const b=i.slice(20*p,20*p+20);return{get PhyCoord(){return new Ge(b.slice(0,2))},get LogCoord(){return new qe(b.slice(4,16))},get State(){return b.data.getInt32(16,ze)}}},[Symbol.iterator]:()=>{var p=0;return{next(){return p>=u?{done:!0,value:void 0}:{done:!1,value:h.get(p++)}}}}};return h}}const Br=64;var En=new TextEncoder,yn=(f,u,i,h)=>{if(!(h>0))return 0;if(f.length>16){const{written:I}=En.encodeInto(f,u.subarray(i,h));return I}for(var p=i,b=i+h-1,N=0;N=55296&&v<=57343){var P=f.charCodeAt(++N);v=65536+((v&1023)<<10)|P&1023}if(v<=127){if(i>=b)break;u[i++]=v}else if(v<=2047){if(i+1>=b)break;u[i++]=192|v>>6,u[i++]=128|v&63}else if(v<=65535){if(i+2>=b)break;u[i++]=224|v>>12,u[i++]=128|v>>6&63,u[i++]=128|v&63}else{if(i+3>=b)break;if(v>1114111)throw new Error("Invalid Unicode code point");u[i++]=240|v>>18,u[i++]=128|v>>12&63,u[i++]=128|v>>6&63,u[i++]=128|v&63}}return u[i]=0,i-p},zr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,_n=(f,u,i,h)=>{const p=u+i,b=h?u+h:(()=>{let ce=u;for(;f[ce]&&!(ce>=p);)++ce;return ce})();if(b-u>16&&f.buffer&&zr)return zr.decode(f.subarray(u,b));for(var N="";u>10,56320|le&1023)}}return N},wn=new TextDecoder("utf8");class Hr{constructor(u){this.ptr=u}static get SIZE(){return 12}get __is_long(){return!!(this.ptr.data.getUint8(11)&128)}get data(){return this.__is_long?this.ptr.deref(0,this.length,!0):this.ptr.slice(0,this.length)}get length(){return this.__is_long?this.ptr.data.getUint32(4,!0):this.ptr.data.getUint8(11)&127}get capacity(){return this.__is_long?this.ptr.data.getUint32(8,!0)^2147483648:10}asString(){return wn.decode(this.data.as(Uint8Array))}get[Symbol.toStringTag](){return`std::string(${this.asString})`}}class Yr{constructor(u){this.ptr=u}static get SIZE(){return 64}get EntryName(){return _n(this.ptr.slice(0,64).as(Uint8Array),0,64)}set EntryName(u){if(yn(u,this.ptr.slice(0,64).as(Uint8Array),0,64)b)throw new Error(`out of bounds access: for index ${u} with elements [0, ${b}]`);return new Be(i.deref(u*$.SIZE,Be.SIZE,!0))}[Symbol.iterator](){const[u,i]=[this.ptr.deref(0*$.SIZE,void 0,!0),this.ptr.deref(1*$.SIZE,0,!0)],h=$.SIZE;var p=u;return{next(){if(p.addr>=i.addr)return{done:!0,value:void 0};const b={done:!1,value:new Be(p.deref(0,Be.SIZE,!0))};return p=p.slice(h),b}}}}class Gr{constructor(u){this.ptr=u}static get SIZE(){return 104}get EntryPoints(){return new qr(this.ptr.slice(40,40+qr.SIZE))}}var Sn=(()=>{var f=import.meta.url;return function(u={}){var i=u,h,p;i.ready=new Promise((e,r)=>{h=e,p=r}),["_malloc","_free","getExceptionMessage","___get_exception_message","___cpp_exception","___cxa_increment_exception_refcount","___cxa_decrement_exception_refcount","___thrown_object_from_unwind_exception","_memory","_Session__create__","_Session__destroy__","_Session__params_ref","_Session__module_ref","_Session_run","_Session_start","_Session_printContext","_Session_step","_Session_continue","_Session_print","_Session_switch","_validate_wasm","_run_wasm","_debug_wasm","_Session_fetch_shrubbery","_exception","_assertion","___indirect_function_table","_fflush","onRuntimeInitialized"].forEach(e=>{Object.getOwnPropertyDescriptor(i.ready,e)||Object.defineProperty(i.ready,e,{get:()=>z("You are getting "+e+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js"),set:()=>z("You are setting "+e+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")})});var b=Object.assign({},i),N="./this.program",v=(e,r)=>{throw r},P=!0,I=!1,le=!1,ce=!1;if(i.ENVIRONMENT)throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");var X="";function Ve(e){return i.locateFile?i.locateFile(e,X):X+e}var we,Ee;{if(typeof document<"u"&&document.currentScript&&(X=document.currentScript.src),f&&(X=f),X.indexOf("blob:")!==0?X=X.substr(0,X.replace(/[?#].*/,"").lastIndexOf("/")+1):X="",!(typeof window=="object"||typeof importScripts=="function"))throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");we=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},Ee=(e,r,t)=>{var o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType="arraybuffer",o.onload=()=>{if(o.status==200||o.status==0&&o.response){r(o.response);return}t()},o.onerror=t,o.send(null)}}var ee=i.print||console.log.bind(console),B=i.printErr||console.error.bind(console);Object.assign(i,b),b=null,Qt(),i.arguments&&i.arguments,re("arguments","arguments_"),i.thisProgram&&(N=i.thisProgram),re("thisProgram","thisProgram"),i.quit&&(v=i.quit),re("quit","quit_"),g(typeof i.memoryInitializerPrefixURL>"u","Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),g(typeof i.pthreadMainPrefixURL>"u","Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),g(typeof i.cdInitializerPrefixURL>"u","Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),g(typeof i.filePackagePrefixURL>"u","Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),g(typeof i.read>"u","Module.read option was removed (modify read_ in JS)"),g(typeof i.readAsync>"u","Module.readAsync option was removed (modify readAsync in JS)"),g(typeof i.readBinary>"u","Module.readBinary option was removed (modify readBinary in JS)"),g(typeof i.setWindowTitle>"u","Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),g(typeof i.TOTAL_MEMORY>"u","Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),re("asm","wasmExports"),re("read","read_"),re("readAsync","readAsync"),re("readBinary","readBinary"),re("setWindowTitle","setWindowTitle"),g(!I,"worker environment detected but not enabled at build time. Add 'worker' to `-sENVIRONMENT` to enable."),g(!le,"node environment detected but not enabled at build time. Add 'node' to `-sENVIRONMENT` to enable."),g(!ce,"shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable.");var fe;i.wasmBinary&&(fe=i.wasmBinary),re("wasmBinary","wasmBinary");var Se=i.noExitRuntime||!0;re("noExitRuntime","noExitRuntime"),typeof WebAssembly!="object"&&z("no native wasm support detected");var me,he=!1;function g(e,r){e||z("Assertion failed"+(r?": "+r:""))}var q,ue,oe,F,S,O;function j(){var e=me.buffer;i.HEAP8=q=new Int8Array(e),i.HEAP16=oe=new Int16Array(e),i.HEAPU8=ue=new Uint8Array(e),i.HEAPU16=new Uint16Array(e),i.HEAP32=F=new Int32Array(e),i.HEAPU32=S=new Uint32Array(e),i.HEAPF32=new Float32Array(e),i.HEAPF64=new Float64Array(e),i.HEAP64=O=new BigInt64Array(e),i.HEAPU64=new BigUint64Array(e)}g(!i.STACK_SIZE,"STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),g(typeof Int32Array<"u"&&typeof Float64Array<"u"&&Int32Array.prototype.subarray!=null&&Int32Array.prototype.set!=null,"JS engine does not provide full typed array support"),g(!i.wasmMemory,"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),g(!i.INITIAL_MEMORY,"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically");function be(){var e=or();g((e&3)==0),e==0&&(e+=4),S[e>>2]=34821223,S[e+4>>2]=2310721022,S[0]=1668509029}function ke(){if(!he){var e=or();e==0&&(e+=4);var r=S[e>>2],t=S[e+4>>2];(r!=34821223||t!=2310721022)&&z(`Stack overflow! Stack cookie has been overwritten at ${Te(e)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${Te(t)} ${Te(r)}`),S[0]!=1668509029&&z("Runtime error: The application has corrupted its heap memory area (address zero)!")}}(function(){var e=new Int16Array(1),r=new Int8Array(e.buffer);if(e[0]=25459,r[0]!==115||r[1]!==99)throw"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)"})();var De=[],cr=[],ur=[],Me=!1,dr=0;function fr(){return Se||dr>0}function Wr(){if(i.preRun)for(typeof i.preRun=="function"&&(i.preRun=[i.preRun]);i.preRun.length;)Vr(i.preRun.shift());Xe(De)}function $r(){g(!Me),Me=!0,ke(),!i.noFSInit&&!n.init.initialized&&n.init(),n.ignorePermissions=!1,Xe(cr)}function jr(){if(ke(),i.postRun)for(typeof i.postRun=="function"&&(i.postRun=[i.postRun]);i.postRun.length;)Xr(i.postRun.shift());Xe(ur)}function Vr(e){De.unshift(e)}function Zr(e){cr.unshift(e)}function Xr(e){ur.unshift(e)}g(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),g(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),g(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),g(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill");var pe=0,ve=null,Ae=null,ye={};function mr(e){for(var r=e;;){if(!ye[e])return e;e=r+Math.random()}}function Ze(e){pe++,i.monitorRunDependencies&&i.monitorRunDependencies(pe),e?(g(!ye[e]),ye[e]=1,ve===null&&typeof setInterval<"u"&&(ve=setInterval(()=>{if(he){clearInterval(ve),ve=null;return}var r=!1;for(var t in ye)r||(r=!0,B("still waiting on run dependencies:")),B(`dependency: ${t}`);r&&B("(end of list)")},1e4))):B("warning: run dependency added without ID")}function Le(e){if(pe--,i.monitorRunDependencies&&i.monitorRunDependencies(pe),e?(g(ye[e]),delete ye[e]):B("warning: run dependency removed without ID"),pe==0&&(ve!==null&&(clearInterval(ve),ve=null),Ae)){var r=Ae;Ae=null,r()}}function z(e){i.onAbort&&i.onAbort(e),e="Aborted("+e+")",B(e),he=!0,Me&&Pr();var r=new WebAssembly.RuntimeError(e);throw p(r),r}var Kr="data:application/octet-stream;base64,";function hr(e){return e.startsWith(Kr)}function Jr(e){return e.startsWith("file://")}function L(e){return function(){g(Me,`native function \`${e}\` called before runtime initialization`);var r=K[e];return g(r,`exported native function \`${e}\` not found`),r.apply(null,arguments)}}var ae;i.locateFile?(ae="talvos-wasm.wasm",hr(ae)||(ae=Ve(ae))):ae=new URL("/learn-gpgpu/_astro/talvos-wasm.5ecfa9a2.wasm",self.location).href;function pr(e){if(e==ae&&fe)return new Uint8Array(fe);throw"both async and sync fetching of the wasm failed"}function Qr(e){return!fe&&P&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw"failed to load wasm binary file at '"+e+"'";return r.arrayBuffer()}).catch(()=>pr(e)):Promise.resolve().then(()=>pr(e))}function vr(e,r,t){return Qr(e).then(o=>WebAssembly.instantiate(o,r)).then(o=>o).then(t,o=>{B(`failed to asynchronously prepare wasm: ${o}`),Jr(ae)&&B(`warning: Loading from a file URI (${ae}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`),z(o)})}function et(e,r,t,o){return!e&&typeof WebAssembly.instantiateStreaming=="function"&&!hr(r)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(a=>{var s=WebAssembly.instantiateStreaming(a,t);return s.then(o,function(l){return B(`wasm streaming compile failed: ${l}`),B("falling back to ArrayBuffer instantiation"),vr(r,t,o)})}):vr(r,t,o)}function rt(){var e={env:Dr,wasi_snapshot_preview1:Dr};function r(a,s){return K=a.exports,i.wasmExports=K,me=K.memory,i.wasmMemory=me,g(me,"memory not found in wasm exports"),j(),Zr(K.__wasm_call_ctors),Le("wasm-instantiate"),K}Ze("wasm-instantiate");var t=i;function o(a){g(i===t,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),t=null,r(a.instance)}if(i.instantiateWasm)try{return i.instantiateWasm(e,r)}catch(a){B(`Module.instantiateWasm callback failed with error: ${a}`),p(a)}return et(fe,ae,e,o).catch(p),{}}function re(e,r,t=!0){Object.getOwnPropertyDescriptor(i,e)||Object.defineProperty(i,e,{configurable:!0,get(){let o=t?" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)":"";z(`\`Module.${e}\` has been replaced by \`${r}\``+o)}})}function tt(e){Object.getOwnPropertyDescriptor(i,e)&&z(`\`Module.${e}\` was supplied but \`${e}\` not included in INCOMING_MODULE_JS_API`)}function gr(e){return e==="FS_createPath"||e==="FS_createDataFile"||e==="FS_createPreloadedFile"||e==="FS_unlink"||e==="addRunDependency"||e==="FS_createLazyFile"||e==="FS_createDevice"||e==="removeRunDependency"}function Er(e,r){typeof globalThis<"u"&&Object.defineProperty(globalThis,e,{configurable:!0,get(){te("`"+e+"` is not longer defined by emscripten. "+r)}})}Er("buffer","Please use HEAP8.buffer or wasmMemory.buffer"),Er("asm","Please use wasmExports instead");function nt(e){typeof globalThis<"u"&&!Object.getOwnPropertyDescriptor(globalThis,e)&&Object.defineProperty(globalThis,e,{configurable:!0,get(){var r="`"+e+"` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line",t=e;t.startsWith("_")||(t="$"+e),r+=" (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='"+t+"')",gr(e)&&(r+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),te(r)}}),yr(e)}function yr(e){Object.getOwnPropertyDescriptor(i,e)||Object.defineProperty(i,e,{configurable:!0,get(){var r="'"+e+"' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)";gr(e)&&(r+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),z(r)}})}function ot(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var Xe=e=>{for(;e.length>0;)e.shift()(i)},Ke=()=>K.__cpp_exception,_r=e=>{var r=e.getArg(Ke(),0);return tn(r)},at=e=>{var r=_r(e);rn(r)},it=e=>{var r=ar(),t=e();return ir(r),t},wr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,ge=(e,r,t)=>{for(var o=r+t,a=r;e[a]&&!(a>=o);)++a;if(a-r>16&&e.buffer&&wr)return wr.decode(e.subarray(r,a));for(var s="";r>10,56320|A&1023)}}return s},ie=(e,r)=>(g(typeof e=="number"),e?ge(ue,e,r):""),st=e=>it(()=>{var r=Oe(4),t=Oe(4);nn(e,r,t);var o=S[r>>2],a=S[t>>2],s=ie(o);Lr(o);var l;return a&&(l=ie(a),Lr(a)),[s,l]}),Sr=e=>{var r=_r(e);return st(r)};i.getExceptionMessage=Sr;var Te=e=>(g(typeof e=="number"),e>>>=0,"0x"+e.toString(16).padStart(8,"0")),te=e=>{te.shown||(te.shown={}),te.shown[e]||(te.shown[e]=1,B(e))},lt=(e,r,t,o)=>{z(`Assertion failed: ${ie(e)}, at: `+[r?ie(r):"unknown filename",t,o?ie(o):"unknown function"])},ct=e=>(F[en()>>2]=e,e),M={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:(e,r)=>{for(var t=0,o=e.length-1;o>=0;o--){var a=e[o];a==="."?e.splice(o,1):a===".."?(e.splice(o,1),t++):t&&(e.splice(o,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=M.isAbs(e),t=e.substr(-1)==="/";return e=M.normalizeArray(e.split("/").filter(o=>!!o),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=M.splitPath(e),t=r[0],o=r[1];return!t&&!o?".":(o&&(o=o.substr(0,o.length-1)),t+o)},basename:e=>{if(e==="/")return"/";e=M.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:function(){var e=Array.prototype.slice.call(arguments);return M.normalize(e.join("/"))},join2:(e,r)=>M.normalize(e+"/"+r)},ut=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return e=>crypto.getRandomValues(e);z("no cryptographic support found for randomDevice. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: (array) => { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };")},br=e=>(br=ut())(e),se={resolve:function(){for(var e="",r=!1,t=arguments.length-1;t>=-1&&!r;t--){var o=t>=0?arguments[t]:n.cwd();if(typeof o!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!o)return"";e=o+"/"+e,r=M.isAbs(o)}return e=M.normalizeArray(e.split("/").filter(a=>!!a),!r).join("/"),(r?"/":"")+e||"."},relative:(e,r)=>{e=se.resolve(e).substr(1),r=se.resolve(r).substr(1);function t(A){for(var T=0;T=0&&A[D]==="";D--);return T>D?[]:A.slice(T,D-T+1)}for(var o=t(e.split("/")),a=t(r.split("/")),s=Math.min(o.length,a.length),l=s,c=0;c{for(var r=0,t=0;t=55296&&o<=57343?(r+=4,++t):r+=3}return r},Pe=(e,r,t,o)=>{if(g(typeof e=="string"),!(o>0))return 0;for(var a=t,s=t+o-1,l=0;l=55296&&c<=57343){var m=e.charCodeAt(++l);c=65536+((c&1023)<<10)|m&1023}if(c<=127){if(t>=s)break;r[t++]=c}else if(c<=2047){if(t+1>=s)break;r[t++]=192|c>>6,r[t++]=128|c&63}else if(c<=65535){if(t+2>=s)break;r[t++]=224|c>>12,r[t++]=128|c>>6&63,r[t++]=128|c&63}else{if(t+3>=s)break;c>1114111&&te("Invalid Unicode code point "+Te(c)+" encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF)."),r[t++]=240|c>>18,r[t++]=128|c>>12&63,r[t++]=128|c>>6&63,r[t++]=128|c&63}}return r[t]=0,t-a};function Ce(e,r,t){var o=t>0?t:Qe(e)+1,a=new Array(o),s=Pe(e,a,0,a.length);return r&&(a.length=s),a}var dt=()=>{if(!Je.length){var e=null;if(typeof window<"u"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=` `)):typeof readline=="function"&&(e=readline(),e!==null&&(e+=` -`)),!e)return null;Je=Ce(e,!0)}return Je.shift()},de={ttys:[],init(){},shutdown(){},register(e,r){de.ttys[e]={input:[],output:[],ops:r},n.registerDevice(e,de.stream_ops)},stream_ops:{open(e){var r=de.ttys[e.node.rdev];if(!r)throw new n.ErrnoError(43);e.tty=r,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,r,t,o,a){if(!e.tty||!e.tty.ops.get_char)throw new n.ErrnoError(60);for(var s=0,l=0;l0&&(ee(ge(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,r,t){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,r){r===null||r===10?(B(ge(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output&&e.output.length>0&&(B(ge(e.output,0)),e.output=[])}}},kr=e=>{z("internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported")},k={ops_table:null,mount(e){return k.createNode(null,"/",16895,0)},createNode(e,r,t,o){if(n.isBlkdev(t)||n.isFIFO(t))throw new n.ErrnoError(63);k.ops_table||(k.ops_table={dir:{node:{getattr:k.node_ops.getattr,setattr:k.node_ops.setattr,lookup:k.node_ops.lookup,mknod:k.node_ops.mknod,rename:k.node_ops.rename,unlink:k.node_ops.unlink,rmdir:k.node_ops.rmdir,readdir:k.node_ops.readdir,symlink:k.node_ops.symlink},stream:{llseek:k.stream_ops.llseek}},file:{node:{getattr:k.node_ops.getattr,setattr:k.node_ops.setattr},stream:{llseek:k.stream_ops.llseek,read:k.stream_ops.read,write:k.stream_ops.write,allocate:k.stream_ops.allocate,mmap:k.stream_ops.mmap,msync:k.stream_ops.msync}},link:{node:{getattr:k.node_ops.getattr,setattr:k.node_ops.setattr,readlink:k.node_ops.readlink},stream:{}},chrdev:{node:{getattr:k.node_ops.getattr,setattr:k.node_ops.setattr},stream:n.chrdev_stream_ops}});var a=n.createNode(e,r,t,o);return n.isDir(a.mode)?(a.node_ops=k.ops_table.dir.node,a.stream_ops=k.ops_table.dir.stream,a.contents={}):n.isFile(a.mode)?(a.node_ops=k.ops_table.file.node,a.stream_ops=k.ops_table.file.stream,a.usedBytes=0,a.contents=null):n.isLink(a.mode)?(a.node_ops=k.ops_table.link.node,a.stream_ops=k.ops_table.link.stream):n.isChrdev(a.mode)&&(a.node_ops=k.ops_table.chrdev.node,a.stream_ops=k.ops_table.chrdev.stream),a.timestamp=Date.now(),e&&(e.contents[r]=a,e.timestamp=a.timestamp),a},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var o=1024*1024;r=Math.max(r,t*(t>>0),t!=0&&(r=Math.max(r,256));var a=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(a.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)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(e){var r={};return r.dev=n.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,n.isDir(e.mode)?r.size=4096:n.isFile(e.mode)?r.size=e.usedBytes:n.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(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&k.resizeFileStorage(e,r.size)},lookup(e,r){throw n.genericErrors[44]},mknod(e,r,t,o){return k.createNode(e,r,t,o)},rename(e,r,t){if(n.isDir(e.mode)){var o;try{o=n.lookupNode(r,t)}catch{}if(o)for(var a in o.contents)throw new n.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(e,r){delete e.contents[r],e.timestamp=Date.now()},rmdir(e,r){var t=n.lookupNode(e,r);for(var o in t.contents)throw new n.ErrnoError(55);delete e.contents[r],e.timestamp=Date.now()},readdir(e){var r=[".",".."];for(var t in e.contents)e.contents.hasOwnProperty(t)&&r.push(t);return r},symlink(e,r,t){var o=k.createNode(e,r,41471,0);return o.link=t,o},readlink(e){if(!n.isLink(e.mode))throw new n.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,o,a){var s=e.node.contents;if(a>=e.node.usedBytes)return 0;var l=Math.min(e.node.usedBytes-a,o);if(g(l>=0),l>8&&s.subarray)r.set(s.subarray(a,a+l),t);else for(var c=0;c0||t+r{var a=o?"":mr(`al ${e}`);Ee(e,s=>{g(s,`Loading data file "${e}" failed (no arrayBuffer).`),r(new Uint8Array(s)),a&&Le(a)},s=>{if(t)t();else throw`Loading data file "${e}" failed.`}),a&&Ze(a)},mt=(e,r,t,o,a,s)=>n.createDataFile(e,r,t,o,a,s),ht=i.preloadPlugins||[],vt=(e,r,t,o)=>{typeof Browser<"u"&&Browser.init();var a=!1;return ht.forEach(s=>{a||s.canHandle(r)&&(s.handle(e,r,t,o),a=!0)}),a},pt=(e,r,t,o,a,s,l,c,m,A)=>{var T=r?se.resolve(M.join2(e,r)):e,D=mr(`cp ${T}`);function _(y){function w(U){A&&A(),c||mt(e,r,U,o,a,m),s&&s(),Le(D)}vt(y,T,w,()=>{l&&l(),Le(D)})||w(y)}Ze(D),typeof t=="string"?ft(t,y=>_(y),l):_(t)},gt=e=>{var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t},er=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},Et={0:"Success",1:"Arg list too long",2:"Permission denied",3:"Address already in use",4:"Address not available",5:"Address family not supported by protocol family",6:"No more processes",7:"Socket already connected",8:"Bad file number",9:"Trying to read unreadable message",10:"Mount device busy",11:"Operation canceled",12:"No children",13:"Connection aborted",14:"Connection refused",15:"Connection reset by peer",16:"File locking deadlock error",17:"Destination address required",18:"Math arg out of domain of func",19:"Quota exceeded",20:"File exists",21:"Bad address",22:"File too large",23:"Host is unreachable",24:"Identifier removed",25:"Illegal byte sequence",26:"Connection already in progress",27:"Interrupted system call",28:"Invalid argument",29:"I/O error",30:"Socket is already connected",31:"Is a directory",32:"Too many symbolic links",33:"Too many open files",34:"Too many links",35:"Message too long",36:"Multihop attempted",37:"File or path name too long",38:"Network interface is not configured",39:"Connection reset by network",40:"Network is unreachable",41:"Too many open files in system",42:"No buffer space available",43:"No such device",44:"No such file or directory",45:"Exec format error",46:"No record locks available",47:"The link has been severed",48:"Not enough core",49:"No message of desired type",50:"Protocol not available",51:"No space left on device",52:"Function not implemented",53:"Socket is not connected",54:"Not a directory",55:"Directory not empty",56:"State not recoverable",57:"Socket operation on non-socket",59:"Not a typewriter",60:"No such device or address",61:"Value too large for defined data type",62:"Previous owner died",63:"Not super-user",64:"Broken pipe",65:"Protocol error",66:"Unknown protocol",67:"Protocol wrong type for socket",68:"Math result not representable",69:"Read only file system",70:"Illegal seek",71:"No such process",72:"Stale file handle",73:"Connection timed out",74:"Text file busy",75:"Cross-device link",100:"Device not a stream",101:"Bad font file fmt",102:"Invalid slot",103:"Invalid request code",104:"No anode",105:"Block device required",106:"Channel number out of range",107:"Level 3 halted",108:"Level 3 reset",109:"Link number out of range",110:"Protocol driver not attached",111:"No CSI structure available",112:"Level 2 halted",113:"Invalid exchange",114:"Invalid request descriptor",115:"Exchange full",116:"No data (for no delay io)",117:"Timer expired",118:"Out of streams resources",119:"Machine is not on the network",120:"Package not installed",121:"The object is remote",122:"Advertise error",123:"Srmount error",124:"Communication error on send",125:"Cross mount point (not really error)",126:"Given log. name not unique",127:"f.d. invalid for this operation",128:"Remote address changed",129:"Can access a needed shared lib",130:"Accessing a corrupted shared lib",131:".lib section in a.out corrupted",132:"Attempting to link in too many libs",133:"Attempting to exec a shared library",135:"Streams pipe error",136:"Too many users",137:"Socket type not supported",138:"Not supported",139:"Protocol family not supported",140:"Can't send after socket shutdown",141:"Too many references",142:"Host is down",148:"No medium (in tape drive)",156:"Level 2 not synchronized"},rr={},yt=e=>(te("warning: build with -sDEMANGLE_SUPPORT to link in libcxxabi demangling"),e),_t=e=>{var r=/\b_Z[\w\d_]+/g;return e.replace(r,function(t){var o=yt(t);return t===o?t:o+" ["+t+"]"})},n={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=se.resolve(e),!e)return{path:"",node:null};var t={follow_mount:!0,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new n.ErrnoError(32);for(var o=e.split("/").filter(D=>!!D),a=n.root,s="/",l=0;l40)throw new n.ErrnoError(32)}}return{path:s,node:a}},getPath(e){for(var r;;){if(n.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,o=0;o>>0)%n.nameTable.length},hashAddNode(e){var r=n.hashName(e.parent.id,e.name);e.name_next=n.nameTable[r],n.nameTable[r]=e},hashRemoveNode(e){var r=n.hashName(e.parent.id,e.name);if(n.nameTable[r]===e)n.nameTable[r]=e.name_next;else for(var t=n.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode(e,r){var t=n.mayLookup(e);if(t)throw new n.ErrnoError(t,e);for(var o=n.hashName(e.id,r),a=n.nameTable[o];a;a=a.name_next){var s=a.name;if(a.parent.id===e.id&&s===r)return a}return n.lookup(e,r)},createNode(e,r,t,o){g(typeof e=="object");var a=new n.FSNode(e,r,t,o);return n.hashAddNode(a),a},destroyNode(e){n.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return(e&61440)===32768},isDir(e){return(e&61440)===16384},isLink(e){return(e&61440)===40960},isChrdev(e){return(e&61440)===8192},isBlkdev(e){return(e&61440)===24576},isFIFO(e){return(e&61440)===4096},isSocket(e){return(e&49152)===49152},flagsToPermissionString(e){var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions(e,r){return n.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){var r=n.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){try{var t=n.lookupNode(e,r);return 20}catch{}return n.nodePermissions(e,"wx")},mayDelete(e,r,t){var o;try{o=n.lookupNode(e,r)}catch(s){return s.errno}var a=n.nodePermissions(e,"wx");if(a)return a;if(t){if(!n.isDir(o.mode))return 54;if(n.isRoot(o)||n.getPath(o)===n.cwd())return 10}else if(n.isDir(o.mode))return 31;return 0},mayOpen(e,r){return e?n.isLink(e.mode)?32:n.isDir(e.mode)&&(n.flagsToPermissionString(r)!=="r"||r&512)?31:n.nodePermissions(e,n.flagsToPermissionString(r)):44},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=n.MAX_OPEN_FDS;e++)if(!n.streams[e])return e;throw new n.ErrnoError(33)},getStreamChecked(e){var r=n.getStream(e);if(!r)throw new n.ErrnoError(8);return r},getStream:e=>n.streams[e],createStream(e,r=-1){return n.FSStream||(n.FSStream=function(){this.shared={}},n.FSStream.prototype={},Object.defineProperties(n.FSStream.prototype,{object:{get(){return this.node},set(t){this.node=t}},isRead:{get(){return(this.flags&2097155)!==1}},isWrite:{get(){return(this.flags&2097155)!==0}},isAppend:{get(){return this.flags&1024}},flags:{get(){return this.shared.flags},set(t){this.shared.flags=t}},position:{get(){return this.shared.position},set(t){this.shared.position=t}}})),e=Object.assign(new n.FSStream,e),r==-1&&(r=n.nextfd()),e.fd=r,n.streams[r]=e,e},closeStream(e){n.streams[e]=null},chrdev_stream_ops:{open(e){var r=n.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek(){throw new n.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice(e,r){n.devices[e]={stream_ops:r}},getDevice:e=>n.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var o=t.pop();r.push(o),t.push.apply(t,o.mounts)}return r},syncfs(e,r){typeof e=="function"&&(r=e,e=!1),n.syncFSRequests++,n.syncFSRequests>1&&B(`warning: ${n.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=n.getMounts(n.root.mount),o=0;function a(l){return g(n.syncFSRequests>0),n.syncFSRequests--,r(l)}function s(l){if(l)return s.errored?void 0:(s.errored=!0,a(l));++o>=t.length&&a(null)}t.forEach(l=>{if(!l.type.syncfs)return s(null);l.type.syncfs(l,e,s)})},mount(e,r,t){if(typeof e=="string")throw e;var o=t==="/",a=!t,s;if(o&&n.root)throw new n.ErrnoError(10);if(!o&&!a){var l=n.lookupPath(t,{follow_mount:!1});if(t=l.path,s=l.node,n.isMountpoint(s))throw new n.ErrnoError(10);if(!n.isDir(s.mode))throw new n.ErrnoError(54)}var c={type:e,opts:r,mountpoint:t,mounts:[]},m=e.mount(c);return m.mount=c,c.root=m,o?n.root=m:s&&(s.mounted=c,s.mount&&s.mount.mounts.push(c)),m},unmount(e){var r=n.lookupPath(e,{follow_mount:!1});if(!n.isMountpoint(r.node))throw new n.ErrnoError(28);var t=r.node,o=t.mounted,a=n.getMounts(o);Object.keys(n.nameTable).forEach(l=>{for(var c=n.nameTable[l];c;){var m=c.name_next;a.includes(c.mount)&&n.destroyNode(c),c=m}}),t.mounted=null;var s=t.mount.mounts.indexOf(o);g(s!==-1),t.mount.mounts.splice(s,1)},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var o=n.lookupPath(e,{parent:!0}),a=o.node,s=M.basename(e);if(!s||s==="."||s==="..")throw new n.ErrnoError(28);var l=n.mayCreate(a,s);if(l)throw new n.ErrnoError(l);if(!a.node_ops.mknod)throw new n.ErrnoError(63);return a.node_ops.mknod(a,s,r,t)},create(e,r){return r=r!==void 0?r:438,r&=4095,r|=32768,n.mknod(e,r,0)},mkdir(e,r){return r=r!==void 0?r:511,r&=1023,r|=16384,n.mknod(e,r,0)},mkdirTree(e,r){for(var t=e.split("/"),o="",a=0;a"u"&&(t=r,r=438),r|=8192,n.mknod(e,r,t)},symlink(e,r){if(!se.resolve(e))throw new n.ErrnoError(44);var t=n.lookupPath(r,{parent:!0}),o=t.node;if(!o)throw new n.ErrnoError(44);var a=M.basename(r),s=n.mayCreate(o,a);if(s)throw new n.ErrnoError(s);if(!o.node_ops.symlink)throw new n.ErrnoError(63);return o.node_ops.symlink(o,a,e)},rename(e,r){var t=M.dirname(e),o=M.dirname(r),a=M.basename(e),s=M.basename(r),l,c,m;if(l=n.lookupPath(e,{parent:!0}),c=l.node,l=n.lookupPath(r,{parent:!0}),m=l.node,!c||!m)throw new n.ErrnoError(44);if(c.mount!==m.mount)throw new n.ErrnoError(75);var A=n.lookupNode(c,a),T=se.relative(e,o);if(T.charAt(0)!==".")throw new n.ErrnoError(28);if(T=se.relative(r,t),T.charAt(0)!==".")throw new n.ErrnoError(55);var D;try{D=n.lookupNode(m,s)}catch{}if(A!==D){var _=n.isDir(A.mode),y=n.mayDelete(c,a,_);if(y)throw new n.ErrnoError(y);if(y=D?n.mayDelete(m,s,_):n.mayCreate(m,s),y)throw new n.ErrnoError(y);if(!c.node_ops.rename)throw new n.ErrnoError(63);if(n.isMountpoint(A)||D&&n.isMountpoint(D))throw new n.ErrnoError(10);if(m!==c&&(y=n.nodePermissions(c,"w"),y))throw new n.ErrnoError(y);n.hashRemoveNode(A);try{c.node_ops.rename(A,m,s)}catch(w){throw w}finally{n.hashAddNode(A)}}},rmdir(e){var r=n.lookupPath(e,{parent:!0}),t=r.node,o=M.basename(e),a=n.lookupNode(t,o),s=n.mayDelete(t,o,!0);if(s)throw new n.ErrnoError(s);if(!t.node_ops.rmdir)throw new n.ErrnoError(63);if(n.isMountpoint(a))throw new n.ErrnoError(10);t.node_ops.rmdir(t,o),n.destroyNode(a)},readdir(e){var r=n.lookupPath(e,{follow:!0}),t=r.node;if(!t.node_ops.readdir)throw new n.ErrnoError(54);return t.node_ops.readdir(t)},unlink(e){var r=n.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new n.ErrnoError(44);var o=M.basename(e),a=n.lookupNode(t,o),s=n.mayDelete(t,o,!1);if(s)throw new n.ErrnoError(s);if(!t.node_ops.unlink)throw new n.ErrnoError(63);if(n.isMountpoint(a))throw new n.ErrnoError(10);t.node_ops.unlink(t,o),n.destroyNode(a)},readlink(e){var r=n.lookupPath(e),t=r.node;if(!t)throw new n.ErrnoError(44);if(!t.node_ops.readlink)throw new n.ErrnoError(28);return se.resolve(n.getPath(t.parent),t.node_ops.readlink(t))},stat(e,r){var t=n.lookupPath(e,{follow:!r}),o=t.node;if(!o)throw new n.ErrnoError(44);if(!o.node_ops.getattr)throw new n.ErrnoError(63);return o.node_ops.getattr(o)},lstat(e){return n.stat(e,!0)},chmod(e,r,t){var o;if(typeof e=="string"){var a=n.lookupPath(e,{follow:!t});o=a.node}else o=e;if(!o.node_ops.setattr)throw new n.ErrnoError(63);o.node_ops.setattr(o,{mode:r&4095|o.mode&-4096,timestamp:Date.now()})},lchmod(e,r){n.chmod(e,r,!0)},fchmod(e,r){var t=n.getStreamChecked(e);n.chmod(t.node,r)},chown(e,r,t,o){var a;if(typeof e=="string"){var s=n.lookupPath(e,{follow:!o});a=s.node}else a=e;if(!a.node_ops.setattr)throw new n.ErrnoError(63);a.node_ops.setattr(a,{timestamp:Date.now()})},lchown(e,r,t){n.chown(e,r,t,!0)},fchown(e,r,t){var o=n.getStreamChecked(e);n.chown(o.node,r,t)},truncate(e,r){if(r<0)throw new n.ErrnoError(28);var t;if(typeof e=="string"){var o=n.lookupPath(e,{follow:!0});t=o.node}else t=e;if(!t.node_ops.setattr)throw new n.ErrnoError(63);if(n.isDir(t.mode))throw new n.ErrnoError(31);if(!n.isFile(t.mode))throw new n.ErrnoError(28);var a=n.nodePermissions(t,"w");if(a)throw new n.ErrnoError(a);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate(e,r){var t=n.getStreamChecked(e);if(!(t.flags&2097155))throw new n.ErrnoError(28);n.truncate(t.node,r)},utime(e,r,t){var o=n.lookupPath(e,{follow:!0}),a=o.node;a.node_ops.setattr(a,{timestamp:Math.max(r,t)})},open(e,r,t){if(e==="")throw new n.ErrnoError(44);r=typeof r=="string"?gt(r):r,t=typeof t>"u"?438:t,r&64?t=t&4095|32768:t=0;var o;if(typeof e=="object")o=e;else{e=M.normalize(e);try{var a=n.lookupPath(e,{follow:!(r&131072)});o=a.node}catch{}}var s=!1;if(r&64)if(o){if(r&128)throw new n.ErrnoError(20)}else o=n.mknod(e,t,0),s=!0;if(!o)throw new n.ErrnoError(44);if(n.isChrdev(o.mode)&&(r&=-513),r&65536&&!n.isDir(o.mode))throw new n.ErrnoError(54);if(!s){var l=n.mayOpen(o,r);if(l)throw new n.ErrnoError(l)}r&512&&!s&&n.truncate(o,0),r&=-131713;var c=n.createStream({node:o,path:n.getPath(o),flags:r,seekable:!0,position:0,stream_ops:o.stream_ops,ungotten:[],error:!1});return c.stream_ops.open&&c.stream_ops.open(c),i.logReadFiles&&!(r&1)&&(n.readFiles||(n.readFiles={}),e in n.readFiles||(n.readFiles[e]=1)),c},close(e){if(n.isClosed(e))throw new n.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{n.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,r,t){if(n.isClosed(e))throw new n.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new n.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new n.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,o,a){if(g(t>=0),o<0||a<0)throw new n.ErrnoError(28);if(n.isClosed(e))throw new n.ErrnoError(8);if((e.flags&2097155)===1)throw new n.ErrnoError(8);if(n.isDir(e.node.mode))throw new n.ErrnoError(31);if(!e.stream_ops.read)throw new n.ErrnoError(28);var s=typeof a<"u";if(!s)a=e.position;else if(!e.seekable)throw new n.ErrnoError(70);var l=e.stream_ops.read(e,r,t,o,a);return s||(e.position+=l),l},write(e,r,t,o,a,s){if(g(t>=0),o<0||a<0)throw new n.ErrnoError(28);if(n.isClosed(e))throw new n.ErrnoError(8);if(!(e.flags&2097155))throw new n.ErrnoError(8);if(n.isDir(e.node.mode))throw new n.ErrnoError(31);if(!e.stream_ops.write)throw new n.ErrnoError(28);e.seekable&&e.flags&1024&&n.llseek(e,0,2);var l=typeof a<"u";if(!l)a=e.position;else if(!e.seekable)throw new n.ErrnoError(70);var c=e.stream_ops.write(e,r,t,o,a,s);return l||(e.position+=c),c},allocate(e,r,t){if(n.isClosed(e))throw new n.ErrnoError(8);if(r<0||t<=0)throw new n.ErrnoError(28);if(!(e.flags&2097155))throw new n.ErrnoError(8);if(!n.isFile(e.node.mode)&&!n.isDir(e.node.mode))throw new n.ErrnoError(43);if(!e.stream_ops.allocate)throw new n.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap(e,r,t,o,a){if(o&2&&!(a&2)&&(e.flags&2097155)!==2)throw new n.ErrnoError(2);if((e.flags&2097155)===1)throw new n.ErrnoError(2);if(!e.stream_ops.mmap)throw new n.ErrnoError(43);return e.stream_ops.mmap(e,r,t,o,a)},msync(e,r,t,o,a){return g(t>=0),e.stream_ops.msync?e.stream_ops.msync(e,r,t,o,a):0},munmap:e=>0,ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new n.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){if(r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary")throw new Error(`Invalid encoding type "${r.encoding}"`);var t,o=n.open(e,r.flags),a=n.stat(e),s=a.size,l=new Uint8Array(s);return n.read(o,l,0,s,0),r.encoding==="utf8"?t=ge(l,0):r.encoding==="binary"&&(t=l),n.close(o),t},writeFile(e,r,t={}){t.flags=t.flags||577;var o=n.open(e,t.flags,t.mode);if(typeof r=="string"){var a=new Uint8Array(Qe(r)+1),s=Pe(r,a,0,a.length);n.write(o,a,0,s,void 0,t.canOwn)}else if(ArrayBuffer.isView(r))n.write(o,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");n.close(o)},cwd:()=>n.currentPath,chdir(e){var r=n.lookupPath(e,{follow:!0});if(r.node===null)throw new n.ErrnoError(44);if(!n.isDir(r.node.mode))throw new n.ErrnoError(54);var t=n.nodePermissions(r.node,"x");if(t)throw new n.ErrnoError(t);n.currentPath=r.path},createDefaultDirectories(){n.mkdir("/tmp"),n.mkdir("/home"),n.mkdir("/home/web_user")},createDefaultDevices(){n.mkdir("/dev"),n.registerDevice(n.makedev(1,3),{read:()=>0,write:(o,a,s,l,c)=>l}),n.mkdev("/dev/null",n.makedev(1,3)),de.register(n.makedev(5,0),de.default_tty_ops),de.register(n.makedev(6,0),de.default_tty1_ops),n.mkdev("/dev/tty",n.makedev(5,0)),n.mkdev("/dev/tty1",n.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(r=br(e).byteLength),e[--r]);n.createDevice("/dev","random",t),n.createDevice("/dev","urandom",t),n.mkdir("/dev/shm"),n.mkdir("/dev/shm/tmp")},createSpecialDirectories(){n.mkdir("/proc");var e=n.mkdir("/proc/self");n.mkdir("/proc/self/fd"),n.mount({mount(){var r=n.createNode(e,"fd",16895,73);return r.node_ops={lookup(t,o){var a=+o,s=n.getStreamChecked(a),l={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>s.path}};return l.parent=l,l}},r}},{},"/proc/self/fd")},createStandardStreams(){i.stdin?n.createDevice("/dev","stdin",i.stdin):n.symlink("/dev/tty","/dev/stdin"),i.stdout?n.createDevice("/dev","stdout",null,i.stdout):n.symlink("/dev/tty","/dev/stdout"),i.stderr?n.createDevice("/dev","stderr",null,i.stderr):n.symlink("/dev/tty1","/dev/stderr");var e=n.open("/dev/stdin",0),r=n.open("/dev/stdout",1),t=n.open("/dev/stderr",1);g(e.fd===0,`invalid handle for stdin (${e.fd})`),g(r.fd===1,`invalid handle for stdout (${r.fd})`),g(t.fd===2,`invalid handle for stderr (${t.fd})`)},ensureErrnoError(){n.ErrnoError||(n.ErrnoError=function(r,t){this.name="ErrnoError",this.node=t,this.setErrno=function(o){this.errno=o;for(var a in rr)if(rr[a]===o){this.code=a;break}},this.setErrno(r),this.message=Et[r],this.stack&&(Object.defineProperty(this,"stack",{value:new Error().stack,writable:!0}),this.stack=_t(this.stack))},n.ErrnoError.prototype=new Error,n.ErrnoError.prototype.constructor=n.ErrnoError,[44].forEach(e=>{n.genericErrors[e]=new n.ErrnoError(e),n.genericErrors[e].stack=""}))},staticInit(){n.ensureErrnoError(),n.nameTable=new Array(4096),n.mount(k,{},"/"),n.createDefaultDirectories(),n.createDefaultDevices(),n.createSpecialDirectories(),n.filesystems={MEMFS:k}},init(e,r,t){g(!n.init.initialized,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)"),n.init.initialized=!0,n.ensureErrnoError(),i.stdin=e||i.stdin,i.stdout=r||i.stdout,i.stderr=t||i.stderr,n.createStandardStreams()},quit(){n.init.initialized=!1,Mr(0);for(var e=0;ethis.length-1||y<0)){var w=y%this.chunkSize,U=y/this.chunkSize|0;return this.getter(U)[w]}},s.prototype.setDataGetter=function(y){this.getter=y},s.prototype.cacheLength=function(){var y=new XMLHttpRequest;if(y.open("HEAD",t,!1),y.send(null),!(y.status>=200&&y.status<300||y.status===304))throw new Error("Couldn't load "+t+". Status: "+y.status);var w=Number(y.getResponseHeader("Content-length")),U,V=(U=y.getResponseHeader("Accept-Ranges"))&&U==="bytes",G=(U=y.getResponseHeader("Content-Encoding"))&&U==="gzip",d=1024*1024;V||(d=w);var E=(x,J)=>{if(x>J)throw new Error("invalid range ("+x+", "+J+") or no bytes requested!");if(J>w-1)throw new Error("only "+w+" bytes available! programmer error!");var H=new XMLHttpRequest;if(H.open("GET",t,!1),w!==d&&H.setRequestHeader("Range","bytes="+x+"-"+J),H.responseType="arraybuffer",H.overrideMimeType&&H.overrideMimeType("text/plain; charset=x-user-defined"),H.send(null),!(H.status>=200&&H.status<300||H.status===304))throw new Error("Couldn't load "+t+". Status: "+H.status);return H.response!==void 0?new Uint8Array(H.response||[]):Ce(H.responseText||"",!0)},Y=this;Y.setDataGetter(x=>{var J=x*d,H=(x+1)*d-1;if(H=Math.min(H,w-1),typeof Y.chunks[x]>"u"&&(Y.chunks[x]=E(J,H)),typeof Y.chunks[x]>"u")throw new Error("doXHR failed!");return Y.chunks[x]}),(G||!w)&&(d=w=1,w=this.getter(0).length,d=w,ee("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=w,this._chunkSize=d,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var l,c}else var c={isDevice:!1,url:t};var m=n.createFile(e,r,c,o,a);c.contents?m.contents=c.contents:c.url&&(m.contents=null,m.url=c.url),Object.defineProperties(m,{usedBytes:{get:function(){return this.contents.length}}});var A={},T=Object.keys(m.stream_ops);T.forEach(_=>{var y=m.stream_ops[_];A[_]=function(){return n.forceLoadFile(m),y.apply(null,arguments)}});function D(_,y,w,U,V){var G=_.node.contents;if(V>=G.length)return 0;var d=Math.min(G.length-V,U);if(g(d>=0),G.slice)for(var E=0;E(n.forceLoadFile(m),D(_,y,w,U,V)),A.mmap=(_,y,w,U,V)=>{n.forceLoadFile(m);var G=kr();if(!G)throw new n.ErrnoError(48);return D(_,q,G,y,w),{ptr:G,allocated:!0}},m.stream_ops=A,m},absolutePath(){z("FS.absolutePath has been removed; use PATH_FS.resolve instead")},createFolder(){z("FS.createFolder has been removed; use FS.mkdir instead")},createLink(){z("FS.createLink has been removed; use FS.symlink instead")},joinPath(){z("FS.joinPath has been removed; use PATH.join instead")},mmapAlloc(){z("FS.mmapAlloc has been replaced by the top level function mmapAlloc")},standardizePath(){z("FS.standardizePath has been removed; use PATH.normalize instead")}},C={DEFAULT_POLLMASK:5,calculateAt(e,r,t){if(M.isAbs(r))return r;var o;if(e===-100)o=n.cwd();else{var a=C.getStreamFromFD(e);o=a.path}if(r.length==0){if(!t)throw new n.ErrnoError(44);return o}return M.join2(o,r)},doStat(e,r,t){try{var o=e(r)}catch(c){if(c&&c.node&&M.normalize(r)!==M.normalize(n.getPath(c.node)))return-54;throw c}F[t>>2]=o.dev,F[t+4>>2]=o.mode,S[t+8>>2]=o.nlink,F[t+12>>2]=o.uid,F[t+16>>2]=o.gid,F[t+20>>2]=o.rdev,O[t+24>>3]=BigInt(o.size),F[t+32>>2]=4096,F[t+36>>2]=o.blocks;var a=o.atime.getTime(),s=o.mtime.getTime(),l=o.ctime.getTime();return O[t+40>>3]=BigInt(Math.floor(a/1e3)),S[t+48>>2]=a%1e3*1e3,O[t+56>>3]=BigInt(Math.floor(s/1e3)),S[t+64>>2]=s%1e3*1e3,O[t+72>>3]=BigInt(Math.floor(l/1e3)),S[t+80>>2]=l%1e3*1e3,O[t+88>>3]=BigInt(o.ino),0},doMsync(e,r,t,o,a){if(!n.isFile(r.node.mode))throw new n.ErrnoError(43);if(o&2)return 0;var s=ue.slice(e,e+t);n.msync(r,s,a,t,o)},varargs:void 0,get(){g(C.varargs!=null);var e=F[+C.varargs>>2];return C.varargs+=4,e},getp(){return C.get()},getStr(e){var r=ie(e);return r},getStreamFromFD(e){var r=n.getStreamChecked(e);return r}};function wt(e,r,t){C.varargs=t;try{var o=C.getStreamFromFD(e);switch(r){case 0:{var a=C.get();if(a<0)return-28;for(;n.streams[a];)a++;var s;return s=n.createStream(o,a),s.fd}case 1:case 2:return 0;case 3:return o.flags;case 4:{var a=C.get();return o.flags|=a,0}case 5:{var a=C.getp(),l=0;return oe[a+l>>1]=2,0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:return ct(28),-1;default:return-28}}catch(c){if(typeof n>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function St(e,r,t){C.varargs=t;try{var o=C.getStreamFromFD(e);switch(r){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=C.getp();F[s>>2]=a.c_iflag||0,F[s+4>>2]=a.c_oflag||0,F[s+8>>2]=a.c_cflag||0,F[s+12>>2]=a.c_lflag||0;for(var l=0;l<32;l++)q[s+l+17>>0]=a.c_cc[l]||0;return 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=C.getp(),c=F[s>>2],m=F[s+4>>2],A=F[s+8>>2],T=F[s+12>>2],D=[],l=0;l<32;l++)D.push(q[s+l+17>>0]);return o.tty.ops.ioctl_tcsets(o.tty,r,{c_iflag:c,c_oflag:m,c_cflag:A,c_lflag:T,c_cc:D})}return 0}case 21519:{if(!o.tty)return-59;var s=C.getp();return F[s>>2]=0,0}case 21520:return o.tty?-28:-59;case 21531:{var s=C.getp();return n.ioctl(o,r,s)}case 21523:{if(!o.tty)return-59;if(o.tty.ops.ioctl_tiocgwinsz){var _=o.tty.ops.ioctl_tiocgwinsz(o.tty),s=C.getp();oe[s>>1]=_[0],oe[s+2>>1]=_[1]}return 0}case 21524:return o.tty?0:-59;case 21515:return o.tty?0:-59;default:return-28}}catch(y){if(typeof n>"u"||y.name!=="ErrnoError")throw y;return-y.errno}}function bt(e,r,t,o){C.varargs=o;try{r=C.getStr(r),r=C.calculateAt(e,r);var a=o?C.get():0;return n.open(r,t,a).fd}catch(s){if(typeof n>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}var kt=e=>{var r=new WebAssembly.Exception(Ke(),[e],{traceStack:!0});if(r.message=Sr(r),r.stack){var t=r.stack.split(` +`)),!e)return null;Je=Ce(e,!0)}return Je.shift()},de={ttys:[],init(){},shutdown(){},register(e,r){de.ttys[e]={input:[],output:[],ops:r},n.registerDevice(e,de.stream_ops)},stream_ops:{open(e){var r=de.ttys[e.node.rdev];if(!r)throw new n.ErrnoError(43);e.tty=r,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,r,t,o,a){if(!e.tty||!e.tty.ops.get_char)throw new n.ErrnoError(60);for(var s=0,l=0;l0&&(ee(ge(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,r,t){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,r){r===null||r===10?(B(ge(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output&&e.output.length>0&&(B(ge(e.output,0)),e.output=[])}}},kr=e=>{z("internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported")},k={ops_table:null,mount(e){return k.createNode(null,"/",16895,0)},createNode(e,r,t,o){if(n.isBlkdev(t)||n.isFIFO(t))throw new n.ErrnoError(63);k.ops_table||(k.ops_table={dir:{node:{getattr:k.node_ops.getattr,setattr:k.node_ops.setattr,lookup:k.node_ops.lookup,mknod:k.node_ops.mknod,rename:k.node_ops.rename,unlink:k.node_ops.unlink,rmdir:k.node_ops.rmdir,readdir:k.node_ops.readdir,symlink:k.node_ops.symlink},stream:{llseek:k.stream_ops.llseek}},file:{node:{getattr:k.node_ops.getattr,setattr:k.node_ops.setattr},stream:{llseek:k.stream_ops.llseek,read:k.stream_ops.read,write:k.stream_ops.write,allocate:k.stream_ops.allocate,mmap:k.stream_ops.mmap,msync:k.stream_ops.msync}},link:{node:{getattr:k.node_ops.getattr,setattr:k.node_ops.setattr,readlink:k.node_ops.readlink},stream:{}},chrdev:{node:{getattr:k.node_ops.getattr,setattr:k.node_ops.setattr},stream:n.chrdev_stream_ops}});var a=n.createNode(e,r,t,o);return n.isDir(a.mode)?(a.node_ops=k.ops_table.dir.node,a.stream_ops=k.ops_table.dir.stream,a.contents={}):n.isFile(a.mode)?(a.node_ops=k.ops_table.file.node,a.stream_ops=k.ops_table.file.stream,a.usedBytes=0,a.contents=null):n.isLink(a.mode)?(a.node_ops=k.ops_table.link.node,a.stream_ops=k.ops_table.link.stream):n.isChrdev(a.mode)&&(a.node_ops=k.ops_table.chrdev.node,a.stream_ops=k.ops_table.chrdev.stream),a.timestamp=Date.now(),e&&(e.contents[r]=a,e.timestamp=a.timestamp),a},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var o=1024*1024;r=Math.max(r,t*(t>>0),t!=0&&(r=Math.max(r,256));var a=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(a.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)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(e){var r={};return r.dev=n.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,n.isDir(e.mode)?r.size=4096:n.isFile(e.mode)?r.size=e.usedBytes:n.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(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&k.resizeFileStorage(e,r.size)},lookup(e,r){throw n.genericErrors[44]},mknod(e,r,t,o){return k.createNode(e,r,t,o)},rename(e,r,t){if(n.isDir(e.mode)){var o;try{o=n.lookupNode(r,t)}catch{}if(o)for(var a in o.contents)throw new n.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(e,r){delete e.contents[r],e.timestamp=Date.now()},rmdir(e,r){var t=n.lookupNode(e,r);for(var o in t.contents)throw new n.ErrnoError(55);delete e.contents[r],e.timestamp=Date.now()},readdir(e){var r=[".",".."];for(var t in e.contents)e.contents.hasOwnProperty(t)&&r.push(t);return r},symlink(e,r,t){var o=k.createNode(e,r,41471,0);return o.link=t,o},readlink(e){if(!n.isLink(e.mode))throw new n.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,o,a){var s=e.node.contents;if(a>=e.node.usedBytes)return 0;var l=Math.min(e.node.usedBytes-a,o);if(g(l>=0),l>8&&s.subarray)r.set(s.subarray(a,a+l),t);else for(var c=0;c0||t+r{var a=o?"":mr(`al ${e}`);Ee(e,s=>{g(s,`Loading data file "${e}" failed (no arrayBuffer).`),r(new Uint8Array(s)),a&&Le(a)},s=>{if(t)t();else throw`Loading data file "${e}" failed.`}),a&&Ze(a)},mt=(e,r,t,o,a,s)=>n.createDataFile(e,r,t,o,a,s),ht=i.preloadPlugins||[],pt=(e,r,t,o)=>{typeof Browser<"u"&&Browser.init();var a=!1;return ht.forEach(s=>{a||s.canHandle(r)&&(s.handle(e,r,t,o),a=!0)}),a},vt=(e,r,t,o,a,s,l,c,m,A)=>{var T=r?se.resolve(M.join2(e,r)):e,D=mr(`cp ${T}`);function _(y){function w(U){A&&A(),c||mt(e,r,U,o,a,m),s&&s(),Le(D)}pt(y,T,w,()=>{l&&l(),Le(D)})||w(y)}Ze(D),typeof t=="string"?ft(t,y=>_(y),l):_(t)},gt=e=>{var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t},er=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},Et={0:"Success",1:"Arg list too long",2:"Permission denied",3:"Address already in use",4:"Address not available",5:"Address family not supported by protocol family",6:"No more processes",7:"Socket already connected",8:"Bad file number",9:"Trying to read unreadable message",10:"Mount device busy",11:"Operation canceled",12:"No children",13:"Connection aborted",14:"Connection refused",15:"Connection reset by peer",16:"File locking deadlock error",17:"Destination address required",18:"Math arg out of domain of func",19:"Quota exceeded",20:"File exists",21:"Bad address",22:"File too large",23:"Host is unreachable",24:"Identifier removed",25:"Illegal byte sequence",26:"Connection already in progress",27:"Interrupted system call",28:"Invalid argument",29:"I/O error",30:"Socket is already connected",31:"Is a directory",32:"Too many symbolic links",33:"Too many open files",34:"Too many links",35:"Message too long",36:"Multihop attempted",37:"File or path name too long",38:"Network interface is not configured",39:"Connection reset by network",40:"Network is unreachable",41:"Too many open files in system",42:"No buffer space available",43:"No such device",44:"No such file or directory",45:"Exec format error",46:"No record locks available",47:"The link has been severed",48:"Not enough core",49:"No message of desired type",50:"Protocol not available",51:"No space left on device",52:"Function not implemented",53:"Socket is not connected",54:"Not a directory",55:"Directory not empty",56:"State not recoverable",57:"Socket operation on non-socket",59:"Not a typewriter",60:"No such device or address",61:"Value too large for defined data type",62:"Previous owner died",63:"Not super-user",64:"Broken pipe",65:"Protocol error",66:"Unknown protocol",67:"Protocol wrong type for socket",68:"Math result not representable",69:"Read only file system",70:"Illegal seek",71:"No such process",72:"Stale file handle",73:"Connection timed out",74:"Text file busy",75:"Cross-device link",100:"Device not a stream",101:"Bad font file fmt",102:"Invalid slot",103:"Invalid request code",104:"No anode",105:"Block device required",106:"Channel number out of range",107:"Level 3 halted",108:"Level 3 reset",109:"Link number out of range",110:"Protocol driver not attached",111:"No CSI structure available",112:"Level 2 halted",113:"Invalid exchange",114:"Invalid request descriptor",115:"Exchange full",116:"No data (for no delay io)",117:"Timer expired",118:"Out of streams resources",119:"Machine is not on the network",120:"Package not installed",121:"The object is remote",122:"Advertise error",123:"Srmount error",124:"Communication error on send",125:"Cross mount point (not really error)",126:"Given log. name not unique",127:"f.d. invalid for this operation",128:"Remote address changed",129:"Can access a needed shared lib",130:"Accessing a corrupted shared lib",131:".lib section in a.out corrupted",132:"Attempting to link in too many libs",133:"Attempting to exec a shared library",135:"Streams pipe error",136:"Too many users",137:"Socket type not supported",138:"Not supported",139:"Protocol family not supported",140:"Can't send after socket shutdown",141:"Too many references",142:"Host is down",148:"No medium (in tape drive)",156:"Level 2 not synchronized"},rr={},yt=e=>(te("warning: build with -sDEMANGLE_SUPPORT to link in libcxxabi demangling"),e),_t=e=>{var r=/\b_Z[\w\d_]+/g;return e.replace(r,function(t){var o=yt(t);return t===o?t:o+" ["+t+"]"})},n={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=se.resolve(e),!e)return{path:"",node:null};var t={follow_mount:!0,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new n.ErrnoError(32);for(var o=e.split("/").filter(D=>!!D),a=n.root,s="/",l=0;l40)throw new n.ErrnoError(32)}}return{path:s,node:a}},getPath(e){for(var r;;){if(n.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,o=0;o>>0)%n.nameTable.length},hashAddNode(e){var r=n.hashName(e.parent.id,e.name);e.name_next=n.nameTable[r],n.nameTable[r]=e},hashRemoveNode(e){var r=n.hashName(e.parent.id,e.name);if(n.nameTable[r]===e)n.nameTable[r]=e.name_next;else for(var t=n.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode(e,r){var t=n.mayLookup(e);if(t)throw new n.ErrnoError(t,e);for(var o=n.hashName(e.id,r),a=n.nameTable[o];a;a=a.name_next){var s=a.name;if(a.parent.id===e.id&&s===r)return a}return n.lookup(e,r)},createNode(e,r,t,o){g(typeof e=="object");var a=new n.FSNode(e,r,t,o);return n.hashAddNode(a),a},destroyNode(e){n.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return(e&61440)===32768},isDir(e){return(e&61440)===16384},isLink(e){return(e&61440)===40960},isChrdev(e){return(e&61440)===8192},isBlkdev(e){return(e&61440)===24576},isFIFO(e){return(e&61440)===4096},isSocket(e){return(e&49152)===49152},flagsToPermissionString(e){var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions(e,r){return n.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){var r=n.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){try{var t=n.lookupNode(e,r);return 20}catch{}return n.nodePermissions(e,"wx")},mayDelete(e,r,t){var o;try{o=n.lookupNode(e,r)}catch(s){return s.errno}var a=n.nodePermissions(e,"wx");if(a)return a;if(t){if(!n.isDir(o.mode))return 54;if(n.isRoot(o)||n.getPath(o)===n.cwd())return 10}else if(n.isDir(o.mode))return 31;return 0},mayOpen(e,r){return e?n.isLink(e.mode)?32:n.isDir(e.mode)&&(n.flagsToPermissionString(r)!=="r"||r&512)?31:n.nodePermissions(e,n.flagsToPermissionString(r)):44},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=n.MAX_OPEN_FDS;e++)if(!n.streams[e])return e;throw new n.ErrnoError(33)},getStreamChecked(e){var r=n.getStream(e);if(!r)throw new n.ErrnoError(8);return r},getStream:e=>n.streams[e],createStream(e,r=-1){return n.FSStream||(n.FSStream=function(){this.shared={}},n.FSStream.prototype={},Object.defineProperties(n.FSStream.prototype,{object:{get(){return this.node},set(t){this.node=t}},isRead:{get(){return(this.flags&2097155)!==1}},isWrite:{get(){return(this.flags&2097155)!==0}},isAppend:{get(){return this.flags&1024}},flags:{get(){return this.shared.flags},set(t){this.shared.flags=t}},position:{get(){return this.shared.position},set(t){this.shared.position=t}}})),e=Object.assign(new n.FSStream,e),r==-1&&(r=n.nextfd()),e.fd=r,n.streams[r]=e,e},closeStream(e){n.streams[e]=null},chrdev_stream_ops:{open(e){var r=n.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek(){throw new n.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice(e,r){n.devices[e]={stream_ops:r}},getDevice:e=>n.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var o=t.pop();r.push(o),t.push.apply(t,o.mounts)}return r},syncfs(e,r){typeof e=="function"&&(r=e,e=!1),n.syncFSRequests++,n.syncFSRequests>1&&B(`warning: ${n.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=n.getMounts(n.root.mount),o=0;function a(l){return g(n.syncFSRequests>0),n.syncFSRequests--,r(l)}function s(l){if(l)return s.errored?void 0:(s.errored=!0,a(l));++o>=t.length&&a(null)}t.forEach(l=>{if(!l.type.syncfs)return s(null);l.type.syncfs(l,e,s)})},mount(e,r,t){if(typeof e=="string")throw e;var o=t==="/",a=!t,s;if(o&&n.root)throw new n.ErrnoError(10);if(!o&&!a){var l=n.lookupPath(t,{follow_mount:!1});if(t=l.path,s=l.node,n.isMountpoint(s))throw new n.ErrnoError(10);if(!n.isDir(s.mode))throw new n.ErrnoError(54)}var c={type:e,opts:r,mountpoint:t,mounts:[]},m=e.mount(c);return m.mount=c,c.root=m,o?n.root=m:s&&(s.mounted=c,s.mount&&s.mount.mounts.push(c)),m},unmount(e){var r=n.lookupPath(e,{follow_mount:!1});if(!n.isMountpoint(r.node))throw new n.ErrnoError(28);var t=r.node,o=t.mounted,a=n.getMounts(o);Object.keys(n.nameTable).forEach(l=>{for(var c=n.nameTable[l];c;){var m=c.name_next;a.includes(c.mount)&&n.destroyNode(c),c=m}}),t.mounted=null;var s=t.mount.mounts.indexOf(o);g(s!==-1),t.mount.mounts.splice(s,1)},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var o=n.lookupPath(e,{parent:!0}),a=o.node,s=M.basename(e);if(!s||s==="."||s==="..")throw new n.ErrnoError(28);var l=n.mayCreate(a,s);if(l)throw new n.ErrnoError(l);if(!a.node_ops.mknod)throw new n.ErrnoError(63);return a.node_ops.mknod(a,s,r,t)},create(e,r){return r=r!==void 0?r:438,r&=4095,r|=32768,n.mknod(e,r,0)},mkdir(e,r){return r=r!==void 0?r:511,r&=1023,r|=16384,n.mknod(e,r,0)},mkdirTree(e,r){for(var t=e.split("/"),o="",a=0;a"u"&&(t=r,r=438),r|=8192,n.mknod(e,r,t)},symlink(e,r){if(!se.resolve(e))throw new n.ErrnoError(44);var t=n.lookupPath(r,{parent:!0}),o=t.node;if(!o)throw new n.ErrnoError(44);var a=M.basename(r),s=n.mayCreate(o,a);if(s)throw new n.ErrnoError(s);if(!o.node_ops.symlink)throw new n.ErrnoError(63);return o.node_ops.symlink(o,a,e)},rename(e,r){var t=M.dirname(e),o=M.dirname(r),a=M.basename(e),s=M.basename(r),l,c,m;if(l=n.lookupPath(e,{parent:!0}),c=l.node,l=n.lookupPath(r,{parent:!0}),m=l.node,!c||!m)throw new n.ErrnoError(44);if(c.mount!==m.mount)throw new n.ErrnoError(75);var A=n.lookupNode(c,a),T=se.relative(e,o);if(T.charAt(0)!==".")throw new n.ErrnoError(28);if(T=se.relative(r,t),T.charAt(0)!==".")throw new n.ErrnoError(55);var D;try{D=n.lookupNode(m,s)}catch{}if(A!==D){var _=n.isDir(A.mode),y=n.mayDelete(c,a,_);if(y)throw new n.ErrnoError(y);if(y=D?n.mayDelete(m,s,_):n.mayCreate(m,s),y)throw new n.ErrnoError(y);if(!c.node_ops.rename)throw new n.ErrnoError(63);if(n.isMountpoint(A)||D&&n.isMountpoint(D))throw new n.ErrnoError(10);if(m!==c&&(y=n.nodePermissions(c,"w"),y))throw new n.ErrnoError(y);n.hashRemoveNode(A);try{c.node_ops.rename(A,m,s)}catch(w){throw w}finally{n.hashAddNode(A)}}},rmdir(e){var r=n.lookupPath(e,{parent:!0}),t=r.node,o=M.basename(e),a=n.lookupNode(t,o),s=n.mayDelete(t,o,!0);if(s)throw new n.ErrnoError(s);if(!t.node_ops.rmdir)throw new n.ErrnoError(63);if(n.isMountpoint(a))throw new n.ErrnoError(10);t.node_ops.rmdir(t,o),n.destroyNode(a)},readdir(e){var r=n.lookupPath(e,{follow:!0}),t=r.node;if(!t.node_ops.readdir)throw new n.ErrnoError(54);return t.node_ops.readdir(t)},unlink(e){var r=n.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new n.ErrnoError(44);var o=M.basename(e),a=n.lookupNode(t,o),s=n.mayDelete(t,o,!1);if(s)throw new n.ErrnoError(s);if(!t.node_ops.unlink)throw new n.ErrnoError(63);if(n.isMountpoint(a))throw new n.ErrnoError(10);t.node_ops.unlink(t,o),n.destroyNode(a)},readlink(e){var r=n.lookupPath(e),t=r.node;if(!t)throw new n.ErrnoError(44);if(!t.node_ops.readlink)throw new n.ErrnoError(28);return se.resolve(n.getPath(t.parent),t.node_ops.readlink(t))},stat(e,r){var t=n.lookupPath(e,{follow:!r}),o=t.node;if(!o)throw new n.ErrnoError(44);if(!o.node_ops.getattr)throw new n.ErrnoError(63);return o.node_ops.getattr(o)},lstat(e){return n.stat(e,!0)},chmod(e,r,t){var o;if(typeof e=="string"){var a=n.lookupPath(e,{follow:!t});o=a.node}else o=e;if(!o.node_ops.setattr)throw new n.ErrnoError(63);o.node_ops.setattr(o,{mode:r&4095|o.mode&-4096,timestamp:Date.now()})},lchmod(e,r){n.chmod(e,r,!0)},fchmod(e,r){var t=n.getStreamChecked(e);n.chmod(t.node,r)},chown(e,r,t,o){var a;if(typeof e=="string"){var s=n.lookupPath(e,{follow:!o});a=s.node}else a=e;if(!a.node_ops.setattr)throw new n.ErrnoError(63);a.node_ops.setattr(a,{timestamp:Date.now()})},lchown(e,r,t){n.chown(e,r,t,!0)},fchown(e,r,t){var o=n.getStreamChecked(e);n.chown(o.node,r,t)},truncate(e,r){if(r<0)throw new n.ErrnoError(28);var t;if(typeof e=="string"){var o=n.lookupPath(e,{follow:!0});t=o.node}else t=e;if(!t.node_ops.setattr)throw new n.ErrnoError(63);if(n.isDir(t.mode))throw new n.ErrnoError(31);if(!n.isFile(t.mode))throw new n.ErrnoError(28);var a=n.nodePermissions(t,"w");if(a)throw new n.ErrnoError(a);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate(e,r){var t=n.getStreamChecked(e);if(!(t.flags&2097155))throw new n.ErrnoError(28);n.truncate(t.node,r)},utime(e,r,t){var o=n.lookupPath(e,{follow:!0}),a=o.node;a.node_ops.setattr(a,{timestamp:Math.max(r,t)})},open(e,r,t){if(e==="")throw new n.ErrnoError(44);r=typeof r=="string"?gt(r):r,t=typeof t>"u"?438:t,r&64?t=t&4095|32768:t=0;var o;if(typeof e=="object")o=e;else{e=M.normalize(e);try{var a=n.lookupPath(e,{follow:!(r&131072)});o=a.node}catch{}}var s=!1;if(r&64)if(o){if(r&128)throw new n.ErrnoError(20)}else o=n.mknod(e,t,0),s=!0;if(!o)throw new n.ErrnoError(44);if(n.isChrdev(o.mode)&&(r&=-513),r&65536&&!n.isDir(o.mode))throw new n.ErrnoError(54);if(!s){var l=n.mayOpen(o,r);if(l)throw new n.ErrnoError(l)}r&512&&!s&&n.truncate(o,0),r&=-131713;var c=n.createStream({node:o,path:n.getPath(o),flags:r,seekable:!0,position:0,stream_ops:o.stream_ops,ungotten:[],error:!1});return c.stream_ops.open&&c.stream_ops.open(c),i.logReadFiles&&!(r&1)&&(n.readFiles||(n.readFiles={}),e in n.readFiles||(n.readFiles[e]=1)),c},close(e){if(n.isClosed(e))throw new n.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{n.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,r,t){if(n.isClosed(e))throw new n.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new n.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new n.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,o,a){if(g(t>=0),o<0||a<0)throw new n.ErrnoError(28);if(n.isClosed(e))throw new n.ErrnoError(8);if((e.flags&2097155)===1)throw new n.ErrnoError(8);if(n.isDir(e.node.mode))throw new n.ErrnoError(31);if(!e.stream_ops.read)throw new n.ErrnoError(28);var s=typeof a<"u";if(!s)a=e.position;else if(!e.seekable)throw new n.ErrnoError(70);var l=e.stream_ops.read(e,r,t,o,a);return s||(e.position+=l),l},write(e,r,t,o,a,s){if(g(t>=0),o<0||a<0)throw new n.ErrnoError(28);if(n.isClosed(e))throw new n.ErrnoError(8);if(!(e.flags&2097155))throw new n.ErrnoError(8);if(n.isDir(e.node.mode))throw new n.ErrnoError(31);if(!e.stream_ops.write)throw new n.ErrnoError(28);e.seekable&&e.flags&1024&&n.llseek(e,0,2);var l=typeof a<"u";if(!l)a=e.position;else if(!e.seekable)throw new n.ErrnoError(70);var c=e.stream_ops.write(e,r,t,o,a,s);return l||(e.position+=c),c},allocate(e,r,t){if(n.isClosed(e))throw new n.ErrnoError(8);if(r<0||t<=0)throw new n.ErrnoError(28);if(!(e.flags&2097155))throw new n.ErrnoError(8);if(!n.isFile(e.node.mode)&&!n.isDir(e.node.mode))throw new n.ErrnoError(43);if(!e.stream_ops.allocate)throw new n.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap(e,r,t,o,a){if(o&2&&!(a&2)&&(e.flags&2097155)!==2)throw new n.ErrnoError(2);if((e.flags&2097155)===1)throw new n.ErrnoError(2);if(!e.stream_ops.mmap)throw new n.ErrnoError(43);return e.stream_ops.mmap(e,r,t,o,a)},msync(e,r,t,o,a){return g(t>=0),e.stream_ops.msync?e.stream_ops.msync(e,r,t,o,a):0},munmap:e=>0,ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new n.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){if(r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary")throw new Error(`Invalid encoding type "${r.encoding}"`);var t,o=n.open(e,r.flags),a=n.stat(e),s=a.size,l=new Uint8Array(s);return n.read(o,l,0,s,0),r.encoding==="utf8"?t=ge(l,0):r.encoding==="binary"&&(t=l),n.close(o),t},writeFile(e,r,t={}){t.flags=t.flags||577;var o=n.open(e,t.flags,t.mode);if(typeof r=="string"){var a=new Uint8Array(Qe(r)+1),s=Pe(r,a,0,a.length);n.write(o,a,0,s,void 0,t.canOwn)}else if(ArrayBuffer.isView(r))n.write(o,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");n.close(o)},cwd:()=>n.currentPath,chdir(e){var r=n.lookupPath(e,{follow:!0});if(r.node===null)throw new n.ErrnoError(44);if(!n.isDir(r.node.mode))throw new n.ErrnoError(54);var t=n.nodePermissions(r.node,"x");if(t)throw new n.ErrnoError(t);n.currentPath=r.path},createDefaultDirectories(){n.mkdir("/tmp"),n.mkdir("/home"),n.mkdir("/home/web_user")},createDefaultDevices(){n.mkdir("/dev"),n.registerDevice(n.makedev(1,3),{read:()=>0,write:(o,a,s,l,c)=>l}),n.mkdev("/dev/null",n.makedev(1,3)),de.register(n.makedev(5,0),de.default_tty_ops),de.register(n.makedev(6,0),de.default_tty1_ops),n.mkdev("/dev/tty",n.makedev(5,0)),n.mkdev("/dev/tty1",n.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(r=br(e).byteLength),e[--r]);n.createDevice("/dev","random",t),n.createDevice("/dev","urandom",t),n.mkdir("/dev/shm"),n.mkdir("/dev/shm/tmp")},createSpecialDirectories(){n.mkdir("/proc");var e=n.mkdir("/proc/self");n.mkdir("/proc/self/fd"),n.mount({mount(){var r=n.createNode(e,"fd",16895,73);return r.node_ops={lookup(t,o){var a=+o,s=n.getStreamChecked(a),l={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>s.path}};return l.parent=l,l}},r}},{},"/proc/self/fd")},createStandardStreams(){i.stdin?n.createDevice("/dev","stdin",i.stdin):n.symlink("/dev/tty","/dev/stdin"),i.stdout?n.createDevice("/dev","stdout",null,i.stdout):n.symlink("/dev/tty","/dev/stdout"),i.stderr?n.createDevice("/dev","stderr",null,i.stderr):n.symlink("/dev/tty1","/dev/stderr");var e=n.open("/dev/stdin",0),r=n.open("/dev/stdout",1),t=n.open("/dev/stderr",1);g(e.fd===0,`invalid handle for stdin (${e.fd})`),g(r.fd===1,`invalid handle for stdout (${r.fd})`),g(t.fd===2,`invalid handle for stderr (${t.fd})`)},ensureErrnoError(){n.ErrnoError||(n.ErrnoError=function(r,t){this.name="ErrnoError",this.node=t,this.setErrno=function(o){this.errno=o;for(var a in rr)if(rr[a]===o){this.code=a;break}},this.setErrno(r),this.message=Et[r],this.stack&&(Object.defineProperty(this,"stack",{value:new Error().stack,writable:!0}),this.stack=_t(this.stack))},n.ErrnoError.prototype=new Error,n.ErrnoError.prototype.constructor=n.ErrnoError,[44].forEach(e=>{n.genericErrors[e]=new n.ErrnoError(e),n.genericErrors[e].stack=""}))},staticInit(){n.ensureErrnoError(),n.nameTable=new Array(4096),n.mount(k,{},"/"),n.createDefaultDirectories(),n.createDefaultDevices(),n.createSpecialDirectories(),n.filesystems={MEMFS:k}},init(e,r,t){g(!n.init.initialized,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)"),n.init.initialized=!0,n.ensureErrnoError(),i.stdin=e||i.stdin,i.stdout=r||i.stdout,i.stderr=t||i.stderr,n.createStandardStreams()},quit(){n.init.initialized=!1,Mr(0);for(var e=0;ethis.length-1||y<0)){var w=y%this.chunkSize,U=y/this.chunkSize|0;return this.getter(U)[w]}},s.prototype.setDataGetter=function(y){this.getter=y},s.prototype.cacheLength=function(){var y=new XMLHttpRequest;if(y.open("HEAD",t,!1),y.send(null),!(y.status>=200&&y.status<300||y.status===304))throw new Error("Couldn't load "+t+". Status: "+y.status);var w=Number(y.getResponseHeader("Content-length")),U,V=(U=y.getResponseHeader("Accept-Ranges"))&&U==="bytes",G=(U=y.getResponseHeader("Content-Encoding"))&&U==="gzip",d=1024*1024;V||(d=w);var E=(x,J)=>{if(x>J)throw new Error("invalid range ("+x+", "+J+") or no bytes requested!");if(J>w-1)throw new Error("only "+w+" bytes available! programmer error!");var H=new XMLHttpRequest;if(H.open("GET",t,!1),w!==d&&H.setRequestHeader("Range","bytes="+x+"-"+J),H.responseType="arraybuffer",H.overrideMimeType&&H.overrideMimeType("text/plain; charset=x-user-defined"),H.send(null),!(H.status>=200&&H.status<300||H.status===304))throw new Error("Couldn't load "+t+". Status: "+H.status);return H.response!==void 0?new Uint8Array(H.response||[]):Ce(H.responseText||"",!0)},Y=this;Y.setDataGetter(x=>{var J=x*d,H=(x+1)*d-1;if(H=Math.min(H,w-1),typeof Y.chunks[x]>"u"&&(Y.chunks[x]=E(J,H)),typeof Y.chunks[x]>"u")throw new Error("doXHR failed!");return Y.chunks[x]}),(G||!w)&&(d=w=1,w=this.getter(0).length,d=w,ee("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=w,this._chunkSize=d,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var l,c}else var c={isDevice:!1,url:t};var m=n.createFile(e,r,c,o,a);c.contents?m.contents=c.contents:c.url&&(m.contents=null,m.url=c.url),Object.defineProperties(m,{usedBytes:{get:function(){return this.contents.length}}});var A={},T=Object.keys(m.stream_ops);T.forEach(_=>{var y=m.stream_ops[_];A[_]=function(){return n.forceLoadFile(m),y.apply(null,arguments)}});function D(_,y,w,U,V){var G=_.node.contents;if(V>=G.length)return 0;var d=Math.min(G.length-V,U);if(g(d>=0),G.slice)for(var E=0;E(n.forceLoadFile(m),D(_,y,w,U,V)),A.mmap=(_,y,w,U,V)=>{n.forceLoadFile(m);var G=kr();if(!G)throw new n.ErrnoError(48);return D(_,q,G,y,w),{ptr:G,allocated:!0}},m.stream_ops=A,m},absolutePath(){z("FS.absolutePath has been removed; use PATH_FS.resolve instead")},createFolder(){z("FS.createFolder has been removed; use FS.mkdir instead")},createLink(){z("FS.createLink has been removed; use FS.symlink instead")},joinPath(){z("FS.joinPath has been removed; use PATH.join instead")},mmapAlloc(){z("FS.mmapAlloc has been replaced by the top level function mmapAlloc")},standardizePath(){z("FS.standardizePath has been removed; use PATH.normalize instead")}},C={DEFAULT_POLLMASK:5,calculateAt(e,r,t){if(M.isAbs(r))return r;var o;if(e===-100)o=n.cwd();else{var a=C.getStreamFromFD(e);o=a.path}if(r.length==0){if(!t)throw new n.ErrnoError(44);return o}return M.join2(o,r)},doStat(e,r,t){try{var o=e(r)}catch(c){if(c&&c.node&&M.normalize(r)!==M.normalize(n.getPath(c.node)))return-54;throw c}F[t>>2]=o.dev,F[t+4>>2]=o.mode,S[t+8>>2]=o.nlink,F[t+12>>2]=o.uid,F[t+16>>2]=o.gid,F[t+20>>2]=o.rdev,O[t+24>>3]=BigInt(o.size),F[t+32>>2]=4096,F[t+36>>2]=o.blocks;var a=o.atime.getTime(),s=o.mtime.getTime(),l=o.ctime.getTime();return O[t+40>>3]=BigInt(Math.floor(a/1e3)),S[t+48>>2]=a%1e3*1e3,O[t+56>>3]=BigInt(Math.floor(s/1e3)),S[t+64>>2]=s%1e3*1e3,O[t+72>>3]=BigInt(Math.floor(l/1e3)),S[t+80>>2]=l%1e3*1e3,O[t+88>>3]=BigInt(o.ino),0},doMsync(e,r,t,o,a){if(!n.isFile(r.node.mode))throw new n.ErrnoError(43);if(o&2)return 0;var s=ue.slice(e,e+t);n.msync(r,s,a,t,o)},varargs:void 0,get(){g(C.varargs!=null);var e=F[+C.varargs>>2];return C.varargs+=4,e},getp(){return C.get()},getStr(e){var r=ie(e);return r},getStreamFromFD(e){var r=n.getStreamChecked(e);return r}};function wt(e,r,t){C.varargs=t;try{var o=C.getStreamFromFD(e);switch(r){case 0:{var a=C.get();if(a<0)return-28;for(;n.streams[a];)a++;var s;return s=n.createStream(o,a),s.fd}case 1:case 2:return 0;case 3:return o.flags;case 4:{var a=C.get();return o.flags|=a,0}case 5:{var a=C.getp(),l=0;return oe[a+l>>1]=2,0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:return ct(28),-1;default:return-28}}catch(c){if(typeof n>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function St(e,r,t){C.varargs=t;try{var o=C.getStreamFromFD(e);switch(r){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=C.getp();F[s>>2]=a.c_iflag||0,F[s+4>>2]=a.c_oflag||0,F[s+8>>2]=a.c_cflag||0,F[s+12>>2]=a.c_lflag||0;for(var l=0;l<32;l++)q[s+l+17>>0]=a.c_cc[l]||0;return 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=C.getp(),c=F[s>>2],m=F[s+4>>2],A=F[s+8>>2],T=F[s+12>>2],D=[],l=0;l<32;l++)D.push(q[s+l+17>>0]);return o.tty.ops.ioctl_tcsets(o.tty,r,{c_iflag:c,c_oflag:m,c_cflag:A,c_lflag:T,c_cc:D})}return 0}case 21519:{if(!o.tty)return-59;var s=C.getp();return F[s>>2]=0,0}case 21520:return o.tty?-28:-59;case 21531:{var s=C.getp();return n.ioctl(o,r,s)}case 21523:{if(!o.tty)return-59;if(o.tty.ops.ioctl_tiocgwinsz){var _=o.tty.ops.ioctl_tiocgwinsz(o.tty),s=C.getp();oe[s>>1]=_[0],oe[s+2>>1]=_[1]}return 0}case 21524:return o.tty?0:-59;case 21515:return o.tty?0:-59;default:return-28}}catch(y){if(typeof n>"u"||y.name!=="ErrnoError")throw y;return-y.errno}}function bt(e,r,t,o){C.varargs=o;try{r=C.getStr(r),r=C.calculateAt(e,r);var a=o?C.get():0;return n.open(r,t,a).fd}catch(s){if(typeof n>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}var kt=e=>{var r=new WebAssembly.Exception(Ke(),[e],{traceStack:!0});if(r.message=Sr(r),r.stack){var t=r.stack.split(` `);t.splice(1,1),r.stack=t.join(` -`)}throw r},At=()=>{z("native code called abort()")},Tt=(e,r,t)=>ue.copyWithin(e,r,r+t),Ft=e=>{z(`Cannot enlarge memory arrays to size ${e} bytes (OOM). Either (1) compile with -sINITIAL_MEMORY=X with X higher than the current value ${q.length}, (2) compile with -sALLOW_MEMORY_GROWTH which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -sABORTING_MALLOC=0`)},Ot=e=>{ue.length,e>>>=0,Ft(e)},tr={},Nt=()=>N||"./this.program",Fe=()=>{if(!Fe.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Nt()};for(var t in tr)tr[t]===void 0?delete r[t]:r[t]=tr[t];var o=[];for(var t in r)o.push(`${t}=${r[t]}`);Fe.strings=o}return Fe.strings},Dt=(e,r)=>{for(var t=0;t>0]=e.charCodeAt(t);q[r>>0]=0},Mt=(e,r)=>{var t=0;return Fe().forEach((o,a)=>{var s=r+t;S[e+a*4>>2]=s,Dt(o,s),t+=o.length+1}),0},Lt=(e,r)=>{var t=Fe();S[e>>2]=t.length;var o=0;return t.forEach(a=>o+=a.length+1),S[r>>2]=o,0},Pt=e=>{fr()||(i.onExit&&i.onExit(e),he=!0),p(e,new ot(e))},Ct=(e,r)=>{if(ln(),fr()&&!r){var t=`program exited (with status: ${e}), but keepRuntimeAlive() is set (counter=${dr}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;v(t),B(t)}Pt(e)},Rt=Ct;function It(e){try{var r=C.getStreamFromFD(e);return n.close(r),0}catch(t){if(typeof n>"u"||t.name!=="ErrnoError")throw t;return t.errno}}function xt(e,r){try{var t=0,o=0,a=0,s=C.getStreamFromFD(e),l=s.tty?2:n.isDir(s.mode)?3:n.isLink(s.mode)?7:4;return q[r>>0]=l,oe[r+2>>1]=a,O[r+8>>3]=BigInt(t),O[r+16>>3]=BigInt(o),0}catch(c){if(typeof n>"u"||c.name!=="ErrnoError")throw c;return c.errno}}var Ut=(e,r,t,o)=>{for(var a=0,s=0;s>2],c=S[r+4>>2];r+=8;var m=n.read(e,q,l,c,o);if(m<0)return-1;if(a+=m,m>2]=s,0}catch(l){if(typeof n>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var zt=9007199254740992,Ht=-9007199254740992,Yt=e=>ezt?NaN:Number(e);function qt(e,r,t,o){r=Yt(r);try{if(isNaN(r))return 61;var a=C.getStreamFromFD(e);return n.llseek(a,r,t),O[o>>3]=BigInt(a.position),a.getdents&&r===0&&t===0&&(a.getdents=null),0}catch(s){if(typeof n>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var Gt=(e,r,t,o)=>{for(var a=0,s=0;s>2],c=S[r+4>>2];r+=8;var m=n.write(e,q,l,c,o);if(m<0)return-1;a+=m,typeof o<"u"&&(o+=m)}return a};function Wt(e,r,t,o){try{var a=C.getStreamFromFD(e),s=Gt(a,r,t);return S[o>>2]=s,0}catch(l){if(typeof n>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var Re=e=>e%4===0&&(e%100!==0||e%400===0),$t=(e,r)=>{for(var t=0,o=0;o<=r;t+=e[o++]);return t},Ar=[31,29,31,30,31,30,31,31,30,31,30,31],Tr=[31,28,31,30,31,30,31,31,30,31,30,31],jt=(e,r)=>{for(var t=new Date(e.getTime());r>0;){var o=Re(t.getFullYear()),a=t.getMonth(),s=(o?Ar:Tr)[a];if(r>s-t.getDate())r-=s-t.getDate()+1,t.setDate(1),a<11?t.setMonth(a+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1));else return t.setDate(t.getDate()+r),t}return t},nr=(e,r)=>{g(e.length>=0,"writeArrayToMemory array must have a length (should be an array or typed array)"),q.set(e,r)},Vt=(e,r,t,o)=>{var a=S[o+40>>2],s={tm_sec:F[o>>2],tm_min:F[o+4>>2],tm_hour:F[o+8>>2],tm_mday:F[o+12>>2],tm_mon:F[o+16>>2],tm_year:F[o+20>>2],tm_wday:F[o+24>>2],tm_yday:F[o+28>>2],tm_isdst:F[o+32>>2],tm_gmtoff:F[o+36>>2],tm_zone:a?ie(a):""},l=ie(t),c={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var m in c)l=l.replace(new RegExp(m,"g"),c[m]);var A=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],T=["January","February","March","April","May","June","July","August","September","October","November","December"];function D(d,E,Y){for(var x=typeof d=="number"?d.toString():d||"";x.length0?1:0}var x;return(x=Y(d.getFullYear()-E.getFullYear()))===0&&(x=Y(d.getMonth()-E.getMonth()))===0&&(x=Y(d.getDate()-E.getDate())),x}function w(d){switch(d.getDay()){case 0:return new Date(d.getFullYear()-1,11,29);case 1:return d;case 2:return new Date(d.getFullYear(),0,3);case 3:return new Date(d.getFullYear(),0,2);case 4:return new Date(d.getFullYear(),0,1);case 5:return new Date(d.getFullYear()-1,11,31);case 6:return new Date(d.getFullYear()-1,11,30)}}function U(d){var E=jt(new Date(d.tm_year+1900,0,1),d.tm_yday),Y=new Date(E.getFullYear(),0,4),x=new Date(E.getFullYear()+1,0,4),J=w(Y),H=w(x);return y(J,E)<=0?y(H,E)<=0?E.getFullYear()+1:E.getFullYear():E.getFullYear()-1}var V={"%a":d=>A[d.tm_wday].substring(0,3),"%A":d=>A[d.tm_wday],"%b":d=>T[d.tm_mon].substring(0,3),"%B":d=>T[d.tm_mon],"%C":d=>{var E=d.tm_year+1900;return _(E/100|0,2)},"%d":d=>_(d.tm_mday,2),"%e":d=>D(d.tm_mday,2," "),"%g":d=>U(d).toString().substring(2),"%G":d=>U(d),"%H":d=>_(d.tm_hour,2),"%I":d=>{var E=d.tm_hour;return E==0?E=12:E>12&&(E-=12),_(E,2)},"%j":d=>_(d.tm_mday+$t(Re(d.tm_year+1900)?Ar:Tr,d.tm_mon-1),3),"%m":d=>_(d.tm_mon+1,2),"%M":d=>_(d.tm_min,2),"%n":()=>` -`,"%p":d=>d.tm_hour>=0&&d.tm_hour<12?"AM":"PM","%S":d=>_(d.tm_sec,2),"%t":()=>" ","%u":d=>d.tm_wday||7,"%U":d=>{var E=d.tm_yday+7-d.tm_wday;return _(Math.floor(E/7),2)},"%V":d=>{var E=Math.floor((d.tm_yday+7-(d.tm_wday+6)%7)/7);if((d.tm_wday+371-d.tm_yday-2)%7<=2&&E++,E){if(E==53){var x=(d.tm_wday+371-d.tm_yday)%7;x!=4&&(x!=3||!Re(d.tm_year))&&(E=1)}}else{E=52;var Y=(d.tm_wday+7-d.tm_yday-1)%7;(Y==4||Y==5&&Re(d.tm_year%400-1))&&E++}return _(E,2)},"%w":d=>d.tm_wday,"%W":d=>{var E=d.tm_yday+7-(d.tm_wday+6)%7;return _(Math.floor(E/7),2)},"%y":d=>(d.tm_year+1900).toString().substring(2),"%Y":d=>d.tm_year+1900,"%z":d=>{var E=d.tm_gmtoff,Y=E>=0;return E=Math.abs(E)/60,E=E/60*100+E%60,(Y?"+":"-")+("0000"+E).slice(-4)},"%Z":d=>d.tm_zone,"%%":()=>"%"};l=l.replace(/%%/g,"\0\0");for(var m in V)l.includes(m)&&(l=l.replace(new RegExp(m,"g"),V[m](s)));l=l.replace(/\0\0/g,"%");var G=Ce(l,!1);return G.length>r?0:(nr(G,e),G.length-1)},Zt=(e,r,t,o,a)=>Vt(e,r,t,o),Xt=e=>{var r=i["_"+e];return g(r,"Cannot call unknown function "+e+", make sure it is exported"),r},Kt=(e,r,t)=>(g(typeof t=="number","stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),Pe(e,ue,r,t)),Fr=e=>{var r=Qe(e)+1,t=Oe(r);return Kt(e,t,r),t},Or=(e,r,t,o,a)=>{var s={string:w=>{var U=0;return w!=null&&w!==0&&(U=Fr(w)),U},array:w=>{var U=Oe(w.length);return nr(w,U),U}};function l(w){return r==="string"?ie(w):r==="boolean"?!!w:w}var c=Xt(e),m=[],A=0;if(g(r!=="array",'Return type should not be "array".'),o)for(var T=0;Tfunction(){return Or(e,r,t,arguments)},Nr=function(e,r,t,o){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=n.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=o},Ie=365,xe=146;Object.defineProperties(Nr.prototype,{read:{get:function(){return(this.mode&Ie)===Ie},set:function(e){e?this.mode|=Ie:this.mode&=~Ie}},write:{get:function(){return(this.mode&xe)===xe},set:function(e){e?this.mode|=xe:this.mode&=~xe}},isFolder:{get:function(){return n.isDir(this.mode)}},isDevice:{get:function(){return n.isChrdev(this.mode)}}}),n.FSNode=Nr,n.createPreloadedFile=pt,n.staticInit(),rr={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135};function Qt(){tt("fetchSettings")}var Dr={__assert_fail:lt,__syscall_fcntl64:wt,__syscall_ioctl:St,__syscall_openat:bt,__throw_exception_with_stack_trace:kt,abort:At,emscripten_memcpy_js:Tt,emscripten_resize_heap:Ot,environ_get:Mt,environ_sizes_get:Lt,exit:Rt,fd_close:It,fd_fdstat_get:xt,fd_read:Bt,fd_seek:qt,fd_write:Wt,strftime_l:Zt},K=rt();i._Session__create__=L("Session__create__"),i._Session__destroy__=L("Session__destroy__"),i._Session__params_ref=L("Session__params_ref"),i._Session__module_ref=L("Session__module_ref"),i._Session_run=L("Session_run"),i._Session_start=L("Session_start"),i._Session_printContext=L("Session_printContext"),i._Session_step=L("Session_step"),i._Session_continue=L("Session_continue"),i._Session_print=L("Session_print"),i._Session_switch=L("Session_switch"),i._validate_wasm=L("validate_wasm"),i._run_wasm=L("run_wasm"),i._debug_wasm=L("debug_wasm"),i._Session_fetch_shrubbery=L("Session_fetch_shrubbery"),i._exception=L("exception"),i._assertion=L("assertion");var en=L("__errno_location"),Mr=i._fflush=L("fflush"),Lr=i._free=L("free");i._malloc=L("malloc");var Pr=()=>(Pr=K.__trap)(),Cr=()=>(Cr=K.emscripten_stack_init)(),or=()=>(or=K.emscripten_stack_get_end)(),ar=L("stackSave"),ir=L("stackRestore"),Oe=L("stackAlloc"),rn=i.___cxa_decrement_exception_refcount=L("__cxa_decrement_exception_refcount");i.___cxa_increment_exception_refcount=L("__cxa_increment_exception_refcount");var tn=i.___thrown_object_from_unwind_exception=L("__thrown_object_from_unwind_exception"),nn=i.___get_exception_message=L("__get_exception_message");i.wasmMemory=me,i.wasmExports=K,i.stackAlloc=Oe,i.stackSave=ar,i.stackRestore=ir,i.ccall=Or,i.cwrap=Jt,i.UTF8ArrayToString=ge,i.stringToUTF8Array=Pe,i.stringToUTF8OnStack=Fr,i.writeArrayToMemory=nr,i.getCppExceptionTag=Ke,i.decrementExceptionRefcount=at;var on=["writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","growMemory","ydayFromDate","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","getHostByName","getCallstack","emscriptenLog","convertPCtoSourceLocation","readEmAsmArgs","jstoi_q","jstoi_s","listenOnce","autoResumeAudioContext","getDynCaller","dynCall","handleException","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","safeSetTimeout","asmjsMangle","handleAllocatorInit","HandleAllocator","getNativeTypeSize","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","getFunctionAddress","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","intArrayToString","AsciiToString","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","stringToNewUTF8","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","findCanvasEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","jsStackTrace","stackTrace","checkWasiClock","wasiRightsToMuslOFlags","wasiOFlagsToMuslOFlags","createDyncallWrapper","setImmediateWrapped","clearImmediateWrapped","polyfillSetImmediate","getPromise","makePromise","idsToPromises","makePromiseCallback","setMainLoop","getSocketFromFD","getSocketAddress","FS_unlink","FS_mkdirTree","_setNetworkCallback","heapObjectForWebGLType","heapAccessShiftForWebGLHeap","webgl_enable_ANGLE_instanced_arrays","webgl_enable_OES_vertex_array_object","webgl_enable_WEBGL_draw_buffers","webgl_enable_WEBGL_multi_draw","emscriptenWebGLGet","computeUnpackAlignedImageSize","colorChannelsInGlTextureFormat","emscriptenWebGLGetTexPixelData","__glGenObject","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","__glGetActiveAttribOrUniform","writeGLArray","registerWebGlEventCallback","runAndAbortIfError","SDL_unicode","SDL_ttfContext","SDL_audio","ALLOC_NORMAL","ALLOC_STACK","allocate","writeStringToMemory","writeAsciiToMemory"];on.forEach(nt);var an=["run","addOnPreRun","addOnInit","addOnPreMain","addOnExit","addOnPostRun","addRunDependency","removeRunDependency","FS_createFolder","FS_createPath","FS_createLazyFile","FS_createLink","FS_createDevice","FS_readFile","out","err","callMain","abort","keepRuntimeAlive","getTempRet0","setTempRet0","writeStackCookie","checkStackCookie","MAX_INT53","MIN_INT53","bigintToI53Checked","ptrToString","zeroMemory","exitJS","getHeapMax","abortOnCannotGrowMemory","ENV","MONTH_DAYS_REGULAR","MONTH_DAYS_LEAP","MONTH_DAYS_REGULAR_CUMULATIVE","MONTH_DAYS_LEAP_CUMULATIVE","isLeapYear","arraySum","addDays","ERRNO_CODES","ERRNO_MESSAGES","setErrNo","DNS","Protocols","Sockets","initRandomFill","randomFill","timers","warnOnce","UNWIND_CACHE","readEmAsmArgsArray","getExecutableName","asyncLoad","alignMemory","mmapAlloc","wasmTable","getCFunc","freeTableIndexes","functionsInTableMap","setValue","getValue","PATH","PATH_FS","UTF8Decoder","UTF8ToString","stringToUTF8","lengthBytesUTF8","intArrayFromString","stringToAscii","UTF16Decoder","JSEvents","specialHTMLTargets","currentFullscreenStrategy","restoreOldWindowedStyle","demangle","demangleAll","ExitStatus","getEnvStrings","doReadv","doWritev","promiseMap","getExceptionMessageCommon","getCppExceptionThrownObjectFromWebAssemblyException","incrementExceptionRefcount","getExceptionMessage","Browser","wget","SYSCALLS","preloadPlugins","FS_createPreloadedFile","FS_modeStringToFlags","FS_getMode","FS_stdin_getChar_buffer","FS_stdin_getChar","FS","FS_createDataFile","MEMFS","TTY","PIPEFS","SOCKFS","tempFixedLengthArray","miniTempWebGLFloatBuffers","miniTempWebGLIntBuffers","GL","emscripten_webgl_power_preferences","AL","GLUT","EGL","GLEW","IDBStore","SDL","SDL_gfx","allocateUTF8","allocateUTF8OnStack"];an.forEach(yr);var Ue;Ae=function e(){Ue||Rr(),Ue||(Ae=e)};function sn(){Cr(),be()}function Rr(){if(ve>0||(sn(),Wr(),ve>0))return;function e(){Ue||(Ue=!0,i.calledRun=!0,!he&&($r(),h(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),g(!i._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),jr()))}i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),e()},1)):e(),ke()}function ln(){var e=ee,r=B,t=!1;ee=B=o=>{t=!0};try{Mr(0),["stdout","stderr"].forEach(function(o){var a=n.analyzePath("/dev/"+o);if(a){var s=a.object,l=s.rdev,c=de.ttys[l];c&&c.output&&c.output.length&&(t=!0)}})}catch{}ee=e,B=r,t&&te("stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.")}if(i.preInit)for(typeof i.preInit=="function"&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return Rr(),u.ready}})();const R=document.getElementById("talvos"),Q=R.querySelector("output.stdio")||{},Z=R.querySelector("output.error")||{};var lr={print:function(f){Q.value+=f+` +`)}throw r},At=()=>{z("native code called abort()")},Tt=(e,r,t)=>ue.copyWithin(e,r,r+t),Ft=e=>{z(`Cannot enlarge memory arrays to size ${e} bytes (OOM). Either (1) compile with -sINITIAL_MEMORY=X with X higher than the current value ${q.length}, (2) compile with -sALLOW_MEMORY_GROWTH which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -sABORTING_MALLOC=0`)},Ot=e=>{ue.length,e>>>=0,Ft(e)},tr={},Nt=()=>N||"./this.program",Fe=()=>{if(!Fe.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Nt()};for(var t in tr)tr[t]===void 0?delete r[t]:r[t]=tr[t];var o=[];for(var t in r)o.push(`${t}=${r[t]}`);Fe.strings=o}return Fe.strings},Dt=(e,r)=>{for(var t=0;t>0]=e.charCodeAt(t);q[r>>0]=0},Mt=(e,r)=>{var t=0;return Fe().forEach((o,a)=>{var s=r+t;S[e+a*4>>2]=s,Dt(o,s),t+=o.length+1}),0},Lt=(e,r)=>{var t=Fe();S[e>>2]=t.length;var o=0;return t.forEach(a=>o+=a.length+1),S[r>>2]=o,0},Pt=e=>{fr()||(i.onExit&&i.onExit(e),he=!0),v(e,new ot(e))},Ct=(e,r)=>{if(ln(),fr()&&!r){var t=`program exited (with status: ${e}), but keepRuntimeAlive() is set (counter=${dr}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;p(t),B(t)}Pt(e)},Rt=Ct;function It(e){try{var r=C.getStreamFromFD(e);return n.close(r),0}catch(t){if(typeof n>"u"||t.name!=="ErrnoError")throw t;return t.errno}}function xt(e,r){try{var t=0,o=0,a=0,s=C.getStreamFromFD(e),l=s.tty?2:n.isDir(s.mode)?3:n.isLink(s.mode)?7:4;return q[r>>0]=l,oe[r+2>>1]=a,O[r+8>>3]=BigInt(t),O[r+16>>3]=BigInt(o),0}catch(c){if(typeof n>"u"||c.name!=="ErrnoError")throw c;return c.errno}}var Ut=(e,r,t,o)=>{for(var a=0,s=0;s>2],c=S[r+4>>2];r+=8;var m=n.read(e,q,l,c,o);if(m<0)return-1;if(a+=m,m>2]=s,0}catch(l){if(typeof n>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var zt=9007199254740992,Ht=-9007199254740992,Yt=e=>ezt?NaN:Number(e);function qt(e,r,t,o){r=Yt(r);try{if(isNaN(r))return 61;var a=C.getStreamFromFD(e);return n.llseek(a,r,t),O[o>>3]=BigInt(a.position),a.getdents&&r===0&&t===0&&(a.getdents=null),0}catch(s){if(typeof n>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var Gt=(e,r,t,o)=>{for(var a=0,s=0;s>2],c=S[r+4>>2];r+=8;var m=n.write(e,q,l,c,o);if(m<0)return-1;a+=m,typeof o<"u"&&(o+=m)}return a};function Wt(e,r,t,o){try{var a=C.getStreamFromFD(e),s=Gt(a,r,t);return S[o>>2]=s,0}catch(l){if(typeof n>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var Re=e=>e%4===0&&(e%100!==0||e%400===0),$t=(e,r)=>{for(var t=0,o=0;o<=r;t+=e[o++]);return t},Ar=[31,29,31,30,31,30,31,31,30,31,30,31],Tr=[31,28,31,30,31,30,31,31,30,31,30,31],jt=(e,r)=>{for(var t=new Date(e.getTime());r>0;){var o=Re(t.getFullYear()),a=t.getMonth(),s=(o?Ar:Tr)[a];if(r>s-t.getDate())r-=s-t.getDate()+1,t.setDate(1),a<11?t.setMonth(a+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1));else return t.setDate(t.getDate()+r),t}return t},nr=(e,r)=>{g(e.length>=0,"writeArrayToMemory array must have a length (should be an array or typed array)"),q.set(e,r)},Vt=(e,r,t,o)=>{var a=S[o+40>>2],s={tm_sec:F[o>>2],tm_min:F[o+4>>2],tm_hour:F[o+8>>2],tm_mday:F[o+12>>2],tm_mon:F[o+16>>2],tm_year:F[o+20>>2],tm_wday:F[o+24>>2],tm_yday:F[o+28>>2],tm_isdst:F[o+32>>2],tm_gmtoff:F[o+36>>2],tm_zone:a?ie(a):""},l=ie(t),c={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var m in c)l=l.replace(new RegExp(m,"g"),c[m]);var A=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],T=["January","February","March","April","May","June","July","August","September","October","November","December"];function D(d,E,Y){for(var x=typeof d=="number"?d.toString():d||"";x.length0?1:0}var x;return(x=Y(d.getFullYear()-E.getFullYear()))===0&&(x=Y(d.getMonth()-E.getMonth()))===0&&(x=Y(d.getDate()-E.getDate())),x}function w(d){switch(d.getDay()){case 0:return new Date(d.getFullYear()-1,11,29);case 1:return d;case 2:return new Date(d.getFullYear(),0,3);case 3:return new Date(d.getFullYear(),0,2);case 4:return new Date(d.getFullYear(),0,1);case 5:return new Date(d.getFullYear()-1,11,31);case 6:return new Date(d.getFullYear()-1,11,30)}}function U(d){var E=jt(new Date(d.tm_year+1900,0,1),d.tm_yday),Y=new Date(E.getFullYear(),0,4),x=new Date(E.getFullYear()+1,0,4),J=w(Y),H=w(x);return y(J,E)<=0?y(H,E)<=0?E.getFullYear()+1:E.getFullYear():E.getFullYear()-1}var V={"%a":d=>A[d.tm_wday].substring(0,3),"%A":d=>A[d.tm_wday],"%b":d=>T[d.tm_mon].substring(0,3),"%B":d=>T[d.tm_mon],"%C":d=>{var E=d.tm_year+1900;return _(E/100|0,2)},"%d":d=>_(d.tm_mday,2),"%e":d=>D(d.tm_mday,2," "),"%g":d=>U(d).toString().substring(2),"%G":d=>U(d),"%H":d=>_(d.tm_hour,2),"%I":d=>{var E=d.tm_hour;return E==0?E=12:E>12&&(E-=12),_(E,2)},"%j":d=>_(d.tm_mday+$t(Re(d.tm_year+1900)?Ar:Tr,d.tm_mon-1),3),"%m":d=>_(d.tm_mon+1,2),"%M":d=>_(d.tm_min,2),"%n":()=>` +`,"%p":d=>d.tm_hour>=0&&d.tm_hour<12?"AM":"PM","%S":d=>_(d.tm_sec,2),"%t":()=>" ","%u":d=>d.tm_wday||7,"%U":d=>{var E=d.tm_yday+7-d.tm_wday;return _(Math.floor(E/7),2)},"%V":d=>{var E=Math.floor((d.tm_yday+7-(d.tm_wday+6)%7)/7);if((d.tm_wday+371-d.tm_yday-2)%7<=2&&E++,E){if(E==53){var x=(d.tm_wday+371-d.tm_yday)%7;x!=4&&(x!=3||!Re(d.tm_year))&&(E=1)}}else{E=52;var Y=(d.tm_wday+7-d.tm_yday-1)%7;(Y==4||Y==5&&Re(d.tm_year%400-1))&&E++}return _(E,2)},"%w":d=>d.tm_wday,"%W":d=>{var E=d.tm_yday+7-(d.tm_wday+6)%7;return _(Math.floor(E/7),2)},"%y":d=>(d.tm_year+1900).toString().substring(2),"%Y":d=>d.tm_year+1900,"%z":d=>{var E=d.tm_gmtoff,Y=E>=0;return E=Math.abs(E)/60,E=E/60*100+E%60,(Y?"+":"-")+("0000"+E).slice(-4)},"%Z":d=>d.tm_zone,"%%":()=>"%"};l=l.replace(/%%/g,"\0\0");for(var m in V)l.includes(m)&&(l=l.replace(new RegExp(m,"g"),V[m](s)));l=l.replace(/\0\0/g,"%");var G=Ce(l,!1);return G.length>r?0:(nr(G,e),G.length-1)},Zt=(e,r,t,o,a)=>Vt(e,r,t,o),Xt=e=>{var r=i["_"+e];return g(r,"Cannot call unknown function "+e+", make sure it is exported"),r},Kt=(e,r,t)=>(g(typeof t=="number","stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),Pe(e,ue,r,t)),Fr=e=>{var r=Qe(e)+1,t=Oe(r);return Kt(e,t,r),t},Or=(e,r,t,o,a)=>{var s={string:w=>{var U=0;return w!=null&&w!==0&&(U=Fr(w)),U},array:w=>{var U=Oe(w.length);return nr(w,U),U}};function l(w){return r==="string"?ie(w):r==="boolean"?!!w:w}var c=Xt(e),m=[],A=0;if(g(r!=="array",'Return type should not be "array".'),o)for(var T=0;Tfunction(){return Or(e,r,t,arguments)},Nr=function(e,r,t,o){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=n.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=o},Ie=365,xe=146;Object.defineProperties(Nr.prototype,{read:{get:function(){return(this.mode&Ie)===Ie},set:function(e){e?this.mode|=Ie:this.mode&=~Ie}},write:{get:function(){return(this.mode&xe)===xe},set:function(e){e?this.mode|=xe:this.mode&=~xe}},isFolder:{get:function(){return n.isDir(this.mode)}},isDevice:{get:function(){return n.isChrdev(this.mode)}}}),n.FSNode=Nr,n.createPreloadedFile=vt,n.staticInit(),rr={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135};function Qt(){tt("fetchSettings")}var Dr={__assert_fail:lt,__syscall_fcntl64:wt,__syscall_ioctl:St,__syscall_openat:bt,__throw_exception_with_stack_trace:kt,abort:At,emscripten_memcpy_js:Tt,emscripten_resize_heap:Ot,environ_get:Mt,environ_sizes_get:Lt,exit:Rt,fd_close:It,fd_fdstat_get:xt,fd_read:Bt,fd_seek:qt,fd_write:Wt,strftime_l:Zt},K=rt();i._Session__create__=L("Session__create__"),i._Session__destroy__=L("Session__destroy__"),i._Session__params_ref=L("Session__params_ref"),i._Session__module_ref=L("Session__module_ref"),i._Session_run=L("Session_run"),i._Session_start=L("Session_start"),i._Session_printContext=L("Session_printContext"),i._Session_step=L("Session_step"),i._Session_continue=L("Session_continue"),i._Session_print=L("Session_print"),i._Session_switch=L("Session_switch"),i._validate_wasm=L("validate_wasm"),i._run_wasm=L("run_wasm"),i._debug_wasm=L("debug_wasm"),i._Session_fetch_shrubbery=L("Session_fetch_shrubbery"),i._exception=L("exception"),i._assertion=L("assertion");var en=L("__errno_location"),Mr=i._fflush=L("fflush"),Lr=i._free=L("free");i._malloc=L("malloc");var Pr=()=>(Pr=K.__trap)(),Cr=()=>(Cr=K.emscripten_stack_init)(),or=()=>(or=K.emscripten_stack_get_end)(),ar=L("stackSave"),ir=L("stackRestore"),Oe=L("stackAlloc"),rn=i.___cxa_decrement_exception_refcount=L("__cxa_decrement_exception_refcount");i.___cxa_increment_exception_refcount=L("__cxa_increment_exception_refcount");var tn=i.___thrown_object_from_unwind_exception=L("__thrown_object_from_unwind_exception"),nn=i.___get_exception_message=L("__get_exception_message");i.wasmMemory=me,i.wasmExports=K,i.stackAlloc=Oe,i.stackSave=ar,i.stackRestore=ir,i.ccall=Or,i.cwrap=Jt,i.UTF8ArrayToString=ge,i.stringToUTF8Array=Pe,i.stringToUTF8OnStack=Fr,i.writeArrayToMemory=nr,i.getCppExceptionTag=Ke,i.decrementExceptionRefcount=at;var on=["writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","growMemory","ydayFromDate","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","getHostByName","getCallstack","emscriptenLog","convertPCtoSourceLocation","readEmAsmArgs","jstoi_q","jstoi_s","listenOnce","autoResumeAudioContext","getDynCaller","dynCall","handleException","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","safeSetTimeout","asmjsMangle","handleAllocatorInit","HandleAllocator","getNativeTypeSize","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","getFunctionAddress","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","intArrayToString","AsciiToString","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","stringToNewUTF8","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","findCanvasEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","jsStackTrace","stackTrace","checkWasiClock","wasiRightsToMuslOFlags","wasiOFlagsToMuslOFlags","createDyncallWrapper","setImmediateWrapped","clearImmediateWrapped","polyfillSetImmediate","getPromise","makePromise","idsToPromises","makePromiseCallback","setMainLoop","getSocketFromFD","getSocketAddress","FS_unlink","FS_mkdirTree","_setNetworkCallback","heapObjectForWebGLType","heapAccessShiftForWebGLHeap","webgl_enable_ANGLE_instanced_arrays","webgl_enable_OES_vertex_array_object","webgl_enable_WEBGL_draw_buffers","webgl_enable_WEBGL_multi_draw","emscriptenWebGLGet","computeUnpackAlignedImageSize","colorChannelsInGlTextureFormat","emscriptenWebGLGetTexPixelData","__glGenObject","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","__glGetActiveAttribOrUniform","writeGLArray","registerWebGlEventCallback","runAndAbortIfError","SDL_unicode","SDL_ttfContext","SDL_audio","ALLOC_NORMAL","ALLOC_STACK","allocate","writeStringToMemory","writeAsciiToMemory"];on.forEach(nt);var an=["run","addOnPreRun","addOnInit","addOnPreMain","addOnExit","addOnPostRun","addRunDependency","removeRunDependency","FS_createFolder","FS_createPath","FS_createLazyFile","FS_createLink","FS_createDevice","FS_readFile","out","err","callMain","abort","keepRuntimeAlive","getTempRet0","setTempRet0","writeStackCookie","checkStackCookie","MAX_INT53","MIN_INT53","bigintToI53Checked","ptrToString","zeroMemory","exitJS","getHeapMax","abortOnCannotGrowMemory","ENV","MONTH_DAYS_REGULAR","MONTH_DAYS_LEAP","MONTH_DAYS_REGULAR_CUMULATIVE","MONTH_DAYS_LEAP_CUMULATIVE","isLeapYear","arraySum","addDays","ERRNO_CODES","ERRNO_MESSAGES","setErrNo","DNS","Protocols","Sockets","initRandomFill","randomFill","timers","warnOnce","UNWIND_CACHE","readEmAsmArgsArray","getExecutableName","asyncLoad","alignMemory","mmapAlloc","wasmTable","getCFunc","freeTableIndexes","functionsInTableMap","setValue","getValue","PATH","PATH_FS","UTF8Decoder","UTF8ToString","stringToUTF8","lengthBytesUTF8","intArrayFromString","stringToAscii","UTF16Decoder","JSEvents","specialHTMLTargets","currentFullscreenStrategy","restoreOldWindowedStyle","demangle","demangleAll","ExitStatus","getEnvStrings","doReadv","doWritev","promiseMap","getExceptionMessageCommon","getCppExceptionThrownObjectFromWebAssemblyException","incrementExceptionRefcount","getExceptionMessage","Browser","wget","SYSCALLS","preloadPlugins","FS_createPreloadedFile","FS_modeStringToFlags","FS_getMode","FS_stdin_getChar_buffer","FS_stdin_getChar","FS","FS_createDataFile","MEMFS","TTY","PIPEFS","SOCKFS","tempFixedLengthArray","miniTempWebGLFloatBuffers","miniTempWebGLIntBuffers","GL","emscripten_webgl_power_preferences","AL","GLUT","EGL","GLEW","IDBStore","SDL","SDL_gfx","allocateUTF8","allocateUTF8OnStack"];an.forEach(yr);var Ue;Ae=function e(){Ue||Rr(),Ue||(Ae=e)};function sn(){Cr(),be()}function Rr(){if(pe>0||(sn(),Wr(),pe>0))return;function e(){Ue||(Ue=!0,i.calledRun=!0,!he&&($r(),h(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),g(!i._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),jr()))}i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),e()},1)):e(),ke()}function ln(){var e=ee,r=B,t=!1;ee=B=o=>{t=!0};try{Mr(0),["stdout","stderr"].forEach(function(o){var a=n.analyzePath("/dev/"+o);if(a){var s=a.object,l=s.rdev,c=de.ttys[l];c&&c.output&&c.output.length&&(t=!0)}})}catch{}ee=e,B=r,t&&te("stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.")}if(i.preInit)for(typeof i.preInit=="function"&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return Rr(),u.ready}})();const R=document.getElementById("talvos"),Q=R.querySelector("output.stdio")||{},Z=R.querySelector("output.error")||{};var lr={print:function(f){Q.value+=f+` `},printErr:function(f){Q.value+=f+` -`}};window.addEventListener("error",f=>{Z.value=""+f.message});window.addEventListener("unhandledrejection",function(f){Z.value=""+f.reason});const Ne=document.querySelector("#talvos svg"),[sr,bn]=(()=>{function*f(...N){const p=N.map(I=>I[Symbol.iterator]());let P=p.map(I=>I.next());for(;P.every(({done:I})=>!I);)yield P.map(({value:I})=>I),P=p.map(I=>I.next())}const u=()=>{Ne.querySelectorAll(".lane").forEach(N=>{N.classList.remove("disabled","selected"),N.dataset.state="inactive",delete N.dataset.logCoords})};document.querySelector("#talvos button.stop").addEventListener("click",u),document.querySelector("#talvos button.continue").addEventListener("click",()=>setTimeout(u,0)),document.querySelector("#talvos button.run").addEventListener("click",u);function b(N){switch(N){case ne.Active:return"active";case ne.Inactive:return"inactive";case ne.AtBarrier:return"at-barrier";case ne.AtBreakpoint:return"at-breakpoint";case ne.AtAssert:return"at-assert";case ne.AtException:return"at-exception";case ne.NotLaunched:return"not-launched";case ne.Exited:return"exited";case ne.UNKNOWN:return"unkown"}}return[N=>{console.assert(""+N.Cores==Ne.dataset.cores),console.assert(""+N.Lanes==Ne.dataset.lanes);for(const[p,P,I]of f(function*(){let le=0;for(;;)yield le++}(),Ne.querySelectorAll("g > .lane"),N.LaneStates))console.assert(`{ ${I.PhyCoord.Core}, ${I.PhyCoord.Lane} }`==P.dataset.phyCoords),P.dataset.state=b(I.State),P.dataset.logCoords=`{ 0, (${I.LogCoord.X},${I.LogCoord.Y},${I.LogCoord.Z}) }`,P.classList.toggle("selected",N.SteppedLanes.has(p))},u]})(),[kn,An,Tn,{Session:$e}]=function(f){return[f.then(u=>u.cwrap("validate_wasm","boolean",["string"])),f.then(u=>u.cwrap("exception",null,[])),f.then(u=>u.cwrap("assertion",null,[])),(()=>{var u=f.then(({wasmExports:{Session__create__:i,Session__destroy__:h,Session__params_ref:v,Session__module_ref:b,Session_run:N,Session_start:p,Session_step:P,Session_switch:I,Session_print:le,Session_continue:ce,Session_printContext:X,Session_fetch_shrubbery:Ve},stackAlloc:we,stackSave:Ee,stackRestore:ee,stringToUTF8OnStack:B,HEAP32:fe,wasmMemory:Se,_malloc:me,_free:he})=>{function g(F){const S=me(F),O=Se.buffer,j=new $(O,S,F);return[j,()=>he(j)]}function q(F){const S=F.map(B),O=we(S.length);return S.forEach((j,be)=>{fe[O+be*4>>2]=j}),[S.length,O]}const ue=4096;class oe{ptr;arena;lastOp;laneMask;params;module;static bind(S){try{var O=Object.create(this.prototype);O.ptr=S,O.arena=new dn(...g(ue)),O.lastOp=new W(O.arena.alloc(W.SIZE)),O.laneMask=new Ye(void 0,{data:O.arena.alloc(8).data}),O.params=new Yr(new $(Se.buffer,v(S),Yr.SIZE)),O.module=new Gr(new $(Se.buffer,b(S),Gr.SIZE))}catch(j){throw h(S),O?.arena&&_e(O.arena),j}return O}constructor(S,O){const j=Ee(),[be,ke]=[S,O].map(B),De=i(be,ke);return ee(j),oe.bind(De)}run(){N(this.ptr)}start(){p(this.ptr,this.lastOp.ptr.asRef()),sr(this.lastOp)}step(){this.laneMask.clear(),Ne.querySelectorAll(".lane").forEach((O,j)=>{O.classList.contains("selected")&&this.laneMask.add(j)});var S=P(this.ptr,this.laneMask.asRef(),this.lastOp.asRef());return sr(this.lastOp),S>0&&bn(),S}switch(S){const O=Ee();I(this.ptr,...q(["switch",...S])),ee(O)}print(S){const O=Ee();le(this.ptr,...q(["print",...S])),ee(O)}continue(){ce(this.ptr,this.lastOp.ptr.asRef()),sr(this.lastOp)}printContext(){X(this.ptr)}fetchShrubbery(){var S=this.arena.alloc(8);return Ve(this.ptr,S.asRef()),new Ye(void 0,{data:S.data})}__destroy__(){console.log("Session.destroy..."),h(this.ptr),this.ptr=0,_e(this.arena)}}return{Session:oe}});return{Session:u.then(i=>i.Session)}})()]}(Sn(lr));function _e(f){f.__destroy__()}function je(f,u){Q.value="",Z.value="",R.querySelector("output.timing").value="...",R.querySelectorAll("button.exec").forEach(h=>h.disabled=!0);let i=u??window.performance.mark("talvos");return(async()=>f())().catch(h=>{var v;if(h instanceof WebAssembly.Exception){var b;[b,v]=lr.getExceptionMessage(h),v=v||`of type ${b}`,console.error(h.stack),lr.decrementExceptionRefcount(h)}else console.error(`in ${i.name}:`,h),v=""+h;Z.value=v}).finally(()=>{const h=window.performance.measure(i.name,i.name);R.querySelector("output.timing").value=`done in ${h.duration}ms`,R.querySelectorAll("button.exec").forEach(v=>v.removeAttribute("disabled"))})}R.querySelector("button.validate").onclick=async function(){const f=R.querySelector(".module").value,u=window.performance.mark("validate_wasm",{detail:{text:f}}),i=await je(async()=>(await kn)(f),u);R.querySelector("output.stdio").value+=i?"ok!":"not ok :("};R.querySelector("button.assertion").onclick=async()=>je(await Tn);R.querySelector("button.exception").onclick=async()=>je(await An);R.querySelector("button.shrubbery").onclick=async()=>{const f=(await $e).bind(828927560446);try{const u=f.fetchShrubbery();console.log(u)}finally{_e(f.arena)}};R.querySelector("button.run").onclick=async function(){const f=R.querySelector(".module").value,u=R.querySelector(".commands").value,i=window.performance.mark("run_wasm",{detail:{text:f,commands:u}});je(async()=>{const h=new(await $e)(f,u),v=R.querySelector('select[name="entry"]');h.params.EntryName=v.selectedOptions.item(0).value;try{h.run()}finally{_e(h)}},i)};R.querySelector("button.debug").onclick=async function(){Q.value="",Z.value="",R.querySelector("output.timing").value="...",R.querySelectorAll("button.exec").forEach(p=>p.disabled=!0);const f=R.querySelector(".module").value,u=R.querySelector(".commands").value,i=window.performance.mark("debug",{detail:{text:f,commands:u}}),h=new(await $e)(f,u);h.params.EntryName="vecadd";const v=R.querySelector(".debugger");function b(){v.hidden=!0,v.querySelectorAll("button").forEach(P=>P.onclick=null),R.querySelectorAll("button.exec").forEach(P=>P.removeAttribute("disabled")),_e(h);const p=window.performance.measure(i.name,i.name);R.querySelector("output.timing").value=`done in ${p.duration}ms`}try{h.start(),h.printContext()}catch(p){throw b(),p}const N=1;v.querySelector("button.step").onclick=function(){Q.value="",Z.value="";try{h.step()==N&&b(),h.printContext()}catch(p){throw b(),p}},v.querySelector("button.switch").onclick=function(){const p=prompt("Usage: switch: X [Y [Z]]","X [Y [Z]]");if(p==null)return;const P=p.split(/\s+/);h.switch(P)},v.querySelector("button.print").onclick=function(){const p=prompt("Usage: print: %","%15");if(p==null)return;const P=p.split(/\s+/);h.print(P)},v.querySelector("button.stop").onclick=b,v.querySelector("button.continue").onclick=function(){Q.value="",Z.value="";try{h.continue()}finally{b()}},v.hidden=!1};const Fn=R.querySelector('select[name="entry"]');setTimeout(async function(){const u=Q.value,i=Z.value;Q.value="",Z.value="";const h=R.querySelector(".module").value,v=new(await $e)(h,"");try{console.log([...v.module.EntryPoints].map(b=>b.Name.asString())),Fn.innerHTML=[...v.module.EntryPoints].map(b=>``).join("")}finally{_e(v)}Q.value&&console.log(Q.value),Q.value=u,Z.value&&console.error(Z.value),Z.value=i},0); +`}};window.addEventListener("error",f=>{Z.value=""+f.message});window.addEventListener("unhandledrejection",function(f){Z.value=""+f.reason});const Ne=document.querySelector("#talvos svg"),[sr,bn]=(()=>{function*f(...N){const v=N.map(I=>I[Symbol.iterator]());let P=v.map(I=>I.next());for(;P.every(({done:I})=>!I);)yield P.map(({value:I})=>I),P=v.map(I=>I.next())}const u=()=>{Ne.querySelectorAll(".lane").forEach(N=>{N.classList.remove("disabled","selected"),N.dataset.state="inactive",delete N.dataset.logCoords})};document.querySelector("#talvos button.stop").addEventListener("click",u),document.querySelector("#talvos button.continue").addEventListener("click",()=>setTimeout(u,0)),document.querySelector("#talvos button.run").addEventListener("click",u);function b(N){switch(N){case ne.Active:return"active";case ne.Inactive:return"inactive";case ne.AtBarrier:return"at-barrier";case ne.AtBreakpoint:return"at-breakpoint";case ne.AtAssert:return"at-assert";case ne.AtException:return"at-exception";case ne.NotLaunched:return"not-launched";case ne.Exited:return"exited";case ne.UNKNOWN:return"unkown"}}return[N=>{console.assert(""+N.Cores==Ne.dataset.cores),console.assert(""+N.Lanes==Ne.dataset.lanes);for(const[v,P,I]of f(function*(){let le=0;for(;;)yield le++}(),Ne.querySelectorAll("g > .lane"),N.LaneStates))console.assert(`{ ${I.PhyCoord.Core}, ${I.PhyCoord.Lane} }`==P.dataset.phyCoords),P.dataset.state=b(I.State),P.dataset.logCoords=`{ 0, (${I.LogCoord.X},${I.LogCoord.Y},${I.LogCoord.Z}) }`,P.classList.toggle("selected",N.SteppedLanes.has(v))},u]})(),[kn,An,Tn,{Session:$e}]=function(f){return[f.then(u=>u.cwrap("validate_wasm","boolean",["string"])),f.then(u=>u.cwrap("exception",null,[])),f.then(u=>u.cwrap("assertion",null,[])),(()=>{var u=f.then(({wasmExports:{Session__create__:i,Session__destroy__:h,Session__params_ref:p,Session__module_ref:b,Session_run:N,Session_start:v,Session_step:P,Session_switch:I,Session_print:le,Session_continue:ce,Session_printContext:X,Session_fetch_shrubbery:Ve},stackAlloc:we,stackSave:Ee,stackRestore:ee,stringToUTF8OnStack:B,HEAP32:fe,wasmMemory:Se,_malloc:me,_free:he})=>{function g(F){const S=me(F),O=Se.buffer,j=new $(O,S,F);return[j,()=>he(j)]}function q(F){const S=F.map(B),O=we(S.length);return S.forEach((j,be)=>{fe[O+be*4>>2]=j}),[S.length,O]}const ue=4096;class oe{ptr;arena;lastOp;laneMask;params;module;static bind(S){try{var O=Object.create(this.prototype);O.ptr=S,O.arena=new dn(...g(ue)),O.lastOp=new W(O.arena.alloc(W.SIZE)),O.laneMask=new Ye(void 0,{data:O.arena.alloc(8).data}),O.params=new Yr(new $(Se.buffer,p(S),Yr.SIZE)),O.module=new Gr(new $(Se.buffer,b(S),Gr.SIZE))}catch(j){throw h(S),O?.arena&&_e(O.arena),j}return O}constructor(S,O){const j=Ee(),[be,ke]=[S,O].map(B),De=i(be,ke);return ee(j),oe.bind(De)}run(){N(this.ptr)}start(){v(this.ptr,this.lastOp.ptr.asRef()),sr(this.lastOp)}step(){this.laneMask.clear(),Ne.querySelectorAll(".lane").forEach((O,j)=>{O.classList.contains("selected")&&this.laneMask.add(j)});var S=P(this.ptr,this.laneMask.asRef(),this.lastOp.asRef());return sr(this.lastOp),S>0&&bn(),S}switch(S){const O=Ee();I(this.ptr,...q(["switch",...S])),ee(O)}print(S){const O=Ee();le(this.ptr,...q(["print",...S])),ee(O)}continue(){ce(this.ptr,this.lastOp.ptr.asRef()),sr(this.lastOp)}printContext(){X(this.ptr)}fetchShrubbery(){var S=this.arena.alloc(8);return Ve(this.ptr,S.asRef()),new Ye(void 0,{data:S.data})}__destroy__(){console.log("Session.destroy..."),h(this.ptr),this.ptr=0,_e(this.arena)}}return{Session:oe}});return{Session:u.then(i=>i.Session)}})()]}(Sn(lr));function _e(f){f.__destroy__()}function je(f,u){Q.value="",Z.value="",R.querySelector("output.timing").value="...",R.querySelectorAll("button.exec").forEach(h=>h.disabled=!0);let i=u??window.performance.mark("talvos");return(async()=>f())().catch(h=>{var p;if(h instanceof WebAssembly.Exception){var b;[b,p]=lr.getExceptionMessage(h),p=p||`of type ${b}`,console.error(h.stack),lr.decrementExceptionRefcount(h)}else console.error(`in ${i.name}:`,h),p=""+h;Z.value=p}).finally(()=>{const h=window.performance.measure(i.name,i.name);R.querySelector("output.timing").value=`done in ${h.duration}ms`,R.querySelectorAll("button.exec").forEach(p=>p.removeAttribute("disabled"))})}R.querySelector("button.validate").onclick=async function(){const f=R.querySelector(".module").value,u=window.performance.mark("validate_wasm",{detail:{text:f}}),i=await je(async()=>(await kn)(f),u);R.querySelector("output.stdio").value+=i?"ok!":"not ok :("};R.querySelector("button.assertion").onclick=async()=>je(await Tn);R.querySelector("button.exception").onclick=async()=>je(await An);R.querySelector("button.shrubbery").onclick=async()=>{const f=(await $e).bind(828927560446);try{const u=f.fetchShrubbery();console.log(u)}finally{_e(f.arena)}};R.querySelector("button.run").onclick=async function(){const f=R.querySelector(".module").value,u=R.querySelector(".commands").value,i=window.performance.mark("run_wasm",{detail:{text:f,commands:u}});je(async()=>{const h=new(await $e)(f,u),p=R.querySelector('select[name="entry"]');h.params.EntryName=p.selectedOptions.item(0).value;try{h.run()}finally{_e(h)}},i)};R.querySelector("button.debug").onclick=async function(){Q.value="",Z.value="",R.querySelector("output.timing").value="...",R.querySelectorAll("button.exec").forEach(v=>v.disabled=!0);const f=R.querySelector(".module").value,u=R.querySelector(".commands").value,i=window.performance.mark("debug",{detail:{text:f,commands:u}}),h=new(await $e)(f,u);h.params.EntryName="vecadd";const p=R.querySelector(".debugger");function b(){p.hidden=!0,p.querySelectorAll("button").forEach(P=>P.onclick=null),R.querySelectorAll("button.exec").forEach(P=>P.removeAttribute("disabled")),_e(h);const v=window.performance.measure(i.name,i.name);R.querySelector("output.timing").value=`done in ${v.duration}ms`}try{h.start(),h.printContext()}catch(v){throw b(),v}const N=1;p.querySelector("button.step").onclick=function(){Q.value="",Z.value="";try{h.step()==N&&b(),h.printContext()}catch(v){throw b(),v}},p.querySelector("button.switch").onclick=function(){const v=prompt("Usage: switch: X [Y [Z]]","X [Y [Z]]");if(v==null)return;const P=v.split(/\s+/);h.switch(P)},p.querySelector("button.print").onclick=function(){const v=prompt("Usage: print: %","%15");if(v==null)return;const P=v.split(/\s+/);h.print(P)},p.querySelector("button.stop").onclick=b,p.querySelector("button.continue").onclick=function(){Q.value="",Z.value="";try{h.continue()}finally{b()}},p.hidden=!1};const Fn=R.querySelector('select[name="entry"]');setTimeout(async function(){const u=Q.value,i=Z.value;Q.value="",Z.value="";const h=R.querySelector(".module").value,p=new(await $e)(h,"");try{console.log([...p.module.EntryPoints].map(b=>b.Name.asString())),Fn.innerHTML=[...p.module.EntryPoints].map(b=>``).join("")}finally{_e(p)}Q.value&&console.log(Q.value),Q.value=u,Z.value&&console.error(Z.value),Z.value=i},0); diff --git a/dist/index.html b/dist/index.html index 5b86221..b52bd79 100644 --- a/dist/index.html +++ b/dist/index.html @@ -1,4 +1,4 @@ -gpgpu playground