trtc-sdk-v5
Version:
Tencent Cloud RTC SDK for Web
3 lines • 111 kB
JavaScript
var $o=Object.create;var nn=Object.defineProperty,Lo=Object.defineProperties,To=Object.getOwnPropertyDescriptor,Mo=Object.getOwnPropertyDescriptors,Fo=Object.getOwnPropertyNames,_o=Object.getOwnPropertySymbols,Bo=Object.getPrototypeOf,bo=Object.prototype.hasOwnProperty,Ho=Object.prototype.propertyIsEnumerable;var so=(T,p,s)=>p in T?nn(T,p,{enumerable:!0,configurable:!0,writable:!0,value:s}):T[p]=s,br=(T,p)=>{for(var s in p||(p={}))bo.call(p,s)&&so(T,s,p[s]);if(_o)for(var s of _o(p))Ho.call(p,s)&&so(T,s,p[s]);return T},Er=(T,p)=>Lo(T,Mo(p));var Wo=(T,p)=>()=>(p||T((p={exports:{}}).exports,p),p.exports);var Vo=(T,p,s,v)=>{if(p&&typeof p=="object"||typeof p=="function")for(let S of Fo(p))!bo.call(T,S)&&S!==s&&nn(T,S,{get:()=>p[S],enumerable:!(v=To(p,S))||v.enumerable});return T};var jo=(T,p,s)=>(s=T!=null?$o(Bo(T)):{},Vo(p||!T||!T.__esModule?nn(s,"default",{value:T,enumerable:!0}):s,T));var Le=(T,p,s,v)=>{for(var S=v>1?void 0:v?To(p,s):p,I=T.length-1,A;I>=0;I--)(A=T[I])&&(S=(v?A(p,s,S):A(S))||S);return v&&S&&nn(p,s,S),S};var fe=(T,p,s)=>so(T,typeof p!="symbol"?p+"":p,s);var wo=Wo((ai,uo)=>{"use strict";var Go=Object.prototype.hasOwnProperty,be="~";function lt(){}Object.create&&(lt.prototype=Object.create(null),new lt().__proto__||(be=!1));function zo(T,p,s){this.fn=T,this.context=p,this.once=s||!1}function Eo(T,p,s,v,S){if(typeof s!="function")throw new TypeError("The listener must be a function");var I=new zo(s,v||T,S),A=be?be+p:p;return T._events[A]?T._events[A].fn?T._events[A]=[T._events[A],I]:T._events[A].push(I):(T._events[A]=I,T._eventsCount++),T}function on(T,p){--T._eventsCount===0?T._events=new lt:delete T._events[p]}function pe(){this._events=new lt,this._eventsCount=0}pe.prototype.eventNames=function(){var p=[],s,v;if(this._eventsCount===0)return p;for(v in s=this._events)Go.call(s,v)&&p.push(be?v.slice(1):v);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(s)):p};pe.prototype.listeners=function(p){var s=be?be+p:p,v=this._events[s];if(!v)return[];if(v.fn)return[v.fn];for(var S=0,I=v.length,A=new Array(I);S<I;S++)A[S]=v[S].fn;return A};pe.prototype.listenerCount=function(p){var s=be?be+p:p,v=this._events[s];return v?v.fn?1:v.length:0};pe.prototype.emit=function(p,s,v,S,I,A){var H=be?be+p:p;if(!this._events[H])return!1;var D=this._events[H],C=arguments.length,F,L;if(D.fn){switch(D.once&&this.removeListener(p,D.fn,void 0,!0),C){case 1:return D.fn.call(D.context),!0;case 2:return D.fn.call(D.context,s),!0;case 3:return D.fn.call(D.context,s,v),!0;case 4:return D.fn.call(D.context,s,v,S),!0;case 5:return D.fn.call(D.context,s,v,S,I),!0;case 6:return D.fn.call(D.context,s,v,S,I,A),!0}for(L=1,F=new Array(C-1);L<C;L++)F[L-1]=arguments[L];D.fn.apply(D.context,F)}else{var W=D.length,me;for(L=0;L<W;L++)switch(D[L].once&&this.removeListener(p,D[L].fn,void 0,!0),C){case 1:D[L].fn.call(D[L].context);break;case 2:D[L].fn.call(D[L].context,s);break;case 3:D[L].fn.call(D[L].context,s,v);break;case 4:D[L].fn.call(D[L].context,s,v,S);break;default:if(!F)for(me=1,F=new Array(C-1);me<C;me++)F[me-1]=arguments[me];D[L].fn.apply(D[L].context,F)}}return!0};pe.prototype.on=function(p,s,v){return Eo(this,p,s,v,!1)};pe.prototype.once=function(p,s,v){return Eo(this,p,s,v,!0)};pe.prototype.removeListener=function(p,s,v,S){var I=be?be+p:p;if(!this._events[I])return this;if(!s)return on(this,I),this;var A=this._events[I];if(A.fn)A.fn===s&&(!S||A.once)&&(!v||A.context===v)&&on(this,I);else{for(var H=0,D=[],C=A.length;H<C;H++)(A[H].fn!==s||S&&!A[H].once||v&&A[H].context!==v)&&D.push(A[H]);D.length?this._events[I]=D.length===1?D[0]:D:on(this,I)}return this};pe.prototype.removeAllListeners=function(p){var s;return p?(s=be?be+p:p,this._events[s]&&on(this,s)):(this._events=new lt,this._eventsCount=0),this};pe.prototype.off=pe.prototype.removeListener;pe.prototype.addListener=pe.prototype.on;pe.prefixed=be;pe.EventEmitter=pe;typeof uo!="undefined"&&(uo.exports=pe)});var Ao=jo(wo(),1),So=Symbol("instance"),si=Symbol("abortCtrl"),an=Symbol("cacheResult"),dt=class{constructor(p,s,v){this.oldState=p,this.newState=s,this.action=v,this.aborted=!1}abort(p){this.aborted=!0,pt.call(p,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}},Nr=class extends Error{constructor(p,s,v){super(s),this.state=p,this.message=s,this.cause=v}};function Ko(T){return typeof T=="object"&&T&&"then"in T}var ft=new Map;function je(T,p,s={}){return(v,S,I)=>{let A=s.action||S;if(!s.context){let D=ft.get(v)||[];ft.has(v)||ft.set(v,D),D.push({from:T,to:p,action:A})}let H=I.value;I.value=function(...D){let C=this;if(s.context&&(C=ce.get(typeof s.context=="function"?s.context.call(this,...D):s.context)),C.state===p)return s.sync?C[an]:Promise.resolve(C[an]);C.state instanceof dt&&C.state.action==s.abortAction&&C.state.abort(C);let F=null;Array.isArray(T)?T.length==0?C.state instanceof dt&&C.state.abort(C):(typeof C.state!="string"||!T.includes(C.state))&&(F=new Nr(C._state,`${C.name} ${A} to ${p} failed: current state ${C._state} not from ${T.join("|")}`)):T!==C.state&&(F=new Nr(C._state,`${C.name} ${A} to ${p} failed: current state ${C._state} not from ${T}`));let L=q=>{if(s.fail&&s.fail.call(this,q),s.sync){if(s.ignoreError)return q;throw q}else return s.ignoreError?Promise.resolve(q):Promise.reject(q)};if(F)return L(F);let W=C.state,me=new dt(W,p,A);pt.call(C,me);let Re=q=>{var ze;return C[an]=q,me.aborted||(pt.call(C,p),(ze=s.success)===null||ze===void 0||ze.call(this,C[an])),q},Me=q=>(pt.call(C,W,q),L(q));try{let q=H.apply(this,D);return Ko(q)?q.then(Re).catch(Me):s.sync?Re(q):Promise.resolve(Re(q))}catch(q){return Me(new Nr(C._state,`${C.name} ${A} from ${T} to ${p} failed: ${q}`,q instanceof Error?q:new Error(String(q))))}}}}function Po(...T){return(p,s,v)=>{let S=v.value,I=s;v.value=function(...A){if(!T.includes(this.state.toString()))throw new Nr(this.state,`${this.name} ${I} failed: current state ${this.state} not in ${T}`);return S.apply(this,A)}}}var Xo=typeof window!="undefined"&&window.__AFSM__?(s,v)=>{window.dispatchEvent(new CustomEvent(s,{detail:v}))}:typeof importScripts!="undefined"?(s,v)=>{postMessage({type:s,payload:v})}:()=>{};function pt(T,p){let s=this._state;this._state=T;let v=T.toString();T&&this.emit(v,s),this.emit(ce.STATECHANGED,T,s,p),this.updateDevTools({value:T,old:s,err:p instanceof Error?p.message:String(p)})}var ce=class T extends Ao.default{constructor(p,s,v){super(),this.name=p,this.groupName=s,this._state=T.INIT,p||(p=Date.now().toString(36)),v?Object.setPrototypeOf(this,v):v=Object.getPrototypeOf(this),s||(this.groupName=this.constructor.name);let S=v[So];S?this.name=S.name+"-"+S.count++:v[So]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let p=Object.getPrototypeOf(this),s=ft.get(p)||[],v=new Set,S=[],I=[],A=new Set,H=Object.getPrototypeOf(p);ft.has(H)&&(H.stateDiagram.forEach(C=>v.add(C)),H.allStates.forEach(C=>A.add(C))),s.forEach(({from:C,to:F,action:L})=>{typeof C=="string"?S.push({from:C,to:F,action:L}):C.length?C.forEach(W=>{S.push({from:W,to:F,action:L})}):I.push({to:F,action:L})}),S.forEach(({from:C,to:F,action:L})=>{A.add(C),A.add(F),A.add(L+"ing"),v.add(`${C} --> ${L}ing : ${L}`),v.add(`${L}ing --> ${F} : ${L} \u{1F7E2}`),v.add(`${L}ing --> ${C} : ${L} \u{1F534}`)}),I.forEach(({to:C,action:F})=>{v.add(`${F}ing --> ${C} : ${F} \u{1F7E2}`),A.forEach(L=>{L!==C&&v.add(`${L} --> ${F}ing : ${F}`)})});let D=[...v];return Object.defineProperties(p,{stateDiagram:{value:D},allStates:{value:A}}),D}static get(p){let s;return typeof p=="string"?(s=T.instances.get(p),s||T.instances.set(p,s=new T(p,void 0,Object.create(T.prototype)))):(s=T.instances2.get(p),s||T.instances2.set(p,s=new T(p.constructor.name,void 0,Object.create(T.prototype)))),s}static getState(p){var s;return(s=T.get(p))===null||s===void 0?void 0:s.state}updateDevTools(p={}){Xo(T.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},p))}get state(){return this._state}set state(p){pt.call(this,p)}};ce.STATECHANGED="stateChanged";ce.UPDATEAFSM="updateAFSM";ce.INIT="[*]";ce.ON="on";ce.OFF="off";ce.instances=new Map;ce.instances2=new WeakMap;var or=class extends ce{constructor(){super(...arguments);fe(this,"decoder");fe(this,"config")}async initialize(){this.decoder=new VideoDecoder({output:s=>{this.emit("videoFrame",s)},error:s=>{this.close(),this.emit("error",s)}})}configure(s){this.config=s,this.decoder.configure(Er(br({},s),{codec:this.getCodec(s)}))}getCodec(s){switch(s.codec){case"hevc":return"hvc1.1.6.L0.12.34.56.78.9A.BC";case"av1":return"av01.0.05M.08";case"avc":return"avc1.420028";default:return s.codec}}decode(s){this.decoder.state==="configured"&&this.decoder.decode(new EncodedVideoChunk(s))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){this.decoder.state!=="closed"&&this.decoder.close()}};Le([je([ce.INIT,"closed"],"initialized")],or.prototype,"initialize",1),Le([je("initialized","configured",{sync:!0})],or.prototype,"configure",1),Le([Po("configured")],or.prototype,"decode",1),Le([je([],ce.INIT)],or.prototype,"reset",1),Le([je([],"closed",{ignoreError:!0,sync:!0})],or.prototype,"close",1);function Yo(){var T;self.onmessage=p=>{if(p.data.type==="init"){let{canvas:s,wasmScript:v,wasmBinary:S}=p.data,I=s==null?void 0:s.getContext("2d"),A=0,H=0,D={wasmBinary:S,postRun:()=>{T=new D.VideoDecoder({videoInfo(C,F){A=C,H=F,console.log("video info",C,F)},yuvData(C,F){let L=A*H,W=L>>2,me=D.HEAPU32[C>>2],Re=D.HEAPU32[(C>>2)+1],Me=D.HEAPU32[(C>>2)+2],q=D.HEAPU8.subarray(me,me+L),ze=D.HEAPU8.subarray(Re,Re+W),lr=D.HEAPU8.subarray(Me,Me+W),ae=new Uint8Array(L+W+W);ae.set(q),ae.set(ze,L),ae.set(lr,L+W);let he=new VideoFrame(ae,{codedWidth:A,codedHeight:H,format:"I420",timestamp:F});s?(I==null||I.drawImage(he,0,0,s.width,s.height),I==null||I.commit()):self.postMessage({type:"yuvData",videoFrame:he},[he])}}),self.postMessage({type:"ready"})}};Function("var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;return "+v)()(D)}else if(p.data.type==="decode"){let{packet:s}=p.data;T==null||T.decode(s.data,s.type=="key",s.timestamp)}else if(p.data.type==="setCodec"){let{codec:s,format:v,description:S}=p.data;T==null||T.setCodec(s,v,S!=null?S:"")}}}var Ge=class extends ce{constructor(s,v,S=!1,I,A=!1){super();this.createModule=s;this.wasmBinary=v;this.workerMode=S;this.canvas=I;this.yuvMode=A;fe(this,"worker");fe(this,"decoder");fe(this,"config");fe(this,"module",{});fe(this,"width",0);fe(this,"height",0)}async initialize(s){var S;if(this.workerMode){let I=new RegExp("\\{(.+)\\}","s").exec(Yo.toString())[1];this.worker=new Worker(URL.createObjectURL(new Blob([I],{type:"text/javascript"})));let A=(S=this.canvas)==null?void 0:S.transferControlToOffscreen(),H=await this.wasmBinary;return console.warn("worker mode",H),this.worker.postMessage({type:"init",canvas:A,wasmScript:this.createModule.toString(),wasmBinary:H},A?[A,H]:[H]),new Promise(D=>{this.worker.onmessage=C=>{if(C.data.type==="ready")delete this.wasmBinary,D(),console.warn("worker mode initialize success");else if(C.data.type==="yuvData"){let{videoFrame:F}=C.data;this.emit("videoFrame",F)}}})}let v=this.module;return this.wasmBinary&&(v.wasmBinary=await this.wasmBinary),v.print=I=>console.log(I),v.printErr=I=>console.log(`[JS] ERROR: ${I}`),v.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),new Promise(I=>{v.postRun=A=>{this.decoder=new this.module.VideoDecoder(this),console.log("video soft decoder initialize success"),I()},s&&Object.assign(v,s),this.createModule(v)})}configure(s){var v,S,I;this.config=s,(S=this.decoder)==null||S.setCodec(this.config.codec,this.config.description?"avcc":"annexb",(v=this.config.description)!=null?v:""),(I=this.worker)==null||I.postMessage({type:"setCodec",codec:this.config.codec,format:this.config.description?"avcc":"annexb",description:this.config.description})}decode(s){var v,S;(v=this.decoder)==null||v.decode(s.data,s.type=="key",s.timestamp),this.state==="configured"&&((S=this.worker)==null||S.postMessage({type:"decode",packet:s}))}flush(){}reset(){this.config=void 0,this.decoder&&this.decoder.clear()}close(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}videoInfo(s,v){this.width=s,this.height=v;let S={width:s,height:v};this.emit("videoCodecInfo",S)}yuvData(s,v){if(!this.module)return;let S=this.width*this.height,I=S>>2,A=this.module.HEAPU32[s>>2],H=this.module.HEAPU32[(s>>2)+1],D=this.module.HEAPU32[(s>>2)+2],C=this.module.HEAPU8.subarray(A,A+S),F=this.module.HEAPU8.subarray(H,H+I),L=this.module.HEAPU8.subarray(D,D+I);if(this.yuvMode){this.emit("videoFrame",[C,F,L]);return}let W=new Uint8Array(S+I+I);W.set(C),W.set(F,S),W.set(L,S+I),this.emit("videoFrame",new VideoFrame(W,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:v}))}errorInfo(s){let v={errMsg:s};this.emit("error",v)}};Le([je([ce.INIT,"closed"],"initialized")],Ge.prototype,"initialize",1),Le([je("initialized","configured")],Ge.prototype,"configure",1),Le([je([],ce.INIT)],Ge.prototype,"reset",1),Le([je([],"closed")],Ge.prototype,"close",1);var Jo=(()=>{var T=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return function(p={}){var s=p,v,S;s.ready=new Promise((e,r)=>{v=e,S=r});var I=Object.assign({},s),A=[],H="./this.program",D=(e,r)=>{throw r},C=typeof window=="object",F=typeof importScripts=="function",L=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",W="";function me(e){return s.locateFile?s.locateFile(e,W):W+e}var Re,Me,q,ze;(C||F)&&(F?W=self.location.href:typeof document!="undefined"&&document.currentScript&&(W=document.currentScript.src),T&&(W=T),W.indexOf("blob:")!==0?W=W.substr(0,W.replace(/[?#].*/,"").lastIndexOf("/")+1):W="",Re=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},F&&(q=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Me=(e,r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{if(n.status==200||n.status==0&&n.response){r(n.response);return}t()},n.onerror=t,n.send(null)},ze=e=>document.title=e);var lr=s.print||console.log.bind(console),ae=s.printErr||console.error.bind(console);Object.assign(s,I),I=null,s.arguments&&(A=s.arguments),s.thisProgram&&(H=s.thisProgram),s.quit&&(D=s.quit);var he;s.wasmBinary&&(he=s.wasmBinary);var Do=s.noExitRuntime||!0;typeof WebAssembly!="object"&&Fe("no native wasm support detected");var $r,ee,Lr=!1,dn;function Ke(e,r){e||Fe(r)}var Y,ie,we,Se,U,X,Mr,mt;function ht(){var e=$r.buffer;s.HEAP8=Y=new Int8Array(e),s.HEAP16=we=new Int16Array(e),s.HEAP32=U=new Int32Array(e),s.HEAPU8=ie=new Uint8Array(e),s.HEAPU16=Se=new Uint16Array(e),s.HEAPU32=X=new Uint32Array(e),s.HEAPF32=Mr=new Float32Array(e),s.HEAPF64=mt=new Float64Array(e)}var Fr,Br=[],Hr=[],vt=[],fn=!1;function pn(){if(s.preRun)for(typeof s.preRun=="function"&&(s.preRun=[s.preRun]);s.preRun.length;)vn(s.preRun.shift());Gr(Br)}function mn(){fn=!0,!s.noFSInit&&!a.init.initialized&&a.init(),a.ignorePermissions=!1,Be.init(),Gr(Hr)}function hn(){if(s.postRun)for(typeof s.postRun=="function"&&(s.postRun=[s.postRun]);s.postRun.length;)Xe(s.postRun.shift());Gr(vt)}function vn(e){Br.unshift(e)}function gn(e){Hr.unshift(e)}function Xe(e){vt.unshift(e)}var De=0,qe=null,dr=null;function fo(e){return e}function ir(e){De++,s.monitorRunDependencies&&s.monitorRunDependencies(De)}function wr(e){if(De--,s.monitorRunDependencies&&s.monitorRunDependencies(De),De==0&&(qe!==null&&(clearInterval(qe),qe=null),dr)){var r=dr;dr=null,r()}}function Fe(e){s.onAbort&&s.onAbort(e),e="Aborted("+e+")",ae(e),Lr=!0,dn=1,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw S(r),r}var ar="data:application/octet-stream;base64,";function Wr(e){return e.startsWith(ar)}var sr;sr="videodec.wasm",Wr(sr)||(sr=me(sr));function Vr(e){if(e==sr&&he)return new Uint8Array(he);if(q)return q(e);throw"both async and sync fetching of the wasm failed"}function yn(e){return!he&&(C||F)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw"failed to load wasm binary file at '"+e+"'";return r.arrayBuffer()}).catch(()=>Vr(e)):Promise.resolve().then(()=>Vr(e))}function gt(e,r,t){return yn(e).then(n=>WebAssembly.instantiate(n,r)).then(n=>n).then(t,n=>{ae("failed to asynchronously prepare wasm: "+n),Fe(n)})}function jr(e,r,t,n){return!e&&typeof WebAssembly.instantiateStreaming=="function"&&!Wr(r)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(u=>{var l=WebAssembly.instantiateStreaming(u,t);return l.then(n,function(f){return ae("wasm streaming compile failed: "+f),ae("falling back to ArrayBuffer instantiation"),gt(r,t,n)})}):gt(r,t,n)}function _n(){var e={a:ko};function r(n,u){var l=n.exports;return ee=l,$r=ee.E,ht(),Fr=ee.H,gn(ee.F),wr("wasm-instantiate"),l}ir("wasm-instantiate");function t(n){r(n.instance)}if(s.instantiateWasm)try{return s.instantiateWasm(e,r)}catch(n){ae("Module.instantiateWasm callback failed with error: "+n),S(n)}return jr(he,sr,e,t).catch(S),{}}var N,Q,Gr=e=>{for(;e.length>0;)e.shift()(s)};function Tn(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(r){X[this.ptr+4>>2]=r},this.get_type=function(){return X[this.ptr+4>>2]},this.set_destructor=function(r){X[this.ptr+8>>2]=r},this.get_destructor=function(){return X[this.ptr+8>>2]},this.set_caught=function(r){r=r?1:0,Y[this.ptr+12>>0]=r},this.get_caught=function(){return Y[this.ptr+12>>0]!=0},this.set_rethrown=function(r){r=r?1:0,Y[this.ptr+13>>0]=r},this.get_rethrown=function(){return Y[this.ptr+13>>0]!=0},this.init=function(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)},this.set_adjusted_ptr=function(r){X[this.ptr+16>>2]=r},this.get_adjusted_ptr=function(){return X[this.ptr+16>>2]},this.get_exception_ptr=function(){var r=go(this.get_type());if(r)return X[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var Sr=0,bn=0;function yt(e,r,t){var n=new Tn(e);throw n.init(r,t),Sr=e,bn++,Sr}var ve=e=>(U[ho()>>2]=e,e),G={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 u=e[n];u==="."?e.splice(n,1):u===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=G.isAbs(e),t=e.substr(-1)==="/";return e=G.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=G.splitPath(e),t=r[0],n=r[1];return!t&&!n?".":(n&&(n=n.substr(0,n.length-1)),t+n)},basename:e=>{if(e==="/")return"/";e=G.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:function(){var e=Array.prototype.slice.call(arguments);return G.normalize(e.join("/"))},join2:(e,r)=>G.normalize(e+"/"+r)},Ye=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return e=>crypto.getRandomValues(e);Fe("initRandomDevice")},fr=e=>(fr=Ye())(e),le={resolve:function(){for(var e="",r=!1,t=arguments.length-1;t>=-1&&!r;t--){var n=t>=0?arguments[t]:a.cwd();if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,r=G.isAbs(n)}return e=G.normalizeArray(e.split("/").filter(u=>!!u),!r).join("/"),(r?"/":"")+e||"."},relative:(e,r)=>{e=le.resolve(e).substr(1),r=le.resolve(r).substr(1);function t(h){for(var R=0;R<h.length&&h[R]==="";R++);for(var x=h.length-1;x>=0&&h[x]==="";x--);return R>x?[]:h.slice(R,x-R+1)}for(var n=t(e.split("/")),u=t(r.split("/")),l=Math.min(n.length,u.length),f=l,d=0;d<l;d++)if(n[d]!==u[d]){f=d;break}for(var y=[],d=f;d<n.length;d++)y.push("..");return y=y.concat(u.slice(f)),y.join("/")}},z=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0,Je=(e,r,t)=>{for(var n=r+t,u=r;e[u]&&!(u>=n);)++u;if(u-r>16&&e.buffer&&z)return z.decode(e.subarray(r,u));for(var l="";r<u;){var f=e[r++];if(!(f&128)){l+=String.fromCharCode(f);continue}var d=e[r++]&63;if((f&224)==192){l+=String.fromCharCode((f&31)<<6|d);continue}var y=e[r++]&63;if((f&240)==224?f=(f&15)<<12|d<<6|y:f=(f&7)<<18|d<<12|y<<6|e[r++]&63,f<65536)l+=String.fromCharCode(f);else{var h=f-65536;l+=String.fromCharCode(55296|h>>10,56320|h&1023)}}return l},ur=[],Ze=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},zr=(e,r,t,n)=>{if(!(n>0))return 0;for(var u=t,l=t+n-1,f=0;f<e.length;++f){var d=e.charCodeAt(f);if(d>=55296&&d<=57343){var y=e.charCodeAt(++f);d=65536+((d&1023)<<10)|y&1023}if(d<=127){if(t>=l)break;r[t++]=d}else if(d<=2047){if(t+1>=l)break;r[t++]=192|d>>6,r[t++]=128|d&63}else if(d<=65535){if(t+2>=l)break;r[t++]=224|d>>12,r[t++]=128|d>>6&63,r[t++]=128|d&63}else{if(t+3>=l)break;r[t++]=240|d>>18,r[t++]=128|d>>12&63,r[t++]=128|d>>6&63,r[t++]=128|d&63}}return r[t]=0,t-u};function Ae(e,r,t){var n=t>0?t:Ze(e)+1,u=new Array(n),l=zr(e,u,0,u.length);return r&&(u.length=l),u}var En=()=>{if(!ur.length){var e=null;if(typeof window!="undefined"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=`
`)):typeof readline=="function"&&(e=readline(),e!==null&&(e+=`
`)),!e)return null;ur=Ae(e,!0)}return ur.shift()},Be={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){Be.ttys[e]={input:[],output:[],ops:r},a.registerDevice(e,Be.stream_ops)},stream_ops:{open:function(e){var r=Be.ttys[e.node.rdev];if(!r)throw new a.ErrnoError(43);e.tty=r,e.seekable=!1},close:function(e){e.tty.ops.fsync(e.tty)},fsync:function(e){e.tty.ops.fsync(e.tty)},read:function(e,r,t,n,u){if(!e.tty||!e.tty.ops.get_char)throw new a.ErrnoError(60);for(var l=0,f=0;f<n;f++){var d;try{d=e.tty.ops.get_char(e.tty)}catch(y){throw new a.ErrnoError(29)}if(d===void 0&&l===0)throw new a.ErrnoError(6);if(d==null)break;l++,r[t+f]=d}return l&&(e.node.timestamp=Date.now()),l},write:function(e,r,t,n,u){if(!e.tty||!e.tty.ops.put_char)throw new a.ErrnoError(60);try{for(var l=0;l<n;l++)e.tty.ops.put_char(e.tty,r[t+l])}catch(f){throw new a.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),l}},default_tty_ops:{get_char:function(e){return En()},put_char:function(e,r){r===null||r===10?(lr(Je(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(lr(Je(e.output,0)),e.output=[])},ioctl_tcgets:function(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:function(e,r,t){return 0},ioctl_tiocgwinsz:function(e){return[24,80]}},default_tty1_ops:{put_char:function(e,r){r===null||r===10?(ae(Je(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(ae(Je(e.output,0)),e.output=[])}}},_t=e=>{Fe()},M={ops_table:null,mount(e){return M.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(a.isBlkdev(t)||a.isFIFO(t))throw new a.ErrnoError(63);M.ops_table||(M.ops_table={dir:{node:{getattr:M.node_ops.getattr,setattr:M.node_ops.setattr,lookup:M.node_ops.lookup,mknod:M.node_ops.mknod,rename:M.node_ops.rename,unlink:M.node_ops.unlink,rmdir:M.node_ops.rmdir,readdir:M.node_ops.readdir,symlink:M.node_ops.symlink},stream:{llseek:M.stream_ops.llseek}},file:{node:{getattr:M.node_ops.getattr,setattr:M.node_ops.setattr},stream:{llseek:M.stream_ops.llseek,read:M.stream_ops.read,write:M.stream_ops.write,allocate:M.stream_ops.allocate,mmap:M.stream_ops.mmap,msync:M.stream_ops.msync}},link:{node:{getattr:M.node_ops.getattr,setattr:M.node_ops.setattr,readlink:M.node_ops.readlink},stream:{}},chrdev:{node:{getattr:M.node_ops.getattr,setattr:M.node_ops.setattr},stream:a.chrdev_stream_ops}});var u=a.createNode(e,r,t,n);return a.isDir(u.mode)?(u.node_ops=M.ops_table.dir.node,u.stream_ops=M.ops_table.dir.stream,u.contents={}):a.isFile(u.mode)?(u.node_ops=M.ops_table.file.node,u.stream_ops=M.ops_table.file.stream,u.usedBytes=0,u.contents=null):a.isLink(u.mode)?(u.node_ops=M.ops_table.link.node,u.stream_ops=M.ops_table.link.stream):a.isChrdev(u.mode)&&(u.node_ops=M.ops_table.chrdev.node,u.stream_ops=M.ops_table.chrdev.stream),u.timestamp=Date.now(),e&&(e.contents[r]=u,e.timestamp=u.timestamp),u},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t!=0&&(r=Math.max(r,256));var u=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(u.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)e.contents=null,e.usedBytes=0;else{var t=e.contents;e.contents=new Uint8Array(r),t&&e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r}},node_ops:{getattr(e){var r={};return r.dev=a.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,a.isDir(e.mode)?r.size=4096:a.isFile(e.mode)?r.size=e.usedBytes:a.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&M.resizeFileStorage(e,r.size)},lookup(e,r){throw a.genericErrors[44]},mknod(e,r,t,n){return M.createNode(e,r,t,n)},rename(e,r,t){if(a.isDir(e.mode)){var n;try{n=a.lookupNode(r,t)}catch(l){}if(n)for(var u in n.contents)throw new a.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp,e.parent=r},unlink(e,r){delete e.contents[r],e.timestamp=Date.now()},rmdir(e,r){var t=a.lookupNode(e,r);for(var n in t.contents)throw new a.ErrnoError(55);delete e.contents[r],e.timestamp=Date.now()},readdir(e){var r=[".",".."];for(var t in e.contents)e.contents.hasOwnProperty(t)&&r.push(t);return r},symlink(e,r,t){var n=M.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!a.isLink(e.mode))throw new a.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,u){var l=e.node.contents;if(u>=e.node.usedBytes)return 0;var f=Math.min(e.node.usedBytes-u,n);if(f>8&&l.subarray)r.set(l.subarray(u,u+f),t);else for(var d=0;d<f;d++)r[t+d]=l[u+d];return f},write(e,r,t,n,u,l){if(!n)return 0;var f=e.node;if(f.timestamp=Date.now(),r.subarray&&(!f.contents||f.contents.subarray)){if(l)return f.contents=r.subarray(t,t+n),f.usedBytes=n,n;if(f.usedBytes===0&&u===0)return f.contents=r.slice(t,t+n),f.usedBytes=n,n;if(u+n<=f.usedBytes)return f.contents.set(r.subarray(t,t+n),u),n}if(M.expandFileStorage(f,u+n),f.contents.subarray&&r.subarray)f.contents.set(r.subarray(t,t+n),u);else for(var d=0;d<n;d++)f.contents[u+d]=r[t+d];return f.usedBytes=Math.max(f.usedBytes,u+n),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&a.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new a.ErrnoError(28);return n},allocate(e,r,t){M.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t)},mmap(e,r,t,n,u){if(!a.isFile(e.node.mode))throw new a.ErrnoError(43);var l,f,d=e.node.contents;if(!(u&2)&&d.buffer===Y.buffer)f=!1,l=d.byteOffset;else{if((t>0||t+r<d.length)&&(d.subarray?d=d.subarray(t,t+r):d=Array.prototype.slice.call(d,t,t+r)),f=!0,l=_t(r),!l)throw new a.ErrnoError(48);Y.set(d,l)}return{ptr:l,allocated:f}},msync(e,r,t,n,u){return M.stream_ops.write(e,r,0,n,t,!1),0}}},Kr=(e,r,t,n)=>{var u=n?"":`al ${e}`;Me(e,l=>{Ke(l,`Loading data file "${e}" failed (no arrayBuffer).`),r(new Uint8Array(l)),u&&wr(u)},l=>{if(t)t();else throw`Loading data file "${e}" failed.`}),u&&ir(u)},Tt=s.preloadPlugins||[];function wn(e,r,t,n){typeof Browser!="undefined"&&Browser.init();var u=!1;return Tt.forEach(function(l){u||l.canHandle(r)&&(l.handle(e,r,t,n),u=!0)}),u}function bt(e,r,t,n,u,l,f,d,y,h){var R=r?le.resolve(G.join2(e,r)):e,x=`cp ${R}`;function k(P){function $(Z){h&&h(),d||a.createDataFile(e,r,Z,n,u,y),l&&l(),wr(x)}wn(P,R,$,()=>{f&&f(),wr(x)})||$(P)}ir(x),typeof t=="string"?Kr(t,P=>k(P),f):k(t)}function Et(e){var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t=="undefined")throw new Error(`Unknown file open mode: ${e}`);return t}function Ar(e,r){var t=0;return e&&(t|=365),r&&(t|=146),t}var a={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(e,r={})=>{if(e=le.resolve(e),!e)return{path:"",node:null};var t={follow_mount:!0,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new a.ErrnoError(32);for(var n=e.split("/").filter(x=>!!x),u=a.root,l="/",f=0;f<n.length;f++){var d=f===n.length-1;if(d&&r.parent)break;if(u=a.lookupNode(u,n[f]),l=G.join2(l,n[f]),a.isMountpoint(u)&&(!d||d&&r.follow_mount)&&(u=u.mounted.root),!d||r.follow)for(var y=0;a.isLink(u.mode);){var h=a.readlink(l);l=le.resolve(G.dirname(l),h);var R=a.lookupPath(l,{recurse_count:r.recurse_count+1});if(u=R.node,y++>40)throw new a.ErrnoError(32)}}return{path:l,node:u}},getPath:e=>{for(var r;;){if(a.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)%a.nameTable.length},hashAddNode:e=>{var r=a.hashName(e.parent.id,e.name);e.name_next=a.nameTable[r],a.nameTable[r]=e},hashRemoveNode:e=>{var r=a.hashName(e.parent.id,e.name);if(a.nameTable[r]===e)a.nameTable[r]=e.name_next;else for(var t=a.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode:(e,r)=>{var t=a.mayLookup(e);if(t)throw new a.ErrnoError(t,e);for(var n=a.hashName(e.id,r),u=a.nameTable[n];u;u=u.name_next){var l=u.name;if(u.parent.id===e.id&&l===r)return u}return a.lookup(e,r)},createNode:(e,r,t,n)=>{var u=new a.FSNode(e,r,t,n);return a.hashAddNode(u),u},destroyNode:e=>{a.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>(e&61440)===32768,isDir:e=>(e&61440)===16384,isLink:e=>(e&61440)===40960,isChrdev:e=>(e&61440)===8192,isBlkdev:e=>(e&61440)===24576,isFIFO:e=>(e&61440)===4096,isSocket:e=>(e&49152)===49152,flagsToPermissionString:e=>{var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions:(e,r)=>a.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0,mayLookup:e=>{var r=a.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate:(e,r)=>{try{var t=a.lookupNode(e,r);return 20}catch(n){}return a.nodePermissions(e,"wx")},mayDelete:(e,r,t)=>{var n;try{n=a.lookupNode(e,r)}catch(l){return l.errno}var u=a.nodePermissions(e,"wx");if(u)return u;if(t){if(!a.isDir(n.mode))return 54;if(a.isRoot(n)||a.getPath(n)===a.cwd())return 10}else if(a.isDir(n.mode))return 31;return 0},mayOpen:(e,r)=>e?a.isLink(e.mode)?32:a.isDir(e.mode)&&(a.flagsToPermissionString(r)!=="r"||r&512)?31:a.nodePermissions(e,a.flagsToPermissionString(r)):44,MAX_OPEN_FDS:4096,nextfd:()=>{for(var e=0;e<=a.MAX_OPEN_FDS;e++)if(!a.streams[e])return e;throw new a.ErrnoError(33)},getStreamChecked:e=>{var r=a.getStream(e);if(!r)throw new a.ErrnoError(8);return r},getStream:e=>a.streams[e],createStream:(e,r=-1)=>(a.FSStream||(a.FSStream=function(){this.shared={}},a.FSStream.prototype={},Object.defineProperties(a.FSStream.prototype,{object:{get(){return this.node},set(t){this.node=t}},isRead:{get(){return(this.flags&2097155)!==1}},isWrite:{get(){return(this.flags&2097155)!==0}},isAppend:{get(){return this.flags&1024}},flags:{get(){return this.shared.flags},set(t){this.shared.flags=t}},position:{get(){return this.shared.position},set(t){this.shared.position=t}}})),e=Object.assign(new a.FSStream,e),r==-1&&(r=a.nextfd()),e.fd=r,a.streams[r]=e,e),closeStream:e=>{a.streams[e]=null},chrdev_stream_ops:{open:e=>{var r=a.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new a.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice:(e,r)=>{a.devices[e]={stream_ops:r}},getDevice:e=>a.devices[e],getMounts:e=>{for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push.apply(t,n.mounts)}return r},syncfs:(e,r)=>{typeof e=="function"&&(r=e,e=!1),a.syncFSRequests++,a.syncFSRequests>1&&ae(`warning: ${a.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=a.getMounts(a.root.mount),n=0;function u(f){return a.syncFSRequests--,r(f)}function l(f){if(f)return l.errored?void 0:(l.errored=!0,u(f));++n>=t.length&&u(null)}t.forEach(f=>{if(!f.type.syncfs)return l(null);f.type.syncfs(f,e,l)})},mount:(e,r,t)=>{var n=t==="/",u=!t,l;if(n&&a.root)throw new a.ErrnoError(10);if(!n&&!u){var f=a.lookupPath(t,{follow_mount:!1});if(t=f.path,l=f.node,a.isMountpoint(l))throw new a.ErrnoError(10);if(!a.isDir(l.mode))throw new a.ErrnoError(54)}var d={type:e,opts:r,mountpoint:t,mounts:[]},y=e.mount(d);return y.mount=d,d.root=y,n?a.root=y:l&&(l.mounted=d,l.mount&&l.mount.mounts.push(d)),y},unmount:e=>{var r=a.lookupPath(e,{follow_mount:!1});if(!a.isMountpoint(r.node))throw new a.ErrnoError(28);var t=r.node,n=t.mounted,u=a.getMounts(n);Object.keys(a.nameTable).forEach(f=>{for(var d=a.nameTable[f];d;){var y=d.name_next;u.includes(d.mount)&&a.destroyNode(d),d=y}}),t.mounted=null;var l=t.mount.mounts.indexOf(n);t.mount.mounts.splice(l,1)},lookup:(e,r)=>e.node_ops.lookup(e,r),mknod:(e,r,t)=>{var n=a.lookupPath(e,{parent:!0}),u=n.node,l=G.basename(e);if(!l||l==="."||l==="..")throw new a.ErrnoError(28);var f=a.mayCreate(u,l);if(f)throw new a.ErrnoError(f);if(!u.node_ops.mknod)throw new a.ErrnoError(63);return u.node_ops.mknod(u,l,r,t)},create:(e,r)=>(r=r!==void 0?r:438,r&=4095,r|=32768,a.mknod(e,r,0)),mkdir:(e,r)=>(r=r!==void 0?r:511,r&=1023,r|=16384,a.mknod(e,r,0)),mkdirTree:(e,r)=>{for(var t=e.split("/"),n="",u=0;u<t.length;++u)if(t[u]){n+="/"+t[u];try{a.mkdir(n,r)}catch(l){if(l.errno!=20)throw l}}},mkdev:(e,r,t)=>(typeof t=="undefined"&&(t=r,r=438),r|=8192,a.mknod(e,r,t)),symlink:(e,r)=>{if(!le.resolve(e))throw new a.ErrnoError(44);var t=a.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new a.ErrnoError(44);var u=G.basename(r),l=a.mayCreate(n,u);if(l)throw new a.ErrnoError(l);if(!n.node_ops.symlink)throw new a.ErrnoError(63);return n.node_ops.symlink(n,u,e)},rename:(e,r)=>{var t=G.dirname(e),n=G.dirname(r),u=G.basename(e),l=G.basename(r),f,d,y;if(f=a.lookupPath(e,{parent:!0}),d=f.node,f=a.lookupPath(r,{parent:!0}),y=f.node,!d||!y)throw new a.ErrnoError(44);if(d.mount!==y.mount)throw new a.ErrnoError(75);var h=a.lookupNode(d,u),R=le.relative(e,n);if(R.charAt(0)!==".")throw new a.ErrnoError(28);if(R=le.relative(r,t),R.charAt(0)!==".")throw new a.ErrnoError(55);var x;try{x=a.lookupNode(y,l)}catch($){}if(h!==x){var k=a.isDir(h.mode),P=a.mayDelete(d,u,k);if(P)throw new a.ErrnoError(P);if(P=x?a.mayDelete(y,l,k):a.mayCreate(y,l),P)throw new a.ErrnoError(P);if(!d.node_ops.rename)throw new a.ErrnoError(63);if(a.isMountpoint(h)||x&&a.isMountpoint(x))throw new a.ErrnoError(10);if(y!==d&&(P=a.nodePermissions(d,"w"),P))throw new a.ErrnoError(P);a.hashRemoveNode(h);try{d.node_ops.rename(h,y,l)}catch($){throw $}finally{a.hashAddNode(h)}}},rmdir:e=>{var r=a.lookupPath(e,{parent:!0}),t=r.node,n=G.basename(e),u=a.lookupNode(t,n),l=a.mayDelete(t,n,!0);if(l)throw new a.ErrnoError(l);if(!t.node_ops.rmdir)throw new a.ErrnoError(63);if(a.isMountpoint(u))throw new a.ErrnoError(10);t.node_ops.rmdir(t,n),a.destroyNode(u)},readdir:e=>{var r=a.lookupPath(e,{follow:!0}),t=r.node;if(!t.node_ops.readdir)throw new a.ErrnoError(54);return t.node_ops.readdir(t)},unlink:e=>{var r=a.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new a.ErrnoError(44);var n=G.basename(e),u=a.lookupNode(t,n),l=a.mayDelete(t,n,!1);if(l)throw new a.ErrnoError(l);if(!t.node_ops.unlink)throw new a.ErrnoError(63);if(a.isMountpoint(u))throw new a.ErrnoError(10);t.node_ops.unlink(t,n),a.destroyNode(u)},readlink:e=>{var r=a.lookupPath(e),t=r.node;if(!t)throw new a.ErrnoError(44);if(!t.node_ops.readlink)throw new a.ErrnoError(28);return le.resolve(a.getPath(t.parent),t.node_ops.readlink(t))},stat:(e,r)=>{var t=a.lookupPath(e,{follow:!r}),n=t.node;if(!n)throw new a.ErrnoError(44);if(!n.node_ops.getattr)throw new a.ErrnoError(63);return n.node_ops.getattr(n)},lstat:e=>a.stat(e,!0),chmod:(e,r,t)=>{var n;if(typeof e=="string"){var u=a.lookupPath(e,{follow:!t});n=u.node}else n=e;if(!n.node_ops.setattr)throw new a.ErrnoError(63);n.node_ops.setattr(n,{mode:r&4095|n.mode&-4096,timestamp:Date.now()})},lchmod:(e,r)=>{a.chmod(e,r,!0)},fchmod:(e,r)=>{var t=a.getStreamChecked(e);a.chmod(t.node,r)},chown:(e,r,t,n)=>{var u;if(typeof e=="string"){var l=a.lookupPath(e,{follow:!n});u=l.node}else u=e;if(!u.node_ops.setattr)throw new a.ErrnoError(63);u.node_ops.setattr(u,{timestamp:Date.now()})},lchown:(e,r,t)=>{a.chown(e,r,t,!0)},fchown:(e,r,t)=>{var n=a.getStreamChecked(e);a.chown(n.node,r,t)},truncate:(e,r)=>{if(r<0)throw new a.ErrnoError(28);var t;if(typeof e=="string"){var n=a.lookupPath(e,{follow:!0});t=n.node}else t=e;if(!t.node_ops.setattr)throw new a.ErrnoError(63);if(a.isDir(t.mode))throw new a.ErrnoError(31);if(!a.isFile(t.mode))throw new a.ErrnoError(28);var u=a.nodePermissions(t,"w");if(u)throw new a.ErrnoError(u);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate:(e,r)=>{var t=a.getStreamChecked(e);if((t.flags&2097155)===0)throw new a.ErrnoError(28);a.truncate(t.node,r)},utime:(e,r,t)=>{var n=a.lookupPath(e,{follow:!0}),u=n.node;u.node_ops.setattr(u,{timestamp:Math.max(r,t)})},open:(e,r,t)=>{if(e==="")throw new a.ErrnoError(44);r=typeof r=="string"?Et(r):r,t=typeof t=="undefined"?438:t,r&64?t=t&4095|32768:t=0;var n;if(typeof e=="object")n=e;else{e=G.normalize(e);try{var u=a.lookupPath(e,{follow:!(r&131072)});n=u.node}catch(y){}}var l=!1;if(r&64)if(n){if(r&128)throw new a.ErrnoError(20)}else n=a.mknod(e,t,0),l=!0;if(!n)throw new a.ErrnoError(44);if(a.isChrdev(n.mode)&&(r&=-513),r&65536&&!a.isDir(n.mode))throw new a.ErrnoError(54);if(!l){var f=a.mayOpen(n,r);if(f)throw new a.ErrnoError(f)}r&512&&!l&&a.truncate(n,0),r&=-131713;var d=a.createStream({node:n,path:a.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.logReadFiles&&!(r&1)&&(a.readFiles||(a.readFiles={}),e in a.readFiles||(a.readFiles[e]=1)),d},close:e=>{if(a.isClosed(e))throw new a.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{a.closeStream(e.fd)}e.fd=null},isClosed:e=>e.fd===null,llseek:(e,r,t)=>{if(a.isClosed(e))throw new a.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new a.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new a.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read:(e,r,t,n,u)=>{if(n<0||u<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===1)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.read)throw new a.ErrnoError(28);var l=typeof u!="undefined";if(!l)u=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var f=e.stream_ops.read(e,r,t,n,u);return l||(e.position+=f),f},write:(e,r,t,n,u,l)=>{if(n<0||u<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.write)throw new a.ErrnoError(28);e.seekable&&e.flags&1024&&a.llseek(e,0,2);var f=typeof u!="undefined";if(!f)u=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var d=e.stream_ops.write(e,r,t,n,u,l);return f||(e.position+=d),d},allocate:(e,r,t)=>{if(a.isClosed(e))throw new a.ErrnoError(8);if(r<0||t<=0)throw new a.ErrnoError(28);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(!a.isFile(e.node.mode)&&!a.isDir(e.node.mode))throw new a.ErrnoError(43);if(!e.stream_ops.allocate)throw new a.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap:(e,r,t,n,u)=>{if((n&2)!==0&&(u&2)===0&&(e.flags&2097155)!==2)throw new a.ErrnoError(2);if((e.flags&2097155)===1)throw new a.ErrnoError(2);if(!e.stream_ops.mmap)throw new a.ErrnoError(43);return e.stream_ops.mmap(e,r,t,n,u)},msync:(e,r,t,n,u)=>e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,u):0,munmap:e=>0,ioctl:(e,r,t)=>{if(!e.stream_ops.ioctl)throw new a.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile:(e,r={})=>{if(r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary")throw new Error(`Invalid encoding type "${r.encoding}"`);var t,n=a.open(e,r.flags),u=a.stat(e),l=u.size,f=new Uint8Array(l);return a.read(n,f,0,l,0),r.encoding==="utf8"?t=Je(f,0):r.encoding==="binary"&&(t=f),a.close(n),t},writeFile:(e,r,t={})=>{t.flags=t.flags||577;var n=a.open(e,t.flags,t.mode);if(typeof r=="string"){var u=new Uint8Array(Ze(r)+1),l=zr(r,u,0,u.length);a.write(n,u,0,l,void 0,t.canOwn)}else if(ArrayBuffer.isView(r))a.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");a.close(n)},cwd:()=>a.currentPath,chdir:e=>{var r=a.lookupPath(e,{follow:!0});if(r.node===null)throw new a.ErrnoError(44);if(!a.isDir(r.node.mode))throw new a.ErrnoError(54);var t=a.nodePermissions(r.node,"x");if(t)throw new a.ErrnoError(t);a.currentPath=r.path},createDefaultDirectories:()=>{a.mkdir("/tmp"),a.mkdir("/home"),a.mkdir("/home/web_user")},createDefaultDevices:()=>{a.mkdir("/dev"),a.registerDevice(a.makedev(1,3),{read:()=>0,write:(n,u,l,f,d)=>f}),a.mkdev("/dev/null",a.makedev(1,3)),Be.register(a.makedev(5,0),Be.default_tty_ops),Be.register(a.makedev(6,0),Be.default_tty1_ops),a.mkdev("/dev/tty",a.makedev(5,0)),a.mkdev("/dev/tty1",a.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(r=fr(e).byteLength),e[--r]);a.createDevice("/dev","random",t),a.createDevice("/dev","urandom",t),a.mkdir("/dev/shm"),a.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{a.mkdir("/proc");var e=a.mkdir("/proc/self");a.mkdir("/proc/self/fd"),a.mount({mount:()=>{var r=a.createNode(e,"fd",16895,73);return r.node_ops={lookup:(t,n)=>{var u=+n,l=a.getStreamChecked(u),f={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>l.path}};return f.parent=f,f}},r}},{},"/proc/self/fd")},createStandardStreams:()=>{s.stdin?a.createDevice("/dev","stdin",s.stdin):a.symlink("/dev/tty","/dev/stdin"),s.stdout?a.createDevice("/dev","stdout",null,s.stdout):a.symlink("/dev/tty","/dev/stdout"),s.stderr?a.createDevice("/dev","stderr",null,s.stderr):a.symlink("/dev/tty1","/dev/stderr");var e=a.open("/dev/stdin",0),r=a.open("/dev/stdout",1),t=a.open("/dev/stderr",1)},ensureErrnoError:()=>{a.ErrnoError||(a.ErrnoError=function(r,t){this.name="ErrnoError",this.node=t,this.setErrno=function(n){this.errno=n},this.setErrno(r),this.message="FS error"},a.ErrnoError.prototype=new Error,a.ErrnoError.prototype.constructor=a.ErrnoError,[44].forEach(e=>{a.genericErrors[e]=new a.ErrnoError(e),a.genericErrors[e].stack="<generic error, no stack>"}))},staticInit:()=>{a.ensureErrnoError(),a.nameTable=new Array(4096),a.mount(M,{},"/"),a.createDefaultDirectories(),a.createDefaultDevices(),a.createSpecialDirectories(),a.filesystems={MEMFS:M}},init:(e,r,t)=>{a.init.initialized=!0,a.ensureErrnoError(),s.stdin=e||s.stdin,s.stdout=r||s.stdout,s.stderr=t||s.stderr,a.createStandardStreams()},quit:()=>{a.init.initialized=!1;for(var e=0;e<a.streams.length;e++){var r=a.streams[e];r&&a.close(r)}},findObject:(e,r)=>{var t=a.analyzePath(e,r);return t.exists?t.object:null},analyzePath:(e,r)=>{try{var t=a.lookupPath(e,{follow:!r});e=t.path}catch(u){}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=a.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=G.basename(e),t=a.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(u){n.error=u.errno}return n},createPath:(e,r,t,n)=>{e=typeof e=="string"?e:a.getPath(e);for(var u=r.split("/").reverse();u.length;){var l=u.pop();if(l){var f=G.join2(e,l);try{a.mkdir(f)}catch(d){}e=f}}return f},createFile:(e,r,t,n,u)=>{var l=G.join2(typeof e=="string"?e:a.getPath(e),r),f=Ar(n,u);return a.create(l,f)},createDataFile:(e,r,t,n,u,l)=>{var f=r;e&&(e=typeof e=="string"?e:a.getPath(e),f=r?G.join2(e,r):e);var d=Ar(n,u),y=a.create(f,d);if(t){if(typeof t=="string"){for(var h=new Array(t.length),R=0,x=t.length;R<x;++R)h[R]=t.charCodeAt(R);t=h}a.chmod(y,d|146);var k=a.open(y,577);a.write(k,t,0,t.length,0,l),a.close(k),a.chmod(y,d)}return y},createDevice:(e,r,t,n)=>{var u=G.join2(typeof e=="string"?e:a.getPath(e),r),l=Ar(!!t,!!n);a.createDevice.major||(a.createDevice.major=64);var f=a.makedev(a.createDevice.major++,0);return a.registerDevice(f,{open:d=>{d.seekable=!1},close:d=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(d,y,h,R,x)=>{for(var k=0,P=0;P<R;P++){var $;try{$=t()}catch(Z){throw new a.ErrnoError(29)}if($===void 0&&k===0)throw new a.ErrnoError(6);if($==null)break;k++,y[h+P]=$}return k&&(d.node.timestamp=Date.now()),k},write:(d,y,h,R,x)=>{for(var k=0;k<R;k++)try{n(y[h+k])}catch(P){throw new a.ErrnoError(29)}return R&&(d.node.timestamp=Date.now()),k}}),a.mkdev(u,l,f)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(typeof XMLHttpRequest!="undefined")throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(Re)try{e.contents=Ae(Re(e.url),!0),e.usedBytes=e.contents.length}catch(r){throw new a.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile:(e,r,t,n,u)=>{function l(){this.lengthKnown=!1,this.chunks=[]}if(l.prototype.get=function(P){if(!(P>this.length-1||P<0)){var $=P%this.chunkSize,Z=P/this.chunkSize|0;return this.getter(Z)[$]}},l.prototype.setDataGetter=function(P){this.getter=P},l.prototype.cacheLength=function(){var P=new XMLHttpRequest;if(P.open("HEAD",t,!1),P.send(null),!(P.status>=200&&P.status<300||P.status===304))throw new Error("Couldn't load "+t+". Status: "+P.status);var $=Number(P.getResponseHeader("Content-length")),Z,re=(Z=P.getResponseHeader("Accept-Ranges"))&&Z==="bytes",se=(Z=P.getResponseHeader("Content-Encoding"))&&Z==="gzip",Te=1024*1024;re||(Te=$);var oe=(Ce,nr)=>{if(Ce>nr)throw new Error("invalid range ("+Ce+", "+nr+") or no bytes requested!");if(nr>$-1)throw new Error("only "+$+" bytes available! programmer error!");var ue=new XMLHttpRequest;if(ue.open("GET",t,!1),$!==Te&&ue.setRequestHeader("Range","bytes="+Ce+"-"+nr),ue.responseType="arraybuffer",ue.overrideMimeType&&ue.overrideMimeType("text/plain; charset=x-user-defined"),ue.send(null),!(ue.status>=200&&ue.status<300||ue.status===304))throw new Error("Couldn't load "+t+". Status: "+ue.status);return ue.response!==void 0?new Uint8Array(ue.response||[]):Ae(ue.responseText||"",!0)},Tr=this;Tr.setDataGetter(Ce=>{var nr=Ce*Te,ue=(Ce+1)*Te-1;if(ue=Math.min(ue,$-1),typeof Tr.chunks[Ce]=="undefined"&&(Tr.chunks[Ce]=oe(nr,ue)),typeof Tr.chunks[Ce]=="undefined")throw new Error("doXHR failed!");return Tr.chunks[Ce]}),(se||!$)&&(Te=$=1,$=this.getter(0).length,Te=$,lr("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=$,this._chunkSize=Te,this.lengthKnown=!0},typeof XMLHttpRequest!="undefined"){if(!F)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var f=new l;Object.defineProperties(f,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var d={isDevice:!1,contents:f}}else var d={isDevice:!1,url:t};var y=a.createFile(e,r,d,n,u);d.contents?y.contents=d.contents:d.url&&(y.contents=null,y.url=d.url),Object.defineProperties(y,{usedBytes:{get:function(){return this.contents.length}}});var h={},R=Object.keys(y.stream_ops);R.forEach(k=>{var P=y.stream_ops[k];h[k]=function(){return a.forceLoadFile(y),P.apply(null,arguments)}});function x(k,P,$,Z,re){var se=k.node.contents;if(re>=se.length)return 0;var Te=Math.min(se.length-re,Z);if(se.slice)for(var oe=0;oe<Te;oe++)P[$+oe]=se[re+oe];else for(var oe=0;oe<Te;oe++)P[$+oe]=se.get(re+oe);return Te}return h.read=(k,P,$,Z,re)=>(a.forceLoadFile(y),x(k,P,$,Z,re)),h.mmap=(k,P,$,Z,re)=>{a.forceLoadFile(y);var se=_t(P);if(!se)throw new a.ErrnoError(48);return x(k,Y,se,P,$),{ptr:se,allocated:!0}},y.stream_ops=h,y}},wt=(e,r)=>e?Je(ie,e,r):"",te={DEFAULT_POLLMASK:5,calculateAt:function(e,r,t){if(G.isAbs(r))return r;var n;if(e===-100)n=a.cwd();else{var u=te.getStreamFromFD(e);n=u.path}if(r.length==0){if(!t)throw new a.ErrnoError(44);return n}return G.join2(n,r)},doStat:function(e,r,t){try{var n=e(r)}catch(d){if(d&&d.node&&G.normalize(r)!==G.normalize(a.getPath(d.node)))return-54;throw d}U[t>>2]=n.dev,U[t+4>>2]=n.mode,X[t+8>>2]=n.nlink,U[t+12>>2]=n.uid,U[t+16>>2]=n.gid,U[t+20>>2]=n.rdev,Q=[n.size>>>0,(N=n.size,+Math.abs(N)>=1?N>0?+Math.floor(N/4294967296)>>>0:~~+Math.ceil((N-+(~~N>>>0))/4294967296)>>>0:0)],U[t+24>>2]=Q[0],U[t+28>>2]=Q[1],U[t+32>>2]=4096,U[t+36>>2]=n.blocks;var u=n.atime.getTime(),l=n.mtime.getTime(),f=n.ctime.getTime();return Q=[Math.floor(u/1e3)>>>0,(N=Math.floor(u/1e3),+Math.abs(N)>=1?N>0?+Math.floor(N/4294967296)>>>0:~~+Math.ceil((N-+(~~N>>>0))/4294967296)>>>0:0)],U[t+40>>2]=Q[0],U[t+44>>2]=Q[1],X[t+48>>2]=u%1e3*1e3,Q=[Math.floor(l/1e3)>>>0,(N=Math.floor(l/1e3),+Math.abs(N)>=1?N>0?+Math.floor(N/4294967296)>>>0:~~+Math.ceil((N-+(~~N>>>0))/4294967296)>>>0:0)],U[t+56>>2]=Q[0],U[t+60>>2]=Q[1],X[t+64>>2]=l%1e3*1e3,Q=[Math.floor(f/1e3)>>>0,(N