autolang-compiler 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/autolang.wasm +0 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +20 -0
- package/dist/index.mjs +20 -0
- package/package.json +27 -0
|
Binary file
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type AutolangPointer = number;
|
|
2
|
+
type AutolangType = number | null | undefined | string | boolean | void | AutolangPointer;
|
|
3
|
+
type AutolangArgs = AutolangType[];
|
|
4
|
+
type AutolangNativeFunc = (args: AutolangArgs) => AutolangType;
|
|
5
|
+
declare class ACompiler {
|
|
6
|
+
private instance;
|
|
7
|
+
outputBuffer: string;
|
|
8
|
+
private constructor();
|
|
9
|
+
static create(): Promise<ACompiler>;
|
|
10
|
+
registerBuiltInLibrary(name: string, source: string, autoImport: boolean | undefined, methods: Record<string, AutolangNativeFunc>): void;
|
|
11
|
+
compileAndRun(path: string, code: string): boolean;
|
|
12
|
+
compile(path: string, code: string): boolean;
|
|
13
|
+
run(): boolean;
|
|
14
|
+
hasError(): boolean;
|
|
15
|
+
refresh(): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { ACompiler, type AutolangArgs, type AutolangNativeFunc, type AutolangPointer, type AutolangType };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type AutolangPointer = number;
|
|
2
|
+
type AutolangType = number | null | undefined | string | boolean | void | AutolangPointer;
|
|
3
|
+
type AutolangArgs = AutolangType[];
|
|
4
|
+
type AutolangNativeFunc = (args: AutolangArgs) => AutolangType;
|
|
5
|
+
declare class ACompiler {
|
|
6
|
+
private instance;
|
|
7
|
+
outputBuffer: string;
|
|
8
|
+
private constructor();
|
|
9
|
+
static create(): Promise<ACompiler>;
|
|
10
|
+
registerBuiltInLibrary(name: string, source: string, autoImport: boolean | undefined, methods: Record<string, AutolangNativeFunc>): void;
|
|
11
|
+
compileAndRun(path: string, code: string): boolean;
|
|
12
|
+
compile(path: string, code: string): boolean;
|
|
13
|
+
run(): boolean;
|
|
14
|
+
hasError(): boolean;
|
|
15
|
+
refresh(): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { ACompiler, type AutolangArgs, type AutolangNativeFunc, type AutolangPointer, type AutolangType };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";var ti=Object.create;var Be=Object.defineProperty;var ni=Object.getOwnPropertyDescriptor;var oi=Object.getOwnPropertyNames;var ii=Object.getPrototypeOf,ai=Object.prototype.hasOwnProperty;var si=(A,w)=>()=>(w||A((w={exports:{}}).exports,w),w.exports),li=(A,w)=>{for(var O in w)Be(A,O,{get:w[O],enumerable:!0})},_t=(A,w,O,d)=>{if(w&&typeof w=="object"||typeof w=="function")for(let U of oi(w))!ai.call(A,U)&&U!==O&&Be(A,U,{get:()=>w[U],enumerable:!(d=ni(w,U))||d.enumerable});return A};var ui=(A,w,O)=>(O=A!=null?ti(ii(A)):{},_t(w||!A||!A.__esModule?Be(O,"default",{value:A,enumerable:!0}):O,A)),ci=A=>_t(Be({},"__esModule",{value:!0}),A);var ht=si((pt,je)=>{"use strict";var fr=(()=>{var A=globalThis.document?.currentScript?.src;return async function(w={}){var O;(function(){function e(l){l=l.split("-")[0];for(var u=l.split(".").slice(0,3);u.length<3;)u.push("00");return u=u.map((c,v,p)=>c.padStart(2,"0")),u.join("")}var r=l=>[l/1e4|0,(l/100|0)%100,l%100].join("."),t=2147483647,n=typeof process<"u"&&process?.versions?.node?e(process.versions.node):t;if(n<17e4)throw new Error(`This emscripten-generated code requires node v${r(17e4)} (detected v${r(n)})`);var i=typeof navigator<"u"&&navigator?.userAgent?.includes("Safari/")&&navigator.userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/)?e(navigator.userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/)[1]):t;if(i<150200)throw new Error(`This emscripten-generated code requires Safari v${r(150200)} (detected v${i})`);var a=typeof navigator<"u"&&navigator?.userAgent?.match(/Firefox\/(\d+(?:\.\d+)?)/)?parseFloat(navigator.userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/)[1]):t;if(a<100)throw new Error(`This emscripten-generated code requires Firefox v100 (detected v${a})`);var s=typeof navigator<"u"&&navigator?.userAgent?.match(/Chrome\/(\d+(?:\.\d+)?)/)?parseFloat(navigator.userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/)[1]):t;if(s<95)throw new Error(`This emscripten-generated code requires Chrome v95 (detected v${s})`)})();var d=w,U=!!globalThis.window,q=!!globalThis.WorkerGlobalScope,ie=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer",mr=!U&&!ie&&!q,_r=[],He="./this.program",yt=(e,r)=>{throw r};typeof __filename<"u"?A=__filename:q&&(A=self.location.href);var ke="";function Et(e){return d.locateFile?d.locateFile(e,ke):ke+e}var Pe,he;if(ie){if(!(globalThis.process?.versions?.node&&globalThis.process?.type!="renderer"))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?)");var Ve=require("fs");ke=__dirname+"/",he=r=>{r=ye(r)?new URL(r):r;var t=Ve.readFileSync(r);return f(Buffer.isBuffer(t)),t},Pe=async(r,t=!0)=>{r=ye(r)?new URL(r):r;var n=Ve.readFileSync(r,t?void 0:"utf8");return f(t?Buffer.isBuffer(n):typeof n=="string"),n},process.argv.length>1&&(He=process.argv[1].replace(/\\/g,"/")),_r=process.argv.slice(2),yt=(r,t)=>{throw process.exitCode=r,t}}else if(!mr)if(U||q){try{ke=new URL(".",A).href}catch{}if(!(globalThis.window||globalThis.WorkerGlobalScope))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?)");q&&(he=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Pe=async e=>{if(ye(e))return new Promise((t,n)=>{var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=()=>{if(i.status==200||i.status==0&&i.response){t(i.response);return}n(i.status)},i.onerror=n,i.send(null)});var r=await fetch(e,{credentials:"same-origin"});if(r.ok)return r.arrayBuffer();throw new Error(r.status+" : "+r.url)}}else throw new Error("environment detection error");var ee=console.log.bind(console),R=console.error.bind(console),fi="IDBFS is no longer included by default; build with -lidbfs.js",vi="PROXYFS is no longer included by default; build with -lproxyfs.js",mi="WORKERFS is no longer included by default; build with -lworkerfs.js",_i="FETCHFS is no longer included by default; build with -lfetchfs.js",pi="ICASEFS is no longer included by default; build with -licasefs.js",hi="JSFILEFS is no longer included by default; build with -ljsfilefs.js",gi="OPFS is no longer included by default; build with -lopfs.js",yi="NODEFS is no longer included by default; build with -lnodefs.js";f(!mr,"shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.");var ge;globalThis.WebAssembly||R("no native wasm support detected");var Ae=!1,Ei;function f(e,r){e||F("Assertion failed"+(r?": "+r:""))}var ye=e=>e.startsWith("file://");function wt(){var e=ur();f((e&3)==0),e==0&&(e+=4),g[e>>2]=34821223,g[e+4>>2]=2310721022,g[0]=1668509029}function ze(){if(!Ae){var e=ur();e==0&&(e+=4);var r=g[e>>2],t=g[e+4>>2];(r!=34821223||t!=2310721022)&&F(`Stack overflow! Stack cookie has been overwritten at ${se(e)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${se(t)} ${se(r)}`),g[0]!=1668509029&&F("Runtime error: The application has corrupted its heap memory area (address zero)!")}}var pr=!0;function wi(...e){!pr&&typeof pr<"u"||console.warn(...e)}(()=>{var e=new Int16Array(1),r=new Int8Array(e.buffer);e[0]=25459,(r[0]!==115||r[1]!==99)&&F("Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)")})();function Ce(e){Object.getOwnPropertyDescriptor(d,e)||Object.defineProperty(d,e,{configurable:!0,set(){F(`Attempt to set \`Module.${e}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`)}})}function C(e){return()=>f(!1,`call to '${e}' via reference taken before Wasm module initialization`)}function bt(e){Object.getOwnPropertyDescriptor(d,e)&&F(`\`Module.${e}\` was supplied but \`${e}\` not included in INCOMING_MODULE_JS_API`)}function St(e){return e==="FS_createPath"||e==="FS_createDataFile"||e==="FS_createPreloadedFile"||e==="FS_preloadFile"||e==="FS_unlink"||e==="addRunDependency"||e==="FS_createLazyFile"||e==="FS_createDevice"||e==="removeRunDependency"}function Ft(e){hr(e)}function hr(e){Object.getOwnPropertyDescriptor(d,e)||Object.defineProperty(d,e,{configurable:!0,get(){var r=`'${e}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;St(e)&&(r+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),F(r)}})}var gr,yr,x,j,V,Ee,S,g,De,Re,M,Er,ae=!1;function wr(){var e=We.buffer;x=new Int8Array(e),V=new Int16Array(e),j=new Uint8Array(e),Ee=new Uint16Array(e),S=new Int32Array(e),g=new Uint32Array(e),De=new Float32Array(e),Re=new Float64Array(e),M=new BigInt64Array(e),Er=new BigUint64Array(e)}f(globalThis.Int32Array&&globalThis.Float64Array&&Int32Array.prototype.subarray&&Int32Array.prototype.set,"JS engine does not provide full typed array support");function Tt(){if(d.preRun)for(typeof d.preRun=="function"&&(d.preRun=[d.preRun]);d.preRun.length;)Nt(d.preRun.shift());Ce("preRun"),br(Fr)}function kt(){f(!ae),ae=!0,ze(),!d.noFSInit&&!o.initialized&&o.init(),X.init(),pe.__wasm_call_ctors(),o.ignorePermissions=!1}function Pt(){if(ze(),d.postRun)for(typeof d.postRun=="function"&&(d.postRun=[d.postRun]);d.postRun.length;)Mt(d.postRun.shift());Ce("postRun"),br(Sr)}function F(e){d.onAbort?.(e),e="Aborted("+e+")",R(e),Ae=!0,ae&&tt();var r=new WebAssembly.RuntimeError(e);throw yr?.(r),r}function Y(e,r){return(...t)=>{f(ae,`native function \`${e}\` called before runtime initialization`);var n=pe[e];return f(n,`exported native function \`${e}\` not found`),f(t.length<=r,`native function \`${e}\` called with ${t.length} args but expects ${r}`),n(...t)}}var Ge;function At(){return Et("autolang.wasm")}function Ct(e){if(e==Ge&&ge)return new Uint8Array(ge);if(he)return he(e);throw"both async and sync fetching of the wasm failed"}async function Dt(e){if(!ge)try{var r=await Pe(e);return new Uint8Array(r)}catch{}return Ct(e)}async function Rt(e,r){try{var t=await Dt(e),n=await WebAssembly.instantiate(t,r);return n}catch(i){R(`failed to asynchronously prepare wasm: ${i}`),ye(e)&&R(`warning: Loading from a file URI (${e}) 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`),F(i)}}async function $t(e,r,t){if(!e&&!ye(r)&&!ie)try{var n=fetch(r,{credentials:"same-origin"}),i=await WebAssembly.instantiateStreaming(n,t);return i}catch(a){R(`wasm streaming compile failed: ${a}`),R("falling back to ArrayBuffer instantiation")}return Rt(r,t)}function Ot(){var e={env:ft,wasi_snapshot_preview1:ft};return e}async function It(){function e(s,l){return pe=s.exports,ei(pe),wr(),pe}var r=d;function t(s){return f(d===r,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),r=null,e(s.instance)}var n=Ot();if(d.instantiateWasm)return new Promise((s,l)=>{try{d.instantiateWasm(n,(u,c)=>{s(e(u,c))})}catch(u){R(`Module.instantiateWasm callback failed with error: ${u}`),l(u)}});Ge??=At();var i=await $t(ge,Ge,n),a=t(i);return a}class bi{name="ExitStatus";constructor(r){this.message=`Program terminated with exit(${r})`,this.status=r}}var br=e=>{for(;e.length>0;)e.shift()(d)},Sr=[],Mt=e=>Sr.push(e),Fr=[],Nt=e=>Fr.push(e);function Si(e,r="i8"){switch(r.endsWith("*")&&(r="*"),r){case"i1":return x[e];case"i8":return x[e];case"i16":return V[e>>1];case"i32":return S[e>>2];case"i64":return M[e>>3];case"float":return De[e>>2];case"double":return Re[e>>3];case"*":return g[e>>2];default:F(`invalid type for getValue: ${r}`)}}var xt=!0,se=e=>(f(typeof e=="number",`ptrToString expects a number, got ${typeof e}`),e>>>=0,"0x"+e.toString(16).padStart(8,"0"));function Fi(e,r,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":x[e]=r;break;case"i8":x[e]=r;break;case"i16":V[e>>1]=r;break;case"i32":S[e>>2]=r;break;case"i64":M[e>>3]=BigInt(r);break;case"float":De[e>>2]=r;break;case"double":Re[e>>3]=r;break;case"*":g[e>>2]=r;break;default:F(`invalid type for setValue: ${t}`)}}var le=e=>{le.shown||={},le.shown[e]||(le.shown[e]=1,ie&&(e="warning: "+e),R(e))},Tr=globalThis.TextDecoder&&new TextDecoder,kr=(e,r,t,n)=>{var i=r+t;if(n)return i;for(;e[r]&&!(r>=i);)++r;return r},ue=(e,r=0,t,n)=>{var i=kr(e,r,t,n);if(i-r>16&&e.buffer&&Tr)return Tr.decode(e.subarray(r,i));for(var a="";r<i;){var s=e[r++];if(!(s&128)){a+=String.fromCharCode(s);continue}var l=e[r++]&63;if((s&224)==192){a+=String.fromCharCode((s&31)<<6|l);continue}var u=e[r++]&63;if((s&240)==224?s=(s&15)<<12|l<<6|u:((s&248)!=240&&le("Invalid UTF-8 leading byte "+se(s)+" encountered when deserializing a UTF-8 string in wasm memory to a JS string!"),s=(s&7)<<18|l<<12|u<<6|e[r++]&63),s<65536)a+=String.fromCharCode(s);else{var c=s-65536;a+=String.fromCharCode(55296|c>>10,56320|c&1023)}}return a},J=(e,r,t)=>(f(typeof e=="number",`UTF8ToString expects a number (got ${typeof e})`),e?ue(j,e,r,t):""),Lt=(e,r,t,n)=>F(`Assertion failed: ${J(e)}, at: `+[r?J(r):"unknown filename",t,n?J(n):"unknown function"]),$e=()=>{f(k.varargs!=null);var e=S[+k.varargs>>2];return k.varargs+=4,e},ce=$e,T={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,n=e.length-1;n>=0;n--){var i=e[n];i==="."?e.splice(n,1):i===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=T.isAbs(e),t=e.slice(-1)==="/";return e=T.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=T.splitPath(e),t=r[0],n=r[1];return!t&&!n?".":(n&&(n=n.slice(0,-1)),t+n)},basename:e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>T.normalize(e.join("/")),join2:(e,r)=>T.normalize(e+"/"+r)},Ut=()=>{if(ie){var e=require("crypto");return r=>e.randomFillSync(r)}return r=>crypto.getRandomValues(r)},Pr=e=>{(Pr=Ut())(e)},de={resolve:(...e)=>{for(var r="",t=!1,n=e.length-1;n>=-1&&!t;n--){var i=n>=0?e[n]:o.cwd();if(typeof i!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";r=i+"/"+r,t=T.isAbs(i)}return r=T.normalizeArray(r.split("/").filter(a=>!!a),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=de.resolve(e).slice(1),r=de.resolve(r).slice(1);function t(c){for(var v=0;v<c.length&&c[v]==="";v++);for(var p=c.length-1;p>=0&&c[p]==="";p--);return v>p?[]:c.slice(v,p-v+1)}for(var n=t(e.split("/")),i=t(r.split("/")),a=Math.min(n.length,i.length),s=a,l=0;l<a;l++)if(n[l]!==i[l]){s=l;break}for(var u=[],l=s;l<n.length;l++)u.push("..");return u=u.concat(i.slice(s)),u.join("/")}},qe=[],fe=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r},Ar=(e,r,t,n)=>{if(f(typeof e=="string",`stringToUTF8Array expects a string (got ${typeof e})`),!(n>0))return 0;for(var i=t,a=t+n-1,s=0;s<e.length;++s){var l=e.codePointAt(s);if(l<=127){if(t>=a)break;r[t++]=l}else if(l<=2047){if(t+1>=a)break;r[t++]=192|l>>6,r[t++]=128|l&63}else if(l<=65535){if(t+2>=a)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63}else{if(t+3>=a)break;l>1114111&&le("Invalid Unicode code point "+se(l)+" 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|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63,s++}}return r[t]=0,t-i},Ye=(e,r,t)=>{var n=t>0?t:fe(e)+1,i=new Array(n),a=Ar(e,i,0,i.length);return r&&(i.length=a),i},Wt=()=>{if(!qe.length){var e=null;if(ie){var r=256,t=Buffer.alloc(r),n=0,i=process.stdin.fd;try{n=Ve.readSync(i,t,0,r)}catch(a){if(a.toString().includes("EOF"))n=0;else throw a}n>0&&(e=t.slice(0,n).toString("utf-8"))}else globalThis.window?.prompt&&(e=window.prompt("Input: "),e!==null&&(e+=`
|
|
2
|
+
`));if(!e)return null;qe=Ye(e,!0)}return qe.shift()},X={ttys:[],init(){},shutdown(){},register(e,r){X.ttys[e]={input:[],output:[],ops:r},o.registerDevice(e,X.stream_ops)},stream_ops:{open(e){var r=X.ttys[e.node.rdev];if(!r)throw new o.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,n,i){if(!e.tty||!e.tty.ops.get_char)throw new o.ErrnoError(60);for(var a=0,s=0;s<n;s++){var l;try{l=e.tty.ops.get_char(e.tty)}catch{throw new o.ErrnoError(29)}if(l===void 0&&a===0)throw new o.ErrnoError(6);if(l==null)break;a++,r[t+s]=l}return a&&(e.node.atime=Date.now()),a},write(e,r,t,n,i){if(!e.tty||!e.tty.ops.put_char)throw new o.ErrnoError(60);try{for(var a=0;a<n;a++)e.tty.ops.put_char(e.tty,r[t+a])}catch{throw new o.ErrnoError(29)}return n&&(e.node.mtime=e.node.ctime=Date.now()),a}},default_tty_ops:{get_char(e){return Wt()},put_char(e,r){r===null||r===10?(ee(ue(e.output)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output?.length>0&&(ee(ue(e.output)),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?(R(ue(e.output)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output?.length>0&&(R(ue(e.output)),e.output=[])}}},Cr=e=>{F("internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported")},E={ops_table:null,mount(e){return E.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(o.isBlkdev(t)||o.isFIFO(t))throw new o.ErrnoError(63);E.ops_table||={dir:{node:{getattr:E.node_ops.getattr,setattr:E.node_ops.setattr,lookup:E.node_ops.lookup,mknod:E.node_ops.mknod,rename:E.node_ops.rename,unlink:E.node_ops.unlink,rmdir:E.node_ops.rmdir,readdir:E.node_ops.readdir,symlink:E.node_ops.symlink},stream:{llseek:E.stream_ops.llseek}},file:{node:{getattr:E.node_ops.getattr,setattr:E.node_ops.setattr},stream:{llseek:E.stream_ops.llseek,read:E.stream_ops.read,write:E.stream_ops.write,mmap:E.stream_ops.mmap,msync:E.stream_ops.msync}},link:{node:{getattr:E.node_ops.getattr,setattr:E.node_ops.setattr,readlink:E.node_ops.readlink},stream:{}},chrdev:{node:{getattr:E.node_ops.getattr,setattr:E.node_ops.setattr},stream:o.chrdev_stream_ops}};var i=o.createNode(e,r,t,n);return o.isDir(i.mode)?(i.node_ops=E.ops_table.dir.node,i.stream_ops=E.ops_table.dir.stream,i.contents={}):o.isFile(i.mode)?(i.node_ops=E.ops_table.file.node,i.stream_ops=E.ops_table.file.stream,i.usedBytes=0,i.contents=null):o.isLink(i.mode)?(i.node_ops=E.ops_table.link.node,i.stream_ops=E.ops_table.link.stream):o.isChrdev(i.mode)&&(i.node_ops=E.ops_table.chrdev.node,i.stream_ops=E.ops_table.chrdev.stream),i.atime=i.mtime=i.ctime=Date.now(),e&&(e.contents[r]=i,e.atime=e.mtime=e.ctime=i.atime),i},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 n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t!=0&&(r=Math.max(r,256));var i=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(i.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=o.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,o.isDir(e.mode)?r.size=4096:o.isFile(e.mode)?r.size=e.usedBytes:o.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.atime),r.mtime=new Date(e.mtime),r.ctime=new Date(e.ctime),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){for(let t of["mode","atime","mtime","ctime"])r[t]!=null&&(e[t]=r[t]);r.size!==void 0&&E.resizeFileStorage(e,r.size)},lookup(e,r){throw new o.ErrnoError(44)},mknod(e,r,t,n){return E.createNode(e,r,t,n)},rename(e,r,t){var n;try{n=o.lookupNode(r,t)}catch{}if(n){if(o.isDir(e.mode))for(var i in n.contents)throw new o.ErrnoError(55);o.hashRemoveNode(n)}delete e.parent.contents[e.name],r.contents[t]=e,e.name=t,r.ctime=r.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,r){delete e.contents[r],e.ctime=e.mtime=Date.now()},rmdir(e,r){var t=o.lookupNode(e,r);for(var n in t.contents)throw new o.ErrnoError(55);delete e.contents[r],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,r,t){var n=E.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!o.isLink(e.mode))throw new o.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,i){var a=e.node.contents;if(i>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-i,n);if(f(s>=0),s>8&&a.subarray)r.set(a.subarray(i,i+s),t);else for(var l=0;l<s;l++)r[t+l]=a[i+l];return s},write(e,r,t,n,i,a){if(f(!(r instanceof ArrayBuffer)),r.buffer===x.buffer&&(a=!1),!n)return 0;var s=e.node;if(s.mtime=s.ctime=Date.now(),r.subarray&&(!s.contents||s.contents.subarray)){if(a)return f(i===0,"canOwn must imply no weird position inside the file"),s.contents=r.subarray(t,t+n),s.usedBytes=n,n;if(s.usedBytes===0&&i===0)return s.contents=r.slice(t,t+n),s.usedBytes=n,n;if(i+n<=s.usedBytes)return s.contents.set(r.subarray(t,t+n),i),n}if(E.expandFileStorage(s,i+n),s.contents.subarray&&r.subarray)s.contents.set(r.subarray(t,t+n),i);else for(var l=0;l<n;l++)s.contents[i+l]=r[t+l];return s.usedBytes=Math.max(s.usedBytes,i+n),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&o.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new o.ErrnoError(28);return n},mmap(e,r,t,n,i){if(!o.isFile(e.node.mode))throw new o.ErrnoError(43);var a,s,l=e.node.contents;if(!(i&2)&&l&&l.buffer===x.buffer)s=!1,a=l.byteOffset;else{if(s=!0,a=Cr(r),!a)throw new o.ErrnoError(48);l&&((t>0||t+r<l.length)&&(l.subarray?l=l.subarray(t,t+r):l=Array.prototype.slice.call(l,t,t+r)),x.set(l,a))}return{ptr:a,allocated:s}},msync(e,r,t,n,i){return E.stream_ops.write(e,r,0,n,t,!1),0}}},Bt=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},Xe=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},jt=e=>J(rt(e)),Dr={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},Ht=async e=>{var r=await Pe(e);return f(r,`Loading data file "${e}" failed (no arrayBuffer).`),new Uint8Array(r)},Vt=(...e)=>o.createDataFile(...e),zt=e=>{for(var r=e;;){if(!ve[e])return e;e=r+Math.random()}},re=0,we=null,ve={},Q=null,Gt=e=>{if(re--,d.monitorRunDependencies?.(re),f(e,"removeRunDependency requires an ID"),f(ve[e]),delete ve[e],re==0&&(Q!==null&&(clearInterval(Q),Q=null),we)){var r=we;we=null,r()}},qt=e=>{re++,d.monitorRunDependencies?.(re),f(e,"addRunDependency requires an ID"),f(!ve[e]),ve[e]=1,Q===null&&globalThis.setInterval&&(Q=setInterval(()=>{if(Ae){clearInterval(Q),Q=null;return}var r=!1;for(var t in ve)r||(r=!0,R("still waiting on run dependencies:")),R(`dependency: ${t}`);r&&R("(end of list)")},1e4),Q.unref?.())},Rr=[],Yt=async(e,r)=>{typeof Browser<"u"&&Browser.init();for(var t of Rr)if(t.canHandle(r))return f(t.handle.constructor.name==="AsyncFunction","Filesystem plugin handlers must be async functions (See #24914)"),t.handle(e,r);return e},$r=async(e,r,t,n,i,a,s,l)=>{var u=r?de.resolve(T.join2(e,r)):e,c=zt(`cp ${u}`);qt(c);try{var v=t;typeof t=="string"&&(v=await Ht(t)),v=await Yt(v,u),l?.(),a||Vt(e,r,v,n,i,s)}finally{Gt(c)}},Xt=(e,r,t,n,i,a,s,l,u,c)=>{$r(e,r,t,n,i,l,u,c).then(a).catch(s)},o={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,filesystems:null,syncFSRequests:0,readFiles:{},ErrnoError:class extends Error{name="ErrnoError";constructor(e){super(ae?jt(e):""),this.errno=e;for(var r in Dr)if(Dr[r]===e){this.code=r;break}}},FSStream:class{shared={};get object(){return this.node}set object(e){this.node=e}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{node_ops={};stream_ops={};readMode=365;writeMode=146;mounted=null;constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.id=o.nextInode++,this.name=r,this.mode=t,this.rdev=n,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return o.isDir(this.mode)}get isDevice(){return o.isChrdev(this.mode)}},lookupPath(e,r={}){if(!e)throw new o.ErrnoError(44);r.follow_mount??=!0,T.isAbs(e)||(e=o.cwd()+"/"+e);e:for(var t=0;t<40;t++){for(var n=e.split("/").filter(c=>!!c),i=o.root,a="/",s=0;s<n.length;s++){var l=s===n.length-1;if(l&&r.parent)break;if(n[s]!=="."){if(n[s]===".."){if(a=T.dirname(a),o.isRoot(i)){e=a+"/"+n.slice(s+1).join("/"),t--;continue e}else i=i.parent;continue}a=T.join2(a,n[s]);try{i=o.lookupNode(i,n[s])}catch(c){if(c?.errno===44&&l&&r.noent_okay)return{path:a};throw c}if(o.isMountpoint(i)&&(!l||r.follow_mount)&&(i=i.mounted.root),o.isLink(i.mode)&&(!l||r.follow)){if(!i.node_ops.readlink)throw new o.ErrnoError(52);var u=i.node_ops.readlink(i);T.isAbs(u)||(u=T.dirname(a)+"/"+u),e=u+"/"+n.slice(s+1).join("/");continue e}}}return{path:a,node:i}}throw new o.ErrnoError(32)},getPath(e){for(var r;;){if(o.isRoot(e)){var t=e.mount.mountpoint;return r?t[t.length-1]!=="/"?`${t}/${r}`:t+r:t}r=r?`${e.name}/${r}`:e.name,e=e.parent}},hashName(e,r){for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return(e+t>>>0)%o.nameTable.length},hashAddNode(e){var r=o.hashName(e.parent.id,e.name);e.name_next=o.nameTable[r],o.nameTable[r]=e},hashRemoveNode(e){var r=o.hashName(e.parent.id,e.name);if(o.nameTable[r]===e)o.nameTable[r]=e.name_next;else for(var t=o.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode(e,r){var t=o.mayLookup(e);if(t)throw new o.ErrnoError(t);for(var n=o.hashName(e.id,r),i=o.nameTable[n];i;i=i.name_next){var a=i.name;if(i.parent.id===e.id&&a===r)return i}return o.lookup(e,r)},createNode(e,r,t,n){f(typeof e=="object");var i=new o.FSNode(e,r,t,n);return o.hashAddNode(i),i},destroyNode(e){o.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 o.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!o.isDir(e.mode))return 54;var r=o.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){if(!o.isDir(e.mode))return 54;try{var t=o.lookupNode(e,r);return 20}catch{}return o.nodePermissions(e,"wx")},mayDelete(e,r,t){var n;try{n=o.lookupNode(e,r)}catch(a){return a.errno}var i=o.nodePermissions(e,"wx");if(i)return i;if(t){if(!o.isDir(n.mode))return 54;if(o.isRoot(n)||o.getPath(n)===o.cwd())return 10}else if(o.isDir(n.mode))return 31;return 0},mayOpen(e,r){return e?o.isLink(e.mode)?32:o.isDir(e.mode)&&(o.flagsToPermissionString(r)!=="r"||r&576)?31:o.nodePermissions(e,o.flagsToPermissionString(r)):44},checkOpExists(e,r){if(!e)throw new o.ErrnoError(r);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=o.MAX_OPEN_FDS;e++)if(!o.streams[e])return e;throw new o.ErrnoError(33)},getStreamChecked(e){var r=o.getStream(e);if(!r)throw new o.ErrnoError(8);return r},getStream:e=>o.streams[e],createStream(e,r=-1){return f(r>=-1),e=Object.assign(new o.FSStream,e),r==-1&&(r=o.nextfd()),e.fd=r,o.streams[r]=e,e},closeStream(e){o.streams[e]=null},dupStream(e,r=-1){var t=o.createStream(e,r);return t.stream_ops?.dup?.(t),t},doSetAttr(e,r,t){var n=e?.stream_ops.setattr,i=n?e:r;n??=r.node_ops.setattr,o.checkOpExists(n,63),n(i,t)},chrdev_stream_ops:{open(e){var r=o.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new o.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice(e,r){o.devices[e]={stream_ops:r}},getDevice:e=>o.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push(...n.mounts)}return r},syncfs(e,r){typeof e=="function"&&(r=e,e=!1),o.syncFSRequests++,o.syncFSRequests>1&&R(`warning: ${o.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=o.getMounts(o.root.mount),n=0;function i(s){return f(o.syncFSRequests>0),o.syncFSRequests--,r(s)}function a(s){if(s)return a.errored?void 0:(a.errored=!0,i(s));++n>=t.length&&i(null)}t.forEach(s=>{if(!s.type.syncfs)return a(null);s.type.syncfs(s,e,a)})},mount(e,r,t){if(typeof e=="string")throw e;var n=t==="/",i=!t,a;if(n&&o.root)throw new o.ErrnoError(10);if(!n&&!i){var s=o.lookupPath(t,{follow_mount:!1});if(t=s.path,a=s.node,o.isMountpoint(a))throw new o.ErrnoError(10);if(!o.isDir(a.mode))throw new o.ErrnoError(54)}var l={type:e,opts:r,mountpoint:t,mounts:[]},u=e.mount(l);return u.mount=l,l.root=u,n?o.root=u:a&&(a.mounted=l,a.mount&&a.mount.mounts.push(l)),u},unmount(e){var r=o.lookupPath(e,{follow_mount:!1});if(!o.isMountpoint(r.node))throw new o.ErrnoError(28);var t=r.node,n=t.mounted,i=o.getMounts(n);Object.keys(o.nameTable).forEach(s=>{for(var l=o.nameTable[s];l;){var u=l.name_next;i.includes(l.mount)&&o.destroyNode(l),l=u}}),t.mounted=null;var a=t.mount.mounts.indexOf(n);f(a!==-1),t.mount.mounts.splice(a,1)},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=o.lookupPath(e,{parent:!0}),i=n.node,a=T.basename(e);if(!a)throw new o.ErrnoError(28);if(a==="."||a==="..")throw new o.ErrnoError(20);var s=o.mayCreate(i,a);if(s)throw new o.ErrnoError(s);if(!i.node_ops.mknod)throw new o.ErrnoError(63);return i.node_ops.mknod(i,a,r,t)},statfs(e){return o.statfsNode(o.lookupPath(e,{follow:!0}).node)},statfsStream(e){return o.statfsNode(e.node)},statfsNode(e){var r={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:o.nextInode,ffree:o.nextInode-1,fsid:42,flags:2,namelen:255};return e.node_ops.statfs&&Object.assign(r,e.node_ops.statfs(e.mount.opts.root)),r},create(e,r=438){return r&=4095,r|=32768,o.mknod(e,r,0)},mkdir(e,r=511){return r&=1023,r|=16384,o.mknod(e,r,0)},mkdirTree(e,r){var t=e.split("/"),n="";for(var i of t)if(i){(n||T.isAbs(e))&&(n+="/"),n+=i;try{o.mkdir(n,r)}catch(a){if(a.errno!=20)throw a}}},mkdev(e,r,t){return typeof t>"u"&&(t=r,r=438),r|=8192,o.mknod(e,r,t)},symlink(e,r){if(!de.resolve(e))throw new o.ErrnoError(44);var t=o.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new o.ErrnoError(44);var i=T.basename(r),a=o.mayCreate(n,i);if(a)throw new o.ErrnoError(a);if(!n.node_ops.symlink)throw new o.ErrnoError(63);return n.node_ops.symlink(n,i,e)},rename(e,r){var t=T.dirname(e),n=T.dirname(r),i=T.basename(e),a=T.basename(r),s,l,u;if(s=o.lookupPath(e,{parent:!0}),l=s.node,s=o.lookupPath(r,{parent:!0}),u=s.node,!l||!u)throw new o.ErrnoError(44);if(l.mount!==u.mount)throw new o.ErrnoError(75);var c=o.lookupNode(l,i),v=de.relative(e,n);if(v.charAt(0)!==".")throw new o.ErrnoError(28);if(v=de.relative(r,t),v.charAt(0)!==".")throw new o.ErrnoError(55);var p;try{p=o.lookupNode(u,a)}catch{}if(c!==p){var h=o.isDir(c.mode),m=o.mayDelete(l,i,h);if(m)throw new o.ErrnoError(m);if(m=p?o.mayDelete(u,a,h):o.mayCreate(u,a),m)throw new o.ErrnoError(m);if(!l.node_ops.rename)throw new o.ErrnoError(63);if(o.isMountpoint(c)||p&&o.isMountpoint(p))throw new o.ErrnoError(10);if(u!==l&&(m=o.nodePermissions(l,"w"),m))throw new o.ErrnoError(m);o.hashRemoveNode(c);try{l.node_ops.rename(c,u,a),c.parent=u}catch(_){throw _}finally{o.hashAddNode(c)}}},rmdir(e){var r=o.lookupPath(e,{parent:!0}),t=r.node,n=T.basename(e),i=o.lookupNode(t,n),a=o.mayDelete(t,n,!0);if(a)throw new o.ErrnoError(a);if(!t.node_ops.rmdir)throw new o.ErrnoError(63);if(o.isMountpoint(i))throw new o.ErrnoError(10);t.node_ops.rmdir(t,n),o.destroyNode(i)},readdir(e){var r=o.lookupPath(e,{follow:!0}),t=r.node,n=o.checkOpExists(t.node_ops.readdir,54);return n(t)},unlink(e){var r=o.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new o.ErrnoError(44);var n=T.basename(e),i=o.lookupNode(t,n),a=o.mayDelete(t,n,!1);if(a)throw new o.ErrnoError(a);if(!t.node_ops.unlink)throw new o.ErrnoError(63);if(o.isMountpoint(i))throw new o.ErrnoError(10);t.node_ops.unlink(t,n),o.destroyNode(i)},readlink(e){var r=o.lookupPath(e),t=r.node;if(!t)throw new o.ErrnoError(44);if(!t.node_ops.readlink)throw new o.ErrnoError(28);return t.node_ops.readlink(t)},stat(e,r){var t=o.lookupPath(e,{follow:!r}),n=t.node,i=o.checkOpExists(n.node_ops.getattr,63);return i(n)},fstat(e){var r=o.getStreamChecked(e),t=r.node,n=r.stream_ops.getattr,i=n?r:t;return n??=t.node_ops.getattr,o.checkOpExists(n,63),n(i)},lstat(e){return o.stat(e,!0)},doChmod(e,r,t,n){o.doSetAttr(e,r,{mode:t&4095|r.mode&-4096,ctime:Date.now(),dontFollow:n})},chmod(e,r,t){var n;if(typeof e=="string"){var i=o.lookupPath(e,{follow:!t});n=i.node}else n=e;o.doChmod(null,n,r,t)},lchmod(e,r){o.chmod(e,r,!0)},fchmod(e,r){var t=o.getStreamChecked(e);o.doChmod(t,t.node,r,!1)},doChown(e,r,t){o.doSetAttr(e,r,{timestamp:Date.now(),dontFollow:t})},chown(e,r,t,n){var i;if(typeof e=="string"){var a=o.lookupPath(e,{follow:!n});i=a.node}else i=e;o.doChown(null,i,n)},lchown(e,r,t){o.chown(e,r,t,!0)},fchown(e,r,t){var n=o.getStreamChecked(e);o.doChown(n,n.node,!1)},doTruncate(e,r,t){if(o.isDir(r.mode))throw new o.ErrnoError(31);if(!o.isFile(r.mode))throw new o.ErrnoError(28);var n=o.nodePermissions(r,"w");if(n)throw new o.ErrnoError(n);o.doSetAttr(e,r,{size:t,timestamp:Date.now()})},truncate(e,r){if(r<0)throw new o.ErrnoError(28);var t;if(typeof e=="string"){var n=o.lookupPath(e,{follow:!0});t=n.node}else t=e;o.doTruncate(null,t,r)},ftruncate(e,r){var t=o.getStreamChecked(e);if(r<0||(t.flags&2097155)===0)throw new o.ErrnoError(28);o.doTruncate(t,t.node,r)},utime(e,r,t){var n=o.lookupPath(e,{follow:!0}),i=n.node,a=o.checkOpExists(i.node_ops.setattr,63);a(i,{atime:r,mtime:t})},open(e,r,t=438){if(e==="")throw new o.ErrnoError(44);r=typeof r=="string"?Bt(r):r,r&64?t=t&4095|32768:t=0;var n,i;if(typeof e=="object")n=e;else{i=e.endsWith("/");var a=o.lookupPath(e,{follow:!(r&131072),noent_okay:!0});n=a.node,e=a.path}var s=!1;if(r&64)if(n){if(r&128)throw new o.ErrnoError(20)}else{if(i)throw new o.ErrnoError(31);n=o.mknod(e,t|511,0),s=!0}if(!n)throw new o.ErrnoError(44);if(o.isChrdev(n.mode)&&(r&=-513),r&65536&&!o.isDir(n.mode))throw new o.ErrnoError(54);if(!s){var l=o.mayOpen(n,r);if(l)throw new o.ErrnoError(l)}r&512&&!s&&o.truncate(n,0),r&=-131713;var u=o.createStream({node:n,path:o.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return u.stream_ops.open&&u.stream_ops.open(u),s&&o.chmod(n,t&511),d.logReadFiles&&!(r&1)&&(e in o.readFiles||(o.readFiles[e]=1)),u},close(e){if(o.isClosed(e))throw new o.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{o.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,r,t){if(o.isClosed(e))throw new o.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new o.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new o.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,n,i){if(f(t>=0),n<0||i<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if((e.flags&2097155)===1)throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.read)throw new o.ErrnoError(28);var a=typeof i<"u";if(!a)i=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var s=e.stream_ops.read(e,r,t,n,i);return a||(e.position+=s),s},write(e,r,t,n,i,a){if(f(t>=0),n<0||i<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if((e.flags&2097155)===0)throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.write)throw new o.ErrnoError(28);e.seekable&&e.flags&1024&&o.llseek(e,0,2);var s=typeof i<"u";if(!s)i=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var l=e.stream_ops.write(e,r,t,n,i,a);return s||(e.position+=l),l},mmap(e,r,t,n,i){if((n&2)!==0&&(i&2)===0&&(e.flags&2097155)!==2)throw new o.ErrnoError(2);if((e.flags&2097155)===1)throw new o.ErrnoError(2);if(!e.stream_ops.mmap)throw new o.ErrnoError(43);if(!r)throw new o.ErrnoError(28);return e.stream_ops.mmap(e,r,t,n,i)},msync(e,r,t,n,i){return f(t>=0),e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,i):0},ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new o.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary"&&F(`Invalid encoding type "${r.encoding}"`);var t=o.open(e,r.flags),n=o.stat(e),i=n.size,a=new Uint8Array(i);return o.read(t,a,0,i,0),r.encoding==="utf8"&&(a=ue(a)),o.close(t),a},writeFile(e,r,t={}){t.flags=t.flags||577;var n=o.open(e,t.flags,t.mode);typeof r=="string"&&(r=new Uint8Array(Ye(r,!0))),ArrayBuffer.isView(r)?o.write(n,r,0,r.byteLength,void 0,t.canOwn):F("Unsupported data type"),o.close(n)},cwd:()=>o.currentPath,chdir(e){var r=o.lookupPath(e,{follow:!0});if(r.node===null)throw new o.ErrnoError(44);if(!o.isDir(r.node.mode))throw new o.ErrnoError(54);var t=o.nodePermissions(r.node,"x");if(t)throw new o.ErrnoError(t);o.currentPath=r.path},createDefaultDirectories(){o.mkdir("/tmp"),o.mkdir("/home"),o.mkdir("/home/web_user")},createDefaultDevices(){o.mkdir("/dev"),o.registerDevice(o.makedev(1,3),{read:()=>0,write:(n,i,a,s,l)=>s,llseek:()=>0}),o.mkdev("/dev/null",o.makedev(1,3)),X.register(o.makedev(5,0),X.default_tty_ops),X.register(o.makedev(6,0),X.default_tty1_ops),o.mkdev("/dev/tty",o.makedev(5,0)),o.mkdev("/dev/tty1",o.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(Pr(e),r=e.byteLength),e[--r]);o.createDevice("/dev","random",t),o.createDevice("/dev","urandom",t),o.mkdir("/dev/shm"),o.mkdir("/dev/shm/tmp")},createSpecialDirectories(){o.mkdir("/proc");var e=o.mkdir("/proc/self");o.mkdir("/proc/self/fd"),o.mount({mount(){var r=o.createNode(e,"fd",16895,73);return r.stream_ops={llseek:E.stream_ops.llseek},r.node_ops={lookup(t,n){var i=+n,a=o.getStreamChecked(i),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>a.path},id:i+1};return s.parent=s,s},readdir(){return Array.from(o.streams.entries()).filter(([t,n])=>n).map(([t,n])=>t.toString())}},r}},{},"/proc/self/fd")},createStandardStreams(e,r,t){e?o.createDevice("/dev","stdin",e):o.symlink("/dev/tty","/dev/stdin"),r?o.createDevice("/dev","stdout",null,r):o.symlink("/dev/tty","/dev/stdout"),t?o.createDevice("/dev","stderr",null,t):o.symlink("/dev/tty1","/dev/stderr");var n=o.open("/dev/stdin",0),i=o.open("/dev/stdout",1),a=o.open("/dev/stderr",1);f(n.fd===0,`invalid handle for stdin (${n.fd})`),f(i.fd===1,`invalid handle for stdout (${i.fd})`),f(a.fd===2,`invalid handle for stderr (${a.fd})`)},staticInit(){o.nameTable=new Array(4096),o.mount(E,{},"/"),o.createDefaultDirectories(),o.createDefaultDevices(),o.createSpecialDirectories(),o.filesystems={MEMFS:E}},init(e,r,t){f(!o.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)"),o.initialized=!0,e??=d.stdin,r??=d.stdout,t??=d.stderr,o.createStandardStreams(e,r,t)},quit(){o.initialized=!1,lr(0);for(var e of o.streams)e&&o.close(e)},findObject(e,r){var t=o.analyzePath(e,r);return t.exists?t.object:null},analyzePath(e,r){try{var t=o.lookupPath(e,{follow:!r});e=t.path}catch{}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=o.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=T.basename(e),t=o.lookupPath(e,{follow:!r}),n.exists=!0,n.path=t.path,n.object=t.node,n.name=t.node.name,n.isRoot=t.path==="/"}catch(i){n.error=i.errno}return n},createPath(e,r,t,n){e=typeof e=="string"?e:o.getPath(e);for(var i=r.split("/").reverse();i.length;){var a=i.pop();if(a){var s=T.join2(e,a);try{o.mkdir(s)}catch(l){if(l.errno!=20)throw l}e=s}}return s},createFile(e,r,t,n,i){var a=T.join2(typeof e=="string"?e:o.getPath(e),r),s=Xe(n,i);return o.create(a,s)},createDataFile(e,r,t,n,i,a){var s=r;e&&(e=typeof e=="string"?e:o.getPath(e),s=r?T.join2(e,r):e);var l=Xe(n,i),u=o.create(s,l);if(t){if(typeof t=="string"){for(var c=new Array(t.length),v=0,p=t.length;v<p;++v)c[v]=t.charCodeAt(v);t=c}o.chmod(u,l|146);var h=o.open(u,577);o.write(h,t,0,t.length,0,a),o.close(h),o.chmod(u,l)}},createDevice(e,r,t,n){var i=T.join2(typeof e=="string"?e:o.getPath(e),r),a=Xe(!!t,!!n);o.createDevice.major??=64;var s=o.makedev(o.createDevice.major++,0);return o.registerDevice(s,{open(l){l.seekable=!1},close(l){n?.buffer?.length&&n(10)},read(l,u,c,v,p){for(var h=0,m=0;m<v;m++){var _;try{_=t()}catch{throw new o.ErrnoError(29)}if(_===void 0&&h===0)throw new o.ErrnoError(6);if(_==null)break;h++,u[c+m]=_}return h&&(l.node.atime=Date.now()),h},write(l,u,c,v,p){for(var h=0;h<v;h++)try{n(u[c+h])}catch{throw new o.ErrnoError(29)}return v&&(l.node.mtime=l.node.ctime=Date.now()),h}}),o.mkdev(i,a,s)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)F("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");else try{e.contents=he(e.url)}catch{throw new o.ErrnoError(29)}},createLazyFile(e,r,t,n,i){class a{lengthKnown=!1;chunks=[];get(m){if(!(m>this.length-1||m<0)){var _=m%this.chunkSize,y=m/this.chunkSize|0;return this.getter(y)[_]}}setDataGetter(m){this.getter=m}cacheLength(){var m=new XMLHttpRequest;m.open("HEAD",t,!1),m.send(null),m.status>=200&&m.status<300||m.status===304||F("Couldn't load "+t+". Status: "+m.status);var _=Number(m.getResponseHeader("Content-length")),y,I=(y=m.getResponseHeader("Accept-Ranges"))&&y==="bytes",P=(y=m.getResponseHeader("Content-Encoding"))&&y==="gzip",N=1024*1024;I||(N=_);var D=(B,K)=>{B>K&&F("invalid range ("+B+", "+K+") or no bytes requested!"),K>_-1&&F("only "+_+" bytes available! programmer error!");var $=new XMLHttpRequest;return $.open("GET",t,!1),_!==N&&$.setRequestHeader("Range","bytes="+B+"-"+K),$.responseType="arraybuffer",$.overrideMimeType&&$.overrideMimeType("text/plain; charset=x-user-defined"),$.send(null),$.status>=200&&$.status<300||$.status===304||F("Couldn't load "+t+". Status: "+$.status),$.response!==void 0?new Uint8Array($.response||[]):Ye($.responseText||"",!0)},oe=this;oe.setDataGetter(B=>{var K=B*N,$=(B+1)*N-1;return $=Math.min($,_-1),typeof oe.chunks[B]>"u"&&(oe.chunks[B]=D(K,$)),typeof oe.chunks[B]>"u"&&F("doXHR failed!"),oe.chunks[B]}),(P||!_)&&(N=_=1,_=this.getter(0).length,N=_,ee("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=_,this._chunkSize=N,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(globalThis.XMLHttpRequest){q||F("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var s=new a,l={isDevice:!1,contents:s}}else var l={isDevice:!1,url:t};var u=o.createFile(e,r,l,n,i);l.contents?u.contents=l.contents:l.url&&(u.contents=null,u.url=l.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var c={},v=Object.keys(u.stream_ops);v.forEach(h=>{var m=u.stream_ops[h];c[h]=(..._)=>(o.forceLoadFile(u),m(..._))});function p(h,m,_,y,I){var P=h.node.contents;if(I>=P.length)return 0;var N=Math.min(P.length-I,y);if(f(N>=0),P.slice)for(var D=0;D<N;D++)m[_+D]=P[I+D];else for(var D=0;D<N;D++)m[_+D]=P.get(I+D);return N}return c.read=(h,m,_,y,I)=>(o.forceLoadFile(u),p(h,m,_,y,I)),c.mmap=(h,m,_,y,I)=>{o.forceLoadFile(u);var P=Cr(m);if(!P)throw new o.ErrnoError(48);return p(h,x,P,m,_),{ptr:P,allocated:!0}},u.stream_ops=c,u},absolutePath(){F("FS.absolutePath has been removed; use PATH_FS.resolve instead")},createFolder(){F("FS.createFolder has been removed; use FS.mkdir instead")},createLink(){F("FS.createLink has been removed; use FS.symlink instead")},joinPath(){F("FS.joinPath has been removed; use PATH.join instead")},mmapAlloc(){F("FS.mmapAlloc has been replaced by the top level function mmapAlloc")},standardizePath(){F("FS.standardizePath has been removed; use PATH.normalize instead")}},k={DEFAULT_POLLMASK:5,calculateAt(e,r,t){if(T.isAbs(r))return r;var n;if(e===-100)n=o.cwd();else{var i=k.getStreamFromFD(e);n=i.path}if(r.length==0){if(!t)throw new o.ErrnoError(44);return n}return n+"/"+r},writeStat(e,r){g[e>>2]=r.dev,g[e+4>>2]=r.mode,g[e+8>>2]=r.nlink,g[e+12>>2]=r.uid,g[e+16>>2]=r.gid,g[e+20>>2]=r.rdev,M[e+24>>3]=BigInt(r.size),S[e+32>>2]=4096,S[e+36>>2]=r.blocks;var t=r.atime.getTime(),n=r.mtime.getTime(),i=r.ctime.getTime();return M[e+40>>3]=BigInt(Math.floor(t/1e3)),g[e+48>>2]=t%1e3*1e3*1e3,M[e+56>>3]=BigInt(Math.floor(n/1e3)),g[e+64>>2]=n%1e3*1e3*1e3,M[e+72>>3]=BigInt(Math.floor(i/1e3)),g[e+80>>2]=i%1e3*1e3*1e3,M[e+88>>3]=BigInt(r.ino),0},writeStatFs(e,r){g[e+4>>2]=r.bsize,g[e+60>>2]=r.bsize,M[e+8>>3]=BigInt(r.blocks),M[e+16>>3]=BigInt(r.bfree),M[e+24>>3]=BigInt(r.bavail),M[e+32>>3]=BigInt(r.files),M[e+40>>3]=BigInt(r.ffree),g[e+48>>2]=r.fsid,g[e+64>>2]=r.flags,g[e+56>>2]=r.namelen},doMsync(e,r,t,n,i){if(!o.isFile(r.node.mode))throw new o.ErrnoError(43);if(n&2)return 0;var a=j.slice(e,e+t);o.msync(r,a,i,t,n)},getStreamFromFD(e){var r=o.getStreamChecked(e);return r},varargs:void 0,getStr(e){var r=J(e);return r}};function Kt(e,r,t){k.varargs=t;try{var n=k.getStreamFromFD(e);switch(r){case 0:{var i=$e();if(i<0)return-28;for(;o.streams[i];)i++;var a;return a=o.dupStream(n,i),a.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var i=$e();return n.flags|=i,0}case 12:{var i=ce(),s=0;return V[i+s>>1]=2,0}case 13:case 14:return 0}return-28}catch(l){if(typeof o>"u"||l.name!=="ErrnoError")throw l;return-l.errno}}function Jt(e,r){try{return k.writeStat(r,o.fstat(e))}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}var Z=(e,r,t)=>(f(typeof t=="number","stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),Ar(e,j,r,t));function Qt(e,r){try{if(r===0)return-28;var t=o.cwd(),n=fe(t)+1;return r<n?-68:(Z(t,e,r),n)}catch(i){if(typeof o>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function Zt(e,r,t){try{var n=k.getStreamFromFD(e);n.getdents||=o.readdir(n.path);for(var i=280,a=0,s=o.llseek(n,0,1),l=Math.floor(s/i),u=Math.min(n.getdents.length,l+Math.floor(t/i)),c=l;c<u;c++){var v,p,h=n.getdents[c];if(h===".")v=n.node.id,p=4;else if(h===".."){var m=o.lookupPath(n.path,{parent:!0});v=m.node.id,p=4}else{var _;try{_=o.lookupNode(n.node,h)}catch(y){if(y?.errno===28)continue;throw y}v=_.id,p=o.isChrdev(_.mode)?2:o.isDir(_.mode)?4:o.isLink(_.mode)?10:8}f(v),M[r+a>>3]=BigInt(v),M[r+a+8>>3]=BigInt((c+1)*i),V[r+a+16>>1]=280,x[r+a+18]=p,Z(h,r+a+19,256),a+=i}return o.llseek(n,c*i,0),a}catch(y){if(typeof o>"u"||y.name!=="ErrnoError")throw y;return-y.errno}}function en(e,r,t){k.varargs=t;try{var n=k.getStreamFromFD(e);switch(r){case 21509:return n.tty?0:-59;case 21505:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcgets){var i=n.tty.ops.ioctl_tcgets(n),a=ce();S[a>>2]=i.c_iflag||0,S[a+4>>2]=i.c_oflag||0,S[a+8>>2]=i.c_cflag||0,S[a+12>>2]=i.c_lflag||0;for(var s=0;s<32;s++)x[a+s+17]=i.c_cc[s]||0;return 0}return 0}case 21510:case 21511:case 21512:return n.tty?0:-59;case 21506:case 21507:case 21508:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcsets){for(var a=ce(),l=S[a>>2],u=S[a+4>>2],c=S[a+8>>2],v=S[a+12>>2],p=[],s=0;s<32;s++)p.push(x[a+s+17]);return n.tty.ops.ioctl_tcsets(n.tty,r,{c_iflag:l,c_oflag:u,c_cflag:c,c_lflag:v,c_cc:p})}return 0}case 21519:{if(!n.tty)return-59;var a=ce();return S[a>>2]=0,0}case 21520:return n.tty?-28:-59;case 21537:case 21531:{var a=ce();return o.ioctl(n,r,a)}case 21523:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tiocgwinsz){var h=n.tty.ops.ioctl_tiocgwinsz(n.tty),a=ce();V[a>>1]=h[0],V[a+2>>1]=h[1]}return 0}case 21524:return n.tty?0:-59;case 21515:return n.tty?0:-59;default:return-28}}catch(m){if(typeof o>"u"||m.name!=="ErrnoError")throw m;return-m.errno}}function rn(e,r){try{return e=k.getStr(e),k.writeStat(r,o.lstat(e))}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}function tn(e,r,t,n){try{r=k.getStr(r);var i=n&256,a=n&4096;return n=n&-6401,f(!n,`unknown flags in __syscall_newfstatat: ${n}`),r=k.calculateAt(e,r,a),k.writeStat(t,i?o.lstat(r):o.stat(r))}catch(s){if(typeof o>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}function nn(e,r,t,n){k.varargs=n;try{r=k.getStr(r),r=k.calculateAt(e,r);var i=n?$e():0;return o.open(r,t,i).fd}catch(a){if(typeof o>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function on(e){try{return e=k.getStr(e),o.rmdir(e),0}catch(r){if(typeof o>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function an(e,r){try{return e=k.getStr(e),k.writeStat(r,o.stat(e))}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}function sn(e,r,t){try{if(r=k.getStr(r),r=k.calculateAt(e,r),!t)o.unlink(r);else if(t===512)o.rmdir(r);else return-28;return 0}catch(n){if(typeof o>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}var Or=()=>dt,Ke=e=>{var r=e.getArg(Or(),0);return ut(r)},ln=()=>at(),un=e=>ot(e),Ir=e=>it(e),cn=e=>{var r=ln(),t=Ir(4),n=Ir(4);ct(e,t,n);var i=g[t>>2],a=g[n>>2],s=J(i);H(i);var l;return a&&(l=J(a),H(a)),un(r),[s,l]},Mr=e=>{var r=Ke(e);return cn(r)},dn=e=>{var r=new WebAssembly.Exception(Or(),[e],{traceStack:!0});throw r.message=Mr(r),r},fn=()=>F("native code called abort()"),W=e=>{for(var r="";;){var t=j[e++];if(!t)return r;r+=String.fromCharCode(t)}},me={},te={},Oe={},be=class extends Error{constructor(r){super(r),this.name="BindingError"}},b=e=>{throw new be(e)};function vn(e,r,t={}){var n=r.name;if(e||b(`type "${n}" must have a positive integer typeid pointer`),te.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;b(`Cannot register type '${n}' twice`)}if(te[e]=r,delete Oe[e],me.hasOwnProperty(e)){var i=me[e];delete me[e],i.forEach(a=>a())}}function z(e,r,t={}){return vn(e,r,t)}var Nr=(e,r,t)=>{switch(r){case 1:return t?n=>x[n]:n=>j[n];case 2:return t?n=>V[n>>1]:n=>Ee[n>>1];case 4:return t?n=>S[n>>2]:n=>g[n>>2];case 8:return t?n=>M[n>>3]:n=>Er[n>>3];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},ne=e=>{if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},xr=(e,r,t,n)=>{if(r<t||r>n)throw new TypeError(`Passing a number "${ne(r)}" from JS side to C/C++ side to an argument of type "${e}", which is outside the valid range [${t}, ${n}]!`)},mn=(e,r,t,n,i)=>{r=W(r);let a=n===0n,s=l=>l;if(a){let l=t*8;s=u=>BigInt.asUintN(l,u),i=s(i)}z(e,{name:r,fromWireType:s,toWireType:(l,u)=>{if(typeof u=="number")u=BigInt(u);else if(typeof u!="bigint")throw new TypeError(`Cannot convert "${ne(u)}" to ${this.name}`);return xr(r,u,n,i),u},readValueFromPointer:Nr(r,t,!a),destructorFunction:null})},_n=(e,r,t,n)=>{r=W(r),z(e,{name:r,fromWireType:function(i){return!!i},toWireType:function(i,a){return a?t:n},readValueFromPointer:function(i){return this.fromWireType(j[i])},destructorFunction:null})},pn=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Je=e=>{function r(t){return t.$$.ptrType.registeredClass.name}b(r(e)+" instance already deleted")},Qe=!1,Lr=e=>{},hn=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)},Ur=e=>{e.count.value-=1;var r=e.count.value===0;r&&hn(e)},Wr=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=Wr(e,r,t.baseClass);return n===null?null:t.downcast(n)},Br={},gn={},yn=(e,r)=>{for(r===void 0&&b("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},En=(e,r)=>(r=yn(e,r),gn[r]),wn=class extends Error{constructor(r){super(r),this.name="InternalError"}},Ie=e=>{throw new wn(e)},Me=(e,r)=>{(!r.ptrType||!r.ptr)&&Ie("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&Ie("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Se(Object.create(e,{$$:{value:r,writable:!0}}))};function jr(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=En(this.registeredClass,r);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function i(){return this.isSmartPointer?Me(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):Me(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var a=this.registeredClass.getActualType(r),s=Br[a];if(!s)return i.call(this);var l;this.isConst?l=s.constPointerType:l=s.pointerType;var u=Wr(r,this.registeredClass,l.registeredClass);return u===null?i.call(this):this.isSmartPointer?Me(l.registeredClass.instancePrototype,{ptrType:l,ptr:u,smartPtrType:this,smartPtr:e}):Me(l.registeredClass.instancePrototype,{ptrType:l,ptr:u})}var Se=e=>globalThis.FinalizationRegistry?(Qe=new FinalizationRegistry(r=>{console.warn(r.leakWarning),Ur(r.$$)}),Se=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var i={$$:t},a=t.ptrType.registeredClass,s=new Error(`Embind found a leaked C++ instance ${a.name} <${se(t.ptr)}>.
|
|
3
|
+
We'll free it automatically in this case, but this functionality is not reliable across various environments.
|
|
4
|
+
Make sure to invoke .delete() manually once you're done with the instance instead.
|
|
5
|
+
Originally allocated`);"captureStackTrace"in Error&&Error.captureStackTrace(s,jr),i.leakWarning=s.stack.replace(/^Error: /,""),Qe.register(r,i,r)}return r},Lr=r=>Qe.unregister(r),Se(e)):(Se=r=>r,e),Ne=[],bn=()=>{for(;Ne.length;){var e=Ne.pop();e.$$.deleteScheduled=!1,e.delete()}},Hr,Sn=()=>{let e=xe.prototype;Object.assign(e,{isAliasOf(t){if(!(this instanceof xe)||!(t instanceof xe))return!1;var n=this.$$.ptrType.registeredClass,i=this.$$.ptr;t.$$=t.$$;for(var a=t.$$.ptrType.registeredClass,s=t.$$.ptr;n.baseClass;)i=n.upcast(i),n=n.baseClass;for(;a.baseClass;)s=a.upcast(s),a=a.baseClass;return n===a&&i===s},clone(){if(this.$$.ptr||Je(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var t=Se(Object.create(Object.getPrototypeOf(this),{$$:{value:pn(this.$$)}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t},delete(){this.$$.ptr||Je(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&b("Object already scheduled for deletion"),Lr(this),Ur(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Je(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&b("Object already scheduled for deletion"),Ne.push(this),Ne.length===1&&Hr&&Hr(bn),this.$$.deleteScheduled=!0,this}});let r=Symbol.dispose;r&&(e[r]=e.delete)};function xe(){}var Ze=(e,r)=>Object.defineProperty(r,"name",{value:e}),Vr=(e,r,t)=>{if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(...i){return e[r].overloadTable.hasOwnProperty(i.length)||b(`Function '${t}' called with an invalid number of arguments (${i.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[i.length].apply(this,i)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n}},Fn=(e,r,t)=>{d.hasOwnProperty(e)?((t===void 0||d[e].overloadTable!==void 0&&d[e].overloadTable[t]!==void 0)&&b(`Cannot register public name '${e}' twice`),Vr(d,e,e),d[e].overloadTable.hasOwnProperty(t)&&b(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),d[e].overloadTable[t]=r):(d[e]=r,d[e].argCount=t)},Tn=48,kn=57,Pn=e=>{f(typeof e=="string"),e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=Tn&&r<=kn?`_${e}`:e};function An(e,r,t,n,i,a,s,l){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=i,this.getActualType=a,this.upcast=s,this.downcast=l,this.pureVirtualFunctions=[]}var er=(e,r,t)=>{for(;r!==t;)r.upcast||b(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function Cn(e,r){if(r===null)return this.isReference&&b(`null is not a valid ${this.name}`),0;r.$$||b(`Cannot pass "${ne(r)}" as a ${this.name}`),r.$$.ptr||b(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=er(r.$$.ptr,t,this.registeredClass);return n}function Dn(e,r){var t;if(r===null)return this.isReference&&b(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;(!r||!r.$$)&&b(`Cannot pass "${ne(r)}" as a ${this.name}`),r.$$.ptr||b(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&b(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);var n=r.$$.ptrType.registeredClass;if(t=er(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&b("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:b(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:t=r.$$.smartPtr;break;case 2:if(r.$$.smartPtrType===this)t=r.$$.smartPtr;else{var i=r.clone();t=this.rawShare(t,L.toHandle(()=>i.delete())),e!==null&&e.push(this.rawDestructor,t)}break;default:b("Unsupporting sharing policy")}return t}function Rn(e,r){if(r===null)return this.isReference&&b(`null is not a valid ${this.name}`),0;r.$$||b(`Cannot pass "${ne(r)}" as a ${this.name}`),r.$$.ptr||b(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&b(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=er(r.$$.ptr,t,this.registeredClass);return n}function Le(e){return this.fromWireType(g[e>>2])}var $n=()=>{Object.assign(Ue.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor?.(e)},readValueFromPointer:Le,fromWireType:jr})};function Ue(e,r,t,n,i,a,s,l,u,c,v){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=i,this.pointeeType=a,this.sharingPolicy=s,this.rawGetPointee=l,this.rawConstructor=u,this.rawShare=c,this.rawDestructor=v,!i&&r.baseClass===void 0?n?(this.toWireType=Cn,this.destructorFunction=null):(this.toWireType=Rn,this.destructorFunction=null):this.toWireType=Dn}var On=(e,r,t)=>{d.hasOwnProperty(e)||Ie("Replacing nonexistent public symbol"),d[e].overloadTable!==void 0&&t!==void 0?d[e].overloadTable[t]=r:(d[e]=r,d[e].argCount=t)},zr=[],In=e=>{var r=zr[e];return r||(zr[e]=r=cr.get(e)),f(cr.get(e)==r,"JavaScript-side Wasm function table mirror is out of date!"),r},_e=(e,r,t=!1)=>{f(!t,"Async bindings are only supported with JSPI."),e=W(e);function n(){var a=In(r);return a}var i=n();return typeof i!="function"&&b(`unknown function pointer with signature ${e}: ${r}`),i};class Mn extends Error{}var Gr=e=>{var r=et(e),t=W(r);return H(r),t},rr=(e,r)=>{var t=[],n={};function i(a){if(!n[a]&&!te[a]){if(Oe[a]){Oe[a].forEach(i);return}t.push(a),n[a]=!0}}throw r.forEach(i),new Mn(`${e}: `+t.map(Gr).join([", "]))},Fe=(e,r,t)=>{e.forEach(l=>Oe[l]=r);function n(l){var u=t(l);u.length!==e.length&&Ie("Mismatched type converter count");for(var c=0;c<e.length;++c)z(e[c],u[c])}var i=new Array(r.length),a=[],s=0;r.forEach((l,u)=>{te.hasOwnProperty(l)?i[u]=te[l]:(a.push(l),me.hasOwnProperty(l)||(me[l]=[]),me[l].push(()=>{i[u]=te[l],++s,s===a.length&&n(i)}))}),a.length===0&&n(i)},Nn=(e,r,t,n,i,a,s,l,u,c,v,p,h)=>{v=W(v),a=_e(i,a),l&&=_e(s,l),c&&=_e(u,c),h=_e(p,h);var m=Pn(v);Fn(m,function(){rr(`Cannot construct ${v} due to unbound types`,[n])}),Fe([e,r,t],n?[n]:[],_=>{_=_[0];var y,I;n?(y=_.registeredClass,I=y.instancePrototype):I=xe.prototype;var P=Ze(v,function(...$){if(Object.getPrototypeOf(this)!==N)throw new be(`Use 'new' to construct ${v}`);if(D.constructor_body===void 0)throw new be(`${v} has no accessible constructor`);var mt=D.constructor_body[$.length];if(mt===void 0)throw new be(`Tried to invoke ctor of ${v} with invalid number of parameters (${$.length}) - expected (${Object.keys(D.constructor_body).toString()}) parameters instead!`);return mt.apply(this,$)}),N=Object.create(I,{constructor:{value:P}});P.prototype=N;var D=new An(v,P,N,h,y,a,l,c);D.baseClass&&(D.baseClass.__derivedClasses??=[],D.baseClass.__derivedClasses.push(D));var oe=new Ue(v,D,!0,!1,!1),B=new Ue(v+"*",D,!1,!1,!1),K=new Ue(v+" const*",D,!1,!0,!1);return Br[e]={pointerType:B,constPointerType:K},On(m,P),[oe,B,K]})},qr=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push(g[r+n*4>>2]);return t},Yr=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r)}};function Xr(e){for(var r=1;r<e.length;++r)if(e[r]!==null&&e[r].destructorFunction===void 0)return!0;return!1}function xn(e,r,t,n,i){if(e<r||e>t){var a=r==t?r:`${r} to ${t}`;i(`function ${n} called with ${e} arguments, expected ${a}`)}}function Ln(e,r,t,n){var i=Xr(e),a=e.length-2,s=[],l=["fn"];r&&l.push("thisWired");for(var u=0;u<a;++u)s.push(`arg${u}`),l.push(`arg${u}Wired`);s=s.join(","),l=l.join(",");var c=`return function (${s}) {
|
|
6
|
+
`;c+=`checkArgCount(arguments.length, minArgs, maxArgs, humanName, throwBindingError);
|
|
7
|
+
`,i&&(c+=`var destructors = [];
|
|
8
|
+
`);var v=i?"destructors":"null",p=["humanName","throwBindingError","invoker","fn","runDestructors","fromRetWire","toClassParamWire"];r&&(c+=`var thisWired = toClassParamWire(${v}, this);
|
|
9
|
+
`);for(var u=0;u<a;++u){var h=`toArg${u}Wire`;c+=`var arg${u}Wired = ${h}(${v}, arg${u});
|
|
10
|
+
`,p.push(h)}c+=(t||n?"var rv = ":"")+`invoker(${l});
|
|
11
|
+
`;var m=t?"rv":"";if(i)c+=`runDestructors(destructors);
|
|
12
|
+
`;else for(var u=r?1:2;u<e.length;++u){var _=u===1?"thisWired":"arg"+(u-2)+"Wired";e[u].destructorFunction!==null&&(c+=`${_}_dtor(${_});
|
|
13
|
+
`,p.push(`${_}_dtor`))}return t&&(c+=`var ret = fromRetWire(rv);
|
|
14
|
+
return ret;
|
|
15
|
+
`),c+=`}
|
|
16
|
+
`,p.push("checkArgCount","minArgs","maxArgs"),c=`if (arguments.length !== ${p.length}){ throw new Error(humanName + "Expected ${p.length} closure arguments " + arguments.length + " given."); }
|
|
17
|
+
${c}`,new Function(p,c)}function Un(e){for(var r=e.length-2,t=e.length-1;t>=2&&e[t].optional;--t)r--;return r}function Kr(e,r,t,n,i,a){var s=r.length;s<2&&b("argTypes array size mismatch! Must at least get return value and 'this' types!"),f(!a,"Async bindings are only supported with JSPI.");for(var l=r[1]!==null&&t!==null,u=Xr(r),c=!r[0].isVoid,v=s-2,p=Un(r),h=r[0],m=r[1],_=[e,b,n,i,Yr,h.fromWireType.bind(h),m?.toWireType.bind(m)],y=2;y<s;++y){var I=r[y];_.push(I.toWireType.bind(I))}if(!u)for(var y=l?1:2;y<r.length;++y)r[y].destructorFunction!==null&&_.push(r[y].destructorFunction);_.push(xn,p,v);var N=Ln(r,l,c,a)(..._);return Ze(e,N)}var Wn=(e,r,t,n,i,a)=>{f(r>0);var s=qr(r,t);i=_e(n,i);var l=[a],u=[];Fe([],[e],c=>{c=c[0];var v=`constructor ${c.name}`;if(c.registeredClass.constructor_body===void 0&&(c.registeredClass.constructor_body=[]),c.registeredClass.constructor_body[r-1]!==void 0)throw new be(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${c.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return c.registeredClass.constructor_body[r-1]=()=>{rr(`Cannot construct ${c.name} due to unbound types`,s)},Fe([],s,p=>(p.splice(1,0,null),c.registeredClass.constructor_body[r-1]=Kr(v,p,null,i,a),[])),[]})},Bn=e=>{e=e.trim();let r=e.indexOf("(");return r===-1?e:(f(e.endsWith(")"),"Parentheses for argument names should match."),e.slice(0,r))},jn=(e,r,t,n,i,a,s,l,u,c)=>{var v=qr(t,n);r=W(r),r=Bn(r),a=_e(i,a,u),Fe([],[e],p=>{p=p[0];var h=`${p.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),l&&p.registeredClass.pureVirtualFunctions.push(r);function m(){rr(`Cannot call ${h} due to unbound types`,v)}var _=p.registeredClass.instancePrototype,y=_[r];return y===void 0||y.overloadTable===void 0&&y.className!==p.name&&y.argCount===t-2?(m.argCount=t-2,m.className=p.name,_[r]=m):(Vr(_,r,h),_[r].overloadTable[t-2]=m),Fe([],v,I=>{var P=Kr(h,I,p,a,s,u);return _[r].overloadTable===void 0?(P.argCount=t-2,_[r]=P):_[r].overloadTable[t-2]=P,[]}),[]})},Jr=[],G=[0,1,,1,null,1,!0,1,!1,1],tr=e=>{e>9&&--G[e+1]===0&&(f(G[e]!==void 0,"Decref for unallocated handle."),G[e]=void 0,Jr.push(e))},L={toValue:e=>(e||b(`Cannot use deleted val. handle = ${e}`),f(e===2||G[e]!==void 0&&e%2===0,`invalid handle: ${e}`),G[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let r=Jr.pop()||G.length;return G[r]=e,G[r+1]=1,r}}}},Hn={name:"emscripten::val",fromWireType:e=>{var r=L.toValue(e);return tr(e),r},toWireType:(e,r)=>L.toHandle(r),readValueFromPointer:Le,destructorFunction:null},Vn=e=>z(e,Hn),zn=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType(De[t>>2])};case 8:return function(t){return this.fromWireType(Re[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},Gn=(e,r,t)=>{r=W(r),z(e,{name:r,fromWireType:n=>n,toWireType:(n,i)=>{if(typeof i!="number"&&typeof i!="boolean")throw new TypeError(`Cannot convert ${ne(i)} to ${this.name}`);return i},readValueFromPointer:zn(r,t),destructorFunction:null})},qn=(e,r,t,n,i)=>{r=W(r);let a=n===0,s=u=>u;if(a){var l=32-8*t;s=u=>u<<l>>>l,i=s(i)}z(e,{name:r,fromWireType:s,toWireType:(u,c)=>{if(typeof c!="number"&&typeof c!="boolean")throw new TypeError(`Cannot convert "${ne(c)}" to ${r}`);return xr(r,c,n,i),c},readValueFromPointer:Nr(r,t,n!==0),destructorFunction:null})},Yn=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array],i=n[r];function a(s){var l=g[s>>2],u=g[s+4>>2];return new i(x.buffer,u,l)}t=W(t),z(e,{name:t,fromWireType:a,readValueFromPointer:a},{ignoreDuplicateRegistrations:!0})},Xn=(e,r)=>{r=W(r);var t=!0;z(e,{name:r,fromWireType(n){var i=g[n>>2],a=n+4,s;if(t)s=J(a,i,!0);else{s="";for(var l=0;l<i;++l)s+=String.fromCharCode(j[a+l])}return H(n),s},toWireType(n,i){i instanceof ArrayBuffer&&(i=new Uint8Array(i));var a,s=typeof i=="string";s||ArrayBuffer.isView(i)&&i.BYTES_PER_ELEMENT==1||b("Cannot pass non-string to std::string"),t&&s?a=fe(i):a=i.length;var l=sr(4+a+1),u=l+4;if(g[l>>2]=a,s)if(t)Z(i,u,a+1);else for(var c=0;c<a;++c){var v=i.charCodeAt(c);v>255&&(H(l),b("String has UTF-16 code units that do not fit in 8 bits")),j[u+c]=v}else j.set(i,u);return n!==null&&n.push(H,l),l},readValueFromPointer:Le,destructorFunction(n){H(n)}})},Qr=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,Kn=(e,r,t)=>{f(e%2==0,"Pointer passed to UTF16ToString must be aligned to two bytes!");var n=e>>1,i=kr(Ee,n,r/2,t);if(i-n>16&&Qr)return Qr.decode(Ee.subarray(n,i));for(var a="",s=n;s<i;++s){var l=Ee[s];a+=String.fromCharCode(l)}return a},Jn=(e,r,t)=>{if(f(r%2==0,"Pointer passed to stringToUTF16 must be aligned to two bytes!"),f(typeof t=="number","stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),t??=2147483647,t<2)return 0;t-=2;for(var n=r,i=t<e.length*2?t/2:e.length,a=0;a<i;++a){var s=e.charCodeAt(a);V[r>>1]=s,r+=2}return V[r>>1]=0,r-n},Qn=e=>e.length*2,Zn=(e,r,t)=>{f(e%4==0,"Pointer passed to UTF32ToString must be aligned to four bytes!");for(var n="",i=e>>2,a=0;!(a>=r/4);a++){var s=g[i+a];if(!s&&!t)break;n+=String.fromCodePoint(s)}return n},eo=(e,r,t)=>{if(f(r%4==0,"Pointer passed to stringToUTF32 must be aligned to four bytes!"),f(typeof t=="number","stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),t??=2147483647,t<4)return 0;for(var n=r,i=n+t-4,a=0;a<e.length;++a){var s=e.codePointAt(a);if(s>65535&&a++,S[r>>2]=s,r+=4,r+4>i)break}return S[r>>2]=0,r-n},ro=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.codePointAt(t);n>65535&&t++,r+=4}return r},to=(e,r,t)=>{t=W(t);var n,i,a;r===2?(n=Kn,i=Jn,a=Qn):(f(r===4,"only 2-byte and 4-byte strings are currently supported"),n=Zn,i=eo,a=ro),z(e,{name:t,fromWireType:s=>{var l=g[s>>2],u=n(s+4,l*r,!0);return H(s),u},toWireType:(s,l)=>{typeof l!="string"&&b(`Cannot pass non-string to C++ string type ${t}`);var u=a(l),c=sr(4+u+r);return g[c>>2]=u/r,i(l,c+4,u+r),s!==null&&s.push(H,c),c},readValueFromPointer:Le,destructorFunction(s){H(s)}})},no=(e,r)=>{r=W(r),z(e,{isVoid:!0,name:r,fromWireType:()=>{},toWireType:(t,n)=>{}})},nr=[],oo=e=>{var r=nr.length;return nr.push(e),r},io=(e,r)=>{var t=te[e];return t===void 0&&b(`${r} has unknown type ${Gr(e)}`),t},ao=(e,r)=>{for(var t=new Array(e),n=0;n<e;++n)t[n]=io(g[r+n*4>>2],`parameter ${n}`);return t},so=(e,r,t)=>{var n=[],i=e(n,t);return n.length&&(g[r>>2]=L.toHandle(n)),i},lo={},or=e=>{var r=lo[e];return r===void 0?W(e):r},uo=(e,r,t)=>{var n=8,[i,...a]=ao(e,r),s=i.toWireType.bind(i),l=a.map(m=>m.readValueFromPointer.bind(m));e--;var u={toValue:L.toValue},c=l.map((m,_)=>{var y=`argFromPtr${_}`;return u[y]=m,`${y}(args${_?"+"+_*n:""})`}),v;switch(t){case 0:v="toValue(handle)";break;case 2:v="new (toValue(handle))";break;case 3:v="";break;case 1:u.getStringOrSymbol=or,v="toValue(handle)[getStringOrSymbol(methodName)]";break}v+=`(${c})`,i.isVoid||(u.toReturnWire=s,u.emval_returnValue=so,v=`return emval_returnValue(toReturnWire, destructorsRef, ${v})`),v=`return function (handle, methodName, destructorsRef, args) {
|
|
18
|
+
${v}
|
|
19
|
+
}`;var p=new Function(Object.keys(u),v)(...Object.values(u)),h=`methodCaller<(${a.map(m=>m.name)}) => ${i.name}>`;return oo(Ze(h,p))},co=e=>e?(e=or(e),L.toHandle(globalThis[e])):L.toHandle(globalThis),fo=(e,r)=>(e=L.toValue(e),r=L.toValue(r),L.toHandle(e[r])),vo=e=>{e>9&&(G[e+1]+=1)},Zr=(e,r,t,n,i)=>nr[e](r,t,n,i),mo=Zr,_o=()=>L.toHandle([]),po=e=>L.toHandle(or(e)),ho=e=>{var r=L.toValue(e);Yr(r),tr(e)},go=e=>(e=L.toValue(e),L.toHandle(typeof e)),yo=e=>e%4===0&&(e%100!==0||e%400===0),Eo=[0,31,60,91,121,152,182,213,244,274,305,335],wo=[0,31,59,90,120,151,181,212,243,273,304,334],bo=e=>{var r=yo(e.getFullYear()),t=r?Eo:wo,n=t[e.getMonth()]+e.getDate()-1;return n},So=9007199254740992,Fo=-9007199254740992,ir=e=>e<Fo||e>So?NaN:Number(e);function To(e,r){e=ir(e);var t=new Date(e*1e3);S[r>>2]=t.getSeconds(),S[r+4>>2]=t.getMinutes(),S[r+8>>2]=t.getHours(),S[r+12>>2]=t.getDate(),S[r+16>>2]=t.getMonth(),S[r+20>>2]=t.getFullYear()-1900,S[r+24>>2]=t.getDay();var n=bo(t)|0;S[r+28>>2]=n,S[r+36>>2]=-(t.getTimezoneOffset()*60);var i=new Date(t.getFullYear(),0,1),a=new Date(t.getFullYear(),6,1).getTimezoneOffset(),s=i.getTimezoneOffset(),l=(a!=s&&t.getTimezoneOffset()==Math.min(s,a))|0;S[r+32>>2]=l}var ko=(e,r,t,n)=>{var i=new Date().getFullYear(),a=new Date(i,0,1),s=new Date(i,6,1),l=a.getTimezoneOffset(),u=s.getTimezoneOffset(),c=Math.max(l,u);g[e>>2]=c*60,S[r>>2]=+(l!=u);var v=m=>{var _=m>=0?"-":"+",y=Math.abs(m),I=String(Math.floor(y/60)).padStart(2,"0"),P=String(y%60).padStart(2,"0");return`UTC${_}${I}${P}`},p=v(l),h=v(u);f(p),f(h),f(fe(p)<=16,`timezone name truncated to fit in TZNAME_MAX (${p})`),f(fe(h)<=16,`timezone name truncated to fit in TZNAME_MAX (${h})`),u<l?(Z(p,t,17),Z(h,n,17)):(Z(p,n,17),Z(h,t,17))},Po=()=>performance.now(),Ao=()=>Date.now(),Co=1,Do=e=>e>=0&&e<=3;function Ro(e,r,t){if(r=ir(r),!Do(e))return 28;var n;if(e===0)n=Ao();else if(Co)n=Po();else return 52;var i=Math.round(n*1e3*1e3);return M[t>>3]=BigInt(i),0}var $o=()=>2147483648,Oo=(e,r)=>(f(r,"alignment argument is required"),Math.ceil(e/r)*r),Io=e=>{var r=We.buffer.byteLength,t=(e-r+65535)/65536|0;try{return We.grow(t),wr(),1}catch(n){R(`growMemory: Attempted to grow heap from ${r} bytes to ${e} bytes, but got error: ${n}`)}},Mo=e=>{var r=j.length;e>>>=0,f(e>r);var t=$o();if(e>t)return R(`Cannot enlarge memory, requested ${e} bytes, but the limit is ${t} bytes!`),!1;for(var n=1;n<=4;n*=2){var i=r*(1+.2/n);i=Math.min(i,e+100663296);var a=Math.min(t,Oo(Math.max(e,i),65536)),s=Io(a);if(s)return!0}return R(`Failed to grow the heap from ${r} bytes to ${a} bytes, not enough memory!`),!1},ar={},No=()=>He||"./this.program",Te=()=>{if(!Te.strings){var e=(typeof navigator=="object"&&navigator.language||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:No()};for(var t in ar)ar[t]===void 0?delete r[t]:r[t]=ar[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);Te.strings=n}return Te.strings},xo=(e,r)=>{var t=0,n=0;for(var i of Te()){var a=r+t;g[e+n>>2]=a,t+=Z(i,a,1/0)+1,n+=4}return 0},Lo=(e,r)=>{var t=Te();g[e>>2]=t.length;var n=0;for(var i of t)n+=fe(i)+1;return g[r>>2]=n,0};function Uo(e){try{var r=k.getStreamFromFD(e);return o.close(r),0}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var Wo=(e,r,t,n)=>{for(var i=0,a=0;a<t;a++){var s=g[r>>2],l=g[r+4>>2];r+=8;var u=o.read(e,x,s,l,n);if(u<0)return-1;if(i+=u,u<l)break;typeof n<"u"&&(n+=u)}return i};function Bo(e,r,t,n){try{var i=k.getStreamFromFD(e),a=Wo(i,r,t);return g[n>>2]=a,0}catch(s){if(typeof o>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function jo(e,r,t,n){r=ir(r);try{if(isNaN(r))return 61;var i=k.getStreamFromFD(e);return o.llseek(i,r,t),M[n>>3]=BigInt(i.position),i.getdents&&r===0&&t===0&&(i.getdents=null),0}catch(a){if(typeof o>"u"||a.name!=="ErrnoError")throw a;return a.errno}}var Ho=(e,r,t,n)=>{for(var i=0,a=0;a<t;a++){var s=g[r>>2],l=g[r+4>>2];r+=8;var u=o.write(e,x,s,l,n);if(u<0)return-1;if(i+=u,u<l)break;typeof n<"u"&&(n+=u)}return i};function Vo(e,r,t,n){try{var i=k.getStreamFromFD(e),a=Ho(i,r,t);return g[n>>2]=a,0}catch(s){if(typeof o>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var zo=e=>{var r=Ke(e);lt(r)},Go=e=>{var r=Ke(e);st(r)};o.createPreloadedFile=Xt,o.preloadFile=$r,o.staticInit(),Sn(),$n(),f(G.length===10);{if(d.noExitRuntime&&(xt=d.noExitRuntime),d.preloadPlugins&&(Rr=d.preloadPlugins),d.print&&(ee=d.print),d.printErr&&(R=d.printErr),d.wasmBinary&&(ge=d.wasmBinary),Xo(),d.arguments&&(_r=d.arguments),d.thisProgram&&(He=d.thisProgram),f(typeof d.memoryInitializerPrefixURL>"u","Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),f(typeof d.pthreadMainPrefixURL>"u","Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),f(typeof d.cdInitializerPrefixURL>"u","Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),f(typeof d.filePackagePrefixURL>"u","Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),f(typeof d.read>"u","Module.read option was removed"),f(typeof d.readAsync>"u","Module.readAsync option was removed (modify readAsync in JS)"),f(typeof d.readBinary>"u","Module.readBinary option was removed (modify readBinary in JS)"),f(typeof d.setWindowTitle>"u","Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),f(typeof d.TOTAL_MEMORY>"u","Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),f(typeof d.ENVIRONMENT>"u","Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)"),f(typeof d.STACK_SIZE>"u","STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),f(typeof d.wasmMemory>"u","Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),f(typeof d.INITIAL_MEMORY>"u","Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically"),d.preInit)for(typeof d.preInit=="function"&&(d.preInit=[d.preInit]);d.preInit.length>0;)d.preInit.shift()();Ce("preInit")}var qo=["writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getTempRet0","setTempRet0","zeroMemory","exitJS","withStackSave","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","readEmAsmArgs","jstoi_q","autoResumeAudioContext","getDynCaller","dynCall","handleException","keepRuntimeAlive","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","asmjsMangle","HandleAllocator","addOnInit","addOnPostCtor","addOnPreMain","addOnExit","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","ccall","cwrap","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","getFunctionAddress","addFunction","removeFunction","intArrayToString","stringToAscii","stringToNewUTF8","stringToUTF8OnStack","writeArrayToMemory","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","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","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","jsStackTrace","getCallstack","convertPCtoSourceLocation","wasiRightsToMuslOFlags","wasiOFlagsToMuslOFlags","safeSetTimeout","setImmediateWrapped","safeRequestAnimationFrame","clearImmediateWrapped","registerPostMainLoop","registerPreMainLoop","getPromise","makePromise","idsToPromises","makePromiseCallback","Browser_asyncPrepareDataCounter","arraySum","addDays","getSocketFromFD","getSocketAddress","FS_mkdirTree","_setNetworkCallback","heapObjectForWebGLType","toTypedArrayIndex","webgl_enable_ANGLE_instanced_arrays","webgl_enable_OES_vertex_array_object","webgl_enable_WEBGL_draw_buffers","webgl_enable_WEBGL_multi_draw","webgl_enable_EXT_polygon_offset_clamp","webgl_enable_EXT_clip_control","webgl_enable_WEBGL_polygon_mode","emscriptenWebGLGet","computeUnpackAlignedImageSize","colorChannelsInGlTextureFormat","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","__glGetActiveAttribOrUniform","writeGLArray","registerWebGlEventCallback","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate","writeStringToMemory","writeAsciiToMemory","allocateUTF8","allocateUTF8OnStack","demangle","stackTrace","getNativeTypeSize","getFunctionArgsName","createJsInvokerSignature","PureVirtualError","registerInheritedInstance","unregisterInheritedInstance","getInheritedInstanceCount","getLiveInheritedInstances","enumReadValueFromPointer","setDelayFunction","validateThis","count_emval_handles"];qo.forEach(Ft);var Yo=["run","out","err","callMain","abort","wasmExports","HEAPF32","HEAPF64","HEAP8","HEAPU8","HEAP16","HEAPU16","HEAP32","HEAPU32","HEAP64","HEAPU64","writeStackCookie","checkStackCookie","INT53_MAX","INT53_MIN","bigintToI53Checked","stackSave","stackRestore","stackAlloc","createNamedFunction","ptrToString","getHeapMax","growMemory","ENV","ERRNO_CODES","strError","DNS","Protocols","Sockets","timers","warnOnce","readEmAsmArgsArray","getExecutableName","asyncLoad","alignMemory","mmapAlloc","wasmTable","wasmMemory","getUniqueRunDependency","noExitRuntime","addRunDependency","removeRunDependency","addOnPreRun","addOnPostRun","freeTableIndexes","functionsInTableMap","setValue","getValue","PATH","PATH_FS","UTF8Decoder","UTF8ArrayToString","UTF8ToString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","intArrayFromString","AsciiToString","UTF16Decoder","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","JSEvents","specialHTMLTargets","findCanvasEventTarget","currentFullscreenStrategy","restoreOldWindowedStyle","UNWIND_CACHE","ExitStatus","getEnvStrings","checkWasiClock","doReadv","doWritev","initRandomFill","randomFill","emSetImmediate","emClearImmediate_deps","emClearImmediate","promiseMap","getExceptionMessageCommon","getCppExceptionTag","getCppExceptionThrownObjectFromWebAssemblyException","Browser","requestFullscreen","requestFullScreen","setCanvasSize","getUserMedia","createContext","getPreloadedImageData__data","wget","MONTH_DAYS_REGULAR","MONTH_DAYS_LEAP","MONTH_DAYS_REGULAR_CUMULATIVE","MONTH_DAYS_LEAP_CUMULATIVE","isLeapYear","ydayFromDate","SYSCALLS","preloadPlugins","FS_createPreloadedFile","FS_preloadFile","FS_modeStringToFlags","FS_getMode","FS_stdin_getChar_buffer","FS_stdin_getChar","FS_unlink","FS_createPath","FS_createDevice","FS_readFile","FS","FS_root","FS_mounts","FS_devices","FS_streams","FS_nextInode","FS_nameTable","FS_currentPath","FS_initialized","FS_ignorePermissions","FS_filesystems","FS_syncFSRequests","FS_readFiles","FS_lookupPath","FS_getPath","FS_hashName","FS_hashAddNode","FS_hashRemoveNode","FS_lookupNode","FS_createNode","FS_destroyNode","FS_isRoot","FS_isMountpoint","FS_isFile","FS_isDir","FS_isLink","FS_isChrdev","FS_isBlkdev","FS_isFIFO","FS_isSocket","FS_flagsToPermissionString","FS_nodePermissions","FS_mayLookup","FS_mayCreate","FS_mayDelete","FS_mayOpen","FS_checkOpExists","FS_nextfd","FS_getStreamChecked","FS_getStream","FS_createStream","FS_closeStream","FS_dupStream","FS_doSetAttr","FS_chrdev_stream_ops","FS_major","FS_minor","FS_makedev","FS_registerDevice","FS_getDevice","FS_getMounts","FS_syncfs","FS_mount","FS_unmount","FS_lookup","FS_mknod","FS_statfs","FS_statfsStream","FS_statfsNode","FS_create","FS_mkdir","FS_mkdev","FS_symlink","FS_rename","FS_rmdir","FS_readdir","FS_readlink","FS_stat","FS_fstat","FS_lstat","FS_doChmod","FS_chmod","FS_lchmod","FS_fchmod","FS_doChown","FS_chown","FS_lchown","FS_fchown","FS_doTruncate","FS_truncate","FS_ftruncate","FS_utime","FS_open","FS_close","FS_isClosed","FS_llseek","FS_read","FS_write","FS_mmap","FS_msync","FS_ioctl","FS_writeFile","FS_cwd","FS_chdir","FS_createDefaultDirectories","FS_createDefaultDevices","FS_createSpecialDirectories","FS_createStandardStreams","FS_staticInit","FS_init","FS_quit","FS_findObject","FS_analyzePath","FS_createFile","FS_createDataFile","FS_forceLoadFile","FS_createLazyFile","FS_absolutePath","FS_createFolder","FS_createLink","FS_joinPath","FS_mmapAlloc","FS_standardizePath","MEMFS","TTY","PIPEFS","SOCKFS","tempFixedLengthArray","miniTempWebGLFloatBuffers","miniTempWebGLIntBuffers","GL","AL","GLUT","EGL","GLEW","IDBStore","SDL","SDL_gfx","print","printErr","jstoi_s","InternalError","BindingError","throwInternalError","throwBindingError","registeredTypes","awaitingDependencies","typeDependencies","tupleRegistrations","structRegistrations","sharedRegisterType","whenDependentTypesAreResolved","getTypeName","getFunctionName","heap32VectorToArray","requireRegisteredType","usesDestructorStack","checkArgCount","getRequiredArgCount","createJsInvoker","UnboundTypeError","EmValType","EmValOptionalType","throwUnboundTypeError","ensureOverloadTable","exposePublicSymbol","replacePublicSymbol","embindRepr","registeredInstances","getBasestPointer","getInheritedInstance","registeredPointers","registerType","integerReadValueFromPointer","floatReadValueFromPointer","assertIntegerRange","readPointer","runDestructors","craftInvokerFunction","embind__requireFunction","genericPointerToWireType","constNoSmartPtrRawPointerToWireType","nonConstNoSmartPtrRawPointerToWireType","init_RegisteredPointer","RegisteredPointer","RegisteredPointer_fromWireType","runDestructor","releaseClassHandle","finalizationRegistry","detachFinalizer_deps","detachFinalizer","attachFinalizer","makeClassHandle","init_ClassHandle","ClassHandle","throwInstanceAlreadyDeleted","deletionQueue","flushPendingDeletes","delayFunction","RegisteredClass","shallowCopyInternalPointer","downcastPointer","upcastPointer","char_0","char_9","makeLegalFunctionName","emval_freelist","emval_handles","emval_symbols","getStringOrSymbol","Emval","emval_returnValue","emval_lookupTypes","emval_methodCallers","emval_addMethodCaller"];Yo.forEach(hr),d.getExceptionMessage=Mr,d.incrementExceptionRefcount=zo,d.decrementExceptionRefcount=Go;function Xo(){bt("fetchSettings")}var sr=C("_malloc"),et=C("___getTypeName"),lr=C("_fflush"),H=C("_free"),ur=C("_emscripten_stack_get_end"),Ko=C("_emscripten_stack_get_base"),rt=C("_strerror"),tt=C("___trap"),nt=C("_emscripten_stack_init"),Jo=C("_emscripten_stack_get_free"),ot=C("__emscripten_stack_restore"),it=C("__emscripten_stack_alloc"),at=C("_emscripten_stack_get_current"),st=C("___cxa_decrement_exception_refcount"),lt=C("___cxa_increment_exception_refcount"),ut=C("___thrown_object_from_unwind_exception"),ct=C("___get_exception_message"),Qo=C("memory"),dt=C("___cpp_exception"),Zo=C("__indirect_function_table"),We=C("wasmMemory"),cr=C("wasmTable");function ei(e){f(e.malloc,"missing Wasm export: malloc"),sr=Y("malloc",1),f(e.__getTypeName,"missing Wasm export: __getTypeName"),et=Y("__getTypeName",1),f(e.fflush,"missing Wasm export: fflush"),lr=Y("fflush",1),f(e.free,"missing Wasm export: free"),H=Y("free",1),f(e.emscripten_stack_get_end,"missing Wasm export: emscripten_stack_get_end"),ur=e.emscripten_stack_get_end,f(e.emscripten_stack_get_base,"missing Wasm export: emscripten_stack_get_base"),Ko=e.emscripten_stack_get_base,f(e.strerror,"missing Wasm export: strerror"),rt=Y("strerror",1),f(e.__trap,"missing Wasm export: __trap"),tt=e.__trap,f(e.emscripten_stack_init,"missing Wasm export: emscripten_stack_init"),nt=e.emscripten_stack_init,f(e.emscripten_stack_get_free,"missing Wasm export: emscripten_stack_get_free"),Jo=e.emscripten_stack_get_free,f(e._emscripten_stack_restore,"missing Wasm export: _emscripten_stack_restore"),ot=e._emscripten_stack_restore,f(e._emscripten_stack_alloc,"missing Wasm export: _emscripten_stack_alloc"),it=e._emscripten_stack_alloc,f(e.emscripten_stack_get_current,"missing Wasm export: emscripten_stack_get_current"),at=e.emscripten_stack_get_current,f(e.__cxa_decrement_exception_refcount,"missing Wasm export: __cxa_decrement_exception_refcount"),st=Y("__cxa_decrement_exception_refcount",1),f(e.__cxa_increment_exception_refcount,"missing Wasm export: __cxa_increment_exception_refcount"),lt=Y("__cxa_increment_exception_refcount",1),f(e.__thrown_object_from_unwind_exception,"missing Wasm export: __thrown_object_from_unwind_exception"),ut=Y("__thrown_object_from_unwind_exception",1),f(e.__get_exception_message,"missing Wasm export: __get_exception_message"),ct=Y("__get_exception_message",3),f(e.memory,"missing Wasm export: memory"),Qo=We=e.memory,f(e.__cpp_exception,"missing Wasm export: __cpp_exception"),dt=e.__cpp_exception,f(e.__indirect_function_table,"missing Wasm export: __indirect_function_table"),Zo=cr=e.__indirect_function_table}var ft={__assert_fail:Lt,__syscall_fcntl64:Kt,__syscall_fstat64:Jt,__syscall_getcwd:Qt,__syscall_getdents64:Zt,__syscall_ioctl:en,__syscall_lstat64:rn,__syscall_newfstatat:tn,__syscall_openat:nn,__syscall_rmdir:on,__syscall_stat64:an,__syscall_unlinkat:sn,__throw_exception_with_stack_trace:dn,_abort_js:fn,_embind_register_bigint:mn,_embind_register_bool:_n,_embind_register_class:Nn,_embind_register_class_constructor:Wn,_embind_register_class_function:jn,_embind_register_emval:Vn,_embind_register_float:Gn,_embind_register_integer:qn,_embind_register_memory_view:Yn,_embind_register_std_string:Xn,_embind_register_std_wstring:to,_embind_register_void:no,_emval_create_invoker:uo,_emval_decref:tr,_emval_get_global:co,_emval_get_property:fo,_emval_incref:vo,_emval_invoke:Zr,_emval_invoke_i64:mo,_emval_new_array:_o,_emval_new_cstring:po,_emval_run_destructors:ho,_emval_typeof:go,_localtime_js:To,_tzset_js:ko,clock_time_get:Ro,emscripten_resize_heap:Mo,environ_get:xo,environ_sizes_get:Lo,fd_close:Uo,fd_read:Bo,fd_seek:jo,fd_write:Vo},vt;function ri(){nt(),wt()}function dr(){if(re>0){we=dr;return}if(ri(),Tt(),re>0){we=dr;return}function e(){f(!vt),vt=!0,d.calledRun=!0,!Ae&&(kt(),gr?.(d),d.onRuntimeInitialized?.(),Ce("onRuntimeInitialized"),f(!d._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),Pt())}d.setStatus?(d.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>d.setStatus(""),1),e()},1)):e(),ze()}function Ti(){var e=ee,r=R,t=!1;ee=R=n=>{t=!0};try{lr(0),["stdout","stderr"].forEach(n=>{var i=o.analyzePath("/dev/"+n);if(i){var a=i.object,s=a.rdev,l=X.ttys[s];l?.output?.length&&(t=!0)}})}catch{}ee=e,R=r,t&&le("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.")}var pe;pe=await It(),dr(),ae?O=d:O=new Promise((e,r)=>{gr=e,yr=r});for(let e of Object.keys(d))e in w||Object.defineProperty(w,e,{configurable:!0,get(){F(`Access to module property ('${e}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)}});return O}})();typeof pt=="object"&&typeof je=="object"?(je.exports=fr,je.exports.default=fr):typeof define=="function"&&define.amd&&define([],()=>fr)});var di={};li(di,{ACompiler:()=>vr});module.exports=ci(di);var gt=ui(ht()),vr=class A{instance;outputBuffer="";constructor(w){this.instance=w}static async create(){let w={stdout:""},O=await(0,gt.default)({print:q=>{w.stdout+=q+`
|
|
20
|
+
`}}),d=new O.ACompiler,U=new A(d);return Object.defineProperty(U,"outputBuffer",{get:()=>w.stdout,set:q=>{w.stdout=q}}),U}registerBuiltInLibrary(w,O,d=!0,U){this.instance.registerBuiltInLibrary(w,O,d,U)}compileAndRun(w,O){return this.instance.compileAndRun(w,O)}compile(w,O){return this.instance.compile(w,O)}run(){return this.instance.run()}hasError(){return this.instance.hasError()}refresh(){this.instance.refresh()}};0&&(module.exports={ACompiler});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var ti=Object.create;var vt=Object.defineProperty;var ni=Object.getOwnPropertyDescriptor;var oi=Object.getOwnPropertyNames;var ii=Object.getPrototypeOf,ai=Object.prototype.hasOwnProperty;var mt=(P=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(P,{get:(b,I)=>(typeof require<"u"?require:b)[I]}):P)(function(P){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+P+'" is not supported')});var si=(P,b)=>()=>(b||P((b={exports:{}}).exports,b),b.exports);var li=(P,b,I,d)=>{if(b&&typeof b=="object"||typeof b=="function")for(let U of oi(b))!ai.call(P,U)&&U!==I&&vt(P,U,{get:()=>b[U],enumerable:!(d=ni(b,U))||d.enumerable});return P};var ui=(P,b,I)=>(I=P!=null?ti(ii(P)):{},li(b||!P||!P.__esModule?vt(I,"default",{value:P,enumerable:!0}):I,P));var pt=si((_t,Be)=>{"use strict";var dr=(()=>{var P=globalThis.document?.currentScript?.src;return async function(b={}){var I;(function(){function e(l){l=l.split("-")[0];for(var u=l.split(".").slice(0,3);u.length<3;)u.push("00");return u=u.map((c,v,p)=>c.padStart(2,"0")),u.join("")}var r=l=>[l/1e4|0,(l/100|0)%100,l%100].join("."),t=2147483647,n=typeof process<"u"&&process?.versions?.node?e(process.versions.node):t;if(n<17e4)throw new Error(`This emscripten-generated code requires node v${r(17e4)} (detected v${r(n)})`);var i=typeof navigator<"u"&&navigator?.userAgent?.includes("Safari/")&&navigator.userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/)?e(navigator.userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/)[1]):t;if(i<150200)throw new Error(`This emscripten-generated code requires Safari v${r(150200)} (detected v${i})`);var a=typeof navigator<"u"&&navigator?.userAgent?.match(/Firefox\/(\d+(?:\.\d+)?)/)?parseFloat(navigator.userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/)[1]):t;if(a<100)throw new Error(`This emscripten-generated code requires Firefox v100 (detected v${a})`);var s=typeof navigator<"u"&&navigator?.userAgent?.match(/Chrome\/(\d+(?:\.\d+)?)/)?parseFloat(navigator.userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/)[1]):t;if(s<95)throw new Error(`This emscripten-generated code requires Chrome v95 (detected v${s})`)})();var d=b,U=!!globalThis.window,q=!!globalThis.WorkerGlobalScope,ie=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer",fr=!U&&!ie&&!q,vr=[],je="./this.program",yt=(e,r)=>{throw r};typeof __filename<"u"?P=__filename:q&&(P=self.location.href);var ke="";function Et(e){return d.locateFile?d.locateFile(e,ke):ke+e}var Pe,he;if(ie){if(!(globalThis.process?.versions?.node&&globalThis.process?.type!="renderer"))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?)");var He=mt("fs");ke=__dirname+"/",he=r=>{r=ye(r)?new URL(r):r;var t=He.readFileSync(r);return f(Buffer.isBuffer(t)),t},Pe=async(r,t=!0)=>{r=ye(r)?new URL(r):r;var n=He.readFileSync(r,t?void 0:"utf8");return f(t?Buffer.isBuffer(n):typeof n=="string"),n},process.argv.length>1&&(je=process.argv[1].replace(/\\/g,"/")),vr=process.argv.slice(2),yt=(r,t)=>{throw process.exitCode=r,t}}else if(!fr)if(U||q){try{ke=new URL(".",P).href}catch{}if(!(globalThis.window||globalThis.WorkerGlobalScope))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?)");q&&(he=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Pe=async e=>{if(ye(e))return new Promise((t,n)=>{var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=()=>{if(i.status==200||i.status==0&&i.response){t(i.response);return}n(i.status)},i.onerror=n,i.send(null)});var r=await fetch(e,{credentials:"same-origin"});if(r.ok)return r.arrayBuffer();throw new Error(r.status+" : "+r.url)}}else throw new Error("environment detection error");var ee=console.log.bind(console),R=console.error.bind(console),ci="IDBFS is no longer included by default; build with -lidbfs.js",di="PROXYFS is no longer included by default; build with -lproxyfs.js",fi="WORKERFS is no longer included by default; build with -lworkerfs.js",vi="FETCHFS is no longer included by default; build with -lfetchfs.js",mi="ICASEFS is no longer included by default; build with -licasefs.js",_i="JSFILEFS is no longer included by default; build with -ljsfilefs.js",pi="OPFS is no longer included by default; build with -lopfs.js",hi="NODEFS is no longer included by default; build with -lnodefs.js";f(!fr,"shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.");var ge;globalThis.WebAssembly||R("no native wasm support detected");var Ae=!1,gi;function f(e,r){e||F("Assertion failed"+(r?": "+r:""))}var ye=e=>e.startsWith("file://");function wt(){var e=lr();f((e&3)==0),e==0&&(e+=4),g[e>>2]=34821223,g[e+4>>2]=2310721022,g[0]=1668509029}function Ve(){if(!Ae){var e=lr();e==0&&(e+=4);var r=g[e>>2],t=g[e+4>>2];(r!=34821223||t!=2310721022)&&F(`Stack overflow! Stack cookie has been overwritten at ${se(e)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${se(t)} ${se(r)}`),g[0]!=1668509029&&F("Runtime error: The application has corrupted its heap memory area (address zero)!")}}var mr=!0;function yi(...e){!mr&&typeof mr<"u"||console.warn(...e)}(()=>{var e=new Int16Array(1),r=new Int8Array(e.buffer);e[0]=25459,(r[0]!==115||r[1]!==99)&&F("Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)")})();function Ce(e){Object.getOwnPropertyDescriptor(d,e)||Object.defineProperty(d,e,{configurable:!0,set(){F(`Attempt to set \`Module.${e}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`)}})}function C(e){return()=>f(!1,`call to '${e}' via reference taken before Wasm module initialization`)}function bt(e){Object.getOwnPropertyDescriptor(d,e)&&F(`\`Module.${e}\` was supplied but \`${e}\` not included in INCOMING_MODULE_JS_API`)}function St(e){return e==="FS_createPath"||e==="FS_createDataFile"||e==="FS_createPreloadedFile"||e==="FS_preloadFile"||e==="FS_unlink"||e==="addRunDependency"||e==="FS_createLazyFile"||e==="FS_createDevice"||e==="removeRunDependency"}function Ft(e){_r(e)}function _r(e){Object.getOwnPropertyDescriptor(d,e)||Object.defineProperty(d,e,{configurable:!0,get(){var r=`'${e}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;St(e)&&(r+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),F(r)}})}var pr,hr,x,j,V,Ee,S,g,De,Re,M,gr,ae=!1;function yr(){var e=We.buffer;x=new Int8Array(e),V=new Int16Array(e),j=new Uint8Array(e),Ee=new Uint16Array(e),S=new Int32Array(e),g=new Uint32Array(e),De=new Float32Array(e),Re=new Float64Array(e),M=new BigInt64Array(e),gr=new BigUint64Array(e)}f(globalThis.Int32Array&&globalThis.Float64Array&&Int32Array.prototype.subarray&&Int32Array.prototype.set,"JS engine does not provide full typed array support");function Tt(){if(d.preRun)for(typeof d.preRun=="function"&&(d.preRun=[d.preRun]);d.preRun.length;)Nt(d.preRun.shift());Ce("preRun"),Er(br)}function kt(){f(!ae),ae=!0,Ve(),!d.noFSInit&&!o.initialized&&o.init(),X.init(),pe.__wasm_call_ctors(),o.ignorePermissions=!1}function Pt(){if(Ve(),d.postRun)for(typeof d.postRun=="function"&&(d.postRun=[d.postRun]);d.postRun.length;)Mt(d.postRun.shift());Ce("postRun"),Er(wr)}function F(e){d.onAbort?.(e),e="Aborted("+e+")",R(e),Ae=!0,ae&&et();var r=new WebAssembly.RuntimeError(e);throw hr?.(r),r}function Y(e,r){return(...t)=>{f(ae,`native function \`${e}\` called before runtime initialization`);var n=pe[e];return f(n,`exported native function \`${e}\` not found`),f(t.length<=r,`native function \`${e}\` called with ${t.length} args but expects ${r}`),n(...t)}}var ze;function At(){return Et("autolang.wasm")}function Ct(e){if(e==ze&&ge)return new Uint8Array(ge);if(he)return he(e);throw"both async and sync fetching of the wasm failed"}async function Dt(e){if(!ge)try{var r=await Pe(e);return new Uint8Array(r)}catch{}return Ct(e)}async function Rt(e,r){try{var t=await Dt(e),n=await WebAssembly.instantiate(t,r);return n}catch(i){R(`failed to asynchronously prepare wasm: ${i}`),ye(e)&&R(`warning: Loading from a file URI (${e}) 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`),F(i)}}async function $t(e,r,t){if(!e&&!ye(r)&&!ie)try{var n=fetch(r,{credentials:"same-origin"}),i=await WebAssembly.instantiateStreaming(n,t);return i}catch(a){R(`wasm streaming compile failed: ${a}`),R("falling back to ArrayBuffer instantiation")}return Rt(r,t)}function Ot(){var e={env:ct,wasi_snapshot_preview1:ct};return e}async function It(){function e(s,l){return pe=s.exports,ei(pe),yr(),pe}var r=d;function t(s){return f(d===r,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),r=null,e(s.instance)}var n=Ot();if(d.instantiateWasm)return new Promise((s,l)=>{try{d.instantiateWasm(n,(u,c)=>{s(e(u,c))})}catch(u){R(`Module.instantiateWasm callback failed with error: ${u}`),l(u)}});ze??=At();var i=await $t(ge,ze,n),a=t(i);return a}class Ei{name="ExitStatus";constructor(r){this.message=`Program terminated with exit(${r})`,this.status=r}}var Er=e=>{for(;e.length>0;)e.shift()(d)},wr=[],Mt=e=>wr.push(e),br=[],Nt=e=>br.push(e);function wi(e,r="i8"){switch(r.endsWith("*")&&(r="*"),r){case"i1":return x[e];case"i8":return x[e];case"i16":return V[e>>1];case"i32":return S[e>>2];case"i64":return M[e>>3];case"float":return De[e>>2];case"double":return Re[e>>3];case"*":return g[e>>2];default:F(`invalid type for getValue: ${r}`)}}var xt=!0,se=e=>(f(typeof e=="number",`ptrToString expects a number, got ${typeof e}`),e>>>=0,"0x"+e.toString(16).padStart(8,"0"));function bi(e,r,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":x[e]=r;break;case"i8":x[e]=r;break;case"i16":V[e>>1]=r;break;case"i32":S[e>>2]=r;break;case"i64":M[e>>3]=BigInt(r);break;case"float":De[e>>2]=r;break;case"double":Re[e>>3]=r;break;case"*":g[e>>2]=r;break;default:F(`invalid type for setValue: ${t}`)}}var le=e=>{le.shown||={},le.shown[e]||(le.shown[e]=1,ie&&(e="warning: "+e),R(e))},Sr=globalThis.TextDecoder&&new TextDecoder,Fr=(e,r,t,n)=>{var i=r+t;if(n)return i;for(;e[r]&&!(r>=i);)++r;return r},ue=(e,r=0,t,n)=>{var i=Fr(e,r,t,n);if(i-r>16&&e.buffer&&Sr)return Sr.decode(e.subarray(r,i));for(var a="";r<i;){var s=e[r++];if(!(s&128)){a+=String.fromCharCode(s);continue}var l=e[r++]&63;if((s&224)==192){a+=String.fromCharCode((s&31)<<6|l);continue}var u=e[r++]&63;if((s&240)==224?s=(s&15)<<12|l<<6|u:((s&248)!=240&&le("Invalid UTF-8 leading byte "+se(s)+" encountered when deserializing a UTF-8 string in wasm memory to a JS string!"),s=(s&7)<<18|l<<12|u<<6|e[r++]&63),s<65536)a+=String.fromCharCode(s);else{var c=s-65536;a+=String.fromCharCode(55296|c>>10,56320|c&1023)}}return a},J=(e,r,t)=>(f(typeof e=="number",`UTF8ToString expects a number (got ${typeof e})`),e?ue(j,e,r,t):""),Lt=(e,r,t,n)=>F(`Assertion failed: ${J(e)}, at: `+[r?J(r):"unknown filename",t,n?J(n):"unknown function"]),$e=()=>{f(k.varargs!=null);var e=S[+k.varargs>>2];return k.varargs+=4,e},ce=$e,T={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,n=e.length-1;n>=0;n--){var i=e[n];i==="."?e.splice(n,1):i===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=T.isAbs(e),t=e.slice(-1)==="/";return e=T.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=T.splitPath(e),t=r[0],n=r[1];return!t&&!n?".":(n&&(n=n.slice(0,-1)),t+n)},basename:e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>T.normalize(e.join("/")),join2:(e,r)=>T.normalize(e+"/"+r)},Ut=()=>{if(ie){var e=mt("crypto");return r=>e.randomFillSync(r)}return r=>crypto.getRandomValues(r)},Tr=e=>{(Tr=Ut())(e)},de={resolve:(...e)=>{for(var r="",t=!1,n=e.length-1;n>=-1&&!t;n--){var i=n>=0?e[n]:o.cwd();if(typeof i!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";r=i+"/"+r,t=T.isAbs(i)}return r=T.normalizeArray(r.split("/").filter(a=>!!a),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=de.resolve(e).slice(1),r=de.resolve(r).slice(1);function t(c){for(var v=0;v<c.length&&c[v]==="";v++);for(var p=c.length-1;p>=0&&c[p]==="";p--);return v>p?[]:c.slice(v,p-v+1)}for(var n=t(e.split("/")),i=t(r.split("/")),a=Math.min(n.length,i.length),s=a,l=0;l<a;l++)if(n[l]!==i[l]){s=l;break}for(var u=[],l=s;l<n.length;l++)u.push("..");return u=u.concat(i.slice(s)),u.join("/")}},Ge=[],fe=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r},kr=(e,r,t,n)=>{if(f(typeof e=="string",`stringToUTF8Array expects a string (got ${typeof e})`),!(n>0))return 0;for(var i=t,a=t+n-1,s=0;s<e.length;++s){var l=e.codePointAt(s);if(l<=127){if(t>=a)break;r[t++]=l}else if(l<=2047){if(t+1>=a)break;r[t++]=192|l>>6,r[t++]=128|l&63}else if(l<=65535){if(t+2>=a)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63}else{if(t+3>=a)break;l>1114111&&le("Invalid Unicode code point "+se(l)+" 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|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63,s++}}return r[t]=0,t-i},qe=(e,r,t)=>{var n=t>0?t:fe(e)+1,i=new Array(n),a=kr(e,i,0,i.length);return r&&(i.length=a),i},Wt=()=>{if(!Ge.length){var e=null;if(ie){var r=256,t=Buffer.alloc(r),n=0,i=process.stdin.fd;try{n=He.readSync(i,t,0,r)}catch(a){if(a.toString().includes("EOF"))n=0;else throw a}n>0&&(e=t.slice(0,n).toString("utf-8"))}else globalThis.window?.prompt&&(e=window.prompt("Input: "),e!==null&&(e+=`
|
|
2
|
+
`));if(!e)return null;Ge=qe(e,!0)}return Ge.shift()},X={ttys:[],init(){},shutdown(){},register(e,r){X.ttys[e]={input:[],output:[],ops:r},o.registerDevice(e,X.stream_ops)},stream_ops:{open(e){var r=X.ttys[e.node.rdev];if(!r)throw new o.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,n,i){if(!e.tty||!e.tty.ops.get_char)throw new o.ErrnoError(60);for(var a=0,s=0;s<n;s++){var l;try{l=e.tty.ops.get_char(e.tty)}catch{throw new o.ErrnoError(29)}if(l===void 0&&a===0)throw new o.ErrnoError(6);if(l==null)break;a++,r[t+s]=l}return a&&(e.node.atime=Date.now()),a},write(e,r,t,n,i){if(!e.tty||!e.tty.ops.put_char)throw new o.ErrnoError(60);try{for(var a=0;a<n;a++)e.tty.ops.put_char(e.tty,r[t+a])}catch{throw new o.ErrnoError(29)}return n&&(e.node.mtime=e.node.ctime=Date.now()),a}},default_tty_ops:{get_char(e){return Wt()},put_char(e,r){r===null||r===10?(ee(ue(e.output)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output?.length>0&&(ee(ue(e.output)),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?(R(ue(e.output)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output?.length>0&&(R(ue(e.output)),e.output=[])}}},Pr=e=>{F("internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported")},E={ops_table:null,mount(e){return E.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(o.isBlkdev(t)||o.isFIFO(t))throw new o.ErrnoError(63);E.ops_table||={dir:{node:{getattr:E.node_ops.getattr,setattr:E.node_ops.setattr,lookup:E.node_ops.lookup,mknod:E.node_ops.mknod,rename:E.node_ops.rename,unlink:E.node_ops.unlink,rmdir:E.node_ops.rmdir,readdir:E.node_ops.readdir,symlink:E.node_ops.symlink},stream:{llseek:E.stream_ops.llseek}},file:{node:{getattr:E.node_ops.getattr,setattr:E.node_ops.setattr},stream:{llseek:E.stream_ops.llseek,read:E.stream_ops.read,write:E.stream_ops.write,mmap:E.stream_ops.mmap,msync:E.stream_ops.msync}},link:{node:{getattr:E.node_ops.getattr,setattr:E.node_ops.setattr,readlink:E.node_ops.readlink},stream:{}},chrdev:{node:{getattr:E.node_ops.getattr,setattr:E.node_ops.setattr},stream:o.chrdev_stream_ops}};var i=o.createNode(e,r,t,n);return o.isDir(i.mode)?(i.node_ops=E.ops_table.dir.node,i.stream_ops=E.ops_table.dir.stream,i.contents={}):o.isFile(i.mode)?(i.node_ops=E.ops_table.file.node,i.stream_ops=E.ops_table.file.stream,i.usedBytes=0,i.contents=null):o.isLink(i.mode)?(i.node_ops=E.ops_table.link.node,i.stream_ops=E.ops_table.link.stream):o.isChrdev(i.mode)&&(i.node_ops=E.ops_table.chrdev.node,i.stream_ops=E.ops_table.chrdev.stream),i.atime=i.mtime=i.ctime=Date.now(),e&&(e.contents[r]=i,e.atime=e.mtime=e.ctime=i.atime),i},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 n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t!=0&&(r=Math.max(r,256));var i=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(i.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=o.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,o.isDir(e.mode)?r.size=4096:o.isFile(e.mode)?r.size=e.usedBytes:o.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.atime),r.mtime=new Date(e.mtime),r.ctime=new Date(e.ctime),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){for(let t of["mode","atime","mtime","ctime"])r[t]!=null&&(e[t]=r[t]);r.size!==void 0&&E.resizeFileStorage(e,r.size)},lookup(e,r){throw new o.ErrnoError(44)},mknod(e,r,t,n){return E.createNode(e,r,t,n)},rename(e,r,t){var n;try{n=o.lookupNode(r,t)}catch{}if(n){if(o.isDir(e.mode))for(var i in n.contents)throw new o.ErrnoError(55);o.hashRemoveNode(n)}delete e.parent.contents[e.name],r.contents[t]=e,e.name=t,r.ctime=r.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,r){delete e.contents[r],e.ctime=e.mtime=Date.now()},rmdir(e,r){var t=o.lookupNode(e,r);for(var n in t.contents)throw new o.ErrnoError(55);delete e.contents[r],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,r,t){var n=E.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!o.isLink(e.mode))throw new o.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,i){var a=e.node.contents;if(i>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-i,n);if(f(s>=0),s>8&&a.subarray)r.set(a.subarray(i,i+s),t);else for(var l=0;l<s;l++)r[t+l]=a[i+l];return s},write(e,r,t,n,i,a){if(f(!(r instanceof ArrayBuffer)),r.buffer===x.buffer&&(a=!1),!n)return 0;var s=e.node;if(s.mtime=s.ctime=Date.now(),r.subarray&&(!s.contents||s.contents.subarray)){if(a)return f(i===0,"canOwn must imply no weird position inside the file"),s.contents=r.subarray(t,t+n),s.usedBytes=n,n;if(s.usedBytes===0&&i===0)return s.contents=r.slice(t,t+n),s.usedBytes=n,n;if(i+n<=s.usedBytes)return s.contents.set(r.subarray(t,t+n),i),n}if(E.expandFileStorage(s,i+n),s.contents.subarray&&r.subarray)s.contents.set(r.subarray(t,t+n),i);else for(var l=0;l<n;l++)s.contents[i+l]=r[t+l];return s.usedBytes=Math.max(s.usedBytes,i+n),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&o.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new o.ErrnoError(28);return n},mmap(e,r,t,n,i){if(!o.isFile(e.node.mode))throw new o.ErrnoError(43);var a,s,l=e.node.contents;if(!(i&2)&&l&&l.buffer===x.buffer)s=!1,a=l.byteOffset;else{if(s=!0,a=Pr(r),!a)throw new o.ErrnoError(48);l&&((t>0||t+r<l.length)&&(l.subarray?l=l.subarray(t,t+r):l=Array.prototype.slice.call(l,t,t+r)),x.set(l,a))}return{ptr:a,allocated:s}},msync(e,r,t,n,i){return E.stream_ops.write(e,r,0,n,t,!1),0}}},Bt=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},Ye=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},jt=e=>J(Zr(e)),Ar={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},Ht=async e=>{var r=await Pe(e);return f(r,`Loading data file "${e}" failed (no arrayBuffer).`),new Uint8Array(r)},Vt=(...e)=>o.createDataFile(...e),zt=e=>{for(var r=e;;){if(!ve[e])return e;e=r+Math.random()}},re=0,we=null,ve={},Q=null,Gt=e=>{if(re--,d.monitorRunDependencies?.(re),f(e,"removeRunDependency requires an ID"),f(ve[e]),delete ve[e],re==0&&(Q!==null&&(clearInterval(Q),Q=null),we)){var r=we;we=null,r()}},qt=e=>{re++,d.monitorRunDependencies?.(re),f(e,"addRunDependency requires an ID"),f(!ve[e]),ve[e]=1,Q===null&&globalThis.setInterval&&(Q=setInterval(()=>{if(Ae){clearInterval(Q),Q=null;return}var r=!1;for(var t in ve)r||(r=!0,R("still waiting on run dependencies:")),R(`dependency: ${t}`);r&&R("(end of list)")},1e4),Q.unref?.())},Cr=[],Yt=async(e,r)=>{typeof Browser<"u"&&Browser.init();for(var t of Cr)if(t.canHandle(r))return f(t.handle.constructor.name==="AsyncFunction","Filesystem plugin handlers must be async functions (See #24914)"),t.handle(e,r);return e},Dr=async(e,r,t,n,i,a,s,l)=>{var u=r?de.resolve(T.join2(e,r)):e,c=zt(`cp ${u}`);qt(c);try{var v=t;typeof t=="string"&&(v=await Ht(t)),v=await Yt(v,u),l?.(),a||Vt(e,r,v,n,i,s)}finally{Gt(c)}},Xt=(e,r,t,n,i,a,s,l,u,c)=>{Dr(e,r,t,n,i,l,u,c).then(a).catch(s)},o={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,filesystems:null,syncFSRequests:0,readFiles:{},ErrnoError:class extends Error{name="ErrnoError";constructor(e){super(ae?jt(e):""),this.errno=e;for(var r in Ar)if(Ar[r]===e){this.code=r;break}}},FSStream:class{shared={};get object(){return this.node}set object(e){this.node=e}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{node_ops={};stream_ops={};readMode=365;writeMode=146;mounted=null;constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.id=o.nextInode++,this.name=r,this.mode=t,this.rdev=n,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return o.isDir(this.mode)}get isDevice(){return o.isChrdev(this.mode)}},lookupPath(e,r={}){if(!e)throw new o.ErrnoError(44);r.follow_mount??=!0,T.isAbs(e)||(e=o.cwd()+"/"+e);e:for(var t=0;t<40;t++){for(var n=e.split("/").filter(c=>!!c),i=o.root,a="/",s=0;s<n.length;s++){var l=s===n.length-1;if(l&&r.parent)break;if(n[s]!=="."){if(n[s]===".."){if(a=T.dirname(a),o.isRoot(i)){e=a+"/"+n.slice(s+1).join("/"),t--;continue e}else i=i.parent;continue}a=T.join2(a,n[s]);try{i=o.lookupNode(i,n[s])}catch(c){if(c?.errno===44&&l&&r.noent_okay)return{path:a};throw c}if(o.isMountpoint(i)&&(!l||r.follow_mount)&&(i=i.mounted.root),o.isLink(i.mode)&&(!l||r.follow)){if(!i.node_ops.readlink)throw new o.ErrnoError(52);var u=i.node_ops.readlink(i);T.isAbs(u)||(u=T.dirname(a)+"/"+u),e=u+"/"+n.slice(s+1).join("/");continue e}}}return{path:a,node:i}}throw new o.ErrnoError(32)},getPath(e){for(var r;;){if(o.isRoot(e)){var t=e.mount.mountpoint;return r?t[t.length-1]!=="/"?`${t}/${r}`:t+r:t}r=r?`${e.name}/${r}`:e.name,e=e.parent}},hashName(e,r){for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return(e+t>>>0)%o.nameTable.length},hashAddNode(e){var r=o.hashName(e.parent.id,e.name);e.name_next=o.nameTable[r],o.nameTable[r]=e},hashRemoveNode(e){var r=o.hashName(e.parent.id,e.name);if(o.nameTable[r]===e)o.nameTable[r]=e.name_next;else for(var t=o.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode(e,r){var t=o.mayLookup(e);if(t)throw new o.ErrnoError(t);for(var n=o.hashName(e.id,r),i=o.nameTable[n];i;i=i.name_next){var a=i.name;if(i.parent.id===e.id&&a===r)return i}return o.lookup(e,r)},createNode(e,r,t,n){f(typeof e=="object");var i=new o.FSNode(e,r,t,n);return o.hashAddNode(i),i},destroyNode(e){o.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 o.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!o.isDir(e.mode))return 54;var r=o.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){if(!o.isDir(e.mode))return 54;try{var t=o.lookupNode(e,r);return 20}catch{}return o.nodePermissions(e,"wx")},mayDelete(e,r,t){var n;try{n=o.lookupNode(e,r)}catch(a){return a.errno}var i=o.nodePermissions(e,"wx");if(i)return i;if(t){if(!o.isDir(n.mode))return 54;if(o.isRoot(n)||o.getPath(n)===o.cwd())return 10}else if(o.isDir(n.mode))return 31;return 0},mayOpen(e,r){return e?o.isLink(e.mode)?32:o.isDir(e.mode)&&(o.flagsToPermissionString(r)!=="r"||r&576)?31:o.nodePermissions(e,o.flagsToPermissionString(r)):44},checkOpExists(e,r){if(!e)throw new o.ErrnoError(r);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=o.MAX_OPEN_FDS;e++)if(!o.streams[e])return e;throw new o.ErrnoError(33)},getStreamChecked(e){var r=o.getStream(e);if(!r)throw new o.ErrnoError(8);return r},getStream:e=>o.streams[e],createStream(e,r=-1){return f(r>=-1),e=Object.assign(new o.FSStream,e),r==-1&&(r=o.nextfd()),e.fd=r,o.streams[r]=e,e},closeStream(e){o.streams[e]=null},dupStream(e,r=-1){var t=o.createStream(e,r);return t.stream_ops?.dup?.(t),t},doSetAttr(e,r,t){var n=e?.stream_ops.setattr,i=n?e:r;n??=r.node_ops.setattr,o.checkOpExists(n,63),n(i,t)},chrdev_stream_ops:{open(e){var r=o.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new o.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice(e,r){o.devices[e]={stream_ops:r}},getDevice:e=>o.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push(...n.mounts)}return r},syncfs(e,r){typeof e=="function"&&(r=e,e=!1),o.syncFSRequests++,o.syncFSRequests>1&&R(`warning: ${o.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=o.getMounts(o.root.mount),n=0;function i(s){return f(o.syncFSRequests>0),o.syncFSRequests--,r(s)}function a(s){if(s)return a.errored?void 0:(a.errored=!0,i(s));++n>=t.length&&i(null)}t.forEach(s=>{if(!s.type.syncfs)return a(null);s.type.syncfs(s,e,a)})},mount(e,r,t){if(typeof e=="string")throw e;var n=t==="/",i=!t,a;if(n&&o.root)throw new o.ErrnoError(10);if(!n&&!i){var s=o.lookupPath(t,{follow_mount:!1});if(t=s.path,a=s.node,o.isMountpoint(a))throw new o.ErrnoError(10);if(!o.isDir(a.mode))throw new o.ErrnoError(54)}var l={type:e,opts:r,mountpoint:t,mounts:[]},u=e.mount(l);return u.mount=l,l.root=u,n?o.root=u:a&&(a.mounted=l,a.mount&&a.mount.mounts.push(l)),u},unmount(e){var r=o.lookupPath(e,{follow_mount:!1});if(!o.isMountpoint(r.node))throw new o.ErrnoError(28);var t=r.node,n=t.mounted,i=o.getMounts(n);Object.keys(o.nameTable).forEach(s=>{for(var l=o.nameTable[s];l;){var u=l.name_next;i.includes(l.mount)&&o.destroyNode(l),l=u}}),t.mounted=null;var a=t.mount.mounts.indexOf(n);f(a!==-1),t.mount.mounts.splice(a,1)},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=o.lookupPath(e,{parent:!0}),i=n.node,a=T.basename(e);if(!a)throw new o.ErrnoError(28);if(a==="."||a==="..")throw new o.ErrnoError(20);var s=o.mayCreate(i,a);if(s)throw new o.ErrnoError(s);if(!i.node_ops.mknod)throw new o.ErrnoError(63);return i.node_ops.mknod(i,a,r,t)},statfs(e){return o.statfsNode(o.lookupPath(e,{follow:!0}).node)},statfsStream(e){return o.statfsNode(e.node)},statfsNode(e){var r={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:o.nextInode,ffree:o.nextInode-1,fsid:42,flags:2,namelen:255};return e.node_ops.statfs&&Object.assign(r,e.node_ops.statfs(e.mount.opts.root)),r},create(e,r=438){return r&=4095,r|=32768,o.mknod(e,r,0)},mkdir(e,r=511){return r&=1023,r|=16384,o.mknod(e,r,0)},mkdirTree(e,r){var t=e.split("/"),n="";for(var i of t)if(i){(n||T.isAbs(e))&&(n+="/"),n+=i;try{o.mkdir(n,r)}catch(a){if(a.errno!=20)throw a}}},mkdev(e,r,t){return typeof t>"u"&&(t=r,r=438),r|=8192,o.mknod(e,r,t)},symlink(e,r){if(!de.resolve(e))throw new o.ErrnoError(44);var t=o.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new o.ErrnoError(44);var i=T.basename(r),a=o.mayCreate(n,i);if(a)throw new o.ErrnoError(a);if(!n.node_ops.symlink)throw new o.ErrnoError(63);return n.node_ops.symlink(n,i,e)},rename(e,r){var t=T.dirname(e),n=T.dirname(r),i=T.basename(e),a=T.basename(r),s,l,u;if(s=o.lookupPath(e,{parent:!0}),l=s.node,s=o.lookupPath(r,{parent:!0}),u=s.node,!l||!u)throw new o.ErrnoError(44);if(l.mount!==u.mount)throw new o.ErrnoError(75);var c=o.lookupNode(l,i),v=de.relative(e,n);if(v.charAt(0)!==".")throw new o.ErrnoError(28);if(v=de.relative(r,t),v.charAt(0)!==".")throw new o.ErrnoError(55);var p;try{p=o.lookupNode(u,a)}catch{}if(c!==p){var h=o.isDir(c.mode),m=o.mayDelete(l,i,h);if(m)throw new o.ErrnoError(m);if(m=p?o.mayDelete(u,a,h):o.mayCreate(u,a),m)throw new o.ErrnoError(m);if(!l.node_ops.rename)throw new o.ErrnoError(63);if(o.isMountpoint(c)||p&&o.isMountpoint(p))throw new o.ErrnoError(10);if(u!==l&&(m=o.nodePermissions(l,"w"),m))throw new o.ErrnoError(m);o.hashRemoveNode(c);try{l.node_ops.rename(c,u,a),c.parent=u}catch(_){throw _}finally{o.hashAddNode(c)}}},rmdir(e){var r=o.lookupPath(e,{parent:!0}),t=r.node,n=T.basename(e),i=o.lookupNode(t,n),a=o.mayDelete(t,n,!0);if(a)throw new o.ErrnoError(a);if(!t.node_ops.rmdir)throw new o.ErrnoError(63);if(o.isMountpoint(i))throw new o.ErrnoError(10);t.node_ops.rmdir(t,n),o.destroyNode(i)},readdir(e){var r=o.lookupPath(e,{follow:!0}),t=r.node,n=o.checkOpExists(t.node_ops.readdir,54);return n(t)},unlink(e){var r=o.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new o.ErrnoError(44);var n=T.basename(e),i=o.lookupNode(t,n),a=o.mayDelete(t,n,!1);if(a)throw new o.ErrnoError(a);if(!t.node_ops.unlink)throw new o.ErrnoError(63);if(o.isMountpoint(i))throw new o.ErrnoError(10);t.node_ops.unlink(t,n),o.destroyNode(i)},readlink(e){var r=o.lookupPath(e),t=r.node;if(!t)throw new o.ErrnoError(44);if(!t.node_ops.readlink)throw new o.ErrnoError(28);return t.node_ops.readlink(t)},stat(e,r){var t=o.lookupPath(e,{follow:!r}),n=t.node,i=o.checkOpExists(n.node_ops.getattr,63);return i(n)},fstat(e){var r=o.getStreamChecked(e),t=r.node,n=r.stream_ops.getattr,i=n?r:t;return n??=t.node_ops.getattr,o.checkOpExists(n,63),n(i)},lstat(e){return o.stat(e,!0)},doChmod(e,r,t,n){o.doSetAttr(e,r,{mode:t&4095|r.mode&-4096,ctime:Date.now(),dontFollow:n})},chmod(e,r,t){var n;if(typeof e=="string"){var i=o.lookupPath(e,{follow:!t});n=i.node}else n=e;o.doChmod(null,n,r,t)},lchmod(e,r){o.chmod(e,r,!0)},fchmod(e,r){var t=o.getStreamChecked(e);o.doChmod(t,t.node,r,!1)},doChown(e,r,t){o.doSetAttr(e,r,{timestamp:Date.now(),dontFollow:t})},chown(e,r,t,n){var i;if(typeof e=="string"){var a=o.lookupPath(e,{follow:!n});i=a.node}else i=e;o.doChown(null,i,n)},lchown(e,r,t){o.chown(e,r,t,!0)},fchown(e,r,t){var n=o.getStreamChecked(e);o.doChown(n,n.node,!1)},doTruncate(e,r,t){if(o.isDir(r.mode))throw new o.ErrnoError(31);if(!o.isFile(r.mode))throw new o.ErrnoError(28);var n=o.nodePermissions(r,"w");if(n)throw new o.ErrnoError(n);o.doSetAttr(e,r,{size:t,timestamp:Date.now()})},truncate(e,r){if(r<0)throw new o.ErrnoError(28);var t;if(typeof e=="string"){var n=o.lookupPath(e,{follow:!0});t=n.node}else t=e;o.doTruncate(null,t,r)},ftruncate(e,r){var t=o.getStreamChecked(e);if(r<0||(t.flags&2097155)===0)throw new o.ErrnoError(28);o.doTruncate(t,t.node,r)},utime(e,r,t){var n=o.lookupPath(e,{follow:!0}),i=n.node,a=o.checkOpExists(i.node_ops.setattr,63);a(i,{atime:r,mtime:t})},open(e,r,t=438){if(e==="")throw new o.ErrnoError(44);r=typeof r=="string"?Bt(r):r,r&64?t=t&4095|32768:t=0;var n,i;if(typeof e=="object")n=e;else{i=e.endsWith("/");var a=o.lookupPath(e,{follow:!(r&131072),noent_okay:!0});n=a.node,e=a.path}var s=!1;if(r&64)if(n){if(r&128)throw new o.ErrnoError(20)}else{if(i)throw new o.ErrnoError(31);n=o.mknod(e,t|511,0),s=!0}if(!n)throw new o.ErrnoError(44);if(o.isChrdev(n.mode)&&(r&=-513),r&65536&&!o.isDir(n.mode))throw new o.ErrnoError(54);if(!s){var l=o.mayOpen(n,r);if(l)throw new o.ErrnoError(l)}r&512&&!s&&o.truncate(n,0),r&=-131713;var u=o.createStream({node:n,path:o.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return u.stream_ops.open&&u.stream_ops.open(u),s&&o.chmod(n,t&511),d.logReadFiles&&!(r&1)&&(e in o.readFiles||(o.readFiles[e]=1)),u},close(e){if(o.isClosed(e))throw new o.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{o.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,r,t){if(o.isClosed(e))throw new o.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new o.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new o.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,n,i){if(f(t>=0),n<0||i<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if((e.flags&2097155)===1)throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.read)throw new o.ErrnoError(28);var a=typeof i<"u";if(!a)i=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var s=e.stream_ops.read(e,r,t,n,i);return a||(e.position+=s),s},write(e,r,t,n,i,a){if(f(t>=0),n<0||i<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if((e.flags&2097155)===0)throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.write)throw new o.ErrnoError(28);e.seekable&&e.flags&1024&&o.llseek(e,0,2);var s=typeof i<"u";if(!s)i=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var l=e.stream_ops.write(e,r,t,n,i,a);return s||(e.position+=l),l},mmap(e,r,t,n,i){if((n&2)!==0&&(i&2)===0&&(e.flags&2097155)!==2)throw new o.ErrnoError(2);if((e.flags&2097155)===1)throw new o.ErrnoError(2);if(!e.stream_ops.mmap)throw new o.ErrnoError(43);if(!r)throw new o.ErrnoError(28);return e.stream_ops.mmap(e,r,t,n,i)},msync(e,r,t,n,i){return f(t>=0),e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,i):0},ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new o.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary"&&F(`Invalid encoding type "${r.encoding}"`);var t=o.open(e,r.flags),n=o.stat(e),i=n.size,a=new Uint8Array(i);return o.read(t,a,0,i,0),r.encoding==="utf8"&&(a=ue(a)),o.close(t),a},writeFile(e,r,t={}){t.flags=t.flags||577;var n=o.open(e,t.flags,t.mode);typeof r=="string"&&(r=new Uint8Array(qe(r,!0))),ArrayBuffer.isView(r)?o.write(n,r,0,r.byteLength,void 0,t.canOwn):F("Unsupported data type"),o.close(n)},cwd:()=>o.currentPath,chdir(e){var r=o.lookupPath(e,{follow:!0});if(r.node===null)throw new o.ErrnoError(44);if(!o.isDir(r.node.mode))throw new o.ErrnoError(54);var t=o.nodePermissions(r.node,"x");if(t)throw new o.ErrnoError(t);o.currentPath=r.path},createDefaultDirectories(){o.mkdir("/tmp"),o.mkdir("/home"),o.mkdir("/home/web_user")},createDefaultDevices(){o.mkdir("/dev"),o.registerDevice(o.makedev(1,3),{read:()=>0,write:(n,i,a,s,l)=>s,llseek:()=>0}),o.mkdev("/dev/null",o.makedev(1,3)),X.register(o.makedev(5,0),X.default_tty_ops),X.register(o.makedev(6,0),X.default_tty1_ops),o.mkdev("/dev/tty",o.makedev(5,0)),o.mkdev("/dev/tty1",o.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(Tr(e),r=e.byteLength),e[--r]);o.createDevice("/dev","random",t),o.createDevice("/dev","urandom",t),o.mkdir("/dev/shm"),o.mkdir("/dev/shm/tmp")},createSpecialDirectories(){o.mkdir("/proc");var e=o.mkdir("/proc/self");o.mkdir("/proc/self/fd"),o.mount({mount(){var r=o.createNode(e,"fd",16895,73);return r.stream_ops={llseek:E.stream_ops.llseek},r.node_ops={lookup(t,n){var i=+n,a=o.getStreamChecked(i),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>a.path},id:i+1};return s.parent=s,s},readdir(){return Array.from(o.streams.entries()).filter(([t,n])=>n).map(([t,n])=>t.toString())}},r}},{},"/proc/self/fd")},createStandardStreams(e,r,t){e?o.createDevice("/dev","stdin",e):o.symlink("/dev/tty","/dev/stdin"),r?o.createDevice("/dev","stdout",null,r):o.symlink("/dev/tty","/dev/stdout"),t?o.createDevice("/dev","stderr",null,t):o.symlink("/dev/tty1","/dev/stderr");var n=o.open("/dev/stdin",0),i=o.open("/dev/stdout",1),a=o.open("/dev/stderr",1);f(n.fd===0,`invalid handle for stdin (${n.fd})`),f(i.fd===1,`invalid handle for stdout (${i.fd})`),f(a.fd===2,`invalid handle for stderr (${a.fd})`)},staticInit(){o.nameTable=new Array(4096),o.mount(E,{},"/"),o.createDefaultDirectories(),o.createDefaultDevices(),o.createSpecialDirectories(),o.filesystems={MEMFS:E}},init(e,r,t){f(!o.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)"),o.initialized=!0,e??=d.stdin,r??=d.stdout,t??=d.stderr,o.createStandardStreams(e,r,t)},quit(){o.initialized=!1,sr(0);for(var e of o.streams)e&&o.close(e)},findObject(e,r){var t=o.analyzePath(e,r);return t.exists?t.object:null},analyzePath(e,r){try{var t=o.lookupPath(e,{follow:!r});e=t.path}catch{}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=o.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=T.basename(e),t=o.lookupPath(e,{follow:!r}),n.exists=!0,n.path=t.path,n.object=t.node,n.name=t.node.name,n.isRoot=t.path==="/"}catch(i){n.error=i.errno}return n},createPath(e,r,t,n){e=typeof e=="string"?e:o.getPath(e);for(var i=r.split("/").reverse();i.length;){var a=i.pop();if(a){var s=T.join2(e,a);try{o.mkdir(s)}catch(l){if(l.errno!=20)throw l}e=s}}return s},createFile(e,r,t,n,i){var a=T.join2(typeof e=="string"?e:o.getPath(e),r),s=Ye(n,i);return o.create(a,s)},createDataFile(e,r,t,n,i,a){var s=r;e&&(e=typeof e=="string"?e:o.getPath(e),s=r?T.join2(e,r):e);var l=Ye(n,i),u=o.create(s,l);if(t){if(typeof t=="string"){for(var c=new Array(t.length),v=0,p=t.length;v<p;++v)c[v]=t.charCodeAt(v);t=c}o.chmod(u,l|146);var h=o.open(u,577);o.write(h,t,0,t.length,0,a),o.close(h),o.chmod(u,l)}},createDevice(e,r,t,n){var i=T.join2(typeof e=="string"?e:o.getPath(e),r),a=Ye(!!t,!!n);o.createDevice.major??=64;var s=o.makedev(o.createDevice.major++,0);return o.registerDevice(s,{open(l){l.seekable=!1},close(l){n?.buffer?.length&&n(10)},read(l,u,c,v,p){for(var h=0,m=0;m<v;m++){var _;try{_=t()}catch{throw new o.ErrnoError(29)}if(_===void 0&&h===0)throw new o.ErrnoError(6);if(_==null)break;h++,u[c+m]=_}return h&&(l.node.atime=Date.now()),h},write(l,u,c,v,p){for(var h=0;h<v;h++)try{n(u[c+h])}catch{throw new o.ErrnoError(29)}return v&&(l.node.mtime=l.node.ctime=Date.now()),h}}),o.mkdev(i,a,s)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)F("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");else try{e.contents=he(e.url)}catch{throw new o.ErrnoError(29)}},createLazyFile(e,r,t,n,i){class a{lengthKnown=!1;chunks=[];get(m){if(!(m>this.length-1||m<0)){var _=m%this.chunkSize,y=m/this.chunkSize|0;return this.getter(y)[_]}}setDataGetter(m){this.getter=m}cacheLength(){var m=new XMLHttpRequest;m.open("HEAD",t,!1),m.send(null),m.status>=200&&m.status<300||m.status===304||F("Couldn't load "+t+". Status: "+m.status);var _=Number(m.getResponseHeader("Content-length")),y,O=(y=m.getResponseHeader("Accept-Ranges"))&&y==="bytes",A=(y=m.getResponseHeader("Content-Encoding"))&&y==="gzip",N=1024*1024;O||(N=_);var D=(B,K)=>{B>K&&F("invalid range ("+B+", "+K+") or no bytes requested!"),K>_-1&&F("only "+_+" bytes available! programmer error!");var $=new XMLHttpRequest;return $.open("GET",t,!1),_!==N&&$.setRequestHeader("Range","bytes="+B+"-"+K),$.responseType="arraybuffer",$.overrideMimeType&&$.overrideMimeType("text/plain; charset=x-user-defined"),$.send(null),$.status>=200&&$.status<300||$.status===304||F("Couldn't load "+t+". Status: "+$.status),$.response!==void 0?new Uint8Array($.response||[]):qe($.responseText||"",!0)},oe=this;oe.setDataGetter(B=>{var K=B*N,$=(B+1)*N-1;return $=Math.min($,_-1),typeof oe.chunks[B]>"u"&&(oe.chunks[B]=D(K,$)),typeof oe.chunks[B]>"u"&&F("doXHR failed!"),oe.chunks[B]}),(A||!_)&&(N=_=1,_=this.getter(0).length,N=_,ee("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=_,this._chunkSize=N,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(globalThis.XMLHttpRequest){q||F("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var s=new a,l={isDevice:!1,contents:s}}else var l={isDevice:!1,url:t};var u=o.createFile(e,r,l,n,i);l.contents?u.contents=l.contents:l.url&&(u.contents=null,u.url=l.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var c={},v=Object.keys(u.stream_ops);v.forEach(h=>{var m=u.stream_ops[h];c[h]=(..._)=>(o.forceLoadFile(u),m(..._))});function p(h,m,_,y,O){var A=h.node.contents;if(O>=A.length)return 0;var N=Math.min(A.length-O,y);if(f(N>=0),A.slice)for(var D=0;D<N;D++)m[_+D]=A[O+D];else for(var D=0;D<N;D++)m[_+D]=A.get(O+D);return N}return c.read=(h,m,_,y,O)=>(o.forceLoadFile(u),p(h,m,_,y,O)),c.mmap=(h,m,_,y,O)=>{o.forceLoadFile(u);var A=Pr(m);if(!A)throw new o.ErrnoError(48);return p(h,x,A,m,_),{ptr:A,allocated:!0}},u.stream_ops=c,u},absolutePath(){F("FS.absolutePath has been removed; use PATH_FS.resolve instead")},createFolder(){F("FS.createFolder has been removed; use FS.mkdir instead")},createLink(){F("FS.createLink has been removed; use FS.symlink instead")},joinPath(){F("FS.joinPath has been removed; use PATH.join instead")},mmapAlloc(){F("FS.mmapAlloc has been replaced by the top level function mmapAlloc")},standardizePath(){F("FS.standardizePath has been removed; use PATH.normalize instead")}},k={DEFAULT_POLLMASK:5,calculateAt(e,r,t){if(T.isAbs(r))return r;var n;if(e===-100)n=o.cwd();else{var i=k.getStreamFromFD(e);n=i.path}if(r.length==0){if(!t)throw new o.ErrnoError(44);return n}return n+"/"+r},writeStat(e,r){g[e>>2]=r.dev,g[e+4>>2]=r.mode,g[e+8>>2]=r.nlink,g[e+12>>2]=r.uid,g[e+16>>2]=r.gid,g[e+20>>2]=r.rdev,M[e+24>>3]=BigInt(r.size),S[e+32>>2]=4096,S[e+36>>2]=r.blocks;var t=r.atime.getTime(),n=r.mtime.getTime(),i=r.ctime.getTime();return M[e+40>>3]=BigInt(Math.floor(t/1e3)),g[e+48>>2]=t%1e3*1e3*1e3,M[e+56>>3]=BigInt(Math.floor(n/1e3)),g[e+64>>2]=n%1e3*1e3*1e3,M[e+72>>3]=BigInt(Math.floor(i/1e3)),g[e+80>>2]=i%1e3*1e3*1e3,M[e+88>>3]=BigInt(r.ino),0},writeStatFs(e,r){g[e+4>>2]=r.bsize,g[e+60>>2]=r.bsize,M[e+8>>3]=BigInt(r.blocks),M[e+16>>3]=BigInt(r.bfree),M[e+24>>3]=BigInt(r.bavail),M[e+32>>3]=BigInt(r.files),M[e+40>>3]=BigInt(r.ffree),g[e+48>>2]=r.fsid,g[e+64>>2]=r.flags,g[e+56>>2]=r.namelen},doMsync(e,r,t,n,i){if(!o.isFile(r.node.mode))throw new o.ErrnoError(43);if(n&2)return 0;var a=j.slice(e,e+t);o.msync(r,a,i,t,n)},getStreamFromFD(e){var r=o.getStreamChecked(e);return r},varargs:void 0,getStr(e){var r=J(e);return r}};function Kt(e,r,t){k.varargs=t;try{var n=k.getStreamFromFD(e);switch(r){case 0:{var i=$e();if(i<0)return-28;for(;o.streams[i];)i++;var a;return a=o.dupStream(n,i),a.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var i=$e();return n.flags|=i,0}case 12:{var i=ce(),s=0;return V[i+s>>1]=2,0}case 13:case 14:return 0}return-28}catch(l){if(typeof o>"u"||l.name!=="ErrnoError")throw l;return-l.errno}}function Jt(e,r){try{return k.writeStat(r,o.fstat(e))}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}var Z=(e,r,t)=>(f(typeof t=="number","stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),kr(e,j,r,t));function Qt(e,r){try{if(r===0)return-28;var t=o.cwd(),n=fe(t)+1;return r<n?-68:(Z(t,e,r),n)}catch(i){if(typeof o>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function Zt(e,r,t){try{var n=k.getStreamFromFD(e);n.getdents||=o.readdir(n.path);for(var i=280,a=0,s=o.llseek(n,0,1),l=Math.floor(s/i),u=Math.min(n.getdents.length,l+Math.floor(t/i)),c=l;c<u;c++){var v,p,h=n.getdents[c];if(h===".")v=n.node.id,p=4;else if(h===".."){var m=o.lookupPath(n.path,{parent:!0});v=m.node.id,p=4}else{var _;try{_=o.lookupNode(n.node,h)}catch(y){if(y?.errno===28)continue;throw y}v=_.id,p=o.isChrdev(_.mode)?2:o.isDir(_.mode)?4:o.isLink(_.mode)?10:8}f(v),M[r+a>>3]=BigInt(v),M[r+a+8>>3]=BigInt((c+1)*i),V[r+a+16>>1]=280,x[r+a+18]=p,Z(h,r+a+19,256),a+=i}return o.llseek(n,c*i,0),a}catch(y){if(typeof o>"u"||y.name!=="ErrnoError")throw y;return-y.errno}}function en(e,r,t){k.varargs=t;try{var n=k.getStreamFromFD(e);switch(r){case 21509:return n.tty?0:-59;case 21505:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcgets){var i=n.tty.ops.ioctl_tcgets(n),a=ce();S[a>>2]=i.c_iflag||0,S[a+4>>2]=i.c_oflag||0,S[a+8>>2]=i.c_cflag||0,S[a+12>>2]=i.c_lflag||0;for(var s=0;s<32;s++)x[a+s+17]=i.c_cc[s]||0;return 0}return 0}case 21510:case 21511:case 21512:return n.tty?0:-59;case 21506:case 21507:case 21508:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcsets){for(var a=ce(),l=S[a>>2],u=S[a+4>>2],c=S[a+8>>2],v=S[a+12>>2],p=[],s=0;s<32;s++)p.push(x[a+s+17]);return n.tty.ops.ioctl_tcsets(n.tty,r,{c_iflag:l,c_oflag:u,c_cflag:c,c_lflag:v,c_cc:p})}return 0}case 21519:{if(!n.tty)return-59;var a=ce();return S[a>>2]=0,0}case 21520:return n.tty?-28:-59;case 21537:case 21531:{var a=ce();return o.ioctl(n,r,a)}case 21523:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tiocgwinsz){var h=n.tty.ops.ioctl_tiocgwinsz(n.tty),a=ce();V[a>>1]=h[0],V[a+2>>1]=h[1]}return 0}case 21524:return n.tty?0:-59;case 21515:return n.tty?0:-59;default:return-28}}catch(m){if(typeof o>"u"||m.name!=="ErrnoError")throw m;return-m.errno}}function rn(e,r){try{return e=k.getStr(e),k.writeStat(r,o.lstat(e))}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}function tn(e,r,t,n){try{r=k.getStr(r);var i=n&256,a=n&4096;return n=n&-6401,f(!n,`unknown flags in __syscall_newfstatat: ${n}`),r=k.calculateAt(e,r,a),k.writeStat(t,i?o.lstat(r):o.stat(r))}catch(s){if(typeof o>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}function nn(e,r,t,n){k.varargs=n;try{r=k.getStr(r),r=k.calculateAt(e,r);var i=n?$e():0;return o.open(r,t,i).fd}catch(a){if(typeof o>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function on(e){try{return e=k.getStr(e),o.rmdir(e),0}catch(r){if(typeof o>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function an(e,r){try{return e=k.getStr(e),k.writeStat(r,o.stat(e))}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}function sn(e,r,t){try{if(r=k.getStr(r),r=k.calculateAt(e,r),!t)o.unlink(r);else if(t===512)o.rmdir(r);else return-28;return 0}catch(n){if(typeof o>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}var Rr=()=>ut,Xe=e=>{var r=e.getArg(Rr(),0);return st(r)},ln=()=>ot(),un=e=>tt(e),$r=e=>nt(e),cn=e=>{var r=ln(),t=$r(4),n=$r(4);lt(e,t,n);var i=g[t>>2],a=g[n>>2],s=J(i);H(i);var l;return a&&(l=J(a),H(a)),un(r),[s,l]},Or=e=>{var r=Xe(e);return cn(r)},dn=e=>{var r=new WebAssembly.Exception(Rr(),[e],{traceStack:!0});throw r.message=Or(r),r},fn=()=>F("native code called abort()"),W=e=>{for(var r="";;){var t=j[e++];if(!t)return r;r+=String.fromCharCode(t)}},me={},te={},Oe={},be=class extends Error{constructor(r){super(r),this.name="BindingError"}},w=e=>{throw new be(e)};function vn(e,r,t={}){var n=r.name;if(e||w(`type "${n}" must have a positive integer typeid pointer`),te.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;w(`Cannot register type '${n}' twice`)}if(te[e]=r,delete Oe[e],me.hasOwnProperty(e)){var i=me[e];delete me[e],i.forEach(a=>a())}}function z(e,r,t={}){return vn(e,r,t)}var Ir=(e,r,t)=>{switch(r){case 1:return t?n=>x[n]:n=>j[n];case 2:return t?n=>V[n>>1]:n=>Ee[n>>1];case 4:return t?n=>S[n>>2]:n=>g[n>>2];case 8:return t?n=>M[n>>3]:n=>gr[n>>3];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},ne=e=>{if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},Mr=(e,r,t,n)=>{if(r<t||r>n)throw new TypeError(`Passing a number "${ne(r)}" from JS side to C/C++ side to an argument of type "${e}", which is outside the valid range [${t}, ${n}]!`)},mn=(e,r,t,n,i)=>{r=W(r);let a=n===0n,s=l=>l;if(a){let l=t*8;s=u=>BigInt.asUintN(l,u),i=s(i)}z(e,{name:r,fromWireType:s,toWireType:(l,u)=>{if(typeof u=="number")u=BigInt(u);else if(typeof u!="bigint")throw new TypeError(`Cannot convert "${ne(u)}" to ${this.name}`);return Mr(r,u,n,i),u},readValueFromPointer:Ir(r,t,!a),destructorFunction:null})},_n=(e,r,t,n)=>{r=W(r),z(e,{name:r,fromWireType:function(i){return!!i},toWireType:function(i,a){return a?t:n},readValueFromPointer:function(i){return this.fromWireType(j[i])},destructorFunction:null})},pn=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Ke=e=>{function r(t){return t.$$.ptrType.registeredClass.name}w(r(e)+" instance already deleted")},Je=!1,Nr=e=>{},hn=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)},xr=e=>{e.count.value-=1;var r=e.count.value===0;r&&hn(e)},Lr=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=Lr(e,r,t.baseClass);return n===null?null:t.downcast(n)},Ur={},gn={},yn=(e,r)=>{for(r===void 0&&w("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},En=(e,r)=>(r=yn(e,r),gn[r]),wn=class extends Error{constructor(r){super(r),this.name="InternalError"}},Ie=e=>{throw new wn(e)},Me=(e,r)=>{(!r.ptrType||!r.ptr)&&Ie("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&Ie("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Se(Object.create(e,{$$:{value:r,writable:!0}}))};function Wr(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=En(this.registeredClass,r);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function i(){return this.isSmartPointer?Me(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):Me(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var a=this.registeredClass.getActualType(r),s=Ur[a];if(!s)return i.call(this);var l;this.isConst?l=s.constPointerType:l=s.pointerType;var u=Lr(r,this.registeredClass,l.registeredClass);return u===null?i.call(this):this.isSmartPointer?Me(l.registeredClass.instancePrototype,{ptrType:l,ptr:u,smartPtrType:this,smartPtr:e}):Me(l.registeredClass.instancePrototype,{ptrType:l,ptr:u})}var Se=e=>globalThis.FinalizationRegistry?(Je=new FinalizationRegistry(r=>{console.warn(r.leakWarning),xr(r.$$)}),Se=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var i={$$:t},a=t.ptrType.registeredClass,s=new Error(`Embind found a leaked C++ instance ${a.name} <${se(t.ptr)}>.
|
|
3
|
+
We'll free it automatically in this case, but this functionality is not reliable across various environments.
|
|
4
|
+
Make sure to invoke .delete() manually once you're done with the instance instead.
|
|
5
|
+
Originally allocated`);"captureStackTrace"in Error&&Error.captureStackTrace(s,Wr),i.leakWarning=s.stack.replace(/^Error: /,""),Je.register(r,i,r)}return r},Nr=r=>Je.unregister(r),Se(e)):(Se=r=>r,e),Ne=[],bn=()=>{for(;Ne.length;){var e=Ne.pop();e.$$.deleteScheduled=!1,e.delete()}},Br,Sn=()=>{let e=xe.prototype;Object.assign(e,{isAliasOf(t){if(!(this instanceof xe)||!(t instanceof xe))return!1;var n=this.$$.ptrType.registeredClass,i=this.$$.ptr;t.$$=t.$$;for(var a=t.$$.ptrType.registeredClass,s=t.$$.ptr;n.baseClass;)i=n.upcast(i),n=n.baseClass;for(;a.baseClass;)s=a.upcast(s),a=a.baseClass;return n===a&&i===s},clone(){if(this.$$.ptr||Ke(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var t=Se(Object.create(Object.getPrototypeOf(this),{$$:{value:pn(this.$$)}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t},delete(){this.$$.ptr||Ke(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&w("Object already scheduled for deletion"),Nr(this),xr(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Ke(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&w("Object already scheduled for deletion"),Ne.push(this),Ne.length===1&&Br&&Br(bn),this.$$.deleteScheduled=!0,this}});let r=Symbol.dispose;r&&(e[r]=e.delete)};function xe(){}var Qe=(e,r)=>Object.defineProperty(r,"name",{value:e}),jr=(e,r,t)=>{if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(...i){return e[r].overloadTable.hasOwnProperty(i.length)||w(`Function '${t}' called with an invalid number of arguments (${i.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[i.length].apply(this,i)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n}},Fn=(e,r,t)=>{d.hasOwnProperty(e)?((t===void 0||d[e].overloadTable!==void 0&&d[e].overloadTable[t]!==void 0)&&w(`Cannot register public name '${e}' twice`),jr(d,e,e),d[e].overloadTable.hasOwnProperty(t)&&w(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),d[e].overloadTable[t]=r):(d[e]=r,d[e].argCount=t)},Tn=48,kn=57,Pn=e=>{f(typeof e=="string"),e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=Tn&&r<=kn?`_${e}`:e};function An(e,r,t,n,i,a,s,l){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=i,this.getActualType=a,this.upcast=s,this.downcast=l,this.pureVirtualFunctions=[]}var Ze=(e,r,t)=>{for(;r!==t;)r.upcast||w(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function Cn(e,r){if(r===null)return this.isReference&&w(`null is not a valid ${this.name}`),0;r.$$||w(`Cannot pass "${ne(r)}" as a ${this.name}`),r.$$.ptr||w(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Ze(r.$$.ptr,t,this.registeredClass);return n}function Dn(e,r){var t;if(r===null)return this.isReference&&w(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;(!r||!r.$$)&&w(`Cannot pass "${ne(r)}" as a ${this.name}`),r.$$.ptr||w(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&w(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);var n=r.$$.ptrType.registeredClass;if(t=Ze(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&w("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:w(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:t=r.$$.smartPtr;break;case 2:if(r.$$.smartPtrType===this)t=r.$$.smartPtr;else{var i=r.clone();t=this.rawShare(t,L.toHandle(()=>i.delete())),e!==null&&e.push(this.rawDestructor,t)}break;default:w("Unsupporting sharing policy")}return t}function Rn(e,r){if(r===null)return this.isReference&&w(`null is not a valid ${this.name}`),0;r.$$||w(`Cannot pass "${ne(r)}" as a ${this.name}`),r.$$.ptr||w(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&w(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Ze(r.$$.ptr,t,this.registeredClass);return n}function Le(e){return this.fromWireType(g[e>>2])}var $n=()=>{Object.assign(Ue.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor?.(e)},readValueFromPointer:Le,fromWireType:Wr})};function Ue(e,r,t,n,i,a,s,l,u,c,v){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=i,this.pointeeType=a,this.sharingPolicy=s,this.rawGetPointee=l,this.rawConstructor=u,this.rawShare=c,this.rawDestructor=v,!i&&r.baseClass===void 0?n?(this.toWireType=Cn,this.destructorFunction=null):(this.toWireType=Rn,this.destructorFunction=null):this.toWireType=Dn}var On=(e,r,t)=>{d.hasOwnProperty(e)||Ie("Replacing nonexistent public symbol"),d[e].overloadTable!==void 0&&t!==void 0?d[e].overloadTable[t]=r:(d[e]=r,d[e].argCount=t)},Hr=[],In=e=>{var r=Hr[e];return r||(Hr[e]=r=ur.get(e)),f(ur.get(e)==r,"JavaScript-side Wasm function table mirror is out of date!"),r},_e=(e,r,t=!1)=>{f(!t,"Async bindings are only supported with JSPI."),e=W(e);function n(){var a=In(r);return a}var i=n();return typeof i!="function"&&w(`unknown function pointer with signature ${e}: ${r}`),i};class Mn extends Error{}var Vr=e=>{var r=Qr(e),t=W(r);return H(r),t},er=(e,r)=>{var t=[],n={};function i(a){if(!n[a]&&!te[a]){if(Oe[a]){Oe[a].forEach(i);return}t.push(a),n[a]=!0}}throw r.forEach(i),new Mn(`${e}: `+t.map(Vr).join([", "]))},Fe=(e,r,t)=>{e.forEach(l=>Oe[l]=r);function n(l){var u=t(l);u.length!==e.length&&Ie("Mismatched type converter count");for(var c=0;c<e.length;++c)z(e[c],u[c])}var i=new Array(r.length),a=[],s=0;r.forEach((l,u)=>{te.hasOwnProperty(l)?i[u]=te[l]:(a.push(l),me.hasOwnProperty(l)||(me[l]=[]),me[l].push(()=>{i[u]=te[l],++s,s===a.length&&n(i)}))}),a.length===0&&n(i)},Nn=(e,r,t,n,i,a,s,l,u,c,v,p,h)=>{v=W(v),a=_e(i,a),l&&=_e(s,l),c&&=_e(u,c),h=_e(p,h);var m=Pn(v);Fn(m,function(){er(`Cannot construct ${v} due to unbound types`,[n])}),Fe([e,r,t],n?[n]:[],_=>{_=_[0];var y,O;n?(y=_.registeredClass,O=y.instancePrototype):O=xe.prototype;var A=Qe(v,function(...$){if(Object.getPrototypeOf(this)!==N)throw new be(`Use 'new' to construct ${v}`);if(D.constructor_body===void 0)throw new be(`${v} has no accessible constructor`);var ft=D.constructor_body[$.length];if(ft===void 0)throw new be(`Tried to invoke ctor of ${v} with invalid number of parameters (${$.length}) - expected (${Object.keys(D.constructor_body).toString()}) parameters instead!`);return ft.apply(this,$)}),N=Object.create(O,{constructor:{value:A}});A.prototype=N;var D=new An(v,A,N,h,y,a,l,c);D.baseClass&&(D.baseClass.__derivedClasses??=[],D.baseClass.__derivedClasses.push(D));var oe=new Ue(v,D,!0,!1,!1),B=new Ue(v+"*",D,!1,!1,!1),K=new Ue(v+" const*",D,!1,!0,!1);return Ur[e]={pointerType:B,constPointerType:K},On(m,A),[oe,B,K]})},zr=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push(g[r+n*4>>2]);return t},Gr=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r)}};function qr(e){for(var r=1;r<e.length;++r)if(e[r]!==null&&e[r].destructorFunction===void 0)return!0;return!1}function xn(e,r,t,n,i){if(e<r||e>t){var a=r==t?r:`${r} to ${t}`;i(`function ${n} called with ${e} arguments, expected ${a}`)}}function Ln(e,r,t,n){var i=qr(e),a=e.length-2,s=[],l=["fn"];r&&l.push("thisWired");for(var u=0;u<a;++u)s.push(`arg${u}`),l.push(`arg${u}Wired`);s=s.join(","),l=l.join(",");var c=`return function (${s}) {
|
|
6
|
+
`;c+=`checkArgCount(arguments.length, minArgs, maxArgs, humanName, throwBindingError);
|
|
7
|
+
`,i&&(c+=`var destructors = [];
|
|
8
|
+
`);var v=i?"destructors":"null",p=["humanName","throwBindingError","invoker","fn","runDestructors","fromRetWire","toClassParamWire"];r&&(c+=`var thisWired = toClassParamWire(${v}, this);
|
|
9
|
+
`);for(var u=0;u<a;++u){var h=`toArg${u}Wire`;c+=`var arg${u}Wired = ${h}(${v}, arg${u});
|
|
10
|
+
`,p.push(h)}c+=(t||n?"var rv = ":"")+`invoker(${l});
|
|
11
|
+
`;var m=t?"rv":"";if(i)c+=`runDestructors(destructors);
|
|
12
|
+
`;else for(var u=r?1:2;u<e.length;++u){var _=u===1?"thisWired":"arg"+(u-2)+"Wired";e[u].destructorFunction!==null&&(c+=`${_}_dtor(${_});
|
|
13
|
+
`,p.push(`${_}_dtor`))}return t&&(c+=`var ret = fromRetWire(rv);
|
|
14
|
+
return ret;
|
|
15
|
+
`),c+=`}
|
|
16
|
+
`,p.push("checkArgCount","minArgs","maxArgs"),c=`if (arguments.length !== ${p.length}){ throw new Error(humanName + "Expected ${p.length} closure arguments " + arguments.length + " given."); }
|
|
17
|
+
${c}`,new Function(p,c)}function Un(e){for(var r=e.length-2,t=e.length-1;t>=2&&e[t].optional;--t)r--;return r}function Yr(e,r,t,n,i,a){var s=r.length;s<2&&w("argTypes array size mismatch! Must at least get return value and 'this' types!"),f(!a,"Async bindings are only supported with JSPI.");for(var l=r[1]!==null&&t!==null,u=qr(r),c=!r[0].isVoid,v=s-2,p=Un(r),h=r[0],m=r[1],_=[e,w,n,i,Gr,h.fromWireType.bind(h),m?.toWireType.bind(m)],y=2;y<s;++y){var O=r[y];_.push(O.toWireType.bind(O))}if(!u)for(var y=l?1:2;y<r.length;++y)r[y].destructorFunction!==null&&_.push(r[y].destructorFunction);_.push(xn,p,v);var N=Ln(r,l,c,a)(..._);return Qe(e,N)}var Wn=(e,r,t,n,i,a)=>{f(r>0);var s=zr(r,t);i=_e(n,i);var l=[a],u=[];Fe([],[e],c=>{c=c[0];var v=`constructor ${c.name}`;if(c.registeredClass.constructor_body===void 0&&(c.registeredClass.constructor_body=[]),c.registeredClass.constructor_body[r-1]!==void 0)throw new be(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${c.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return c.registeredClass.constructor_body[r-1]=()=>{er(`Cannot construct ${c.name} due to unbound types`,s)},Fe([],s,p=>(p.splice(1,0,null),c.registeredClass.constructor_body[r-1]=Yr(v,p,null,i,a),[])),[]})},Bn=e=>{e=e.trim();let r=e.indexOf("(");return r===-1?e:(f(e.endsWith(")"),"Parentheses for argument names should match."),e.slice(0,r))},jn=(e,r,t,n,i,a,s,l,u,c)=>{var v=zr(t,n);r=W(r),r=Bn(r),a=_e(i,a,u),Fe([],[e],p=>{p=p[0];var h=`${p.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),l&&p.registeredClass.pureVirtualFunctions.push(r);function m(){er(`Cannot call ${h} due to unbound types`,v)}var _=p.registeredClass.instancePrototype,y=_[r];return y===void 0||y.overloadTable===void 0&&y.className!==p.name&&y.argCount===t-2?(m.argCount=t-2,m.className=p.name,_[r]=m):(jr(_,r,h),_[r].overloadTable[t-2]=m),Fe([],v,O=>{var A=Yr(h,O,p,a,s,u);return _[r].overloadTable===void 0?(A.argCount=t-2,_[r]=A):_[r].overloadTable[t-2]=A,[]}),[]})},Xr=[],G=[0,1,,1,null,1,!0,1,!1,1],rr=e=>{e>9&&--G[e+1]===0&&(f(G[e]!==void 0,"Decref for unallocated handle."),G[e]=void 0,Xr.push(e))},L={toValue:e=>(e||w(`Cannot use deleted val. handle = ${e}`),f(e===2||G[e]!==void 0&&e%2===0,`invalid handle: ${e}`),G[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let r=Xr.pop()||G.length;return G[r]=e,G[r+1]=1,r}}}},Hn={name:"emscripten::val",fromWireType:e=>{var r=L.toValue(e);return rr(e),r},toWireType:(e,r)=>L.toHandle(r),readValueFromPointer:Le,destructorFunction:null},Vn=e=>z(e,Hn),zn=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType(De[t>>2])};case 8:return function(t){return this.fromWireType(Re[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},Gn=(e,r,t)=>{r=W(r),z(e,{name:r,fromWireType:n=>n,toWireType:(n,i)=>{if(typeof i!="number"&&typeof i!="boolean")throw new TypeError(`Cannot convert ${ne(i)} to ${this.name}`);return i},readValueFromPointer:zn(r,t),destructorFunction:null})},qn=(e,r,t,n,i)=>{r=W(r);let a=n===0,s=u=>u;if(a){var l=32-8*t;s=u=>u<<l>>>l,i=s(i)}z(e,{name:r,fromWireType:s,toWireType:(u,c)=>{if(typeof c!="number"&&typeof c!="boolean")throw new TypeError(`Cannot convert "${ne(c)}" to ${r}`);return Mr(r,c,n,i),c},readValueFromPointer:Ir(r,t,n!==0),destructorFunction:null})},Yn=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array],i=n[r];function a(s){var l=g[s>>2],u=g[s+4>>2];return new i(x.buffer,u,l)}t=W(t),z(e,{name:t,fromWireType:a,readValueFromPointer:a},{ignoreDuplicateRegistrations:!0})},Xn=(e,r)=>{r=W(r);var t=!0;z(e,{name:r,fromWireType(n){var i=g[n>>2],a=n+4,s;if(t)s=J(a,i,!0);else{s="";for(var l=0;l<i;++l)s+=String.fromCharCode(j[a+l])}return H(n),s},toWireType(n,i){i instanceof ArrayBuffer&&(i=new Uint8Array(i));var a,s=typeof i=="string";s||ArrayBuffer.isView(i)&&i.BYTES_PER_ELEMENT==1||w("Cannot pass non-string to std::string"),t&&s?a=fe(i):a=i.length;var l=ar(4+a+1),u=l+4;if(g[l>>2]=a,s)if(t)Z(i,u,a+1);else for(var c=0;c<a;++c){var v=i.charCodeAt(c);v>255&&(H(l),w("String has UTF-16 code units that do not fit in 8 bits")),j[u+c]=v}else j.set(i,u);return n!==null&&n.push(H,l),l},readValueFromPointer:Le,destructorFunction(n){H(n)}})},Kr=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,Kn=(e,r,t)=>{f(e%2==0,"Pointer passed to UTF16ToString must be aligned to two bytes!");var n=e>>1,i=Fr(Ee,n,r/2,t);if(i-n>16&&Kr)return Kr.decode(Ee.subarray(n,i));for(var a="",s=n;s<i;++s){var l=Ee[s];a+=String.fromCharCode(l)}return a},Jn=(e,r,t)=>{if(f(r%2==0,"Pointer passed to stringToUTF16 must be aligned to two bytes!"),f(typeof t=="number","stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),t??=2147483647,t<2)return 0;t-=2;for(var n=r,i=t<e.length*2?t/2:e.length,a=0;a<i;++a){var s=e.charCodeAt(a);V[r>>1]=s,r+=2}return V[r>>1]=0,r-n},Qn=e=>e.length*2,Zn=(e,r,t)=>{f(e%4==0,"Pointer passed to UTF32ToString must be aligned to four bytes!");for(var n="",i=e>>2,a=0;!(a>=r/4);a++){var s=g[i+a];if(!s&&!t)break;n+=String.fromCodePoint(s)}return n},eo=(e,r,t)=>{if(f(r%4==0,"Pointer passed to stringToUTF32 must be aligned to four bytes!"),f(typeof t=="number","stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),t??=2147483647,t<4)return 0;for(var n=r,i=n+t-4,a=0;a<e.length;++a){var s=e.codePointAt(a);if(s>65535&&a++,S[r>>2]=s,r+=4,r+4>i)break}return S[r>>2]=0,r-n},ro=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.codePointAt(t);n>65535&&t++,r+=4}return r},to=(e,r,t)=>{t=W(t);var n,i,a;r===2?(n=Kn,i=Jn,a=Qn):(f(r===4,"only 2-byte and 4-byte strings are currently supported"),n=Zn,i=eo,a=ro),z(e,{name:t,fromWireType:s=>{var l=g[s>>2],u=n(s+4,l*r,!0);return H(s),u},toWireType:(s,l)=>{typeof l!="string"&&w(`Cannot pass non-string to C++ string type ${t}`);var u=a(l),c=ar(4+u+r);return g[c>>2]=u/r,i(l,c+4,u+r),s!==null&&s.push(H,c),c},readValueFromPointer:Le,destructorFunction(s){H(s)}})},no=(e,r)=>{r=W(r),z(e,{isVoid:!0,name:r,fromWireType:()=>{},toWireType:(t,n)=>{}})},tr=[],oo=e=>{var r=tr.length;return tr.push(e),r},io=(e,r)=>{var t=te[e];return t===void 0&&w(`${r} has unknown type ${Vr(e)}`),t},ao=(e,r)=>{for(var t=new Array(e),n=0;n<e;++n)t[n]=io(g[r+n*4>>2],`parameter ${n}`);return t},so=(e,r,t)=>{var n=[],i=e(n,t);return n.length&&(g[r>>2]=L.toHandle(n)),i},lo={},nr=e=>{var r=lo[e];return r===void 0?W(e):r},uo=(e,r,t)=>{var n=8,[i,...a]=ao(e,r),s=i.toWireType.bind(i),l=a.map(m=>m.readValueFromPointer.bind(m));e--;var u={toValue:L.toValue},c=l.map((m,_)=>{var y=`argFromPtr${_}`;return u[y]=m,`${y}(args${_?"+"+_*n:""})`}),v;switch(t){case 0:v="toValue(handle)";break;case 2:v="new (toValue(handle))";break;case 3:v="";break;case 1:u.getStringOrSymbol=nr,v="toValue(handle)[getStringOrSymbol(methodName)]";break}v+=`(${c})`,i.isVoid||(u.toReturnWire=s,u.emval_returnValue=so,v=`return emval_returnValue(toReturnWire, destructorsRef, ${v})`),v=`return function (handle, methodName, destructorsRef, args) {
|
|
18
|
+
${v}
|
|
19
|
+
}`;var p=new Function(Object.keys(u),v)(...Object.values(u)),h=`methodCaller<(${a.map(m=>m.name)}) => ${i.name}>`;return oo(Qe(h,p))},co=e=>e?(e=nr(e),L.toHandle(globalThis[e])):L.toHandle(globalThis),fo=(e,r)=>(e=L.toValue(e),r=L.toValue(r),L.toHandle(e[r])),vo=e=>{e>9&&(G[e+1]+=1)},Jr=(e,r,t,n,i)=>tr[e](r,t,n,i),mo=Jr,_o=()=>L.toHandle([]),po=e=>L.toHandle(nr(e)),ho=e=>{var r=L.toValue(e);Gr(r),rr(e)},go=e=>(e=L.toValue(e),L.toHandle(typeof e)),yo=e=>e%4===0&&(e%100!==0||e%400===0),Eo=[0,31,60,91,121,152,182,213,244,274,305,335],wo=[0,31,59,90,120,151,181,212,243,273,304,334],bo=e=>{var r=yo(e.getFullYear()),t=r?Eo:wo,n=t[e.getMonth()]+e.getDate()-1;return n},So=9007199254740992,Fo=-9007199254740992,or=e=>e<Fo||e>So?NaN:Number(e);function To(e,r){e=or(e);var t=new Date(e*1e3);S[r>>2]=t.getSeconds(),S[r+4>>2]=t.getMinutes(),S[r+8>>2]=t.getHours(),S[r+12>>2]=t.getDate(),S[r+16>>2]=t.getMonth(),S[r+20>>2]=t.getFullYear()-1900,S[r+24>>2]=t.getDay();var n=bo(t)|0;S[r+28>>2]=n,S[r+36>>2]=-(t.getTimezoneOffset()*60);var i=new Date(t.getFullYear(),0,1),a=new Date(t.getFullYear(),6,1).getTimezoneOffset(),s=i.getTimezoneOffset(),l=(a!=s&&t.getTimezoneOffset()==Math.min(s,a))|0;S[r+32>>2]=l}var ko=(e,r,t,n)=>{var i=new Date().getFullYear(),a=new Date(i,0,1),s=new Date(i,6,1),l=a.getTimezoneOffset(),u=s.getTimezoneOffset(),c=Math.max(l,u);g[e>>2]=c*60,S[r>>2]=+(l!=u);var v=m=>{var _=m>=0?"-":"+",y=Math.abs(m),O=String(Math.floor(y/60)).padStart(2,"0"),A=String(y%60).padStart(2,"0");return`UTC${_}${O}${A}`},p=v(l),h=v(u);f(p),f(h),f(fe(p)<=16,`timezone name truncated to fit in TZNAME_MAX (${p})`),f(fe(h)<=16,`timezone name truncated to fit in TZNAME_MAX (${h})`),u<l?(Z(p,t,17),Z(h,n,17)):(Z(p,n,17),Z(h,t,17))},Po=()=>performance.now(),Ao=()=>Date.now(),Co=1,Do=e=>e>=0&&e<=3;function Ro(e,r,t){if(r=or(r),!Do(e))return 28;var n;if(e===0)n=Ao();else if(Co)n=Po();else return 52;var i=Math.round(n*1e3*1e3);return M[t>>3]=BigInt(i),0}var $o=()=>2147483648,Oo=(e,r)=>(f(r,"alignment argument is required"),Math.ceil(e/r)*r),Io=e=>{var r=We.buffer.byteLength,t=(e-r+65535)/65536|0;try{return We.grow(t),yr(),1}catch(n){R(`growMemory: Attempted to grow heap from ${r} bytes to ${e} bytes, but got error: ${n}`)}},Mo=e=>{var r=j.length;e>>>=0,f(e>r);var t=$o();if(e>t)return R(`Cannot enlarge memory, requested ${e} bytes, but the limit is ${t} bytes!`),!1;for(var n=1;n<=4;n*=2){var i=r*(1+.2/n);i=Math.min(i,e+100663296);var a=Math.min(t,Oo(Math.max(e,i),65536)),s=Io(a);if(s)return!0}return R(`Failed to grow the heap from ${r} bytes to ${a} bytes, not enough memory!`),!1},ir={},No=()=>je||"./this.program",Te=()=>{if(!Te.strings){var e=(typeof navigator=="object"&&navigator.language||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:No()};for(var t in ir)ir[t]===void 0?delete r[t]:r[t]=ir[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);Te.strings=n}return Te.strings},xo=(e,r)=>{var t=0,n=0;for(var i of Te()){var a=r+t;g[e+n>>2]=a,t+=Z(i,a,1/0)+1,n+=4}return 0},Lo=(e,r)=>{var t=Te();g[e>>2]=t.length;var n=0;for(var i of t)n+=fe(i)+1;return g[r>>2]=n,0};function Uo(e){try{var r=k.getStreamFromFD(e);return o.close(r),0}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var Wo=(e,r,t,n)=>{for(var i=0,a=0;a<t;a++){var s=g[r>>2],l=g[r+4>>2];r+=8;var u=o.read(e,x,s,l,n);if(u<0)return-1;if(i+=u,u<l)break;typeof n<"u"&&(n+=u)}return i};function Bo(e,r,t,n){try{var i=k.getStreamFromFD(e),a=Wo(i,r,t);return g[n>>2]=a,0}catch(s){if(typeof o>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function jo(e,r,t,n){r=or(r);try{if(isNaN(r))return 61;var i=k.getStreamFromFD(e);return o.llseek(i,r,t),M[n>>3]=BigInt(i.position),i.getdents&&r===0&&t===0&&(i.getdents=null),0}catch(a){if(typeof o>"u"||a.name!=="ErrnoError")throw a;return a.errno}}var Ho=(e,r,t,n)=>{for(var i=0,a=0;a<t;a++){var s=g[r>>2],l=g[r+4>>2];r+=8;var u=o.write(e,x,s,l,n);if(u<0)return-1;if(i+=u,u<l)break;typeof n<"u"&&(n+=u)}return i};function Vo(e,r,t,n){try{var i=k.getStreamFromFD(e),a=Ho(i,r,t);return g[n>>2]=a,0}catch(s){if(typeof o>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var zo=e=>{var r=Xe(e);at(r)},Go=e=>{var r=Xe(e);it(r)};o.createPreloadedFile=Xt,o.preloadFile=Dr,o.staticInit(),Sn(),$n(),f(G.length===10);{if(d.noExitRuntime&&(xt=d.noExitRuntime),d.preloadPlugins&&(Cr=d.preloadPlugins),d.print&&(ee=d.print),d.printErr&&(R=d.printErr),d.wasmBinary&&(ge=d.wasmBinary),Xo(),d.arguments&&(vr=d.arguments),d.thisProgram&&(je=d.thisProgram),f(typeof d.memoryInitializerPrefixURL>"u","Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),f(typeof d.pthreadMainPrefixURL>"u","Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),f(typeof d.cdInitializerPrefixURL>"u","Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),f(typeof d.filePackagePrefixURL>"u","Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),f(typeof d.read>"u","Module.read option was removed"),f(typeof d.readAsync>"u","Module.readAsync option was removed (modify readAsync in JS)"),f(typeof d.readBinary>"u","Module.readBinary option was removed (modify readBinary in JS)"),f(typeof d.setWindowTitle>"u","Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),f(typeof d.TOTAL_MEMORY>"u","Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),f(typeof d.ENVIRONMENT>"u","Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)"),f(typeof d.STACK_SIZE>"u","STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),f(typeof d.wasmMemory>"u","Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),f(typeof d.INITIAL_MEMORY>"u","Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically"),d.preInit)for(typeof d.preInit=="function"&&(d.preInit=[d.preInit]);d.preInit.length>0;)d.preInit.shift()();Ce("preInit")}var qo=["writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getTempRet0","setTempRet0","zeroMemory","exitJS","withStackSave","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","readEmAsmArgs","jstoi_q","autoResumeAudioContext","getDynCaller","dynCall","handleException","keepRuntimeAlive","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","asmjsMangle","HandleAllocator","addOnInit","addOnPostCtor","addOnPreMain","addOnExit","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","ccall","cwrap","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","getFunctionAddress","addFunction","removeFunction","intArrayToString","stringToAscii","stringToNewUTF8","stringToUTF8OnStack","writeArrayToMemory","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","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","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","jsStackTrace","getCallstack","convertPCtoSourceLocation","wasiRightsToMuslOFlags","wasiOFlagsToMuslOFlags","safeSetTimeout","setImmediateWrapped","safeRequestAnimationFrame","clearImmediateWrapped","registerPostMainLoop","registerPreMainLoop","getPromise","makePromise","idsToPromises","makePromiseCallback","Browser_asyncPrepareDataCounter","arraySum","addDays","getSocketFromFD","getSocketAddress","FS_mkdirTree","_setNetworkCallback","heapObjectForWebGLType","toTypedArrayIndex","webgl_enable_ANGLE_instanced_arrays","webgl_enable_OES_vertex_array_object","webgl_enable_WEBGL_draw_buffers","webgl_enable_WEBGL_multi_draw","webgl_enable_EXT_polygon_offset_clamp","webgl_enable_EXT_clip_control","webgl_enable_WEBGL_polygon_mode","emscriptenWebGLGet","computeUnpackAlignedImageSize","colorChannelsInGlTextureFormat","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","__glGetActiveAttribOrUniform","writeGLArray","registerWebGlEventCallback","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate","writeStringToMemory","writeAsciiToMemory","allocateUTF8","allocateUTF8OnStack","demangle","stackTrace","getNativeTypeSize","getFunctionArgsName","createJsInvokerSignature","PureVirtualError","registerInheritedInstance","unregisterInheritedInstance","getInheritedInstanceCount","getLiveInheritedInstances","enumReadValueFromPointer","setDelayFunction","validateThis","count_emval_handles"];qo.forEach(Ft);var Yo=["run","out","err","callMain","abort","wasmExports","HEAPF32","HEAPF64","HEAP8","HEAPU8","HEAP16","HEAPU16","HEAP32","HEAPU32","HEAP64","HEAPU64","writeStackCookie","checkStackCookie","INT53_MAX","INT53_MIN","bigintToI53Checked","stackSave","stackRestore","stackAlloc","createNamedFunction","ptrToString","getHeapMax","growMemory","ENV","ERRNO_CODES","strError","DNS","Protocols","Sockets","timers","warnOnce","readEmAsmArgsArray","getExecutableName","asyncLoad","alignMemory","mmapAlloc","wasmTable","wasmMemory","getUniqueRunDependency","noExitRuntime","addRunDependency","removeRunDependency","addOnPreRun","addOnPostRun","freeTableIndexes","functionsInTableMap","setValue","getValue","PATH","PATH_FS","UTF8Decoder","UTF8ArrayToString","UTF8ToString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","intArrayFromString","AsciiToString","UTF16Decoder","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","JSEvents","specialHTMLTargets","findCanvasEventTarget","currentFullscreenStrategy","restoreOldWindowedStyle","UNWIND_CACHE","ExitStatus","getEnvStrings","checkWasiClock","doReadv","doWritev","initRandomFill","randomFill","emSetImmediate","emClearImmediate_deps","emClearImmediate","promiseMap","getExceptionMessageCommon","getCppExceptionTag","getCppExceptionThrownObjectFromWebAssemblyException","Browser","requestFullscreen","requestFullScreen","setCanvasSize","getUserMedia","createContext","getPreloadedImageData__data","wget","MONTH_DAYS_REGULAR","MONTH_DAYS_LEAP","MONTH_DAYS_REGULAR_CUMULATIVE","MONTH_DAYS_LEAP_CUMULATIVE","isLeapYear","ydayFromDate","SYSCALLS","preloadPlugins","FS_createPreloadedFile","FS_preloadFile","FS_modeStringToFlags","FS_getMode","FS_stdin_getChar_buffer","FS_stdin_getChar","FS_unlink","FS_createPath","FS_createDevice","FS_readFile","FS","FS_root","FS_mounts","FS_devices","FS_streams","FS_nextInode","FS_nameTable","FS_currentPath","FS_initialized","FS_ignorePermissions","FS_filesystems","FS_syncFSRequests","FS_readFiles","FS_lookupPath","FS_getPath","FS_hashName","FS_hashAddNode","FS_hashRemoveNode","FS_lookupNode","FS_createNode","FS_destroyNode","FS_isRoot","FS_isMountpoint","FS_isFile","FS_isDir","FS_isLink","FS_isChrdev","FS_isBlkdev","FS_isFIFO","FS_isSocket","FS_flagsToPermissionString","FS_nodePermissions","FS_mayLookup","FS_mayCreate","FS_mayDelete","FS_mayOpen","FS_checkOpExists","FS_nextfd","FS_getStreamChecked","FS_getStream","FS_createStream","FS_closeStream","FS_dupStream","FS_doSetAttr","FS_chrdev_stream_ops","FS_major","FS_minor","FS_makedev","FS_registerDevice","FS_getDevice","FS_getMounts","FS_syncfs","FS_mount","FS_unmount","FS_lookup","FS_mknod","FS_statfs","FS_statfsStream","FS_statfsNode","FS_create","FS_mkdir","FS_mkdev","FS_symlink","FS_rename","FS_rmdir","FS_readdir","FS_readlink","FS_stat","FS_fstat","FS_lstat","FS_doChmod","FS_chmod","FS_lchmod","FS_fchmod","FS_doChown","FS_chown","FS_lchown","FS_fchown","FS_doTruncate","FS_truncate","FS_ftruncate","FS_utime","FS_open","FS_close","FS_isClosed","FS_llseek","FS_read","FS_write","FS_mmap","FS_msync","FS_ioctl","FS_writeFile","FS_cwd","FS_chdir","FS_createDefaultDirectories","FS_createDefaultDevices","FS_createSpecialDirectories","FS_createStandardStreams","FS_staticInit","FS_init","FS_quit","FS_findObject","FS_analyzePath","FS_createFile","FS_createDataFile","FS_forceLoadFile","FS_createLazyFile","FS_absolutePath","FS_createFolder","FS_createLink","FS_joinPath","FS_mmapAlloc","FS_standardizePath","MEMFS","TTY","PIPEFS","SOCKFS","tempFixedLengthArray","miniTempWebGLFloatBuffers","miniTempWebGLIntBuffers","GL","AL","GLUT","EGL","GLEW","IDBStore","SDL","SDL_gfx","print","printErr","jstoi_s","InternalError","BindingError","throwInternalError","throwBindingError","registeredTypes","awaitingDependencies","typeDependencies","tupleRegistrations","structRegistrations","sharedRegisterType","whenDependentTypesAreResolved","getTypeName","getFunctionName","heap32VectorToArray","requireRegisteredType","usesDestructorStack","checkArgCount","getRequiredArgCount","createJsInvoker","UnboundTypeError","EmValType","EmValOptionalType","throwUnboundTypeError","ensureOverloadTable","exposePublicSymbol","replacePublicSymbol","embindRepr","registeredInstances","getBasestPointer","getInheritedInstance","registeredPointers","registerType","integerReadValueFromPointer","floatReadValueFromPointer","assertIntegerRange","readPointer","runDestructors","craftInvokerFunction","embind__requireFunction","genericPointerToWireType","constNoSmartPtrRawPointerToWireType","nonConstNoSmartPtrRawPointerToWireType","init_RegisteredPointer","RegisteredPointer","RegisteredPointer_fromWireType","runDestructor","releaseClassHandle","finalizationRegistry","detachFinalizer_deps","detachFinalizer","attachFinalizer","makeClassHandle","init_ClassHandle","ClassHandle","throwInstanceAlreadyDeleted","deletionQueue","flushPendingDeletes","delayFunction","RegisteredClass","shallowCopyInternalPointer","downcastPointer","upcastPointer","char_0","char_9","makeLegalFunctionName","emval_freelist","emval_handles","emval_symbols","getStringOrSymbol","Emval","emval_returnValue","emval_lookupTypes","emval_methodCallers","emval_addMethodCaller"];Yo.forEach(_r),d.getExceptionMessage=Or,d.incrementExceptionRefcount=zo,d.decrementExceptionRefcount=Go;function Xo(){bt("fetchSettings")}var ar=C("_malloc"),Qr=C("___getTypeName"),sr=C("_fflush"),H=C("_free"),lr=C("_emscripten_stack_get_end"),Ko=C("_emscripten_stack_get_base"),Zr=C("_strerror"),et=C("___trap"),rt=C("_emscripten_stack_init"),Jo=C("_emscripten_stack_get_free"),tt=C("__emscripten_stack_restore"),nt=C("__emscripten_stack_alloc"),ot=C("_emscripten_stack_get_current"),it=C("___cxa_decrement_exception_refcount"),at=C("___cxa_increment_exception_refcount"),st=C("___thrown_object_from_unwind_exception"),lt=C("___get_exception_message"),Qo=C("memory"),ut=C("___cpp_exception"),Zo=C("__indirect_function_table"),We=C("wasmMemory"),ur=C("wasmTable");function ei(e){f(e.malloc,"missing Wasm export: malloc"),ar=Y("malloc",1),f(e.__getTypeName,"missing Wasm export: __getTypeName"),Qr=Y("__getTypeName",1),f(e.fflush,"missing Wasm export: fflush"),sr=Y("fflush",1),f(e.free,"missing Wasm export: free"),H=Y("free",1),f(e.emscripten_stack_get_end,"missing Wasm export: emscripten_stack_get_end"),lr=e.emscripten_stack_get_end,f(e.emscripten_stack_get_base,"missing Wasm export: emscripten_stack_get_base"),Ko=e.emscripten_stack_get_base,f(e.strerror,"missing Wasm export: strerror"),Zr=Y("strerror",1),f(e.__trap,"missing Wasm export: __trap"),et=e.__trap,f(e.emscripten_stack_init,"missing Wasm export: emscripten_stack_init"),rt=e.emscripten_stack_init,f(e.emscripten_stack_get_free,"missing Wasm export: emscripten_stack_get_free"),Jo=e.emscripten_stack_get_free,f(e._emscripten_stack_restore,"missing Wasm export: _emscripten_stack_restore"),tt=e._emscripten_stack_restore,f(e._emscripten_stack_alloc,"missing Wasm export: _emscripten_stack_alloc"),nt=e._emscripten_stack_alloc,f(e.emscripten_stack_get_current,"missing Wasm export: emscripten_stack_get_current"),ot=e.emscripten_stack_get_current,f(e.__cxa_decrement_exception_refcount,"missing Wasm export: __cxa_decrement_exception_refcount"),it=Y("__cxa_decrement_exception_refcount",1),f(e.__cxa_increment_exception_refcount,"missing Wasm export: __cxa_increment_exception_refcount"),at=Y("__cxa_increment_exception_refcount",1),f(e.__thrown_object_from_unwind_exception,"missing Wasm export: __thrown_object_from_unwind_exception"),st=Y("__thrown_object_from_unwind_exception",1),f(e.__get_exception_message,"missing Wasm export: __get_exception_message"),lt=Y("__get_exception_message",3),f(e.memory,"missing Wasm export: memory"),Qo=We=e.memory,f(e.__cpp_exception,"missing Wasm export: __cpp_exception"),ut=e.__cpp_exception,f(e.__indirect_function_table,"missing Wasm export: __indirect_function_table"),Zo=ur=e.__indirect_function_table}var ct={__assert_fail:Lt,__syscall_fcntl64:Kt,__syscall_fstat64:Jt,__syscall_getcwd:Qt,__syscall_getdents64:Zt,__syscall_ioctl:en,__syscall_lstat64:rn,__syscall_newfstatat:tn,__syscall_openat:nn,__syscall_rmdir:on,__syscall_stat64:an,__syscall_unlinkat:sn,__throw_exception_with_stack_trace:dn,_abort_js:fn,_embind_register_bigint:mn,_embind_register_bool:_n,_embind_register_class:Nn,_embind_register_class_constructor:Wn,_embind_register_class_function:jn,_embind_register_emval:Vn,_embind_register_float:Gn,_embind_register_integer:qn,_embind_register_memory_view:Yn,_embind_register_std_string:Xn,_embind_register_std_wstring:to,_embind_register_void:no,_emval_create_invoker:uo,_emval_decref:rr,_emval_get_global:co,_emval_get_property:fo,_emval_incref:vo,_emval_invoke:Jr,_emval_invoke_i64:mo,_emval_new_array:_o,_emval_new_cstring:po,_emval_run_destructors:ho,_emval_typeof:go,_localtime_js:To,_tzset_js:ko,clock_time_get:Ro,emscripten_resize_heap:Mo,environ_get:xo,environ_sizes_get:Lo,fd_close:Uo,fd_read:Bo,fd_seek:jo,fd_write:Vo},dt;function ri(){rt(),wt()}function cr(){if(re>0){we=cr;return}if(ri(),Tt(),re>0){we=cr;return}function e(){f(!dt),dt=!0,d.calledRun=!0,!Ae&&(kt(),pr?.(d),d.onRuntimeInitialized?.(),Ce("onRuntimeInitialized"),f(!d._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),Pt())}d.setStatus?(d.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>d.setStatus(""),1),e()},1)):e(),Ve()}function Si(){var e=ee,r=R,t=!1;ee=R=n=>{t=!0};try{sr(0),["stdout","stderr"].forEach(n=>{var i=o.analyzePath("/dev/"+n);if(i){var a=i.object,s=a.rdev,l=X.ttys[s];l?.output?.length&&(t=!0)}})}catch{}ee=e,R=r,t&&le("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.")}var pe;pe=await It(),cr(),ae?I=d:I=new Promise((e,r)=>{pr=e,hr=r});for(let e of Object.keys(d))e in b||Object.defineProperty(b,e,{configurable:!0,get(){F(`Access to module property ('${e}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)}});return I}})();typeof _t=="object"&&typeof Be=="object"?(Be.exports=dr,Be.exports.default=dr):typeof define=="function"&&define.amd&&define([],()=>dr)});var gt=ui(pt()),ht=class P{instance;outputBuffer="";constructor(b){this.instance=b}static async create(){let b={stdout:""},I=await(0,gt.default)({print:q=>{b.stdout+=q+`
|
|
20
|
+
`}}),d=new I.ACompiler,U=new P(d);return Object.defineProperty(U,"outputBuffer",{get:()=>b.stdout,set:q=>{b.stdout=q}}),U}registerBuiltInLibrary(b,I,d=!0,U){this.instance.registerBuiltInLibrary(b,I,d,U)}compileAndRun(b,I){return this.instance.compileAndRun(b,I)}compile(b,I){return this.instance.compile(b,I)}run(){return this.instance.run()}hasError(){return this.instance.hasError()}refresh(){this.instance.refresh()}};export{ht as ACompiler};
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "autolang-compiler",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "An AI-friendly scripting runtime for rapidly building tools and extensions on top of a minimal, high-performance core.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"bin/*.wasm"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean --minify --no-splitting",
|
|
21
|
+
"dev": "tsup src/index.ts --format cjs,esm --watch --dts"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"tsup": "^8.5.1",
|
|
25
|
+
"typescript": "^6.0.2"
|
|
26
|
+
}
|
|
27
|
+
}
|