@tailwindcss/oxide-wasm32-wasi 4.1.10 → 4.1.12

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.
Files changed (42) hide show
  1. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.js +1 -1
  2. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.js +1 -1
  3. package/node_modules/@emnapi/core/dist/emnapi-core.esm-bundler.js +1 -1
  4. package/node_modules/@emnapi/core/dist/emnapi-core.js +30 -30
  5. package/node_modules/@emnapi/core/dist/emnapi-core.min.js +1 -1
  6. package/node_modules/@emnapi/core/dist/emnapi-core.min.mjs +1 -1
  7. package/node_modules/@emnapi/core/dist/emnapi-core.mjs +1 -1
  8. package/node_modules/@emnapi/core/package.json +2 -2
  9. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.js +1 -1
  10. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.js +1 -1
  11. package/node_modules/@emnapi/runtime/dist/emnapi.esm-bundler.js +1 -1
  12. package/node_modules/@emnapi/runtime/dist/emnapi.iife.js +1 -1
  13. package/node_modules/@emnapi/runtime/dist/emnapi.js +1 -1
  14. package/node_modules/@emnapi/runtime/dist/emnapi.min.js +1 -1
  15. package/node_modules/@emnapi/runtime/dist/emnapi.min.mjs +1 -1
  16. package/node_modules/@emnapi/runtime/dist/emnapi.mjs +1 -1
  17. package/node_modules/@emnapi/runtime/package.json +1 -1
  18. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.js +29 -29
  19. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.js +1 -1
  20. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.esm-bundler.js +29 -29
  21. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +29 -29
  22. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.js +1 -1
  23. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.mjs +1 -1
  24. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.mjs +29 -29
  25. package/node_modules/@emnapi/wasi-threads/package.json +1 -1
  26. package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +33 -48
  27. package/node_modules/@napi-rs/wasm-runtime/dist/runtime.js +24 -21
  28. package/node_modules/@napi-rs/wasm-runtime/fs-proxy.cjs +2 -2
  29. package/node_modules/@napi-rs/wasm-runtime/package.json +3 -3
  30. package/node_modules/@tybys/wasm-util/dist/wasm-util.d.ts +6 -0
  31. package/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +19 -16
  32. package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +19 -16
  33. package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +1 -1
  34. package/node_modules/@tybys/wasm-util/dist/wasm-util.js +19 -16
  35. package/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +1 -1
  36. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/index.js +12 -14
  37. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +7 -2
  38. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/index.mjs +12 -14
  39. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +7 -2
  40. package/node_modules/@tybys/wasm-util/package.json +1 -1
  41. package/package.json +6 -6
  42. package/tailwindcss-oxide.wasm32-wasi.wasm +0 -0
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).wasmUtil={})}(this,(function(t){"use strict";const e="undefined"!=typeof WebAssembly?WebAssembly:"undefined"!=typeof WXWebAssembly?WXWebAssembly:void 0;if(!e)throw new Error("WebAssembly is not supported in this environment");function n(t,e){if(null===t||"object"!=typeof t)throw new TypeError(`${e} must be an object. Received ${null===t?"null":typeof t}`)}function r(t,e){if("string"!=typeof t)throw new TypeError(`${e} must be a string. Received ${null===t?"null":typeof t}`)}function i(t,e){if("function"!=typeof t)throw new TypeError(`${e} must be a function. Received ${null===t?"null":typeof t}`)}function s(t,e){if(void 0!==t)throw new TypeError(`${e} must be undefined. Received ${null===t?"null":typeof t}`)}function o(t){return!(!t||"object"!=typeof t&&"function"!=typeof t||"function"!=typeof t.then)}function a(t,e){const n=Object.create(null);return Object.keys(t).forEach((r=>{const i=t[r];Object.defineProperty(n,r,{enumerable:!0,value:e(i,r)})})),n}function c(t,e,n){return"function"==typeof SharedArrayBuffer&&t.buffer instanceof SharedArrayBuffer||"[object SharedArrayBuffer]"===Object.prototype.toString.call(t.buffer.constructor)?t.slice(e,n):t.subarray(e,n)}const u=["asyncify_get_state","asyncify_start_rewind","asyncify_start_unwind","asyncify_stop_rewind","asyncify_stop_unwind"];function f(t,e,n,r){if("function"!=typeof t.exports[r]||n<=0)return{wasm64:e,dataPtr:16,start:e?32:24,end:1024};const i=t.exports[r],s=e?Number(i(BigInt(16)+BigInt(n))):i(8+n);if(0===s)throw new Error("Allocate asyncify data failed");return e?{wasm64:e,dataPtr:s,start:s+16,end:s+16+n}:{wasm64:e,dataPtr:s,start:s+8,end:s+8+n}}class h{constructor(){this.value=void 0,this.exports=void 0,this.dataPtr=0}init(t,n,r){var i,s;if(this.exports)throw new Error("Asyncify has been initialized");if(!(t instanceof e.Memory))throw new TypeError("Require WebAssembly.Memory object");const o=n.exports;for(let t=0;t<u.length;++t)if("function"!=typeof o[u[t]])throw new TypeError("Invalid asyncify wasm");let a;const c=Boolean(r.wasm64);a=r.tryAllocate?!0===r.tryAllocate?f(n,c,4096,"malloc"):f(n,c,null!==(i=r.tryAllocate.size)&&void 0!==i?i:4096,null!==(s=r.tryAllocate.name)&&void 0!==s?s:"malloc"):{wasm64:c,dataPtr:16,start:c?32:24,end:1024},this.dataPtr=a.dataPtr,c?new BigInt64Array(t.buffer,this.dataPtr).set([BigInt(a.start),BigInt(a.end)]):new Int32Array(t.buffer,this.dataPtr).set([a.start,a.end]),this.exports=this.wrapExports(o,r.wrapExports);const h=Object.create(e.Instance.prototype);return Object.defineProperty(h,"exports",{value:this.exports}),h}assertState(){if(0!==this.exports.asyncify_get_state())throw new Error("Asyncify state error")}wrapImportFunction(t){const e=this;return function(){for(;2===e.exports.asyncify_get_state();)return e.exports.asyncify_stop_rewind(),e.value;e.assertState();const n=t.apply(this,arguments);if(!o(n))return n;e.exports.asyncify_start_unwind(e.dataPtr),e.value=n}}wrapImports(t){const e={};return Object.keys(t).forEach((n=>{const r=t[n],i={};Object.keys(r).forEach((t=>{const e=r[t];i[t]="function"==typeof e?this.wrapImportFunction(e):e})),e[n]=i})),e}wrapExportFunction(t){const e=this;return async function(){e.assertState();let n=t.apply(this,arguments);for(;1===e.exports.asyncify_get_state();)e.exports.asyncify_stop_unwind(),e.value=await e.value,e.assertState(),e.exports.asyncify_start_rewind(e.dataPtr),n=t.call(this);return e.assertState(),n}}wrapExports(t,e){return a(t,((t,n)=>{let r=-1!==u.indexOf(n)||"function"!=typeof t;return Array.isArray(e)&&(r=r||-1===e.indexOf(n)),r?t:this.wrapExportFunction(t)}))}}function d(t){if(t&&"object"!=typeof t)throw new TypeError("imports must be an object or undefined")}function g(t,n){return"undefined"!=typeof wx&&"undefined"!=typeof __wxConfig?e.instantiate(t,n):fetch(t).then((t=>t.arrayBuffer())).then((t=>e.instantiate(t,n)))}function l(t,n){let r;if(d(n),n=null!=n?n:{},t instanceof ArrayBuffer||ArrayBuffer.isView(t))return e.instantiate(t,n);if(t instanceof e.Module)return e.instantiate(t,n).then((e=>({instance:e,module:t})));if("string"!=typeof t&&!(t instanceof URL))throw new TypeError("Invalid source");if("function"==typeof e.instantiateStreaming){let i;try{i=fetch(t),r=e.instantiateStreaming(i,n).catch((()=>g(t,n)))}catch(e){r=g(t,n)}}else r=g(t,n);return r}function _(t,n){let r;if(d(n),n=null!=n?n:{},t instanceof ArrayBuffer||ArrayBuffer.isView(t))r=new e.Module(t);else{if(!(t instanceof WebAssembly.Module))throw new TypeError("Invalid source");r=t}return{instance:new e.Instance(r,n),module:r}}const y=46,p=47;function E(t){return t===p}function I(...t){let e="",n=!1;for(let i=t.length-1;i>=-1&&!n;i--){const s=i>=0?t[i]:"/";r(s,"path"),0!==s.length&&(e=`${s}/${e}`,n=s.charCodeAt(0)===p)}return e=function(t,e,n,r){let i="",s=0,o=-1,a=0,c=0;for(let u=0;u<=t.length;++u){if(u<t.length)c=t.charCodeAt(u);else{if(r(c))break;c=p}if(r(c)){if(o===u-1||1===a);else if(2===a){if(i.length<2||2!==s||i.charCodeAt(i.length-1)!==y||i.charCodeAt(i.length-2)!==y){if(i.length>2){const t=i.indexOf(n);-1===t?(i="",s=0):(i=i.slice(0,t),s=i.length-1-i.indexOf(n)),o=u,a=0;continue}if(0!==i.length){i="",s=0,o=u,a=0;continue}}e&&(i+=i.length>0?`${n}..`:"..",s=2)}else i.length>0?i+=`${n}${t.slice(o+1,u)}`:i=t.slice(o+1,u),s=u-o-1;o=u,a=0}else c===y&&-1!==a?++a:a=-1}return i}(e,!n,"/",E),n?`/${e}`:e.length>0?e:"."}const m={FD_DATASYNC:BigInt(1)<<BigInt(0),FD_READ:BigInt(1)<<BigInt(1),FD_SEEK:BigInt(1)<<BigInt(2),FD_FDSTAT_SET_FLAGS:BigInt(1)<<BigInt(3),FD_SYNC:BigInt(1)<<BigInt(4),FD_TELL:BigInt(1)<<BigInt(5),FD_WRITE:BigInt(1)<<BigInt(6),FD_ADVISE:BigInt(1)<<BigInt(7),FD_ALLOCATE:BigInt(1)<<BigInt(8),PATH_CREATE_DIRECTORY:BigInt(1)<<BigInt(9),PATH_CREATE_FILE:BigInt(1)<<BigInt(10),PATH_LINK_SOURCE:BigInt(1)<<BigInt(11),PATH_LINK_TARGET:BigInt(1)<<BigInt(12),PATH_OPEN:BigInt(1)<<BigInt(13),FD_READDIR:BigInt(1)<<BigInt(14),PATH_READLINK:BigInt(1)<<BigInt(15),PATH_RENAME_SOURCE:BigInt(1)<<BigInt(16),PATH_RENAME_TARGET:BigInt(1)<<BigInt(17),PATH_FILESTAT_GET:BigInt(1)<<BigInt(18),PATH_FILESTAT_SET_SIZE:BigInt(1)<<BigInt(19),PATH_FILESTAT_SET_TIMES:BigInt(1)<<BigInt(20),FD_FILESTAT_GET:BigInt(1)<<BigInt(21),FD_FILESTAT_SET_SIZE:BigInt(1)<<BigInt(22),FD_FILESTAT_SET_TIMES:BigInt(1)<<BigInt(23),PATH_SYMLINK:BigInt(1)<<BigInt(24),PATH_REMOVE_DIRECTORY:BigInt(1)<<BigInt(25),PATH_UNLINK_FILE:BigInt(1)<<BigInt(26),POLL_FD_READWRITE:BigInt(1)<<BigInt(27),SOCK_SHUTDOWN:BigInt(1)<<BigInt(28),SOCK_ACCEPT:BigInt(1)<<BigInt(29)};class A extends Error{constructor(t,e){super(t),this.errno=e}getErrorMessage(){return function(t){switch(t){case 0:return"Success";case 1:return"Argument list too long";case 2:return"Permission denied";case 3:return"Address in use";case 4:return"Address not available";case 5:return"Address family not supported by protocol";case 6:return"Resource temporarily unavailable";case 7:return"Operation already in progress";case 8:return"Bad file descriptor";case 9:return"Bad message";case 10:return"Resource busy";case 11:return"Operation canceled";case 12:return"No child process";case 13:return"Connection aborted";case 14:return"Connection refused";case 15:return"Connection reset by peer";case 16:return"Resource deadlock would occur";case 17:return"Destination address required";case 18:return"Domain error";case 19:return"Quota exceeded";case 20:return"File exists";case 21:return"Bad address";case 22:return"File too large";case 23:return"Host is unreachable";case 24:return"Identifier removed";case 25:return"Illegal byte sequence";case 26:return"Operation in progress";case 27:return"Interrupted system call";case 28:return"Invalid argument";case 29:return"I/O error";case 30:return"Socket is connected";case 31:return"Is a directory";case 32:return"Symbolic link loop";case 33:return"No file descriptors available";case 34:return"Too many links";case 35:return"Message too large";case 36:return"Multihop attempted";case 37:return"Filename too long";case 38:return"Network is down";case 39:return"Connection reset by network";case 40:return"Network unreachable";case 41:return"Too many files open in system";case 42:return"No buffer space available";case 43:return"No such device";case 44:return"No such file or directory";case 45:return"Exec format error";case 46:return"No locks available";case 47:return"Link has been severed";case 48:return"Out of memory";case 49:return"No message of the desired type";case 50:return"Protocol not available";case 51:return"No space left on device";case 52:return"Function not implemented";case 53:return"Socket not connected";case 54:return"Not a directory";case 55:return"Directory not empty";case 56:return"State not recoverable";case 57:return"Not a socket";case 58:return"Not supported";case 59:return"Not a tty";case 60:return"No such device or address";case 61:return"Value too large for data type";case 62:return"Previous owner died";case 63:return"Operation not permitted";case 64:return"Broken pipe";case 65:return"Protocol error";case 66:return"Protocol not supported";case 67:return"Protocol wrong type for socket";case 68:return"Result not representable";case 69:return"Read-only file system";case 70:return"Invalid seek";case 71:return"No such process";case 72:return"Stale file handle";case 73:return"Operation timed out";case 74:return"Text file busy";case 75:return"Cross-device link";case 76:return"Capabilities insufficient";default:return"Unknown error"}}(this.errno)}}Object.defineProperty(A.prototype,"name",{configurable:!0,writable:!0,value:"WasiError"});const b=m.FD_DATASYNC|m.FD_READ|m.FD_SEEK|m.FD_FDSTAT_SET_FLAGS|m.FD_SYNC|m.FD_TELL|m.FD_WRITE|m.FD_ADVISE|m.FD_ALLOCATE|m.PATH_CREATE_DIRECTORY|m.PATH_CREATE_FILE|m.PATH_LINK_SOURCE|m.PATH_LINK_TARGET|m.PATH_OPEN|m.FD_READDIR|m.PATH_READLINK|m.PATH_RENAME_SOURCE|m.PATH_RENAME_TARGET|m.PATH_FILESTAT_GET|m.PATH_FILESTAT_SET_SIZE|m.PATH_FILESTAT_SET_TIMES|m.FD_FILESTAT_GET|m.FD_FILESTAT_SET_TIMES|m.FD_FILESTAT_SET_SIZE|m.PATH_SYMLINK|m.PATH_UNLINK_FILE|m.PATH_REMOVE_DIRECTORY|m.POLL_FD_READWRITE|m.SOCK_SHUTDOWN|m.SOCK_ACCEPT,T=b,w=b,B=b,N=b,S=m.FD_DATASYNC|m.FD_READ|m.FD_SEEK|m.FD_FDSTAT_SET_FLAGS|m.FD_SYNC|m.FD_TELL|m.FD_WRITE|m.FD_ADVISE|m.FD_ALLOCATE|m.FD_FILESTAT_GET|m.FD_FILESTAT_SET_SIZE|m.FD_FILESTAT_SET_TIMES|m.POLL_FD_READWRITE,P=BigInt(0),D=m.FD_FDSTAT_SET_FLAGS|m.FD_SYNC|m.FD_ADVISE|m.PATH_CREATE_DIRECTORY|m.PATH_CREATE_FILE|m.PATH_LINK_SOURCE|m.PATH_LINK_TARGET|m.PATH_OPEN|m.FD_READDIR|m.PATH_READLINK|m.PATH_RENAME_SOURCE|m.PATH_RENAME_TARGET|m.PATH_FILESTAT_GET|m.PATH_FILESTAT_SET_SIZE|m.PATH_FILESTAT_SET_TIMES|m.FD_FILESTAT_GET|m.FD_FILESTAT_SET_TIMES|m.PATH_SYMLINK|m.PATH_UNLINK_FILE|m.PATH_REMOVE_DIRECTORY|m.POLL_FD_READWRITE,F=D|S,U=m.FD_READ|m.FD_FDSTAT_SET_FLAGS|m.FD_WRITE|m.FD_FILESTAT_GET|m.POLL_FD_READWRITE|m.SOCK_SHUTDOWN,v=b,R=m.FD_READ|m.FD_FDSTAT_SET_FLAGS|m.FD_WRITE|m.FD_FILESTAT_GET|m.POLL_FD_READWRITE,L=BigInt(0);function H(t,e,n,r){const i={base:BigInt(0),inheriting:BigInt(0)};if(0===r)throw new A("Unknown file type",28);switch(r){case 4:i.base=S,i.inheriting=P;break;case 3:i.base=D,i.inheriting=F;break;case 6:case 5:i.base=U,i.inheriting=v;break;case 2:-1!==t.indexOf(e)?(i.base=R,i.inheriting=L):(i.base=B,i.inheriting=N);break;case 1:i.base=T,i.inheriting=w;break;default:i.base=BigInt(0),i.inheriting=BigInt(0)}const s=3&n;return 0===s?i.base&=~m.FD_WRITE:1===s&&(i.base&=~m.FD_READ),i}function O(t,e){let n=0;if("number"==typeof e&&e>=0)n=e;else for(let e=0;e<t.length;e++){n+=t[e].length}let r=0;const i=new Uint8Array(n);for(let e=0;e<t.length;e++){const n=t[e];i.set(n,r),r+=n.length}return i}class k{constructor(t,e,n,r,i,s,o,a){this.id=t,this.fd=e,this.path=n,this.realPath=r,this.type=i,this.rightsBase=s,this.rightsInheriting=o,this.preopen=a,this.pos=BigInt(0),this.size=BigInt(0)}seek(t,e){if(0===e)this.pos=BigInt(t);else if(1===e)this.pos+=BigInt(t);else{if(2!==e)throw new A("Unknown whence",29);this.pos=BigInt(this.size)-BigInt(t)}return this.pos}}class C extends k{constructor(t,e,n,r,i,s,o,a,c){super(e,n,r,i,s,o,a,c),this._log=t,this._buf=null}write(t){const e=t;if(this._buf&&(t=O([this._buf,t]),this._buf=null),-1===t.indexOf(10))return this._buf=t,e.byteLength;let n,r=0,i=0;for(;-1!==(n=t.indexOf(10,r));){const e=(new TextDecoder).decode(t.subarray(i,n));this._log(e),r+=n-i+1,i=n+1}return r<t.length&&(this._buf=t.slice(r)),e.byteLength}}function x(t){return t.isBlockDevice()?1:t.isCharacterDevice()?2:t.isDirectory()?3:t.isSocket()?6:t.isFile()?4:t.isSymbolicLink()?7:0}function M(t,e,n){t.setBigUint64(e,n.dev,!0),t.setBigUint64(e+8,n.ino,!0),t.setBigUint64(e+16,BigInt(x(n)),!0),t.setBigUint64(e+24,n.nlink,!0),t.setBigUint64(e+32,n.size,!0),t.setBigUint64(e+40,n.atimeMs*BigInt(1e6),!0),t.setBigUint64(e+48,n.mtimeMs*BigInt(1e6),!0),t.setBigUint64(e+56,n.ctimeMs*BigInt(1e6),!0)}class W{constructor(t){this.used=0,this.size=t.size,this.fds=Array(t.size),this.stdio=[t.in,t.out,t.err],this.print=t.print,this.printErr=t.printErr,this.insertStdio(t.in,0,"<stdin>"),this.insertStdio(t.out,1,"<stdout>"),this.insertStdio(t.err,2,"<stderr>")}insertStdio(t,e,n){const{base:r,inheriting:i}=H(this.stdio,t,2,2),s=this.insert(t,n,n,2,r,i,0);if(s.id!==e)throw new A(`id: ${s.id} !== expected: ${e}`,8);return s}insert(t,e,n,r,i,s,o){var a,c;let u,f=-1;if(this.used>=this.size){const t=2*this.size;this.fds.length=t,f=this.size,this.size=t}else for(let t=0;t<this.size;++t)if(null==this.fds[t]){f=t;break}return u="<stdout>"===e?new C(null!==(a=this.print)&&void 0!==a?a:console.log,f,t,e,n,r,i,s,o):"<stderr>"===e?new C(null!==(c=this.printErr)&&void 0!==c?c:console.error,f,t,e,n,r,i,s,o):new k(f,t,e,n,r,i,s,o),this.fds[f]=u,this.used++,u}get(t,e,n){if(t>=this.size)throw new A("Invalid fd",8);const r=this.fds[t];if(!r||r.id!==t)throw new A("Bad file descriptor",8);if((~r.rightsBase&e)!==BigInt(0)||(~r.rightsInheriting&n)!==BigInt(0))throw new A("Capabilities insufficient",76);return r}remove(t){if(t>=this.size)throw new A("Invalid fd",8);const e=this.fds[t];if(!e||e.id!==t)throw new A("Bad file descriptor",8);this.fds[t]=void 0,this.used--}}class K extends W{constructor(t){super(t),this.fs=t.fs}getFileTypeByFd(t){return x(this.fs.fstatSync(t,{bigint:!0}))}insertPreopen(t,e,n){const r=this.getFileTypeByFd(t);if(3!==r)throw new A(`Preopen not dir: ["${e}", "${n}"]`,54);const i=H(this.stdio,t,0,r);return this.insert(t,e,n,r,i.base,i.inheriting,1)}renumber(t,e){if(t===e)return;if(t>=this.size||e>=this.size)throw new A("Invalid fd",8);const n=this.fds[t],r=this.fds[e];if(!n||!r||n.id!==t||r.id!==e)throw new A("Invalid fd",8);this.fs.closeSync(n.fd),this.fds[t]=this.fds[e],this.fds[t].id=t,this.fds[e]=void 0,this.used--}}class z extends W{constructor(t){super(t)}async getFileTypeByFd(t){return x(await t.stat({bigint:!0}))}async insertPreopen(t,e,n){const r=await this.getFileTypeByFd(t);if(3!==r)throw new A(`Preopen not dir: ["${e}", "${n}"]`,54);const i=H(this.stdio,t.fd,0,r);return this.insert(t,e,n,r,i.base,i.inheriting,1)}async renumber(t,e){if(t===e)return;if(t>=this.size||e>=this.size)throw new A("Invalid fd",8);const n=this.fds[t],r=this.fds[e];if(!n||!r||n.id!==t||r.id!==e)throw new A("Invalid fd",8);await n.fd.close(),this.fds[t]=this.fds[e],this.fds[t].id=t,this.fds[e]=void 0,this.used--}}const j=function(){return e.Memory}();class G extends j{constructor(t){super(t)}get HEAP8(){return new Int8Array(super.buffer)}get HEAPU8(){return new Uint8Array(super.buffer)}get HEAP16(){return new Int16Array(super.buffer)}get HEAPU16(){return new Uint16Array(super.buffer)}get HEAP32(){return new Int32Array(super.buffer)}get HEAPU32(){return new Uint32Array(super.buffer)}get HEAP64(){return new BigInt64Array(super.buffer)}get HEAPU64(){return new BigUint64Array(super.buffer)}get HEAPF32(){return new Float32Array(super.buffer)}get HEAPF64(){return new Float64Array(super.buffer)}get view(){return new DataView(super.buffer)}}function Y(t){return Object.getPrototypeOf(t)===e.Memory.prototype&&Object.setPrototypeOf(t,G.prototype),t}function $(){const t=e.Function;if("function"!=typeof t)throw new Error('WebAssembly.Function is not supported in this environment. If you are using V8 based browser like Chrome, try to specify --js-flags="--wasm-staging --experimental-wasm-stack-switching"');return t}function V(t,e,n){const r=$();if("function"!=typeof t)throw new TypeError("Function required");const i=e.slice(0);return i.unshift("externref"),new r({parameters:i,results:n},t,{suspending:"first"})}function Z(t){const e=$();if("function"!=typeof t)throw new TypeError("Function required");return new e({parameters:[...e.type(t).parameters.slice(1)],results:["externref"]},t,{promising:"first"})}function q(t,e){if(0===t.length||0===e.length)return 0;let n=0,r=e.length-n;for(let i=0;i<t.length;++i){const s=t[i];if(r<s.length)return s.set(e.subarray(n,n+r),0),n+=r,r=0,n;s.set(e.subarray(n,n+s.length),0),n+=s.length,r-=s.length}return n}const X=new WeakMap,Q=new WeakMap,J=new WeakMap;function tt(t){return X.get(t)}function et(t){const e=J.get(t);if(!e)throw new Error("filesystem is unavailable");return e}function nt(t){if(t instanceof A)return t.errno;switch(t.code){case"ENOENT":return 44;case"EBADF":return 8;case"EINVAL":return 28;case"EPERM":return 63;case"EPROTO":return 65;case"EEXIST":return 20;case"ENOTDIR":return 54;case"EMFILE":return 33;case"EACCES":return 2;case"EISDIR":return 31;case"ENOTEMPTY":return 55;case"ENOSYS":return 52}throw t}function rt(t,e,n){return function(t,e){return Object.defineProperty(e,"name",{value:t}),e}(e,(function(){let e;try{e=n.apply(t,arguments)}catch(t){return nt(t)}return o(e)?e.then((t=>t),nt):e}))}function it(t,e,n,r){let i=I(e.realPath,n);if(1==(1&r))try{i=t.readlinkSync(i)}catch(t){if("EINVAL"!==t.code&&"ENOENT"!==t.code)throw t}return i}async function st(t,e,n,r){let i=I(e.realPath,n);if(1==(1&r))try{i=await t.promises.readlink(i)}catch(t){if("EINVAL"!==t.code&&"ENOENT"!==t.code)throw t}return i}const ot=new TextEncoder,at=new TextDecoder,ct=(BigInt(1)<<BigInt(63))-BigInt(1);function ut(){const t=window.prompt();if(null===t)return new Uint8Array;return(new TextEncoder).encode(t+"\n")}function ft(t){return Boolean(-16&t)||3==(3&t)||12==(12&t)}class ht{constructor(t,n,r,i,s,o){this.args_get=rt(this,"args_get",(function(t,e){if(t=Number(t),e=Number(e),0===t||0===e)return 28;const{HEAPU8:n,view:r}=tt(this),i=Q.get(this).args;for(let s=0;s<i.length;++s){const o=i[s];r.setInt32(t,e,!0),t+=4;const a=ot.encode(o+"\0");n.set(a,e),e+=a.length}return 0})),this.args_sizes_get=rt(this,"args_sizes_get",(function(t,e){if(t=Number(t),e=Number(e),0===t||0===e)return 28;const{view:n}=tt(this),r=Q.get(this).args;return n.setUint32(t,r.length,!0),n.setUint32(e,ot.encode(r.join("\0")+"\0").length,!0),0})),this.environ_get=rt(this,"environ_get",(function(t,e){if(t=Number(t),e=Number(e),0===t||0===e)return 28;const{HEAPU8:n,view:r}=tt(this),i=Q.get(this).env;for(let s=0;s<i.length;++s){const o=i[s];r.setInt32(t,e,!0),t+=4;const a=ot.encode(o+"\0");n.set(a,e),e+=a.length}return 0})),this.environ_sizes_get=rt(this,"environ_sizes_get",(function(t,e){if(t=Number(t),e=Number(e),0===t||0===e)return 28;const{view:n}=tt(this),r=Q.get(this);return n.setUint32(t,r.env.length,!0),n.setUint32(e,ot.encode(r.env.join("\0")+"\0").length,!0),0})),this.clock_res_get=rt(this,"clock_res_get",(function(t,e){if(0===(e=Number(e)))return 28;const{view:n}=tt(this);switch(t){case 0:return n.setBigUint64(e,BigInt(1e6),!0),0;case 1:case 2:case 3:return n.setBigUint64(e,BigInt(1e3),!0),0;default:return 28}})),this.clock_time_get=rt(this,"clock_time_get",(function(t,e,n){if(0===(n=Number(n)))return 28;const{view:r}=tt(this);switch(t){case 0:return r.setBigUint64(n,BigInt(Date.now())*BigInt(1e6),!0),0;case 1:case 2:case 3:{const t=performance.now(),e=Math.trunc(t),i=Math.floor(1e3*(t-e)),s=BigInt(e)*BigInt(1e9)+BigInt(i)*BigInt(1e6);return r.setBigUint64(n,s,!0),0}default:return 28}})),this.fd_advise=rt(this,"fd_advise",(function(t,e,n,r){return 52})),this.fd_fdstat_get=rt(this,"fd_fdstat_get",(function(t,e){if(0===(e=Number(e)))return 28;const n=Q.get(this).fds.get(t,BigInt(0),BigInt(0)),{view:r}=tt(this);return r.setUint16(e,n.type,!0),r.setUint16(e+2,0,!0),r.setBigUint64(e+8,n.rightsBase,!0),r.setBigUint64(e+16,n.rightsInheriting,!0),0})),this.fd_fdstat_set_flags=rt(this,"fd_fdstat_set_flags",(function(t,e){return 52})),this.fd_fdstat_set_rights=rt(this,"fd_fdstat_set_rights",(function(t,e,n){const r=Q.get(this).fds.get(t,BigInt(0),BigInt(0));return(e|r.rightsBase)>r.rightsBase||(n|r.rightsInheriting)>r.rightsInheriting?76:(r.rightsBase=e,r.rightsInheriting=n,0)})),this.fd_prestat_get=rt(this,"fd_prestat_get",(function(t,e){if(0===(e=Number(e)))return 28;const n=Q.get(this);let r;try{r=n.fds.get(t,BigInt(0),BigInt(0))}catch(t){if(t instanceof A)return t.errno;throw t}if(1!==r.preopen)return 28;const{view:i}=tt(this);return i.setUint32(e,0,!0),i.setUint32(e+4,ot.encode(r.path).length,!0),0})),this.fd_prestat_dir_name=rt(this,"fd_prestat_dir_name",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const r=Q.get(this).fds.get(t,BigInt(0),BigInt(0));if(1!==r.preopen)return 8;const i=ot.encode(r.path);if(i.length>n)return 42;const{HEAPU8:s}=tt(this);return s.set(i,e),0})),this.fd_seek=rt(this,"fd_seek",(function(t,e,n,r){if(0===(r=Number(r)))return 28;if(0===t||1===t||2===t)return 0;const i=Q.get(this).fds.get(t,m.FD_SEEK,BigInt(0)).seek(e,n),{view:s}=tt(this);return s.setBigUint64(r,i,!0),0})),this.fd_tell=rt(this,"fd_tell",(function(t,e){const n=Q.get(this).fds.get(t,m.FD_TELL,BigInt(0)),r=BigInt(n.pos),{view:i}=tt(this);return i.setBigUint64(Number(e),r,!0),0})),this.poll_oneoff=rt(this,"poll_oneoff",(function(t,e,n,r){if(t=Number(t),e=Number(e),r=Number(r),n=Number(n),n>>>=0,0===t||0===e||0===n||0===r)return 28;const{view:i}=tt(this);i.setUint32(r,0,!0);let s,o=0,a=BigInt(0),c=BigInt(0),u=0,f=BigInt(0);const h=Array(n);for(o=0;o<n;o++){s=t+48*o;const e=i.getBigUint64(s,!0),n=i.getUint8(s+8),r=i.getUint32(s+16,!0),a=i.getBigUint64(s+24,!0),c=i.getBigUint64(s+32,!0),u=i.getUint16(s+40,!0);h[o]={userdata:e,type:n,u:{clock:{clock_id:r,timeout:a,precision:c,flags:u},fd_readwrite:{fd:r}}}}const d=[];for(o=0;o<n;o++)switch(s=h[o],s.type){case 0:if(1===s.u.clock.flags){const t=BigInt(Date.now())*BigInt(1e6);c=s.u.clock.timeout-t}else c=s.u.clock.timeout;(0===u||c<f)&&(f=c,a=s.userdata,u=1);break;case 1:case 2:d.push(s);break;default:return 28}if(d.length>0){for(o=0;o<d.length;o++){const t=d[o],n=e+32*o;i.setBigUint64(n,t.userdata,!0),i.setUint32(n+8,52,!0),i.setUint32(n+12,t.type,!0),i.setBigUint64(n+16,BigInt(0),!0),i.setUint16(n+24,0,!0),i.setUint32(r,1,!0)}return i.setUint32(r,d.length,!0),0}if(u){!function(t,e){const n=Date.now()+t;let r=!1;for(;Date.now()<n;)if(e()){r=!0;break}}(Number(f/BigInt(1e6)),(()=>!1));const t=e;i.setBigUint64(t,a,!0),i.setUint32(t+8,0,!0),i.setUint32(t+12,0,!0),i.setUint32(r,1,!0)}return 0})),this.proc_exit=rt(this,"proc_exit",(function(t){return"object"==typeof process&&null!==process&&"function"==typeof process.exit&&process.exit(t),0})),this.proc_raise=rt(this,"proc_raise",(function(t){return 52})),this.sched_yield=rt(this,"sched_yield",(function(){return 0})),this.random_get="undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues?rt(this,"random_get",(function(t,e){if(0===(t=Number(t)))return 28;e=Number(e);const{HEAPU8:n,view:r}=tt(this);if("function"==typeof SharedArrayBuffer&&n.buffer instanceof SharedArrayBuffer||"[object SharedArrayBuffer]"===Object.prototype.toString.call(n.buffer)){for(let n=t;n<t+e;++n)r.setUint8(n,Math.floor(256*Math.random()));return 0}let i;const s=65536;for(i=0;i+s<e;i+=s)crypto.getRandomValues(n.subarray(t+i,t+i+s));return crypto.getRandomValues(n.subarray(t+i,t+e)),0})):rt(this,"random_get",(function(t,e){if(0===(t=Number(t)))return 28;e=Number(e);const{view:n}=tt(this);for(let r=t;r<t+e;++r)n.setUint8(r,Math.floor(256*Math.random()));return 0})),this.sock_recv=rt(this,"sock_recv",(function(){return 58})),this.sock_send=rt(this,"sock_send",(function(){return 58})),this.sock_shutdown=rt(this,"sock_shutdown",(function(){return 58})),this.sock_accept=rt(this,"sock_accept",(function(){return 58})),Q.set(this,{fds:r,args:t,env:n}),s&&J.set(this,s);const a=this;function u(t,e,n,r,s){a[t]=i?o?o.wrapImportFunction(rt(a,t,n)):V(rt(a,t,n),r,s):rt(a,t,e)}function f(t,e,n,r){const i=Q.get(this).fds.get(t,m.FD_FILESTAT_SET_TIMES,BigInt(0));return 2==(2&r)&&(e=BigInt(1e6*Date.now())),8==(8&r)&&(n=BigInt(1e6*Date.now())),{fileDescriptor:i,atim:e,mtim:n}}function h(t,e,n,r){const i=(e&(m.FD_READ|m.FD_READDIR))!==BigInt(0),s=(e&(m.FD_DATASYNC|m.FD_WRITE|m.FD_ALLOCATE|m.FD_FILESTAT_SET_SIZE))!==BigInt(0);let o=s?i?2:1:0,a=m.PATH_OPEN,c=e|n;return 0!=(1&t)&&(o|=64,a|=m.PATH_CREATE_FILE),0!=(2&t)&&(o|=65536),0!=(4&t)&&(o|=128),0!=(8&t)&&(o|=512,a|=m.PATH_FILESTAT_SET_SIZE),0!=(1&r)&&(o|=1024),0!=(2&r)&&(c|=m.FD_DATASYNC),0!=(4&r)&&(o|=2048),0!=(8&r)&&(o|=1052672,c|=m.FD_SYNC),0!=(16&r)&&(o|=1052672,c|=m.FD_SYNC),s&&0==(1536&o)&&(c|=m.FD_SEEK),{flags:o,needed_base:a,needed_inheriting:c}}u("fd_allocate",(function(t,e,n){const r=Q.get(this),i=et(this),s=r.fds.get(t,m.FD_ALLOCATE,BigInt(0));return i.fstatSync(s.fd,{bigint:!0}).size<e+n&&i.ftruncateSync(s.fd,Number(e+n)),0}),(async function(t,e,n){const r=Q.get(this).fds.get(t,m.FD_ALLOCATE,BigInt(0)).fd;return(await r.stat({bigint:!0})).size<e+n&&await r.truncate(Number(e+n)),0}),["i32","i64","f64"],["i32"]),u("fd_close",(function(t){const e=Q.get(this),n=e.fds.get(t,BigInt(0),BigInt(0));return et(this).closeSync(n.fd),e.fds.remove(t),0}),(async function(t){const e=Q.get(this),n=e.fds.get(t,BigInt(0),BigInt(0));return await n.fd.close(),e.fds.remove(t),0}),["i32"],["i32"]),u("fd_datasync",(function(t){const e=Q.get(this).fds.get(t,m.FD_DATASYNC,BigInt(0));return et(this).fdatasyncSync(e.fd),0}),(async function(t){const e=Q.get(this).fds.get(t,m.FD_DATASYNC,BigInt(0));return await e.fd.datasync(),0}),["i32"],["i32"]),u("fd_filestat_get",(function(t,e){if(0===(e=Number(e)))return 28;const n=Q.get(this).fds.get(t,m.FD_FILESTAT_GET,BigInt(0)),r=et(this).fstatSync(n.fd,{bigint:!0}),{view:i}=tt(this);return M(i,e,r),0}),(async function(t,e){if(0===(e=Number(e)))return 28;const n=Q.get(this).fds.get(t,m.FD_FILESTAT_GET,BigInt(0)).fd,r=await n.stat({bigint:!0}),{view:i}=tt(this);return M(i,e,r),0}),["i32","i32"],["i32"]),u("fd_filestat_set_size",(function(t,e){const n=Q.get(this).fds.get(t,m.FD_FILESTAT_SET_SIZE,BigInt(0));return et(this).ftruncateSync(n.fd,Number(e)),0}),(async function(t,e){const n=Q.get(this).fds.get(t,m.FD_FILESTAT_SET_SIZE,BigInt(0)).fd;return await n.truncate(Number(e)),0}),["i32","i64"],["i32"]),u("fd_filestat_set_times",(function(t,e,n,r){if(ft(r))return 28;const{fileDescriptor:i,atim:s,mtim:o}=f.call(this,t,e,n,r);return et(this).futimesSync(i.fd,Number(s),Number(o)),0}),(async function(t,e,n,r){if(ft(r))return 28;const{fileDescriptor:i,atim:s,mtim:o}=f.call(this,t,e,n,r),a=i.fd;return await a.utimes(Number(s),Number(o)),0}),["i32","i64","i64","i32"],["i32"]),u("fd_pread",(function(t,e,n,r,i){if(e=Number(e),i=Number(i),0===e&&n||0===i||r>ct)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.FD_READ|m.FD_SEEK,BigInt(0));if(!n)return o.setUint32(i,0,!0),0;let c=0;const u=Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,i=o.getInt32(r,!0),a=o.getUint32(r+4,!0);return c+=a,s.subarray(i,i+a)}));let f=0;const h=(()=>{try{return new Uint8Array(new SharedArrayBuffer(c))}catch(t){return new Uint8Array(c)}})();h._isBuffer=!0;const d=et(this).readSync(a.fd,h,0,h.length,Number(r));return f=h?q(u,h.subarray(0,d)):0,o.setUint32(i,f,!0),0}),(async function(t,e,n,r,i){if(e=Number(e),i=Number(i),0===e&&n||0===i||r>ct)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.FD_READ|m.FD_SEEK,BigInt(0));if(!n)return o.setUint32(i,0,!0),0;let c=0;const u=Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,i=o.getInt32(r,!0),a=o.getUint32(r+4,!0);return c+=a,s.subarray(i,i+a)}));let f=0;const h=new Uint8Array(c);h._isBuffer=!0;const{bytesRead:d}=await a.fd.read(h,0,h.length,Number(r));return f=h?q(u,h.subarray(0,d)):0,o.setUint32(i,f,!0),0}),["i32","i32","i32","i64","i32"],["i32"]),u("fd_pwrite",(function(t,e,n,r,i){if(e=Number(e),i=Number(i),0===e&&n||0===i||r>ct)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.FD_WRITE|m.FD_SEEK,BigInt(0));if(!n)return o.setUint32(i,0,!0),0;const c=O(Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,i=o.getInt32(r,!0),a=o.getUint32(r+4,!0);return s.subarray(i,i+a)}))),u=et(this).writeSync(a.fd,c,0,c.length,Number(r));return o.setUint32(i,u,!0),0}),(async function(t,e,n,r,i){if(e=Number(e),i=Number(i),0===e&&n||0===i||r>ct)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.FD_WRITE|m.FD_SEEK,BigInt(0));if(!n)return o.setUint32(i,0,!0),0;const c=O(Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,i=o.getInt32(r,!0),a=o.getUint32(r+4,!0);return s.subarray(i,i+a)}))),{bytesWritten:u}=await a.fd.write(c,0,c.length,Number(r));return o.setUint32(i,u,!0),0}),["i32","i32","i32","i64","i32"],["i32"]),u("fd_read",(function(t,e,n,r){if(e=Number(e),r=Number(r),0===e&&n||0===r)return 28;const{HEAPU8:i,view:s}=tt(this),o=Q.get(this).fds.get(t,m.FD_READ,BigInt(0));if(!n)return s.setUint32(r,0,!0),0;let a=0;const c=Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,o=s.getInt32(r,!0),c=s.getUint32(r+4,!0);return a+=c,i.subarray(o,o+c)}));let u,f=0;if(0===t){if("undefined"==typeof window||"function"!=typeof window.prompt)return 58;u=ut(),f=u?q(c,u):0}else{u=(()=>{try{return new Uint8Array(new SharedArrayBuffer(a))}catch(t){return new Uint8Array(a)}})(),u._isBuffer=!0;const t=et(this).readSync(o.fd,u,0,u.length,Number(o.pos));f=u?q(c,u.subarray(0,t)):0,o.pos+=BigInt(f)}return s.setUint32(r,f,!0),0}),(async function(t,e,n,r){if(e=Number(e),r=Number(r),0===e&&n||0===r)return 28;const{HEAPU8:i,view:s}=tt(this),o=Q.get(this).fds.get(t,m.FD_READ,BigInt(0));if(!n)return s.setUint32(r,0,!0),0;let a=0;const c=Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,o=s.getInt32(r,!0),c=s.getUint32(r+4,!0);return a+=c,i.subarray(o,o+c)}));let u,f=0;if(0===t){if("undefined"==typeof window||"function"!=typeof window.prompt)return 58;u=ut(),f=u?q(c,u):0}else{u=new Uint8Array(a),u._isBuffer=!0;const{bytesRead:t}=await o.fd.read(u,0,u.length,Number(o.pos));f=u?q(c,u.subarray(0,t)):0,o.pos+=BigInt(f)}return s.setUint32(r,f,!0),0}),["i32","i32","i32","i32"],["i32"]),u("fd_readdir",(function(t,e,n,r,i){if(e=Number(e),n=Number(n),i=Number(i),0===e||0===i)return 0;const s=Q.get(this).fds.get(t,m.FD_READDIR,BigInt(0)),o=et(this),a=o.readdirSync(s.realPath,{withFileTypes:!0}),{HEAPU8:c,view:u}=tt(this);let f=0;for(let t=Number(r);t<a.length;t++){const r=ot.encode(a[t].name),i=o.statSync(I(s.realPath,a[t].name),{bigint:!0}),u=new Uint8Array(24+r.byteLength),h=new DataView(u.buffer);let d;h.setBigUint64(0,BigInt(t+1),!0),h.setBigUint64(8,BigInt(i.ino?i.ino:0),!0),h.setUint32(16,r.byteLength,!0),d=a[t].isFile()?4:a[t].isDirectory()?3:a[t].isSymbolicLink()?7:a[t].isCharacterDevice()?2:a[t].isBlockDevice()?1:a[t].isSocket()?6:0,h.setUint8(20,d),u.set(r,24);const g=u.slice(0,Math.min(u.length,n-f));c.set(g,e+f),f+=g.byteLength}return u.setUint32(i,f,!0),0}),(async function(t,e,n,r,i){if(e=Number(e),n=Number(n),i=Number(i),0===e||0===i)return 0;const s=Q.get(this).fds.get(t,m.FD_READDIR,BigInt(0)),o=et(this),a=await o.promises.readdir(s.realPath,{withFileTypes:!0}),{HEAPU8:c,view:u}=tt(this);let f=0;for(let t=Number(r);t<a.length;t++){const r=ot.encode(a[t].name),i=await o.promises.stat(I(s.realPath,a[t].name),{bigint:!0}),u=new Uint8Array(24+r.byteLength),h=new DataView(u.buffer);let d;h.setBigUint64(0,BigInt(t+1),!0),h.setBigUint64(8,BigInt(i.ino?i.ino:0),!0),h.setUint32(16,r.byteLength,!0),d=a[t].isFile()?4:a[t].isDirectory()?3:a[t].isSymbolicLink()?7:a[t].isCharacterDevice()?2:a[t].isBlockDevice()?1:a[t].isSocket()?6:0,h.setUint8(20,d),u.set(r,24);const g=u.slice(0,Math.min(u.length,n-f));c.set(g,e+f),f+=g.byteLength}return u.setUint32(i,f,!0),0}),["i32","i32","i32","i64","i32"],["i32"]),u("fd_renumber",(function(t,e){return Q.get(this).fds.renumber(e,t),0}),(async function(t,e){const n=Q.get(this);return await n.fds.renumber(e,t),0}),["i32","i32"],["i32"]),u("fd_sync",(function(t){const e=Q.get(this).fds.get(t,m.FD_SYNC,BigInt(0));return et(this).fsyncSync(e.fd),0}),(async function(t){const e=Q.get(this).fds.get(t,m.FD_SYNC,BigInt(0));return await e.fd.sync(),0}),["i32"],["i32"]),u("fd_write",(function(t,e,n,r){if(e=Number(e),r=Number(r),0===e&&n||0===r)return 28;const{HEAPU8:i,view:s}=tt(this),o=Q.get(this).fds.get(t,m.FD_WRITE,BigInt(0));if(!n)return s.setUint32(r,0,!0),0;const a=O(Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,o=s.getInt32(r,!0),a=s.getUint32(r+4,!0);return i.subarray(o,o+a)})));let c;if(1===t||2===t)c=o.write(a);else{c=et(this).writeSync(o.fd,a,0,a.length,Number(o.pos)),o.pos+=BigInt(c)}return s.setUint32(r,c,!0),0}),(async function(t,e,n,r){if(e=Number(e),r=Number(r),0===e&&n||0===r)return 28;const{HEAPU8:i,view:s}=tt(this),o=Q.get(this).fds.get(t,m.FD_WRITE,BigInt(0));if(!n)return s.setUint32(r,0,!0),0;const a=O(Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,o=s.getInt32(r,!0),a=s.getUint32(r+4,!0);return i.subarray(o,o+a)})));let c;return 1===t||2===t?c=o.write(a):(c=await(await o.fd.write(a,0,a.length,Number(o.pos))).bytesWritten,o.pos+=BigInt(c)),s.setUint32(r,c,!0),0}),["i32","i32","i32","i32"],["i32"]),u("path_create_directory",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=tt(this),i=Q.get(this).fds.get(t,m.PATH_CREATE_DIRECTORY,BigInt(0));let s=at.decode(c(r,e,e+n));s=I(i.realPath,s);return et(this).mkdirSync(s),0}),(async function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=tt(this),i=Q.get(this).fds.get(t,m.PATH_CREATE_DIRECTORY,BigInt(0));let s=at.decode(c(r,e,e+n));s=I(i.realPath,s);const o=et(this);return await o.promises.mkdir(s),0}),["i32","i32","i32"],["i32"]),u("path_filestat_get",(function(t,e,n,r,i){if(n=Number(n),r=Number(r),i=Number(i),0===n||0===i)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.PATH_FILESTAT_GET,BigInt(0));let u=at.decode(c(s,n,n+r));const f=et(this);let h;return u=I(a.realPath,u),h=1==(1&e)?f.statSync(u,{bigint:!0}):f.lstatSync(u,{bigint:!0}),M(o,i,h),0}),(async function(t,e,n,r,i){if(n=Number(n),r=Number(r),i=Number(i),0===n||0===i)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.PATH_FILESTAT_GET,BigInt(0));let u=at.decode(c(s,n,n+r));const f=et(this);let h;return u=I(a.realPath,u),h=1==(1&e)?await f.promises.stat(u,{bigint:!0}):await f.promises.lstat(u,{bigint:!0}),M(o,i,h),0}),["i32","i32","i32","i32","i32"],["i32"]),u("path_filestat_set_times",(function(t,e,n,r,i,s,o){if(n=Number(n),r=Number(r),0===n)return 28;const{HEAPU8:a}=tt(this),u=Q.get(this).fds.get(t,m.PATH_FILESTAT_SET_TIMES,BigInt(0));if(ft(o))return 28;const f=et(this),h=it(f,u,at.decode(c(a,n,n+r)),e);return 2==(2&o)&&(i=BigInt(1e6*Date.now())),8==(8&o)&&(s=BigInt(1e6*Date.now())),f.utimesSync(h,Number(i),Number(s)),0}),(async function(t,e,n,r,i,s,o){if(n=Number(n),r=Number(r),0===n)return 28;const{HEAPU8:a}=tt(this),u=Q.get(this).fds.get(t,m.PATH_FILESTAT_SET_TIMES,BigInt(0));if(ft(o))return 28;const f=et(this),h=await st(f,u,at.decode(c(a,n,n+r)),e);return 2==(2&o)&&(i=BigInt(1e6*Date.now())),8==(8&o)&&(s=BigInt(1e6*Date.now())),await f.promises.utimes(h,Number(i),Number(s)),0}),["i32","i32","i32","i32","i64","i64","i32"],["i32"]),u("path_link",(function(t,e,n,r,i,s,o){if(n=Number(n),r=Number(r),s=Number(s),o=Number(o),0===n||0===s)return 28;const a=Q.get(this);let u,f;t===i?u=f=a.fds.get(t,m.PATH_LINK_SOURCE|m.PATH_LINK_TARGET,BigInt(0)):(u=a.fds.get(t,m.PATH_LINK_SOURCE,BigInt(0)),f=a.fds.get(i,m.PATH_LINK_TARGET,BigInt(0)));const{HEAPU8:h}=tt(this),d=et(this),g=it(d,u,at.decode(c(h,n,n+r)),e),l=I(f.realPath,at.decode(c(h,s,s+o)));return d.linkSync(g,l),0}),(async function(t,e,n,r,i,s,o){if(n=Number(n),r=Number(r),s=Number(s),o=Number(o),0===n||0===s)return 28;const a=Q.get(this);let u,f;t===i?u=f=a.fds.get(t,m.PATH_LINK_SOURCE|m.PATH_LINK_TARGET,BigInt(0)):(u=a.fds.get(t,m.PATH_LINK_SOURCE,BigInt(0)),f=a.fds.get(i,m.PATH_LINK_TARGET,BigInt(0)));const{HEAPU8:h}=tt(this),d=et(this),g=await st(d,u,at.decode(c(h,n,n+r)),e),l=I(f.realPath,at.decode(c(h,s,s+o)));return await d.promises.link(g,l),0}),["i32","i32","i32","i32","i32","i32","i32"],["i32"]),u("path_open",(function(t,e,n,r,i,s,o,a,u){if(n=Number(n),u=Number(u),0===n||0===u)return 28;r=Number(r),s=BigInt(s),o=BigInt(o);const{flags:f,needed_base:d,needed_inheriting:g}=h(i,s,o,a),l=Q.get(this),_=l.fds.get(t,d,g),y=tt(this),p=y.HEAPU8,E=at.decode(c(p,n,n+r)),I=et(this),m=it(I,_,E,e),A=I.openSync(m,f,438),b=l.fds.getFileTypeByFd(A);if(0!=(2&i)&&3!==b)return 54;const{base:T,inheriting:w}=H(l.fds.stdio,A,f,b),B=l.fds.insert(A,m,m,b,s&T,o&w,0),N=I.fstatSync(A,{bigint:!0});N.isFile()&&(B.size=N.size,0!=(1024&f)&&(B.pos=N.size));return y.view.setInt32(u,B.id,!0),0}),(async function(t,e,n,r,i,s,o,a,u){if(n=Number(n),u=Number(u),0===n||0===u)return 28;r=Number(r),s=BigInt(s),o=BigInt(o);const{flags:f,needed_base:d,needed_inheriting:g}=h(i,s,o,a),l=Q.get(this),_=l.fds.get(t,d,g),y=tt(this),p=y.HEAPU8,E=at.decode(c(p,n,n+r)),I=et(this),m=await st(I,_,E,e),A=await I.promises.open(m,f,438),b=await l.fds.getFileTypeByFd(A);if(0!=(2&i)&&3!==b)return 54;const{base:T,inheriting:w}=H(l.fds.stdio,A.fd,f,b),B=l.fds.insert(A,m,m,b,s&T,o&w,0),N=await A.stat({bigint:!0});N.isFile()&&(B.size=N.size,0!=(1024&f)&&(B.pos=N.size));return y.view.setInt32(u,B.id,!0),0}),["i32","i32","i32","i32","i32","i64","i64","i32","i32"],["i32"]),u("path_readlink",(function(t,e,n,r,i,s){if(e=Number(e),n=Number(n),r=Number(r),i=Number(i),s=Number(s),0===e||0===r||0===s)return 28;const{HEAPU8:o,view:a}=tt(this),u=Q.get(this).fds.get(t,m.PATH_READLINK,BigInt(0));let f=at.decode(c(o,e,e+n));f=I(u.realPath,f);const h=et(this).readlinkSync(f),d=ot.encode(h),g=Math.min(d.length,i);return g>=i?42:(o.set(d.subarray(0,g),r),o[r+g]=0,a.setUint32(s,g,!0),0)}),(async function(t,e,n,r,i,s){if(e=Number(e),n=Number(n),r=Number(r),i=Number(i),s=Number(s),0===e||0===r||0===s)return 28;const{HEAPU8:o,view:a}=tt(this),u=Q.get(this).fds.get(t,m.PATH_READLINK,BigInt(0));let f=at.decode(c(o,e,e+n));f=I(u.realPath,f);const h=et(this),d=await h.promises.readlink(f),g=ot.encode(d),l=Math.min(g.length,i);return l>=i?42:(o.set(g.subarray(0,l),r),o[r+l]=0,a.setUint32(s,l,!0),0)}),["i32","i32","i32","i32","i32","i32"],["i32"]),u("path_remove_directory",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=tt(this),i=Q.get(this).fds.get(t,m.PATH_REMOVE_DIRECTORY,BigInt(0));let s=at.decode(c(r,e,e+n));s=I(i.realPath,s);return et(this).rmdirSync(s),0}),(async function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=tt(this),i=Q.get(this).fds.get(t,m.PATH_REMOVE_DIRECTORY,BigInt(0));let s=at.decode(c(r,e,e+n));s=I(i.realPath,s);const o=et(this);return await o.promises.rmdir(s),0}),["i32","i32","i32"],["i32"]),u("path_rename",(function(t,e,n,r,i,s){if(e=Number(e),n=Number(n),i=Number(i),s=Number(s),0===e||0===i)return 28;const o=Q.get(this);let a,u;t===r?a=u=o.fds.get(t,m.PATH_RENAME_SOURCE|m.PATH_RENAME_TARGET,BigInt(0)):(a=o.fds.get(t,m.PATH_RENAME_SOURCE,BigInt(0)),u=o.fds.get(r,m.PATH_RENAME_TARGET,BigInt(0)));const{HEAPU8:f}=tt(this),h=I(a.realPath,at.decode(c(f,e,e+n))),d=I(u.realPath,at.decode(c(f,i,i+s)));return et(this).renameSync(h,d),0}),(async function(t,e,n,r,i,s){if(e=Number(e),n=Number(n),i=Number(i),s=Number(s),0===e||0===i)return 28;const o=Q.get(this);let a,u;t===r?a=u=o.fds.get(t,m.PATH_RENAME_SOURCE|m.PATH_RENAME_TARGET,BigInt(0)):(a=o.fds.get(t,m.PATH_RENAME_SOURCE,BigInt(0)),u=o.fds.get(r,m.PATH_RENAME_TARGET,BigInt(0)));const{HEAPU8:f}=tt(this),h=I(a.realPath,at.decode(c(f,e,e+n))),d=I(u.realPath,at.decode(c(f,i,i+s))),g=et(this);return await g.promises.rename(h,d),0}),["i32","i32","i32","i32","i32","i32"],["i32"]),u("path_symlink",(function(t,e,n,r,i){if(t=Number(t),e=Number(e),r=Number(r),i=Number(i),0===t||0===r)return 28;const{HEAPU8:s}=tt(this),o=Q.get(this).fds.get(n,m.PATH_SYMLINK,BigInt(0)),a=at.decode(c(s,t,t+e));let u=at.decode(c(s,r,r+i));u=I(o.realPath,u);return et(this).symlinkSync(a,u),0}),(async function(t,e,n,r,i){if(t=Number(t),e=Number(e),r=Number(r),i=Number(i),0===t||0===r)return 28;const{HEAPU8:s}=tt(this),o=Q.get(this).fds.get(n,m.PATH_SYMLINK,BigInt(0)),a=at.decode(c(s,t,t+e));let u=at.decode(c(s,r,r+i));u=I(o.realPath,u);const f=et(this);return await f.promises.symlink(a,u),0}),["i32","i32","i32","i32","i32"],["i32"]),u("path_unlink_file",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=tt(this),i=Q.get(this).fds.get(t,m.PATH_UNLINK_FILE,BigInt(0));let s=at.decode(c(r,e,e+n));s=I(i.realPath,s);return et(this).unlinkSync(s),0}),(async function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=tt(this),i=Q.get(this).fds.get(t,m.PATH_UNLINK_FILE,BigInt(0));let s=at.decode(c(r,e,e+n));s=I(i.realPath,s);const o=et(this);return await o.promises.unlink(s),0}),["i32","i32","i32"],["i32"]),this._setMemory=function(t){if(!(t instanceof e.Memory))throw new TypeError('"instance.exports.memory" property must be a WebAssembly.Memory');X.set(a,Y(t))}}static createSync(t,e,n,r,i,s,o){const a=new K({size:3,in:r[0],out:r[1],err:r[2],fs:i,print:s,printErr:o}),c=new ht(t,e,a,!1,i);if(n.length>0)for(let t=0;t<n.length;++t){const e=i.realpathSync(n[t].realPath,"utf8"),r=i.openSync(e,"r",438);a.insertPreopen(r,n[t].mappedPath,e)}return c}static async createAsync(t,e,n,r,i,s,o,a){const c=new z({size:3,in:r[0],out:r[1],err:r[2],print:s,printErr:o}),u=new ht(t,e,c,!0,i,a);if(n.length>0)for(let t=0;t<n.length;++t){const e=n[t],r=await i.promises.realpath(e.realPath),s=await i.promises.open(r,"r",438);await c.insertPreopen(s,e.mappedPath,r)}return u}}const dt=Object.freeze(Object.create(null)),gt=Symbol("kExitCode"),lt=Symbol("kSetMemory"),_t=Symbol("kStarted"),yt=Symbol("kInstance"),pt=Symbol("kBindingName");function Et(t,e){n(e,"instance"),n(e.exports,"instance.exports"),t[yt]=e,t[lt](e.exports.memory)}function It(t){var e;let s;if(n(t,"options"),void 0!==t.version)switch(r(t.version,"options.version"),t.version){case"unstable":s=ht,this[pt]="wasi_unstable";break;case"preview1":s=ht,this[pt]="wasi_snapshot_preview1";break;default:throw new TypeError(`unsupported WASI version "${t.version}"`)}else s=ht,this[pt]="wasi_snapshot_preview1";void 0!==t.args&&function(t,e){if(!Array.isArray(t))throw new TypeError(`${e} must be an array. Received ${null===t?"null":typeof t}`)}(t.args,"options.args");const o=(null!==(e=t.args)&&void 0!==e?e:[]).map(String),a=[];void 0!==t.env&&(n(t.env,"options.env"),Object.entries(t.env).forEach((({0:t,1:e})=>{void 0!==e&&a.push(`${t}=${e}`)})));const c=[];if(void 0!==t.preopens&&(n(t.preopens,"options.preopens"),Object.entries(t.preopens).forEach((({0:t,1:e})=>c.push({mappedPath:String(t),realPath:String(e)})))),c.length>0){if(void 0===t.fs)throw new Error("filesystem is disabled, can not preopen directory");try{n(t.fs,"options.fs")}catch(t){throw new TypeError("Node.js fs like implementation is not provided")}}void 0!==t.print&&i(t.print,"options.print"),void 0!==t.printErr&&i(t.printErr,"options.printErr"),void 0!==t.returnOnExit&&function(t,e){if("boolean"!=typeof t)throw new TypeError(`${e} must be a boolean. Received ${null===t?"null":typeof t}`)}(t.returnOnExit,"options.returnOnExit");return{args:o,env:a,preopens:c,stdio:[0,1,2],_WASI:s}}function mt(t,e){this[lt]=t,this.wasiImport=e,this[_t]=!1,this[gt]=0,this[yt]=void 0}class At{constructor(t=dt){const{args:e,env:n,preopens:r,stdio:i,_WASI:s}=It.call(this,t),o=s.createSync(e,n,r,i,t.fs,t.print,t.printErr),a=o._setMemory;delete o._setMemory,mt.call(this,a,o),t.returnOnExit&&(o.proc_exit=bt.bind(this))}start(t){if(this[_t])throw new Error("WASI instance has already started");this[_t]=!0,Et(this,t);const{_start:e,_initialize:n}=this[yt].exports;let r;i(e,"instance.exports._start"),s(n,"instance.exports._initialize");try{r=e()}catch(t){if(t!==gt)throw t}return r instanceof Promise?r.then((()=>this[gt]),(t=>{if(t!==gt)throw t;return this[gt]})):this[gt]}initialize(t){if(this[_t])throw new Error("WASI instance has already started");this[_t]=!0,Et(this,t);const{_start:e,_initialize:n}=this[yt].exports;if(s(e,"instance.exports._start"),void 0!==n)return i(n,"instance.exports._initialize"),n()}getImportObject(){return{[this[pt]]:this.wasiImport}}}function bt(t){throw this[gt]=t,gt}t.Asyncify=h,t.Memory=G,t.WASI=At,t.WebAssemblyMemory=j,t.asyncifyLoad=function(t,e,n){d(n),n=null!=n?n:{};const r=new h;return l(e,n=r.wrapImports(n)).then((e=>{var i;const s=e.instance.exports.memory||(null===(i=n.env)||void 0===i?void 0:i.memory);return{module:e.module,instance:r.init(s,e.instance,t)}}))},t.asyncifyLoadSync=function(t,e,n){var r;d(n),n=null!=n?n:{};const i=new h,s=_(e,n=i.wrapImports(n)),o=s.instance.exports.memory||(null===(r=n.env)||void 0===r?void 0:r.memory);return{module:s.module,instance:i.init(o,s.instance,t)}},t.createAsyncWASI=async function(t=dt){const e=Object.create(At.prototype),{args:r,env:s,preopens:o,stdio:a,_WASI:c}=It.call(e,t);void 0!==t.asyncify&&(n(t.asyncify,"options.asyncify"),i(t.asyncify.wrapImportFunction,"options.asyncify.wrapImportFunction"));const u=await c.createAsync(r,s,o,a,t.fs,t.print,t.printErr,t.asyncify),f=u._setMemory;return delete u._setMemory,mt.call(e,f,u),t.returnOnExit&&(u.proc_exit=bt.bind(e)),e},t.extendMemory=Y,t.load=l,t.loadSync=_,t.wrapAsyncExport=Z,t.wrapAsyncImport=V,t.wrapExports=function(t,e){return a(t,((t,n)=>{let r="function"!=typeof t;return Array.isArray(e)&&(r=r||-1===e.indexOf(n)),r?t:Z(t)}))},Object.defineProperty(t,"__esModule",{value:!0})}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).wasmUtil={})}(this,(function(t){"use strict";const e="undefined"!=typeof WebAssembly?WebAssembly:"undefined"!=typeof WXWebAssembly?WXWebAssembly:void 0;if(!e)throw new Error("WebAssembly is not supported in this environment");function n(t,e){if(null===t||"object"!=typeof t)throw new TypeError(`${e} must be an object. Received ${null===t?"null":typeof t}`)}function i(t,e){if("string"!=typeof t)throw new TypeError(`${e} must be a string. Received ${null===t?"null":typeof t}`)}function r(t,e){if("function"!=typeof t)throw new TypeError(`${e} must be a function. Received ${null===t?"null":typeof t}`)}function s(t,e){if(void 0!==t)throw new TypeError(`${e} must be undefined. Received ${null===t?"null":typeof t}`)}function o(t){return!(!t||"object"!=typeof t&&"function"!=typeof t||"function"!=typeof t.then)}function a(t,e){const n=Object.create(null);return Object.keys(t).forEach((i=>{const r=t[i];Object.defineProperty(n,i,{enumerable:!0,value:e(r,i)})})),n}function c(t,e,n){return"function"==typeof SharedArrayBuffer&&t.buffer instanceof SharedArrayBuffer||"[object SharedArrayBuffer]"===Object.prototype.toString.call(t.buffer.constructor)?t.slice(e,n):t.subarray(e,n)}const u=["asyncify_get_state","asyncify_start_rewind","asyncify_start_unwind","asyncify_stop_rewind","asyncify_stop_unwind"];function f(t,e,n,i){if("function"!=typeof t.exports[i]||n<=0)return{wasm64:e,dataPtr:16,start:e?32:24,end:1024};const r=t.exports[i],s=e?Number(r(BigInt(16)+BigInt(n))):r(8+n);if(0===s)throw new Error("Allocate asyncify data failed");return e?{wasm64:e,dataPtr:s,start:s+16,end:s+16+n}:{wasm64:e,dataPtr:s,start:s+8,end:s+8+n}}class h{constructor(){this.value=void 0,this.exports=void 0,this.dataPtr=0}init(t,n,i){var r,s;if(this.exports)throw new Error("Asyncify has been initialized");if(!(t instanceof e.Memory))throw new TypeError("Require WebAssembly.Memory object");const o=n.exports;for(let t=0;t<u.length;++t)if("function"!=typeof o[u[t]])throw new TypeError("Invalid asyncify wasm");let a;const c=Boolean(i.wasm64);a=i.tryAllocate?!0===i.tryAllocate?f(n,c,4096,"malloc"):f(n,c,null!==(r=i.tryAllocate.size)&&void 0!==r?r:4096,null!==(s=i.tryAllocate.name)&&void 0!==s?s:"malloc"):{wasm64:c,dataPtr:16,start:c?32:24,end:1024},this.dataPtr=a.dataPtr,c?new BigInt64Array(t.buffer,this.dataPtr).set([BigInt(a.start),BigInt(a.end)]):new Int32Array(t.buffer,this.dataPtr).set([a.start,a.end]),this.exports=this.wrapExports(o,i.wrapExports);const h=Object.create(e.Instance.prototype);return Object.defineProperty(h,"exports",{value:this.exports}),h}assertState(){if(0!==this.exports.asyncify_get_state())throw new Error("Asyncify state error")}wrapImportFunction(t){const e=this;return function(){for(;2===e.exports.asyncify_get_state();)return e.exports.asyncify_stop_rewind(),e.value;e.assertState();const n=t.apply(this,arguments);if(!o(n))return n;e.exports.asyncify_start_unwind(e.dataPtr),e.value=n}}wrapImports(t){const e={};return Object.keys(t).forEach((n=>{const i=t[n],r={};Object.keys(i).forEach((t=>{const e=i[t];r[t]="function"==typeof e?this.wrapImportFunction(e):e})),e[n]=r})),e}wrapExportFunction(t){const e=this;return async function(){e.assertState();let n=t.apply(this,arguments);for(;1===e.exports.asyncify_get_state();)e.exports.asyncify_stop_unwind(),e.value=await e.value,e.assertState(),e.exports.asyncify_start_rewind(e.dataPtr),n=t.call(this);return e.assertState(),n}}wrapExports(t,e){return a(t,((t,n)=>{let i=-1!==u.indexOf(n)||"function"!=typeof t;return Array.isArray(e)&&(i=i||-1===e.indexOf(n)),i?t:this.wrapExportFunction(t)}))}}function d(t){if(t&&"object"!=typeof t)throw new TypeError("imports must be an object or undefined")}function g(t,n){return"undefined"!=typeof wx&&"undefined"!=typeof __wxConfig?e.instantiate(t,n):fetch(t).then((t=>t.arrayBuffer())).then((t=>e.instantiate(t,n)))}function l(t,n){let i;if(d(n),n=null!=n?n:{},t instanceof ArrayBuffer||ArrayBuffer.isView(t))return e.instantiate(t,n);if(t instanceof e.Module)return e.instantiate(t,n).then((e=>({instance:e,module:t})));if("string"!=typeof t&&!(t instanceof URL))throw new TypeError("Invalid source");if("function"==typeof e.instantiateStreaming){let r;try{r=fetch(t),i=e.instantiateStreaming(r,n).catch((()=>g(t,n)))}catch(e){i=g(t,n)}}else i=g(t,n);return i}function _(t,n){let i;if(d(n),n=null!=n?n:{},t instanceof ArrayBuffer||ArrayBuffer.isView(t))i=new e.Module(t);else{if(!(t instanceof WebAssembly.Module))throw new TypeError("Invalid source");i=t}return{instance:new e.Instance(i,n),module:i}}const y=46,p=47;function E(t){return t===p}function I(...t){let e="",n=!1;for(let r=t.length-1;r>=-1&&!n;r--){const s=r>=0?t[r]:"/";i(s,"path"),0!==s.length&&(e=`${s}/${e}`,n=s.charCodeAt(0)===p)}return e=function(t,e,n,i){let r="",s=0,o=-1,a=0,c=0;for(let u=0;u<=t.length;++u){if(u<t.length)c=t.charCodeAt(u);else{if(i(c))break;c=p}if(i(c)){if(o===u-1||1===a);else if(2===a){if(r.length<2||2!==s||r.charCodeAt(r.length-1)!==y||r.charCodeAt(r.length-2)!==y){if(r.length>2){const t=r.indexOf(n);-1===t?(r="",s=0):(r=r.slice(0,t),s=r.length-1-r.indexOf(n)),o=u,a=0;continue}if(0!==r.length){r="",s=0,o=u,a=0;continue}}e&&(r+=r.length>0?`${n}..`:"..",s=2)}else r.length>0?r+=`${n}${t.slice(o+1,u)}`:r=t.slice(o+1,u),s=u-o-1;o=u,a=0}else c===y&&-1!==a?++a:a=-1}return r}(e,!n,"/",E),n?`/${e}`:e.length>0?e:"."}const m={FD_DATASYNC:BigInt(1)<<BigInt(0),FD_READ:BigInt(1)<<BigInt(1),FD_SEEK:BigInt(1)<<BigInt(2),FD_FDSTAT_SET_FLAGS:BigInt(1)<<BigInt(3),FD_SYNC:BigInt(1)<<BigInt(4),FD_TELL:BigInt(1)<<BigInt(5),FD_WRITE:BigInt(1)<<BigInt(6),FD_ADVISE:BigInt(1)<<BigInt(7),FD_ALLOCATE:BigInt(1)<<BigInt(8),PATH_CREATE_DIRECTORY:BigInt(1)<<BigInt(9),PATH_CREATE_FILE:BigInt(1)<<BigInt(10),PATH_LINK_SOURCE:BigInt(1)<<BigInt(11),PATH_LINK_TARGET:BigInt(1)<<BigInt(12),PATH_OPEN:BigInt(1)<<BigInt(13),FD_READDIR:BigInt(1)<<BigInt(14),PATH_READLINK:BigInt(1)<<BigInt(15),PATH_RENAME_SOURCE:BigInt(1)<<BigInt(16),PATH_RENAME_TARGET:BigInt(1)<<BigInt(17),PATH_FILESTAT_GET:BigInt(1)<<BigInt(18),PATH_FILESTAT_SET_SIZE:BigInt(1)<<BigInt(19),PATH_FILESTAT_SET_TIMES:BigInt(1)<<BigInt(20),FD_FILESTAT_GET:BigInt(1)<<BigInt(21),FD_FILESTAT_SET_SIZE:BigInt(1)<<BigInt(22),FD_FILESTAT_SET_TIMES:BigInt(1)<<BigInt(23),PATH_SYMLINK:BigInt(1)<<BigInt(24),PATH_REMOVE_DIRECTORY:BigInt(1)<<BigInt(25),PATH_UNLINK_FILE:BigInt(1)<<BigInt(26),POLL_FD_READWRITE:BigInt(1)<<BigInt(27),SOCK_SHUTDOWN:BigInt(1)<<BigInt(28),SOCK_ACCEPT:BigInt(1)<<BigInt(29)};class A extends Error{constructor(t,e){super(t),this.errno=e}getErrorMessage(){return function(t){switch(t){case 0:return"Success";case 1:return"Argument list too long";case 2:return"Permission denied";case 3:return"Address in use";case 4:return"Address not available";case 5:return"Address family not supported by protocol";case 6:return"Resource temporarily unavailable";case 7:return"Operation already in progress";case 8:return"Bad file descriptor";case 9:return"Bad message";case 10:return"Resource busy";case 11:return"Operation canceled";case 12:return"No child process";case 13:return"Connection aborted";case 14:return"Connection refused";case 15:return"Connection reset by peer";case 16:return"Resource deadlock would occur";case 17:return"Destination address required";case 18:return"Domain error";case 19:return"Quota exceeded";case 20:return"File exists";case 21:return"Bad address";case 22:return"File too large";case 23:return"Host is unreachable";case 24:return"Identifier removed";case 25:return"Illegal byte sequence";case 26:return"Operation in progress";case 27:return"Interrupted system call";case 28:return"Invalid argument";case 29:return"I/O error";case 30:return"Socket is connected";case 31:return"Is a directory";case 32:return"Symbolic link loop";case 33:return"No file descriptors available";case 34:return"Too many links";case 35:return"Message too large";case 36:return"Multihop attempted";case 37:return"Filename too long";case 38:return"Network is down";case 39:return"Connection reset by network";case 40:return"Network unreachable";case 41:return"Too many files open in system";case 42:return"No buffer space available";case 43:return"No such device";case 44:return"No such file or directory";case 45:return"Exec format error";case 46:return"No locks available";case 47:return"Link has been severed";case 48:return"Out of memory";case 49:return"No message of the desired type";case 50:return"Protocol not available";case 51:return"No space left on device";case 52:return"Function not implemented";case 53:return"Socket not connected";case 54:return"Not a directory";case 55:return"Directory not empty";case 56:return"State not recoverable";case 57:return"Not a socket";case 58:return"Not supported";case 59:return"Not a tty";case 60:return"No such device or address";case 61:return"Value too large for data type";case 62:return"Previous owner died";case 63:return"Operation not permitted";case 64:return"Broken pipe";case 65:return"Protocol error";case 66:return"Protocol not supported";case 67:return"Protocol wrong type for socket";case 68:return"Result not representable";case 69:return"Read-only file system";case 70:return"Invalid seek";case 71:return"No such process";case 72:return"Stale file handle";case 73:return"Operation timed out";case 74:return"Text file busy";case 75:return"Cross-device link";case 76:return"Capabilities insufficient";default:return"Unknown error"}}(this.errno)}}Object.defineProperty(A.prototype,"name",{configurable:!0,writable:!0,value:"WasiError"});const b=m.FD_DATASYNC|m.FD_READ|m.FD_SEEK|m.FD_FDSTAT_SET_FLAGS|m.FD_SYNC|m.FD_TELL|m.FD_WRITE|m.FD_ADVISE|m.FD_ALLOCATE|m.PATH_CREATE_DIRECTORY|m.PATH_CREATE_FILE|m.PATH_LINK_SOURCE|m.PATH_LINK_TARGET|m.PATH_OPEN|m.FD_READDIR|m.PATH_READLINK|m.PATH_RENAME_SOURCE|m.PATH_RENAME_TARGET|m.PATH_FILESTAT_GET|m.PATH_FILESTAT_SET_SIZE|m.PATH_FILESTAT_SET_TIMES|m.FD_FILESTAT_GET|m.FD_FILESTAT_SET_TIMES|m.FD_FILESTAT_SET_SIZE|m.PATH_SYMLINK|m.PATH_UNLINK_FILE|m.PATH_REMOVE_DIRECTORY|m.POLL_FD_READWRITE|m.SOCK_SHUTDOWN|m.SOCK_ACCEPT,T=b,w=b,B=b,N=b,S=m.FD_DATASYNC|m.FD_READ|m.FD_SEEK|m.FD_FDSTAT_SET_FLAGS|m.FD_SYNC|m.FD_TELL|m.FD_WRITE|m.FD_ADVISE|m.FD_ALLOCATE|m.FD_FILESTAT_GET|m.FD_FILESTAT_SET_SIZE|m.FD_FILESTAT_SET_TIMES|m.POLL_FD_READWRITE,P=BigInt(0),D=m.FD_FDSTAT_SET_FLAGS|m.FD_SYNC|m.FD_ADVISE|m.PATH_CREATE_DIRECTORY|m.PATH_CREATE_FILE|m.PATH_LINK_SOURCE|m.PATH_LINK_TARGET|m.PATH_OPEN|m.FD_READDIR|m.PATH_READLINK|m.PATH_RENAME_SOURCE|m.PATH_RENAME_TARGET|m.PATH_FILESTAT_GET|m.PATH_FILESTAT_SET_SIZE|m.PATH_FILESTAT_SET_TIMES|m.FD_FILESTAT_GET|m.FD_FILESTAT_SET_TIMES|m.PATH_SYMLINK|m.PATH_UNLINK_FILE|m.PATH_REMOVE_DIRECTORY|m.POLL_FD_READWRITE,F=D|S,U=m.FD_READ|m.FD_FDSTAT_SET_FLAGS|m.FD_WRITE|m.FD_FILESTAT_GET|m.POLL_FD_READWRITE|m.SOCK_SHUTDOWN,v=b,R=m.FD_READ|m.FD_FDSTAT_SET_FLAGS|m.FD_WRITE|m.FD_FILESTAT_GET|m.POLL_FD_READWRITE,L=BigInt(0);function H(t,e,n,i){const r={base:BigInt(0),inheriting:BigInt(0)};if(0===i)throw new A("Unknown file type",28);switch(i){case 4:r.base=S,r.inheriting=P;break;case 3:r.base=D,r.inheriting=F;break;case 6:case 5:r.base=U,r.inheriting=v;break;case 2:-1!==t.indexOf(e)?(r.base=R,r.inheriting=L):(r.base=B,r.inheriting=N);break;case 1:r.base=T,r.inheriting=w;break;default:r.base=BigInt(0),r.inheriting=BigInt(0)}const s=3&n;return 0===s?r.base&=~m.FD_WRITE:1===s&&(r.base&=~m.FD_READ),r}function O(t,e){let n=0;if("number"==typeof e&&e>=0)n=e;else for(let e=0;e<t.length;e++){n+=t[e].length}let i=0;const r=new Uint8Array(n);for(let e=0;e<t.length;e++){const n=t[e];r.set(n,i),i+=n.length}return r}class k{constructor(t,e,n,i,r,s,o,a){this.id=t,this.fd=e,this.path=n,this.realPath=i,this.type=r,this.rightsBase=s,this.rightsInheriting=o,this.preopen=a,this.pos=BigInt(0),this.size=BigInt(0)}seek(t,e){if(0===e)this.pos=BigInt(t);else if(1===e)this.pos+=BigInt(t);else{if(2!==e)throw new A("Unknown whence",29);this.pos=BigInt(this.size)-BigInt(t)}return this.pos}}class C extends k{constructor(t,e,n,i,r,s,o,a,c){super(e,n,i,r,s,o,a,c),this._log=t,this._buf=null}write(t){const e=t;if(this._buf&&(t=O([this._buf,t]),this._buf=null),-1===t.indexOf(10))return this._buf=t,e.byteLength;let n,i=0,r=0;for(;-1!==(n=t.indexOf(10,i));){const e=(new TextDecoder).decode(t.subarray(r,n));this._log(e),i+=n-r+1,r=n+1}return i<t.length&&(this._buf=t.slice(i)),e.byteLength}}function x(t){return t.isBlockDevice()?1:t.isCharacterDevice()?2:t.isDirectory()?3:t.isSocket()?6:t.isFile()?4:t.isSymbolicLink()?7:0}function M(t,e,n){t.setBigUint64(e,n.dev,!0),t.setBigUint64(e+8,n.ino,!0),t.setBigUint64(e+16,BigInt(x(n)),!0),t.setBigUint64(e+24,n.nlink,!0),t.setBigUint64(e+32,n.size,!0),t.setBigUint64(e+40,n.atimeMs*BigInt(1e6),!0),t.setBigUint64(e+48,n.mtimeMs*BigInt(1e6),!0),t.setBigUint64(e+56,n.ctimeMs*BigInt(1e6),!0)}class W{constructor(t){this.used=0,this.size=t.size,this.fds=Array(t.size),this.stdio=[t.in,t.out,t.err],this.print=t.print,this.printErr=t.printErr,this.insertStdio(t.in,0,"<stdin>"),this.insertStdio(t.out,1,"<stdout>"),this.insertStdio(t.err,2,"<stderr>")}insertStdio(t,e,n){const{base:i,inheriting:r}=H(this.stdio,t,2,2),s=this.insert(t,n,n,2,i,r,0);if(s.id!==e)throw new A(`id: ${s.id} !== expected: ${e}`,8);return s}insert(t,e,n,i,r,s,o){var a,c;let u,f=-1;if(this.used>=this.size){const t=2*this.size;this.fds.length=t,f=this.size,this.size=t}else for(let t=0;t<this.size;++t)if(null==this.fds[t]){f=t;break}return u="<stdout>"===e?new C(null!==(a=this.print)&&void 0!==a?a:console.log,f,t,e,n,i,r,s,o):"<stderr>"===e?new C(null!==(c=this.printErr)&&void 0!==c?c:console.error,f,t,e,n,i,r,s,o):new k(f,t,e,n,i,r,s,o),this.fds[f]=u,this.used++,u}get(t,e,n){if(t>=this.size)throw new A("Invalid fd",8);const i=this.fds[t];if(!i||i.id!==t)throw new A("Bad file descriptor",8);if((~i.rightsBase&e)!==BigInt(0)||(~i.rightsInheriting&n)!==BigInt(0))throw new A("Capabilities insufficient",76);return i}remove(t){if(t>=this.size)throw new A("Invalid fd",8);const e=this.fds[t];if(!e||e.id!==t)throw new A("Bad file descriptor",8);this.fds[t]=void 0,this.used--}}class z extends W{constructor(t){super(t),this.fs=t.fs}getFileTypeByFd(t){return x(this.fs.fstatSync(t,{bigint:!0}))}insertPreopen(t,e,n){const i=this.getFileTypeByFd(t);if(3!==i)throw new A(`Preopen not dir: ["${e}", "${n}"]`,54);const r=H(this.stdio,t,0,i);return this.insert(t,e,n,i,r.base,r.inheriting,1)}renumber(t,e){if(t===e)return;if(t>=this.size||e>=this.size)throw new A("Invalid fd",8);const n=this.fds[t],i=this.fds[e];if(!n||!i||n.id!==t||i.id!==e)throw new A("Invalid fd",8);this.fs.closeSync(n.fd),this.fds[t]=this.fds[e],this.fds[t].id=t,this.fds[e]=void 0,this.used--}}class K extends W{constructor(t){super(t)}async getFileTypeByFd(t){return x(await t.stat({bigint:!0}))}async insertPreopen(t,e,n){const i=await this.getFileTypeByFd(t);if(3!==i)throw new A(`Preopen not dir: ["${e}", "${n}"]`,54);const r=H(this.stdio,t.fd,0,i);return this.insert(t,e,n,i,r.base,r.inheriting,1)}async renumber(t,e){if(t===e)return;if(t>=this.size||e>=this.size)throw new A("Invalid fd",8);const n=this.fds[t],i=this.fds[e];if(!n||!i||n.id!==t||i.id!==e)throw new A("Invalid fd",8);await n.fd.close(),this.fds[t]=this.fds[e],this.fds[t].id=t,this.fds[e]=void 0,this.used--}}const j=function(){return e.Memory}();class G extends j{constructor(t){super(t)}get HEAP8(){return new Int8Array(super.buffer)}get HEAPU8(){return new Uint8Array(super.buffer)}get HEAP16(){return new Int16Array(super.buffer)}get HEAPU16(){return new Uint16Array(super.buffer)}get HEAP32(){return new Int32Array(super.buffer)}get HEAPU32(){return new Uint32Array(super.buffer)}get HEAP64(){return new BigInt64Array(super.buffer)}get HEAPU64(){return new BigUint64Array(super.buffer)}get HEAPF32(){return new Float32Array(super.buffer)}get HEAPF64(){return new Float64Array(super.buffer)}get view(){return new DataView(super.buffer)}}function Y(t){return Object.getPrototypeOf(t)===e.Memory.prototype&&Object.setPrototypeOf(t,G.prototype),t}function $(){const t=e.Function;if("function"!=typeof t)throw new Error('WebAssembly.Function is not supported in this environment. If you are using V8 based browser like Chrome, try to specify --js-flags="--wasm-staging --experimental-wasm-stack-switching"');return t}function V(t,e,n){const i=$();if("function"!=typeof t)throw new TypeError("Function required");const r=e.slice(0);return r.unshift("externref"),new i({parameters:r,results:n},t,{suspending:"first"})}function Z(t){const e=$();if("function"!=typeof t)throw new TypeError("Function required");return new e({parameters:[...e.type(t).parameters.slice(1)],results:["externref"]},t,{promising:"first"})}function q(t,e){if(0===t.length||0===e.length)return 0;let n=0,i=e.length-n;for(let r=0;r<t.length;++r){const s=t[r];if(i<s.length)return s.set(e.subarray(n,n+i),0),n+=i,i=0,n;s.set(e.subarray(n,n+s.length),0),n+=s.length,i-=s.length}return n}const X=new WeakMap,Q=new WeakMap,J=new WeakMap;function tt(t){return X.get(t)}function et(t){const e=J.get(t);if(!e)throw new Error("filesystem is unavailable");return e}function nt(t){if(t instanceof A)return t.errno;switch(t.code){case"ENOENT":return 44;case"EBADF":return 8;case"EINVAL":return 28;case"EPERM":return 63;case"EPROTO":return 65;case"EEXIST":return 20;case"ENOTDIR":return 54;case"EMFILE":return 33;case"EACCES":return 2;case"EISDIR":return 31;case"ENOTEMPTY":return 55;case"ENOSYS":return 52}throw t}function it(t,e,n){return function(t,e){return Object.defineProperty(e,"name",{value:t}),e}(e,(function(){let e;try{e=n.apply(t,arguments)}catch(t){return nt(t)}return o(e)?e.then((t=>t),nt):e}))}function rt(t,e,n,i){let r=I(e.realPath,n);if(1==(1&i))try{r=t.readlinkSync(r)}catch(t){if("EINVAL"!==t.code&&"ENOENT"!==t.code)throw t}return r}async function st(t,e,n,i){let r=I(e.realPath,n);if(1==(1&i))try{r=await t.promises.readlink(r)}catch(t){if("EINVAL"!==t.code&&"ENOENT"!==t.code)throw t}return r}const ot=new TextEncoder,at=new TextDecoder,ct=(BigInt(1)<<BigInt(63))-BigInt(1);function ut(){const t=window.prompt();if(null===t)return new Uint8Array;return(new TextEncoder).encode(t+"\n")}function ft(t){return Boolean(-16&t)||3==(3&t)||12==(12&t)}class ht{constructor(t,n,i,r,s,o){this.args_get=it(this,"args_get",(function(t,e){if(t=Number(t),e=Number(e),0===t||0===e)return 28;const{HEAPU8:n,view:i}=tt(this),r=Q.get(this).args;for(let s=0;s<r.length;++s){const o=r[s];i.setInt32(t,e,!0),t+=4;const a=ot.encode(o+"\0");n.set(a,e),e+=a.length}return 0})),this.args_sizes_get=it(this,"args_sizes_get",(function(t,e){if(t=Number(t),e=Number(e),0===t||0===e)return 28;const{view:n}=tt(this),i=Q.get(this).args;return n.setUint32(t,i.length,!0),n.setUint32(e,ot.encode(i.join("\0")+"\0").length,!0),0})),this.environ_get=it(this,"environ_get",(function(t,e){if(t=Number(t),e=Number(e),0===t||0===e)return 28;const{HEAPU8:n,view:i}=tt(this),r=Q.get(this).env;for(let s=0;s<r.length;++s){const o=r[s];i.setInt32(t,e,!0),t+=4;const a=ot.encode(o+"\0");n.set(a,e),e+=a.length}return 0})),this.environ_sizes_get=it(this,"environ_sizes_get",(function(t,e){if(t=Number(t),e=Number(e),0===t||0===e)return 28;const{view:n}=tt(this),i=Q.get(this);return n.setUint32(t,i.env.length,!0),n.setUint32(e,ot.encode(i.env.join("\0")+"\0").length,!0),0})),this.clock_res_get=it(this,"clock_res_get",(function(t,e){if(0===(e=Number(e)))return 28;const{view:n}=tt(this);switch(t){case 0:return n.setBigUint64(e,BigInt(1e6),!0),0;case 1:case 2:case 3:return n.setBigUint64(e,BigInt(1e3),!0),0;default:return 28}})),this.clock_time_get=it(this,"clock_time_get",(function(t,e,n){if(0===(n=Number(n)))return 28;const{view:i}=tt(this);switch(t){case 0:return i.setBigUint64(n,BigInt(Date.now())*BigInt(1e6),!0),0;case 1:case 2:case 3:{const t=performance.now()/1e3,e=Math.trunc(t),r=Math.floor(1e3*(t-e)),s=BigInt(e)*BigInt(1e9)+BigInt(r)*BigInt(1e6);return i.setBigUint64(n,s,!0),0}default:return 28}})),this.fd_advise=it(this,"fd_advise",(function(t,e,n,i){return 52})),this.fd_fdstat_get=it(this,"fd_fdstat_get",(function(t,e){if(0===(e=Number(e)))return 28;const n=Q.get(this).fds.get(t,BigInt(0),BigInt(0)),{view:i}=tt(this);return i.setUint16(e,n.type,!0),i.setUint16(e+2,0,!0),i.setBigUint64(e+8,n.rightsBase,!0),i.setBigUint64(e+16,n.rightsInheriting,!0),0})),this.fd_fdstat_set_flags=it(this,"fd_fdstat_set_flags",(function(t,e){return 52})),this.fd_fdstat_set_rights=it(this,"fd_fdstat_set_rights",(function(t,e,n){const i=Q.get(this).fds.get(t,BigInt(0),BigInt(0));return(e|i.rightsBase)>i.rightsBase||(n|i.rightsInheriting)>i.rightsInheriting?76:(i.rightsBase=e,i.rightsInheriting=n,0)})),this.fd_prestat_get=it(this,"fd_prestat_get",(function(t,e){if(0===(e=Number(e)))return 28;const n=Q.get(this);let i;try{i=n.fds.get(t,BigInt(0),BigInt(0))}catch(t){if(t instanceof A)return t.errno;throw t}if(1!==i.preopen)return 28;const{view:r}=tt(this);return r.setUint32(e,0,!0),r.setUint32(e+4,ot.encode(i.path).length,!0),0})),this.fd_prestat_dir_name=it(this,"fd_prestat_dir_name",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const i=Q.get(this).fds.get(t,BigInt(0),BigInt(0));if(1!==i.preopen)return 8;const r=ot.encode(i.path);if(r.length>n)return 42;const{HEAPU8:s}=tt(this);return s.set(r,e),0})),this.fd_seek=it(this,"fd_seek",(function(t,e,n,i){if(0===(i=Number(i)))return 28;if(0===t||1===t||2===t)return 0;const r=Q.get(this).fds.get(t,m.FD_SEEK,BigInt(0)).seek(e,n),{view:s}=tt(this);return s.setBigUint64(i,r,!0),0})),this.fd_tell=it(this,"fd_tell",(function(t,e){const n=Q.get(this).fds.get(t,m.FD_TELL,BigInt(0)),i=BigInt(n.pos),{view:r}=tt(this);return r.setBigUint64(Number(e),i,!0),0})),this.poll_oneoff=it(this,"poll_oneoff",(function(t,e,n,i){if(t=Number(t),e=Number(e),i=Number(i),n=Number(n),n>>>=0,0===t||0===e||0===n||0===i)return 28;const{view:r}=tt(this);r.setUint32(i,0,!0);let s,o=0,a=BigInt(0),c=BigInt(0),u=0,f=BigInt(0);const h=Array(n);for(o=0;o<n;o++){s=t+48*o;const e=r.getBigUint64(s,!0),n=r.getUint8(s+8),i=r.getUint32(s+16,!0),a=r.getBigUint64(s+24,!0),c=r.getBigUint64(s+32,!0),u=r.getUint16(s+40,!0);h[o]={userdata:e,type:n,u:{clock:{clock_id:i,timeout:a,precision:c,flags:u},fd_readwrite:{fd:i}}}}const d=[];for(o=0;o<n;o++)switch(s=h[o],s.type){case 0:if(1===s.u.clock.flags){const t=BigInt(Date.now())*BigInt(1e6);c=s.u.clock.timeout-t}else c=s.u.clock.timeout;(0===u||c<f)&&(f=c,a=s.userdata,u=1);break;case 1:case 2:d.push(s);break;default:return 28}if(d.length>0){for(o=0;o<d.length;o++){const t=d[o],n=e+32*o;r.setBigUint64(n,t.userdata,!0),r.setUint32(n+8,52,!0),r.setUint32(n+12,t.type,!0),r.setBigUint64(n+16,BigInt(0),!0),r.setUint16(n+24,0,!0),r.setUint32(i,1,!0)}return r.setUint32(i,d.length,!0),0}if(u){!function(t,e){const n=Date.now()+t;let i=!1;for(;Date.now()<n;)if(e()){i=!0;break}}(Number(f/BigInt(1e6)),(()=>!1));const t=e;r.setBigUint64(t,a,!0),r.setUint32(t+8,0,!0),r.setUint32(t+12,0,!0),r.setUint32(i,1,!0)}return 0})),this.proc_exit=it(this,"proc_exit",(function(t){return"object"==typeof process&&null!==process&&"function"==typeof process.exit&&process.exit(t),0})),this.proc_raise=it(this,"proc_raise",(function(t){return 52})),this.sched_yield=it(this,"sched_yield",(function(){return 0})),this.random_get="undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues?it(this,"random_get",(function(t,e){if(0===(t=Number(t)))return 28;e=Number(e);const{HEAPU8:n,view:i}=tt(this);if("function"==typeof SharedArrayBuffer&&n.buffer instanceof SharedArrayBuffer||"[object SharedArrayBuffer]"===Object.prototype.toString.call(n.buffer)){for(let n=t;n<t+e;++n)i.setUint8(n,Math.floor(256*Math.random()));return 0}let r;const s=65536;for(r=0;r+s<e;r+=s)crypto.getRandomValues(n.subarray(t+r,t+r+s));return crypto.getRandomValues(n.subarray(t+r,t+e)),0})):it(this,"random_get",(function(t,e){if(0===(t=Number(t)))return 28;e=Number(e);const{view:n}=tt(this);for(let i=t;i<t+e;++i)n.setUint8(i,Math.floor(256*Math.random()));return 0})),this.sock_recv=it(this,"sock_recv",(function(){return 58})),this.sock_send=it(this,"sock_send",(function(){return 58})),this.sock_shutdown=it(this,"sock_shutdown",(function(){return 58})),this.sock_accept=it(this,"sock_accept",(function(){return 58})),Q.set(this,{fds:i,args:t,env:n}),s&&J.set(this,s);const a=this;function u(t,e,n,i,s){a[t]=r?o?o.wrapImportFunction(it(a,t,n)):V(it(a,t,n),i,s):it(a,t,e)}function f(t,e,n,i){const r=Q.get(this).fds.get(t,m.FD_FILESTAT_SET_TIMES,BigInt(0));return 2==(2&i)&&(e=BigInt(1e6*Date.now())),8==(8&i)&&(n=BigInt(1e6*Date.now())),{fileDescriptor:r,atim:e,mtim:n}}function h(t,e,n,i){const r=(e&(m.FD_READ|m.FD_READDIR))!==BigInt(0),s=(e&(m.FD_DATASYNC|m.FD_WRITE|m.FD_ALLOCATE|m.FD_FILESTAT_SET_SIZE))!==BigInt(0);let o=s?r?2:1:0,a=m.PATH_OPEN,c=e|n;return 0!=(1&t)&&(o|=64,a|=m.PATH_CREATE_FILE),0!=(2&t)&&(o|=65536),0!=(4&t)&&(o|=128),0!=(8&t)&&(o|=512,a|=m.PATH_FILESTAT_SET_SIZE),0!=(1&i)&&(o|=1024),0!=(2&i)&&(c|=m.FD_DATASYNC),0!=(4&i)&&(o|=2048),0!=(8&i)&&(o|=1052672,c|=m.FD_SYNC),0!=(16&i)&&(o|=1052672,c|=m.FD_SYNC),s&&0==(1536&o)&&(c|=m.FD_SEEK),{flags:o,needed_base:a,needed_inheriting:c}}u("fd_allocate",(function(t,e,n){const i=Q.get(this),r=et(this),s=i.fds.get(t,m.FD_ALLOCATE,BigInt(0));return r.fstatSync(s.fd,{bigint:!0}).size<e+n&&r.ftruncateSync(s.fd,Number(e+n)),0}),(async function(t,e,n){const i=Q.get(this).fds.get(t,m.FD_ALLOCATE,BigInt(0)).fd;return(await i.stat({bigint:!0})).size<e+n&&await i.truncate(Number(e+n)),0}),["i32","i64","f64"],["i32"]),u("fd_close",(function(t){const e=Q.get(this),n=e.fds.get(t,BigInt(0),BigInt(0));return et(this).closeSync(n.fd),e.fds.remove(t),0}),(async function(t){const e=Q.get(this),n=e.fds.get(t,BigInt(0),BigInt(0));return await n.fd.close(),e.fds.remove(t),0}),["i32"],["i32"]),u("fd_datasync",(function(t){const e=Q.get(this).fds.get(t,m.FD_DATASYNC,BigInt(0));return et(this).fdatasyncSync(e.fd),0}),(async function(t){const e=Q.get(this).fds.get(t,m.FD_DATASYNC,BigInt(0));return await e.fd.datasync(),0}),["i32"],["i32"]),u("fd_filestat_get",(function(t,e){if(0===(e=Number(e)))return 28;const n=Q.get(this).fds.get(t,m.FD_FILESTAT_GET,BigInt(0)),i=et(this).fstatSync(n.fd,{bigint:!0}),{view:r}=tt(this);return M(r,e,i),0}),(async function(t,e){if(0===(e=Number(e)))return 28;const n=Q.get(this).fds.get(t,m.FD_FILESTAT_GET,BigInt(0)).fd,i=await n.stat({bigint:!0}),{view:r}=tt(this);return M(r,e,i),0}),["i32","i32"],["i32"]),u("fd_filestat_set_size",(function(t,e){const n=Q.get(this).fds.get(t,m.FD_FILESTAT_SET_SIZE,BigInt(0));return et(this).ftruncateSync(n.fd,Number(e)),0}),(async function(t,e){const n=Q.get(this).fds.get(t,m.FD_FILESTAT_SET_SIZE,BigInt(0)).fd;return await n.truncate(Number(e)),0}),["i32","i64"],["i32"]),u("fd_filestat_set_times",(function(t,e,n,i){if(ft(i))return 28;const{fileDescriptor:r,atim:s,mtim:o}=f.call(this,t,e,n,i);return et(this).futimesSync(r.fd,Number(s),Number(o)),0}),(async function(t,e,n,i){if(ft(i))return 28;const{fileDescriptor:r,atim:s,mtim:o}=f.call(this,t,e,n,i),a=r.fd;return await a.utimes(Number(s),Number(o)),0}),["i32","i64","i64","i32"],["i32"]),u("fd_pread",(function(t,e,n,i,r){if(e=Number(e),r=Number(r),0===e&&n||0===r||i>ct)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.FD_READ|m.FD_SEEK,BigInt(0));if(!n)return o.setUint32(r,0,!0),0;let c=0;const u=Array.from({length:Number(n)},((t,n)=>{const i=e+8*n,r=o.getInt32(i,!0),a=o.getUint32(i+4,!0);return c+=a,s.subarray(r,r+a)}));let f=0;const h=(()=>{try{return new Uint8Array(new SharedArrayBuffer(c))}catch(t){return new Uint8Array(c)}})();h._isBuffer=!0;const d=et(this).readSync(a.fd,h,0,h.length,Number(i));return f=h?q(u,h.subarray(0,d)):0,o.setUint32(r,f,!0),0}),(async function(t,e,n,i,r){if(e=Number(e),r=Number(r),0===e&&n||0===r||i>ct)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.FD_READ|m.FD_SEEK,BigInt(0));if(!n)return o.setUint32(r,0,!0),0;let c=0;const u=Array.from({length:Number(n)},((t,n)=>{const i=e+8*n,r=o.getInt32(i,!0),a=o.getUint32(i+4,!0);return c+=a,s.subarray(r,r+a)}));let f=0;const h=new Uint8Array(c);h._isBuffer=!0;const{bytesRead:d}=await a.fd.read(h,0,h.length,Number(i));return f=h?q(u,h.subarray(0,d)):0,o.setUint32(r,f,!0),0}),["i32","i32","i32","i64","i32"],["i32"]),u("fd_pwrite",(function(t,e,n,i,r){if(e=Number(e),r=Number(r),0===e&&n||0===r||i>ct)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.FD_WRITE|m.FD_SEEK,BigInt(0));if(!n)return o.setUint32(r,0,!0),0;const c=O(Array.from({length:Number(n)},((t,n)=>{const i=e+8*n,r=o.getInt32(i,!0),a=o.getUint32(i+4,!0);return s.subarray(r,r+a)}))),u=et(this).writeSync(a.fd,c,0,c.length,Number(i));return o.setUint32(r,u,!0),0}),(async function(t,e,n,i,r){if(e=Number(e),r=Number(r),0===e&&n||0===r||i>ct)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.FD_WRITE|m.FD_SEEK,BigInt(0));if(!n)return o.setUint32(r,0,!0),0;const c=O(Array.from({length:Number(n)},((t,n)=>{const i=e+8*n,r=o.getInt32(i,!0),a=o.getUint32(i+4,!0);return s.subarray(r,r+a)}))),{bytesWritten:u}=await a.fd.write(c,0,c.length,Number(i));return o.setUint32(r,u,!0),0}),["i32","i32","i32","i64","i32"],["i32"]),u("fd_read",(function(t,e,n,i){if(e=Number(e),i=Number(i),0===e&&n||0===i)return 28;const{HEAPU8:r,view:s}=tt(this),o=Q.get(this).fds.get(t,m.FD_READ,BigInt(0));if(!n)return s.setUint32(i,0,!0),0;let a=0;const c=Array.from({length:Number(n)},((t,n)=>{const i=e+8*n,o=s.getInt32(i,!0),c=s.getUint32(i+4,!0);return a+=c,r.subarray(o,o+c)}));let u,f=0;if(0===t){if("undefined"==typeof window||"function"!=typeof window.prompt)return 58;u=ut(),f=u?q(c,u):0}else{u=(()=>{try{return new Uint8Array(new SharedArrayBuffer(a))}catch(t){return new Uint8Array(a)}})(),u._isBuffer=!0;const t=et(this).readSync(o.fd,u,0,u.length,Number(o.pos));f=u?q(c,u.subarray(0,t)):0,o.pos+=BigInt(f)}return s.setUint32(i,f,!0),0}),(async function(t,e,n,i){if(e=Number(e),i=Number(i),0===e&&n||0===i)return 28;const{HEAPU8:r,view:s}=tt(this),o=Q.get(this).fds.get(t,m.FD_READ,BigInt(0));if(!n)return s.setUint32(i,0,!0),0;let a=0;const c=Array.from({length:Number(n)},((t,n)=>{const i=e+8*n,o=s.getInt32(i,!0),c=s.getUint32(i+4,!0);return a+=c,r.subarray(o,o+c)}));let u,f=0;if(0===t){if("undefined"==typeof window||"function"!=typeof window.prompt)return 58;u=ut(),f=u?q(c,u):0}else{u=new Uint8Array(a),u._isBuffer=!0;const{bytesRead:t}=await o.fd.read(u,0,u.length,Number(o.pos));f=u?q(c,u.subarray(0,t)):0,o.pos+=BigInt(f)}return s.setUint32(i,f,!0),0}),["i32","i32","i32","i32"],["i32"]),u("fd_readdir",(function(t,e,n,i,r){if(e=Number(e),n=Number(n),r=Number(r),0===e||0===r)return 0;const s=Q.get(this).fds.get(t,m.FD_READDIR,BigInt(0)),o=et(this),a=o.readdirSync(s.realPath,{withFileTypes:!0}),{HEAPU8:c,view:u}=tt(this);let f=0;for(let t=Number(i);t<a.length;t++){const i=ot.encode(a[t].name),r=o.statSync(I(s.realPath,a[t].name),{bigint:!0}),u=new Uint8Array(24+i.byteLength),h=new DataView(u.buffer);let d;h.setBigUint64(0,BigInt(t+1),!0),h.setBigUint64(8,BigInt(r.ino?r.ino:0),!0),h.setUint32(16,i.byteLength,!0),d=a[t].isFile()?4:a[t].isDirectory()?3:a[t].isSymbolicLink()?7:a[t].isCharacterDevice()?2:a[t].isBlockDevice()?1:a[t].isSocket()?6:0,h.setUint8(20,d),u.set(i,24);const g=u.slice(0,Math.min(u.length,n-f));c.set(g,e+f),f+=g.byteLength}return u.setUint32(r,f,!0),0}),(async function(t,e,n,i,r){if(e=Number(e),n=Number(n),r=Number(r),0===e||0===r)return 0;const s=Q.get(this).fds.get(t,m.FD_READDIR,BigInt(0)),o=et(this),a=await o.promises.readdir(s.realPath,{withFileTypes:!0}),{HEAPU8:c,view:u}=tt(this);let f=0;for(let t=Number(i);t<a.length;t++){const i=ot.encode(a[t].name),r=await o.promises.stat(I(s.realPath,a[t].name),{bigint:!0}),u=new Uint8Array(24+i.byteLength),h=new DataView(u.buffer);let d;h.setBigUint64(0,BigInt(t+1),!0),h.setBigUint64(8,BigInt(r.ino?r.ino:0),!0),h.setUint32(16,i.byteLength,!0),d=a[t].isFile()?4:a[t].isDirectory()?3:a[t].isSymbolicLink()?7:a[t].isCharacterDevice()?2:a[t].isBlockDevice()?1:a[t].isSocket()?6:0,h.setUint8(20,d),u.set(i,24);const g=u.slice(0,Math.min(u.length,n-f));c.set(g,e+f),f+=g.byteLength}return u.setUint32(r,f,!0),0}),["i32","i32","i32","i64","i32"],["i32"]),u("fd_renumber",(function(t,e){return Q.get(this).fds.renumber(e,t),0}),(async function(t,e){const n=Q.get(this);return await n.fds.renumber(e,t),0}),["i32","i32"],["i32"]),u("fd_sync",(function(t){const e=Q.get(this).fds.get(t,m.FD_SYNC,BigInt(0));return et(this).fsyncSync(e.fd),0}),(async function(t){const e=Q.get(this).fds.get(t,m.FD_SYNC,BigInt(0));return await e.fd.sync(),0}),["i32"],["i32"]),u("fd_write",(function(t,e,n,i){if(e=Number(e),i=Number(i),0===e&&n||0===i)return 28;const{HEAPU8:r,view:s}=tt(this),o=Q.get(this).fds.get(t,m.FD_WRITE,BigInt(0));if(!n)return s.setUint32(i,0,!0),0;const a=O(Array.from({length:Number(n)},((t,n)=>{const i=e+8*n,o=s.getInt32(i,!0),a=s.getUint32(i+4,!0);return r.subarray(o,o+a)})));let c;if(1===t||2===t)c=o.write(a);else{c=et(this).writeSync(o.fd,a,0,a.length,Number(o.pos)),o.pos+=BigInt(c)}return s.setUint32(i,c,!0),0}),(async function(t,e,n,i){if(e=Number(e),i=Number(i),0===e&&n||0===i)return 28;const{HEAPU8:r,view:s}=tt(this),o=Q.get(this).fds.get(t,m.FD_WRITE,BigInt(0));if(!n)return s.setUint32(i,0,!0),0;const a=O(Array.from({length:Number(n)},((t,n)=>{const i=e+8*n,o=s.getInt32(i,!0),a=s.getUint32(i+4,!0);return r.subarray(o,o+a)})));let c;return 1===t||2===t?c=o.write(a):(c=await(await o.fd.write(a,0,a.length,Number(o.pos))).bytesWritten,o.pos+=BigInt(c)),s.setUint32(i,c,!0),0}),["i32","i32","i32","i32"],["i32"]),u("path_create_directory",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:i}=tt(this),r=Q.get(this).fds.get(t,m.PATH_CREATE_DIRECTORY,BigInt(0));let s=at.decode(c(i,e,e+n));s=I(r.realPath,s);return et(this).mkdirSync(s),0}),(async function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:i}=tt(this),r=Q.get(this).fds.get(t,m.PATH_CREATE_DIRECTORY,BigInt(0));let s=at.decode(c(i,e,e+n));s=I(r.realPath,s);const o=et(this);return await o.promises.mkdir(s),0}),["i32","i32","i32"],["i32"]),u("path_filestat_get",(function(t,e,n,i,r){if(n=Number(n),i=Number(i),r=Number(r),0===n||0===r)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.PATH_FILESTAT_GET,BigInt(0));let u=at.decode(c(s,n,n+i));const f=et(this);let h;return u=I(a.realPath,u),h=1==(1&e)?f.statSync(u,{bigint:!0}):f.lstatSync(u,{bigint:!0}),M(o,r,h),0}),(async function(t,e,n,i,r){if(n=Number(n),i=Number(i),r=Number(r),0===n||0===r)return 28;const{HEAPU8:s,view:o}=tt(this),a=Q.get(this).fds.get(t,m.PATH_FILESTAT_GET,BigInt(0));let u=at.decode(c(s,n,n+i));const f=et(this);let h;return u=I(a.realPath,u),h=1==(1&e)?await f.promises.stat(u,{bigint:!0}):await f.promises.lstat(u,{bigint:!0}),M(o,r,h),0}),["i32","i32","i32","i32","i32"],["i32"]),u("path_filestat_set_times",(function(t,e,n,i,r,s,o){if(n=Number(n),i=Number(i),0===n)return 28;const{HEAPU8:a}=tt(this),u=Q.get(this).fds.get(t,m.PATH_FILESTAT_SET_TIMES,BigInt(0));if(ft(o))return 28;const f=et(this),h=rt(f,u,at.decode(c(a,n,n+i)),e);return 2==(2&o)&&(r=BigInt(1e6*Date.now())),8==(8&o)&&(s=BigInt(1e6*Date.now())),f.utimesSync(h,Number(r),Number(s)),0}),(async function(t,e,n,i,r,s,o){if(n=Number(n),i=Number(i),0===n)return 28;const{HEAPU8:a}=tt(this),u=Q.get(this).fds.get(t,m.PATH_FILESTAT_SET_TIMES,BigInt(0));if(ft(o))return 28;const f=et(this),h=await st(f,u,at.decode(c(a,n,n+i)),e);return 2==(2&o)&&(r=BigInt(1e6*Date.now())),8==(8&o)&&(s=BigInt(1e6*Date.now())),await f.promises.utimes(h,Number(r),Number(s)),0}),["i32","i32","i32","i32","i64","i64","i32"],["i32"]),u("path_link",(function(t,e,n,i,r,s,o){if(n=Number(n),i=Number(i),s=Number(s),o=Number(o),0===n||0===s)return 28;const a=Q.get(this);let u,f;t===r?u=f=a.fds.get(t,m.PATH_LINK_SOURCE|m.PATH_LINK_TARGET,BigInt(0)):(u=a.fds.get(t,m.PATH_LINK_SOURCE,BigInt(0)),f=a.fds.get(r,m.PATH_LINK_TARGET,BigInt(0)));const{HEAPU8:h}=tt(this),d=et(this),g=rt(d,u,at.decode(c(h,n,n+i)),e),l=I(f.realPath,at.decode(c(h,s,s+o)));return d.linkSync(g,l),0}),(async function(t,e,n,i,r,s,o){if(n=Number(n),i=Number(i),s=Number(s),o=Number(o),0===n||0===s)return 28;const a=Q.get(this);let u,f;t===r?u=f=a.fds.get(t,m.PATH_LINK_SOURCE|m.PATH_LINK_TARGET,BigInt(0)):(u=a.fds.get(t,m.PATH_LINK_SOURCE,BigInt(0)),f=a.fds.get(r,m.PATH_LINK_TARGET,BigInt(0)));const{HEAPU8:h}=tt(this),d=et(this),g=await st(d,u,at.decode(c(h,n,n+i)),e),l=I(f.realPath,at.decode(c(h,s,s+o)));return await d.promises.link(g,l),0}),["i32","i32","i32","i32","i32","i32","i32"],["i32"]),u("path_open",(function(t,e,n,i,r,s,o,a,u){if(n=Number(n),u=Number(u),0===n||0===u)return 28;i=Number(i),s=BigInt(s),o=BigInt(o);const{flags:f,needed_base:d,needed_inheriting:g}=h(r,s,o,a),l=Q.get(this),_=l.fds.get(t,d,g),y=tt(this),p=y.HEAPU8,E=at.decode(c(p,n,n+i)),I=et(this),m=rt(I,_,E,e),A=I.openSync(m,f,438),b=l.fds.getFileTypeByFd(A);if(3!==b&&(0!=(2&r)||m.endsWith("/")))return 54;const{base:T,inheriting:w}=H(l.fds.stdio,A,f,b),B=l.fds.insert(A,m,m,b,s&T,o&w,0),N=I.fstatSync(A,{bigint:!0});N.isFile()&&(B.size=N.size,0!=(1024&f)&&(B.pos=N.size));return y.view.setInt32(u,B.id,!0),0}),(async function(t,e,n,i,r,s,o,a,u){if(n=Number(n),u=Number(u),0===n||0===u)return 28;i=Number(i),s=BigInt(s),o=BigInt(o);const{flags:f,needed_base:d,needed_inheriting:g}=h(r,s,o,a),l=Q.get(this),_=l.fds.get(t,d,g),y=tt(this),p=y.HEAPU8,E=at.decode(c(p,n,n+i)),I=et(this),m=await st(I,_,E,e),A=await I.promises.open(m,f,438),b=await l.fds.getFileTypeByFd(A);if(0!=(2&r)&&3!==b)return 54;const{base:T,inheriting:w}=H(l.fds.stdio,A.fd,f,b),B=l.fds.insert(A,m,m,b,s&T,o&w,0),N=await A.stat({bigint:!0});N.isFile()&&(B.size=N.size,0!=(1024&f)&&(B.pos=N.size));return y.view.setInt32(u,B.id,!0),0}),["i32","i32","i32","i32","i32","i64","i64","i32","i32"],["i32"]),u("path_readlink",(function(t,e,n,i,r,s){if(e=Number(e),n=Number(n),i=Number(i),r=Number(r),s=Number(s),0===e||0===i||0===s)return 28;const{HEAPU8:o,view:a}=tt(this),u=Q.get(this).fds.get(t,m.PATH_READLINK,BigInt(0));let f=at.decode(c(o,e,e+n));f=I(u.realPath,f);const h=et(this).readlinkSync(f),d=ot.encode(h),g=Math.min(d.length,r);return g>=r?42:(o.set(d.subarray(0,g),i),o[i+g]=0,a.setUint32(s,g,!0),0)}),(async function(t,e,n,i,r,s){if(e=Number(e),n=Number(n),i=Number(i),r=Number(r),s=Number(s),0===e||0===i||0===s)return 28;const{HEAPU8:o,view:a}=tt(this),u=Q.get(this).fds.get(t,m.PATH_READLINK,BigInt(0));let f=at.decode(c(o,e,e+n));f=I(u.realPath,f);const h=et(this),d=await h.promises.readlink(f),g=ot.encode(d),l=Math.min(g.length,r);return l>=r?42:(o.set(g.subarray(0,l),i),o[i+l]=0,a.setUint32(s,l,!0),0)}),["i32","i32","i32","i32","i32","i32"],["i32"]),u("path_remove_directory",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:i}=tt(this),r=Q.get(this).fds.get(t,m.PATH_REMOVE_DIRECTORY,BigInt(0));let s=at.decode(c(i,e,e+n));s=I(r.realPath,s);return et(this).rmdirSync(s),0}),(async function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:i}=tt(this),r=Q.get(this).fds.get(t,m.PATH_REMOVE_DIRECTORY,BigInt(0));let s=at.decode(c(i,e,e+n));s=I(r.realPath,s);const o=et(this);return await o.promises.rmdir(s),0}),["i32","i32","i32"],["i32"]),u("path_rename",(function(t,e,n,i,r,s){if(e=Number(e),n=Number(n),r=Number(r),s=Number(s),0===e||0===r)return 28;const o=Q.get(this);let a,u;t===i?a=u=o.fds.get(t,m.PATH_RENAME_SOURCE|m.PATH_RENAME_TARGET,BigInt(0)):(a=o.fds.get(t,m.PATH_RENAME_SOURCE,BigInt(0)),u=o.fds.get(i,m.PATH_RENAME_TARGET,BigInt(0)));const{HEAPU8:f}=tt(this),h=I(a.realPath,at.decode(c(f,e,e+n))),d=I(u.realPath,at.decode(c(f,r,r+s)));return et(this).renameSync(h,d),0}),(async function(t,e,n,i,r,s){if(e=Number(e),n=Number(n),r=Number(r),s=Number(s),0===e||0===r)return 28;const o=Q.get(this);let a,u;t===i?a=u=o.fds.get(t,m.PATH_RENAME_SOURCE|m.PATH_RENAME_TARGET,BigInt(0)):(a=o.fds.get(t,m.PATH_RENAME_SOURCE,BigInt(0)),u=o.fds.get(i,m.PATH_RENAME_TARGET,BigInt(0)));const{HEAPU8:f}=tt(this),h=I(a.realPath,at.decode(c(f,e,e+n))),d=I(u.realPath,at.decode(c(f,r,r+s))),g=et(this);return await g.promises.rename(h,d),0}),["i32","i32","i32","i32","i32","i32"],["i32"]),u("path_symlink",(function(t,e,n,i,r){if(t=Number(t),e=Number(e),i=Number(i),r=Number(r),0===t||0===i)return 28;const{HEAPU8:s}=tt(this),o=Q.get(this).fds.get(n,m.PATH_SYMLINK,BigInt(0)),a=at.decode(c(s,t,t+e));if(a.length>0&&"/"===a[0])return 63;let u=at.decode(c(s,i,i+r));u=I(o.realPath,u);return et(this).symlinkSync(a,u),0}),(async function(t,e,n,i,r){if(t=Number(t),e=Number(e),i=Number(i),r=Number(r),0===t||0===i)return 28;const{HEAPU8:s}=tt(this),o=Q.get(this).fds.get(n,m.PATH_SYMLINK,BigInt(0)),a=at.decode(c(s,t,t+e));let u=at.decode(c(s,i,i+r));u=I(o.realPath,u);const f=et(this);return await f.promises.symlink(a,u),0}),["i32","i32","i32","i32","i32"],["i32"]),u("path_unlink_file",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:i}=tt(this),r=Q.get(this).fds.get(t,m.PATH_UNLINK_FILE,BigInt(0));let s=at.decode(c(i,e,e+n));s=I(r.realPath,s);return et(this).unlinkSync(s),0}),(async function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:i}=tt(this),r=Q.get(this).fds.get(t,m.PATH_UNLINK_FILE,BigInt(0));let s=at.decode(c(i,e,e+n));s=I(r.realPath,s);const o=et(this);return await o.promises.unlink(s),0}),["i32","i32","i32"],["i32"]),this._setMemory=function(t){if(!(t instanceof e.Memory))throw new TypeError('"instance.exports.memory" property must be a WebAssembly.Memory');X.set(a,Y(t))}}static createSync(t,e,n,i,r,s,o){const a=new z({size:3,in:i[0],out:i[1],err:i[2],fs:r,print:s,printErr:o}),c=new ht(t,e,a,!1,r);if(n.length>0)for(let t=0;t<n.length;++t){const e=r.realpathSync(n[t].realPath,"utf8"),i=r.openSync(e,"r",438);a.insertPreopen(i,n[t].mappedPath,e)}return c}static async createAsync(t,e,n,i,r,s,o,a){const c=new K({size:3,in:i[0],out:i[1],err:i[2],print:s,printErr:o}),u=new ht(t,e,c,!0,r,a);if(n.length>0)for(let t=0;t<n.length;++t){const e=n[t],i=await r.promises.realpath(e.realPath),s=await r.promises.open(i,"r",438);await c.insertPreopen(s,e.mappedPath,i)}return u}}const dt=Object.freeze(Object.create(null)),gt=Symbol("kExitCode"),lt=Symbol("kSetMemory"),_t=Symbol("kStarted"),yt=Symbol("kInstance"),pt=Symbol("kBindingName");function Et(t){var e;let s;if(n(t,"options"),void 0!==t.version)switch(i(t.version,"options.version"),t.version){case"unstable":s=ht,this[pt]="wasi_unstable";break;case"preview1":s=ht,this[pt]="wasi_snapshot_preview1";break;default:throw new TypeError(`unsupported WASI version "${t.version}"`)}else s=ht,this[pt]="wasi_snapshot_preview1";void 0!==t.args&&function(t,e){if(!Array.isArray(t))throw new TypeError(`${e} must be an array. Received ${null===t?"null":typeof t}`)}(t.args,"options.args");const o=(null!==(e=t.args)&&void 0!==e?e:[]).map(String),a=[];void 0!==t.env&&(n(t.env,"options.env"),Object.entries(t.env).forEach((({0:t,1:e})=>{void 0!==e&&a.push(`${t}=${e}`)})));const c=[];if(void 0!==t.preopens&&(n(t.preopens,"options.preopens"),Object.entries(t.preopens).forEach((({0:t,1:e})=>c.push({mappedPath:String(t),realPath:String(e)})))),c.length>0){if(void 0===t.fs)throw new Error("filesystem is disabled, can not preopen directory");try{n(t.fs,"options.fs")}catch(t){throw new TypeError("Node.js fs like implementation is not provided")}}void 0!==t.print&&r(t.print,"options.print"),void 0!==t.printErr&&r(t.printErr,"options.printErr"),void 0!==t.returnOnExit&&function(t,e){if("boolean"!=typeof t)throw new TypeError(`${e} must be a boolean. Received ${null===t?"null":typeof t}`)}(t.returnOnExit,"options.returnOnExit");return{args:o,env:a,preopens:c,stdio:[0,1,2],_WASI:s}}function It(t,e){this[lt]=t,this.wasiImport=e,this[_t]=!1,this[gt]=0,this[yt]=void 0}class mt{constructor(t=dt){const{args:e,env:n,preopens:i,stdio:r,_WASI:s}=Et.call(this,t),o=s.createSync(e,n,i,r,t.fs,t.print,t.printErr),a=o._setMemory;delete o._setMemory,It.call(this,a,o),t.returnOnExit&&(o.proc_exit=At.bind(this))}finalizeBindings(t,e){var i,{memory:r=(null===(i=null==t?void 0:t.exports)||void 0===i?void 0:i.memory)}=void 0===e?{}:e;if(this[_t])throw new Error("WASI instance has already started");n(t,"instance"),n(t.exports,"instance.exports"),this[lt](r),this[yt]=t,this[_t]=!0}start(t){this.finalizeBindings(t);const{_start:e,_initialize:n}=this[yt].exports;let i;r(e,"instance.exports._start"),s(n,"instance.exports._initialize");try{i=e()}catch(t){if(t!==gt)throw t}return i instanceof Promise?i.then((()=>this[gt]),(t=>{if(t!==gt)throw t;return this[gt]})):this[gt]}initialize(t){this.finalizeBindings(t);const{_start:e,_initialize:n}=this[yt].exports;if(s(e,"instance.exports._start"),void 0!==n)return r(n,"instance.exports._initialize"),n()}getImportObject(){return{[this[pt]]:this.wasiImport}}}function At(t){throw this[gt]=t,gt}t.Asyncify=h,t.Memory=G,t.WASI=mt,t.WebAssemblyMemory=j,t.asyncifyLoad=function(t,e,n){d(n),n=null!=n?n:{};const i=new h;return l(e,n=i.wrapImports(n)).then((e=>{var r;const s=e.instance.exports.memory||(null===(r=n.env)||void 0===r?void 0:r.memory);return{module:e.module,instance:i.init(s,e.instance,t)}}))},t.asyncifyLoadSync=function(t,e,n){var i;d(n),n=null!=n?n:{};const r=new h,s=_(e,n=r.wrapImports(n)),o=s.instance.exports.memory||(null===(i=n.env)||void 0===i?void 0:i.memory);return{module:s.module,instance:r.init(o,s.instance,t)}},t.createAsyncWASI=async function(t=dt){const e=Object.create(mt.prototype),{args:i,env:s,preopens:o,stdio:a,_WASI:c}=Et.call(e,t);void 0!==t.asyncify&&(n(t.asyncify,"options.asyncify"),r(t.asyncify.wrapImportFunction,"options.asyncify.wrapImportFunction"));const u=await c.createAsync(i,s,o,a,t.fs,t.print,t.printErr,t.asyncify),f=u._setMemory;return delete u._setMemory,It.call(e,f,u),t.returnOnExit&&(u.proc_exit=At.bind(e)),e},t.extendMemory=Y,t.load=l,t.loadSync=_,t.wrapAsyncExport=Z,t.wrapAsyncImport=V,t.wrapExports=function(t,e){return a(t,((t,n)=>{let i="function"!=typeof t;return Array.isArray(e)&&(i=i||-1===e.indexOf(n)),i?t:Z(t)}))},Object.defineProperty(t,"__esModule",{value:!0})}));
@@ -10,12 +10,6 @@ const kSetMemory = Symbol('kSetMemory');
10
10
  const kStarted = Symbol('kStarted');
