usePlay-db12062a.js 91 KB

1234567891011121314151617181920212223242526
  1. import{av as mi}from"./index-fb7a0cf7.js";import{O as gi,r as yi}from"./vue-18ee037d.js";import"./dayjs-4778c158.js";const Vi=gi({id:"screen-store",persist:{paths:["customInfo"]},state:()=>({activeInfo:{ID:"",DeviceID:"",DeviceName:"",Name:"",LiveStatus:0},customInfo:{collapsed:!1,rowNum:1,screenNum:1,selectNum:0}}),getters:{getActiveInfo(){return this.activeInfo}},actions:{setActiveInfo(h){this.activeInfo=h},setCustomInfo(h){const a=Object.assign(this.customInfo,h);this.customInfo=a}}});var xe={},wi={get exports(){return xe},set exports(h){xe=h}};(function(h){var a=Object.prototype.hasOwnProperty,o="~";function d(){}Object.create&&(d.prototype=Object.create(null),new d().__proto__||(o=!1));function v(F,g,w){this.fn=F,this.context=g,this.once=w||!1}function T(F,g,w,m,D){if(typeof w!="function")throw new TypeError("The listener must be a function");var k=new v(w,m||F,D),A=o?o+g:g;return F._events[A]?F._events[A].fn?F._events[A]=[F._events[A],k]:F._events[A].push(k):(F._events[A]=k,F._eventsCount++),F}function P(F,g){--F._eventsCount===0?F._events=new d:delete F._events[g]}function R(){this._events=new d,this._eventsCount=0}R.prototype.eventNames=function(){var g=[],w,m;if(this._eventsCount===0)return g;for(m in w=this._events)a.call(w,m)&&g.push(o?m.slice(1):m);return Object.getOwnPropertySymbols?g.concat(Object.getOwnPropertySymbols(w)):g},R.prototype.listeners=function(g){var w=o?o+g:g,m=this._events[w];if(!m)return[];if(m.fn)return[m.fn];for(var D=0,k=m.length,A=new Array(k);D<k;D++)A[D]=m[D].fn;return A},R.prototype.listenerCount=function(g){var w=o?o+g:g,m=this._events[w];return m?m.fn?1:m.length:0},R.prototype.emit=function(g,w,m,D,k,A){var N=o?o+g:g;if(!this._events[N])return!1;var C=this._events[N],X=arguments.length,J,I;if(C.fn){switch(C.once&&this.removeListener(g,C.fn,void 0,!0),X){case 1:return C.fn.call(C.context),!0;case 2:return C.fn.call(C.context,w),!0;case 3:return C.fn.call(C.context,w,m),!0;case 4:return C.fn.call(C.context,w,m,D),!0;case 5:return C.fn.call(C.context,w,m,D,k),!0;case 6:return C.fn.call(C.context,w,m,D,k,A),!0}for(I=1,J=new Array(X-1);I<X;I++)J[I-1]=arguments[I];C.fn.apply(C.context,J)}else{var ie=C.length,M;for(I=0;I<ie;I++)switch(C[I].once&&this.removeListener(g,C[I].fn,void 0,!0),X){case 1:C[I].fn.call(C[I].context);break;case 2:C[I].fn.call(C[I].context,w);break;case 3:C[I].fn.call(C[I].context,w,m);break;case 4:C[I].fn.call(C[I].context,w,m,D);break;default:if(!J)for(M=1,J=new Array(X-1);M<X;M++)J[M-1]=arguments[M];C[I].fn.apply(C[I].context,J)}}return!0},R.prototype.on=function(g,w,m){return T(this,g,w,m,!1)},R.prototype.once=function(g,w,m){return T(this,g,w,m,!0)},R.prototype.removeListener=function(g,w,m,D){var k=o?o+g:g;if(!this._events[k])return this;if(!w)return P(this,k),this;var A=this._events[k];if(A.fn)A.fn===w&&(!D||A.once)&&(!m||A.context===m)&&P(this,k);else{for(var N=0,C=[],X=A.length;N<X;N++)(A[N].fn!==w||D&&!A[N].once||m&&A[N].context!==m)&&C.push(A[N]);C.length?this._events[k]=C.length===1?C[0]:C:P(this,k)}return this},R.prototype.removeAllListeners=function(g){var w;return g?(w=o?o+g:g,this._events[w]&&P(this,w)):(this._events=new d,this._eventsCount=0),this},R.prototype.off=R.prototype.removeListener,R.prototype.addListener=R.prototype.on,R.prefixed=o,R.EventEmitter=R,h.exports=R})(wi);var _i=globalThis&&globalThis.__awaiter||function(h,a,o,d){function v(T){return T instanceof o?T:new o(function(P){P(T)})}return new(o||(o=Promise))(function(T,P){function R(w){try{g(d.next(w))}catch(m){P(m)}}function F(w){try{g(d.throw(w))}catch(m){P(m)}}function g(w){w.done?T(w.value):v(w.value).then(R,F)}g((d=d.apply(h,a||[])).next())})};const Rr=Symbol(32),$r=Symbol(16),Ir=Symbol(8);class ze{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 _i(this,void 0,void 0,function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise((o,d)=>{var v;this.reject=d,this.resolve=P=>{delete this.lastReadPromise,delete this.resolve,delete this.need,o(P)},this.demand(a,!0)||(v=this.pull)===null||v===void 0||v.call(this,a)})})}readU32(){return this.read(Rr)}readU16(){return this.read($r)}readU8(){return this.read(Ir)}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 d=0;const v=T=>o.length<(d=T);if(typeof this.need=="number"){if(v(this.need))return;a=o.subarray(0,d)}else if(this.need===Rr){if(v(4))return;a=o[0]<<24|o[1]<<16|o[2]<<8|o[3]}else if(this.need===$r){if(v(2))return;a=o[0]<<8|o[1]}else if(this.need===Ir){if(v(1))return;a=o[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(v(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(o.subarray(0,d)),a=this.need}else if(this.g){this.g.throw(new Error("Unsupported type"));return}}else{if(v(this.need.byteLength))return;new Uint8Array(this.need).set(o.subarray(0,d)),a=this.need}return this.consumed+=d,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,d=o+a;if(d<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,d);else{const v=new Uint8Array(d);v.set(this.buffer),this.buffer=v}return this.buffer.subarray(o,d)}else return this.buffer=new Uint8Array(a),this.buffer}}ze.U32=Rr;ze.U16=$r;ze.U8=Ir;var Se=(h=>(h.AUDIO_ENCODER_CONFIG_CHANGED="audio-encoder-config-changed",h.VIDEO_ENCODER_CONFIG_CHANGED="video-encoder-config-changed",h))(Se||{}),Le=(h=>(h[h.PULL=0]="PULL",h[h.PUSH=1]="PUSH",h))(Le||{});class Ei extends xe.EventEmitter{constructor(a,o=0){super(),this.source=a,this.mode=o,Object.getPrototypeOf(this).constructor.name,a&&(o==0?this.startPull(a):a.oput=new ze(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 bi=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,-1,-1,-1];class Pi extends Ei{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],d=this.readLength(a.subarray(5,8)),v=this.readTimestamp(a.subarray(8,11)),T=await this.source.read(d);return{type:o,data:T.slice(),timestamp:v}},console.time("flv"),await this.source.read(9).then(o=>{if(this.header=o,o[0]!="F".charCodeAt(0)||o[1]!="L".charCodeAt(0)||o[2]!="V".charCodeAt(0))throw new Error("not flv");console.timeEnd("flv")}),this.pullTag()}readTag(a){const o=a[0],d=this.readLength(a.subarray(1,4)),v=this.readTimestamp(a.subarray(4,8));this.gotTag(o,a.subarray(11,11+d),v)}gotTag(a,o,d){var v,T;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=bi[(o[2]&7)<<1|o[3]>>7]):this.emit(Se.AUDIO_ENCODER_CONFIG_CHANGED,this.audioDecoderConfig)),this.audioDecoderConfig.codec=="aac"&&o[1]==0?(this.audioDecoderConfig.description=o.subarray(2),this.emit(Se.AUDIO_ENCODER_CONFIG_CHANGED,this.audioDecoderConfig),this.mode==Le.PULL?this.pull():void 0):(v=this.gotAudio)==null?void 0:v.call(this,{type:"key",data:this.audioDecoderConfig.codec=="aac"?o.subarray(2):o.subarray(1),timestamp:d,duration:0});case 9:return this.videoDecoderConfig||(this.videoDecoderConfig={codec:{7:"avc",12:"hevc"}[o[0]&15]||"unknown",description:o.subarray(5)}),o[1]==0?(this.emit(Se.VIDEO_ENCODER_CONFIG_CHANGED,this.videoDecoderConfig),this.mode==Le.PULL?this.pull():void 0):(T=this.gotVideo)==null?void 0:T.call(this,{type:o[0]>>4==1?"key":"delta",data:o.subarray(5),timestamp:d,duration:0});default:if(this.mode==Le.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[0]!="F".charCodeAt(0)||a[1]!="L".charCodeAt(0)||a[2]!="V".charCodeAt(0))throw new Error("not flv");console.timeEnd("flv")}*demux(){for(this.readHead(yield 13);;){let a=yield 11;const o=a[0],d=this.readLength(a.subarray(1,4)),v=this.readTimestamp(a.subarray(4,8));a=yield d,this.gotTag(o,a.slice(),v),yield 4}}}const vt=Symbol("instance"),Fr=Symbol("cacheResult");class Or{constructor(a,o,d){this.oldState=a,this.newState=o,this.action=d,this.aborted=!1}abort(a){this.aborted=!0,Me.call(a,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}}class fr extends Error{constructor(a,o,d){super(o),this.state=a,this.message=o,this.cause=d}}function Ti(h){return typeof h=="object"&&h&&"then"in h}const je=new Map;function W(h,a,o={}){return(d,v,T)=>{const P=o.action||v;if(!o.context){const F=je.get(d)||[];je.has(d)||je.set(d,F),F.push({from:h,to:a,action:P})}const R=T.value;T.value=function(...F){let g=this;if(o.context&&(g=U.get(typeof o.context=="function"?o.context.call(this,...F):o.context)),g.state===a)return g[Fr];g.state instanceof Or&&g.state.action==o.abortAction&&g.state.abort(g);let w=null;if(Array.isArray(h)?h.length==0?g.state instanceof Or&&g.state.abort(g):(typeof g.state!="string"||!h.includes(g.state))&&(w=new fr(g._state,`${g.name} ${P} to ${a} failed: current state ${g._state} not in from config`)):h!==g.state&&(w=new fr(g._state,`${g.name} ${P} to ${a} failed: current state ${g._state} not from ${h}`)),w)if(o.fail)o.fail.call(this,w);else{if(o.ignoreError)return w;throw w}const m=g.state,D=new Or(m,a,P);Me.call(g,D);const k=N=>{var C;return g[Fr]=N,D.aborted||(Me.call(g,a),(C=o.success)===null||C===void 0||C.call(this,g[Fr])),N},A=N=>{const C=N instanceof Error?N.message:String(N);if(Me.call(g,m,N),o.fail)o.fail.call(this,new fr(g._state,`action '${P}' failed :${C}`,N instanceof Error?N:new Error(C)));else{if(o.ignoreError)return N;throw N}};try{const N=R.apply(this,F);return Ti(N)?N.then(k).catch(A):k(N)}catch(N){A(N)}}}}function He(...h){return(a,o,d)=>{const v=d.value,T=o;d.value=function(...P){if(!h.includes(this.state.toString()))throw new fr(this.state,`${this.name} ${T} failed: current state ${this.state} not in ${h}`);return v.apply(this,P)}}}const Ci=(()=>typeof window<"u"&&window.__AFSM__?(o,d)=>{window.dispatchEvent(new CustomEvent(o,{detail:d}))}:typeof importScripts<"u"?(o,d)=>{postMessage({type:o,payload:d})}:()=>{})();function Me(h,a){const o=this._state;this._state=h;const d=h.toString();h&&this.emit(d,o),this.emit(U.STATECHANGED,h,o,a),this.updateDevTools({value:h,old:o,err:a instanceof Error?a.message:String(a)})}class U extends xe{constructor(a,o,d){super(),this.name=a,this.groupName=o,this._state=U.INIT,a||(a=Date.now().toString(36)),d?Object.setPrototypeOf(this,d):d=Object.getPrototypeOf(this),o||(this.groupName=this.constructor.name);const v=d[vt];v?this.name=v.name+"-"+v.count++:d[vt]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){const a=Object.getPrototypeOf(this),o=je.get(a)||[];let d=new Set,v=[],T=[];const P=new Set,R=Object.getPrototypeOf(a);je.has(R)&&(R.stateDiagram.forEach(g=>d.add(g)),R.allStates.forEach(g=>P.add(g))),o.forEach(({from:g,to:w,action:m})=>{typeof g=="string"?v.push({from:g,to:w,action:m}):g.length?g.forEach(D=>{v.push({from:D,to:w,action:m})}):T.push({to:w,action:m})}),v.forEach(({from:g,to:w,action:m})=>{P.add(g),P.add(w),P.add(m+"ing"),d.add(`${g} --> ${m}ing : ${m}`),d.add(`${m}ing --> ${w} : ${m} 🟢`),d.add(`${m}ing --> ${g} : ${m} 🔴`)}),T.forEach(({to:g,action:w})=>{d.add(`${w}ing --> ${g} : ${w} 🟢`),P.forEach(m=>{m!==g&&d.add(`${m} --> ${w}ing : ${w}`)})});const F=[...d];return Object.defineProperties(a,{stateDiagram:{value:F},allStates:{value:P}}),F}static get(a){let o;return typeof a=="string"?(o=U.instances.get(a),o||U.instances.set(a,o=new U(a,void 0,Object.create(U.prototype)))):(o=U.instances2.get(a),o||U.instances2.set(a,o=new U(a.constructor.name,void 0,Object.create(U.prototype)))),o}static getState(a){var o;return(o=U.get(a))===null||o===void 0?void 0:o.state}updateDevTools(a={}){Ci(U.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},a))}get state(){return this._state}set state(a){Me.call(this,a)}}U.STATECHANGED="stateChanged";U.UPDATEAFSM="updateAFSM";U.INIT="[*]";U.ON="on";U.OFF="off";U.instances=new Map;U.instances2=new WeakMap;var ve=(h=>(h.CONNECTED="connected",h.DISCONNECTED="disconnected",h.RECONNECTED="reconnected",h))(ve||{}),Di=Object.defineProperty,Si=Object.getOwnPropertyDescriptor,Be=(h,a,o,d)=>{for(var v=d>1?void 0:d?Si(a,o):a,T=h.length-1,P;T>=0;T--)(P=h[T])&&(v=(d?P(a,o,v):P(v))||v);return d&&v&&Di(a,o,v),v};function gt(h,a=1,o=1){return h<=1?o:gt(h-1,o,a+o)}function Ai(h){const a=Math.round(h/2)+1;return a>6?13*1e3:gt(a)*1e3}class mt{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 be extends U{constructor(a,o={}){super(a||"conn","Connection"),this.url=a,this.options=o,this.up=new mt,this.down=new mt,this.underlyingSink={write:async d=>{var v;return this.down.add(d.length||d.byteLength),(v=this.oput)==null?void 0:v.write(d)}},this.options.reconnectTimeout||(this.options.reconnectTimeout=Ai)}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 ze),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(d=>{`${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)}}Be([He(ve.CONNECTED)],be.prototype,"read",1);Be([W([ve.DISCONNECTED,U.INIT],ve.CONNECTED)],be.prototype,"connect",1);Be([W(ve.DISCONNECTED,ve.RECONNECTED)],be.prototype,"reconnect",1);Be([W(ve.CONNECTED,ve.DISCONNECTED)],be.prototype,"disconnect",1);Be([W([],U.INIT)],be.prototype,"close",1);class ki extends be{constructor(a){super(a.label),this.dc=a}async _connect(){return new ReadableStream({start:a=>{this.dc.onclose=()=>{a.close()},this.dc.onerror=o=>{a.error(o)},this.dc.onmessage=o=>{a.enqueue(o.data)}}})}_close(){this.dc.close()}_send(a){this.dc.send(a)}}class Fi extends xe.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")}}class Oi extends be{constructor(){super(...arguments),this.webrtc=new RTCPeerConnection(this.options.rtcConfig),this.streams=new Map,this.videoTransceiver=new Array,this.audioTransceiver=new Array}async _connect(){const a=await this.webrtc.createOffer();await this.webrtc.setLocalDescription(a);const d=await(await fetch(this.url,{method:"POST",body:a.sdp,...this.options.requestInit||{}})).text();return await this.webrtc.setRemoteDescription({type:"answer",sdp:d}),this.webrtc.ontrack=({track:v,streams:T,transceiver:P})=>{if(T.length){const R=this.streams.get(T[0].id);R&&R.direction==="recvonly"&&(R.mediaStream=T[0])}},new Promise((v,T)=>{this.webrtc.onconnectionstatechange=P=>{switch(this.webrtc.connectionState){case"disconnected":this.disconnect(P);break;case"connected":v();break;case"failed":T(P)}}})}addStream(a){return this.audioTransceiver.length?(a.audioTransceiver=this.audioTransceiver.pop(),a.audioTransceiver.direction=a.direction):a.audioTransceiver=this.webrtc.addTransceiver(a.audioTrack||"audio",{direction:a.direction}),this.videoTransceiver.length?(a.videoTransceiver=this.videoTransceiver.pop(),a.videoTransceiver.direction=a.direction):a.videoTransceiver=this.webrtc.addTransceiver(a.videoTrack||"video",{direction:a.direction}),this.streams.set(a.id,a),a}deleteStream(a){const o=this.streams.get(a);o&&(delete o.mediaStream,o.audioTransceiver.direction="inactive",o.videoTransceiver.direction="inactive",this.audioTransceiver.push(o.audioTransceiver),this.videoTransceiver.push(o.videoTransceiver),this.streams.delete(a))}_close(){var a;(a=this.webrtc)==null||a.close()}}var he=(h=>(h.VideoCodecInfo="videoCodecInfo",h.VideoFrame="videoFrame",h.Error="error",h))(he||{}),pe=(h=>(h.AudioCodecInfo="audioCodecInfo",h.AudioFrame="audioFrame",h.Error="error",h))(pe||{}),Ri=Object.defineProperty,$i=Object.getOwnPropertyDescriptor,We=(h,a,o,d)=>{for(var v=d>1?void 0:d?$i(a,o):a,T=h.length-1,P;T>=0;T--)(P=h[T])&&(v=(d?P(a,o,v):P(v))||v);return d&&v&&Ri(a,o,v),v};class Ve extends U{constructor(a){super(),this.module={},this.width=0,this.height=0,this.createModule=a}initialize(){return new Promise(a=>{const o=this.module;o.print=d=>console.log(d),o.printErr=d=>console.log(`[JS] ERROR: ${d}`),o.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),o.postRun=d=>{this.decoder=new this.module.VideoDecoder(this),a()},this.createModule(o)})}configure(a){this.config=a,this.decoder.setCodec(this.config.codec,this.config.description?"avcc":"annexb",this.config.description??"")}decode(a){this.decoder.decode(a.data,a.type=="key",a.timestamp)}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 d={width:a,height:o};this.emit(he.VideoCodecInfo,d)}yuvData(a,o){if(!this.module)return;const d=this.width*this.height,v=d>>2;let T=this.module.HEAPU32[a>>2],P=this.module.HEAPU32[(a>>2)+1],R=this.module.HEAPU32[(a>>2)+2],F=this.module.HEAPU8.subarray(T,T+d),g=this.module.HEAPU8.subarray(P,P+v),w=this.module.HEAPU8.subarray(R,R+v);const m=new Uint8Array(d+v+v);m.set(F),m.set(g,d),m.set(w,d+v),this.emit(he.VideoFrame,new VideoFrame(m,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:o}))}errorInfo(a){let o={errMsg:a};this.emit(he.Error,o)}}We([W([U.INIT,"closed"],"initialized")],Ve.prototype,"initialize",1);We([W("initialized","configured")],Ve.prototype,"configure",1);We([He("configured")],Ve.prototype,"decode",1);We([W([],U.INIT)],Ve.prototype,"reset",1);We([W([],"closed")],Ve.prototype,"close",1);var Ii=Object.defineProperty,Ni=Object.getOwnPropertyDescriptor,Ge=(h,a,o,d)=>{for(var v=d>1?void 0:d?Ni(a,o):a,T=h.length-1,P;T>=0;T--)(P=h[T])&&(v=(d?P(a,o,v):P(v))||v);return d&&v&&Ii(a,o,v),v};class Ae extends U{async initialize(){this.decoder=new VideoDecoder({output:a=>{this.emit(he.VideoFrame,a)},error:a=>{this.emit(he.Error,a),this.close()}})}configure(a){this.config=a,this.decoder.configure({...a,codec:a.codec=="hevc"?"hvc1.1.6.L0.12.34.56.78.9A.BC":"avc1.420028"})}decode(a){this.decoder.state==="configured"&&this.decoder.decode(new EncodedVideoChunk(a))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){this.decoder.close()}}Ge([W([U.INIT,"closed"],"initialized")],Ae.prototype,"initialize",1);Ge([W("initialized","configured")],Ae.prototype,"configure",1);Ge([He("configured")],Ae.prototype,"decode",1);Ge([W([],U.INIT)],Ae.prototype,"reset",1);Ge([W([],"closed",{ignoreError:!0})],Ae.prototype,"close",1);var Ui=(()=>{var h=import.meta.url;return function(o){o=o||{};var o=typeof o<"u"?o:{},d,v;o.ready=new Promise(function(e,r){d=e,v=r});var T=Object.assign({},o),P="./this.program",R=typeof window=="object",F=typeof importScripts=="function",g=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",w="";function m(e){return o.locateFile?o.locateFile(e,w):w+e}var D,k,A,N,C,X;g?(F?w=require("path").dirname(w)+"/":w=__dirname+"/",X=()=>{C||(N=require("fs"),C=require("path"))},D=function(r,t){return X(),r=C.normalize(r),N.readFileSync(r,t?void 0:"utf8")},A=e=>{var r=D(e,!0);return r.buffer||(r=new Uint8Array(r)),r},k=(e,r,t)=>{X(),e=C.normalize(e),N.readFile(e,function(n,s){n?t(n):r(s.buffer)})},process.argv.length>1&&(P=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(e){if(!(e instanceof vi))throw e}),process.on("unhandledRejection",function(e){throw e}),o.inspect=function(){return"[Emscripten Module object]"}):(R||F)&&(F?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="",D=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},F&&(A=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),k=(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 J=o.print||console.log.bind(console),I=o.printErr||console.warn.bind(console);Object.assign(o,T),T=null,o.arguments&&o.arguments,o.thisProgram&&(P=o.thisProgram),o.quit&&o.quit;var ie=4,M;o.wasmBinary&&(M=o.wasmBinary),o.noExitRuntime,typeof WebAssembly!="object"&&ye("no native wasm support detected");var ne,Nr=!1;function Ur(e,r){e||ye(r)}var Lr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Pe(e,r,t){for(var n=r+t,s=r;e[s]&&!(s>=n);)++s;if(s-r>16&&e.buffer&&Lr)return Lr.decode(e.subarray(r,s));for(var u="";r<s;){var f=e[r++];if(!(f&128)){u+=String.fromCharCode(f);continue}var c=e[r++]&63;if((f&224)==192){u+=String.fromCharCode((f&31)<<6|c);continue}var l=e[r++]&63;if((f&240)==224?f=(f&15)<<12|c<<6|l:f=(f&7)<<18|c<<12|l<<6|e[r++]&63,f<65536)u+=String.fromCharCode(f);else{var p=f-65536;u+=String.fromCharCode(55296|p>>10,56320|p&1023)}}return u}function jr(e,r){return e?Pe(K,e,r):""}function lr(e,r,t,n){if(!(n>0))return 0;for(var s=t,u=t+n-1,f=0;f<e.length;++f){var c=e.charCodeAt(f);if(c>=55296&&c<=57343){var l=e.charCodeAt(++f);c=65536+((c&1023)<<10)|l&1023}if(c<=127){if(t>=u)break;r[t++]=c}else if(c<=2047){if(t+1>=u)break;r[t++]=192|c>>6,r[t++]=128|c&63}else if(c<=65535){if(t+2>=u)break;r[t++]=224|c>>12,r[t++]=128|c>>6&63,r[t++]=128|c&63}else{if(t+3>=u)break;r[t++]=240|c>>18,r[t++]=128|c>>12&63,r[t++]=128|c>>6&63,r[t++]=128|c&63}}return r[t]=0,t-s}function yt(e,r,t){return lr(e,K,r,t)}function dr(e){for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&(n=65536+((n&1023)<<10)|e.charCodeAt(++t)&1023),n<=127?++r:n<=2047?r+=2:n<=65535?r+=3:r+=4}return r}var Mr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0;function wt(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&&Mr)return Mr.decode(K.subarray(e,t));for(var u="",f=0;!(f>=r/2);++f){var c=me[e+f*2>>1];if(c==0)break;u+=String.fromCharCode(c)}return u}function _t(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 f=e.charCodeAt(u);me[r>>1]=f,r+=2}return me[r>>1]=0,r-n}function Et(e){return e.length*2}function bt(e,r){for(var t=0,n="";!(t>=r/4);){var s=$[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}function Pt(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 f=e.charCodeAt(u);if(f>=55296&&f<=57343){var c=e.charCodeAt(++u);f=65536+((f&1023)<<10)|c&1023}if($[r>>2]=f,r+=4,r+4>s)break}return $[r>>2]=0,r-n}function Tt(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}function Ct(e,r,t){for(var n=0;n<e.length;++n)ee[r++>>0]=e.charCodeAt(n);t||(ee[r>>0]=0)}var hr,ee,K,me,Ke,$,z,xr,zr;function Dt(e){hr=e,o.HEAP8=ee=new Int8Array(e),o.HEAP16=me=new Int16Array(e),o.HEAP32=$=new Int32Array(e),o.HEAPU8=K=new Uint8Array(e),o.HEAPU16=Ke=new Uint16Array(e),o.HEAPU32=z=new Uint32Array(e),o.HEAPF32=xr=new Float32Array(e),o.HEAPF64=zr=new Float64Array(e)}o.INITIAL_MEMORY;var Hr,Br=[],Wr=[],Vr=[];function St(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)Ft(o.preRun.shift());vr(Br)}function At(){!o.noFSInit&&!i.init.initialized&&i.init(),i.ignorePermissions=!1,vr(Wr)}function kt(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)Rt(o.postRun.shift());vr(Vr)}function Ft(e){Br.unshift(e)}function Ot(e){Wr.unshift(e)}function Rt(e){Vr.unshift(e)}var ge=0,Fe=null;function zi(e){return e}function pr(e){ge++,o.monitorRunDependencies&&o.monitorRunDependencies(ge)}function Ye(e){if(ge--,o.monitorRunDependencies&&o.monitorRunDependencies(ge),ge==0&&Fe){var r=Fe;Fe=null,r()}}function ye(e){o.onAbort&&o.onAbort(e),e="Aborted("+e+")",I(e),Nr=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw v(r),r}var $t="data:application/octet-stream;base64,";function Gr(e){return e.startsWith($t)}function qr(e){return e.startsWith("file://")}var Q;o.locateFile?(Q="audiodec.wasm",Gr(Q)||(Q=m(Q))):Q=new URL("/plugin/media/assets/audiodec-28b192dd.wasm",self.location).toString();function Xr(e){try{if(e==Q&&M)return new Uint8Array(M);if(A)return A(e);throw"both async and sync fetching of the wasm failed"}catch(r){ye(r)}}function It(){if(!M&&(R||F)){if(typeof fetch=="function"&&!qr(Q))return fetch(Q,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+Q+"'";return e.arrayBuffer()}).catch(function(){return Xr(Q)});if(k)return new Promise(function(e,r){k(Q,function(t){e(new Uint8Array(t))},r)})}return Promise.resolve().then(function(){return Xr(Q)})}function Nt(){var e={a:pi};function r(f,c){var l=f.exports;o.asm=l,ne=o.asm.G,Dt(ne.buffer),Hr=o.asm.J,Ot(o.asm.H),Ye()}pr();function t(f){r(f.instance)}function n(f){return It().then(function(c){return WebAssembly.instantiate(c,e)}).then(function(c){return c}).then(f,function(c){I("failed to asynchronously prepare wasm: "+c),ye(c)})}function s(){return!M&&typeof WebAssembly.instantiateStreaming=="function"&&!Gr(Q)&&!qr(Q)&&!g&&typeof fetch=="function"?fetch(Q,{credentials:"same-origin"}).then(function(f){var c=WebAssembly.instantiateStreaming(f,e);return c.then(t,function(l){return I("wasm streaming compile failed: "+l),I("falling back to ArrayBuffer instantiation"),n(t)})}):n(t)}if(o.instantiateWasm)try{var u=o.instantiateWasm(e,r);return u}catch(f){return I("Module.instantiateWasm callback failed with error: "+f),!1}return s().catch(v),{}}var V,se;function vr(e){for(;e.length>0;){var r=e.shift();if(typeof r=="function"){r(o);continue}var t=r.func;typeof t=="number"?r.arg===void 0?Ze(t)():Ze(t)(r.arg):t(r.arg===void 0?null:r.arg)}}var Qe=[];function Ze(e){var r=Qe[e];return r||(e>=Qe.length&&(Qe.length=e+1),Qe[e]=r=Hr.get(e)),r}function Ut(e){return ur(e+24)+24}function Lt(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(r){z[this.ptr+4>>2]=r},this.get_type=function(){return z[this.ptr+4>>2]},this.set_destructor=function(r){z[this.ptr+8>>2]=r},this.get_destructor=function(){return z[this.ptr+8>>2]},this.set_refcount=function(r){$[this.ptr>>2]=r},this.set_caught=function(r){r=r?1:0,ee[this.ptr+12>>0]=r},this.get_caught=function(){return ee[this.ptr+12>>0]!=0},this.set_rethrown=function(r){r=r?1:0,ee[this.ptr+13>>0]=r},this.get_rethrown=function(){return ee[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_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var r=$[this.ptr>>2];$[this.ptr>>2]=r+1},this.release_ref=function(){var r=$[this.ptr>>2];return $[this.ptr>>2]=r-1,r===1},this.set_adjusted_ptr=function(r){z[this.ptr+16>>2]=r},this.get_adjusted_ptr=function(){return z[this.ptr+16>>2]},this.get_exception_ptr=function(){var r=pt(this.get_type());if(r)return z[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}function jt(e,r,t){var n=new Lt(e);throw n.init(r,t),e}function Mt(e){return $[lt()>>2]=e,e}var L={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=L.isAbs(e),t=e.substr(-1)==="/";return e=L.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=L.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=L.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,0);return L.normalize(e.join("/"))},join2:(e,r)=>L.normalize(e+"/"+r)};function xt(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var e=new Uint8Array(1);return function(){return crypto.getRandomValues(e),e[0]}}else if(g)try{var r=require("crypto");return function(){return r.randomBytes(1)[0]}}catch{}return function(){ye("randomDevice")}}var ae={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=L.isAbs(n)}return e=L.normalizeArray(e.split("/").filter(s=>!!s),!r).join("/"),(r?"/":"")+e||"."},relative:(e,r)=>{e=ae.resolve(e).substr(1),r=ae.resolve(r).substr(1);function t(p){for(var _=0;_<p.length&&p[_]==="";_++);for(var E=p.length-1;E>=0&&p[E]==="";E--);return _>E?[]:p.slice(_,E-_+1)}for(var n=t(e.split("/")),s=t(r.split("/")),u=Math.min(n.length,s.length),f=u,c=0;c<u;c++)if(n[c]!==s[c]){f=c;break}for(var l=[],c=f;c<n.length;c++)l.push("..");return l=l.concat(s.slice(f)),l.join("/")}},we={ttys:[],init:function(){},shutdown:function(){},register:function(e,r){we.ttys[e]={input:[],output:[],ops:r},i.registerDevice(e,we.stream_ops)},stream_ops:{open:function(e){var r=we.ttys[e.node.rdev];if(!r)throw new i.ErrnoError(43);e.tty=r,e.seekable=!1},close:function(e){e.tty.ops.flush(e.tty)},flush:function(e){e.tty.ops.flush(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,f=0;f<n;f++){var c;try{c=e.tty.ops.get_char(e.tty)}catch{throw new i.ErrnoError(29)}if(c===void 0&&u===0)throw new i.ErrnoError(6);if(c==null)break;u++,r[t+f]=c}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){if(!e.input.length){var r=null;if(g){var t=256,n=Buffer.alloc(t),s=0;try{s=N.readSync(process.stdin.fd,n,0,t,-1)}catch(u){if(u.toString().includes("EOF"))s=0;else throw u}s>0?r=n.slice(0,s).toString("utf-8"):r=null}else typeof window<"u"&&typeof window.prompt=="function"?(r=window.prompt("Input: "),r!==null&&(r+=`
  2. `)):typeof readline=="function"&&(r=readline(),r!==null&&(r+=`
  3. `));if(!r)return null;e.input=Ar(r,!0)}return e.input.shift()},put_char:function(e,r){r===null||r===10?(J(Pe(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},flush:function(e){e.output&&e.output.length>0&&(J(Pe(e.output,0)),e.output=[])}},default_tty1_ops:{put_char:function(e,r){r===null||r===10?(I(Pe(e.output,0)),e.output=[]):r!=0&&e.output.push(r)},flush:function(e){e.output&&e.output.length>0&&(I(Pe(e.output,0)),e.output=[])}}};function zt(e,r){K.fill(0,e,e+r)}function Ht(e,r){return Math.ceil(e/r)*r}function Jr(e){e=Ht(e,65536);var r=ht(65536,e);return r?(zt(r,e),r):0}var O={ops_table:null,mount:function(e){return O.createNode(null,"/",16895,0)},createNode:function(e,r,t,n){if(i.isBlkdev(t)||i.isFIFO(t))throw new i.ErrnoError(63);O.ops_table||(O.ops_table={dir:{node:{getattr:O.node_ops.getattr,setattr:O.node_ops.setattr,lookup:O.node_ops.lookup,mknod:O.node_ops.mknod,rename:O.node_ops.rename,unlink:O.node_ops.unlink,rmdir:O.node_ops.rmdir,readdir:O.node_ops.readdir,symlink:O.node_ops.symlink},stream:{llseek:O.stream_ops.llseek}},file:{node:{getattr:O.node_ops.getattr,setattr:O.node_ops.setattr},stream:{llseek:O.stream_ops.llseek,read:O.stream_ops.read,write:O.stream_ops.write,allocate:O.stream_ops.allocate,mmap:O.stream_ops.mmap,msync:O.stream_ops.msync}},link:{node:{getattr:O.node_ops.getattr,setattr:O.node_ops.setattr,readlink:O.node_ops.readlink},stream:{}},chrdev:{node:{getattr:O.node_ops.getattr,setattr:O.node_ops.setattr},stream:i.chrdev_stream_ops}});var s=i.createNode(e,r,t,n);return i.isDir(s.mode)?(s.node_ops=O.ops_table.dir.node,s.stream_ops=O.ops_table.dir.stream,s.contents={}):i.isFile(s.mode)?(s.node_ops=O.ops_table.file.node,s.stream_ops=O.ops_table.file.stream,s.usedBytes=0,s.contents=null):i.isLink(s.mode)?(s.node_ops=O.ops_table.link.node,s.stream_ops=O.ops_table.link.stream):i.isChrdev(s.mode)&&(s.node_ops=O.ops_table.chrdev.node,s.stream_ops=O.ops_table.chrdev.stream),s.timestamp=Date.now(),e&&(e.contents[r]=s,e.timestamp=s.timestamp),s},getFileDataAsTypedArray:function(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage:function(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:function(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:function(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:function(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&O.resizeFileStorage(e,r.size)},lookup:function(e,r){throw i.genericErrors[44]},mknod:function(e,r,t,n){return O.createNode(e,r,t,n)},rename:function(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:function(e,r){delete e.contents[r],e.timestamp=Date.now()},rmdir:function(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:function(e){var r=[".",".."];for(var t in e.contents)e.contents.hasOwnProperty(t)&&r.push(t);return r},symlink:function(e,r,t){var n=O.createNode(e,r,41471,0);return n.link=t,n},readlink:function(e){if(!i.isLink(e.mode))throw new i.ErrnoError(28);return e.link}},stream_ops:{read:function(e,r,t,n,s){var u=e.node.contents;if(s>=e.node.usedBytes)return 0;var f=Math.min(e.node.usedBytes-s,n);if(f>8&&u.subarray)r.set(u.subarray(s,s+f),t);else for(var c=0;c<f;c++)r[t+c]=u[s+c];return f},write:function(e,r,t,n,s,u){if(!n)return 0;var f=e.node;if(f.timestamp=Date.now(),r.subarray&&(!f.contents||f.contents.subarray)){if(u)return f.contents=r.subarray(t,t+n),f.usedBytes=n,n;if(f.usedBytes===0&&s===0)return f.contents=r.slice(t,t+n),f.usedBytes=n,n;if(s+n<=f.usedBytes)return f.contents.set(r.subarray(t,t+n),s),n}if(O.expandFileStorage(f,s+n),f.contents.subarray&&r.subarray)f.contents.set(r.subarray(t,t+n),s);else for(var c=0;c<n;c++)f.contents[s+c]=r[t+c];return f.usedBytes=Math.max(f.usedBytes,s+n),n},llseek:function(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:function(e,r,t){O.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t)},mmap:function(e,r,t,n,s){if(!i.isFile(e.node.mode))throw new i.ErrnoError(43);var u,f,c=e.node.contents;if(!(s&2)&&c.buffer===hr)f=!1,u=c.byteOffset;else{if((t>0||t+r<c.length)&&(c.subarray?c=c.subarray(t,t+r):c=Array.prototype.slice.call(c,t,t+r)),f=!0,u=Jr(r),!u)throw new i.ErrnoError(48);ee.set(c,u)}return{ptr:u,allocated:f}},msync:function(e,r,t,n,s){if(!i.isFile(e.node.mode))throw new i.ErrnoError(43);return s&2||O.stream_ops.write(e,r,0,n,t,!1),0}}};function Bt(e,r,t,n){var s=n?"":"al "+e;k(e,function(u){Ur(u,'Loading data file "'+e+'" failed (no arrayBuffer).'),r(new Uint8Array(u)),s&&Ye()},function(u){if(t)t();else throw'Loading data file "'+e+'" failed.'}),s&&pr()}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=ae.resolve(i.cwd(),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=L.normalizeArray(e.split("/").filter(E=>!!E),!1),s=i.root,u="/",f=0;f<n.length;f++){var c=f===n.length-1;if(c&&r.parent)break;if(s=i.lookupNode(s,n[f]),u=L.join2(u,n[f]),i.isMountpoint(s)&&(!c||c&&r.follow_mount)&&(s=s.mounted.root),!c||r.follow)for(var l=0;i.isLink(s.mode);){var p=i.readlink(u);u=ae.resolve(L.dirname(u),p);var _=i.lookupPath(u,{recurse_count:r.recurse_count+1});if(s=_.node,l++>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,flagModes:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},modeStringToFlags:e=>{var r=i.flagModes[e];if(typeof r>"u")throw new Error("Unknown file open mode: "+e);return r},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:(e=0,r=i.MAX_OPEN_FDS)=>{for(var t=e;t<=r;t++)if(!i.streams[t])return t;throw new i.ErrnoError(33)},getStream:e=>i.streams[e],createStream:(e,r,t)=>{i.FSStream||(i.FSStream=function(){this.shared={}},i.FSStream.prototype={},Object.defineProperties(i.FSStream.prototype,{object:{get:function(){return this.node},set:function(s){this.node=s}},isRead:{get:function(){return(this.flags&2097155)!==1}},isWrite:{get:function(){return(this.flags&2097155)!==0}},isAppend:{get:function(){return this.flags&1024}},flags:{get:function(){return this.shared.flags},set:function(s){this.shared.flags=s}},position:{get:function(){return this.shared.position},set:function(s){this.shared.position=s}}})),e=Object.assign(new i.FSStream,e);var n=i.nextfd(r,t);return e.fd=n,i.streams[n]=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&&I("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(f){return i.syncFSRequests--,r(f)}function u(f){if(f)return u.errored?void 0:(u.errored=!0,s(f));++n>=t.length&&s(null)}t.forEach(f=>{if(!f.type.syncfs)return u(null);f.type.syncfs(f,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 f=i.lookupPath(t,{follow_mount:!1});if(t=f.path,u=f.node,i.isMountpoint(u))throw new i.ErrnoError(10);if(!i.isDir(u.mode))throw new i.ErrnoError(54)}var c={type:e,opts:r,mountpoint:t,mounts:[]},l=e.mount(c);return l.mount=c,c.root=l,n?i.root=l:u&&(u.mounted=c,u.mount&&u.mount.mounts.push(c)),l},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(f=>{for(var c=i.nameTable[f];c;){var l=c.name_next;s.includes(c.mount)&&i.destroyNode(c),c=l}}),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=L.basename(e);if(!u||u==="."||u==="..")throw new i.ErrnoError(28);var f=i.mayCreate(s,u);if(f)throw new i.ErrnoError(f);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(!ae.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=L.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=L.dirname(e),n=L.dirname(r),s=L.basename(e),u=L.basename(r),f,c,l;if(f=i.lookupPath(e,{parent:!0}),c=f.node,f=i.lookupPath(r,{parent:!0}),l=f.node,!c||!l)throw new i.ErrnoError(44);if(c.mount!==l.mount)throw new i.ErrnoError(75);var p=i.lookupNode(c,s),_=ae.relative(e,n);if(_.charAt(0)!==".")throw new i.ErrnoError(28);if(_=ae.relative(r,t),_.charAt(0)!==".")throw new i.ErrnoError(55);var E;try{E=i.lookupNode(l,u)}catch{}if(p!==E){var y=i.isDir(p.mode),b=i.mayDelete(c,s,y);if(b)throw new i.ErrnoError(b);if(b=E?i.mayDelete(l,u,y):i.mayCreate(l,u),b)throw new i.ErrnoError(b);if(!c.node_ops.rename)throw new i.ErrnoError(63);if(i.isMountpoint(p)||E&&i.isMountpoint(E))throw new i.ErrnoError(10);if(l!==c&&(b=i.nodePermissions(c,"w"),b))throw new i.ErrnoError(b);i.hashRemoveNode(p);try{c.node_ops.rename(p,l,u)}catch(S){throw S}finally{i.hashAddNode(p)}}},rmdir:e=>{var r=i.lookupPath(e,{parent:!0}),t=r.node,n=L.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=L.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 ae.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.getStream(e);if(!t)throw new i.ErrnoError(8);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.getStream(e);if(!n)throw new i.ErrnoError(8);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.getStream(e);if(!t)throw new i.ErrnoError(8);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"?i.modeStringToFlags(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=L.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 f=i.mayOpen(n,r);if(f)throw new i.ErrnoError(f)}r&512&&!u&&i.truncate(n,0),r&=-131713;var c=i.createStream({node:n,path:i.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return c.stream_ops.open&&c.stream_ops.open(c),o.logReadFiles&&!(r&1)&&(i.readFiles||(i.readFiles={}),e in i.readFiles||(i.readFiles[e]=1)),c},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 f=e.stream_ops.read(e,r,t,n,s);return u||(e.position+=f),f},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 f=typeof s<"u";if(!f)s=e.position;else if(!e.seekable)throw new i.ErrnoError(70);var c=e.stream_ops.write(e,r,t,n,s,u);return f||(e.position+=c),c},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||!e.stream_ops.msync?0:e.stream_ops.msync(e,r,t,n,s),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,f=new Uint8Array(u);return i.read(n,f,0,u,0),r.encoding==="utf8"?t=Pe(f,0):r.encoding==="binary"&&(t=f),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(dr(r)+1),u=lr(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:(r,t,n,s,u)=>s}),i.mkdev("/dev/null",i.makedev(1,3)),we.register(i.makedev(5,0),we.default_tty_ops),we.register(i.makedev(6,0),we.default_tty1_ops),i.mkdev("/dev/tty",i.makedev(5,0)),i.mkdev("/dev/tty1",i.makedev(6,0));var e=xt();i.createDevice("/dev","random",e),i.createDevice("/dev","urandom",e),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.getStream(s);if(!u)throw new i.ErrnoError(8);var f={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>u.path}};return f.parent=f,f}},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.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(O,{},"/"),i.createDefaultDirectories(),i.createDefaultDevices(),i.createSpecialDirectories(),i.filesystems={MEMFS:O}},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)}},getMode:(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},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=L.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 f=L.join2(e,u);try{i.mkdir(f)}catch{}e=f}}return f},createFile:(e,r,t,n,s)=>{var u=L.join2(typeof e=="string"?e:i.getPath(e),r),f=i.getMode(n,s);return i.create(u,f)},createDataFile:(e,r,t,n,s,u)=>{var f=r;e&&(e=typeof e=="string"?e:i.getPath(e),f=r?L.join2(e,r):e);var c=i.getMode(n,s),l=i.create(f,c);if(t){if(typeof t=="string"){for(var p=new Array(t.length),_=0,E=t.length;_<E;++_)p[_]=t.charCodeAt(_);t=p}i.chmod(l,c|146);var y=i.open(l,577);i.write(y,t,0,t.length,0,u),i.close(y),i.chmod(l,c)}return l},createDevice:(e,r,t,n)=>{var s=L.join2(typeof e=="string"?e:i.getPath(e),r),u=i.getMode(!!t,!!n);i.createDevice.major||(i.createDevice.major=64);var f=i.makedev(i.createDevice.major++,0);return i.registerDevice(f,{open:c=>{c.seekable=!1},close:c=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(c,l,p,_,E)=>{for(var y=0,b=0;b<_;b++){var S;try{S=t()}catch{throw new i.ErrnoError(29)}if(S===void 0&&y===0)throw new i.ErrnoError(6);if(S==null)break;y++,l[p+b]=S}return y&&(c.node.timestamp=Date.now()),y},write:(c,l,p,_,E)=>{for(var y=0;y<_;y++)try{n(l[p+y])}catch{throw new i.ErrnoError(29)}return _&&(c.node.timestamp=Date.now()),y}}),i.mkdev(s,u,f)},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(D)try{e.contents=Ar(D(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(b){if(!(b>this.length-1||b<0)){var S=b%this.chunkSize,x=b/this.chunkSize|0;return this.getter(x)[S]}},u.prototype.setDataGetter=function(b){this.getter=b},u.prototype.cacheLength=function(){var b=new XMLHttpRequest;if(b.open("HEAD",t,!1),b.send(null),!(b.status>=200&&b.status<300||b.status===304))throw new Error("Couldn't load "+t+". Status: "+b.status);var S=Number(b.getResponseHeader("Content-length")),x,H=(x=b.getResponseHeader("Accept-Ranges"))&&x==="bytes",G=(x=b.getResponseHeader("Content-Encoding"))&&x==="gzip",Z=1024*1024;H||(Z=S);var q=(te,le)=>{if(te>le)throw new Error("invalid range ("+te+", "+le+") or no bytes requested!");if(le>S-1)throw new Error("only "+S+" bytes available! programmer error!");var B=new XMLHttpRequest;if(B.open("GET",t,!1),S!==Z&&B.setRequestHeader("Range","bytes="+te+"-"+le),B.responseType="arraybuffer",B.overrideMimeType&&B.overrideMimeType("text/plain; charset=x-user-defined"),B.send(null),!(B.status>=200&&B.status<300||B.status===304))throw new Error("Couldn't load "+t+". Status: "+B.status);return B.response!==void 0?new Uint8Array(B.response||[]):Ar(B.responseText||"",!0)},Ee=this;Ee.setDataGetter(te=>{var le=te*Z,B=(te+1)*Z-1;if(B=Math.min(B,S-1),typeof Ee.chunks[te]>"u"&&(Ee.chunks[te]=q(le,B)),typeof Ee.chunks[te]>"u")throw new Error("doXHR failed!");return Ee.chunks[te]}),(G||!S)&&(Z=S=1,S=this.getter(0).length,Z=S,J("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=S,this._chunkSize=Z,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){if(!F)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var f=new u;Object.defineProperties(f,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var c={isDevice:!1,contents:f}}else var c={isDevice:!1,url:t};var l=i.createFile(e,r,c,n,s);c.contents?l.contents=c.contents:c.url&&(l.contents=null,l.url=c.url),Object.defineProperties(l,{usedBytes:{get:function(){return this.contents.length}}});var p={},_=Object.keys(l.stream_ops);_.forEach(y=>{var b=l.stream_ops[y];p[y]=function(){return i.forceLoadFile(l),b.apply(null,arguments)}});function E(y,b,S,x,H){var G=y.node.contents;if(H>=G.length)return 0;var Z=Math.min(G.length-H,x);if(G.slice)for(var q=0;q<Z;q++)b[S+q]=G[H+q];else for(var q=0;q<Z;q++)b[S+q]=G.get(H+q);return Z}return p.read=(y,b,S,x,H)=>(i.forceLoadFile(l),E(y,b,S,x,H)),p.mmap=(y,b,S,x,H)=>{i.forceLoadFile(l);var G=Jr(b);if(!G)throw new i.ErrnoError(48);return E(y,ee,G,b,S),{ptr:G,allocated:!0}},l.stream_ops=p,l},createPreloadedFile:(e,r,t,n,s,u,f,c,l,p)=>{var _=r?ae.resolve(L.join2(e,r)):e;function E(y){function b(S){p&&p(),c||i.createDataFile(e,r,S,n,s,l),u&&u(),Ye()}Browser.handledByPreloadPlugin(y,_,b,()=>{f&&f(),Ye()})||b(y)}pr(),typeof t=="string"?Bt(t,y=>E(y),f):E(t)},indexedDB:()=>window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,DB_NAME:()=>"EM_FS_"+window.location.pathname,DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:(e,r,t)=>{r=r||(()=>{}),t=t||(()=>{});var n=i.indexedDB();try{var s=n.open(i.DB_NAME(),i.DB_VERSION)}catch(u){return t(u)}s.onupgradeneeded=()=>{J("creating db");var u=s.result;u.createObjectStore(i.DB_STORE_NAME)},s.onsuccess=()=>{var u=s.result,f=u.transaction([i.DB_STORE_NAME],"readwrite"),c=f.objectStore(i.DB_STORE_NAME),l=0,p=0,_=e.length;function E(){p==0?r():t()}e.forEach(y=>{var b=c.put(i.analyzePath(y).object.contents,y);b.onsuccess=()=>{l++,l+p==_&&E()},b.onerror=()=>{p++,l+p==_&&E()}}),f.onerror=t},s.onerror=t},loadFilesFromDB:(e,r,t)=>{r=r||(()=>{}),t=t||(()=>{});var n=i.indexedDB();try{var s=n.open(i.DB_NAME(),i.DB_VERSION)}catch(u){return t(u)}s.onupgradeneeded=t,s.onsuccess=()=>{var u=s.result;try{var f=u.transaction([i.DB_STORE_NAME],"readonly")}catch(y){t(y);return}var c=f.objectStore(i.DB_STORE_NAME),l=0,p=0,_=e.length;function E(){p==0?r():t()}e.forEach(y=>{var b=c.get(y);b.onsuccess=()=>{i.analyzePath(y).exists&&i.unlink(y),i.createDataFile(L.dirname(y),L.basename(y),b.result,!0,!0,!0),l++,l+p==_&&E()},b.onerror=()=>{p++,l+p==_&&E()}}),f.onerror=t},s.onerror=t}},Y={DEFAULT_POLLMASK:5,calculateAt:function(e,r,t){if(L.isAbs(r))return r;var n;if(e===-100)n=i.cwd();else{var s=i.getStream(e);if(!s)throw new i.ErrnoError(8);n=s.path}if(r.length==0){if(!t)throw new i.ErrnoError(44);return n}return L.join2(n,r)},doStat:function(e,r,t){try{var n=e(r)}catch(s){if(s&&s.node&&L.normalize(r)!==L.normalize(i.getPath(s.node)))return-54;throw s}return $[t>>2]=n.dev,$[t+4>>2]=0,$[t+8>>2]=n.ino,$[t+12>>2]=n.mode,$[t+16>>2]=n.nlink,$[t+20>>2]=n.uid,$[t+24>>2]=n.gid,$[t+28>>2]=n.rdev,$[t+32>>2]=0,se=[n.size>>>0,(V=n.size,+Math.abs(V)>=1?V>0?(Math.min(+Math.floor(V/4294967296),4294967295)|0)>>>0:~~+Math.ceil((V-+(~~V>>>0))/4294967296)>>>0:0)],$[t+40>>2]=se[0],$[t+44>>2]=se[1],$[t+48>>2]=4096,$[t+52>>2]=n.blocks,$[t+56>>2]=n.atime.getTime()/1e3|0,$[t+60>>2]=0,$[t+64>>2]=n.mtime.getTime()/1e3|0,$[t+68>>2]=0,$[t+72>>2]=n.ctime.getTime()/1e3|0,$[t+76>>2]=0,se=[n.ino>>>0,(V=n.ino,+Math.abs(V)>=1?V>0?(Math.min(+Math.floor(V/4294967296),4294967295)|0)>>>0:~~+Math.ceil((V-+(~~V>>>0))/4294967296)>>>0:0)],$[t+80>>2]=se[0],$[t+84>>2]=se[1],0},doMsync:function(e,r,t,n,s){var u=K.slice(e,e+t);i.msync(r,u,s,t,n)},varargs:void 0,get:function(){Y.varargs+=4;var e=$[Y.varargs-4>>2];return e},getStr:function(e){var r=jr(e);return r},getStreamFromFD:function(e){var r=i.getStream(e);if(!r)throw new i.ErrnoError(8);return r}};function Wt(e,r,t){Y.varargs=t;try{var n=Y.getStreamFromFD(e);switch(r){case 0:{var s=Y.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=Y.get();return n.flags|=s,0}case 5:{var s=Y.get(),f=0;return me[s+f>>1]=2,0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:return Mt(28),-1;default:return-28}}catch(c){if(typeof i>"u"||!(c instanceof i.ErrnoError))throw c;return-c.errno}}function Vt(e,r,t,n){Y.varargs=n;try{r=Y.getStr(r),r=Y.calculateAt(e,r);var s=n?Y.get():0;return i.open(r,t,s).fd}catch(u){if(typeof i>"u"||!(u instanceof i.ErrnoError))throw u;return-u.errno}}function Gt(e,r,t,n,s){}function mr(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 qt(){for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);Kr=e}var Kr=void 0;function re(e){for(var r="",t=e;K[t];)r+=Kr[K[t++]];return r}var Te={},_e={},er={},Xt=48,Jt=57;function rr(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=Xt&&r<=Jt?"_"+e:e}function gr(e,r){return e=rr(e),new Function("body","return function "+e+`() {
  4. "use strict"; return body.apply(this, arguments);
  5. };
  6. `)(r)}function yr(e,r){var t=gr(r,function(n){this.name=r,this.message=n;var s=new Error(n).stack;s!==void 0&&(this.stack=this.toString()+`
  7. `+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 Ce=void 0;function j(e){throw new Ce(e)}var Yr=void 0;function tr(e){throw new Yr(e)}function Oe(e,r,t){e.forEach(function(c){er[c]=r});function n(c){var l=t(c);l.length!==e.length&&tr("Mismatched type converter count");for(var p=0;p<e.length;++p)ue(e[p],l[p])}var s=new Array(r.length),u=[],f=0;r.forEach((c,l)=>{_e.hasOwnProperty(c)?s[l]=_e[c]:(u.push(c),Te.hasOwnProperty(c)||(Te[c]=[]),Te[c].push(()=>{s[l]=_e[c],++f,f===u.length&&n(s)}))}),u.length===0&&n(s)}function ue(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");var n=r.name;if(e||j('type "'+n+'" must have a positive integer typeid pointer'),_e.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;j("Cannot register type '"+n+"' twice")}if(_e[e]=r,delete er[e],Te.hasOwnProperty(e)){var s=Te[e];delete Te[e],s.forEach(u=>u())}}function Kt(e,r,t,n,s){var u=mr(t);r=re(r),ue(e,{name:r,fromWireType:function(f){return!!f},toWireType:function(f,c){return c?n:s},argPackAdvance:8,readValueFromPointer:function(f){var c;if(t===1)c=ee;else if(t===2)c=me;else if(t===4)c=$;else throw new TypeError("Unknown boolean type size: "+r);return this.fromWireType(c[f>>u])},destructorFunction:null})}function Yt(e){if(!(this instanceof de)||!(e instanceof de))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 Qt(e){return{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}}function wr(e){function r(t){return t.$$.ptrType.registeredClass.name}j(r(e)+" instance already deleted")}var _r=!1;function Qr(e){}function Zt(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}function Zr(e){e.count.value-=1;var r=e.count.value===0;r&&Zt(e)}function et(e,r,t){if(r===t)return e;if(t.baseClass===void 0)return null;var n=et(e,r,t.baseClass);return n===null?null:t.downcast(n)}var rt={};function en(){return Object.keys(Ie).length}function rn(){var e=[];for(var r in Ie)Ie.hasOwnProperty(r)&&e.push(Ie[r]);return e}var Re=[];function Er(){for(;Re.length;){var e=Re.pop();e.$$.deleteScheduled=!1,e.delete()}}var $e=void 0;function tn(e){$e=e,Re.length&&$e&&$e(Er)}function nn(){o.getInheritedInstanceCount=en,o.getLiveInheritedInstances=rn,o.flushPendingDeletes=Er,o.setDelayFunction=tn}var Ie={};function on(e,r){for(r===void 0&&j("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r}function sn(e,r){return r=on(e,r),Ie[r]}function nr(e,r){(!r.ptrType||!r.ptr)&&tr("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&tr("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Ne(Object.create(e,{$$:{value:r}}))}function an(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=sn(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?nr(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):nr(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var u=this.registeredClass.getActualType(r),f=rt[u];if(!f)return s.call(this);var c;this.isConst?c=f.constPointerType:c=f.pointerType;var l=et(r,this.registeredClass,c.registeredClass);return l===null?s.call(this):this.isSmartPointer?nr(c.registeredClass.instancePrototype,{ptrType:c,ptr:l,smartPtrType:this,smartPtr:e}):nr(c.registeredClass.instancePrototype,{ptrType:c,ptr:l})}function Ne(e){return typeof FinalizationRegistry>"u"?(Ne=r=>r,e):(_r=new FinalizationRegistry(r=>{Zr(r.$$)}),Ne=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var s={$$:t};_r.register(r,s,r)}return r},Qr=r=>_r.unregister(r),Ne(e))}function un(){if(this.$$.ptr||wr(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=Ne(Object.create(Object.getPrototypeOf(this),{$$:{value:Qt(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e}function cn(){this.$$.ptr||wr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&j("Object already scheduled for deletion"),Qr(this),Zr(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function fn(){return!this.$$.ptr}function ln(){return this.$$.ptr||wr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&j("Object already scheduled for deletion"),Re.push(this),Re.length===1&&$e&&$e(Er),this.$$.deleteScheduled=!0,this}function dn(){de.prototype.isAliasOf=Yt,de.prototype.clone=un,de.prototype.delete=cn,de.prototype.isDeleted=fn,de.prototype.deleteLater=ln}function de(){}function tt(e,r,t){if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(){return e[r].overloadTable.hasOwnProperty(arguments.length)||j("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 hn(e,r,t){o.hasOwnProperty(e)?((t===void 0||o[e].overloadTable!==void 0&&o[e].overloadTable[t]!==void 0)&&j("Cannot register public name '"+e+"' twice"),tt(o,e,e),o.hasOwnProperty(t)&&j("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 pn(e,r,t,n,s,u,f,c){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=s,this.getActualType=u,this.upcast=f,this.downcast=c,this.pureVirtualFunctions=[]}function br(e,r,t){for(;r!==t;)r.upcast||j("Expected null or instance of "+t.name+", got an instance of "+r.name),e=r.upcast(e),r=r.baseClass;return e}function vn(e,r){if(r===null)return this.isReference&&j("null is not a valid "+this.name),0;r.$$||j('Cannot pass "'+Cr(r)+'" as a '+this.name),r.$$.ptr||j("Cannot pass deleted object as a pointer of type "+this.name);var t=r.$$.ptrType.registeredClass,n=br(r.$$.ptr,t,this.registeredClass);return n}function mn(e,r){var t;if(r===null)return this.isReference&&j("null is not a valid "+this.name),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;r.$$||j('Cannot pass "'+Cr(r)+'" as a '+this.name),r.$$.ptr||j("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&r.$$.ptrType.isConst&&j("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=br(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&j("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:j("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,or.toHandle(function(){s.delete()})),e!==null&&e.push(this.rawDestructor,t)}break;default:j("Unsupporting sharing policy")}return t}function gn(e,r){if(r===null)return this.isReference&&j("null is not a valid "+this.name),0;r.$$||j('Cannot pass "'+Cr(r)+'" as a '+this.name),r.$$.ptr||j("Cannot pass deleted object as a pointer of type "+this.name),r.$$.ptrType.isConst&&j("Cannot convert argument of type "+r.$$.ptrType.name+" to parameter type "+this.name);var t=r.$$.ptrType.registeredClass,n=br(r.$$.ptr,t,this.registeredClass);return n}function ir(e){return this.fromWireType(z[e>>2])}function yn(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function wn(e){this.rawDestructor&&this.rawDestructor(e)}function _n(e){e!==null&&e.delete()}function En(){ce.prototype.getPointee=yn,ce.prototype.destructor=wn,ce.prototype.argPackAdvance=8,ce.prototype.readValueFromPointer=ir,ce.prototype.deleteObject=_n,ce.prototype.fromWireType=an}function ce(e,r,t,n,s,u,f,c,l,p,_){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=s,this.pointeeType=u,this.sharingPolicy=f,this.rawGetPointee=c,this.rawConstructor=l,this.rawShare=p,this.rawDestructor=_,!s&&r.baseClass===void 0?n?(this.toWireType=vn,this.destructorFunction=null):(this.toWireType=gn,this.destructorFunction=null):this.toWireType=mn}function bn(e,r,t){o.hasOwnProperty(e)||tr("Replacing nonexistant public symbol"),o[e].overloadTable!==void 0&&t!==void 0?o[e].overloadTable[t]=r:(o[e]=r,o[e].argCount=t)}function Pn(e,r,t){var n=o["dynCall_"+e];return t&&t.length?n.apply(null,[r].concat(t)):n.call(null,r)}function Tn(e,r,t){return e.includes("j")?Pn(e,r,t):Ze(r).apply(null,t)}function Cn(e,r){var t=[];return function(){return t.length=0,Object.assign(t,arguments),Tn(e,r,t)}}function De(e,r){e=re(e);function t(){return e.includes("j")?Cn(e,r):Ze(r)}var n=t();return typeof n!="function"&&j("unknown function pointer with signature "+e+": "+r),n}var nt=void 0;function it(e){var r=dt(e),t=re(r);return fe(r),t}function Pr(e,r){var t=[],n={};function s(u){if(!n[u]&&!_e[u]){if(er[u]){er[u].forEach(s);return}t.push(u),n[u]=!0}}throw r.forEach(s),new nt(e+": "+t.map(it).join([", "]))}function Dn(e,r,t,n,s,u,f,c,l,p,_,E,y){_=re(_),u=De(s,u),c&&(c=De(f,c)),p&&(p=De(l,p)),y=De(E,y);var b=rr(_);hn(b,function(){Pr("Cannot construct "+_+" due to unbound types",[n])}),Oe([e,r,t],n?[n]:[],function(S){S=S[0];var x,H;n?(x=S.registeredClass,H=x.instancePrototype):H=de.prototype;var G=gr(b,function(){if(Object.getPrototypeOf(this)!==Z)throw new Ce("Use 'new' to construct "+_);if(q.constructor_body===void 0)throw new Ce(_+" has no accessible constructor");var B=q.constructor_body[arguments.length];if(B===void 0)throw new Ce("Tried to invoke ctor of "+_+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(q.constructor_body).toString()+") parameters instead!");return B.apply(this,arguments)}),Z=Object.create(H,{constructor:{value:G}});G.prototype=Z;var q=new pn(_,G,Z,y,x,u,c,p),Ee=new ce(_,q,!0,!1,!1),te=new ce(_+"*",q,!1,!1,!1),le=new ce(_+" const*",q,!1,!0,!1);return rt[e]={pointerType:te,constPointerType:le},bn(b,G),[Ee,te,le]})}function ot(e,r){for(var t=[],n=0;n<e;n++)t.push($[(r>>2)+n]);return t}function Sn(e){for(;e.length;){var r=e.pop(),t=e.pop();t(r)}}function st(e,r){if(!(e instanceof Function))throw new TypeError("new_ called with constructor type "+typeof e+" which is not a function");var t=gr(e.name||"unknownFunctionName",function(){});t.prototype=e.prototype;var n=new t,s=e.apply(n,r);return s instanceof Object?s:n}function at(e,r,t,n,s){var u=r.length;u<2&&j("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var f=r[1]!==null&&t!==null,c=!1,l=1;l<r.length;++l)if(r[l]!==null&&r[l].destructorFunction===void 0){c=!0;break}for(var p=r[0].name!=="void",_="",E="",l=0;l<u-2;++l)_+=(l!==0?", ":"")+"arg"+l,E+=(l!==0?", ":"")+"arg"+l+"Wired";var y="return function "+rr(e)+"("+_+`) {
  8. if (arguments.length !== `+(u-2)+`) {
  9. throwBindingError('function `+e+" called with ' + arguments.length + ' arguments, expected "+(u-2)+` args!');
  10. }
  11. `;c&&(y+=`var destructors = [];
  12. `);var b=c?"destructors":"null",S=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],x=[j,n,s,Sn,r[0],r[1]];f&&(y+="var thisWired = classParam.toWireType("+b+`, this);
  13. `);for(var l=0;l<u-2;++l)y+="var arg"+l+"Wired = argType"+l+".toWireType("+b+", arg"+l+"); // "+r[l+2].name+`
  14. `,S.push("argType"+l),x.push(r[l+2]);if(f&&(E="thisWired"+(E.length>0?", ":"")+E),y+=(p?"var rv = ":"")+"invoker(fn"+(E.length>0?", ":"")+E+`);
  15. `,c)y+=`runDestructors(destructors);
  16. `;else for(var l=f?1:2;l<r.length;++l){var H=l===1?"thisWired":"arg"+(l-2)+"Wired";r[l].destructorFunction!==null&&(y+=H+"_dtor("+H+"); // "+r[l].name+`
  17. `,S.push(H+"_dtor"),x.push(r[l].destructorFunction))}p&&(y+=`var ret = retType.fromWireType(rv);
  18. return ret;
  19. `),y+=`}
  20. `,S.push(y);var G=st(Function,S).apply(null,x);return G}function An(e,r,t,n,s,u){Ur(r>0);var f=ot(r,t);s=De(n,s),Oe([],[e],function(c){c=c[0];var l="constructor "+c.name;if(c.registeredClass.constructor_body===void 0&&(c.registeredClass.constructor_body=[]),c.registeredClass.constructor_body[r-1]!==void 0)throw new Ce("Cannot register multiple constructors with identical number of parameters ("+(r-1)+") for class '"+c.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return c.registeredClass.constructor_body[r-1]=()=>{Pr("Cannot construct "+c.name+" due to unbound types",f)},Oe([],f,function(p){return p.splice(1,0,null),c.registeredClass.constructor_body[r-1]=at(l,p,null,s,u),[]}),[]})}function kn(e,r,t,n,s,u,f,c){var l=ot(t,n);r=re(r),u=De(s,u),Oe([],[e],function(p){p=p[0];var _=p.name+"."+r;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),c&&p.registeredClass.pureVirtualFunctions.push(r);function E(){Pr("Cannot call "+_+" due to unbound types",l)}var y=p.registeredClass.instancePrototype,b=y[r];return b===void 0||b.overloadTable===void 0&&b.className!==p.name&&b.argCount===t-2?(E.argCount=t-2,E.className=p.name,y[r]=E):(tt(y,r,_),y[r].overloadTable[t-2]=E),Oe([],l,function(S){var x=at(_,S,p,u,f);return y[r].overloadTable===void 0?(x.argCount=t-2,y[r]=x):y[r].overloadTable[t-2]=x,[]}),[]})}var Tr=[],oe=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function ut(e){e>4&&--oe[e].refcount===0&&(oe[e]=void 0,Tr.push(e))}function Fn(){for(var e=0,r=5;r<oe.length;++r)oe[r]!==void 0&&++e;return e}function On(){for(var e=5;e<oe.length;++e)if(oe[e]!==void 0)return oe[e];return null}function Rn(){o.count_emval_handles=Fn,o.get_first_emval=On}var or={toValue:e=>(e||j("Cannot use deleted val. handle = "+e),oe[e].value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:{var r=Tr.length?Tr.pop():oe.length;return oe[r]={refcount:1,value:e},r}}}};function $n(e,r){r=re(r),ue(e,{name:r,fromWireType:function(t){var n=or.toValue(t);return ut(t),n},toWireType:function(t,n){return or.toHandle(n)},argPackAdvance:8,readValueFromPointer:ir,destructorFunction:null})}function Cr(e){if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e}function In(e,r){switch(r){case 2:return function(t){return this.fromWireType(xr[t>>2])};case 3:return function(t){return this.fromWireType(zr[t>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Nn(e,r,t){var n=mr(t);r=re(r),ue(e,{name:r,fromWireType:function(s){return s},toWireType:function(s,u){return u},argPackAdvance:8,readValueFromPointer:In(r,n),destructorFunction:null})}function Un(e,r,t){switch(r){case 0:return t?function(s){return ee[s]}:function(s){return K[s]};case 1:return t?function(s){return me[s>>1]}:function(s){return Ke[s>>1]};case 2:return t?function(s){return $[s>>2]}:function(s){return z[s>>2]};default:throw new TypeError("Unknown integer type: "+e)}}function Ln(e,r,t,n,s){r=re(r);var u=mr(t),f=E=>E;if(n===0){var c=32-8*t;f=E=>E<<c>>>c}var l=r.includes("unsigned"),p=(E,y)=>{},_;l?_=function(E,y){return p(y,this.name),y>>>0}:_=function(E,y){return p(y,this.name),y},ue(e,{name:r,fromWireType:f,toWireType:_,argPackAdvance:8,readValueFromPointer:Un(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(f){f=f>>2;var c=z,l=c[f],p=c[f+1];return new s(hr,p,l)}t=re(t),ue(e,{name:t,fromWireType:u,argPackAdvance:8,readValueFromPointer:u},{ignoreDuplicateRegistrations:!0})}function Mn(e,r){r=re(r);var t=r==="std::string";ue(e,{name:r,fromWireType:function(n){var s=z[n>>2],u;if(t)for(var f=n+4,c=0;c<=s;++c){var l=n+4+c;if(c==s||K[l]==0){var p=l-f,_=jr(f,p);u===void 0?u=_:(u+=String.fromCharCode(0),u+=_),f=l+1}}else{for(var E=new Array(s),c=0;c<s;++c)E[c]=String.fromCharCode(K[n+4+c]);u=E.join("")}return fe(n),u},toWireType:function(n,s){s instanceof ArrayBuffer&&(s=new Uint8Array(s));var u,f=typeof s=="string";f||s instanceof Uint8Array||s instanceof Uint8ClampedArray||s instanceof Int8Array||j("Cannot pass non-string to std::string"),t&&f?u=()=>dr(s):u=()=>s.length;var c=u(),l=ur(4+c+1);if(z[l>>2]=c,t&&f)yt(s,l+4,c+1);else if(f)for(var p=0;p<c;++p){var _=s.charCodeAt(p);_>255&&(fe(l),j("String has UTF-16 code units that do not fit in 8 bits")),K[l+4+p]=_}else for(var p=0;p<c;++p)K[l+4+p]=s[p];return n!==null&&n.push(fe,l),l},argPackAdvance:8,readValueFromPointer:ir,destructorFunction:function(n){fe(n)}})}function xn(e,r,t){t=re(t);var n,s,u,f,c;r===2?(n=wt,s=_t,f=Et,u=()=>Ke,c=1):r===4&&(n=bt,s=Pt,f=Tt,u=()=>z,c=2),ue(e,{name:t,fromWireType:function(l){for(var p=z[l>>2],_=u(),E,y=l+4,b=0;b<=p;++b){var S=l+4+b*r;if(b==p||_[S>>c]==0){var x=S-y,H=n(y,x);E===void 0?E=H:(E+=String.fromCharCode(0),E+=H),y=S+r}}return fe(l),E},toWireType:function(l,p){typeof p!="string"&&j("Cannot pass non-string to C++ string type "+t);var _=f(p),E=ur(4+_+r);return z[E>>2]=_>>c,s(p,E+4,_+r),l!==null&&l.push(fe,E),E},argPackAdvance:8,readValueFromPointer:ir,destructorFunction:function(l){fe(l)}})}function zn(e,r){r=re(r),ue(e,{isVoid:!0,name:r,argPackAdvance:0,fromWireType:function(){},toWireType:function(t,n){}})}function Hn(){return Date.now()}var Bn={};function Wn(e){var r=Bn[e];return r===void 0?re(e):r}var Dr=[];function Vn(e,r,t,n){e=Dr[e],r=or.toValue(r),t=Wn(t),e(r,t,null,n)}function Gn(e){var r=Dr.length;return Dr.push(e),r}function qn(e,r){var t=_e[e];return t===void 0&&j(r+" has unknown type "+it(e)),t}function Xn(e,r){for(var t=new Array(e),n=0;n<e;++n)t[n]=qn(z[r+n*ie>>2],"parameter "+n);return t}var ct=[];function Jn(e,r){var t=Xn(e,r),n=t[0],s=n.name+"_$"+t.slice(1).map(function(S){return S.name}).join("_")+"$",u=ct[s];if(u!==void 0)return u;for(var f=["retType"],c=[n],l="",p=0;p<e-1;++p)l+=(p!==0?", ":"")+"arg"+p,f.push("argType"+p),c.push(t[1+p]);for(var _=rr("methodCaller_"+s),E="return function "+_+`(handle, name, destructors, args) {
  21. `,y=0,p=0;p<e-1;++p)E+=" var arg"+p+" = argType"+p+".readValueFromPointer(args"+(y?"+"+y:"")+`);
  22. `,y+=t[p+1].argPackAdvance;E+=" var rv = handle[name]("+l+`);
  23. `;for(var p=0;p<e-1;++p)t[p+1].deleteObject&&(E+=" argType"+p+".deleteObject(arg"+p+`);
  24. `);n.isVoid||(E+=` return retType.toWireType(destructors, rv);
  25. `),E+=`};
  26. `,f.push(E);var b=st(Function,f).apply(null,c);return u=Gn(b),ct[s]=u,u}function Kn(){ye("")}function Yn(){return K.length}function Qn(){return Yn()}function Zn(e,r,t){K.copyWithin(e,r,r+t)}function ei(e){ye("OOM")}function ri(e){K.length,ei()}var Sr={};function ti(){return P||"./this.program"}function Ue(){if(!Ue.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,_:ti()};for(var t in Sr)Sr[t]===void 0?delete r[t]:r[t]=Sr[t];var n=[];for(var t in r)n.push(t+"="+r[t]);Ue.strings=n}return Ue.strings}function ni(e,r){var t=0;return Ue().forEach(function(n,s){var u=r+t;z[e+s*4>>2]=u,Ct(n,u),t+=n.length+1}),0}function ii(e,r){var t=Ue();z[e>>2]=t.length;var n=0;return t.forEach(function(s){n+=s.length+1}),z[r>>2]=n,0}function oi(e){try{var r=Y.getStreamFromFD(e);return i.close(r),0}catch(t){if(typeof i>"u"||!(t instanceof i.ErrnoError))throw t;return t.errno}}function si(e,r){try{var t=Y.getStreamFromFD(e),n=t.tty?2:i.isDir(t.mode)?3:i.isLink(t.mode)?7:4;return ee[r>>0]=n,0}catch(s){if(typeof i>"u"||!(s instanceof i.ErrnoError))throw s;return s.errno}}function ai(e,r,t,n){for(var s=0,u=0;u<t;u++){var f=z[r>>2],c=z[r+4>>2];r+=8;var l=i.read(e,ee,f,c,n);if(l<0)return-1;if(s+=l,l<c)break}return s}function ui(e,r,t,n){try{var s=Y.getStreamFromFD(e),u=ai(s,r,t);return $[n>>2]=u,0}catch(f){if(typeof i>"u"||!(f instanceof i.ErrnoError))throw f;return f.errno}}function ci(e,r){return r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN}function fi(e,r,t,n,s){try{var u=ci(r,t);if(isNaN(u))return 61;var f=Y.getStreamFromFD(e);return i.llseek(f,u,n),se=[f.position>>>0,(V=f.position,+Math.abs(V)>=1?V>0?(Math.min(+Math.floor(V/4294967296),4294967295)|0)>>>0:~~+Math.ceil((V-+(~~V>>>0))/4294967296)>>>0:0)],$[s>>2]=se[0],$[s+4>>2]=se[1],f.getdents&&u===0&&n===0&&(f.getdents=null),0}catch(c){if(typeof i>"u"||!(c instanceof i.ErrnoError))throw c;return c.errno}}function li(e,r,t,n){for(var s=0,u=0;u<t;u++){var f=z[r>>2],c=z[r+4>>2];r+=8;var l=i.write(e,ee,f,c,n);if(l<0)return-1;s+=l}return s}function di(e,r,t,n){try{var s=Y.getStreamFromFD(e),u=li(s,r,t);return z[n>>2]=u,0}catch(f){if(typeof i>"u"||!(f instanceof i.ErrnoError))throw f;return f.errno}}function hi(e){}var ft=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},sr=365,ar=146;Object.defineProperties(ft.prototype,{read:{get:function(){return(this.mode&sr)===sr},set:function(e){e?this.mode|=sr:this.mode&=~sr}},write:{get:function(){return(this.mode&ar)===ar},set:function(e){e?this.mode|=ar:this.mode&=~ar}},isFolder:{get:function(){return i.isDir(this.mode)}},isDevice:{get:function(){return i.isChrdev(this.mode)}}}),i.FSNode=ft,i.staticInit(),qt(),Ce=o.BindingError=yr(Error,"BindingError"),Yr=o.InternalError=yr(Error,"InternalError"),dn(),nn(),En(),nt=o.UnboundTypeError=yr(Error,"UnboundTypeError"),Rn();function Ar(e,r,t){var n=t>0?t:dr(e)+1,s=new Array(n),u=lr(e,s,0,s.length);return r&&(s.length=u),s}var pi={q:Ut,p:jt,D:Wt,x:Vt,t:Gt,F:Kt,u:Dn,r:An,d:kn,E:$n,l:Nn,c:Ln,b:jn,k:Mn,g:xn,o:zn,f:Hn,i:Vn,n:ut,m:Jn,a:Kn,w:Qn,B:Zn,v:ri,z:ni,A:ii,j:oi,y:si,C:ui,s:fi,h:di,e:hi};Nt(),o.___wasm_call_ctors=function(){return(o.___wasm_call_ctors=o.asm.H).apply(null,arguments)};var ur=o._malloc=function(){return(ur=o._malloc=o.asm.I).apply(null,arguments)},fe=o._free=function(){return(fe=o._free=o.asm.K).apply(null,arguments)},lt=o.___errno_location=function(){return(lt=o.___errno_location=o.asm.L).apply(null,arguments)},dt=o.___getTypeName=function(){return(dt=o.___getTypeName=o.asm.M).apply(null,arguments)};o.___embind_register_native_and_builtin_types=function(){return(o.___embind_register_native_and_builtin_types=o.asm.N).apply(null,arguments)};var ht=o._emscripten_builtin_memalign=function(){return(ht=o._emscripten_builtin_memalign=o.asm.O).apply(null,arguments)},pt=o.___cxa_is_pointer_type=function(){return(pt=o.___cxa_is_pointer_type=o.asm.P).apply(null,arguments)};o.dynCall_viiijj=function(){return(o.dynCall_viiijj=o.asm.Q).apply(null,arguments)},o.dynCall_jij=function(){return(o.dynCall_jij=o.asm.R).apply(null,arguments)},o.dynCall_jii=function(){return(o.dynCall_jii=o.asm.S).apply(null,arguments)},o.dynCall_jiji=function(){return(o.dynCall_jiji=o.asm.T).apply(null,arguments)};var cr;function vi(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}Fe=function e(){cr||kr(),cr||(Fe=e)};function kr(e){if(ge>0||(St(),ge>0))return;function r(){cr||(cr=!0,o.calledRun=!0,!Nr&&(At(),d(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),kt()))}o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),r()},1)):r()}if(o.run=kr,o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return kr(),o.ready}})(),Li=Object.defineProperty,ji=Object.getOwnPropertyDescriptor,qe=(h,a,o,d)=>{for(var v=d>1?void 0:d?ji(a,o):a,T=h.length-1,P;T>=0;T--)(P=h[T])&&(v=(d?P(a,o,v):P(v))||v);return d&&v&&Li(a,o,v),v};class Xe extends U{constructor(){super(...arguments),this.sampleRate=0,this.channels=0}initialize(){return new Promise(a=>{const o={};o.print=d=>console.log(d),o.printErr=d=>console.log(`[JS] ERROR: ${d}`),o.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),o.postRun=d=>{this.module=d,this.decoder=new this.module.AudioDecoder(this),a()},Ui(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 d={sampleRate:a,channels:o,depth:16};this.emit(pe.AudioCodecInfo,d)}pcmData(a,o,d){if(!this.module)return;let v=[];for(let P=0;P<this.channels;P++){let R=this.module.HEAPU32[(a>>2)+P]>>2;v.push(Float32Array.of(...this.module.HEAPF32.subarray(R,R+o)))}let T={datas:v,sampleNum:o,channles:this.channels,pts:d};this.emit(pe.AudioFrame,T)}errorInfo(a){let o={errMsg:a};this.emit(pe.Error,o)}}qe([W(U.INIT,"initialized")],Xe.prototype,"initialize",1);qe([W("initialized","configured")],Xe.prototype,"configure",1);qe([He("configured")],Xe.prototype,"decode",1);qe([W("configured","initialized")],Xe.prototype,"reset",1);qe([W([],"closed")],Xe.prototype,"close",1);var Mi=Object.defineProperty,xi=Object.getOwnPropertyDescriptor,Je=(h,a,o,d)=>{for(var v=d>1?void 0:d?xi(a,o):a,T=h.length-1,P;T>=0;T--)(P=h[T])&&(v=(d?P(a,o,v):P(v))||v);return d&&v&&Mi(a,o,v),v};class ke extends U{async initialize(){this.decoder=new AudioDecoder({output:a=>{this.emit(pe.AudioFrame,a)},error:a=>{this.emit(pe.Error,a),this.close()}})}configure(a){this.config=a,this.decoder.configure({codec:{aac:"mp4a.40.2",pcma:"alaw",pcmu:"ulaw"}[a.codec],description:a.description,sampleRate:a.sampleRate,numberOfChannels:a.numberOfChannels})}decode(a){this.decoder.state==="configured"&&this.decoder.decode(new EncodedAudioChunk(a))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){this.decoder.close()}}Je([W([U.INIT,"closed"],"initialized")],ke.prototype,"initialize",1);Je([W("initialized","configured")],ke.prototype,"configure",1);Je([He("configured")],ke.prototype,"decode",1);Je([W([],U.INIT)],ke.prototype,"reset",1);Je([W([],"closed",{ignoreError:!0})],ke.prototype,"close",1);function Gi(){const h=yi([]);if(location.protocol==="http:"||location.protocol==="https:")return{webrtc:!1,streamList:h,changeStreamList:m=>{h.length=0,h.push(...m)},delItem:m=>{h[m].path="",delete h[m].item,delete h[m].stream},closeAll:()=>{h.length=0},updateItem:async(m,D)=>{let k,A;typeof m!="string"?(k=m,A=`${m.ID}/${m.DeviceID}`):A=m,h[D].path=A,h[D].item=k}};let a;const o=new Map;let d,v;const T=async()=>{const m=h.filter(D=>D.path);for(const D of m)if(o.has(D.path))D.stream||(D.stream=o.get(D.path));else{const k=new Fi(D.path);d||await P(),d.addStream(k),D.stream=k,o.set(D.path,D.stream)}if(m.length){const D=new Set(m.map(A=>A.path)),k=await v.createOffer();await v.setLocalDescription(k),a.send(JSON.stringify({type:"subscribe",offer:k.sdp,streamList:[...D]}))}else d&&(d.close(),d=null,o.clear())},P=async()=>new Promise(m=>{d=new Oi(mi("webrtc","/batch")),v=d.webrtc,a=v.createDataChannel("signal"),a.onmessage=async D=>{const k=JSON.parse(D.data);switch(k.type){case"answer":v.setRemoteDescription(new RTCSessionDescription(k));break;case"remove":d.deleteStream(k.streamPath),o.delete(k.streamPath);break;case"offer":await v.setRemoteDescription(new RTCSessionDescription(k));const A=await v.createAnswer();await v.setLocalDescription(A),a.send(JSON.stringify(A))}},a.onopen=m,v.ondatachannel=async D=>{const k=D.channel,A=o.get(k.label);if(A){let N,C;const X=new ki(k),J=new Pi(X,Le.PUSH);J.gotVideo=M=>I.decode(M),J.gotAudio=M=>ie.decode(M);const I=new Ae,ie=new ke;await I.initialize(),await ie.initialize(),J.on(Se.VIDEO_ENCODER_CONFIG_CHANGED,M=>{I.configure(M)}),J.on(Se.AUDIO_ENCODER_CONFIG_CHANGED,M=>{ie.configure(M)}),I.on(he.Error,M=>{console.error(M),I.initialize()}),I.on(he.VideoFrame,M=>{if(!N){const ne=new MediaStreamTrackGenerator({kind:"video"});A.videoTrack=ne,N=ne.writable.getWriter()}N.write(M).catch(ne=>{console.error(ne),I.close(),X.close()})}),ie.on(pe.Error,M=>{console.error(M),ie.initialize()}),ie.on(pe.AudioFrame,M=>{if(!C){const ne=new MediaStreamTrackGenerator({kind:"audio"});A.audioTrack=ne,C=ne.writable.getWriter()}C.write(M).catch(ne=>{console.error(ne),ie.close(),X.close()})}),X.connect()}},d.connect()});return{webrtc:!0,changeStreamList:m=>{h.length=0,h.push(...m),T()},streamList:h,updateItem:async(m,D)=>{let k,A;typeof m!="string"?(k=m,A=`${m.ID}/${m.DeviceID}`):A=m,h[D].path=A,h[D].item=k,h[D].stream=o.get(A),await T()},delItem:async m=>{h[m].path="",delete h[m].item,delete h[m].stream,await T()},closeAll:()=>{d==null||d.close(),d=null,h.length=0,o.clear()}}}export{Gi as a,Vi as u};