e57-js 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.mjs +1 -1
- package/dist/index.mjs +8 -8
- package/package.json +1 -1
package/dist/index.browser.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import P from"./libe57-js.js";var s=class a{static LibE57=null;static RootDir="/root ";static Init(){let e=typeof window<"u";return a.LibE57!==null?Promise.resolve():P().then(function(t){e||(t.FS.mkdir(a.RootDir),t.FS.mount(t.FS.filesystems.NODEFS,{root:"/"},a.RootDir)),a.LibE57=t})}};var y=typeof process<"u"&&!!process.versions?.node;function d(a){if(!y)return a;let e=setInterval(()=>{},1<<30);return a.finally(()=>clearInterval(e))}var o=()=>{throw new Error("path is not available in the browser")};var m=()=>{throw new Error("fs is not available in the browser")};var l=class{constructor(e,t){this.e57Reader=e,this.scanIdx=t,this._header=null}GetHeader(){return this._header||(this._header=this.e57Reader.GetData3DHeader(this.scanIdx)),this._header}Destroy(){this._header&&this._header.delete()}ReadScan(e=!0){return this.ReadPoints(Number(this.GetHeader().pointCount),e)}ReadScanSync(e=!0){let t=Number(this.GetHeader().pointCount);return this.ReadPointsSync(t,e)}ReadPoints(e,t=!0){return d(this.e57Reader.ReadScan(this.scanIdx,e,t))}ReadPointsSync(e,t=!0){return this.e57Reader.ReadScanSync(this.scanIdx,e,t)}ScanPoints(e,t,r=!0){let i=Number(this.GetHeader().pointCount),h=Math.ceil(i/e);if(t){for(let n=0;n<h;n++){let c=this.ReadPointsSync(e,r);t(c),c.delete()}return}let u=[];for(let n=0;n<h;n++)u.push(this.ReadPointsSync(e,r));return u}},_=class{constructor(e,t){this._e57Reader=e,this._imageIdx=t,this._header=null}GetHeader(){return this._header||(this._header=this._e57Reader.GetImage2DHeader(this._imageIdx)),this._header}Destroy(){this._header&&this._header.delete()}ReadImage(){return d(this._e57Reader.ReadImage(this._imageIdx))}ReadImageSync(){return this._e57Reader.ReadImageSync(this._imageIdx)}Release(e){e&&typeof e.free=="function"&&e.free()}ToBase64(){return this.ReadImage().then(e=>{let t=Buffer.from(e).toString("base64");return this.Release(e),t})}Extension(){switch(this.GetHeader().imageType){case s.LibE57.Image2DType.ImageJPEG:return".jpeg";case s.LibE57.Image2DType.ImagePNG:return".png";case s.LibE57.Image2DType.ImageMaskPNG:return".png";case s.LibE57.Image2DType.E57_JPEG_IMAGE:return".jpeg";case s.LibE57.Image2DType.E57_PNG_IMAGE:return".png";case s.LibE57.Image2DType.E57_PNG_IMAGE_MASK:return".png";default:return".jpg"}}Save(e){if(typeof window<"u")throw new Error("Save() is not available in the browser \u2014 use ReadImage() to get a Uint8Array instead");let t=this.Extension(),r=e.replace(o.extname(e),t);return this.ReadImage().then(i=>m.promises.writeFile(r,i).then(()=>{this.Release(i)}))}},f=class a{constructor(e,t=!1){let r=t?e:o.join(s.RootDir,o.resolve(e));this._reader=new s.LibE57.E57Reader(r);var i=this.GetData3DCount();this.scans=new Array(i);for(var h=0;h<i;h++)this.scans[h]=new l(this._reader,h);var u=this.GetImage2DCount();this.images=new Array(u);for(var n=0;n<u;n++)this.images[n]=new _(this._reader,n)}static FromBuffer(e){let t="/"+crypto.randomUUID()+".e57";s.LibE57.FS.writeFile(t,e);let r=new a(t,!0);return r._memFsFilePath=t,r}GetHeader(){return this._reader.GetHeader()}GetData3DCount(){return Number(this._reader.GetData3DCount())}GetImage2DCount(){return Number(this._reader.GetImage2DCount())}GetScan(e){return this.scans[e]}GetImage(e){return this.images[e]}Close(){for(let e of this.scans)e.Destroy();for(let e of this.images)e.Destroy();this._reader&&(this._reader.Close(),this._reader.delete()),this._memFsFilePath&&s.LibE57.FS.unlink(this._memFsFilePath),this.scans=null,this.images=null}};var p=()=>{throw new Error("sharp is not available in the browser")};var g=class a{constructor(e,t,r){this._imgPath=e,this._imgType=t,this._imgProjection=r,this._imageHeader=new s.LibE57.ImageHeader}static FromBuffer(e,t,r){let i=new a(null,t,r);return i._buffer=e,i._width=null,i._height=null,i}GetPath(){return this._imgPath}SetPath(e){this._imgPath=e}GetType(){return this._imgType}SetType(e){this._imgType=e}GetProjection(){return this._imgProjection}SetProjection(e){this._imgProjection=e}_resolveMetadata(){return this._width!=null&&this._height!=null?Promise.resolve({width:this._width,height:this._height}):this._metadataPromise?this._metadataPromise:(typeof window<"u"?this._metadataPromise=this.GetBuffer().then(e=>{let t=new Blob([e]);return createImageBitmap(t).then(r=>{let i={width:r.width,height:r.height};return r.close(),this._width=i.width,this._height=i.height,i})}):this._metadataPromise=this.GetBuffer().then(e=>p(e).metadata()).then(e=>(this._width=e.width,this._height=e.height,e)),this._metadataPromise)}GetMetadata(){return this._resolveMetadata()}GetDimensions(){return this._resolveMetadata().then(e=>[e.width,e.height])}GetWidth(){return this._resolveMetadata().then(e=>e.width)}GetHeight(){return this._resolveMetadata().then(e=>e.height)}GetPose(){return this._imageHeader.pose}SetPose(e){this._imageHeader.pose=e}GetName(){return this._imageHeader.name}SetName(e){this._imageHeader.name=e}GetGuid(){return this._imageHeader.guid}SetGuid(e){this._imageHeader.guid=e}GetHeader(){return this._imageHeader}SetHeader(e){this._imageHeader.delete(),this._imageHeader=e}GetBufferSync(){return this._buffer?this._buffer:new Uint8Array(m.readFileSync(this.GetPath()))}GetBuffer(){return this._buffer?Promise.resolve(this._buffer):m.promises.readFile(this.GetPath()).then(e=>new Uint8Array(e))}SetTranslation(e,t,r){this._imageHeader.pose.translation.x=e,this._imageHeader.pose.translation.y=t,this._imageHeader.pose.translation.z=r}SetRotation(e,t,r,i){this._imageHeader.pose.rotation.w=e,this._imageHeader.pose.rotation.x=t,this._imageHeader.pose.rotation.y=r,this._imageHeader.pose.rotation.z=i}Destroy(){this._imageHeader.delete(),this._imageHeader=null,this._buffer=null}},w=class{constructor(){this._header=new s.LibE57.Data3D,this._points=[]}GetHeader(){return this._header}SetHeader(e){this._header&&this._header.delete(),this._header=e}GetPoints(){return this._points}AddPoint(e){this._points&&this._points.push(e)}Destroy(){this._header&&(this._header.delete(),this._header=null);for(let e of this._points)e&&e.delete();this._points=[]}},G=class a{constructor(e,t=!1){let r=crypto.randomUUID();this._bufferFileMemFSFilePath="/"+r+".e57";let i=t?this._bufferFileMemFSFilePath:o.join(s.RootDir,o.resolve(e));this._writer=new s.LibE57.E57Writer(i),this._toBuffer=t}static ToBuffer(){return new a("",!0)}AddImage(e){return Promise.all([e.GetBuffer(),e.GetMetadata()]).then(([t,r])=>d(this._writer.AddImage(e.GetHeader(),e.GetType(),e.GetProjection(),0,t,t.length,r.width,r.height)).then(Number))}AddScanSync(e){let t=e.GetHeader(),r=e.GetPoints();return Number(this._writer.AddScanSync(t,r))}AddScan(e){let t=e.GetHeader(),r=e.GetPoints();return d(this._writer.AddScan(t,r)).then(Number)}Close(){if(this._writer&&(this._writer.Close(),this._writer.delete()),this._toBuffer){let e=s.LibE57.FS.readFile(this._bufferFileMemFSFilePath);return s.LibE57.FS.unlink(this._bufferFileMemFSFilePath),e}}};export{s as E57,f as E57Reader,_ as E57ReaderImage,l as E57ReaderScan,G as E57Writer,g as E57WriterImage,w as E57WriterScan};
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
async function
|
|
2
|
-
`),
|
|
3
|
-
`)}var ge=
|
|
4
|
-
`)}else console.warn(...e)}(()=>{var e=new Int16Array(1),r=new Int8Array(e.buffer);e[0]=25459,(r[0]!==115||r[1]!==99)&&q("Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)")})();function ir(e){Object.getOwnPropertyDescriptor(f,e)||Object.defineProperty(f,e,{configurable:!0,set(){q(`Attempt to set \`Module.${e}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`)}})}function $(e){return()=>h(!1,`call to '${e}' via reference taken before Wasm module initialization`)}function Se(e){Object.getOwnPropertyDescriptor(f,e)&&q(`\`Module.${e}\` was supplied but \`${e}\` not included in INCOMING_MODULE_JS_API`)}function gi(e){return e==="FS_createPath"||e==="FS_createDataFile"||e==="FS_createPreloadedFile"||e==="FS_preloadFile"||e==="FS_unlink"||e==="addRunDependency"||e==="FS_createLazyFile"||e==="FS_createDevice"||e==="removeRunDependency"}function yi(e){St(e)}function St(e){w||Object.getOwnPropertyDescriptor(f,e)||Object.defineProperty(f,e,{configurable:!0,get(){var r=`'${e}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;gi(e)&&(r+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),q(r)}})}function wi(){function e(){var t=0;return Ne&&typeof De<"u"&&(t=De()),`w:${Tt},t:${we(t)}:`}var r=Dr;Dr=(...t)=>r(e(),...t)}wi();function c(){fe.buffer!=H.buffer&&ar()}var Rr,Ir;if(M&&w){globalThis.self=globalThis;var kt=er.parentPort;globalThis.postMessage||(kt.on("message",e=>globalThis.onmessage?.({data:e})),globalThis.postMessage=e=>kt.postMessage(e)),process.on("uncaughtException",e=>{postMessage({cmd:"uncaughtException",error:e}),process.exit(1)})}var Tt=0,Ft;if(w){let e=function(r){try{var t=r.data,n=t.cmd;if(n==="load"){Tt=t.workerID;let i=[];self.onmessage=a=>i.push(a),Ft=()=>{postMessage({cmd:"loaded"});for(let a of i)e(a);self.onmessage=e};for(let a of t.handlers)(!f[a]||f[a].proxy)&&(f[a]=(...s)=>{postMessage({cmd:"callHandler",handler:a,args:s})},a=="print"&&(ge=f[a]),a=="printErr"&&(C=f[a]));fe=t.wasmMemory,ar(),be=t.wasmModule,At(),Pr()}else if(n==="run"){h(t.pthread_ptr),Ri(t.pthread_ptr),ot(t.pthread_ptr,0,0,1,0,0),P.threadInitTLS(),nt(t.pthread_ptr),$r||(Vn(),$r=!0);try{Ii(t.start_routine,t.arg)}catch(i){if(i!="unwind")throw i}}else t.target==="setimmediate"||(n==="checkMailbox"?$r&&kr():n&&(C(`worker: received unknown command ${n}`),C(t)))}catch(i){throw C(`worker: onmessage() captured an uncaught exception: ${i}`),i?.stack&&C(i.stack),Xn(),i}};var $r=!1;self.onunhandledrejection=r=>{throw r.reason||r},self.onmessage=e}var Ne=!1;function ar(){var e=fe.buffer;H=new Int8Array(e),ne=new Int16Array(e),f.HEAPU8=te=new Uint8Array(e),ke=new Uint16Array(e),S=new Int32Array(e),y=new Uint32Array(e),or=new Float32Array(e),Me=new Float64Array(e),Z=new BigInt64Array(e),Dt=new BigUint64Array(e)}function Ei(){if(!w){if(f.wasmMemory)fe=f.wasmMemory;else{var e=f.INITIAL_MEMORY||16777216;h(e>=65536,`INITIAL_MEMORY should be larger than STACK_SIZE, was ${e}! (STACK_SIZE=65536)`),fe=new WebAssembly.Memory({initial:e/65536,maximum:32768,shared:!0})}ar()}}h(globalThis.Int32Array&&globalThis.Float64Array&&Int32Array.prototype.subarray&&Int32Array.prototype.set,"JS engine does not provide full typed array support");function bi(){if(h(!w),f.preRun)for(typeof f.preRun=="function"&&(f.preRun=[f.preRun]);f.preRun.length;)Mt(f.preRun.shift());ir("preRun"),$t(Nt)}function Pt(){if(h(!Ne),Ne=!0,w)return Ft();Ge(),T.root=o.mount(T,{},null),!f.noFSInit&&!o.initialized&&o.init(),pe.init(),Re.__wasm_call_ctors(),o.ignorePermissions=!1}function Si(){if(Ge(),!w){if(f.postRun)for(typeof f.postRun=="function"&&(f.postRun=[f.postRun]);f.postRun.length;)Di(f.postRun.shift());ir("postRun"),$t(jt)}}function q(e){f.onAbort?.(e),e=`Aborted(${e})`,C(e),Ie=!0;var r=new WebAssembly.RuntimeError(e);throw Ir?.(r),r}function J(e,r){return(...t)=>{h(Ne,`native function \`${e}\` called before runtime initialization`);var n=Re[e];return h(n,`exported native function \`${e}\` not found`),h(t.length<=r,`native function \`${e}\` called with ${t.length} args but expects ${r}`),n(...t)}}var Nr;function ki(){return f.locateFile?pi("libe57-js.wasm"):new URL("libe57-js.wasm",import.meta.url).href}function Ti(e){if(e==Nr&&He)return new Uint8Array(He);if(Be)return Be(e);throw"both async and sync fetching of the wasm failed"}async function Fi(e){if(!He)try{var r=await tr(e);return new Uint8Array(r)}catch{}return Ti(e)}async function Pi(e,r){try{var t=await Fi(e),n=await WebAssembly.instantiate(t,r);return n}catch(i){C(`failed to asynchronously prepare wasm: ${i}`),nr(e)&&C(`warning: Loading from a file URI (${e}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`),q(i)}}async function Ci(e,r,t){if(!e&&!M)try{var n=fetch(r,{credentials:"same-origin"}),i=await WebAssembly.instantiateStreaming(n,t);return i}catch(a){C(`wasm streaming compile failed: ${a}`),C("falling back to ArrayBuffer instantiation")}return Pi(r,t)}function Ct(){es();var e={env:_t,wasi_snapshot_preview1:_t};return e}async function At(){function e(l,d){return Re=l.exports,$i(Re._emscripten_tls_init),Qo(Re),be=d,Re}var r=f;function t(l){return h(f===r,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),r=null,e(l.instance,l.module)}var n=Ct();if(f.instantiateWasm)return new Promise((l,d)=>{try{f.instantiateWasm(n,(u,_)=>{l(e(u,_))})}catch(u){C(`Module.instantiateWasm callback failed with error: ${u}`),d(u)}});if(w){h(be,"wasmModule should have been received via postMessage");var i=new WebAssembly.Instance(be,Ct());return e(i,be)}Nr??=ki();var a=await Ci(He,Nr,n),s=t(a);return s}class Ot{name="ExitStatus";constructor(r){this.message=`Program terminated with exit(${r})`,this.status=r}}var ne,S,Z,H,or,Me,ke,y,Dt,te,Rt=e=>{e.terminate(),e.onmessage=r=>{var t=r.data.cmd;C(`received "${t}" command from terminated worker: ${e.workerID}`)}},It=e=>{h(!w,"cleanupThread() should only be called from the main thread"),h(e,"null pthread_ptr passed to cleanupThread");var r=P.pthreads[e];h(r),P.returnWorkerToPool(r)},$t=e=>{for(;e.length>0;)e.shift()(f)},Nt=[],Mt=e=>Nt.push(e),Te=0,ze=null,xe={},ye=null,Mr=e=>{if(Te--,f.monitorRunDependencies?.(Te),h(e,"removeRunDependency requires an ID"),h(xe[e]),delete xe[e],Te==0&&(ye!==null&&(clearInterval(ye),ye=null),ze)){var r=ze;ze=null,r()}},xr=e=>{Te++,f.monitorRunDependencies?.(Te),h(e,"addRunDependency requires an ID"),h(!xe[e]),xe[e]=1,ye===null&&globalThis.setInterval&&(ye=setInterval(()=>{if(Ie){clearInterval(ye),ye=null;return}var r=!1;for(var t in xe)r||(r=!0,C("still waiting on run dependencies:")),C(`dependency: ${t}`);r&&C("(end of list)")},1e4),ye.unref?.())},xt=e=>{h(!w,"spawnThread() should only be called from the main thread"),h(e.pthread_ptr,"spawnThread called with null pthread ptr");var r=P.getNewWorker();if(!r)return 6;h(!r.pthread_ptr),P.runningWorkers.push(r),P.pthreads[e.pthread_ptr]=r,r.pthread_ptr=e.pthread_ptr;var t={cmd:"run",start_routine:e.startRoutine,arg:e.arg,pthread_ptr:e.pthread_ptr};return M&&r.unref(),r.postMessage(t,e.transferList),0},sr=0,lr=()=>Wr||sr>0,B=()=>ut(),L=e=>ti(e),Ai=e=>ni(e),K=(e,r,t,...n)=>{var i=8*n.length*2,a=B(),s=Ai(i),l=s>>3;for(var d of n)typeof d=="bigint"?((c(),Z)[l++]=1n,(c(),Z)[l++]=d):((c(),Z)[l++]=0n,(c(),Me)[l++]=d);var u=Jn(e,r,i,s,t);return L(a),u};function Lt(e){if(w)return K(0,0,1,e);$e=e,lr()||(P.terminateAllThreads(),f.onExit?.(e),Ie=!0),Ar(e,new Ot(e))}function Wt(e){if(w)return K(1,0,0,e);Lr(e)}var Oi=(e,r)=>{if($e=e,Os(),w)throw h(!r),Wt(e),"unwind";if(lr()&&!r){var t=`program exited (with status: ${e}), but keepRuntimeAlive() is set (counter=${sr}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;Ir?.(t),C(t)}Lt(e)},Lr=Oi,Ut=!Atomics.waitAsync||globalThis.navigator?.userAgent&&Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2])<91;function we(e){return h(typeof e=="number",`ptrToString expects a number, got ${typeof e}`),e>>>=0,"0x"+e.toString(16).padStart(8,"0")}var P={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},nextWorkerID:1,init(){w||P.initMainThread()},initMainThread(){for(var e=2;e--;)P.allocateUnusedWorker();Mt(async()=>{var r=P.loadWasmModuleToAllWorkers();xr("loading-workers"),await r,Mr("loading-workers")})},terminateAllThreads:()=>{h(!w,"terminateAllThreads() should only be called from the main thread");for(var e of P.runningWorkers)Rt(e);for(var e of P.unusedWorkers)Rt(e);P.unusedWorkers=[],P.runningWorkers=[],P.pthreads={}},terminateRuntime:()=>{h(!w,"terminateRuntime() should only be called from the main thread"),P.terminateAllThreads();var e=De();Kn(0,0,0,1),Ut||Atomics.notify((c(),S),e>>2)},returnWorkerToPool:e=>{var r=e.pthread_ptr;delete P.pthreads[r],P.unusedWorkers.push(e),P.runningWorkers.splice(P.runningWorkers.indexOf(e),1),e.pthread_ptr=0,Zn(r)},threadInitTLS(){P.tlsInitFunctions.forEach(e=>e())},loadWasmModuleToWorker:e=>new Promise(r=>{e.onmessage=a=>{var s=a.data,l=s.cmd;if(s.targetThread&&s.targetThread!=De()){var d=P.pthreads[s.targetThread];d?d.postMessage(s,s.transferList):C(`worker sent message (${l}) to pthread (${s.targetThread}) that no longer exists`);return}l==="checkMailbox"?kr():l==="spawnThread"?xt(s):l==="cleanupThread"?In(()=>It(s.thread)):l==="loaded"?(e.loaded=!0,M&&!e.pthread_ptr&&e.unref(),r(e)):s.target==="setimmediate"?e.postMessage(s):l==="uncaughtException"?e.onerror(s.error):l==="callHandler"?f[s.handler](...s.args):l&&C(`worker sent an unknown command ${l}`)},e.onerror=a=>{var s="worker sent an error!";throw e.pthread_ptr&&(s=`Pthread ${we(e.pthread_ptr)} sent an error!`),C(`${s} ${a.filename}:${a.lineno}: ${a.message}`),a},M&&(e.on("message",a=>e.onmessage({data:a})),e.on("error",a=>e.onerror(a))),h(fe instanceof WebAssembly.Memory,"wasmMemory should have been loaded by now"),h(be instanceof WebAssembly.Module,"wasmModule should have been loaded by now");var t=[],n=["onExit","onAbort","print","printErr"];for(var i of n)f.propertyIsEnumerable(i)&&t.push(i);e.postMessage({cmd:"load",handlers:t,wasmMemory:fe,wasmModule:be,workerID:e.workerID})}),async loadWasmModuleToAllWorkers(){return w?void 0:Promise.all(P.unusedWorkers.map(P.loadWasmModuleToWorker))},allocateUnusedWorker(){var e;if(f.mainScriptUrlOrBlob){var r=f.mainScriptUrlOrBlob;typeof r!="string"&&(r=URL.createObjectURL(r)),e=new Worker(r,{type:"module",workerData:"em-pthread",name:"em-pthread-"+P.nextWorkerID})}else e=new Worker(new URL("libe57-js.js",import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread-"+P.nextWorkerID});e.workerID=P.nextWorkerID++,P.unusedWorkers.push(e)},getNewWorker(){return P.unusedWorkers.length==0&&(M||C("Tried to spawn a new thread, but the thread pool is exhausted.\nThis might result in a deadlock unless some threads eventually exit or the code explicitly breaks out to the event loop.\nIf you want to increase the pool size, use setting `-sPTHREAD_POOL_SIZE=...`.\nIf you want to throw an explicit error instead of the risk of deadlocking in those cases, use setting `-sPTHREAD_POOL_SIZE_STRICT=2`."),P.allocateUnusedWorker(),P.loadWasmModuleToWorker(P.unusedWorkers[0])),P.unusedWorkers.pop()}},jt=[],Di=e=>jt.push(e);function Ri(e){var r=(c(),y)[e+48>>2],t=(c(),y)[e+52>>2],n=r-t;h(r!=0),h(n!=0),h(r>n,"stackHigh must be higher then stackLow"),ri(r,n),L(r),Et()}function Bs(e,r="i8"){switch(r.endsWith("*")&&(r="*"),r){case"i1":return(c(),H)[e];case"i8":return(c(),H)[e];case"i16":return(c(),ne)[e>>1];case"i32":return(c(),S)[e>>2];case"i64":return(c(),Z)[e>>3];case"float":return(c(),or)[e>>2];case"double":return(c(),Me)[e>>3];case"*":return(c(),y)[e>>2];default:q(`invalid type for getValue: ${r}`)}}var Bt=[],W=e=>{var r=Bt[e];return r||(Bt[e]=r=ft.get(e)),h(ft.get(e)==r,"table mirror is out of date"),r},Ii=(e,r)=>{sr=0,Wr=0;var t=W(e)(r);Ge();function n(i){if(lr()){$e=i;return}ct(i)}n(t)},Wr=!0,$i=e=>P.tlsInitFunctions.push(e);function Hs(e,r,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":(c(),H)[e]=r;break;case"i8":(c(),H)[e]=r;break;case"i16":(c(),ne)[e>>1]=r;break;case"i32":(c(),S)[e>>2]=r;break;case"i64":(c(),Z)[e>>3]=BigInt(r);break;case"float":(c(),or)[e>>2]=r;break;case"double":(c(),Me)[e>>3]=r;break;case"*":(c(),y)[e>>2]=r;break;default:q(`invalid type for setValue: ${t}`)}}var Fe=e=>{Fe.shown||={},Fe.shown[e]||(Fe.shown[e]=1,M&&(e="warning: "+e),C(e))},fe,Ht=globalThis.TextDecoder&&new TextDecoder,Gt=(e,r,t,n)=>{var i=r+t;if(n)return i;for(;e[r]&&!(r>=i);)++r;return r},Le=(e,r=0,t,n)=>{var i=Gt(e,r,t,n);if(i-r>16&&e.buffer&&Ht)return Ht.decode(e.buffer instanceof ArrayBuffer?e.subarray(r,i):e.slice(r,i));for(var a="";r<i;){var s=e[r++];if(!(s&128)){a+=String.fromCharCode(s);continue}var l=e[r++]&63;if((s&224)==192){a+=String.fromCharCode((s&31)<<6|l);continue}var d=e[r++]&63;if((s&240)==224?s=(s&15)<<12|l<<6|d:((s&248)!=240&&Fe(`Invalid UTF-8 leading byte ${we(s)} encountered when deserializing a UTF-8 string in wasm memory to a JS string!`),s=(s&7)<<18|l<<12|d<<6|e[r++]&63),s<65536)a+=String.fromCharCode(s);else{var u=s-65536;a+=String.fromCharCode(55296|u>>10,56320|u&1023)}}return a},_e=(e,r,t)=>(h(typeof e=="number",`UTF8ToString expects a number (got ${typeof e})`),e?Le((c(),te),e,r,t):""),Ni=(e,r,t,n)=>q(`Assertion failed: ${_e(e)}, at: `+[r?_e(r):"unknown filename",t,n?_e(n):"unknown function"]),Ur=[],zt=0,Mi=e=>{var r=new Vt(e);return r.get_caught()||(r.set_caught(!0),zt--),r.set_rethrown(!1),Ur.push(r),ai(e)},xi=()=>{U(0,0),h(Ur.length>0);var e=Ur.pop();ii(e.excPtr)},jr=e=>(setTempRet0(0),0),Li=()=>jr([]),Wi=e=>jr([e]),Ui=(e,r)=>jr([e,r]);class Vt{constructor(r){this.excPtr=r,this.ptr=r-24}set_type(r){(c(),y)[this.ptr+4>>2]=r}get_type(){return(c(),y)[this.ptr+4>>2]}set_destructor(r){(c(),y)[this.ptr+8>>2]=r}get_destructor(){return(c(),y)[this.ptr+8>>2]}set_caught(r){r=r?1:0,(c(),H)[this.ptr+12]=r}get_caught(){return(c(),H)[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,(c(),H)[this.ptr+13]=r}get_rethrown(){return(c(),H)[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)}set_adjusted_ptr(r){(c(),y)[this.ptr+16>>2]=r}get_adjusted_ptr(){return(c(),y)[this.ptr+16>>2]}}var ji=(e,r,t)=>{var n=new Vt(e);n.init(r,t),zt++,h(!1,"Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.")};function qt(e,r,t,n){return w?K(2,0,1,e,r,t,n):Kt(e,r,t,n)}var Bi=()=>!!globalThis.SharedArrayBuffer,Kt=(e,r,t,n)=>{if(!Bi())return Dr("pthread_create: environment does not support SharedArrayBuffer, pthreads are not available"),6;var i=[],a=0;if(w&&(i.length===0||a))return qt(e,r,t,n);if(a)return a;var s={startRoutine:t,pthread_ptr:e,arg:n,transferList:i};return w?(s.cmd="spawnThread",postMessage(s,i),0):xt(s)},Hi=e=>{h(!1,"Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.")},Gi=()=>{if(M){var e=le("node:crypto");return r=>e.randomFillSync(r)}return r=>(r.set(crypto.getRandomValues(new Uint8Array(r.byteLength))),0)},Br=e=>(Br=Gi())(e),I={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var i=e[n];i==="."?e.splice(n,1):i===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=I.isAbs(e),t=e.slice(-1)==="/";return e=I.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=I.splitPath(e),t=r[0],n=r[1];return!t&&!n?".":(n&&(n=n.slice(0,-1)),t+n)},basename:e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>I.normalize(e.join("/")),join2:(e,r)=>I.normalize(e+"/"+r)},We={resolve:(...e)=>{for(var r="",t=!1,n=e.length-1;n>=-1&&!t;n--){var i=n>=0?e[n]:o.cwd();if(typeof i!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";r=i+"/"+r,t=I.isAbs(i)}return r=I.normalizeArray(r.split("/").filter(a=>!!a),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=We.resolve(e).slice(1),r=We.resolve(r).slice(1);function t(u){for(var _=0;_<u.length&&u[_]==="";_++);for(var p=u.length-1;p>=0&&u[p]==="";p--);return _>p?[]:u.slice(_,p-_+1)}for(var n=t(e.split("/")),i=t(r.split("/")),a=Math.min(n.length,i.length),s=a,l=0;l<a;l++)if(n[l]!==i[l]){s=l;break}for(var d=[],l=s;l<n.length;l++)d.push("..");return d=d.concat(i.slice(s)),d.join("/")}},Hr=[],Pe=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r},Xt=(e,r,t,n)=>{if(h(typeof e=="string",`stringToUTF8Array expects a string (got ${typeof e})`),!(n>0))return 0;for(var i=t,a=t+n-1,s=0;s<e.length;++s){var l=e.codePointAt(s);if(l<=127){if(t>=a)break;r[t++]=l}else if(l<=2047){if(t+1>=a)break;r[t++]=192|l>>6,r[t++]=128|l&63}else if(l<=65535){if(t+2>=a)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63}else{if(t+3>=a)break;l>1114111&&Fe(`Invalid Unicode code point ${we(l)} encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).`),r[t++]=240|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63,s++}}return r[t]=0,t-i},Gr=(e,r,t)=>{var n=t>0?t:Pe(e)+1,i=new Array(n),a=Xt(e,i,0,i.length);return r&&(i.length=a),i},zi=()=>{if(!Hr.length){var e=null;if(M){var r=256,t=Buffer.alloc(r),n=0,i=process.stdin.fd;try{n=x.readSync(i,t,0,r)}catch(a){if(a.toString().includes("EOF"))n=0;else throw a}n>0&&(e=t.slice(0,n).toString("utf-8"))}else globalThis.window?.prompt&&(e=window.prompt("Input: "),e!==null&&(e+=`
|
|
5
|
-
`));if(!e)return null;Hr=Gr(e,!0)}return Hr.shift()},pe={ttys:[],init(){},shutdown(){},register(e,r){pe.ttys[e]={input:[],output:[],ops:r},o.registerDevice(e,pe.stream_ops)},stream_ops:{open(e){var r=pe.ttys[e.node.rdev];if(!r)throw new o.ErrnoError(43);e.tty=r,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,r,t,n,i){if(!e.tty||!e.tty.ops.get_char)throw new o.ErrnoError(60);for(var a=0,s=0;s<n;s++){var l;try{l=e.tty.ops.get_char(e.tty)}catch{throw new o.ErrnoError(29)}if(l===void 0&&a===0)throw new o.ErrnoError(6);if(l==null)break;a++,r[t+s]=l}return a&&(e.node.atime=Date.now()),a},write(e,r,t,n,i){if(!e.tty||!e.tty.ops.put_char)throw new o.ErrnoError(60);try{for(var a=0;a<n;a++)e.tty.ops.put_char(e.tty,r[t+a])}catch{throw new o.ErrnoError(29)}return n&&(e.node.mtime=e.node.ctime=Date.now()),a}},default_tty_ops:{get_char(e){return zi()},put_char(e,r){r===null||r===10?(ge(Le(e.output)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output?.length>0&&(ge(Le(e.output)),e.output=[])},ioctl_tcgets(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(e,r,t){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,r){r===null||r===10?(C(Le(e.output)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output?.length>0&&(C(Le(e.output)),e.output=[])}}},zr=e=>{q("internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported")},F={ops_table:null,mount(e){return F.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(o.isBlkdev(t)||o.isFIFO(t))throw new o.ErrnoError(63);F.ops_table||={dir:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr,lookup:F.node_ops.lookup,mknod:F.node_ops.mknod,rename:F.node_ops.rename,unlink:F.node_ops.unlink,rmdir:F.node_ops.rmdir,readdir:F.node_ops.readdir,symlink:F.node_ops.symlink},stream:{llseek:F.stream_ops.llseek}},file:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr},stream:{llseek:F.stream_ops.llseek,read:F.stream_ops.read,write:F.stream_ops.write,mmap:F.stream_ops.mmap,msync:F.stream_ops.msync}},link:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr,readlink:F.node_ops.readlink},stream:{}},chrdev:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr},stream:o.chrdev_stream_ops}};var i=o.createNode(e,r,t,n);return o.isDir(i.mode)?(i.node_ops=F.ops_table.dir.node,i.stream_ops=F.ops_table.dir.stream,i.contents={}):o.isFile(i.mode)?(i.node_ops=F.ops_table.file.node,i.stream_ops=F.ops_table.file.stream,i.usedBytes=0,i.contents=F.emptyFileContents??=new Uint8Array(0)):o.isLink(i.mode)?(i.node_ops=F.ops_table.link.node,i.stream_ops=F.ops_table.link.stream):o.isChrdev(i.mode)&&(i.node_ops=F.ops_table.chrdev.node,i.stream_ops=F.ops_table.chrdev.stream),i.atime=i.mtime=i.ctime=Date.now(),e&&(e.contents[r]=i,e.atime=e.mtime=e.ctime=i.atime),i},getFileDataAsTypedArray(e){return h(o.isFile(e.mode),"getFileDataAsTypedArray called on non-file"),e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,r){var t=e.contents.length;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t&&(r=Math.max(r,256));var i=F.getFileDataAsTypedArray(e);e.contents=new Uint8Array(r),e.contents.set(i)}},resizeFileStorage(e,r){if(e.usedBytes!=r){var t=e.contents;e.contents=new Uint8Array(r),e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r}},node_ops:{getattr(e){var r={};return r.dev=o.isChrdev(e.mode)?e.id:1,r.ino=e.id,r.mode=e.mode,r.nlink=1,r.uid=0,r.gid=0,r.rdev=e.rdev,o.isDir(e.mode)?r.size=4096:o.isFile(e.mode)?r.size=e.usedBytes:o.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.atime),r.mtime=new Date(e.mtime),r.ctime=new Date(e.ctime),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){for(let t of["mode","atime","mtime","ctime"])r[t]!=null&&(e[t]=r[t]);r.size!==void 0&&F.resizeFileStorage(e,r.size)},lookup(e,r){throw new o.ErrnoError(44)},mknod(e,r,t,n){return F.createNode(e,r,t,n)},rename(e,r,t){var n;try{n=o.lookupNode(r,t)}catch{}if(n){if(o.isDir(e.mode))for(var i in n.contents)throw new o.ErrnoError(55);o.hashRemoveNode(n)}delete e.parent.contents[e.name],r.contents[t]=e,e.name=t,r.ctime=r.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,r){delete e.contents[r],e.ctime=e.mtime=Date.now()},rmdir(e,r){var t=o.lookupNode(e,r);for(var n in t.contents)throw new o.ErrnoError(55);delete e.contents[r],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,r,t){var n=F.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!o.isLink(e.mode))throw new o.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,i){var a=e.node.contents;if(i>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-i,n);return h(s>=0),r.set(a.subarray(i,i+s),t),s},write(e,r,t,n,i,a){if(h(r.subarray,"FS.write expects a TypedArray"),r.buffer===(c(),H).buffer&&(a=!1),!n)return 0;var s=e.node;return s.mtime=s.ctime=Date.now(),a?(h(i===0,"canOwn must imply no weird position inside the file"),s.contents=r.subarray(t,t+n),s.usedBytes=n):s.usedBytes===0&&i===0?(s.contents=r.slice(t,t+n),s.usedBytes=n):(F.expandFileStorage(s,i+n),s.contents.set(r.subarray(t,t+n),i),s.usedBytes=Math.max(s.usedBytes,i+n)),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&o.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new o.ErrnoError(28);return n},mmap(e,r,t,n,i){if(!o.isFile(e.node.mode))throw new o.ErrnoError(43);var a,s,l=e.node.contents;if(!(i&2)&&l.buffer===(c(),H).buffer)s=!1,a=l.byteOffset;else{if(s=!0,a=zr(r),!a)throw new o.ErrnoError(48);l&&((t>0||t+r<l.length)&&(l.subarray?l=l.subarray(t,t+r):l=Array.prototype.slice.call(l,t,t+r)),(c(),H).set(l,a))}return{ptr:a,allocated:s}},msync(e,r,t,n,i){return F.stream_ops.write(e,r,0,n,t,!1),0}}},Vi=e=>{if(typeof e!="string")return e;var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t},Yt=e=>(typeof e=="string"&&(e=Gr(e,!0)),e.subarray||(e=new Uint8Array(e)),e),Vr=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},dr={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135},b={isWindows:!1,staticInit(){b.isWindows=!!process.platform.match(/^win/);var e=process.binding("constants").fs;b.flagsForNodeMap={1024:e.O_APPEND,64:e.O_CREAT,128:e.O_EXCL,256:e.O_NOCTTY,0:e.O_RDONLY,2:e.O_RDWR,4096:e.O_SYNC,512:e.O_TRUNC,1:e.O_WRONLY,131072:e.O_NOFOLLOW},h(b.flagsForNodeMap[0]===0)},convertNodeCode(e){var r=e.code;return h(r in dr,`unexpected node error code: ${r} (${e})`),dr[r]},tryFSOperation(e){try{return e()}catch(r){throw r.code?r.code==="UNKNOWN"?new o.ErrnoError(28):new o.ErrnoError(b.convertNodeCode(r)):r}},mount(e){return h(M),b.createNode(null,"/",b.getMode(e.opts.root),0)},createNode(e,r,t,n){if(!o.isDir(t)&&!o.isFile(t)&&!o.isLink(t))throw new o.ErrnoError(28);var i=o.createNode(e,r,t);return i.node_ops=b.node_ops,i.stream_ops=b.stream_ops,i},getMode(e){return b.tryFSOperation(()=>{var r=x.lstatSync(e).mode;return b.isWindows&&(r|=(r&292)>>2),r})},realPath(e){for(var r=[];e.parent!==e;)r.push(e.name),e=e.parent;return r.push(e.mount.opts.root),r.reverse(),I.join(...r)},flagsForNode(e){e&=-2097153,e&=-2049,e&=-32769,e&=-524289,e&=-65537;var r=0;for(var t in b.flagsForNodeMap)e&t&&(r|=b.flagsForNodeMap[t],e^=t);if(e)throw new o.ErrnoError(28);return r},getattr(e,r){var t=b.tryFSOperation(e);return b.isWindows&&(t.blksize||(t.blksize=4096),t.blocks||(t.blocks=(t.size+t.blksize-1)/t.blksize|0),t.mode|=(t.mode&292)>>2),{dev:t.dev,ino:r.id,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,size:t.size,atime:t.atime,mtime:t.mtime,ctime:t.ctime,blksize:t.blksize,blocks:t.blocks}},setattr(e,r,t,n,i,a,s){b.tryFSOperation(()=>{if(t.mode!==void 0){var l=t.mode;b.isWindows&&(l&=384),n(e,l),r.mode=t.mode}if(typeof(t.atime??t.mtime)=="number"){var d=new Date(t.atime??s(e).atime),u=new Date(t.mtime??s(e).mtime);i(e,d,u)}t.size!==void 0&&a(e,t.size)})},node_ops:{getattr(e){var r=b.realPath(e);return b.getattr(()=>x.lstatSync(r),e)},setattr(e,r){var t=b.realPath(e);if(r.mode!=null&&r.dontFollow)throw new o.ErrnoError(52);b.setattr(t,e,r,x.chmodSync,x.utimesSync,x.truncateSync,x.lstatSync)},lookup(e,r){var t=I.join2(b.realPath(e),r),n=b.getMode(t);return b.createNode(e,r,n)},mknod(e,r,t,n){var i=b.createNode(e,r,t,n),a=b.realPath(i);return b.tryFSOperation(()=>{o.isDir(i.mode)?x.mkdirSync(a,i.mode):x.writeFileSync(a,"",{mode:i.mode})}),i},rename(e,r,t){var n=b.realPath(e),i=I.join2(b.realPath(r),t);try{o.unlink(i)}catch{}b.tryFSOperation(()=>x.renameSync(n,i)),e.name=t},unlink(e,r){var t=I.join2(b.realPath(e),r);b.tryFSOperation(()=>x.unlinkSync(t))},rmdir(e,r){var t=I.join2(b.realPath(e),r);b.tryFSOperation(()=>x.rmdirSync(t))},readdir(e){var r=b.realPath(e);return b.tryFSOperation(()=>x.readdirSync(r))},symlink(e,r,t){var n=I.join2(b.realPath(e),r);b.tryFSOperation(()=>x.symlinkSync(t,n))},readlink(e){var r=b.realPath(e);return b.tryFSOperation(()=>x.readlinkSync(r))},statfs(e){var r=b.tryFSOperation(()=>x.statfsSync(e));return r.frsize=r.bsize,r}},stream_ops:{getattr(e){return b.getattr(()=>x.fstatSync(e.nfd),e.node)},setattr(e,r){b.setattr(e.nfd,e.node,r,x.fchmodSync,x.futimesSync,x.ftruncateSync,x.fstatSync)},open(e){var r=b.realPath(e.node);b.tryFSOperation(()=>{e.shared.refcount=1,e.nfd=x.openSync(r,b.flagsForNode(e.flags))})},close(e){b.tryFSOperation(()=>{e.nfd&&--e.shared.refcount===0&&x.closeSync(e.nfd)})},dup(e){e.shared.refcount++},read(e,r,t,n,i){return b.tryFSOperation(()=>x.readSync(e.nfd,r,t,n,i))},write(e,r,t,n,i){return b.tryFSOperation(()=>x.writeSync(e.nfd,r,t,n,i))},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&o.isFile(e.node.mode)&&b.tryFSOperation(()=>{var i=x.fstatSync(e.nfd);n+=i.size}),n<0)throw new o.ErrnoError(28);return n},mmap(e,r,t,n,i){if(!o.isFile(e.node.mode))throw new o.ErrnoError(43);var a=zr(r);return b.stream_ops.read(e,(c(),H),a,r,t),{ptr:a,allocated:!0}},msync(e,r,t,n,i){return b.stream_ops.write(e,r,0,n,t,!1),0}}},qi=e=>_e(qn(e)),Ki=async e=>{var r=await tr(e);return h(r,`Loading data file "${e}" failed (no arrayBuffer).`),new Uint8Array(r)},Jt=(...e)=>o.createDataFile(...e),Xi=e=>{for(var r=e;;){if(!xe[e])return e;e=r+Math.random()}},Zt=[],Yi=async(e,r)=>{typeof Browser<"u"&&Browser.init();for(var t of Zt)if(t.canHandle(r))return h(t.handle.constructor.name==="AsyncFunction","Filesystem plugin handlers must be async functions (See #24914)"),t.handle(e,r);return e},qr=async(e,r,t,n,i,a,s,l)=>{var d=r?We.resolve(I.join2(e,r)):e,u=Xi(`cp ${d}`);xr(u);try{var _=t;typeof t=="string"&&(_=await Ki(t)),_=await Yi(_,d),l?.(),a||Jt(e,r,_,n,i,s)}finally{Mr(u)}},Ji=(e,r,t,n,i,a,s,l,d,u)=>{qr(e,r,t,n,i,l,d,u).then(a).catch(s)},o={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,filesystems:null,syncFSRequests:0,ErrnoError:class extends Error{name="ErrnoError";constructor(e){super(Ne?qi(e):""),this.errno=e;for(var r in dr)if(dr[r]===e){this.code=r;break}}},FSStream:class{shared={};get object(){return this.node}set object(e){this.node=e}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{node_ops={};stream_ops={};readMode=365;writeMode=146;mounted=null;constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.id=o.nextInode++,this.name=r,this.mode=t,this.rdev=n,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return o.isDir(this.mode)}get isDevice(){return o.isChrdev(this.mode)}},lookupPath(e,r={}){if(!e)throw new o.ErrnoError(44);r.follow_mount??=!0,I.isAbs(e)||(e=o.cwd()+"/"+e);e:for(var t=0;t<40;t++){for(var n=e.split("/").filter(u=>!!u),i=o.root,a="/",s=0;s<n.length;s++){var l=s===n.length-1;if(l&&r.parent)break;if(n[s]!=="."){if(n[s]===".."){if(a=I.dirname(a),o.isRoot(i)){e=a+"/"+n.slice(s+1).join("/"),t--;continue e}else i=i.parent;continue}a=I.join2(a,n[s]);try{i=o.lookupNode(i,n[s])}catch(u){if(u?.errno===44&&l&&r.noent_okay)return{path:a};throw u}if(o.isMountpoint(i)&&(!l||r.follow_mount)&&(i=i.mounted.root),o.isLink(i.mode)&&(!l||r.follow)){if(!i.node_ops.readlink)throw new o.ErrnoError(52);var d=i.node_ops.readlink(i);I.isAbs(d)||(d=I.dirname(a)+"/"+d),e=d+"/"+n.slice(s+1).join("/");continue e}}}return{path:a,node:i}}throw new o.ErrnoError(32)},getPath(e){for(var r;;){if(o.isRoot(e)){var t=e.mount.mountpoint;return r?t[t.length-1]!=="/"?`${t}/${r}`:t+r:t}r=r?`${e.name}/${r}`:e.name,e=e.parent}},hashName(e,r){for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return(e+t>>>0)%o.nameTable.length},hashAddNode(e){var r=o.hashName(e.parent.id,e.name);e.name_next=o.nameTable[r],o.nameTable[r]=e},hashRemoveNode(e){var r=o.hashName(e.parent.id,e.name);if(o.nameTable[r]===e)o.nameTable[r]=e.name_next;else for(var t=o.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode(e,r){var t=o.mayLookup(e);if(t)throw new o.ErrnoError(t);for(var n=o.hashName(e.id,r),i=o.nameTable[n];i;i=i.name_next){var a=i.name;if(i.parent.id===e.id&&a===r)return i}return o.lookup(e,r)},createNode(e,r,t,n){h(typeof e=="object");var i=new o.FSNode(e,r,t,n);return o.hashAddNode(i),i},destroyNode(e){o.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return(e&61440)===32768},isDir(e){return(e&61440)===16384},isLink(e){return(e&61440)===40960},isChrdev(e){return(e&61440)===8192},isBlkdev(e){return(e&61440)===24576},isFIFO(e){return(e&61440)===4096},isSocket(e){return(e&49152)===49152},flagsToPermissionString(e){var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions(e,r){return o.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!o.isDir(e.mode))return 54;var r=o.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){if(!o.isDir(e.mode))return 54;try{var t=o.lookupNode(e,r);return 20}catch{}return o.nodePermissions(e,"wx")},mayDelete(e,r,t){var n;try{n=o.lookupNode(e,r)}catch(a){return a.errno}var i=o.nodePermissions(e,"wx");if(i)return i;if(t){if(!o.isDir(n.mode))return 54;if(o.isRoot(n)||o.getPath(n)===o.cwd())return 10}else if(o.isDir(n.mode))return 31;return 0},mayOpen(e,r){if(!e)return 44;if(o.isLink(e.mode))return 32;var t=o.flagsToPermissionString(r);return o.isDir(e.mode)&&(t!=="r"||r&576)?31:o.nodePermissions(e,t)},checkOpExists(e,r){if(!e)throw new o.ErrnoError(r);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=o.MAX_OPEN_FDS;e++)if(!o.streams[e])return e;throw new o.ErrnoError(33)},getStreamChecked(e){var r=o.getStream(e);if(!r)throw new o.ErrnoError(8);return r},getStream:e=>o.streams[e],createStream(e,r=-1){return h(r>=-1),e=Object.assign(new o.FSStream,e),r==-1&&(r=o.nextfd()),e.fd=r,o.streams[r]=e,e},closeStream(e){o.streams[e]=null},dupStream(e,r=-1){var t=o.createStream(e,r);return t.stream_ops?.dup?.(t),t},doSetAttr(e,r,t){var n=e?.stream_ops.setattr,i=n?e:r;n??=r.node_ops.setattr,o.checkOpExists(n,63);try{n(i,t)}catch(a){throw a instanceof RangeError?new o.ErrnoError(22):a}},chrdev_stream_ops:{open(e){var r=o.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new o.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice(e,r){o.devices[e]={stream_ops:r}},getDevice:e=>o.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push(...n.mounts)}return r},syncfs(e,r){typeof e=="function"&&(r=e,e=!1),o.syncFSRequests++,o.syncFSRequests>1&&C(`warning: ${o.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=o.getMounts(o.root.mount),n=0;function i(l){return h(o.syncFSRequests>0),o.syncFSRequests--,r(l)}function a(l){if(l)return a.errored?void 0:(a.errored=!0,i(l));++n>=t.length&&i(null)}for(var s of t)s.type.syncfs?s.type.syncfs(s,e,a):a(null)},mount(e,r,t){if(typeof e=="string")throw e;var n=t==="/",i=!t,a;if(n&&o.root)throw new o.ErrnoError(10);if(!n&&!i){var s=o.lookupPath(t,{follow_mount:!1});if(t=s.path,a=s.node,o.isMountpoint(a))throw new o.ErrnoError(10);if(!o.isDir(a.mode))throw new o.ErrnoError(54)}var l={type:e,opts:r,mountpoint:t,mounts:[]},d=e.mount(l);return d.mount=l,l.root=d,n?o.root=d:a&&(a.mounted=l,a.mount&&a.mount.mounts.push(l)),d},unmount(e){var r=o.lookupPath(e,{follow_mount:!1});if(!o.isMountpoint(r.node))throw new o.ErrnoError(28);var t=r.node,n=t.mounted,i=o.getMounts(n);for(var[a,s]of Object.entries(o.nameTable))for(;s;){var l=s.name_next;i.includes(s.mount)&&o.destroyNode(s),s=l}t.mounted=null;var d=t.mount.mounts.indexOf(n);h(d!==-1),t.mount.mounts.splice(d,1)},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=o.lookupPath(e,{parent:!0}),i=n.node,a=I.basename(e);if(!a)throw new o.ErrnoError(28);if(a==="."||a==="..")throw new o.ErrnoError(20);var s=o.mayCreate(i,a);if(s)throw new o.ErrnoError(s);if(!i.node_ops.mknod)throw new o.ErrnoError(63);return i.node_ops.mknod(i,a,r,t)},statfs(e){return o.statfsNode(o.lookupPath(e,{follow:!0}).node)},statfsStream(e){return o.statfsNode(e.node)},statfsNode(e){var r={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:o.nextInode,ffree:o.nextInode-1,fsid:42,flags:2,namelen:255};return e.node_ops.statfs&&Object.assign(r,e.node_ops.statfs(e.mount.opts.root)),r},create(e,r=438){return r&=4095,r|=32768,o.mknod(e,r,0)},mkdir(e,r=511){return r&=1023,r|=16384,o.mknod(e,r,0)},mkdirTree(e,r){var t=e.split("/"),n="";for(var i of t)if(i){(n||I.isAbs(e))&&(n+="/"),n+=i;try{o.mkdir(n,r)}catch(a){if(a.errno!=20)throw a}}},mkdev(e,r,t){return typeof t>"u"&&(t=r,r=438),r|=8192,o.mknod(e,r,t)},symlink(e,r){if(!We.resolve(e))throw new o.ErrnoError(44);var t=o.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new o.ErrnoError(44);var i=I.basename(r),a=o.mayCreate(n,i);if(a)throw new o.ErrnoError(a);if(!n.node_ops.symlink)throw new o.ErrnoError(63);return n.node_ops.symlink(n,i,e)},rename(e,r){var t=I.dirname(e),n=I.dirname(r),i=I.basename(e),a=I.basename(r),s,l,d;if(s=o.lookupPath(e,{parent:!0}),l=s.node,s=o.lookupPath(r,{parent:!0}),d=s.node,!l||!d)throw new o.ErrnoError(44);if(l.mount!==d.mount)throw new o.ErrnoError(75);var u=o.lookupNode(l,i),_=We.relative(e,n);if(_.charAt(0)!==".")throw new o.ErrnoError(28);if(_=We.relative(r,t),_.charAt(0)!==".")throw new o.ErrnoError(55);var p;try{p=o.lookupNode(d,a)}catch{}if(u!==p){var m=o.isDir(u.mode),g=o.mayDelete(l,i,m);if(g)throw new o.ErrnoError(g);if(g=p?o.mayDelete(d,a,m):o.mayCreate(d,a),g)throw new o.ErrnoError(g);if(!l.node_ops.rename)throw new o.ErrnoError(63);if(o.isMountpoint(u)||p&&o.isMountpoint(p))throw new o.ErrnoError(10);if(d!==l&&(g=o.nodePermissions(l,"w"),g))throw new o.ErrnoError(g);o.hashRemoveNode(u);try{l.node_ops.rename(u,d,a),u.parent=d}catch(E){throw E}finally{o.hashAddNode(u)}}},rmdir(e){var r=o.lookupPath(e,{parent:!0}),t=r.node,n=I.basename(e),i=o.lookupNode(t,n),a=o.mayDelete(t,n,!0);if(a)throw new o.ErrnoError(a);if(!t.node_ops.rmdir)throw new o.ErrnoError(63);if(o.isMountpoint(i))throw new o.ErrnoError(10);t.node_ops.rmdir(t,n),o.destroyNode(i)},readdir(e){var r=o.lookupPath(e,{follow:!0}),t=r.node,n=o.checkOpExists(t.node_ops.readdir,54);return n(t)},unlink(e){var r=o.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new o.ErrnoError(44);var n=I.basename(e),i=o.lookupNode(t,n),a=o.mayDelete(t,n,!1);if(a)throw new o.ErrnoError(a);if(!t.node_ops.unlink)throw new o.ErrnoError(63);if(o.isMountpoint(i))throw new o.ErrnoError(10);t.node_ops.unlink(t,n),o.destroyNode(i)},readlink(e){var r=o.lookupPath(e),t=r.node;if(!t)throw new o.ErrnoError(44);if(!t.node_ops.readlink)throw new o.ErrnoError(28);return t.node_ops.readlink(t)},stat(e,r){var t=o.lookupPath(e,{follow:!r}),n=t.node,i=o.checkOpExists(n.node_ops.getattr,63);return i(n)},fstat(e){var r=o.getStreamChecked(e),t=r.node,n=r.stream_ops.getattr,i=n?r:t;return n??=t.node_ops.getattr,o.checkOpExists(n,63),n(i)},lstat(e){return o.stat(e,!0)},doChmod(e,r,t,n){o.doSetAttr(e,r,{mode:t&4095|r.mode&-4096,ctime:Date.now(),dontFollow:n})},chmod(e,r,t){var n;if(typeof e=="string"){var i=o.lookupPath(e,{follow:!t});n=i.node}else n=e;o.doChmod(null,n,r,t)},lchmod(e,r){o.chmod(e,r,!0)},fchmod(e,r){var t=o.getStreamChecked(e);o.doChmod(t,t.node,r,!1)},doChown(e,r,t){o.doSetAttr(e,r,{timestamp:Date.now(),dontFollow:t})},chown(e,r,t,n){var i;if(typeof e=="string"){var a=o.lookupPath(e,{follow:!n});i=a.node}else i=e;o.doChown(null,i,n)},lchown(e,r,t){o.chown(e,r,t,!0)},fchown(e,r,t){var n=o.getStreamChecked(e);o.doChown(n,n.node,!1)},doTruncate(e,r,t){if(o.isDir(r.mode))throw new o.ErrnoError(31);if(!o.isFile(r.mode))throw new o.ErrnoError(28);var n=o.nodePermissions(r,"w");if(n)throw new o.ErrnoError(n);o.doSetAttr(e,r,{size:t,timestamp:Date.now()})},truncate(e,r){if(r<0)throw new o.ErrnoError(28);var t;if(typeof e=="string"){var n=o.lookupPath(e,{follow:!0});t=n.node}else t=e;o.doTruncate(null,t,r)},ftruncate(e,r){var t=o.getStreamChecked(e);if(r<0||(t.flags&2097155)===0)throw new o.ErrnoError(28);o.doTruncate(t,t.node,r)},utime(e,r,t){var n=o.lookupPath(e,{follow:!0}),i=n.node,a=o.checkOpExists(i.node_ops.setattr,63);a(i,{atime:r,mtime:t})},open(e,r,t=438){if(e==="")throw new o.ErrnoError(44);r=Vi(r),r&64?t=t&4095|32768:t=0;var n,i;if(typeof e=="object")n=e;else{i=e.endsWith("/");var a=o.lookupPath(e,{follow:!(r&131072),noent_okay:!0});n=a.node,e=a.path}var s=!1;if(r&64)if(n){if(r&128)throw new o.ErrnoError(20)}else{if(i)throw new o.ErrnoError(31);n=o.mknod(e,t|511,0),s=!0}if(!n)throw new o.ErrnoError(44);if(o.isChrdev(n.mode)&&(r&=-513),r&65536&&!o.isDir(n.mode))throw new o.ErrnoError(54);if(!s){var l=o.mayOpen(n,r);if(l)throw new o.ErrnoError(l)}r&512&&!s&&o.truncate(n,0),r&=-131713;var d=o.createStream({node:n,path:o.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return d.stream_ops.open&&d.stream_ops.open(d),s&&o.chmod(n,t&511),d},close(e){if(o.isClosed(e))throw new o.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{o.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,r,t){if(o.isClosed(e))throw new o.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new o.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new o.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,n,i){if(h(t>=0),n<0||i<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if((e.flags&2097155)===1)throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.read)throw new o.ErrnoError(28);var a=typeof i<"u";if(!a)i=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var s=e.stream_ops.read(e,r,t,n,i);return a||(e.position+=s),s},write(e,r,t,n,i,a){if(h(t>=0),h(r.subarray,"FS.write expects a TypedArray"),n<0||i<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if((e.flags&2097155)===0)throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.write)throw new o.ErrnoError(28);e.seekable&&e.flags&1024&&o.llseek(e,0,2);var s=typeof i<"u";if(!s)i=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var l=e.stream_ops.write(e,r,t,n,i,a);return s||(e.position+=l),l},mmap(e,r,t,n,i){if((n&2)!==0&&(i&2)===0&&(e.flags&2097155)!==2)throw new o.ErrnoError(2);if((e.flags&2097155)===1)throw new o.ErrnoError(2);if(!e.stream_ops.mmap)throw new o.ErrnoError(43);if(!r)throw new o.ErrnoError(28);return e.stream_ops.mmap(e,r,t,n,i)},msync(e,r,t,n,i){return h(t>=0),e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,i):0},ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new o.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary"&&q(`Invalid encoding type "${r.encoding}"`);var t=o.open(e,r.flags),n=o.stat(e),i=n.size,a=new Uint8Array(i);return o.read(t,a,0,i,0),r.encoding==="utf8"&&(a=Le(a)),o.close(t),a},writeFile(e,r,t={}){t.flags=t.flags||577;var n=o.open(e,t.flags,t.mode);r=Yt(r),o.write(n,r,0,r.byteLength,void 0,t.canOwn),o.close(n)},cwd:()=>o.currentPath,chdir(e){var r=o.lookupPath(e,{follow:!0});if(r.node===null)throw new o.ErrnoError(44);if(!o.isDir(r.node.mode))throw new o.ErrnoError(54);var t=o.nodePermissions(r.node,"x");if(t)throw new o.ErrnoError(t);o.currentPath=r.path},createDefaultDirectories(){o.mkdir("/tmp"),o.mkdir("/home"),o.mkdir("/home/web_user")},createDefaultDevices(){o.mkdir("/dev"),o.registerDevice(o.makedev(1,3),{read:()=>0,write:(n,i,a,s,l)=>s,llseek:()=>0}),o.mkdev("/dev/null",o.makedev(1,3)),pe.register(o.makedev(5,0),pe.default_tty_ops),pe.register(o.makedev(6,0),pe.default_tty1_ops),o.mkdev("/dev/tty",o.makedev(5,0)),o.mkdev("/dev/tty1",o.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(Br(e),r=e.byteLength),e[--r]);o.createDevice("/dev","random",t),o.createDevice("/dev","urandom",t),o.mkdir("/dev/shm"),o.mkdir("/dev/shm/tmp")},createSpecialDirectories(){o.mkdir("/proc");var e=o.mkdir("/proc/self");o.mkdir("/proc/self/fd"),o.mount({mount(){var r=o.createNode(e,"fd",16895,73);return r.stream_ops={llseek:F.stream_ops.llseek},r.node_ops={lookup(t,n){var i=+n,a=o.getStreamChecked(i),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>a.path},id:i+1};return s.parent=s,s},readdir(){return Array.from(o.streams.entries()).filter(([t,n])=>n).map(([t,n])=>t.toString())}},r}},{},"/proc/self/fd")},createStandardStreams(e,r,t){e?o.createDevice("/dev","stdin",e):o.symlink("/dev/tty","/dev/stdin"),r?o.createDevice("/dev","stdout",null,r):o.symlink("/dev/tty","/dev/stdout"),t?o.createDevice("/dev","stderr",null,t):o.symlink("/dev/tty1","/dev/stderr");var n=o.open("/dev/stdin",0),i=o.open("/dev/stdout",1),a=o.open("/dev/stderr",1);h(n.fd===0,`invalid handle for stdin (${n.fd})`),h(i.fd===1,`invalid handle for stdout (${i.fd})`),h(a.fd===2,`invalid handle for stderr (${a.fd})`)},staticInit(){o.nameTable=new Array(4096),o.mount(F,{},"/"),o.createDefaultDirectories(),o.createDefaultDevices(),o.createSpecialDirectories(),o.filesystems={MEMFS:F,NODEFS:b}},init(e,r,t){h(!o.initialized,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)"),o.initialized=!0,e??=f.stdin,r??=f.stdout,t??=f.stderr,o.createStandardStreams(e,r,t)},quit(){o.initialized=!1,st(0);for(var e of o.streams)e&&o.close(e)},findObject(e,r){var t=o.analyzePath(e,r);return t.exists?t.object:null},analyzePath(e,r){try{var t=o.lookupPath(e,{follow:!r});e=t.path}catch{}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=o.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=I.basename(e),t=o.lookupPath(e,{follow:!r}),n.exists=!0,n.path=t.path,n.object=t.node,n.name=t.node.name,n.isRoot=t.path==="/"}catch(i){n.error=i.errno}return n},createPath(e,r,t,n){e=typeof e=="string"?e:o.getPath(e);for(var i=r.split("/").reverse();i.length;){var a=i.pop();if(a){var s=I.join2(e,a);try{o.mkdir(s)}catch(l){if(l.errno!=20)throw l}e=s}}return s},createFile(e,r,t,n,i){var a=I.join2(typeof e=="string"?e:o.getPath(e),r),s=Vr(n,i);return o.create(a,s)},createDataFile(e,r,t,n,i,a){var s=r;e&&(e=typeof e=="string"?e:o.getPath(e),s=r?I.join2(e,r):e);var l=Vr(n,i),d=o.create(s,l);if(t){t=Yt(t),o.chmod(d,l|146);var u=o.open(d,577);o.write(u,t,0,t.length,0,a),o.close(u),o.chmod(d,l)}},createDevice(e,r,t,n){var i=I.join2(typeof e=="string"?e:o.getPath(e),r),a=Vr(!!t,!!n);o.createDevice.major??=64;var s=o.makedev(o.createDevice.major++,0);return o.registerDevice(s,{open(l){l.seekable=!1},close(l){n?.buffer?.length&&n(10)},read(l,d,u,_,p){for(var m=0,g=0;g<_;g++){var E;try{E=t()}catch{throw new o.ErrnoError(29)}if(E===void 0&&m===0)throw new o.ErrnoError(6);if(E==null)break;m++,d[u+g]=E}return m&&(l.node.atime=Date.now()),m},write(l,d,u,_,p){for(var m=0;m<_;m++)try{n(d[u+m])}catch{throw new o.ErrnoError(29)}return _&&(l.node.mtime=l.node.ctime=Date.now()),m}}),o.mkdev(i,a,s)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)q("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");else try{e.contents=Be(e.url)}catch{throw new o.ErrnoError(29)}},createLazyFile(e,r,t,n,i){class a{lengthKnown=!1;chunks=[];get(m){if(!(m>this.length-1||m<0)){var g=m%this.chunkSize,E=m/this.chunkSize|0;return this.getter(E)[g]}}setDataGetter(m){this.getter=m}cacheLength(){var m=new XMLHttpRequest;m.open("HEAD",t,!1),m.send(null),m.status>=200&&m.status<300||m.status===304||q("Couldn't load "+t+". Status: "+m.status);var g=Number(m.getResponseHeader("Content-length")),E,k=(E=m.getResponseHeader("Accept-Ranges"))&&E==="bytes",D=(E=m.getResponseHeader("Content-Encoding"))&&E==="gzip",R=1024*1024;k||(R=g);var G=(oe,de)=>{oe>de&&q("invalid range ("+oe+", "+de+") or no bytes requested!"),de>g-1&&q("only "+g+" bytes available! programmer error!");var V=new XMLHttpRequest;return V.open("GET",t,!1),g!==R&&V.setRequestHeader("Range","bytes="+oe+"-"+de),V.responseType="arraybuffer",V.overrideMimeType&&V.overrideMimeType("text/plain; charset=x-user-defined"),V.send(null),V.status>=200&&V.status<300||V.status===304||q("Couldn't load "+t+". Status: "+V.status),V.response!==void 0?new Uint8Array(V.response||[]):Gr(V.responseText||"",!0)},z=this;z.setDataGetter(oe=>{var de=oe*R,V=(oe+1)*R-1;return V=Math.min(V,g-1),typeof z.chunks[oe]>"u"&&(z.chunks[oe]=G(de,V)),typeof z.chunks[oe]>"u"&&q("doXHR failed!"),z.chunks[oe]}),(D||!g)&&(R=g=1,g=this.getter(0).length,R=g,ge("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=g,this._chunkSize=R,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(globalThis.XMLHttpRequest){N||q("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var s=new a,l={isDevice:!1,contents:s}}else var l={isDevice:!1,url:t};var d=o.createFile(e,r,l,n,i);l.contents?d.contents=l.contents:l.url&&(d.contents=null,d.url=l.url),Object.defineProperties(d,{usedBytes:{get:function(){return this.contents.length}}});var u={};for(let[p,m]of Object.entries(d.stream_ops))u[p]=(...g)=>(o.forceLoadFile(d),m(...g));function _(p,m,g,E,k){var D=p.node.contents;if(k>=D.length)return 0;var R=Math.min(D.length-k,E);if(h(R>=0),D.slice)for(var G=0;G<R;G++)m[g+G]=D[k+G];else for(var G=0;G<R;G++)m[g+G]=D.get(k+G);return R}return u.read=(p,m,g,E,k)=>(o.forceLoadFile(d),_(p,m,g,E,k)),u.mmap=(p,m,g,E,k)=>{o.forceLoadFile(d);var D=zr(m);if(!D)throw new o.ErrnoError(48);return _(p,(c(),H),D,m,g),{ptr:D,allocated:!0}},d.stream_ops=u,d}},T={websocketArgs:{},callbacks:{},on(e,r){T.callbacks[e]=r},emit(e,r){T.callbacks[e]?.(r)},mount(e){return T.websocketArgs=f.websocket||{},(f.websocket??={}).on=T.on,o.createNode(null,"/",16895,0)},createSocket(e,r,t){if(e!=2)throw new o.ErrnoError(5);if(r&=-526337,r!=1&&r!=2)throw new o.ErrnoError(28);var n=r==1;if(n&&t&&t!=6)throw new o.ErrnoError(66);var i={family:e,type:r,protocol:t,server:null,error:null,peers:{},pending:[],recv_queue:[],sock_ops:T.websocket_sock_ops},a=T.nextname(),s=o.createNode(T.root,a,49152,0);s.sock=i;var l=o.createStream({path:a,node:s,flags:2,seekable:!1,stream_ops:T.stream_ops});return i.stream=l,i},getSocket(e){var r=o.getStream(e);return!r||!o.isSocket(r.node.mode)?null:r.node.sock},stream_ops:{poll(e){var r=e.node.sock;return r.sock_ops.poll(r)},ioctl(e,r,t){var n=e.node.sock;return n.sock_ops.ioctl(n,r,t)},read(e,r,t,n,i){var a=e.node.sock,s=a.sock_ops.recvmsg(a,n);return s?(r.set(s.buffer,t),s.buffer.length):0},write(e,r,t,n,i){var a=e.node.sock;return a.sock_ops.sendmsg(a,r,t,n)},close(e){var r=e.node.sock;r.sock_ops.close(r)}},nextname(){return T.nextname.current||(T.nextname.current=0),`socket[${T.nextname.current++}]`},websocket_sock_ops:{createPeer(e,r,t){var n;if(typeof r=="object"&&(n=r,r=null,t=null),n)if(n._socket)r=n._socket.remoteAddress,t=n._socket.remotePort;else{var i=/ws[s]?:\/\/([^:]+):(\d+)/.exec(n.url);if(!i)throw new Error("WebSocket URL must be in the format ws(s)://address:port");r=i[1],t=parseInt(i[2],10)}else try{var a="ws://".replace("#","//"),s="binary",l=void 0;if(T.websocketArgs.url&&(a=T.websocketArgs.url),T.websocketArgs.subprotocol?s=T.websocketArgs.subprotocol:T.websocketArgs.subprotocol===null&&(s="null"),a==="ws://"||a==="wss://"){var d=r.split("/");a=a+d[0]+":"+t+"/"+d.slice(1).join("/")}s!=="null"&&(s=s.replace(/^ +| +$/g,"").split(/ *, */),l=s);var u;M?u=le("ws"):u=WebSocket,n=new u(a,l),n.binaryType="arraybuffer"}catch{throw new o.ErrnoError(23)}var _={addr:r,port:t,socket:n,msg_send_queue:[]};return T.websocket_sock_ops.addPeer(e,_),T.websocket_sock_ops.handlePeerEvents(e,_),e.type===2&&typeof e.sport<"u"&&_.msg_send_queue.push(new Uint8Array([255,255,255,255,112,111,114,116,(e.sport&65280)>>8,e.sport&255])),_},getPeer(e,r,t){return e.peers[r+":"+t]},addPeer(e,r){e.peers[r.addr+":"+r.port]=r},removePeer(e,r){delete e.peers[r.addr+":"+r.port]},handlePeerEvents(e,r){var t=!0;function n(){e.connecting=!1,T.emit("open",e.stream.fd);try{for(var a=r.msg_send_queue.shift();a;)r.socket.send(a),a=r.msg_send_queue.shift()}catch{r.socket.close()}}function i(a){if(typeof a=="string"){var s=new TextEncoder;a=s.encode(a)}else{if(h(a.byteLength!==void 0),a.byteLength==0)return;a=new Uint8Array(a)}var l=t;if(t=!1,l&&a.length===10&&a[0]===255&&a[1]===255&&a[2]===255&&a[3]===255&&a[4]===112&&a[5]===111&&a[6]===114&&a[7]===116){var d=a[8]<<8|a[9];T.websocket_sock_ops.removePeer(e,r),r.port=d,T.websocket_sock_ops.addPeer(e,r);return}e.recv_queue.push({addr:r.addr,port:r.port,data:a}),T.emit("message",e.stream.fd)}if(M){r.socket.on("open",n),r.socket.on("message",(a,s)=>{s&&i(new Uint8Array(a).buffer)}),r.socket.on("close",()=>T.emit("close",e.stream.fd)),r.socket.on("error",a=>{e.error=14,T.emit("error",[e.stream.fd,e.error,"ECONNREFUSED: Connection refused"])});return}r.socket.onopen=n,r.socket.onclose=()=>T.emit("close",e.stream.fd),r.socket.onmessage=a=>i(a.data),r.socket.onerror=a=>{e.error=14,T.emit("error",[e.stream.fd,e.error,"ECONNREFUSED: Connection refused"])}},poll(e){if(e.type===1&&e.server)return e.pending.length?65:0;var r=0,t=e.type===1?T.websocket_sock_ops.getPeer(e,e.daddr,e.dport):null;return(e.recv_queue.length||!t||t&&t.socket.readyState===t.socket.CLOSING||t&&t.socket.readyState===t.socket.CLOSED)&&(r|=65),(!t||t&&t.socket.readyState===t.socket.OPEN)&&(r|=4),(t&&t.socket.readyState===t.socket.CLOSING||t&&t.socket.readyState===t.socket.CLOSED)&&(e.connecting?r|=4:r|=16),r},ioctl(e,r,t){switch(r){case 21531:var n=0;return e.recv_queue.length&&(n=e.recv_queue[0].data.length),(c(),S)[t>>2]=n,0;case 21537:var i=(c(),S)[t>>2];return i?e.stream.flags|=2048:e.stream.flags&=-2049,0;default:return 28}},close(e){if(e.server){try{e.server.close()}catch{}e.server=null}for(var r of Object.values(e.peers)){try{r.socket.close()}catch{}T.websocket_sock_ops.removePeer(e,r)}return 0},bind(e,r,t){if(typeof e.saddr<"u"||typeof e.sport<"u")throw new o.ErrnoError(28);if(e.saddr=r,e.sport=t,e.type===2){e.server&&(e.server.close(),e.server=null);try{e.sock_ops.listen(e,0)}catch(n){if(n.name!=="ErrnoError"||n.errno!==138)throw n}}},connect(e,r,t){if(e.server)throw new o.ErrnoError(138);if(typeof e.daddr<"u"&&typeof e.dport<"u"){var n=T.websocket_sock_ops.getPeer(e,e.daddr,e.dport);if(n)throw n.socket.readyState===n.socket.CONNECTING?new o.ErrnoError(7):new o.ErrnoError(30)}var i=T.websocket_sock_ops.createPeer(e,r,t);e.daddr=i.addr,e.dport=i.port,e.connecting=!0},listen(e,r){if(!M)throw new o.ErrnoError(138);if(e.server)throw new o.ErrnoError(28);var t=le("ws").Server,n=e.saddr;e.server=new t({host:n,port:e.sport}),T.emit("listen",e.stream.fd),e.server.on("connection",i=>{if(e.type===1){var a=T.createSocket(e.family,e.type,e.protocol),s=T.websocket_sock_ops.createPeer(a,i);a.daddr=s.addr,a.dport=s.port,e.pending.push(a),T.emit("connection",a.stream.fd)}else T.websocket_sock_ops.createPeer(e,i),T.emit("connection",e.stream.fd)}),e.server.on("close",()=>{T.emit("close",e.stream.fd),e.server=null}),e.server.on("error",i=>{e.error=23,T.emit("error",[e.stream.fd,e.error,"EHOSTUNREACH: Host is unreachable"])})},accept(e){if(!e.server||!e.pending.length)throw new o.ErrnoError(28);var r=e.pending.shift();return r.stream.flags=e.stream.flags,r},getname(e,r){var t,n;if(r){if(e.daddr===void 0||e.dport===void 0)throw new o.ErrnoError(53);t=e.daddr,n=e.dport}else t=e.saddr||0,n=e.sport||0;return{addr:t,port:n}},sendmsg(e,r,t,n,i,a){if(e.type===2){if((i===void 0||a===void 0)&&(i=e.daddr,a=e.dport),i===void 0||a===void 0)throw new o.ErrnoError(17)}else i=e.daddr,a=e.dport;var s=T.websocket_sock_ops.getPeer(e,i,a);if(e.type===1&&(!s||s.socket.readyState===s.socket.CLOSING||s.socket.readyState===s.socket.CLOSED))throw new o.ErrnoError(53);ArrayBuffer.isView(r)&&(t+=r.byteOffset,r=r.buffer);var l=r.slice(t,t+n);if(l instanceof SharedArrayBuffer&&(l=new Uint8Array(new Uint8Array(l)).buffer),!s||s.socket.readyState!==s.socket.OPEN)return e.type===2&&(!s||s.socket.readyState===s.socket.CLOSING||s.socket.readyState===s.socket.CLOSED)&&(s=T.websocket_sock_ops.createPeer(e,i,a)),s.msg_send_queue.push(l),n;try{return s.socket.send(l),n}catch{throw new o.ErrnoError(28)}},recvmsg(e,r){if(e.type===1&&e.server)throw new o.ErrnoError(53);var t=e.recv_queue.shift();if(!t){if(e.type===1){var n=T.websocket_sock_ops.getPeer(e,e.daddr,e.dport);if(!n)throw new o.ErrnoError(53);if(n.socket.readyState===n.socket.CLOSING||n.socket.readyState===n.socket.CLOSED)return null;throw new o.ErrnoError(6)}throw new o.ErrnoError(6)}var i=t.data.byteLength||t.data.length,a=t.data.byteOffset||0,s=t.data.buffer||t.data,l=Math.min(r,i),d={buffer:new Uint8Array(s,a,l),addr:t.addr,port:t.port};if(e.type===1&&l<i){var u=i-l;t.data=new Uint8Array(s,a+l,u),e.recv_queue.unshift(t)}return d}}},Kr=e=>{var r=T.getSocket(e);if(!r)throw new o.ErrnoError(8);return r},Xr=e=>(e&255)+"."+(e>>8&255)+"."+(e>>16&255)+"."+(e>>24&255),Qt=e=>{var r="",t=0,n=0,i=0,a=0,s=0,l=0,d=[e[0]&65535,e[0]>>16,e[1]&65535,e[1]>>16,e[2]&65535,e[2]>>16,e[3]&65535,e[3]>>16],u=!0,_="";for(l=0;l<5;l++)if(d[l]!==0){u=!1;break}if(u){if(_=Xr(d[6]|d[7]<<16),d[5]===-1)return r="::ffff:",r+=_,r;if(d[5]===0)return r="::",_==="0.0.0.0"&&(_=""),_==="0.0.0.1"&&(_="1"),r+=_,r}for(t=0;t<8;t++)d[t]===0&&(t-i>1&&(s=0),i=t,s++),s>n&&(n=s,a=t-n+1);for(t=0;t<8;t++){if(n>1&&d[t]===0&&t>=a&&t<a+n){t===a&&(r+=":",a===0&&(r+=":"));continue}r+=Number(dt(d[t]&65535)).toString(16),r+=t<7?":":""}return r},Zi=(e,r)=>{var t=(c(),ne)[e>>1],n=dt((c(),ke)[e+2>>1]),i;switch(t){case 2:if(r!==16)return{errno:28};i=(c(),S)[e+4>>2],i=Xr(i);break;case 10:if(r!==28)return{errno:28};i=[(c(),S)[e+8>>2],(c(),S)[e+12>>2],(c(),S)[e+16>>2],(c(),S)[e+20>>2]],i=Qt(i);break;default:return{errno:5}}return{family:t,addr:i,port:n}},cr=e=>{for(var r=e.split("."),t=0;t<4;t++){var n=Number(r[t]);if(isNaN(n))return null;r[t]=n}return(r[0]|r[1]<<8|r[2]<<16|r[3]<<24)>>>0},Yr=e=>{var r,t,n,i,a,s=/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,l=[];if(!s.test(e))return null;if(e==="::")return[0,0,0,0,0,0,0,0];for(e.startsWith("::")?e=e.replace("::","Z:"):e=e.replace("::",":Z:"),e.indexOf(".")>0?(e=e.replace(new RegExp("[.]","g"),":"),r=e.split(":"),r[r.length-4]=Number(r[r.length-4])+Number(r[r.length-3])*256,r[r.length-3]=Number(r[r.length-2])+Number(r[r.length-1])*256,r=r.slice(0,r.length-2)):r=e.split(":"),n=0,i=0,t=0;t<r.length;t++)if(typeof r[t]=="string")if(r[t]==="Z"){for(i=0;i<8-r.length+1;i++)l[t+i]=0;n=i-1}else l[t+n]=Fr(parseInt(r[t],16));else l[t+n]=r[t];return[l[1]<<16|l[0],l[3]<<16|l[2],l[5]<<16|l[4],l[7]<<16|l[6]]},he={address_map:{id:1,addrs:{},names:{}},lookup_name(e){var r=cr(e);if(r!==null||(r=Yr(e),r!==null))return e;var t;if(he.address_map.addrs[e])t=he.address_map.addrs[e];else{var n=he.address_map.id++;h(n<65535,"exceeded max address mappings of 65535"),t="172.29."+(n&255)+"."+(n&65280),he.address_map.names[t]=e,he.address_map.addrs[e]=t}return t},lookup_addr(e){return he.address_map.names[e]?he.address_map.names[e]:null}},en=(e,r)=>{var t=Zi(e,r);if(t.errno)throw new o.ErrnoError(t.errno);return t.addr=he.lookup_addr(t.addr)||t.addr,t};function rn(e,r,t,n,i,a){if(w)return K(3,0,1,e,r,t,n,i,a);try{var s=Kr(e),l=en(r,t);return s.sock_ops.connect(s,l.addr,l.port),0}catch(d){if(typeof o>"u"||d.name!=="ErrnoError")throw d;return-d.errno}}var X={currentUmask:18,calculateAt(e,r,t){if(I.isAbs(r))return r;var n;if(e===-100)n=o.cwd();else{var i=X.getStreamFromFD(e);n=i.path}if(r.length==0){if(!t)throw new o.ErrnoError(44);return n}return n+"/"+r},writeStat(e,r){(c(),y)[e>>2]=r.dev,(c(),y)[e+4>>2]=r.mode,(c(),y)[e+8>>2]=r.nlink,(c(),y)[e+12>>2]=r.uid,(c(),y)[e+16>>2]=r.gid,(c(),y)[e+20>>2]=r.rdev,(c(),Z)[e+24>>3]=BigInt(r.size),(c(),S)[e+32>>2]=4096,(c(),S)[e+36>>2]=r.blocks;var t=r.atime.getTime(),n=r.mtime.getTime(),i=r.ctime.getTime();return(c(),Z)[e+40>>3]=BigInt(Math.floor(t/1e3)),(c(),y)[e+48>>2]=t%1e3*1e3*1e3,(c(),Z)[e+56>>3]=BigInt(Math.floor(n/1e3)),(c(),y)[e+64>>2]=n%1e3*1e3*1e3,(c(),Z)[e+72>>3]=BigInt(Math.floor(i/1e3)),(c(),y)[e+80>>2]=i%1e3*1e3*1e3,(c(),Z)[e+88>>3]=BigInt(r.ino),0},writeStatFs(e,r){(c(),y)[e+4>>2]=r.bsize,(c(),y)[e+60>>2]=r.bsize,(c(),Z)[e+8>>3]=BigInt(r.blocks),(c(),Z)[e+16>>3]=BigInt(r.bfree),(c(),Z)[e+24>>3]=BigInt(r.bavail),(c(),Z)[e+32>>3]=BigInt(r.files),(c(),Z)[e+40>>3]=BigInt(r.ffree),(c(),y)[e+48>>2]=r.fsid,(c(),y)[e+64>>2]=r.flags,(c(),y)[e+56>>2]=r.namelen},doMsync(e,r,t,n,i){if(!o.isFile(r.node.mode))throw new o.ErrnoError(43);if(n&2)return 0;var a=(c(),te).slice(e,e+t);o.msync(r,a,i,t,n)},getStreamFromFD(e){var r=o.getStreamChecked(e);return r},varargs:void 0,getStr(e){var r=_e(e);return r}};function tn(e){if(w)return K(4,0,1,e);try{var r=X.getStreamFromFD(e);return o.dupStream(r).fd}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}var ur=()=>{h(X.varargs!=null);var e=(c(),S)[+X.varargs>>2];return X.varargs+=4,e},Ue=ur;function nn(e,r,t){if(w)return K(5,0,1,e,r,t);X.varargs=t;try{var n=X.getStreamFromFD(e);switch(r){case 0:{var i=ur();if(i<0)return-28;for(;o.streams[i];)i++;var a;return a=o.dupStream(n,i),a.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var i=ur(),s=289792;return n.flags=n.flags&~s|i&s,0}case 12:{var i=Ue(),l=0;return(c(),ne)[i+l>>1]=2,0}case 13:case 14:return 0}return-28}catch(d){if(typeof o>"u"||d.name!=="ErrnoError")throw d;return-d.errno}}var Ee=(e,r,t)=>(h(typeof t=="number","stringToUTF8 requires a third parameter that specifies the length of the output buffer"),Xt(e,(c(),te),r,t));function an(e,r){if(w)return K(6,0,1,e,r);try{if(r===0)return-28;var t=o.cwd(),n=Pe(t)+1;return r<n?-68:(Ee(t,e,r),n)}catch(i){if(typeof o>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function on(e,r,t){if(w)return K(7,0,1,e,r,t);X.varargs=t;try{var n=X.getStreamFromFD(e);switch(r){case 21509:return n.tty?0:-59;case 21505:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcgets){var i=n.tty.ops.ioctl_tcgets(n),a=Ue();(c(),S)[a>>2]=i.c_iflag||0,(c(),S)[a+4>>2]=i.c_oflag||0,(c(),S)[a+8>>2]=i.c_cflag||0,(c(),S)[a+12>>2]=i.c_lflag||0;for(var s=0;s<32;s++)(c(),H)[a+s+17]=i.c_cc[s]||0;return 0}return 0}case 21510:case 21511:case 21512:return n.tty?0:-59;case 21506:case 21507:case 21508:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcsets){for(var a=Ue(),l=(c(),S)[a>>2],d=(c(),S)[a+4>>2],u=(c(),S)[a+8>>2],_=(c(),S)[a+12>>2],p=[],s=0;s<32;s++)p.push((c(),H)[a+s+17]);return n.tty.ops.ioctl_tcsets(n.tty,r,{c_iflag:l,c_oflag:d,c_cflag:u,c_lflag:_,c_cc:p})}return 0}case 21519:{if(!n.tty)return-59;var a=Ue();return(c(),S)[a>>2]=0,0}case 21520:return n.tty?-28:-59;case 21537:case 21531:{var a=Ue();return o.ioctl(n,r,a)}case 21523:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tiocgwinsz){var m=n.tty.ops.ioctl_tiocgwinsz(n.tty),a=Ue();(c(),ne)[a>>1]=m[0],(c(),ne)[a+2>>1]=m[1]}return 0}case 21524:return n.tty?0:-59;case 21515:return n.tty?0:-59;default:return-28}}catch(g){if(typeof o>"u"||g.name!=="ErrnoError")throw g;return-g.errno}}function sn(e,r,t,n){if(w)return K(8,0,1,e,r,t,n);X.varargs=n;try{r=X.getStr(r),r=X.calculateAt(e,r);var i=n?ur():0;return t&64&&(i&=~X.currentUmask),o.open(r,t,i).fd}catch(a){if(typeof o>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function ln(e,r,t,n){if(w)return K(9,0,1,e,r,t,n);try{if(r=X.getStr(r),r=X.calculateAt(e,r),n<=0)return-28;var i=o.readlink(r),a=Math.min(n,Pe(i)),s=(c(),H)[t+a];return Ee(i,t,n+1),(c(),H)[t+a]=s,a}catch(l){if(typeof o>"u"||l.name!=="ErrnoError")throw l;return-l.errno}}var dn=(e,r)=>(c(),te).fill(0,e,e+r),cn=(e,r,t,n,i)=>{switch(r){case 2:t=cr(t),dn(e,16),i&&((c(),S)[i>>2]=16),(c(),ne)[e>>1]=r,(c(),S)[e+4>>2]=t,(c(),ne)[e+2>>1]=Fr(n);break;case 10:t=Yr(t),dn(e,28),i&&((c(),S)[i>>2]=28),(c(),S)[e>>2]=r,(c(),S)[e+8>>2]=t[0],(c(),S)[e+12>>2]=t[1],(c(),S)[e+16>>2]=t[2],(c(),S)[e+20>>2]=t[3],(c(),ne)[e+2>>1]=Fr(n);break;default:return 5}return 0};function un(e,r,t,n,i,a){if(w)return K(10,0,1,e,r,t,n,i,a);try{var s=Kr(e),l=s.sock_ops.recvmsg(s,t);if(!l)return 0;if(i){var d=cn(i,s.family,he.lookup_name(l.addr),l.port,a);h(!d)}return(c(),te).set(l.buffer,r),l.buffer.byteLength}catch(u){if(typeof o>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}function fn(e){if(w)return K(11,0,1,e);try{return e=X.getStr(e),o.rmdir(e),0}catch(r){if(typeof o>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function _n(e,r,t,n,i,a){if(w)return K(12,0,1,e,r,t,n,i,a);try{var s=Kr(e);if(!i)return o.write(s.stream,(c(),H),r,t);var l=en(i,a);return s.sock_ops.sendmsg(s,(c(),H),r,t,l.addr,l.port)}catch(d){if(typeof o>"u"||d.name!=="ErrnoError")throw d;return-d.errno}}function hn(e,r,t){if(w)return K(13,0,1,e,r,t);try{var n=T.createSocket(e,r,t);return h(n.stream.fd<64),n.stream.fd}catch(i){if(typeof o>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function vn(e,r,t){if(w)return K(14,0,1,e,r,t);try{if(r=X.getStr(r),r=X.calculateAt(e,r),!t)o.unlink(r);else if(t===512)o.rmdir(r);else return-28;return 0}catch(n){if(typeof o>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}var Qi=()=>q("native code called abort()"),fr={},_r=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r)}};function Ve(e){return this.fromWireType((c(),y)[e>>2])}var je={},Ce={},hr={},ea=class extends Error{constructor(r){super(r),this.name="InternalError"}},vr=e=>{throw new ea(e)},ce=(e,r,t)=>{e.forEach(l=>hr[l]=r);function n(l){var d=t(l);d.length!==e.length&&vr("Mismatched type converter count");for(var u=0;u<e.length;++u)ie(e[u],d[u])}var i=new Array(r.length),a=[],s=0;for(let[l,d]of r.entries())Ce.hasOwnProperty(d)?i[l]=Ce[d]:(a.push(d),je.hasOwnProperty(d)||(je[d]=[]),je[d].push(()=>{i[l]=Ce[d],++s,s===a.length&&n(i)}));a.length===0&&n(i)},ra=e=>{var r=fr[e];delete fr[e];var t=r.rawConstructor,n=r.rawDestructor,i=r.fields,a=i.map(s=>s.getterReturnType).concat(i.map(s=>s.setterArgumentType));ce([e],a,s=>{var l={};for(var[d,u]of i.entries()){let _=s[d],p=u.getter,m=u.getterContext,g=s[d+i.length],E=u.setter,k=u.setterContext;l[u.fieldName]={read:D=>_.fromWireType(p(m,D)),write:(D,R)=>{var G=[];E(k,D,g.toWireType(G,R)),_r(G)},optional:_.optional}}return[{name:r.name,fromWireType:_=>{var p={};for(var m in l)p[m]=l[m].read(_);return n(_),p},toWireType:(_,p)=>{for(var m in l)if(!(m in p)&&!l[m].optional)throw new TypeError(`Missing field: "${m}"`);var g=t();for(m in l)l[m].write(g,p[m]);return _!==null&&_.push(n,g),g},readValueFromPointer:Ve,destructorFunction:n}]})},Y=e=>{for(var r="";;){var t=(c(),te)[e++];if(!t)return r;r+=String.fromCharCode(t)}},qe=class extends Error{constructor(r){super(r),this.name="BindingError"}},A=e=>{throw new qe(e)};function ta(e,r,t={}){var n=r.name;if(e||A(`type "${n}" must have a positive integer typeid pointer`),Ce.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;A(`Cannot register type '${n}' twice`)}if(Ce[e]=r,delete hr[e],je.hasOwnProperty(e)){var i=je[e];delete je[e],i.forEach(a=>a())}}function ie(e,r,t={}){return ta(e,r,t)}var pn=(e,r,t)=>{switch(r){case 1:return t?n=>(c(),H)[n]:n=>(c(),te)[n];case 2:return t?n=>(c(),ne)[n>>1]:n=>(c(),ke)[n>>1];case 4:return t?n=>(c(),S)[n>>2]:n=>(c(),y)[n>>2];case 8:return t?n=>(c(),Z)[n>>3]:n=>(c(),Dt)[n>>3];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},Ae=e=>{if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},mn=(e,r,t,n)=>{if(r<t||r>n)throw new TypeError(`Passing a number "${Ae(r)}" from JS side to C/C++ side to an argument of type "${e}", which is outside the valid range [${t}, ${n}]!`)},na=(e,r,t,n,i)=>{r=Y(r);let a=n===0n,s=l=>l;if(a){let l=t*8;s=d=>BigInt.asUintN(l,d),i=s(i)}ie(e,{name:r,fromWireType:s,toWireType:(l,d)=>{if(typeof d=="number")d=BigInt(d);else if(typeof d!="bigint")throw new TypeError(`Cannot convert "${Ae(d)}" to ${r}`);return mn(r,d,n,i),d},readValueFromPointer:pn(r,t,!a),destructorFunction:null})},ia=(e,r,t,n)=>{r=Y(r),ie(e,{name:r,fromWireType:function(i){return!!i},toWireType:function(i,a){return a?t:n},readValueFromPointer:function(i){return this.fromWireType((c(),te)[i])},destructorFunction:null})},aa=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Jr=e=>{function r(t){return t.$$.ptrType.registeredClass.name}A(r(e)+" instance already deleted")},Zr=!1,gn=e=>{},oa=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)},yn=e=>{e.count.value-=1;var r=e.count.value===0;r&&oa(e)},wn=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=wn(e,r,t.baseClass);return n===null?null:t.downcast(n)},En={},sa={},la=(e,r)=>{for(r===void 0&&A("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},da=(e,r)=>(r=la(e,r),sa[r]),pr=(e,r)=>{(!r.ptrType||!r.ptr)&&vr("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&vr("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Ke(Object.create(e,{$$:{value:r,writable:!0}}))};function bn(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=da(this.registeredClass,r);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function i(){return this.isSmartPointer?pr(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):pr(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var a=this.registeredClass.getActualType(r),s=En[a];if(!s)return i.call(this);var l;this.isConst?l=s.constPointerType:l=s.pointerType;var d=wn(r,this.registeredClass,l.registeredClass);return d===null?i.call(this):this.isSmartPointer?pr(l.registeredClass.instancePrototype,{ptrType:l,ptr:d,smartPtrType:this,smartPtr:e}):pr(l.registeredClass.instancePrototype,{ptrType:l,ptr:d})}var Ke=e=>globalThis.FinalizationRegistry?(Zr=new FinalizationRegistry(r=>{console.warn(r.leakWarning),yn(r.$$)}),Ke=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var i={$$:t},a=t.ptrType.registeredClass,s=new Error(`Embind found a leaked C++ instance ${a.name} <${we(t.ptr)}>.
|
|
1
|
+
async function li(Q={}){var v;(function(){function e(d){d=d.split("-")[0];for(var u=d.split(".").slice(0,3);u.length<3;)u.push("00");return u=u.map((_,p,m)=>_.padStart(2,"0")),u.join("")}var r=d=>[d/1e4|0,(d/100|0)%100,d%100].join("."),t=2147483647,n=typeof process<"u"&&process.versions?.node?e(process.versions.node):t;if(n<180300)throw new Error(`This emscripten-generated code requires node v${r(180300)} (detected v${r(n)})`);var i=typeof navigator<"u"&&navigator.userAgent;if(i){var a=i.includes("Safari/")&&!i.includes("Chrome/")&&i.match(/Version\/(\d+\.?\d*\.?\d*)/)?e(i.match(/Version\/(\d+\.?\d*\.?\d*)/)[1]):t;if(a<15e4)throw new Error(`This emscripten-generated code requires Safari v${r(15e4)} (detected v${a})`);var s=i.match(/Firefox\/(\d+(?:\.\d+)?)/)?parseFloat(i.match(/Firefox\/(\d+(?:\.\d+)?)/)[1]):t;if(s<114)throw new Error(`This emscripten-generated code requires Firefox v114 (detected v${s})`);var l=i.match(/Chrome\/(\d+(?:\.\d+)?)/)?parseFloat(i.match(/Chrome\/(\d+(?:\.\d+)?)/)[1]):t;if(l<85)throw new Error(`This emscripten-generated code requires Chrome v85 (detected v${l})`)}})();var f=Q,O=!!globalThis.window,N=!!globalThis.WorkerGlobalScope,M=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer",me=!O&&!M&&!N,w=N&&globalThis.name?.startsWith("em-pthread");if(w&&(h(!globalThis.moduleLoaded,"module should only be loaded once on each pthread worker"),globalThis.moduleLoaded=!0),M){let{createRequire:e}=await import("node:module");var le=e(import.meta.url),rr=le("node:worker_threads");globalThis.Worker=rr.Worker,N=!rr.isMainThread,w=N&&rr.workerData=="em-pthread"}var gt=[],Ar="./this.program",Or=(e,r)=>{throw r},Dr=import.meta.url,tr="";function mi(e){return f.locateFile?f.locateFile(e,tr):tr+e}var nr,He;if(M){if(!(globalThis.process?.versions?.node&&globalThis.process?.type!="renderer"))throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");var x=le("node:fs");Dr.startsWith("file:")&&(tr=le("node:path").dirname(le("node:url").fileURLToPath(Dr))+"/"),He=r=>{r=ir(r)?new URL(r):r;var t=x.readFileSync(r);return h(Buffer.isBuffer(t)),t},nr=async(r,t=!0)=>{r=ir(r)?new URL(r):r;var n=x.readFileSync(r,t?void 0:"utf8");return h(t?Buffer.isBuffer(n):typeof n=="string"),n},process.argv.length>1&&(Ar=process.argv[1].replace(/\\/g,"/")),gt=process.argv.slice(2),Or=(r,t)=>{throw process.exitCode=r,t}}else if(!me)if(O||N){try{tr=new URL(".",Dr).href}catch{}if(!(globalThis.window||globalThis.WorkerGlobalScope))throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");M||(N&&(He=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),nr=async e=>{h(!ir(e),"readAsync does not work with file:// URLs");var r=await fetch(e,{credentials:"same-origin"});if(r.ok)return r.arrayBuffer();throw new Error(r.status+" : "+r.url)})}else throw new Error("environment detection error");var yt=console.log.bind(console),wt=console.error.bind(console);if(M){var gi=le("node:util"),Et=e=>typeof e=="object"?gi.inspect(e):e;yt=(...e)=>x.writeSync(1,e.map(Et).join(" ")+`
|
|
2
|
+
`),wt=(...e)=>x.writeSync(2,e.map(Et).join(" ")+`
|
|
3
|
+
`)}var ge=yt,C=wt,Ms="IDBFS is no longer included by default; build with -lidbfs.js",xs="PROXYFS is no longer included by default; build with -lproxyfs.js",Ls="WORKERFS is no longer included by default; build with -lworkerfs.js",Ws="FETCHFS is no longer included by default; build with -lfetchfs.js",Us="ICASEFS is no longer included by default; build with -licasefs.js",js="JSFILEFS is no longer included by default; build with -ljsfilefs.js",Bs="OPFS is no longer included by default; build with -lopfs.js";h(O||N||M,"pthreads do not work in this environment yet (need Web Workers, or an alternative to them)"),h(!me,"shell environment detected but not enabled at build time (add `shell` to `-sENVIRONMENT` to enable)");var Ge;globalThis.WebAssembly||C("no native wasm support detected");var be,Ie=!1,$e;function h(e,r){e||q("Assertion failed"+(r?": "+r:""))}var ir=e=>e.startsWith("file://");function bt(){var e=dt();h((e&3)==0),e==0&&(e+=4),(c(),y)[e>>2]=34821223,(c(),y)[e+4>>2]=2310721022,(c(),y)[0]=1668509029}function ze(){if(!Ie){var e=dt();e==0&&(e+=4);var r=(c(),y)[e>>2],t=(c(),y)[e+4>>2];(r!=34821223||t!=2310721022)&&q(`Stack overflow! Stack cookie has been overwritten at ${we(e)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${we(t)} ${we(r)}`),(c(),y)[0]!=1668509029&&q("Runtime error: The application has corrupted its heap memory area (address zero)!")}}class j{}class Hs extends j{}var St=!0;function Rr(...e){if(!(!St&&typeof St<"u"))if(M){let n=function(i){switch(typeof i){case"object":return t.inspect(i);case"undefined":return"undefined"}return i};var r=le("node:fs"),t=le("node:util");r.writeSync(2,e.map(n).join(" ")+`
|
|
4
|
+
`)}else console.warn(...e)}(()=>{var e=new Int16Array(1),r=new Int8Array(e.buffer);e[0]=25459,(r[0]!==115||r[1]!==99)&&q("Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)")})();function ar(e){Object.getOwnPropertyDescriptor(f,e)||Object.defineProperty(f,e,{configurable:!0,set(){q(`Attempt to set \`Module.${e}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`)}})}function $(e){return()=>h(!1,`call to '${e}' via reference taken before Wasm module initialization`)}function Se(e){Object.getOwnPropertyDescriptor(f,e)&&q(`\`Module.${e}\` was supplied but \`${e}\` not included in INCOMING_MODULE_JS_API`)}function yi(e){return e==="FS_createPath"||e==="FS_createDataFile"||e==="FS_createPreloadedFile"||e==="FS_preloadFile"||e==="FS_unlink"||e==="addRunDependency"||e==="FS_createLazyFile"||e==="FS_createDevice"||e==="removeRunDependency"}function wi(e){kt(e)}function kt(e){w||Object.getOwnPropertyDescriptor(f,e)||Object.defineProperty(f,e,{configurable:!0,get(){var r=`'${e}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;yi(e)&&(r+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),q(r)}})}function Ei(){function e(){var t=0;return Ne&&typeof De<"u"&&(t=De()),`w:${Ft},t:${we(t)}:`}var r=Rr;Rr=(...t)=>r(e(),...t)}Ei();function c(){fe.buffer!=H.buffer&&or()}var Ir,$r;if(M&&w){globalThis.self=globalThis;var Tt=rr.parentPort;globalThis.postMessage||(Tt.on("message",e=>globalThis.onmessage?.({data:e})),globalThis.postMessage=e=>Tt.postMessage(e)),process.on("uncaughtException",e=>{postMessage({cmd:"uncaughtException",error:e}),process.exit(1)})}var Ft=0,Pt;if(w){let e=function(r){try{var t=r.data,n=t.cmd;if(n==="load"){Ft=t.workerID;let i=[];self.onmessage=a=>i.push(a),Pt=()=>{postMessage({cmd:"loaded"});for(let a of i)e(a);self.onmessage=e};for(let a of t.handlers)(!f[a]||f[a].proxy)&&(f[a]=(...s)=>{postMessage({cmd:"callHandler",handler:a,args:s})},a=="print"&&(ge=f[a]),a=="printErr"&&(C=f[a]));fe=t.wasmMemory,or(),be=t.wasmModule,Ot(),Cr()}else if(n==="run"){h(t.pthread_ptr),Ii(t.pthread_ptr),st(t.pthread_ptr,0,0,1,0,0),P.threadInitTLS(),it(t.pthread_ptr),Nr||(qn(),Nr=!0);try{$i(t.start_routine,t.arg)}catch(i){if(i!="unwind")throw i}}else t.target==="setimmediate"||(n==="checkMailbox"?Nr&&Tr():n&&(C(`worker: received unknown command ${n}`),C(t)))}catch(i){throw C(`worker: onmessage() captured an uncaught exception: ${i}`),i?.stack&&C(i.stack),Yn(),i}};var Nr=!1;self.onunhandledrejection=r=>{throw r.reason||r},self.onmessage=e}var Ne=!1;function or(){var e=fe.buffer;H=new Int8Array(e),ne=new Int16Array(e),f.HEAPU8=te=new Uint8Array(e),ke=new Uint16Array(e),S=new Int32Array(e),y=new Uint32Array(e),sr=new Float32Array(e),Me=new Float64Array(e),Z=new BigInt64Array(e),Rt=new BigUint64Array(e)}function bi(){if(!w){if(f.wasmMemory)fe=f.wasmMemory;else{var e=f.INITIAL_MEMORY||16777216;h(e>=65536,`INITIAL_MEMORY should be larger than STACK_SIZE, was ${e}! (STACK_SIZE=65536)`),fe=new WebAssembly.Memory({initial:e/65536,maximum:32768,shared:!0})}or()}}h(globalThis.Int32Array&&globalThis.Float64Array&&Int32Array.prototype.subarray&&Int32Array.prototype.set,"JS engine does not provide full typed array support");function Si(){if(h(!w),f.preRun)for(typeof f.preRun=="function"&&(f.preRun=[f.preRun]);f.preRun.length;)xt(f.preRun.shift());ar("preRun"),Nt(Mt)}function Ct(){if(h(!Ne),Ne=!0,w)return Pt();ze(),T.root=o.mount(T,{},null),!f.noFSInit&&!o.initialized&&o.init(),pe.init(),Re.__wasm_call_ctors(),o.ignorePermissions=!1}function ki(){if(ze(),!w){if(f.postRun)for(typeof f.postRun=="function"&&(f.postRun=[f.postRun]);f.postRun.length;)Ri(f.postRun.shift());ar("postRun"),Nt(Bt)}}function q(e){f.onAbort?.(e),e=`Aborted(${e})`,C(e),Ie=!0;var r=new WebAssembly.RuntimeError(e);throw $r?.(r),r}function J(e,r){return(...t)=>{h(Ne,`native function \`${e}\` called before runtime initialization`);var n=Re[e];return h(n,`exported native function \`${e}\` not found`),h(t.length<=r,`native function \`${e}\` called with ${t.length} args but expects ${r}`),n(...t)}}var Mr;function Ti(){return f.locateFile?mi("libe57-js.wasm"):new URL("libe57-js.wasm",import.meta.url).href}function Fi(e){if(e==Mr&&Ge)return new Uint8Array(Ge);if(He)return He(e);throw"both async and sync fetching of the wasm failed"}async function Pi(e){if(!Ge)try{var r=await nr(e);return new Uint8Array(r)}catch{}return Fi(e)}async function Ci(e,r){try{var t=await Pi(e),n=await WebAssembly.instantiate(t,r);return n}catch(i){C(`failed to asynchronously prepare wasm: ${i}`),ir(e)&&C(`warning: Loading from a file URI (${e}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`),q(i)}}async function Ai(e,r,t){if(!e&&!M)try{var n=fetch(r,{credentials:"same-origin"}),i=await WebAssembly.instantiateStreaming(n,t);return i}catch(a){C(`wasm streaming compile failed: ${a}`),C("falling back to ArrayBuffer instantiation")}return Ci(r,t)}function At(){rs();var e={env:ht,wasi_snapshot_preview1:ht};return e}async function Ot(){function e(l,d){return Re=l.exports,Ni(Re._emscripten_tls_init),es(Re),be=d,Re}var r=f;function t(l){return h(f===r,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),r=null,e(l.instance,l.module)}var n=At();if(f.instantiateWasm)return new Promise((l,d)=>{try{f.instantiateWasm(n,(u,_)=>{l(e(u,_))})}catch(u){C(`Module.instantiateWasm callback failed with error: ${u}`),d(u)}});if(w){h(be,"wasmModule should have been received via postMessage");var i=new WebAssembly.Instance(be,At());return e(i,be)}Mr??=Ti();var a=await Ai(Ge,Mr,n),s=t(a);return s}class Dt{name="ExitStatus";constructor(r){this.message=`Program terminated with exit(${r})`,this.status=r}}var ne,S,Z,H,sr,Me,ke,y,Rt,te,It=e=>{e.terminate(),e.onmessage=r=>{var t=r.data.cmd;C(`received "${t}" command from terminated worker: ${e.workerID}`)}},$t=e=>{h(!w,"cleanupThread() should only be called from the main thread"),h(e,"null pthread_ptr passed to cleanupThread");var r=P.pthreads[e];h(r),P.returnWorkerToPool(r)},Nt=e=>{for(;e.length>0;)e.shift()(f)},Mt=[],xt=e=>Mt.push(e),Te=0,Ve=null,xe={},ye=null,xr=e=>{if(Te--,f.monitorRunDependencies?.(Te),h(e,"removeRunDependency requires an ID"),h(xe[e]),delete xe[e],Te==0&&(ye!==null&&(clearInterval(ye),ye=null),Ve)){var r=Ve;Ve=null,r()}},Lr=e=>{Te++,f.monitorRunDependencies?.(Te),h(e,"addRunDependency requires an ID"),h(!xe[e]),xe[e]=1,ye===null&&globalThis.setInterval&&(ye=setInterval(()=>{if(Ie){clearInterval(ye),ye=null;return}var r=!1;for(var t in xe)r||(r=!0,C("still waiting on run dependencies:")),C(`dependency: ${t}`);r&&C("(end of list)")},1e4),ye.unref?.())},Lt=e=>{h(!w,"spawnThread() should only be called from the main thread"),h(e.pthread_ptr,"spawnThread called with null pthread ptr");var r=P.getNewWorker();if(!r)return 6;h(!r.pthread_ptr),P.runningWorkers.push(r),P.pthreads[e.pthread_ptr]=r,r.pthread_ptr=e.pthread_ptr;var t={cmd:"run",start_routine:e.startRoutine,arg:e.arg,pthread_ptr:e.pthread_ptr};return M&&r.unref(),r.postMessage(t,e.transferList),0},lr=0,dr=()=>Ur||lr>0,B=()=>ft(),L=e=>ni(e),Oi=e=>ii(e),K=(e,r,t,...n)=>{var i=8*n.length*2,a=B(),s=Oi(i),l=s>>3;for(var d of n)typeof d=="bigint"?((c(),Z)[l++]=1n,(c(),Z)[l++]=d):((c(),Z)[l++]=0n,(c(),Me)[l++]=d);var u=Zn(e,r,i,s,t);return L(a),u};function Wt(e){if(w)return K(0,0,1,e);$e=e,dr()||(P.terminateAllThreads(),f.onExit?.(e),Ie=!0),Or(e,new Dt(e))}function Ut(e){if(w)return K(1,0,0,e);Wr(e)}var Di=(e,r)=>{if($e=e,Ds(),w)throw h(!r),Ut(e),"unwind";if(dr()&&!r){var t=`program exited (with status: ${e}), but keepRuntimeAlive() is set (counter=${lr}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;$r?.(t),C(t)}Wt(e)},Wr=Di,jt=!Atomics.waitAsync||globalThis.navigator?.userAgent&&Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2])<91;function we(e){return h(typeof e=="number",`ptrToString expects a number, got ${typeof e}`),e>>>=0,"0x"+e.toString(16).padStart(8,"0")}var P={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},nextWorkerID:1,init(){w||P.initMainThread()},initMainThread(){for(var e=2;e--;)P.allocateUnusedWorker();xt(async()=>{var r=P.loadWasmModuleToAllWorkers();Lr("loading-workers"),await r,xr("loading-workers")})},terminateAllThreads:()=>{h(!w,"terminateAllThreads() should only be called from the main thread");for(var e of P.runningWorkers)It(e);for(var e of P.unusedWorkers)It(e);P.unusedWorkers=[],P.runningWorkers=[],P.pthreads={}},terminateRuntime:()=>{h(!w,"terminateRuntime() should only be called from the main thread"),P.terminateAllThreads();var e=De();Xn(0,0,0,1),jt||Atomics.notify((c(),S),e>>2)},returnWorkerToPool:e=>{var r=e.pthread_ptr;delete P.pthreads[r],P.unusedWorkers.push(e),P.runningWorkers.splice(P.runningWorkers.indexOf(e),1),e.pthread_ptr=0,Qn(r)},threadInitTLS(){P.tlsInitFunctions.forEach(e=>e())},loadWasmModuleToWorker:e=>new Promise(r=>{e.onmessage=a=>{var s=a.data,l=s.cmd;if(s.targetThread&&s.targetThread!=De()){var d=P.pthreads[s.targetThread];d?d.postMessage(s,s.transferList):C(`worker sent message (${l}) to pthread (${s.targetThread}) that no longer exists`);return}l==="checkMailbox"?Tr():l==="spawnThread"?Lt(s):l==="cleanupThread"?$n(()=>$t(s.thread)):l==="loaded"?(e.loaded=!0,M&&!e.pthread_ptr&&e.unref(),r(e)):s.target==="setimmediate"?e.postMessage(s):l==="uncaughtException"?e.onerror(s.error):l==="callHandler"?f[s.handler](...s.args):l&&C(`worker sent an unknown command ${l}`)},e.onerror=a=>{var s="worker sent an error!";throw e.pthread_ptr&&(s=`Pthread ${we(e.pthread_ptr)} sent an error!`),C(`${s} ${a.filename}:${a.lineno}: ${a.message}`),a},M&&(e.on("message",a=>e.onmessage({data:a})),e.on("error",a=>e.onerror(a))),h(fe instanceof WebAssembly.Memory,"wasmMemory should have been loaded by now"),h(be instanceof WebAssembly.Module,"wasmModule should have been loaded by now");var t=[],n=["onExit","onAbort","print","printErr"];for(var i of n)f.propertyIsEnumerable(i)&&t.push(i);e.postMessage({cmd:"load",handlers:t,wasmMemory:fe,wasmModule:be,workerID:e.workerID})}),async loadWasmModuleToAllWorkers(){return w?void 0:Promise.all(P.unusedWorkers.map(P.loadWasmModuleToWorker))},allocateUnusedWorker(){var e;if(f.mainScriptUrlOrBlob){var r=f.mainScriptUrlOrBlob;typeof r!="string"&&(r=URL.createObjectURL(r)),e=new Worker(r,{type:"module",workerData:"em-pthread",name:"em-pthread-"+P.nextWorkerID})}else e=new Worker(new URL("libe57-js.js",import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread-"+P.nextWorkerID});e.workerID=P.nextWorkerID++,P.unusedWorkers.push(e)},getNewWorker(){return P.unusedWorkers.length==0&&(M||C("Tried to spawn a new thread, but the thread pool is exhausted.\nThis might result in a deadlock unless some threads eventually exit or the code explicitly breaks out to the event loop.\nIf you want to increase the pool size, use setting `-sPTHREAD_POOL_SIZE=...`.\nIf you want to throw an explicit error instead of the risk of deadlocking in those cases, use setting `-sPTHREAD_POOL_SIZE_STRICT=2`."),P.allocateUnusedWorker(),P.loadWasmModuleToWorker(P.unusedWorkers[0])),P.unusedWorkers.pop()}},Bt=[],Ri=e=>Bt.push(e);function Ii(e){var r=(c(),y)[e+48>>2],t=(c(),y)[e+52>>2],n=r-t;h(r!=0),h(n!=0),h(r>n,"stackHigh must be higher then stackLow"),ti(r,n),L(r),bt()}function Gs(e,r="i8"){switch(r.endsWith("*")&&(r="*"),r){case"i1":return(c(),H)[e];case"i8":return(c(),H)[e];case"i16":return(c(),ne)[e>>1];case"i32":return(c(),S)[e>>2];case"i64":return(c(),Z)[e>>3];case"float":return(c(),sr)[e>>2];case"double":return(c(),Me)[e>>3];case"*":return(c(),y)[e>>2];default:q(`invalid type for getValue: ${r}`)}}var Ht=[],W=e=>{var r=Ht[e];return r||(Ht[e]=r=_t.get(e)),h(_t.get(e)==r,"table mirror is out of date"),r},$i=(e,r)=>{lr=0,Ur=0;var t=W(e)(r);ze();function n(i){if(dr()){$e=i;return}ut(i)}n(t)},Ur=!0,Ni=e=>P.tlsInitFunctions.push(e);function zs(e,r,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":(c(),H)[e]=r;break;case"i8":(c(),H)[e]=r;break;case"i16":(c(),ne)[e>>1]=r;break;case"i32":(c(),S)[e>>2]=r;break;case"i64":(c(),Z)[e>>3]=BigInt(r);break;case"float":(c(),sr)[e>>2]=r;break;case"double":(c(),Me)[e>>3]=r;break;case"*":(c(),y)[e>>2]=r;break;default:q(`invalid type for setValue: ${t}`)}}var Fe=e=>{Fe.shown||={},Fe.shown[e]||(Fe.shown[e]=1,M&&(e="warning: "+e),C(e))},fe,Gt=globalThis.TextDecoder&&new TextDecoder,zt=(e,r,t,n)=>{var i=r+t;if(n)return i;for(;e[r]&&!(r>=i);)++r;return r},Le=(e,r=0,t,n)=>{var i=zt(e,r,t,n);if(i-r>16&&e.buffer&&Gt)return Gt.decode(e.buffer instanceof ArrayBuffer?e.subarray(r,i):e.slice(r,i));for(var a="";r<i;){var s=e[r++];if(!(s&128)){a+=String.fromCharCode(s);continue}var l=e[r++]&63;if((s&224)==192){a+=String.fromCharCode((s&31)<<6|l);continue}var d=e[r++]&63;if((s&240)==224?s=(s&15)<<12|l<<6|d:((s&248)!=240&&Fe(`Invalid UTF-8 leading byte ${we(s)} encountered when deserializing a UTF-8 string in wasm memory to a JS string!`),s=(s&7)<<18|l<<12|d<<6|e[r++]&63),s<65536)a+=String.fromCharCode(s);else{var u=s-65536;a+=String.fromCharCode(55296|u>>10,56320|u&1023)}}return a},_e=(e,r,t)=>(h(typeof e=="number",`UTF8ToString expects a number (got ${typeof e})`),e?Le((c(),te),e,r,t):""),Mi=(e,r,t,n)=>q(`Assertion failed: ${_e(e)}, at: `+[r?_e(r):"unknown filename",t,n?_e(n):"unknown function"]),jr=[],Vt=0,xi=e=>{var r=new qt(e);return r.get_caught()||(r.set_caught(!0),Vt--),r.set_rethrown(!1),jr.push(r),oi(e)},Li=()=>{U(0,0),h(jr.length>0);var e=jr.pop();ai(e.excPtr)},Br=e=>(setTempRet0(0),0),Wi=()=>Br([]),Ui=e=>Br([e]),ji=(e,r)=>Br([e,r]);class qt{constructor(r){this.excPtr=r,this.ptr=r-24}set_type(r){(c(),y)[this.ptr+4>>2]=r}get_type(){return(c(),y)[this.ptr+4>>2]}set_destructor(r){(c(),y)[this.ptr+8>>2]=r}get_destructor(){return(c(),y)[this.ptr+8>>2]}set_caught(r){r=r?1:0,(c(),H)[this.ptr+12]=r}get_caught(){return(c(),H)[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,(c(),H)[this.ptr+13]=r}get_rethrown(){return(c(),H)[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)}set_adjusted_ptr(r){(c(),y)[this.ptr+16>>2]=r}get_adjusted_ptr(){return(c(),y)[this.ptr+16>>2]}}var Bi=(e,r,t)=>{var n=new qt(e);n.init(r,t),Vt++,h(!1,"Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.")};function Kt(e,r,t,n){return w?K(2,0,1,e,r,t,n):Xt(e,r,t,n)}var Hi=()=>!!globalThis.SharedArrayBuffer,Xt=(e,r,t,n)=>{if(!Hi())return Rr("pthread_create: environment does not support SharedArrayBuffer, pthreads are not available"),6;var i=[],a=0;if(w&&(i.length===0||a))return Kt(e,r,t,n);if(a)return a;var s={startRoutine:t,pthread_ptr:e,arg:n,transferList:i};return w?(s.cmd="spawnThread",postMessage(s,i),0):Lt(s)},Gi=e=>{h(!1,"Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.")},zi=()=>{if(M){var e=le("node:crypto");return r=>e.randomFillSync(r)}return r=>(r.set(crypto.getRandomValues(new Uint8Array(r.byteLength))),0)},Hr=e=>(Hr=zi())(e),I={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var i=e[n];i==="."?e.splice(n,1):i===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=I.isAbs(e),t=e.slice(-1)==="/";return e=I.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=I.splitPath(e),t=r[0],n=r[1];return!t&&!n?".":(n&&(n=n.slice(0,-1)),t+n)},basename:e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>I.normalize(e.join("/")),join2:(e,r)=>I.normalize(e+"/"+r)},We={resolve:(...e)=>{for(var r="",t=!1,n=e.length-1;n>=-1&&!t;n--){var i=n>=0?e[n]:o.cwd();if(typeof i!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";r=i+"/"+r,t=I.isAbs(i)}return r=I.normalizeArray(r.split("/").filter(a=>!!a),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=We.resolve(e).slice(1),r=We.resolve(r).slice(1);function t(u){for(var _=0;_<u.length&&u[_]==="";_++);for(var p=u.length-1;p>=0&&u[p]==="";p--);return _>p?[]:u.slice(_,p-_+1)}for(var n=t(e.split("/")),i=t(r.split("/")),a=Math.min(n.length,i.length),s=a,l=0;l<a;l++)if(n[l]!==i[l]){s=l;break}for(var d=[],l=s;l<n.length;l++)d.push("..");return d=d.concat(i.slice(s)),d.join("/")}},Gr=[],Pe=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r},Yt=(e,r,t,n)=>{if(h(typeof e=="string",`stringToUTF8Array expects a string (got ${typeof e})`),!(n>0))return 0;for(var i=t,a=t+n-1,s=0;s<e.length;++s){var l=e.codePointAt(s);if(l<=127){if(t>=a)break;r[t++]=l}else if(l<=2047){if(t+1>=a)break;r[t++]=192|l>>6,r[t++]=128|l&63}else if(l<=65535){if(t+2>=a)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63}else{if(t+3>=a)break;l>1114111&&Fe(`Invalid Unicode code point ${we(l)} encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).`),r[t++]=240|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63,s++}}return r[t]=0,t-i},zr=(e,r,t)=>{var n=t>0?t:Pe(e)+1,i=new Array(n),a=Yt(e,i,0,i.length);return r&&(i.length=a),i},Vi=()=>{if(!Gr.length){var e=null;if(M){var r=256,t=Buffer.alloc(r),n=0,i=process.stdin.fd;try{n=x.readSync(i,t,0,r)}catch(a){if(a.toString().includes("EOF"))n=0;else throw a}n>0&&(e=t.slice(0,n).toString("utf-8"))}else globalThis.window?.prompt&&(e=window.prompt("Input: "),e!==null&&(e+=`
|
|
5
|
+
`));if(!e)return null;Gr=zr(e,!0)}return Gr.shift()},pe={ttys:[],init(){},shutdown(){},register(e,r){pe.ttys[e]={input:[],output:[],ops:r},o.registerDevice(e,pe.stream_ops)},stream_ops:{open(e){var r=pe.ttys[e.node.rdev];if(!r)throw new o.ErrnoError(43);e.tty=r,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,r,t,n,i){if(!e.tty||!e.tty.ops.get_char)throw new o.ErrnoError(60);for(var a=0,s=0;s<n;s++){var l;try{l=e.tty.ops.get_char(e.tty)}catch{throw new o.ErrnoError(29)}if(l===void 0&&a===0)throw new o.ErrnoError(6);if(l==null)break;a++,r[t+s]=l}return a&&(e.node.atime=Date.now()),a},write(e,r,t,n,i){if(!e.tty||!e.tty.ops.put_char)throw new o.ErrnoError(60);try{for(var a=0;a<n;a++)e.tty.ops.put_char(e.tty,r[t+a])}catch{throw new o.ErrnoError(29)}return n&&(e.node.mtime=e.node.ctime=Date.now()),a}},default_tty_ops:{get_char(e){return Vi()},put_char(e,r){r===null||r===10?(ge(Le(e.output)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output?.length>0&&(ge(Le(e.output)),e.output=[])},ioctl_tcgets(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(e,r,t){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,r){r===null||r===10?(C(Le(e.output)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output?.length>0&&(C(Le(e.output)),e.output=[])}}},Vr=e=>{q("internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported")},F={ops_table:null,mount(e){return F.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(o.isBlkdev(t)||o.isFIFO(t))throw new o.ErrnoError(63);F.ops_table||={dir:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr,lookup:F.node_ops.lookup,mknod:F.node_ops.mknod,rename:F.node_ops.rename,unlink:F.node_ops.unlink,rmdir:F.node_ops.rmdir,readdir:F.node_ops.readdir,symlink:F.node_ops.symlink},stream:{llseek:F.stream_ops.llseek}},file:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr},stream:{llseek:F.stream_ops.llseek,read:F.stream_ops.read,write:F.stream_ops.write,mmap:F.stream_ops.mmap,msync:F.stream_ops.msync}},link:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr,readlink:F.node_ops.readlink},stream:{}},chrdev:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr},stream:o.chrdev_stream_ops}};var i=o.createNode(e,r,t,n);return o.isDir(i.mode)?(i.node_ops=F.ops_table.dir.node,i.stream_ops=F.ops_table.dir.stream,i.contents={}):o.isFile(i.mode)?(i.node_ops=F.ops_table.file.node,i.stream_ops=F.ops_table.file.stream,i.usedBytes=0,i.contents=F.emptyFileContents??=new Uint8Array(0)):o.isLink(i.mode)?(i.node_ops=F.ops_table.link.node,i.stream_ops=F.ops_table.link.stream):o.isChrdev(i.mode)&&(i.node_ops=F.ops_table.chrdev.node,i.stream_ops=F.ops_table.chrdev.stream),i.atime=i.mtime=i.ctime=Date.now(),e&&(e.contents[r]=i,e.atime=e.mtime=e.ctime=i.atime),i},getFileDataAsTypedArray(e){return h(o.isFile(e.mode),"getFileDataAsTypedArray called on non-file"),e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,r){var t=e.contents.length;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t&&(r=Math.max(r,256));var i=F.getFileDataAsTypedArray(e);e.contents=new Uint8Array(r),e.contents.set(i)}},resizeFileStorage(e,r){if(e.usedBytes!=r){var t=e.contents;e.contents=new Uint8Array(r),e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r}},node_ops:{getattr(e){var r={};return r.dev=o.isChrdev(e.mode)?e.id:1,r.ino=e.id,r.mode=e.mode,r.nlink=1,r.uid=0,r.gid=0,r.rdev=e.rdev,o.isDir(e.mode)?r.size=4096:o.isFile(e.mode)?r.size=e.usedBytes:o.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.atime),r.mtime=new Date(e.mtime),r.ctime=new Date(e.ctime),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){for(let t of["mode","atime","mtime","ctime"])r[t]!=null&&(e[t]=r[t]);r.size!==void 0&&F.resizeFileStorage(e,r.size)},lookup(e,r){throw new o.ErrnoError(44)},mknod(e,r,t,n){return F.createNode(e,r,t,n)},rename(e,r,t){var n;try{n=o.lookupNode(r,t)}catch{}if(n){if(o.isDir(e.mode))for(var i in n.contents)throw new o.ErrnoError(55);o.hashRemoveNode(n)}delete e.parent.contents[e.name],r.contents[t]=e,e.name=t,r.ctime=r.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,r){delete e.contents[r],e.ctime=e.mtime=Date.now()},rmdir(e,r){var t=o.lookupNode(e,r);for(var n in t.contents)throw new o.ErrnoError(55);delete e.contents[r],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,r,t){var n=F.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!o.isLink(e.mode))throw new o.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,i){var a=e.node.contents;if(i>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-i,n);return h(s>=0),r.set(a.subarray(i,i+s),t),s},write(e,r,t,n,i,a){if(h(r.subarray,"FS.write expects a TypedArray"),r.buffer===(c(),H).buffer&&(a=!1),!n)return 0;var s=e.node;return s.mtime=s.ctime=Date.now(),a?(h(i===0,"canOwn must imply no weird position inside the file"),s.contents=r.subarray(t,t+n),s.usedBytes=n):s.usedBytes===0&&i===0?(s.contents=r.slice(t,t+n),s.usedBytes=n):(F.expandFileStorage(s,i+n),s.contents.set(r.subarray(t,t+n),i),s.usedBytes=Math.max(s.usedBytes,i+n)),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&o.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new o.ErrnoError(28);return n},mmap(e,r,t,n,i){if(!o.isFile(e.node.mode))throw new o.ErrnoError(43);var a,s,l=e.node.contents;if(!(i&2)&&l.buffer===(c(),H).buffer)s=!1,a=l.byteOffset;else{if(s=!0,a=Vr(r),!a)throw new o.ErrnoError(48);l&&((t>0||t+r<l.length)&&(l.subarray?l=l.subarray(t,t+r):l=Array.prototype.slice.call(l,t,t+r)),(c(),H).set(l,a))}return{ptr:a,allocated:s}},msync(e,r,t,n,i){return F.stream_ops.write(e,r,0,n,t,!1),0}}},qi=e=>{if(typeof e!="string")return e;var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t},Jt=e=>(typeof e=="string"&&(e=zr(e,!0)),e.subarray||(e=new Uint8Array(e)),e),qr=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},cr={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135},b={isWindows:!1,staticInit(){b.isWindows=!!process.platform.match(/^win/);var e=process.binding("constants").fs;b.flagsForNodeMap={1024:e.O_APPEND,64:e.O_CREAT,128:e.O_EXCL,256:e.O_NOCTTY,0:e.O_RDONLY,2:e.O_RDWR,4096:e.O_SYNC,512:e.O_TRUNC,1:e.O_WRONLY,131072:e.O_NOFOLLOW},h(b.flagsForNodeMap[0]===0)},convertNodeCode(e){var r=e.code;return h(r in cr,`unexpected node error code: ${r} (${e})`),cr[r]},tryFSOperation(e){try{return e()}catch(r){throw r.code?r.code==="UNKNOWN"?new o.ErrnoError(28):new o.ErrnoError(b.convertNodeCode(r)):r}},mount(e){return h(M),b.createNode(null,"/",b.getMode(e.opts.root),0)},createNode(e,r,t,n){if(!o.isDir(t)&&!o.isFile(t)&&!o.isLink(t))throw new o.ErrnoError(28);var i=o.createNode(e,r,t);return i.node_ops=b.node_ops,i.stream_ops=b.stream_ops,i},getMode(e){return b.tryFSOperation(()=>{var r=x.lstatSync(e).mode;return b.isWindows&&(r|=(r&292)>>2),r})},realPath(e){for(var r=[];e.parent!==e;)r.push(e.name),e=e.parent;return r.push(e.mount.opts.root),r.reverse(),I.join(...r)},flagsForNode(e){e&=-2097153,e&=-2049,e&=-32769,e&=-524289,e&=-65537;var r=0;for(var t in b.flagsForNodeMap)e&t&&(r|=b.flagsForNodeMap[t],e^=t);if(e)throw new o.ErrnoError(28);return r},getattr(e,r){var t=b.tryFSOperation(e);return b.isWindows&&(t.blksize||(t.blksize=4096),t.blocks||(t.blocks=(t.size+t.blksize-1)/t.blksize|0),t.mode|=(t.mode&292)>>2),{dev:t.dev,ino:r.id,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,size:t.size,atime:t.atime,mtime:t.mtime,ctime:t.ctime,blksize:t.blksize,blocks:t.blocks}},setattr(e,r,t,n,i,a,s){b.tryFSOperation(()=>{if(t.mode!==void 0){var l=t.mode;b.isWindows&&(l&=384),n(e,l),r.mode=t.mode}if(typeof(t.atime??t.mtime)=="number"){var d=new Date(t.atime??s(e).atime),u=new Date(t.mtime??s(e).mtime);i(e,d,u)}t.size!==void 0&&a(e,t.size)})},node_ops:{getattr(e){var r=b.realPath(e);return b.getattr(()=>x.lstatSync(r),e)},setattr(e,r){var t=b.realPath(e);if(r.mode!=null&&r.dontFollow)throw new o.ErrnoError(52);b.setattr(t,e,r,x.chmodSync,x.utimesSync,x.truncateSync,x.lstatSync)},lookup(e,r){var t=I.join2(b.realPath(e),r),n=b.getMode(t);return b.createNode(e,r,n)},mknod(e,r,t,n){var i=b.createNode(e,r,t,n),a=b.realPath(i);return b.tryFSOperation(()=>{o.isDir(i.mode)?x.mkdirSync(a,i.mode):x.writeFileSync(a,"",{mode:i.mode})}),i},rename(e,r,t){var n=b.realPath(e),i=I.join2(b.realPath(r),t);try{o.unlink(i)}catch{}b.tryFSOperation(()=>x.renameSync(n,i)),e.name=t},unlink(e,r){var t=I.join2(b.realPath(e),r);b.tryFSOperation(()=>x.unlinkSync(t))},rmdir(e,r){var t=I.join2(b.realPath(e),r);b.tryFSOperation(()=>x.rmdirSync(t))},readdir(e){var r=b.realPath(e);return b.tryFSOperation(()=>x.readdirSync(r))},symlink(e,r,t){var n=I.join2(b.realPath(e),r);b.tryFSOperation(()=>x.symlinkSync(t,n))},readlink(e){var r=b.realPath(e);return b.tryFSOperation(()=>x.readlinkSync(r))},statfs(e){var r=b.tryFSOperation(()=>x.statfsSync(e));return r.frsize=r.bsize,r}},stream_ops:{getattr(e){return b.getattr(()=>x.fstatSync(e.nfd),e.node)},setattr(e,r){b.setattr(e.nfd,e.node,r,x.fchmodSync,x.futimesSync,x.ftruncateSync,x.fstatSync)},open(e){var r=b.realPath(e.node);b.tryFSOperation(()=>{e.shared.refcount=1,e.nfd=x.openSync(r,b.flagsForNode(e.flags))})},close(e){b.tryFSOperation(()=>{e.nfd&&--e.shared.refcount===0&&x.closeSync(e.nfd)})},dup(e){e.shared.refcount++},read(e,r,t,n,i){return b.tryFSOperation(()=>x.readSync(e.nfd,r,t,n,i))},write(e,r,t,n,i){return b.tryFSOperation(()=>x.writeSync(e.nfd,r,t,n,i))},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&o.isFile(e.node.mode)&&b.tryFSOperation(()=>{var i=x.fstatSync(e.nfd);n+=i.size}),n<0)throw new o.ErrnoError(28);return n},mmap(e,r,t,n,i){if(!o.isFile(e.node.mode))throw new o.ErrnoError(43);var a=Vr(r);return b.stream_ops.read(e,(c(),H),a,r,t),{ptr:a,allocated:!0}},msync(e,r,t,n,i){return b.stream_ops.write(e,r,0,n,t,!1),0}}},Ki=e=>_e(Kn(e)),Xi=async e=>{var r=await nr(e);return h(r,`Loading data file "${e}" failed (no arrayBuffer).`),new Uint8Array(r)},Zt=(...e)=>o.createDataFile(...e),Yi=e=>{for(var r=e;;){if(!xe[e])return e;e=r+Math.random()}},Qt=[],Ji=async(e,r)=>{typeof Browser<"u"&&Browser.init();for(var t of Qt)if(t.canHandle(r))return h(t.handle.constructor.name==="AsyncFunction","Filesystem plugin handlers must be async functions (See #24914)"),t.handle(e,r);return e},Kr=async(e,r,t,n,i,a,s,l)=>{var d=r?We.resolve(I.join2(e,r)):e,u=Yi(`cp ${d}`);Lr(u);try{var _=t;typeof t=="string"&&(_=await Xi(t)),_=await Ji(_,d),l?.(),a||Zt(e,r,_,n,i,s)}finally{xr(u)}},Zi=(e,r,t,n,i,a,s,l,d,u)=>{Kr(e,r,t,n,i,l,d,u).then(a).catch(s)},o={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,filesystems:null,syncFSRequests:0,ErrnoError:class extends Error{name="ErrnoError";constructor(e){super(Ne?Ki(e):""),this.errno=e;for(var r in cr)if(cr[r]===e){this.code=r;break}}},FSStream:class{shared={};get object(){return this.node}set object(e){this.node=e}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{node_ops={};stream_ops={};readMode=365;writeMode=146;mounted=null;constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.id=o.nextInode++,this.name=r,this.mode=t,this.rdev=n,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return o.isDir(this.mode)}get isDevice(){return o.isChrdev(this.mode)}},lookupPath(e,r={}){if(!e)throw new o.ErrnoError(44);r.follow_mount??=!0,I.isAbs(e)||(e=o.cwd()+"/"+e);e:for(var t=0;t<40;t++){for(var n=e.split("/").filter(u=>!!u),i=o.root,a="/",s=0;s<n.length;s++){var l=s===n.length-1;if(l&&r.parent)break;if(n[s]!=="."){if(n[s]===".."){if(a=I.dirname(a),o.isRoot(i)){e=a+"/"+n.slice(s+1).join("/"),t--;continue e}else i=i.parent;continue}a=I.join2(a,n[s]);try{i=o.lookupNode(i,n[s])}catch(u){if(u?.errno===44&&l&&r.noent_okay)return{path:a};throw u}if(o.isMountpoint(i)&&(!l||r.follow_mount)&&(i=i.mounted.root),o.isLink(i.mode)&&(!l||r.follow)){if(!i.node_ops.readlink)throw new o.ErrnoError(52);var d=i.node_ops.readlink(i);I.isAbs(d)||(d=I.dirname(a)+"/"+d),e=d+"/"+n.slice(s+1).join("/");continue e}}}return{path:a,node:i}}throw new o.ErrnoError(32)},getPath(e){for(var r;;){if(o.isRoot(e)){var t=e.mount.mountpoint;return r?t[t.length-1]!=="/"?`${t}/${r}`:t+r:t}r=r?`${e.name}/${r}`:e.name,e=e.parent}},hashName(e,r){for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return(e+t>>>0)%o.nameTable.length},hashAddNode(e){var r=o.hashName(e.parent.id,e.name);e.name_next=o.nameTable[r],o.nameTable[r]=e},hashRemoveNode(e){var r=o.hashName(e.parent.id,e.name);if(o.nameTable[r]===e)o.nameTable[r]=e.name_next;else for(var t=o.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode(e,r){var t=o.mayLookup(e);if(t)throw new o.ErrnoError(t);for(var n=o.hashName(e.id,r),i=o.nameTable[n];i;i=i.name_next){var a=i.name;if(i.parent.id===e.id&&a===r)return i}return o.lookup(e,r)},createNode(e,r,t,n){h(typeof e=="object");var i=new o.FSNode(e,r,t,n);return o.hashAddNode(i),i},destroyNode(e){o.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return(e&61440)===32768},isDir(e){return(e&61440)===16384},isLink(e){return(e&61440)===40960},isChrdev(e){return(e&61440)===8192},isBlkdev(e){return(e&61440)===24576},isFIFO(e){return(e&61440)===4096},isSocket(e){return(e&49152)===49152},flagsToPermissionString(e){var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions(e,r){return o.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!o.isDir(e.mode))return 54;var r=o.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){if(!o.isDir(e.mode))return 54;try{var t=o.lookupNode(e,r);return 20}catch{}return o.nodePermissions(e,"wx")},mayDelete(e,r,t){var n;try{n=o.lookupNode(e,r)}catch(a){return a.errno}var i=o.nodePermissions(e,"wx");if(i)return i;if(t){if(!o.isDir(n.mode))return 54;if(o.isRoot(n)||o.getPath(n)===o.cwd())return 10}else if(o.isDir(n.mode))return 31;return 0},mayOpen(e,r){if(!e)return 44;if(o.isLink(e.mode))return 32;var t=o.flagsToPermissionString(r);return o.isDir(e.mode)&&(t!=="r"||r&576)?31:o.nodePermissions(e,t)},checkOpExists(e,r){if(!e)throw new o.ErrnoError(r);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=o.MAX_OPEN_FDS;e++)if(!o.streams[e])return e;throw new o.ErrnoError(33)},getStreamChecked(e){var r=o.getStream(e);if(!r)throw new o.ErrnoError(8);return r},getStream:e=>o.streams[e],createStream(e,r=-1){return h(r>=-1),e=Object.assign(new o.FSStream,e),r==-1&&(r=o.nextfd()),e.fd=r,o.streams[r]=e,e},closeStream(e){o.streams[e]=null},dupStream(e,r=-1){var t=o.createStream(e,r);return t.stream_ops?.dup?.(t),t},doSetAttr(e,r,t){var n=e?.stream_ops.setattr,i=n?e:r;n??=r.node_ops.setattr,o.checkOpExists(n,63);try{n(i,t)}catch(a){throw a instanceof RangeError?new o.ErrnoError(22):a}},chrdev_stream_ops:{open(e){var r=o.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new o.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice(e,r){o.devices[e]={stream_ops:r}},getDevice:e=>o.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push(...n.mounts)}return r},syncfs(e,r){typeof e=="function"&&(r=e,e=!1),o.syncFSRequests++,o.syncFSRequests>1&&C(`warning: ${o.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=o.getMounts(o.root.mount),n=0;function i(l){return h(o.syncFSRequests>0),o.syncFSRequests--,r(l)}function a(l){if(l)return a.errored?void 0:(a.errored=!0,i(l));++n>=t.length&&i(null)}for(var s of t)s.type.syncfs?s.type.syncfs(s,e,a):a(null)},mount(e,r,t){if(typeof e=="string")throw e;var n=t==="/",i=!t,a;if(n&&o.root)throw new o.ErrnoError(10);if(!n&&!i){var s=o.lookupPath(t,{follow_mount:!1});if(t=s.path,a=s.node,o.isMountpoint(a))throw new o.ErrnoError(10);if(!o.isDir(a.mode))throw new o.ErrnoError(54)}var l={type:e,opts:r,mountpoint:t,mounts:[]},d=e.mount(l);return d.mount=l,l.root=d,n?o.root=d:a&&(a.mounted=l,a.mount&&a.mount.mounts.push(l)),d},unmount(e){var r=o.lookupPath(e,{follow_mount:!1});if(!o.isMountpoint(r.node))throw new o.ErrnoError(28);var t=r.node,n=t.mounted,i=o.getMounts(n);for(var[a,s]of Object.entries(o.nameTable))for(;s;){var l=s.name_next;i.includes(s.mount)&&o.destroyNode(s),s=l}t.mounted=null;var d=t.mount.mounts.indexOf(n);h(d!==-1),t.mount.mounts.splice(d,1)},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=o.lookupPath(e,{parent:!0}),i=n.node,a=I.basename(e);if(!a)throw new o.ErrnoError(28);if(a==="."||a==="..")throw new o.ErrnoError(20);var s=o.mayCreate(i,a);if(s)throw new o.ErrnoError(s);if(!i.node_ops.mknod)throw new o.ErrnoError(63);return i.node_ops.mknod(i,a,r,t)},statfs(e){return o.statfsNode(o.lookupPath(e,{follow:!0}).node)},statfsStream(e){return o.statfsNode(e.node)},statfsNode(e){var r={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:o.nextInode,ffree:o.nextInode-1,fsid:42,flags:2,namelen:255};return e.node_ops.statfs&&Object.assign(r,e.node_ops.statfs(e.mount.opts.root)),r},create(e,r=438){return r&=4095,r|=32768,o.mknod(e,r,0)},mkdir(e,r=511){return r&=1023,r|=16384,o.mknod(e,r,0)},mkdirTree(e,r){var t=e.split("/"),n="";for(var i of t)if(i){(n||I.isAbs(e))&&(n+="/"),n+=i;try{o.mkdir(n,r)}catch(a){if(a.errno!=20)throw a}}},mkdev(e,r,t){return typeof t>"u"&&(t=r,r=438),r|=8192,o.mknod(e,r,t)},symlink(e,r){if(!We.resolve(e))throw new o.ErrnoError(44);var t=o.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new o.ErrnoError(44);var i=I.basename(r),a=o.mayCreate(n,i);if(a)throw new o.ErrnoError(a);if(!n.node_ops.symlink)throw new o.ErrnoError(63);return n.node_ops.symlink(n,i,e)},rename(e,r){var t=I.dirname(e),n=I.dirname(r),i=I.basename(e),a=I.basename(r),s,l,d;if(s=o.lookupPath(e,{parent:!0}),l=s.node,s=o.lookupPath(r,{parent:!0}),d=s.node,!l||!d)throw new o.ErrnoError(44);if(l.mount!==d.mount)throw new o.ErrnoError(75);var u=o.lookupNode(l,i),_=We.relative(e,n);if(_.charAt(0)!==".")throw new o.ErrnoError(28);if(_=We.relative(r,t),_.charAt(0)!==".")throw new o.ErrnoError(55);var p;try{p=o.lookupNode(d,a)}catch{}if(u!==p){var m=o.isDir(u.mode),g=o.mayDelete(l,i,m);if(g)throw new o.ErrnoError(g);if(g=p?o.mayDelete(d,a,m):o.mayCreate(d,a),g)throw new o.ErrnoError(g);if(!l.node_ops.rename)throw new o.ErrnoError(63);if(o.isMountpoint(u)||p&&o.isMountpoint(p))throw new o.ErrnoError(10);if(d!==l&&(g=o.nodePermissions(l,"w"),g))throw new o.ErrnoError(g);o.hashRemoveNode(u);try{l.node_ops.rename(u,d,a),u.parent=d}catch(E){throw E}finally{o.hashAddNode(u)}}},rmdir(e){var r=o.lookupPath(e,{parent:!0}),t=r.node,n=I.basename(e),i=o.lookupNode(t,n),a=o.mayDelete(t,n,!0);if(a)throw new o.ErrnoError(a);if(!t.node_ops.rmdir)throw new o.ErrnoError(63);if(o.isMountpoint(i))throw new o.ErrnoError(10);t.node_ops.rmdir(t,n),o.destroyNode(i)},readdir(e){var r=o.lookupPath(e,{follow:!0}),t=r.node,n=o.checkOpExists(t.node_ops.readdir,54);return n(t)},unlink(e){var r=o.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new o.ErrnoError(44);var n=I.basename(e),i=o.lookupNode(t,n),a=o.mayDelete(t,n,!1);if(a)throw new o.ErrnoError(a);if(!t.node_ops.unlink)throw new o.ErrnoError(63);if(o.isMountpoint(i))throw new o.ErrnoError(10);t.node_ops.unlink(t,n),o.destroyNode(i)},readlink(e){var r=o.lookupPath(e),t=r.node;if(!t)throw new o.ErrnoError(44);if(!t.node_ops.readlink)throw new o.ErrnoError(28);return t.node_ops.readlink(t)},stat(e,r){var t=o.lookupPath(e,{follow:!r}),n=t.node,i=o.checkOpExists(n.node_ops.getattr,63);return i(n)},fstat(e){var r=o.getStreamChecked(e),t=r.node,n=r.stream_ops.getattr,i=n?r:t;return n??=t.node_ops.getattr,o.checkOpExists(n,63),n(i)},lstat(e){return o.stat(e,!0)},doChmod(e,r,t,n){o.doSetAttr(e,r,{mode:t&4095|r.mode&-4096,ctime:Date.now(),dontFollow:n})},chmod(e,r,t){var n;if(typeof e=="string"){var i=o.lookupPath(e,{follow:!t});n=i.node}else n=e;o.doChmod(null,n,r,t)},lchmod(e,r){o.chmod(e,r,!0)},fchmod(e,r){var t=o.getStreamChecked(e);o.doChmod(t,t.node,r,!1)},doChown(e,r,t){o.doSetAttr(e,r,{timestamp:Date.now(),dontFollow:t})},chown(e,r,t,n){var i;if(typeof e=="string"){var a=o.lookupPath(e,{follow:!n});i=a.node}else i=e;o.doChown(null,i,n)},lchown(e,r,t){o.chown(e,r,t,!0)},fchown(e,r,t){var n=o.getStreamChecked(e);o.doChown(n,n.node,!1)},doTruncate(e,r,t){if(o.isDir(r.mode))throw new o.ErrnoError(31);if(!o.isFile(r.mode))throw new o.ErrnoError(28);var n=o.nodePermissions(r,"w");if(n)throw new o.ErrnoError(n);o.doSetAttr(e,r,{size:t,timestamp:Date.now()})},truncate(e,r){if(r<0)throw new o.ErrnoError(28);var t;if(typeof e=="string"){var n=o.lookupPath(e,{follow:!0});t=n.node}else t=e;o.doTruncate(null,t,r)},ftruncate(e,r){var t=o.getStreamChecked(e);if(r<0||(t.flags&2097155)===0)throw new o.ErrnoError(28);o.doTruncate(t,t.node,r)},utime(e,r,t){var n=o.lookupPath(e,{follow:!0}),i=n.node,a=o.checkOpExists(i.node_ops.setattr,63);a(i,{atime:r,mtime:t})},open(e,r,t=438){if(e==="")throw new o.ErrnoError(44);r=qi(r),r&64?t=t&4095|32768:t=0;var n,i;if(typeof e=="object")n=e;else{i=e.endsWith("/");var a=o.lookupPath(e,{follow:!(r&131072),noent_okay:!0});n=a.node,e=a.path}var s=!1;if(r&64)if(n){if(r&128)throw new o.ErrnoError(20)}else{if(i)throw new o.ErrnoError(31);n=o.mknod(e,t|511,0),s=!0}if(!n)throw new o.ErrnoError(44);if(o.isChrdev(n.mode)&&(r&=-513),r&65536&&!o.isDir(n.mode))throw new o.ErrnoError(54);if(!s){var l=o.mayOpen(n,r);if(l)throw new o.ErrnoError(l)}r&512&&!s&&o.truncate(n,0),r&=-131713;var d=o.createStream({node:n,path:o.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return d.stream_ops.open&&d.stream_ops.open(d),s&&o.chmod(n,t&511),d},close(e){if(o.isClosed(e))throw new o.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{o.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,r,t){if(o.isClosed(e))throw new o.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new o.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new o.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,n,i){if(h(t>=0),n<0||i<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if((e.flags&2097155)===1)throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.read)throw new o.ErrnoError(28);var a=typeof i<"u";if(!a)i=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var s=e.stream_ops.read(e,r,t,n,i);return a||(e.position+=s),s},write(e,r,t,n,i,a){if(h(t>=0),h(r.subarray,"FS.write expects a TypedArray"),n<0||i<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if((e.flags&2097155)===0)throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.write)throw new o.ErrnoError(28);e.seekable&&e.flags&1024&&o.llseek(e,0,2);var s=typeof i<"u";if(!s)i=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var l=e.stream_ops.write(e,r,t,n,i,a);return s||(e.position+=l),l},mmap(e,r,t,n,i){if((n&2)!==0&&(i&2)===0&&(e.flags&2097155)!==2)throw new o.ErrnoError(2);if((e.flags&2097155)===1)throw new o.ErrnoError(2);if(!e.stream_ops.mmap)throw new o.ErrnoError(43);if(!r)throw new o.ErrnoError(28);return e.stream_ops.mmap(e,r,t,n,i)},msync(e,r,t,n,i){return h(t>=0),e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,i):0},ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new o.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary"&&q(`Invalid encoding type "${r.encoding}"`);var t=o.open(e,r.flags),n=o.stat(e),i=n.size,a=new Uint8Array(i);return o.read(t,a,0,i,0),r.encoding==="utf8"&&(a=Le(a)),o.close(t),a},writeFile(e,r,t={}){t.flags=t.flags||577;var n=o.open(e,t.flags,t.mode);r=Jt(r),o.write(n,r,0,r.byteLength,void 0,t.canOwn),o.close(n)},cwd:()=>o.currentPath,chdir(e){var r=o.lookupPath(e,{follow:!0});if(r.node===null)throw new o.ErrnoError(44);if(!o.isDir(r.node.mode))throw new o.ErrnoError(54);var t=o.nodePermissions(r.node,"x");if(t)throw new o.ErrnoError(t);o.currentPath=r.path},createDefaultDirectories(){o.mkdir("/tmp"),o.mkdir("/home"),o.mkdir("/home/web_user")},createDefaultDevices(){o.mkdir("/dev"),o.registerDevice(o.makedev(1,3),{read:()=>0,write:(n,i,a,s,l)=>s,llseek:()=>0}),o.mkdev("/dev/null",o.makedev(1,3)),pe.register(o.makedev(5,0),pe.default_tty_ops),pe.register(o.makedev(6,0),pe.default_tty1_ops),o.mkdev("/dev/tty",o.makedev(5,0)),o.mkdev("/dev/tty1",o.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(Hr(e),r=e.byteLength),e[--r]);o.createDevice("/dev","random",t),o.createDevice("/dev","urandom",t),o.mkdir("/dev/shm"),o.mkdir("/dev/shm/tmp")},createSpecialDirectories(){o.mkdir("/proc");var e=o.mkdir("/proc/self");o.mkdir("/proc/self/fd"),o.mount({mount(){var r=o.createNode(e,"fd",16895,73);return r.stream_ops={llseek:F.stream_ops.llseek},r.node_ops={lookup(t,n){var i=+n,a=o.getStreamChecked(i),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>a.path},id:i+1};return s.parent=s,s},readdir(){return Array.from(o.streams.entries()).filter(([t,n])=>n).map(([t,n])=>t.toString())}},r}},{},"/proc/self/fd")},createStandardStreams(e,r,t){e?o.createDevice("/dev","stdin",e):o.symlink("/dev/tty","/dev/stdin"),r?o.createDevice("/dev","stdout",null,r):o.symlink("/dev/tty","/dev/stdout"),t?o.createDevice("/dev","stderr",null,t):o.symlink("/dev/tty1","/dev/stderr");var n=o.open("/dev/stdin",0),i=o.open("/dev/stdout",1),a=o.open("/dev/stderr",1);h(n.fd===0,`invalid handle for stdin (${n.fd})`),h(i.fd===1,`invalid handle for stdout (${i.fd})`),h(a.fd===2,`invalid handle for stderr (${a.fd})`)},staticInit(){o.nameTable=new Array(4096),o.mount(F,{},"/"),o.createDefaultDirectories(),o.createDefaultDevices(),o.createSpecialDirectories(),o.filesystems={MEMFS:F,NODEFS:b}},init(e,r,t){h(!o.initialized,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)"),o.initialized=!0,e??=f.stdin,r??=f.stdout,t??=f.stderr,o.createStandardStreams(e,r,t)},quit(){o.initialized=!1,lt(0);for(var e of o.streams)e&&o.close(e)},findObject(e,r){var t=o.analyzePath(e,r);return t.exists?t.object:null},analyzePath(e,r){try{var t=o.lookupPath(e,{follow:!r});e=t.path}catch{}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=o.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=I.basename(e),t=o.lookupPath(e,{follow:!r}),n.exists=!0,n.path=t.path,n.object=t.node,n.name=t.node.name,n.isRoot=t.path==="/"}catch(i){n.error=i.errno}return n},createPath(e,r,t,n){e=typeof e=="string"?e:o.getPath(e);for(var i=r.split("/").reverse();i.length;){var a=i.pop();if(a){var s=I.join2(e,a);try{o.mkdir(s)}catch(l){if(l.errno!=20)throw l}e=s}}return s},createFile(e,r,t,n,i){var a=I.join2(typeof e=="string"?e:o.getPath(e),r),s=qr(n,i);return o.create(a,s)},createDataFile(e,r,t,n,i,a){var s=r;e&&(e=typeof e=="string"?e:o.getPath(e),s=r?I.join2(e,r):e);var l=qr(n,i),d=o.create(s,l);if(t){t=Jt(t),o.chmod(d,l|146);var u=o.open(d,577);o.write(u,t,0,t.length,0,a),o.close(u),o.chmod(d,l)}},createDevice(e,r,t,n){var i=I.join2(typeof e=="string"?e:o.getPath(e),r),a=qr(!!t,!!n);o.createDevice.major??=64;var s=o.makedev(o.createDevice.major++,0);return o.registerDevice(s,{open(l){l.seekable=!1},close(l){n?.buffer?.length&&n(10)},read(l,d,u,_,p){for(var m=0,g=0;g<_;g++){var E;try{E=t()}catch{throw new o.ErrnoError(29)}if(E===void 0&&m===0)throw new o.ErrnoError(6);if(E==null)break;m++,d[u+g]=E}return m&&(l.node.atime=Date.now()),m},write(l,d,u,_,p){for(var m=0;m<_;m++)try{n(d[u+m])}catch{throw new o.ErrnoError(29)}return _&&(l.node.mtime=l.node.ctime=Date.now()),m}}),o.mkdev(i,a,s)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)q("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");else try{e.contents=He(e.url)}catch{throw new o.ErrnoError(29)}},createLazyFile(e,r,t,n,i){class a{lengthKnown=!1;chunks=[];get(m){if(!(m>this.length-1||m<0)){var g=m%this.chunkSize,E=m/this.chunkSize|0;return this.getter(E)[g]}}setDataGetter(m){this.getter=m}cacheLength(){var m=new XMLHttpRequest;m.open("HEAD",t,!1),m.send(null),m.status>=200&&m.status<300||m.status===304||q("Couldn't load "+t+". Status: "+m.status);var g=Number(m.getResponseHeader("Content-length")),E,k=(E=m.getResponseHeader("Accept-Ranges"))&&E==="bytes",D=(E=m.getResponseHeader("Content-Encoding"))&&E==="gzip",R=1024*1024;k||(R=g);var G=(oe,de)=>{oe>de&&q("invalid range ("+oe+", "+de+") or no bytes requested!"),de>g-1&&q("only "+g+" bytes available! programmer error!");var V=new XMLHttpRequest;return V.open("GET",t,!1),g!==R&&V.setRequestHeader("Range","bytes="+oe+"-"+de),V.responseType="arraybuffer",V.overrideMimeType&&V.overrideMimeType("text/plain; charset=x-user-defined"),V.send(null),V.status>=200&&V.status<300||V.status===304||q("Couldn't load "+t+". Status: "+V.status),V.response!==void 0?new Uint8Array(V.response||[]):zr(V.responseText||"",!0)},z=this;z.setDataGetter(oe=>{var de=oe*R,V=(oe+1)*R-1;return V=Math.min(V,g-1),typeof z.chunks[oe]>"u"&&(z.chunks[oe]=G(de,V)),typeof z.chunks[oe]>"u"&&q("doXHR failed!"),z.chunks[oe]}),(D||!g)&&(R=g=1,g=this.getter(0).length,R=g,ge("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=g,this._chunkSize=R,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(globalThis.XMLHttpRequest){N||q("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var s=new a,l={isDevice:!1,contents:s}}else var l={isDevice:!1,url:t};var d=o.createFile(e,r,l,n,i);l.contents?d.contents=l.contents:l.url&&(d.contents=null,d.url=l.url),Object.defineProperties(d,{usedBytes:{get:function(){return this.contents.length}}});var u={};for(let[p,m]of Object.entries(d.stream_ops))u[p]=(...g)=>(o.forceLoadFile(d),m(...g));function _(p,m,g,E,k){var D=p.node.contents;if(k>=D.length)return 0;var R=Math.min(D.length-k,E);if(h(R>=0),D.slice)for(var G=0;G<R;G++)m[g+G]=D[k+G];else for(var G=0;G<R;G++)m[g+G]=D.get(k+G);return R}return u.read=(p,m,g,E,k)=>(o.forceLoadFile(d),_(p,m,g,E,k)),u.mmap=(p,m,g,E,k)=>{o.forceLoadFile(d);var D=Vr(m);if(!D)throw new o.ErrnoError(48);return _(p,(c(),H),D,m,g),{ptr:D,allocated:!0}},d.stream_ops=u,d}},T={websocketArgs:{},callbacks:{},on(e,r){T.callbacks[e]=r},emit(e,r){T.callbacks[e]?.(r)},mount(e){return T.websocketArgs=f.websocket||{},(f.websocket??={}).on=T.on,o.createNode(null,"/",16895,0)},createSocket(e,r,t){if(e!=2)throw new o.ErrnoError(5);if(r&=-526337,r!=1&&r!=2)throw new o.ErrnoError(28);var n=r==1;if(n&&t&&t!=6)throw new o.ErrnoError(66);var i={family:e,type:r,protocol:t,server:null,error:null,peers:{},pending:[],recv_queue:[],sock_ops:T.websocket_sock_ops},a=T.nextname(),s=o.createNode(T.root,a,49152,0);s.sock=i;var l=o.createStream({path:a,node:s,flags:2,seekable:!1,stream_ops:T.stream_ops});return i.stream=l,i},getSocket(e){var r=o.getStream(e);return!r||!o.isSocket(r.node.mode)?null:r.node.sock},stream_ops:{poll(e){var r=e.node.sock;return r.sock_ops.poll(r)},ioctl(e,r,t){var n=e.node.sock;return n.sock_ops.ioctl(n,r,t)},read(e,r,t,n,i){var a=e.node.sock,s=a.sock_ops.recvmsg(a,n);return s?(r.set(s.buffer,t),s.buffer.length):0},write(e,r,t,n,i){var a=e.node.sock;return a.sock_ops.sendmsg(a,r,t,n)},close(e){var r=e.node.sock;r.sock_ops.close(r)}},nextname(){return T.nextname.current||(T.nextname.current=0),`socket[${T.nextname.current++}]`},websocket_sock_ops:{createPeer(e,r,t){var n;if(typeof r=="object"&&(n=r,r=null,t=null),n)if(n._socket)r=n._socket.remoteAddress,t=n._socket.remotePort;else{var i=/ws[s]?:\/\/([^:]+):(\d+)/.exec(n.url);if(!i)throw new Error("WebSocket URL must be in the format ws(s)://address:port");r=i[1],t=parseInt(i[2],10)}else try{var a="ws://".replace("#","//"),s="binary",l=void 0;if(T.websocketArgs.url&&(a=T.websocketArgs.url),T.websocketArgs.subprotocol?s=T.websocketArgs.subprotocol:T.websocketArgs.subprotocol===null&&(s="null"),a==="ws://"||a==="wss://"){var d=r.split("/");a=a+d[0]+":"+t+"/"+d.slice(1).join("/")}s!=="null"&&(s=s.replace(/^ +| +$/g,"").split(/ *, */),l=s);var u;M?u=le("ws"):u=WebSocket,n=new u(a,l),n.binaryType="arraybuffer"}catch{throw new o.ErrnoError(23)}var _={addr:r,port:t,socket:n,msg_send_queue:[]};return T.websocket_sock_ops.addPeer(e,_),T.websocket_sock_ops.handlePeerEvents(e,_),e.type===2&&typeof e.sport<"u"&&_.msg_send_queue.push(new Uint8Array([255,255,255,255,112,111,114,116,(e.sport&65280)>>8,e.sport&255])),_},getPeer(e,r,t){return e.peers[r+":"+t]},addPeer(e,r){e.peers[r.addr+":"+r.port]=r},removePeer(e,r){delete e.peers[r.addr+":"+r.port]},handlePeerEvents(e,r){var t=!0;function n(){e.connecting=!1,T.emit("open",e.stream.fd);try{for(var a=r.msg_send_queue.shift();a;)r.socket.send(a),a=r.msg_send_queue.shift()}catch{r.socket.close()}}function i(a){if(typeof a=="string"){var s=new TextEncoder;a=s.encode(a)}else{if(h(a.byteLength!==void 0),a.byteLength==0)return;a=new Uint8Array(a)}var l=t;if(t=!1,l&&a.length===10&&a[0]===255&&a[1]===255&&a[2]===255&&a[3]===255&&a[4]===112&&a[5]===111&&a[6]===114&&a[7]===116){var d=a[8]<<8|a[9];T.websocket_sock_ops.removePeer(e,r),r.port=d,T.websocket_sock_ops.addPeer(e,r);return}e.recv_queue.push({addr:r.addr,port:r.port,data:a}),T.emit("message",e.stream.fd)}if(M){r.socket.on("open",n),r.socket.on("message",(a,s)=>{s&&i(new Uint8Array(a).buffer)}),r.socket.on("close",()=>T.emit("close",e.stream.fd)),r.socket.on("error",a=>{e.error=14,T.emit("error",[e.stream.fd,e.error,"ECONNREFUSED: Connection refused"])});return}r.socket.onopen=n,r.socket.onclose=()=>T.emit("close",e.stream.fd),r.socket.onmessage=a=>i(a.data),r.socket.onerror=a=>{e.error=14,T.emit("error",[e.stream.fd,e.error,"ECONNREFUSED: Connection refused"])}},poll(e){if(e.type===1&&e.server)return e.pending.length?65:0;var r=0,t=e.type===1?T.websocket_sock_ops.getPeer(e,e.daddr,e.dport):null;return(e.recv_queue.length||!t||t&&t.socket.readyState===t.socket.CLOSING||t&&t.socket.readyState===t.socket.CLOSED)&&(r|=65),(!t||t&&t.socket.readyState===t.socket.OPEN)&&(r|=4),(t&&t.socket.readyState===t.socket.CLOSING||t&&t.socket.readyState===t.socket.CLOSED)&&(e.connecting?r|=4:r|=16),r},ioctl(e,r,t){switch(r){case 21531:var n=0;return e.recv_queue.length&&(n=e.recv_queue[0].data.length),(c(),S)[t>>2]=n,0;case 21537:var i=(c(),S)[t>>2];return i?e.stream.flags|=2048:e.stream.flags&=-2049,0;default:return 28}},close(e){if(e.server){try{e.server.close()}catch{}e.server=null}for(var r of Object.values(e.peers)){try{r.socket.close()}catch{}T.websocket_sock_ops.removePeer(e,r)}return 0},bind(e,r,t){if(typeof e.saddr<"u"||typeof e.sport<"u")throw new o.ErrnoError(28);if(e.saddr=r,e.sport=t,e.type===2){e.server&&(e.server.close(),e.server=null);try{e.sock_ops.listen(e,0)}catch(n){if(n.name!=="ErrnoError"||n.errno!==138)throw n}}},connect(e,r,t){if(e.server)throw new o.ErrnoError(138);if(typeof e.daddr<"u"&&typeof e.dport<"u"){var n=T.websocket_sock_ops.getPeer(e,e.daddr,e.dport);if(n)throw n.socket.readyState===n.socket.CONNECTING?new o.ErrnoError(7):new o.ErrnoError(30)}var i=T.websocket_sock_ops.createPeer(e,r,t);e.daddr=i.addr,e.dport=i.port,e.connecting=!0},listen(e,r){if(!M)throw new o.ErrnoError(138);if(e.server)throw new o.ErrnoError(28);var t=le("ws").Server,n=e.saddr;e.server=new t({host:n,port:e.sport}),T.emit("listen",e.stream.fd),e.server.on("connection",i=>{if(e.type===1){var a=T.createSocket(e.family,e.type,e.protocol),s=T.websocket_sock_ops.createPeer(a,i);a.daddr=s.addr,a.dport=s.port,e.pending.push(a),T.emit("connection",a.stream.fd)}else T.websocket_sock_ops.createPeer(e,i),T.emit("connection",e.stream.fd)}),e.server.on("close",()=>{T.emit("close",e.stream.fd),e.server=null}),e.server.on("error",i=>{e.error=23,T.emit("error",[e.stream.fd,e.error,"EHOSTUNREACH: Host is unreachable"])})},accept(e){if(!e.server||!e.pending.length)throw new o.ErrnoError(28);var r=e.pending.shift();return r.stream.flags=e.stream.flags,r},getname(e,r){var t,n;if(r){if(e.daddr===void 0||e.dport===void 0)throw new o.ErrnoError(53);t=e.daddr,n=e.dport}else t=e.saddr||0,n=e.sport||0;return{addr:t,port:n}},sendmsg(e,r,t,n,i,a){if(e.type===2){if((i===void 0||a===void 0)&&(i=e.daddr,a=e.dport),i===void 0||a===void 0)throw new o.ErrnoError(17)}else i=e.daddr,a=e.dport;var s=T.websocket_sock_ops.getPeer(e,i,a);if(e.type===1&&(!s||s.socket.readyState===s.socket.CLOSING||s.socket.readyState===s.socket.CLOSED))throw new o.ErrnoError(53);ArrayBuffer.isView(r)&&(t+=r.byteOffset,r=r.buffer);var l=r.slice(t,t+n);if(l instanceof SharedArrayBuffer&&(l=new Uint8Array(new Uint8Array(l)).buffer),!s||s.socket.readyState!==s.socket.OPEN)return e.type===2&&(!s||s.socket.readyState===s.socket.CLOSING||s.socket.readyState===s.socket.CLOSED)&&(s=T.websocket_sock_ops.createPeer(e,i,a)),s.msg_send_queue.push(l),n;try{return s.socket.send(l),n}catch{throw new o.ErrnoError(28)}},recvmsg(e,r){if(e.type===1&&e.server)throw new o.ErrnoError(53);var t=e.recv_queue.shift();if(!t){if(e.type===1){var n=T.websocket_sock_ops.getPeer(e,e.daddr,e.dport);if(!n)throw new o.ErrnoError(53);if(n.socket.readyState===n.socket.CLOSING||n.socket.readyState===n.socket.CLOSED)return null;throw new o.ErrnoError(6)}throw new o.ErrnoError(6)}var i=t.data.byteLength||t.data.length,a=t.data.byteOffset||0,s=t.data.buffer||t.data,l=Math.min(r,i),d={buffer:new Uint8Array(s,a,l),addr:t.addr,port:t.port};if(e.type===1&&l<i){var u=i-l;t.data=new Uint8Array(s,a+l,u),e.recv_queue.unshift(t)}return d}}},Xr=e=>{var r=T.getSocket(e);if(!r)throw new o.ErrnoError(8);return r},Yr=e=>(e&255)+"."+(e>>8&255)+"."+(e>>16&255)+"."+(e>>24&255),en=e=>{var r="",t=0,n=0,i=0,a=0,s=0,l=0,d=[e[0]&65535,e[0]>>16,e[1]&65535,e[1]>>16,e[2]&65535,e[2]>>16,e[3]&65535,e[3]>>16],u=!0,_="";for(l=0;l<5;l++)if(d[l]!==0){u=!1;break}if(u){if(_=Yr(d[6]|d[7]<<16),d[5]===-1)return r="::ffff:",r+=_,r;if(d[5]===0)return r="::",_==="0.0.0.0"&&(_=""),_==="0.0.0.1"&&(_="1"),r+=_,r}for(t=0;t<8;t++)d[t]===0&&(t-i>1&&(s=0),i=t,s++),s>n&&(n=s,a=t-n+1);for(t=0;t<8;t++){if(n>1&&d[t]===0&&t>=a&&t<a+n){t===a&&(r+=":",a===0&&(r+=":"));continue}r+=Number(ct(d[t]&65535)).toString(16),r+=t<7?":":""}return r},Qi=(e,r)=>{var t=(c(),ne)[e>>1],n=ct((c(),ke)[e+2>>1]),i;switch(t){case 2:if(r!==16)return{errno:28};i=(c(),S)[e+4>>2],i=Yr(i);break;case 10:if(r!==28)return{errno:28};i=[(c(),S)[e+8>>2],(c(),S)[e+12>>2],(c(),S)[e+16>>2],(c(),S)[e+20>>2]],i=en(i);break;default:return{errno:5}}return{family:t,addr:i,port:n}},ur=e=>{for(var r=e.split("."),t=0;t<4;t++){var n=Number(r[t]);if(isNaN(n))return null;r[t]=n}return(r[0]|r[1]<<8|r[2]<<16|r[3]<<24)>>>0},Jr=e=>{var r,t,n,i,a,s=/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,l=[];if(!s.test(e))return null;if(e==="::")return[0,0,0,0,0,0,0,0];for(e.startsWith("::")?e=e.replace("::","Z:"):e=e.replace("::",":Z:"),e.indexOf(".")>0?(e=e.replace(new RegExp("[.]","g"),":"),r=e.split(":"),r[r.length-4]=Number(r[r.length-4])+Number(r[r.length-3])*256,r[r.length-3]=Number(r[r.length-2])+Number(r[r.length-1])*256,r=r.slice(0,r.length-2)):r=e.split(":"),n=0,i=0,t=0;t<r.length;t++)if(typeof r[t]=="string")if(r[t]==="Z"){for(i=0;i<8-r.length+1;i++)l[t+i]=0;n=i-1}else l[t+n]=Pr(parseInt(r[t],16));else l[t+n]=r[t];return[l[1]<<16|l[0],l[3]<<16|l[2],l[5]<<16|l[4],l[7]<<16|l[6]]},he={address_map:{id:1,addrs:{},names:{}},lookup_name(e){var r=ur(e);if(r!==null||(r=Jr(e),r!==null))return e;var t;if(he.address_map.addrs[e])t=he.address_map.addrs[e];else{var n=he.address_map.id++;h(n<65535,"exceeded max address mappings of 65535"),t="172.29."+(n&255)+"."+(n&65280),he.address_map.names[t]=e,he.address_map.addrs[e]=t}return t},lookup_addr(e){return he.address_map.names[e]?he.address_map.names[e]:null}},rn=(e,r)=>{var t=Qi(e,r);if(t.errno)throw new o.ErrnoError(t.errno);return t.addr=he.lookup_addr(t.addr)||t.addr,t};function tn(e,r,t,n,i,a){if(w)return K(3,0,1,e,r,t,n,i,a);try{var s=Xr(e),l=rn(r,t);return s.sock_ops.connect(s,l.addr,l.port),0}catch(d){if(typeof o>"u"||d.name!=="ErrnoError")throw d;return-d.errno}}var X={currentUmask:18,calculateAt(e,r,t){if(I.isAbs(r))return r;var n;if(e===-100)n=o.cwd();else{var i=X.getStreamFromFD(e);n=i.path}if(r.length==0){if(!t)throw new o.ErrnoError(44);return n}return n+"/"+r},writeStat(e,r){(c(),y)[e>>2]=r.dev,(c(),y)[e+4>>2]=r.mode,(c(),y)[e+8>>2]=r.nlink,(c(),y)[e+12>>2]=r.uid,(c(),y)[e+16>>2]=r.gid,(c(),y)[e+20>>2]=r.rdev,(c(),Z)[e+24>>3]=BigInt(r.size),(c(),S)[e+32>>2]=4096,(c(),S)[e+36>>2]=r.blocks;var t=r.atime.getTime(),n=r.mtime.getTime(),i=r.ctime.getTime();return(c(),Z)[e+40>>3]=BigInt(Math.floor(t/1e3)),(c(),y)[e+48>>2]=t%1e3*1e3*1e3,(c(),Z)[e+56>>3]=BigInt(Math.floor(n/1e3)),(c(),y)[e+64>>2]=n%1e3*1e3*1e3,(c(),Z)[e+72>>3]=BigInt(Math.floor(i/1e3)),(c(),y)[e+80>>2]=i%1e3*1e3*1e3,(c(),Z)[e+88>>3]=BigInt(r.ino),0},writeStatFs(e,r){(c(),y)[e+4>>2]=r.bsize,(c(),y)[e+60>>2]=r.bsize,(c(),Z)[e+8>>3]=BigInt(r.blocks),(c(),Z)[e+16>>3]=BigInt(r.bfree),(c(),Z)[e+24>>3]=BigInt(r.bavail),(c(),Z)[e+32>>3]=BigInt(r.files),(c(),Z)[e+40>>3]=BigInt(r.ffree),(c(),y)[e+48>>2]=r.fsid,(c(),y)[e+64>>2]=r.flags,(c(),y)[e+56>>2]=r.namelen},doMsync(e,r,t,n,i){if(!o.isFile(r.node.mode))throw new o.ErrnoError(43);if(n&2)return 0;var a=(c(),te).slice(e,e+t);o.msync(r,a,i,t,n)},getStreamFromFD(e){var r=o.getStreamChecked(e);return r},varargs:void 0,getStr(e){var r=_e(e);return r}};function nn(e){if(w)return K(4,0,1,e);try{var r=X.getStreamFromFD(e);return o.dupStream(r).fd}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}var fr=()=>{h(X.varargs!=null);var e=(c(),S)[+X.varargs>>2];return X.varargs+=4,e},Ue=fr;function an(e,r,t){if(w)return K(5,0,1,e,r,t);X.varargs=t;try{var n=X.getStreamFromFD(e);switch(r){case 0:{var i=fr();if(i<0)return-28;for(;o.streams[i];)i++;var a;return a=o.dupStream(n,i),a.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var i=fr(),s=289792;return n.flags=n.flags&~s|i&s,0}case 12:{var i=Ue(),l=0;return(c(),ne)[i+l>>1]=2,0}case 13:case 14:return 0}return-28}catch(d){if(typeof o>"u"||d.name!=="ErrnoError")throw d;return-d.errno}}var Ee=(e,r,t)=>(h(typeof t=="number","stringToUTF8 requires a third parameter that specifies the length of the output buffer"),Yt(e,(c(),te),r,t));function on(e,r){if(w)return K(6,0,1,e,r);try{if(r===0)return-28;var t=o.cwd(),n=Pe(t)+1;return r<n?-68:(Ee(t,e,r),n)}catch(i){if(typeof o>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function sn(e,r,t){if(w)return K(7,0,1,e,r,t);X.varargs=t;try{var n=X.getStreamFromFD(e);switch(r){case 21509:return n.tty?0:-59;case 21505:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcgets){var i=n.tty.ops.ioctl_tcgets(n),a=Ue();(c(),S)[a>>2]=i.c_iflag||0,(c(),S)[a+4>>2]=i.c_oflag||0,(c(),S)[a+8>>2]=i.c_cflag||0,(c(),S)[a+12>>2]=i.c_lflag||0;for(var s=0;s<32;s++)(c(),H)[a+s+17]=i.c_cc[s]||0;return 0}return 0}case 21510:case 21511:case 21512:return n.tty?0:-59;case 21506:case 21507:case 21508:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcsets){for(var a=Ue(),l=(c(),S)[a>>2],d=(c(),S)[a+4>>2],u=(c(),S)[a+8>>2],_=(c(),S)[a+12>>2],p=[],s=0;s<32;s++)p.push((c(),H)[a+s+17]);return n.tty.ops.ioctl_tcsets(n.tty,r,{c_iflag:l,c_oflag:d,c_cflag:u,c_lflag:_,c_cc:p})}return 0}case 21519:{if(!n.tty)return-59;var a=Ue();return(c(),S)[a>>2]=0,0}case 21520:return n.tty?-28:-59;case 21537:case 21531:{var a=Ue();return o.ioctl(n,r,a)}case 21523:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tiocgwinsz){var m=n.tty.ops.ioctl_tiocgwinsz(n.tty),a=Ue();(c(),ne)[a>>1]=m[0],(c(),ne)[a+2>>1]=m[1]}return 0}case 21524:return n.tty?0:-59;case 21515:return n.tty?0:-59;default:return-28}}catch(g){if(typeof o>"u"||g.name!=="ErrnoError")throw g;return-g.errno}}function ln(e,r,t,n){if(w)return K(8,0,1,e,r,t,n);X.varargs=n;try{r=X.getStr(r),r=X.calculateAt(e,r);var i=n?fr():0;return t&64&&(i&=~X.currentUmask),o.open(r,t,i).fd}catch(a){if(typeof o>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function dn(e,r,t,n){if(w)return K(9,0,1,e,r,t,n);try{if(r=X.getStr(r),r=X.calculateAt(e,r),n<=0)return-28;var i=o.readlink(r),a=Math.min(n,Pe(i)),s=(c(),H)[t+a];return Ee(i,t,n+1),(c(),H)[t+a]=s,a}catch(l){if(typeof o>"u"||l.name!=="ErrnoError")throw l;return-l.errno}}var cn=(e,r)=>(c(),te).fill(0,e,e+r),un=(e,r,t,n,i)=>{switch(r){case 2:t=ur(t),cn(e,16),i&&((c(),S)[i>>2]=16),(c(),ne)[e>>1]=r,(c(),S)[e+4>>2]=t,(c(),ne)[e+2>>1]=Pr(n);break;case 10:t=Jr(t),cn(e,28),i&&((c(),S)[i>>2]=28),(c(),S)[e>>2]=r,(c(),S)[e+8>>2]=t[0],(c(),S)[e+12>>2]=t[1],(c(),S)[e+16>>2]=t[2],(c(),S)[e+20>>2]=t[3],(c(),ne)[e+2>>1]=Pr(n);break;default:return 5}return 0};function fn(e,r,t,n,i,a){if(w)return K(10,0,1,e,r,t,n,i,a);try{var s=Xr(e),l=s.sock_ops.recvmsg(s,t);if(!l)return 0;if(i){var d=un(i,s.family,he.lookup_name(l.addr),l.port,a);h(!d)}return(c(),te).set(l.buffer,r),l.buffer.byteLength}catch(u){if(typeof o>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}function _n(e){if(w)return K(11,0,1,e);try{return e=X.getStr(e),o.rmdir(e),0}catch(r){if(typeof o>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function hn(e,r,t,n,i,a){if(w)return K(12,0,1,e,r,t,n,i,a);try{var s=Xr(e);if(!i)return o.write(s.stream,(c(),H),r,t);var l=rn(i,a);return s.sock_ops.sendmsg(s,(c(),H),r,t,l.addr,l.port)}catch(d){if(typeof o>"u"||d.name!=="ErrnoError")throw d;return-d.errno}}function vn(e,r,t){if(w)return K(13,0,1,e,r,t);try{var n=T.createSocket(e,r,t);return h(n.stream.fd<64),n.stream.fd}catch(i){if(typeof o>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function pn(e,r,t){if(w)return K(14,0,1,e,r,t);try{if(r=X.getStr(r),r=X.calculateAt(e,r),!t)o.unlink(r);else if(t===512)o.rmdir(r);else return-28;return 0}catch(n){if(typeof o>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}var ea=()=>q("native code called abort()"),_r={},hr=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r)}};function qe(e){return this.fromWireType((c(),y)[e>>2])}var je={},Ce={},vr={},ra=class extends Error{constructor(r){super(r),this.name="InternalError"}},pr=e=>{throw new ra(e)},ce=(e,r,t)=>{e.forEach(l=>vr[l]=r);function n(l){var d=t(l);d.length!==e.length&&pr("Mismatched type converter count");for(var u=0;u<e.length;++u)ie(e[u],d[u])}var i=new Array(r.length),a=[],s=0;for(let[l,d]of r.entries())Ce.hasOwnProperty(d)?i[l]=Ce[d]:(a.push(d),je.hasOwnProperty(d)||(je[d]=[]),je[d].push(()=>{i[l]=Ce[d],++s,s===a.length&&n(i)}));a.length===0&&n(i)},ta=e=>{var r=_r[e];delete _r[e];var t=r.rawConstructor,n=r.rawDestructor,i=r.fields,a=i.map(s=>s.getterReturnType).concat(i.map(s=>s.setterArgumentType));ce([e],a,s=>{var l={};for(var[d,u]of i.entries()){let _=s[d],p=u.getter,m=u.getterContext,g=s[d+i.length],E=u.setter,k=u.setterContext;l[u.fieldName]={read:D=>_.fromWireType(p(m,D)),write:(D,R)=>{var G=[];E(k,D,g.toWireType(G,R)),hr(G)},optional:_.optional}}return[{name:r.name,fromWireType:_=>{var p={};for(var m in l)p[m]=l[m].read(_);return n(_),p},toWireType:(_,p)=>{for(var m in l)if(!(m in p)&&!l[m].optional)throw new TypeError(`Missing field: "${m}"`);var g=t();for(m in l)l[m].write(g,p[m]);return _!==null&&_.push(n,g),g},readValueFromPointer:qe,destructorFunction:n}]})},Y=e=>{for(var r="";;){var t=(c(),te)[e++];if(!t)return r;r+=String.fromCharCode(t)}},Ke=class extends Error{constructor(r){super(r),this.name="BindingError"}},A=e=>{throw new Ke(e)};function na(e,r,t={}){var n=r.name;if(e||A(`type "${n}" must have a positive integer typeid pointer`),Ce.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;A(`Cannot register type '${n}' twice`)}if(Ce[e]=r,delete vr[e],je.hasOwnProperty(e)){var i=je[e];delete je[e],i.forEach(a=>a())}}function ie(e,r,t={}){return na(e,r,t)}var mn=(e,r,t)=>{switch(r){case 1:return t?n=>(c(),H)[n]:n=>(c(),te)[n];case 2:return t?n=>(c(),ne)[n>>1]:n=>(c(),ke)[n>>1];case 4:return t?n=>(c(),S)[n>>2]:n=>(c(),y)[n>>2];case 8:return t?n=>(c(),Z)[n>>3]:n=>(c(),Rt)[n>>3];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},Ae=e=>{if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},gn=(e,r,t,n)=>{if(r<t||r>n)throw new TypeError(`Passing a number "${Ae(r)}" from JS side to C/C++ side to an argument of type "${e}", which is outside the valid range [${t}, ${n}]!`)},ia=(e,r,t,n,i)=>{r=Y(r);let a=n===0n,s=l=>l;if(a){let l=t*8;s=d=>BigInt.asUintN(l,d),i=s(i)}ie(e,{name:r,fromWireType:s,toWireType:(l,d)=>{if(typeof d=="number")d=BigInt(d);else if(typeof d!="bigint")throw new TypeError(`Cannot convert "${Ae(d)}" to ${r}`);return gn(r,d,n,i),d},readValueFromPointer:mn(r,t,!a),destructorFunction:null})},aa=(e,r,t,n)=>{r=Y(r),ie(e,{name:r,fromWireType:function(i){return!!i},toWireType:function(i,a){return a?t:n},readValueFromPointer:function(i){return this.fromWireType((c(),te)[i])},destructorFunction:null})},oa=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Zr=e=>{function r(t){return t.$$.ptrType.registeredClass.name}A(r(e)+" instance already deleted")},Qr=!1,yn=e=>{},sa=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)},wn=e=>{e.count.value-=1;var r=e.count.value===0;r&&sa(e)},En=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=En(e,r,t.baseClass);return n===null?null:t.downcast(n)},bn={},la={},da=(e,r)=>{for(r===void 0&&A("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},ca=(e,r)=>(r=da(e,r),la[r]),mr=(e,r)=>{(!r.ptrType||!r.ptr)&&pr("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&pr("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Xe(Object.create(e,{$$:{value:r,writable:!0}}))};function Sn(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=ca(this.registeredClass,r);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function i(){return this.isSmartPointer?mr(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):mr(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var a=this.registeredClass.getActualType(r),s=bn[a];if(!s)return i.call(this);var l;this.isConst?l=s.constPointerType:l=s.pointerType;var d=En(r,this.registeredClass,l.registeredClass);return d===null?i.call(this):this.isSmartPointer?mr(l.registeredClass.instancePrototype,{ptrType:l,ptr:d,smartPtrType:this,smartPtr:e}):mr(l.registeredClass.instancePrototype,{ptrType:l,ptr:d})}var Xe=e=>globalThis.FinalizationRegistry?(Qr=new FinalizationRegistry(r=>{console.warn(r.leakWarning),wn(r.$$)}),Xe=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var i={$$:t},a=t.ptrType.registeredClass,s=new Error(`Embind found a leaked C++ instance ${a.name} <${we(t.ptr)}>.
|
|
6
6
|
We'll free it automatically in this case, but this functionality is not reliable across various environments.
|
|
7
7
|
Make sure to invoke .delete() manually once you're done with the instance instead.
|
|
8
|
-
Originally allocated`);"captureStackTrace"in Error&&Error.captureStackTrace(s,
|
|
8
|
+
Originally allocated`);"captureStackTrace"in Error&&Error.captureStackTrace(s,Sn),i.leakWarning=s.stack.replace(/^Error: /,""),Qr.register(r,i,r)}return r},yn=r=>Qr.unregister(r),Xe(e)):(Xe=r=>r,e),gr=[],ua=()=>{for(;gr.length;){var e=gr.pop();e.$$.deleteScheduled=!1,e.delete()}},kn,fa=()=>{let e=yr.prototype;Object.assign(e,{isAliasOf(t){if(!(this instanceof yr)||!(t instanceof yr))return!1;var n=this.$$.ptrType.registeredClass,i=this.$$.ptr;t.$$=t.$$;for(var a=t.$$.ptrType.registeredClass,s=t.$$.ptr;n.baseClass;)i=n.upcast(i),n=n.baseClass;for(;a.baseClass;)s=a.upcast(s),a=a.baseClass;return n===a&&i===s},clone(){if(this.$$.ptr||Zr(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var t=Xe(Object.create(Object.getPrototypeOf(this),{$$:{value:oa(this.$$)}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t},delete(){this.$$.ptr||Zr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&A("Object already scheduled for deletion"),yn(this),wn(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Zr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&A("Object already scheduled for deletion"),gr.push(this),gr.length===1&&kn&&kn(ua),this.$$.deleteScheduled=!0,this}});let r=Symbol.dispose;r&&(e[r]=e.delete)};function yr(){}var wr=(e,r)=>Object.defineProperty(r,"name",{value:e}),et=(e,r,t)=>{if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(...i){return e[r].overloadTable.hasOwnProperty(i.length)||A(`Function '${t}' called with an invalid number of arguments (${i.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[i.length].apply(this,i)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n}},Ye=(e,r,t)=>{f.hasOwnProperty(e)?((t===void 0||f[e].overloadTable!==void 0&&f[e].overloadTable[t]!==void 0)&&A(`Cannot register public name '${e}' twice`),et(f,e,e),f[e].overloadTable.hasOwnProperty(t)&&A(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),f[e].overloadTable[t]=r):(f[e]=r,f[e].argCount=t)},_a=48,ha=57,va=e=>{h(typeof e=="string"),e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=_a&&r<=ha?`_${e}`:e};function pa(e,r,t,n,i,a,s,l){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=i,this.getActualType=a,this.upcast=s,this.downcast=l,this.pureVirtualFunctions=[]}var Er=(e,r,t)=>{for(;r!==t;)r.upcast||A(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function ma(e,r){if(r===null)return this.isReference&&A(`null is not a valid ${this.name}`),0;r.$$||A(`Cannot pass "${Ae(r)}" as a ${this.name}`),r.$$.ptr||A(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Er(r.$$.ptr,t,this.registeredClass);return n}function ga(e,r){var t;if(r===null)return this.isReference&&A(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;(!r||!r.$$)&&A(`Cannot pass "${Ae(r)}" as a ${this.name}`),r.$$.ptr||A(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&A(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);var n=r.$$.ptrType.registeredClass;if(t=Er(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&A("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:A(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:t=r.$$.smartPtr;break;case 2:if(r.$$.smartPtrType===this)t=r.$$.smartPtr;else{var i=r.clone();t=this.rawShare(t,re.toHandle(()=>i.delete())),e!==null&&e.push(this.rawDestructor,t)}break;default:A("Unsupported sharing policy")}return t}function ya(e,r){if(r===null)return this.isReference&&A(`null is not a valid ${this.name}`),0;r.$$||A(`Cannot pass "${Ae(r)}" as a ${this.name}`),r.$$.ptr||A(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&A(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Er(r.$$.ptr,t,this.registeredClass);return n}var wa=()=>{Object.assign(br.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor?.(e)},readValueFromPointer:qe,fromWireType:Sn})};function br(e,r,t,n,i,a,s,l,d,u,_){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=i,this.pointeeType=a,this.sharingPolicy=s,this.rawGetPointee=l,this.rawConstructor=d,this.rawShare=u,this.rawDestructor=_,!i&&r.baseClass===void 0?n?(this.toWireType=ma,this.destructorFunction=null):(this.toWireType=ya,this.destructorFunction=null):this.toWireType=ga}var Tn=(e,r,t)=>{f.hasOwnProperty(e)||pr("Replacing nonexistent public symbol"),f[e].overloadTable!==void 0&&t!==void 0?f[e].overloadTable[t]=r:(f[e]=r,f[e].argCount=t)},ae=(e,r,t=!1)=>{h(!t,"async bindings are only supported with JSPI"),e=Y(e);function n(){var a=W(r);return a}var i=n();return typeof i!="function"&&A(`unknown function pointer with signature ${e}: ${r}`),i};class Ea extends Error{}var Fn=e=>{var r=Vn(e),t=Y(r);return ve(r),t},Oe=(e,r)=>{var t=[],n={};function i(a){if(!n[a]&&!Ce[a]){if(vr[a]){vr[a].forEach(i);return}t.push(a),n[a]=!0}}throw r.forEach(i),new Ea(`${e}: `+t.map(Fn).join([", "]))},ba=(e,r,t,n,i,a,s,l,d,u,_,p,m)=>{_=Y(_),a=ae(i,a),l&&=ae(s,l),u&&=ae(d,u),m=ae(p,m);var g=va(_);Ye(g,function(){Oe(`Cannot construct ${_} due to unbound types`,[n])}),ce([e,r,t],n?[n]:[],E=>{E=E[0];var k,D;n?(k=E.registeredClass,D=k.instancePrototype):D=yr.prototype;var R=wr(_,function(...se){if(Object.getPrototypeOf(this)!==G)throw new Ke(`Use 'new' to construct ${_}`);if(z.constructor_body===void 0)throw new Ke(`${_} has no accessible constructor`);var er=z.constructor_body[se.length];if(er===void 0)throw new Ke(`Tried to invoke ctor of ${_} with invalid number of parameters (${se.length}) - expected (${Object.keys(z.constructor_body).toString()}) parameters instead!`);return er.apply(this,se)}),G=Object.create(D,{constructor:{value:R}});R.prototype=G;var z=new pa(_,R,G,m,k,a,l,u);z.baseClass&&(z.baseClass.__derivedClasses??=[],z.baseClass.__derivedClasses.push(z));var oe=new br(_,z,!0,!1,!1),de=new br(_+"*",z,!1,!1,!1),V=new br(_+" const*",z,!1,!0,!1);return bn[e]={pointerType:de,constPointerType:V},Tn(g,R),[oe,de,V]})};function Pn(e){for(var r=1;r<e.length;++r)if(e[r]!==null&&e[r].destructorFunction===void 0)return!0;return!1}function Sa(e,r,t,n,i){if(e<r||e>t){var a=r==t?r:`${r} to ${t}`;i(`function ${n} called with ${e} arguments, expected ${a}`)}}function ka(e,r,t,n){var i=Pn(e),a=e.length-2,s=[],l=["fn"];r&&l.push("thisWired");for(var d=0;d<a;++d)s.push(`arg${d}`),l.push(`arg${d}Wired`);s=s.join(","),l=l.join(",");var u=`return function (${s}) {
|
|
9
9
|
`;u+=`checkArgCount(arguments.length, minArgs, maxArgs, humanName, throwBindingError);
|
|
10
10
|
`,i&&(u+=`var destructors = [];
|
|
11
11
|
`);var _=i?"destructors":"null",p=["humanName","throwBindingError","invoker","fn","runDestructors","fromRetWire","toClassParamWire"];r&&(u+=`var thisWired = toClassParamWire(${_}, this);
|
|
@@ -17,6 +17,6 @@ Originally allocated`);"captureStackTrace"in Error&&Error.captureStackTrace(s,bn
|
|
|
17
17
|
return ret;
|
|
18
18
|
`),u+=`}
|
|
19
19
|
`,p.push("checkArgCount","minArgs","maxArgs"),u=`if (arguments.length !== ${p.length}){ throw new Error(humanName + "Expected ${p.length} closure arguments " + arguments.length + " given."); }
|
|
20
|
-
${u}`,new Function(p,u)}function ka(e){for(var r=e.length-2,t=e.length-1;t>=2&&e[t].optional;--t)r--;return r}function br(e,r,t,n,i,a){var s=r.length;s<2&&A("argTypes array size mismatch! Must at least get return value and 'this' types!"),h(!a,"async bindings are only supported with JSPI");for(var l=r[1]!==null&&t!==null,d=Fn(r),u=!r[0].isVoid,_=s-2,p=ka(r),m=r[0],g=r[1],E=[e,A,n,i,_r,m.fromWireType.bind(m),g?.toWireType.bind(g)],k=2;k<s;++k){var D=r[k];E.push(D.toWireType.bind(D))}if(!d)for(var k=l?1:2;k<r.length;++k)r[k].destructorFunction!==null&&E.push(r[k].destructorFunction);E.push(ba,p,_);var G=Sa(r,l,u,a)(...E);return yr(e,G)}var Sr=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push((c(),y)[r+n*4>>2]);return t},et=e=>{e=e.trim();let r=e.indexOf("(");return r===-1?e:(h(e.endsWith(")"),"Parentheses for argument names should match."),e.slice(0,r))},Ta=(e,r,t,n,i,a,s,l,d)=>{var u=Sr(t,n);r=Y(r),r=et(r),a=ae(i,a,l),ce([],[e],_=>{_=_[0];var p=`${_.name}.${r}`;function m(){Oe(`Cannot call ${p} due to unbound types`,u)}r.startsWith("@@")&&(r=Symbol[r.substring(2)]);var g=_.registeredClass.constructor;return g[r]===void 0?(m.argCount=t-1,g[r]=m):(Qr(g,r,p),g[r].overloadTable[t-1]=m),ce([],u,E=>{var k=[E[0],null].concat(E.slice(1)),D=br(p,k,null,a,s,l);if(g[r].overloadTable===void 0?(D.argCount=t-1,g[r]=D):g[r].overloadTable[t-1]=D,_.registeredClass.__derivedClasses)for(let R of _.registeredClass.__derivedClasses)R.constructor.hasOwnProperty(r)||(R.constructor[r]=D);return[]}),[]})},Fa=(e,r,t,n,i,a)=>{h(r>0);var s=Sr(r,t);i=ae(n,i);var l=[a],d=[];ce([],[e],u=>{u=u[0];var _=`constructor ${u.name}`;if(u.registeredClass.constructor_body===void 0&&(u.registeredClass.constructor_body=[]),u.registeredClass.constructor_body[r-1]!==void 0)throw new qe(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${u.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return u.registeredClass.constructor_body[r-1]=()=>{Oe(`Cannot construct ${u.name} due to unbound types`,s)},ce([],s,p=>(p.splice(1,0,null),u.registeredClass.constructor_body[r-1]=br(_,p,null,i,a),[])),[]})},Pa=(e,r,t,n,i,a,s,l,d,u)=>{var _=Sr(t,n);r=Y(r),r=et(r),a=ae(i,a,d),ce([],[e],p=>{p=p[0];var m=`${p.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),l&&p.registeredClass.pureVirtualFunctions.push(r);function g(){Oe(`Cannot call ${m} due to unbound types`,_)}var E=p.registeredClass.instancePrototype,k=E[r];return k===void 0||k.overloadTable===void 0&&k.className!==p.name&&k.argCount===t-2?(g.argCount=t-2,g.className=p.name,E[r]=g):(Qr(E,r,m),E[r].overloadTable[t-2]=g),ce([],_,D=>{var R=br(m,D,p,a,s,d);return E[r].overloadTable===void 0?(R.argCount=t-2,E[r]=R):E[r].overloadTable[t-2]=R,[]}),[]})},Pn=(e,r,t)=>(e instanceof Object||A(`${t} with invalid "this": ${e}`),e instanceof r.registeredClass.constructor||A(`${t} incompatible with "this" of type ${e.constructor.name}`),e.$$.ptr||A(`cannot call emscripten binding method ${t} on deleted object`),wr(e.$$.ptr,e.$$.ptrType.registeredClass,r.registeredClass)),Ca=(e,r,t,n,i,a,s,l,d,u)=>{r=Y(r),i=ae(n,i),ce([],[e],_=>{_=_[0];var p=`${_.name}.${r}`,m={get(){Oe(`Cannot access ${p} due to unbound types`,[t,s])},enumerable:!0,configurable:!0};return d?m.set=()=>Oe(`Cannot access ${p} due to unbound types`,[t,s]):m.set=g=>A(p+" is a read-only property"),Object.defineProperty(_.registeredClass.instancePrototype,r,m),ce([],d?[t,s]:[t],g=>{var E=g[0],k={get(){var R=Pn(this,_,p+" getter");return E.fromWireType(i(a,R))},enumerable:!0};if(d){d=ae(l,d);var D=g[1];k.set=function(R){var G=Pn(this,_,p+" setter"),z=[];d(u,G,D.toWireType(z,R)),_r(z)}}return Object.defineProperty(_.registeredClass.instancePrototype,r,k),[]}),[]})},Cn=[],ue=[0,1,,1,null,1,!0,1,!1,1],rt=e=>{if(e>9&&--ue[e+1]===0){h(ue[e]!==void 0,"decref for unallocated handle");var r=ue[e];ue[e]=void 0,Cn.push(e)}},re={toValue:e=>(e||A(`Cannot use deleted val. handle = ${e}`),h(e===2||ue[e]!==void 0&&e%2===0,`invalid handle: ${e}`),ue[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let r=Cn.pop()||ue.length;return ue[r]=e,ue[r+1]=1,r}}}},An={name:"emscripten::val",fromWireType:e=>{var r=re.toValue(e);return rt(e),r},toWireType:(e,r)=>re.toHandle(r),readValueFromPointer:Ve,destructorFunction:null},Aa=e=>ie(e,An),tt=(e,r,t)=>{switch(r){case 1:return t?function(n){return this.fromWireType((c(),H)[n])}:function(n){return this.fromWireType((c(),te)[n])};case 2:return t?function(n){return this.fromWireType((c(),ne)[n>>1])}:function(n){return this.fromWireType((c(),ke)[n>>1])};case 4:return t?function(n){return this.fromWireType((c(),S)[n>>2])}:function(n){return this.fromWireType((c(),y)[n>>2])};default:throw new TypeError(`invalid integer width (${r}): ${e}`)}};function Oa(e){return e===0?"object":e===1?"number":"string"}var Da=(e,r,t,n,i)=>{r=Y(r);let a=Oa(i);switch(a){case"object":{let u=function(){};u.values={},ie(e,{name:r,constructor:u,valueType:a,fromWireType:function(_){return this.constructor.values[_]},toWireType:(_,p)=>p.value,readValueFromPointer:tt(r,t,n),destructorFunction:null}),Xe(r,u);break}case"number":{var s={};ie(e,{name:r,keysMap:s,valueType:a,fromWireType:u=>u,toWireType:(u,_)=>_,readValueFromPointer:tt(r,t,n),destructorFunction:null}),Xe(r,s),delete f[r].argCount;break}case"string":{var l={},d={},s={};ie(e,{name:r,valuesMap:l,reverseMap:d,keysMap:s,valueType:a,fromWireType:function(_){return this.reverseMap[_]},toWireType:function(_,p){return this.valuesMap[p]},readValueFromPointer:tt(r,t,n),destructorFunction:null}),Xe(r,s),delete f[r].argCount;break}}},On=(e,r)=>{var t=Ce[e];return t===void 0&&A(`${r} has unknown type ${Tn(e)}`),t},Ra=(e,r,t)=>{var n=On(e,"enum");switch(r=Y(r),n.valueType){case"object":{var i=n.constructor,a=Object.create(n.constructor.prototype,{value:{value:t},constructor:{value:yr(`${n.name}_${r}`,function(){})}});i.values[t]=a,i[r]=a;break}case"number":{n.keysMap[r]=t;break}case"string":{n.valuesMap[r]=t,n.reverseMap[t]=r,n.keysMap[r]=r;break}}},Ia=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType((c(),or)[t>>2])};case 8:return function(t){return this.fromWireType((c(),Me)[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},$a=(e,r,t)=>{r=Y(r),ie(e,{name:r,fromWireType:n=>n,toWireType:(n,i)=>{if(typeof i!="number"&&typeof i!="boolean")throw new TypeError(`Cannot convert ${Ae(i)} to ${r}`);return i},readValueFromPointer:Ia(r,t),destructorFunction:null})},Na=(e,r,t,n,i,a,s,l)=>{var d=Sr(r,t);e=Y(e),e=et(e),i=ae(n,i,s),Xe(e,function(){Oe(`Cannot call ${e} due to unbound types`,d)},r-1),ce([],d,u=>{var _=[u[0],null].concat(u.slice(1));return kn(e,br(e,_,null,i,a,s),r-1),[]})},Ma=(e,r,t,n,i)=>{r=Y(r);let a=n===0,s=d=>d;if(a){var l=32-8*t;s=d=>d<<l>>>l,i=s(i)}ie(e,{name:r,fromWireType:s,toWireType:(d,u)=>{if(typeof u!="number"&&typeof u!="boolean")throw new TypeError(`Cannot convert "${Ae(u)}" to ${r}`);return mn(r,u,n,i),u},readValueFromPointer:pn(r,t,n!==0),destructorFunction:null})},xa=(e,r,t)=>{let n=(i,a)=>{let s=0;return{next(){if(s>=i)return{done:!0};let l=s;return s++,{value:a(l),done:!1}},[Symbol.iterator](){return this}}};e[Symbol.iterator]||(e[Symbol.iterator]=function(){let i=this[r]();return n(i,a=>this[t](a))})},La=(e,r,t,n)=>{t=Y(t),n=Y(n),ce([],[e,r],i=>{let a=i[0];return xa(a.registeredClass.instancePrototype,t,n),[]})},Wa=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array],i=n[r];function a(s){var l=(c(),y)[s>>2],d=(c(),y)[s+4>>2];return new i((c(),H).buffer,d,l)}t=Y(t),ie(e,{name:t,fromWireType:a,readValueFromPointer:a},{ignoreDuplicateRegistrations:!0})},Ua=Object.assign({optional:!0},An),ja=(e,r)=>{ie(e,Ua)},Ba=(e,r)=>{r=Y(r);var t=!0;ie(e,{name:r,fromWireType(n){var i=(c(),y)[n>>2],a=n+4,s;if(t)s=_e(a,i,!0);else{s="";for(var l=0;l<i;++l)s+=String.fromCharCode((c(),te)[a+l])}return ve(n),s},toWireType(n,i){i instanceof ArrayBuffer&&(i=new Uint8Array(i));var a,s=typeof i=="string";s||ArrayBuffer.isView(i)&&i.BYTES_PER_ELEMENT==1||A("Cannot pass non-string to std::string"),t&&s?a=Pe(i):a=i.length;var l=Je(4+a+1),d=l+4;if((c(),y)[l>>2]=a,s)if(t)Ee(i,d,a+1);else for(var u=0;u<a;++u){var _=i.charCodeAt(u);_>255&&(ve(l),A("String has UTF-16 code units that do not fit in 8 bits")),(c(),te)[d+u]=_}else(c(),te).set(i,d);return n!==null&&n.push(ve,l),l},readValueFromPointer:Ve,destructorFunction(n){ve(n)}})},Dn=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,Ha=(e,r,t)=>{h(e%2==0,"pointer passed to UTF16ToString must be 2-byte aligned");var n=e>>1,i=Gt((c(),ke),n,r/2,t);if(i-n>16&&Dn)return Dn.decode((c(),ke).slice(n,i));for(var a="",s=n;s<i;++s){var l=(c(),ke)[s];a+=String.fromCharCode(l)}return a},Ga=(e,r,t)=>{if(h(r%2==0,"pointer passed to stringToUTF16 must be 2-byte aligned"),h(typeof t=="number","stringToUTF16 requires a third parameter that specifies the length of the output buffer"),t??=2147483647,t<2)return 0;t-=2;for(var n=r,i=t<e.length*2?t/2:e.length,a=0;a<i;++a){var s=e.charCodeAt(a);(c(),ne)[r>>1]=s,r+=2}return(c(),ne)[r>>1]=0,r-n},za=e=>e.length*2,Va=(e,r,t)=>{h(e%4==0,"pointer passed to UTF32ToString must be 2-byte aligned");for(var n="",i=e>>2,a=0;!(a>=r/4);a++){var s=(c(),y)[i+a];if(!s&&!t)break;n+=String.fromCodePoint(s)}return n},qa=(e,r,t)=>{if(h(r%4==0,"pointer passed to stringToUTF32 must be 4-byte aligned"),h(typeof t=="number","stringToUTF32 requires a third parameter that specifies the length of the output buffer"),t??=2147483647,t<4)return 0;for(var n=r,i=n+t-4,a=0;a<e.length;++a){var s=e.codePointAt(a);if(s>65535&&a++,(c(),S)[r>>2]=s,r+=4,r+4>i)break}return(c(),S)[r>>2]=0,r-n},Ka=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.codePointAt(t);n>65535&&t++,r+=4}return r},Xa=(e,r,t)=>{t=Y(t);var n,i,a;r===2?(n=Ha,i=Ga,a=za):(h(r===4,"only 2-byte and 4-byte strings are currently supported"),n=Va,i=qa,a=Ka),ie(e,{name:t,fromWireType:s=>{var l=(c(),y)[s>>2],d=n(s+4,l*r,!0);return ve(s),d},toWireType:(s,l)=>{typeof l!="string"&&A(`Cannot pass non-string to C++ string type ${t}`);var d=a(l),u=Je(4+d+r);return(c(),y)[u>>2]=d/r,i(l,u+4,d+r),s!==null&&s.push(ve,u),u},readValueFromPointer:Ve,destructorFunction(s){ve(s)}})},Ya=(e,r,t,n,i,a)=>{fr[e]={name:Y(r),rawConstructor:ae(t,n),rawDestructor:ae(i,a),fields:[]}},Ja=(e,r,t,n,i,a,s,l,d,u)=>{fr[e].fields.push({fieldName:Y(r),getterReturnType:t,getter:ae(n,i),getterContext:a,setterArgumentType:s,setter:ae(l,d),setterContext:u})},Za=(e,r)=>{r=Y(r),ie(e,{isVoid:!0,name:r,fromWireType:()=>{},toWireType:(t,n)=>{}})},Qa=e=>{ot(e,!N,1,!O,65536,!1),P.threadInitTLS()},Rn=e=>{if(e instanceof Ot||e=="unwind")return $e;Ge(),e instanceof WebAssembly.RuntimeError&&ut()<=0&&C("Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to 65536)"),Ar(1,e)},eo=()=>{if(!lr())try{if(w){De()&&ct($e);return}Lr($e)}catch(e){Rn(e)}},In=e=>{if(Ie){C("user callback triggered after runtime exited or application aborted. Ignoring.");return}try{return e()}catch(r){Rn(r)}finally{eo()}},nt=e=>{if(!Ut){var r=Atomics.waitAsync((c(),S),e>>2,e);h(r.async),r.value.then(kr);var t=e+120;Atomics.store((c(),S),t>>2,1)}},kr=()=>{var e=De();e&&In(()=>{nt(e),Qn()})},ro=(e,r)=>{if(e==r)setTimeout(kr);else if(w)postMessage({targetThread:e,cmd:"checkMailbox"});else{var t=P.pthreads[e];if(!t){C(`Cannot send message to thread with ID ${e}, unknown thread ID!`);return}t.postMessage({cmd:"checkMailbox"})}},Tr=[],to=(e,r,t,n,i,a,s)=>{Tr.length=0;for(var l=i>>3,d=i+n>>3;l<d;){var u;(c(),Z)[l++]?u=(c(),Z)[l++]:u=(c(),Me)[l++],Tr.push(u)}h(!r);var _=Ho[e];h(!(e&&r)),h(_.length==Tr.length,"Call args mismatch in _emscripten_receive_on_main_thread_js"),P.currentProxiedOperationCallerThread=t;var p=_(...Tr);if(P.currentProxiedOperationCallerThread=0,a){p.then(m=>Yn(a,s,m));return}return h(typeof p!="bigint"),p},no=e=>{w?postMessage({cmd:"cleanupThread",thread:e}):It(e)},io=e=>{M&&P.pthreads[e].ref()},ao=(e,r)=>{e=re.toValue(e),r=re.toValue(r),e.set(r)},it=[],oo=e=>{var r=it.length;return it.push(e),r},so=(e,r)=>{for(var t=new Array(e),n=0;n<e;++n)t[n]=On((c(),y)[r+n*4>>2],`parameter ${n}`);return t},lo=(e,r,t)=>{var n=[],i=e(n,t);return n.length&&((c(),y)[r>>2]=re.toHandle(n)),i},co={},$n=e=>{var r=co[e];return r===void 0?Y(e):r},uo=(e,r,t)=>{var n=8,[i,...a]=so(e,r),s=i.toWireType.bind(i),l=a.map(g=>g.readValueFromPointer.bind(g));e--;var d={toValue:re.toValue},u=l.map((g,E)=>{var k=`argFromPtr${E}`;return d[k]=g,`${k}(args${E?"+"+E*n:""})`}),_;switch(t){case 0:_="toValue(handle)";break;case 2:_="new (toValue(handle))";break;case 3:_="";break;case 1:d.getStringOrSymbol=$n,_="toValue(handle)[getStringOrSymbol(methodName)]";break}_+=`(${u})`,i.isVoid||(d.toReturnWire=s,d.emval_returnValue=lo,_=`return emval_returnValue(toReturnWire, destructorsRef, ${_})`),_=`return function (handle, methodName, destructorsRef, args) {
|
|
20
|
+
${u}`,new Function(p,u)}function Ta(e){for(var r=e.length-2,t=e.length-1;t>=2&&e[t].optional;--t)r--;return r}function Sr(e,r,t,n,i,a){var s=r.length;s<2&&A("argTypes array size mismatch! Must at least get return value and 'this' types!"),h(!a,"async bindings are only supported with JSPI");for(var l=r[1]!==null&&t!==null,d=Pn(r),u=!r[0].isVoid,_=s-2,p=Ta(r),m=r[0],g=r[1],E=[e,A,n,i,hr,m.fromWireType.bind(m),g?.toWireType.bind(g)],k=2;k<s;++k){var D=r[k];E.push(D.toWireType.bind(D))}if(!d)for(var k=l?1:2;k<r.length;++k)r[k].destructorFunction!==null&&E.push(r[k].destructorFunction);E.push(Sa,p,_);var G=ka(r,l,u,a)(...E);return wr(e,G)}var kr=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push((c(),y)[r+n*4>>2]);return t},rt=e=>{e=e.trim();let r=e.indexOf("(");return r===-1?e:(h(e.endsWith(")"),"Parentheses for argument names should match."),e.slice(0,r))},Fa=(e,r,t,n,i,a,s,l,d)=>{var u=kr(t,n);r=Y(r),r=rt(r),a=ae(i,a,l),ce([],[e],_=>{_=_[0];var p=`${_.name}.${r}`;function m(){Oe(`Cannot call ${p} due to unbound types`,u)}r.startsWith("@@")&&(r=Symbol[r.substring(2)]);var g=_.registeredClass.constructor;return g[r]===void 0?(m.argCount=t-1,g[r]=m):(et(g,r,p),g[r].overloadTable[t-1]=m),ce([],u,E=>{var k=[E[0],null].concat(E.slice(1)),D=Sr(p,k,null,a,s,l);if(g[r].overloadTable===void 0?(D.argCount=t-1,g[r]=D):g[r].overloadTable[t-1]=D,_.registeredClass.__derivedClasses)for(let R of _.registeredClass.__derivedClasses)R.constructor.hasOwnProperty(r)||(R.constructor[r]=D);return[]}),[]})},Pa=(e,r,t,n,i,a)=>{h(r>0);var s=kr(r,t);i=ae(n,i);var l=[a],d=[];ce([],[e],u=>{u=u[0];var _=`constructor ${u.name}`;if(u.registeredClass.constructor_body===void 0&&(u.registeredClass.constructor_body=[]),u.registeredClass.constructor_body[r-1]!==void 0)throw new Ke(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${u.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return u.registeredClass.constructor_body[r-1]=()=>{Oe(`Cannot construct ${u.name} due to unbound types`,s)},ce([],s,p=>(p.splice(1,0,null),u.registeredClass.constructor_body[r-1]=Sr(_,p,null,i,a),[])),[]})},Ca=(e,r,t,n,i,a,s,l,d,u)=>{var _=kr(t,n);r=Y(r),r=rt(r),a=ae(i,a,d),ce([],[e],p=>{p=p[0];var m=`${p.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),l&&p.registeredClass.pureVirtualFunctions.push(r);function g(){Oe(`Cannot call ${m} due to unbound types`,_)}var E=p.registeredClass.instancePrototype,k=E[r];return k===void 0||k.overloadTable===void 0&&k.className!==p.name&&k.argCount===t-2?(g.argCount=t-2,g.className=p.name,E[r]=g):(et(E,r,m),E[r].overloadTable[t-2]=g),ce([],_,D=>{var R=Sr(m,D,p,a,s,d);return E[r].overloadTable===void 0?(R.argCount=t-2,E[r]=R):E[r].overloadTable[t-2]=R,[]}),[]})},Cn=(e,r,t)=>(e instanceof Object||A(`${t} with invalid "this": ${e}`),e instanceof r.registeredClass.constructor||A(`${t} incompatible with "this" of type ${e.constructor.name}`),e.$$.ptr||A(`cannot call emscripten binding method ${t} on deleted object`),Er(e.$$.ptr,e.$$.ptrType.registeredClass,r.registeredClass)),Aa=(e,r,t,n,i,a,s,l,d,u)=>{r=Y(r),i=ae(n,i),ce([],[e],_=>{_=_[0];var p=`${_.name}.${r}`,m={get(){Oe(`Cannot access ${p} due to unbound types`,[t,s])},enumerable:!0,configurable:!0};return d?m.set=()=>Oe(`Cannot access ${p} due to unbound types`,[t,s]):m.set=g=>A(p+" is a read-only property"),Object.defineProperty(_.registeredClass.instancePrototype,r,m),ce([],d?[t,s]:[t],g=>{var E=g[0],k={get(){var R=Cn(this,_,p+" getter");return E.fromWireType(i(a,R))},enumerable:!0};if(d){d=ae(l,d);var D=g[1];k.set=function(R){var G=Cn(this,_,p+" setter"),z=[];d(u,G,D.toWireType(z,R)),hr(z)}}return Object.defineProperty(_.registeredClass.instancePrototype,r,k),[]}),[]})},An=[],ue=[0,1,,1,null,1,!0,1,!1,1],tt=e=>{if(e>9&&--ue[e+1]===0){h(ue[e]!==void 0,"decref for unallocated handle");var r=ue[e];ue[e]=void 0,An.push(e)}},re={toValue:e=>(e||A(`Cannot use deleted val. handle = ${e}`),h(e===2||ue[e]!==void 0&&e%2===0,`invalid handle: ${e}`),ue[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let r=An.pop()||ue.length;return ue[r]=e,ue[r+1]=1,r}}}},On={name:"emscripten::val",fromWireType:e=>{var r=re.toValue(e);return tt(e),r},toWireType:(e,r)=>re.toHandle(r),readValueFromPointer:qe,destructorFunction:null},Oa=e=>ie(e,On),nt=(e,r,t)=>{switch(r){case 1:return t?function(n){return this.fromWireType((c(),H)[n])}:function(n){return this.fromWireType((c(),te)[n])};case 2:return t?function(n){return this.fromWireType((c(),ne)[n>>1])}:function(n){return this.fromWireType((c(),ke)[n>>1])};case 4:return t?function(n){return this.fromWireType((c(),S)[n>>2])}:function(n){return this.fromWireType((c(),y)[n>>2])};default:throw new TypeError(`invalid integer width (${r}): ${e}`)}};function Da(e){return e===0?"object":e===1?"number":"string"}var Ra=(e,r,t,n,i)=>{r=Y(r);let a=Da(i);switch(a){case"object":{let u=function(){};u.values={},ie(e,{name:r,constructor:u,valueType:a,fromWireType:function(_){return this.constructor.values[_]},toWireType:(_,p)=>p.value,readValueFromPointer:nt(r,t,n),destructorFunction:null}),Ye(r,u);break}case"number":{var s={};ie(e,{name:r,keysMap:s,valueType:a,fromWireType:u=>u,toWireType:(u,_)=>_,readValueFromPointer:nt(r,t,n),destructorFunction:null}),Ye(r,s),delete f[r].argCount;break}case"string":{var l={},d={},s={};ie(e,{name:r,valuesMap:l,reverseMap:d,keysMap:s,valueType:a,fromWireType:function(_){return this.reverseMap[_]},toWireType:function(_,p){return this.valuesMap[p]},readValueFromPointer:nt(r,t,n),destructorFunction:null}),Ye(r,s),delete f[r].argCount;break}}},Dn=(e,r)=>{var t=Ce[e];return t===void 0&&A(`${r} has unknown type ${Fn(e)}`),t},Ia=(e,r,t)=>{var n=Dn(e,"enum");switch(r=Y(r),n.valueType){case"object":{var i=n.constructor,a=Object.create(n.constructor.prototype,{value:{value:t},constructor:{value:wr(`${n.name}_${r}`,function(){})}});i.values[t]=a,i[r]=a;break}case"number":{n.keysMap[r]=t;break}case"string":{n.valuesMap[r]=t,n.reverseMap[t]=r,n.keysMap[r]=r;break}}},$a=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType((c(),sr)[t>>2])};case 8:return function(t){return this.fromWireType((c(),Me)[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},Na=(e,r,t)=>{r=Y(r),ie(e,{name:r,fromWireType:n=>n,toWireType:(n,i)=>{if(typeof i!="number"&&typeof i!="boolean")throw new TypeError(`Cannot convert ${Ae(i)} to ${r}`);return i},readValueFromPointer:$a(r,t),destructorFunction:null})},Ma=(e,r,t,n,i,a,s,l)=>{var d=kr(r,t);e=Y(e),e=rt(e),i=ae(n,i,s),Ye(e,function(){Oe(`Cannot call ${e} due to unbound types`,d)},r-1),ce([],d,u=>{var _=[u[0],null].concat(u.slice(1));return Tn(e,Sr(e,_,null,i,a,s),r-1),[]})},xa=(e,r,t,n,i)=>{r=Y(r);let a=n===0,s=d=>d;if(a){var l=32-8*t;s=d=>d<<l>>>l,i=s(i)}ie(e,{name:r,fromWireType:s,toWireType:(d,u)=>{if(typeof u!="number"&&typeof u!="boolean")throw new TypeError(`Cannot convert "${Ae(u)}" to ${r}`);return gn(r,u,n,i),u},readValueFromPointer:mn(r,t,n!==0),destructorFunction:null})},La=(e,r,t)=>{let n=(i,a)=>{let s=0;return{next(){if(s>=i)return{done:!0};let l=s;return s++,{value:a(l),done:!1}},[Symbol.iterator](){return this}}};e[Symbol.iterator]||(e[Symbol.iterator]=function(){let i=this[r]();return n(i,a=>this[t](a))})},Wa=(e,r,t,n)=>{t=Y(t),n=Y(n),ce([],[e,r],i=>{let a=i[0];return La(a.registeredClass.instancePrototype,t,n),[]})},Ua=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array],i=n[r];function a(s){var l=(c(),y)[s>>2],d=(c(),y)[s+4>>2];return new i((c(),H).buffer,d,l)}t=Y(t),ie(e,{name:t,fromWireType:a,readValueFromPointer:a},{ignoreDuplicateRegistrations:!0})},ja=Object.assign({optional:!0},On),Ba=(e,r)=>{ie(e,ja)},Ha=(e,r)=>{r=Y(r);var t=!0;ie(e,{name:r,fromWireType(n){var i=(c(),y)[n>>2],a=n+4,s;if(t)s=_e(a,i,!0);else{s="";for(var l=0;l<i;++l)s+=String.fromCharCode((c(),te)[a+l])}return ve(n),s},toWireType(n,i){i instanceof ArrayBuffer&&(i=new Uint8Array(i));var a,s=typeof i=="string";s||ArrayBuffer.isView(i)&&i.BYTES_PER_ELEMENT==1||A("Cannot pass non-string to std::string"),t&&s?a=Pe(i):a=i.length;var l=Ze(4+a+1),d=l+4;if((c(),y)[l>>2]=a,s)if(t)Ee(i,d,a+1);else for(var u=0;u<a;++u){var _=i.charCodeAt(u);_>255&&(ve(l),A("String has UTF-16 code units that do not fit in 8 bits")),(c(),te)[d+u]=_}else(c(),te).set(i,d);return n!==null&&n.push(ve,l),l},readValueFromPointer:qe,destructorFunction(n){ve(n)}})},Rn=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,Ga=(e,r,t)=>{h(e%2==0,"pointer passed to UTF16ToString must be 2-byte aligned");var n=e>>1,i=zt((c(),ke),n,r/2,t);if(i-n>16&&Rn)return Rn.decode((c(),ke).slice(n,i));for(var a="",s=n;s<i;++s){var l=(c(),ke)[s];a+=String.fromCharCode(l)}return a},za=(e,r,t)=>{if(h(r%2==0,"pointer passed to stringToUTF16 must be 2-byte aligned"),h(typeof t=="number","stringToUTF16 requires a third parameter that specifies the length of the output buffer"),t??=2147483647,t<2)return 0;t-=2;for(var n=r,i=t<e.length*2?t/2:e.length,a=0;a<i;++a){var s=e.charCodeAt(a);(c(),ne)[r>>1]=s,r+=2}return(c(),ne)[r>>1]=0,r-n},Va=e=>e.length*2,qa=(e,r,t)=>{h(e%4==0,"pointer passed to UTF32ToString must be 2-byte aligned");for(var n="",i=e>>2,a=0;!(a>=r/4);a++){var s=(c(),y)[i+a];if(!s&&!t)break;n+=String.fromCodePoint(s)}return n},Ka=(e,r,t)=>{if(h(r%4==0,"pointer passed to stringToUTF32 must be 4-byte aligned"),h(typeof t=="number","stringToUTF32 requires a third parameter that specifies the length of the output buffer"),t??=2147483647,t<4)return 0;for(var n=r,i=n+t-4,a=0;a<e.length;++a){var s=e.codePointAt(a);if(s>65535&&a++,(c(),S)[r>>2]=s,r+=4,r+4>i)break}return(c(),S)[r>>2]=0,r-n},Xa=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.codePointAt(t);n>65535&&t++,r+=4}return r},Ya=(e,r,t)=>{t=Y(t);var n,i,a;r===2?(n=Ga,i=za,a=Va):(h(r===4,"only 2-byte and 4-byte strings are currently supported"),n=qa,i=Ka,a=Xa),ie(e,{name:t,fromWireType:s=>{var l=(c(),y)[s>>2],d=n(s+4,l*r,!0);return ve(s),d},toWireType:(s,l)=>{typeof l!="string"&&A(`Cannot pass non-string to C++ string type ${t}`);var d=a(l),u=Ze(4+d+r);return(c(),y)[u>>2]=d/r,i(l,u+4,d+r),s!==null&&s.push(ve,u),u},readValueFromPointer:qe,destructorFunction(s){ve(s)}})},Ja=(e,r,t,n,i,a)=>{_r[e]={name:Y(r),rawConstructor:ae(t,n),rawDestructor:ae(i,a),fields:[]}},Za=(e,r,t,n,i,a,s,l,d,u)=>{_r[e].fields.push({fieldName:Y(r),getterReturnType:t,getter:ae(n,i),getterContext:a,setterArgumentType:s,setter:ae(l,d),setterContext:u})},Qa=(e,r)=>{r=Y(r),ie(e,{isVoid:!0,name:r,fromWireType:()=>{},toWireType:(t,n)=>{}})},eo=e=>{st(e,!N,1,!O,65536,!1),P.threadInitTLS()},In=e=>{if(e instanceof Dt||e=="unwind")return $e;ze(),e instanceof WebAssembly.RuntimeError&&ft()<=0&&C("Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to 65536)"),Or(1,e)},ro=()=>{if(!dr())try{if(w){De()&&ut($e);return}Wr($e)}catch(e){In(e)}},$n=e=>{if(Ie){C("user callback triggered after runtime exited or application aborted. Ignoring.");return}try{return e()}catch(r){In(r)}finally{ro()}},it=e=>{if(!jt){var r=Atomics.waitAsync((c(),S),e>>2,e);h(r.async),r.value.then(Tr);var t=e+120;Atomics.store((c(),S),t>>2,1)}},Tr=()=>{var e=De();e&&$n(()=>{it(e),ei()})},to=(e,r)=>{if(e==r)setTimeout(Tr);else if(w)postMessage({targetThread:e,cmd:"checkMailbox"});else{var t=P.pthreads[e];if(!t){C(`Cannot send message to thread with ID ${e}, unknown thread ID!`);return}t.postMessage({cmd:"checkMailbox"})}},Fr=[],no=(e,r,t,n,i,a,s)=>{Fr.length=0;for(var l=i>>3,d=i+n>>3;l<d;){var u;(c(),Z)[l++]?u=(c(),Z)[l++]:u=(c(),Me)[l++],Fr.push(u)}h(!r);var _=Go[e];h(!(e&&r)),h(_.length==Fr.length,"Call args mismatch in _emscripten_receive_on_main_thread_js"),P.currentProxiedOperationCallerThread=t;var p=_(...Fr);if(P.currentProxiedOperationCallerThread=0,a){p.then(m=>Jn(a,s,m));return}return h(typeof p!="bigint"),p},io=e=>{w?postMessage({cmd:"cleanupThread",thread:e}):$t(e)},ao=e=>{M&&P.pthreads[e].ref()},oo=(e,r)=>{e=re.toValue(e),r=re.toValue(r),e.set(r)},at=[],so=e=>{var r=at.length;return at.push(e),r},lo=(e,r)=>{for(var t=new Array(e),n=0;n<e;++n)t[n]=Dn((c(),y)[r+n*4>>2],`parameter ${n}`);return t},co=(e,r,t)=>{var n=[],i=e(n,t);return n.length&&((c(),y)[r>>2]=re.toHandle(n)),i},uo={},Nn=e=>{var r=uo[e];return r===void 0?Y(e):r},fo=(e,r,t)=>{var n=8,[i,...a]=lo(e,r),s=i.toWireType.bind(i),l=a.map(g=>g.readValueFromPointer.bind(g));e--;var d={toValue:re.toValue},u=l.map((g,E)=>{var k=`argFromPtr${E}`;return d[k]=g,`${k}(args${E?"+"+E*n:""})`}),_;switch(t){case 0:_="toValue(handle)";break;case 2:_="new (toValue(handle))";break;case 3:_="";break;case 1:d.getStringOrSymbol=Nn,_="toValue(handle)[getStringOrSymbol(methodName)]";break}_+=`(${u})`,i.isVoid||(d.toReturnWire=s,d.emval_returnValue=co,_=`return emval_returnValue(toReturnWire, destructorsRef, ${_})`),_=`return function (handle, methodName, destructorsRef, args) {
|
|
21
21
|
${_}
|
|
22
|
-
}`;var p=new Function(Object.keys(d),_)(...Object.values(d)),m=`methodCaller<(${a.map(g=>g.name)}) => ${i.name}>`;return oo(yr(m,p))},fo=(e,r)=>(e=re.toValue(e),r=re.toValue(r),re.toHandle(e[r])),_o=e=>{e>9&&(ue[e+1]+=1)},Nn=(e,r,t,n,i)=>it[e](r,t,n,i),ho=(e,r,t,n,i)=>Nn(e,r,t,n,i),vo=e=>re.toHandle($n(e)),po=e=>{var r=re.toValue(e);_r(r),rt(e)},mo=(e,r,t,n)=>{var i=new Date().getFullYear(),a=new Date(i,0,1),s=new Date(i,6,1),l=a.getTimezoneOffset(),d=s.getTimezoneOffset(),u=Math.max(l,d);(c(),y)[e>>2]=u*60,(c(),S)[r>>2]=+(l!=d);var _=g=>{var E=g>=0?"-":"+",k=Math.abs(g),D=String(Math.floor(k/60)).padStart(2,"0"),R=String(k%60).padStart(2,"0");return`UTC${E}${D}${R}`},p=_(l),m=_(d);h(p),h(m),h(Pe(p)<=16,`timezone name truncated to fit in TZNAME_MAX (${p})`),h(Pe(m)<=16,`timezone name truncated to fit in TZNAME_MAX (${m})`),d<l?(Ee(p,t,17),Ee(m,n,17)):(Ee(p,n,17),Ee(m,t,17))},Mn=()=>performance.timeOrigin+performance.now(),go=()=>Date.now(),yo=1,wo=e=>e>=0&&e<=3,Eo=9007199254740992,bo=-9007199254740992,xn=e=>e<bo||e>Eo?NaN:Number(e);function So(e,r,t){if(r=xn(r),!wo(e))return 28;var n;if(e===0)n=go();else if(yo)n=Mn();else return 52;var i=Math.round(n*1e3*1e3);return(c(),Z)[t>>3]=BigInt(i),0}var ko=()=>{M||N||Fe("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")},To=e=>C(_e(e)),Fo=()=>{sr+=1},Po=()=>{throw Fo(),"unwind"},Co=()=>2147483648,Ao=(e,r)=>(h(r,"alignment argument is required"),Math.ceil(e/r)*r),Oo=e=>{var r=fe.buffer.byteLength,t=(e-r+65535)/65536|0;try{return fe.grow(t),ar(),1}catch(n){C(`growMemory: Attempted to grow heap from ${r} bytes to ${e} bytes, but got error: ${n}`)}},Do=e=>{var r=(c(),te).length;if(e>>>=0,e<=r)return!1;var t=Co();if(e>t)return C(`Cannot enlarge memory, requested ${e} bytes, but the limit is ${t} bytes!`),!1;for(var n=1;n<=4;n*=2){var i=r*(1+.2/n);i=Math.min(i,e+100663296);var a=Math.min(t,Ao(Math.max(e,i),65536)),s=Oo(a);if(s)return!0}return C(`Failed to grow the heap from ${r} bytes to ${a} bytes, not enough memory!`),!1},at={},Ro=()=>Cr||"./this.program",Ye=()=>{if(!Ye.strings){var e=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Ro()};for(var t in at)at[t]===void 0?delete r[t]:r[t]=at[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);Ye.strings=n}return Ye.strings};function Ln(e,r){if(w)return K(15,0,1,e,r);var t=0,n=0;for(var i of Ye()){var a=r+t;(c(),y)[e+n>>2]=a,t+=Ee(i,a,1/0)+1,n+=4}return 0}function Wn(e,r){if(w)return K(16,0,1,e,r);var t=Ye();(c(),y)[e>>2]=t.length;var n=0;for(var i of t)n+=Pe(i)+1;return(c(),y)[r>>2]=n,0}function Un(e){if(w)return K(17,0,1,e);try{var r=X.getStreamFromFD(e);return o.close(r),0}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var Io=(e,r,t,n)=>{for(var i=0,a=0;a<t;a++){var s=(c(),y)[r>>2],l=(c(),y)[r+4>>2];r+=8;var d=o.read(e,(c(),H),s,l,n);if(d<0)return-1;if(i+=d,d<l)break;typeof n<"u"&&(n+=d)}return i};function jn(e,r,t,n){if(w)return K(18,0,1,e,r,t,n);try{var i=X.getStreamFromFD(e),a=Io(i,r,t);return(c(),y)[n>>2]=a,0}catch(s){if(typeof o>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function Bn(e,r,t,n){if(w)return K(19,0,1,e,r,t,n);r=xn(r);try{if(isNaN(r))return 22;var i=X.getStreamFromFD(e);return o.llseek(i,r,t),(c(),Z)[n>>3]=BigInt(i.position),i.getdents&&r===0&&t===0&&(i.getdents=null),0}catch(a){if(typeof o>"u"||a.name!=="ErrnoError")throw a;return a.errno}}var $o=(e,r,t,n)=>{for(var i=0,a=0;a<t;a++){var s=(c(),y)[r>>2],l=(c(),y)[r+4>>2];r+=8;var d=o.write(e,(c(),H),s,l,n);if(d<0)return-1;if(i+=d,d<l)break;typeof n<"u"&&(n+=d)}return i};function Hn(e,r,t,n){if(w)return K(20,0,1,e,r,t,n);try{var i=X.getStreamFromFD(e),a=$o(i,r,t);return(c(),y)[n>>2]=a,0}catch(s){if(typeof o>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function Gn(e,r,t,n){if(w)return K(21,0,1,e,r,t,n);var i=[],a=null,s=0,l=0,d=0,u=0,_=0,p=0,m,g;function E(k,D,R,G,z,oe){var de,V,se,Qe;return V=k===10?28:16,z=k===10?Qt(z):Xr(z),de=Je(V),Qe=cn(de,k,z,oe),h(!Qe),se=Je(32),(c(),S)[se+4>>2]=k,(c(),S)[se+8>>2]=D,(c(),S)[se+12>>2]=R,(c(),y)[se+24>>2]=G,(c(),y)[se+20>>2]=de,k===10?(c(),S)[se+16>>2]=28:(c(),S)[se+16>>2]=16,(c(),S)[se+28>>2]=0,se}if(t&&(d=(c(),S)[t>>2],u=(c(),S)[t+4>>2],_=(c(),S)[t+8>>2],p=(c(),S)[t+12>>2]),_&&!p&&(p=_===2?17:6),!_&&p&&(_=p===17?2:1),p===0&&(p=6),_===0&&(_=1),!e&&!r)return-2;if(d&-1088||t!==0&&(c(),S)[t>>2]&2&&!e)return-1;if(d&32)return-2;if(_!==0&&_!==1&&_!==2)return-7;if(u!==0&&u!==2&&u!==10)return-6;if(r&&(r=_e(r),l=parseInt(r,10),isNaN(l)))return d&1024?-2:-8;if(!e)return u===0&&(u=2),(d&1)===0&&(u===2?s=Ze(2130706433):s=[0,0,0,Ze(1)]),m=E(u,_,p,null,s,l),(c(),y)[n>>2]=m,0;if(e=_e(e),s=cr(e),s!==null)if(u===0||u===2)u=2;else if(u===10&&d&8)s=[0,0,Ze(65535),s],u=10;else return-2;else if(s=Yr(e),s!==null)if(u===0||u===10)u=10;else return-2;return s!=null?(m=E(u,_,p,e,s,l),(c(),y)[n>>2]=m,0):d&4?-2:(e=he.lookup_name(e),s=cr(e),u===0?u=2:u===10&&(s=[0,0,Ze(65535),s]),m=E(u,_,p,null,s,l),(c(),y)[n>>2]=m,0)}var No=e=>e,Mo=(e,r)=>Br((c(),te).subarray(e,e+r)),xo=(...e)=>o.createPath(...e),Lo=(...e)=>o.unlink(...e),Wo=(...e)=>o.createLazyFile(...e),Uo=(...e)=>o.createDevice(...e);P.init(),o.createPreloadedFile=Ji,o.preloadFile=qr,o.staticInit(),M&&b.staticInit(),ua(),ya(),h(ue.length===10);{if(Ei(),f.noExitRuntime&&(Wr=f.noExitRuntime),f.preloadPlugins&&(Zt=f.preloadPlugins),f.print&&(ge=f.print),f.printErr&&(C=f.printErr),f.wasmBinary&&(He=f.wasmBinary),Go(),f.arguments&&(mt=f.arguments),f.thisProgram&&(Cr=f.thisProgram),h(typeof f.memoryInitializerPrefixURL>"u","Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),h(typeof f.pthreadMainPrefixURL>"u","Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),h(typeof f.cdInitializerPrefixURL>"u","Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),h(typeof f.filePackagePrefixURL>"u","Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),h(typeof f.read>"u","Module.read option was removed"),h(typeof f.readAsync>"u","Module.readAsync option was removed (modify readAsync in JS)"),h(typeof f.readBinary>"u","Module.readBinary option was removed (modify readBinary in JS)"),h(typeof f.setWindowTitle>"u","Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),h(typeof f.TOTAL_MEMORY>"u","Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),h(typeof f.ENVIRONMENT>"u","Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)"),h(typeof f.STACK_SIZE>"u","STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),f.preInit)for(typeof f.preInit=="function"&&(f.preInit=[f.preInit]);f.preInit.length>0;)f.preInit.shift()();ir("preInit")}f.addRunDependency=xr,f.removeRunDependency=Mr,f.FS_preloadFile=qr,f.FS_unlink=Lo,f.FS_createPath=xo,f.FS_createDevice=Uo,f.FS=o,f.FS_createDataFile=Jt,f.FS_createLazyFile=Wo;var jo=["writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getTempRet0","setTempRet0","withStackSave","readEmAsmArgs","jstoi_q","autoResumeAudioContext","getDynCaller","dynCall","runtimeKeepalivePop","asmjsMangle","HandleAllocator","addOnInit","addOnPostCtor","addOnPreMain","addOnExit","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","ccall","cwrap","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","getFunctionAddress","addFunction","removeFunction","intArrayToString","stringToAscii","stringToNewUTF8","stringToUTF8OnStack","writeArrayToMemory","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","registerBatteryEventCallback","setCanvasElementSizeCallingThread","setCanvasElementSizeMainThread","setCanvasElementSize","getCanvasSizeCallingThread","getCanvasSizeMainThread","getCanvasElementSize","jsStackTrace","getCallstack","convertPCtoSourceLocation","wasiRightsToMuslOFlags","wasiOFlagsToMuslOFlags","safeSetTimeout","setImmediateWrapped","safeRequestAnimationFrame","clearImmediateWrapped","registerPostMainLoop","registerPreMainLoop","getPromise","makePromise","idsToPromises","makePromiseCallback","incrementUncaughtExceptionCount","decrementUncaughtExceptionCount","Browser_asyncPrepareDataCounter","isLeapYear","ydayFromDate","arraySum","addDays","FS_mkdirTree","_setNetworkCallback","heapObjectForWebGLType","toTypedArrayIndex","webgl_enable_ANGLE_instanced_arrays","webgl_enable_OES_vertex_array_object","webgl_enable_WEBGL_draw_buffers","webgl_enable_WEBGL_multi_draw","webgl_enable_EXT_polygon_offset_clamp","webgl_enable_EXT_clip_control","webgl_enable_WEBGL_polygon_mode","emscriptenWebGLGet","computeUnpackAlignedImageSize","colorChannelsInGlTextureFormat","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","__glGetActiveAttribOrUniform","writeGLArray","emscripten_webgl_destroy_context_before_on_calling_thread","registerWebGlEventCallback","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate","writeStringToMemory","writeAsciiToMemory","allocateUTF8","allocateUTF8OnStack","demangle","stackTrace","getNativeTypeSize","getFunctionArgsName","createJsInvokerSignature","PureVirtualError","registerInheritedInstance","unregisterInheritedInstance","getInheritedInstanceCount","getLiveInheritedInstances","setDelayFunction","count_emval_handles"];jo.forEach(yi);var Bo=["run","out","err","callMain","abort","wasmExports","writeStackCookie","checkStackCookie","INT53_MAX","INT53_MIN","bigintToI53Checked","HEAP8","HEAP16","HEAPU16","HEAP32","HEAPU32","HEAPF32","HEAPF64","HEAP64","HEAPU64","stackSave","stackRestore","stackAlloc","createNamedFunction","ptrToString","zeroMemory","exitJS","getHeapMax","growMemory","ENV","ERRNO_CODES","strError","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","DNS","Protocols","Sockets","timers","warnOnce","readEmAsmArgsArray","getExecutableName","handleException","keepRuntimeAlive","runtimeKeepalivePush","callUserCallback","maybeExit","asyncLoad","alignMemory","mmapAlloc","wasmTable","wasmMemory","getUniqueRunDependency","noExitRuntime","addOnPreRun","addOnPostRun","freeTableIndexes","functionsInTableMap","setValue","getValue","PATH","PATH_FS","UTF8Decoder","UTF8ArrayToString","UTF8ToString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","intArrayFromString","AsciiToString","UTF16Decoder","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","JSEvents","specialHTMLTargets","findCanvasEventTarget","currentFullscreenStrategy","restoreOldWindowedStyle","UNWIND_CACHE","ExitStatus","getEnvStrings","checkWasiClock","doReadv","doWritev","initRandomFill","randomFill","emSetImmediate","emClearImmediate_deps","emClearImmediate","promiseMap","uncaughtExceptionCount","exceptionCaught","ExceptionInfo","findMatchingCatch","Browser","requestFullscreen","requestFullScreen","setCanvasSize","getUserMedia","createContext","getPreloadedImageData__data","wget","MONTH_DAYS_REGULAR","MONTH_DAYS_LEAP","MONTH_DAYS_REGULAR_CUMULATIVE","MONTH_DAYS_LEAP_CUMULATIVE","SYSCALLS","getSocketFromFD","getSocketAddress","preloadPlugins","FS_createPreloadedFile","FS_modeStringToFlags","FS_getMode","FS_fileDataToTypedArray","FS_stdin_getChar_buffer","FS_stdin_getChar","FS_readFile","FS_root","FS_mounts","FS_devices","FS_streams","FS_nextInode","FS_nameTable","FS_currentPath","FS_initialized","FS_ignorePermissions","FS_filesystems","FS_syncFSRequests","FS_lookupPath","FS_getPath","FS_hashName","FS_hashAddNode","FS_hashRemoveNode","FS_lookupNode","FS_createNode","FS_destroyNode","FS_isRoot","FS_isMountpoint","FS_isFile","FS_isDir","FS_isLink","FS_isChrdev","FS_isBlkdev","FS_isFIFO","FS_isSocket","FS_flagsToPermissionString","FS_nodePermissions","FS_mayLookup","FS_mayCreate","FS_mayDelete","FS_mayOpen","FS_checkOpExists","FS_nextfd","FS_getStreamChecked","FS_getStream","FS_createStream","FS_closeStream","FS_dupStream","FS_doSetAttr","FS_chrdev_stream_ops","FS_major","FS_minor","FS_makedev","FS_registerDevice","FS_getDevice","FS_getMounts","FS_syncfs","FS_mount","FS_unmount","FS_lookup","FS_mknod","FS_statfs","FS_statfsStream","FS_statfsNode","FS_create","FS_mkdir","FS_mkdev","FS_symlink","FS_rename","FS_rmdir","FS_readdir","FS_readlink","FS_stat","FS_fstat","FS_lstat","FS_doChmod","FS_chmod","FS_lchmod","FS_fchmod","FS_doChown","FS_chown","FS_lchown","FS_fchown","FS_doTruncate","FS_truncate","FS_ftruncate","FS_utime","FS_open","FS_close","FS_isClosed","FS_llseek","FS_read","FS_write","FS_mmap","FS_msync","FS_ioctl","FS_writeFile","FS_cwd","FS_chdir","FS_createDefaultDirectories","FS_createDefaultDevices","FS_createSpecialDirectories","FS_createStandardStreams","FS_staticInit","FS_init","FS_quit","FS_findObject","FS_analyzePath","FS_createFile","FS_forceLoadFile","MEMFS","TTY","PIPEFS","SOCKFS","tempFixedLengthArray","miniTempWebGLFloatBuffers","miniTempWebGLIntBuffers","GL","AL","GLUT","EGL","GLEW","IDBStore","SDL","SDL_gfx","waitAsyncPolyfilled","print","printErr","jstoi_s","PThread","terminateWorker","cleanupThread","registerTLSInit","spawnThread","exitOnMainThread","proxyToMainThread","proxiedJSCallArgs","invokeEntryPoint","checkMailbox","InternalError","BindingError","throwInternalError","throwBindingError","registeredTypes","awaitingDependencies","typeDependencies","tupleRegistrations","structRegistrations","sharedRegisterType","whenDependentTypesAreResolved","getTypeName","getFunctionName","heap32VectorToArray","requireRegisteredType","usesDestructorStack","checkArgCount","getEnumValueType","getRequiredArgCount","createJsInvoker","UnboundTypeError","EmValType","EmValOptionalType","throwUnboundTypeError","ensureOverloadTable","exposePublicSymbol","replacePublicSymbol","embindRepr","registeredInstances","getBasestPointer","getInheritedInstance","registeredPointers","registerType","integerReadValueFromPointer","enumReadValueFromPointer","floatReadValueFromPointer","assertIntegerRange","readPointer","installIndexedIterator","runDestructors","craftInvokerFunction","embind__requireFunction","genericPointerToWireType","constNoSmartPtrRawPointerToWireType","nonConstNoSmartPtrRawPointerToWireType","init_RegisteredPointer","RegisteredPointer","RegisteredPointer_fromWireType","runDestructor","releaseClassHandle","finalizationRegistry","detachFinalizer_deps","detachFinalizer","attachFinalizer","makeClassHandle","init_ClassHandle","ClassHandle","throwInstanceAlreadyDeleted","deletionQueue","flushPendingDeletes","delayFunction","RegisteredClass","shallowCopyInternalPointer","downcastPointer","upcastPointer","validateThis","char_0","char_9","makeLegalFunctionName","emval_freelist","emval_handles","emval_symbols","getStringOrSymbol","Emval","emval_returnValue","emval_lookupTypes","emval_methodCallers","emval_addMethodCaller","NODEFS"];Bo.forEach(St);var Ho=[Lt,Wt,qt,rn,tn,nn,an,on,sn,ln,un,fn,_n,hn,vn,Ln,Wn,Un,jn,Bn,Hn,Gn];function Go(){Se("fetchSettings"),Se("logReadFiles"),Se("loadSplitModule"),Se("onMalloc"),Se("onRealloc"),Se("onFree"),Se("onSbrkGrow")}function zo(){var e,r,t=new Promise(function(n,i){e=n,r=i});return re.toHandle({promise:t,resolve:e,reject:r})}function Vo(e,r){re.toValue(e)(re.toValue(r))}function qo(e,r){re.toValue(e)(new Error(_e(r)))}function Ko(e,r,t){var n=(c(),te).subarray(e,e+r*t),i=!1;return n.free=function(){i||(i=!0,ve(e))},globalThis._e57Finalizer||(globalThis._e57Finalizer=new FinalizationRegistry(function(a){a()})),globalThis._e57Finalizer.register(n,n.free),re.toHandle(n)}var zn=$("___getTypeName"),Vn=$("__embind_initialize_bindings"),Je=f._malloc=$("_malloc"),ve=f._free=$("_free"),De=$("_pthread_self"),qn=$("_strerror"),Xo=$("__emscripten_tls_init"),ot=$("__emscripten_thread_init"),Kn=$("___set_thread_state"),Xn=$("__emscripten_thread_crashed"),st=$("_fflush"),Ze=$("_htonl"),Fr=$("_htons"),lt=$("_emscripten_stack_get_end"),Yo=$("_emscripten_stack_get_base"),dt=$("_ntohs"),Yn=$("__emscripten_run_js_on_main_thread_done"),Jn=$("__emscripten_run_js_on_main_thread"),Zn=$("__emscripten_thread_free_data"),ct=$("__emscripten_thread_exit"),Qn=$("__emscripten_check_mailbox"),U=$("_setThrew"),ei=$("_emscripten_stack_init"),ri=$("_emscripten_stack_set_limits"),Jo=$("_emscripten_stack_get_free"),ti=$("__emscripten_stack_restore"),ni=$("__emscripten_stack_alloc"),ut=$("_emscripten_stack_get_current"),ii=$("___cxa_decrement_exception_refcount"),ai=$("___cxa_get_exception_ptr"),Zo=$("__indirect_function_table"),ft=$("wasmTable");function Qo(e){h(typeof e.__getTypeName<"u","missing Wasm export: __getTypeName"),h(typeof e._embind_initialize_bindings<"u","missing Wasm export: _embind_initialize_bindings"),h(typeof e.malloc<"u","missing Wasm export: malloc"),h(typeof e.free<"u","missing Wasm export: free"),h(typeof e.pthread_self<"u","missing Wasm export: pthread_self"),h(typeof e.strerror<"u","missing Wasm export: strerror"),h(typeof e._emscripten_tls_init<"u","missing Wasm export: _emscripten_tls_init"),h(typeof e._emscripten_thread_init<"u","missing Wasm export: _emscripten_thread_init"),h(typeof e.__set_thread_state<"u","missing Wasm export: __set_thread_state"),h(typeof e._emscripten_thread_crashed<"u","missing Wasm export: _emscripten_thread_crashed"),h(typeof e.fflush<"u","missing Wasm export: fflush"),h(typeof e.htonl<"u","missing Wasm export: htonl"),h(typeof e.htons<"u","missing Wasm export: htons"),h(typeof e.emscripten_stack_get_end<"u","missing Wasm export: emscripten_stack_get_end"),h(typeof e.emscripten_stack_get_base<"u","missing Wasm export: emscripten_stack_get_base"),h(typeof e.ntohs<"u","missing Wasm export: ntohs"),h(typeof e._emscripten_run_js_on_main_thread_done<"u","missing Wasm export: _emscripten_run_js_on_main_thread_done"),h(typeof e._emscripten_run_js_on_main_thread<"u","missing Wasm export: _emscripten_run_js_on_main_thread"),h(typeof e._emscripten_thread_free_data<"u","missing Wasm export: _emscripten_thread_free_data"),h(typeof e._emscripten_thread_exit<"u","missing Wasm export: _emscripten_thread_exit"),h(typeof e._emscripten_check_mailbox<"u","missing Wasm export: _emscripten_check_mailbox"),h(typeof e.setThrew<"u","missing Wasm export: setThrew"),h(typeof e.emscripten_stack_init<"u","missing Wasm export: emscripten_stack_init"),h(typeof e.emscripten_stack_set_limits<"u","missing Wasm export: emscripten_stack_set_limits"),h(typeof e.emscripten_stack_get_free<"u","missing Wasm export: emscripten_stack_get_free"),h(typeof e._emscripten_stack_restore<"u","missing Wasm export: _emscripten_stack_restore"),h(typeof e._emscripten_stack_alloc<"u","missing Wasm export: _emscripten_stack_alloc"),h(typeof e.emscripten_stack_get_current<"u","missing Wasm export: emscripten_stack_get_current"),h(typeof e.__cxa_decrement_exception_refcount<"u","missing Wasm export: __cxa_decrement_exception_refcount"),h(typeof e.__cxa_get_exception_ptr<"u","missing Wasm export: __cxa_get_exception_ptr"),h(typeof e.__indirect_function_table<"u","missing Wasm export: __indirect_function_table"),zn=J("__getTypeName",1),Vn=J("_embind_initialize_bindings",0),Je=f._malloc=J("malloc",1),ve=f._free=J("free",1),De=e.pthread_self,qn=J("strerror",1),Xo=J("_emscripten_tls_init",0),ot=J("_emscripten_thread_init",6),Kn=J("__set_thread_state",4),Xn=J("_emscripten_thread_crashed",0),st=J("fflush",1),Ze=J("htonl",1),Fr=J("htons",1),lt=e.emscripten_stack_get_end,Yo=e.emscripten_stack_get_base,dt=J("ntohs",1),Yn=J("_emscripten_run_js_on_main_thread_done",3),Jn=J("_emscripten_run_js_on_main_thread",5),Zn=J("_emscripten_thread_free_data",1),ct=J("_emscripten_thread_exit",1),Qn=J("_emscripten_check_mailbox",0),U=J("setThrew",2),ei=e.emscripten_stack_init,ri=e.emscripten_stack_set_limits,Jo=e.emscripten_stack_get_free,ti=e._emscripten_stack_restore,ni=e._emscripten_stack_alloc,ut=e.emscripten_stack_get_current,ii=J("__cxa_decrement_exception_refcount",1),ai=J("__cxa_get_exception_ptr",1),Zo=ft=e.__indirect_function_table}var _t;function es(){_t={__assert_fail:Ni,__cxa_begin_catch:Mi,__cxa_end_catch:xi,__cxa_find_matching_catch_2:Li,__cxa_find_matching_catch_3:Wi,__cxa_find_matching_catch_4:Ui,__cxa_throw:ji,__pthread_create_js:Kt,__resumeException:Hi,__syscall_connect:rn,__syscall_dup:tn,__syscall_fcntl64:nn,__syscall_getcwd:an,__syscall_ioctl:on,__syscall_openat:sn,__syscall_readlinkat:ln,__syscall_recvfrom:un,__syscall_rmdir:fn,__syscall_sendto:_n,__syscall_socket:hn,__syscall_unlinkat:vn,_abort_js:Qi,_embind_finalize_value_object:ra,_embind_register_bigint:na,_embind_register_bool:ia,_embind_register_class:Ea,_embind_register_class_class_function:Ta,_embind_register_class_constructor:Fa,_embind_register_class_function:Pa,_embind_register_class_property:Ca,_embind_register_emval:Aa,_embind_register_enum:Da,_embind_register_enum_value:Ra,_embind_register_float:$a,_embind_register_function:Na,_embind_register_integer:Ma,_embind_register_iterable:La,_embind_register_memory_view:Wa,_embind_register_optional:ja,_embind_register_std_string:Ba,_embind_register_std_wstring:Xa,_embind_register_value_object:Ya,_embind_register_value_object_field:Ja,_embind_register_void:Za,_emjs_array_view:Ko,_emjs_call_reject:qo,_emjs_call_resolve:Vo,_emjs_make_deferred:zo,_emscripten_init_main_thread_js:Qa,_emscripten_notify_mailbox_postmessage:ro,_emscripten_receive_on_main_thread_js:to,_emscripten_thread_cleanup:no,_emscripten_thread_mailbox_await:nt,_emscripten_thread_set_strongref:io,_emval_array_to_memory_view:ao,_emval_create_invoker:uo,_emval_decref:rt,_emval_get_property:fo,_emval_incref:_o,_emval_invoke:Nn,_emval_invoke_i64:ho,_emval_new_cstring:vo,_emval_run_destructors:po,_tzset_js:mo,clock_time_get:So,emscripten_check_blocking_allowed:ko,emscripten_err:To,emscripten_exit_with_live_runtime:Po,emscripten_get_now:Mn,emscripten_resize_heap:Do,environ_get:Ln,environ_sizes_get:Wn,exit:Lr,fd_close:Un,fd_read:jn,fd_seek:Bn,fd_write:Hn,getaddrinfo:Gn,invoke_i:ys,invoke_ii:rs,invoke_iii:ts,invoke_iiii:hs,invoke_iiiii:gs,invoke_iiij:cs,invoke_iiijjj:Fs,invoke_iij:ss,invoke_iiji:is,invoke_iijiiiiiii:os,invoke_ji:bs,invoke_jiii:ks,invoke_jiiiijijii:Ps,invoke_v:ws,invoke_vi:us,invoke_vii:ds,invoke_viii:ns,invoke_viiii:ms,invoke_viiiii:ps,invoke_viiiiii:Ts,invoke_viiiiijijii:Cs,invoke_viiiijijii:Es,invoke_viij:Ss,invoke_viijii:fs,invoke_vij:as,invoke_viji:vs,invoke_vijj:ls,invoke_vijjii:_s,llvm_eh_typeid_for:No,memory:fe,random_get:Mo}}function rs(e,r){var t=B();try{return W(e)(r)}catch(n){if(L(t),!(n instanceof j))throw n;U(1,0)}}function ts(e,r,t){var n=B();try{return W(e)(r,t)}catch(i){if(L(n),!(i instanceof j))throw i;U(1,0)}}function ns(e,r,t,n){var i=B();try{W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function is(e,r,t,n){var i=B();try{return W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function as(e,r,t){var n=B();try{W(e)(r,t)}catch(i){if(L(n),!(i instanceof j))throw i;U(1,0)}}function os(e,r,t,n,i,a,s,l,d,u){var _=B();try{return W(e)(r,t,n,i,a,s,l,d,u)}catch(p){if(L(_),!(p instanceof j))throw p;U(1,0)}}function ss(e,r,t){var n=B();try{return W(e)(r,t)}catch(i){if(L(n),!(i instanceof j))throw i;U(1,0)}}function ls(e,r,t,n){var i=B();try{W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function ds(e,r,t){var n=B();try{W(e)(r,t)}catch(i){if(L(n),!(i instanceof j))throw i;U(1,0)}}function cs(e,r,t,n){var i=B();try{return W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function us(e,r){var t=B();try{W(e)(r)}catch(n){if(L(t),!(n instanceof j))throw n;U(1,0)}}function fs(e,r,t,n,i,a){var s=B();try{W(e)(r,t,n,i,a)}catch(l){if(L(s),!(l instanceof j))throw l;U(1,0)}}function _s(e,r,t,n,i,a){var s=B();try{W(e)(r,t,n,i,a)}catch(l){if(L(s),!(l instanceof j))throw l;U(1,0)}}function hs(e,r,t,n){var i=B();try{return W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function vs(e,r,t,n){var i=B();try{W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function ps(e,r,t,n,i,a){var s=B();try{W(e)(r,t,n,i,a)}catch(l){if(L(s),!(l instanceof j))throw l;U(1,0)}}function ms(e,r,t,n,i){var a=B();try{W(e)(r,t,n,i)}catch(s){if(L(a),!(s instanceof j))throw s;U(1,0)}}function gs(e,r,t,n,i){var a=B();try{return W(e)(r,t,n,i)}catch(s){if(L(a),!(s instanceof j))throw s;U(1,0)}}function ys(e){var r=B();try{return W(e)()}catch(t){if(L(r),!(t instanceof j))throw t;U(1,0)}}function ws(e){var r=B();try{W(e)()}catch(t){if(L(r),!(t instanceof j))throw t;U(1,0)}}function Es(e,r,t,n,i,a,s,l,d,u){var _=B();try{W(e)(r,t,n,i,a,s,l,d,u)}catch(p){if(L(_),!(p instanceof j))throw p;U(1,0)}}function bs(e,r){var t=B();try{return W(e)(r)}catch(n){if(L(t),!(n instanceof j))throw n;return U(1,0),0n}}function Ss(e,r,t,n){var i=B();try{W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function ks(e,r,t,n){var i=B();try{return W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;return U(1,0),0n}}function Ts(e,r,t,n,i,a,s){var l=B();try{W(e)(r,t,n,i,a,s)}catch(d){if(L(l),!(d instanceof j))throw d;U(1,0)}}function Fs(e,r,t,n,i,a){var s=B();try{return W(e)(r,t,n,i,a)}catch(l){if(L(s),!(l instanceof j))throw l;U(1,0)}}function Ps(e,r,t,n,i,a,s,l,d,u){var _=B();try{return W(e)(r,t,n,i,a,s,l,d,u)}catch(p){if(L(_),!(p instanceof j))throw p;return U(1,0),0n}}function Cs(e,r,t,n,i,a,s,l,d,u,_){var p=B();try{W(e)(r,t,n,i,a,s,l,d,u,_)}catch(m){if(L(p),!(m instanceof j))throw m;U(1,0)}}var oi;function As(){h(!w),ei(),Et()}function Pr(){if(Te>0){ze=Pr;return}if(w){Rr?.(f),Pt();return}if(As(),bi(),Te>0){ze=Pr;return}function e(){h(!oi),oi=!0,f.calledRun=!0,!Ie&&(Pt(),Rr?.(f),f.onRuntimeInitialized?.(),ir("onRuntimeInitialized"),h(!f._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),Si())}f.setStatus?(f.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>f.setStatus(""),1),e()},1)):e(),Ge()}function Os(){var e=ge,r=C,t=!1;ge=C=d=>{t=!0};try{st(0);for(var n of["stdout","stderr"]){var i=o.analyzePath("/dev/"+n);if(!i)return;var a=i.object,s=a.rdev,l=pe.ttys[s];l?.output?.length&&(t=!0)}}catch{}ge=e,C=r,t&&Fe("stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.")}var Re;w||(Re=await At(),Pr()),Ne?v=f:v=new Promise((e,r)=>{Rr=e,Ir=r});for(let e of Object.keys(f))e in ee||Object.defineProperty(ee,e,{configurable:!0,get(){q(`Access to module property ('${e}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)}});return v}var li=si,di=globalThis.name?.startsWith("em-pthread"),Ds=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";Ds&&(di=(await import("node:worker_threads")).workerData==="em-pthread");di&&si();var Q=class ee{static LibE57=null;static RootDir="/root ";static Init(){let v=typeof window<"u";return ee.LibE57!==null?Promise.resolve():li().then(function(f){v||(f.FS.mkdir(ee.RootDir),f.FS.mount(f.FS.filesystems.NODEFS,{root:"/"},ee.RootDir)),ee.LibE57=f})}};import ht from"path";import Rs from"fs";var vt=class{constructor(v,f){this.e57Reader=v,this.scanIdx=f,this._header=null}GetHeader(){return this._header||(this._header=this.e57Reader.GetData3DHeader(this.scanIdx)),this._header}Destroy(){this._header&&this._header.delete()}ReadScan(v=!0){return this.ReadPoints(Number(this.GetHeader().pointCount),v)}ReadScanSync(v=!0){let f=Number(this.GetHeader().pointCount);return this.ReadPointsSync(f,v)}ReadPoints(v,f=!0){return this.e57Reader.ReadScan(this.scanIdx,v,f)}ReadPointsSync(v,f=!0){return this.e57Reader.ReadScanSync(this.scanIdx,v,f)}ScanPoints(v,f,O=!0){let N=Number(this.GetHeader().pointCount),M=Math.ceil(N/v);if(f){for(let w=0;w<M;w++){let le=this.ReadPointsSync(v,O);f(le),le.delete()}return}let me=[];for(let w=0;w<M;w++)me.push(this.ReadPointsSync(v,O));return me}},pt=class{constructor(v,f){this._e57Reader=v,this._imageIdx=f,this._header=null}GetHeader(){return this._header||(this._header=this._e57Reader.GetImage2DHeader(this._imageIdx)),this._header}Destroy(){this._header&&this._header.delete()}ReadImage(){return this._e57Reader.ReadImage(this._imageIdx)}ReadImageSync(){return this._e57Reader.ReadImageSync(this._imageIdx)}Release(v){v&&typeof v.free=="function"&&v.free()}ToBase64(){return this.ReadImage().then(v=>{let f=Buffer.from(v).toString("base64");return this.Release(v),f})}Extension(){switch(this.GetHeader().imageType){case Q.LibE57.Image2DType.ImageJPEG:return".jpeg";case Q.LibE57.Image2DType.ImagePNG:return".png";case Q.LibE57.Image2DType.ImageMaskPNG:return".png";case Q.LibE57.Image2DType.E57_JPEG_IMAGE:return".jpeg";case Q.LibE57.Image2DType.E57_PNG_IMAGE:return".png";case Q.LibE57.Image2DType.E57_PNG_IMAGE_MASK:return".png";default:return".jpg"}}Save(v){if(typeof window<"u")throw new Error("Save() is not available in the browser \u2014 use ReadImage() to get a Uint8Array instead");let f=this.Extension(),O=v.replace(ht.extname(v),f);return this.ReadImage().then(N=>Rs.promises.writeFile(O,N).then(()=>{this.Release(N)}))}},ci=class ee{constructor(v,f=!1){let O=f?v:ht.join(Q.RootDir,ht.resolve(v));this._reader=new Q.LibE57.E57Reader(O);var N=this.GetData3DCount();this.scans=new Array(N);for(var M=0;M<N;M++)this.scans[M]=new vt(this._reader,M);var me=this.GetImage2DCount();this.images=new Array(me);for(var w=0;w<me;w++)this.images[w]=new pt(this._reader,w)}static FromBuffer(v){let f="/"+crypto.randomUUID()+".e57";Q.LibE57.FS.writeFile(f,v);let O=new ee(f,!0);return O._memFsFilePath=f,O}GetHeader(){return this._reader.GetHeader()}GetData3DCount(){return Number(this._reader.GetData3DCount())}GetImage2DCount(){return Number(this._reader.GetImage2DCount())}GetScan(v){return this.scans[v]}GetImage(v){return this.images[v]}Close(){for(let v of this.scans)v.Destroy();for(let v of this.images)v.Destroy();this._reader&&(this._reader.Close(),this._reader.delete()),this._memFsFilePath&&Q.LibE57.FS.unlink(this._memFsFilePath),this.scans=null,this.images=null}};import ui from"path";import fi from"fs";import Is from"sharp";var _i=class ee{constructor(v,f,O){this._imgPath=v,this._imgType=f,this._imgProjection=O,this._imageHeader=new Q.LibE57.ImageHeader}static FromBuffer(v,f,O){let N=new ee(null,f,O);return N._buffer=v,N._width=null,N._height=null,N}GetPath(){return this._imgPath}SetPath(v){this._imgPath=v}GetType(){return this._imgType}SetType(v){this._imgType=v}GetProjection(){return this._imgProjection}SetProjection(v){this._imgProjection=v}_resolveMetadata(){return this._width!=null&&this._height!=null?Promise.resolve({width:this._width,height:this._height}):this._metadataPromise?this._metadataPromise:(typeof window<"u"?this._metadataPromise=this.GetBuffer().then(v=>{let f=new Blob([v]);return createImageBitmap(f).then(O=>{let N={width:O.width,height:O.height};return O.close(),this._width=N.width,this._height=N.height,N})}):this._metadataPromise=this.GetBuffer().then(v=>Is(v).metadata()).then(v=>(this._width=v.width,this._height=v.height,v)),this._metadataPromise)}GetMetadata(){return this._resolveMetadata()}GetDimensions(){return this._resolveMetadata().then(v=>[v.width,v.height])}GetWidth(){return this._resolveMetadata().then(v=>v.width)}GetHeight(){return this._resolveMetadata().then(v=>v.height)}GetPose(){return this._imageHeader.pose}SetPose(v){this._imageHeader.pose=v}GetName(){return this._imageHeader.name}SetName(v){this._imageHeader.name=v}GetGuid(){return this._imageHeader.guid}SetGuid(v){this._imageHeader.guid=v}GetHeader(){return this._imageHeader}SetHeader(v){this._imageHeader.delete(),this._imageHeader=v}GetBufferSync(){return this._buffer?this._buffer:new Uint8Array(fi.readFileSync(this.GetPath()))}GetBuffer(){return this._buffer?Promise.resolve(this._buffer):fi.promises.readFile(this.GetPath()).then(v=>new Uint8Array(v))}SetTranslation(v,f,O){this._imageHeader.pose.translation.x=v,this._imageHeader.pose.translation.y=f,this._imageHeader.pose.translation.z=O}SetRotation(v,f,O,N){this._imageHeader.pose.rotation.w=v,this._imageHeader.pose.rotation.x=f,this._imageHeader.pose.rotation.y=O,this._imageHeader.pose.rotation.z=N}Destroy(){this._imageHeader.delete(),this._imageHeader=null,this._buffer=null}},hi=class{constructor(){this._header=new Q.LibE57.Data3D,this._points=[]}GetHeader(){return this._header}SetHeader(v){this._header&&this._header.delete(),this._header=v}GetPoints(){return this._points}AddPoint(v){this._points&&this._points.push(v)}Destroy(){this._header&&(this._header.delete(),this._header=null);for(let v of this._points)v&&v.delete();this._points=[]}},vi=class ee{constructor(v,f=!1){let O=crypto.randomUUID();this._bufferFileMemFSFilePath="/"+O+".e57";let N=f?this._bufferFileMemFSFilePath:ui.join(Q.RootDir,ui.resolve(v));this._writer=new Q.LibE57.E57Writer(N),this._toBuffer=f}static ToBuffer(){return new ee("",!0)}AddImage(v){return Promise.all([v.GetBuffer(),v.GetMetadata()]).then(([f,O])=>this._writer.AddImage(v.GetHeader(),v.GetType(),v.GetProjection(),0,f,f.length,O.width,O.height).then(Number))}AddScanSync(v){let f=v.GetHeader(),O=v.GetPoints();return Number(this._writer.AddScanSync(f,O))}AddScan(v){let f=v.GetHeader(),O=v.GetPoints();return this._writer.AddScan(f,O).then(Number)}Close(){if(this._writer&&(this._writer.Close(),this._writer.delete()),this._toBuffer){let v=Q.LibE57.FS.readFile(this._bufferFileMemFSFilePath);return Q.LibE57.FS.unlink(this._bufferFileMemFSFilePath),v}}};export{Q as E57,ci as E57Reader,pt as E57ReaderImage,vt as E57ReaderScan,vi as E57Writer,_i as E57WriterImage,hi as E57WriterScan};
|
|
22
|
+
}`;var p=new Function(Object.keys(d),_)(...Object.values(d)),m=`methodCaller<(${a.map(g=>g.name)}) => ${i.name}>`;return so(wr(m,p))},_o=(e,r)=>(e=re.toValue(e),r=re.toValue(r),re.toHandle(e[r])),ho=e=>{e>9&&(ue[e+1]+=1)},Mn=(e,r,t,n,i)=>at[e](r,t,n,i),vo=(e,r,t,n,i)=>Mn(e,r,t,n,i),po=e=>re.toHandle(Nn(e)),mo=e=>{var r=re.toValue(e);hr(r),tt(e)},go=(e,r,t,n)=>{var i=new Date().getFullYear(),a=new Date(i,0,1),s=new Date(i,6,1),l=a.getTimezoneOffset(),d=s.getTimezoneOffset(),u=Math.max(l,d);(c(),y)[e>>2]=u*60,(c(),S)[r>>2]=+(l!=d);var _=g=>{var E=g>=0?"-":"+",k=Math.abs(g),D=String(Math.floor(k/60)).padStart(2,"0"),R=String(k%60).padStart(2,"0");return`UTC${E}${D}${R}`},p=_(l),m=_(d);h(p),h(m),h(Pe(p)<=16,`timezone name truncated to fit in TZNAME_MAX (${p})`),h(Pe(m)<=16,`timezone name truncated to fit in TZNAME_MAX (${m})`),d<l?(Ee(p,t,17),Ee(m,n,17)):(Ee(p,n,17),Ee(m,t,17))},xn=()=>performance.timeOrigin+performance.now(),yo=()=>Date.now(),wo=1,Eo=e=>e>=0&&e<=3,bo=9007199254740992,So=-9007199254740992,Ln=e=>e<So||e>bo?NaN:Number(e);function ko(e,r,t){if(r=Ln(r),!Eo(e))return 28;var n;if(e===0)n=yo();else if(wo)n=xn();else return 52;var i=Math.round(n*1e3*1e3);return(c(),Z)[t>>3]=BigInt(i),0}var To=()=>{M||N||Fe("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")},Fo=e=>C(_e(e)),Po=()=>{lr+=1},Co=()=>{throw Po(),"unwind"},Ao=()=>2147483648,Oo=(e,r)=>(h(r,"alignment argument is required"),Math.ceil(e/r)*r),Do=e=>{var r=fe.buffer.byteLength,t=(e-r+65535)/65536|0;try{return fe.grow(t),or(),1}catch(n){C(`growMemory: Attempted to grow heap from ${r} bytes to ${e} bytes, but got error: ${n}`)}},Ro=e=>{var r=(c(),te).length;if(e>>>=0,e<=r)return!1;var t=Ao();if(e>t)return C(`Cannot enlarge memory, requested ${e} bytes, but the limit is ${t} bytes!`),!1;for(var n=1;n<=4;n*=2){var i=r*(1+.2/n);i=Math.min(i,e+100663296);var a=Math.min(t,Oo(Math.max(e,i),65536)),s=Do(a);if(s)return!0}return C(`Failed to grow the heap from ${r} bytes to ${a} bytes, not enough memory!`),!1},ot={},Io=()=>Ar||"./this.program",Je=()=>{if(!Je.strings){var e=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Io()};for(var t in ot)ot[t]===void 0?delete r[t]:r[t]=ot[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);Je.strings=n}return Je.strings};function Wn(e,r){if(w)return K(15,0,1,e,r);var t=0,n=0;for(var i of Je()){var a=r+t;(c(),y)[e+n>>2]=a,t+=Ee(i,a,1/0)+1,n+=4}return 0}function Un(e,r){if(w)return K(16,0,1,e,r);var t=Je();(c(),y)[e>>2]=t.length;var n=0;for(var i of t)n+=Pe(i)+1;return(c(),y)[r>>2]=n,0}function jn(e){if(w)return K(17,0,1,e);try{var r=X.getStreamFromFD(e);return o.close(r),0}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var $o=(e,r,t,n)=>{for(var i=0,a=0;a<t;a++){var s=(c(),y)[r>>2],l=(c(),y)[r+4>>2];r+=8;var d=o.read(e,(c(),H),s,l,n);if(d<0)return-1;if(i+=d,d<l)break;typeof n<"u"&&(n+=d)}return i};function Bn(e,r,t,n){if(w)return K(18,0,1,e,r,t,n);try{var i=X.getStreamFromFD(e),a=$o(i,r,t);return(c(),y)[n>>2]=a,0}catch(s){if(typeof o>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function Hn(e,r,t,n){if(w)return K(19,0,1,e,r,t,n);r=Ln(r);try{if(isNaN(r))return 22;var i=X.getStreamFromFD(e);return o.llseek(i,r,t),(c(),Z)[n>>3]=BigInt(i.position),i.getdents&&r===0&&t===0&&(i.getdents=null),0}catch(a){if(typeof o>"u"||a.name!=="ErrnoError")throw a;return a.errno}}var No=(e,r,t,n)=>{for(var i=0,a=0;a<t;a++){var s=(c(),y)[r>>2],l=(c(),y)[r+4>>2];r+=8;var d=o.write(e,(c(),H),s,l,n);if(d<0)return-1;if(i+=d,d<l)break;typeof n<"u"&&(n+=d)}return i};function Gn(e,r,t,n){if(w)return K(20,0,1,e,r,t,n);try{var i=X.getStreamFromFD(e),a=No(i,r,t);return(c(),y)[n>>2]=a,0}catch(s){if(typeof o>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function zn(e,r,t,n){if(w)return K(21,0,1,e,r,t,n);var i=[],a=null,s=0,l=0,d=0,u=0,_=0,p=0,m,g;function E(k,D,R,G,z,oe){var de,V,se,er;return V=k===10?28:16,z=k===10?en(z):Yr(z),de=Ze(V),er=un(de,k,z,oe),h(!er),se=Ze(32),(c(),S)[se+4>>2]=k,(c(),S)[se+8>>2]=D,(c(),S)[se+12>>2]=R,(c(),y)[se+24>>2]=G,(c(),y)[se+20>>2]=de,k===10?(c(),S)[se+16>>2]=28:(c(),S)[se+16>>2]=16,(c(),S)[se+28>>2]=0,se}if(t&&(d=(c(),S)[t>>2],u=(c(),S)[t+4>>2],_=(c(),S)[t+8>>2],p=(c(),S)[t+12>>2]),_&&!p&&(p=_===2?17:6),!_&&p&&(_=p===17?2:1),p===0&&(p=6),_===0&&(_=1),!e&&!r)return-2;if(d&-1088||t!==0&&(c(),S)[t>>2]&2&&!e)return-1;if(d&32)return-2;if(_!==0&&_!==1&&_!==2)return-7;if(u!==0&&u!==2&&u!==10)return-6;if(r&&(r=_e(r),l=parseInt(r,10),isNaN(l)))return d&1024?-2:-8;if(!e)return u===0&&(u=2),(d&1)===0&&(u===2?s=Qe(2130706433):s=[0,0,0,Qe(1)]),m=E(u,_,p,null,s,l),(c(),y)[n>>2]=m,0;if(e=_e(e),s=ur(e),s!==null)if(u===0||u===2)u=2;else if(u===10&&d&8)s=[0,0,Qe(65535),s],u=10;else return-2;else if(s=Jr(e),s!==null)if(u===0||u===10)u=10;else return-2;return s!=null?(m=E(u,_,p,e,s,l),(c(),y)[n>>2]=m,0):d&4?-2:(e=he.lookup_name(e),s=ur(e),u===0?u=2:u===10&&(s=[0,0,Qe(65535),s]),m=E(u,_,p,null,s,l),(c(),y)[n>>2]=m,0)}var Mo=e=>e,xo=(e,r)=>Hr((c(),te).subarray(e,e+r)),Lo=(...e)=>o.createPath(...e),Wo=(...e)=>o.unlink(...e),Uo=(...e)=>o.createLazyFile(...e),jo=(...e)=>o.createDevice(...e);P.init(),o.createPreloadedFile=Zi,o.preloadFile=Kr,o.staticInit(),M&&b.staticInit(),fa(),wa(),h(ue.length===10);{if(bi(),f.noExitRuntime&&(Ur=f.noExitRuntime),f.preloadPlugins&&(Qt=f.preloadPlugins),f.print&&(ge=f.print),f.printErr&&(C=f.printErr),f.wasmBinary&&(Ge=f.wasmBinary),zo(),f.arguments&&(gt=f.arguments),f.thisProgram&&(Ar=f.thisProgram),h(typeof f.memoryInitializerPrefixURL>"u","Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),h(typeof f.pthreadMainPrefixURL>"u","Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),h(typeof f.cdInitializerPrefixURL>"u","Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),h(typeof f.filePackagePrefixURL>"u","Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),h(typeof f.read>"u","Module.read option was removed"),h(typeof f.readAsync>"u","Module.readAsync option was removed (modify readAsync in JS)"),h(typeof f.readBinary>"u","Module.readBinary option was removed (modify readBinary in JS)"),h(typeof f.setWindowTitle>"u","Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),h(typeof f.TOTAL_MEMORY>"u","Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),h(typeof f.ENVIRONMENT>"u","Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)"),h(typeof f.STACK_SIZE>"u","STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),f.preInit)for(typeof f.preInit=="function"&&(f.preInit=[f.preInit]);f.preInit.length>0;)f.preInit.shift()();ar("preInit")}f.addRunDependency=Lr,f.removeRunDependency=xr,f.FS_preloadFile=Kr,f.FS_unlink=Wo,f.FS_createPath=Lo,f.FS_createDevice=jo,f.FS=o,f.FS_createDataFile=Zt,f.FS_createLazyFile=Uo;var Bo=["writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getTempRet0","setTempRet0","withStackSave","readEmAsmArgs","jstoi_q","autoResumeAudioContext","getDynCaller","dynCall","runtimeKeepalivePop","asmjsMangle","HandleAllocator","addOnInit","addOnPostCtor","addOnPreMain","addOnExit","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","ccall","cwrap","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","getFunctionAddress","addFunction","removeFunction","intArrayToString","stringToAscii","stringToNewUTF8","stringToUTF8OnStack","writeArrayToMemory","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","registerBatteryEventCallback","setCanvasElementSizeCallingThread","setCanvasElementSizeMainThread","setCanvasElementSize","getCanvasSizeCallingThread","getCanvasSizeMainThread","getCanvasElementSize","jsStackTrace","getCallstack","convertPCtoSourceLocation","wasiRightsToMuslOFlags","wasiOFlagsToMuslOFlags","safeSetTimeout","setImmediateWrapped","safeRequestAnimationFrame","clearImmediateWrapped","registerPostMainLoop","registerPreMainLoop","getPromise","makePromise","idsToPromises","makePromiseCallback","incrementUncaughtExceptionCount","decrementUncaughtExceptionCount","Browser_asyncPrepareDataCounter","isLeapYear","ydayFromDate","arraySum","addDays","FS_mkdirTree","_setNetworkCallback","heapObjectForWebGLType","toTypedArrayIndex","webgl_enable_ANGLE_instanced_arrays","webgl_enable_OES_vertex_array_object","webgl_enable_WEBGL_draw_buffers","webgl_enable_WEBGL_multi_draw","webgl_enable_EXT_polygon_offset_clamp","webgl_enable_EXT_clip_control","webgl_enable_WEBGL_polygon_mode","emscriptenWebGLGet","computeUnpackAlignedImageSize","colorChannelsInGlTextureFormat","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","__glGetActiveAttribOrUniform","writeGLArray","emscripten_webgl_destroy_context_before_on_calling_thread","registerWebGlEventCallback","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate","writeStringToMemory","writeAsciiToMemory","allocateUTF8","allocateUTF8OnStack","demangle","stackTrace","getNativeTypeSize","getFunctionArgsName","createJsInvokerSignature","PureVirtualError","registerInheritedInstance","unregisterInheritedInstance","getInheritedInstanceCount","getLiveInheritedInstances","setDelayFunction","count_emval_handles"];Bo.forEach(wi);var Ho=["run","out","err","callMain","abort","wasmExports","writeStackCookie","checkStackCookie","INT53_MAX","INT53_MIN","bigintToI53Checked","HEAP8","HEAP16","HEAPU16","HEAP32","HEAPU32","HEAPF32","HEAPF64","HEAP64","HEAPU64","stackSave","stackRestore","stackAlloc","createNamedFunction","ptrToString","zeroMemory","exitJS","getHeapMax","growMemory","ENV","ERRNO_CODES","strError","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","DNS","Protocols","Sockets","timers","warnOnce","readEmAsmArgsArray","getExecutableName","handleException","keepRuntimeAlive","runtimeKeepalivePush","callUserCallback","maybeExit","asyncLoad","alignMemory","mmapAlloc","wasmTable","wasmMemory","getUniqueRunDependency","noExitRuntime","addOnPreRun","addOnPostRun","freeTableIndexes","functionsInTableMap","setValue","getValue","PATH","PATH_FS","UTF8Decoder","UTF8ArrayToString","UTF8ToString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","intArrayFromString","AsciiToString","UTF16Decoder","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","JSEvents","specialHTMLTargets","findCanvasEventTarget","currentFullscreenStrategy","restoreOldWindowedStyle","UNWIND_CACHE","ExitStatus","getEnvStrings","checkWasiClock","doReadv","doWritev","initRandomFill","randomFill","emSetImmediate","emClearImmediate_deps","emClearImmediate","promiseMap","uncaughtExceptionCount","exceptionCaught","ExceptionInfo","findMatchingCatch","Browser","requestFullscreen","requestFullScreen","setCanvasSize","getUserMedia","createContext","getPreloadedImageData__data","wget","MONTH_DAYS_REGULAR","MONTH_DAYS_LEAP","MONTH_DAYS_REGULAR_CUMULATIVE","MONTH_DAYS_LEAP_CUMULATIVE","SYSCALLS","getSocketFromFD","getSocketAddress","preloadPlugins","FS_createPreloadedFile","FS_modeStringToFlags","FS_getMode","FS_fileDataToTypedArray","FS_stdin_getChar_buffer","FS_stdin_getChar","FS_readFile","FS_root","FS_mounts","FS_devices","FS_streams","FS_nextInode","FS_nameTable","FS_currentPath","FS_initialized","FS_ignorePermissions","FS_filesystems","FS_syncFSRequests","FS_lookupPath","FS_getPath","FS_hashName","FS_hashAddNode","FS_hashRemoveNode","FS_lookupNode","FS_createNode","FS_destroyNode","FS_isRoot","FS_isMountpoint","FS_isFile","FS_isDir","FS_isLink","FS_isChrdev","FS_isBlkdev","FS_isFIFO","FS_isSocket","FS_flagsToPermissionString","FS_nodePermissions","FS_mayLookup","FS_mayCreate","FS_mayDelete","FS_mayOpen","FS_checkOpExists","FS_nextfd","FS_getStreamChecked","FS_getStream","FS_createStream","FS_closeStream","FS_dupStream","FS_doSetAttr","FS_chrdev_stream_ops","FS_major","FS_minor","FS_makedev","FS_registerDevice","FS_getDevice","FS_getMounts","FS_syncfs","FS_mount","FS_unmount","FS_lookup","FS_mknod","FS_statfs","FS_statfsStream","FS_statfsNode","FS_create","FS_mkdir","FS_mkdev","FS_symlink","FS_rename","FS_rmdir","FS_readdir","FS_readlink","FS_stat","FS_fstat","FS_lstat","FS_doChmod","FS_chmod","FS_lchmod","FS_fchmod","FS_doChown","FS_chown","FS_lchown","FS_fchown","FS_doTruncate","FS_truncate","FS_ftruncate","FS_utime","FS_open","FS_close","FS_isClosed","FS_llseek","FS_read","FS_write","FS_mmap","FS_msync","FS_ioctl","FS_writeFile","FS_cwd","FS_chdir","FS_createDefaultDirectories","FS_createDefaultDevices","FS_createSpecialDirectories","FS_createStandardStreams","FS_staticInit","FS_init","FS_quit","FS_findObject","FS_analyzePath","FS_createFile","FS_forceLoadFile","MEMFS","TTY","PIPEFS","SOCKFS","tempFixedLengthArray","miniTempWebGLFloatBuffers","miniTempWebGLIntBuffers","GL","AL","GLUT","EGL","GLEW","IDBStore","SDL","SDL_gfx","waitAsyncPolyfilled","print","printErr","jstoi_s","PThread","terminateWorker","cleanupThread","registerTLSInit","spawnThread","exitOnMainThread","proxyToMainThread","proxiedJSCallArgs","invokeEntryPoint","checkMailbox","InternalError","BindingError","throwInternalError","throwBindingError","registeredTypes","awaitingDependencies","typeDependencies","tupleRegistrations","structRegistrations","sharedRegisterType","whenDependentTypesAreResolved","getTypeName","getFunctionName","heap32VectorToArray","requireRegisteredType","usesDestructorStack","checkArgCount","getEnumValueType","getRequiredArgCount","createJsInvoker","UnboundTypeError","EmValType","EmValOptionalType","throwUnboundTypeError","ensureOverloadTable","exposePublicSymbol","replacePublicSymbol","embindRepr","registeredInstances","getBasestPointer","getInheritedInstance","registeredPointers","registerType","integerReadValueFromPointer","enumReadValueFromPointer","floatReadValueFromPointer","assertIntegerRange","readPointer","installIndexedIterator","runDestructors","craftInvokerFunction","embind__requireFunction","genericPointerToWireType","constNoSmartPtrRawPointerToWireType","nonConstNoSmartPtrRawPointerToWireType","init_RegisteredPointer","RegisteredPointer","RegisteredPointer_fromWireType","runDestructor","releaseClassHandle","finalizationRegistry","detachFinalizer_deps","detachFinalizer","attachFinalizer","makeClassHandle","init_ClassHandle","ClassHandle","throwInstanceAlreadyDeleted","deletionQueue","flushPendingDeletes","delayFunction","RegisteredClass","shallowCopyInternalPointer","downcastPointer","upcastPointer","validateThis","char_0","char_9","makeLegalFunctionName","emval_freelist","emval_handles","emval_symbols","getStringOrSymbol","Emval","emval_returnValue","emval_lookupTypes","emval_methodCallers","emval_addMethodCaller","NODEFS"];Ho.forEach(kt);var Go=[Wt,Ut,Kt,tn,nn,an,on,sn,ln,dn,fn,_n,hn,vn,pn,Wn,Un,jn,Bn,Hn,Gn,zn];function zo(){Se("fetchSettings"),Se("logReadFiles"),Se("loadSplitModule"),Se("onMalloc"),Se("onRealloc"),Se("onFree"),Se("onSbrkGrow")}function Vo(){var e,r,t=new Promise(function(n,i){e=n,r=i});return re.toHandle({promise:t,resolve:e,reject:r})}function qo(e,r){re.toValue(e)(re.toValue(r))}function Ko(e,r){re.toValue(e)(new Error(_e(r)))}function Xo(e,r,t){var n=(c(),te).subarray(e,e+r*t),i=!1;return n.free=function(){i||(i=!0,ve(e))},globalThis._e57Finalizer||(globalThis._e57Finalizer=new FinalizationRegistry(function(a){a()})),globalThis._e57Finalizer.register(n,n.free),re.toHandle(n)}var Vn=$("___getTypeName"),qn=$("__embind_initialize_bindings"),Ze=f._malloc=$("_malloc"),ve=f._free=$("_free"),De=$("_pthread_self"),Kn=$("_strerror"),Yo=$("__emscripten_tls_init"),st=$("__emscripten_thread_init"),Xn=$("___set_thread_state"),Yn=$("__emscripten_thread_crashed"),lt=$("_fflush"),Qe=$("_htonl"),Pr=$("_htons"),dt=$("_emscripten_stack_get_end"),Jo=$("_emscripten_stack_get_base"),ct=$("_ntohs"),Jn=$("__emscripten_run_js_on_main_thread_done"),Zn=$("__emscripten_run_js_on_main_thread"),Qn=$("__emscripten_thread_free_data"),ut=$("__emscripten_thread_exit"),ei=$("__emscripten_check_mailbox"),U=$("_setThrew"),ri=$("_emscripten_stack_init"),ti=$("_emscripten_stack_set_limits"),Zo=$("_emscripten_stack_get_free"),ni=$("__emscripten_stack_restore"),ii=$("__emscripten_stack_alloc"),ft=$("_emscripten_stack_get_current"),ai=$("___cxa_decrement_exception_refcount"),oi=$("___cxa_get_exception_ptr"),Qo=$("__indirect_function_table"),_t=$("wasmTable");function es(e){h(typeof e.__getTypeName<"u","missing Wasm export: __getTypeName"),h(typeof e._embind_initialize_bindings<"u","missing Wasm export: _embind_initialize_bindings"),h(typeof e.malloc<"u","missing Wasm export: malloc"),h(typeof e.free<"u","missing Wasm export: free"),h(typeof e.pthread_self<"u","missing Wasm export: pthread_self"),h(typeof e.strerror<"u","missing Wasm export: strerror"),h(typeof e._emscripten_tls_init<"u","missing Wasm export: _emscripten_tls_init"),h(typeof e._emscripten_thread_init<"u","missing Wasm export: _emscripten_thread_init"),h(typeof e.__set_thread_state<"u","missing Wasm export: __set_thread_state"),h(typeof e._emscripten_thread_crashed<"u","missing Wasm export: _emscripten_thread_crashed"),h(typeof e.fflush<"u","missing Wasm export: fflush"),h(typeof e.htonl<"u","missing Wasm export: htonl"),h(typeof e.htons<"u","missing Wasm export: htons"),h(typeof e.emscripten_stack_get_end<"u","missing Wasm export: emscripten_stack_get_end"),h(typeof e.emscripten_stack_get_base<"u","missing Wasm export: emscripten_stack_get_base"),h(typeof e.ntohs<"u","missing Wasm export: ntohs"),h(typeof e._emscripten_run_js_on_main_thread_done<"u","missing Wasm export: _emscripten_run_js_on_main_thread_done"),h(typeof e._emscripten_run_js_on_main_thread<"u","missing Wasm export: _emscripten_run_js_on_main_thread"),h(typeof e._emscripten_thread_free_data<"u","missing Wasm export: _emscripten_thread_free_data"),h(typeof e._emscripten_thread_exit<"u","missing Wasm export: _emscripten_thread_exit"),h(typeof e._emscripten_check_mailbox<"u","missing Wasm export: _emscripten_check_mailbox"),h(typeof e.setThrew<"u","missing Wasm export: setThrew"),h(typeof e.emscripten_stack_init<"u","missing Wasm export: emscripten_stack_init"),h(typeof e.emscripten_stack_set_limits<"u","missing Wasm export: emscripten_stack_set_limits"),h(typeof e.emscripten_stack_get_free<"u","missing Wasm export: emscripten_stack_get_free"),h(typeof e._emscripten_stack_restore<"u","missing Wasm export: _emscripten_stack_restore"),h(typeof e._emscripten_stack_alloc<"u","missing Wasm export: _emscripten_stack_alloc"),h(typeof e.emscripten_stack_get_current<"u","missing Wasm export: emscripten_stack_get_current"),h(typeof e.__cxa_decrement_exception_refcount<"u","missing Wasm export: __cxa_decrement_exception_refcount"),h(typeof e.__cxa_get_exception_ptr<"u","missing Wasm export: __cxa_get_exception_ptr"),h(typeof e.__indirect_function_table<"u","missing Wasm export: __indirect_function_table"),Vn=J("__getTypeName",1),qn=J("_embind_initialize_bindings",0),Ze=f._malloc=J("malloc",1),ve=f._free=J("free",1),De=e.pthread_self,Kn=J("strerror",1),Yo=J("_emscripten_tls_init",0),st=J("_emscripten_thread_init",6),Xn=J("__set_thread_state",4),Yn=J("_emscripten_thread_crashed",0),lt=J("fflush",1),Qe=J("htonl",1),Pr=J("htons",1),dt=e.emscripten_stack_get_end,Jo=e.emscripten_stack_get_base,ct=J("ntohs",1),Jn=J("_emscripten_run_js_on_main_thread_done",3),Zn=J("_emscripten_run_js_on_main_thread",5),Qn=J("_emscripten_thread_free_data",1),ut=J("_emscripten_thread_exit",1),ei=J("_emscripten_check_mailbox",0),U=J("setThrew",2),ri=e.emscripten_stack_init,ti=e.emscripten_stack_set_limits,Zo=e.emscripten_stack_get_free,ni=e._emscripten_stack_restore,ii=e._emscripten_stack_alloc,ft=e.emscripten_stack_get_current,ai=J("__cxa_decrement_exception_refcount",1),oi=J("__cxa_get_exception_ptr",1),Qo=_t=e.__indirect_function_table}var ht;function rs(){ht={__assert_fail:Mi,__cxa_begin_catch:xi,__cxa_end_catch:Li,__cxa_find_matching_catch_2:Wi,__cxa_find_matching_catch_3:Ui,__cxa_find_matching_catch_4:ji,__cxa_throw:Bi,__pthread_create_js:Xt,__resumeException:Gi,__syscall_connect:tn,__syscall_dup:nn,__syscall_fcntl64:an,__syscall_getcwd:on,__syscall_ioctl:sn,__syscall_openat:ln,__syscall_readlinkat:dn,__syscall_recvfrom:fn,__syscall_rmdir:_n,__syscall_sendto:hn,__syscall_socket:vn,__syscall_unlinkat:pn,_abort_js:ea,_embind_finalize_value_object:ta,_embind_register_bigint:ia,_embind_register_bool:aa,_embind_register_class:ba,_embind_register_class_class_function:Fa,_embind_register_class_constructor:Pa,_embind_register_class_function:Ca,_embind_register_class_property:Aa,_embind_register_emval:Oa,_embind_register_enum:Ra,_embind_register_enum_value:Ia,_embind_register_float:Na,_embind_register_function:Ma,_embind_register_integer:xa,_embind_register_iterable:Wa,_embind_register_memory_view:Ua,_embind_register_optional:Ba,_embind_register_std_string:Ha,_embind_register_std_wstring:Ya,_embind_register_value_object:Ja,_embind_register_value_object_field:Za,_embind_register_void:Qa,_emjs_array_view:Xo,_emjs_call_reject:Ko,_emjs_call_resolve:qo,_emjs_make_deferred:Vo,_emscripten_init_main_thread_js:eo,_emscripten_notify_mailbox_postmessage:to,_emscripten_receive_on_main_thread_js:no,_emscripten_thread_cleanup:io,_emscripten_thread_mailbox_await:it,_emscripten_thread_set_strongref:ao,_emval_array_to_memory_view:oo,_emval_create_invoker:fo,_emval_decref:tt,_emval_get_property:_o,_emval_incref:ho,_emval_invoke:Mn,_emval_invoke_i64:vo,_emval_new_cstring:po,_emval_run_destructors:mo,_tzset_js:go,clock_time_get:ko,emscripten_check_blocking_allowed:To,emscripten_err:Fo,emscripten_exit_with_live_runtime:Co,emscripten_get_now:xn,emscripten_resize_heap:Ro,environ_get:Wn,environ_sizes_get:Un,exit:Wr,fd_close:jn,fd_read:Bn,fd_seek:Hn,fd_write:Gn,getaddrinfo:zn,invoke_i:ws,invoke_ii:ts,invoke_iii:ns,invoke_iiii:vs,invoke_iiiii:ys,invoke_iiij:us,invoke_iiijjj:Ps,invoke_iij:ls,invoke_iiji:as,invoke_iijiiiiiii:ss,invoke_ji:Ss,invoke_jiii:Ts,invoke_jiiiijijii:Cs,invoke_v:Es,invoke_vi:fs,invoke_vii:cs,invoke_viii:is,invoke_viiii:gs,invoke_viiiii:ms,invoke_viiiiii:Fs,invoke_viiiiijijii:As,invoke_viiiijijii:bs,invoke_viij:ks,invoke_viijii:_s,invoke_vij:os,invoke_viji:ps,invoke_vijj:ds,invoke_vijjii:hs,llvm_eh_typeid_for:Mo,memory:fe,random_get:xo}}function ts(e,r){var t=B();try{return W(e)(r)}catch(n){if(L(t),!(n instanceof j))throw n;U(1,0)}}function ns(e,r,t){var n=B();try{return W(e)(r,t)}catch(i){if(L(n),!(i instanceof j))throw i;U(1,0)}}function is(e,r,t,n){var i=B();try{W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function as(e,r,t,n){var i=B();try{return W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function os(e,r,t){var n=B();try{W(e)(r,t)}catch(i){if(L(n),!(i instanceof j))throw i;U(1,0)}}function ss(e,r,t,n,i,a,s,l,d,u){var _=B();try{return W(e)(r,t,n,i,a,s,l,d,u)}catch(p){if(L(_),!(p instanceof j))throw p;U(1,0)}}function ls(e,r,t){var n=B();try{return W(e)(r,t)}catch(i){if(L(n),!(i instanceof j))throw i;U(1,0)}}function ds(e,r,t,n){var i=B();try{W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function cs(e,r,t){var n=B();try{W(e)(r,t)}catch(i){if(L(n),!(i instanceof j))throw i;U(1,0)}}function us(e,r,t,n){var i=B();try{return W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function fs(e,r){var t=B();try{W(e)(r)}catch(n){if(L(t),!(n instanceof j))throw n;U(1,0)}}function _s(e,r,t,n,i,a){var s=B();try{W(e)(r,t,n,i,a)}catch(l){if(L(s),!(l instanceof j))throw l;U(1,0)}}function hs(e,r,t,n,i,a){var s=B();try{W(e)(r,t,n,i,a)}catch(l){if(L(s),!(l instanceof j))throw l;U(1,0)}}function vs(e,r,t,n){var i=B();try{return W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function ps(e,r,t,n){var i=B();try{W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function ms(e,r,t,n,i,a){var s=B();try{W(e)(r,t,n,i,a)}catch(l){if(L(s),!(l instanceof j))throw l;U(1,0)}}function gs(e,r,t,n,i){var a=B();try{W(e)(r,t,n,i)}catch(s){if(L(a),!(s instanceof j))throw s;U(1,0)}}function ys(e,r,t,n,i){var a=B();try{return W(e)(r,t,n,i)}catch(s){if(L(a),!(s instanceof j))throw s;U(1,0)}}function ws(e){var r=B();try{return W(e)()}catch(t){if(L(r),!(t instanceof j))throw t;U(1,0)}}function Es(e){var r=B();try{W(e)()}catch(t){if(L(r),!(t instanceof j))throw t;U(1,0)}}function bs(e,r,t,n,i,a,s,l,d,u){var _=B();try{W(e)(r,t,n,i,a,s,l,d,u)}catch(p){if(L(_),!(p instanceof j))throw p;U(1,0)}}function Ss(e,r){var t=B();try{return W(e)(r)}catch(n){if(L(t),!(n instanceof j))throw n;return U(1,0),0n}}function ks(e,r,t,n){var i=B();try{W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function Ts(e,r,t,n){var i=B();try{return W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;return U(1,0),0n}}function Fs(e,r,t,n,i,a,s){var l=B();try{W(e)(r,t,n,i,a,s)}catch(d){if(L(l),!(d instanceof j))throw d;U(1,0)}}function Ps(e,r,t,n,i,a){var s=B();try{return W(e)(r,t,n,i,a)}catch(l){if(L(s),!(l instanceof j))throw l;U(1,0)}}function Cs(e,r,t,n,i,a,s,l,d,u){var _=B();try{return W(e)(r,t,n,i,a,s,l,d,u)}catch(p){if(L(_),!(p instanceof j))throw p;return U(1,0),0n}}function As(e,r,t,n,i,a,s,l,d,u,_){var p=B();try{W(e)(r,t,n,i,a,s,l,d,u,_)}catch(m){if(L(p),!(m instanceof j))throw m;U(1,0)}}var si;function Os(){h(!w),ri(),bt()}function Cr(){if(Te>0){Ve=Cr;return}if(w){Ir?.(f),Ct();return}if(Os(),Si(),Te>0){Ve=Cr;return}function e(){h(!si),si=!0,f.calledRun=!0,!Ie&&(Ct(),Ir?.(f),f.onRuntimeInitialized?.(),ar("onRuntimeInitialized"),h(!f._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),ki())}f.setStatus?(f.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>f.setStatus(""),1),e()},1)):e(),ze()}function Ds(){var e=ge,r=C,t=!1;ge=C=d=>{t=!0};try{lt(0);for(var n of["stdout","stderr"]){var i=o.analyzePath("/dev/"+n);if(!i)return;var a=i.object,s=a.rdev,l=pe.ttys[s];l?.output?.length&&(t=!0)}}catch{}ge=e,C=r,t&&Fe("stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.")}var Re;w||(Re=await Ot(),Cr()),Ne?v=f:v=new Promise((e,r)=>{Ir=e,$r=r});for(let e of Object.keys(f))e in Q||Object.defineProperty(Q,e,{configurable:!0,get(){q(`Access to module property ('${e}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)}});return v}var di=li,ci=globalThis.name?.startsWith("em-pthread"),Rs=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";Rs&&(ci=(await import("node:worker_threads")).workerData==="em-pthread");ci&&li();var ee=class Q{static LibE57=null;static RootDir="/root ";static Init(){let v=typeof window<"u";return Q.LibE57!==null?Promise.resolve():di().then(function(f){v||(f.FS.mkdir(Q.RootDir),f.FS.mount(f.FS.filesystems.NODEFS,{root:"/"},Q.RootDir)),Q.LibE57=f})}};var Is=typeof process<"u"&&!!process.versions?.node;function Be(Q){if(!Is)return Q;let v=setInterval(()=>{},1<<30);return Q.finally(()=>clearInterval(v))}import vt from"path";import $s from"fs";var pt=class{constructor(v,f){this.e57Reader=v,this.scanIdx=f,this._header=null}GetHeader(){return this._header||(this._header=this.e57Reader.GetData3DHeader(this.scanIdx)),this._header}Destroy(){this._header&&this._header.delete()}ReadScan(v=!0){return this.ReadPoints(Number(this.GetHeader().pointCount),v)}ReadScanSync(v=!0){let f=Number(this.GetHeader().pointCount);return this.ReadPointsSync(f,v)}ReadPoints(v,f=!0){return Be(this.e57Reader.ReadScan(this.scanIdx,v,f))}ReadPointsSync(v,f=!0){return this.e57Reader.ReadScanSync(this.scanIdx,v,f)}ScanPoints(v,f,O=!0){let N=Number(this.GetHeader().pointCount),M=Math.ceil(N/v);if(f){for(let w=0;w<M;w++){let le=this.ReadPointsSync(v,O);f(le),le.delete()}return}let me=[];for(let w=0;w<M;w++)me.push(this.ReadPointsSync(v,O));return me}},mt=class{constructor(v,f){this._e57Reader=v,this._imageIdx=f,this._header=null}GetHeader(){return this._header||(this._header=this._e57Reader.GetImage2DHeader(this._imageIdx)),this._header}Destroy(){this._header&&this._header.delete()}ReadImage(){return Be(this._e57Reader.ReadImage(this._imageIdx))}ReadImageSync(){return this._e57Reader.ReadImageSync(this._imageIdx)}Release(v){v&&typeof v.free=="function"&&v.free()}ToBase64(){return this.ReadImage().then(v=>{let f=Buffer.from(v).toString("base64");return this.Release(v),f})}Extension(){switch(this.GetHeader().imageType){case ee.LibE57.Image2DType.ImageJPEG:return".jpeg";case ee.LibE57.Image2DType.ImagePNG:return".png";case ee.LibE57.Image2DType.ImageMaskPNG:return".png";case ee.LibE57.Image2DType.E57_JPEG_IMAGE:return".jpeg";case ee.LibE57.Image2DType.E57_PNG_IMAGE:return".png";case ee.LibE57.Image2DType.E57_PNG_IMAGE_MASK:return".png";default:return".jpg"}}Save(v){if(typeof window<"u")throw new Error("Save() is not available in the browser \u2014 use ReadImage() to get a Uint8Array instead");let f=this.Extension(),O=v.replace(vt.extname(v),f);return this.ReadImage().then(N=>$s.promises.writeFile(O,N).then(()=>{this.Release(N)}))}},ui=class Q{constructor(v,f=!1){let O=f?v:vt.join(ee.RootDir,vt.resolve(v));this._reader=new ee.LibE57.E57Reader(O);var N=this.GetData3DCount();this.scans=new Array(N);for(var M=0;M<N;M++)this.scans[M]=new pt(this._reader,M);var me=this.GetImage2DCount();this.images=new Array(me);for(var w=0;w<me;w++)this.images[w]=new mt(this._reader,w)}static FromBuffer(v){let f="/"+crypto.randomUUID()+".e57";ee.LibE57.FS.writeFile(f,v);let O=new Q(f,!0);return O._memFsFilePath=f,O}GetHeader(){return this._reader.GetHeader()}GetData3DCount(){return Number(this._reader.GetData3DCount())}GetImage2DCount(){return Number(this._reader.GetImage2DCount())}GetScan(v){return this.scans[v]}GetImage(v){return this.images[v]}Close(){for(let v of this.scans)v.Destroy();for(let v of this.images)v.Destroy();this._reader&&(this._reader.Close(),this._reader.delete()),this._memFsFilePath&&ee.LibE57.FS.unlink(this._memFsFilePath),this.scans=null,this.images=null}};import fi from"path";import _i from"fs";import Ns from"sharp";var hi=class Q{constructor(v,f,O){this._imgPath=v,this._imgType=f,this._imgProjection=O,this._imageHeader=new ee.LibE57.ImageHeader}static FromBuffer(v,f,O){let N=new Q(null,f,O);return N._buffer=v,N._width=null,N._height=null,N}GetPath(){return this._imgPath}SetPath(v){this._imgPath=v}GetType(){return this._imgType}SetType(v){this._imgType=v}GetProjection(){return this._imgProjection}SetProjection(v){this._imgProjection=v}_resolveMetadata(){return this._width!=null&&this._height!=null?Promise.resolve({width:this._width,height:this._height}):this._metadataPromise?this._metadataPromise:(typeof window<"u"?this._metadataPromise=this.GetBuffer().then(v=>{let f=new Blob([v]);return createImageBitmap(f).then(O=>{let N={width:O.width,height:O.height};return O.close(),this._width=N.width,this._height=N.height,N})}):this._metadataPromise=this.GetBuffer().then(v=>Ns(v).metadata()).then(v=>(this._width=v.width,this._height=v.height,v)),this._metadataPromise)}GetMetadata(){return this._resolveMetadata()}GetDimensions(){return this._resolveMetadata().then(v=>[v.width,v.height])}GetWidth(){return this._resolveMetadata().then(v=>v.width)}GetHeight(){return this._resolveMetadata().then(v=>v.height)}GetPose(){return this._imageHeader.pose}SetPose(v){this._imageHeader.pose=v}GetName(){return this._imageHeader.name}SetName(v){this._imageHeader.name=v}GetGuid(){return this._imageHeader.guid}SetGuid(v){this._imageHeader.guid=v}GetHeader(){return this._imageHeader}SetHeader(v){this._imageHeader.delete(),this._imageHeader=v}GetBufferSync(){return this._buffer?this._buffer:new Uint8Array(_i.readFileSync(this.GetPath()))}GetBuffer(){return this._buffer?Promise.resolve(this._buffer):_i.promises.readFile(this.GetPath()).then(v=>new Uint8Array(v))}SetTranslation(v,f,O){this._imageHeader.pose.translation.x=v,this._imageHeader.pose.translation.y=f,this._imageHeader.pose.translation.z=O}SetRotation(v,f,O,N){this._imageHeader.pose.rotation.w=v,this._imageHeader.pose.rotation.x=f,this._imageHeader.pose.rotation.y=O,this._imageHeader.pose.rotation.z=N}Destroy(){this._imageHeader.delete(),this._imageHeader=null,this._buffer=null}},vi=class{constructor(){this._header=new ee.LibE57.Data3D,this._points=[]}GetHeader(){return this._header}SetHeader(v){this._header&&this._header.delete(),this._header=v}GetPoints(){return this._points}AddPoint(v){this._points&&this._points.push(v)}Destroy(){this._header&&(this._header.delete(),this._header=null);for(let v of this._points)v&&v.delete();this._points=[]}},pi=class Q{constructor(v,f=!1){let O=crypto.randomUUID();this._bufferFileMemFSFilePath="/"+O+".e57";let N=f?this._bufferFileMemFSFilePath:fi.join(ee.RootDir,fi.resolve(v));this._writer=new ee.LibE57.E57Writer(N),this._toBuffer=f}static ToBuffer(){return new Q("",!0)}AddImage(v){return Promise.all([v.GetBuffer(),v.GetMetadata()]).then(([f,O])=>Be(this._writer.AddImage(v.GetHeader(),v.GetType(),v.GetProjection(),0,f,f.length,O.width,O.height)).then(Number))}AddScanSync(v){let f=v.GetHeader(),O=v.GetPoints();return Number(this._writer.AddScanSync(f,O))}AddScan(v){let f=v.GetHeader(),O=v.GetPoints();return Be(this._writer.AddScan(f,O)).then(Number)}Close(){if(this._writer&&(this._writer.Close(),this._writer.delete()),this._toBuffer){let v=ee.LibE57.FS.readFile(this._bufferFileMemFSFilePath);return ee.LibE57.FS.unlink(this._bufferFileMemFSFilePath),v}}};export{ee as E57,ui as E57Reader,mt as E57ReaderImage,pt as E57ReaderScan,pi as E57Writer,hi as E57WriterImage,vi as E57WriterScan};
|