jb4-ws-flv-d472901e.js 204 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import{d as Ii,k as ti,r as ji,s as _i,b as Li,o as Bi,x as Hi,X as Wi,a6 as zi,t as Ni,A as Vi,f as Gi,u as qi,a9 as Xi,a7 as Ki,P as Qi}from"./vue-bbe2430e.js";import{ba as Yi,bu as Zi,ac as Ji,V as eo}from"./radical-70d8c19d.js";import{o as ro}from"./index-f4b030ea.js";var kr=(h=>(h.VideoCodecInfo="videoCodecInfo",h.VideoFrame="videoFrame",h.Error="error",h))(kr||{}),lt=(h=>(h.AudioCodecInfo="audioCodecInfo",h.AudioFrame="audioFrame",h.Error="error",h))(lt||{}),Yt={},to={get exports(){return Yt},set exports(h){Yt=h}};(function(h){var a=Object.prototype.hasOwnProperty,o="~";function p(){}Object.create&&(p.prototype=Object.create(null),new p().__proto__||(o=!1));function y(k,w,$){this.fn=k,this.context=w,this.once=$||!1}function _(k,w,$,S,G){if(typeof $!="function")throw new TypeError("The listener must be a function");var Q=new y($,S||k,G),V=o?o+w:w;return k._events[V]?k._events[V].fn?k._events[V]=[k._events[V],Q]:k._events[V].push(Q):(k._events[V]=Q,k._eventsCount++),k}function b(k,w){--k._eventsCount===0?k._events=new p:delete k._events[w]}function F(){this._events=new p,this._eventsCount=0}F.prototype.eventNames=function(){var w=[],$,S;if(this._eventsCount===0)return w;for(S in $=this._events)a.call($,S)&&w.push(o?S.slice(1):S);return Object.getOwnPropertySymbols?w.concat(Object.getOwnPropertySymbols($)):w},F.prototype.listeners=function(w){var $=o?o+w:w,S=this._events[$];if(!S)return[];if(S.fn)return[S.fn];for(var G=0,Q=S.length,V=new Array(Q);G<Q;G++)V[G]=S[G].fn;return V},F.prototype.listenerCount=function(w){var $=o?o+w:w,S=this._events[$];return S?S.fn?1:S.length:0},F.prototype.emit=function(w,$,S,G,Q,V){var W=o?o+w:w;if(!this._events[W])return!1;var R=this._events[W],Z=arguments.length,B,te;if(R.fn){switch(R.once&&this.removeListener(w,R.fn,void 0,!0),Z){case 1:return R.fn.call(R.context),!0;case 2:return R.fn.call(R.context,$),!0;case 3:return R.fn.call(R.context,$,S),!0;case 4:return R.fn.call(R.context,$,S,G),!0;case 5:return R.fn.call(R.context,$,S,G,Q),!0;case 6:return R.fn.call(R.context,$,S,G,Q,V),!0}for(te=1,B=new Array(Z-1);te<Z;te++)B[te-1]=arguments[te];R.fn.apply(R.context,B)}else{var be=R.length,J;for(te=0;te<be;te++)switch(R[te].once&&this.removeListener(w,R[te].fn,void 0,!0),Z){case 1:R[te].fn.call(R[te].context);break;case 2:R[te].fn.call(R[te].context,$);break;case 3:R[te].fn.call(R[te].context,$,S);break;case 4:R[te].fn.call(R[te].context,$,S,G);break;default:if(!B)for(J=1,B=new Array(Z-1);J<Z;J++)B[J-1]=arguments[J];R[te].fn.apply(R[te].context,B)}}return!0},F.prototype.on=function(w,$,S){return _(this,w,$,S,!1)},F.prototype.once=function(w,$,S){return _(this,w,$,S,!0)},F.prototype.removeListener=function(w,$,S,G){var Q=o?o+w:w;if(!this._events[Q])return this;if(!$)return b(this,Q),this;var V=this._events[Q];if(V.fn)V.fn===$&&(!G||V.once)&&(!S||V.context===S)&&b(this,Q);else{for(var W=0,R=[],Z=V.length;W<Z;W++)(V[W].fn!==$||G&&!V[W].once||S&&V[W].context!==S)&&R.push(V[W]);R.length?this._events[Q]=R.length===1?R[0]:R:b(this,Q)}return this},F.prototype.removeAllListeners=function(w){var $;return w?($=o?o+w:w,this._events[$]&&b(this,$)):(this._events=new p,this._eventsCount=0),this},F.prototype.off=F.prototype.removeListener,F.prototype.addListener=F.prototype.on,F.prefixed=o,F.EventEmitter=F,h.exports=F})(to);const Di=Symbol("instance"),bi=Symbol("cacheResult");let Ei=class{constructor(a,o,p){this.oldState=a,this.newState=o,this.action=p,this.aborted=!1}abort(a){this.aborted=!0,qn.call(a,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}},ii=class extends Error{constructor(a,o,p){super(o),this.state=a,this.message=o,this.cause=p}};function no(h){return typeof h=="object"&&h&&"then"in h}const Gn=new Map;function oi(h,a,o={}){return(p,y,_)=>{const b=o.action||y;if(!o.context){const k=Gn.get(p)||[];Gn.has(p)||Gn.set(p,k),k.push({from:h,to:a,action:b})}const F=_.value;_.value=function(...k){let w=this;if(o.context&&(w=vr.get(typeof o.context=="function"?o.context.call(this,...k):o.context)),w.state===a)return w[bi];w.state instanceof Ei&&w.state.action==o.abortAction&&w.state.abort(w);let $=null;if(Array.isArray(h)?h.length==0?w.state instanceof Ei&&w.state.abort(w):(typeof w.state!="string"||!h.includes(w.state))&&($=new ii(w._state,`${w.name} ${b} to ${a} failed: current state ${w._state} not in from config`)):h!==w.state&&($=new ii(w._state,`${w.name} ${b} to ${a} failed: current state ${w._state} not from ${h}`)),$)if(o.fail)o.fail.call(this,$);else{if(o.ignoreError)return $;throw $}const S=w.state,G=new Ei(S,a,b);qn.call(w,G);const Q=W=>{var R;return w[bi]=W,G.aborted||(qn.call(w,a),(R=o.success)===null||R===void 0||R.call(this,w[bi])),W},V=W=>{const R=W instanceof Error?W.message:String(W);if(qn.call(w,S,W),o.fail)o.fail.call(this,new ii(w._state,`action '${b}' failed :${R}`,W instanceof Error?W:new Error(R)));else{if(o.ignoreError)return W;throw W}};try{const W=F.apply(this,k);return no(W)?W.then(Q).catch(V):Q(W)}catch(W){V(W)}}}}function io(...h){return(a,o,p)=>{const y=p.value,_=o;p.value=function(...b){if(!h.includes(this.state.toString()))throw new ii(this.state,`${this.name} ${_} failed: current state ${this.state} not in ${h}`);return y.apply(this,b)}}}const oo=(()=>typeof window<"u"&&window.__AFSM__?(o,p)=>{window.dispatchEvent(new CustomEvent(o,{detail:p}))}:typeof importScripts<"u"?(o,p)=>{postMessage({type:o,payload:p})}:()=>{})();function qn(h,a){const o=this._state;this._state=h;const p=h.toString();h&&this.emit(p,o),this.emit(vr.STATECHANGED,h,o,a),this.updateDevTools({value:h,old:o,err:a instanceof Error?a.message:String(a)})}let vr=class pr extends Yt{constructor(a,o,p){super(),this.name=a,this.groupName=o,this._state=pr.INIT,a||(a=Date.now().toString(36)),p?Object.setPrototypeOf(this,p):p=Object.getPrototypeOf(this),o||(this.groupName=this.constructor.name);const y=p[Di];y?this.name=y.name+"-"+y.count++:p[Di]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){const a=Object.getPrototypeOf(this),o=Gn.get(a)||[];let p=new Set,y=[],_=[];const b=new Set,F=Object.getPrototypeOf(a);Gn.has(F)&&(F.stateDiagram.forEach(w=>p.add(w)),F.allStates.forEach(w=>b.add(w))),o.forEach(({from:w,to:$,action:S})=>{typeof w=="string"?y.push({from:w,to:$,action:S}):w.length?w.forEach(G=>{y.push({from:G,to:$,action:S})}):_.push({to:$,action:S})}),y.forEach(({from:w,to:$,action:S})=>{b.add(w),b.add($),b.add(S+"ing"),p.add(`${w} --> ${S}ing : ${S}`),p.add(`${S}ing --> ${$} : ${S} 🟢`),p.add(`${S}ing --> ${w} : ${S} 🔴`)}),_.forEach(({to:w,action:$})=>{p.add(`${$}ing --> ${w} : ${$} 🟢`),b.forEach(S=>{S!==w&&p.add(`${S} --> ${$}ing : ${$}`)})});const k=[...p];return Object.defineProperties(a,{stateDiagram:{value:k},allStates:{value:b}}),k}static get(a){let o;return typeof a=="string"?(o=pr.instances.get(a),o||pr.instances.set(a,o=new pr(a,void 0,Object.create(pr.prototype)))):(o=pr.instances2.get(a),o||pr.instances2.set(a,o=new pr(a.constructor.name,void 0,Object.create(pr.prototype)))),o}static getState(a){var o;return(o=pr.get(a))===null||o===void 0?void 0:o.state}updateDevTools(a={}){oo(pr.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},a))}get state(){return this._state}set state(a){qn.call(this,a)}};vr.STATECHANGED="stateChanged";vr.UPDATEAFSM="updateAFSM";vr.INIT="[*]";vr.ON="on";vr.OFF="off";vr.instances=new Map;vr.instances2=new WeakMap;var pt=(h=>(h.CONNECTED="connected",h.DISCONNECTED="disconnected",h.RECONNECTED="reconnected",h))(pt||{}),so=globalThis&&globalThis.__awaiter||function(h,a,o,p){function y(_){return _ instanceof o?_:new o(function(b){b(_)})}return new(o||(o=Promise))(function(_,b){function F($){try{w(p.next($))}catch(S){b(S)}}function k($){try{w(p.throw($))}catch(S){b(S)}}function w($){$.done?_($.value):y($.value).then(F,k)}w((p=p.apply(h,a||[])).next())})};const Ti=Symbol(32),$i=Symbol(16),Si=Symbol(8);class Qn{constructor(a){this.g=a,this.consumed=0,a&&(this.need=a.next().value)}setG(a){this.g=a,this.demand(a.next().value,!0)}consume(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}demand(a,o){return o&&this.consume(),this.need=a,this.flush()}read(a){return so(this,void 0,void 0,function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise((o,p)=>{var y;this.reject=p,this.resolve=b=>{delete this.lastReadPromise,delete this.resolve,delete this.need,o(b)},this.demand(a,!0)||(y=this.pull)===null||y===void 0||y.call(this,a)})})}readU32(){return this.read(Ti)}readU16(){return this.read($i)}readU8(){return this.read(Si)}close(){var a;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),(a=this.reject)===null||a===void 0||a.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let a=null;const o=this.buffer.subarray(this.consumed);let p=0;const y=_=>o.length<(p=_);if(typeof this.need=="number"){if(y(this.need))return;a=o.subarray(0,p)}else if(this.need===Ti){if(y(4))return;a=o[0]<<24|o[1]<<16|o[2]<<8|o[3]}else if(this.need===$i){if(y(2))return;a=o[0]<<8|o[1]}else if(this.need===Si){if(y(1))return;a=o[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(y(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(o.subarray(0,p)),a=this.need}else if(this.g){this.g.throw(new Error("Unsupported type"));return}}else{if(y(this.need.byteLength))return;new Uint8Array(this.need).set(o.subarray(0,p)),a=this.need}return this.consumed+=p,this.g?this.demand(this.g.next(a).value,!0):this.resolve&&this.resolve(a),a}write(a){if(a instanceof Uint8Array?this.malloc(a.length).set(a):"buffer"in a?this.malloc(a.byteLength).set(new Uint8Array(a.buffer,a.byteOffset,a.byteLength)):this.malloc(a.byteLength).set(new Uint8Array(a)),this.g||this.resolve)this.flush();else return new Promise(o=>this.pull=o)}writeU32(a){this.malloc(4).set([a>>24&255,a>>16&255,a>>8&255,a&255]),this.flush()}writeU16(a){this.malloc(2).set([a>>8&255,a&255]),this.flush()}writeU8(a){this.malloc(1)[0]=a,this.flush()}malloc(a){if(this.buffer){const o=this.buffer.length,p=o+a;if(p<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,p);else{const y=new Uint8Array(p);y.set(this.buffer),this.buffer=y}return this.buffer.subarray(o,p)}else return this.buffer=new Uint8Array(a),this.buffer}}Qn.U32=Ti;Qn.U16=$i;Qn.U8=Si;var ao=Object.defineProperty,uo=Object.getOwnPropertyDescriptor,Yn=(h,a,o,p)=>{for(var y=p>1?void 0:p?uo(a,o):a,_=h.length-1,b;_>=0;_--)(b=h[_])&&(y=(p?b(a,o,y):b(y))||y);return p&&y&&ao(a,o,y),y};function xi(h,a=1,o=1){return h<=1?o:xi(h-1,o,a+o)}function fo(h){const a=Math.round(h/2)+1;return a>6?13*1e3:xi(a)*1e3}class Fi{constructor(){this.total=0,this._buffer=0,this.lastTime=0,this._bps=0}add(a){const o=Date.now();this._buffer+=a,this.lastTime===0?this.lastTime=o:o-this.lastTime>1e3&&(this._bps=this._buffer*1e3/(o-this.lastTime)>>0,this._buffer=0,this.lastTime=o),this.total+=a}get bps(){return Date.now()-this.lastTime>5e3?0:this._bps}}class Zt extends vr{constructor(a,o={}){super(a||"conn","Connection"),this.url=a,this.options=o,this.up=new Fi,this.down=new Fi,this.underlyingSink={write:async p=>{var y;return this.down.add(p.length||p.byteLength),(y=this.oput)==null?void 0:y.write(p)}},this.options.reconnectTimeout||(this.options.reconnectTimeout=fo)}read(a){return Promise.reject("not connected")}async connect(){this.abortCtrl=new AbortController,`${this.url}`,console.time(this.url),this.onConnected(await this._connect())}_close(){}_send(a){}async reconnect(){`${this.url}`,console.time(this.url),this.abortCtrl=new AbortController,this.onConnected(await this._connect())}onConnected(a){if(console.timeEnd(this.url),!!a)return this.oput||(this.oput=new Qn),this.read=this.oput.read.bind(this.oput),a.pipeTo(new WritableStream(this.underlyingSink),this.abortCtrl).catch(o=>{this.abortCtrl.signal.aborted||this.disconnect(o)})}disconnect(a){console.warn(`disconnect: ${this.url}`,a),this.options.reconnectCount&&this.reconnectAfter()}reconnectAfter(a=1e3,o=0){setTimeout(()=>{this.reconnect().catch(p=>{`${this.url}`,o<this.options.reconnectCount&&this.reconnectAfter(this.options.reconnectTimeout(o),o+1)})},a)}close(){var a;(a=this.abortCtrl)==null||a.abort(),this._close()}send(a){this.up.add(a.byteLength-("byteOffset"in a?a.byteOffset:0)),this._send(a)}}Yn([io(pt.CONNECTED)],Zt.prototype,"read",1);Yn([oi([pt.DISCONNECTED,vr.INIT],pt.CONNECTED)],Zt.prototype,"connect",1);Yn([oi(pt.DISCONNECTED,pt.RECONNECTED)],Zt.prototype,"reconnect",1);Yn([oi(pt.CONNECTED,pt.DISCONNECTED)],Zt.prototype,"disconnect",1);Yn([oi([],vr.INIT)],Zt.prototype,"close",1);class lo extends Zt{async _connect(){const a=new WebSocket(this.url);return this.ws=a,a.binaryType="arraybuffer",new Promise((o,p)=>{a.onerror=p,a.onopen=()=>{o(new ReadableStream({start:y=>{a.onclose=_=>y.error(_),a.onmessage=_=>y.enqueue(_.data)}}))}})}_close(){var a;(a=this.ws)==null||a.close(1e3,"close")}_send(a){var o;(o=this.ws)==null||o.send(a)}}class co extends Yt.EventEmitter{constructor(a,o="recvonly"){super(),this.id=a,this.direction=o}get mediaStream(){return this._mediaStream}set mediaStream(a){this._mediaStream=a,a&&this.emit("change",a)}set audioTrack(a){if(this._audioTrack=a,this._mediaStream){const o=this._mediaStream.getAudioTracks()[0];o&&this._mediaStream.removeTrack(o)}a&&(this._mediaStream?this._mediaStream.addTrack(a):this._mediaStream=new MediaStream([a])),this._mediaStream&&this.emit("change",this._mediaStream)}get audioTrack(){var a;return this._audioTrack||((a=this._mediaStream)==null?void 0:a.getAudioTracks()[0])}set videoTrack(a){if(this._videoTrack=a,this._mediaStream){const o=this._mediaStream.getVideoTracks()[0];o&&this._mediaStream.removeTrack(o)}a&&(this._mediaStream?this._mediaStream.addTrack(a):this._mediaStream=new MediaStream([a])),this._mediaStream&&this.emit("change",this._mediaStream)}get videoTrack(){var a;return this._videoTrack||((a=this._mediaStream)==null?void 0:a.getVideoTracks()[0])}close(){this.emit("close")}}const Ri=Symbol("instance"),ni=Symbol("cacheResult");class Pi{constructor(a,o,p){this.oldState=a,this.newState=o,this.action=p,this.aborted=!1}abort(a){this.aborted=!0,Kn.call(a,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}}class ki extends Error{constructor(a,o,p){super(o),this.state=a,this.message=o,this.cause=p}}function ho(h){return typeof h=="object"&&h&&"then"in h}const Xn=new Map;function Oe(h,a,o={}){return(p,y,_)=>{const b=o.action||y;if(!o.context){const k=Xn.get(p)||[];Xn.has(p)||Xn.set(p,k),k.push({from:h,to:a,action:b})}const F=_.value;_.value=function(...k){let w=this;if(o.context&&(w=pe.get(typeof o.context=="function"?o.context.call(this,...k):o.context)),w.state===a)return o.sync?w[ni]:Promise.resolve(w[ni]);w.state instanceof Pi&&w.state.action==o.abortAction&&w.state.abort(w);let $=null;Array.isArray(h)?h.length==0?w.state instanceof Pi&&w.state.abort(w):(typeof w.state!="string"||!h.includes(w.state))&&($=new ki(w._state,`${w.name} ${b} to ${a} failed: current state ${w._state} not from ${h.join("|")}`)):h!==w.state&&($=new ki(w._state,`${w.name} ${b} to ${a} failed: current state ${w._state} not from ${h}`));const S=R=>{if(o.fail&&o.fail.call(this,R),o.sync){if(o.ignoreError)return R;throw R}else return o.ignoreError?Promise.resolve(R):Promise.reject(R)};if($)return S($);const G=w.state,Q=new Pi(G,a,b);Kn.call(w,Q);const V=R=>{var Z;return w[ni]=R,Q.aborted||(Kn.call(w,a),(Z=o.success)===null||Z===void 0||Z.call(this,w[ni])),R},W=R=>(Kn.call(w,G,R),S(R));try{const R=F.apply(this,k);return ho(R)?R.then(V).catch(W):o.sync?V(R):Promise.resolve(V(R))}catch(R){return W(R)}}}}function Ai(...h){return(a,o,p)=>{const y=p.value,_=o;p.value=function(...b){if(!h.includes(this.state.toString()))throw new ki(this.state,`${this.name} ${_} failed: current state ${this.state} not in ${h}`);return y.apply(this,b)}}}const po=(()=>typeof window<"u"&&window.__AFSM__?(o,p)=>{window.dispatchEvent(new CustomEvent(o,{detail:p}))}:typeof importScripts<"u"?(o,p)=>{postMessage({type:o,payload:p})}:()=>{})();function Kn(h,a){const o=this._state;this._state=h;const p=h.toString();h&&this.emit(p,o),this.emit(pe.STATECHANGED,h,o,a),this.updateDevTools({value:h,old:o,err:a instanceof Error?a.message:String(a)})}class pe extends Yt{constructor(a,o,p){super(),this.name=a,this.groupName=o,this._state=pe.INIT,a||(a=Date.now().toString(36)),p?Object.setPrototypeOf(this,p):p=Object.getPrototypeOf(this),o||(this.groupName=this.constructor.name);const y=p[Ri];y?this.name=y.name+"-"+y.count++:p[Ri]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){const a=Object.getPrototypeOf(this),o=Xn.get(a)||[];let p=new Set,y=[],_=[];const b=new Set,F=Object.getPrototypeOf(a);Xn.has(F)&&(F.stateDiagram.forEach(w=>p.add(w)),F.allStates.forEach(w=>b.add(w))),o.forEach(({from:w,to:$,action:S})=>{typeof w=="string"?y.push({from:w,to:$,action:S}):w.length?w.forEach(G=>{y.push({from:G,to:$,action:S})}):_.push({to:$,action:S})}),y.forEach(({from:w,to:$,action:S})=>{b.add(w),b.add($),b.add(S+"ing"),p.add(`${w} --> ${S}ing : ${S}`),p.add(`${S}ing --> ${$} : ${S} 🟢`),p.add(`${S}ing --> ${w} : ${S} 🔴`)}),_.forEach(({to:w,action:$})=>{p.add(`${$}ing --> ${w} : ${$} 🟢`),b.forEach(S=>{S!==w&&p.add(`${S} --> ${$}ing : ${$}`)})});const k=[...p];return Object.defineProperties(a,{stateDiagram:{value:k},allStates:{value:b}}),k}static get(a){let o;return typeof a=="string"?(o=pe.instances.get(a),o||pe.instances.set(a,o=new pe(a,void 0,Object.create(pe.prototype)))):(o=pe.instances2.get(a),o||pe.instances2.set(a,o=new pe(a.constructor.name,void 0,Object.create(pe.prototype)))),o}static getState(a){var o;return(o=pe.get(a))===null||o===void 0?void 0:o.state}updateDevTools(a={}){po(pe.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},a))}get state(){return this._state}set state(a){Kn.call(this,a)}}pe.STATECHANGED="stateChanged";pe.UPDATEAFSM="updateAFSM";pe.INIT="[*]";pe.ON="on";pe.OFF="off";pe.instances=new Map;pe.instances2=new WeakMap;var vo=Object.defineProperty,mo=Object.getOwnPropertyDescriptor,si=(h,a,o,p)=>{for(var y=p>1?void 0:p?mo(a,o):a,_=h.length-1,b;_>=0;_--)(b=h[_])&&(y=(p?b(a,o,y):b(y))||y);return p&&y&&vo(a,o,y),y};function yo(){var h;self.onmessage=a=>{if(a.data.type==="init"){const{canvas:o,wasmScript:p,wasmBinary:y}=a.data,_=o==null?void 0:o.getContext("2d");let b=0,F=0;const k={wasmBinary:y,postRun:()=>{h=new k.VideoDecoder({videoInfo(w,$){b=w,F=$},yuvData(w,$){const S=b*F,G=S>>2;let Q=k.HEAPU32[w>>2],V=k.HEAPU32[(w>>2)+1],W=k.HEAPU32[(w>>2)+2],R=k.HEAPU8.subarray(Q,Q+S),Z=k.HEAPU8.subarray(V,V+G),B=k.HEAPU8.subarray(W,W+G);const te=new Uint8Array(S+G+G);te.set(R),te.set(Z,S),te.set(B,S+G);const be=new VideoFrame(te,{codedWidth:b,codedHeight:F,format:"I420",timestamp:$});o?(_==null||_.drawImage(be,0,0,o.width,o.height),_==null||_.commit()):self.postMessage({type:"yuvData",videoFrame:be},[be])}}),self.postMessage({type:"ready"})}};Function("var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;return "+p)()(k)}else if(a.data.type==="decode"){const{packet:o}=a.data;h==null||h.decode(o.data,o.type=="key",o.timestamp)}else if(a.data.type==="setCodec"){const{codec:o,format:p,description:y}=a.data;h==null||h.setCodec(o,p,y??"")}}}class Jt extends pe{constructor(a,o,p=!1,y,_=!1){super(),this.createModule=a,this.wasmBinary=o,this.workerMode=p,this.canvas=y,this.yuvMode=_,this.module={},this.width=0,this.height=0}async initialize(a){var p;if(this.workerMode){const y=/\{(.+)\}/s.exec(yo.toString())[1];this.worker=new Worker(URL.createObjectURL(new Blob([y],{type:"text/javascript"})));const _=(p=this.canvas)==null?void 0:p.transferControlToOffscreen(),b=await this.wasmBinary;return console.warn("worker mode",b),this.worker.postMessage({type:"init",canvas:_,wasmScript:this.createModule.toString(),wasmBinary:b},_?[_,b]:[b]),new Promise(F=>{this.worker.onmessage=k=>{if(k.data.type==="ready")delete this.wasmBinary,F(),console.warn("worker mode initialize success");else if(k.data.type==="yuvData"){const{videoFrame:w}=k.data;this.emit(kr.VideoFrame,w)}}})}const o=this.module;return this.wasmBinary&&(o.wasmBinary=await this.wasmBinary),o.print=y=>console.log(y),o.printErr=y=>console.log(`[JS] ERROR: ${y}`),o.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),new Promise(y=>{o.postRun=_=>{this.decoder=new this.module.VideoDecoder(this),y()},a&&Object.assign(o,a),this.createModule(o)})}configure(a){var y,_;this.config=a;const o=this.config.codec.startsWith("avc")?"avc":"hevc",p=this.config.description?o=="avc"?"avcc":"hvcc":"annexb";(y=this.decoder)==null||y.setCodec(o,p,this.config.description??""),(_=this.worker)==null||_.postMessage({type:"setCodec",codec:o,format:p,description:this.config.description})}decode(a){var o,p;(o=this.decoder)==null||o.decode(a.data,a.type=="key",a.timestamp),this.state==="configured"&&((p=this.worker)==null||p.postMessage({type:"decode",packet:a}))}flush(){}reset(){this.config=void 0,this.decoder&&this.decoder.clear()}close(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}videoInfo(a,o){this.width=a,this.height=o;let p={width:a,height:o};this.emit(kr.VideoCodecInfo,p)}yuvData(a,o){if(!this.module)return;const p=this.width*this.height,y=p>>2;let _=this.module.HEAPU32[a>>2],b=this.module.HEAPU32[(a>>2)+1],F=this.module.HEAPU32[(a>>2)+2],k=this.module.HEAPU8.subarray(_,_+p),w=this.module.HEAPU8.subarray(b,b+y),$=this.module.HEAPU8.subarray(F,F+y);if(this.yuvMode){this.emit(kr.VideoFrame,{y:k,u:w,v:$,timestamp:o});return}const S=new Uint8Array(p+y+y);S.set(k),S.set(w,p),S.set($,p+y),this.emit(kr.VideoFrame,new VideoFrame(S,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:o}))}errorInfo(a){let o={errMsg:a};this.emit(kr.Error,o)}}si([Oe([pe.INIT,"closed"],"initialized")],Jt.prototype,"initialize",1);si([Oe("initialized","configured",{sync:!0})],Jt.prototype,"configure",1);si([Oe([],pe.INIT,{sync:!0})],Jt.prototype,"reset",1);si([Oe([],"closed",{sync:!0})],Jt.prototype,"close",1);var go=(()=>{var h=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(a={}){var o=a,p,y;o.ready=new Promise((e,r)=>{p=e,y=r});var _=Object.assign({},o),b="./this.program",F=typeof window=="object",k=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&process.versions.node;var w="";function $(e){return o.locateFile?o.locateFile(e,w):w+e}var S,G,Q;(F||k)&&(k?w=self.location.href:typeof document<"u"&&document.currentScript&&(w=document.currentScript.src),h&&(w=h),w.indexOf("blob:")!==0?w=w.substr(0,w.replace(/[?#].*/,"").lastIndexOf("/")+1):w="",S=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},k&&(Q=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),G=(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)});var V=o.print||console.log.bind(console),W=o.printErr||console.error.bind(console);Object.assign(o,_),_=null,o.arguments&&o.arguments,o.thisProgram&&(b=o.thisProgram),o.quit&&o.quit;var R;o.wasmBinary&&(R=o.wasmBinary),o.noExitRuntime,typeof WebAssembly!="object"&&je("no native wasm support detected");var Z,B,te=!1;function be(e,r){e||je(r)}var J,Y,we,ke,z,N,ze,he;function se(){var e=Z.buffer;o.HEAP8=J=new Int8Array(e),o.HEAP16=we=new Int16Array(e),o.HEAP32=z=new Int32Array(e),o.HEAPU8=Y=new Uint8Array(e),o.HEAPU16=ke=new Uint16Array(e),o.HEAPU32=N=new Uint32Array(e),o.HEAPF32=ze=new Float32Array(e),o.HEAPF64=he=new Float64Array(e)}var ve,Jr=[],Ar=[],mr=[];function xr(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)yr(o.preRun.shift());Dr(Jr)}function Ir(){!o.noFSInit&&!i.init.initialized&&i.init(),i.ignorePermissions=!1,Dr(Ar)}function Ge(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)Te(o.postRun.shift());Dr(mr)}function yr(e){Jr.unshift(e)}function Ce(e){Ar.unshift(e)}function Te(e){mr.unshift(e)}var Se=0,ir=null;function ri(e){return e}function er(e){Se++,o.monitorRunDependencies&&o.monitorRunDependencies(Se)}function lr(e){if(Se--,o.monitorRunDependencies&&o.monitorRunDependencies(Se),Se==0&&ir){var r=ir;ir=null,r()}}function je(e){o.onAbort&&o.onAbort(e),e="Aborted("+e+")",W(e),te=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw y(r),r}var Ut="data:application/octet-stream;base64,";function vt(e){return e.startsWith(Ut)}var qe;qe="videodec.wasm",vt(qe)||(qe=$(qe));function jr(e){if(e==qe&&R)return new Uint8Array(R);if(Q)return Q(e);throw"both async and sync fetching of the wasm failed"}function en(e){return!R&&(F||k)&&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(()=>jr(e)):Promise.resolve().then(()=>jr(e))}function et(e,r,t){return en(e).then(n=>WebAssembly.instantiate(n,r)).then(n=>n).then(t,n=>{W("failed to asynchronously prepare wasm: "+n),je(n)})}function rn(e,r,t,n){return!e&&typeof WebAssembly.instantiateStreaming=="function"&&!vt(r)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(s=>{var u=WebAssembly.instantiateStreaming(s,t);return u.then(n,function(l){return W("wasm streaming compile failed: "+l),W("falling back to ArrayBuffer instantiation"),et(r,t,n)})}):et(r,t,n)}function tn(){var e={a:wi};function r(n,s){var u=n.exports;return B=u,Z=B.E,se(),ve=B.H,Ce(B.F),lr(),u}er();function t(n){r(n.instance)}if(o.instantiateWasm)try{return o.instantiateWasm(e,r)}catch(n){W("Module.instantiateWasm callback failed with error: "+n),y(n)}return rn(R,qe,e,t).catch(y),{}}var M,ee,Dr=e=>{for(;e.length>0;)e.shift()(o)};function Le(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(r){N[this.ptr+4>>2]=r},this.get_type=function(){return N[this.ptr+4>>2]},this.set_destructor=function(r){N[this.ptr+8>>2]=r},this.get_destructor=function(){return N[this.ptr+8>>2]},this.set_caught=function(r){r=r?1:0,J[this.ptr+12>>0]=r},this.get_caught=function(){return J[this.ptr+12>>0]!=0},this.set_rethrown=function(r){r=r?1:0,J[this.ptr+13>>0]=r},this.get_rethrown=function(){return J[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){N[this.ptr+16>>2]=r},this.get_adjusted_ptr=function(){return N[this.ptr+16>>2]},this.get_exception_ptr=function(){var r=Nn(this.get_type());if(r)return N[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var cr=0;function gr(e,r,t){var n=new Le(e);throw n.init(r,t),cr=e,cr}var rt=e=>(z[Wn()>>2]=e,e),K={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 s=e[n];s==="."?e.splice(n,1):s===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=K.isAbs(e),t=e.substr(-1)==="/";return e=K.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=K.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=K.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 K.normalize(e.join("/"))},join2:(e,r)=>K.normalize(e+"/"+r)},de=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return e=>crypto.getRandomValues(e);je("initRandomDevice")},tt=e=>(tt=de())(e),Pe={resolve:function(){for(var e="",r=!1,t=arguments.length-1;t>=-1&&!r;t--){var n=t>=0?arguments[t]:i.cwd();if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,r=K.isAbs(n)}return e=K.normalizeArray(e.split("/").filter(s=>!!s),!r).join("/"),(r?"/":"")+e||"."},relative:(e,r)=>{e=Pe.resolve(e).substr(1),r=Pe.resolve(r).substr(1);function t(m){for(var C=0;C<m.length&&m[C]==="";C++);for(var A=m.length-1;A>=0&&m[A]==="";A--);return C>A?[]:m.slice(C,A-C+1)}for(var n=t(e.split("/")),s=t(r.split("/")),u=Math.min(n.length,s.length),l=u,f=0;f<u;f++)if(n[f]!==s[f]){l=f;break}for(var g=[],f=l;f<n.length;f++)g.push("..");return g=g.concat(s.slice(l)),g.join("/")}},wr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Xe=(e,r,t)=>{for(var n=r+t,s=r;e[s]&&!(s>=n);)++s;if(s-r>16&&e.buffer&&wr)return wr.decode(e.subarray(r,s));for(var u="";r<s;){var l=e[r++];if(!(l&128)){u+=String.fromCharCode(l);continue}var f=e[r++]&63;if((l&224)==192){u+=String.fromCharCode((l&31)<<6|f);continue}var g=e[r++]&63;if((l&240)==224?l=(l&15)<<12|f<<6|g:l=(l&7)<<18|f<<12|g<<6|e[r++]&63,l<65536)u+=String.fromCharCode(l);else{var m=l-65536;u+=String.fromCharCode(55296|m>>10,56320|m&1023)}}return u},Be=[],Lr=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},Br=(e,r,t,n)=>{if(!(n>0))return 0;for(var s=t,u=t+n-1,l=0;l<e.length;++l){var f=e.charCodeAt(l);if(f>=55296&&f<=57343){var g=e.charCodeAt(++l);f=65536+((f&1023)<<10)|g&1023}if(f<=127){if(t>=u)break;r[t++]=f}else if(f<=2047){if(t+1>=u)break;r[t++]=192|f>>6,r[t++]=128|f&63}else if(f<=65535){if(t+2>=u)break;r[t++]=224|f>>12,r[t++]=128|f>>6&63,r[t++]=128|f&63}else{if(t+3>=u)break;r[t++]=240|f>>18,r[t++]=128|f>>12&63,r[t++]=128|f>>6&63,r[t++]=128|f&63}}return r[t]=0,t-s};function Hr(e,r,t){var n=t>0?t:Lr(e)+1,s=new Array(n),u=Br(e,s,0,s.length);return r&&(s.length=u),s}var mt=()=>{if(!Be.length){var e=null;if(typeof window<"u"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=`
  2. `)):typeof readline=="function"&&(e=readline(),e!==null&&(e+=`
  3. `)),!e)return null;Be=Hr(e,!0)}return Be.shift()},Ue={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){Ue.ttys[e]={input:[],output:[],ops:r},i.registerDevice(e,Ue.stream_ops)},stream_ops:{open:function(e){var r=Ue.ttys[e.node.rdev];if(!r)throw new i.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,s){if(!e.tty||!e.tty.ops.get_char)throw new i.ErrnoError(60);for(var u=0,l=0;l<n;l++){var f;try{f=e.tty.ops.get_char(e.tty)}catch{throw new i.ErrnoError(29)}if(f===void 0&&u===0)throw new i.ErrnoError(6);if(f==null)break;u++,r[t+l]=f}return u&&(e.node.timestamp=Date.now()),u},write:function(e,r,t,n,s){if(!e.tty||!e.tty.ops.put_char)throw new i.ErrnoError(60);try{for(var u=0;u<n;u++)e.tty.ops.put_char(e.tty,r[t+u])}catch{throw new i.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),u}},default_tty_ops:{get_char:function(e){return mt()},put_char:function(e,r){r===null||r===10?(V(Xe(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(V(Xe(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?(W(Xe(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(W(Xe(e.output,0)),e.output=[])}}},nt=e=>{je()},H={ops_table:null,mount(e){return H.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(i.isBlkdev(t)||i.isFIFO(t))throw new i.ErrnoError(63);H.ops_table||(H.ops_table={dir:{node:{getattr:H.node_ops.getattr,setattr:H.node_ops.setattr,lookup:H.node_ops.lookup,mknod:H.node_ops.mknod,rename:H.node_ops.rename,unlink:H.node_ops.unlink,rmdir:H.node_ops.rmdir,readdir:H.node_ops.readdir,symlink:H.node_ops.symlink},stream:{llseek:H.stream_ops.llseek}},file:{node:{getattr:H.node_ops.getattr,setattr:H.node_ops.setattr},stream:{llseek:H.stream_ops.llseek,read:H.stream_ops.read,write:H.stream_ops.write,allocate:H.stream_ops.allocate,mmap:H.stream_ops.mmap,msync:H.stream_ops.msync}},link:{node:{getattr:H.node_ops.getattr,setattr:H.node_ops.setattr,readlink:H.node_ops.readlink},stream:{}},chrdev:{node:{getattr:H.node_ops.getattr,setattr:H.node_ops.setattr},stream:i.chrdev_stream_ops}});var s=i.createNode(e,r,t,n);return i.isDir(s.mode)?(s.node_ops=H.ops_table.dir.node,s.stream_ops=H.ops_table.dir.stream,s.contents={}):i.isFile(s.mode)?(s.node_ops=H.ops_table.file.node,s.stream_ops=H.ops_table.file.stream,s.usedBytes=0,s.contents=null):i.isLink(s.mode)?(s.node_ops=H.ops_table.link.node,s.stream_ops=H.ops_table.link.stream):i.isChrdev(s.mode)&&(s.node_ops=H.ops_table.chrdev.node,s.stream_ops=H.ops_table.chrdev.stream),s.timestamp=Date.now(),e&&(e.contents[r]=s,e.timestamp=s.timestamp),s},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 s=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(s.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=i.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,i.isDir(e.mode)?r.size=4096:i.isFile(e.mode)?r.size=e.usedBytes:i.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&&H.resizeFileStorage(e,r.size)},lookup(e,r){throw i.genericErrors[44]},mknod(e,r,t,n){return H.createNode(e,r,t,n)},rename(e,r,t){if(i.isDir(e.mode)){var n;try{n=i.lookupNode(r,t)}catch{}if(n)for(var s in n.contents)throw new i.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=i.lookupNode(e,r);for(var n in t.contents)throw new i.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=H.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!i.isLink(e.mode))throw new i.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,s){var u=e.node.contents;if(s>=e.node.usedBytes)return 0;var l=Math.min(e.node.usedBytes-s,n);if(l>8&&u.subarray)r.set(u.subarray(s,s+l),t);else for(var f=0;f<l;f++)r[t+f]=u[s+f];return l},write(e,r,t,n,s,u){if(!n)return 0;var l=e.node;if(l.timestamp=Date.now(),r.subarray&&(!l.contents||l.contents.subarray)){if(u)return l.contents=r.subarray(t,t+n),l.usedBytes=n,n;if(l.usedBytes===0&&s===0)return l.contents=r.slice(t,t+n),l.usedBytes=n,n;if(s+n<=l.usedBytes)return l.contents.set(r.subarray(t,t+n),s),n}if(H.expandFileStorage(l,s+n),l.contents.subarray&&r.subarray)l.contents.set(r.subarray(t,t+n),s);else for(var f=0;f<n;f++)l.contents[s+f]=r[t+f];return l.usedBytes=Math.max(l.usedBytes,s+n),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&i.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new i.ErrnoError(28);return n},allocate(e,r,t){H.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t)},mmap(e,r,t,n,s){if(!i.isFile(e.node.mode))throw new i.ErrnoError(43);var u,l,f=e.node.contents;if(!(s&2)&&f.buffer===J.buffer)l=!1,u=f.byteOffset;else{if((t>0||t+r<f.length)&&(f.subarray?f=f.subarray(t,t+r):f=Array.prototype.slice.call(f,t,t+r)),l=!0,u=nt(),!u)throw new i.ErrnoError(48);J.set(f,u)}return{ptr:u,allocated:l}},msync(e,r,t,n,s){return H.stream_ops.write(e,r,0,n,t,!1),0}}},Mt=(e,r,t,n)=>{var s=n?"":`al ${e}`;G(e,u=>{be(u,`Loading data file "${e}" failed (no arrayBuffer).`),r(new Uint8Array(u)),s&&lr()},u=>{if(t)t();else throw`Loading data file "${e}" failed.`}),s&&er()},xt=o.preloadPlugins||[];function It(e,r,t,n){typeof Browser<"u"&&Browser.init();var s=!1;return xt.forEach(function(u){s||u.canHandle(r)&&(u.handle(e,r,t,n),s=!0)}),s}function nn(e,r,t,n,s,u,l,f,g,m){var C=r?Pe.resolve(K.join2(e,r)):e;function A(T){function P(I){m&&m(),f||i.createDataFile(e,r,I,n,s,g),u&&u(),lr()}It(T,C,P,()=>{l&&l(),lr()})||P(T)}er(),typeof t=="string"?Mt(t,T=>A(T),l):A(t)}function on(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}function or(e,r){var t=0;return e&&(t|=365),r&&(t|=146),t}var i={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=Pe.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 i.ErrnoError(32);for(var n=e.split("/").filter(A=>!!A),s=i.root,u="/",l=0;l<n.length;l++){var f=l===n.length-1;if(f&&r.parent)break;if(s=i.lookupNode(s,n[l]),u=K.join2(u,n[l]),i.isMountpoint(s)&&(!f||f&&r.follow_mount)&&(s=s.mounted.root),!f||r.follow)for(var g=0;i.isLink(s.mode);){var m=i.readlink(u);u=Pe.resolve(K.dirname(u),m);var C=i.lookupPath(u,{recurse_count:r.recurse_count+1});if(s=C.node,g++>40)throw new i.ErrnoError(32)}}return{path:u,node:s}},getPath:e=>{for(var r;;){if(i.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)%i.nameTable.length},hashAddNode:e=>{var r=i.hashName(e.parent.id,e.name);e.name_next=i.nameTable[r],i.nameTable[r]=e},hashRemoveNode:e=>{var r=i.hashName(e.parent.id,e.name);if(i.nameTable[r]===e)i.nameTable[r]=e.name_next;else for(var t=i.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode:(e,r)=>{var t=i.mayLookup(e);if(t)throw new i.ErrnoError(t,e);for(var n=i.hashName(e.id,r),s=i.nameTable[n];s;s=s.name_next){var u=s.name;if(s.parent.id===e.id&&u===r)return s}return i.lookup(e,r)},createNode:(e,r,t,n)=>{var s=new i.FSNode(e,r,t,n);return i.hashAddNode(s),s},destroyNode:e=>{i.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)=>i.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=i.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate:(e,r)=>{try{var t=i.lookupNode(e,r);return 20}catch{}return i.nodePermissions(e,"wx")},mayDelete:(e,r,t)=>{var n;try{n=i.lookupNode(e,r)}catch(u){return u.errno}var s=i.nodePermissions(e,"wx");if(s)return s;if(t){if(!i.isDir(n.mode))return 54;if(i.isRoot(n)||i.getPath(n)===i.cwd())return 10}else if(i.isDir(n.mode))return 31;return 0},mayOpen:(e,r)=>e?i.isLink(e.mode)?32:i.isDir(e.mode)&&(i.flagsToPermissionString(r)!=="r"||r&512)?31:i.nodePermissions(e,i.flagsToPermissionString(r)):44,MAX_OPEN_FDS:4096,nextfd:()=>{for(var e=0;e<=i.MAX_OPEN_FDS;e++)if(!i.streams[e])return e;throw new i.ErrnoError(33)},getStreamChecked:e=>{var r=i.getStream(e);if(!r)throw new i.ErrnoError(8);return r},getStream:e=>i.streams[e],createStream:(e,r=-1)=>(i.FSStream||(i.FSStream=function(){this.shared={}},i.FSStream.prototype={},Object.defineProperties(i.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 i.FSStream,e),r==-1&&(r=i.nextfd()),e.fd=r,i.streams[r]=e,e),closeStream:e=>{i.streams[e]=null},chrdev_stream_ops:{open:e=>{var r=i.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new i.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice:(e,r)=>{i.devices[e]={stream_ops:r}},getDevice:e=>i.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),i.syncFSRequests++,i.syncFSRequests>1&&W(`warning: ${i.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=i.getMounts(i.root.mount),n=0;function s(l){return i.syncFSRequests--,r(l)}function u(l){if(l)return u.errored?void 0:(u.errored=!0,s(l));++n>=t.length&&s(null)}t.forEach(l=>{if(!l.type.syncfs)return u(null);l.type.syncfs(l,e,u)})},mount:(e,r,t)=>{var n=t==="/",s=!t,u;if(n&&i.root)throw new i.ErrnoError(10);if(!n&&!s){var l=i.lookupPath(t,{follow_mount:!1});if(t=l.path,u=l.node,i.isMountpoint(u))throw new i.ErrnoError(10);if(!i.isDir(u.mode))throw new i.ErrnoError(54)}var f={type:e,opts:r,mountpoint:t,mounts:[]},g=e.mount(f);return g.mount=f,f.root=g,n?i.root=g:u&&(u.mounted=f,u.mount&&u.mount.mounts.push(f)),g},unmount:e=>{var r=i.lookupPath(e,{follow_mount:!1});if(!i.isMountpoint(r.node))throw new i.ErrnoError(28);var t=r.node,n=t.mounted,s=i.getMounts(n);Object.keys(i.nameTable).forEach(l=>{for(var f=i.nameTable[l];f;){var g=f.name_next;s.includes(f.mount)&&i.destroyNode(f),f=g}}),t.mounted=null;var u=t.mount.mounts.indexOf(n);t.mount.mounts.splice(u,1)},lookup:(e,r)=>e.node_ops.lookup(e,r),mknod:(e,r,t)=>{var n=i.lookupPath(e,{parent:!0}),s=n.node,u=K.basename(e);if(!u||u==="."||u==="..")throw new i.ErrnoError(28);var l=i.mayCreate(s,u);if(l)throw new i.ErrnoError(l);if(!s.node_ops.mknod)throw new i.ErrnoError(63);return s.node_ops.mknod(s,u,r,t)},create:(e,r)=>(r=r!==void 0?r:438,r&=4095,r|=32768,i.mknod(e,r,0)),mkdir:(e,r)=>(r=r!==void 0?r:511,r&=1023,r|=16384,i.mknod(e,r,0)),mkdirTree:(e,r)=>{for(var t=e.split("/"),n="",s=0;s<t.length;++s)if(t[s]){n+="/"+t[s];try{i.mkdir(n,r)}catch(u){if(u.errno!=20)throw u}}},mkdev:(e,r,t)=>(typeof t>"u"&&(t=r,r=438),r|=8192,i.mknod(e,r,t)),symlink:(e,r)=>{if(!Pe.resolve(e))throw new i.ErrnoError(44);var t=i.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new i.ErrnoError(44);var s=K.basename(r),u=i.mayCreate(n,s);if(u)throw new i.ErrnoError(u);if(!n.node_ops.symlink)throw new i.ErrnoError(63);return n.node_ops.symlink(n,s,e)},rename:(e,r)=>{var t=K.dirname(e),n=K.dirname(r),s=K.basename(e),u=K.basename(r),l,f,g;if(l=i.lookupPath(e,{parent:!0}),f=l.node,l=i.lookupPath(r,{parent:!0}),g=l.node,!f||!g)throw new i.ErrnoError(44);if(f.mount!==g.mount)throw new i.ErrnoError(75);var m=i.lookupNode(f,s),C=Pe.relative(e,n);if(C.charAt(0)!==".")throw new i.ErrnoError(28);if(C=Pe.relative(r,t),C.charAt(0)!==".")throw new i.ErrnoError(55);var A;try{A=i.lookupNode(g,u)}catch{}if(m!==A){var T=i.isDir(m.mode),P=i.mayDelete(f,s,T);if(P)throw new i.ErrnoError(P);if(P=A?i.mayDelete(g,u,T):i.mayCreate(g,u),P)throw new i.ErrnoError(P);if(!f.node_ops.rename)throw new i.ErrnoError(63);if(i.isMountpoint(m)||A&&i.isMountpoint(A))throw new i.ErrnoError(10);if(g!==f&&(P=i.nodePermissions(f,"w"),P))throw new i.ErrnoError(P);i.hashRemoveNode(m);try{f.node_ops.rename(m,g,u)}catch(I){throw I}finally{i.hashAddNode(m)}}},rmdir:e=>{var r=i.lookupPath(e,{parent:!0}),t=r.node,n=K.basename(e),s=i.lookupNode(t,n),u=i.mayDelete(t,n,!0);if(u)throw new i.ErrnoError(u);if(!t.node_ops.rmdir)throw new i.ErrnoError(63);if(i.isMountpoint(s))throw new i.ErrnoError(10);t.node_ops.rmdir(t,n),i.destroyNode(s)},readdir:e=>{var r=i.lookupPath(e,{follow:!0}),t=r.node;if(!t.node_ops.readdir)throw new i.ErrnoError(54);return t.node_ops.readdir(t)},unlink:e=>{var r=i.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new i.ErrnoError(44);var n=K.basename(e),s=i.lookupNode(t,n),u=i.mayDelete(t,n,!1);if(u)throw new i.ErrnoError(u);if(!t.node_ops.unlink)throw new i.ErrnoError(63);if(i.isMountpoint(s))throw new i.ErrnoError(10);t.node_ops.unlink(t,n),i.destroyNode(s)},readlink:e=>{var r=i.lookupPath(e),t=r.node;if(!t)throw new i.ErrnoError(44);if(!t.node_ops.readlink)throw new i.ErrnoError(28);return Pe.resolve(i.getPath(t.parent),t.node_ops.readlink(t))},stat:(e,r)=>{var t=i.lookupPath(e,{follow:!r}),n=t.node;if(!n)throw new i.ErrnoError(44);if(!n.node_ops.getattr)throw new i.ErrnoError(63);return n.node_ops.getattr(n)},lstat:e=>i.stat(e,!0),chmod:(e,r,t)=>{var n;if(typeof e=="string"){var s=i.lookupPath(e,{follow:!t});n=s.node}else n=e;if(!n.node_ops.setattr)throw new i.ErrnoError(63);n.node_ops.setattr(n,{mode:r&4095|n.mode&-4096,timestamp:Date.now()})},lchmod:(e,r)=>{i.chmod(e,r,!0)},fchmod:(e,r)=>{var t=i.getStreamChecked(e);i.chmod(t.node,r)},chown:(e,r,t,n)=>{var s;if(typeof e=="string"){var u=i.lookupPath(e,{follow:!n});s=u.node}else s=e;if(!s.node_ops.setattr)throw new i.ErrnoError(63);s.node_ops.setattr(s,{timestamp:Date.now()})},lchown:(e,r,t)=>{i.chown(e,r,t,!0)},fchown:(e,r,t)=>{var n=i.getStreamChecked(e);i.chown(n.node,r,t)},truncate:(e,r)=>{if(r<0)throw new i.ErrnoError(28);var t;if(typeof e=="string"){var n=i.lookupPath(e,{follow:!0});t=n.node}else t=e;if(!t.node_ops.setattr)throw new i.ErrnoError(63);if(i.isDir(t.mode))throw new i.ErrnoError(31);if(!i.isFile(t.mode))throw new i.ErrnoError(28);var s=i.nodePermissions(t,"w");if(s)throw new i.ErrnoError(s);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate:(e,r)=>{var t=i.getStreamChecked(e);if(!(t.flags&2097155))throw new i.ErrnoError(28);i.truncate(t.node,r)},utime:(e,r,t)=>{var n=i.lookupPath(e,{follow:!0}),s=n.node;s.node_ops.setattr(s,{timestamp:Math.max(r,t)})},open:(e,r,t)=>{if(e==="")throw new i.ErrnoError(44);r=typeof r=="string"?on(r):r,t=typeof t>"u"?438:t,r&64?t=t&4095|32768:t=0;var n;if(typeof e=="object")n=e;else{e=K.normalize(e);try{var s=i.lookupPath(e,{follow:!(r&131072)});n=s.node}catch{}}var u=!1;if(r&64)if(n){if(r&128)throw new i.ErrnoError(20)}else n=i.mknod(e,t,0),u=!0;if(!n)throw new i.ErrnoError(44);if(i.isChrdev(n.mode)&&(r&=-513),r&65536&&!i.isDir(n.mode))throw new i.ErrnoError(54);if(!u){var l=i.mayOpen(n,r);if(l)throw new i.ErrnoError(l)}r&512&&!u&&i.truncate(n,0),r&=-131713;var f=i.createStream({node:n,path:i.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return f.stream_ops.open&&f.stream_ops.open(f),o.logReadFiles&&!(r&1)&&(i.readFiles||(i.readFiles={}),e in i.readFiles||(i.readFiles[e]=1)),f},close:e=>{if(i.isClosed(e))throw new i.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{i.closeStream(e.fd)}e.fd=null},isClosed:e=>e.fd===null,llseek:(e,r,t)=>{if(i.isClosed(e))throw new i.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new i.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new i.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read:(e,r,t,n,s)=>{if(n<0||s<0)throw new i.ErrnoError(28);if(i.isClosed(e))throw new i.ErrnoError(8);if((e.flags&2097155)===1)throw new i.ErrnoError(8);if(i.isDir(e.node.mode))throw new i.ErrnoError(31);if(!e.stream_ops.read)throw new i.ErrnoError(28);var u=typeof s<"u";if(!u)s=e.position;else if(!e.seekable)throw new i.ErrnoError(70);var l=e.stream_ops.read(e,r,t,n,s);return u||(e.position+=l),l},write:(e,r,t,n,s,u)=>{if(n<0||s<0)throw new i.ErrnoError(28);if(i.isClosed(e))throw new i.ErrnoError(8);if(!(e.flags&2097155))throw new i.ErrnoError(8);if(i.isDir(e.node.mode))throw new i.ErrnoError(31);if(!e.stream_ops.write)throw new i.ErrnoError(28);e.seekable&&e.flags&1024&&i.llseek(e,0,2);var l=typeof s<"u";if(!l)s=e.position;else if(!e.seekable)throw new i.ErrnoError(70);var f=e.stream_ops.write(e,r,t,n,s,u);return l||(e.position+=f),f},allocate:(e,r,t)=>{if(i.isClosed(e))throw new i.ErrnoError(8);if(r<0||t<=0)throw new i.ErrnoError(28);if(!(e.flags&2097155))throw new i.ErrnoError(8);if(!i.isFile(e.node.mode)&&!i.isDir(e.node.mode))throw new i.ErrnoError(43);if(!e.stream_ops.allocate)throw new i.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap:(e,r,t,n,s)=>{if(n&2&&!(s&2)&&(e.flags&2097155)!==2)throw new i.ErrnoError(2);if((e.flags&2097155)===1)throw new i.ErrnoError(2);if(!e.stream_ops.mmap)throw new i.ErrnoError(43);return e.stream_ops.mmap(e,r,t,n,s)},msync:(e,r,t,n,s)=>e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,s):0,munmap:e=>0,ioctl:(e,r,t)=>{if(!e.stream_ops.ioctl)throw new i.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=i.open(e,r.flags),s=i.stat(e),u=s.size,l=new Uint8Array(u);return i.read(n,l,0,u,0),r.encoding==="utf8"?t=Xe(l,0):r.encoding==="binary"&&(t=l),i.close(n),t},writeFile:(e,r,t={})=>{t.flags=t.flags||577;var n=i.open(e,t.flags,t.mode);if(typeof r=="string"){var s=new Uint8Array(Lr(r)+1),u=Br(r,s,0,s.length);i.write(n,s,0,u,void 0,t.canOwn)}else if(ArrayBuffer.isView(r))i.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");i.close(n)},cwd:()=>i.currentPath,chdir:e=>{var r=i.lookupPath(e,{follow:!0});if(r.node===null)throw new i.ErrnoError(44);if(!i.isDir(r.node.mode))throw new i.ErrnoError(54);var t=i.nodePermissions(r.node,"x");if(t)throw new i.ErrnoError(t);i.currentPath=r.path},createDefaultDirectories:()=>{i.mkdir("/tmp"),i.mkdir("/home"),i.mkdir("/home/web_user")},createDefaultDevices:()=>{i.mkdir("/dev"),i.registerDevice(i.makedev(1,3),{read:()=>0,write:(n,s,u,l,f)=>l}),i.mkdev("/dev/null",i.makedev(1,3)),Ue.register(i.makedev(5,0),Ue.default_tty_ops),Ue.register(i.makedev(6,0),Ue.default_tty1_ops),i.mkdev("/dev/tty",i.makedev(5,0)),i.mkdev("/dev/tty1",i.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(r=tt(e).byteLength),e[--r]);i.createDevice("/dev","random",t),i.createDevice("/dev","urandom",t),i.mkdir("/dev/shm"),i.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{i.mkdir("/proc");var e=i.mkdir("/proc/self");i.mkdir("/proc/self/fd"),i.mount({mount:()=>{var r=i.createNode(e,"fd",16895,73);return r.node_ops={lookup:(t,n)=>{var s=+n,u=i.getStreamChecked(s),l={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>u.path}};return l.parent=l,l}},r}},{},"/proc/self/fd")},createStandardStreams:()=>{o.stdin?i.createDevice("/dev","stdin",o.stdin):i.symlink("/dev/tty","/dev/stdin"),o.stdout?i.createDevice("/dev","stdout",null,o.stdout):i.symlink("/dev/tty","/dev/stdout"),o.stderr?i.createDevice("/dev","stderr",null,o.stderr):i.symlink("/dev/tty1","/dev/stderr"),i.open("/dev/stdin",0),i.open("/dev/stdout",1),i.open("/dev/stderr",1)},ensureErrnoError:()=>{i.ErrnoError||(i.ErrnoError=function(r,t){this.name="ErrnoError",this.node=t,this.setErrno=function(n){this.errno=n},this.setErrno(r),this.message="FS error"},i.ErrnoError.prototype=new Error,i.ErrnoError.prototype.constructor=i.ErrnoError,[44].forEach(e=>{i.genericErrors[e]=new i.ErrnoError(e),i.genericErrors[e].stack="<generic error, no stack>"}))},staticInit:()=>{i.ensureErrnoError(),i.nameTable=new Array(4096),i.mount(H,{},"/"),i.createDefaultDirectories(),i.createDefaultDevices(),i.createSpecialDirectories(),i.filesystems={MEMFS:H}},init:(e,r,t)=>{i.init.initialized=!0,i.ensureErrnoError(),o.stdin=e||o.stdin,o.stdout=r||o.stdout,o.stderr=t||o.stderr,i.createStandardStreams()},quit:()=>{i.init.initialized=!1;for(var e=0;e<i.streams.length;e++){var r=i.streams[e];r&&i.close(r)}},findObject:(e,r)=>{var t=i.analyzePath(e,r);return t.exists?t.object:null},analyzePath:(e,r)=>{try{var t=i.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=i.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=K.basename(e),t=i.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(s){n.error=s.errno}return n},createPath:(e,r,t,n)=>{e=typeof e=="string"?e:i.getPath(e);for(var s=r.split("/").reverse();s.length;){var u=s.pop();if(u){var l=K.join2(e,u);try{i.mkdir(l)}catch{}e=l}}return l},createFile:(e,r,t,n,s)=>{var u=K.join2(typeof e=="string"?e:i.getPath(e),r),l=or(n,s);return i.create(u,l)},createDataFile:(e,r,t,n,s,u)=>{var l=r;e&&(e=typeof e=="string"?e:i.getPath(e),l=r?K.join2(e,r):e);var f=or(n,s),g=i.create(l,f);if(t){if(typeof t=="string"){for(var m=new Array(t.length),C=0,A=t.length;C<A;++C)m[C]=t.charCodeAt(C);t=m}i.chmod(g,f|146);var T=i.open(g,577);i.write(T,t,0,t.length,0,u),i.close(T),i.chmod(g,f)}return g},createDevice:(e,r,t,n)=>{var s=K.join2(typeof e=="string"?e:i.getPath(e),r),u=or(!!t,!!n);i.createDevice.major||(i.createDevice.major=64);var l=i.makedev(i.createDevice.major++,0);return i.registerDevice(l,{open:f=>{f.seekable=!1},close:f=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(f,g,m,C,A)=>{for(var T=0,P=0;P<C;P++){var I;try{I=t()}catch{throw new i.ErrnoError(29)}if(I===void 0&&T===0)throw new i.ErrnoError(6);if(I==null)break;T++,g[m+P]=I}return T&&(f.node.timestamp=Date.now()),T},write:(f,g,m,C,A)=>{for(var T=0;T<C;T++)try{n(g[m+T])}catch{throw new i.ErrnoError(29)}return C&&(f.node.timestamp=Date.now()),T}}),i.mkdev(s,u,l)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(typeof XMLHttpRequest<"u")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(S)try{e.contents=Hr(S(e.url),!0),e.usedBytes=e.contents.length}catch{throw new i.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile:(e,r,t,n,s)=>{function u(){this.lengthKnown=!1,this.chunks=[]}if(u.prototype.get=function(P){if(!(P>this.length-1||P<0)){var I=P%this.chunkSize,re=P/this.chunkSize|0;return this.getter(re)[I]}},u.prototype.setDataGetter=function(P){this.getter=P},u.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 I=Number(P.getResponseHeader("Content-length")),re,ne=(re=P.getResponseHeader("Accept-Ranges"))&&re==="bytes",ue=(re=P.getResponseHeader("Content-Encoding"))&&re==="gzip",ge=1024*1024;ne||(ge=I);var ie=(_e,xe)=>{if(_e>xe)throw new Error("invalid range ("+_e+", "+xe+") or no bytes requested!");if(xe>I-1)throw new Error("only "+I+" bytes available! programmer error!");var fe=new XMLHttpRequest;if(fe.open("GET",t,!1),I!==ge&&fe.setRequestHeader("Range","bytes="+_e+"-"+xe),fe.responseType="arraybuffer",fe.overrideMimeType&&fe.overrideMimeType("text/plain; charset=x-user-defined"),fe.send(null),!(fe.status>=200&&fe.status<300||fe.status===304))throw new Error("Couldn't load "+t+". Status: "+fe.status);return fe.response!==void 0?new Uint8Array(fe.response||[]):Hr(fe.responseText||"",!0)},Ze=this;Ze.setDataGetter(_e=>{var xe=_e*ge,fe=(_e+1)*ge-1;if(fe=Math.min(fe,I-1),typeof Ze.chunks[_e]>"u"&&(Ze.chunks[_e]=ie(xe,fe)),typeof Ze.chunks[_e]>"u")throw new Error("doXHR failed!");return Ze.chunks[_e]}),(ue||!I)&&(ge=I=1,I=this.getter(0).length,ge=I,V("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=I,this._chunkSize=ge,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){if(!k)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var l=new u;Object.defineProperties(l,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var f={isDevice:!1,contents:l}}else var f={isDevice:!1,url:t};var g=i.createFile(e,r,f,n,s);f.contents?g.contents=f.contents:f.url&&(g.contents=null,g.url=f.url),Object.defineProperties(g,{usedBytes:{get:function(){return this.contents.length}}});var m={},C=Object.keys(g.stream_ops);C.forEach(T=>{var P=g.stream_ops[T];m[T]=function(){return i.forceLoadFile(g),P.apply(null,arguments)}});function A(T,P,I,re,ne){var ue=T.node.contents;if(ne>=ue.length)return 0;var ge=Math.min(ue.length-ne,re);if(ue.slice)for(var ie=0;ie<ge;ie++)P[I+ie]=ue[ne+ie];else for(var ie=0;ie<ge;ie++)P[I+ie]=ue.get(ne+ie);return ge}return m.read=(T,P,I,re,ne)=>(i.forceLoadFile(g),A(T,P,I,re,ne)),m.mmap=(T,P,I,re,ne)=>{i.forceLoadFile(g);var ue=nt();if(!ue)throw new i.ErrnoError(48);return A(T,J,ue,P,I),{ptr:ue,allocated:!0}},g.stream_ops=m,g}},_r=(e,r)=>e?Xe(Y,e,r):"",le={DEFAULT_POLLMASK:5,calculateAt:function(e,r,t){if(K.isAbs(r))return r;var n;if(e===-100)n=i.cwd();else{var s=le.getStreamFromFD(e);n=s.path}if(r.length==0){if(!t)throw new i.ErrnoError(44);return n}return K.join2(n,r)},doStat:function(e,r,t){try{var n=e(r)}catch(f){if(f&&f.node&&K.normalize(r)!==K.normalize(i.getPath(f.node)))return-54;throw f}z[t>>2]=n.dev,z[t+4>>2]=n.mode,N[t+8>>2]=n.nlink,z[t+12>>2]=n.uid,z[t+16>>2]=n.gid,z[t+20>>2]=n.rdev,ee=[n.size>>>0,(M=n.size,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+24>>2]=ee[0],z[t+28>>2]=ee[1],z[t+32>>2]=4096,z[t+36>>2]=n.blocks;var s=n.atime.getTime(),u=n.mtime.getTime(),l=n.ctime.getTime();return ee=[Math.floor(s/1e3)>>>0,(M=Math.floor(s/1e3),+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+40>>2]=ee[0],z[t+44>>2]=ee[1],N[t+48>>2]=s%1e3*1e3,ee=[Math.floor(u/1e3)>>>0,(M=Math.floor(u/1e3),+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+56>>2]=ee[0],z[t+60>>2]=ee[1],N[t+64>>2]=u%1e3*1e3,ee=[Math.floor(l/1e3)>>>0,(M=Math.floor(l/1e3),+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+72>>2]=ee[0],z[t+76>>2]=ee[1],N[t+80>>2]=l%1e3*1e3,ee=[n.ino>>>0,(M=n.ino,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+88>>2]=ee[0],z[t+92>>2]=ee[1],0},doMsync:function(e,r,t,n,s){if(!i.isFile(r.node.mode))throw new i.ErrnoError(43);if(n&2)return 0;var u=Y.slice(e,e+t);i.msync(r,u,s,t,n)},varargs:void 0,get(){le.varargs+=4;var e=z[le.varargs-4>>2];return e},getStr(e){var r=_r(e);return r},getStreamFromFD:function(e){var r=i.getStreamChecked(e);return r}};function sn(e,r,t){le.varargs=t;try{var n=le.getStreamFromFD(e);switch(r){case 0:{var s=le.get();if(s<0)return-28;var u;return u=i.createStream(n,s),u.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var s=le.get();return n.flags|=s,0}case 5:{var s=le.get(),l=0;return we[s+l>>1]=2,0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:return rt(28),-1;default:return-28}}catch(f){if(typeof i>"u"||f.name!=="ErrnoError")throw f;return-f.errno}}function Wr(e,r,t,n){le.varargs=n;try{r=le.getStr(r),r=le.calculateAt(e,r);var s=n?le.get():0;return i.open(r,t,s).fd}catch(u){if(typeof i>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}function an(e,r,t,n,s){}function zr(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${e}`)}}function it(){for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);yt=e}var yt=void 0;function me(e){for(var r="",t=e;Y[t];)r+=yt[Y[t++]];return r}var Ke={},He={},br={},Qe=void 0;function q(e){throw new Qe(e)}var rr=void 0;function Er(e){throw new rr(e)}function sr(e,r,t){e.forEach(function(f){br[f]=r});function n(f){var g=t(f);g.length!==e.length&&Er("Mismatched type converter count");for(var m=0;m<e.length;++m)$e(e[m],g[m])}var s=new Array(r.length),u=[],l=0;r.forEach((f,g)=>{He.hasOwnProperty(f)?s[g]=He[f]:(u.push(f),Ke.hasOwnProperty(f)||(Ke[f]=[]),Ke[f].push(()=>{s[g]=He[f],++l,l===u.length&&n(s)}))}),u.length===0&&n(s)}function ot(e,r,t={}){var n=r.name;if(e||q(`type "${n}" must have a positive integer typeid pointer`),He.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;q(`Cannot register type '${n}' twice`)}if(He[e]=r,delete br[e],Ke.hasOwnProperty(e)){var s=Ke[e];delete Ke[e],s.forEach(u=>u())}}function $e(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return ot(e,r,t)}function jt(e,r,t,n,s){var u=zr(t);r=me(r),$e(e,{name:r,fromWireType:function(l){return!!l},toWireType:function(l,f){return f?n:s},argPackAdvance:8,readValueFromPointer:function(l){var f;if(t===1)f=J;else if(t===2)f=we;else if(t===4)f=z;else throw new TypeError("Unknown boolean type size: "+r);return this.fromWireType(f[l>>u])},destructorFunction:null})}function un(e){if(!(this instanceof Re)||!(e instanceof Re))return!1;for(var r=this.$$.ptrType.registeredClass,t=this.$$.ptr,n=e.$$.ptrType.registeredClass,s=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)s=n.upcast(s),n=n.baseClass;return r===n&&t===s}function fn(e){return{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}}function Pr(e){function r(t){return t.$$.ptrType.registeredClass.name}q(r(e)+" instance already deleted")}var Nr=!1;function gt(e){}function ln(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}function Fr(e){e.count.value-=1;var r=e.count.value===0;r&&ln(e)}function wt(e,r,t){if(r===t)return e;if(t.baseClass===void 0)return null;var n=wt(e,r,t.baseClass);return n===null?null:t.downcast(n)}var _t={};function cn(){return Object.keys(ur).length}function dn(){var e=[];for(var r in ur)ur.hasOwnProperty(r)&&e.push(ur[r]);return e}var Ae=[];function Vr(){for(;Ae.length;){var e=Ae.pop();e.$$.deleteScheduled=!1,e.delete()}}var ar=void 0;function st(e){ar=e,Ae.length&&ar&&ar(Vr)}function Lt(){o.getInheritedInstanceCount=cn,o.getLiveInheritedInstances=dn,o.flushPendingDeletes=Vr,o.setDelayFunction=st}var ur={};function hn(e,r){for(r===void 0&&q("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r}function Rr(e,r){return r=hn(e,r),ur[r]}function Cr(e,r){(!r.ptrType||!r.ptr)&&Er("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&Er("Both smartPtrType and smartPtr must be specified"),r.count={value:1},tr(Object.create(e,{$$:{value:r}}))}function Bt(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=Rr(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 s(){return this.isSmartPointer?Cr(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):Cr(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var u=this.registeredClass.getActualType(r),l=_t[u];if(!l)return s.call(this);var f;this.isConst?f=l.constPointerType:f=l.pointerType;var g=wt(r,this.registeredClass,f.registeredClass);return g===null?s.call(this):this.isSmartPointer?Cr(f.registeredClass.instancePrototype,{ptrType:f,ptr:g,smartPtrType:this,smartPtr:e}):Cr(f.registeredClass.instancePrototype,{ptrType:f,ptr:g})}var tr=function(e){return typeof FinalizationRegistry>"u"?(tr=r=>r,e):(Nr=new FinalizationRegistry(r=>{Fr(r.$$)}),tr=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var s={$$:t};Nr.register(r,s,r)}return r},gt=r=>Nr.unregister(r),tr(e))};function bt(){if(this.$$.ptr||Pr(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=tr(Object.create(Object.getPrototypeOf(this),{$$:{value:fn(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e}function pn(){this.$$.ptr||Pr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&q("Object already scheduled for deletion"),gt(this),Fr(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function Ht(){return!this.$$.ptr}function vn(){return this.$$.ptr||Pr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&q("Object already scheduled for deletion"),Ae.push(this),Ae.length===1&&ar&&ar(Vr),this.$$.deleteScheduled=!0,this}function Wt(){Re.prototype.isAliasOf=un,Re.prototype.clone=bt,Re.prototype.delete=pn,Re.prototype.isDeleted=Ht,Re.prototype.deleteLater=vn}function Re(){}var mn=48,yn=57;function Tr(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=mn&&r<=yn?`_${e}`:e}function Or(e,r){return e=Tr(e),{[e]:function(){return r.apply(this,arguments)}}[e]}function We(e,r,t){if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(){return e[r].overloadTable.hasOwnProperty(arguments.length)||q(`Function '${t}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[arguments.length].apply(this,arguments)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n}}function zt(e,r,t){o.hasOwnProperty(e)?((t===void 0||o[e].overloadTable!==void 0&&o[e].overloadTable[t]!==void 0)&&q(`Cannot register public name '${e}' twice`),We(o,e,e),o.hasOwnProperty(t)&&q(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),o[e].overloadTable[t]=r):(o[e]=r,t!==void 0&&(o[e].numArguments=t))}function gn(e,r,t,n,s,u,l,f){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=s,this.getActualType=u,this.upcast=l,this.downcast=f,this.pureVirtualFunctions=[]}function Gr(e,r,t){for(;r!==t;)r.upcast||q(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e}function at(e,r){if(r===null)return this.isReference&&q(`null is not a valid ${this.name}`),0;r.$$||q(`Cannot pass "${Xr(r)}" as a ${this.name}`),r.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Gr(r.$$.ptr,t,this.registeredClass);return n}function wn(e,r){var t;if(r===null)return this.isReference&&q(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;r.$$||q(`Cannot pass "${Xr(r)}" as a ${this.name}`),r.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&q(`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=Gr(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&q("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:q(`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 s=r.clone();t=this.rawShare(t,Sr.toHandle(function(){s.delete()})),e!==null&&e.push(this.rawDestructor,t)}break;default:q("Unsupporting sharing policy")}return t}function Et(e,r){if(r===null)return this.isReference&&q(`null is not a valid ${this.name}`),0;r.$$||q(`Cannot pass "${Xr(r)}" as a ${this.name}`),r.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&q(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Gr(r.$$.ptr,t,this.registeredClass);return n}function $r(e){return this.fromWireType(z[e>>2])}function _n(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function bn(e){this.rawDestructor&&this.rawDestructor(e)}function En(e){e!==null&&e.delete()}function Pn(){De.prototype.getPointee=_n,De.prototype.destructor=bn,De.prototype.argPackAdvance=8,De.prototype.readValueFromPointer=$r,De.prototype.deleteObject=En,De.prototype.fromWireType=Bt}function De(e,r,t,n,s,u,l,f,g,m,C){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=s,this.pointeeType=u,this.sharingPolicy=l,this.rawGetPointee=f,this.rawConstructor=g,this.rawShare=m,this.rawDestructor=C,!s&&r.baseClass===void 0?n?(this.toWireType=at,this.destructorFunction=null):(this.toWireType=Et,this.destructorFunction=null):this.toWireType=wn}function Cn(e,r,t){o.hasOwnProperty(e)||Er("Replacing nonexistant public symbol"),o[e].overloadTable!==void 0&&t!==void 0?o[e].overloadTable[t]=r:(o[e]=r,o[e].argCount=t)}var Tn=(e,r,t)=>{var n=o["dynCall_"+e];return t&&t.length?n.apply(null,[r].concat(t)):n.call(null,r)},dr=[],ut=e=>{var r=dr[e];return r||(e>=dr.length&&(dr.length=e+1),dr[e]=r=ve.get(e)),r},$n=(e,r,t)=>{if(e.includes("j"))return Tn(e,r,t);var n=ut(r).apply(null,t);return n},Sn=(e,r)=>{var t=[];return function(){return t.length=0,Object.assign(t,arguments),$n(e,r,t)}};function Ne(e,r){e=me(e);function t(){return e.includes("j")?Sn(e,r):ut(r)}var n=t();return typeof n!="function"&&q(`unknown function pointer with signature ${e}: ${r}`),n}function kn(e,r){var t=Or(r,function(n){this.name=r,this.message=n;var s=new Error(n).stack;s!==void 0&&(this.stack=this.toString()+`
  4. `+s.replace(/^Error(:[^\n]*)?\n/,""))});return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},t}var Pt=void 0;function Ct(e){var r=zn(e),t=me(r);return Me(r),t}function qr(e,r){var t=[],n={};function s(u){if(!n[u]&&!He[u]){if(br[u]){br[u].forEach(s);return}t.push(u),n[u]=!0}}throw r.forEach(s),new Pt(`${e}: `+t.map(Ct).join([", "]))}function An(e,r,t,n,s,u,l,f,g,m,C,A,T){C=me(C),u=Ne(s,u),f&&(f=Ne(l,f)),m&&(m=Ne(g,m)),T=Ne(A,T);var P=Tr(C);zt(P,function(){qr(`Cannot construct ${C} due to unbound types`,[n])}),sr([e,r,t],n?[n]:[],function(I){I=I[0];var re,ne;n?(re=I.registeredClass,ne=re.instancePrototype):ne=Re.prototype;var ue=Or(P,function(){if(Object.getPrototypeOf(this)!==ge)throw new Qe("Use 'new' to construct "+C);if(ie.constructor_body===void 0)throw new Qe(C+" has no accessible constructor");var fe=ie.constructor_body[arguments.length];if(fe===void 0)throw new Qe(`Tried to invoke ctor of ${C} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(ie.constructor_body).toString()}) parameters instead!`);return fe.apply(this,arguments)}),ge=Object.create(ne,{constructor:{value:ue}});ue.prototype=ge;var ie=new gn(C,ue,ge,T,re,u,f,m);ie.baseClass&&(ie.baseClass.__derivedClasses===void 0&&(ie.baseClass.__derivedClasses=[]),ie.baseClass.__derivedClasses.push(ie));var Ze=new De(C,ie,!0,!1,!1),_e=new De(C+"*",ie,!1,!1,!1),xe=new De(C+" const*",ie,!1,!0,!1);return _t[e]={pointerType:_e,constPointerType:xe},Cn(P,ue),[Ze,_e,xe]})}function Tt(e,r){for(var t=[],n=0;n<e;n++)t.push(N[r+n*4>>2]);return t}function Dn(e){for(;e.length;){var r=e.pop(),t=e.pop();t(r)}}function $t(e,r){if(!(e instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof e} which is not a function`);var t=Or(e.name||"unknownFunctionName",function(){});t.prototype=e.prototype;var n=new t,s=e.apply(n,r);return s instanceof Object?s:n}function St(e,r,t,n,s,u){var l=r.length;l<2&&q("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var f=r[1]!==null&&t!==null,g=!1,m=1;m<r.length;++m)if(r[m]!==null&&r[m].destructorFunction===void 0){g=!0;break}for(var C=r[0].name!=="void",A="",T="",m=0;m<l-2;++m)A+=(m!==0?", ":"")+"arg"+m,T+=(m!==0?", ":"")+"arg"+m+"Wired";var P=`
  5. return function ${Tr(e)}(${A}) {
  6. if (arguments.length !== ${l-2}) {
  7. throwBindingError('function ${e} called with ${arguments.length} arguments, expected ${l-2} args!');
  8. }`;g&&(P+=`var destructors = [];
  9. `);var I=g?"destructors":"null",re=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],ne=[q,n,s,Dn,r[0],r[1]];f&&(P+="var thisWired = classParam.toWireType("+I+`, this);
  10. `);for(var m=0;m<l-2;++m)P+="var arg"+m+"Wired = argType"+m+".toWireType("+I+", arg"+m+"); // "+r[m+2].name+`
  11. `,re.push("argType"+m),ne.push(r[m+2]);if(f&&(T="thisWired"+(T.length>0?", ":"")+T),P+=(C||u?"var rv = ":"")+"invoker(fn"+(T.length>0?", ":"")+T+`);
  12. `,g)P+=`runDestructors(destructors);
  13. `;else for(var m=f?1:2;m<r.length;++m){var ue=m===1?"thisWired":"arg"+(m-2)+"Wired";r[m].destructorFunction!==null&&(P+=ue+"_dtor("+ue+"); // "+r[m].name+`
  14. `,re.push(ue+"_dtor"),ne.push(r[m].destructorFunction))}return C&&(P+=`var ret = retType.fromWireType(rv);
  15. return ret;
  16. `),P+=`}
  17. `,re.push(P),$t(Function,re).apply(null,ne)}function Fn(e,r,t,n,s,u){var l=Tt(r,t);s=Ne(n,s),sr([],[e],function(f){f=f[0];var g=`constructor ${f.name}`;if(f.registeredClass.constructor_body===void 0&&(f.registeredClass.constructor_body=[]),f.registeredClass.constructor_body[r-1]!==void 0)throw new Qe(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${f.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return f.registeredClass.constructor_body[r-1]=()=>{qr(`Cannot construct ${f.name} due to unbound types`,l)},sr([],l,function(m){return m.splice(1,0,null),f.registeredClass.constructor_body[r-1]=St(g,m,null,s,u),[]}),[]})}function kt(e,r,t,n,s,u,l,f,g){var m=Tt(t,n);r=me(r),u=Ne(s,u),sr([],[e],function(C){C=C[0];var A=`${C.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),f&&C.registeredClass.pureVirtualFunctions.push(r);function T(){qr(`Cannot call ${A} due to unbound types`,m)}var P=C.registeredClass.instancePrototype,I=P[r];return I===void 0||I.overloadTable===void 0&&I.className!==C.name&&I.argCount===t-2?(T.argCount=t-2,T.className=C.name,P[r]=T):(We(P,r,A),P[r].overloadTable[t-2]=T),sr([],m,function(re){var ne=St(A,re,C,u,l,g);return P[r].overloadTable===void 0?(ne.argCount=t-2,P[r]=ne):P[r].overloadTable[t-2]=ne,[]}),[]})}function Rn(){Object.assign(At.prototype,{get(e){return this.allocated[e]},has(e){return this.allocated[e]!==void 0},allocate(e){var r=this.freelist.pop()||this.allocated.length;return this.allocated[r]=e,r},free(e){this.allocated[e]=void 0,this.freelist.push(e)}})}function At(){this.allocated=[void 0],this.freelist=[]}var Ee=new At;function Dt(e){e>=Ee.reserved&&--Ee.get(e).refcount===0&&Ee.free(e)}function Nt(){for(var e=0,r=Ee.reserved;r<Ee.allocated.length;++r)Ee.allocated[r]!==void 0&&++e;return e}function On(){Ee.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),Ee.reserved=Ee.allocated.length,o.count_emval_handles=Nt}var Sr={toValue:e=>(e||q("Cannot use deleted val. handle = "+e),Ee.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Ee.allocate({refcount:1,value:e})}}};function Vt(e,r){r=me(r),$e(e,{name:r,fromWireType:function(t){var n=Sr.toValue(t);return Dt(t),n},toWireType:function(t,n){return Sr.toHandle(n)},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:null})}function Xr(e){if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e}function Un(e,r){switch(r){case 2:return function(t){return this.fromWireType(ze[t>>2])};case 3:return function(t){return this.fromWireType(he[t>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Mn(e,r,t){var n=zr(t);r=me(r),$e(e,{name:r,fromWireType:function(s){return s},toWireType:function(s,u){return u},argPackAdvance:8,readValueFromPointer:Un(r,n),destructorFunction:null})}function xn(e,r,t){switch(r){case 0:return t?function(s){return J[s]}:function(s){return Y[s]};case 1:return t?function(s){return we[s>>1]}:function(s){return ke[s>>1]};case 2:return t?function(s){return z[s>>2]}:function(s){return N[s>>2]};default:throw new TypeError("Unknown integer type: "+e)}}function In(e,r,t,n,s){r=me(r);var u=zr(t),l=A=>A;if(n===0){var f=32-8*t;l=A=>A<<f>>>f}var g=r.includes("unsigned"),m=(A,T)=>{},C;g?C=function(A,T){return m(T,this.name),T>>>0}:C=function(A,T){return m(T,this.name),T},$e(e,{name:r,fromWireType:l,toWireType:C,argPackAdvance:8,readValueFromPointer:xn(r,u,n!==0),destructorFunction:null})}function jn(e,r,t){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],s=n[r];function u(l){l=l>>2;var f=N,g=f[l],m=f[l+1];return new s(f.buffer,m,g)}t=me(t),$e(e,{name:t,fromWireType:u,argPackAdvance:8,readValueFromPointer:u},{ignoreDuplicateRegistrations:!0})}var Ln=(e,r,t)=>Br(e,Y,r,t);function fr(e,r){r=me(r);var t=r==="std::string";$e(e,{name:r,fromWireType:function(n){var s=N[n>>2],u=n+4,l;if(t)for(var f=u,g=0;g<=s;++g){var m=u+g;if(g==s||Y[m]==0){var C=m-f,A=_r(f,C);l===void 0?l=A:(l+=String.fromCharCode(0),l+=A),f=m+1}}else{for(var T=new Array(s),g=0;g<s;++g)T[g]=String.fromCharCode(Y[u+g]);l=T.join("")}return Me(n),l},toWireType:function(n,s){s instanceof ArrayBuffer&&(s=new Uint8Array(s));var u,l=typeof s=="string";l||s instanceof Uint8Array||s instanceof Uint8ClampedArray||s instanceof Int8Array||q("Cannot pass non-string to std::string"),t&&l?u=Lr(s):u=s.length;var f=Rt(4+u+1),g=f+4;if(N[f>>2]=u,t&&l)Ln(s,g,u+1);else if(l)for(var m=0;m<u;++m){var C=s.charCodeAt(m);C>255&&(Me(g),q("String has UTF-16 code units that do not fit in 8 bits")),Y[g+m]=C}else for(var m=0;m<u;++m)Y[g+m]=s[m];return n!==null&&n.push(Me,f),f},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:function(n){Me(n)}})}var Kr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,Gt=(e,r)=>{for(var t=e,n=t>>1,s=n+r/2;!(n>=s)&&ke[n];)++n;if(t=n<<1,t-e>32&&Kr)return Kr.decode(Y.subarray(e,t));for(var u="",l=0;!(l>=r/2);++l){var f=we[e+l*2>>1];if(f==0)break;u+=String.fromCharCode(f)}return u},qt=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<2)return 0;t-=2;for(var n=r,s=t<e.length*2?t/2:e.length,u=0;u<s;++u){var l=e.charCodeAt(u);we[r>>1]=l,r+=2}return we[r>>1]=0,r-n},ft=e=>e.length*2,Xt=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var s=z[e+t*4>>2];if(s==0)break;if(++t,s>=65536){var u=s-65536;n+=String.fromCharCode(55296|u>>10,56320|u&1023)}else n+=String.fromCharCode(s)}return n},c=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<4)return 0;for(var n=r,s=n+t-4,u=0;u<e.length;++u){var l=e.charCodeAt(u);if(l>=55296&&l<=57343){var f=e.charCodeAt(++u);l=65536+((l&1023)<<10)|f&1023}if(z[r>>2]=l,r+=4,r+4>s)break}return z[r>>2]=0,r-n},d=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&++t,r+=4}return r},v=function(e,r,t){t=me(t);var n,s,u,l,f;r===2?(n=Gt,s=qt,l=ft,u=()=>ke,f=1):r===4&&(n=Xt,s=c,l=d,u=()=>N,f=2),$e(e,{name:t,fromWireType:function(g){for(var m=N[g>>2],C=u(),A,T=g+4,P=0;P<=m;++P){var I=g+4+P*r;if(P==m||C[I>>f]==0){var re=I-T,ne=n(T,re);A===void 0?A=ne:(A+=String.fromCharCode(0),A+=ne),T=I+r}}return Me(g),A},toWireType:function(g,m){typeof m!="string"&&q(`Cannot pass non-string to C++ string type ${t}`);var C=l(m),A=Rt(4+C+r);return N[A>>2]=C>>f,s(m,A+4,C+r),g!==null&&g.push(Me,A),A},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:function(g){Me(g)}})};function E(e,r){r=me(r),$e(e,{isVoid:!0,name:r,argPackAdvance:0,fromWireType:function(){},toWireType:function(t,n){}})}var D={};function x(e){var r=D[e];return r===void 0?me(e):r}var j=[];function O(e,r,t,n){e=j[e],r=Sr.toValue(r),t=x(t),e(r,t,null,n)}function X(e){var r=j.length;return j.push(e),r}function L(e,r){var t=He[e];return t===void 0&&q(r+" has unknown type "+Ct(e)),t}function oe(e,r){for(var t=new Array(e),n=0;n<e;++n)t[n]=L(N[r+n*4>>2],"parameter "+n);return t}var ae=[];function ce(e,r){var t=oe(e,r),n=t[0],s=n.name+"_$"+t.slice(1).map(function(I){return I.name}).join("_")+"$",u=ae[s];if(u!==void 0)return u;for(var l=["retType"],f=[n],g="",m=0;m<e-1;++m)g+=(m!==0?", ":"")+"arg"+m,l.push("argType"+m),f.push(t[1+m]);for(var C=Tr("methodCaller_"+s),A="return function "+C+`(handle, name, destructors, args) {
  18. `,T=0,m=0;m<e-1;++m)A+=" var arg"+m+" = argType"+m+".readValueFromPointer(args"+(T?"+"+T:"")+`);
  19. `,T+=t[m+1].argPackAdvance;A+=" var rv = handle[name]("+g+`);
  20. `;for(var m=0;m<e-1;++m)t[m+1].deleteObject&&(A+=" argType"+m+".deleteObject(arg"+m+`);
  21. `);n.isVoid||(A+=` return retType.toWireType(destructors, rv);
  22. `),A+=`};
  23. `,l.push(A);var P=$t(Function,l).apply(null,f);return u=X(P),ae[s]=u,u}function ye(e,r){return r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN}var Fe=()=>{je("")};function Ve(){return Date.now()}var Ie=()=>Y.length,hr=()=>Ie(),Ft=(e,r,t)=>Y.copyWithin(e,r,r+t),Ye=e=>{je("OOM")},Bn=e=>{Y.length,Ye()},Ur={},Kt=()=>b||"./this.program",nr=()=>{if(!nr.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Kt()};for(var t in Ur)Ur[t]===void 0?delete r[t]:r[t]=Ur[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);nr.strings=n}return nr.strings},fi=(e,r)=>{for(var t=0;t<e.length;++t)J[r++>>0]=e.charCodeAt(t);J[r>>0]=0},li=(e,r)=>{var t=0;return nr().forEach(function(n,s){var u=r+t;N[e+s*4>>2]=u,fi(n,u),t+=n.length+1}),0},ci=(e,r)=>{var t=nr();N[e>>2]=t.length;var n=0;return t.forEach(function(s){n+=s.length+1}),N[r>>2]=n,0};function di(e){try{var r=le.getStreamFromFD(e);return i.close(r),0}catch(t){if(typeof i>"u"||t.name!=="ErrnoError")throw t;return t.errno}}function hi(e,r){try{var t=0,n=0,s=0,u=le.getStreamFromFD(e),l=u.tty?2:i.isDir(u.mode)?3:i.isLink(u.mode)?7:4;return J[r>>0]=l,we[r+2>>1]=s,ee=[t>>>0,(M=t,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[r+8>>2]=ee[0],z[r+12>>2]=ee[1],ee=[n>>>0,(M=n,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[r+16>>2]=ee[0],z[r+20>>2]=ee[1],0}catch(f){if(typeof i>"u"||f.name!=="ErrnoError")throw f;return f.errno}}var pi=(e,r,t,n)=>{for(var s=0,u=0;u<t;u++){var l=N[r>>2],f=N[r+4>>2];r+=8;var g=i.read(e,J,l,f,n);if(g<0)return-1;if(s+=g,g<f)break;typeof n<"u"&&(n+=g)}return s};function vi(e,r,t,n){try{var s=le.getStreamFromFD(e),u=pi(s,r,t);return N[n>>2]=u,0}catch(l){if(typeof i>"u"||l.name!=="ErrnoError")throw l;return l.errno}}function mi(e,r,t,n,s){var u=ye(r,t);try{if(isNaN(u))return 61;var l=le.getStreamFromFD(e);return i.llseek(l,u,n),ee=[l.position>>>0,(M=l.position,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[s>>2]=ee[0],z[s+4>>2]=ee[1],l.getdents&&u===0&&n===0&&(l.getdents=null),0}catch(f){if(typeof i>"u"||f.name!=="ErrnoError")throw f;return f.errno}}var yi=(e,r,t,n)=>{for(var s=0,u=0;u<t;u++){var l=N[r>>2],f=N[r+4>>2];r+=8;var g=i.write(e,J,l,f,n);if(g<0)return-1;s+=g,typeof n<"u"&&(n+=g)}return s};function gi(e,r,t,n){try{var s=le.getStreamFromFD(e),u=yi(s,r,t);return N[n>>2]=u,0}catch(l){if(typeof i>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var Hn=function(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=i.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n},Qr=365,Yr=146;Object.defineProperties(Hn.prototype,{read:{get:function(){return(this.mode&Qr)===Qr},set:function(e){e?this.mode|=Qr:this.mode&=~Qr}},write:{get:function(){return(this.mode&Yr)===Yr},set:function(e){e?this.mode|=Yr:this.mode&=~Yr}},isFolder:{get:function(){return i.isDir(this.mode)}},isDevice:{get:function(){return i.isChrdev(this.mode)}}}),i.FSNode=Hn,i.createPreloadedFile=nn,i.staticInit(),it(),Qe=o.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError"}},rr=o.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError"}},Wt(),Lt(),Pn(),Pt=o.UnboundTypeError=kn(Error,"UnboundTypeError"),Rn(),On();var wi={p:gr,C:sn,w:Wr,t:an,n:jt,r:An,q:Fn,d:kt,D:Vt,k:Mn,c:In,b:jn,j:fr,f:v,o:E,g:O,m:Dt,l:ce,a:Fe,e:Ve,v:hr,A:Ft,u:Bn,y:li,z:ci,i:di,x:hi,B:vi,s:mi,h:gi};tn();var Rt=e=>(Rt=B.G)(e),Me=e=>(Me=B.I)(e),Wn=()=>(Wn=B.J)(),zn=e=>(zn=B.K)(e);o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=B.L)();var Nn=e=>(Nn=B.M)(e);o.dynCall_jiji=(e,r,t,n,s)=>(o.dynCall_jiji=B.N)(e,r,t,n,s),o._ff_h264_cabac_tables=67061;var Zr;ir=function e(){Zr||Vn(),Zr||(ir=e)};function Vn(){if(Se>0||(xr(),Se>0))return;function e(){Zr||(Zr=!0,o.calledRun=!0,!te&&(Ir(),p(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),Ge()))}o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),e()},1)):e()}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return Vn(),a.ready}})();class Ci extends Jt{constructor(a){super(go,a!=null&&a.wasmPath?fetch(a==null?void 0:a.wasmPath).then(o=>o.arrayBuffer()):void 0,a==null?void 0:a.workerMode,a==null?void 0:a.canvas,a==null?void 0:a.yuvMode)}}var wo=(()=>{var h=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(a={}){var o=a,p,y;o.ready=new Promise((c,d)=>{p=c,y=d});var _=Object.assign({},o),b=typeof window=="object",F=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&process.versions.node;var k="";function w(c){return o.locateFile?o.locateFile(c,k):k+c}var $;(b||F)&&(F?k=self.location.href:typeof document<"u"&&document.currentScript&&(k=document.currentScript.src),h&&(k=h),k.indexOf("blob:")!==0?k=k.substr(0,k.replace(/[?#].*/,"").lastIndexOf("/")+1):k="",F&&($=c=>{var d=new XMLHttpRequest;return d.open("GET",c,!1),d.responseType="arraybuffer",d.send(null),new Uint8Array(d.response)}));var S=o.print||console.log.bind(console),G=o.printErr||console.error.bind(console);Object.assign(o,_),_=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit;var Q;o.wasmBinary&&(Q=o.wasmBinary),o.noExitRuntime,typeof WebAssembly!="object"&&Se("no native wasm support detected");var V,W,R=!1,Z,B,te,be,J,Y,we,ke;function z(){var c=V.buffer;o.HEAP8=Z=new Int8Array(c),o.HEAP16=te=new Int16Array(c),o.HEAP32=J=new Int32Array(c),o.HEAPU8=B=new Uint8Array(c),o.HEAPU16=be=new Uint16Array(c),o.HEAPU32=Y=new Uint32Array(c),o.HEAPF32=we=new Float32Array(c),o.HEAPF64=ke=new Float64Array(c)}var N,ze=[],he=[],se=[];function ve(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)mr(o.preRun.shift());jr(ze)}function Jr(){jr(he)}function Ar(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)Ir(o.postRun.shift());jr(se)}function mr(c){ze.unshift(c)}function xr(c){he.unshift(c)}function Ir(c){se.unshift(c)}var Ge=0,yr=null;function Ce(c){Ge++,o.monitorRunDependencies&&o.monitorRunDependencies(Ge)}function Te(c){if(Ge--,o.monitorRunDependencies&&o.monitorRunDependencies(Ge),Ge==0&&yr){var d=yr;yr=null,d()}}function Se(c){o.onAbort&&o.onAbort(c),c="Aborted("+c+")",G(c),R=!0,c+=". Build with -sASSERTIONS for more info.";var d=new WebAssembly.RuntimeError(c);throw y(d),d}var ir="data:application/octet-stream;base64,";function ri(c){return c.startsWith(ir)}var er;er="videodec_simd.wasm",ri(er)||(er=w(er));function lr(c){if(c==er&&Q)return new Uint8Array(Q);if($)return $(c);throw"both async and sync fetching of the wasm failed"}function je(c){return!Q&&(b||F)&&typeof fetch=="function"?fetch(c,{credentials:"same-origin"}).then(d=>{if(!d.ok)throw"failed to load wasm binary file at '"+c+"'";return d.arrayBuffer()}).catch(()=>lr(c)):Promise.resolve().then(()=>lr(c))}function Ut(c,d,v){return je(c).then(E=>WebAssembly.instantiate(E,d)).then(E=>E).then(v,E=>{G("failed to asynchronously prepare wasm: "+E),Se(E)})}function vt(c,d,v,E){return!c&&typeof WebAssembly.instantiateStreaming=="function"&&!ri(d)&&typeof fetch=="function"?fetch(d,{credentials:"same-origin"}).then(D=>{var x=WebAssembly.instantiateStreaming(D,v);return x.then(E,function(j){return G("wasm streaming compile failed: "+j),G("falling back to ArrayBuffer instantiation"),Ut(d,v,E)})}):Ut(d,v,E)}function qe(){var c={a:Ln};function d(E,D){var x=E.exports;return W=x,V=W.v,z(),N=W.z,xr(W.w),Te(),x}Ce();function v(E){d(E.instance)}if(o.instantiateWasm)try{return o.instantiateWasm(c,d)}catch(E){G("Module.instantiateWasm callback failed with error: "+E),y(E)}return vt(Q,er,c,v).catch(y),{}}var jr=c=>{for(;c.length>0;)c.shift()(o)};function en(c){this.excPtr=c,this.ptr=c-24,this.set_type=function(d){Y[this.ptr+4>>2]=d},this.get_type=function(){return Y[this.ptr+4>>2]},this.set_destructor=function(d){Y[this.ptr+8>>2]=d},this.get_destructor=function(){return Y[this.ptr+8>>2]},this.set_caught=function(d){d=d?1:0,Z[this.ptr+12>>0]=d},this.get_caught=function(){return Z[this.ptr+12>>0]!=0},this.set_rethrown=function(d){d=d?1:0,Z[this.ptr+13>>0]=d},this.get_rethrown=function(){return Z[this.ptr+13>>0]!=0},this.init=function(d,v){this.set_adjusted_ptr(0),this.set_type(d),this.set_destructor(v)},this.set_adjusted_ptr=function(d){Y[this.ptr+16>>2]=d},this.get_adjusted_ptr=function(){return Y[this.ptr+16>>2]},this.get_exception_ptr=function(){var d=qt(this.get_type());if(d)return Y[this.excPtr>>2];var v=this.get_adjusted_ptr();return v!==0?v:this.excPtr}}var et=0;function rn(c,d,v){var E=new en(c);throw E.init(d,v),et=c,et}function tn(c,d,v,E,D){}function M(c){switch(c){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${c}`)}}function ee(){for(var c=new Array(256),d=0;d<256;++d)c[d]=String.fromCharCode(d);Dr=c}var Dr=void 0;function Le(c){for(var d="",v=c;B[v];)d+=Dr[B[v++]];return d}var cr={},gr={},rt={},K=void 0;function de(c){throw new K(c)}var tt=void 0;function Pe(c){throw new tt(c)}function wr(c,d,v){c.forEach(function(O){rt[O]=d});function E(O){var X=v(O);X.length!==c.length&&Pe("Mismatched type converter count");for(var L=0;L<c.length;++L)Be(c[L],X[L])}var D=new Array(d.length),x=[],j=0;d.forEach((O,X)=>{gr.hasOwnProperty(O)?D[X]=gr[O]:(x.push(O),cr.hasOwnProperty(O)||(cr[O]=[]),cr[O].push(()=>{D[X]=gr[O],++j,j===x.length&&E(D)}))}),x.length===0&&E(D)}function Xe(c,d,v={}){var E=d.name;if(c||de(`type "${E}" must have a positive integer typeid pointer`),gr.hasOwnProperty(c)){if(v.ignoreDuplicateRegistrations)return;de(`Cannot register type '${E}' twice`)}if(gr[c]=d,delete rt[c],cr.hasOwnProperty(c)){var D=cr[c];delete cr[c],D.forEach(x=>x())}}function Be(c,d,v={}){if(!("argPackAdvance"in d))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Xe(c,d,v)}function Lr(c,d,v,E,D){var x=M(v);d=Le(d),Be(c,{name:d,fromWireType:function(j){return!!j},toWireType:function(j,O){return O?E:D},argPackAdvance:8,readValueFromPointer:function(j){var O;if(v===1)O=Z;else if(v===2)O=te;else if(v===4)O=J;else throw new TypeError("Unknown boolean type size: "+d);return this.fromWireType(O[j>>x])},destructorFunction:null})}function Br(c){if(!(this instanceof rr)||!(c instanceof rr))return!1;for(var d=this.$$.ptrType.registeredClass,v=this.$$.ptr,E=c.$$.ptrType.registeredClass,D=c.$$.ptr;d.baseClass;)v=d.upcast(v),d=d.baseClass;for(;E.baseClass;)D=E.upcast(D),E=E.baseClass;return d===E&&v===D}function Hr(c){return{count:c.count,deleteScheduled:c.deleteScheduled,preservePointerOnDelete:c.preservePointerOnDelete,ptr:c.ptr,ptrType:c.ptrType,smartPtr:c.smartPtr,smartPtrType:c.smartPtrType}}function mt(c){function d(v){return v.$$.ptrType.registeredClass.name}de(d(c)+" instance already deleted")}var Ue=!1;function nt(c){}function H(c){c.smartPtr?c.smartPtrType.rawDestructor(c.smartPtr):c.ptrType.registeredClass.rawDestructor(c.ptr)}function Mt(c){c.count.value-=1;var d=c.count.value===0;d&&H(c)}function xt(c,d,v){if(d===v)return c;if(v.baseClass===void 0)return null;var E=xt(c,d,v.baseClass);return E===null?null:v.downcast(E)}var It={};function nn(){return Object.keys(Wr).length}function on(){var c=[];for(var d in Wr)Wr.hasOwnProperty(d)&&c.push(Wr[d]);return c}var or=[];function i(){for(;or.length;){var c=or.pop();c.$$.deleteScheduled=!1,c.delete()}}var _r=void 0;function le(c){_r=c,or.length&&_r&&_r(i)}function sn(){o.getInheritedInstanceCount=nn,o.getLiveInheritedInstances=on,o.flushPendingDeletes=i,o.setDelayFunction=le}var Wr={};function an(c,d){for(d===void 0&&de("ptr should not be undefined");c.baseClass;)d=c.upcast(d),c=c.baseClass;return d}function zr(c,d){return d=an(c,d),Wr[d]}function it(c,d){(!d.ptrType||!d.ptr)&&Pe("makeClassHandle requires ptr and ptrType");var v=!!d.smartPtrType,E=!!d.smartPtr;return v!==E&&Pe("Both smartPtrType and smartPtr must be specified"),d.count={value:1},me(Object.create(c,{$$:{value:d}}))}function yt(c){var d=this.getPointee(c);if(!d)return this.destructor(c),null;var v=zr(this.registeredClass,d);if(v!==void 0){if(v.$$.count.value===0)return v.$$.ptr=d,v.$$.smartPtr=c,v.clone();var E=v.clone();return this.destructor(c),E}function D(){return this.isSmartPointer?it(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:d,smartPtrType:this,smartPtr:c}):it(this.registeredClass.instancePrototype,{ptrType:this,ptr:c})}var x=this.registeredClass.getActualType(d),j=It[x];if(!j)return D.call(this);var O;this.isConst?O=j.constPointerType:O=j.pointerType;var X=xt(d,this.registeredClass,O.registeredClass);return X===null?D.call(this):this.isSmartPointer?it(O.registeredClass.instancePrototype,{ptrType:O,ptr:X,smartPtrType:this,smartPtr:c}):it(O.registeredClass.instancePrototype,{ptrType:O,ptr:X})}var me=function(c){return typeof FinalizationRegistry>"u"?(me=d=>d,c):(Ue=new FinalizationRegistry(d=>{Mt(d.$$)}),me=d=>{var v=d.$$,E=!!v.smartPtr;if(E){var D={$$:v};Ue.register(d,D,d)}return d},nt=d=>Ue.unregister(d),me(c))};function Ke(){if(this.$$.ptr||mt(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var c=me(Object.create(Object.getPrototypeOf(this),{$$:{value:Hr(this.$$)}}));return c.$$.count.value+=1,c.$$.deleteScheduled=!1,c}function He(){this.$$.ptr||mt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&de("Object already scheduled for deletion"),nt(this),Mt(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function br(){return!this.$$.ptr}function Qe(){return this.$$.ptr||mt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&de("Object already scheduled for deletion"),or.push(this),or.length===1&&_r&&_r(i),this.$$.deleteScheduled=!0,this}function q(){rr.prototype.isAliasOf=Br,rr.prototype.clone=Ke,rr.prototype.delete=He,rr.prototype.isDeleted=br,rr.prototype.deleteLater=Qe}function rr(){}var Er=48,sr=57;function ot(c){if(c===void 0)return"_unknown";c=c.replace(/[^a-zA-Z0-9_]/g,"$");var d=c.charCodeAt(0);return d>=Er&&d<=sr?`_${c}`:c}function $e(c,d){return c=ot(c),{[c]:function(){return d.apply(this,arguments)}}[c]}function jt(c,d,v){if(c[d].overloadTable===void 0){var E=c[d];c[d]=function(){return c[d].overloadTable.hasOwnProperty(arguments.length)||de(`Function '${v}' called with an invalid number of arguments (${arguments.length}) - expects one of (${c[d].overloadTable})!`),c[d].overloadTable[arguments.length].apply(this,arguments)},c[d].overloadTable=[],c[d].overloadTable[E.argCount]=E}}function un(c,d,v){o.hasOwnProperty(c)?((v===void 0||o[c].overloadTable!==void 0&&o[c].overloadTable[v]!==void 0)&&de(`Cannot register public name '${c}' twice`),jt(o,c,c),o.hasOwnProperty(v)&&de(`Cannot register multiple overloads of a function with the same number of arguments (${v})!`),o[c].overloadTable[v]=d):(o[c]=d,v!==void 0&&(o[c].numArguments=v))}function fn(c,d,v,E,D,x,j,O){this.name=c,this.constructor=d,this.instancePrototype=v,this.rawDestructor=E,this.baseClass=D,this.getActualType=x,this.upcast=j,this.downcast=O,this.pureVirtualFunctions=[]}function Pr(c,d,v){for(;d!==v;)d.upcast||de(`Expected null or instance of ${v.name}, got an instance of ${d.name}`),c=d.upcast(c),d=d.baseClass;return c}function Nr(c,d){if(d===null)return this.isReference&&de(`null is not a valid ${this.name}`),0;d.$$||de(`Cannot pass "${Et(d)}" as a ${this.name}`),d.$$.ptr||de(`Cannot pass deleted object as a pointer of type ${this.name}`);var v=d.$$.ptrType.registeredClass,E=Pr(d.$$.ptr,v,this.registeredClass);return E}function gt(c,d){var v;if(d===null)return this.isReference&&de(`null is not a valid ${this.name}`),this.isSmartPointer?(v=this.rawConstructor(),c!==null&&c.push(this.rawDestructor,v),v):0;d.$$||de(`Cannot pass "${Et(d)}" as a ${this.name}`),d.$$.ptr||de(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&d.$$.ptrType.isConst&&de(`Cannot convert argument of type ${d.$$.smartPtrType?d.$$.smartPtrType.name:d.$$.ptrType.name} to parameter type ${this.name}`);var E=d.$$.ptrType.registeredClass;if(v=Pr(d.$$.ptr,E,this.registeredClass),this.isSmartPointer)switch(d.$$.smartPtr===void 0&&de("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:d.$$.smartPtrType===this?v=d.$$.smartPtr:de(`Cannot convert argument of type ${d.$$.smartPtrType?d.$$.smartPtrType.name:d.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:v=d.$$.smartPtr;break;case 2:if(d.$$.smartPtrType===this)v=d.$$.smartPtr;else{var D=d.clone();v=this.rawShare(v,at.toHandle(function(){D.delete()})),c!==null&&c.push(this.rawDestructor,v)}break;default:de("Unsupporting sharing policy")}return v}function ln(c,d){if(d===null)return this.isReference&&de(`null is not a valid ${this.name}`),0;d.$$||de(`Cannot pass "${Et(d)}" as a ${this.name}`),d.$$.ptr||de(`Cannot pass deleted object as a pointer of type ${this.name}`),d.$$.ptrType.isConst&&de(`Cannot convert argument of type ${d.$$.ptrType.name} to parameter type ${this.name}`);var v=d.$$.ptrType.registeredClass,E=Pr(d.$$.ptr,v,this.registeredClass);return E}function Fr(c){return this.fromWireType(J[c>>2])}function wt(c){return this.rawGetPointee&&(c=this.rawGetPointee(c)),c}function _t(c){this.rawDestructor&&this.rawDestructor(c)}function cn(c){c!==null&&c.delete()}function dn(){Ae.prototype.getPointee=wt,Ae.prototype.destructor=_t,Ae.prototype.argPackAdvance=8,Ae.prototype.readValueFromPointer=Fr,Ae.prototype.deleteObject=cn,Ae.prototype.fromWireType=yt}function Ae(c,d,v,E,D,x,j,O,X,L,oe){this.name=c,this.registeredClass=d,this.isReference=v,this.isConst=E,this.isSmartPointer=D,this.pointeeType=x,this.sharingPolicy=j,this.rawGetPointee=O,this.rawConstructor=X,this.rawShare=L,this.rawDestructor=oe,!D&&d.baseClass===void 0?E?(this.toWireType=Nr,this.destructorFunction=null):(this.toWireType=ln,this.destructorFunction=null):this.toWireType=gt}function Vr(c,d,v){o.hasOwnProperty(c)||Pe("Replacing nonexistant public symbol"),o[c].overloadTable!==void 0&&v!==void 0?o[c].overloadTable[v]=d:(o[c]=d,o[c].argCount=v)}var ar=(c,d,v)=>{var E=o["dynCall_"+c];return v&&v.length?E.apply(null,[d].concat(v)):E.call(null,d)},st=[],Lt=c=>{var d=st[c];return d||(c>=st.length&&(st.length=c+1),st[c]=d=N.get(c)),d},ur=(c,d,v)=>{if(c.includes("j"))return ar(c,d,v);var E=Lt(d).apply(null,v);return E},hn=(c,d)=>{var v=[];return function(){return v.length=0,Object.assign(v,arguments),ur(c,d,v)}};function Rr(c,d){c=Le(c);function v(){return c.includes("j")?hn(c,d):Lt(d)}var E=v();return typeof E!="function"&&de(`unknown function pointer with signature ${c}: ${d}`),E}function Cr(c,d){var v=$e(d,function(E){this.name=d,this.message=E;var D=new Error(E).stack;D!==void 0&&(this.stack=this.toString()+`
  24. `+D.replace(/^Error(:[^\n]*)?\n/,""))});return v.prototype=Object.create(c.prototype),v.prototype.constructor=v,v.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},v}var Bt=void 0;function tr(c){var d=Gt(c),v=Le(d);return fr(d),v}function bt(c,d){var v=[],E={};function D(x){if(!E[x]&&!gr[x]){if(rt[x]){rt[x].forEach(D);return}v.push(x),E[x]=!0}}throw d.forEach(D),new Bt(`${c}: `+v.map(tr).join([", "]))}function pn(c,d,v,E,D,x,j,O,X,L,oe,ae,ce){oe=Le(oe),x=Rr(D,x),O&&(O=Rr(j,O)),L&&(L=Rr(X,L)),ce=Rr(ae,ce);var ye=ot(oe);un(ye,function(){bt(`Cannot construct ${oe} due to unbound types`,[E])}),wr([c,d,v],E?[E]:[],function(Fe){Fe=Fe[0];var Ve,Ie;E?(Ve=Fe.registeredClass,Ie=Ve.instancePrototype):Ie=rr.prototype;var hr=$e(ye,function(){if(Object.getPrototypeOf(this)!==Ft)throw new K("Use 'new' to construct "+oe);if(Ye.constructor_body===void 0)throw new K(oe+" has no accessible constructor");var nr=Ye.constructor_body[arguments.length];if(nr===void 0)throw new K(`Tried to invoke ctor of ${oe} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(Ye.constructor_body).toString()}) parameters instead!`);return nr.apply(this,arguments)}),Ft=Object.create(Ie,{constructor:{value:hr}});hr.prototype=Ft;var Ye=new fn(oe,hr,Ft,ce,Ve,x,O,L);Ye.baseClass&&(Ye.baseClass.__derivedClasses===void 0&&(Ye.baseClass.__derivedClasses=[]),Ye.baseClass.__derivedClasses.push(Ye));var Bn=new Ae(oe,Ye,!0,!1,!1),Ur=new Ae(oe+"*",Ye,!1,!1,!1),Kt=new Ae(oe+" const*",Ye,!1,!0,!1);return It[c]={pointerType:Ur,constPointerType:Kt},Vr(ye,hr),[Bn,Ur,Kt]})}function Ht(c,d){for(var v=[],E=0;E<c;E++)v.push(Y[d+E*4>>2]);return v}function vn(c){for(;c.length;){var d=c.pop(),v=c.pop();v(d)}}function Wt(c,d){if(!(c instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof c} which is not a function`);var v=$e(c.name||"unknownFunctionName",function(){});v.prototype=c.prototype;var E=new v,D=c.apply(E,d);return D instanceof Object?D:E}function Re(c,d,v,E,D,x){var j=d.length;j<2&&de("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var O=d[1]!==null&&v!==null,X=!1,L=1;L<d.length;++L)if(d[L]!==null&&d[L].destructorFunction===void 0){X=!0;break}for(var oe=d[0].name!=="void",ae="",ce="",L=0;L<j-2;++L)ae+=(L!==0?", ":"")+"arg"+L,ce+=(L!==0?", ":"")+"arg"+L+"Wired";var ye=`
  25. return function ${ot(c)}(${ae}) {
  26. if (arguments.length !== ${j-2}) {
  27. throwBindingError('function ${c} called with ${arguments.length} arguments, expected ${j-2} args!');
  28. }`;X&&(ye+=`var destructors = [];
  29. `);var Fe=X?"destructors":"null",Ve=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],Ie=[de,E,D,vn,d[0],d[1]];O&&(ye+="var thisWired = classParam.toWireType("+Fe+`, this);
  30. `);for(var L=0;L<j-2;++L)ye+="var arg"+L+"Wired = argType"+L+".toWireType("+Fe+", arg"+L+"); // "+d[L+2].name+`
  31. `,Ve.push("argType"+L),Ie.push(d[L+2]);if(O&&(ce="thisWired"+(ce.length>0?", ":"")+ce),ye+=(oe||x?"var rv = ":"")+"invoker(fn"+(ce.length>0?", ":"")+ce+`);
  32. `,X)ye+=`runDestructors(destructors);
  33. `;else for(var L=O?1:2;L<d.length;++L){var hr=L===1?"thisWired":"arg"+(L-2)+"Wired";d[L].destructorFunction!==null&&(ye+=hr+"_dtor("+hr+"); // "+d[L].name+`
  34. `,Ve.push(hr+"_dtor"),Ie.push(d[L].destructorFunction))}return oe&&(ye+=`var ret = retType.fromWireType(rv);
  35. return ret;
  36. `),ye+=`}
  37. `,Ve.push(ye),Wt(Function,Ve).apply(null,Ie)}function mn(c,d,v,E,D,x){var j=Ht(d,v);D=Rr(E,D),wr([],[c],function(O){O=O[0];var X=`constructor ${O.name}`;if(O.registeredClass.constructor_body===void 0&&(O.registeredClass.constructor_body=[]),O.registeredClass.constructor_body[d-1]!==void 0)throw new K(`Cannot register multiple constructors with identical number of parameters (${d-1}) for class '${O.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return O.registeredClass.constructor_body[d-1]=()=>{bt(`Cannot construct ${O.name} due to unbound types`,j)},wr([],j,function(L){return L.splice(1,0,null),O.registeredClass.constructor_body[d-1]=Re(X,L,null,D,x),[]}),[]})}function yn(c,d,v,E,D,x,j,O,X){var L=Ht(v,E);d=Le(d),x=Rr(D,x),wr([],[c],function(oe){oe=oe[0];var ae=`${oe.name}.${d}`;d.startsWith("@@")&&(d=Symbol[d.substring(2)]),O&&oe.registeredClass.pureVirtualFunctions.push(d);function ce(){bt(`Cannot call ${ae} due to unbound types`,L)}var ye=oe.registeredClass.instancePrototype,Fe=ye[d];return Fe===void 0||Fe.overloadTable===void 0&&Fe.className!==oe.name&&Fe.argCount===v-2?(ce.argCount=v-2,ce.className=oe.name,ye[d]=ce):(jt(ye,d,ae),ye[d].overloadTable[v-2]=ce),wr([],L,function(Ve){var Ie=Re(ae,Ve,oe,x,j,X);return ye[d].overloadTable===void 0?(Ie.argCount=v-2,ye[d]=Ie):ye[d].overloadTable[v-2]=Ie,[]}),[]})}function Tr(){Object.assign(Or.prototype,{get(c){return this.allocated[c]},has(c){return this.allocated[c]!==void 0},allocate(c){var d=this.freelist.pop()||this.allocated.length;return this.allocated[d]=c,d},free(c){this.allocated[c]=void 0,this.freelist.push(c)}})}function Or(){this.allocated=[void 0],this.freelist=[]}var We=new Or;function zt(c){c>=We.reserved&&--We.get(c).refcount===0&&We.free(c)}function gn(){for(var c=0,d=We.reserved;d<We.allocated.length;++d)We.allocated[d]!==void 0&&++c;return c}function Gr(){We.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),We.reserved=We.allocated.length,o.count_emval_handles=gn}var at={toValue:c=>(c||de("Cannot use deleted val. handle = "+c),We.get(c).value),toHandle:c=>{switch(c){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return We.allocate({refcount:1,value:c})}}};function wn(c,d){d=Le(d),Be(c,{name:d,fromWireType:function(v){var E=at.toValue(v);return zt(v),E},toWireType:function(v,E){return at.toHandle(E)},argPackAdvance:8,readValueFromPointer:Fr,destructorFunction:null})}function Et(c){if(c===null)return"null";var d=typeof c;return d==="object"||d==="array"||d==="function"?c.toString():""+c}function $r(c,d){switch(d){case 2:return function(v){return this.fromWireType(we[v>>2])};case 3:return function(v){return this.fromWireType(ke[v>>3])};default:throw new TypeError("Unknown float type: "+c)}}function _n(c,d,v){var E=M(v);d=Le(d),Be(c,{name:d,fromWireType:function(D){return D},toWireType:function(D,x){return x},argPackAdvance:8,readValueFromPointer:$r(d,E),destructorFunction:null})}function bn(c,d,v){switch(d){case 0:return v?function(D){return Z[D]}:function(D){return B[D]};case 1:return v?function(D){return te[D>>1]}:function(D){return be[D>>1]};case 2:return v?function(D){return J[D>>2]}:function(D){return Y[D>>2]};default:throw new TypeError("Unknown integer type: "+c)}}function En(c,d,v,E,D){d=Le(d);var x=M(v),j=ae=>ae;if(E===0){var O=32-8*v;j=ae=>ae<<O>>>O}var X=d.includes("unsigned"),L=(ae,ce)=>{},oe;X?oe=function(ae,ce){return L(ce,this.name),ce>>>0}:oe=function(ae,ce){return L(ce,this.name),ce},Be(c,{name:d,fromWireType:j,toWireType:oe,argPackAdvance:8,readValueFromPointer:bn(d,x,E!==0),destructorFunction:null})}function Pn(c,d,v){var E=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],D=E[d];function x(j){j=j>>2;var O=Y,X=O[j],L=O[j+1];return new D(O.buffer,L,X)}v=Le(v),Be(c,{name:v,fromWireType:x,argPackAdvance:8,readValueFromPointer:x},{ignoreDuplicateRegistrations:!0})}var De=(c,d,v,E)=>{if(!(E>0))return 0;for(var D=v,x=v+E-1,j=0;j<c.length;++j){var O=c.charCodeAt(j);if(O>=55296&&O<=57343){var X=c.charCodeAt(++j);O=65536+((O&1023)<<10)|X&1023}if(O<=127){if(v>=x)break;d[v++]=O}else if(O<=2047){if(v+1>=x)break;d[v++]=192|O>>6,d[v++]=128|O&63}else if(O<=65535){if(v+2>=x)break;d[v++]=224|O>>12,d[v++]=128|O>>6&63,d[v++]=128|O&63}else{if(v+3>=x)break;d[v++]=240|O>>18,d[v++]=128|O>>12&63,d[v++]=128|O>>6&63,d[v++]=128|O&63}}return d[v]=0,v-D},Cn=(c,d,v)=>De(c,B,d,v),Tn=c=>{for(var d=0,v=0;v<c.length;++v){var E=c.charCodeAt(v);E<=127?d++:E<=2047?d+=2:E>=55296&&E<=57343?(d+=4,++v):d+=3}return d},dr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,ut=(c,d,v)=>{for(var E=d+v,D=d;c[D]&&!(D>=E);)++D;if(D-d>16&&c.buffer&&dr)return dr.decode(c.subarray(d,D));for(var x="";d<D;){var j=c[d++];if(!(j&128)){x+=String.fromCharCode(j);continue}var O=c[d++]&63;if((j&224)==192){x+=String.fromCharCode((j&31)<<6|O);continue}var X=c[d++]&63;if((j&240)==224?j=(j&15)<<12|O<<6|X:j=(j&7)<<18|O<<12|X<<6|c[d++]&63,j<65536)x+=String.fromCharCode(j);else{var L=j-65536;x+=String.fromCharCode(55296|L>>10,56320|L&1023)}}return x},$n=(c,d)=>c?ut(B,c,d):"";function Sn(c,d){d=Le(d);var v=d==="std::string";Be(c,{name:d,fromWireType:function(E){var D=Y[E>>2],x=E+4,j;if(v)for(var O=x,X=0;X<=D;++X){var L=x+X;if(X==D||B[L]==0){var oe=L-O,ae=$n(O,oe);j===void 0?j=ae:(j+=String.fromCharCode(0),j+=ae),O=L+1}}else{for(var ce=new Array(D),X=0;X<D;++X)ce[X]=String.fromCharCode(B[x+X]);j=ce.join("")}return fr(E),j},toWireType:function(E,D){D instanceof ArrayBuffer&&(D=new Uint8Array(D));var x,j=typeof D=="string";j||D instanceof Uint8Array||D instanceof Uint8ClampedArray||D instanceof Int8Array||de("Cannot pass non-string to std::string"),v&&j?x=Tn(D):x=D.length;var O=Kr(4+x+1),X=O+4;if(Y[O>>2]=x,v&&j)Cn(D,X,x+1);else if(j)for(var L=0;L<x;++L){var oe=D.charCodeAt(L);oe>255&&(fr(X),de("String has UTF-16 code units that do not fit in 8 bits")),B[X+L]=oe}else for(var L=0;L<x;++L)B[X+L]=D[L];return E!==null&&E.push(fr,O),O},argPackAdvance:8,readValueFromPointer:Fr,destructorFunction:function(E){fr(E)}})}var Ne=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,kn=(c,d)=>{for(var v=c,E=v>>1,D=E+d/2;!(E>=D)&&be[E];)++E;if(v=E<<1,v-c>32&&Ne)return Ne.decode(B.subarray(c,v));for(var x="",j=0;!(j>=d/2);++j){var O=te[c+j*2>>1];if(O==0)break;x+=String.fromCharCode(O)}return x},Pt=(c,d,v)=>{if(v===void 0&&(v=2147483647),v<2)return 0;v-=2;for(var E=d,D=v<c.length*2?v/2:c.length,x=0;x<D;++x){var j=c.charCodeAt(x);te[d>>1]=j,d+=2}return te[d>>1]=0,d-E},Ct=c=>c.length*2,qr=(c,d)=>{for(var v=0,E="";!(v>=d/4);){var D=J[c+v*4>>2];if(D==0)break;if(++v,D>=65536){var x=D-65536;E+=String.fromCharCode(55296|x>>10,56320|x&1023)}else E+=String.fromCharCode(D)}return E},An=(c,d,v)=>{if(v===void 0&&(v=2147483647),v<4)return 0;for(var E=d,D=E+v-4,x=0;x<c.length;++x){var j=c.charCodeAt(x);if(j>=55296&&j<=57343){var O=c.charCodeAt(++x);j=65536+((j&1023)<<10)|O&1023}if(J[d>>2]=j,d+=4,d+4>D)break}return J[d>>2]=0,d-E},Tt=c=>{for(var d=0,v=0;v<c.length;++v){var E=c.charCodeAt(v);E>=55296&&E<=57343&&++v,d+=4}return d},Dn=function(c,d,v){v=Le(v);var E,D,x,j,O;d===2?(E=kn,D=Pt,j=Ct,x=()=>be,O=1):d===4&&(E=qr,D=An,j=Tt,x=()=>Y,O=2),Be(c,{name:v,fromWireType:function(X){for(var L=Y[X>>2],oe=x(),ae,ce=X+4,ye=0;ye<=L;++ye){var Fe=X+4+ye*d;if(ye==L||oe[Fe>>O]==0){var Ve=Fe-ce,Ie=E(ce,Ve);ae===void 0?ae=Ie:(ae+=String.fromCharCode(0),ae+=Ie),ce=Fe+d}}return fr(X),ae},toWireType:function(X,L){typeof L!="string"&&de(`Cannot pass non-string to C++ string type ${v}`);var oe=j(L),ae=Kr(4+oe+d);return Y[ae>>2]=oe>>O,D(L,ae+4,oe+d),X!==null&&X.push(fr,ae),ae},argPackAdvance:8,readValueFromPointer:Fr,destructorFunction:function(X){fr(X)}})};function $t(c,d){d=Le(d),Be(c,{isVoid:!0,name:d,argPackAdvance:0,fromWireType:function(){},toWireType:function(v,E){}})}var St={};function Fn(c){var d=St[c];return d===void 0?Le(c):d}var kt=[];function Rn(c,d,v,E){c=kt[c],d=at.toValue(d),v=Fn(v),c(d,v,null,E)}function At(c){var d=kt.length;return kt.push(c),d}function Ee(c,d){var v=gr[c];return v===void 0&&de(d+" has unknown type "+tr(c)),v}function Dt(c,d){for(var v=new Array(c),E=0;E<c;++E)v[E]=Ee(Y[d+E*4>>2],"parameter "+E);return v}var Nt=[];function On(c,d){var v=Dt(c,d),E=v[0],D=E.name+"_$"+v.slice(1).map(function(Fe){return Fe.name}).join("_")+"$",x=Nt[D];if(x!==void 0)return x;for(var j=["retType"],O=[E],X="",L=0;L<c-1;++L)X+=(L!==0?", ":"")+"arg"+L,j.push("argType"+L),O.push(v[1+L]);for(var oe=ot("methodCaller_"+D),ae="return function "+oe+`(handle, name, destructors, args) {
  38. `,ce=0,L=0;L<c-1;++L)ae+=" var arg"+L+" = argType"+L+".readValueFromPointer(args"+(ce?"+"+ce:"")+`);
  39. `,ce+=v[L+1].argPackAdvance;ae+=" var rv = handle[name]("+X+`);
  40. `;for(var L=0;L<c-1;++L)v[L+1].deleteObject&&(ae+=" argType"+L+".deleteObject(arg"+L+`);
  41. `);E.isVoid||(ae+=` return retType.toWireType(destructors, rv);
  42. `),ae+=`};
  43. `,j.push(ae);var ye=Wt(Function,j).apply(null,O);return x=At(ye),Nt[D]=x,x}var Sr=()=>{Se("")},Vt;Vt=()=>performance.now();var Xr=(c,d,v)=>B.copyWithin(c,d,d+v),Un=c=>{Se("OOM")},Mn=c=>{B.length,Un()},xn=[null,[],[]],In=(c,d)=>{var v=xn[c];d===0||d===10?((c===1?S:G)(ut(v,0)),v.length=0):v.push(d)},jn=(c,d,v,E)=>{for(var D=0,x=0;x<v;x++){var j=Y[d>>2],O=Y[d+4>>2];d+=8;for(var X=0;X<O;X++)In(c,B[j+X]);D+=O}return Y[E>>2]=D,0};ee(),K=o.BindingError=class extends Error{constructor(d){super(d),this.name="BindingError"}},tt=o.InternalError=class extends Error{constructor(d){super(d),this.name="InternalError"}},q(),sn(),dn(),Bt=o.UnboundTypeError=Cr(Error,"UnboundTypeError"),Tr(),Gr();var Ln={o:rn,r:tn,m:Lr,q:pn,p:mn,d:yn,u:wn,k:_n,b:En,a:Pn,j:Sn,g:Dn,n:$t,e:Rn,l:zt,h:On,f:Sr,c:Vt,t:Xr,s:Mn,i:jn};qe();var fr=c=>(fr=W.x)(c),Kr=c=>(Kr=W.y)(c),Gt=c=>(Gt=W.A)(c);o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=W.B)();var qt=c=>(qt=W.C)(c);o.dynCall_jiji=(c,d,v,E,D)=>(o.dynCall_jiji=W.D)(c,d,v,E,D);var ft;yr=function c(){ft||Xt(),ft||(yr=c)};function Xt(){if(Ge>0||(ve(),Ge>0))return;function c(){ft||(ft=!0,o.calledRun=!0,!R&&(Jr(),p(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),Ar()))}o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),c()},1)):c()}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return Xt(),a.ready}})();class Oi extends Jt{constructor(a){super(wo,a!=null&&a.wasmPath?fetch(a.wasmPath).then(o=>o.arrayBuffer()):void 0,a==null?void 0:a.workerMode,a==null?void 0:a.canvas,a==null?void 0:a.yuvMode)}}var _o=Object.defineProperty,bo=Object.getOwnPropertyDescriptor,Zn=(h,a,o,p)=>{for(var y=p>1?void 0:p?bo(a,o):a,_=h.length-1,b;_>=0;_--)(b=h[_])&&(y=(p?b(a,o,y):b(y))||y);return p&&y&&_o(a,o,y),y};class ct extends pe{async initialize(){this.decoder=new VideoDecoder({output:a=>{this.emit(kr.VideoFrame,a)},error:a=>{this.close(),this.emit(kr.Error,a)}})}configure(a){this.config=a,!a.description&&a.codec!=="av1"&&(this.config[a.codec]={format:"annexb"}),this.decoder.configure({...a,codec:this.getCodec(a)})}getCodec(a){switch(a.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 a.codec}}decode(a){this.decoder.state==="configured"&&this.decoder.decode(new EncodedVideoChunk(a))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){this.decoder.state!=="closed"&&this.decoder.close()}}Zn([Oe([pe.INIT,"closed"],"initialized")],ct.prototype,"initialize",1);Zn([Oe("initialized","configured",{sync:!0})],ct.prototype,"configure",1);Zn([Ai("configured")],ct.prototype,"decode",1);Zn([Oe([],pe.INIT,{sync:!0})],ct.prototype,"reset",1);Zn([Oe([],"closed",{ignoreError:!0,sync:!0})],ct.prototype,"close",1);const U=class{static box(h,...a){let o=8,p=a.length;for(let b=0;b<p;b++)o+=a[b].byteLength;let y=new Uint8Array(o);y[0]=o>>>24&255,y[1]=o>>>16&255,y[2]=o>>>8&255,y[3]=o&255,y.set(h,4);let _=8;for(let b=0;b<p;b++)y.set(a[b],_),_+=a[b].byteLength;return y}static generateInitSegment(h){let a=U.box(U.types.ftyp,U.constants.FTYP),o=U.moov(h),p=new Uint8Array(a.byteLength+o.byteLength);return p.set(a,0),p.set(o,a.byteLength),p}static moov(h){let a=U.mvhd(h.timescale,h.duration),o=U.trak(h),p=U.mvex(h);return U.box(U.types.moov,a,o,p)}static mvhd(h,a){return U.box(U.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,h>>>24&255,h>>>16&255,h>>>8&255,h&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))}static trak(h){return U.box(U.types.trak,U.tkhd(h),U.mdia(h))}static tkhd(h){let a=h.id,o=h.duration,p=h.presentWidth,y=h.presentHeight;return U.box(U.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,a&255,0,0,0,0,o>>>24&255,o>>>16&255,o>>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,p>>>8&255,p&255,0,0,y>>>8&255,y&255,0,0]))}static mdia(h){return U.box(U.types.mdia,U.mdhd(h),U.hdlr(h),U.minf(h))}static mdhd(h){let a=h.timescale,o=h.duration;return U.box(U.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,a&255,o>>>24&255,o>>>16&255,o>>>8&255,o&255,85,196,0,0]))}static hdlr(h){let a=null;return h.type==="audio"?a=U.constants.HDLR_AUDIO:a=U.constants.HDLR_VIDEO,U.box(U.types.hdlr,a)}static minf(h){let a=null;return h.type==="audio"?a=U.box(U.types.smhd,U.constants.SMHD):a=U.box(U.types.vmhd,U.constants.VMHD),U.box(U.types.minf,a,U.dinf(),U.stbl(h))}static dinf(){return U.box(U.types.dinf,U.box(U.types.dref,U.constants.DREF))}static stbl(h){return U.box(U.types.stbl,U.stsd(h),U.box(U.types.stts,U.constants.STTS),U.box(U.types.stsc,U.constants.STSC),U.box(U.types.stsz,U.constants.STSZ),U.box(U.types.stco,U.constants.STCO))}static stsd(h){return h.type==="audio"?U.box(U.types.stsd,U.constants.STSD_PREFIX,U.mp4a(h)):h.videoType==="avc"?U.box(U.types.stsd,U.constants.STSD_PREFIX,U.avc1(h)):U.box(U.types.stsd,U.constants.STSD_PREFIX,U.hvc1(h))}static mp4a(h){let a=h.channelCount,o=h.audioSampleRate,p=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,a,0,16,0,0,0,0,o>>>8&255,o&255,0,0]);return U.box(U.types.mp4a,p,U.esds(h))}static esds(h){let a=h.config||[],o=a.length,p=new Uint8Array([0,0,0,0,3,23+o,0,1,0,4,15+o,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([o]).concat(a).concat([6,1,2]));return U.box(U.types.esds,p)}static avc1(h){let a=h.avcc;const o=h.codecWidth,p=h.codecHeight;let y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>>8&255,o&255,p>>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return U.box(U.types.avc1,y,U.box(U.types.avcC,a))}static hvc1(h){let a=h.avcc;const o=h.codecWidth,p=h.codecHeight;let y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>>8&255,o&255,p>>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return U.box(U.types.hvc1,y,U.box(U.types.hvcC,a))}static mvex(h){return U.box(U.types.mvex,U.trex(h))}static trex(h){let a=h.id,o=new Uint8Array([0,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,a&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return U.box(U.types.trex,o)}static moof(h,a){return U.box(U.types.moof,U.mfhd(h.sequenceNumber),U.traf(h,a))}static mfhd(h){let a=new Uint8Array([0,0,0,0,h>>>24&255,h>>>16&255,h>>>8&255,h&255]);return U.box(U.types.mfhd,a)}static traf(h,a){let o=h.id,p=U.box(U.types.tfhd,new Uint8Array([0,0,0,0,o>>>24&255,o>>>16&255,o>>>8&255,o&255])),y=U.box(U.types.tfdt,new Uint8Array([0,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,a&255])),_=U.sdtp(h),b=U.trun(h,_.byteLength+16+16+8+16+8+8);return U.box(U.types.traf,p,y,b,_)}static sdtp(h){let a=new Uint8Array(5),o=h.flags;return a[4]=o.isLeading<<6|o.dependsOn<<4|o.isDependedOn<<2|o.hasRedundancy,U.box(U.types.sdtp,a)}static trun(h,a){let o=28,p=new Uint8Array(o);a+=8+o,p.set([0,0,15,1,0,0,0,1,a>>>24&255,a>>>16&255,a>>>8&255,a&255],0);let y=h.duration,_=h.size,b=h.flags,F=h.cts;return p.set([y>>>24&255,y>>>16&255,y>>>8&255,y&255,_>>>24&255,_>>>16&255,_>>>8&255,_&255,b.isLeading<<2|b.dependsOn,b.isDependedOn<<6|b.hasRedundancy<<4|b.isNonSync,0,0,F>>>24&255,F>>>16&255,F>>>8&255,F&255],12),U.box(U.types.trun,p)}static mdat(h){return U.box(U.types.mdat,h)}};let Je=U;Je.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};Je.constants={FTYP:new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),STSD_PREFIX:new Uint8Array([0,0,0,0,0,0,0,1]),STTS:new Uint8Array([0,0,0,0,0,0,0,0]),STSC:new Uint8Array([0,0,0,0,0,0,0,0]),STCO:new Uint8Array([0,0,0,0,0,0,0,0]),STSZ:new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),HDLR_VIDEO:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),HDLR_AUDIO:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),DREF:new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),SMHD:new Uint8Array([0,0,0,0,0,0,0,0]),VMHD:new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])};for(let h in Je.types)Je.types.hasOwnProperty(h)&&(Je.types[h]=[h.charCodeAt(0),h.charCodeAt(1),h.charCodeAt(2),h.charCodeAt(3)]);Je.constants.STSC=Je.constants.STTS;Je.constants.STCO=Je.constants.STTS;class Eo{constructor(a){this.TAG="ExpGolomb",this._buffer=a,this._buffer_index=0,this._total_bytes=a.byteLength,this._total_bits=a.byteLength*8,this._current_word=0,this._current_word_bits_left=0}destroy(){this._buffer=new Uint8Array(0)}_fillCurrentWord(){const a=this._total_bytes-this._buffer_index;if(a<=0)throw new Error("ExpGolomb: _fillCurrentWord() but no bytes available");const o=Math.min(4,a),p=new Uint8Array(4);p.set(this._buffer.subarray(this._buffer_index,this._buffer_index+o)),this._current_word=new DataView(p.buffer).getUint32(0,!1),this._buffer_index+=o,this._current_word_bits_left=o*8}readBits(a){if(a>32)throw new Error("ExpGolomb: readBits() bits exceeded max 32bits!");if(a<=this._current_word_bits_left){const b=this._current_word>>>32-a;return this._current_word<<=a,this._current_word_bits_left-=a,b}let o=this._current_word_bits_left?this._current_word:0;o=o>>>32-this._current_word_bits_left;const p=a-this._current_word_bits_left;this._fillCurrentWord();const y=Math.min(p,this._current_word_bits_left),_=this._current_word>>>32-y;return this._current_word<<=y,this._current_word_bits_left-=y,o=o<<y|_,o}readBool(){return this.readBits(1)===1}readByte(){return this.readBits(8)}_skipLeadingZero(){let a;for(a=0;a<this._current_word_bits_left;a++)if(this._current_word&2147483648>>>a)return this._current_word<<=a,this._current_word_bits_left-=a,a;return this._fillCurrentWord(),a+this._skipLeadingZero()}readUEG(){const a=this._skipLeadingZero();return this.readBits(a+1)-1}readSEG(){const a=this.readUEG();return a&1?a+1>>>1:-1*(a>>>1)}}class Mr{static _ebsp2rbsp(a){let o=a,p=o.byteLength,y=new Uint8Array(p),_=0;for(let b=0;b<p;b++)b>=2&&o[b]===3&&o[b-1]===0&&o[b-2]===0||(y[_]=o[b],_++);return new Uint8Array(y.buffer,0,_)}static parseSPS(a){let o=a.subarray(1,4),p="avc1.";for(let Ce=0;Ce<3;Ce++){let Te=o[Ce].toString(16);Te.length<2&&(Te="0"+Te),p+=Te}let y=Mr._ebsp2rbsp(a),_=new Eo(y);_.readByte();let b=_.readByte();_.readByte();let F=_.readByte();_.readUEG();let k=Mr.getProfileString(b),w=Mr.getLevelString(F),$=1,S=420,G=[0,420,422,444],Q=8,V=8;if((b===100||b===110||b===122||b===244||b===44||b===83||b===86||b===118||b===128||b===138||b===144)&&($=_.readUEG(),$===3&&_.readBits(1),$<=3&&(S=G[$]),Q=_.readUEG()+8,V=_.readUEG()+8,_.readBits(1),_.readBool())){let Ce=$!==3?8:12;for(let Te=0;Te<Ce;Te++)_.readBool()&&(Te<6?Mr._skipScalingList(_,16):Mr._skipScalingList(_,64))}_.readUEG();let W=_.readUEG();if(W===0)_.readUEG();else if(W===1){_.readBits(1),_.readSEG(),_.readSEG();let Ce=_.readUEG();for(let Te=0;Te<Ce;Te++)_.readSEG()}let R=_.readUEG();_.readBits(1);let Z=_.readUEG(),B=_.readUEG(),te=_.readBits(1);te===0&&_.readBits(1),_.readBits(1);let be=0,J=0,Y=0,we=0;_.readBool()&&(be=_.readUEG(),J=_.readUEG(),Y=_.readUEG(),we=_.readUEG());let z=1,N=1,ze=0,he=!0,se=0,ve=0;if(_.readBool()){if(_.readBool()){let Ce=_.readByte(),Te=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],Se=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];Ce>0&&Ce<16?(z=Te[Ce-1],N=Se[Ce-1]):Ce===255&&(z=_.readByte()<<8|_.readByte(),N=_.readByte()<<8|_.readByte())}if(_.readBool()&&_.readBool(),_.readBool()&&(_.readBits(4),_.readBool()&&_.readBits(24)),_.readBool()&&(_.readUEG(),_.readUEG()),_.readBool()){let Ce=_.readBits(32),Te=_.readBits(32);he=_.readBool(),se=Te,ve=Ce*2,ze=se/ve}}let Ar=1;(z!==1||N!==1)&&(Ar=z/N);let mr=0,xr=0;if($===0)mr=1,xr=2-te;else{let Ce=$===3?1:2,Te=$===1?2:1;mr=Ce,xr=Te*(2-te)}let Ir=(Z+1)*16,Ge=(2-te)*((B+1)*16);Ir-=(be+J)*mr,Ge-=(Y+we)*xr;let yr=Math.ceil(Ir*Ar);return _.destroy(),_=null,{codec_mimetype:p,profile_idc:b,level_idc:F,profile_string:k,level_string:w,chroma_format_idc:$,bit_depth:Q,bit_depth_luma:Q,bit_depth_chroma:V,ref_frames:R,chroma_format:S,chroma_format_string:Mr.getChromaFormatString(S),frame_rate:{fixed:he,fps:ze,fps_den:ve,fps_num:se},sar_ratio:{width:z,height:N},codec_size:{width:Ir,height:Ge},present_size:{width:yr,height:Ge}}}static _skipScalingList(a,o){let p=8,y=8,_=0;for(let b=0;b<o;b++)y!==0&&(_=a.readSEG(),y=(p+_+256)%256),p=y===0?p:y}static getProfileString(a){switch(a){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}}static getLevelString(a){return(a/10).toFixed(1)}static getChromaFormatString(a){switch(a){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}}}function Po({sps:h,pps:a}){let o=8+h.byteLength+1+2+a.byteLength,p=!1;const y=Mr.parseSPS(h);h[3]!==66&&h[3]!==77&&h[3]!==88&&(p=!0,o+=4);let _=new Uint8Array(o);_[0]=1,_[1]=h[1],_[2]=h[2],_[3]=h[3],_[4]=255,_[5]=225;let b=h.byteLength;_[6]=b>>>8,_[7]=b&255;let F=8;_.set(h,8),F+=b,_[F]=1;let k=a.byteLength;_[F+1]=k>>>8,_[F+2]=k&255,_.set(a,F+3),F+=3+k,p&&(_[F]=252|y.chroma_format_idc,_[F+1]=248|y.bit_depth_luma-8,_[F+2]=248|y.bit_depth_chroma-8,_[F+3]=0,F+=4);const w=[23,0,0,0,0],$=new Uint8Array(w.length+_.byteLength);return $.set(w,0),$.set(_,w.length),$}var Co=Object.defineProperty,To=Object.getOwnPropertyDescriptor,ai=(h,a,o,p)=>{for(var y=p>1?void 0:p?To(a,o):a,_=h.length-1,b;_>=0;_--)(b=h[_])&&(y=(p?b(a,o,y):b(y))||y);return p&&y&&Co(a,o,y),y};class ui extends pe{constructor(){super(...arguments),this.sourceBufferCache=[]}decode(a){var p,y,_,b,F,k;if(!!((p=this.config)!=null&&p.description))try{const w=a.data.byteLength,$=8+w,S=new Uint8Array($);new DataView(S.buffer,0).setUint32(0,$,!1),S.set(Je.types.mdat,4);const Q={id:1,sequenceNumber:++this.sequenceNumber,size:w,dts:a.timestamp,cts:a.timestamp,isKeyframe:a.type==="key",data:a.data,flags:{isLeading:0,dependsOn:2,isDependedOn:1,hasRedundancy:0,isNonSync:0},duration:40},V=Je.moof(Q,a.timestamp),W=new Uint8Array(V.byteLength+S.byteLength);W.set(V,0),W.set(S,V.byteLength),(b=this.sourceBuffer)!=null&&b.updating?this.sourceBufferCache.push(W):(F=this.sourceBuffer)==null||F.appendBuffer(W)}catch(w){(k=this.element)==null||k.error,console.error(w)}else{const w=a.data instanceof ArrayBuffer?new Uint8Array(a.data):a.data;let $,S,G=!1;const V=(R=>{const Z=[];for(let B=0;B<R.length-3;B++)R[B]===0&&R[B+1]===0&&R[B+2]===0&&R[B+3]===1?Z.push(B+4):R[B]===0&&R[B+1]===0&&R[B+2]===1&&Z.push(B+3);return Z})(w),W=[];for(let R=0;R<V.length;R++){const Z=V[R],B=R<V.length-1?V[R+1]:w.length;W.push(w.subarray(Z,B))}if(W.forEach((R,Z)=>{const B=R[0]&31;B===7?$=R:B===8?S=R:B===5&&(G=!0)}),$&&S&&!this.sourceBuffer){const R=Mr.parseSPS($),Z={id:1,type:"video",timescale:1e3,duration:0,avcc:Po({sps:$,pps:S}),codecWidth:R.codec_size.width,codecHeight:R.codec_size.height,presentWidth:R.present_size.width,presentHeight:R.present_size.height,videoType:"avc"};this.sourceBuffer=this.mse.addSourceBuffer(`video/mp4; codecs="${R.codec_mimetype}"`),this.sourceBuffer.appendBuffer(Je.generateInitSegment(Z)),this.sourceBuffer.addEventListener("updateend",()=>{this.sourceBufferCache.length&&this.sourceBuffer.appendBuffer(this.sourceBufferCache.shift())})}else{const R=W.reduce((ke,z)=>ke+z.length+4,0),Z=8+R,B=new Uint8Array(Z),te=new DataView(B.buffer,0);te.setUint32(0,Z,!1),B.set(Je.types.mdat,4);let be=8;W.forEach(ke=>{te.setUint32(be,ke.length,!1),B.set(ke,be+4),be+=ke.length+4});const J={id:1,sequenceNumber:++this.sequenceNumber,size:R,dts:a.timestamp,cts:a.timestamp,isKeyframe:G,data:w,flags:{isLeading:0,dependsOn:2,isDependedOn:1,hasRedundancy:0,isNonSync:0},duration:40},Y=Je.moof(J,a.timestamp),we=new Uint8Array(Y.byteLength+B.byteLength);we.set(Y,0),we.set(B,Y.byteLength),(y=this.sourceBuffer)!=null&&y.updating?this.sourceBufferCache.push(we):(_=this.sourceBuffer)==null||_.appendBuffer(we)}}}flush(){throw new Error("Method not implemented.")}reset(){throw new Error("Method not implemented.")}close(){this.src&&URL.revokeObjectURL(this.src)}initialize(a){return this.mse=new MediaSource,this.src=URL.createObjectURL(this.mse),this.element=a,a.src=this.src,new Promise(o=>{this.mse.addEventListener("sourceopen",o)})}configure(a){if(this.config=a,a.description){const o=a.description,p=6,y=o[p]<<8|o[p+1],_=o.subarray(p+2,p+2+y),b=Mr.parseSPS(_),F={id:1,type:"video",timescale:1e3,duration:0,avcc:o,codecWidth:b.codec_size.width,codecHeight:b.codec_size.height,presentWidth:b.present_size.width,presentHeight:b.present_size.height,videoType:"avc"};this.sourceBuffer=this.mse.addSourceBuffer(`video/mp4; codecs="${b.codec_mimetype}"`),this.sourceBuffer.appendBuffer(Je.generateInitSegment(F)),this.sourceBuffer.addEventListener("updateend",()=>{this.sourceBufferCache.length&&this.sourceBuffer.appendBuffer(this.sourceBufferCache.shift())})}}}ai([Oe([],pe.INIT,{sync:!0})],ui.prototype,"reset",1);ai([Oe([],"closed",{ignoreError:!0,sync:!0})],ui.prototype,"close",1);ai([Oe([pe.INIT,"closed"],"initialized")],ui.prototype,"initialize",1);ai([Oe("initialized","configured",{sync:!0})],ui.prototype,"configure",1);var $o=(()=>{var h=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(a={}){var o=a,p,y;o.ready=new Promise((e,r)=>{p=e,y=r});var _=Object.assign({},o),b="./this.program",F=typeof window=="object",k=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&process.versions.node;var w="";function $(e){return o.locateFile?o.locateFile(e,w):w+e}var S,G,Q;(F||k)&&(k?w=self.location.href:typeof document<"u"&&document.currentScript&&(w=document.currentScript.src),h&&(w=h),w.indexOf("blob:")!==0?w=w.substr(0,w.replace(/[?#].*/,"").lastIndexOf("/")+1):w="",S=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},k&&(Q=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),G=(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)});var V=o.print||console.log.bind(console),W=o.printErr||console.error.bind(console);Object.assign(o,_),_=null,o.arguments&&o.arguments,o.thisProgram&&(b=o.thisProgram),o.quit&&o.quit;var R;o.wasmBinary&&(R=o.wasmBinary),o.noExitRuntime,typeof WebAssembly!="object"&&je("no native wasm support detected");var Z,B,te=!1;function be(e,r){e||je(r)}var J,Y,we,ke,z,N,ze,he;function se(){var e=Z.buffer;o.HEAP8=J=new Int8Array(e),o.HEAP16=we=new Int16Array(e),o.HEAP32=z=new Int32Array(e),o.HEAPU8=Y=new Uint8Array(e),o.HEAPU16=ke=new Uint16Array(e),o.HEAPU32=N=new Uint32Array(e),o.HEAPF32=ze=new Float32Array(e),o.HEAPF64=he=new Float64Array(e)}var ve,Jr=[],Ar=[],mr=[];function xr(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)yr(o.preRun.shift());Dr(Jr)}function Ir(){!o.noFSInit&&!i.init.initialized&&i.init(),i.ignorePermissions=!1,Dr(Ar)}function Ge(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)Te(o.postRun.shift());Dr(mr)}function yr(e){Jr.unshift(e)}function Ce(e){Ar.unshift(e)}function Te(e){mr.unshift(e)}var Se=0,ir=null;function ri(e){return e}function er(e){Se++,o.monitorRunDependencies&&o.monitorRunDependencies(Se)}function lr(e){if(Se--,o.monitorRunDependencies&&o.monitorRunDependencies(Se),Se==0&&ir){var r=ir;ir=null,r()}}function je(e){o.onAbort&&o.onAbort(e),e="Aborted("+e+")",W(e),te=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw y(r),r}var Ut="data:application/octet-stream;base64,";function vt(e){return e.startsWith(Ut)}var qe;qe="audiodec.wasm",vt(qe)||(qe=$(qe));function jr(e){if(e==qe&&R)return new Uint8Array(R);if(Q)return Q(e);throw"both async and sync fetching of the wasm failed"}function en(e){return!R&&(F||k)&&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(()=>jr(e)):Promise.resolve().then(()=>jr(e))}function et(e,r,t){return en(e).then(n=>WebAssembly.instantiate(n,r)).then(n=>n).then(t,n=>{W("failed to asynchronously prepare wasm: "+n),je(n)})}function rn(e,r,t,n){return!e&&typeof WebAssembly.instantiateStreaming=="function"&&!vt(r)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(s=>{var u=WebAssembly.instantiateStreaming(s,t);return u.then(n,function(l){return W("wasm streaming compile failed: "+l),W("falling back to ArrayBuffer instantiation"),et(r,t,n)})}):et(r,t,n)}function tn(){var e={a:wi};function r(n,s){var u=n.exports;return B=u,Z=B.E,se(),ve=B.H,Ce(B.F),lr(),u}er();function t(n){r(n.instance)}if(o.instantiateWasm)try{return o.instantiateWasm(e,r)}catch(n){W("Module.instantiateWasm callback failed with error: "+n),y(n)}return rn(R,qe,e,t).catch(y),{}}var M,ee,Dr=e=>{for(;e.length>0;)e.shift()(o)};function Le(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(r){N[this.ptr+4>>2]=r},this.get_type=function(){return N[this.ptr+4>>2]},this.set_destructor=function(r){N[this.ptr+8>>2]=r},this.get_destructor=function(){return N[this.ptr+8>>2]},this.set_caught=function(r){r=r?1:0,J[this.ptr+12>>0]=r},this.get_caught=function(){return J[this.ptr+12>>0]!=0},this.set_rethrown=function(r){r=r?1:0,J[this.ptr+13>>0]=r},this.get_rethrown=function(){return J[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){N[this.ptr+16>>2]=r},this.get_adjusted_ptr=function(){return N[this.ptr+16>>2]},this.get_exception_ptr=function(){var r=Nn(this.get_type());if(r)return N[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var cr=0;function gr(e,r,t){var n=new Le(e);throw n.init(r,t),cr=e,cr}var rt=e=>(z[Wn()>>2]=e,e),K={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 s=e[n];s==="."?e.splice(n,1):s===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=K.isAbs(e),t=e.substr(-1)==="/";return e=K.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=K.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=K.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 K.normalize(e.join("/"))},join2:(e,r)=>K.normalize(e+"/"+r)},de=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return e=>crypto.getRandomValues(e);je("initRandomDevice")},tt=e=>(tt=de())(e),Pe={resolve:function(){for(var e="",r=!1,t=arguments.length-1;t>=-1&&!r;t--){var n=t>=0?arguments[t]:i.cwd();if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,r=K.isAbs(n)}return e=K.normalizeArray(e.split("/").filter(s=>!!s),!r).join("/"),(r?"/":"")+e||"."},relative:(e,r)=>{e=Pe.resolve(e).substr(1),r=Pe.resolve(r).substr(1);function t(m){for(var C=0;C<m.length&&m[C]==="";C++);for(var A=m.length-1;A>=0&&m[A]==="";A--);return C>A?[]:m.slice(C,A-C+1)}for(var n=t(e.split("/")),s=t(r.split("/")),u=Math.min(n.length,s.length),l=u,f=0;f<u;f++)if(n[f]!==s[f]){l=f;break}for(var g=[],f=l;f<n.length;f++)g.push("..");return g=g.concat(s.slice(l)),g.join("/")}},wr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Xe=(e,r,t)=>{for(var n=r+t,s=r;e[s]&&!(s>=n);)++s;if(s-r>16&&e.buffer&&wr)return wr.decode(e.subarray(r,s));for(var u="";r<s;){var l=e[r++];if(!(l&128)){u+=String.fromCharCode(l);continue}var f=e[r++]&63;if((l&224)==192){u+=String.fromCharCode((l&31)<<6|f);continue}var g=e[r++]&63;if((l&240)==224?l=(l&15)<<12|f<<6|g:l=(l&7)<<18|f<<12|g<<6|e[r++]&63,l<65536)u+=String.fromCharCode(l);else{var m=l-65536;u+=String.fromCharCode(55296|m>>10,56320|m&1023)}}return u},Be=[],Lr=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},Br=(e,r,t,n)=>{if(!(n>0))return 0;for(var s=t,u=t+n-1,l=0;l<e.length;++l){var f=e.charCodeAt(l);if(f>=55296&&f<=57343){var g=e.charCodeAt(++l);f=65536+((f&1023)<<10)|g&1023}if(f<=127){if(t>=u)break;r[t++]=f}else if(f<=2047){if(t+1>=u)break;r[t++]=192|f>>6,r[t++]=128|f&63}else if(f<=65535){if(t+2>=u)break;r[t++]=224|f>>12,r[t++]=128|f>>6&63,r[t++]=128|f&63}else{if(t+3>=u)break;r[t++]=240|f>>18,r[t++]=128|f>>12&63,r[t++]=128|f>>6&63,r[t++]=128|f&63}}return r[t]=0,t-s};function Hr(e,r,t){var n=t>0?t:Lr(e)+1,s=new Array(n),u=Br(e,s,0,s.length);return r&&(s.length=u),s}var mt=()=>{if(!Be.length){var e=null;if(typeof window<"u"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=`
  44. `)):typeof readline=="function"&&(e=readline(),e!==null&&(e+=`
  45. `)),!e)return null;Be=Hr(e,!0)}return Be.shift()},Ue={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){Ue.ttys[e]={input:[],output:[],ops:r},i.registerDevice(e,Ue.stream_ops)},stream_ops:{open:function(e){var r=Ue.ttys[e.node.rdev];if(!r)throw new i.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,s){if(!e.tty||!e.tty.ops.get_char)throw new i.ErrnoError(60);for(var u=0,l=0;l<n;l++){var f;try{f=e.tty.ops.get_char(e.tty)}catch{throw new i.ErrnoError(29)}if(f===void 0&&u===0)throw new i.ErrnoError(6);if(f==null)break;u++,r[t+l]=f}return u&&(e.node.timestamp=Date.now()),u},write:function(e,r,t,n,s){if(!e.tty||!e.tty.ops.put_char)throw new i.ErrnoError(60);try{for(var u=0;u<n;u++)e.tty.ops.put_char(e.tty,r[t+u])}catch{throw new i.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),u}},default_tty_ops:{get_char:function(e){return mt()},put_char:function(e,r){r===null||r===10?(V(Xe(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(V(Xe(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?(W(Xe(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},fsync:function(e){e.output&&e.output.length>0&&(W(Xe(e.output,0)),e.output=[])}}},nt=e=>{je()},H={ops_table:null,mount(e){return H.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(i.isBlkdev(t)||i.isFIFO(t))throw new i.ErrnoError(63);H.ops_table||(H.ops_table={dir:{node:{getattr:H.node_ops.getattr,setattr:H.node_ops.setattr,lookup:H.node_ops.lookup,mknod:H.node_ops.mknod,rename:H.node_ops.rename,unlink:H.node_ops.unlink,rmdir:H.node_ops.rmdir,readdir:H.node_ops.readdir,symlink:H.node_ops.symlink},stream:{llseek:H.stream_ops.llseek}},file:{node:{getattr:H.node_ops.getattr,setattr:H.node_ops.setattr},stream:{llseek:H.stream_ops.llseek,read:H.stream_ops.read,write:H.stream_ops.write,allocate:H.stream_ops.allocate,mmap:H.stream_ops.mmap,msync:H.stream_ops.msync}},link:{node:{getattr:H.node_ops.getattr,setattr:H.node_ops.setattr,readlink:H.node_ops.readlink},stream:{}},chrdev:{node:{getattr:H.node_ops.getattr,setattr:H.node_ops.setattr},stream:i.chrdev_stream_ops}});var s=i.createNode(e,r,t,n);return i.isDir(s.mode)?(s.node_ops=H.ops_table.dir.node,s.stream_ops=H.ops_table.dir.stream,s.contents={}):i.isFile(s.mode)?(s.node_ops=H.ops_table.file.node,s.stream_ops=H.ops_table.file.stream,s.usedBytes=0,s.contents=null):i.isLink(s.mode)?(s.node_ops=H.ops_table.link.node,s.stream_ops=H.ops_table.link.stream):i.isChrdev(s.mode)&&(s.node_ops=H.ops_table.chrdev.node,s.stream_ops=H.ops_table.chrdev.stream),s.timestamp=Date.now(),e&&(e.contents[r]=s,e.timestamp=s.timestamp),s},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 s=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(s.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=i.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,i.isDir(e.mode)?r.size=4096:i.isFile(e.mode)?r.size=e.usedBytes:i.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&&H.resizeFileStorage(e,r.size)},lookup(e,r){throw i.genericErrors[44]},mknod(e,r,t,n){return H.createNode(e,r,t,n)},rename(e,r,t){if(i.isDir(e.mode)){var n;try{n=i.lookupNode(r,t)}catch{}if(n)for(var s in n.contents)throw new i.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=i.lookupNode(e,r);for(var n in t.contents)throw new i.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=H.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!i.isLink(e.mode))throw new i.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,s){var u=e.node.contents;if(s>=e.node.usedBytes)return 0;var l=Math.min(e.node.usedBytes-s,n);if(l>8&&u.subarray)r.set(u.subarray(s,s+l),t);else for(var f=0;f<l;f++)r[t+f]=u[s+f];return l},write(e,r,t,n,s,u){if(!n)return 0;var l=e.node;if(l.timestamp=Date.now(),r.subarray&&(!l.contents||l.contents.subarray)){if(u)return l.contents=r.subarray(t,t+n),l.usedBytes=n,n;if(l.usedBytes===0&&s===0)return l.contents=r.slice(t,t+n),l.usedBytes=n,n;if(s+n<=l.usedBytes)return l.contents.set(r.subarray(t,t+n),s),n}if(H.expandFileStorage(l,s+n),l.contents.subarray&&r.subarray)l.contents.set(r.subarray(t,t+n),s);else for(var f=0;f<n;f++)l.contents[s+f]=r[t+f];return l.usedBytes=Math.max(l.usedBytes,s+n),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&i.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new i.ErrnoError(28);return n},allocate(e,r,t){H.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t)},mmap(e,r,t,n,s){if(!i.isFile(e.node.mode))throw new i.ErrnoError(43);var u,l,f=e.node.contents;if(!(s&2)&&f.buffer===J.buffer)l=!1,u=f.byteOffset;else{if((t>0||t+r<f.length)&&(f.subarray?f=f.subarray(t,t+r):f=Array.prototype.slice.call(f,t,t+r)),l=!0,u=nt(),!u)throw new i.ErrnoError(48);J.set(f,u)}return{ptr:u,allocated:l}},msync(e,r,t,n,s){return H.stream_ops.write(e,r,0,n,t,!1),0}}},Mt=(e,r,t,n)=>{var s=n?"":`al ${e}`;G(e,u=>{be(u,`Loading data file "${e}" failed (no arrayBuffer).`),r(new Uint8Array(u)),s&&lr()},u=>{if(t)t();else throw`Loading data file "${e}" failed.`}),s&&er()},xt=o.preloadPlugins||[];function It(e,r,t,n){typeof Browser<"u"&&Browser.init();var s=!1;return xt.forEach(function(u){s||u.canHandle(r)&&(u.handle(e,r,t,n),s=!0)}),s}function nn(e,r,t,n,s,u,l,f,g,m){var C=r?Pe.resolve(K.join2(e,r)):e;function A(T){function P(I){m&&m(),f||i.createDataFile(e,r,I,n,s,g),u&&u(),lr()}It(T,C,P,()=>{l&&l(),lr()})||P(T)}er(),typeof t=="string"?Mt(t,T=>A(T),l):A(t)}function on(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}function or(e,r){var t=0;return e&&(t|=365),r&&(t|=146),t}var i={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=Pe.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 i.ErrnoError(32);for(var n=e.split("/").filter(A=>!!A),s=i.root,u="/",l=0;l<n.length;l++){var f=l===n.length-1;if(f&&r.parent)break;if(s=i.lookupNode(s,n[l]),u=K.join2(u,n[l]),i.isMountpoint(s)&&(!f||f&&r.follow_mount)&&(s=s.mounted.root),!f||r.follow)for(var g=0;i.isLink(s.mode);){var m=i.readlink(u);u=Pe.resolve(K.dirname(u),m);var C=i.lookupPath(u,{recurse_count:r.recurse_count+1});if(s=C.node,g++>40)throw new i.ErrnoError(32)}}return{path:u,node:s}},getPath:e=>{for(var r;;){if(i.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)%i.nameTable.length},hashAddNode:e=>{var r=i.hashName(e.parent.id,e.name);e.name_next=i.nameTable[r],i.nameTable[r]=e},hashRemoveNode:e=>{var r=i.hashName(e.parent.id,e.name);if(i.nameTable[r]===e)i.nameTable[r]=e.name_next;else for(var t=i.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode:(e,r)=>{var t=i.mayLookup(e);if(t)throw new i.ErrnoError(t,e);for(var n=i.hashName(e.id,r),s=i.nameTable[n];s;s=s.name_next){var u=s.name;if(s.parent.id===e.id&&u===r)return s}return i.lookup(e,r)},createNode:(e,r,t,n)=>{var s=new i.FSNode(e,r,t,n);return i.hashAddNode(s),s},destroyNode:e=>{i.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)=>i.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=i.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate:(e,r)=>{try{var t=i.lookupNode(e,r);return 20}catch{}return i.nodePermissions(e,"wx")},mayDelete:(e,r,t)=>{var n;try{n=i.lookupNode(e,r)}catch(u){return u.errno}var s=i.nodePermissions(e,"wx");if(s)return s;if(t){if(!i.isDir(n.mode))return 54;if(i.isRoot(n)||i.getPath(n)===i.cwd())return 10}else if(i.isDir(n.mode))return 31;return 0},mayOpen:(e,r)=>e?i.isLink(e.mode)?32:i.isDir(e.mode)&&(i.flagsToPermissionString(r)!=="r"||r&512)?31:i.nodePermissions(e,i.flagsToPermissionString(r)):44,MAX_OPEN_FDS:4096,nextfd:()=>{for(var e=0;e<=i.MAX_OPEN_FDS;e++)if(!i.streams[e])return e;throw new i.ErrnoError(33)},getStreamChecked:e=>{var r=i.getStream(e);if(!r)throw new i.ErrnoError(8);return r},getStream:e=>i.streams[e],createStream:(e,r=-1)=>(i.FSStream||(i.FSStream=function(){this.shared={}},i.FSStream.prototype={},Object.defineProperties(i.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 i.FSStream,e),r==-1&&(r=i.nextfd()),e.fd=r,i.streams[r]=e,e),closeStream:e=>{i.streams[e]=null},chrdev_stream_ops:{open:e=>{var r=i.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new i.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice:(e,r)=>{i.devices[e]={stream_ops:r}},getDevice:e=>i.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),i.syncFSRequests++,i.syncFSRequests>1&&W(`warning: ${i.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=i.getMounts(i.root.mount),n=0;function s(l){return i.syncFSRequests--,r(l)}function u(l){if(l)return u.errored?void 0:(u.errored=!0,s(l));++n>=t.length&&s(null)}t.forEach(l=>{if(!l.type.syncfs)return u(null);l.type.syncfs(l,e,u)})},mount:(e,r,t)=>{var n=t==="/",s=!t,u;if(n&&i.root)throw new i.ErrnoError(10);if(!n&&!s){var l=i.lookupPath(t,{follow_mount:!1});if(t=l.path,u=l.node,i.isMountpoint(u))throw new i.ErrnoError(10);if(!i.isDir(u.mode))throw new i.ErrnoError(54)}var f={type:e,opts:r,mountpoint:t,mounts:[]},g=e.mount(f);return g.mount=f,f.root=g,n?i.root=g:u&&(u.mounted=f,u.mount&&u.mount.mounts.push(f)),g},unmount:e=>{var r=i.lookupPath(e,{follow_mount:!1});if(!i.isMountpoint(r.node))throw new i.ErrnoError(28);var t=r.node,n=t.mounted,s=i.getMounts(n);Object.keys(i.nameTable).forEach(l=>{for(var f=i.nameTable[l];f;){var g=f.name_next;s.includes(f.mount)&&i.destroyNode(f),f=g}}),t.mounted=null;var u=t.mount.mounts.indexOf(n);t.mount.mounts.splice(u,1)},lookup:(e,r)=>e.node_ops.lookup(e,r),mknod:(e,r,t)=>{var n=i.lookupPath(e,{parent:!0}),s=n.node,u=K.basename(e);if(!u||u==="."||u==="..")throw new i.ErrnoError(28);var l=i.mayCreate(s,u);if(l)throw new i.ErrnoError(l);if(!s.node_ops.mknod)throw new i.ErrnoError(63);return s.node_ops.mknod(s,u,r,t)},create:(e,r)=>(r=r!==void 0?r:438,r&=4095,r|=32768,i.mknod(e,r,0)),mkdir:(e,r)=>(r=r!==void 0?r:511,r&=1023,r|=16384,i.mknod(e,r,0)),mkdirTree:(e,r)=>{for(var t=e.split("/"),n="",s=0;s<t.length;++s)if(t[s]){n+="/"+t[s];try{i.mkdir(n,r)}catch(u){if(u.errno!=20)throw u}}},mkdev:(e,r,t)=>(typeof t>"u"&&(t=r,r=438),r|=8192,i.mknod(e,r,t)),symlink:(e,r)=>{if(!Pe.resolve(e))throw new i.ErrnoError(44);var t=i.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new i.ErrnoError(44);var s=K.basename(r),u=i.mayCreate(n,s);if(u)throw new i.ErrnoError(u);if(!n.node_ops.symlink)throw new i.ErrnoError(63);return n.node_ops.symlink(n,s,e)},rename:(e,r)=>{var t=K.dirname(e),n=K.dirname(r),s=K.basename(e),u=K.basename(r),l,f,g;if(l=i.lookupPath(e,{parent:!0}),f=l.node,l=i.lookupPath(r,{parent:!0}),g=l.node,!f||!g)throw new i.ErrnoError(44);if(f.mount!==g.mount)throw new i.ErrnoError(75);var m=i.lookupNode(f,s),C=Pe.relative(e,n);if(C.charAt(0)!==".")throw new i.ErrnoError(28);if(C=Pe.relative(r,t),C.charAt(0)!==".")throw new i.ErrnoError(55);var A;try{A=i.lookupNode(g,u)}catch{}if(m!==A){var T=i.isDir(m.mode),P=i.mayDelete(f,s,T);if(P)throw new i.ErrnoError(P);if(P=A?i.mayDelete(g,u,T):i.mayCreate(g,u),P)throw new i.ErrnoError(P);if(!f.node_ops.rename)throw new i.ErrnoError(63);if(i.isMountpoint(m)||A&&i.isMountpoint(A))throw new i.ErrnoError(10);if(g!==f&&(P=i.nodePermissions(f,"w"),P))throw new i.ErrnoError(P);i.hashRemoveNode(m);try{f.node_ops.rename(m,g,u)}catch(I){throw I}finally{i.hashAddNode(m)}}},rmdir:e=>{var r=i.lookupPath(e,{parent:!0}),t=r.node,n=K.basename(e),s=i.lookupNode(t,n),u=i.mayDelete(t,n,!0);if(u)throw new i.ErrnoError(u);if(!t.node_ops.rmdir)throw new i.ErrnoError(63);if(i.isMountpoint(s))throw new i.ErrnoError(10);t.node_ops.rmdir(t,n),i.destroyNode(s)},readdir:e=>{var r=i.lookupPath(e,{follow:!0}),t=r.node;if(!t.node_ops.readdir)throw new i.ErrnoError(54);return t.node_ops.readdir(t)},unlink:e=>{var r=i.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new i.ErrnoError(44);var n=K.basename(e),s=i.lookupNode(t,n),u=i.mayDelete(t,n,!1);if(u)throw new i.ErrnoError(u);if(!t.node_ops.unlink)throw new i.ErrnoError(63);if(i.isMountpoint(s))throw new i.ErrnoError(10);t.node_ops.unlink(t,n),i.destroyNode(s)},readlink:e=>{var r=i.lookupPath(e),t=r.node;if(!t)throw new i.ErrnoError(44);if(!t.node_ops.readlink)throw new i.ErrnoError(28);return Pe.resolve(i.getPath(t.parent),t.node_ops.readlink(t))},stat:(e,r)=>{var t=i.lookupPath(e,{follow:!r}),n=t.node;if(!n)throw new i.ErrnoError(44);if(!n.node_ops.getattr)throw new i.ErrnoError(63);return n.node_ops.getattr(n)},lstat:e=>i.stat(e,!0),chmod:(e,r,t)=>{var n;if(typeof e=="string"){var s=i.lookupPath(e,{follow:!t});n=s.node}else n=e;if(!n.node_ops.setattr)throw new i.ErrnoError(63);n.node_ops.setattr(n,{mode:r&4095|n.mode&-4096,timestamp:Date.now()})},lchmod:(e,r)=>{i.chmod(e,r,!0)},fchmod:(e,r)=>{var t=i.getStreamChecked(e);i.chmod(t.node,r)},chown:(e,r,t,n)=>{var s;if(typeof e=="string"){var u=i.lookupPath(e,{follow:!n});s=u.node}else s=e;if(!s.node_ops.setattr)throw new i.ErrnoError(63);s.node_ops.setattr(s,{timestamp:Date.now()})},lchown:(e,r,t)=>{i.chown(e,r,t,!0)},fchown:(e,r,t)=>{var n=i.getStreamChecked(e);i.chown(n.node,r,t)},truncate:(e,r)=>{if(r<0)throw new i.ErrnoError(28);var t;if(typeof e=="string"){var n=i.lookupPath(e,{follow:!0});t=n.node}else t=e;if(!t.node_ops.setattr)throw new i.ErrnoError(63);if(i.isDir(t.mode))throw new i.ErrnoError(31);if(!i.isFile(t.mode))throw new i.ErrnoError(28);var s=i.nodePermissions(t,"w");if(s)throw new i.ErrnoError(s);t.node_ops.setattr(t,{size:r,timestamp:Date.now()})},ftruncate:(e,r)=>{var t=i.getStreamChecked(e);if(!(t.flags&2097155))throw new i.ErrnoError(28);i.truncate(t.node,r)},utime:(e,r,t)=>{var n=i.lookupPath(e,{follow:!0}),s=n.node;s.node_ops.setattr(s,{timestamp:Math.max(r,t)})},open:(e,r,t)=>{if(e==="")throw new i.ErrnoError(44);r=typeof r=="string"?on(r):r,t=typeof t>"u"?438:t,r&64?t=t&4095|32768:t=0;var n;if(typeof e=="object")n=e;else{e=K.normalize(e);try{var s=i.lookupPath(e,{follow:!(r&131072)});n=s.node}catch{}}var u=!1;if(r&64)if(n){if(r&128)throw new i.ErrnoError(20)}else n=i.mknod(e,t,0),u=!0;if(!n)throw new i.ErrnoError(44);if(i.isChrdev(n.mode)&&(r&=-513),r&65536&&!i.isDir(n.mode))throw new i.ErrnoError(54);if(!u){var l=i.mayOpen(n,r);if(l)throw new i.ErrnoError(l)}r&512&&!u&&i.truncate(n,0),r&=-131713;var f=i.createStream({node:n,path:i.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return f.stream_ops.open&&f.stream_ops.open(f),o.logReadFiles&&!(r&1)&&(i.readFiles||(i.readFiles={}),e in i.readFiles||(i.readFiles[e]=1)),f},close:e=>{if(i.isClosed(e))throw new i.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{i.closeStream(e.fd)}e.fd=null},isClosed:e=>e.fd===null,llseek:(e,r,t)=>{if(i.isClosed(e))throw new i.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new i.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new i.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read:(e,r,t,n,s)=>{if(n<0||s<0)throw new i.ErrnoError(28);if(i.isClosed(e))throw new i.ErrnoError(8);if((e.flags&2097155)===1)throw new i.ErrnoError(8);if(i.isDir(e.node.mode))throw new i.ErrnoError(31);if(!e.stream_ops.read)throw new i.ErrnoError(28);var u=typeof s<"u";if(!u)s=e.position;else if(!e.seekable)throw new i.ErrnoError(70);var l=e.stream_ops.read(e,r,t,n,s);return u||(e.position+=l),l},write:(e,r,t,n,s,u)=>{if(n<0||s<0)throw new i.ErrnoError(28);if(i.isClosed(e))throw new i.ErrnoError(8);if(!(e.flags&2097155))throw new i.ErrnoError(8);if(i.isDir(e.node.mode))throw new i.ErrnoError(31);if(!e.stream_ops.write)throw new i.ErrnoError(28);e.seekable&&e.flags&1024&&i.llseek(e,0,2);var l=typeof s<"u";if(!l)s=e.position;else if(!e.seekable)throw new i.ErrnoError(70);var f=e.stream_ops.write(e,r,t,n,s,u);return l||(e.position+=f),f},allocate:(e,r,t)=>{if(i.isClosed(e))throw new i.ErrnoError(8);if(r<0||t<=0)throw new i.ErrnoError(28);if(!(e.flags&2097155))throw new i.ErrnoError(8);if(!i.isFile(e.node.mode)&&!i.isDir(e.node.mode))throw new i.ErrnoError(43);if(!e.stream_ops.allocate)throw new i.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap:(e,r,t,n,s)=>{if(n&2&&!(s&2)&&(e.flags&2097155)!==2)throw new i.ErrnoError(2);if((e.flags&2097155)===1)throw new i.ErrnoError(2);if(!e.stream_ops.mmap)throw new i.ErrnoError(43);return e.stream_ops.mmap(e,r,t,n,s)},msync:(e,r,t,n,s)=>e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,s):0,munmap:e=>0,ioctl:(e,r,t)=>{if(!e.stream_ops.ioctl)throw new i.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=i.open(e,r.flags),s=i.stat(e),u=s.size,l=new Uint8Array(u);return i.read(n,l,0,u,0),r.encoding==="utf8"?t=Xe(l,0):r.encoding==="binary"&&(t=l),i.close(n),t},writeFile:(e,r,t={})=>{t.flags=t.flags||577;var n=i.open(e,t.flags,t.mode);if(typeof r=="string"){var s=new Uint8Array(Lr(r)+1),u=Br(r,s,0,s.length);i.write(n,s,0,u,void 0,t.canOwn)}else if(ArrayBuffer.isView(r))i.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");i.close(n)},cwd:()=>i.currentPath,chdir:e=>{var r=i.lookupPath(e,{follow:!0});if(r.node===null)throw new i.ErrnoError(44);if(!i.isDir(r.node.mode))throw new i.ErrnoError(54);var t=i.nodePermissions(r.node,"x");if(t)throw new i.ErrnoError(t);i.currentPath=r.path},createDefaultDirectories:()=>{i.mkdir("/tmp"),i.mkdir("/home"),i.mkdir("/home/web_user")},createDefaultDevices:()=>{i.mkdir("/dev"),i.registerDevice(i.makedev(1,3),{read:()=>0,write:(n,s,u,l,f)=>l}),i.mkdev("/dev/null",i.makedev(1,3)),Ue.register(i.makedev(5,0),Ue.default_tty_ops),Ue.register(i.makedev(6,0),Ue.default_tty1_ops),i.mkdev("/dev/tty",i.makedev(5,0)),i.mkdev("/dev/tty1",i.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(r=tt(e).byteLength),e[--r]);i.createDevice("/dev","random",t),i.createDevice("/dev","urandom",t),i.mkdir("/dev/shm"),i.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{i.mkdir("/proc");var e=i.mkdir("/proc/self");i.mkdir("/proc/self/fd"),i.mount({mount:()=>{var r=i.createNode(e,"fd",16895,73);return r.node_ops={lookup:(t,n)=>{var s=+n,u=i.getStreamChecked(s),l={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>u.path}};return l.parent=l,l}},r}},{},"/proc/self/fd")},createStandardStreams:()=>{o.stdin?i.createDevice("/dev","stdin",o.stdin):i.symlink("/dev/tty","/dev/stdin"),o.stdout?i.createDevice("/dev","stdout",null,o.stdout):i.symlink("/dev/tty","/dev/stdout"),o.stderr?i.createDevice("/dev","stderr",null,o.stderr):i.symlink("/dev/tty1","/dev/stderr"),i.open("/dev/stdin",0),i.open("/dev/stdout",1),i.open("/dev/stderr",1)},ensureErrnoError:()=>{i.ErrnoError||(i.ErrnoError=function(r,t){this.name="ErrnoError",this.node=t,this.setErrno=function(n){this.errno=n},this.setErrno(r),this.message="FS error"},i.ErrnoError.prototype=new Error,i.ErrnoError.prototype.constructor=i.ErrnoError,[44].forEach(e=>{i.genericErrors[e]=new i.ErrnoError(e),i.genericErrors[e].stack="<generic error, no stack>"}))},staticInit:()=>{i.ensureErrnoError(),i.nameTable=new Array(4096),i.mount(H,{},"/"),i.createDefaultDirectories(),i.createDefaultDevices(),i.createSpecialDirectories(),i.filesystems={MEMFS:H}},init:(e,r,t)=>{i.init.initialized=!0,i.ensureErrnoError(),o.stdin=e||o.stdin,o.stdout=r||o.stdout,o.stderr=t||o.stderr,i.createStandardStreams()},quit:()=>{i.init.initialized=!1;for(var e=0;e<i.streams.length;e++){var r=i.streams[e];r&&i.close(r)}},findObject:(e,r)=>{var t=i.analyzePath(e,r);return t.exists?t.object:null},analyzePath:(e,r)=>{try{var t=i.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=i.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=K.basename(e),t=i.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(s){n.error=s.errno}return n},createPath:(e,r,t,n)=>{e=typeof e=="string"?e:i.getPath(e);for(var s=r.split("/").reverse();s.length;){var u=s.pop();if(u){var l=K.join2(e,u);try{i.mkdir(l)}catch{}e=l}}return l},createFile:(e,r,t,n,s)=>{var u=K.join2(typeof e=="string"?e:i.getPath(e),r),l=or(n,s);return i.create(u,l)},createDataFile:(e,r,t,n,s,u)=>{var l=r;e&&(e=typeof e=="string"?e:i.getPath(e),l=r?K.join2(e,r):e);var f=or(n,s),g=i.create(l,f);if(t){if(typeof t=="string"){for(var m=new Array(t.length),C=0,A=t.length;C<A;++C)m[C]=t.charCodeAt(C);t=m}i.chmod(g,f|146);var T=i.open(g,577);i.write(T,t,0,t.length,0,u),i.close(T),i.chmod(g,f)}return g},createDevice:(e,r,t,n)=>{var s=K.join2(typeof e=="string"?e:i.getPath(e),r),u=or(!!t,!!n);i.createDevice.major||(i.createDevice.major=64);var l=i.makedev(i.createDevice.major++,0);return i.registerDevice(l,{open:f=>{f.seekable=!1},close:f=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(f,g,m,C,A)=>{for(var T=0,P=0;P<C;P++){var I;try{I=t()}catch{throw new i.ErrnoError(29)}if(I===void 0&&T===0)throw new i.ErrnoError(6);if(I==null)break;T++,g[m+P]=I}return T&&(f.node.timestamp=Date.now()),T},write:(f,g,m,C,A)=>{for(var T=0;T<C;T++)try{n(g[m+T])}catch{throw new i.ErrnoError(29)}return C&&(f.node.timestamp=Date.now()),T}}),i.mkdev(s,u,l)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(typeof XMLHttpRequest<"u")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(S)try{e.contents=Hr(S(e.url),!0),e.usedBytes=e.contents.length}catch{throw new i.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile:(e,r,t,n,s)=>{function u(){this.lengthKnown=!1,this.chunks=[]}if(u.prototype.get=function(P){if(!(P>this.length-1||P<0)){var I=P%this.chunkSize,re=P/this.chunkSize|0;return this.getter(re)[I]}},u.prototype.setDataGetter=function(P){this.getter=P},u.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 I=Number(P.getResponseHeader("Content-length")),re,ne=(re=P.getResponseHeader("Accept-Ranges"))&&re==="bytes",ue=(re=P.getResponseHeader("Content-Encoding"))&&re==="gzip",ge=1024*1024;ne||(ge=I);var ie=(_e,xe)=>{if(_e>xe)throw new Error("invalid range ("+_e+", "+xe+") or no bytes requested!");if(xe>I-1)throw new Error("only "+I+" bytes available! programmer error!");var fe=new XMLHttpRequest;if(fe.open("GET",t,!1),I!==ge&&fe.setRequestHeader("Range","bytes="+_e+"-"+xe),fe.responseType="arraybuffer",fe.overrideMimeType&&fe.overrideMimeType("text/plain; charset=x-user-defined"),fe.send(null),!(fe.status>=200&&fe.status<300||fe.status===304))throw new Error("Couldn't load "+t+". Status: "+fe.status);return fe.response!==void 0?new Uint8Array(fe.response||[]):Hr(fe.responseText||"",!0)},Ze=this;Ze.setDataGetter(_e=>{var xe=_e*ge,fe=(_e+1)*ge-1;if(fe=Math.min(fe,I-1),typeof Ze.chunks[_e]>"u"&&(Ze.chunks[_e]=ie(xe,fe)),typeof Ze.chunks[_e]>"u")throw new Error("doXHR failed!");return Ze.chunks[_e]}),(ue||!I)&&(ge=I=1,I=this.getter(0).length,ge=I,V("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=I,this._chunkSize=ge,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){if(!k)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var l=new u;Object.defineProperties(l,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var f={isDevice:!1,contents:l}}else var f={isDevice:!1,url:t};var g=i.createFile(e,r,f,n,s);f.contents?g.contents=f.contents:f.url&&(g.contents=null,g.url=f.url),Object.defineProperties(g,{usedBytes:{get:function(){return this.contents.length}}});var m={},C=Object.keys(g.stream_ops);C.forEach(T=>{var P=g.stream_ops[T];m[T]=function(){return i.forceLoadFile(g),P.apply(null,arguments)}});function A(T,P,I,re,ne){var ue=T.node.contents;if(ne>=ue.length)return 0;var ge=Math.min(ue.length-ne,re);if(ue.slice)for(var ie=0;ie<ge;ie++)P[I+ie]=ue[ne+ie];else for(var ie=0;ie<ge;ie++)P[I+ie]=ue.get(ne+ie);return ge}return m.read=(T,P,I,re,ne)=>(i.forceLoadFile(g),A(T,P,I,re,ne)),m.mmap=(T,P,I,re,ne)=>{i.forceLoadFile(g);var ue=nt();if(!ue)throw new i.ErrnoError(48);return A(T,J,ue,P,I),{ptr:ue,allocated:!0}},g.stream_ops=m,g}},_r=(e,r)=>e?Xe(Y,e,r):"",le={DEFAULT_POLLMASK:5,calculateAt:function(e,r,t){if(K.isAbs(r))return r;var n;if(e===-100)n=i.cwd();else{var s=le.getStreamFromFD(e);n=s.path}if(r.length==0){if(!t)throw new i.ErrnoError(44);return n}return K.join2(n,r)},doStat:function(e,r,t){try{var n=e(r)}catch(f){if(f&&f.node&&K.normalize(r)!==K.normalize(i.getPath(f.node)))return-54;throw f}z[t>>2]=n.dev,z[t+4>>2]=n.mode,N[t+8>>2]=n.nlink,z[t+12>>2]=n.uid,z[t+16>>2]=n.gid,z[t+20>>2]=n.rdev,ee=[n.size>>>0,(M=n.size,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+24>>2]=ee[0],z[t+28>>2]=ee[1],z[t+32>>2]=4096,z[t+36>>2]=n.blocks;var s=n.atime.getTime(),u=n.mtime.getTime(),l=n.ctime.getTime();return ee=[Math.floor(s/1e3)>>>0,(M=Math.floor(s/1e3),+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+40>>2]=ee[0],z[t+44>>2]=ee[1],N[t+48>>2]=s%1e3*1e3,ee=[Math.floor(u/1e3)>>>0,(M=Math.floor(u/1e3),+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+56>>2]=ee[0],z[t+60>>2]=ee[1],N[t+64>>2]=u%1e3*1e3,ee=[Math.floor(l/1e3)>>>0,(M=Math.floor(l/1e3),+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+72>>2]=ee[0],z[t+76>>2]=ee[1],N[t+80>>2]=l%1e3*1e3,ee=[n.ino>>>0,(M=n.ino,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[t+88>>2]=ee[0],z[t+92>>2]=ee[1],0},doMsync:function(e,r,t,n,s){if(!i.isFile(r.node.mode))throw new i.ErrnoError(43);if(n&2)return 0;var u=Y.slice(e,e+t);i.msync(r,u,s,t,n)},varargs:void 0,get(){le.varargs+=4;var e=z[le.varargs-4>>2];return e},getStr(e){var r=_r(e);return r},getStreamFromFD:function(e){var r=i.getStreamChecked(e);return r}};function sn(e,r,t){le.varargs=t;try{var n=le.getStreamFromFD(e);switch(r){case 0:{var s=le.get();if(s<0)return-28;var u;return u=i.createStream(n,s),u.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var s=le.get();return n.flags|=s,0}case 5:{var s=le.get(),l=0;return we[s+l>>1]=2,0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:return rt(28),-1;default:return-28}}catch(f){if(typeof i>"u"||f.name!=="ErrnoError")throw f;return-f.errno}}function Wr(e,r,t,n){le.varargs=n;try{r=le.getStr(r),r=le.calculateAt(e,r);var s=n?le.get():0;return i.open(r,t,s).fd}catch(u){if(typeof i>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}function an(e,r,t,n,s){}function zr(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${e}`)}}function it(){for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);yt=e}var yt=void 0;function me(e){for(var r="",t=e;Y[t];)r+=yt[Y[t++]];return r}var Ke={},He={},br={},Qe=void 0;function q(e){throw new Qe(e)}var rr=void 0;function Er(e){throw new rr(e)}function sr(e,r,t){e.forEach(function(f){br[f]=r});function n(f){var g=t(f);g.length!==e.length&&Er("Mismatched type converter count");for(var m=0;m<e.length;++m)$e(e[m],g[m])}var s=new Array(r.length),u=[],l=0;r.forEach((f,g)=>{He.hasOwnProperty(f)?s[g]=He[f]:(u.push(f),Ke.hasOwnProperty(f)||(Ke[f]=[]),Ke[f].push(()=>{s[g]=He[f],++l,l===u.length&&n(s)}))}),u.length===0&&n(s)}function ot(e,r,t={}){var n=r.name;if(e||q(`type "${n}" must have a positive integer typeid pointer`),He.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;q(`Cannot register type '${n}' twice`)}if(He[e]=r,delete br[e],Ke.hasOwnProperty(e)){var s=Ke[e];delete Ke[e],s.forEach(u=>u())}}function $e(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return ot(e,r,t)}function jt(e,r,t,n,s){var u=zr(t);r=me(r),$e(e,{name:r,fromWireType:function(l){return!!l},toWireType:function(l,f){return f?n:s},argPackAdvance:8,readValueFromPointer:function(l){var f;if(t===1)f=J;else if(t===2)f=we;else if(t===4)f=z;else throw new TypeError("Unknown boolean type size: "+r);return this.fromWireType(f[l>>u])},destructorFunction:null})}function un(e){if(!(this instanceof Re)||!(e instanceof Re))return!1;for(var r=this.$$.ptrType.registeredClass,t=this.$$.ptr,n=e.$$.ptrType.registeredClass,s=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)s=n.upcast(s),n=n.baseClass;return r===n&&t===s}function fn(e){return{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}}function Pr(e){function r(t){return t.$$.ptrType.registeredClass.name}q(r(e)+" instance already deleted")}var Nr=!1;function gt(e){}function ln(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}function Fr(e){e.count.value-=1;var r=e.count.value===0;r&&ln(e)}function wt(e,r,t){if(r===t)return e;if(t.baseClass===void 0)return null;var n=wt(e,r,t.baseClass);return n===null?null:t.downcast(n)}var _t={};function cn(){return Object.keys(ur).length}function dn(){var e=[];for(var r in ur)ur.hasOwnProperty(r)&&e.push(ur[r]);return e}var Ae=[];function Vr(){for(;Ae.length;){var e=Ae.pop();e.$$.deleteScheduled=!1,e.delete()}}var ar=void 0;function st(e){ar=e,Ae.length&&ar&&ar(Vr)}function Lt(){o.getInheritedInstanceCount=cn,o.getLiveInheritedInstances=dn,o.flushPendingDeletes=Vr,o.setDelayFunction=st}var ur={};function hn(e,r){for(r===void 0&&q("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r}function Rr(e,r){return r=hn(e,r),ur[r]}function Cr(e,r){(!r.ptrType||!r.ptr)&&Er("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&Er("Both smartPtrType and smartPtr must be specified"),r.count={value:1},tr(Object.create(e,{$$:{value:r}}))}function Bt(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=Rr(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 s(){return this.isSmartPointer?Cr(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):Cr(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var u=this.registeredClass.getActualType(r),l=_t[u];if(!l)return s.call(this);var f;this.isConst?f=l.constPointerType:f=l.pointerType;var g=wt(r,this.registeredClass,f.registeredClass);return g===null?s.call(this):this.isSmartPointer?Cr(f.registeredClass.instancePrototype,{ptrType:f,ptr:g,smartPtrType:this,smartPtr:e}):Cr(f.registeredClass.instancePrototype,{ptrType:f,ptr:g})}var tr=function(e){return typeof FinalizationRegistry>"u"?(tr=r=>r,e):(Nr=new FinalizationRegistry(r=>{Fr(r.$$)}),tr=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var s={$$:t};Nr.register(r,s,r)}return r},gt=r=>Nr.unregister(r),tr(e))};function bt(){if(this.$$.ptr||Pr(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=tr(Object.create(Object.getPrototypeOf(this),{$$:{value:fn(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e}function pn(){this.$$.ptr||Pr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&q("Object already scheduled for deletion"),gt(this),Fr(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function Ht(){return!this.$$.ptr}function vn(){return this.$$.ptr||Pr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&q("Object already scheduled for deletion"),Ae.push(this),Ae.length===1&&ar&&ar(Vr),this.$$.deleteScheduled=!0,this}function Wt(){Re.prototype.isAliasOf=un,Re.prototype.clone=bt,Re.prototype.delete=pn,Re.prototype.isDeleted=Ht,Re.prototype.deleteLater=vn}function Re(){}var mn=48,yn=57;function Tr(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=mn&&r<=yn?`_${e}`:e}function Or(e,r){return e=Tr(e),{[e]:function(){return r.apply(this,arguments)}}[e]}function We(e,r,t){if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(){return e[r].overloadTable.hasOwnProperty(arguments.length)||q(`Function '${t}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[arguments.length].apply(this,arguments)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n}}function zt(e,r,t){o.hasOwnProperty(e)?((t===void 0||o[e].overloadTable!==void 0&&o[e].overloadTable[t]!==void 0)&&q(`Cannot register public name '${e}' twice`),We(o,e,e),o.hasOwnProperty(t)&&q(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),o[e].overloadTable[t]=r):(o[e]=r,t!==void 0&&(o[e].numArguments=t))}function gn(e,r,t,n,s,u,l,f){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=s,this.getActualType=u,this.upcast=l,this.downcast=f,this.pureVirtualFunctions=[]}function Gr(e,r,t){for(;r!==t;)r.upcast||q(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e}function at(e,r){if(r===null)return this.isReference&&q(`null is not a valid ${this.name}`),0;r.$$||q(`Cannot pass "${Xr(r)}" as a ${this.name}`),r.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Gr(r.$$.ptr,t,this.registeredClass);return n}function wn(e,r){var t;if(r===null)return this.isReference&&q(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;r.$$||q(`Cannot pass "${Xr(r)}" as a ${this.name}`),r.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&q(`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=Gr(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&q("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:q(`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 s=r.clone();t=this.rawShare(t,Sr.toHandle(function(){s.delete()})),e!==null&&e.push(this.rawDestructor,t)}break;default:q("Unsupporting sharing policy")}return t}function Et(e,r){if(r===null)return this.isReference&&q(`null is not a valid ${this.name}`),0;r.$$||q(`Cannot pass "${Xr(r)}" as a ${this.name}`),r.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&q(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Gr(r.$$.ptr,t,this.registeredClass);return n}function $r(e){return this.fromWireType(z[e>>2])}function _n(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function bn(e){this.rawDestructor&&this.rawDestructor(e)}function En(e){e!==null&&e.delete()}function Pn(){De.prototype.getPointee=_n,De.prototype.destructor=bn,De.prototype.argPackAdvance=8,De.prototype.readValueFromPointer=$r,De.prototype.deleteObject=En,De.prototype.fromWireType=Bt}function De(e,r,t,n,s,u,l,f,g,m,C){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=s,this.pointeeType=u,this.sharingPolicy=l,this.rawGetPointee=f,this.rawConstructor=g,this.rawShare=m,this.rawDestructor=C,!s&&r.baseClass===void 0?n?(this.toWireType=at,this.destructorFunction=null):(this.toWireType=Et,this.destructorFunction=null):this.toWireType=wn}function Cn(e,r,t){o.hasOwnProperty(e)||Er("Replacing nonexistant public symbol"),o[e].overloadTable!==void 0&&t!==void 0?o[e].overloadTable[t]=r:(o[e]=r,o[e].argCount=t)}var Tn=(e,r,t)=>{var n=o["dynCall_"+e];return t&&t.length?n.apply(null,[r].concat(t)):n.call(null,r)},dr=[],ut=e=>{var r=dr[e];return r||(e>=dr.length&&(dr.length=e+1),dr[e]=r=ve.get(e)),r},$n=(e,r,t)=>{if(e.includes("j"))return Tn(e,r,t);var n=ut(r).apply(null,t);return n},Sn=(e,r)=>{var t=[];return function(){return t.length=0,Object.assign(t,arguments),$n(e,r,t)}};function Ne(e,r){e=me(e);function t(){return e.includes("j")?Sn(e,r):ut(r)}var n=t();return typeof n!="function"&&q(`unknown function pointer with signature ${e}: ${r}`),n}function kn(e,r){var t=Or(r,function(n){this.name=r,this.message=n;var s=new Error(n).stack;s!==void 0&&(this.stack=this.toString()+`
  46. `+s.replace(/^Error(:[^\n]*)?\n/,""))});return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},t}var Pt=void 0;function Ct(e){var r=zn(e),t=me(r);return Me(r),t}function qr(e,r){var t=[],n={};function s(u){if(!n[u]&&!He[u]){if(br[u]){br[u].forEach(s);return}t.push(u),n[u]=!0}}throw r.forEach(s),new Pt(`${e}: `+t.map(Ct).join([", "]))}function An(e,r,t,n,s,u,l,f,g,m,C,A,T){C=me(C),u=Ne(s,u),f&&(f=Ne(l,f)),m&&(m=Ne(g,m)),T=Ne(A,T);var P=Tr(C);zt(P,function(){qr(`Cannot construct ${C} due to unbound types`,[n])}),sr([e,r,t],n?[n]:[],function(I){I=I[0];var re,ne;n?(re=I.registeredClass,ne=re.instancePrototype):ne=Re.prototype;var ue=Or(P,function(){if(Object.getPrototypeOf(this)!==ge)throw new Qe("Use 'new' to construct "+C);if(ie.constructor_body===void 0)throw new Qe(C+" has no accessible constructor");var fe=ie.constructor_body[arguments.length];if(fe===void 0)throw new Qe(`Tried to invoke ctor of ${C} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(ie.constructor_body).toString()}) parameters instead!`);return fe.apply(this,arguments)}),ge=Object.create(ne,{constructor:{value:ue}});ue.prototype=ge;var ie=new gn(C,ue,ge,T,re,u,f,m);ie.baseClass&&(ie.baseClass.__derivedClasses===void 0&&(ie.baseClass.__derivedClasses=[]),ie.baseClass.__derivedClasses.push(ie));var Ze=new De(C,ie,!0,!1,!1),_e=new De(C+"*",ie,!1,!1,!1),xe=new De(C+" const*",ie,!1,!0,!1);return _t[e]={pointerType:_e,constPointerType:xe},Cn(P,ue),[Ze,_e,xe]})}function Tt(e,r){for(var t=[],n=0;n<e;n++)t.push(N[r+n*4>>2]);return t}function Dn(e){for(;e.length;){var r=e.pop(),t=e.pop();t(r)}}function $t(e,r){if(!(e instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof e} which is not a function`);var t=Or(e.name||"unknownFunctionName",function(){});t.prototype=e.prototype;var n=new t,s=e.apply(n,r);return s instanceof Object?s:n}function St(e,r,t,n,s,u){var l=r.length;l<2&&q("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var f=r[1]!==null&&t!==null,g=!1,m=1;m<r.length;++m)if(r[m]!==null&&r[m].destructorFunction===void 0){g=!0;break}for(var C=r[0].name!=="void",A="",T="",m=0;m<l-2;++m)A+=(m!==0?", ":"")+"arg"+m,T+=(m!==0?", ":"")+"arg"+m+"Wired";var P=`
  47. return function ${Tr(e)}(${A}) {
  48. if (arguments.length !== ${l-2}) {
  49. throwBindingError('function ${e} called with ${arguments.length} arguments, expected ${l-2} args!');
  50. }`;g&&(P+=`var destructors = [];
  51. `);var I=g?"destructors":"null",re=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],ne=[q,n,s,Dn,r[0],r[1]];f&&(P+="var thisWired = classParam.toWireType("+I+`, this);
  52. `);for(var m=0;m<l-2;++m)P+="var arg"+m+"Wired = argType"+m+".toWireType("+I+", arg"+m+"); // "+r[m+2].name+`
  53. `,re.push("argType"+m),ne.push(r[m+2]);if(f&&(T="thisWired"+(T.length>0?", ":"")+T),P+=(C||u?"var rv = ":"")+"invoker(fn"+(T.length>0?", ":"")+T+`);
  54. `,g)P+=`runDestructors(destructors);
  55. `;else for(var m=f?1:2;m<r.length;++m){var ue=m===1?"thisWired":"arg"+(m-2)+"Wired";r[m].destructorFunction!==null&&(P+=ue+"_dtor("+ue+"); // "+r[m].name+`
  56. `,re.push(ue+"_dtor"),ne.push(r[m].destructorFunction))}return C&&(P+=`var ret = retType.fromWireType(rv);
  57. return ret;
  58. `),P+=`}
  59. `,re.push(P),$t(Function,re).apply(null,ne)}function Fn(e,r,t,n,s,u){var l=Tt(r,t);s=Ne(n,s),sr([],[e],function(f){f=f[0];var g=`constructor ${f.name}`;if(f.registeredClass.constructor_body===void 0&&(f.registeredClass.constructor_body=[]),f.registeredClass.constructor_body[r-1]!==void 0)throw new Qe(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${f.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return f.registeredClass.constructor_body[r-1]=()=>{qr(`Cannot construct ${f.name} due to unbound types`,l)},sr([],l,function(m){return m.splice(1,0,null),f.registeredClass.constructor_body[r-1]=St(g,m,null,s,u),[]}),[]})}function kt(e,r,t,n,s,u,l,f,g){var m=Tt(t,n);r=me(r),u=Ne(s,u),sr([],[e],function(C){C=C[0];var A=`${C.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),f&&C.registeredClass.pureVirtualFunctions.push(r);function T(){qr(`Cannot call ${A} due to unbound types`,m)}var P=C.registeredClass.instancePrototype,I=P[r];return I===void 0||I.overloadTable===void 0&&I.className!==C.name&&I.argCount===t-2?(T.argCount=t-2,T.className=C.name,P[r]=T):(We(P,r,A),P[r].overloadTable[t-2]=T),sr([],m,function(re){var ne=St(A,re,C,u,l,g);return P[r].overloadTable===void 0?(ne.argCount=t-2,P[r]=ne):P[r].overloadTable[t-2]=ne,[]}),[]})}function Rn(){Object.assign(At.prototype,{get(e){return this.allocated[e]},has(e){return this.allocated[e]!==void 0},allocate(e){var r=this.freelist.pop()||this.allocated.length;return this.allocated[r]=e,r},free(e){this.allocated[e]=void 0,this.freelist.push(e)}})}function At(){this.allocated=[void 0],this.freelist=[]}var Ee=new At;function Dt(e){e>=Ee.reserved&&--Ee.get(e).refcount===0&&Ee.free(e)}function Nt(){for(var e=0,r=Ee.reserved;r<Ee.allocated.length;++r)Ee.allocated[r]!==void 0&&++e;return e}function On(){Ee.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),Ee.reserved=Ee.allocated.length,o.count_emval_handles=Nt}var Sr={toValue:e=>(e||q("Cannot use deleted val. handle = "+e),Ee.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Ee.allocate({refcount:1,value:e})}}};function Vt(e,r){r=me(r),$e(e,{name:r,fromWireType:function(t){var n=Sr.toValue(t);return Dt(t),n},toWireType:function(t,n){return Sr.toHandle(n)},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:null})}function Xr(e){if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e}function Un(e,r){switch(r){case 2:return function(t){return this.fromWireType(ze[t>>2])};case 3:return function(t){return this.fromWireType(he[t>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Mn(e,r,t){var n=zr(t);r=me(r),$e(e,{name:r,fromWireType:function(s){return s},toWireType:function(s,u){return u},argPackAdvance:8,readValueFromPointer:Un(r,n),destructorFunction:null})}function xn(e,r,t){switch(r){case 0:return t?function(s){return J[s]}:function(s){return Y[s]};case 1:return t?function(s){return we[s>>1]}:function(s){return ke[s>>1]};case 2:return t?function(s){return z[s>>2]}:function(s){return N[s>>2]};default:throw new TypeError("Unknown integer type: "+e)}}function In(e,r,t,n,s){r=me(r);var u=zr(t),l=A=>A;if(n===0){var f=32-8*t;l=A=>A<<f>>>f}var g=r.includes("unsigned"),m=(A,T)=>{},C;g?C=function(A,T){return m(T,this.name),T>>>0}:C=function(A,T){return m(T,this.name),T},$e(e,{name:r,fromWireType:l,toWireType:C,argPackAdvance:8,readValueFromPointer:xn(r,u,n!==0),destructorFunction:null})}function jn(e,r,t){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],s=n[r];function u(l){l=l>>2;var f=N,g=f[l],m=f[l+1];return new s(f.buffer,m,g)}t=me(t),$e(e,{name:t,fromWireType:u,argPackAdvance:8,readValueFromPointer:u},{ignoreDuplicateRegistrations:!0})}var Ln=(e,r,t)=>Br(e,Y,r,t);function fr(e,r){r=me(r);var t=r==="std::string";$e(e,{name:r,fromWireType:function(n){var s=N[n>>2],u=n+4,l;if(t)for(var f=u,g=0;g<=s;++g){var m=u+g;if(g==s||Y[m]==0){var C=m-f,A=_r(f,C);l===void 0?l=A:(l+=String.fromCharCode(0),l+=A),f=m+1}}else{for(var T=new Array(s),g=0;g<s;++g)T[g]=String.fromCharCode(Y[u+g]);l=T.join("")}return Me(n),l},toWireType:function(n,s){s instanceof ArrayBuffer&&(s=new Uint8Array(s));var u,l=typeof s=="string";l||s instanceof Uint8Array||s instanceof Uint8ClampedArray||s instanceof Int8Array||q("Cannot pass non-string to std::string"),t&&l?u=Lr(s):u=s.length;var f=Rt(4+u+1),g=f+4;if(N[f>>2]=u,t&&l)Ln(s,g,u+1);else if(l)for(var m=0;m<u;++m){var C=s.charCodeAt(m);C>255&&(Me(g),q("String has UTF-16 code units that do not fit in 8 bits")),Y[g+m]=C}else for(var m=0;m<u;++m)Y[g+m]=s[m];return n!==null&&n.push(Me,f),f},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:function(n){Me(n)}})}var Kr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,Gt=(e,r)=>{for(var t=e,n=t>>1,s=n+r/2;!(n>=s)&&ke[n];)++n;if(t=n<<1,t-e>32&&Kr)return Kr.decode(Y.subarray(e,t));for(var u="",l=0;!(l>=r/2);++l){var f=we[e+l*2>>1];if(f==0)break;u+=String.fromCharCode(f)}return u},qt=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<2)return 0;t-=2;for(var n=r,s=t<e.length*2?t/2:e.length,u=0;u<s;++u){var l=e.charCodeAt(u);we[r>>1]=l,r+=2}return we[r>>1]=0,r-n},ft=e=>e.length*2,Xt=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var s=z[e+t*4>>2];if(s==0)break;if(++t,s>=65536){var u=s-65536;n+=String.fromCharCode(55296|u>>10,56320|u&1023)}else n+=String.fromCharCode(s)}return n},c=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<4)return 0;for(var n=r,s=n+t-4,u=0;u<e.length;++u){var l=e.charCodeAt(u);if(l>=55296&&l<=57343){var f=e.charCodeAt(++u);l=65536+((l&1023)<<10)|f&1023}if(z[r>>2]=l,r+=4,r+4>s)break}return z[r>>2]=0,r-n},d=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&++t,r+=4}return r},v=function(e,r,t){t=me(t);var n,s,u,l,f;r===2?(n=Gt,s=qt,l=ft,u=()=>ke,f=1):r===4&&(n=Xt,s=c,l=d,u=()=>N,f=2),$e(e,{name:t,fromWireType:function(g){for(var m=N[g>>2],C=u(),A,T=g+4,P=0;P<=m;++P){var I=g+4+P*r;if(P==m||C[I>>f]==0){var re=I-T,ne=n(T,re);A===void 0?A=ne:(A+=String.fromCharCode(0),A+=ne),T=I+r}}return Me(g),A},toWireType:function(g,m){typeof m!="string"&&q(`Cannot pass non-string to C++ string type ${t}`);var C=l(m),A=Rt(4+C+r);return N[A>>2]=C>>f,s(m,A+4,C+r),g!==null&&g.push(Me,A),A},argPackAdvance:8,readValueFromPointer:$r,destructorFunction:function(g){Me(g)}})};function E(e,r){r=me(r),$e(e,{isVoid:!0,name:r,argPackAdvance:0,fromWireType:function(){},toWireType:function(t,n){}})}var D={};function x(e){var r=D[e];return r===void 0?me(e):r}var j=[];function O(e,r,t,n){e=j[e],r=Sr.toValue(r),t=x(t),e(r,t,null,n)}function X(e){var r=j.length;return j.push(e),r}function L(e,r){var t=He[e];return t===void 0&&q(r+" has unknown type "+Ct(e)),t}function oe(e,r){for(var t=new Array(e),n=0;n<e;++n)t[n]=L(N[r+n*4>>2],"parameter "+n);return t}var ae=[];function ce(e,r){var t=oe(e,r),n=t[0],s=n.name+"_$"+t.slice(1).map(function(I){return I.name}).join("_")+"$",u=ae[s];if(u!==void 0)return u;for(var l=["retType"],f=[n],g="",m=0;m<e-1;++m)g+=(m!==0?", ":"")+"arg"+m,l.push("argType"+m),f.push(t[1+m]);for(var C=Tr("methodCaller_"+s),A="return function "+C+`(handle, name, destructors, args) {
  60. `,T=0,m=0;m<e-1;++m)A+=" var arg"+m+" = argType"+m+".readValueFromPointer(args"+(T?"+"+T:"")+`);
  61. `,T+=t[m+1].argPackAdvance;A+=" var rv = handle[name]("+g+`);
  62. `;for(var m=0;m<e-1;++m)t[m+1].deleteObject&&(A+=" argType"+m+".deleteObject(arg"+m+`);
  63. `);n.isVoid||(A+=` return retType.toWireType(destructors, rv);
  64. `),A+=`};
  65. `,l.push(A);var P=$t(Function,l).apply(null,f);return u=X(P),ae[s]=u,u}function ye(e,r){return r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN}var Fe=()=>{je("")};function Ve(){return Date.now()}var Ie=()=>Y.length,hr=()=>Ie(),Ft=(e,r,t)=>Y.copyWithin(e,r,r+t),Ye=e=>{je("OOM")},Bn=e=>{Y.length,Ye()},Ur={},Kt=()=>b||"./this.program",nr=()=>{if(!nr.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Kt()};for(var t in Ur)Ur[t]===void 0?delete r[t]:r[t]=Ur[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);nr.strings=n}return nr.strings},fi=(e,r)=>{for(var t=0;t<e.length;++t)J[r++>>0]=e.charCodeAt(t);J[r>>0]=0},li=(e,r)=>{var t=0;return nr().forEach(function(n,s){var u=r+t;N[e+s*4>>2]=u,fi(n,u),t+=n.length+1}),0},ci=(e,r)=>{var t=nr();N[e>>2]=t.length;var n=0;return t.forEach(function(s){n+=s.length+1}),N[r>>2]=n,0};function di(e){try{var r=le.getStreamFromFD(e);return i.close(r),0}catch(t){if(typeof i>"u"||t.name!=="ErrnoError")throw t;return t.errno}}function hi(e,r){try{var t=0,n=0,s=0,u=le.getStreamFromFD(e),l=u.tty?2:i.isDir(u.mode)?3:i.isLink(u.mode)?7:4;return J[r>>0]=l,we[r+2>>1]=s,ee=[t>>>0,(M=t,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[r+8>>2]=ee[0],z[r+12>>2]=ee[1],ee=[n>>>0,(M=n,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[r+16>>2]=ee[0],z[r+20>>2]=ee[1],0}catch(f){if(typeof i>"u"||f.name!=="ErrnoError")throw f;return f.errno}}var pi=(e,r,t,n)=>{for(var s=0,u=0;u<t;u++){var l=N[r>>2],f=N[r+4>>2];r+=8;var g=i.read(e,J,l,f,n);if(g<0)return-1;if(s+=g,g<f)break;typeof n<"u"&&(n+=g)}return s};function vi(e,r,t,n){try{var s=le.getStreamFromFD(e),u=pi(s,r,t);return N[n>>2]=u,0}catch(l){if(typeof i>"u"||l.name!=="ErrnoError")throw l;return l.errno}}function mi(e,r,t,n,s){var u=ye(r,t);try{if(isNaN(u))return 61;var l=le.getStreamFromFD(e);return i.llseek(l,u,n),ee=[l.position>>>0,(M=l.position,+Math.abs(M)>=1?M>0?+Math.floor(M/4294967296)>>>0:~~+Math.ceil((M-+(~~M>>>0))/4294967296)>>>0:0)],z[s>>2]=ee[0],z[s+4>>2]=ee[1],l.getdents&&u===0&&n===0&&(l.getdents=null),0}catch(f){if(typeof i>"u"||f.name!=="ErrnoError")throw f;return f.errno}}var yi=(e,r,t,n)=>{for(var s=0,u=0;u<t;u++){var l=N[r>>2],f=N[r+4>>2];r+=8;var g=i.write(e,J,l,f,n);if(g<0)return-1;s+=g,typeof n<"u"&&(n+=g)}return s};function gi(e,r,t,n){try{var s=le.getStreamFromFD(e),u=yi(s,r,t);return N[n>>2]=u,0}catch(l){if(typeof i>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var Hn=function(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=i.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n},Qr=365,Yr=146;Object.defineProperties(Hn.prototype,{read:{get:function(){return(this.mode&Qr)===Qr},set:function(e){e?this.mode|=Qr:this.mode&=~Qr}},write:{get:function(){return(this.mode&Yr)===Yr},set:function(e){e?this.mode|=Yr:this.mode&=~Yr}},isFolder:{get:function(){return i.isDir(this.mode)}},isDevice:{get:function(){return i.isChrdev(this.mode)}}}),i.FSNode=Hn,i.createPreloadedFile=nn,i.staticInit(),it(),Qe=o.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError"}},rr=o.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError"}},Wt(),Lt(),Pn(),Pt=o.UnboundTypeError=kn(Error,"UnboundTypeError"),Rn(),On();var wi={p:gr,C:sn,w:Wr,t:an,n:jt,r:An,q:Fn,d:kt,D:Vt,k:Mn,c:In,b:jn,j:fr,f:v,o:E,g:O,m:Dt,l:ce,a:Fe,e:Ve,v:hr,A:Ft,u:Bn,y:li,z:ci,i:di,x:hi,B:vi,s:mi,h:gi};tn();var Rt=e=>(Rt=B.G)(e),Me=e=>(Me=B.I)(e),Wn=()=>(Wn=B.J)(),zn=e=>(zn=B.K)(e);o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=B.L)();var Nn=e=>(Nn=B.M)(e);o.dynCall_viiijj=(e,r,t,n,s,u,l,f)=>(o.dynCall_viiijj=B.N)(e,r,t,n,s,u,l,f),o.dynCall_jij=(e,r,t,n)=>(o.dynCall_jij=B.O)(e,r,t,n),o.dynCall_jii=(e,r,t)=>(o.dynCall_jii=B.P)(e,r,t),o.dynCall_jiji=(e,r,t,n,s)=>(o.dynCall_jiji=B.Q)(e,r,t,n,s);var Zr;ir=function e(){Zr||Vn(),Zr||(ir=e)};function Vn(){if(Se>0||(xr(),Se>0))return;function e(){Zr||(Zr=!0,o.calledRun=!0,!te&&(Ir(),p(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),Ge()))}o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),e()},1)):e()}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return Vn(),a.ready}})(),So=Object.defineProperty,ko=Object.getOwnPropertyDescriptor,Jn=(h,a,o,p)=>{for(var y=p>1?void 0:p?ko(a,o):a,_=h.length-1,b;_>=0;_--)(b=h[_])&&(y=(p?b(a,o,y):b(y))||y);return p&&y&&So(a,o,y),y};class dt extends pe{constructor(){super(...arguments),this.sampleRate=0,this.channels=0}initialize(){return new Promise(a=>{const o={};o.print=p=>console.log(p),o.printErr=p=>console.log(`[JS] ERROR: ${p}`),o.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),o.postRun=p=>{this.module=p,this.decoder=new this.module.AudioDecoder(this),a()},$o(o)})}configure(a){this.config=a,this.decoder.setCodec(this.config.codec,this.config.description??"")}decode(a){this.decoder.decode(a.data,a.timestamp)}flush(){}reset(){this.config=void 0,this.decoder&&this.decoder.clear()}close(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}audioInfo(a,o){this.sampleRate=a,this.channels=o;let p={sampleRate:a,channels:o,depth:16};this.emit(lt.AudioCodecInfo,p)}pcmData(a,o,p){if(!this.module)return;let y=[],_=0,b=0;for(let k=0;k<this.channels;k++){let w=this.module.HEAPU32[(a>>2)+k]>>2;const $=this.module.HEAPF32.subarray(w,w+o);y.push($),_+=$.length}const F=new Float32Array(_);this.emit(lt.AudioFrame,new AudioData({format:"f32-planar",sampleRate:this.sampleRate,numberOfChannels:this.channels,timestamp:p,numberOfFrames:o,data:y.reduce((k,w)=>(k.subarray(b).set(w),b+=w.length,k),F)}))}errorInfo(a){let o={errMsg:a};this.emit(lt.Error,o)}}Jn([Oe(pe.INIT,"initialized")],dt.prototype,"initialize",1);Jn([Oe("initialized","configured",{sync:!0})],dt.prototype,"configure",1);Jn([Ai("configured")],dt.prototype,"decode",1);Jn([Oe("configured","initialized",{sync:!0})],dt.prototype,"reset",1);Jn([Oe([],"closed",{sync:!0})],dt.prototype,"close",1);var Ao=Object.defineProperty,Do=Object.getOwnPropertyDescriptor,ei=(h,a,o,p)=>{for(var y=p>1?void 0:p?Do(a,o):a,_=h.length-1,b;_>=0;_--)(b=h[_])&&(y=(p?b(a,o,y):b(y))||y);return p&&y&&Ao(a,o,y),y};class ht extends pe{async initialize(){this.decoder=new AudioDecoder({output:a=>{this.emit(lt.AudioFrame,a)},error:a=>{this.emit(lt.Error,a),this.close()}})}configure(a){a.codec==="aac"&&(a.codec="mp4a.40.2"),this.config=a,this.decoder.configure(a)}decode(a){this.decoder.state==="configured"&&this.decoder.decode(new EncodedAudioChunk(a))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){this.decoder.state!=="closed"&&this.decoder.close()}}ei([Oe([pe.INIT,"closed"],"initialized")],ht.prototype,"initialize",1);ei([Oe("initialized","configured",{sync:!0})],ht.prototype,"configure",1);ei([Ai("configured")],ht.prototype,"decode",1);ei([Oe([],pe.INIT,{sync:!0})],ht.prototype,"reset",1);ei([Oe([],"closed",{ignoreError:!0,sync:!0})],ht.prototype,"close",1);var Ot=(h=>(h.AUDIO_ENCODER_CONFIG_CHANGED="audio-encoder-config-changed",h.VIDEO_ENCODER_CONFIG_CHANGED="video-encoder-config-changed",h.DEMUX_ERROR="demux-error",h))(Ot||{}),Qt=(h=>(h[h.PULL=0]="PULL",h[h.PUSH=1]="PUSH",h))(Qt||{});class Fo extends Yt.EventEmitter{constructor(a,o=0,p="annexb"){super(),this.source=a,this.mode=o,this.format=p,Object.getPrototypeOf(this).constructor.name,a&&(o==0?this.startPull(a):a.oput=new Qn(this.demux()))}startPull(a){this.mode=0,this.source=a,this.audioReadable=new ReadableStream({pull:async o=>o.enqueue(await this.pullAudio())}),this.videoReadable=new ReadableStream({pull:async o=>o.enqueue(await this.pullVideo())})}pullAudio(){return new Promise((a,o)=>{this.gotAudio=a,this.gotVideo&&this.pull().catch(o)})}pullVideo(){return new Promise((a,o)=>{this.gotVideo=a,this.gotAudio&&this.pull().catch(o)})}}const Ro=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,-1,-1,-1];function Ui(h,a=!1,o){const p=new Uint8Array([0,0,0,1]);let y=0;if(a&&o&&o.length>0)for(const w of o)w instanceof Uint8Array&&w.length>0&&(y+=w.length+4);let _=0,b=0;for(;b<h.length&&!(b+4>h.length);){const w=h[b]<<24|h[b+1]<<16|h[b+2]<<8|h[b+3];if(w<0||b+4+w>h.length)break;_+=w+4,b+=4+w}y+=_;const F=new Uint8Array(y);let k=0;if(a&&o&&o.length>0){for(const w of o)if(w instanceof Uint8Array&&w.length>0){if(k+4+w.length>F.length)return console.error("Error writing parameter set: buffer overflow"),F.slice(0,k);F.set(p,k),F.set(w,k+4),k+=w.length+4}}for(b=0;b<h.length&&!(b+4>h.length);){const w=h[b]<<24|h[b+1]<<16|h[b+2]<<8|h[b+3];if(w<0||b+4+w>h.length)break;if(k+4+w>F.length){console.error("Error writing NALU from AVCC: buffer overflow");break}F.set(p,k),F.set(h.subarray(b+4,b+4+w),k+4),k+=w+4,b+=4+w}return k!==y?F.slice(0,k):F}function Mi(h){const a=[],o=[];let p=0;if(!h||h.length<7)return console.error("Invalid AVCC data: too short"),{sps:a,pps:o};p+=5;const y=h[p++]&31;for(let b=0;b<y;b++){if(p+2>h.length){console.error("Invalid AVCC data: not enough bytes for SPS length");break}const F=h[p]<<8|h[p+1];if(p+=2,p+F>h.length){console.error("Invalid AVCC data: not enough bytes for SPS NAL unit");break}a.push(h.subarray(p,p+F)),p+=F}if(p+1>h.length)return y>0&&a.length,{sps:a,pps:o};const _=h[p++];for(let b=0;b<_;b++){if(p+2>h.length){console.error("Invalid AVCC data: not enough bytes for PPS length");break}const F=h[p]<<8|h[p+1];if(p+=2,p+F>h.length){console.error("Invalid AVCC data: not enough bytes for PPS NAL unit");break}o.push(h.subarray(p,p+F)),p+=F}return{sps:a,pps:o}}function Oo(h){const a=[],o=[],p=[];let y=0;if(!h||h.length<23)return console.error("Invalid HVCC data: too short for header"),{vps:a,sps:o,pps:p};y+=22;const _=h[y++];if(y+_*3>h.length)return console.error("Invalid HVCC data: numOfArrays inconsistent with data length"),{vps:a,sps:o,pps:p};for(let b=0;b<_;b++){if(y+3>h.length){console.error("Invalid HVCC data: not enough bytes for NAL unit array header");break}const F=h[y]&63;y++;const k=h[y]<<8|h[y+1];y+=2;let w=!1;for(let $=0;$<k;$++){if(y+2>h.length){console.error("Invalid HVCC data: not enough bytes for NAL unit length"),w=!0;break}const S=h[y]<<8|h[y+1];if(y+=2,y+S>h.length){console.error("Invalid HVCC data: not enough bytes for NAL unit data"),w=!0;break}const G=h.subarray(y,y+S);switch(y+=S,F){case 32:a.push(G);break;case 33:o.push(G);break;case 34:p.push(G);break}}if(w)break}return{vps:a,sps:o,pps:p}}const Uo="hvc1",Mo="av01";class xo extends Fo{constructor(){super(...arguments),this.tmp8=new Uint8Array(4),this.dv=new DataView(this.tmp8.buffer)}async pullTag(){const a=new Uint8Array(15);return this.pullTag=async()=>{await this.source.read(a);const o=a[4],p=this.readLength(a.subarray(5,8)),y=this.readTimestamp(a.subarray(8,11)),_=await this.source.read(p);return{type:o,data:_.slice(),timestamp:y}},console.time("flv"),await this.source.read(9).then(o=>{if(this.header=o,o.subarray(0,3).reduce((p,y)=>p+String.fromCharCode(y),"")!=="FLV")throw new Error("not flv");console.timeEnd("flv")}),this.pullTag()}readTag(a){const o=a[0],p=this.readLength(a.subarray(1,4)),y=this.readTimestamp(a.subarray(4,8));this.gotTag(o,a.subarray(11,11+p),y)}gotTag(a,o,p){var y,_,b,F,k;switch(a){case 8:return this.audioDecoderConfig||(this.audioDecoderConfig={codec:{10:"aac",7:"pcma",8:"pcmu"}[o[0]>>4]||"unknown",numberOfChannels:1,sampleRate:8e3},this.audioDecoderConfig.codec=="aac"?(this.audioDecoderConfig.numberOfChannels=o[3]>>3&15,this.audioDecoderConfig.sampleRate=Ro[(o[2]&7)<<1|o[3]>>7]):this.emit(Ot.AUDIO_ENCODER_CONFIG_CHANGED,this.audioDecoderConfig)),this.audioDecoderConfig.codec=="aac"&&o[1]==0?(this.audioDecoderConfig.description=o.subarray(2),this.emit(Ot.AUDIO_ENCODER_CONFIG_CHANGED,this.audioDecoderConfig),this.mode==Qt.PULL?this.pull():void 0):(y=this.gotAudio)==null?void 0:y.call(this,{type:"key",data:this.audioDecoderConfig.codec=="aac"?o.subarray(2):o.subarray(1),timestamp:p,duration:0});case 9:if(o[0]>>7){const S=o[0]&15;if(S){const G=(o[0]&112)>>4==1,Q=S===3,V=o.subarray(Q?5:8);return(b=this.gotVideo)==null?void 0:b.call(this,{type:G?"key":"delta",data:this.format==="annexb"&&((_=this.videoDecoderConfig)==null?void 0:_.codec)!=="av1"?Ui(V,G,this.videoDecoderConfig.parameterSets):V,timestamp:p,duration:0})}else{switch(o.subarray(1,5).reduce((G,Q)=>G+String.fromCharCode(Q),"")){case Uo:const G={codec:"hevc",description:o.subarray(5)};if(this.format==="annexb"){const Q=Oo(G.description);this.videoDecoderConfig={codec:"hevc",parameterSets:[Q.vps[0],Q.sps[0],Q.pps[0]]}}else this.videoDecoderConfig=G;break;case Mo:this.videoDecoderConfig={codec:"av1"};break}return this.emit(Ot.VIDEO_ENCODER_CONFIG_CHANGED,this.videoDecoderConfig),this.mode==Qt.PULL?this.pull():void 0}}else if(o[1]===0){const S={codec:{7:"avc",12:"hevc",13:"av1"}[o[0]&15]||"unknown",description:o.subarray(5)};if(S.codec=="av1")this.videoDecoderConfig={codec:"av1"};else if(this.format==="annexb"){const G=S.codec==="hevc";let Q=[];if(G){const V=Mi(S.description);Q=[V.vps[0],V.sps[0],V.pps[0]]}else{const V=Mi(S.description);Q=[V.sps[0],V.pps[0]]}this.videoDecoderConfig={codec:S.codec,parameterSets:Q}}else this.videoDecoderConfig=S;return this.emit(Ot.VIDEO_ENCODER_CONFIG_CHANGED,this.videoDecoderConfig),this.mode==Qt.PULL?this.pull():void 0}const w=o[0]>>4==1,$=o.subarray(5);return(k=this.gotVideo)==null?void 0:k.call(this,{type:w?"key":"delta",data:this.format==="annexb"&&((F=this.videoDecoderConfig)==null?void 0:F.codec)!=="av1"?Ui($,w,this.videoDecoderConfig.parameterSets):$,timestamp:p,duration:0});default:if(this.mode==Qt.PULL)return this.pull()}}async pull(){const a=await this.pullTag();if(a)return this.gotTag(a.type,a.data,a.timestamp)}readLength(a){return this.tmp8[0]=0,this.tmp8.set(a,1),this.dv.getUint32(0)}readTimestamp(a){this.tmp8.set(a.subarray(0,3),1);let o=this.dv.getUint32(0);return o===16777215&&(this.tmp8[0]=a[3],o=this.dv.getUint32(0)),o}readHead(a){if(console.time("flv"),this.header=a,a.subarray(0,3).reduce((o,p)=>o+String.fromCharCode(p),"")!=="FLV")throw new Error("not flv");console.timeEnd("flv")}*demux(){for(this.readHead(yield 13);;){let a=yield 11;const o=a[0],p=this.readLength(a.subarray(1,4)),y=this.readTimestamp(a.subarray(4,8));a=yield p,this.gotTag(o,a.slice(),y),yield 4}}}class Io{constructor(a){this.initialized=!1,this.audioQueue=[],this.nextAudioStartTime=0,this.display=a;const o=a.getContext("2d");if(!o)throw new Error("Failed to get 2d context");this.ctx=o,this.audioContext=new AudioContext}async writeAudio(a){const o=a.numberOfChannels,p=a.numberOfFrames,y=a.sampleRate,_=new AudioBuffer({length:p,numberOfChannels:o,sampleRate:y});for(let b=0;b<o;b++){const F=new Float32Array(p);a.copyTo(F,{planeIndex:b}),_.copyToChannel(F,b)}this.scheduleAudioBuffer(_),a.close()}scheduleAudioBuffer(a){const o=this.audioContext.currentTime;this.audioQueue.length===0&&o>this.nextAudioStartTime&&(this.nextAudioStartTime=o),this.audioQueue.push({buffer:a,startTime:this.nextAudioStartTime}),this.nextAudioStartTime+=a.duration,this.processAudioQueue()}processAudioQueue(){const a=this.audioContext.currentTime;for(;this.audioQueue.length>0&&this.audioQueue[0].startTime+this.audioQueue[0].buffer.duration<a;)this.audioQueue.shift();for(;this.audioQueue.length>0;){const o=this.audioQueue[0];if(o.startTime>a)break;const p=this.audioContext.createBufferSource();p.buffer=o.buffer,p.connect(this.audioContext.destination);const y=Math.max(0,a-o.startTime);o.buffer.duration-y>0&&p.start(a,y),this.audioQueue.shift()}}writeVideo(a){(this.display.width!==a.displayWidth||this.display.height!==a.displayHeight)&&(this.display.width=a.displayWidth,this.display.height=a.displayHeight),this.ctx.drawImage(a,0,0,a.displayWidth,a.displayHeight),a.close()}close(){this.audioContext.close()}}const jo={class:"video-container"},Lo=["srcObject"],Bo=Ii({__name:"jb4-ws-flv",props:{videoShadow:{},streamPath:{},webrtcStream:{},speed:{},pause:{type:Boolean},startTime:{}},emits:["postion","play"],setup(h,{emit:a}){const o=h,p=a;let y,_=0,b=0;const F=ti();let k,w;const $=ti(),S=typeof VideoDecoder=="function",G=ti();let Q=null,V=null,W=null;function R(){return typeof WebAssembly>"u"?!1:WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]))}let Z=J(S?ct:R()?Oi:Ci),B=Y(S?ht:dt);const te=ji(new co(""));let be=!1;_i(()=>{F.value&&(F.value.addEventListener("playing",()=>{p("play",!0)}),F.value.addEventListener("pause",()=>{p("play","pause")}),F.value.addEventListener("ended",()=>{p("play","ended")}),F.value.addEventListener("error",()=>{p("play","error")}))});function J(he){const se=new he;return se.on(kr.VideoCodecInfo,ve=>{`${ve.width}${ve.height}`}),se.on(kr.VideoFrame,ve=>{w?w.write(ve):Q&&G.value&&(ze.value=!1,Q.writeVideo(ve),ve.close())}),se.on(kr.Error,ve=>{console.error(ve),be=!1,Z instanceof ct&&(Z=J(R()?Oi:Ci),Z.initialize().then(()=>{W&&Z.configure({...W})}))}),se}function Y(he){const se=new he;return se.on(lt.Error,ve=>{console.error(ve),se instanceof ht&&(B=Y(dt),B.initialize().then(()=>{V&&B.configure({...V})}))}),se.on(lt.AudioFrame,ve=>{k?k.write(ve):Q&&(ze.value=!1,Q.writeAudio(ve))}),se}function we(){B==null||B.close(),V=null}function ke(){Z==null||Z.close(),W=null}function z(){var he;F.value&&((he=o.webrtcStream)!=null&&he.mediaStream)&&($.value=o.webrtcStream.mediaStream)}Li(()=>{var he;(he=o.webrtcStream)==null||he.off("change",z)}),_i(()=>{te.mediaStream&&($.value=te.mediaStream),o.webrtcStream&&(z(),o.webrtcStream.on("change",z))}),_i(async()=>{if(o.streamPath)try{y&&(we(),ke(),await y.close()),B=Y(S?ht:dt),Z=J(S?ct:Ci),await Z.initialize(),await B.initialize(),y=new lo(`${ro("flv","","ws")}/${o.streamPath}`),N(new xo(y,Qt.PUSH)),await y.connect()}catch(he){Yi.error({message:"播放失败",description:he instanceof Event?"连接失败":String(he)}),p("play","connect error")}});function N(he){if(S&&typeof MediaStreamTrackGenerator=="function"){const se=new MediaStreamTrackGenerator({kind:"audio"});k=se.writable.getWriter(),se.onmute=()=>{p("play","audio mute")};const ve=new MediaStreamTrackGenerator({kind:"video"});w=ve.writable.getWriter(),ve.onmute=()=>{p("play","videomute")},$.value=new MediaStream([se,ve])}he.on(Ot.VIDEO_ENCODER_CONFIG_CHANGED,se=>{W={...se},delete W.description,Z.state==="initialized"&&Z.configure(W),!S&&G.value&&(Q=new Io(G.value))}),he.on(Ot.AUDIO_ENCODER_CONFIG_CHANGED,se=>{V=se;try{B.configure({...se})}catch(ve){console.error(ve)}}),he.gotVideo=se=>{try{if(Z.state!=="configured"){console.warn("Video decoder not configured yet, waiting...");return}if(!be&&se.type!=="key"){console.warn("Waiting for keyframe...");return}se.type==="key"&&(be||(be=!0)),Z.decode(se),_=se.timestamp,o.startTime!==void 0&&o.startTime!==null&&p("postion",_-b+o.startTime)}catch(ve){console.error(ve,se)}},he.gotAudio=se=>{if(B.state!=="configured"){console.warn("Audio decoder not configured yet, waiting...");return}B.decode(se)}}const ze=ti(!0);return Bi(()=>{var he;if(!S&&F.value){const se=document.createElement("canvas");se.style.width="100%",se.style.objectFit="cover",se.style.borderRadius="6px",o.videoShadow&&(se.style.boxShadow="4px 4px 8px 4px #dedede"),(he=F.value.parentElement)==null||he.replaceChild(se,F.value),G.value=se}Zi(F.value,"canplay",()=>{ze.value=!1})}),Hi(()=>{y==null||y.close(),w&&w.close(),k&&k.close()}),(he,se)=>(Wi(),zi("div",jo,[Ni(Gi(qi(Ji),{class:"loading",size:"large"},null,512),[[Vi,ze.value]]),Xi("video",{ref_key:"videoEle",ref:F,class:Ki(["video",{videoShadow:he.videoShadow}]),srcObject:$.value,autoplay:""},null,10,Lo),Qi(he.$slots,"default",{},void 0,!0)]))}});const Zo=eo(Bo,[["__scopeId","data-v-fea00ff5"]]);export{dt as A,Zo as V,Ci as a,ht as b,kr as c,lt as d};