11
11
  const kInstance = Symbol('kInstance');
12
12
  const kBindingName = Symbol('kBindingName');
13
- function setupInstance(self, instance) {
14
- (0, util_1.validateObject)(instance, 'instance');
15
- (0, util_1.validateObject)(instance.exports, 'instance.exports');
16
- self[kInstance] = instance;
17
- self[kSetMemory](instance.exports.memory);
18
- }
19
13
  function validateOptions(options) {
20
14
  var _a;
21
15
  (0, util_1.validateObject)(options, 'options');
@@ -120,13 +114,21 @@ class WASI {
120
114
  wrap.proc_exit = wasiReturnOnProcExit.bind(this);
121
115
  }
122
116
  }
123
- // Must not export _initialize, must export _start
124
- start(instance) {
117
+ finalizeBindings(instance, _a) {
118
+ var _b;
119
+ var { memory = (_b = instance === null || instance === void 0 ? void 0 : instance.exports) === null || _b === void 0 ? void 0 : _b.memory } = _a === void 0 ? {} : _a;
125
120
  if (this[kStarted]) {
126
121
  throw new Error('WASI instance has already started');
127
122
  }
123
+ (0, util_1.validateObject)(instance, 'instance');
124
+ (0, util_1.validateObject)(instance.exports, 'instance.exports');
125
+ this[kSetMemory](memory);
126
+ this[kInstance] = instance;
128
127
  this[kStarted] = true;
129
- setupInstance(this, instance);
128
+ }
129
+ // Must not export _initialize, must export _start
130
+ start(instance) {
131
+ this.finalizeBindings(instance);
130
132
  const { _start, _initialize } = this[kInstance].exports;
131
133
  (0, util_1.validateFunction)(_start, 'instance.exports._start');
132
134
  (0, util_1.validateUndefined)(_initialize, 'instance.exports._initialize');
@@ -151,11 +153,7 @@ class WASI {
151
153
  }
152
154
  // Must not export _start, may optionally export _initialize
153
155
  initialize(instance) {
154
- if (this[kStarted]) {
155
- throw new Error('WASI instance has already started');
156
- }
157
- this[kStarted] = true;
158
- setupInstance(this, instance);
156
+ this.finalizeBindings(instance);
159
157
  const { _start, _initialize } = this[kInstance].exports;
160
158
  (0, util_1.validateUndefined)(_start, 'instance.exports._start');
161
159
  if (_initialize !== undefined) {
@@ -233,7 +233,7 @@ class WASI {
233
233
  case types_1.WasiClockid.MONOTONIC:
234
234
  case types_1.WasiClockid.PROCESS_CPUTIME_ID:
235
235
  case types_1.WasiClockid.THREAD_CPUTIME_ID: {
236
- const t = performance.now();
236
+ const t = performance.now() / 1000;
237
237
  const s = Math.trunc(t);
238
238
  const ms = Math.floor((t - s) * 1000);
239
239
  const result = BigInt(s) * BigInt(1000000000) + BigInt(ms) * BigInt(1000000);
@@ -1251,7 +1251,9 @@ class WASI {
1251
1251
  const resolved_path = resolvePathSync(fs, fileDescriptor, pathString, dirflags);
1252
1252
  const r = fs.openSync(resolved_path, flagsRes, 0o666);
1253
1253
  const filetype = wasi.fds.getFileTypeByFd(r);
1254
- if ((o_flags & types_1.WasiFileControlFlag.O_DIRECTORY) !== 0 && filetype !== types_1.WasiFileType.DIRECTORY) {
1254
+ if ((filetype !== types_1.WasiFileType.DIRECTORY) &&
1255
+ ((o_flags & types_1.WasiFileControlFlag.O_DIRECTORY) !== 0 ||
1256
+ (resolved_path.endsWith('/')))) {
1255
1257
  return types_1.WasiErrno.ENOTDIR;
1256
1258
  }
1257
1259
  const { base: max_base, inheriting: max_inheriting } = (0, rights_1.getRights)(wasi.fds.stdio, r, flagsRes, filetype);
@@ -1440,6 +1442,9 @@ class WASI {
1440
1442
  const wasi = _wasi.get(this);
1441
1443
  const fileDescriptor = wasi.fds.get(fd, types_1.WasiRights.PATH_SYMLINK, BigInt(0));
1442
1444
  const oldPath = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, old_path, old_path + old_path_len));
1445
+ if (oldPath.length > 0 && oldPath[0] === '/') {
1446
+ return types_1.WasiErrno.EPERM;
1447
+ }
1443
1448
  let newPath = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, new_path, new_path + new_path_len));
1444
1449
  newPath = (0, path_1.resolve)(fileDescriptor.realPath, newPath);
1445
1450
  const fs = getFs(this);
@@ -7,12 +7,6 @@ const kSetMemory = Symbol('kSetMemory');
7
7
  const kStarted = Symbol('kStarted');
8
8
  const kInstance = Symbol('kInstance');
9
9
  const kBindingName = Symbol('kBindingName');
10
- function setupInstance(self, instance) {
11
- validateObject(instance, 'instance');
12
- validateObject(instance.exports, 'instance.exports');
13
- self[kInstance] = instance;
14
- self[kSetMemory](instance.exports.memory);
15
- }
16
10
  function validateOptions(options) {
17
11
  var _a;
18
12
  validateObject(options, 'options');
@@ -117,13 +111,21 @@ export class WASI {
117
111
  wrap.proc_exit = wasiReturnOnProcExit.bind(this);
118
112
  }
119
113
  }
120
- // Must not export _initialize, must export _start
121
- start(instance) {
114
+ finalizeBindings(instance, _a) {
115
+ var _b;
116
+ var { memory = (_b = instance === null || instance === void 0 ? void 0 : instance.exports) === null || _b === void 0 ? void 0 : _b.memory } = _a === void 0 ? {} : _a;
122
117
  if (this[kStarted]) {
123
118
  throw new Error('WASI instance has already started');
124
119
  }
120
+ validateObject(instance, 'instance');
121
+ validateObject(instance.exports, 'instance.exports');
122
+ this[kSetMemory](memory);
123
+ this[kInstance] = instance;
125
124
  this[kStarted] = true;
126
- setupInstance(this, instance);
125
+ }
126
+ // Must not export _initialize, must export _start
127
+ start(instance) {
128
+ this.finalizeBindings(instance);
127
129
  const { _start, _initialize } = this[kInstance].exports;
128
130
  validateFunction(_start, 'instance.exports._start');
129
131
  validateUndefined(_initialize, 'instance.exports._initialize');
@@ -148,11 +150,7 @@ export class WASI {
148
150
  }
149
151
  // Must not export _start, may optionally export _initialize
150
152
  initialize(instance) {
151
- if (this[kStarted]) {
152
- throw new Error('WASI instance has already started');
153
- }
154
- this[kStarted] = true;
155
- setupInstance(this, instance);
153
+ this.finalizeBindings(instance);
156
154
  const { _start, _initialize } = this[kInstance].exports;
157
155
  validateUndefined(_start, 'instance.exports._start');
158
156
  if (_initialize !== undefined) {
@@ -230,7 +230,7 @@ export class WASI {
230
230
  case WasiClockid.MONOTONIC:
231
231
  case WasiClockid.PROCESS_CPUTIME_ID:
232
232
  case WasiClockid.THREAD_CPUTIME_ID: {
233
- const t = performance.now();
233
+ const t = performance.now() / 1000;
234
234
  const s = Math.trunc(t);
235
235
  const ms = Math.floor((t - s) * 1000);
236
236
  const result = BigInt(s) * BigInt(1000000000) + BigInt(ms) * BigInt(1000000);
@@ -1248,7 +1248,9 @@ export class WASI {
1248
1248
  const resolved_path = resolvePathSync(fs, fileDescriptor, pathString, dirflags);
1249
1249
  const r = fs.openSync(resolved_path, flagsRes, 0o666);
1250
1250
  const filetype = wasi.fds.getFileTypeByFd(r);
1251
- if ((o_flags & WasiFileControlFlag.O_DIRECTORY) !== 0 && filetype !== WasiFileType.DIRECTORY) {
1251
+ if ((filetype !== WasiFileType.DIRECTORY) &&
1252
+ ((o_flags & WasiFileControlFlag.O_DIRECTORY) !== 0 ||
1253
+ (resolved_path.endsWith('/')))) {
1252
1254
  return WasiErrno.ENOTDIR;
1253
1255
  }
1254
1256
  const { base: max_base, inheriting: max_inheriting } = getRights(wasi.fds.stdio, r, flagsRes, filetype);
@@ -1437,6 +1439,9 @@ export class WASI {
1437
1439
  const wasi = _wasi.get(this);
1438
1440
  const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_SYMLINK, BigInt(0));
1439
1441
  const oldPath = decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len));
1442
+ if (oldPath.length > 0 && oldPath[0] === '/') {
1443
+ return WasiErrno.EPERM;
1444
+ }
1440
1445
  let newPath = decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len));
1441
1446
  newPath = resolve(fileDescriptor.realPath, newPath);
1442
1447
  const fs = getFs(this);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tybys/wasm-util",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "WASI polyfill for browser and some wasm util",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./dist/wasm-util.esm-bundler.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailwindcss/oxide-wasm32-wasi",
3
- "version": "4.1.10",
3
+ "version": "4.1.12",
4
4
  "cpu": [
5
5
  "wasm32"
6
6
  ],
@@ -27,11 +27,11 @@
27
27
  },
28
28
  "browser": "tailwindcss-oxide.wasi-browser.js",
29
29
  "dependencies": {
30
- "@napi-rs/wasm-runtime": "^0.2.10",
31
- "@emnapi/core": "^1.4.3",
32
- "@emnapi/runtime": "^1.4.3",
33
- "@tybys/wasm-util": "^0.9.0",
34
- "@emnapi/wasi-threads": "^1.0.2",
30
+ "@napi-rs/wasm-runtime": "^0.2.12",
31
+ "@emnapi/core": "^1.4.5",
32
+ "@emnapi/runtime": "^1.4.5",
33
+ "@tybys/wasm-util": "^0.10.0",
34
+ "@emnapi/wasi-threads": "^1.0.4",
35
35
  "tslib": "^2.8.0"
36
36
  },
37
37
  "bundledDependencies": [
Binary file