trtc-sdk-v5 5.9.0-wasm.5 → 5.9.0-wasm.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/assets/worker.js CHANGED
@@ -1,17 +1,17 @@
1
- var Sc=Object.create;var cr=Object.defineProperty;var Vi=Object.getOwnPropertyDescriptor;var yc=Object.getOwnPropertyNames,Bi=Object.getOwnPropertySymbols,Ic=Object.getPrototypeOf,Fi=Object.prototype.hasOwnProperty,Ac=Object.prototype.propertyIsEnumerable;var _n=(n,t,e)=>t in n?cr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,hn=(n,t)=>{for(var e in t||(t={}))Fi.call(t,e)&&_n(n,e,t[e]);if(Bi)for(var e of Bi(t))Ac.call(t,e)&&_n(n,e,t[e]);return n};var Rc=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var xc=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of yc(t))!Fi.call(n,s)&&s!==e&&cr(n,s,{get:()=>t[s],enumerable:!(r=Vi(t,s))||r.enumerable});return n};var lr=(n,t,e)=>(e=n!=null?Sc(Ic(n)):{},xc(t||!n||!n.__esModule?cr(e,"default",{value:n,enumerable:!0}):e,n));var me=(n,t,e,r)=>{for(var s=r>1?void 0:r?Vi(t,e):t,a=n.length-1,c;a>=0;a--)(c=n[a])&&(s=(r?c(t,e,s):c(s))||s);return r&&s&&cr(t,e,s),s};var m=(n,t,e)=>(_n(n,typeof t!="symbol"?t+"":t,e),e);var Ft=Rc((Tm,Hs)=>{"use strict";var Wc=Object.prototype.hasOwnProperty,_e="~";function Vt(){}Object.create&&(Vt.prototype=Object.create(null),new Vt().__proto__||(_e=!1));function Gc(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function ro(n,t,e,r,s){if(typeof e!="function")throw new TypeError("The listener must be a function");var a=new Gc(e,r||n,s),c=_e?_e+t:t;return n._events[c]?n._events[c].fn?n._events[c]=[n._events[c],a]:n._events[c].push(a):(n._events[c]=a,n._eventsCount++),n}function Mr(n,t){--n._eventsCount===0?n._events=new Vt:delete n._events[t]}function de(){this._events=new Vt,this._eventsCount=0}de.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)Wc.call(e,r)&&t.push(_e?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};de.prototype.listeners=function(t){var e=_e?_e+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var s=0,a=r.length,c=new Array(a);s<a;s++)c[s]=r[s].fn;return c};de.prototype.listenerCount=function(t){var e=_e?_e+t:t,r=this._events[e];return r?r.fn?1:r.length:0};de.prototype.emit=function(t,e,r,s,a,c){var f=_e?_e+t:t;if(!this._events[f])return!1;var l=this._events[f],d=arguments.length,_,h;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,r),!0;case 4:return l.fn.call(l.context,e,r,s),!0;case 5:return l.fn.call(l.context,e,r,s,a),!0;case 6:return l.fn.call(l.context,e,r,s,a,c),!0}for(h=1,_=new Array(d-1);h<d;h++)_[h-1]=arguments[h];l.fn.apply(l.context,_)}else{var I=l.length,U;for(h=0;h<I;h++)switch(l[h].once&&this.removeListener(t,l[h].fn,void 0,!0),d){case 1:l[h].fn.call(l[h].context);break;case 2:l[h].fn.call(l[h].context,e);break;case 3:l[h].fn.call(l[h].context,e,r);break;case 4:l[h].fn.call(l[h].context,e,r,s);break;default:if(!_)for(U=1,_=new Array(d-1);U<d;U++)_[U-1]=arguments[U];l[h].fn.apply(l[h].context,_)}}return!0};de.prototype.on=function(t,e,r){return ro(this,t,e,r,!1)};de.prototype.once=function(t,e,r){return ro(this,t,e,r,!0)};de.prototype.removeListener=function(t,e,r,s){var a=_e?_e+t:t;if(!this._events[a])return this;if(!e)return Mr(this,a),this;var c=this._events[a];if(c.fn)c.fn===e&&(!s||c.once)&&(!r||c.context===r)&&Mr(this,a);else{for(var f=0,l=[],d=c.length;f<d;f++)(c[f].fn!==e||s&&!c[f].once||r&&c[f].context!==r)&&l.push(c[f]);l.length?this._events[a]=l.length===1?l[0]:l:Mr(this,a)}return this};de.prototype.removeAllListeners=function(t){var e;return t?(e=_e?_e+t:t,this._events[e]&&Mr(this,e)):(this._events=new Vt,this._eventsCount=0),this};de.prototype.off=de.prototype.removeListener;de.prototype.addListener=de.prototype.on;de.prefixed=_e;de.EventEmitter=de;typeof Hs!="undefined"&&(Hs.exports=de)});function j(...n){}var vc=n=>n();function gn(){this.dispose()}var Uc=()=>typeof __FASTRX_DEVTOOLS__!="undefined",Oc=1,Le=class extends Function{toString(){return`${this.name}(${this.args.length?[...this.args].join(", "):""})`}subscribe(t){let e=new bn(t,this,this.streamId++);return ne.subscribe({id:this.id,end:!1},{nodeId:e.sourceId,streamId:e.id}),this(e),e}},pt=class{constructor(){this.defers=new Set,this.disposed=!1}next(t){}complete(){this.dispose()}error(t){this.dispose()}get bindDispose(){return()=>this.dispose()}dispose(){this.disposed=!0,this.complete=j,this.error=j,this.next=j,this.dispose=j,this.subscribe=j,this.doDefer()}subscribe(t){return t instanceof Le?t.subscribe(this):t(this),this}get bindSubscribe(){return t=>this.subscribe(t)}doDefer(){this.defers.forEach(vc),this.defers.clear()}defer(t){this.defers.add(t)}removeDefer(t){this.defers.delete(t)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}},P=class extends pt{constructor(t){super(),this.sink=t,t.defer(this.bindDispose)}next(t){this.sink.next(t)}complete(){this.sink.complete()}error(t){this.sink.error(t)}},dr=class extends pt{constructor(t,e=j,r=j,s=j){if(super(),this._next=e,this._error=r,this._complete=s,this.then=j,t instanceof Le){let a={toString:()=>"subscribe",id:0,source:t};this.defer(()=>{ne.defer(a,0)}),ne.create(a),ne.pipe(a),this.sourceId=a.id,this.subscribe(t),ne.subscribe({id:a.id,end:!0}),e==j?this._next=c=>ne.next(a,0,c):this.next=c=>{ne.next(a,0,c),e(c)},s==j?this._complete=()=>ne.complete(a,0):this.complete=()=>{this.dispose(),ne.complete(a,0),s()},r==j?this._error=c=>ne.complete(a,0,c):this.error=c=>{this.dispose(),ne.complete(a,0,c),r()}}else this.subscribe(t)}next(t){this._next(t)}complete(){this.dispose(),this._complete()}error(t){this.dispose(),this._error(t)}};function Y(n,...t){return t.reduce((e,r)=>r(e),n)}function fe(n,t,e){if(Uc()){let r=Object.defineProperties(Object.setPrototypeOf(n,Le.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:e,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});ne.create(r);for(let s=0;s<e.length;s++){let a=e[s];typeof a=="function"&&a instanceof Le&&ne.addSource(r,a)}return r}return n}function D(n,t){return function(...e){return r=>{if(r instanceof Le){let s=fe(a=>{let c=new n(a,...e);c.sourceId=s.id,c.subscribe(r)},t,arguments);return s.source=r,ne.pipe(s),s}else return s=>r(new n(s,...e))}}}function $e(n,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:n,payload:t}})}var bn=class extends P{constructor(t,e,r){super(t),this.source=e,this.id=r,this.sourceId=t.sourceId,this.defer(()=>{ne.defer(this.source,this.id)})}next(t){ne.next(this.source,this.id,t),this.sink.next(t)}complete(){ne.complete(this.source,this.id),this.sink.complete()}error(t){ne.complete(this.source,this.id,t),this.sink.error(t)}},ne={addSource(n,t){$e("addSource",{id:n.id,name:n.toString(),source:{id:t.id,name:t.toString()}})},next(n,t,e){$e("next",{id:n.id,streamId:t,data:e&&e.toString()})},subscribe({id:n,end:t},e){$e("subscribe",{id:n,end:t,sink:{nodeId:e&&e.nodeId,streamId:e&&e.streamId}})},complete(n,t,e){$e("complete",{id:n.id,streamId:t,err:e?e.toString():null})},defer(n,t){$e("defer",{id:n.id,streamId:t})},pipe(n){$e("pipe",{name:n.toString(),id:n.id,source:{id:n.source.id,name:n.source.toString()}})},update(n){$e("update",{id:n.id,name:n.toString()})},create(n){n.id||(n.id=Oc++),$e("create",{name:n.toString(),id:n.id})}},pr=class extends Error{constructor(t){super(`timeout after ${t}ms`),this.timeout=t}};var En=class extends pt{constructor(t){super(),this.source=t,this.sinks=new Set}add(t){t.defer(()=>this.remove(t)),this.sinks.add(t).size===1&&(this.reset(),this.subscribe(this.source))}remove(t){this.sinks.delete(t),this.sinks.size===0&&this.dispose()}next(t){this.sinks.forEach(e=>e.next(t))}complete(){this.sinks.forEach(t=>t.complete()),this.sinks.clear()}error(t){this.sinks.forEach(e=>e.error(t)),this.sinks.clear()}};function mt(){return n=>{let t=new En(n);if(n instanceof Le){let e=fe(r=>{t.add(r)},"share",arguments);return t.sourceId=e.id,e.source=n,ne.pipe(e),e}return fe(t.add.bind(t),"share",arguments)}}function Hi(...n){return fe(t=>{let e=new P(t),r=n.length;e.complete=()=>{--r===0&&t.complete()},n.forEach(e.bindSubscribe)},"merge",arguments)}function Pc(...n){return fe(t=>{let e=n.length,r=e,s=e,a=new Array(e),c=()=>{--s===0&&t.complete()},f=(l,d)=>{let _=new P(t);_.next=h=>{--r===0?(_.next=I=>{a[d]=I,t.next(a)},_.next(h)):a[d]=h},_.complete=c,_.subscribe(l)};n.forEach(f)},"combineLatest",arguments)}function qi(...n){return fe(t=>{let e=n.length,r=e,s=new Array(e),a=()=>{--r===0&&t.complete()},c=(f,l)=>{let d=new P(t),_=[];s[l]=_,d.next=h=>{_.push(h),s.every(I=>I.length)&&t.next(s.map(I=>I.shift()))},d.complete=a,d.subscribe(f)};n.forEach(c)},"zip",arguments)}var Tn=class extends P{constructor(t,...e){super(t);let r=new P(this.sink);r.next=s=>this.buffer=s,r.complete=j,r.subscribe(Pc(...e))}next(t){this.buffer&&this.sink.next([t,...this.buffer])}},sd=D(Tn,"withLatestFrom"),Sn=class extends P{constructor(t,e,r){super(t),this.bufferSize=e,this.startBufferEvery=r,this.buffer=[],this.count=0,this.startBufferEvery&&(this.buffers=[[]])}next(t){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach(e=>{e.push(t)}),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(t),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}complete(){this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach(t=>this.sink.next(t)),super.complete()}},id=D(Sn,"bufferCount"),yn=class extends P{constructor(t,e){super(t),this.buffer=[];let r=new P(t);r.next=s=>{t.next(this.buffer),this.buffer=[]},r.complete=j,r.subscribe(e)}next(t){this.buffer.push(t)}complete(){this.buffer.length&&this.sink.next(this.buffer),super.complete()}},od=D(yn,"buffer");function ft(n){let t=arguments,e=mt()(fe(r=>{e.next=s=>r.next(s),e.complete=()=>r.complete(),e.error=s=>r.error(s),n&&r.subscribe(n)},"subject",t));return e.next=j,e.complete=j,e.error=j,e}function mr(n){return fe(t=>{let e=0,r=setInterval(()=>t.next(e++),n);return t.defer(()=>{clearInterval(r)}),"interval"},"interval",arguments)}function Wi(n,t){return fe(e=>{let r=0,s=setTimeout(()=>{if(e.removeDefer(a),e.next(r++),t){let c=setInterval(()=>e.next(r++),t);e.defer(()=>{clearInterval(c)})}else e.complete()},n),a=()=>{clearTimeout(s)};e.defer(a)},"timer",arguments)}function In(n,t){return e=>{let r=s=>e.next(s);e.defer(()=>t(r)),n(r)}}function ve(n,t){if("on"in n)return fe(In(e=>n.on(t,e),e=>n.off(t,e)),"fromEvent",arguments);if("addListener"in n)return fe(In(e=>n.addListener(t,e),e=>n.removeListener(t,e)),"fromEvent",arguments);if("addEventListener"in n)return fe(In(e=>n.addEventListener(t,e),e=>n.removeEventListener(t,e)),"fromEvent",arguments);throw"target is not a EventDispachter"}var An=class extends P{constructor(t,e,r){super(t),this.f=e;let s=()=>{this.sink.next(this.acc),this.sink.complete()};typeof r=="undefined"?this.next=a=>{this.acc=a,this.complete=s,this.resetNext()}:(this.acc=r,this.complete=s)}next(t){this.acc=this.f(this.acc,t)}},Nc=D(An,"reduce");var Rn=class extends P{constructor(t,e,r){super(t),this.filter=e,this.thisArg=r}next(t){this.filter.call(this.thisArg,t)&&this.sink.next(t)}},_r=D(Rn,"filter"),xn=class extends P{next(t){}},hd=D(xn,"ignoreElements"),vn=class extends P{constructor(t,e){super(t),this.count=e}next(t){this.sink.next(t),--this.count===0&&this.complete()}},Gi=D(vn,"take"),Un=class extends P{constructor(t,e){super(t);let r=new P(t);r.next=()=>t.complete(),r.complete=gn,r.subscribe(e)}},Ue=D(Un,"takeUntil"),On=class extends P{constructor(t,e){super(t),this.f=e}next(t){this.f(t)?this.sink.next(t):this.complete()}},ji=D(On,"takeWhile");var Pn=class extends P{constructor(t,e){super(t),this.count=e}next(t){--this.count===0&&(this.next=super.next)}},bd=D(Pn,"skip"),Nn=class extends P{constructor(t,e){super(t),t.next=j;let r=new P(t);r.next=()=>{r.dispose(),t.resetNext()},r.complete=gn,r.subscribe(e)}},gd=D(Nn,"skipUntil"),Cn=class extends P{constructor(t,e){super(t),this.f=e}next(t){this.f(t)||(this.next=super.next,this.next(t))}},Ed=D(Cn,"skipWhile"),Cc={leading:!0,trailing:!1},wn=class extends P{constructor(t,e,r){super(t),this.durationSelector=e,this.trailing=r}cacheValue(t){this.last=t,this.disposed&&this.throttle(t)}send(t){this.sink.next(t),this.throttle(t)}throttle(t){this.reset(),this.subscribe(this.durationSelector(t))}next(){this.complete()}complete(){this.dispose(),this.trailing&&this.send(this.last)}},Dn=class extends P{constructor(t,e,r=Cc){super(t),this.durationSelector=e,this.config=r,this._throttle=new wn(this.sink,this.durationSelector,this.config.trailing),this._throttle.dispose()}next(t){this._throttle.disposed&&this.config.leading?this._throttle.send(t):this._throttle.cacheValue(t)}complete(){this._throttle.throttle=j,this._throttle.complete(),super.complete()}},Yi=D(Dn,"throttle");var Ln=class extends P{next(){this.complete()}complete(){this.dispose(),this.sink.next(this.last)}},fr=class extends P{constructor(t,e){super(t),this.durationSelector=e,this._debounce=new Ln(this.sink),this._debounce.dispose()}next(t){this._debounce.dispose(),this._debounce.reset(),this._debounce.last=t,this._debounce.subscribe(this.durationSelector(t))}complete(){this._debounce.complete(),super.complete()}},$i=D(fr,"debounce"),Ki=n=>D(fr,"debounceTime")(t=>Wi(n)),Mn=class extends P{constructor(t,e,r){super(t),this.count=e,this.defaultValue=r}next(t){this.count--===0&&(this.defaultValue=t,this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("not enough elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},Td=D(Mn,"elementAt");var kn=class extends P{constructor(t,e){super(t),this.f=e,this.i=0}next(t){this.f(t)?(this.sink.next(this.i++),this.complete()):++this.i}},Sd=D(kn,"findIndex"),Bn=class extends P{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t,this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},yd=D(Bn,"first"),Vn=class extends P{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t)}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},Id=D(Vn,"last"),Fn=class extends P{constructor(t,e){super(t),this.predicate=e,this.index=0}next(t){this.predicate(t,this.index++)?this.result=!0:(this.result=!1,this.complete())}complete(){if(this.result===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.result);super.complete()}},Ad=D(Fn,"every");var Hn=class extends P{constructor(t,e,r){super(t),this.f=e,typeof r=="undefined"?this.next=s=>{this.acc=s,this.resetNext(),this.sink.next(this.acc)}:this.acc=r}next(t){this.sink.next(this.acc=this.f(this.acc,t))}},Ud=D(Hn,"scan"),qn=class extends P{constructor(){super(...arguments),this.hasLast=!1}next(t){this.hasLast?this.sink.next([this.last,t]):this.hasLast=!0,this.last=t}},Od=D(qn,"pairwise"),hr=class extends P{constructor(t,e,r){super(t),this.mapper=e,this.thisArg=r}next(t){super.next(this.mapper.call(this.thisArg,t))}},yr=D(hr,"map"),Qn=n=>D(hr,"mapTo")(t=>n),_t=class extends P{constructor(t,e,r){super(t),this.data=e,this.context=r}next(t){let e=this.context.combineResults;e?this.sink.next(e(this.data,t)):this.sink.next(t)}tryComplete(){this.context.resetComplete(),this.dispose()}},ht=class extends P{constructor(t,e,r){super(t),this.makeSource=e,this.combineResults=r,this.index=0}subInner(t,e){let r=this.currentSink=new e(this.sink,t,this);this.complete=this.tryComplete,r.complete=r.tryComplete,r.subscribe(this.makeSource(t,this.index++))}tryComplete(){this.currentSink.resetComplete(),this.dispose()}},br=class extends _t{},gr=class extends ht{next(t){this.subInner(t,br),this.next=e=>{this.currentSink.dispose(),this.subInner(e,br)}}},Ji=D(gr,"switchMap");function Ir(n){return(t,e)=>n(()=>t,e)}var Lt=Ir(D(gr,"switchMapTo")),Wn=class extends _t{tryComplete(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}},Er=class extends ht{constructor(){super(...arguments),this.sources=[],this.next2=this.sources.push.bind(this.sources)}next(t){this.next2(t),this.subNext()}subNext(){this.next=this.next2,this.subInner(this.sources.shift(),Wn),this.disposed&&this.sources.length===0&&this.currentSink.resetComplete()}tryComplete(){this.sources.length===0&&this.currentSink.resetComplete(),this.dispose()}},Pd=D(Er,"concatMap"),Nd=Ir(D(Er,"concatMapTo")),Gn=class extends _t{tryComplete(){this.context.inners.delete(this),super.dispose(),this.context.inners.size===0&&this.context.resetComplete()}},Tr=class extends ht{constructor(){super(...arguments),this.inners=new Set}next(t){this.subInner(t,Gn),this.inners.add(this.currentSink)}tryComplete(){this.inners.size===1?this.inners.forEach(t=>t.resetComplete()):this.dispose()}},Cd=D(Tr,"mergeMap"),wd=Ir(D(Tr,"mergeMapTo")),jn=class extends _t{dispose(){this.context.resetNext(),super.dispose()}},Sr=class extends ht{next(t){this.next=j,this.subInner(t,jn)}},Dd=D(Sr,"exhaustMap"),Ld=Ir(D(Sr,"exhaustMapTo")),Yn=class extends P{constructor(t,e){super(t),this.f=e,this.groups=new Map}next(t){let e=this.f(t),r=this.groups.get(e);typeof r=="undefined"&&(r=ft(),r.key=e,this.groups.set(e,r),super.next(r)),r.next(t)}complete(){this.groups.forEach(t=>t.complete()),super.complete()}error(t){this.groups.forEach(e=>e.error(t)),super.error(t)}},Md=D(Yn,"groupBy"),$n=class extends P{constructor(){super(...arguments),this.start=new Date}next(t){this.sink.next({value:t,interval:Number(new Date)-Number(this.start)}),this.start=new Date}},kd=D($n,"timeInterval"),Kn=class extends P{constructor(t,e){super(t),this.miniseconds=e,this.buffer=[],this.id=setInterval(()=>{this.sink.next(this.buffer.concat()),this.buffer.length=0},this.miniseconds)}next(t){this.buffer.push(t)}complete(){this.sink.next(this.buffer),super.complete()}dispose(){clearInterval(this.id),super.dispose()}},Bd=D(Kn,"bufferTime"),Jn=class extends P{constructor(t,e){super(t),this.buffer=[],this.delayTime=e}dispose(){clearTimeout(this.timeoutId),super.dispose()}delay(t){this.timeoutId=setTimeout(()=>{let e=this.buffer.shift();if(e){let{time:r,data:s}=e;super.next(s),this.buffer.length&&this.delay(Number(this.buffer[0].time)-Number(r))}},t)}next(t){this.buffer.length||this.delay(this.delayTime),this.buffer.push({time:new Date,data:t})}complete(){this.timeoutId=setTimeout(()=>super.complete(),this.delayTime)}},Vd=D(Jn,"delay"),Xn=class extends P{constructor(t,e){super(t),this.selector=e}error(t){this.dispose(),this.selector(t)(this.sink)}},Fd=D(Xn,"catchError");var ee=(n=j,t=j,e=j)=>r=>new dr(r,n,t,e),zn=class extends P{constructor(t,e){super(t),e instanceof Function?this.next=r=>{e(r),t.next(r)}:(e.next&&(this.next=r=>{e.next(r),t.next(r)}),e.complete&&(this.complete=()=>{e.complete(),t.complete()}),e.error&&(this.error=r=>{e.error(r),t.error(r)}))}},Ar=D(zn,"tap"),Zn=class extends P{constructor(t,e){super(t),this.timeout=e,this.id=setTimeout(()=>this.error(new pr(this.timeout)),this.timeout)}next(t){super.next(t),clearTimeout(this.id),this.next=super.next}dispose(){clearTimeout(this.id),super.dispose()}},Wd=D(Zn,"timeout");function Mt(n,t=!1){let e=Object.defineProperties(ft(),{postMessage:{value:n.postMessage.bind(n)},port:{get(){return n},set(s){n.onmessage=j,n.onmessageerror=j,n=s,r()}}});function r(){n.onmessage=s=>{s.data?s.ports.length||t?e.next(s):e.next(s.data):(e.complete(),n.close())},n.onmessageerror=s=>{e.error(s),n.close()}}return r(),e}var es=class extends P{constructor(t,e){super(t);let r=new P(t);r.next=j,e(r)}},Fe=D(es,"takeUntilComplete");var re={useWt:!0,useAINS:!0,useHardDecoder:"prefer-software",useHardEncoder:"prefer-software",unreliable:!1,debug:!1,assetsPath:"",enableUpload:!0},wc="__INLINE__WORKER__",Xi="__INLINE__WASM__",{debug:Rr}=console;re.debug||(console.debug=()=>{});var ip=!wc.startsWith("__");var op=Xi.startsWith("__")?`${re.assetsPath?`${re.assetsPath}/`:""}av_processing.wasm`:`data:application/octet-stream;base64,${Xi}`;function ie(...n){}var Dc=n=>n();function rs(){this.dispose()}var Lc=()=>typeof __FASTRX_DEVTOOLS__!="undefined",Mc=1,He=class extends Function{toString(){return`${this.name}(${this.args.length?[...this.args].join(", "):""})`}subscribe(t){let e=new ts(t,this,this.streamId++);return Oe.subscribe({id:this.id,end:!1},{nodeId:e.sourceId,streamId:e.id}),this(e),e}},kt=class{constructor(){this.defers=new Set,this.disposed=!1}next(t){}complete(){this.dispose()}error(t){this.dispose()}get bindDispose(){return()=>this.dispose()}dispose(){this.disposed=!0,this.complete=ie,this.error=ie,this.next=ie,this.dispose=ie,this.subscribe=ie,this.doDefer()}subscribe(t){return t instanceof He?t.subscribe(this):t(this),this}get bindSubscribe(){return t=>this.subscribe(t)}doDefer(){this.defers.forEach(Dc),this.defers.clear()}defer(t){this.defers.add(t)}removeDefer(t){this.defers.delete(t)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}},L=class extends kt{constructor(t){super(),this.sink=t,t.defer(this.bindDispose)}next(t){this.sink.next(t)}complete(){this.sink.complete()}error(t){this.sink.error(t)}};function vr(n,...t){return t.reduce((e,r)=>r(e),n)}function qe(n,t,e){if(Lc()){let r=Object.defineProperties(Object.setPrototypeOf(n,He.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:e,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});Oe.create(r);for(let s=0;s<e.length;s++){let a=e[s];typeof a=="function"&&a instanceof He&&Oe.addSource(r,a)}return r}return n}function V(n,t){return function(...e){return r=>{if(r instanceof He){let s=qe(a=>{let c=new n(a,...e);c.sourceId=s.id,c.subscribe(r)},t,arguments);return s.source=r,Oe.pipe(s),s}else return s=>r(new n(s,...e))}}}function Ke(n,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:n,payload:t}})}var ts=class extends L{constructor(t,e,r){super(t),this.source=e,this.id=r,this.sourceId=t.sourceId,this.defer(()=>{Oe.defer(this.source,this.id)})}next(t){Oe.next(this.source,this.id,t),this.sink.next(t)}complete(){Oe.complete(this.source,this.id),this.sink.complete()}error(t){Oe.complete(this.source,this.id,t),this.sink.error(t)}},Oe={addSource(n,t){Ke("addSource",{id:n.id,name:n.toString(),source:{id:t.id,name:t.toString()}})},next(n,t,e){Ke("next",{id:n.id,streamId:t,data:e&&e.toString()})},subscribe({id:n,end:t},e){Ke("subscribe",{id:n,end:t,sink:{nodeId:e&&e.nodeId,streamId:e&&e.streamId}})},complete(n,t,e){Ke("complete",{id:n.id,streamId:t,err:e?e.toString():null})},defer(n,t){Ke("defer",{id:n.id,streamId:t})},pipe(n){Ke("pipe",{name:n.toString(),id:n.id,source:{id:n.source.id,name:n.source.toString()}})},update(n){Ke("update",{id:n.id,name:n.toString()})},create(n){n.id||(n.id=Mc++),Ke("create",{name:n.toString(),id:n.id})}},xr=class extends Error{constructor(t){super(`timeout after ${t}ms`),this.timeout=t}};var ns=class extends kt{constructor(t){super(),this.source=t,this.sinks=new Set}add(t){t.defer(()=>this.remove(t)),this.sinks.add(t).size===1&&(this.reset(),this.subscribe(this.source))}remove(t){this.sinks.delete(t),this.sinks.size===0&&this.dispose()}next(t){this.sinks.forEach(e=>e.next(t))}complete(){this.sinks.forEach(t=>t.complete()),this.sinks.clear()}error(t){this.sinks.forEach(e=>e.error(t)),this.sinks.clear()}};function Ur(){return n=>{let t=new ns(n);if(n instanceof He){let e=qe(r=>{t.add(r)},"share",arguments);return t.sourceId=e.id,e.source=n,Oe.pipe(e),e}return qe(t.add.bind(t),"share",arguments)}}function kc(...n){return qe(t=>{let e=n.length,r=e,s=e,a=new Array(e),c=()=>{--s===0&&t.complete()},f=(l,d)=>{let _=new L(t);_.next=h=>{--r===0?(_.next=I=>{a[d]=I,t.next(a)},_.next(h)):a[d]=h},_.complete=c,_.subscribe(l)};n.forEach(f)},"combineLatest",arguments)}var ss=class extends L{constructor(t,...e){super(t);let r=new L(this.sink);r.next=s=>this.buffer=s,r.complete=ie,r.subscribe(kc(...e))}next(t){this.buffer&&this.sink.next([t,...this.buffer])}},lp=V(ss,"withLatestFrom"),is=class extends L{constructor(t,e,r){super(t),this.bufferSize=e,this.startBufferEvery=r,this.buffer=[],this.count=0,this.startBufferEvery&&(this.buffers=[[]])}next(t){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach(e=>{e.push(t)}),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(t),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}complete(){this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach(t=>this.sink.next(t)),super.complete()}},dp=V(is,"bufferCount"),os=class extends L{constructor(t,e){super(t),this.buffer=[];let r=new L(t);r.next=s=>{t.next(this.buffer),this.buffer=[]},r.complete=ie,r.subscribe(e)}next(t){this.buffer.push(t)}complete(){this.buffer.length&&this.sink.next(this.buffer),super.complete()}},pp=V(os,"buffer");function as(n){let t=arguments,e=Ur()(qe(r=>{e.next=s=>r.next(s),e.complete=()=>r.complete(),e.error=s=>r.error(s),n&&r.subscribe(n)},"subject",t));return e.next=ie,e.complete=ie,e.error=ie,e}function Qi(n){return qe(t=>{let e=0,r=setInterval(()=>t.next(e++),n);return t.defer(()=>{clearInterval(r)}),"interval"},"interval",arguments)}var us=class extends L{constructor(t,e,r){super(t),this.f=e;let s=()=>{this.sink.next(this.acc),this.sink.complete()};typeof r=="undefined"?this.next=a=>{this.acc=a,this.complete=s,this.resetNext()}:(this.acc=r,this.complete=s)}next(t){this.acc=this.f(this.acc,t)}},Bc=V(us,"reduce");var cs=class extends L{constructor(t,e,r){super(t),this.filter=e,this.thisArg=r}next(t){this.filter.call(this.thisArg,t)&&this.sink.next(t)}},zi=V(cs,"filter"),ls=class extends L{next(t){}},Ip=V(ls,"ignoreElements"),ds=class extends L{constructor(t,e){super(t),this.count=e}next(t){this.sink.next(t),--this.count===0&&this.complete()}},Zi=V(ds,"take"),ps=class extends L{constructor(t,e){super(t);let r=new L(t);r.next=()=>t.complete(),r.complete=rs,r.subscribe(e)}},Ap=V(ps,"takeUntil"),ms=class extends L{constructor(t,e){super(t),this.f=e}next(t){this.f(t)?this.sink.next(t):this.complete()}},Vc=V(ms,"takeWhile");var fs=class extends L{constructor(t,e){super(t),this.count=e}next(t){--this.count===0&&(this.next=super.next)}},Rp=V(fs,"skip"),_s=class extends L{constructor(t,e){super(t),t.next=ie;let r=new L(t);r.next=()=>{r.dispose(),t.resetNext()},r.complete=rs,r.subscribe(e)}},xp=V(_s,"skipUntil"),hs=class extends L{constructor(t,e){super(t),this.f=e}next(t){this.f(t)||(this.next=super.next,this.next(t))}},eo=V(hs,"skipWhile"),Fc={leading:!0,trailing:!1},bs=class extends L{constructor(t,e,r){super(t),this.durationSelector=e,this.trailing=r}cacheValue(t){this.last=t,this.disposed&&this.throttle(t)}send(t){this.sink.next(t),this.throttle(t)}throttle(t){this.reset(),this.subscribe(this.durationSelector(t))}next(){this.complete()}complete(){this.dispose(),this.trailing&&this.send(this.last)}},gs=class extends L{constructor(t,e,r=Fc){super(t),this.durationSelector=e,this.config=r,this._throttle=new bs(this.sink,this.durationSelector,this.config.trailing),this._throttle.dispose()}next(t){this._throttle.disposed&&this.config.leading?this._throttle.send(t):this._throttle.cacheValue(t)}complete(){this._throttle.throttle=ie,this._throttle.complete(),super.complete()}},vp=V(gs,"throttle");var Es=class extends L{next(){this.complete()}complete(){this.dispose(),this.sink.next(this.last)}},Ts=class extends L{constructor(t,e){super(t),this.durationSelector=e,this._debounce=new Es(this.sink),this._debounce.dispose()}next(t){this._debounce.dispose(),this._debounce.reset(),this._debounce.last=t,this._debounce.subscribe(this.durationSelector(t))}complete(){this._debounce.complete(),super.complete()}},Up=V(Ts,"debounce");var Ss=class extends L{constructor(t,e,r){super(t),this.count=e,this.defaultValue=r}next(t){this.count--===0&&(this.defaultValue=t,this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("not enough elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},Op=V(Ss,"elementAt");var ys=class extends L{constructor(t,e){super(t),this.f=e,this.i=0}next(t){this.f(t)?(this.sink.next(this.i++),this.complete()):++this.i}},Pp=V(ys,"findIndex"),Is=class extends L{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t,this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},Np=V(Is,"first"),As=class extends L{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t)}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},Cp=V(As,"last"),Rs=class extends L{constructor(t,e){super(t),this.predicate=e,this.index=0}next(t){this.predicate(t,this.index++)?this.result=!0:(this.result=!1,this.complete())}complete(){if(this.result===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.result);super.complete()}},wp=V(Rs,"every");var xs=class extends L{constructor(t,e,r){super(t),this.f=e,typeof r=="undefined"?this.next=s=>{this.acc=s,this.resetNext(),this.sink.next(this.acc)}:this.acc=r}next(t){this.sink.next(this.acc=this.f(this.acc,t))}},kp=V(xs,"scan"),vs=class extends L{constructor(){super(...arguments),this.hasLast=!1}next(t){this.hasLast?this.sink.next([this.last,t]):this.hasLast=!0,this.last=t}},Bp=V(vs,"pairwise"),Us=class extends L{constructor(t,e,r){super(t),this.mapper=e,this.thisArg=r}next(t){super.next(this.mapper.call(this.thisArg,t))}},ks=V(Us,"map");var bt=class extends L{constructor(t,e,r){super(t),this.data=e,this.context=r}next(t){let e=this.context.combineResults;e?this.sink.next(e(this.data,t)):this.sink.next(t)}tryComplete(){this.context.resetComplete(),this.dispose()}},gt=class extends L{constructor(t,e,r){super(t),this.makeSource=e,this.combineResults=r,this.index=0}subInner(t,e){let r=this.currentSink=new e(this.sink,t,this);this.complete=this.tryComplete,r.complete=r.tryComplete,r.subscribe(this.makeSource(t,this.index++))}tryComplete(){this.currentSink.resetComplete(),this.dispose()}},Or=class extends bt{},Pr=class extends gt{next(t){this.subInner(t,Or),this.next=e=>{this.currentSink.dispose(),this.subInner(e,Or)}}},Hc=V(Pr,"switchMap");function Dr(n){return(t,e)=>n(()=>t,e)}var Vp=Dr(V(Pr,"switchMapTo")),Os=class extends bt{tryComplete(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}},Nr=class extends gt{constructor(){super(...arguments),this.sources=[],this.next2=this.sources.push.bind(this.sources)}next(t){this.next2(t),this.subNext()}subNext(){this.next=this.next2,this.subInner(this.sources.shift(),Os),this.disposed&&this.sources.length===0&&this.currentSink.resetComplete()}tryComplete(){this.sources.length===0&&this.currentSink.resetComplete(),this.dispose()}},Fp=V(Nr,"concatMap"),Hp=Dr(V(Nr,"concatMapTo")),Ps=class extends bt{tryComplete(){this.context.inners.delete(this),super.dispose(),this.context.inners.size===0&&this.context.resetComplete()}},Cr=class extends gt{constructor(){super(...arguments),this.inners=new Set}next(t){this.subInner(t,Ps),this.inners.add(this.currentSink)}tryComplete(){this.inners.size===1?this.inners.forEach(t=>t.resetComplete()):this.dispose()}},qp=V(Cr,"mergeMap"),Wp=Dr(V(Cr,"mergeMapTo")),Ns=class extends bt{dispose(){this.context.resetNext(),super.dispose()}},wr=class extends gt{next(t){this.next=ie,this.subInner(t,Ns)}},Gp=V(wr,"exhaustMap"),jp=Dr(V(wr,"exhaustMapTo")),Cs=class extends L{constructor(t,e){super(t),this.f=e,this.groups=new Map}next(t){let e=this.f(t),r=this.groups.get(e);typeof r=="undefined"&&(r=as(),r.key=e,this.groups.set(e,r),super.next(r)),r.next(t)}complete(){this.groups.forEach(t=>t.complete()),super.complete()}error(t){this.groups.forEach(e=>e.error(t)),super.error(t)}},Yp=V(Cs,"groupBy"),ws=class extends L{constructor(){super(...arguments),this.start=new Date}next(t){this.sink.next({value:t,interval:Number(new Date)-Number(this.start)}),this.start=new Date}},$p=V(ws,"timeInterval"),Ds=class extends L{constructor(t,e){super(t),this.miniseconds=e,this.buffer=[],this.id=setInterval(()=>{this.sink.next(this.buffer.concat()),this.buffer.length=0},this.miniseconds)}next(t){this.buffer.push(t)}complete(){this.sink.next(this.buffer),super.complete()}dispose(){clearInterval(this.id),super.dispose()}},Kp=V(Ds,"bufferTime"),Ls=class extends L{constructor(t,e){super(t),this.buffer=[],this.delayTime=e}dispose(){clearTimeout(this.timeoutId),super.dispose()}delay(t){this.timeoutId=setTimeout(()=>{let e=this.buffer.shift();if(e){let{time:r,data:s}=e;super.next(s),this.buffer.length&&this.delay(Number(this.buffer[0].time)-Number(r))}},t)}next(t){this.buffer.length||this.delay(this.delayTime),this.buffer.push({time:new Date,data:t})}complete(){this.timeoutId=setTimeout(()=>super.complete(),this.delayTime)}},Jp=V(Ls,"delay"),Ms=class extends L{constructor(t,e){super(t),this.selector=e}error(t){this.dispose(),this.selector(t)(this.sink)}},Xp=V(Ms,"catchError");var Bs=class extends L{constructor(t,e){super(t),e instanceof Function?this.next=r=>{e(r),t.next(r)}:(e.next&&(this.next=r=>{e.next(r),t.next(r)}),e.complete&&(this.complete=()=>{e.complete(),t.complete()}),e.error&&(this.error=r=>{e.error(r),t.error(r)}))}},em=V(Bs,"tap"),Vs=class extends L{constructor(t,e){super(t),this.timeout=e,this.id=setTimeout(()=>this.error(new xr(this.timeout)),this.timeout)}next(t){super.next(t),clearTimeout(this.id),this.next=super.next}dispose(){clearTimeout(this.id),super.dispose()}},tm=V(Vs,"timeout");var to=vr(Qi(250),ks(()=>performance.now()),Ur()),Pe=n=>t=>{let e=0,r=performance.now();vr(to,ks(s=>(s-r)/n>>0),zi(s=>s!=e?(e=s,!0):!1))(t)},Je=n=>t=>{let e=performance.now();vr(to,eo(r=>r-e<n),Zi(1))(t)};function Xe(n,t,e){let r=t.aborted?Promise.reject(t.reason):new Promise((s,a)=>{t.addEventListener("abort",()=>a(t.reason),{once:!0}),typeof n=="function"?n(s,a):n.then(s,a)});return e?r.catch(e):r}var qc=new Intl.DateTimeFormat("zh-CN",{dateStyle:"short",timeStyle:"medium"}),rt=()=>qc.format(new Date),oe=(A=>(A[A.JOIN_ROOM=0]="JOIN_ROOM",A[A.LEAVE_ROOM=1]="LEAVE_ROOM",A[A.PUBLISH=2]="PUBLISH",A[A.UNPUBLISH=3]="UNPUBLISH",A[A.SUBSCRIBE=4]="SUBSCRIBE",A[A.UNSUBSCRIBE=5]="UNSUBSCRIBE",A[A.GET_WHOLE_LIST=6]="GET_WHOLE_LIST",A[A.QUALITY_REPORT=7]="QUALITY_REPORT",A[A.MUTE=8]="MUTE",A[A.UNMUTE=9]="UNMUTE",A[A.CONFIG=10]="CONFIG",A[A.REQUEST_PLI=11]="REQUEST_PLI",A[A.HEARTBEAT=12]="HEARTBEAT",A[A.START_PUSH_CDN=13]="START_PUSH_CDN",A[A.STOP_PUSH_CDN=14]="STOP_PUSH_CDN",A[A.START_MCU_MIX=15]="START_MCU_MIX",A[A.STOP_MCU_MIX=16]="STOP_MCU_MIX",A[A.UDPATE_TRACK=17]="UDPATE_TRACK",A[A.START_PUSHING=18]="START_PUSHING",A[A.STOP_PUSHING=19]="STOP_PUSHING",A[A.SWITCH_ROLE=20]="SWITCH_ROLE",A[A.WHOLE_LIST_UPDATE=255]="WHOLE_LIST_UPDATE",A[A.PEER_JOINED=256]="PEER_JOINED",A[A.PEER_LEFT=257]="PEER_LEFT",A[A.PEER_UDPATED_TRACK=258]="PEER_UDPATED_TRACK",A[A.SELECT_ABILITY=259]="SELECT_ABILITY",A[A.PEER_REQUEST_PLI=260]="PEER_REQUEST_PLI",A[A.AUDIO_DATA=4095]="AUDIO_DATA",A[A.VIDEO_DATA=4096]="VIDEO_DATA",A[A.SCREEN_DATA=4097]="SCREEN_DATA",A[A.NACK=4098]="NACK",A[A.ACK=4099]="ACK",A[A.REQUEST_RTT=4100]="REQUEST_RTT",A[A.RESPONSE_RTT=4101]="RESPONSE_RTT",A[A.PIP_DATA=4102]="PIP_DATA",A[A.LAYER_DATA=4103]="LAYER_DATA",A[A.MAX_FORCE=65535]="MAX_FORCE",A))(oe||{});function Fs(n,t,e){let r=t>65535?1:0,s=0;return e.setUint8(0,s<<4|r),e.setUint16(1,n),r?e.setUint32(3,t):e.setUint16(3,t),r?7:5}function Bt(n,t){let e=n>=255&&n<4095;e&&(t+=4);let s=(t>65535?1:0)?7:5,a=new DataView(new ArrayBuffer(s+t));Fs(n,t,a),e&&(a.setUint32(s,0),s+=4),a=new DataView(a.buffer,s),s=0;let c=I=>{a.setUint8(s,I),s++},f=I=>{a.setUint16(s,I),s+=2},l=(I,U=!1)=>{a.setUint32(s,I,U),s+=4},d=I=>{a.setBigUint64(s,I),s+=8},_=I=>{let U=new Uint8Array(a.buffer,a.byteOffset+s,I);return s+=I,U};return{write8:c,write32:l,write16:f,write64:d,writeData:I=>_(I.length).set(I),dv:a,next:_}}function Lr(n,t,e){let r=JSON.stringify(t),{writeData:s,dv:a}=Bt(n,r.length+16);switch(s(e.split("").map(c=>c.charCodeAt(0))),s(r.split("").map(c=>c.charCodeAt(0))),n){case 11:case 12:case 7:console.debug("send",oe[n],e,t,a.buffer);break;default:n<255&&console.log(rt(),"send",oe[n],e,t,a.buffer)}return a.buffer}var no=lr(Ft()),Te=class extends no.EventEmitter{constructor(e){super();this.io=e}get statReportReq(){return this.io.statReportReq.stat}get qualityReport(){return this.io.qualityReportReq.report}get appId(){return this.io.joinReq.sdkAppID}get roomId(){return this.io.joinReq.roomid}get userId(){return this.io.joinRes.openid}get userMap_(){return this.io.userManager.remotePublishedUserMap}send(e,r){return this.io.sendReq(e,r)}post(e,r){return this.io.postReq(e,r)}postMessage(e,r){this.io.postMessage({cmd:e,payload:r})}createResposeOb(e){return ve(this.io,oe[e])}glog(e){self.postMessage({type:"glog",payload:e})}};var Ht=class{constructor(){m(this,"arguments");m(this,"environment");m(this,"preInit");m(this,"preRun");m(this,"postRun");m(this,"onAbort");m(this,"preinitializedWebGLContext");m(this,"noInitialRun");m(this,"noExitRuntime");m(this,"logReadFiles");m(this,"filePackagePrefixURL");m(this,"wasmBinary");m(this,"HEAP");m(this,"IHEAP");m(this,"FHEAP");m(this,"HEAP8");m(this,"HEAP16");m(this,"HEAP32");m(this,"HEAPU8");m(this,"HEAPU16");m(this,"HEAPU32");m(this,"HEAPF32");m(this,"HEAPF64");m(this,"TOTAL_STACK");m(this,"TOTAL_MEMORY");m(this,"FAST_MEMORY");m(this,"preloadedImages");m(this,"preloadedAudios");m(this,"_GetEncodedFrame");m(this,"_ReceivedAudioPacket");m(this,"_CreateUdtPacketizer");m(this,"_PacketizeVideoUdt");m(this,"udtver",3)}onRuntimeInitialized(){}print(t){console.debug(t)}printErr(t){console.debug(t)}},pe=new Ht,B=class{constructor(t,e){this.size=t;m(this,"point");this.point=pe._malloc(t),e&&this.set(e)}set(t){t.length>this.size&&this.grow(t.length),pe.HEAPU8.set(t,this.point)}setUint32(t,e){new DataView(pe.HEAPU8.buffer).setUint32(this.point+t,e)}setBigUint64(t,e){new DataView(pe.HEAPU8.buffer).setBigUint64(this.point+t,e)}getBigUint64(t){return new DataView(pe.HEAPU8.buffer).getBigUint64(this.point+t)}getUint32(t){return pe.HEAPU8[this.point+t]|pe.HEAPU8[this.point+t+1]<<8|pe.HEAPU8[this.point+t+2]<<16|pe.HEAPU8[this.point+t+3]<<24}getInt8(t){return pe.HEAPU8[this.point+t]}uint8Array(t=NaN){return new Uint8Array(pe.HEAPU8.buffer,this.point,t>=0?t:this.size)}uint8Slice(t=NaN){return pe.HEAPU8.slice(this.point,this.point+(t>=0?t:this.size))}fill(t=0,e=this.point,r=this.point+this.size){pe.HEAPU8.fill(t,e,r)}free(){pe._free(this.point)}grow(t){t>this.size&&(this.free(),this.size=t,this.point=pe._malloc(t))}};m(B,"global");var H=pe;var kr=class{constructor(t){m(this,"lastReceiveTime",-1);m(this,"blocking",!1);m(this,"blockCnt",0);m(this,"blockTime",0);m(this,"received",ft());let e=Je(t);Y(this.received,$i(()=>(this.blockDone(),this.lastReceiveTime=Date.now(),e)),ee(()=>{this.blocking=!0},j,()=>{this.blockDone()}))}blockDone(){this.blocking&&(this.blockCnt++,this.blockTime+=Date.now()-this.lastReceiveTime,this.blocking=!1)}clear(){this.blockCnt=0,this.blockTime=0}},qs=class{constructor(t=2){m(this,"videoStatus",{uint32_video_stream_type:2,uint32_video_codec_fps:0,uint32_video_capture_fps:0,uint32_video_receive_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_type:0,uint32_video_gop:0,uint32_video_rps_open:0,uint32_video_rps_interval:0,uint32_video_codec_bitrate:0,uint32_video_total_bitrate:0,uint32_video_fec_ratio:0,uint32_video_fec_recover:0,uint32_video_arq_request:0,uint32_video_arq_recover:0,uint32_video_arq_packets:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_final_lost:0,uint32_video_block_cnt:0,uint32_video_cache_ms:0,uint32_video_total_frame:0,uint32_video_decode_frame:0,uint32_video_block_time:0,uint32_video_quality:0,uint32_video_jitter_fps:0});m(this,"videoPort");m(this,"control");m(this,"lastReceiveTime",-1);m(this,"vBlock",new kr(500));m(this,"ssrc",qs.g_ssrc++);m(this,"framesFromStartPull",0);this.videoStatus.uint32_video_stream_type=t}getVideoStatus(){let t=hn({},this.videoStatus);return t.uint32_video_block_cnt=this.vBlock.blockCnt,t.uint32_video_block_time=this.vBlock.blockTime,t.uint32_video_codec_bitrate>>=1,t.uint32_video_total_bitrate>>=1,t.uint32_video_receive_fps>>=1,t.uint32_video_capture_fps>>=1,t.uint32_video_codec_fps>>=1,this.videoStatus.uint32_video_codec_bitrate=0,this.videoStatus.uint32_video_total_bitrate=0,this.videoStatus.uint32_video_receive_fps=0,this.videoStatus.uint32_video_capture_fps=0,this.videoStatus.uint32_video_codec_fps=0,this.vBlock.clear(),t}demuxPacket(t){let e=t.length,{ssrc:r,videoStatus:s,vBlock:a}=this;s.uint32_video_receive++;let c=Date.now();s.uint32_video_total_bitrate+=e<<3,B.global.set(t);let f=H._ReceivedVideoPacket(B.global.point,e,c/1e3,c%1e3,r);f==0&&(this.lastReceiveTime>0&&c-this.lastReceiveTime>500&&console.debug("demuxPacket",c-this.lastReceiveTime),this.lastReceiveTime=c),a.received.next(f)}gotVideoFrame(t){var r;this.videoStatus.uint32_video_total_frame++,this.videoStatus.uint32_video_codec_bitrate+=t.length<<3,this.videoStatus.uint32_video_receive_fps++,this.videoStatus.uint32_video_capture_fps++;let e=t.slice();(r=this.videoPort)==null||r.postMessage({data:e,packetsReceived:this.videoStatus.uint32_video_receive},[e.buffer])}},qt=qs;m(qt,"g_ssrc",1);var Br=class{constructor(t,e){this.writer=t;this.ssrc=e;m(this,"buffer",new B(960));m(this,"timestamp",0);H._AddAudioChannel(e,e)}feed(){}close(){H._DelAudioChannel(this.ssrc),this.buffer.free()}},Vr=class{constructor(t,e){this.io=e;m(this,"userId");m(this,"tinyId");m(this,"role");m(this,"terminalType");m(this,"lastCapNtpMs",-1);m(this,"startTimestamp",Date.now());m(this,"alastReceivedTimestamp",-1);m(this,"lengthPoint",new B(4));m(this,"audioPuller");m(this,"mainPuller",new qt(2));m(this,"screenPuller",new qt(7));m(this,"aBlock",new kr(250));m(this,"events",[]);m(this,"msg_audio_status",{uint32_audio_format:0,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_total_bitrate:0,uint32_audio_aec:0,uint32_audio_fec_ratio:0,uint32_audio_fec_recover:0,uint32_audio_arq_request:0,uint32_audio_arq_recover:0,uint32_audio_arq_packets:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_final_lost:0,uint32_audio_cache_ms:0,uint32_audio_capture_state:0,uint32_audio_filtered_max_cache_ms:0,uint32_audio_filtered_avg_cache_ms:0,uint32_audio_target_max_cache_ms:0,uint32_audio_target_avg_cache_ms:0,uint32_audio_delay_peak_count:0,uint32_audio_speed_percent:0,uint32_audio_quality:0,uint32_audio_block_time:0,uint32_audio_block_cnt:0,uint32_audio_level:0});m(this,"subscribe",0);m(this,"removing",!1);Object.defineProperties(this,Object.getOwnPropertyDescriptors(t))}remove(){var t;this.lengthPoint.free(),(t=this.audioPuller)==null||t.close()}toDownStreamInfo(t,e){let r=[this.mainPuller.getVideoStatus()];r[0].uint32_video_stream_type=this.subscribe&8?3:2,this.screenPuller.videoPort&&r.push(this.screenPuller.getVideoStatus());let s=hn({},this.msg_audio_status);return s.uint32_audio_codec_bitrate>>=1,s.uint32_audio_total_bitrate>>=1,s.uint32_audio_block_cnt=this.aBlock.blockCnt,s.uint32_audio_block_time=this.aBlock.blockTime,e&&console.log(new Date().toLocaleString(),t.userId,r.map(a=>({t:a.uint32_video_stream_type,r_fps:a.uint32_video_receive_fps,c_fps:a.uint32_video_codec_fps,c_bps:a.uint32_video_codec_bitrate})),s.uint32_audio_codec_bitrate),this.msg_audio_status.uint32_audio_total_bitrate=0,this.msg_audio_status.uint32_audio_codec_bitrate=0,this.aBlock.clear(),{msg_user_info:{str_identifier:this.userId,uint64_tinyid:Number(this.tinyId)},msg_audio_status:s,msg_video_status:r,msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0,uint32_jitter:0}}}getNextVideoFrame(t){this.lengthPoint.setUint32(0,B.global.size);let e=H._GetEncodedFrame(B.global.point,this.lengthPoint.point,!1,t.ssrc),r=this.lengthPoint.getUint32(0);if(e==-1||r==0)return 10;let s=B.global.uint8Array(r);return t.videoStatus.uint32_video_total_frame||console.timeEnd(`${this.userId}${t==this.mainPuller?"big":"aux"}`),t.gotVideoFrame(s),e}startPullOnlyAudio(t,e,r){this.io.log_.info("start pull only audio",t),H._AddAudioChannel(t.ssrc,t.ssrc)}startPull(t,e,r){this.io.log_.info("start pull",t,r);let s=t===this.mainPuller;if(t.videoPort){t.framesFromStartPull=0,t.videoPort.port=e.port;return}let a=s?[2,1]:[7];t.videoPort=e,console.time(`${this.userId}${r.mediaType&2?"aux":"big"}`),Y(e,ee(({width:_,height:h})=>{t.videoStatus.uint32_video_width=_,t.videoStatus.uint32_video_height=h,t.videoStatus.uint32_video_decode_frame++,t.videoStatus.uint32_video_codec_fps++}));let c=_=>{delete t.videoPort,_?this.io.log_.error("stop pull",_):this.io.log_.info("stop pull",t),H._DelVideoChannel(t.ssrc),t.vBlock.received.complete(),s&&this.aBlock.received.complete()};H._AddVideoChannel(t.ssrc,t.ssrc);let f=0,l=0,d=()=>{Date.now()-l>2e3&&(l=Date.now(),this.io.sendReq(11,r))};Y(this.io.wh.interval10ms,_r(_=>(f<=0&&(f=this.getNextVideoFrame(t),f>500&&(f=20)),f-=10,re.useWt&&(_&1)==0&&!a.every(h=>{let I=H._CheckMissingPacket(B.global.point,B.global.size,h,t.ssrc,this.io.rtt);return I>0&&(B.global.setBigUint64(5,BigInt(this.tinyId)),this.io.send(B.global.uint8Array(I))),I>=0}))),Fe(e),ee(d,c,c)),d(),Y(Pe(5e3),Fe(e),ee(d))}};var jc=1e8;function Yc(){let n=new B(500,[0]);return H._GetAudioEnergy(n.point,100),n}var Wt=class extends Te{constructor(){super(...arguments);m(this,"audioReceivedBuff",new B(2048));m(this,"levelsMap",new Map);m(this,"timestampBuff",new B(12))}["decodeAudio"](e,r){Y(this.createResposeOb(4095),Fe(r),ee(({data:s})=>{let c=new DataView(s.buffer,s.byteOffset,s.byteLength).getBigUint64(9).toString();this.userMap_.has(c)&&(this.statReportReq.msg_net_stat_report.uint32_down_real_pkg++,this.statReportReq.msg_net_stat_report.uint32_down_recv_br+=s.byteLength,this.demuxPacket(s,this.userMap_.get(c),e&&r))})),e&&Y(r,ee(({timestamp:s,rtpTimestamp:a,seqNum:c,ssrc:f,data:l})=>{this.audioReceivedBuff.set(l),H._ReceivedRawAudioPacket(this.audioReceivedBuff.point,l.byteLength,s,a,c,f)}))}["pullAudio"]({tinyId:e,writable:r}){let s=this.userMap_.get(e);s&&(s.audioPuller=new Br(r.getWriter(),s.mainPuller.ssrc))}["getAudioEnergy"](e,r){Wt.energys||(Wt.energys=Yc());let{energys:s}=Wt;Y(Pe(e),Fe(r),ee(()=>{let a=s.getInt8(0);for(let c=1;c<5*a;c+=5)this.levelsMap.set(s.getUint32(c),s.getInt8(c+4));if(this.userMap_.size>0){let c=[...this.userMap_.values()];r.postMessage(c.map(f=>{let l=Math.min(100,(this.levelsMap.get(f.mainPuller.ssrc)||0)*2);return f.msg_audio_status.uint32_audio_level=l*jc/100>>0,{userId:f.userId,volume:l}}))}else r.postMessage([])}))}demuxPacket(e,r,s){let{aBlock:a,msg_audio_status:c}=r;a.received.next(!0),c.uint32_audio_total_bitrate+=e.byteLength<<3,c.uint32_audio_codec_bitrate=c.uint32_audio_total_bitrate-31,this.audioReceivedBuff.set(e);let f=Date.now(),l=f/1e3,d=f%1e3;if(s){let _=H._ParseUdtAudioPacket(this.audioReceivedBuff.point,e.length,this.timestampBuff.point,this.timestampBuff.point+4,this.timestampBuff.point+8,this.audioReceivedBuff.point,r.mainPuller.ssrc);if(_>0){let h=this.audioReceivedBuff.getUint32(0),I=H.HEAPU8.slice(h,h+_);s.postMessage({timestamp:this.timestampBuff.getUint32(0),rtpTimestamp:this.timestampBuff.getUint32(4),seqNum:this.timestampBuff.getUint32(8),data:I,ssrc:r.mainPuller.ssrc},[I.buffer])}}else H._ReceivedAudioUdtPacket(this.audioReceivedBuff.point,e.length,l,d,r.mainPuller.ssrc)}},Et=Wt;m(Et,"energys");var io=lr(Ft(),1),so=Symbol("instance"),zm=Symbol("abortCtrl"),qr=Symbol("cacheResult"),Gt=class{constructor(t,e,r){this.oldState=t,this.newState=e,this.action=r,this.aborted=!1}abort(t){this.aborted=!0,Yt.call(t,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}},nt=class extends Error{constructor(t,e,r){super(e),this.state=t,this.message=e,this.cause=r}};function $c(n){return typeof n=="object"&&n&&"then"in n}var jt=new Map;function he(n,t,e={}){return(r,s,a)=>{let c=e.action||s;if(!e.context){let l=jt.get(r)||[];jt.has(r)||jt.set(r,l),l.push({from:n,to:t,action:c})}let f=a.value;a.value=function(...l){let d=this;if(e.context&&(d=$.get(typeof e.context=="function"?e.context.call(this,...l):e.context)),d.state===t)return e.sync?d[qr]:Promise.resolve(d[qr]);d.state instanceof Gt&&d.state.action==e.abortAction&&d.state.abort(d);let _=null;Array.isArray(n)?n.length==0?d.state instanceof Gt&&d.state.abort(d):(typeof d.state!="string"||!n.includes(d.state))&&(_=new nt(d._state,`${d.name} ${c} to ${t} failed: current state ${d._state} not from ${n.join("|")}`)):n!==d.state&&(_=new nt(d._state,`${d.name} ${c} to ${t} failed: current state ${d._state} not from ${n}`));let h=R=>{if(e.fail&&e.fail.call(this,R),e.sync){if(e.ignoreError)return R;throw R}else return e.ignoreError?Promise.resolve(R):Promise.reject(R)};if(_)return h(_);let I=d.state,U=new Gt(I,t,c);Yt.call(d,U);let O=R=>{var w;return d[qr]=R,U.aborted||(Yt.call(d,t),(w=e.success)===null||w===void 0||w.call(this,d[qr])),R},J=R=>(Yt.call(d,I,R),h(R));try{let R=f.apply(this,l);return $c(R)?R.then(O).catch(J):e.sync?O(R):Promise.resolve(O(R))}catch(R){return J(new nt(d._state,`${d.name} ${c} from ${n} to ${t} failed: ${R}`,R instanceof Error?R:new Error(String(R))))}}}}var Kc=(()=>typeof window!="undefined"&&window.__AFSM__?(e,r)=>{window.dispatchEvent(new CustomEvent(e,{detail:r}))}:typeof importScripts!="undefined"?(e,r)=>{postMessage({type:e,payload:r})}:()=>{})();function Yt(n,t){let e=this._state;this._state=n;let r=n.toString();n&&this.emit(r,e),this.emit($.STATECHANGED,n,e,t),this.updateDevTools({value:n,old:e,err:t instanceof Error?t.message:String(t)})}var $=class extends io.default{constructor(t,e,r){super(),this.name=t,this.groupName=e,this._state=$.INIT,t||(t=Date.now().toString(36)),r?Object.setPrototypeOf(this,r):r=Object.getPrototypeOf(this),e||(this.groupName=this.constructor.name);let s=r[so];s?this.name=s.name+"-"+s.count++:r[so]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let t=Object.getPrototypeOf(this),e=jt.get(t)||[],r=new Set,s=[],a=[],c=new Set,f=Object.getPrototypeOf(t);jt.has(f)&&(f.stateDiagram.forEach(d=>r.add(d)),f.allStates.forEach(d=>c.add(d))),e.forEach(({from:d,to:_,action:h})=>{typeof d=="string"?s.push({from:d,to:_,action:h}):d.length?d.forEach(I=>{s.push({from:I,to:_,action:h})}):a.push({to:_,action:h})}),s.forEach(({from:d,to:_,action:h})=>{c.add(d),c.add(_),c.add(h+"ing"),r.add(`${d} --> ${h}ing : ${h}`),r.add(`${h}ing --> ${_} : ${h} \u{1F7E2}`),r.add(`${h}ing --> ${d} : ${h} \u{1F534}`)}),a.forEach(({to:d,action:_})=>{r.add(`${_}ing --> ${d} : ${_} \u{1F7E2}`),c.forEach(h=>{h!==d&&r.add(`${h} --> ${_}ing : ${_}`)})});let l=[...r];return Object.defineProperties(t,{stateDiagram:{value:l},allStates:{value:c}}),l}static get(t){let e;return typeof t=="string"?(e=$.instances.get(t),e||$.instances.set(t,e=new $(t,void 0,Object.create($.prototype)))):(e=$.instances2.get(t),e||$.instances2.set(t,e=new $(t.constructor.name,void 0,Object.create($.prototype)))),e}static getState(t){var e;return(e=$.get(t))===null||e===void 0?void 0:e.state}updateDevTools(t={}){Kc($.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(t){Yt.call(this,t)}};$.STATECHANGED="stateChanged";$.UPDATEAFSM="updateAFSM";$.INIT="[*]";$.ON="on";$.OFF="off";$.instances=new Map;$.instances2=new WeakMap;var Jc=function(n,t,e,r){function s(a){return a instanceof e?a:new e(function(c){c(a)})}return new(e||(e=Promise))(function(a,c){function f(_){try{d(r.next(_))}catch(h){c(h)}}function l(_){try{d(r.throw(_))}catch(h){c(h)}}function d(_){_.done?a(_.value):s(_.value).then(f,l)}d((r=r.apply(n,t||[])).next())})},Ws=Symbol(32),Gs=Symbol(16),js=Symbol(8),Ne=class{constructor(t){this.g=t,this.consumed=0,t&&(this.need=t.next().value)}setG(t){this.g=t,this.demand(t.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(t,e){return e&&this.consume(),this.need=t,this.flush()}read(t){return Jc(this,void 0,void 0,function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise((e,r)=>{var s;this.reject=r,this.resolve=c=>{delete this.lastReadPromise,delete this.resolve,delete this.need,e(c)},this.demand(t,!0)||(s=this.pull)===null||s===void 0||s.call(this,t)})})}readU32(){return this.read(Ws)}readU16(){return this.read(Gs)}readU8(){return this.read(js)}close(){var t;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),(t=this.reject)===null||t===void 0||t.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let t=null,e=this.buffer.subarray(this.consumed),r=0,s=a=>e.length<(r=a);if(typeof this.need=="number"){if(s(this.need))return;t=e.subarray(0,r)}else if(this.need===Ws){if(s(4))return;t=e[0]<<24|e[1]<<16|e[2]<<8|e[3]}else if(this.need===Gs){if(s(2))return;t=e[0]<<8|e[1]}else if(this.need===js){if(s(1))return;t=e[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(s(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(e.subarray(0,r)),t=this.need}else if(this.g){this.g.throw(new Error("Unsupported type"));return}}else{if(s(this.need.byteLength))return;new Uint8Array(this.need).set(e.subarray(0,r)),t=this.need}return this.consumed+=r,this.g?this.demand(this.g.next(t).value,!0):this.resolve&&this.resolve(t),t}write(t){if(t instanceof Uint8Array?this.malloc(t.length).set(t):"buffer"in t?this.malloc(t.byteLength).set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)):this.malloc(t.byteLength).set(new Uint8Array(t)),this.g||this.resolve)this.flush();else return new Promise(e=>this.pull=e)}writeU32(t){this.malloc(4).set([t>>24&255,t>>16&255,t>>8&255,t&255]),this.flush()}writeU16(t){this.malloc(2).set([t>>8&255,t&255]),this.flush()}writeU8(t){this.malloc(1)[0]=t,this.flush()}malloc(t){if(this.buffer){let e=this.buffer.length,r=e+t;if(r<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,r);else{let s=new Uint8Array(r);s.set(this.buffer),this.buffer=s}return this.buffer.subarray(e,r)}else return this.buffer=new Uint8Array(t),this.buffer}};Ne.U32=Ws;Ne.U16=Gs;Ne.U8=js;var Qe=class extends ${constructor(e){super(e.params.userId,"WebSocket");this.connectFSM=e;m(this,"ws")}connect(){this.connectFSM.log_.info("connect to",this.connectFSM.wsUrl);let e=new WebSocket(this.connectFSM.wsUrl);return console.time("WebSocket connect"),e.binaryType="arraybuffer",Xe((r,s)=>{e.onerror=a=>{e.onmessage=null,this.connectFSM.log_.error("websocket onerror",a),s(a.type)},e.onclose=a=>{e.onmessage=null,s(a),this.connectFSM.log_.info("websocket onclose",a),this.disconnect(a.reason,a.code)},e.onopen=a=>{console.timeEnd("WebSocket connect"),this.connectFSM.log_.info("websocket onopen")},e.onmessage=a=>{try{let c=JSON.parse(String(a.data));if(this.connectFSM.log_.info("websocket verify",c),c.err!==0)throw c.err;this.connectFSM.verify(c.verify,c.rebuild),this.ws=e,r(e);let f=this.connectFSM.createOputReceiver("w");e.onmessage=l=>f.write(l.data)}catch(c){s(c)}}},this.connectFSM.abortCtrl.signal)}disconnect(e="",r=0){return r===0&&this.ws&&(this.ws.onmessage=null,this.ws.close(1e3,e)),this.connectFSM.log_.warn("websocket disconnected :",r,e),this.connectFSM.disconnect(e)}close(){!this.ws||(this.ws.onmessage=null,this.ws.close(1e3,"close"))}sendReq(e,r,s){this.send(Lr(e,r,s||this.connectFSM.generateUUID()))}send(e){var r;this.state=="CONNECTED"&&((r=this.ws)==null||r.send(e))}};me([he(["DISCONNECTED",$.INIT],"CONNECTED")],Qe.prototype,"connect",1),me([he("CONNECTED","DISCONNECTED",{sync:!0,ignoreError:!0})],Qe.prototype,"disconnect",1),me([he([],$.INIT,{sync:!0})],Qe.prototype,"close",1);var bf=new Uint32Array([Date.now()]),Xc=Y(mr(20),yr(()=>performance.now()),mt()),$s=class{constructor(t){this.wt=t;m(this,"chunk",new Map);m(this,"timestamp",performance.now());m(this,"groupId");m(this,"resentCount",0);this.groupId=t.groupid,t.groupid=t.groupid+1&127,t.sentCache.has(this.groupId)&&t.sentCache.get(this.groupId).chunk.clear(),t.sentCache.set(this.groupId,this),Y(Xc,ji(()=>this.chunk.size>0&&this.resentCount<20),Ue(ve(t,"DISCONNECTED")),ee(e=>{e-this.timestamp>2*t.connectFSM.rtt+10&&(this.chunk.forEach((r,s)=>this.wt.send(r.buffer)),console.debug("resent",this.groupId,this.chunk.size,"after",e-this.timestamp,"ms",++this.resentCount),this.timestamp=e)},console.error,()=>{this.wt.sentCache.delete(this.groupId)}))}ack(t){this.chunk.delete(t)}},ze=class extends ${constructor(e){super(e.params.userId,"WebTransport");this.connectFSM=e;m(this,"wt");m(this,"writer");m(this,"dw");m(this,"sentCache",new Map);m(this,"groupid",0);m(this,"mtu",1e3)}async connect(){this.connectFSM.log_.info("connect to",this.connectFSM.wtUrl);let e=new WebTransport(this.connectFSM.wtUrl);console.time("WebTransport connect"),e.ready.then(()=>console.timeEnd("WebTransport connect"));let r=this.connectFSM.abortCtrl.signal,{value:s,stream:a}=await Promise.race([(async()=>{await Xe(e.ready,r);let f=await Xe(e.createBidirectionalStream(),r),l=f.readable.getReader();return this.writer=f.writable.getWriter(),this.dw=e.datagrams.writable.getWriter(),Xe(l.read(),r).then(({value:d})=>(l.releaseLock(),{value:d,stream:f}))})(),new Promise((f,l)=>setTimeout(()=>l(new Error("WebTransport connect timeout")),1e3))]),c=JSON.parse(String.fromCharCode(...s));if(this.connectFSM.log_.info("WebTransport connect result:",c),c.err!==0)throw c.err;this.connectFSM.verify(c.verify,c.rebuild),this.wt=e,Y(ve(this.connectFSM,oe[4099]),Ue(ve(this,"DISCONNECTED")),ee(({data:f})=>{let l=f[0]&127,d=this.sentCache.get(l);!d||d.ack(f[1])})),Promise.race([e.datagrams.readable.pipeTo(new WritableStream(this.connectFSM.createOputReceiver("d"))),a.readable.pipeTo(new WritableStream(this.connectFSM.createOputReceiver("s"))),e.closed]).then(()=>this.disconnect(),this.disconnect.bind(this))}disconnect(e=""){var r;return(r=this.wt)==null||r.close(),this.connectFSM.disconnect(e)}close(){var e;return(e=this.wt)==null?void 0:e.close()}async sendReq(e,r,s){if(s||(s=this.connectFSM.generateUUID()),!this.wt)return new Error("WebTransport not connected");if(!re.unreliable){let U=Lr(e,r,s);return this.writer.write(U).then(()=>!0).catch(this.catchError)}let a=e>=255&&e<4095,c=JSON.stringify(r),f=0,l=c.length+(a?20:16),_=(l>65535?1:0)?7:5,h=Math.ceil(l/this.mtu),I=new $s(this);console.debug("WebTransport send:",a?"ack":"",oe[e],s,"chunks:",h,I.groupId);for(let U=0;U<h;U++){let O=l-U*this.mtu,J=Math.min(this.mtu,O),R=new Uint8Array(_+4+J),w=Fs(e,R.length-_,new DataView(R.buffer));if(R[0]|=2,R.set([1,2,(U==h-1?1<<7:0)|I.groupId,U],w),w+=4,U==0){a&&(R.set([0,0,0,0],w),w+=4);for(let X=0;X<16;X++)R[w++]=s.charCodeAt(X)}for(let X=0;w<R.length;X++)R[w++]=c.charCodeAt(f++);I.chunk.set(U,R),this.send(R.buffer)}}async send(e){if(!(!this.wt||!this.dw)){if(e instanceof ArrayBuffer){if(!e.byteLength)throw oo}else{if(!e.length)throw oo;e=e.slice(0)}return this.dw.write(e).catch(this.catchError)}}catchError(e){}};me([he(["DISCONNECTED",$.INIT],"CONNECTED")],ze.prototype,"connect",1),me([he("CONNECTED","DISCONNECTED",{sync:!0,ignoreError:!0})],ze.prototype,"disconnect",1),me([he([],$.INIT,{sync:!0})],ze.prototype,"close",1);var oo=new Error("WebTransport send empty datagram");var st="5.0.0";var ao=typeof importScripts!="undefined",Wr=typeof registerProcessor!="undefined";var Ks="";var Qc="web.sdk.qcloud.com";var zc=`https://${Qc}/trtc/webrtc/v5/doc`;var Ef=`${zc}/zh-cn/`,uo="https://yun.tim.qq.com",co="https://apisgp.my-imcloud.com";var lo={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"};var We=(c=>(c[c.TRACE=0]="TRACE",c[c.DEBUG=1]="DEBUG",c[c.INFO=2]="INFO",c[c.WARN=3]="WARN",c[c.ERROR=4]="ERROR",c[c.NONE=5]="NONE",c))(We||{}),po=18e3;var Tf=7*24*3600*1e3;var Gr={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADEDDATA:"loadeddata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture"};var St=1,jr=2,Yr=4,yt=8,It=64,At=16;var Sf=Gr.MAIN,yf=Gr.AUXILIARY;var mo=30;var If=Gr.BIG,Af=Gr.SMALL,Rf=10*1e3;var xf=Object.keys(We),fo=["normal leave","timeout leave","kick","role change"];var vf=10*1e3;var bo=lr(Ft(),1);var el=n=>Number(n)<14e8,_o=function(n,t){let e;Ks?e=Ks:e=el(n)?co:uo;let r=Math.floor(Math.random()*2**31);return`${e}/v5/AVQualityReportSvc/C2S?random=${r}&sdkappid=${n}&cmdtype=${t}`};var kf=typeof window!="undefined"&&typeof window.glog=="function"?window.glog:()=>{};var $r=n=>typeof n=="undefined",Js=n=>typeof n=="string",ho=n=>typeof n=="number";var{toString:Bf}=Object.prototype;function Xs(n,t){return{userId:t,hasAudio:!!(n&yt),hasVideo:!!(n&St),hasAuxiliary:!!(n&Yr),hasSmall:!!(n&jr),audioMuted:!!(n&It),videoMuted:!!(n&At),audioAvailable:!!(n&yt)&&!(n&It),videoAvailable:!!(n&St)&&!(n&At)}}var Kr=class extends bo.EventEmitter{constructor(e,r,s="userId"){super();this.mySelfId=e;this._log=r;this.key=s;this.userMap=new Map;this.remotePublishedUserMap=new Map}get hasRobotUser(){return!![...this.remotePublishedUserMap.values()].find(e=>e.isRobot)}getPublishedUser(e){return this.remotePublishedUserMap.get(e)}addUser(e){let r=e[this.key],{userId:s,tinyId:a,role:c}=e;if(this.userMap.has(r))return;let f={userId:s,tinyId:a,role:c===20?"anchor":"audience"};this.userMap.set(r,f),this.emit("1",f)}deleteUser(e,r){let s=this.userMap.get(e);if(!s)return;let a=`peer leave [${e}]`;$r(r)||(a+=`:${fo[r]}`),this._log.info(a);let c=this.remotePublishedUserMap.get(e);if(c){let f=c.muteState;c.flag=0,this.emit("5",c.userId),this.deleteRemotePublishedUser(e),this.emit("6",{prevMuteState:f,muteState:c.muteState,flag:0})}this.userMap.delete(e),this.emit("2",s.userId)}setUserList(e){this.userMap.forEach(r=>{e.findIndex(s=>s[this.key]===r[this.key])<0&&this.deleteUser(r[this.key],0)}),e.forEach(r=>{!this.userMap.has(r[this.key])&&r[this.key]!==this.mySelfId&&this.addUser(r)})}addRemotePublishedUser(e){this.remotePublishedUserMap.has(e[this.key])||this.remotePublishedUserMap.set(e[this.key],e)}deleteRemotePublishedUser(e){!this.remotePublishedUserMap.has(e)||this.remotePublishedUserMap.delete(e)}setRemotePublishedUserList(e){this.remotePublishedUserMap.forEach(r=>{let s=r[this.key];if(e.findIndex(a=>a[this.key]===r[this.key])<0){this._log.info(`remote [${s}] unpublish`);let a=r.muteState;r.flag=0,this.emit("5",r.userId),this.deleteRemotePublishedUser(s),this.emit("6",{prevMuteState:a,muteState:r.muteState,flag:0})}}),e.forEach(r=>{var _;let s=r[this.key];if(s===this.mySelfId)return;let{flag:a,userId:c,tinyId:f}=r,l=Xs(a,c),d=(_=this.remotePublishedUserMap.get(s))==null?void 0:_.muteState;if(d){let h=this.remotePublishedUserMap.get(s);h&&h.flag!==a&&(h.flag=a,this._log.info(`remote publish updated: ${JSON.stringify(h.muteState)}`),this.emit("6",{prevMuteState:d,muteState:l,flag:a}))}else this._log.info(`remote publish. state: ${JSON.stringify(l)}`),this.addUser({userId:c,tinyId:f,role:20}),this.emit("3",r),this.emit("6",{prevMuteState:Xs(0,c),muteState:l,flag:a})})}clear(){this.userMap.clear(),this.remotePublishedUserMap.clear()}};var Jf=new Date().getTime(),tl=0;var Qs=function(){return new Date().getTime()+tl},go=function(){let n=new Date;return n.setTime(Qs()),n.toLocaleString()};function Eo({url:n,body:t,method:e="POST",timeout:r,priority:s}){return new Promise((a,c)=>{if("fetch"in window)return fetch(n,{method:e,body:t,priority:s}).then(l=>l.text()).then(l=>{try{a({data:JSON.parse(l)})}catch(d){a({data:l})}},c);let f=new XMLHttpRequest;f.onreadystatechange=()=>{if(f.readyState===4)if(f.status>=200&&f.status<300)try{let l=JSON.parse(f.response);a({data:l})}catch(l){a({data:f.response})}else c({status:f.status,statusText:f.statusText||"request failed!"})},f.timeout=r||5e3,f.open(e,n,!0),f.send(t)})}var rl=Object.prototype.hasOwnProperty;var xt=n=>typeof n=="function",To=n=>typeof n=="undefined";var So=n=>typeof n=="boolean";var nl=function(n){if(!n||typeof n!="object"||Object.prototype.toString.call(n)!="[object Object]")return!1;let t=Object.getPrototypeOf(n);if(t===null)return!0;let e=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&Function.prototype.toString.call(e)===Function.prototype.toString.call(Object)};function yo(n){if(n==null)return!0;if(typeof n=="boolean")return!1;if(typeof n=="number")return n===0;if(typeof n=="string"||typeof n=="function"||Array.isArray(n))return n.length===0;if(n instanceof Error)return n.message==="";if(nl(n))switch(Object.prototype.toString.call(n)){case"[object File]":case"[object Map]":case"[object Set]":return n.size===0;case"[object Object]":{for(let t in n)if(rl.call(n,t))return!1;return!0}}return!1}var sl=0,il=1,Io=2;function ol({retryFunction:n,settings:t,onError:e,onRetrying:r,onRetryFailed:s,onRetrySuccess:a,context:c}){return function(...f){let{retries:l=5,timeout:d=1e3}=t,_=0,h=-1,I=sl,U=async(O,J)=>{let R=c||this;try{let w=await n.apply(R,f);_>0&&a&&a.call(this,_),_=0,O(w)}catch(w){let X=()=>{clearTimeout(h),_=0,I=Io,J(w)},ye=()=>{I!==Io&&_<(xt(l)?l():l)?(_++,I=il,xt(r)&&r.call(this,_,X),h=window.setTimeout(()=>{h=-1,U(O,J)},xt(d)?d(_):d)):(X(),xt(s)&&s.call(this,w))};xt(e)?e.call(this,{error:w,retry:ye,reject:J,retryFuncArgs:f,retriedCount:_}):ye()}};return new Promise(U)}}var Ao=ol;var $t=class{constructor(t){m(this,"userId");m(this,"remoteUserId");m(this,"id");m(this,"sdkAppId");m(this,"type");m(this,"isLocal");this.id=t.id,this.userId=t.userId,this.sdkAppId=t.sdkAppId,this.remoteUserId=t.remoteUserId,this.isLocal=So(t.isLocal)?t.isLocal:!0,this.type=this.isLocal?"":t.type}createChild(t){return Object.setPrototypeOf(t,this)}setUserId(t){this.userId=t}setSdkAppId(t){this.sdkAppId=t}log(t,e){let r=this.isLocal?this.userId:this.remoteUserId;e.unshift(`[${this.isLocal?"\u2191":"\u2193"}${this.type&&this.type!=="main"?"*":""}${this.id}${r?`|${r}`:""}]`),Rt.log(t,e,To(this.userId)||yo(this.userId),this.userId,this.sdkAppId)}info(...t){this.log(2,t)}debug(...t){this.log(1,t)}warn(...t){this.log(3,t)}error(...t){this.log(4,t)}};var Me=typeof navigator=="undefined"?"":navigator.userAgent,k=n=>new RegExp(n,"i").test(Me),ae=n=>{if(k(n)){let t=new RegExp(`${n}\\/([\\d.]+)`),e=Me.match(t);if(e&&e[1])return e[1]}return""},zs=n=>{if(k(n)){let t=new RegExp(`${n}\\/(\\d+)`),e=Me.match(t);if(e&&e[1])return parseFloat(e[1])}return NaN},Ro=/AppleWebKit\/([\d.]+)/i.exec(Me),al=Ro?parseFloat(Ro[1]):NaN,vo=k("iPad"),Uo=typeof navigator!="undefined"&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&k("Macintosh"),Oo=k("iPhone")&&!vo,ul=k("iPod"),Jr=Oo||vo||ul||Uo,vt=k("Android"),Po=function(){if(vt){let n=Me.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(n){let t=n[1]&&parseFloat(n[1]),e=n[2]&&parseFloat(n[2]);if(t&&e)return parseFloat(`${n[1]}.${n[2]}`);if(t)return t}}return NaN}(),u_=vt&&k("webkit")&&Po<2.3,c_=vt&&Po<5&&al<537,cl=k("Firefox"),ll=ae("Firefox"),l_=zs("Firefox"),No=k("Edge"),dl=ae("Edge"),Co=k("Edg"),pl=ae("Edg"),d_=zs("Edg"),wo=k("SogouMobileBrowser"),ml=ae("SogouMobileBrowser"),Do=k("MetaSr\\s"),fl=ae("MetaSr\\s"),it=k("TBS"),_l=ae("TBS"),Lo=k("XWEB"),hl=ae("XWEB"),p_=k("MSIE\\s8\\.0"),bl=k("MSIE\\/\\d+"),m_=function(){if(bl){let n=/MSIE\s(\d+)\.\d/.exec(Me),t=n&&parseFloat(n[1]);return!t&&/Trident\/7.0/i.test(Me)&&/rv:11.0/.test(Me)&&(t=11),t}return NaN}(),gl=k("(micromessenger|webbrowser)"),El=ae("MicroMessenger"),Zs=!it&&k("MQQBrowser")&&k("COVC"),ei=!it&&k("MQQBrowser")&&!k("COVC"),xo=ei||Zs?ae("MQQBrowser"):"",Mo=!it&&k(" QQBrowser"),Tl=ae(" QQBrowser"),ko=!it&&k("QQBrowserLite"),Sl=ae("QQBrowserLite"),Bo=!it&&k("MQBHD"),yl=ae("MQBHD"),f_=k("Windows"),__=!Jr&&k("MAC OS X"),h_=!vt&&k("Linux"),b_=k("CrOS"),g_=k("MicroMessenger"),E_=k("UCBrowser"),T_=k("Electron"),Vo=k("MiuiBrowser"),Il=ae("MiuiBrowser"),Fo=k("HuaweiBrowser"),S_=k("Huawei")||k("HUAWEI"),y_=k("Honor")||k("HONOR"),Al=ae("HuaweiBrowser"),Ho=k("SamsungBrowser"),Rl=ae("SamsungBrowser"),qo=k("HeyTapBrowser"),xl=ae("HeyTapBrowser"),Wo=k("VivoBrowser"),vl=ae("VivoBrowser"),Ul=()=>zs("Chrome"),Go=k("Chrome"),Ol=!No&&!Do&&!wo&&!it&&!Lo&&!Co&&!Mo&&!Vo&&!Fo&&!Ho&&!qo&&!Wo&&Go,jo=k("HeadlessChrome"),I_=Ul(),Pl=ae("Chrome"),Nl=!Go&&!ei&&!Zs&&!ko&&!Bo&&k("Safari");var Yo=ae("Version"),A_=/Android.*(wv|.0.0.0)/.test(Me),$o=(()=>{if(Uo)return Yo;if(Jr){let n=Me.match(/OS (\d+)_(\d+)/i);if(n&&n[1]){let t=n[1];return n[2]&&(t+=`.${n[2]}`),t}}return""})(),R_=Number($o.split(".")[0]);var x_=(()=>{let n=Number($o.split(".")[0]);return n===14||n===13})(),v_=typeof location=="undefined"?!1:location.protocol==="file:"||location.hostname==="localhost"||location.hostname==="127.0.0.1",U_=(()=>{let n;return()=>{if(typeof n=="undefined")try{n=!!window.localStorage}catch(t){n=!1}return n}})(),O_=Cl();function Cl(){let n=new Map([[cl,["Firefox",ll]],[Co,["Edg",pl]],[Ol,["Chrome",Pl]],[Nl,["Safari",Yo]],[it,["TBS",_l]],[Lo,["XWEB",hl]],[gl&&Oo,["WeChat",El]],[Mo,["QQ(Win)",Tl]],[ei,["QQ(Mobile)",xo]],[Zs,["QQ(Mobile X5)",xo]],[ko,["QQ(Mac)",Sl]],[Bo,["QQ(iPad)",yl]],[Vo,["MI",Il]],[Fo,["HW",Al]],[Ho,["Samsung",Rl]],[qo,["OPPO",xl]],[Wo,["VIVO",vl]],[No,["EDGE",dl]],[wo,["SogouMobile",ml]],[Do,["Sogou",fl]]]),t="unknown",e="unknown";return n.has(!0)&&([t,e]=n.get(!0)),{name:t,version:e}}var Ko=lr(Ft(),1),wl=new Ko.default,Ut=wl;var ti=(C=>(C.ROOM_DESTROY="1",C.JOIN_START="21",C.JOIN_SCHEDULE_SUCCESS="22",C.JOIN_SIGNAL_CONNECTION_START="23",C.JOIN_SIGNAL_CONNECTION_END="24",C.JOIN_SEND_CMD="25",C.JOIN_RECEIVED_CMD_RES="26",C.JOIN_SUCCESS="27",C.JOIN_FAILED="28",C.LEAVE_START="51",C.LEAVE_SEND_CMD="52",C.LEAVE_SUCCESS="53",C.PUBLISH_START="61",C.SEND_FIRST_VIDEO_FRAME="62",C.PUBLISH_FAILED="63",C.SUBSCRIBE_START="81",C.SUBSCRIBE_SUCCESS="82",C.SUBSCRIBE_FAILED="84",C.UNSUBSCRIBE_SUCCESS="83",C.LOCAL_TRACK_CAPTURE_START="101",C.LOCAL_TRACK_CAPTURE_SUCCESS="102",C.LOCAL_TRACK_CAPTURE_FAILED="103",C.LOCAL_TRACK_PUBLISHED="104",C.LOCAL_TRACK_UNPUBLISHED="105",C.LOCAL_TRACK_REPLACED="106",C.SWITCH_DEVICE_SUCCESS="107",C.TRACK_MUTED="108",C.TRACK_UNMUTED="109",C.REMOTE_TRACK_SUBSCRIBED="110",C.REMOTE_TRACK_UNSUBSCRIBED="111",C.LOCAL_TRACK_RECAPTURE="112",C.PLAY_TRACK_START="151",C.PLAYER_STATE_CHANGED="152",C.VIDEO_LOADED_DATA="153",C.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",C.SIGNAL_CONNECTION_STATE_CHANGED="201",C.PEER_CONNECTION_STATE_CHANGED="202",C.SINGLE_CONNECTION_STAT="203",C.SPC_RECONNECTED="204",C.HEARTBEAT_REPORT="251",C.RECEIVED_PUBLISHED_USER_LIST="252",C.REMOTE_PUBLISH_STATE_CHANGED="253",C.AUDIO_LEVEL_INTERVAL="260",C.NETWORK_QUALITY="261",C.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",C.QUALITY_LIMITATION_CHANGED="263",C.LOG="264",C))(ti||{});var Ze=ti;var Dl="%cTRTC%c%s",Ll="padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;",Ml="display: inline",kl=!(Jr||vt||jo),ri=class{constructor(){this._isEnableUploadLog=!0;this._localJoinedUser=new Map;this._queue=[];this._timeoutId=-1;this._logLevel=1;this._logLevelToUpload=2;!ao&&!Wr&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&this._timeoutId!==-1}installEvents(){Ut.on(Ze.JOIN_SCHEDULE_SUCCESS,({schedule:t})=>{var e;((e=t==null?void 0:t.config)==null?void 0:e.logLevelToUpload)&&We[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)}),Ut.on(Ze.JOIN_SUCCESS,({room:t})=>{this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()}),Ut.once(Ze.JOIN_FAILED,()=>{this.startUpload()}),Ut.on(Ze.LEAVE_SUCCESS,({room:t})=>{this.deleteJoinedUser(t.userId)})}startUpload(){this._timeoutId===-1&&this.uploadInterval()}addJoinedUser(t){this._localJoinedUser.set(t.userId,t),this.startUpload()}deleteJoinedUser(t){this._localJoinedUser.delete(t)}uploadInterval(){this.upload().catch(()=>{}),this._timeoutId=window.setTimeout(()=>this.uploadInterval(),5e3)}getLogsToUpload(){let t={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&this._localJoinedUser.size===0)return t;let e=0;for(;e<this._queue.length&&e!==50;e++){let r=this._queue[e];if(r.forAllJoinedClients)this._localJoinedUser.forEach(({userId:s,sdkAppId:a})=>{t.map.has(s)?t.map.get(s).logs.push(r):t.map.set(s,{userId:s,sdkAppId:a,logs:[r]})});else if(Js(r.userId)&&ho(r.sdkAppId)){let{userId:s,sdkAppId:a}=r;t.map.has(s)?t.map.get(s).logs.push(r):t.map.set(s,{userId:s,sdkAppId:a,logs:[r]})}}return t.map.size>0&&(t.splicedQueue=this._queue.splice(0,e)),t}async upload(){if(this._queue.length===0||!this._isEnableUploadLog)return;let{map:t,splicedQueue:e}=this.getLogsToUpload();if(t.size===0)return;try{let s=[...t.values()];for(let a=0;a<s.length;a++){let{userId:c,sdkAppId:f,logs:l}=s[a];await this.uploadLogWithRetry(JSON.stringify({timestamp:go(),sdkAppId:String(f),userId:c,version:st,log:l.map(d=>d.log).join(`
2
- `)}),f),l.forEach(d=>d.uploaded=!0)}}catch(s){}let r=e.filter(s=>!s.uploaded);r.length>0&&(this._queue=r.concat(this._queue))}uploadLogWithRetry(t,e){return Ao({retryFunction:()=>Eo({url:_o(e,lo.LOG),body:t,timeout:5e3,priority:"low"}),settings:{retries:3,timeout:2e3},onError:({retry:r})=>{r()}})()}getPrefix(t){let e=new Date;e.setTime(Qs());let r=String(e.getMilliseconds());return"padStart"in String.prototype&&(r=r.toString().padStart(3,"0")),`[${e.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")}:${r}] <${We[t]}>`}getLogLevel(){return this._logLevel}setLogLevel(t){$r(We[t])||(this._logLevel!==t&&this.info("setLogLevel",t),this._logLevel=t)}enableUploadLog(){this._isEnableUploadLog=!0}disableUploadLog(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}logChunkToString(t){if(Js(t))return t;try{return t instanceof Error?t.toString():JSON.stringify(t)}catch(e){return""}}log(t,e,r=!0,s,a){var l;e.unshift(this.getPrefix(t));let c={log:e.reduce((d,_)=>`${d} ${this.logChunkToString(_)}`.trim(),""),level:t,userId:s,sdkAppId:a,forAllJoinedClients:r};if(Ut.emit(Ze.LOG,{log:c}),this._isEnableUploadLog&&t>=this._logLevelToUpload&&this._queue.push(c),t<this._logLevel)return;let f=((l=We[t])==null?void 0:l.toLowerCase())||"info";kl?console[f](Dl,Ll,Ml,...e):console[f](...e)}debug(...t){this.log(1,t)}info(...t){this.log(2,t)}warn(...t){this.log(3,t)}error(...t){this.log(4,t)}createLogger(t){return new $t(t)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),r=e?Number(e):-1;We[r]&&(this._logLevelToUpload=r)}getQueue(){return this._queue}},Rt=new ri;function Jo(n,t=1,e=1){return n<=1?e:Jo(n-1,e,t+e)}function Hl(n){return n>8?30*1e3:Jo(n)*1e3}function ql(n,t){return{userId:t,hasAudio:!!(n&yt),hasVideo:!!(n&St),hasAuxiliary:!!(n&Yr),hasSmall:!!(n&jr),audioMuted:!!(n&It),videoMuted:!!(n&At),audioAvailable:!!(n&yt)&&!(n&It),videoAvailable:!!(n&St)&&!(n&At)}}var ni=class{constructor(t){this.connect=t;m(this,"publishReq");m(this,"recovering",!1);m(this,"pingCount",0)}async recoverLocal(){return this.recovering=!0,this.publishReq?this.connect._sendReq(2,this.publishReq).then(t=>{this.connect.log_.info("republish",t)}):!1}recoverRemote(t){this.recovering=!1,t.forEach((e,r)=>{this.connect.sendSubscribe(e)})}onSendReq(t,e){switch(t){case 2:this.publishReq?this.publishReq.mediaType|=e.mediaType:this.publishReq=e;break;case 3:this.publishReq=void 0;break;case 8:this.publishReq&&(this.publishReq.mediaType&=~e.mediaType);break;case 9:this.publishReq&&(this.publishReq.mediaType|=e.mediaType);break;case 12:this.connect.updateDevTools({note:`ping${this.pingCount++}`});break}}},ue=class extends ${constructor(e,r,s){super(s.joinReq.roomid,"Connection");this.id=e;this.port=r;m(this,"signalInfo_");m(this,"reqUser_");m(this,"joinReq");m(this,"frameWorkType");m(this,"userManager");m(this,"joinRes");m(this,"statReportReq");m(this,"qualityReportReq");m(this,"wFSM");m(this,"rtt",50);m(this,"recovery",new ni(this));m(this,"reqPromise",new Map);m(this,"rebuild");m(this,"osName");m(this,"browserInfo");m(this,"tinyId_",new B(32));m(this,"tinyId");m(this,"domains");m(this,"log_");m(this,"params");m(this,"proxy_ws");m(this,"proxy_wt");m(this,"proxy_cloud");m(this,"proxy_unified");m(this,"env");m(this,"wh");m(this,"abortCtrl",new AbortController);m(this,"firstReceiveUserlist");m(this,"connectParams");m(this,"selectDomain",0);m(this,"selectCloudDomain",0);m(this,"abort",this.abortCtrl.abort.bind(this.abortCtrl));m(this,"reconnectedOB",ve(this,"RECONNECTED"));m(this,"reconnectOB",e=>{this.reconnect().then(()=>{this.postMessage({cmd:"signal-connection-state-changed",payload:{prevState:"RECONNECTING",state:"CONNECTED"}}),this.rejoinRoom()},r=>{e.next(r),this.selectDomain=1-this.selectDomain})});console.log(this),Object.assign(this,s),this.connectParams=new URLSearchParams({sdkAppid:this.params.sdkAppId.toString(),userSig:this.params.userSig,identifier:this.params.userId}),this.tinyId&&this.connectParams.append("tinyId",this.tinyId),this.log_=Rt.createLogger({id:`wc${e}`,userId:this.params.userId,sdkAppId:this.params.sdkAppId}),this.proxy_unified?re.useWt=!1:(this.proxy_ws||this.proxy_wt)&&(re.useWt=!!this.proxy_wt),re.useWt?this.wFSM=new ze(this):this.wFSM=new Qe(this),this.userManager=new Kr("",this.log_,"tinyId");let a=c=>this.userManager.on(c,f=>this.postMessage({cmd:c,payload:f}));this.userManager.on("3",({flag:c,userId:f,tinyId:l})=>{let d={flag:c,userId:f,tinyId:l,get muteState(){return ql(this.flag,this.userId)},subscribe:0,removing:!1};this.log_.debug("create user",d),this.postMessage({cmd:"3",payload:d}),this.userManager.addRemotePublishedUser(new Vr(d,this))}),a("6"),a("5"),a("1"),a("2"),this.statReportReq={tinyid:"",stat:{msg_audio_stat_report:{msg_audio_enc_stat:{uint32_audio_enc_br:0,uint32_audio_frame_interval:0},msg_audio_send_stat:{uint32_audio_send_br:0,uint32_audio_fec_br:0,uint32_audio_arq_br:0}},rpt_msg_video_stat_report:[{uint32_video_type:2,msg_video_enc_stat:{uint32_video_enc_fps:0,uint32_video_enc_br:0,uint32_video_encrd:1},msg_video_send_stat:{uint32_video_send_br:0,uint32_video_fec_br:0,uint32_video_arq_br:0}}],msg_net_stat_report:{uint32_total_send_br:0,uint32_rtt:0,uint32_down_expect_pkg:0,uint32_down_real_pkg:0,uint32_down_recv_br:0},msg_rtt_info_req:{uint64_last_server_timestamp_ms:0,uint32_delay_since_last_server_timestamp_ms:0,uint64_client_timestamp_ms:0},msg_system_load_report:{uint32_total_cpu_rate:0},msg_down_bandwidth_est:{uint32_bandwidth_br:0,uint32_avg_bandwidth_br:0,uint32_jitter:0,uint32_jitter_in_frm:0},msg_play_report:{uint32_video_jitter_receive_fps_ratio:0}}},this.qualityReportReq={tinyid:"",report:{str_sdk_version:this.joinReq.jsSdkVersion,uint32_groupid:0,uint64_datetime:Date.now(),msg_user_info:{str_identifier:"",uint64_tinyid:0},msg_device_info:{uint32_terminal_type:this.joinReq.AbilityOption.GeneralLimit.uint32_terminal_type,str_device_name:this.browserInfo.browserName,str_os_version:this.osName,uint32_net_type:this.joinReq.AbilityOption.GeneralLimit.uint32_net_type,uint32_app_cpu:0,uint32_system_cpu:0,uint32_app_memory:0,uint32_background:0,uint32_headset:0},msg_up_stream_info:{msg_audio_status:{uint32_audio_format:11,uint32_audio_sample_rate:48e3,uint32_audio_codec_bitrate:0,uint32_audio_receive:0},msg_video_status:[{uint32_video_stream_type:2,uint32_video_decode_frame:0,uint32_video_total_frame:0,uint32_video_capture_fps:0,uint32_video_codec_fps:0,uint32_video_enc_fps:0,uint32_video_codec_bitrate:0,uint32_video_total_bitrate:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0,uint32_jitter:0},msg_qos:[]},msg_down_stream_info:[],msg_event_msg:[],str_acc_ip:"",str_client_ip:"",str_groupid:""}}}get aborted(){return this.abortCtrl.signal.aborted}get wtDomain(){return this.env?`${this.env}.rtc.qq.com:8080`:this.proxy_wt?this.proxy_wt:this.domains.length?`${this.domains[this.selectDomain]}:80`:"wasm.rtc.qq.com:80"}get wsDomain(){return this.env?`${this.env}.rtc.qq.com:8687`:this.proxy_cloud.length?this.proxy_cloud[this.selectCloudDomain].replace("wss://",""):this.proxy_ws?this.proxy_ws:this.domains.length?this.domains[this.selectDomain]:"wasm.rtc.qq.com"}get wtUrl(){return`https://${this.wtDomain}/v1/wt?${this.connectParams}`}get wsUrl(){var r;let e=((r=this.domains)==null?void 0:r[this.selectDomain])||"wasm.rtc.qq.com";return`wss://${this.wsDomain}/v1/ws?${this.connectParams}&realHost=${e}`}async connect(){let e=this.wFSM.connect(),r=(s,a=!1)=>c=>{if(this.aborted||typeof c=="number")throw c;return this.selectDomain=s,this.wFSM=a?new ze(this):new Qe(this),console.warn(c),console.warn("downgrade to",a?"WebTransport":"WebSocket",this.selectDomain?"\u5907\u7528\u57DF\u540D":"\u4E3B\u57DF\u540D"),this.wFSM.connect()};return re.useWt&&(this.proxy_ws||!this.proxy_wt)&&(e=e.catch(r(0))),!this.proxy_wt&&!this.proxy_ws&&(e=e.catch(r(1,re.useWt)),re.useWt&&(e=e.catch(r(1)))),e}async joinRoom(){let{dataport:e,stunport:r,relayip:s,socketid:a,checkSigSeq:c}=this.signalInfo_,f=await this.sendReq(0,Object.assign(this.joinReq,{dataport:e,stunport:r,relayip:s,socketid:a,checkSigSeq:c}));if(f.err===0)this.setJoinRes(f.data);else throw f.err;return f}async leaveRoom(){return await this.sendReq(1,{}),this.close()}async rejoinRoom(){if(!this.rebuild){let e=await this.sendReq(0,this.joinReq);if(e.err===0)this.setJoinRes(e.data);else return}return this.recovery.recoverLocal()}async reconnect(){return this.postMessage({cmd:"signal-connection-state-changed",payload:{prevState:"DISCONNECTED",state:"RECONNECTING"}}),this.wFSM.connect()}retry(e=0){if(console.log(rt(),"retry",e),e>mo){this.close();return}let r=Je(Hl(e));Y(e?qi(r,this.reconnectOB):r,Gi(1),Ue(this.reconnectedOB),ee(s=>{typeof s!="number"&&this.state==="DISCONNECTED"&&this.retry(e+1)}))}disconnect(e){this.log_.warn("connection lost:",e),this.postMessage({cmd:"signal-connection-state-changed",payload:{prevState:"CONNECTED",state:"DISCONNECTED"}}),this.retry()}close(){this.userManager.clear(),this.port.postMessage(null),this.port.close(),this.wFSM.close()}postMessage(e,r){this.port.postMessage(e,r)}verify(e,r){this.signalInfo_=e,this.rebuild=r,this.reqUser_={openid:e.openid,tinyid:e.tinyid}}async _sendReq(e,r){r.tinyid||(r.reqUser=this.reqUser_);let s=this.generateUUID();return await this.wFSM.sendReq(e,r,s),Xe((a,c)=>this.reqPromise.set(s,{resolve:a,reject:c,startTime:Date.now()}),this.abortCtrl.signal,a=>(console.log("abort",oe[e]),{err:a}))}postReq(e,r){return this.wFSM.sendReq(e,r,this.generateUUID())}async sendReq(e,r){return this.recovery.onSendReq(e,r),this._sendReq(e,r)}send(e){return this.wFSM.send(e)}setJoinRes(e){this.joinRes=e,this.userManager.mySelfId=e.tinyid,this.statReportReq.tinyid=e.tinyid,this.qualityReportReq.tinyid=e.tinyid,this.qualityReportReq.report.str_acc_ip=e.relayip,this.qualityReportReq.report.str_client_ip=e.clientip,this.qualityReportReq.report.msg_user_info.str_identifier=e.openid,this.qualityReportReq.report.msg_user_info.uint64_tinyid=Number(e.tinyid),this.tinyId_.set([...e.tinyid].map(r=>r.charCodeAt(0)).concat(0)),[1,2,3,7].forEach(r=>{H._CreateUdtPacketizer(e.roomid,this.tinyId_.point,e.locationid,r,H.udtver,this.id)}),this.wFSM.sendReq(6,{})}onReceive(e,r,s){let a="",c=0,f=new DataView(s.buffer,s.byteOffset);r<255&&(c=f.getUint32(0),s=s.subarray(4)),r<4095&&(a=String.fromCharCode(...s.subarray(0,16)),s=s.subarray(16));let l=s;if(!a)f=new DataView(s.buffer,s.byteOffset,s.byteLength);else{let _="";for(let h=0,I=s.length,U=32768;h<I;h+=U)_+=String.fromCharCode.apply(null,s.subarray(h,Math.min(h+U,I)));if(c)l=_;else try{l=JSON.parse(_)}catch(h){l=_}}let d=oe[r];switch(r){case 259:this.joinRes&&this.wFSM.sendReq(r,{tinyid:this.joinRes.tinyid}),console.debug(e,"receive:",d,a,l);break;case 256:l.userlist.forEach(R=>{if(this.userManager.addUser({userId:R.userid,tinyId:R.srctinyid,role:R.role}),this.joinRes&&R.srctinyid!=this.joinRes.tinyid&&this.userManager.userMap.has(R.srctinyid)){let w=this.userManager.userMap.get(R.srctinyid);this.sendSubscribe(w)}}),this.log_.info(e,"receive:",d,a,l),this.wFSM.sendReq(r,{count:this.userManager.userMap.size});break;case 257:this.userManager.deleteUser(l.userlist.srctinyid),this.log_.info(e,"receive:",d,a,l),this.wFSM.sendReq(r,{count:this.userManager.userMap.size});break;case 6:this.userManager.setUserList(l.userlist.map(R=>({userId:R.userid,tinyId:R.srctinyid,role:R.role})));break;case 255:this.wFSM.sendReq(r,{count:this.userManager.userMap.size});{let R=l.userlist.map(w=>({userId:w.userid,tinyId:w.srctinyid,flag:w.flag,terminalType:w.terminaltype}));this.firstReceiveUserlist||(this.firstReceiveUserlist=!0,this.postMessage({cmd:Ze.RECEIVED_PUBLISHED_USER_LIST,payload:{publishedUserList:R}})),this.userManager.setRemotePublishedUserList(R),this.recovery.recovering&&this.recovery.recoverRemote(this.userManager.remotePublishedUserMap)}break;case 4100:this.rtt=f.getUint32(4),console.debug(e,"receive:",d,a,l,this.rtt);let{dv:_,writeData:h}=Bt(4101,8);h(s.subarray(0,4)),this.send(_.buffer);break;case 12:this.reqPromise.forEach(R=>{Date.now()-R.startTime>5e3&&(R.reject(new Error("heartbeat timeout")),this.reqPromise.delete(R.uuid))}),self.postMessage({type:"glog",payload:{heartbeatReceive:1}});case 11:case 260:console.debug(e,"receive:",d,a,l);case 7:case 4095:break;case 4096:case 4097:{let R=s.length;this.statReportReq.stat.msg_net_stat_report.uint32_down_real_pkg++,this.statReportReq.stat.msg_net_stat_report.uint32_down_recv_br+=R<<3;let w=f.getBigUint64(9).toString(),X=this.userManager.getPublishedUser(w);X?r===4096?(X.mainPuller.videoStatus.uint32_video_receive||console.timeLog(`${X.userId}big`,"first video data"),X.mainPuller.demuxPacket(s)):(X.screenPuller.videoStatus.uint32_video_receive||console.timeLog(`${X.userId}aux`,"first video data"),X.screenPuller.demuxPacket(s)):console.warn(e,"receive:",d,a,l,"user not found")}break;case 4102:case 4103:case 4099:break;case 4103:H.HEAPU8.set(s,B.global.point+8);let I=H._ParseUdtMousePacket(B.global.point+8,s.length,B.global.point),U=s.subarray(I),O=B.global.getBigUint64(0).toString(),J=this.userManager.userMap.get(O);J&&this.postMessage({cmd:"layerData",payload:{userId:J.userId,tinyId:O,layerData:U}}),console.debug(e,"receive:",d,I,l,O,U);break;case 4098:{let R=f.getUint8(8);for(let w=9;w<s.length;w+=6){let X=f.getUint32(w),ye=f.getUint16(w+4);for(let Ie=0;Ie<=16;Ie++){if(Ie>0&&(ye>>16-Ie&1)==0)continue;let Ae=H._GetRetransPacket(R,X+Ie,B.global.point,this.id),ce=B.global.getUint32(0),be=H.HEAPU8.subarray(ce,ce+Ae);Ae>0&&this.send(be)}}}break;case 1:this.log_.info(e,"receive:",d,a,l),l>0&&l!==3&&(this.postMessage({cmd:"banned",payload:l}),this.close());break;case 258:this.log_.info(e,"receive:",d,a||"",l);break;default:this.log_.info(e,"receive:",d||r,a||"",l)}this.reqPromise.has(a)&&(c&&this.log_.warn(c,l,a),this.reqPromise.get(a).resolve({err:c,data:l,uuid:a}),this.reqPromise.delete(a)),this.emit(d,a?{uuid:a,err:c,data:l}:{data:l})}sendSubscribe(e){let r=e.subscribe;if(r==0)return;let s={mediaType:r,mediaDescription:{audioParam:r&1?{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]}:void 0,videoParam:[4,8,2].filter(a=>r&a).map(a=>({mediaType:a,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]}))},userId:e.userId,srctinyid:e.tinyId};this._sendReq(4,s)}createOputReceiver(e){return new Ne(this.unMarshal(e))}*unMarshal(e){let r=null,s=new Map;for(;;){let a=0,c=0;try{r=yield 1;let f=r[0]>>4,l=r[0]&2,d=r[0]&1;r=yield 4+d*2;let _=new DataView(r.buffer,r.byteOffset);if(c=_.getUint16(0),a=d==1?_.getUint32(2):_.getUint16(2),r=yield a,l){let h=r[0]&63,I=r[1],U=r.subarray(2,2+I);switch(h){case 1:let O=U[0]>>7,J=U[0]&127,R=U[1],{dv:w,write8:X}=Bt(4099,2);X(J),X(R),this.send(w.buffer);let ye=J%64;for(let Ae=0;Ae<64;Ae++){let ce=J-Ae;ce<0&&(ce+=64);let be=ye-Ae;be<0&&(be+=64),s.has(be)&&s.get(be).groupId!=ce&&s.delete(be)}let Ie=s.get(ye);if(Ie||s.set(ye,Ie=new si(J)),r=Ie.push(R,r.slice(2+I),O!=0),r)s.delete(ye);else continue}}this.onReceive(e,c,r)}catch(f){this.log_.error(e,f,a,c,r)}}}generateUUID(){return"xxxxxxxxxxxxxxxx".replace(/[xy]/g,e=>{let r=Math.random()*16|0;return(e=="x"?r:r&3|8).toString(16)})}};m(ue,"JOINED","joined"),m(ue,"CLOSED","closed"),me([he($.INIT,"CONNECTED")],ue.prototype,"connect",1),me([he("CONNECTED",ue.JOINED)],ue.prototype,"joinRoom",1),me([he("RECONNECTED",ue.JOINED,{fail(){this.close()}})],ue.prototype,"rejoinRoom",1),me([he("DISCONNECTED","RECONNECTED")],ue.prototype,"reconnect",1),me([he([],"DISCONNECTED",{sync:!0})],ue.prototype,"disconnect",1),me([he([],ue.CLOSED,{sync:!0})],ue.prototype,"close",1);var si=class{constructor(t){this.groupId=t;m(this,"chunks",[]);m(this,"totalLen",0);m(this,"marker",!1)}push(t,e,r){if(this.chunks[t])return null;if(this.chunks[t]=e,this.totalLen+=e.length,r&&(this.chunks.length=t+1,this.marker=!0),this.marker){for(let a=0;a<this.chunks.length;a++)if(!this.chunks[a])return null;let s=new Uint8Array(this.totalLen);for(;this.chunks.length;){let a=this.chunks.pop();s.set(a,this.totalLen-=a.length)}return s}return null}};var Kt=class extends Te{["publishCdn"](t,e){return"request_time"in t?(console.info("startPublishTXCDN:",t),this.send(18,t).then(e.postMessage)):(console.info("startPublishCDN:",t),this.send(13,t).then(e.postMessage))}["stopPublishCdn"](t,e){return"request_time"in t?(console.info("stopPublishTXCDN:",t),this.send(19,t).then(e.postMessage)):(console.info("stopPublishCDN:",t),this.send(14,t).then(e.postMessage))}["startMcuMix"](t,e){let{inputParam:r,outputParam:s}=t,a={mcuMix:{reqUser:this.io.reqUser_,roomid:t.roomId,sdkAppID:this.appId,socketid:this.io.joinRes.socketid,mcuRequestTime:t.mcuRequestTime,outputSessionId:t.outputSessionId},inputParam:r.map(c=>({userid:c.userId,width:c.width,height:c.height,locationX:c.locationX,locationY:c.locationY,zOrder:c.zOrder,streamType:c.streamType,inputType:c.inputType})),outputParam:{streamId:s.streamId,streamType:s.streamType,videoWidth:s.width,videoHeight:s.height,videoBitrate:s.videoBps,videoFramerate:s.fps,vidoeGOP:s.gop,audioSampleRate:s.audioSampleRate,audioBitrate:s.audioBps,audioChannels:s.audioChannels,backgroundColor:s.backgroundColor,backgroundImage:s.backgroundImg,extraInfo:s.extraInfo,VCodec:s.videoCodec,ACodec:s.audioCodec}};return this.send(15,a).then(e.postMessage)}["stopMcuMix"](t,e){let r={mcuMix:{reqUser:this.io.reqUser_,roomid:this.roomId,sdkAppID:this.appId,socketid:this.io.joinRes.socketid,mcuRequestTime:t.mcuRequestTime,outputSessionId:t.outputSessionId},userid:this.userId,streamType:t.streamType};return console.info("stop mcuMix:",t),this.send(16,r).then(e.postMessage)}};var Wl=1200;var Gl=1+2+4+2+8+4+4+4+2,jl=4+1+1,Yl=1+1+1+1+1+1,xh=1+1+1+1+12,Xo={[1]:1,["audio"]:1,["video"]:4,[2]:4,["auxVideo"]:2,[7]:2,[3]:8};var vh=Date.now(),Uh=Gl+jl+6+Yl+Wl+1;var Jt=class extends Te{constructor(){super(...arguments);m(this,"videoEncBuffer_",new B(1920*1080*3>>1));m(this,"videoStats",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0});m(this,"audioStats",{bytesSent:0,packetsSent:0});m(this,"videoTypeIndexMap",new Map([[2,0]]));m(this,"requestTypeMap",new Map([[0,4096]]))}["getLocalVideoStats"](e){e.postMessage({[this.io.joinRes.openid]:this.videoStats})}["getLocalAudioStats"](e){e.postMessage({[this.io.joinRes.openid]:this.audioStats})}["pushAudio"]({sampleRate:e,channelCount:r,bitrate:s,index:a},c,f){var U;let l=new B(e*r*2),d=O=>{this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_level=O.volume*1e8/100>>0;let{data:J}=O,R=J.length;l.set(J),this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_enc_br+=R<<3,this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_frame_interval++,this.audioStats.packetsSent++;let w=H._PacketizeAudioUdt(l.point,R,O.timestamp,e,r,O.energy,B.global.point,B.global.size,this.io.id,!!f);if(w<=0){console.warn("audio pack len is 0");return}this.io.send(B.global.uint8Array(w)),this.audioStats.bytesSent+=w,this.statReportReq.msg_audio_stat_report.msg_audio_send_stat.uint32_audio_send_br+=w<<3,this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_receive++},_=O=>{l.free(),this.send(3,{mediaType:1})},h=new MessageChannel;(U=this.io.wh.playPort)==null||U.postMessage({cmd:"pushAudio",payload:{numberOfChannels:r,bitrate:s},encrypt:!!f,index:a},[h.port2,c.port]);let I=Mt(h.port1);f&&Y(I,ee()),Y(f||I,ee(d,_,_))}createSelectAbilityOb(e,r){let s=r.bitrate;return Y(this.createResposeOb(259),Yi(()=>Je(2e3)),yr(a=>{var c;return(c=a.data.ability.rpt_msg_video_control_info)==null?void 0:c.find(f=>f.uint32_video_type===e)}),_r(a=>{if(!a)return!1;let c=a.uint32_video_enc_br,f=c*Math.pow(1-this.qualityReport.msg_up_stream_info.msg_network_status.uint32_lost/100,2),l=Math.min(s,f);a.uint32_video_enc_br=l,this.glog({[`confBr${e}`]:[c,f,l]});let d=!1;return((h,I)=>{a[I]&&a[I]!==r[h]&&(d=!0,r[h]=a[I])})("bitrate","uint32_video_enc_br"),d}),Qn(r))}["pushVideo"]({profile:{width:e,height:r,frameRate:s,bitrate:a},type:c,trackType:f},l){this.videoStats.frameWidth=e,this.videoStats.frameHeight=r;let d=0,_=Xo[c];this.videoTypeIndexMap.has(c)?d=this.videoTypeIndexMap.get(c):(d=this.statReportReq.rpt_msg_video_stat_report.length,this.requestTypeMap.set(d,c===7?4097:4096),this.videoTypeIndexMap.set(c,d),this.statReportReq.rpt_msg_video_stat_report.push({uint32_video_type:c,msg_video_enc_stat:{uint32_video_enc_fps:0,uint32_video_enc_br:0,uint32_video_encrd:1},msg_video_send_stat:{uint32_video_send_br:0,uint32_video_fec_br:0,uint32_video_arq_br:0}}),this.qualityReport.msg_up_stream_info.msg_video_status.push({uint32_video_codec_bitrate:0,uint32_video_total_bitrate:0,uint32_video_enc_fps:0,uint32_video_capture_fps:0,uint32_video_codec_fps:0,uint32_video_stream_type:c,uint32_video_codec_type:0,uint32_video_decode_frame:0,uint32_video_total_frame:0,uint32_video_width:e,uint32_video_height:r}));let h={width:e,height:r,bitrate:a*1e3,framerate:s};Object.assign(this.qualityReport.msg_up_stream_info.msg_video_status[d],{uint32_video_width:e,uint32_video_height:r});let I=0,U=!1,O=R=>{this.send(3,{mediaType:_})};Y(this.createSelectAbilityOb(c,h),ee(()=>{l.postMessage(h)}));let J=l;f!="camera"&&(this.io.log_.info(`push ${f} track`),J=Hi(l,Y(l,Ki(2e3),Ji(R=>(this.io.log_.warn("start push last video frame"),Y(Pe(2e3),Qn(R),Ue(l),Ar({complete:()=>this.io.log_.warn("stop push last video frame")})))),Fe(l)))),Y(J,ee(R=>{let w=this.getVideoStatus(d);w.uint32_video_total_frame++,I++,this.videoStats.framesSent++,w.uint32_video_capture_fps++,I%300==0&&l.postMessage(260),this.handleVideoEncoded(R,c)},O,O)),Y(this.createResposeOb(260),Fe(l),ee(()=>l.postMessage(260)))}getVideoStatus(e){return this.qualityReport.msg_up_stream_info.msg_video_status[e]}handleVideoEncoded(e,r){let{chunk:s,timestamp:a}=e;this.videoStats.framesEncoded++;let c=this.videoTypeIndexMap.get(r),f=this.getVideoStatus(c);f.uint32_video_decode_frame++,f.uint32_video_codec_fps++,f.uint32_video_enc_fps++,this.statReportReq.rpt_msg_video_stat_report[c].msg_video_enc_stat.uint32_video_enc_fps++;let l="byteLength"in s?s.byteLength:s.data.length;if(this.statReportReq.rpt_msg_video_stat_report[c].msg_video_enc_stat.uint32_video_enc_br+=l<<3,l>this.videoEncBuffer_.size){console.log("buffer too small!");return}"byteLength"in s?s.copyTo(this.videoEncBuffer_.uint8Array(l)):this.videoEncBuffer_.set(s.data),B.global.fill();let d=H._PacketizeVideoUdt(this.videoEncBuffer_.point,l,a,s.type=="key"?1:0,r,B.global.point,this.io.id);this.sendUdtv3Video(d,c)}sendUdtv3Video(e,r){let s=0,a=B.global.uint8Array();for(let c=0;c<e;c++){let f=B.global.getUint32(s);if(f<=0){this.io.log_.warn("sendUdtv3Video pktSize is ",f);continue}this.io.send(a.subarray(s+=4,s+=f)),this.statReportReq.rpt_msg_video_stat_report[r].msg_video_send_stat.uint32_video_send_br+=f<<3,this.videoStats.bytesSent+=f,this.videoStats.packetsSent++}}["mute"](e){if(this.send(8,e),e.userId!==this.io.joinRes.openid){let r=this.userMap_.get(e.srctinyid);r&&(r.subscribe&=~e.mediaType)}}["unmute"](e){if(this.send(9,e),e.userId!==this.io.joinRes.openid){let r=this.userMap_.get(e.srctinyid);r&&(r.subscribe|=e.mediaType)}}["waitKeyFrame"](e){this.send(11,e)}["publish"](e,r){this.audioStats.bytesSent=0,this.audioStats.packetsSent=0,this.videoStats.framesSent=0,this.videoStats.bytesSent=0,this.videoStats.packetsSent=0,this.videoStats.framesEncoded=0;let s={mediaType:e,mediaDescription:{audioParam:e&1?{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]}:void 0,videoParam:[4,8,2].filter(a=>e&a).map(a=>({mediaType:a,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]}))}};this.send(2,s).then(a=>{r.postMessage(a),r.postMessage(null)})}};var $l=2,Xt=class extends Te{["addEventMsgs"](t){this.qualityReport.msg_event_msg=t}constructor(t){super(t);let e,r=ve(t,ue.JOINED),s=ve(t,ue.CLOSED),a={};Y(r,Lt(Pe(1e3)),Ue(s),ee(l=>{let d=Date.now();this.statReportReq.msg_down_bandwidth_est.uint32_avg_bandwidth_br=this.statReportReq.msg_down_bandwidth_est.uint32_bandwidth_br=this.statReportReq.msg_net_stat_report.uint32_down_recv_br,this.statReportReq.msg_rtt_info_req.uint64_client_timestamp_ms=d,this.statReportReq.msg_rtt_info_req.uint32_delay_since_last_server_timestamp_ms=e&&d-e||0,this.statReportReq.msg_net_stat_report.uint32_down_expect_pkg=this.statReportReq.msg_net_stat_report.uint32_down_real_pkg,this.statReportReq.msg_net_stat_report.uint32_total_send_br=this.statReportReq.msg_audio_stat_report.msg_audio_send_stat.uint32_audio_send_br+this.statReportReq.rpt_msg_video_stat_report.reduce((h,I)=>h+I.msg_video_send_stat.uint32_video_send_br,0),a.bandwidth=this.statReportReq.msg_down_bandwidth_est.uint32_avg_bandwidth_br,a.heartbeatSend=1;let _=[this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_codec_bitrate=this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_enc_br];this.qualityReport.msg_up_stream_info.msg_video_status.forEach((h,I)=>{let U=this.statReportReq.rpt_msg_video_stat_report[I];h.uint32_video_total_bitrate=U.msg_video_send_stat.uint32_video_send_br,_[U.uint32_video_type==7?3:U.uint32_video_type-1]=h.uint32_video_codec_bitrate=U.msg_video_enc_stat.uint32_video_enc_br}),a.localBr=_,this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_total_bitrate=this.statReportReq.msg_audio_stat_report.msg_audio_send_stat.uint32_audio_send_br,l%2&&this.post(12,this.io.statReportReq),this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_frame_interval=0,this.statReportReq.msg_audio_stat_report.msg_audio_send_stat.uint32_audio_send_br=0,this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_enc_br=0,this.statReportReq.rpt_msg_video_stat_report.forEach(h=>{h.msg_video_send_stat.uint32_video_send_br=0,h.msg_video_enc_stat.uint32_video_enc_br=0,h.msg_video_enc_stat.uint32_video_enc_fps=0}),this.statReportReq.msg_net_stat_report.uint32_down_recv_br=0}));let c=Y(this.createResposeOb(12),Ar(l=>{l.err||!l.data||(this.statReportReq.msg_rtt_info_req.uint64_last_server_timestamp_ms=l.data.msg_rtt_info_res.uint64_server_timestamp_ms,e=Date.now(),this.statReportReq.msg_net_stat_report.uint32_rtt=e-l.data.msg_rtt_info_res.uint64_last_client_timestamp_ms-l.data.msg_rtt_info_res.uint32_delay_since_last_client_timestamp_ms,this.statReportReq.msg_net_stat_report.uint32_rtt<0&&(this.statReportReq.msg_net_stat_report.uint32_rtt=30),this.qualityReport.msg_up_stream_info.msg_network_status.uint32_lost=Math.max(0,(l.data.uint32_up_expect_pkg-l.data.uint32_up_real_pkg)*100/l.data.uint32_up_expect_pkg>>0))}));Y(r,Lt(c),Lt(Je(po)),Ue(s),ee(()=>{this.io.log_.warn("ping timeout,lastrecv:",e,"now:",Date.now()),this.io.state==ue.JOINED&&this.io.wFSM.disconnect("ping timeout")}));let f=new B(13<<2);Y(r,Lt(Pe($l*1e3)),Ue(s),ee(l=>{let d=[...this.userMap_.values()];this.qualityReport.uint64_datetime=Date.now(),this.qualityReport.msg_up_stream_info.msg_network_status.uint32_bitrate=this.statReportReq.msg_net_stat_report.uint32_total_send_br,this.qualityReport.msg_up_stream_info.msg_network_status.uint32_rtt=this.statReportReq.msg_net_stat_report.uint32_rtt,this.qualityReport.msg_down_stream_info=d.map(O=>{var w,X;let J=O.toDownStreamInfo(O,l%10===0),R=[J.msg_audio_status.uint32_audio_codec_bitrate];return R[1]=J.msg_video_status[0].uint32_video_codec_bitrate,R[2]=((w=J.msg_video_status[1])==null?void 0:w.uint32_video_codec_bitrate)||0,a[`RemoteBr_${O.userId}`]=R,a[`RemoteBlock_${O.userId}`]=[J.msg_audio_status.uint32_audio_block_cnt,J.msg_video_status[0].uint32_video_block_cnt,((X=J.msg_video_status[1])==null?void 0:X.uint32_video_block_cnt)||0],J}),this.glog(a),a={};let _=this.qualityReport.msg_down_stream_info.map(O=>({userId:O.msg_user_info.str_identifier,rtt:O.msg_network_status.uint32_rtt,loss:O.msg_network_status.uint32_lost})),h=Kl(_),I=this.qualityReport.msg_up_stream_info.msg_network_status.uint32_rtt,U=this.qualityReport.msg_up_stream_info.msg_network_status.uint32_lost;this.postMessage("network-quality",{uplinkNetworkQuality:this.io.state!="DISCONNECTED"?Qo(U,I):6,downlinkNetworkQuality:Qo(h.loss,h.rtt),uplinkInfo:this.qualityReport.msg_up_stream_info,msg_down_stream_info:this.qualityReport.msg_down_stream_info,downlinkInfo:_,uplinkRTT:I,uplinkLoss:U,downlinkRTT:h.rtt,downlinkLoss:h.loss}),this.qualityReport.msg_up_stream_info.msg_video_status.forEach(O=>{O.uint32_video_capture_fps>>=1,O.uint32_video_codec_fps>>=1,l%10===0&&console.log(rt(),"video uplink fps:",O.uint32_video_stream_type,O.uint32_video_capture_fps,O.uint32_video_codec_fps)}),this.post(7,this.io.qualityReportReq),this.qualityReport.msg_event_msg=[],this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_level=0,this.qualityReport.msg_up_stream_info.msg_video_status.forEach(O=>{O.uint32_video_capture_fps=0,O.uint32_video_codec_fps=0,O.uint32_video_enc_fps=0})},l=>{},()=>{this.qualityReport.msg_down_stream_info=[...this.userMap_.values()].map(l=>l.toDownStreamInfo(l,!1)),this.post(7,this.io.qualityReportReq),f.free()}))}};function Kl(n){let t={rtt:0,loss:0};return Array.isArray(n)&&n.length>0&&(n.forEach(e=>{t.rtt+=e.rtt,t.loss+=e.loss}),Object.keys(t).forEach(e=>{t[e]=Math.round(t[e]/n.length)})),t}function Qo(n,t){return n>50||t>500?5:n>30||t>350?4:n>20||t>200?3:n>10||t>100?2:n>=0||t>=0?1:0}var Qt=class extends Te{async["subscribe"](t,e){let{mediaType:r,srctinyid:s}=t,a=this.userMap_.get(s);if(a){if(a.subscribe|=t.mediaType,t.mediaType=a.subscribe,e)e.postMessage(await this.send(4,t));else return this.send(4,t);r===1&&a.startPullOnlyAudio(a.mainPuller,e,{mediaType:r,srctinyid:s})}}async["unSubscribe"](t,e){let{mediaType:r,srctinyid:s}=t,a=this.userMap_.get(s);if(a){let c=a.subscribe;a.subscribe&=~r,c!==a.subscribe&&e.postMessage(await this.send(a.subscribe===0?5:4,t))}}["pullVideo"]({mediaType:t,tinyId:e},r){let s=this.userMap_.get(e);s&&s.startPull(t===2?s.screenPuller:s.mainPuller,r,{mediaType:t,srctinyid:e})}["changetype"](t){let{mediaType:e,srctinyid:r}=t,s=this.userMap_.get(r);if(s){let a=s.subscribe;e===8?(s.subscribe|=8,s.subscribe&=-5):e===4&&(s.subscribe|=4,s.subscribe&=-9),a!=s.subscribe&&(t.mediaType=s.subscribe,this.send(4,t))}}};var ii=class extends Ht{constructor(e,r,s,a){super();this.seq=e;this.player=r;this.numberOfChannels=s;this.bitrate=a;m(this,"aecPtr");m(this,"encodePrt");m(this,"tenms",sampleRate/100);m(this,"numberOfFrames",this.tenms<<1);m(this,"float32Array");m(this,"pos",0);m(this,"bufferLen",0);m(this,"outputPort");m(this,"mainPort");m(this,"workerPort");m(this,"outPrt");m(this,"audioCaptBuff");m(this,"oput");m(this,"first10ms");m(this,"dumpPort");m(this,"encodeCount",0);typeof r.wasm!="string"&&(this.wasmBinary=r.wasm),this.locateFile=()=>r.wasm}reset(){this.encodeCount=0}print(e){console.debug(e)}printErr(e){console.debug(e)}onRuntimeInitialized(){this.aecPtr=this._malloc(1920*10),this.encodePrt=this._malloc(1920*4),this.outPrt=this._malloc(1920*4),this.float32Array=new Float32Array(this.HEAPU8.buffer,this.encodePrt),this._CreateMediaProcessing(0,1,0,!1),this._UseAINS(re.useAINS),this._SetAudioFrameFormat(sampleRate,this.numberOfChannels),this._InitOpusEncoder(sampleRate,this.numberOfChannels,1),this.bitrate&&this._SetOpusEncBitrate(this.bitrate*1e3),console.log(st,"audio worklet initialized",sampleRate,this.numberOfChannels,this.seq),this.oput=new Ne,this.oput.buffer=new Uint8Array(this.HEAPU8.buffer,this.encodePrt),this.player.encoders[this.seq]=this}aec(e){return this.HEAPU8.set(e,this.aecPtr),this._AudioReverseProcessFloat(this.aecPtr,e.length>>2),this.HEAPU8.subarray(this.aecPtr,this.aecPtr+e.length)}encode(...e){if(!this.bitrate)return;let r=this.encodePrt;for(let s of e){this.float32Array.set(s,this.bufferLen),this.bufferLen+=s.length;let a=0;for(;this.bufferLen-this.pos>=this.tenms;){let c=this.player.delay+(this.bufferLen-this.pos)/(sampleRate/1e3)+20>>0,f=this._AudioProcessFloat(this.encodePrt+this.pos*4,this.tenms,c);if(a<f&&(a=f),this.pos+=this.tenms,this.pos>=this.numberOfFrames){if(this.dumpPort){let h=this.float32Array.slice(0,this.numberOfFrames);this.dumpPort.postMessage({data:h},[h.buffer])}let l=this._OpusEncode(this.encodePrt,this.numberOfFrames,this.outPrt);this.encodeCount++,this.encodeCount<10&&console.log("audio encoded",this.encodeCount,l);let d=this.HEAPU8.slice(this.outPrt,this.outPrt+l),_=a*100/32768;this.mainPort.postMessage(_),this.outputPort.postMessage({data:d,volume:_,energy:a,timestamp:Date.now()},[d.buffer]),a=0,this.float32Array.copyWithin(0,this.numberOfFrames,this.bufferLen),this.bufferLen-=this.numberOfFrames,this.pos-=this.numberOfFrames}}break}}close(){this._free(this.aecPtr),this._free(this.encodePrt)}};function zo(n){class t extends AudioWorkletProcessor{constructor(s){super();m(this,"oput",new Ne);m(this,"wasm");m(this,"encoders",[]);m(this,"useAINS",!0);console.log("worklet created:",sampleRate),this.wasm=s.processorOptions.wasm,Object.assign(re,s.processorOptions.flag),this.port.onmessage=a=>this.pushAudio(a)}get delay(){var s;return(((s=this.oput.buffer)==null?void 0:s.length)||0)/(sampleRate*4/1e3)}process(s,a){return this.oput.demand(a[0][0],!0),this.encoders.forEach((c,f)=>c.encode(...s[f])),!0}pushAudio(s){if(s.data instanceof Uint8Array){let{data:a}=s;this.encoders.forEach(c=>a=c.aec(s.data)),this.oput.malloc(a.length).set(a);return}switch(console.log("worklet receive",s.data.cmd),s.data.cmd){case"dump":switch(s.data.payload){case"mic0":this.encoders[0].dumpPort=s.ports[0];break}break;case"useAINS":re.useAINS=s.data.payload,this.encoders.forEach(a=>a._UseAINS(s.data.payload));break;case"enableAEC":this.encoders.forEach(a=>a._EnableAEC(s.data.payload));break;case"enableDebug":console.debug=s.data.payload?Rr:()=>{};break;case"pushAudio":{let[a,c]=s.ports,{payload:{numberOfChannels:f,bitrate:l},encrypt:d,index:_}=s.data,h=this.encoders[_]||new ii(_,this,f,l);this.encoders[_]?(h.bitrate=l,h._SetOpusEncBitrate(l*1e3)):n(h),h.reset(),h.mainPort=c,h.workerPort=a,h.outputPort=d?c:a,c.onmessage=I=>{I.data?h.encode(I.data):(console.log(rt(),"encoder",_,"stopped"),a.postMessage(null))}}}}}registerProcessor("global-audio-player",t)}var oi=class{constructor(){m(this,"playPort");m(this,"dumpPort");m(this,"downlinkAudioCount",0);m(this,"interval10ms",Y(mr(10),mt()));m(this,"ios")}glog(t){self.postMessage({type:"glog",payload:t})}async joinRoom(t){let{data:{id:e,payload:r},ports:s}=t,a=new ue(e,s[0],r);a.wh=this;let c=[new Jt(a),new Qt(a),new Et(a),new Xt(a),new Kt(a)],f=(d="leave room")=>{a.leaveRoom().catch(),a.abort(d),this.ios.delete(a)},l=setTimeout(a.abort,5e3,"timeout");Y(Mt(a.port,!0),ee(({data:{cmd:d,payload:_},ports:h})=>{switch(console.log(self.name,"received message",d),d){case"setAudioWorkletPort":this.playPort=h[0];break;case"switchRole":a.sendReq(20,{role:_,privateMapKey:a.params.privateMapKey}).then(U=>h[0].postMessage(U));break;default:let I=h.map(U=>Mt(U));typeof _!="undefined"&&I.unshift(_),c.forEach(U=>{var O;(O=U[d])==null||O.call(U,...I)})}},f,f));try{await a.connect(),postMessage({id:e,payload:await a.joinRoom()}),clearTimeout(l),this.ios.add(a)}catch(d){d instanceof WebTransportError?d=`Transport initialization failed.
1
+ var Tc=Object.create;var cr=Object.defineProperty;var Vi=Object.getOwnPropertyDescriptor;var Sc=Object.getOwnPropertyNames,Bi=Object.getOwnPropertySymbols,yc=Object.getPrototypeOf,Fi=Object.prototype.hasOwnProperty,Ic=Object.prototype.propertyIsEnumerable;var _n=(n,t,e)=>t in n?cr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,hn=(n,t)=>{for(var e in t||(t={}))Fi.call(t,e)&&_n(n,e,t[e]);if(Bi)for(var e of Bi(t))Ic.call(t,e)&&_n(n,e,t[e]);return n};var Ac=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var Rc=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Sc(t))!Fi.call(n,s)&&s!==e&&cr(n,s,{get:()=>t[s],enumerable:!(r=Vi(t,s))||r.enumerable});return n};var lr=(n,t,e)=>(e=n!=null?Tc(yc(n)):{},Rc(t||!n||!n.__esModule?cr(e,"default",{value:n,enumerable:!0}):e,n));var me=(n,t,e,r)=>{for(var s=r>1?void 0:r?Vi(t,e):t,a=n.length-1,c;a>=0;a--)(c=n[a])&&(s=(r?c(t,e,s):c(s))||s);return r&&s&&cr(t,e,s),s};var m=(n,t,e)=>(_n(n,typeof t!="symbol"?t+"":t,e),e);var Ft=Ac((gm,Hs)=>{"use strict";var qc=Object.prototype.hasOwnProperty,_e="~";function Vt(){}Object.create&&(Vt.prototype=Object.create(null),new Vt().__proto__||(_e=!1));function Wc(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function to(n,t,e,r,s){if(typeof e!="function")throw new TypeError("The listener must be a function");var a=new Wc(e,r||n,s),c=_e?_e+t:t;return n._events[c]?n._events[c].fn?n._events[c]=[n._events[c],a]:n._events[c].push(a):(n._events[c]=a,n._eventsCount++),n}function Mr(n,t){--n._eventsCount===0?n._events=new Vt:delete n._events[t]}function de(){this._events=new Vt,this._eventsCount=0}de.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)qc.call(e,r)&&t.push(_e?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};de.prototype.listeners=function(t){var e=_e?_e+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var s=0,a=r.length,c=new Array(a);s<a;s++)c[s]=r[s].fn;return c};de.prototype.listenerCount=function(t){var e=_e?_e+t:t,r=this._events[e];return r?r.fn?1:r.length:0};de.prototype.emit=function(t,e,r,s,a,c){var f=_e?_e+t:t;if(!this._events[f])return!1;var l=this._events[f],d=arguments.length,_,h;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,r),!0;case 4:return l.fn.call(l.context,e,r,s),!0;case 5:return l.fn.call(l.context,e,r,s,a),!0;case 6:return l.fn.call(l.context,e,r,s,a,c),!0}for(h=1,_=new Array(d-1);h<d;h++)_[h-1]=arguments[h];l.fn.apply(l.context,_)}else{var I=l.length,U;for(h=0;h<I;h++)switch(l[h].once&&this.removeListener(t,l[h].fn,void 0,!0),d){case 1:l[h].fn.call(l[h].context);break;case 2:l[h].fn.call(l[h].context,e);break;case 3:l[h].fn.call(l[h].context,e,r);break;case 4:l[h].fn.call(l[h].context,e,r,s);break;default:if(!_)for(U=1,_=new Array(d-1);U<d;U++)_[U-1]=arguments[U];l[h].fn.apply(l[h].context,_)}}return!0};de.prototype.on=function(t,e,r){return to(this,t,e,r,!1)};de.prototype.once=function(t,e,r){return to(this,t,e,r,!0)};de.prototype.removeListener=function(t,e,r,s){var a=_e?_e+t:t;if(!this._events[a])return this;if(!e)return Mr(this,a),this;var c=this._events[a];if(c.fn)c.fn===e&&(!s||c.once)&&(!r||c.context===r)&&Mr(this,a);else{for(var f=0,l=[],d=c.length;f<d;f++)(c[f].fn!==e||s&&!c[f].once||r&&c[f].context!==r)&&l.push(c[f]);l.length?this._events[a]=l.length===1?l[0]:l:Mr(this,a)}return this};de.prototype.removeAllListeners=function(t){var e;return t?(e=_e?_e+t:t,this._events[e]&&Mr(this,e)):(this._events=new Vt,this._eventsCount=0),this};de.prototype.off=de.prototype.removeListener;de.prototype.addListener=de.prototype.on;de.prefixed=_e;de.EventEmitter=de;typeof Hs!="undefined"&&(Hs.exports=de)});function j(...n){}var xc=n=>n();function gn(){this.dispose()}var vc=()=>typeof __FASTRX_DEVTOOLS__!="undefined",Uc=1,Le=class extends Function{toString(){return`${this.name}(${this.args.length?[...this.args].join(", "):""})`}subscribe(t){let e=new bn(t,this,this.streamId++);return re.subscribe({id:this.id,end:!1},{nodeId:e.sourceId,streamId:e.id}),this(e),e}},pt=class{constructor(){this.defers=new Set,this.disposed=!1}next(t){}complete(){this.dispose()}error(t){this.dispose()}get bindDispose(){return()=>this.dispose()}dispose(){this.disposed=!0,this.complete=j,this.error=j,this.next=j,this.dispose=j,this.subscribe=j,this.doDefer()}subscribe(t){return t instanceof Le?t.subscribe(this):t(this),this}get bindSubscribe(){return t=>this.subscribe(t)}doDefer(){this.defers.forEach(xc),this.defers.clear()}defer(t){this.defers.add(t)}removeDefer(t){this.defers.delete(t)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}},P=class extends pt{constructor(t){super(),this.sink=t,t.defer(this.bindDispose)}next(t){this.sink.next(t)}complete(){this.sink.complete()}error(t){this.sink.error(t)}},dr=class extends pt{constructor(t,e=j,r=j,s=j){if(super(),this._next=e,this._error=r,this._complete=s,this.then=j,t instanceof Le){let a={toString:()=>"subscribe",id:0,source:t};this.defer(()=>{re.defer(a,0)}),re.create(a),re.pipe(a),this.sourceId=a.id,this.subscribe(t),re.subscribe({id:a.id,end:!0}),e==j?this._next=c=>re.next(a,0,c):this.next=c=>{re.next(a,0,c),e(c)},s==j?this._complete=()=>re.complete(a,0):this.complete=()=>{this.dispose(),re.complete(a,0),s()},r==j?this._error=c=>re.complete(a,0,c):this.error=c=>{this.dispose(),re.complete(a,0,c),r()}}else this.subscribe(t)}next(t){this._next(t)}complete(){this.dispose(),this._complete()}error(t){this.dispose(),this._error(t)}};function Y(n,...t){return t.reduce((e,r)=>r(e),n)}function fe(n,t,e){if(vc()){let r=Object.defineProperties(Object.setPrototypeOf(n,Le.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:e,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});re.create(r);for(let s=0;s<e.length;s++){let a=e[s];typeof a=="function"&&a instanceof Le&&re.addSource(r,a)}return r}return n}function D(n,t){return function(...e){return r=>{if(r instanceof Le){let s=fe(a=>{let c=new n(a,...e);c.sourceId=s.id,c.subscribe(r)},t,arguments);return s.source=r,re.pipe(s),s}else return s=>r(new n(s,...e))}}}function $e(n,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:n,payload:t}})}var bn=class extends P{constructor(t,e,r){super(t),this.source=e,this.id=r,this.sourceId=t.sourceId,this.defer(()=>{re.defer(this.source,this.id)})}next(t){re.next(this.source,this.id,t),this.sink.next(t)}complete(){re.complete(this.source,this.id),this.sink.complete()}error(t){re.complete(this.source,this.id,t),this.sink.error(t)}},re={addSource(n,t){$e("addSource",{id:n.id,name:n.toString(),source:{id:t.id,name:t.toString()}})},next(n,t,e){$e("next",{id:n.id,streamId:t,data:e&&e.toString()})},subscribe({id:n,end:t},e){$e("subscribe",{id:n,end:t,sink:{nodeId:e&&e.nodeId,streamId:e&&e.streamId}})},complete(n,t,e){$e("complete",{id:n.id,streamId:t,err:e?e.toString():null})},defer(n,t){$e("defer",{id:n.id,streamId:t})},pipe(n){$e("pipe",{name:n.toString(),id:n.id,source:{id:n.source.id,name:n.source.toString()}})},update(n){$e("update",{id:n.id,name:n.toString()})},create(n){n.id||(n.id=Uc++),$e("create",{name:n.toString(),id:n.id})}},pr=class extends Error{constructor(t){super(`timeout after ${t}ms`),this.timeout=t}};var En=class extends pt{constructor(t){super(),this.source=t,this.sinks=new Set}add(t){t.defer(()=>this.remove(t)),this.sinks.add(t).size===1&&(this.reset(),this.subscribe(this.source))}remove(t){this.sinks.delete(t),this.sinks.size===0&&this.dispose()}next(t){this.sinks.forEach(e=>e.next(t))}complete(){this.sinks.forEach(t=>t.complete()),this.sinks.clear()}error(t){this.sinks.forEach(e=>e.error(t)),this.sinks.clear()}};function mt(){return n=>{let t=new En(n);if(n instanceof Le){let e=fe(r=>{t.add(r)},"share",arguments);return t.sourceId=e.id,e.source=n,re.pipe(e),e}return fe(t.add.bind(t),"share",arguments)}}function Hi(...n){return fe(t=>{let e=new P(t),r=n.length;e.complete=()=>{--r===0&&t.complete()},n.forEach(e.bindSubscribe)},"merge",arguments)}function Oc(...n){return fe(t=>{let e=n.length,r=e,s=e,a=new Array(e),c=()=>{--s===0&&t.complete()},f=(l,d)=>{let _=new P(t);_.next=h=>{--r===0?(_.next=I=>{a[d]=I,t.next(a)},_.next(h)):a[d]=h},_.complete=c,_.subscribe(l)};n.forEach(f)},"combineLatest",arguments)}function qi(...n){return fe(t=>{let e=n.length,r=e,s=new Array(e),a=()=>{--r===0&&t.complete()},c=(f,l)=>{let d=new P(t),_=[];s[l]=_,d.next=h=>{_.push(h),s.every(I=>I.length)&&t.next(s.map(I=>I.shift()))},d.complete=a,d.subscribe(f)};n.forEach(c)},"zip",arguments)}var Tn=class extends P{constructor(t,...e){super(t);let r=new P(this.sink);r.next=s=>this.buffer=s,r.complete=j,r.subscribe(Oc(...e))}next(t){this.buffer&&this.sink.next([t,...this.buffer])}},nd=D(Tn,"withLatestFrom"),Sn=class extends P{constructor(t,e,r){super(t),this.bufferSize=e,this.startBufferEvery=r,this.buffer=[],this.count=0,this.startBufferEvery&&(this.buffers=[[]])}next(t){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach(e=>{e.push(t)}),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(t),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}complete(){this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach(t=>this.sink.next(t)),super.complete()}},sd=D(Sn,"bufferCount"),yn=class extends P{constructor(t,e){super(t),this.buffer=[];let r=new P(t);r.next=s=>{t.next(this.buffer),this.buffer=[]},r.complete=j,r.subscribe(e)}next(t){this.buffer.push(t)}complete(){this.buffer.length&&this.sink.next(this.buffer),super.complete()}},id=D(yn,"buffer");function ft(n){let t=arguments,e=mt()(fe(r=>{e.next=s=>r.next(s),e.complete=()=>r.complete(),e.error=s=>r.error(s),n&&r.subscribe(n)},"subject",t));return e.next=j,e.complete=j,e.error=j,e}function mr(n){return fe(t=>{let e=0,r=setInterval(()=>t.next(e++),n);return t.defer(()=>{clearInterval(r)}),"interval"},"interval",arguments)}function Wi(n,t){return fe(e=>{let r=0,s=setTimeout(()=>{if(e.removeDefer(a),e.next(r++),t){let c=setInterval(()=>e.next(r++),t);e.defer(()=>{clearInterval(c)})}else e.complete()},n),a=()=>{clearTimeout(s)};e.defer(a)},"timer",arguments)}function In(n,t){return e=>{let r=s=>e.next(s);e.defer(()=>t(r)),n(r)}}function ve(n,t){if("on"in n)return fe(In(e=>n.on(t,e),e=>n.off(t,e)),"fromEvent",arguments);if("addListener"in n)return fe(In(e=>n.addListener(t,e),e=>n.removeListener(t,e)),"fromEvent",arguments);if("addEventListener"in n)return fe(In(e=>n.addEventListener(t,e),e=>n.removeEventListener(t,e)),"fromEvent",arguments);throw"target is not a EventDispachter"}var An=class extends P{constructor(t,e,r){super(t),this.f=e;let s=()=>{this.sink.next(this.acc),this.sink.complete()};typeof r=="undefined"?this.next=a=>{this.acc=a,this.complete=s,this.resetNext()}:(this.acc=r,this.complete=s)}next(t){this.acc=this.f(this.acc,t)}},Pc=D(An,"reduce");var Rn=class extends P{constructor(t,e,r){super(t),this.filter=e,this.thisArg=r}next(t){this.filter.call(this.thisArg,t)&&this.sink.next(t)}},_r=D(Rn,"filter"),xn=class extends P{next(t){}},_d=D(xn,"ignoreElements"),vn=class extends P{constructor(t,e){super(t),this.count=e}next(t){this.sink.next(t),--this.count===0&&this.complete()}},Gi=D(vn,"take"),Un=class extends P{constructor(t,e){super(t);let r=new P(t);r.next=()=>t.complete(),r.complete=gn,r.subscribe(e)}},Ue=D(Un,"takeUntil"),On=class extends P{constructor(t,e){super(t),this.f=e}next(t){this.f(t)?this.sink.next(t):this.complete()}},ji=D(On,"takeWhile");var Pn=class extends P{constructor(t,e){super(t),this.count=e}next(t){--this.count===0&&(this.next=super.next)}},hd=D(Pn,"skip"),Nn=class extends P{constructor(t,e){super(t),t.next=j;let r=new P(t);r.next=()=>{r.dispose(),t.resetNext()},r.complete=gn,r.subscribe(e)}},bd=D(Nn,"skipUntil"),Cn=class extends P{constructor(t,e){super(t),this.f=e}next(t){this.f(t)||(this.next=super.next,this.next(t))}},gd=D(Cn,"skipWhile"),Nc={leading:!0,trailing:!1},wn=class extends P{constructor(t,e,r){super(t),this.durationSelector=e,this.trailing=r}cacheValue(t){this.last=t,this.disposed&&this.throttle(t)}send(t){this.sink.next(t),this.throttle(t)}throttle(t){this.reset(),this.subscribe(this.durationSelector(t))}next(){this.complete()}complete(){this.dispose(),this.trailing&&this.send(this.last)}},Dn=class extends P{constructor(t,e,r=Nc){super(t),this.durationSelector=e,this.config=r,this._throttle=new wn(this.sink,this.durationSelector,this.config.trailing),this._throttle.dispose()}next(t){this._throttle.disposed&&this.config.leading?this._throttle.send(t):this._throttle.cacheValue(t)}complete(){this._throttle.throttle=j,this._throttle.complete(),super.complete()}},Yi=D(Dn,"throttle");var Ln=class extends P{next(){this.complete()}complete(){this.dispose(),this.sink.next(this.last)}},fr=class extends P{constructor(t,e){super(t),this.durationSelector=e,this._debounce=new Ln(this.sink),this._debounce.dispose()}next(t){this._debounce.dispose(),this._debounce.reset(),this._debounce.last=t,this._debounce.subscribe(this.durationSelector(t))}complete(){this._debounce.complete(),super.complete()}},$i=D(fr,"debounce"),Ki=n=>D(fr,"debounceTime")(t=>Wi(n)),Mn=class extends P{constructor(t,e,r){super(t),this.count=e,this.defaultValue=r}next(t){this.count--===0&&(this.defaultValue=t,this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("not enough elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},Ed=D(Mn,"elementAt");var kn=class extends P{constructor(t,e){super(t),this.f=e,this.i=0}next(t){this.f(t)?(this.sink.next(this.i++),this.complete()):++this.i}},Td=D(kn,"findIndex"),Bn=class extends P{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t,this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},Sd=D(Bn,"first"),Vn=class extends P{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t)}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},yd=D(Vn,"last"),Fn=class extends P{constructor(t,e){super(t),this.predicate=e,this.index=0}next(t){this.predicate(t,this.index++)?this.result=!0:(this.result=!1,this.complete())}complete(){if(this.result===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.result);super.complete()}},Id=D(Fn,"every");var Hn=class extends P{constructor(t,e,r){super(t),this.f=e,typeof r=="undefined"?this.next=s=>{this.acc=s,this.resetNext(),this.sink.next(this.acc)}:this.acc=r}next(t){this.sink.next(this.acc=this.f(this.acc,t))}},vd=D(Hn,"scan"),qn=class extends P{constructor(){super(...arguments),this.hasLast=!1}next(t){this.hasLast?this.sink.next([this.last,t]):this.hasLast=!0,this.last=t}},Ud=D(qn,"pairwise"),hr=class extends P{constructor(t,e,r){super(t),this.mapper=e,this.thisArg=r}next(t){super.next(this.mapper.call(this.thisArg,t))}},yr=D(hr,"map"),Qn=n=>D(hr,"mapTo")(t=>n),_t=class extends P{constructor(t,e,r){super(t),this.data=e,this.context=r}next(t){let e=this.context.combineResults;e?this.sink.next(e(this.data,t)):this.sink.next(t)}tryComplete(){this.context.resetComplete(),this.dispose()}},ht=class extends P{constructor(t,e,r){super(t),this.makeSource=e,this.combineResults=r,this.index=0}subInner(t,e){let r=this.currentSink=new e(this.sink,t,this);this.complete=this.tryComplete,r.complete=r.tryComplete,r.subscribe(this.makeSource(t,this.index++))}tryComplete(){this.currentSink.resetComplete(),this.dispose()}},br=class extends _t{},gr=class extends ht{next(t){this.subInner(t,br),this.next=e=>{this.currentSink.dispose(),this.subInner(e,br)}}},Ji=D(gr,"switchMap");function Ir(n){return(t,e)=>n(()=>t,e)}var Lt=Ir(D(gr,"switchMapTo")),Wn=class extends _t{tryComplete(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}},Er=class extends ht{constructor(){super(...arguments),this.sources=[],this.next2=this.sources.push.bind(this.sources)}next(t){this.next2(t),this.subNext()}subNext(){this.next=this.next2,this.subInner(this.sources.shift(),Wn),this.disposed&&this.sources.length===0&&this.currentSink.resetComplete()}tryComplete(){this.sources.length===0&&this.currentSink.resetComplete(),this.dispose()}},Od=D(Er,"concatMap"),Pd=Ir(D(Er,"concatMapTo")),Gn=class extends _t{tryComplete(){this.context.inners.delete(this),super.dispose(),this.context.inners.size===0&&this.context.resetComplete()}},Tr=class extends ht{constructor(){super(...arguments),this.inners=new Set}next(t){this.subInner(t,Gn),this.inners.add(this.currentSink)}tryComplete(){this.inners.size===1?this.inners.forEach(t=>t.resetComplete()):this.dispose()}},Nd=D(Tr,"mergeMap"),Cd=Ir(D(Tr,"mergeMapTo")),jn=class extends _t{dispose(){this.context.resetNext(),super.dispose()}},Sr=class extends ht{next(t){this.next=j,this.subInner(t,jn)}},wd=D(Sr,"exhaustMap"),Dd=Ir(D(Sr,"exhaustMapTo")),Yn=class extends P{constructor(t,e){super(t),this.f=e,this.groups=new Map}next(t){let e=this.f(t),r=this.groups.get(e);typeof r=="undefined"&&(r=ft(),r.key=e,this.groups.set(e,r),super.next(r)),r.next(t)}complete(){this.groups.forEach(t=>t.complete()),super.complete()}error(t){this.groups.forEach(e=>e.error(t)),super.error(t)}},Ld=D(Yn,"groupBy"),$n=class extends P{constructor(){super(...arguments),this.start=new Date}next(t){this.sink.next({value:t,interval:Number(new Date)-Number(this.start)}),this.start=new Date}},Md=D($n,"timeInterval"),Kn=class extends P{constructor(t,e){super(t),this.miniseconds=e,this.buffer=[],this.id=setInterval(()=>{this.sink.next(this.buffer.concat()),this.buffer.length=0},this.miniseconds)}next(t){this.buffer.push(t)}complete(){this.sink.next(this.buffer),super.complete()}dispose(){clearInterval(this.id),super.dispose()}},kd=D(Kn,"bufferTime"),Jn=class extends P{constructor(t,e){super(t),this.buffer=[],this.delayTime=e}dispose(){clearTimeout(this.timeoutId),super.dispose()}delay(t){this.timeoutId=setTimeout(()=>{let e=this.buffer.shift();if(e){let{time:r,data:s}=e;super.next(s),this.buffer.length&&this.delay(Number(this.buffer[0].time)-Number(r))}},t)}next(t){this.buffer.length||this.delay(this.delayTime),this.buffer.push({time:new Date,data:t})}complete(){this.timeoutId=setTimeout(()=>super.complete(),this.delayTime)}},Bd=D(Jn,"delay"),Xn=class extends P{constructor(t,e){super(t),this.selector=e}error(t){this.dispose(),this.selector(t)(this.sink)}},Vd=D(Xn,"catchError");var ee=(n=j,t=j,e=j)=>r=>new dr(r,n,t,e),zn=class extends P{constructor(t,e){super(t),e instanceof Function?this.next=r=>{e(r),t.next(r)}:(e.next&&(this.next=r=>{e.next(r),t.next(r)}),e.complete&&(this.complete=()=>{e.complete(),t.complete()}),e.error&&(this.error=r=>{e.error(r),t.error(r)}))}},Ar=D(zn,"tap"),Zn=class extends P{constructor(t,e){super(t),this.timeout=e,this.id=setTimeout(()=>this.error(new pr(this.timeout)),this.timeout)}next(t){super.next(t),clearTimeout(this.id),this.next=super.next}dispose(){clearTimeout(this.id),super.dispose()}},qd=D(Zn,"timeout");function Mt(n,t=!1){let e=Object.defineProperties(ft(),{postMessage:{value:n.postMessage.bind(n)},port:{get(){return n},set(s){n.onmessage=j,n.onmessageerror=j,n=s,r()}}});function r(){n.onmessage=s=>{s.data?s.ports.length||t?e.next(s):e.next(s.data):(e.complete(),n.close())},n.onmessageerror=s=>{e.error(s),n.close()}}return r(),e}var es=class extends P{constructor(t,e){super(t);let r=new P(t);r.next=j,e(r)}},Fe=D(es,"takeUntilComplete");var se={useWt:!0,useAINS:!0,useHardDecoder:"prefer-software",useHardEncoder:"prefer-software",unreliable:!1,debug:!1,assetsPath:"",enableUpload:!0},Cc="__INLINE__WORKER__";var{debug:Rr}=console;se.debug||(console.debug=()=>{});var sp=!Cc.startsWith("__");function ie(...n){}var wc=n=>n();function rs(){this.dispose()}var Dc=()=>typeof __FASTRX_DEVTOOLS__!="undefined",Lc=1,He=class extends Function{toString(){return`${this.name}(${this.args.length?[...this.args].join(", "):""})`}subscribe(t){let e=new ts(t,this,this.streamId++);return Oe.subscribe({id:this.id,end:!1},{nodeId:e.sourceId,streamId:e.id}),this(e),e}},kt=class{constructor(){this.defers=new Set,this.disposed=!1}next(t){}complete(){this.dispose()}error(t){this.dispose()}get bindDispose(){return()=>this.dispose()}dispose(){this.disposed=!0,this.complete=ie,this.error=ie,this.next=ie,this.dispose=ie,this.subscribe=ie,this.doDefer()}subscribe(t){return t instanceof He?t.subscribe(this):t(this),this}get bindSubscribe(){return t=>this.subscribe(t)}doDefer(){this.defers.forEach(wc),this.defers.clear()}defer(t){this.defers.add(t)}removeDefer(t){this.defers.delete(t)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}},L=class extends kt{constructor(t){super(),this.sink=t,t.defer(this.bindDispose)}next(t){this.sink.next(t)}complete(){this.sink.complete()}error(t){this.sink.error(t)}};function vr(n,...t){return t.reduce((e,r)=>r(e),n)}function qe(n,t,e){if(Dc()){let r=Object.defineProperties(Object.setPrototypeOf(n,He.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:e,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});Oe.create(r);for(let s=0;s<e.length;s++){let a=e[s];typeof a=="function"&&a instanceof He&&Oe.addSource(r,a)}return r}return n}function V(n,t){return function(...e){return r=>{if(r instanceof He){let s=qe(a=>{let c=new n(a,...e);c.sourceId=s.id,c.subscribe(r)},t,arguments);return s.source=r,Oe.pipe(s),s}else return s=>r(new n(s,...e))}}}function Ke(n,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:n,payload:t}})}var ts=class extends L{constructor(t,e,r){super(t),this.source=e,this.id=r,this.sourceId=t.sourceId,this.defer(()=>{Oe.defer(this.source,this.id)})}next(t){Oe.next(this.source,this.id,t),this.sink.next(t)}complete(){Oe.complete(this.source,this.id),this.sink.complete()}error(t){Oe.complete(this.source,this.id,t),this.sink.error(t)}},Oe={addSource(n,t){Ke("addSource",{id:n.id,name:n.toString(),source:{id:t.id,name:t.toString()}})},next(n,t,e){Ke("next",{id:n.id,streamId:t,data:e&&e.toString()})},subscribe({id:n,end:t},e){Ke("subscribe",{id:n,end:t,sink:{nodeId:e&&e.nodeId,streamId:e&&e.streamId}})},complete(n,t,e){Ke("complete",{id:n.id,streamId:t,err:e?e.toString():null})},defer(n,t){Ke("defer",{id:n.id,streamId:t})},pipe(n){Ke("pipe",{name:n.toString(),id:n.id,source:{id:n.source.id,name:n.source.toString()}})},update(n){Ke("update",{id:n.id,name:n.toString()})},create(n){n.id||(n.id=Lc++),Ke("create",{name:n.toString(),id:n.id})}},xr=class extends Error{constructor(t){super(`timeout after ${t}ms`),this.timeout=t}};var ns=class extends kt{constructor(t){super(),this.source=t,this.sinks=new Set}add(t){t.defer(()=>this.remove(t)),this.sinks.add(t).size===1&&(this.reset(),this.subscribe(this.source))}remove(t){this.sinks.delete(t),this.sinks.size===0&&this.dispose()}next(t){this.sinks.forEach(e=>e.next(t))}complete(){this.sinks.forEach(t=>t.complete()),this.sinks.clear()}error(t){this.sinks.forEach(e=>e.error(t)),this.sinks.clear()}};function Ur(){return n=>{let t=new ns(n);if(n instanceof He){let e=qe(r=>{t.add(r)},"share",arguments);return t.sourceId=e.id,e.source=n,Oe.pipe(e),e}return qe(t.add.bind(t),"share",arguments)}}function Mc(...n){return qe(t=>{let e=n.length,r=e,s=e,a=new Array(e),c=()=>{--s===0&&t.complete()},f=(l,d)=>{let _=new L(t);_.next=h=>{--r===0?(_.next=I=>{a[d]=I,t.next(a)},_.next(h)):a[d]=h},_.complete=c,_.subscribe(l)};n.forEach(f)},"combineLatest",arguments)}var ss=class extends L{constructor(t,...e){super(t);let r=new L(this.sink);r.next=s=>this.buffer=s,r.complete=ie,r.subscribe(Mc(...e))}next(t){this.buffer&&this.sink.next([t,...this.buffer])}},up=V(ss,"withLatestFrom"),is=class extends L{constructor(t,e,r){super(t),this.bufferSize=e,this.startBufferEvery=r,this.buffer=[],this.count=0,this.startBufferEvery&&(this.buffers=[[]])}next(t){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach(e=>{e.push(t)}),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(t),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}complete(){this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach(t=>this.sink.next(t)),super.complete()}},cp=V(is,"bufferCount"),os=class extends L{constructor(t,e){super(t),this.buffer=[];let r=new L(t);r.next=s=>{t.next(this.buffer),this.buffer=[]},r.complete=ie,r.subscribe(e)}next(t){this.buffer.push(t)}complete(){this.buffer.length&&this.sink.next(this.buffer),super.complete()}},lp=V(os,"buffer");function as(n){let t=arguments,e=Ur()(qe(r=>{e.next=s=>r.next(s),e.complete=()=>r.complete(),e.error=s=>r.error(s),n&&r.subscribe(n)},"subject",t));return e.next=ie,e.complete=ie,e.error=ie,e}function Xi(n){return qe(t=>{let e=0,r=setInterval(()=>t.next(e++),n);return t.defer(()=>{clearInterval(r)}),"interval"},"interval",arguments)}var us=class extends L{constructor(t,e,r){super(t),this.f=e;let s=()=>{this.sink.next(this.acc),this.sink.complete()};typeof r=="undefined"?this.next=a=>{this.acc=a,this.complete=s,this.resetNext()}:(this.acc=r,this.complete=s)}next(t){this.acc=this.f(this.acc,t)}},kc=V(us,"reduce");var cs=class extends L{constructor(t,e,r){super(t),this.filter=e,this.thisArg=r}next(t){this.filter.call(this.thisArg,t)&&this.sink.next(t)}},Qi=V(cs,"filter"),ls=class extends L{next(t){}},Sp=V(ls,"ignoreElements"),ds=class extends L{constructor(t,e){super(t),this.count=e}next(t){this.sink.next(t),--this.count===0&&this.complete()}},zi=V(ds,"take"),ps=class extends L{constructor(t,e){super(t);let r=new L(t);r.next=()=>t.complete(),r.complete=rs,r.subscribe(e)}},yp=V(ps,"takeUntil"),ms=class extends L{constructor(t,e){super(t),this.f=e}next(t){this.f(t)?this.sink.next(t):this.complete()}},Bc=V(ms,"takeWhile");var fs=class extends L{constructor(t,e){super(t),this.count=e}next(t){--this.count===0&&(this.next=super.next)}},Ip=V(fs,"skip"),_s=class extends L{constructor(t,e){super(t),t.next=ie;let r=new L(t);r.next=()=>{r.dispose(),t.resetNext()},r.complete=rs,r.subscribe(e)}},Ap=V(_s,"skipUntil"),hs=class extends L{constructor(t,e){super(t),this.f=e}next(t){this.f(t)||(this.next=super.next,this.next(t))}},Zi=V(hs,"skipWhile"),Vc={leading:!0,trailing:!1},bs=class extends L{constructor(t,e,r){super(t),this.durationSelector=e,this.trailing=r}cacheValue(t){this.last=t,this.disposed&&this.throttle(t)}send(t){this.sink.next(t),this.throttle(t)}throttle(t){this.reset(),this.subscribe(this.durationSelector(t))}next(){this.complete()}complete(){this.dispose(),this.trailing&&this.send(this.last)}},gs=class extends L{constructor(t,e,r=Vc){super(t),this.durationSelector=e,this.config=r,this._throttle=new bs(this.sink,this.durationSelector,this.config.trailing),this._throttle.dispose()}next(t){this._throttle.disposed&&this.config.leading?this._throttle.send(t):this._throttle.cacheValue(t)}complete(){this._throttle.throttle=ie,this._throttle.complete(),super.complete()}},Rp=V(gs,"throttle");var Es=class extends L{next(){this.complete()}complete(){this.dispose(),this.sink.next(this.last)}},Ts=class extends L{constructor(t,e){super(t),this.durationSelector=e,this._debounce=new Es(this.sink),this._debounce.dispose()}next(t){this._debounce.dispose(),this._debounce.reset(),this._debounce.last=t,this._debounce.subscribe(this.durationSelector(t))}complete(){this._debounce.complete(),super.complete()}},xp=V(Ts,"debounce");var Ss=class extends L{constructor(t,e,r){super(t),this.count=e,this.defaultValue=r}next(t){this.count--===0&&(this.defaultValue=t,this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("not enough elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},vp=V(Ss,"elementAt");var ys=class extends L{constructor(t,e){super(t),this.f=e,this.i=0}next(t){this.f(t)?(this.sink.next(this.i++),this.complete()):++this.i}},Up=V(ys,"findIndex"),Is=class extends L{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t,this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},Op=V(Is,"first"),As=class extends L{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t)}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},Pp=V(As,"last"),Rs=class extends L{constructor(t,e){super(t),this.predicate=e,this.index=0}next(t){this.predicate(t,this.index++)?this.result=!0:(this.result=!1,this.complete())}complete(){if(this.result===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.result);super.complete()}},Np=V(Rs,"every");var xs=class extends L{constructor(t,e,r){super(t),this.f=e,typeof r=="undefined"?this.next=s=>{this.acc=s,this.resetNext(),this.sink.next(this.acc)}:this.acc=r}next(t){this.sink.next(this.acc=this.f(this.acc,t))}},Lp=V(xs,"scan"),vs=class extends L{constructor(){super(...arguments),this.hasLast=!1}next(t){this.hasLast?this.sink.next([this.last,t]):this.hasLast=!0,this.last=t}},Mp=V(vs,"pairwise"),Us=class extends L{constructor(t,e,r){super(t),this.mapper=e,this.thisArg=r}next(t){super.next(this.mapper.call(this.thisArg,t))}},ks=V(Us,"map");var bt=class extends L{constructor(t,e,r){super(t),this.data=e,this.context=r}next(t){let e=this.context.combineResults;e?this.sink.next(e(this.data,t)):this.sink.next(t)}tryComplete(){this.context.resetComplete(),this.dispose()}},gt=class extends L{constructor(t,e,r){super(t),this.makeSource=e,this.combineResults=r,this.index=0}subInner(t,e){let r=this.currentSink=new e(this.sink,t,this);this.complete=this.tryComplete,r.complete=r.tryComplete,r.subscribe(this.makeSource(t,this.index++))}tryComplete(){this.currentSink.resetComplete(),this.dispose()}},Or=class extends bt{},Pr=class extends gt{next(t){this.subInner(t,Or),this.next=e=>{this.currentSink.dispose(),this.subInner(e,Or)}}},Fc=V(Pr,"switchMap");function Dr(n){return(t,e)=>n(()=>t,e)}var kp=Dr(V(Pr,"switchMapTo")),Os=class extends bt{tryComplete(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}},Nr=class extends gt{constructor(){super(...arguments),this.sources=[],this.next2=this.sources.push.bind(this.sources)}next(t){this.next2(t),this.subNext()}subNext(){this.next=this.next2,this.subInner(this.sources.shift(),Os),this.disposed&&this.sources.length===0&&this.currentSink.resetComplete()}tryComplete(){this.sources.length===0&&this.currentSink.resetComplete(),this.dispose()}},Bp=V(Nr,"concatMap"),Vp=Dr(V(Nr,"concatMapTo")),Ps=class extends bt{tryComplete(){this.context.inners.delete(this),super.dispose(),this.context.inners.size===0&&this.context.resetComplete()}},Cr=class extends gt{constructor(){super(...arguments),this.inners=new Set}next(t){this.subInner(t,Ps),this.inners.add(this.currentSink)}tryComplete(){this.inners.size===1?this.inners.forEach(t=>t.resetComplete()):this.dispose()}},Fp=V(Cr,"mergeMap"),Hp=Dr(V(Cr,"mergeMapTo")),Ns=class extends bt{dispose(){this.context.resetNext(),super.dispose()}},wr=class extends gt{next(t){this.next=ie,this.subInner(t,Ns)}},qp=V(wr,"exhaustMap"),Wp=Dr(V(wr,"exhaustMapTo")),Cs=class extends L{constructor(t,e){super(t),this.f=e,this.groups=new Map}next(t){let e=this.f(t),r=this.groups.get(e);typeof r=="undefined"&&(r=as(),r.key=e,this.groups.set(e,r),super.next(r)),r.next(t)}complete(){this.groups.forEach(t=>t.complete()),super.complete()}error(t){this.groups.forEach(e=>e.error(t)),super.error(t)}},Gp=V(Cs,"groupBy"),ws=class extends L{constructor(){super(...arguments),this.start=new Date}next(t){this.sink.next({value:t,interval:Number(new Date)-Number(this.start)}),this.start=new Date}},jp=V(ws,"timeInterval"),Ds=class extends L{constructor(t,e){super(t),this.miniseconds=e,this.buffer=[],this.id=setInterval(()=>{this.sink.next(this.buffer.concat()),this.buffer.length=0},this.miniseconds)}next(t){this.buffer.push(t)}complete(){this.sink.next(this.buffer),super.complete()}dispose(){clearInterval(this.id),super.dispose()}},Yp=V(Ds,"bufferTime"),Ls=class extends L{constructor(t,e){super(t),this.buffer=[],this.delayTime=e}dispose(){clearTimeout(this.timeoutId),super.dispose()}delay(t){this.timeoutId=setTimeout(()=>{let e=this.buffer.shift();if(e){let{time:r,data:s}=e;super.next(s),this.buffer.length&&this.delay(Number(this.buffer[0].time)-Number(r))}},t)}next(t){this.buffer.length||this.delay(this.delayTime),this.buffer.push({time:new Date,data:t})}complete(){this.timeoutId=setTimeout(()=>super.complete(),this.delayTime)}},$p=V(Ls,"delay"),Ms=class extends L{constructor(t,e){super(t),this.selector=e}error(t){this.dispose(),this.selector(t)(this.sink)}},Kp=V(Ms,"catchError");var Bs=class extends L{constructor(t,e){super(t),e instanceof Function?this.next=r=>{e(r),t.next(r)}:(e.next&&(this.next=r=>{e.next(r),t.next(r)}),e.complete&&(this.complete=()=>{e.complete(),t.complete()}),e.error&&(this.error=r=>{e.error(r),t.error(r)}))}},zp=V(Bs,"tap"),Vs=class extends L{constructor(t,e){super(t),this.timeout=e,this.id=setTimeout(()=>this.error(new xr(this.timeout)),this.timeout)}next(t){super.next(t),clearTimeout(this.id),this.next=super.next}dispose(){clearTimeout(this.id),super.dispose()}},Zp=V(Vs,"timeout");var eo=vr(Xi(250),ks(()=>performance.now()),Ur()),Pe=n=>t=>{let e=0,r=performance.now();vr(eo,ks(s=>(s-r)/n>>0),Qi(s=>s!=e?(e=s,!0):!1))(t)},Je=n=>t=>{let e=performance.now();vr(eo,Zi(r=>r-e<n),zi(1))(t)};function Xe(n,t,e){let r=t.aborted?Promise.reject(t.reason):new Promise((s,a)=>{t.addEventListener("abort",()=>a(t.reason),{once:!0}),typeof n=="function"?n(s,a):n.then(s,a)});return e?r.catch(e):r}var Hc=new Intl.DateTimeFormat("zh-CN",{dateStyle:"short",timeStyle:"medium"}),rt=()=>Hc.format(new Date),oe=(A=>(A[A.JOIN_ROOM=0]="JOIN_ROOM",A[A.LEAVE_ROOM=1]="LEAVE_ROOM",A[A.PUBLISH=2]="PUBLISH",A[A.UNPUBLISH=3]="UNPUBLISH",A[A.SUBSCRIBE=4]="SUBSCRIBE",A[A.UNSUBSCRIBE=5]="UNSUBSCRIBE",A[A.GET_WHOLE_LIST=6]="GET_WHOLE_LIST",A[A.QUALITY_REPORT=7]="QUALITY_REPORT",A[A.MUTE=8]="MUTE",A[A.UNMUTE=9]="UNMUTE",A[A.CONFIG=10]="CONFIG",A[A.REQUEST_PLI=11]="REQUEST_PLI",A[A.HEARTBEAT=12]="HEARTBEAT",A[A.START_PUSH_CDN=13]="START_PUSH_CDN",A[A.STOP_PUSH_CDN=14]="STOP_PUSH_CDN",A[A.START_MCU_MIX=15]="START_MCU_MIX",A[A.STOP_MCU_MIX=16]="STOP_MCU_MIX",A[A.UDPATE_TRACK=17]="UDPATE_TRACK",A[A.START_PUSHING=18]="START_PUSHING",A[A.STOP_PUSHING=19]="STOP_PUSHING",A[A.SWITCH_ROLE=20]="SWITCH_ROLE",A[A.WHOLE_LIST_UPDATE=255]="WHOLE_LIST_UPDATE",A[A.PEER_JOINED=256]="PEER_JOINED",A[A.PEER_LEFT=257]="PEER_LEFT",A[A.PEER_UDPATED_TRACK=258]="PEER_UDPATED_TRACK",A[A.SELECT_ABILITY=259]="SELECT_ABILITY",A[A.PEER_REQUEST_PLI=260]="PEER_REQUEST_PLI",A[A.AUDIO_DATA=4095]="AUDIO_DATA",A[A.VIDEO_DATA=4096]="VIDEO_DATA",A[A.SCREEN_DATA=4097]="SCREEN_DATA",A[A.NACK=4098]="NACK",A[A.ACK=4099]="ACK",A[A.REQUEST_RTT=4100]="REQUEST_RTT",A[A.RESPONSE_RTT=4101]="RESPONSE_RTT",A[A.PIP_DATA=4102]="PIP_DATA",A[A.LAYER_DATA=4103]="LAYER_DATA",A[A.MAX_FORCE=65535]="MAX_FORCE",A))(oe||{});function Fs(n,t,e){let r=t>65535?1:0,s=0;return e.setUint8(0,s<<4|r),e.setUint16(1,n),r?e.setUint32(3,t):e.setUint16(3,t),r?7:5}function Bt(n,t){let e=n>=255&&n<4095;e&&(t+=4);let s=(t>65535?1:0)?7:5,a=new DataView(new ArrayBuffer(s+t));Fs(n,t,a),e&&(a.setUint32(s,0),s+=4),a=new DataView(a.buffer,s),s=0;let c=I=>{a.setUint8(s,I),s++},f=I=>{a.setUint16(s,I),s+=2},l=(I,U=!1)=>{a.setUint32(s,I,U),s+=4},d=I=>{a.setBigUint64(s,I),s+=8},_=I=>{let U=new Uint8Array(a.buffer,a.byteOffset+s,I);return s+=I,U};return{write8:c,write32:l,write16:f,write64:d,writeData:I=>_(I.length).set(I),dv:a,next:_}}function Lr(n,t,e){let r=JSON.stringify(t),{writeData:s,dv:a}=Bt(n,r.length+16);switch(s(e.split("").map(c=>c.charCodeAt(0))),s(r.split("").map(c=>c.charCodeAt(0))),n){case 11:case 12:case 7:console.debug("send",oe[n],e,t,a.buffer);break;default:n<255&&console.log(rt(),"send",oe[n],e,t,a.buffer)}return a.buffer}var ro=lr(Ft()),Te=class extends ro.EventEmitter{constructor(e){super();this.io=e}get statReportReq(){return this.io.statReportReq.stat}get qualityReport(){return this.io.qualityReportReq.report}get appId(){return this.io.joinReq.sdkAppID}get roomId(){return this.io.joinReq.roomid}get userId(){return this.io.joinRes.openid}get userMap_(){return this.io.userManager.remotePublishedUserMap}send(e,r){return this.io.sendReq(e,r)}post(e,r){return this.io.postReq(e,r)}postMessage(e,r){this.io.postMessage({cmd:e,payload:r})}createResposeOb(e){return ve(this.io,oe[e])}glog(e){self.postMessage({type:"glog",payload:e})}};var Ht=class{constructor(){m(this,"arguments");m(this,"environment");m(this,"preInit");m(this,"preRun");m(this,"postRun");m(this,"onAbort");m(this,"preinitializedWebGLContext");m(this,"noInitialRun");m(this,"noExitRuntime");m(this,"logReadFiles");m(this,"filePackagePrefixURL");m(this,"wasmBinary");m(this,"HEAP");m(this,"IHEAP");m(this,"FHEAP");m(this,"HEAP8");m(this,"HEAP16");m(this,"HEAP32");m(this,"HEAPU8");m(this,"HEAPU16");m(this,"HEAPU32");m(this,"HEAPF32");m(this,"HEAPF64");m(this,"TOTAL_STACK");m(this,"TOTAL_MEMORY");m(this,"FAST_MEMORY");m(this,"preloadedImages");m(this,"preloadedAudios");m(this,"_GetEncodedFrame");m(this,"_ReceivedAudioPacket");m(this,"_CreateUdtPacketizer");m(this,"_PacketizeVideoUdt");m(this,"udtver",3)}onRuntimeInitialized(){}print(t){console.debug(t)}printErr(t){console.debug(t)}},pe=new Ht,B=class{constructor(t,e){this.size=t;m(this,"point");this.point=pe._malloc(t),e&&this.set(e)}set(t){t.length>this.size&&this.grow(t.length),pe.HEAPU8.set(t,this.point)}setUint32(t,e){new DataView(pe.HEAPU8.buffer).setUint32(this.point+t,e)}setBigUint64(t,e){new DataView(pe.HEAPU8.buffer).setBigUint64(this.point+t,e)}getBigUint64(t){return new DataView(pe.HEAPU8.buffer).getBigUint64(this.point+t)}getUint32(t){return pe.HEAPU8[this.point+t]|pe.HEAPU8[this.point+t+1]<<8|pe.HEAPU8[this.point+t+2]<<16|pe.HEAPU8[this.point+t+3]<<24}getInt8(t){return pe.HEAPU8[this.point+t]}uint8Array(t=NaN){return new Uint8Array(pe.HEAPU8.buffer,this.point,t>=0?t:this.size)}uint8Slice(t=NaN){return pe.HEAPU8.slice(this.point,this.point+(t>=0?t:this.size))}fill(t=0,e=this.point,r=this.point+this.size){pe.HEAPU8.fill(t,e,r)}free(){pe._free(this.point)}grow(t){t>this.size&&(this.free(),this.size=t,this.point=pe._malloc(t))}};m(B,"global");var H=pe;var kr=class{constructor(t){m(this,"lastReceiveTime",-1);m(this,"blocking",!1);m(this,"blockCnt",0);m(this,"blockTime",0);m(this,"received",ft());let e=Je(t);Y(this.received,$i(()=>(this.blockDone(),this.lastReceiveTime=Date.now(),e)),ee(()=>{this.blocking=!0},j,()=>{this.blockDone()}))}blockDone(){this.blocking&&(this.blockCnt++,this.blockTime+=Date.now()-this.lastReceiveTime,this.blocking=!1)}clear(){this.blockCnt=0,this.blockTime=0}},qs=class{constructor(t=2){m(this,"videoStatus",{uint32_video_stream_type:2,uint32_video_codec_fps:0,uint32_video_capture_fps:0,uint32_video_receive_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_type:0,uint32_video_gop:0,uint32_video_rps_open:0,uint32_video_rps_interval:0,uint32_video_codec_bitrate:0,uint32_video_total_bitrate:0,uint32_video_fec_ratio:0,uint32_video_fec_recover:0,uint32_video_arq_request:0,uint32_video_arq_recover:0,uint32_video_arq_packets:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_final_lost:0,uint32_video_block_cnt:0,uint32_video_cache_ms:0,uint32_video_total_frame:0,uint32_video_decode_frame:0,uint32_video_block_time:0,uint32_video_quality:0,uint32_video_jitter_fps:0});m(this,"videoPort");m(this,"control");m(this,"lastReceiveTime",-1);m(this,"vBlock",new kr(500));m(this,"ssrc",qs.g_ssrc++);m(this,"framesFromStartPull",0);this.videoStatus.uint32_video_stream_type=t}getVideoStatus(){let t=hn({},this.videoStatus);return t.uint32_video_block_cnt=this.vBlock.blockCnt,t.uint32_video_block_time=this.vBlock.blockTime,t.uint32_video_codec_bitrate>>=1,t.uint32_video_total_bitrate>>=1,t.uint32_video_receive_fps>>=1,t.uint32_video_capture_fps>>=1,t.uint32_video_codec_fps>>=1,this.videoStatus.uint32_video_codec_bitrate=0,this.videoStatus.uint32_video_total_bitrate=0,this.videoStatus.uint32_video_receive_fps=0,this.videoStatus.uint32_video_capture_fps=0,this.videoStatus.uint32_video_codec_fps=0,this.vBlock.clear(),t}demuxPacket(t){let e=t.length,{ssrc:r,videoStatus:s,vBlock:a}=this;s.uint32_video_receive++;let c=Date.now();s.uint32_video_total_bitrate+=e<<3,B.global.set(t);let f=H._ReceivedVideoPacket(B.global.point,e,c/1e3,c%1e3,r);f==0&&(this.lastReceiveTime>0&&c-this.lastReceiveTime>500&&console.debug("demuxPacket",c-this.lastReceiveTime),this.lastReceiveTime=c),a.received.next(f)}gotVideoFrame(t){var r;this.videoStatus.uint32_video_total_frame++,this.videoStatus.uint32_video_codec_bitrate+=t.length<<3,this.videoStatus.uint32_video_receive_fps++,this.videoStatus.uint32_video_capture_fps++;let e=t.slice();(r=this.videoPort)==null||r.postMessage({data:e,packetsReceived:this.videoStatus.uint32_video_receive},[e.buffer])}},qt=qs;m(qt,"g_ssrc",1);var Br=class{constructor(t,e){this.writer=t;this.ssrc=e;m(this,"buffer",new B(960));m(this,"timestamp",0);H._AddAudioChannel(e,e)}feed(){}close(){H._DelAudioChannel(this.ssrc),this.buffer.free()}},Vr=class{constructor(t,e){this.io=e;m(this,"userId");m(this,"tinyId");m(this,"role");m(this,"terminalType");m(this,"lastCapNtpMs",-1);m(this,"startTimestamp",Date.now());m(this,"alastReceivedTimestamp",-1);m(this,"lengthPoint",new B(4));m(this,"audioPuller");m(this,"mainPuller",new qt(2));m(this,"screenPuller",new qt(7));m(this,"aBlock",new kr(250));m(this,"events",[]);m(this,"msg_audio_status",{uint32_audio_format:0,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_total_bitrate:0,uint32_audio_aec:0,uint32_audio_fec_ratio:0,uint32_audio_fec_recover:0,uint32_audio_arq_request:0,uint32_audio_arq_recover:0,uint32_audio_arq_packets:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_final_lost:0,uint32_audio_cache_ms:0,uint32_audio_capture_state:0,uint32_audio_filtered_max_cache_ms:0,uint32_audio_filtered_avg_cache_ms:0,uint32_audio_target_max_cache_ms:0,uint32_audio_target_avg_cache_ms:0,uint32_audio_delay_peak_count:0,uint32_audio_speed_percent:0,uint32_audio_quality:0,uint32_audio_block_time:0,uint32_audio_block_cnt:0,uint32_audio_level:0});m(this,"subscribe",0);m(this,"removing",!1);Object.defineProperties(this,Object.getOwnPropertyDescriptors(t))}remove(){var t;this.lengthPoint.free(),(t=this.audioPuller)==null||t.close()}toDownStreamInfo(t,e){let r=[this.mainPuller.getVideoStatus()];r[0].uint32_video_stream_type=this.subscribe&8?3:2,this.screenPuller.videoPort&&r.push(this.screenPuller.getVideoStatus());let s=hn({},this.msg_audio_status);return s.uint32_audio_codec_bitrate>>=1,s.uint32_audio_total_bitrate>>=1,s.uint32_audio_block_cnt=this.aBlock.blockCnt,s.uint32_audio_block_time=this.aBlock.blockTime,e&&console.log(new Date().toLocaleString(),t.userId,r.map(a=>({t:a.uint32_video_stream_type,r_fps:a.uint32_video_receive_fps,c_fps:a.uint32_video_codec_fps,c_bps:a.uint32_video_codec_bitrate})),s.uint32_audio_codec_bitrate),this.msg_audio_status.uint32_audio_total_bitrate=0,this.msg_audio_status.uint32_audio_codec_bitrate=0,this.aBlock.clear(),{msg_user_info:{str_identifier:this.userId,uint64_tinyid:Number(this.tinyId)},msg_audio_status:s,msg_video_status:r,msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0,uint32_jitter:0}}}getNextVideoFrame(t){this.lengthPoint.setUint32(0,B.global.size);let e=H._GetEncodedFrame(B.global.point,this.lengthPoint.point,!1,t.ssrc),r=this.lengthPoint.getUint32(0);if(e==-1||r==0)return 10;let s=B.global.uint8Array(r);return t.videoStatus.uint32_video_total_frame||console.timeEnd(`${this.userId}${t==this.mainPuller?"big":"aux"}`),t.gotVideoFrame(s),e}startPullOnlyAudio(t,e,r){this.io.log_.info("start pull only audio",t),H._AddAudioChannel(t.ssrc,t.ssrc)}startPull(t,e,r){this.io.log_.info("start pull",t,r);let s=t===this.mainPuller;if(t.videoPort){t.framesFromStartPull=0,t.videoPort.port=e.port;return}let a=s?[2,1]:[7];t.videoPort=e,console.time(`${this.userId}${r.mediaType&2?"aux":"big"}`),Y(e,ee(({width:_,height:h})=>{t.videoStatus.uint32_video_width=_,t.videoStatus.uint32_video_height=h,t.videoStatus.uint32_video_decode_frame++,t.videoStatus.uint32_video_codec_fps++}));let c=_=>{delete t.videoPort,_?this.io.log_.error("stop pull",_):this.io.log_.info("stop pull",t),H._DelVideoChannel(t.ssrc),t.vBlock.received.complete(),s&&this.aBlock.received.complete()};H._AddVideoChannel(t.ssrc,t.ssrc);let f=0,l=0,d=()=>{Date.now()-l>2e3&&(l=Date.now(),this.io.sendReq(11,r))};Y(this.io.wh.interval10ms,_r(_=>(f<=0&&(f=this.getNextVideoFrame(t),f>500&&(f=20)),f-=10,se.useWt&&(_&1)==0&&!a.every(h=>{let I=H._CheckMissingPacket(B.global.point,B.global.size,h,t.ssrc,this.io.rtt);return I>0&&(B.global.setBigUint64(5,BigInt(this.tinyId)),this.io.send(B.global.uint8Array(I))),I>=0}))),Fe(e),ee(d,c,c)),d(),Y(Pe(5e3),Fe(e),ee(d))}};var Gc=1e8;function jc(){let n=new B(500,[0]);return H._GetAudioEnergy(n.point,100),n}var Wt=class extends Te{constructor(){super(...arguments);m(this,"audioReceivedBuff",new B(2048));m(this,"levelsMap",new Map);m(this,"timestampBuff",new B(12))}["decodeAudio"](e,r){Y(this.createResposeOb(4095),Fe(r),ee(({data:s})=>{let c=new DataView(s.buffer,s.byteOffset,s.byteLength).getBigUint64(9).toString();this.userMap_.has(c)&&(this.statReportReq.msg_net_stat_report.uint32_down_real_pkg++,this.statReportReq.msg_net_stat_report.uint32_down_recv_br+=s.byteLength,this.demuxPacket(s,this.userMap_.get(c),e&&r))})),e&&Y(r,ee(({timestamp:s,rtpTimestamp:a,seqNum:c,ssrc:f,data:l})=>{this.audioReceivedBuff.set(l),H._ReceivedRawAudioPacket(this.audioReceivedBuff.point,l.byteLength,s,a,c,f)}))}["pullAudio"]({tinyId:e,writable:r}){let s=this.userMap_.get(e);s&&(s.audioPuller=new Br(r.getWriter(),s.mainPuller.ssrc))}["getAudioEnergy"](e,r){Wt.energys||(Wt.energys=jc());let{energys:s}=Wt;Y(Pe(e),Fe(r),ee(()=>{let a=s.getInt8(0);for(let c=1;c<5*a;c+=5)this.levelsMap.set(s.getUint32(c),s.getInt8(c+4));if(this.userMap_.size>0){let c=[...this.userMap_.values()];r.postMessage(c.map(f=>{let l=Math.min(100,(this.levelsMap.get(f.mainPuller.ssrc)||0)*2);return f.msg_audio_status.uint32_audio_level=l*Gc/100>>0,{userId:f.userId,volume:l}}))}else r.postMessage([])}))}demuxPacket(e,r,s){let{aBlock:a,msg_audio_status:c}=r;a.received.next(!0),c.uint32_audio_total_bitrate+=e.byteLength<<3,c.uint32_audio_codec_bitrate=c.uint32_audio_total_bitrate-31,this.audioReceivedBuff.set(e);let f=Date.now(),l=f/1e3,d=f%1e3;if(s){let _=H._ParseUdtAudioPacket(this.audioReceivedBuff.point,e.length,this.timestampBuff.point,this.timestampBuff.point+4,this.timestampBuff.point+8,this.audioReceivedBuff.point,r.mainPuller.ssrc);if(_>0){let h=this.audioReceivedBuff.getUint32(0),I=H.HEAPU8.slice(h,h+_);s.postMessage({timestamp:this.timestampBuff.getUint32(0),rtpTimestamp:this.timestampBuff.getUint32(4),seqNum:this.timestampBuff.getUint32(8),data:I,ssrc:r.mainPuller.ssrc},[I.buffer])}}else H._ReceivedAudioUdtPacket(this.audioReceivedBuff.point,e.length,l,d,r.mainPuller.ssrc)}},Et=Wt;m(Et,"energys");var so=lr(Ft(),1),no=Symbol("instance"),Xm=Symbol("abortCtrl"),qr=Symbol("cacheResult"),Gt=class{constructor(t,e,r){this.oldState=t,this.newState=e,this.action=r,this.aborted=!1}abort(t){this.aborted=!0,Yt.call(t,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}},nt=class extends Error{constructor(t,e,r){super(e),this.state=t,this.message=e,this.cause=r}};function Yc(n){return typeof n=="object"&&n&&"then"in n}var jt=new Map;function he(n,t,e={}){return(r,s,a)=>{let c=e.action||s;if(!e.context){let l=jt.get(r)||[];jt.has(r)||jt.set(r,l),l.push({from:n,to:t,action:c})}let f=a.value;a.value=function(...l){let d=this;if(e.context&&(d=$.get(typeof e.context=="function"?e.context.call(this,...l):e.context)),d.state===t)return e.sync?d[qr]:Promise.resolve(d[qr]);d.state instanceof Gt&&d.state.action==e.abortAction&&d.state.abort(d);let _=null;Array.isArray(n)?n.length==0?d.state instanceof Gt&&d.state.abort(d):(typeof d.state!="string"||!n.includes(d.state))&&(_=new nt(d._state,`${d.name} ${c} to ${t} failed: current state ${d._state} not from ${n.join("|")}`)):n!==d.state&&(_=new nt(d._state,`${d.name} ${c} to ${t} failed: current state ${d._state} not from ${n}`));let h=R=>{if(e.fail&&e.fail.call(this,R),e.sync){if(e.ignoreError)return R;throw R}else return e.ignoreError?Promise.resolve(R):Promise.reject(R)};if(_)return h(_);let I=d.state,U=new Gt(I,t,c);Yt.call(d,U);let O=R=>{var w;return d[qr]=R,U.aborted||(Yt.call(d,t),(w=e.success)===null||w===void 0||w.call(this,d[qr])),R},J=R=>(Yt.call(d,I,R),h(R));try{let R=f.apply(this,l);return Yc(R)?R.then(O).catch(J):e.sync?O(R):Promise.resolve(O(R))}catch(R){return J(new nt(d._state,`${d.name} ${c} from ${n} to ${t} failed: ${R}`,R instanceof Error?R:new Error(String(R))))}}}}var $c=(()=>typeof window!="undefined"&&window.__AFSM__?(e,r)=>{window.dispatchEvent(new CustomEvent(e,{detail:r}))}:typeof importScripts!="undefined"?(e,r)=>{postMessage({type:e,payload:r})}:()=>{})();function Yt(n,t){let e=this._state;this._state=n;let r=n.toString();n&&this.emit(r,e),this.emit($.STATECHANGED,n,e,t),this.updateDevTools({value:n,old:e,err:t instanceof Error?t.message:String(t)})}var $=class extends so.default{constructor(t,e,r){super(),this.name=t,this.groupName=e,this._state=$.INIT,t||(t=Date.now().toString(36)),r?Object.setPrototypeOf(this,r):r=Object.getPrototypeOf(this),e||(this.groupName=this.constructor.name);let s=r[no];s?this.name=s.name+"-"+s.count++:r[no]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let t=Object.getPrototypeOf(this),e=jt.get(t)||[],r=new Set,s=[],a=[],c=new Set,f=Object.getPrototypeOf(t);jt.has(f)&&(f.stateDiagram.forEach(d=>r.add(d)),f.allStates.forEach(d=>c.add(d))),e.forEach(({from:d,to:_,action:h})=>{typeof d=="string"?s.push({from:d,to:_,action:h}):d.length?d.forEach(I=>{s.push({from:I,to:_,action:h})}):a.push({to:_,action:h})}),s.forEach(({from:d,to:_,action:h})=>{c.add(d),c.add(_),c.add(h+"ing"),r.add(`${d} --> ${h}ing : ${h}`),r.add(`${h}ing --> ${_} : ${h} \u{1F7E2}`),r.add(`${h}ing --> ${d} : ${h} \u{1F534}`)}),a.forEach(({to:d,action:_})=>{r.add(`${_}ing --> ${d} : ${_} \u{1F7E2}`),c.forEach(h=>{h!==d&&r.add(`${h} --> ${_}ing : ${_}`)})});let l=[...r];return Object.defineProperties(t,{stateDiagram:{value:l},allStates:{value:c}}),l}static get(t){let e;return typeof t=="string"?(e=$.instances.get(t),e||$.instances.set(t,e=new $(t,void 0,Object.create($.prototype)))):(e=$.instances2.get(t),e||$.instances2.set(t,e=new $(t.constructor.name,void 0,Object.create($.prototype)))),e}static getState(t){var e;return(e=$.get(t))===null||e===void 0?void 0:e.state}updateDevTools(t={}){$c($.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(t){Yt.call(this,t)}};$.STATECHANGED="stateChanged";$.UPDATEAFSM="updateAFSM";$.INIT="[*]";$.ON="on";$.OFF="off";$.instances=new Map;$.instances2=new WeakMap;var Kc=function(n,t,e,r){function s(a){return a instanceof e?a:new e(function(c){c(a)})}return new(e||(e=Promise))(function(a,c){function f(_){try{d(r.next(_))}catch(h){c(h)}}function l(_){try{d(r.throw(_))}catch(h){c(h)}}function d(_){_.done?a(_.value):s(_.value).then(f,l)}d((r=r.apply(n,t||[])).next())})},Ws=Symbol(32),Gs=Symbol(16),js=Symbol(8),Ne=class{constructor(t){this.g=t,this.consumed=0,t&&(this.need=t.next().value)}setG(t){this.g=t,this.demand(t.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(t,e){return e&&this.consume(),this.need=t,this.flush()}read(t){return Kc(this,void 0,void 0,function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise((e,r)=>{var s;this.reject=r,this.resolve=c=>{delete this.lastReadPromise,delete this.resolve,delete this.need,e(c)},this.demand(t,!0)||(s=this.pull)===null||s===void 0||s.call(this,t)})})}readU32(){return this.read(Ws)}readU16(){return this.read(Gs)}readU8(){return this.read(js)}close(){var t;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),(t=this.reject)===null||t===void 0||t.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let t=null,e=this.buffer.subarray(this.consumed),r=0,s=a=>e.length<(r=a);if(typeof this.need=="number"){if(s(this.need))return;t=e.subarray(0,r)}else if(this.need===Ws){if(s(4))return;t=e[0]<<24|e[1]<<16|e[2]<<8|e[3]}else if(this.need===Gs){if(s(2))return;t=e[0]<<8|e[1]}else if(this.need===js){if(s(1))return;t=e[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(s(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(e.subarray(0,r)),t=this.need}else if(this.g){this.g.throw(new Error("Unsupported type"));return}}else{if(s(this.need.byteLength))return;new Uint8Array(this.need).set(e.subarray(0,r)),t=this.need}return this.consumed+=r,this.g?this.demand(this.g.next(t).value,!0):this.resolve&&this.resolve(t),t}write(t){if(t instanceof Uint8Array?this.malloc(t.length).set(t):"buffer"in t?this.malloc(t.byteLength).set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)):this.malloc(t.byteLength).set(new Uint8Array(t)),this.g||this.resolve)this.flush();else return new Promise(e=>this.pull=e)}writeU32(t){this.malloc(4).set([t>>24&255,t>>16&255,t>>8&255,t&255]),this.flush()}writeU16(t){this.malloc(2).set([t>>8&255,t&255]),this.flush()}writeU8(t){this.malloc(1)[0]=t,this.flush()}malloc(t){if(this.buffer){let e=this.buffer.length,r=e+t;if(r<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,r);else{let s=new Uint8Array(r);s.set(this.buffer),this.buffer=s}return this.buffer.subarray(e,r)}else return this.buffer=new Uint8Array(t),this.buffer}};Ne.U32=Ws;Ne.U16=Gs;Ne.U8=js;var Qe=class extends ${constructor(e){super(e.params.userId,"WebSocket");this.connectFSM=e;m(this,"ws")}connect(){this.connectFSM.log_.info("connect to",this.connectFSM.wsUrl);let e=new WebSocket(this.connectFSM.wsUrl);return console.time("WebSocket connect"),e.binaryType="arraybuffer",Xe((r,s)=>{e.onerror=a=>{e.onmessage=null,this.connectFSM.log_.error("websocket onerror",a),s(a.type)},e.onclose=a=>{e.onmessage=null,s(a),this.connectFSM.log_.info("websocket onclose",a),this.disconnect(a.reason,a.code)},e.onopen=a=>{console.timeEnd("WebSocket connect"),this.connectFSM.log_.info("websocket onopen")},e.onmessage=a=>{try{let c=JSON.parse(String(a.data));if(this.connectFSM.log_.info("websocket verify",c),c.err!==0)throw c.err;this.connectFSM.verify(c.verify,c.rebuild),this.ws=e,r(e);let f=this.connectFSM.createOputReceiver("w");e.onmessage=l=>f.write(l.data)}catch(c){s(c)}}},this.connectFSM.abortCtrl.signal)}disconnect(e="",r=0){return r===0&&this.ws&&(this.ws.onmessage=null,this.ws.close(1e3,e)),this.connectFSM.log_.warn("websocket disconnected :",r,e),this.connectFSM.disconnect(e)}close(){!this.ws||(this.ws.onmessage=null,this.ws.close(1e3,"close"))}sendReq(e,r,s){this.send(Lr(e,r,s||this.connectFSM.generateUUID()))}send(e){var r;this.state=="CONNECTED"&&((r=this.ws)==null||r.send(e))}};me([he(["DISCONNECTED",$.INIT],"CONNECTED")],Qe.prototype,"connect",1),me([he("CONNECTED","DISCONNECTED",{sync:!0,ignoreError:!0})],Qe.prototype,"disconnect",1),me([he([],$.INIT,{sync:!0})],Qe.prototype,"close",1);var _f=new Uint32Array([Date.now()]),Jc=Y(mr(20),yr(()=>performance.now()),mt()),$s=class{constructor(t){this.wt=t;m(this,"chunk",new Map);m(this,"timestamp",performance.now());m(this,"groupId");m(this,"resentCount",0);this.groupId=t.groupid,t.groupid=t.groupid+1&127,t.sentCache.has(this.groupId)&&t.sentCache.get(this.groupId).chunk.clear(),t.sentCache.set(this.groupId,this),Y(Jc,ji(()=>this.chunk.size>0&&this.resentCount<20),Ue(ve(t,"DISCONNECTED")),ee(e=>{e-this.timestamp>2*t.connectFSM.rtt+10&&(this.chunk.forEach((r,s)=>this.wt.send(r.buffer)),console.debug("resent",this.groupId,this.chunk.size,"after",e-this.timestamp,"ms",++this.resentCount),this.timestamp=e)},console.error,()=>{this.wt.sentCache.delete(this.groupId)}))}ack(t){this.chunk.delete(t)}},ze=class extends ${constructor(e){super(e.params.userId,"WebTransport");this.connectFSM=e;m(this,"wt");m(this,"writer");m(this,"dw");m(this,"sentCache",new Map);m(this,"groupid",0);m(this,"mtu",1e3)}async connect(){this.connectFSM.log_.info("connect to",this.connectFSM.wtUrl);let e=new WebTransport(this.connectFSM.wtUrl);console.time("WebTransport connect"),e.ready.then(()=>console.timeEnd("WebTransport connect"));let r=this.connectFSM.abortCtrl.signal,{value:s,stream:a}=await Promise.race([(async()=>{await Xe(e.ready,r);let f=await Xe(e.createBidirectionalStream(),r),l=f.readable.getReader();return this.writer=f.writable.getWriter(),this.dw=e.datagrams.writable.getWriter(),Xe(l.read(),r).then(({value:d})=>(l.releaseLock(),{value:d,stream:f}))})(),new Promise((f,l)=>setTimeout(()=>l(new Error("WebTransport connect timeout")),1e3))]),c=JSON.parse(String.fromCharCode(...s));if(this.connectFSM.log_.info("WebTransport connect result:",c),c.err!==0)throw c.err;this.connectFSM.verify(c.verify,c.rebuild),this.wt=e,Y(ve(this.connectFSM,oe[4099]),Ue(ve(this,"DISCONNECTED")),ee(({data:f})=>{let l=f[0]&127,d=this.sentCache.get(l);!d||d.ack(f[1])})),Promise.race([e.datagrams.readable.pipeTo(new WritableStream(this.connectFSM.createOputReceiver("d"))),a.readable.pipeTo(new WritableStream(this.connectFSM.createOputReceiver("s"))),e.closed]).then(()=>this.disconnect(),this.disconnect.bind(this))}disconnect(e=""){var r;return(r=this.wt)==null||r.close(),this.connectFSM.disconnect(e)}close(){var e;return(e=this.wt)==null?void 0:e.close()}async sendReq(e,r,s){if(s||(s=this.connectFSM.generateUUID()),!this.wt)return new Error("WebTransport not connected");if(!se.unreliable){let U=Lr(e,r,s);return this.writer.write(U).then(()=>!0).catch(this.catchError)}let a=e>=255&&e<4095,c=JSON.stringify(r),f=0,l=c.length+(a?20:16),_=(l>65535?1:0)?7:5,h=Math.ceil(l/this.mtu),I=new $s(this);console.debug("WebTransport send:",a?"ack":"",oe[e],s,"chunks:",h,I.groupId);for(let U=0;U<h;U++){let O=l-U*this.mtu,J=Math.min(this.mtu,O),R=new Uint8Array(_+4+J),w=Fs(e,R.length-_,new DataView(R.buffer));if(R[0]|=2,R.set([1,2,(U==h-1?1<<7:0)|I.groupId,U],w),w+=4,U==0){a&&(R.set([0,0,0,0],w),w+=4);for(let X=0;X<16;X++)R[w++]=s.charCodeAt(X)}for(let X=0;w<R.length;X++)R[w++]=c.charCodeAt(f++);I.chunk.set(U,R),this.send(R.buffer)}}async send(e){if(!(!this.wt||!this.dw)){if(e instanceof ArrayBuffer){if(!e.byteLength)throw io}else{if(!e.length)throw io;e=e.slice(0)}return this.dw.write(e).catch(this.catchError)}}catchError(e){}};me([he(["DISCONNECTED",$.INIT],"CONNECTED")],ze.prototype,"connect",1),me([he("CONNECTED","DISCONNECTED",{sync:!0,ignoreError:!0})],ze.prototype,"disconnect",1),me([he([],$.INIT,{sync:!0})],ze.prototype,"close",1);var io=new Error("WebTransport send empty datagram");var st="5.0.0";var oo=typeof importScripts!="undefined",Wr=typeof registerProcessor!="undefined";var Ks="";var Xc="web.sdk.qcloud.com";var Qc=`https://${Xc}/trtc/webrtc/v5/doc`;var bf=`${Qc}/zh-cn/`,ao="https://yun.tim.qq.com",uo="https://apisgp.my-imcloud.com";var co={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"};var We=(c=>(c[c.TRACE=0]="TRACE",c[c.DEBUG=1]="DEBUG",c[c.INFO=2]="INFO",c[c.WARN=3]="WARN",c[c.ERROR=4]="ERROR",c[c.NONE=5]="NONE",c))(We||{}),lo=18e3;var gf=7*24*3600*1e3;var Gr={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADEDDATA:"loadeddata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture"};var St=1,jr=2,Yr=4,yt=8,It=64,At=16;var Ef=Gr.MAIN,Tf=Gr.AUXILIARY;var po=30;var Sf=Gr.BIG,yf=Gr.SMALL,If=10*1e3;var Af=Object.keys(We),mo=["normal leave","timeout leave","kick","role change"];var Rf=10*1e3;var ho=lr(Ft(),1);var Zc=n=>Number(n)<14e8,fo=function(n,t){let e;Ks?e=Ks:e=Zc(n)?uo:ao;let r=Math.floor(Math.random()*2**31);return`${e}/v5/AVQualityReportSvc/C2S?random=${r}&sdkappid=${n}&cmdtype=${t}`};var Lf=typeof window!="undefined"&&typeof window.glog=="function"?window.glog:()=>{};var $r=n=>typeof n=="undefined",Js=n=>typeof n=="string",_o=n=>typeof n=="number";var{toString:Mf}=Object.prototype;function Xs(n,t){return{userId:t,hasAudio:!!(n&yt),hasVideo:!!(n&St),hasAuxiliary:!!(n&Yr),hasSmall:!!(n&jr),audioMuted:!!(n&It),videoMuted:!!(n&At),audioAvailable:!!(n&yt)&&!(n&It),videoAvailable:!!(n&St)&&!(n&At)}}var Kr=class extends ho.EventEmitter{constructor(e,r,s="userId"){super();this.mySelfId=e;this._log=r;this.key=s;this.userMap=new Map;this.remotePublishedUserMap=new Map}get hasRobotUser(){return!![...this.remotePublishedUserMap.values()].find(e=>e.isRobot)}getPublishedUser(e){return this.remotePublishedUserMap.get(e)}addUser(e){let r=e[this.key],{userId:s,tinyId:a,role:c}=e;if(this.userMap.has(r))return;let f={userId:s,tinyId:a,role:c===20?"anchor":"audience"};this.userMap.set(r,f),this.emit("1",f)}deleteUser(e,r){let s=this.userMap.get(e);if(!s)return;let a=`peer leave [${e}]`;$r(r)||(a+=`:${mo[r]}`),this._log.info(a);let c=this.remotePublishedUserMap.get(e);if(c){let f=c.muteState;c.flag=0,this.emit("5",c.userId),this.deleteRemotePublishedUser(e),this.emit("6",{prevMuteState:f,muteState:c.muteState,flag:0})}this.userMap.delete(e),this.emit("2",s.userId)}setUserList(e){this.userMap.forEach(r=>{e.findIndex(s=>s[this.key]===r[this.key])<0&&this.deleteUser(r[this.key],0)}),e.forEach(r=>{!this.userMap.has(r[this.key])&&r[this.key]!==this.mySelfId&&this.addUser(r)})}addRemotePublishedUser(e){this.remotePublishedUserMap.has(e[this.key])||this.remotePublishedUserMap.set(e[this.key],e)}deleteRemotePublishedUser(e){!this.remotePublishedUserMap.has(e)||this.remotePublishedUserMap.delete(e)}setRemotePublishedUserList(e){this.remotePublishedUserMap.forEach(r=>{let s=r[this.key];if(e.findIndex(a=>a[this.key]===r[this.key])<0){this._log.info(`remote [${s}] unpublish`);let a=r.muteState;r.flag=0,this.emit("5",r.userId),this.deleteRemotePublishedUser(s),this.emit("6",{prevMuteState:a,muteState:r.muteState,flag:0})}}),e.forEach(r=>{var _;let s=r[this.key];if(s===this.mySelfId)return;let{flag:a,userId:c,tinyId:f}=r,l=Xs(a,c),d=(_=this.remotePublishedUserMap.get(s))==null?void 0:_.muteState;if(d){let h=this.remotePublishedUserMap.get(s);h&&h.flag!==a&&(h.flag=a,this._log.info(`remote publish updated: ${JSON.stringify(h.muteState)}`),this.emit("6",{prevMuteState:d,muteState:l,flag:a}))}else this._log.info(`remote publish. state: ${JSON.stringify(l)}`),this.addUser({userId:c,tinyId:f,role:20}),this.emit("3",r),this.emit("6",{prevMuteState:Xs(0,c),muteState:l,flag:a})})}clear(){this.userMap.clear(),this.remotePublishedUserMap.clear()}};var $f=new Date().getTime(),el=0;var Qs=function(){return new Date().getTime()+el},bo=function(){let n=new Date;return n.setTime(Qs()),n.toLocaleString()};function go({url:n,body:t,method:e="POST",timeout:r,priority:s}){return new Promise((a,c)=>{if("fetch"in window)return fetch(n,{method:e,body:t,priority:s}).then(l=>l.text()).then(l=>{try{a({data:JSON.parse(l)})}catch(d){a({data:l})}},c);let f=new XMLHttpRequest;f.onreadystatechange=()=>{if(f.readyState===4)if(f.status>=200&&f.status<300)try{let l=JSON.parse(f.response);a({data:l})}catch(l){a({data:f.response})}else c({status:f.status,statusText:f.statusText||"request failed!"})},f.timeout=r||5e3,f.open(e,n,!0),f.send(t)})}var tl=Object.prototype.hasOwnProperty;var xt=n=>typeof n=="function",Eo=n=>typeof n=="undefined";var To=n=>typeof n=="boolean";var rl=function(n){if(!n||typeof n!="object"||Object.prototype.toString.call(n)!="[object Object]")return!1;let t=Object.getPrototypeOf(n);if(t===null)return!0;let e=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&Function.prototype.toString.call(e)===Function.prototype.toString.call(Object)};function So(n){if(n==null)return!0;if(typeof n=="boolean")return!1;if(typeof n=="number")return n===0;if(typeof n=="string"||typeof n=="function"||Array.isArray(n))return n.length===0;if(n instanceof Error)return n.message==="";if(rl(n))switch(Object.prototype.toString.call(n)){case"[object File]":case"[object Map]":case"[object Set]":return n.size===0;case"[object Object]":{for(let t in n)if(tl.call(n,t))return!1;return!0}}return!1}var nl=0,sl=1,yo=2;function il({retryFunction:n,settings:t,onError:e,onRetrying:r,onRetryFailed:s,onRetrySuccess:a,context:c}){return function(...f){let{retries:l=5,timeout:d=1e3}=t,_=0,h=-1,I=nl,U=async(O,J)=>{let R=c||this;try{let w=await n.apply(R,f);_>0&&a&&a.call(this,_),_=0,O(w)}catch(w){let X=()=>{clearTimeout(h),_=0,I=yo,J(w)},ye=()=>{I!==yo&&_<(xt(l)?l():l)?(_++,I=sl,xt(r)&&r.call(this,_,X),h=window.setTimeout(()=>{h=-1,U(O,J)},xt(d)?d(_):d)):(X(),xt(s)&&s.call(this,w))};xt(e)?e.call(this,{error:w,retry:ye,reject:J,retryFuncArgs:f,retriedCount:_}):ye()}};return new Promise(U)}}var Io=il;var $t=class{constructor(t){m(this,"userId");m(this,"remoteUserId");m(this,"id");m(this,"sdkAppId");m(this,"type");m(this,"isLocal");this.id=t.id,this.userId=t.userId,this.sdkAppId=t.sdkAppId,this.remoteUserId=t.remoteUserId,this.isLocal=To(t.isLocal)?t.isLocal:!0,this.type=this.isLocal?"":t.type}createChild(t){return Object.setPrototypeOf(t,this)}setUserId(t){this.userId=t}setSdkAppId(t){this.sdkAppId=t}log(t,e){let r=this.isLocal?this.userId:this.remoteUserId;e.unshift(`[${this.isLocal?"\u2191":"\u2193"}${this.type&&this.type!=="main"?"*":""}${this.id}${r?`|${r}`:""}]`),Rt.log(t,e,Eo(this.userId)||So(this.userId),this.userId,this.sdkAppId)}info(...t){this.log(2,t)}debug(...t){this.log(1,t)}warn(...t){this.log(3,t)}error(...t){this.log(4,t)}};var Me=typeof navigator=="undefined"?"":navigator.userAgent,k=n=>new RegExp(n,"i").test(Me),ae=n=>{if(k(n)){let t=new RegExp(`${n}\\/([\\d.]+)`),e=Me.match(t);if(e&&e[1])return e[1]}return""},zs=n=>{if(k(n)){let t=new RegExp(`${n}\\/(\\d+)`),e=Me.match(t);if(e&&e[1])return parseFloat(e[1])}return NaN},Ao=/AppleWebKit\/([\d.]+)/i.exec(Me),ol=Ao?parseFloat(Ao[1]):NaN,xo=k("iPad"),vo=typeof navigator!="undefined"&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&k("Macintosh"),Uo=k("iPhone")&&!xo,al=k("iPod"),Jr=Uo||xo||al||vo,vt=k("Android"),Oo=function(){if(vt){let n=Me.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(n){let t=n[1]&&parseFloat(n[1]),e=n[2]&&parseFloat(n[2]);if(t&&e)return parseFloat(`${n[1]}.${n[2]}`);if(t)return t}}return NaN}(),o_=vt&&k("webkit")&&Oo<2.3,a_=vt&&Oo<5&&ol<537,ul=k("Firefox"),cl=ae("Firefox"),u_=zs("Firefox"),Po=k("Edge"),ll=ae("Edge"),No=k("Edg"),dl=ae("Edg"),c_=zs("Edg"),Co=k("SogouMobileBrowser"),pl=ae("SogouMobileBrowser"),wo=k("MetaSr\\s"),ml=ae("MetaSr\\s"),it=k("TBS"),fl=ae("TBS"),Do=k("XWEB"),_l=ae("XWEB"),l_=k("MSIE\\s8\\.0"),hl=k("MSIE\\/\\d+"),d_=function(){if(hl){let n=/MSIE\s(\d+)\.\d/.exec(Me),t=n&&parseFloat(n[1]);return!t&&/Trident\/7.0/i.test(Me)&&/rv:11.0/.test(Me)&&(t=11),t}return NaN}(),bl=k("(micromessenger|webbrowser)"),gl=ae("MicroMessenger"),Zs=!it&&k("MQQBrowser")&&k("COVC"),ei=!it&&k("MQQBrowser")&&!k("COVC"),Ro=ei||Zs?ae("MQQBrowser"):"",Lo=!it&&k(" QQBrowser"),El=ae(" QQBrowser"),Mo=!it&&k("QQBrowserLite"),Tl=ae("QQBrowserLite"),ko=!it&&k("MQBHD"),Sl=ae("MQBHD"),p_=k("Windows"),m_=!Jr&&k("MAC OS X"),f_=!vt&&k("Linux"),__=k("CrOS"),h_=k("MicroMessenger"),b_=k("UCBrowser"),g_=k("Electron"),Bo=k("MiuiBrowser"),yl=ae("MiuiBrowser"),Vo=k("HuaweiBrowser"),E_=k("Huawei")||k("HUAWEI"),T_=k("Honor")||k("HONOR"),Il=ae("HuaweiBrowser"),Fo=k("SamsungBrowser"),Al=ae("SamsungBrowser"),Ho=k("HeyTapBrowser"),Rl=ae("HeyTapBrowser"),qo=k("VivoBrowser"),xl=ae("VivoBrowser"),vl=()=>zs("Chrome"),Wo=k("Chrome"),Ul=!Po&&!wo&&!Co&&!it&&!Do&&!No&&!Lo&&!Bo&&!Vo&&!Fo&&!Ho&&!qo&&Wo,Go=k("HeadlessChrome"),S_=vl(),Ol=ae("Chrome"),Pl=!Wo&&!ei&&!Zs&&!Mo&&!ko&&k("Safari");var jo=ae("Version"),y_=/Android.*(wv|.0.0.0)/.test(Me),Yo=(()=>{if(vo)return jo;if(Jr){let n=Me.match(/OS (\d+)_(\d+)/i);if(n&&n[1]){let t=n[1];return n[2]&&(t+=`.${n[2]}`),t}}return""})(),I_=Number(Yo.split(".")[0]);var A_=(()=>{let n=Number(Yo.split(".")[0]);return n===14||n===13})(),R_=typeof location=="undefined"?!1:location.protocol==="file:"||location.hostname==="localhost"||location.hostname==="127.0.0.1",x_=(()=>{let n;return()=>{if(typeof n=="undefined")try{n=!!window.localStorage}catch(t){n=!1}return n}})(),v_=Nl();function Nl(){let n=new Map([[ul,["Firefox",cl]],[No,["Edg",dl]],[Ul,["Chrome",Ol]],[Pl,["Safari",jo]],[it,["TBS",fl]],[Do,["XWEB",_l]],[bl&&Uo,["WeChat",gl]],[Lo,["QQ(Win)",El]],[ei,["QQ(Mobile)",Ro]],[Zs,["QQ(Mobile X5)",Ro]],[Mo,["QQ(Mac)",Tl]],[ko,["QQ(iPad)",Sl]],[Bo,["MI",yl]],[Vo,["HW",Il]],[Fo,["Samsung",Al]],[Ho,["OPPO",Rl]],[qo,["VIVO",xl]],[Po,["EDGE",ll]],[Co,["SogouMobile",pl]],[wo,["Sogou",ml]]]),t="unknown",e="unknown";return n.has(!0)&&([t,e]=n.get(!0)),{name:t,version:e}}var $o=lr(Ft(),1),Cl=new $o.default,Ut=Cl;var ti=(C=>(C.ROOM_DESTROY="1",C.JOIN_START="21",C.JOIN_SCHEDULE_SUCCESS="22",C.JOIN_SIGNAL_CONNECTION_START="23",C.JOIN_SIGNAL_CONNECTION_END="24",C.JOIN_SEND_CMD="25",C.JOIN_RECEIVED_CMD_RES="26",C.JOIN_SUCCESS="27",C.JOIN_FAILED="28",C.LEAVE_START="51",C.LEAVE_SEND_CMD="52",C.LEAVE_SUCCESS="53",C.PUBLISH_START="61",C.SEND_FIRST_VIDEO_FRAME="62",C.PUBLISH_FAILED="63",C.SUBSCRIBE_START="81",C.SUBSCRIBE_SUCCESS="82",C.SUBSCRIBE_FAILED="84",C.UNSUBSCRIBE_SUCCESS="83",C.LOCAL_TRACK_CAPTURE_START="101",C.LOCAL_TRACK_CAPTURE_SUCCESS="102",C.LOCAL_TRACK_CAPTURE_FAILED="103",C.LOCAL_TRACK_PUBLISHED="104",C.LOCAL_TRACK_UNPUBLISHED="105",C.LOCAL_TRACK_REPLACED="106",C.SWITCH_DEVICE_SUCCESS="107",C.TRACK_MUTED="108",C.TRACK_UNMUTED="109",C.REMOTE_TRACK_SUBSCRIBED="110",C.REMOTE_TRACK_UNSUBSCRIBED="111",C.LOCAL_TRACK_RECAPTURE="112",C.PLAY_TRACK_START="151",C.PLAYER_STATE_CHANGED="152",C.VIDEO_LOADED_DATA="153",C.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",C.SIGNAL_CONNECTION_STATE_CHANGED="201",C.PEER_CONNECTION_STATE_CHANGED="202",C.SINGLE_CONNECTION_STAT="203",C.SPC_RECONNECTED="204",C.HEARTBEAT_REPORT="251",C.RECEIVED_PUBLISHED_USER_LIST="252",C.REMOTE_PUBLISH_STATE_CHANGED="253",C.AUDIO_LEVEL_INTERVAL="260",C.NETWORK_QUALITY="261",C.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",C.QUALITY_LIMITATION_CHANGED="263",C.LOG="264",C))(ti||{});var Ze=ti;var wl="%cTRTC%c%s",Dl="padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;",Ll="display: inline",Ml=!(Jr||vt||Go),ri=class{constructor(){this._isEnableUploadLog=!0;this._localJoinedUser=new Map;this._queue=[];this._timeoutId=-1;this._logLevel=1;this._logLevelToUpload=2;!oo&&!Wr&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&this._timeoutId!==-1}installEvents(){Ut.on(Ze.JOIN_SCHEDULE_SUCCESS,({schedule:t})=>{var e;((e=t==null?void 0:t.config)==null?void 0:e.logLevelToUpload)&&We[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)}),Ut.on(Ze.JOIN_SUCCESS,({room:t})=>{this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()}),Ut.once(Ze.JOIN_FAILED,()=>{this.startUpload()}),Ut.on(Ze.LEAVE_SUCCESS,({room:t})=>{this.deleteJoinedUser(t.userId)})}startUpload(){this._timeoutId===-1&&this.uploadInterval()}addJoinedUser(t){this._localJoinedUser.set(t.userId,t),this.startUpload()}deleteJoinedUser(t){this._localJoinedUser.delete(t)}uploadInterval(){this.upload().catch(()=>{}),this._timeoutId=window.setTimeout(()=>this.uploadInterval(),5e3)}getLogsToUpload(){let t={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&this._localJoinedUser.size===0)return t;let e=0;for(;e<this._queue.length&&e!==50;e++){let r=this._queue[e];if(r.forAllJoinedClients)this._localJoinedUser.forEach(({userId:s,sdkAppId:a})=>{t.map.has(s)?t.map.get(s).logs.push(r):t.map.set(s,{userId:s,sdkAppId:a,logs:[r]})});else if(Js(r.userId)&&_o(r.sdkAppId)){let{userId:s,sdkAppId:a}=r;t.map.has(s)?t.map.get(s).logs.push(r):t.map.set(s,{userId:s,sdkAppId:a,logs:[r]})}}return t.map.size>0&&(t.splicedQueue=this._queue.splice(0,e)),t}async upload(){if(this._queue.length===0||!this._isEnableUploadLog)return;let{map:t,splicedQueue:e}=this.getLogsToUpload();if(t.size===0)return;try{let s=[...t.values()];for(let a=0;a<s.length;a++){let{userId:c,sdkAppId:f,logs:l}=s[a];await this.uploadLogWithRetry(JSON.stringify({timestamp:bo(),sdkAppId:String(f),userId:c,version:st,log:l.map(d=>d.log).join(`
2
+ `)}),f),l.forEach(d=>d.uploaded=!0)}}catch(s){}let r=e.filter(s=>!s.uploaded);r.length>0&&(this._queue=r.concat(this._queue))}uploadLogWithRetry(t,e){return Io({retryFunction:()=>go({url:fo(e,co.LOG),body:t,timeout:5e3,priority:"low"}),settings:{retries:3,timeout:2e3},onError:({retry:r})=>{r()}})()}getPrefix(t){let e=new Date;e.setTime(Qs());let r=String(e.getMilliseconds());return"padStart"in String.prototype&&(r=r.toString().padStart(3,"0")),`[${e.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")}:${r}] <${We[t]}>`}getLogLevel(){return this._logLevel}setLogLevel(t){$r(We[t])||(this._logLevel!==t&&this.info("setLogLevel",t),this._logLevel=t)}enableUploadLog(){this._isEnableUploadLog=!0}disableUploadLog(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}logChunkToString(t){if(Js(t))return t;try{return t instanceof Error?t.toString():JSON.stringify(t)}catch(e){return""}}log(t,e,r=!0,s,a){var l;e.unshift(this.getPrefix(t));let c={log:e.reduce((d,_)=>`${d} ${this.logChunkToString(_)}`.trim(),""),level:t,userId:s,sdkAppId:a,forAllJoinedClients:r};if(Ut.emit(Ze.LOG,{log:c}),this._isEnableUploadLog&&t>=this._logLevelToUpload&&this._queue.push(c),t<this._logLevel)return;let f=((l=We[t])==null?void 0:l.toLowerCase())||"info";Ml?console[f](wl,Dl,Ll,...e):console[f](...e)}debug(...t){this.log(1,t)}info(...t){this.log(2,t)}warn(...t){this.log(3,t)}error(...t){this.log(4,t)}createLogger(t){return new $t(t)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),r=e?Number(e):-1;We[r]&&(this._logLevelToUpload=r)}getQueue(){return this._queue}},Rt=new ri;function Ko(n,t=1,e=1){return n<=1?e:Ko(n-1,e,t+e)}function Fl(n){return n>8?30*1e3:Ko(n)*1e3}function Hl(n,t){return{userId:t,hasAudio:!!(n&yt),hasVideo:!!(n&St),hasAuxiliary:!!(n&Yr),hasSmall:!!(n&jr),audioMuted:!!(n&It),videoMuted:!!(n&At),audioAvailable:!!(n&yt)&&!(n&It),videoAvailable:!!(n&St)&&!(n&At)}}var ni=class{constructor(t){this.connect=t;m(this,"publishReq");m(this,"recovering",!1);m(this,"pingCount",0)}async recoverLocal(){return this.recovering=!0,this.publishReq?this.connect._sendReq(2,this.publishReq).then(t=>{this.connect.log_.info("republish",t)}):!1}recoverRemote(t){this.recovering=!1,t.forEach((e,r)=>{this.connect.sendSubscribe(e)})}onSendReq(t,e){switch(t){case 2:this.publishReq?this.publishReq.mediaType|=e.mediaType:this.publishReq=e;break;case 3:this.publishReq=void 0;break;case 8:this.publishReq&&(this.publishReq.mediaType&=~e.mediaType);break;case 9:this.publishReq&&(this.publishReq.mediaType|=e.mediaType);break;case 12:this.connect.updateDevTools({note:`ping${this.pingCount++}`});break}}},ue=class extends ${constructor(e,r,s){super(s.joinReq.roomid,"Connection");this.id=e;this.port=r;m(this,"signalInfo_");m(this,"reqUser_");m(this,"joinReq");m(this,"frameWorkType");m(this,"userManager");m(this,"joinRes");m(this,"statReportReq");m(this,"qualityReportReq");m(this,"wFSM");m(this,"rtt",50);m(this,"recovery",new ni(this));m(this,"reqPromise",new Map);m(this,"rebuild");m(this,"osName");m(this,"browserInfo");m(this,"tinyId_",new B(32));m(this,"tinyId");m(this,"domains");m(this,"log_");m(this,"params");m(this,"proxy_ws");m(this,"proxy_wt");m(this,"proxy_cloud");m(this,"proxy_unified");m(this,"env");m(this,"wh");m(this,"abortCtrl",new AbortController);m(this,"firstReceiveUserlist");m(this,"connectParams");m(this,"selectDomain",0);m(this,"selectCloudDomain",0);m(this,"abort",this.abortCtrl.abort.bind(this.abortCtrl));m(this,"reconnectedOB",ve(this,"RECONNECTED"));m(this,"reconnectOB",e=>{this.reconnect().then(()=>{this.postMessage({cmd:"signal-connection-state-changed",payload:{prevState:"RECONNECTING",state:"CONNECTED"}}),this.rejoinRoom()},r=>{e.next(r),this.selectDomain=1-this.selectDomain})});console.log(this),Object.assign(this,s),this.connectParams=new URLSearchParams({sdkAppid:this.params.sdkAppId.toString(),userSig:this.params.userSig,identifier:this.params.userId}),this.tinyId&&this.connectParams.append("tinyId",this.tinyId),this.log_=Rt.createLogger({id:`wc${e}`,userId:this.params.userId,sdkAppId:this.params.sdkAppId}),this.proxy_unified?se.useWt=!1:(this.proxy_ws||this.proxy_wt)&&(se.useWt=!!this.proxy_wt),se.useWt?this.wFSM=new ze(this):this.wFSM=new Qe(this),this.userManager=new Kr("",this.log_,"tinyId");let a=c=>this.userManager.on(c,f=>this.postMessage({cmd:c,payload:f}));this.userManager.on("3",({flag:c,userId:f,tinyId:l})=>{let d={flag:c,userId:f,tinyId:l,get muteState(){return Hl(this.flag,this.userId)},subscribe:0,removing:!1};this.log_.debug("create user",d),this.postMessage({cmd:"3",payload:d}),this.userManager.addRemotePublishedUser(new Vr(d,this))}),a("6"),a("5"),a("1"),a("2"),this.statReportReq={tinyid:"",stat:{msg_audio_stat_report:{msg_audio_enc_stat:{uint32_audio_enc_br:0,uint32_audio_frame_interval:0},msg_audio_send_stat:{uint32_audio_send_br:0,uint32_audio_fec_br:0,uint32_audio_arq_br:0}},rpt_msg_video_stat_report:[{uint32_video_type:2,msg_video_enc_stat:{uint32_video_enc_fps:0,uint32_video_enc_br:0,uint32_video_encrd:1},msg_video_send_stat:{uint32_video_send_br:0,uint32_video_fec_br:0,uint32_video_arq_br:0}}],msg_net_stat_report:{uint32_total_send_br:0,uint32_rtt:0,uint32_down_expect_pkg:0,uint32_down_real_pkg:0,uint32_down_recv_br:0},msg_rtt_info_req:{uint64_last_server_timestamp_ms:0,uint32_delay_since_last_server_timestamp_ms:0,uint64_client_timestamp_ms:0},msg_system_load_report:{uint32_total_cpu_rate:0},msg_down_bandwidth_est:{uint32_bandwidth_br:0,uint32_avg_bandwidth_br:0,uint32_jitter:0,uint32_jitter_in_frm:0},msg_play_report:{uint32_video_jitter_receive_fps_ratio:0}}},this.qualityReportReq={tinyid:"",report:{str_sdk_version:this.joinReq.jsSdkVersion,uint32_groupid:0,uint64_datetime:Date.now(),msg_user_info:{str_identifier:"",uint64_tinyid:0},msg_device_info:{uint32_terminal_type:this.joinReq.AbilityOption.GeneralLimit.uint32_terminal_type,str_device_name:this.browserInfo.browserName,str_os_version:this.osName,uint32_net_type:this.joinReq.AbilityOption.GeneralLimit.uint32_net_type,uint32_app_cpu:0,uint32_system_cpu:0,uint32_app_memory:0,uint32_background:0,uint32_headset:0},msg_up_stream_info:{msg_audio_status:{uint32_audio_format:11,uint32_audio_sample_rate:48e3,uint32_audio_codec_bitrate:0,uint32_audio_receive:0},msg_video_status:[{uint32_video_stream_type:2,uint32_video_decode_frame:0,uint32_video_total_frame:0,uint32_video_capture_fps:0,uint32_video_codec_fps:0,uint32_video_enc_fps:0,uint32_video_codec_bitrate:0,uint32_video_total_bitrate:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0,uint32_jitter:0},msg_qos:[]},msg_down_stream_info:[],msg_event_msg:[],str_acc_ip:"",str_client_ip:"",str_groupid:""}}}get aborted(){return this.abortCtrl.signal.aborted}get wtDomain(){return this.env?`${this.env}.rtc.qq.com:8080`:this.proxy_wt?this.proxy_wt:this.domains.length?`${this.domains[this.selectDomain]}:80`:"wasm.rtc.qq.com:80"}get wsDomain(){return this.env?`${this.env}.rtc.qq.com:8687`:this.proxy_cloud.length?this.proxy_cloud[this.selectCloudDomain].replace("wss://",""):this.proxy_ws?this.proxy_ws:this.domains.length?this.domains[this.selectDomain]:"wasm.rtc.qq.com"}get wtUrl(){return`https://${this.wtDomain}/v1/wt?${this.connectParams}`}get wsUrl(){var r;let e=((r=this.domains)==null?void 0:r[this.selectDomain])||"wasm.rtc.qq.com";return`wss://${this.wsDomain}/v1/ws?${this.connectParams}&realHost=${e}`}async connect(){let e=this.wFSM.connect(),r=(s,a=!1)=>c=>{if(this.aborted||typeof c=="number")throw c;return this.selectDomain=s,this.wFSM=a?new ze(this):new Qe(this),console.warn(c),console.warn("downgrade to",a?"WebTransport":"WebSocket",this.selectDomain?"\u5907\u7528\u57DF\u540D":"\u4E3B\u57DF\u540D"),this.wFSM.connect()};return se.useWt&&(this.proxy_ws||!this.proxy_wt)&&(e=e.catch(r(0))),!this.proxy_wt&&!this.proxy_ws&&(e=e.catch(r(1,se.useWt)),se.useWt&&(e=e.catch(r(1)))),e}async joinRoom(){let{dataport:e,stunport:r,relayip:s,socketid:a,checkSigSeq:c}=this.signalInfo_,f=await this.sendReq(0,Object.assign(this.joinReq,{dataport:e,stunport:r,relayip:s,socketid:a,checkSigSeq:c}));if(f.err===0)this.setJoinRes(f.data);else throw f.err;return f}async leaveRoom(){return await this.sendReq(1,{}),this.close()}async rejoinRoom(){if(!this.rebuild){let e=await this.sendReq(0,this.joinReq);if(e.err===0)this.setJoinRes(e.data);else return}return this.recovery.recoverLocal()}async reconnect(){return this.postMessage({cmd:"signal-connection-state-changed",payload:{prevState:"DISCONNECTED",state:"RECONNECTING"}}),this.wFSM.connect()}retry(e=0){if(console.log(rt(),"retry",e),e>po){this.close();return}let r=Je(Fl(e));Y(e?qi(r,this.reconnectOB):r,Gi(1),Ue(this.reconnectedOB),ee(s=>{typeof s!="number"&&this.state==="DISCONNECTED"&&this.retry(e+1)}))}disconnect(e){this.log_.warn("connection lost:",e),this.postMessage({cmd:"signal-connection-state-changed",payload:{prevState:"CONNECTED",state:"DISCONNECTED"}}),this.retry()}close(){this.userManager.clear(),this.port.postMessage(null),this.port.close(),this.wFSM.close()}postMessage(e,r){this.port.postMessage(e,r)}verify(e,r){this.signalInfo_=e,this.rebuild=r,this.reqUser_={openid:e.openid,tinyid:e.tinyid}}async _sendReq(e,r){r.tinyid||(r.reqUser=this.reqUser_);let s=this.generateUUID();return await this.wFSM.sendReq(e,r,s),Xe((a,c)=>this.reqPromise.set(s,{resolve:a,reject:c,startTime:Date.now()}),this.abortCtrl.signal,a=>(console.log("abort",oe[e]),{err:a}))}postReq(e,r){return this.wFSM.sendReq(e,r,this.generateUUID())}async sendReq(e,r){return this.recovery.onSendReq(e,r),this._sendReq(e,r)}send(e){return this.wFSM.send(e)}setJoinRes(e){this.joinRes=e,this.userManager.mySelfId=e.tinyid,this.statReportReq.tinyid=e.tinyid,this.qualityReportReq.tinyid=e.tinyid,this.qualityReportReq.report.str_acc_ip=e.relayip,this.qualityReportReq.report.str_client_ip=e.clientip,this.qualityReportReq.report.msg_user_info.str_identifier=e.openid,this.qualityReportReq.report.msg_user_info.uint64_tinyid=Number(e.tinyid),this.tinyId_.set([...e.tinyid].map(r=>r.charCodeAt(0)).concat(0)),[1,2,3,7].forEach(r=>{H._CreateUdtPacketizer(e.roomid,this.tinyId_.point,e.locationid,r,H.udtver,this.id)}),this.wFSM.sendReq(6,{})}onReceive(e,r,s){let a="",c=0,f=new DataView(s.buffer,s.byteOffset);r<255&&(c=f.getUint32(0),s=s.subarray(4)),r<4095&&(a=String.fromCharCode(...s.subarray(0,16)),s=s.subarray(16));let l=s;if(!a)f=new DataView(s.buffer,s.byteOffset,s.byteLength);else{let _="";for(let h=0,I=s.length,U=32768;h<I;h+=U)_+=String.fromCharCode.apply(null,s.subarray(h,Math.min(h+U,I)));if(c)l=_;else try{l=JSON.parse(_)}catch(h){l=_}}let d=oe[r];switch(r){case 259:this.joinRes&&this.wFSM.sendReq(r,{tinyid:this.joinRes.tinyid}),console.debug(e,"receive:",d,a,l);break;case 256:l.userlist.forEach(R=>{if(this.userManager.addUser({userId:R.userid,tinyId:R.srctinyid,role:R.role}),this.joinRes&&R.srctinyid!=this.joinRes.tinyid&&this.userManager.userMap.has(R.srctinyid)){let w=this.userManager.userMap.get(R.srctinyid);this.sendSubscribe(w)}}),this.log_.info(e,"receive:",d,a,l),this.wFSM.sendReq(r,{count:this.userManager.userMap.size});break;case 257:this.userManager.deleteUser(l.userlist.srctinyid),this.log_.info(e,"receive:",d,a,l),this.wFSM.sendReq(r,{count:this.userManager.userMap.size});break;case 6:this.userManager.setUserList(l.userlist.map(R=>({userId:R.userid,tinyId:R.srctinyid,role:R.role})));break;case 255:this.wFSM.sendReq(r,{count:this.userManager.userMap.size});{let R=l.userlist.map(w=>({userId:w.userid,tinyId:w.srctinyid,flag:w.flag,terminalType:w.terminaltype}));this.firstReceiveUserlist||(this.firstReceiveUserlist=!0,this.postMessage({cmd:Ze.RECEIVED_PUBLISHED_USER_LIST,payload:{publishedUserList:R}})),this.userManager.setRemotePublishedUserList(R),this.recovery.recovering&&this.recovery.recoverRemote(this.userManager.remotePublishedUserMap)}break;case 4100:this.rtt=f.getUint32(4),console.debug(e,"receive:",d,a,l,this.rtt);let{dv:_,writeData:h}=Bt(4101,8);h(s.subarray(0,4)),this.send(_.buffer);break;case 12:this.reqPromise.forEach(R=>{Date.now()-R.startTime>5e3&&(R.reject(new Error("heartbeat timeout")),this.reqPromise.delete(R.uuid))}),self.postMessage({type:"glog",payload:{heartbeatReceive:1}});case 11:case 260:console.debug(e,"receive:",d,a,l);case 7:case 4095:break;case 4096:case 4097:{let R=s.length;this.statReportReq.stat.msg_net_stat_report.uint32_down_real_pkg++,this.statReportReq.stat.msg_net_stat_report.uint32_down_recv_br+=R<<3;let w=f.getBigUint64(9).toString(),X=this.userManager.getPublishedUser(w);X?r===4096?(X.mainPuller.videoStatus.uint32_video_receive||console.timeLog(`${X.userId}big`,"first video data"),X.mainPuller.demuxPacket(s)):(X.screenPuller.videoStatus.uint32_video_receive||console.timeLog(`${X.userId}aux`,"first video data"),X.screenPuller.demuxPacket(s)):console.warn(e,"receive:",d,a,l,"user not found")}break;case 4102:case 4103:case 4099:break;case 4103:H.HEAPU8.set(s,B.global.point+8);let I=H._ParseUdtMousePacket(B.global.point+8,s.length,B.global.point),U=s.subarray(I),O=B.global.getBigUint64(0).toString(),J=this.userManager.userMap.get(O);J&&this.postMessage({cmd:"layerData",payload:{userId:J.userId,tinyId:O,layerData:U}}),console.debug(e,"receive:",d,I,l,O,U);break;case 4098:{let R=f.getUint8(8);for(let w=9;w<s.length;w+=6){let X=f.getUint32(w),ye=f.getUint16(w+4);for(let Ie=0;Ie<=16;Ie++){if(Ie>0&&(ye>>16-Ie&1)==0)continue;let Ae=H._GetRetransPacket(R,X+Ie,B.global.point,this.id),ce=B.global.getUint32(0),be=H.HEAPU8.subarray(ce,ce+Ae);Ae>0&&this.send(be)}}}break;case 1:this.log_.info(e,"receive:",d,a,l),l>0&&l!==3&&(this.postMessage({cmd:"banned",payload:l}),this.close());break;case 258:this.log_.info(e,"receive:",d,a||"",l);break;default:this.log_.info(e,"receive:",d||r,a||"",l)}this.reqPromise.has(a)&&(c&&this.log_.warn(c,l,a),this.reqPromise.get(a).resolve({err:c,data:l,uuid:a}),this.reqPromise.delete(a)),this.emit(d,a?{uuid:a,err:c,data:l}:{data:l})}sendSubscribe(e){let r=e.subscribe;if(r==0)return;let s={mediaType:r,mediaDescription:{audioParam:r&1?{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]}:void 0,videoParam:[4,8,2].filter(a=>r&a).map(a=>({mediaType:a,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]}))},userId:e.userId,srctinyid:e.tinyId};this._sendReq(4,s)}createOputReceiver(e){return new Ne(this.unMarshal(e))}*unMarshal(e){let r=null,s=new Map;for(;;){let a=0,c=0;try{r=yield 1;let f=r[0]>>4,l=r[0]&2,d=r[0]&1;r=yield 4+d*2;let _=new DataView(r.buffer,r.byteOffset);if(c=_.getUint16(0),a=d==1?_.getUint32(2):_.getUint16(2),r=yield a,l){let h=r[0]&63,I=r[1],U=r.subarray(2,2+I);switch(h){case 1:let O=U[0]>>7,J=U[0]&127,R=U[1],{dv:w,write8:X}=Bt(4099,2);X(J),X(R),this.send(w.buffer);let ye=J%64;for(let Ae=0;Ae<64;Ae++){let ce=J-Ae;ce<0&&(ce+=64);let be=ye-Ae;be<0&&(be+=64),s.has(be)&&s.get(be).groupId!=ce&&s.delete(be)}let Ie=s.get(ye);if(Ie||s.set(ye,Ie=new si(J)),r=Ie.push(R,r.slice(2+I),O!=0),r)s.delete(ye);else continue}}this.onReceive(e,c,r)}catch(f){this.log_.error(e,f,a,c,r)}}}generateUUID(){return"xxxxxxxxxxxxxxxx".replace(/[xy]/g,e=>{let r=Math.random()*16|0;return(e=="x"?r:r&3|8).toString(16)})}};m(ue,"JOINED","joined"),m(ue,"CLOSED","closed"),me([he($.INIT,"CONNECTED")],ue.prototype,"connect",1),me([he("CONNECTED",ue.JOINED)],ue.prototype,"joinRoom",1),me([he("RECONNECTED",ue.JOINED,{fail(){this.close()}})],ue.prototype,"rejoinRoom",1),me([he("DISCONNECTED","RECONNECTED")],ue.prototype,"reconnect",1),me([he([],"DISCONNECTED",{sync:!0})],ue.prototype,"disconnect",1),me([he([],ue.CLOSED,{sync:!0})],ue.prototype,"close",1);var si=class{constructor(t){this.groupId=t;m(this,"chunks",[]);m(this,"totalLen",0);m(this,"marker",!1)}push(t,e,r){if(this.chunks[t])return null;if(this.chunks[t]=e,this.totalLen+=e.length,r&&(this.chunks.length=t+1,this.marker=!0),this.marker){for(let a=0;a<this.chunks.length;a++)if(!this.chunks[a])return null;let s=new Uint8Array(this.totalLen);for(;this.chunks.length;){let a=this.chunks.pop();s.set(a,this.totalLen-=a.length)}return s}return null}};var Kt=class extends Te{["publishCdn"](t,e){return"request_time"in t?(console.info("startPublishTXCDN:",t),this.send(18,t).then(e.postMessage)):(console.info("startPublishCDN:",t),this.send(13,t).then(e.postMessage))}["stopPublishCdn"](t,e){return"request_time"in t?(console.info("stopPublishTXCDN:",t),this.send(19,t).then(e.postMessage)):(console.info("stopPublishCDN:",t),this.send(14,t).then(e.postMessage))}["startMcuMix"](t,e){let{inputParam:r,outputParam:s}=t,a={mcuMix:{reqUser:this.io.reqUser_,roomid:t.roomId,sdkAppID:this.appId,socketid:this.io.joinRes.socketid,mcuRequestTime:t.mcuRequestTime,outputSessionId:t.outputSessionId},inputParam:r.map(c=>({userid:c.userId,width:c.width,height:c.height,locationX:c.locationX,locationY:c.locationY,zOrder:c.zOrder,streamType:c.streamType,inputType:c.inputType})),outputParam:{streamId:s.streamId,streamType:s.streamType,videoWidth:s.width,videoHeight:s.height,videoBitrate:s.videoBps,videoFramerate:s.fps,vidoeGOP:s.gop,audioSampleRate:s.audioSampleRate,audioBitrate:s.audioBps,audioChannels:s.audioChannels,backgroundColor:s.backgroundColor,backgroundImage:s.backgroundImg,extraInfo:s.extraInfo,VCodec:s.videoCodec,ACodec:s.audioCodec}};return this.send(15,a).then(e.postMessage)}["stopMcuMix"](t,e){let r={mcuMix:{reqUser:this.io.reqUser_,roomid:this.roomId,sdkAppID:this.appId,socketid:this.io.joinRes.socketid,mcuRequestTime:t.mcuRequestTime,outputSessionId:t.outputSessionId},userid:this.userId,streamType:t.streamType};return console.info("stop mcuMix:",t),this.send(16,r).then(e.postMessage)}};var ql=1200;var Wl=1+2+4+2+8+4+4+4+2,Gl=4+1+1,jl=1+1+1+1+1+1,Ah=1+1+1+1+12,Jo={[1]:1,["audio"]:1,["video"]:4,[2]:4,["auxVideo"]:2,[7]:2,[3]:8};var Rh=Date.now(),xh=Wl+Gl+6+jl+ql+1;var Jt=class extends Te{constructor(){super(...arguments);m(this,"videoEncBuffer_",new B(1920*1080*3>>1));m(this,"videoStats",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0});m(this,"audioStats",{bytesSent:0,packetsSent:0});m(this,"videoTypeIndexMap",new Map([[2,0]]));m(this,"requestTypeMap",new Map([[0,4096]]))}["getLocalVideoStats"](e){e.postMessage({[this.io.joinRes.openid]:this.videoStats})}["getLocalAudioStats"](e){e.postMessage({[this.io.joinRes.openid]:this.audioStats})}["pushAudio"]({sampleRate:e,channelCount:r,bitrate:s,index:a},c,f){var U;let l=new B(e*r*2),d=O=>{this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_level=O.volume*1e8/100>>0;let{data:J}=O,R=J.length;l.set(J),this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_enc_br+=R<<3,this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_frame_interval++,this.audioStats.packetsSent++;let w=H._PacketizeAudioUdt(l.point,R,O.timestamp,e,r,O.energy,B.global.point,B.global.size,this.io.id,!!f);if(w<=0){console.warn("audio pack len is 0");return}this.io.send(B.global.uint8Array(w)),this.audioStats.bytesSent+=w,this.statReportReq.msg_audio_stat_report.msg_audio_send_stat.uint32_audio_send_br+=w<<3,this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_receive++},_=O=>{l.free(),this.send(3,{mediaType:1})},h=new MessageChannel;(U=this.io.wh.playPort)==null||U.postMessage({cmd:"pushAudio",payload:{numberOfChannels:r,bitrate:s},encrypt:!!f,index:a},[h.port2,c.port]);let I=Mt(h.port1);f&&Y(I,ee()),Y(f||I,ee(d,_,_))}createSelectAbilityOb(e,r){let s=r.bitrate;return Y(this.createResposeOb(259),Yi(()=>Je(2e3)),yr(a=>{var c;return(c=a.data.ability.rpt_msg_video_control_info)==null?void 0:c.find(f=>f.uint32_video_type===e)}),_r(a=>{if(!a)return!1;let c=a.uint32_video_enc_br,f=c*Math.pow(1-this.qualityReport.msg_up_stream_info.msg_network_status.uint32_lost/100,2),l=Math.min(s,f);a.uint32_video_enc_br=l,this.glog({[`confBr${e}`]:[c,f,l]});let d=!1;return((h,I)=>{a[I]&&a[I]!==r[h]&&(d=!0,r[h]=a[I])})("bitrate","uint32_video_enc_br"),d}),Qn(r))}["pushVideo"]({profile:{width:e,height:r,frameRate:s,bitrate:a},type:c,trackType:f},l){this.videoStats.frameWidth=e,this.videoStats.frameHeight=r;let d=0,_=Jo[c];this.videoTypeIndexMap.has(c)?d=this.videoTypeIndexMap.get(c):(d=this.statReportReq.rpt_msg_video_stat_report.length,this.requestTypeMap.set(d,c===7?4097:4096),this.videoTypeIndexMap.set(c,d),this.statReportReq.rpt_msg_video_stat_report.push({uint32_video_type:c,msg_video_enc_stat:{uint32_video_enc_fps:0,uint32_video_enc_br:0,uint32_video_encrd:1},msg_video_send_stat:{uint32_video_send_br:0,uint32_video_fec_br:0,uint32_video_arq_br:0}}),this.qualityReport.msg_up_stream_info.msg_video_status.push({uint32_video_codec_bitrate:0,uint32_video_total_bitrate:0,uint32_video_enc_fps:0,uint32_video_capture_fps:0,uint32_video_codec_fps:0,uint32_video_stream_type:c,uint32_video_codec_type:0,uint32_video_decode_frame:0,uint32_video_total_frame:0,uint32_video_width:e,uint32_video_height:r}));let h={width:e,height:r,bitrate:a*1e3,framerate:s};Object.assign(this.qualityReport.msg_up_stream_info.msg_video_status[d],{uint32_video_width:e,uint32_video_height:r});let I=0,U=!1,O=R=>{this.send(3,{mediaType:_})};Y(this.createSelectAbilityOb(c,h),ee(()=>{l.postMessage(h)}));let J=l;f!="camera"&&(this.io.log_.info(`push ${f} track`),J=Hi(l,Y(l,Ki(2e3),Ji(R=>(this.io.log_.warn("start push last video frame"),Y(Pe(2e3),Qn(R),Ue(l),Ar({complete:()=>this.io.log_.warn("stop push last video frame")})))),Fe(l)))),Y(J,ee(R=>{let w=this.getVideoStatus(d);w.uint32_video_total_frame++,I++,this.videoStats.framesSent++,w.uint32_video_capture_fps++,I%300==0&&l.postMessage(260),this.handleVideoEncoded(R,c)},O,O)),Y(this.createResposeOb(260),Fe(l),ee(()=>l.postMessage(260)))}getVideoStatus(e){return this.qualityReport.msg_up_stream_info.msg_video_status[e]}handleVideoEncoded(e,r){let{chunk:s,timestamp:a}=e;this.videoStats.framesEncoded++;let c=this.videoTypeIndexMap.get(r),f=this.getVideoStatus(c);f.uint32_video_decode_frame++,f.uint32_video_codec_fps++,f.uint32_video_enc_fps++,this.statReportReq.rpt_msg_video_stat_report[c].msg_video_enc_stat.uint32_video_enc_fps++;let l="byteLength"in s?s.byteLength:s.data.length;if(this.statReportReq.rpt_msg_video_stat_report[c].msg_video_enc_stat.uint32_video_enc_br+=l<<3,l>this.videoEncBuffer_.size){console.log("buffer too small!");return}"byteLength"in s?s.copyTo(this.videoEncBuffer_.uint8Array(l)):this.videoEncBuffer_.set(s.data),B.global.fill();let d=H._PacketizeVideoUdt(this.videoEncBuffer_.point,l,a,s.type=="key"?1:0,r,B.global.point,this.io.id);this.sendUdtv3Video(d,c)}sendUdtv3Video(e,r){let s=0,a=B.global.uint8Array();for(let c=0;c<e;c++){let f=B.global.getUint32(s);if(f<=0){this.io.log_.warn("sendUdtv3Video pktSize is ",f);continue}this.io.send(a.subarray(s+=4,s+=f)),this.statReportReq.rpt_msg_video_stat_report[r].msg_video_send_stat.uint32_video_send_br+=f<<3,this.videoStats.bytesSent+=f,this.videoStats.packetsSent++}}["mute"](e){if(this.send(8,e),e.userId!==this.io.joinRes.openid){let r=this.userMap_.get(e.srctinyid);r&&(r.subscribe&=~e.mediaType)}}["unmute"](e){if(this.send(9,e),e.userId!==this.io.joinRes.openid){let r=this.userMap_.get(e.srctinyid);r&&(r.subscribe|=e.mediaType)}}["waitKeyFrame"](e){this.send(11,e)}["publish"](e,r){this.audioStats.bytesSent=0,this.audioStats.packetsSent=0,this.videoStats.framesSent=0,this.videoStats.bytesSent=0,this.videoStats.packetsSent=0,this.videoStats.framesEncoded=0;let s={mediaType:e,mediaDescription:{audioParam:e&1?{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]}:void 0,videoParam:[4,8,2].filter(a=>e&a).map(a=>({mediaType:a,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]}))}};this.send(2,s).then(a=>{r.postMessage(a),r.postMessage(null)})}};var Yl=2,Xt=class extends Te{["addEventMsgs"](t){this.qualityReport.msg_event_msg=t}constructor(t){super(t);let e,r=ve(t,ue.JOINED),s=ve(t,ue.CLOSED),a={};Y(r,Lt(Pe(1e3)),Ue(s),ee(l=>{let d=Date.now();this.statReportReq.msg_down_bandwidth_est.uint32_avg_bandwidth_br=this.statReportReq.msg_down_bandwidth_est.uint32_bandwidth_br=this.statReportReq.msg_net_stat_report.uint32_down_recv_br,this.statReportReq.msg_rtt_info_req.uint64_client_timestamp_ms=d,this.statReportReq.msg_rtt_info_req.uint32_delay_since_last_server_timestamp_ms=e&&d-e||0,this.statReportReq.msg_net_stat_report.uint32_down_expect_pkg=this.statReportReq.msg_net_stat_report.uint32_down_real_pkg,this.statReportReq.msg_net_stat_report.uint32_total_send_br=this.statReportReq.msg_audio_stat_report.msg_audio_send_stat.uint32_audio_send_br+this.statReportReq.rpt_msg_video_stat_report.reduce((h,I)=>h+I.msg_video_send_stat.uint32_video_send_br,0),a.bandwidth=this.statReportReq.msg_down_bandwidth_est.uint32_avg_bandwidth_br,a.heartbeatSend=1;let _=[this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_codec_bitrate=this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_enc_br];this.qualityReport.msg_up_stream_info.msg_video_status.forEach((h,I)=>{let U=this.statReportReq.rpt_msg_video_stat_report[I];h.uint32_video_total_bitrate=U.msg_video_send_stat.uint32_video_send_br,_[U.uint32_video_type==7?3:U.uint32_video_type-1]=h.uint32_video_codec_bitrate=U.msg_video_enc_stat.uint32_video_enc_br}),a.localBr=_,this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_total_bitrate=this.statReportReq.msg_audio_stat_report.msg_audio_send_stat.uint32_audio_send_br,l%2&&this.post(12,this.io.statReportReq),this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_frame_interval=0,this.statReportReq.msg_audio_stat_report.msg_audio_send_stat.uint32_audio_send_br=0,this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_enc_br=0,this.statReportReq.rpt_msg_video_stat_report.forEach(h=>{h.msg_video_send_stat.uint32_video_send_br=0,h.msg_video_enc_stat.uint32_video_enc_br=0,h.msg_video_enc_stat.uint32_video_enc_fps=0}),this.statReportReq.msg_net_stat_report.uint32_down_recv_br=0}));let c=Y(this.createResposeOb(12),Ar(l=>{l.err||!l.data||(this.statReportReq.msg_rtt_info_req.uint64_last_server_timestamp_ms=l.data.msg_rtt_info_res.uint64_server_timestamp_ms,e=Date.now(),this.statReportReq.msg_net_stat_report.uint32_rtt=e-l.data.msg_rtt_info_res.uint64_last_client_timestamp_ms-l.data.msg_rtt_info_res.uint32_delay_since_last_client_timestamp_ms,this.statReportReq.msg_net_stat_report.uint32_rtt<0&&(this.statReportReq.msg_net_stat_report.uint32_rtt=30),this.qualityReport.msg_up_stream_info.msg_network_status.uint32_lost=Math.max(0,(l.data.uint32_up_expect_pkg-l.data.uint32_up_real_pkg)*100/l.data.uint32_up_expect_pkg>>0))}));Y(r,Lt(c),Lt(Je(lo)),Ue(s),ee(()=>{this.io.log_.warn("ping timeout,lastrecv:",e,"now:",Date.now()),this.io.state==ue.JOINED&&this.io.wFSM.disconnect("ping timeout")}));let f=new B(13<<2);Y(r,Lt(Pe(Yl*1e3)),Ue(s),ee(l=>{let d=[...this.userMap_.values()];this.qualityReport.uint64_datetime=Date.now(),this.qualityReport.msg_up_stream_info.msg_network_status.uint32_bitrate=this.statReportReq.msg_net_stat_report.uint32_total_send_br,this.qualityReport.msg_up_stream_info.msg_network_status.uint32_rtt=this.statReportReq.msg_net_stat_report.uint32_rtt,this.qualityReport.msg_down_stream_info=d.map(O=>{var w,X;let J=O.toDownStreamInfo(O,l%10===0),R=[J.msg_audio_status.uint32_audio_codec_bitrate];return R[1]=J.msg_video_status[0].uint32_video_codec_bitrate,R[2]=((w=J.msg_video_status[1])==null?void 0:w.uint32_video_codec_bitrate)||0,a[`RemoteBr_${O.userId}`]=R,a[`RemoteBlock_${O.userId}`]=[J.msg_audio_status.uint32_audio_block_cnt,J.msg_video_status[0].uint32_video_block_cnt,((X=J.msg_video_status[1])==null?void 0:X.uint32_video_block_cnt)||0],J}),this.glog(a),a={};let _=this.qualityReport.msg_down_stream_info.map(O=>({userId:O.msg_user_info.str_identifier,rtt:O.msg_network_status.uint32_rtt,loss:O.msg_network_status.uint32_lost})),h=$l(_),I=this.qualityReport.msg_up_stream_info.msg_network_status.uint32_rtt,U=this.qualityReport.msg_up_stream_info.msg_network_status.uint32_lost;this.postMessage("network-quality",{uplinkNetworkQuality:this.io.state!="DISCONNECTED"?Xo(U,I):6,downlinkNetworkQuality:Xo(h.loss,h.rtt),uplinkInfo:this.qualityReport.msg_up_stream_info,msg_down_stream_info:this.qualityReport.msg_down_stream_info,downlinkInfo:_,uplinkRTT:I,uplinkLoss:U,downlinkRTT:h.rtt,downlinkLoss:h.loss}),this.qualityReport.msg_up_stream_info.msg_video_status.forEach(O=>{O.uint32_video_capture_fps>>=1,O.uint32_video_codec_fps>>=1,l%10===0&&console.log(rt(),"video uplink fps:",O.uint32_video_stream_type,O.uint32_video_capture_fps,O.uint32_video_codec_fps)}),this.post(7,this.io.qualityReportReq),this.qualityReport.msg_event_msg=[],this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_level=0,this.qualityReport.msg_up_stream_info.msg_video_status.forEach(O=>{O.uint32_video_capture_fps=0,O.uint32_video_codec_fps=0,O.uint32_video_enc_fps=0})},l=>{},()=>{this.qualityReport.msg_down_stream_info=[...this.userMap_.values()].map(l=>l.toDownStreamInfo(l,!1)),this.post(7,this.io.qualityReportReq),f.free()}))}};function $l(n){let t={rtt:0,loss:0};return Array.isArray(n)&&n.length>0&&(n.forEach(e=>{t.rtt+=e.rtt,t.loss+=e.loss}),Object.keys(t).forEach(e=>{t[e]=Math.round(t[e]/n.length)})),t}function Xo(n,t){return n>50||t>500?5:n>30||t>350?4:n>20||t>200?3:n>10||t>100?2:n>=0||t>=0?1:0}var Qt=class extends Te{async["subscribe"](t,e){let{mediaType:r,srctinyid:s}=t,a=this.userMap_.get(s);if(a){if(a.subscribe|=t.mediaType,t.mediaType=a.subscribe,e)e.postMessage(await this.send(4,t));else return this.send(4,t);r===1&&a.startPullOnlyAudio(a.mainPuller,e,{mediaType:r,srctinyid:s})}}async["unSubscribe"](t,e){let{mediaType:r,srctinyid:s}=t,a=this.userMap_.get(s);if(a){let c=a.subscribe;a.subscribe&=~r,c!==a.subscribe&&e.postMessage(await this.send(a.subscribe===0?5:4,t))}}["pullVideo"]({mediaType:t,tinyId:e},r){let s=this.userMap_.get(e);s&&s.startPull(t===2?s.screenPuller:s.mainPuller,r,{mediaType:t,srctinyid:e})}["changetype"](t){let{mediaType:e,srctinyid:r}=t,s=this.userMap_.get(r);if(s){let a=s.subscribe;e===8?(s.subscribe|=8,s.subscribe&=-5):e===4&&(s.subscribe|=4,s.subscribe&=-9),a!=s.subscribe&&(t.mediaType=s.subscribe,this.send(4,t))}}};var ii=class extends Ht{constructor(e,r,s,a){super();this.seq=e;this.player=r;this.numberOfChannels=s;this.bitrate=a;m(this,"aecPtr");m(this,"encodePrt");m(this,"tenms",sampleRate/100);m(this,"numberOfFrames",this.tenms<<1);m(this,"float32Array");m(this,"pos",0);m(this,"bufferLen",0);m(this,"outputPort");m(this,"mainPort");m(this,"workerPort");m(this,"outPrt");m(this,"audioCaptBuff");m(this,"oput");m(this,"first10ms");m(this,"dumpPort");m(this,"encodeCount",0);typeof r.wasm!="string"&&(this.wasmBinary=r.wasm),this.locateFile=()=>r.wasm}reset(){this.encodeCount=0}print(e){console.debug(e)}printErr(e){console.debug(e)}onRuntimeInitialized(){this.aecPtr=this._malloc(1920*10),this.encodePrt=this._malloc(1920*4),this.outPrt=this._malloc(1920*4),this.float32Array=new Float32Array(this.HEAPU8.buffer,this.encodePrt),this._CreateMediaProcessing(0,1,0,!1),this._UseAINS(se.useAINS),this._SetAudioFrameFormat(sampleRate,this.numberOfChannels),this._InitOpusEncoder(sampleRate,this.numberOfChannels,1),this.bitrate&&this._SetOpusEncBitrate(this.bitrate*1e3),console.log(st,"audio worklet initialized",sampleRate,this.numberOfChannels,this.seq),this.oput=new Ne,this.oput.buffer=new Uint8Array(this.HEAPU8.buffer,this.encodePrt),this.player.encoders[this.seq]=this}aec(e){return this.HEAPU8.set(e,this.aecPtr),this._AudioReverseProcessFloat(this.aecPtr,e.length>>2),this.HEAPU8.subarray(this.aecPtr,this.aecPtr+e.length)}encode(...e){if(!this.bitrate)return;let r=this.encodePrt;for(let s of e){this.float32Array.set(s,this.bufferLen),this.bufferLen+=s.length;let a=0;for(;this.bufferLen-this.pos>=this.tenms;){let c=this.player.delay+(this.bufferLen-this.pos)/(sampleRate/1e3)+20>>0,f=this._AudioProcessFloat(this.encodePrt+this.pos*4,this.tenms,c);if(a<f&&(a=f),this.pos+=this.tenms,this.pos>=this.numberOfFrames){if(this.dumpPort){let h=this.float32Array.slice(0,this.numberOfFrames);this.dumpPort.postMessage({data:h},[h.buffer])}let l=this._OpusEncode(this.encodePrt,this.numberOfFrames,this.outPrt);this.encodeCount++,this.encodeCount<10&&console.log("audio encoded",this.encodeCount,l);let d=this.HEAPU8.slice(this.outPrt,this.outPrt+l),_=a*100/32768;this.mainPort.postMessage(_),this.outputPort.postMessage({data:d,volume:_,energy:a,timestamp:Date.now()},[d.buffer]),a=0,this.float32Array.copyWithin(0,this.numberOfFrames,this.bufferLen),this.bufferLen-=this.numberOfFrames,this.pos-=this.numberOfFrames}}break}}close(){this._free(this.aecPtr),this._free(this.encodePrt)}};function Qo(n){class t extends AudioWorkletProcessor{constructor(s){super();m(this,"oput",new Ne);m(this,"wasm");m(this,"encoders",[]);m(this,"useAINS",!0);console.log("worklet created:",sampleRate),this.wasm=s.processorOptions.wasm,Object.assign(se,s.processorOptions.flag),this.port.onmessage=a=>this.pushAudio(a)}get delay(){var s;return(((s=this.oput.buffer)==null?void 0:s.length)||0)/(sampleRate*4/1e3)}process(s,a){return this.oput.demand(a[0][0],!0),this.encoders.forEach((c,f)=>c.encode(...s[f])),!0}pushAudio(s){if(s.data instanceof Uint8Array){let{data:a}=s;this.encoders.forEach(c=>a=c.aec(s.data)),this.oput.malloc(a.length).set(a);return}switch(console.log("worklet receive",s.data.cmd),s.data.cmd){case"dump":switch(s.data.payload){case"mic0":this.encoders[0].dumpPort=s.ports[0];break}break;case"useAINS":se.useAINS=s.data.payload,this.encoders.forEach(a=>a._UseAINS(s.data.payload));break;case"enableAEC":this.encoders.forEach(a=>a._EnableAEC(s.data.payload));break;case"enableDebug":console.debug=s.data.payload?Rr:()=>{};break;case"pushAudio":{let[a,c]=s.ports,{payload:{numberOfChannels:f,bitrate:l},encrypt:d,index:_}=s.data,h=this.encoders[_]||new ii(_,this,f,l);this.encoders[_]?(h.bitrate=l,h._SetOpusEncBitrate(l*1e3)):n(h),h.reset(),h.mainPort=c,h.workerPort=a,h.outputPort=d?c:a,c.onmessage=I=>{I.data?h.encode(I.data):(console.log(rt(),"encoder",_,"stopped"),a.postMessage(null))}}}}}registerProcessor("global-audio-player",t)}var oi=class{constructor(){m(this,"playPort");m(this,"dumpPort");m(this,"downlinkAudioCount",0);m(this,"interval10ms",Y(mr(10),mt()));m(this,"ios")}glog(t){self.postMessage({type:"glog",payload:t})}async joinRoom(t){let{data:{id:e,payload:r},ports:s}=t,a=new ue(e,s[0],r);a.wh=this;let c=[new Jt(a),new Qt(a),new Et(a),new Xt(a),new Kt(a)],f=(d="leave room")=>{a.leaveRoom().catch(),a.abort(d),this.ios.delete(a)},l=setTimeout(a.abort,5e3,"timeout");Y(Mt(a.port,!0),ee(({data:{cmd:d,payload:_},ports:h})=>{switch(console.log(self.name,"received message",d),d){case"setAudioWorkletPort":this.playPort=h[0];break;case"switchRole":a.sendReq(20,{role:_,privateMapKey:a.params.privateMapKey}).then(U=>h[0].postMessage(U));break;default:let I=h.map(U=>Mt(U));typeof _!="undefined"&&I.unshift(_),c.forEach(U=>{var O;(O=U[d])==null||O.call(U,...I)})}},f,f));try{await a.connect(),postMessage({id:e,payload:await a.joinRoom()}),clearTimeout(l),this.ios.add(a)}catch(d){d instanceof WebTransportError?d=`Transport initialization failed.
3
3
  Reason: ${d.message}.
4
4
  Source: ${d.source}.
5
- Error code: ${d.streamErrorCode}.`:d instanceof nt?d=d.cause:d instanceof Event&&(d=d.type),postMessage({id:e,payload:{err:d}}),a.close()}}};function Xl(n){self.onmessage=async t=>{let e=setTimeout(()=>{self.postMessage({type:"error",payload:"timeout"})},5e3);try{t.data.wasm&&(H.locateFile=function(r,s){return t.data.wasm}),Object.assign(re,t.data.flag),console.time(`Worker[${self.name}${st}]`),H.postRun=[()=>{B.global=new B(1920*1080*3>>1),H._CreateMediaProcessing(0,1,0,!1),console.timeEnd(`Worker[${self.name}${st}]`),H._UseAINS(re.useAINS),this.ios=new Set,t.ports[0].onmessage=l=>{var h,I,U;let[d,_]=l.data;switch(d){case"dump":switch(_){case"audio":this.dumpPort=l.ports[0];break;case"mic0":(h=this.playPort)==null||h.postMessage({cmd:d,payload:_},l.ports);break}break;case"useAINS":H._UseAINS(_),(I=this.playPort)==null||I.postMessage({cmd:d,payload:_});break;case"enableDebug":console.debug=_?Rr:()=>{},(U=this.playPort)==null||U.postMessage({cmd:d,payload:_});break;case"useV2":H.udtver=_?2:3;break;case"useWt":re.useWt=_;break;case"enableAEC":H._EnableAEC(_);break}};let r=0,s=Date.now(),a=0;Y(Pe(1e3),ee(()=>{let _=(Date.now()-s)/10-r;console.debug("interval10ms:",_,_-a),a=_,H._UpdateStreamSync()})),H._SetAudioOutStreamFormat(48e3,1);let c=H._malloc(3*4),f=new B(480<<2);Y(this.interval10ms,ee(()=>{if(r++,H._GetAudioMixedFloat(f.point,48e3,c)>=0){if(this.playPort){let d=f.uint8Slice();this.playPort.postMessage(d,[d.buffer])}if(this.dumpPort){let d=f.uint8Slice();this.dumpPort.postMessage(d,[d.buffer])}this.ios.forEach(d=>d.userManager.remotePublishedUserMap.forEach(_=>{var h;return(h=_.audioPuller)==null?void 0:h.feed()}))}})),self.onmessage=this.joinRoom.bind(this),clearTimeout(e),self.postMessage({type:"ready"})}],n(H)}catch(r){self.postMessage({type:"error",err:r})}}}var Zo=Wr?zo:Xl.bind(new oi);var Ql=function(){var n=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return function(e){e=e||{};var e=typeof e!="undefined"?e:{},r,s;e.ready=new Promise(function(i,o){r=i,s=o});var a={},c;for(c in e)e.hasOwnProperty(c)&&(a[c]=e[c]);var f=[],l="./this.program",d=function(i,o){throw o},_=typeof window=="object",h=typeof importScripts=="function",I=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",U=!_&&!I&&!h,O="";function J(i){return e.locateFile?e.locateFile(i,O):O+i}var R,w,X,ye;function Ie(i){if(!(i instanceof Ec)){var o=i;ce("exiting due to exception: "+o)}}U?(typeof read!="undefined"&&(R=function(o){return read(o)}),X=function(o){var u;return typeof readbuffer=="function"?new Uint8Array(readbuffer(o)):(u=read(o,"binary"),ui(typeof u=="object"),u)},w=function(o,u,p){setTimeout(function(){u(X(o))},0)},typeof scriptArgs!="undefined"?f=scriptArgs:typeof arguments!="undefined"&&(f=arguments),typeof quit=="function"&&(d=function(i,o){Ie(o),quit(i)}),typeof print!="undefined"&&(typeof console=="undefined"&&(console={}),console.log=print,console.warn=console.error=typeof printErr!="undefined"?printErr:print)):(_||h)&&(h?O=self.location.href:typeof document!="undefined"&&document.currentScript&&(O=document.currentScript.src),n&&(O=n),O.indexOf("blob:")!==0?O=O.substr(0,O.replace(/[?#].*/,"").lastIndexOf("/")+1):O="",R=function(i){var o=new XMLHttpRequest;return o.open("GET",i,!1),o.send(null),o.responseText},h&&(X=function(i){var o=new XMLHttpRequest;return o.open("GET",i,!1),o.responseType="arraybuffer",o.send(null),new Uint8Array(o.response)}),w=function(i,o,u){var p=new XMLHttpRequest;p.open("GET",i,!0),p.responseType="arraybuffer",p.onload=function(){if(p.status==200||p.status==0&&p.response){o(p.response);return}u()},p.onerror=u,p.send(null)},ye=function(i){document.title=i});var Ae=e.print||console.log.bind(console),ce=e.printErr||console.warn.bind(console);for(c in a)a.hasOwnProperty(c)&&(e[c]=a[c]);a=null,e.arguments&&(f=e.arguments),e.thisProgram&&(l=e.thisProgram),e.quit&&(d=e.quit);function be(i){be.shown||(be.shown={}),be.shown[i]||(be.shown[i]=1,ce(i))}function ta(i,o){if(typeof WebAssembly.Function=="function"){for(var u={i:"i32",j:"i64",f:"f32",d:"f64"},p={parameters:[],results:o[0]=="v"?[]:[u[o[0]]]},b=1;b<o.length;++b)p.parameters.push(u[o[b]]);return new WebAssembly.Function(p,i)}var E=[1,0,1,96],T=o.slice(0,1),y=o.slice(1),S={i:127,j:126,f:125,d:124};E.push(y.length);for(var b=0;b<y.length;++b)E.push(S[y[b]]);T=="v"?E.push(0):E=E.concat([1,S[T]]),E[1]=E.length-2;var x=new Uint8Array([0,97,115,109,1,0,0,0].concat(E,[2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0])),q=new WebAssembly.Module(x),Q=new WebAssembly.Instance(q,{e:{f:i}}),W=Q.exports.f;return W}var Xr=[],et;function ra(){if(Xr.length)return Xr.pop();try{at.grow(1)}catch(i){throw i instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":i}return at.length-1}function na(i,o){for(var u=i;u<i+o;u++){var p=er(u);p&&et.set(p,u)}}function sa(i,o){if(et||(et=new WeakMap,na(0,at.length)),et.has(i))return et.get(i);var u=ra();try{Ii(u,i)}catch(b){if(!(b instanceof TypeError))throw b;var p=ta(i,o);Ii(u,p)}return et.set(i,u),u}function ia(i){et.delete(er(i)),Xr.push(i)}var Ot;e.wasmBinary&&(Ot=e.wasmBinary);var zl=e.noExitRuntime||!1;typeof WebAssembly!="object"&&ut("no native wasm support detected");var zt,ai=!1,oa;function ui(i,o){i||ut("Assertion failed: "+o)}function A(i){var o=e["_"+i];return ui(o,"Cannot call unknown function "+i+", make sure it is exported"),o}function ci(i,o,u,p,b){var E={string:function(G){var se=0;if(G!=null&&G!==0){var K=(G.length<<2)+1;se=pn(K),pi(G,se,K)}return se},array:function(G){var se=pn(G.length);return _i(G,se),se}};function T(G){return o==="string"?Pt(G):o==="boolean"?Boolean(G):G}var y=A(i),S=[],x=0;if(p)for(var q=0;q<p.length;q++){var Q=E[u[q]];Q?(x===0&&(x=Di()),S[q]=Q(p[q])):S[q]=p[q]}var W=y.apply(null,S);function Z(G){return x!==0&&Li(x),T(G)}return W=Z(W),W}function aa(i,o,u,p){u=u||[];var b=u.every(function(T){return T==="number"}),E=o!=="string";return E&&b&&!p?A(i):function(){return ci(i,o,u,arguments,p)}}var li=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function Qr(i,o,u){for(var p=o+u,b=o;i[b]&&!(b>=p);)++b;if(b-o>16&&i.subarray&&li)return li.decode(i.subarray(o,b));for(var E="";o<b;){var T=i[o++];if(!(T&128)){E+=String.fromCharCode(T);continue}var y=i[o++]&63;if((T&224)==192){E+=String.fromCharCode((T&31)<<6|y);continue}var S=i[o++]&63;if((T&240)==224?T=(T&15)<<12|y<<6|S:T=(T&7)<<18|y<<12|S<<6|i[o++]&63,T<65536)E+=String.fromCharCode(T);else{var x=T-65536;E+=String.fromCharCode(55296|x>>10,56320|x&1023)}}return E}function Pt(i,o){return i?Qr(le,i,o):""}function di(i,o,u,p){if(!(p>0))return 0;for(var b=u,E=u+p-1,T=0;T<i.length;++T){var y=i.charCodeAt(T);if(y>=55296&&y<=57343){var S=i.charCodeAt(++T);y=65536+((y&1023)<<10)|S&1023}if(y<=127){if(u>=E)break;o[u++]=y}else if(y<=2047){if(u+1>=E)break;o[u++]=192|y>>6,o[u++]=128|y&63}else if(y<=65535){if(u+2>=E)break;o[u++]=224|y>>12,o[u++]=128|y>>6&63,o[u++]=128|y&63}else{if(u+3>=E)break;o[u++]=240|y>>18,o[u++]=128|y>>12&63,o[u++]=128|y>>6&63,o[u++]=128|y&63}}return o[u]=0,u-b}function pi(i,o,u){return di(i,le,o,u)}function mi(i){for(var o=0,u=0;u<i.length;++u){var p=i.charCodeAt(u);p>=55296&&p<=57343&&(p=65536+((p&1023)<<10)|i.charCodeAt(++u)&1023),p<=127?++o:p<=2047?o+=2:p<=65535?o+=3:o+=4}return o}var fi=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function C(i,o){for(var u=i,p=u>>1,b=p+o/2;!(p>=b)&&Zt[p];)++p;if(u=p<<1,u-i>32&&fi)return fi.decode(le.subarray(i,u));for(var E="",T=0;!(T>=o/2);++T){var y=ot[i+T*2>>1];if(y==0)break;E+=String.fromCharCode(y)}return E}function ua(i,o,u){if(u===void 0&&(u=2147483647),u<2)return 0;u-=2;for(var p=o,b=u<i.length*2?u/2:i.length,E=0;E<b;++E){var T=i.charCodeAt(E);ot[o>>1]=T,o+=2}return ot[o>>1]=0,o-p}function ca(i){return i.length*2}function la(i,o){for(var u=0,p="";!(u>=o/4);){var b=M[i+u*4>>2];if(b==0)break;if(++u,b>=65536){var E=b-65536;p+=String.fromCharCode(55296|E>>10,56320|E&1023)}else p+=String.fromCharCode(b)}return p}function da(i,o,u){if(u===void 0&&(u=2147483647),u<4)return 0;for(var p=o,b=p+u-4,E=0;E<i.length;++E){var T=i.charCodeAt(E);if(T>=55296&&T<=57343){var y=i.charCodeAt(++E);T=65536+((T&1023)<<10)|y&1023}if(M[o>>2]=T,o+=4,o+4>b)break}return M[o>>2]=0,o-p}function pa(i){for(var o=0,u=0;u<i.length;++u){var p=i.charCodeAt(u);p>=55296&&p<=57343&&++u,o+=4}return o}function _i(i,o){te.set(i,o)}function ma(i,o,u){for(var p=0;p<i.length;++p)te[o++>>0]=i.charCodeAt(p);u||(te[o>>0]=0)}function fa(i,o){return i%o>0&&(i+=o-i%o),i}var zr,te,le,ot,Zt,M,ke,hi,Zr;function bi(i){zr=i,e.HEAP8=te=new Int8Array(i),e.HEAP16=ot=new Int16Array(i),e.HEAP32=M=new Int32Array(i),e.HEAPU8=le=new Uint8Array(i),e.HEAPU16=Zt=new Uint16Array(i),e.HEAPU32=ke=new Uint32Array(i),e.HEAPF32=hi=new Float32Array(i),e.HEAPF64=Zr=new Float64Array(i)}var Zl=e.INITIAL_MEMORY||134217728,at,gi=[],Ei=[],_a=[],Ti=[],ha=!1;function ba(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Ta(e.preRun.shift());tn(gi)}function ga(){ha=!0,tn(Ei)}function Ea(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)ya(e.postRun.shift());tn(Ti)}function Ta(i){gi.unshift(i)}function Sa(i){Ei.unshift(i)}function ya(i){Ti.unshift(i)}var tt=0,en=null,Nt=null;function Ia(i){tt++,e.monitorRunDependencies&&e.monitorRunDependencies(tt)}function Aa(i){if(tt--,e.monitorRunDependencies&&e.monitorRunDependencies(tt),tt==0&&(en!==null&&(clearInterval(en),en=null),Nt)){var o=Nt;Nt=null,o()}}e.preloadedImages={},e.preloadedAudios={};function ut(i){e.onAbort&&e.onAbort(i),i="Aborted("+i+")",ce(i),ai=!0,oa=1,i+=". Build with -s ASSERTIONS=1 for more info.";var o=new WebAssembly.RuntimeError(i);throw s(o),o}var Ra="data:application/octet-stream;base64,";function Si(i){return i.startsWith(Ra)}var Re;Re="av_processing.wasm",Si(Re)||(Re=J(Re));function yi(i){try{if(i==Re&&Ot)return new Uint8Array(Ot);if(X)return X(i);throw"both async and sync fetching of the wasm failed"}catch(o){ut(o)}}function xa(){return!Ot&&(_||h)&&typeof fetch=="function"?fetch(Re,{credentials:"same-origin"}).then(function(i){if(!i.ok)throw"failed to load wasm binary file at '"+Re+"'";return i.arrayBuffer()}).catch(function(){return yi(Re)}):Promise.resolve().then(function(){return yi(Re)})}function va(){var i={a:Pu};function o(T,y){var S=T.exports;e.asm=S,zt=e.asm.B,bi(zt.buffer),at=e.asm.na,Sa(e.asm.C),Aa("wasm-instantiate")}Ia("wasm-instantiate");function u(T){o(T.instance)}function p(T){return xa().then(function(y){return WebAssembly.instantiate(y,i)}).then(function(y){return y}).then(T,function(y){ce("failed to asynchronously prepare wasm: "+y),ut(y)})}function b(){return!Ot&&typeof WebAssembly.instantiateStreaming=="function"&&!Si(Re)&&typeof fetch=="function"?fetch(Re,{credentials:"same-origin"}).then(function(T){var y=WebAssembly.instantiateStreaming(T,i);return y.then(u,function(S){return ce("wasm streaming compile failed: "+S),ce("falling back to ArrayBuffer instantiation"),p(u)})}):p(u)}if(e.instantiateWasm)try{var E=e.instantiateWasm(i,o);return E}catch(T){return ce("Module.instantiateWasm callback failed with error: "+T),!1}return b().catch(s),{}}function tn(i){for(;i.length>0;){var o=i.shift();if(typeof o=="function"){o(e);continue}var u=o.func;typeof u=="number"?o.arg===void 0?er(u)():er(u)(o.arg):u(o.arg===void 0?null:o.arg)}}function er(i){return at.get(i)}function Ua(){var i=new Error;if(!i.stack){try{throw new Error}catch(o){i=o}if(!i.stack)return"(no stack trace available)"}return i.stack.toString()}function Ii(i,o){at.set(i,o)}function Oa(i){return or(i+16)+16}function Pa(i,o){_a.unshift({func:i,arg:o})}function Na(i,o){return Pa(i,o)}function Ca(i){this.excPtr=i,this.ptr=i-16,this.set_type=function(o){M[this.ptr+4>>2]=o},this.get_type=function(){return M[this.ptr+4>>2]},this.set_destructor=function(o){M[this.ptr+8>>2]=o},this.get_destructor=function(){return M[this.ptr+8>>2]},this.set_refcount=function(o){M[this.ptr>>2]=o},this.set_caught=function(o){o=o?1:0,te[this.ptr+12>>0]=o},this.get_caught=function(){return te[this.ptr+12>>0]!=0},this.set_rethrown=function(o){o=o?1:0,te[this.ptr+13>>0]=o},this.get_rethrown=function(){return te[this.ptr+13>>0]!=0},this.init=function(o,u){this.set_type(o),this.set_destructor(u),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var o=M[this.ptr>>2];M[this.ptr>>2]=o+1},this.release_ref=function(){var o=M[this.ptr>>2];return M[this.ptr>>2]=o-1,o===1}}var wa=0,Da=0;function La(i,o,u){var p=new Ca(i);throw p.init(o,u),wa=i,Da++,i}function Ma(i,o,u,p,b){}function rn(i){switch(i){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+i)}}function ka(){for(var i=new Array(256),o=0;o<256;++o)i[o]=String.fromCharCode(o);Ai=i}var Ai=void 0;function Ge(i){for(var o="",u=i;le[u];)o+=Ai[le[u++]];return o}var nn={},Ri={},Ba={},Va=48,Fa=57;function Ha(i){if(i===void 0)return"_unknown";i=i.replace(/[^a-zA-Z0-9_]/g,"$");var o=i.charCodeAt(0);return o>=Va&&o<=Fa?"_"+i:i}function qa(i,o){return i=Ha(i),new Function("body","return function "+i+`() {
5
+ Error code: ${d.streamErrorCode}.`:d instanceof nt?d=d.cause:d instanceof Event&&(d=d.type),postMessage({id:e,payload:{err:d}}),a.close()}}};function Jl(n){self.onmessage=async t=>{let e=setTimeout(()=>{self.postMessage({type:"error",payload:"timeout"})},5e3);try{t.data.wasm&&(H.locateFile=function(r,s){return t.data.wasm}),Object.assign(se,t.data.flag),console.time(`Worker[${self.name}${st}]`),H.postRun=[()=>{B.global=new B(1920*1080*3>>1),H._CreateMediaProcessing(0,1,0,!1),console.timeEnd(`Worker[${self.name}${st}]`),H._UseAINS(se.useAINS),this.ios=new Set,t.ports[0].onmessage=l=>{var h,I,U;let[d,_]=l.data;switch(d){case"dump":switch(_){case"audio":this.dumpPort=l.ports[0];break;case"mic0":(h=this.playPort)==null||h.postMessage({cmd:d,payload:_},l.ports);break}break;case"useAINS":H._UseAINS(_),(I=this.playPort)==null||I.postMessage({cmd:d,payload:_});break;case"enableDebug":console.debug=_?Rr:()=>{},(U=this.playPort)==null||U.postMessage({cmd:d,payload:_});break;case"useV2":H.udtver=_?2:3;break;case"useWt":se.useWt=_;break;case"enableAEC":H._EnableAEC(_);break}};let r=0,s=Date.now(),a=0;Y(Pe(1e3),ee(()=>{let _=(Date.now()-s)/10-r;console.debug("interval10ms:",_,_-a),a=_,H._UpdateStreamSync()})),H._SetAudioOutStreamFormat(48e3,1);let c=H._malloc(3*4),f=new B(480<<2);Y(this.interval10ms,ee(()=>{if(r++,H._GetAudioMixedFloat(f.point,48e3,c)>=0){if(this.playPort){let d=f.uint8Slice();this.playPort.postMessage(d,[d.buffer])}if(this.dumpPort){let d=f.uint8Slice();this.dumpPort.postMessage(d,[d.buffer])}this.ios.forEach(d=>d.userManager.remotePublishedUserMap.forEach(_=>{var h;return(h=_.audioPuller)==null?void 0:h.feed()}))}})),self.onmessage=this.joinRoom.bind(this),clearTimeout(e),self.postMessage({type:"ready"})}],n(H)}catch(r){self.postMessage({type:"error",err:r})}}}var zo=Wr?Qo:Jl.bind(new oi);var Xl=function(){var n=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return function(e){e=e||{};var e=typeof e!="undefined"?e:{},r,s;e.ready=new Promise(function(i,o){r=i,s=o});var a={},c;for(c in e)e.hasOwnProperty(c)&&(a[c]=e[c]);var f=[],l="./this.program",d=function(i,o){throw o},_=typeof window=="object",h=typeof importScripts=="function",I=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",U=!_&&!I&&!h,O="";function J(i){return e.locateFile?e.locateFile(i,O):O+i}var R,w,X,ye;function Ie(i){if(!(i instanceof gc)){var o=i;ce("exiting due to exception: "+o)}}U?(typeof read!="undefined"&&(R=function(o){return read(o)}),X=function(o){var u;return typeof readbuffer=="function"?new Uint8Array(readbuffer(o)):(u=read(o,"binary"),ui(typeof u=="object"),u)},w=function(o,u,p){setTimeout(function(){u(X(o))},0)},typeof scriptArgs!="undefined"?f=scriptArgs:typeof arguments!="undefined"&&(f=arguments),typeof quit=="function"&&(d=function(i,o){Ie(o),quit(i)}),typeof print!="undefined"&&(typeof console=="undefined"&&(console={}),console.log=print,console.warn=console.error=typeof printErr!="undefined"?printErr:print)):(_||h)&&(h?O=self.location.href:typeof document!="undefined"&&document.currentScript&&(O=document.currentScript.src),n&&(O=n),O.indexOf("blob:")!==0?O=O.substr(0,O.replace(/[?#].*/,"").lastIndexOf("/")+1):O="",R=function(i){var o=new XMLHttpRequest;return o.open("GET",i,!1),o.send(null),o.responseText},h&&(X=function(i){var o=new XMLHttpRequest;return o.open("GET",i,!1),o.responseType="arraybuffer",o.send(null),new Uint8Array(o.response)}),w=function(i,o,u){var p=new XMLHttpRequest;p.open("GET",i,!0),p.responseType="arraybuffer",p.onload=function(){if(p.status==200||p.status==0&&p.response){o(p.response);return}u()},p.onerror=u,p.send(null)},ye=function(i){document.title=i});var Ae=e.print||console.log.bind(console),ce=e.printErr||console.warn.bind(console);for(c in a)a.hasOwnProperty(c)&&(e[c]=a[c]);a=null,e.arguments&&(f=e.arguments),e.thisProgram&&(l=e.thisProgram),e.quit&&(d=e.quit);function be(i){be.shown||(be.shown={}),be.shown[i]||(be.shown[i]=1,ce(i))}function ea(i,o){if(typeof WebAssembly.Function=="function"){for(var u={i:"i32",j:"i64",f:"f32",d:"f64"},p={parameters:[],results:o[0]=="v"?[]:[u[o[0]]]},b=1;b<o.length;++b)p.parameters.push(u[o[b]]);return new WebAssembly.Function(p,i)}var E=[1,0,1,96],T=o.slice(0,1),y=o.slice(1),S={i:127,j:126,f:125,d:124};E.push(y.length);for(var b=0;b<y.length;++b)E.push(S[y[b]]);T=="v"?E.push(0):E=E.concat([1,S[T]]),E[1]=E.length-2;var x=new Uint8Array([0,97,115,109,1,0,0,0].concat(E,[2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0])),q=new WebAssembly.Module(x),Q=new WebAssembly.Instance(q,{e:{f:i}}),W=Q.exports.f;return W}var Xr=[],et;function ta(){if(Xr.length)return Xr.pop();try{at.grow(1)}catch(i){throw i instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":i}return at.length-1}function ra(i,o){for(var u=i;u<i+o;u++){var p=er(u);p&&et.set(p,u)}}function na(i,o){if(et||(et=new WeakMap,ra(0,at.length)),et.has(i))return et.get(i);var u=ta();try{Ii(u,i)}catch(b){if(!(b instanceof TypeError))throw b;var p=ea(i,o);Ii(u,p)}return et.set(i,u),u}function sa(i){et.delete(er(i)),Xr.push(i)}var Ot;e.wasmBinary&&(Ot=e.wasmBinary);var Ql=e.noExitRuntime||!1;typeof WebAssembly!="object"&&ut("no native wasm support detected");var zt,ai=!1,ia;function ui(i,o){i||ut("Assertion failed: "+o)}function A(i){var o=e["_"+i];return ui(o,"Cannot call unknown function "+i+", make sure it is exported"),o}function ci(i,o,u,p,b){var E={string:function(G){var ne=0;if(G!=null&&G!==0){var K=(G.length<<2)+1;ne=pn(K),pi(G,ne,K)}return ne},array:function(G){var ne=pn(G.length);return _i(G,ne),ne}};function T(G){return o==="string"?Pt(G):o==="boolean"?Boolean(G):G}var y=A(i),S=[],x=0;if(p)for(var q=0;q<p.length;q++){var Q=E[u[q]];Q?(x===0&&(x=Di()),S[q]=Q(p[q])):S[q]=p[q]}var W=y.apply(null,S);function Z(G){return x!==0&&Li(x),T(G)}return W=Z(W),W}function oa(i,o,u,p){u=u||[];var b=u.every(function(T){return T==="number"}),E=o!=="string";return E&&b&&!p?A(i):function(){return ci(i,o,u,arguments,p)}}var li=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function Qr(i,o,u){for(var p=o+u,b=o;i[b]&&!(b>=p);)++b;if(b-o>16&&i.subarray&&li)return li.decode(i.subarray(o,b));for(var E="";o<b;){var T=i[o++];if(!(T&128)){E+=String.fromCharCode(T);continue}var y=i[o++]&63;if((T&224)==192){E+=String.fromCharCode((T&31)<<6|y);continue}var S=i[o++]&63;if((T&240)==224?T=(T&15)<<12|y<<6|S:T=(T&7)<<18|y<<12|S<<6|i[o++]&63,T<65536)E+=String.fromCharCode(T);else{var x=T-65536;E+=String.fromCharCode(55296|x>>10,56320|x&1023)}}return E}function Pt(i,o){return i?Qr(le,i,o):""}function di(i,o,u,p){if(!(p>0))return 0;for(var b=u,E=u+p-1,T=0;T<i.length;++T){var y=i.charCodeAt(T);if(y>=55296&&y<=57343){var S=i.charCodeAt(++T);y=65536+((y&1023)<<10)|S&1023}if(y<=127){if(u>=E)break;o[u++]=y}else if(y<=2047){if(u+1>=E)break;o[u++]=192|y>>6,o[u++]=128|y&63}else if(y<=65535){if(u+2>=E)break;o[u++]=224|y>>12,o[u++]=128|y>>6&63,o[u++]=128|y&63}else{if(u+3>=E)break;o[u++]=240|y>>18,o[u++]=128|y>>12&63,o[u++]=128|y>>6&63,o[u++]=128|y&63}}return o[u]=0,u-b}function pi(i,o,u){return di(i,le,o,u)}function mi(i){for(var o=0,u=0;u<i.length;++u){var p=i.charCodeAt(u);p>=55296&&p<=57343&&(p=65536+((p&1023)<<10)|i.charCodeAt(++u)&1023),p<=127?++o:p<=2047?o+=2:p<=65535?o+=3:o+=4}return o}var fi=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function C(i,o){for(var u=i,p=u>>1,b=p+o/2;!(p>=b)&&Zt[p];)++p;if(u=p<<1,u-i>32&&fi)return fi.decode(le.subarray(i,u));for(var E="",T=0;!(T>=o/2);++T){var y=ot[i+T*2>>1];if(y==0)break;E+=String.fromCharCode(y)}return E}function aa(i,o,u){if(u===void 0&&(u=2147483647),u<2)return 0;u-=2;for(var p=o,b=u<i.length*2?u/2:i.length,E=0;E<b;++E){var T=i.charCodeAt(E);ot[o>>1]=T,o+=2}return ot[o>>1]=0,o-p}function ua(i){return i.length*2}function ca(i,o){for(var u=0,p="";!(u>=o/4);){var b=M[i+u*4>>2];if(b==0)break;if(++u,b>=65536){var E=b-65536;p+=String.fromCharCode(55296|E>>10,56320|E&1023)}else p+=String.fromCharCode(b)}return p}function la(i,o,u){if(u===void 0&&(u=2147483647),u<4)return 0;for(var p=o,b=p+u-4,E=0;E<i.length;++E){var T=i.charCodeAt(E);if(T>=55296&&T<=57343){var y=i.charCodeAt(++E);T=65536+((T&1023)<<10)|y&1023}if(M[o>>2]=T,o+=4,o+4>b)break}return M[o>>2]=0,o-p}function da(i){for(var o=0,u=0;u<i.length;++u){var p=i.charCodeAt(u);p>=55296&&p<=57343&&++u,o+=4}return o}function _i(i,o){te.set(i,o)}function pa(i,o,u){for(var p=0;p<i.length;++p)te[o++>>0]=i.charCodeAt(p);u||(te[o>>0]=0)}function ma(i,o){return i%o>0&&(i+=o-i%o),i}var zr,te,le,ot,Zt,M,ke,hi,Zr;function bi(i){zr=i,e.HEAP8=te=new Int8Array(i),e.HEAP16=ot=new Int16Array(i),e.HEAP32=M=new Int32Array(i),e.HEAPU8=le=new Uint8Array(i),e.HEAPU16=Zt=new Uint16Array(i),e.HEAPU32=ke=new Uint32Array(i),e.HEAPF32=hi=new Float32Array(i),e.HEAPF64=Zr=new Float64Array(i)}var zl=e.INITIAL_MEMORY||134217728,at,gi=[],Ei=[],fa=[],Ti=[],_a=!1;function ha(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Ea(e.preRun.shift());tn(gi)}function ba(){_a=!0,tn(Ei)}function ga(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Sa(e.postRun.shift());tn(Ti)}function Ea(i){gi.unshift(i)}function Ta(i){Ei.unshift(i)}function Sa(i){Ti.unshift(i)}var tt=0,en=null,Nt=null;function ya(i){tt++,e.monitorRunDependencies&&e.monitorRunDependencies(tt)}function Ia(i){if(tt--,e.monitorRunDependencies&&e.monitorRunDependencies(tt),tt==0&&(en!==null&&(clearInterval(en),en=null),Nt)){var o=Nt;Nt=null,o()}}e.preloadedImages={},e.preloadedAudios={};function ut(i){e.onAbort&&e.onAbort(i),i="Aborted("+i+")",ce(i),ai=!0,ia=1,i+=". Build with -s ASSERTIONS=1 for more info.";var o=new WebAssembly.RuntimeError(i);throw s(o),o}var Aa="data:application/octet-stream;base64,";function Si(i){return i.startsWith(Aa)}var Re;Re="av_processing.wasm",Si(Re)||(Re=J(Re));function yi(i){try{if(i==Re&&Ot)return new Uint8Array(Ot);if(X)return X(i);throw"both async and sync fetching of the wasm failed"}catch(o){ut(o)}}function Ra(){return!Ot&&(_||h)&&typeof fetch=="function"?fetch(Re,{credentials:"same-origin"}).then(function(i){if(!i.ok)throw"failed to load wasm binary file at '"+Re+"'";return i.arrayBuffer()}).catch(function(){return yi(Re)}):Promise.resolve().then(function(){return yi(Re)})}function xa(){var i={a:Ou};function o(T,y){var S=T.exports;e.asm=S,zt=e.asm.B,bi(zt.buffer),at=e.asm.na,Ta(e.asm.C),Ia("wasm-instantiate")}ya("wasm-instantiate");function u(T){o(T.instance)}function p(T){return Ra().then(function(y){return WebAssembly.instantiate(y,i)}).then(function(y){return y}).then(T,function(y){ce("failed to asynchronously prepare wasm: "+y),ut(y)})}function b(){return!Ot&&typeof WebAssembly.instantiateStreaming=="function"&&!Si(Re)&&typeof fetch=="function"?fetch(Re,{credentials:"same-origin"}).then(function(T){var y=WebAssembly.instantiateStreaming(T,i);return y.then(u,function(S){return ce("wasm streaming compile failed: "+S),ce("falling back to ArrayBuffer instantiation"),p(u)})}):p(u)}if(e.instantiateWasm)try{var E=e.instantiateWasm(i,o);return E}catch(T){return ce("Module.instantiateWasm callback failed with error: "+T),!1}return b().catch(s),{}}function tn(i){for(;i.length>0;){var o=i.shift();if(typeof o=="function"){o(e);continue}var u=o.func;typeof u=="number"?o.arg===void 0?er(u)():er(u)(o.arg):u(o.arg===void 0?null:o.arg)}}function er(i){return at.get(i)}function va(){var i=new Error;if(!i.stack){try{throw new Error}catch(o){i=o}if(!i.stack)return"(no stack trace available)"}return i.stack.toString()}function Ii(i,o){at.set(i,o)}function Ua(i){return or(i+16)+16}function Oa(i,o){fa.unshift({func:i,arg:o})}function Pa(i,o){return Oa(i,o)}function Na(i){this.excPtr=i,this.ptr=i-16,this.set_type=function(o){M[this.ptr+4>>2]=o},this.get_type=function(){return M[this.ptr+4>>2]},this.set_destructor=function(o){M[this.ptr+8>>2]=o},this.get_destructor=function(){return M[this.ptr+8>>2]},this.set_refcount=function(o){M[this.ptr>>2]=o},this.set_caught=function(o){o=o?1:0,te[this.ptr+12>>0]=o},this.get_caught=function(){return te[this.ptr+12>>0]!=0},this.set_rethrown=function(o){o=o?1:0,te[this.ptr+13>>0]=o},this.get_rethrown=function(){return te[this.ptr+13>>0]!=0},this.init=function(o,u){this.set_type(o),this.set_destructor(u),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var o=M[this.ptr>>2];M[this.ptr>>2]=o+1},this.release_ref=function(){var o=M[this.ptr>>2];return M[this.ptr>>2]=o-1,o===1}}var Ca=0,wa=0;function Da(i,o,u){var p=new Na(i);throw p.init(o,u),Ca=i,wa++,i}function La(i,o,u,p,b){}function rn(i){switch(i){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+i)}}function Ma(){for(var i=new Array(256),o=0;o<256;++o)i[o]=String.fromCharCode(o);Ai=i}var Ai=void 0;function Ge(i){for(var o="",u=i;le[u];)o+=Ai[le[u++]];return o}var nn={},Ri={},ka={},Ba=48,Va=57;function Fa(i){if(i===void 0)return"_unknown";i=i.replace(/[^a-zA-Z0-9_]/g,"$");var o=i.charCodeAt(0);return o>=Ba&&o<=Va?"_"+i:i}function Ha(i,o){return i=Fa(i),new Function("body","return function "+i+`() {
6
6
  "use strict"; return body.apply(this, arguments);
7
7
  };
8
- `)(o)}function xi(i,o){var u=qa(o,function(p){this.name=o,this.message=p;var b=new Error(p).stack;b!==void 0&&(this.stack=this.toString()+`
9
- `+b.replace(/^Error(:[^\n]*)?\n/,""))});return u.prototype=Object.create(i.prototype),u.prototype.constructor=u,u.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},u}var vi=void 0;function ct(i){throw new vi(i)}var Wa=void 0;function je(i,o,u){if(u=u||{},!("argPackAdvance"in o))throw new TypeError("registerType registeredInstance requires argPackAdvance");var p=o.name;if(i||ct('type "'+p+'" must have a positive integer typeid pointer'),Ri.hasOwnProperty(i)){if(u.ignoreDuplicateRegistrations)return;ct("Cannot register type '"+p+"' twice")}if(Ri[i]=o,delete Ba[i],nn.hasOwnProperty(i)){var b=nn[i];delete nn[i],b.forEach(function(E){E()})}}function Ga(i,o,u,p,b){var E=rn(u);o=Ge(o),je(i,{name:o,fromWireType:function(T){return!!T},toWireType:function(T,y){return y?p:b},argPackAdvance:8,readValueFromPointer:function(T){var y;if(u===1)y=te;else if(u===2)y=ot;else if(u===4)y=M;else throw new TypeError("Unknown boolean type size: "+o);return this.fromWireType(y[T>>E])},destructorFunction:null})}var sn=[],Ce=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function ja(i){i>4&&--Ce[i].refcount===0&&(Ce[i]=void 0,sn.push(i))}function Ya(){for(var i=0,o=5;o<Ce.length;++o)Ce[o]!==void 0&&++i;return i}function $a(){for(var i=5;i<Ce.length;++i)if(Ce[i]!==void 0)return Ce[i];return null}function Ka(){e.count_emval_handles=Ya,e.get_first_emval=$a}var Ui={toValue:function(i){return i||ct("Cannot use deleted val. handle = "+i),Ce[i].value},toHandle:function(i){switch(i){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:{var o=sn.length?sn.pop():Ce.length;return Ce[o]={refcount:1,value:i},o}}}};function on(i){return this.fromWireType(ke[i>>2])}function Ja(i,o){o=Ge(o),je(i,{name:o,fromWireType:function(u){var p=Ui.toValue(u);return ja(u),p},toWireType:function(u,p){return Ui.toHandle(p)},argPackAdvance:8,readValueFromPointer:on,destructorFunction:null})}function an(i){if(i===null)return"null";var o=typeof i;return o==="object"||o==="array"||o==="function"?i.toString():""+i}function Xa(i,o){switch(o){case 2:return function(u){return this.fromWireType(hi[u>>2])};case 3:return function(u){return this.fromWireType(Zr[u>>3])};default:throw new TypeError("Unknown float type: "+i)}}function Qa(i,o,u){var p=rn(u);o=Ge(o),je(i,{name:o,fromWireType:function(b){return b},toWireType:function(b,E){if(typeof E!="number"&&typeof E!="boolean")throw new TypeError('Cannot convert "'+an(E)+'" to '+this.name);return E},argPackAdvance:8,readValueFromPointer:Xa(o,p),destructorFunction:null})}function za(i,o,u){switch(o){case 0:return u?function(b){return te[b]}:function(b){return le[b]};case 1:return u?function(b){return ot[b>>1]}:function(b){return Zt[b>>1]};case 2:return u?function(b){return M[b>>2]}:function(b){return ke[b>>2]};default:throw new TypeError("Unknown integer type: "+i)}}function Za(i,o,u,p,b){o=Ge(o),b===-1&&(b=4294967295);var E=rn(u),T=function(x){return x};if(p===0){var y=32-8*u;T=function(x){return x<<y>>>y}}var S=o.includes("unsigned");je(i,{name:o,fromWireType:T,toWireType:function(x,q){if(typeof q!="number"&&typeof q!="boolean")throw new TypeError('Cannot convert "'+an(q)+'" to '+this.name);if(q<p||q>b)throw new TypeError('Passing a number "'+an(q)+'" from JS side to C/C++ side to an argument of type "'+o+'", which is outside the valid range ['+p+", "+b+"]!");return S?q>>>0:q|0},argPackAdvance:8,readValueFromPointer:za(o,E,p!==0),destructorFunction:null})}function eu(i,o,u){var p=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],b=p[o];function E(T){T=T>>2;var y=ke,S=y[T],x=y[T+1];return new b(zr,x,S)}u=Ge(u),je(i,{name:u,fromWireType:E,argPackAdvance:8,readValueFromPointer:E},{ignoreDuplicateRegistrations:!0})}function tu(i,o){o=Ge(o);var u=o==="std::string";je(i,{name:o,fromWireType:function(p){var b=ke[p>>2],E;if(u)for(var T=p+4,y=0;y<=b;++y){var S=p+4+y;if(y==b||le[S]==0){var x=S-T,q=Pt(T,x);E===void 0?E=q:(E+=String.fromCharCode(0),E+=q),T=S+1}}else{for(var Q=new Array(b),y=0;y<b;++y)Q[y]=String.fromCharCode(le[p+4+y]);E=Q.join("")}return Ye(p),E},toWireType:function(p,b){b instanceof ArrayBuffer&&(b=new Uint8Array(b));var E,T=typeof b=="string";T||b instanceof Uint8Array||b instanceof Uint8ClampedArray||b instanceof Int8Array||ct("Cannot pass non-string to std::string"),u&&T?E=function(){return mi(b)}:E=function(){return b.length};var y=E(),S=or(4+y+1);if(ke[S>>2]=y,u&&T)pi(b,S+4,y+1);else if(T)for(var x=0;x<y;++x){var q=b.charCodeAt(x);q>255&&(Ye(S),ct("String has UTF-16 code units that do not fit in 8 bits")),le[S+4+x]=q}else for(var x=0;x<y;++x)le[S+4+x]=b[x];return p!==null&&p.push(Ye,S),S},argPackAdvance:8,readValueFromPointer:on,destructorFunction:function(p){Ye(p)}})}function ru(i,o,u){u=Ge(u);var p,b,E,T,y;o===2?(p=C,b=ua,T=ca,E=function(){return Zt},y=1):o===4&&(p=la,b=da,T=pa,E=function(){return ke},y=2),je(i,{name:u,fromWireType:function(S){for(var x=ke[S>>2],q=E(),Q,W=S+4,Z=0;Z<=x;++Z){var G=S+4+Z*o;if(Z==x||q[G>>y]==0){var se=G-W,K=p(W,se);Q===void 0?Q=K:(Q+=String.fromCharCode(0),Q+=K),W=G+o}}return Ye(S),Q},toWireType:function(S,x){typeof x!="string"&&ct("Cannot pass non-string to C++ string type "+u);var q=T(x),Q=or(4+q+o);return ke[Q>>2]=q>>y,b(x,Q+4,q+o),S!==null&&S.push(Ye,Q),Q},argPackAdvance:8,readValueFromPointer:on,destructorFunction:function(S){Ye(S)}})}function nu(i,o){o=Ge(o),je(i,{isVoid:!0,name:o,argPackAdvance:0,fromWireType:function(){},toWireType:function(u,p){}})}function su(){ut("")}var un;typeof dateNow!="undefined"?un=dateNow:un=function(){return performance.now()};var iu=!0;function ou(i){return M[wi()>>2]=i,i}function au(i,o){var u;if(i===0)u=Date.now();else if((i===1||i===4)&&iu)u=un();else return ou(28),-1;return M[o>>2]=u/1e3|0,M[o+4>>2]=u%1e3*1e3*1e3|0,0}function uu(i){return i<0||i===0&&1/i===-1/0}function cu(i,o){return(i>>>0)+o*4294967296}function lu(i,o){return(i>>>0)+(o>>>0)*4294967296}function Oi(i,o){if(i<=0)return i;var u=o<=32?Math.abs(1<<o-1):Math.pow(2,o-1);return i>=u&&(o<=32||i>u)&&(i=-2*u+i),i}function Pi(i,o){return i>=0?i:o<=32?2*Math.abs(1<<o-1)+i:Math.pow(2,o)+i}function Ni(i){for(var o=i;le[o];)++o;return o-i}e._strlen=Ni;function du(i,o){var u=i,p=o;function b(De,Ve){return(Ve==="double"||Ve==="i64")&&De&7&&(De+=4),De}function E(De){var Ve;return p=b(p,De),De==="double"?(Ve=Number(Zr[p>>3]),p+=8):De=="i64"?(Ve=[M[p>>2],M[p+4>>2]],p+=8):(De="i32",Ve=M[p>>2],p+=4),Ve}for(var T=[],y,S,x;;){var q=u;if(y=te[u>>0],y===0)break;if(S=te[u+1>>0],y==37){var Q=!1,W=!1,Z=!1,G=!1,se=!1;e:for(;;){switch(S){case 43:Q=!0;break;case 45:W=!0;break;case 35:Z=!0;break;case 48:if(G)break e;G=!0;break;case 32:se=!0;break;default:break e}u++,S=te[u+1>>0]}var K=0;if(S==42)K=E("i32"),u++,S=te[u+1>>0];else for(;S>=48&&S<=57;)K=K*10+(S-48),u++,S=te[u+1>>0];var Ee=!1,g=-1;if(S==46){if(g=0,Ee=!0,u++,S=te[u+1>>0],S==42)g=E("i32"),u++;else for(;;){var N=te[u+1>>0];if(N<48||N>57)break;g=g*10+(N-48),u++}S=te[u+1>>0]}g<0&&(g=6,Ee=!1);var F;switch(String.fromCharCode(S)){case"h":var z=te[u+2>>0];z==104?(u++,F=1):F=2;break;case"l":var z=te[u+2>>0];z==108?(u++,F=8):F=4;break;case"L":case"q":case"j":F=8;break;case"z":case"t":case"I":F=4;break;default:F=null}switch(F&&u++,S=te[u+1>>0],String.fromCharCode(S)){case"d":case"i":case"u":case"o":case"x":case"X":case"p":{var Se=S==100||S==105;F=F||4,x=E("i"+F*8);var v;if(F==8&&(x=S==117?lu(x[0],x[1]):cu(x[0],x[1])),F<=4){var Be=Math.pow(256,F)-1;x=(Se?Oi:Pi)(x&Be,F*8)}var wt=Math.abs(x),ge="";if(S==100||S==105)v=Oi(x,8*F,1).toString(10);else if(S==117)v=Pi(x,8*F,1).toString(10),x=Math.abs(x);else if(S==111)v=(Z?"0":"")+wt.toString(8);else if(S==120||S==88){if(ge=Z&&x!=0?"0x":"",x<0){x=-x,v=(wt-1).toString(16);for(var Mi=[],we=0;we<v.length;we++)Mi.push((15-parseInt(v[we],16)).toString(16));for(v=Mi.join("");v.length<F*2;)v="f"+v}else v=wt.toString(16);S==88&&(ge=ge.toUpperCase(),v=v.toUpperCase())}else S==112&&(wt===0?v="(nil)":(ge="0x",v=wt.toString(16)));if(Ee)for(;v.length<g;)v="0"+v;for(x>=0&&(Q?ge="+"+ge:se&&(ge=" "+ge)),v.charAt(0)=="-"&&(ge="-"+ge,v=v.substr(1));ge.length+v.length<K;)W?v+=" ":G?v="0"+v:ge=" "+ge;v=ge+v,v.split("").forEach(function(De){T.push(De.charCodeAt(0))});break}case"f":case"F":case"e":case"E":case"g":case"G":{x=E("double");var v;if(isNaN(x))v="nan",G=!1;else if(!isFinite(x))v=(x<0?"-":"")+"inf",G=!1;else{var ki=!1,Dt=Math.min(g,20);if(S==103||S==71){ki=!0,g=g||1;var fn=parseInt(x.toExponential(Dt).split("e")[1],10);g>fn&&fn>=-4?(S=(S==103?"f":"F").charCodeAt(0),g-=fn+1):(S=(S==103?"e":"E").charCodeAt(0),g--),Dt=Math.min(g,20)}S==101||S==69?(v=x.toExponential(Dt),/[eE][-+]\d$/.test(v)&&(v=v.slice(0,-1)+"0"+v.slice(-1))):(S==102||S==70)&&(v=x.toFixed(Dt),x===0&&uu(x)&&(v="-"+v));var xe=v.split("e");if(ki&&!Z)for(;xe[0].length>1&&xe[0].includes(".")&&(xe[0].slice(-1)=="0"||xe[0].slice(-1)==".");)xe[0]=xe[0].slice(0,-1);else for(Z&&v.indexOf(".")==-1&&(xe[0]+=".");g>Dt++;)xe[0]+="0";v=xe[0]+(xe.length>1?"e"+xe[1]:""),S==69&&(v=v.toUpperCase()),x>=0&&(Q?v="+"+v:se&&(v=" "+v))}for(;v.length<K;)W?v+=" ":G&&(v[0]=="-"||v[0]=="+")?v=v[0]+"0"+v.slice(1):v=(G?"0":" ")+v;S<97&&(v=v.toUpperCase()),v.split("").forEach(function(Ve){T.push(Ve.charCodeAt(0))});break}case"s":{var ur=E("i8*"),dt=ur?Ni(ur):6;if(Ee&&(dt=Math.min(dt,g)),!W)for(;dt<K--;)T.push(32);if(ur)for(var we=0;we<dt;we++)T.push(le[ur++>>0]);else T=T.concat(Ci("(null)".substr(0,dt),!0));if(W)for(;dt<K--;)T.push(32);break}case"c":{for(W&&T.push(E("i8"));--K>0;)T.push(32);W||T.push(E("i8"));break}case"n":{var Tc=E("i32*");M[Tc>>2]=T.length;break}case"%":{T.push(y);break}default:for(var we=q;we<u+2;we++)T.push(te[we>>0])}u+=2}else T.push(y),u+=1}return T}function cn(i){if(!i||!i.callee||!i.callee.name)return[null,"",""];var o=i.callee.toString(),u=i.callee.name,p="(",b=!0;for(var E in i){var T=i[E];b||(p+=", "),b=!1,typeof T=="number"||typeof T=="string"?p+=T:p+="("+typeof T+")"}p+=")";var y=i.callee.caller;return i=y?y.arguments:[],b&&(p=""),[i,u,p]}function pu(i){var o=Ua(),u=o.lastIndexOf("_emscripten_log"),p=o.lastIndexOf("_emscripten_get_callstack"),b=o.indexOf(`
8
+ `)(o)}function xi(i,o){var u=Ha(o,function(p){this.name=o,this.message=p;var b=new Error(p).stack;b!==void 0&&(this.stack=this.toString()+`
9
+ `+b.replace(/^Error(:[^\n]*)?\n/,""))});return u.prototype=Object.create(i.prototype),u.prototype.constructor=u,u.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},u}var vi=void 0;function ct(i){throw new vi(i)}var qa=void 0;function je(i,o,u){if(u=u||{},!("argPackAdvance"in o))throw new TypeError("registerType registeredInstance requires argPackAdvance");var p=o.name;if(i||ct('type "'+p+'" must have a positive integer typeid pointer'),Ri.hasOwnProperty(i)){if(u.ignoreDuplicateRegistrations)return;ct("Cannot register type '"+p+"' twice")}if(Ri[i]=o,delete ka[i],nn.hasOwnProperty(i)){var b=nn[i];delete nn[i],b.forEach(function(E){E()})}}function Wa(i,o,u,p,b){var E=rn(u);o=Ge(o),je(i,{name:o,fromWireType:function(T){return!!T},toWireType:function(T,y){return y?p:b},argPackAdvance:8,readValueFromPointer:function(T){var y;if(u===1)y=te;else if(u===2)y=ot;else if(u===4)y=M;else throw new TypeError("Unknown boolean type size: "+o);return this.fromWireType(y[T>>E])},destructorFunction:null})}var sn=[],Ce=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Ga(i){i>4&&--Ce[i].refcount===0&&(Ce[i]=void 0,sn.push(i))}function ja(){for(var i=0,o=5;o<Ce.length;++o)Ce[o]!==void 0&&++i;return i}function Ya(){for(var i=5;i<Ce.length;++i)if(Ce[i]!==void 0)return Ce[i];return null}function $a(){e.count_emval_handles=ja,e.get_first_emval=Ya}var Ui={toValue:function(i){return i||ct("Cannot use deleted val. handle = "+i),Ce[i].value},toHandle:function(i){switch(i){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:{var o=sn.length?sn.pop():Ce.length;return Ce[o]={refcount:1,value:i},o}}}};function on(i){return this.fromWireType(ke[i>>2])}function Ka(i,o){o=Ge(o),je(i,{name:o,fromWireType:function(u){var p=Ui.toValue(u);return Ga(u),p},toWireType:function(u,p){return Ui.toHandle(p)},argPackAdvance:8,readValueFromPointer:on,destructorFunction:null})}function an(i){if(i===null)return"null";var o=typeof i;return o==="object"||o==="array"||o==="function"?i.toString():""+i}function Ja(i,o){switch(o){case 2:return function(u){return this.fromWireType(hi[u>>2])};case 3:return function(u){return this.fromWireType(Zr[u>>3])};default:throw new TypeError("Unknown float type: "+i)}}function Xa(i,o,u){var p=rn(u);o=Ge(o),je(i,{name:o,fromWireType:function(b){return b},toWireType:function(b,E){if(typeof E!="number"&&typeof E!="boolean")throw new TypeError('Cannot convert "'+an(E)+'" to '+this.name);return E},argPackAdvance:8,readValueFromPointer:Ja(o,p),destructorFunction:null})}function Qa(i,o,u){switch(o){case 0:return u?function(b){return te[b]}:function(b){return le[b]};case 1:return u?function(b){return ot[b>>1]}:function(b){return Zt[b>>1]};case 2:return u?function(b){return M[b>>2]}:function(b){return ke[b>>2]};default:throw new TypeError("Unknown integer type: "+i)}}function za(i,o,u,p,b){o=Ge(o),b===-1&&(b=4294967295);var E=rn(u),T=function(x){return x};if(p===0){var y=32-8*u;T=function(x){return x<<y>>>y}}var S=o.includes("unsigned");je(i,{name:o,fromWireType:T,toWireType:function(x,q){if(typeof q!="number"&&typeof q!="boolean")throw new TypeError('Cannot convert "'+an(q)+'" to '+this.name);if(q<p||q>b)throw new TypeError('Passing a number "'+an(q)+'" from JS side to C/C++ side to an argument of type "'+o+'", which is outside the valid range ['+p+", "+b+"]!");return S?q>>>0:q|0},argPackAdvance:8,readValueFromPointer:Qa(o,E,p!==0),destructorFunction:null})}function Za(i,o,u){var p=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],b=p[o];function E(T){T=T>>2;var y=ke,S=y[T],x=y[T+1];return new b(zr,x,S)}u=Ge(u),je(i,{name:u,fromWireType:E,argPackAdvance:8,readValueFromPointer:E},{ignoreDuplicateRegistrations:!0})}function eu(i,o){o=Ge(o);var u=o==="std::string";je(i,{name:o,fromWireType:function(p){var b=ke[p>>2],E;if(u)for(var T=p+4,y=0;y<=b;++y){var S=p+4+y;if(y==b||le[S]==0){var x=S-T,q=Pt(T,x);E===void 0?E=q:(E+=String.fromCharCode(0),E+=q),T=S+1}}else{for(var Q=new Array(b),y=0;y<b;++y)Q[y]=String.fromCharCode(le[p+4+y]);E=Q.join("")}return Ye(p),E},toWireType:function(p,b){b instanceof ArrayBuffer&&(b=new Uint8Array(b));var E,T=typeof b=="string";T||b instanceof Uint8Array||b instanceof Uint8ClampedArray||b instanceof Int8Array||ct("Cannot pass non-string to std::string"),u&&T?E=function(){return mi(b)}:E=function(){return b.length};var y=E(),S=or(4+y+1);if(ke[S>>2]=y,u&&T)pi(b,S+4,y+1);else if(T)for(var x=0;x<y;++x){var q=b.charCodeAt(x);q>255&&(Ye(S),ct("String has UTF-16 code units that do not fit in 8 bits")),le[S+4+x]=q}else for(var x=0;x<y;++x)le[S+4+x]=b[x];return p!==null&&p.push(Ye,S),S},argPackAdvance:8,readValueFromPointer:on,destructorFunction:function(p){Ye(p)}})}function tu(i,o,u){u=Ge(u);var p,b,E,T,y;o===2?(p=C,b=aa,T=ua,E=function(){return Zt},y=1):o===4&&(p=ca,b=la,T=da,E=function(){return ke},y=2),je(i,{name:u,fromWireType:function(S){for(var x=ke[S>>2],q=E(),Q,W=S+4,Z=0;Z<=x;++Z){var G=S+4+Z*o;if(Z==x||q[G>>y]==0){var ne=G-W,K=p(W,ne);Q===void 0?Q=K:(Q+=String.fromCharCode(0),Q+=K),W=G+o}}return Ye(S),Q},toWireType:function(S,x){typeof x!="string"&&ct("Cannot pass non-string to C++ string type "+u);var q=T(x),Q=or(4+q+o);return ke[Q>>2]=q>>y,b(x,Q+4,q+o),S!==null&&S.push(Ye,Q),Q},argPackAdvance:8,readValueFromPointer:on,destructorFunction:function(S){Ye(S)}})}function ru(i,o){o=Ge(o),je(i,{isVoid:!0,name:o,argPackAdvance:0,fromWireType:function(){},toWireType:function(u,p){}})}function nu(){ut("")}var un;typeof dateNow!="undefined"?un=dateNow:un=function(){return performance.now()};var su=!0;function iu(i){return M[wi()>>2]=i,i}function ou(i,o){var u;if(i===0)u=Date.now();else if((i===1||i===4)&&su)u=un();else return iu(28),-1;return M[o>>2]=u/1e3|0,M[o+4>>2]=u%1e3*1e3*1e3|0,0}function au(i){return i<0||i===0&&1/i===-1/0}function uu(i,o){return(i>>>0)+o*4294967296}function cu(i,o){return(i>>>0)+(o>>>0)*4294967296}function Oi(i,o){if(i<=0)return i;var u=o<=32?Math.abs(1<<o-1):Math.pow(2,o-1);return i>=u&&(o<=32||i>u)&&(i=-2*u+i),i}function Pi(i,o){return i>=0?i:o<=32?2*Math.abs(1<<o-1)+i:Math.pow(2,o)+i}function Ni(i){for(var o=i;le[o];)++o;return o-i}e._strlen=Ni;function lu(i,o){var u=i,p=o;function b(De,Ve){return(Ve==="double"||Ve==="i64")&&De&7&&(De+=4),De}function E(De){var Ve;return p=b(p,De),De==="double"?(Ve=Number(Zr[p>>3]),p+=8):De=="i64"?(Ve=[M[p>>2],M[p+4>>2]],p+=8):(De="i32",Ve=M[p>>2],p+=4),Ve}for(var T=[],y,S,x;;){var q=u;if(y=te[u>>0],y===0)break;if(S=te[u+1>>0],y==37){var Q=!1,W=!1,Z=!1,G=!1,ne=!1;e:for(;;){switch(S){case 43:Q=!0;break;case 45:W=!0;break;case 35:Z=!0;break;case 48:if(G)break e;G=!0;break;case 32:ne=!0;break;default:break e}u++,S=te[u+1>>0]}var K=0;if(S==42)K=E("i32"),u++,S=te[u+1>>0];else for(;S>=48&&S<=57;)K=K*10+(S-48),u++,S=te[u+1>>0];var Ee=!1,g=-1;if(S==46){if(g=0,Ee=!0,u++,S=te[u+1>>0],S==42)g=E("i32"),u++;else for(;;){var N=te[u+1>>0];if(N<48||N>57)break;g=g*10+(N-48),u++}S=te[u+1>>0]}g<0&&(g=6,Ee=!1);var F;switch(String.fromCharCode(S)){case"h":var z=te[u+2>>0];z==104?(u++,F=1):F=2;break;case"l":var z=te[u+2>>0];z==108?(u++,F=8):F=4;break;case"L":case"q":case"j":F=8;break;case"z":case"t":case"I":F=4;break;default:F=null}switch(F&&u++,S=te[u+1>>0],String.fromCharCode(S)){case"d":case"i":case"u":case"o":case"x":case"X":case"p":{var Se=S==100||S==105;F=F||4,x=E("i"+F*8);var v;if(F==8&&(x=S==117?cu(x[0],x[1]):uu(x[0],x[1])),F<=4){var Be=Math.pow(256,F)-1;x=(Se?Oi:Pi)(x&Be,F*8)}var wt=Math.abs(x),ge="";if(S==100||S==105)v=Oi(x,8*F,1).toString(10);else if(S==117)v=Pi(x,8*F,1).toString(10),x=Math.abs(x);else if(S==111)v=(Z?"0":"")+wt.toString(8);else if(S==120||S==88){if(ge=Z&&x!=0?"0x":"",x<0){x=-x,v=(wt-1).toString(16);for(var Mi=[],we=0;we<v.length;we++)Mi.push((15-parseInt(v[we],16)).toString(16));for(v=Mi.join("");v.length<F*2;)v="f"+v}else v=wt.toString(16);S==88&&(ge=ge.toUpperCase(),v=v.toUpperCase())}else S==112&&(wt===0?v="(nil)":(ge="0x",v=wt.toString(16)));if(Ee)for(;v.length<g;)v="0"+v;for(x>=0&&(Q?ge="+"+ge:ne&&(ge=" "+ge)),v.charAt(0)=="-"&&(ge="-"+ge,v=v.substr(1));ge.length+v.length<K;)W?v+=" ":G?v="0"+v:ge=" "+ge;v=ge+v,v.split("").forEach(function(De){T.push(De.charCodeAt(0))});break}case"f":case"F":case"e":case"E":case"g":case"G":{x=E("double");var v;if(isNaN(x))v="nan",G=!1;else if(!isFinite(x))v=(x<0?"-":"")+"inf",G=!1;else{var ki=!1,Dt=Math.min(g,20);if(S==103||S==71){ki=!0,g=g||1;var fn=parseInt(x.toExponential(Dt).split("e")[1],10);g>fn&&fn>=-4?(S=(S==103?"f":"F").charCodeAt(0),g-=fn+1):(S=(S==103?"e":"E").charCodeAt(0),g--),Dt=Math.min(g,20)}S==101||S==69?(v=x.toExponential(Dt),/[eE][-+]\d$/.test(v)&&(v=v.slice(0,-1)+"0"+v.slice(-1))):(S==102||S==70)&&(v=x.toFixed(Dt),x===0&&au(x)&&(v="-"+v));var xe=v.split("e");if(ki&&!Z)for(;xe[0].length>1&&xe[0].includes(".")&&(xe[0].slice(-1)=="0"||xe[0].slice(-1)==".");)xe[0]=xe[0].slice(0,-1);else for(Z&&v.indexOf(".")==-1&&(xe[0]+=".");g>Dt++;)xe[0]+="0";v=xe[0]+(xe.length>1?"e"+xe[1]:""),S==69&&(v=v.toUpperCase()),x>=0&&(Q?v="+"+v:ne&&(v=" "+v))}for(;v.length<K;)W?v+=" ":G&&(v[0]=="-"||v[0]=="+")?v=v[0]+"0"+v.slice(1):v=(G?"0":" ")+v;S<97&&(v=v.toUpperCase()),v.split("").forEach(function(Ve){T.push(Ve.charCodeAt(0))});break}case"s":{var ur=E("i8*"),dt=ur?Ni(ur):6;if(Ee&&(dt=Math.min(dt,g)),!W)for(;dt<K--;)T.push(32);if(ur)for(var we=0;we<dt;we++)T.push(le[ur++>>0]);else T=T.concat(Ci("(null)".substr(0,dt),!0));if(W)for(;dt<K--;)T.push(32);break}case"c":{for(W&&T.push(E("i8"));--K>0;)T.push(32);W||T.push(E("i8"));break}case"n":{var Ec=E("i32*");M[Ec>>2]=T.length;break}case"%":{T.push(y);break}default:for(var we=q;we<u+2;we++)T.push(te[we>>0])}u+=2}else T.push(y),u+=1}return T}function cn(i){if(!i||!i.callee||!i.callee.name)return[null,"",""];var o=i.callee.toString(),u=i.callee.name,p="(",b=!0;for(var E in i){var T=i[E];b||(p+=", "),b=!1,typeof T=="number"||typeof T=="string"?p+=T:p+="("+typeof T+")"}p+=")";var y=i.callee.caller;return i=y?y.arguments:[],b&&(p=""),[i,u,p]}function du(i){var o=va(),u=o.lastIndexOf("_emscripten_log"),p=o.lastIndexOf("_emscripten_get_callstack"),b=o.indexOf(`
10
10
  `,Math.max(u,p))+1;o=o.slice(b),i&32&&be("EM_LOG_DEMANGLE is deprecated; ignoring"),i&8&&typeof emscripten_source_map=="undefined"&&(be('Source map information is not available, emscripten_log with EM_LOG_C_STACK will be ignored. Build with "--pre-js $EMSCRIPTEN/src/emscripten-source-map.min.js" linker flag to add source map loading to code.'),i^=8,i|=16);var E=null;if(i&128)for(E=cn(arguments);E[1].includes("_emscripten_");)E=cn(E[0]);var T=o.split(`
11
- `);o="";var y=new RegExp("\\s*(.*?)@(.*?):([0-9]+):([0-9]+)"),S=new RegExp("\\s*(.*?)@(.*):(.*)(:(.*))?"),x=new RegExp("\\s*at (.*?) \\((.*):(.*):(.*)\\)");for(var q in T){var Q=T[q],W="",Z="",G=0,se=0,K=x.exec(Q);if(K&&K.length==5)W=K[1],Z=K[2],G=K[3],se=K[4];else if(K=y.exec(Q),K||(K=S.exec(Q)),K&&K.length>=4)W=K[1],Z=K[2],G=K[3],se=K[4]|0;else{o+=Q+`
12
- `;continue}var Ee=!1;if(i&8){var g=emscripten_source_map.originalPositionFor({line:G,column:se});Ee=g&&g.source,Ee&&(i&64&&(g.source=g.source.substring(g.source.replace(/\\/g,"/").lastIndexOf("/")+1)),o+=" at "+W+" ("+g.source+":"+g.line+":"+g.column+`)
13
- `)}(i&16||!Ee)&&(i&64&&(Z=Z.substring(Z.replace(/\\/g,"/").lastIndexOf("/")+1)),o+=(Ee?" = "+W:" at "+W)+" ("+Z+":"+G+":"+se+`)
11
+ `);o="";var y=new RegExp("\\s*(.*?)@(.*?):([0-9]+):([0-9]+)"),S=new RegExp("\\s*(.*?)@(.*):(.*)(:(.*))?"),x=new RegExp("\\s*at (.*?) \\((.*):(.*):(.*)\\)");for(var q in T){var Q=T[q],W="",Z="",G=0,ne=0,K=x.exec(Q);if(K&&K.length==5)W=K[1],Z=K[2],G=K[3],ne=K[4];else if(K=y.exec(Q),K||(K=S.exec(Q)),K&&K.length>=4)W=K[1],Z=K[2],G=K[3],ne=K[4]|0;else{o+=Q+`
12
+ `;continue}var Ee=!1;if(i&8){var g=emscripten_source_map.originalPositionFor({line:G,column:ne});Ee=g&&g.source,Ee&&(i&64&&(g.source=g.source.substring(g.source.replace(/\\/g,"/").lastIndexOf("/")+1)),o+=" at "+W+" ("+g.source+":"+g.line+":"+g.column+`)
13
+ `)}(i&16||!Ee)&&(i&64&&(Z=Z.substring(Z.replace(/\\/g,"/").lastIndexOf("/")+1)),o+=(Ee?" = "+W:" at "+W)+" ("+Z+":"+G+":"+ne+`)
14
14
  `),i&128&&E[0]&&(E[1]==W&&E[2].length>0&&(o=o.replace(/\s+$/,""),o+=" with values: "+E[1]+E[2]+`
15
- `),E=cn(E[0]))}return o=o.replace(/\s+$/,""),o}function mu(i,o){i&24&&(o=o.replace(/\s+$/,""),o+=(o.length>0?`
16
- `:"")+pu(i)),i&1?i&4?ce(o):i&2?console.warn(o):i&512?console.info(o):i&256?console.debug(o):Ae(o):i&6?ce(o):Ae(o)}function fu(i,o,u){var p=du(o,u),b=Qr(p,0);mu(i,b)}function _u(i,o,u){le.copyWithin(i,o,o+u)}function hu(i){try{return zt.grow(i-zr.byteLength+65535>>>16),bi(zt.buffer),1}catch(o){}}function bu(i){var o=le.length;i=i>>>0;var u=1073741824;if(i>u)return!1;for(var p=1;p<=4;p*=2){var b=o*(1+.2/p);b=Math.min(b,i+100663296);var E=Math.min(u,fa(Math.max(i,b),65536)),T=hu(E);if(T)return!0}return!1}var ln={};function gu(){return l||"./this.program"}function Ct(){if(!Ct.strings){var i=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",o={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:i,_:gu()};for(var u in ln)ln[u]===void 0?delete o[u]:o[u]=ln[u];var p=[];for(var u in o)p.push(u+"="+o[u]);Ct.strings=p}return Ct.strings}var lt={mappings:{},buffers:[null,[],[]],printChar:function(i,o){var u=lt.buffers[i];o===0||o===10?((i===1?Ae:ce)(Qr(u,0)),u.length=0):u.push(o)},varargs:void 0,get:function(){lt.varargs+=4;var i=M[lt.varargs-4>>2];return i},getStr:function(i){var o=Pt(i);return o},get64:function(i,o){return i}};function Eu(i,o){var u=0;return Ct().forEach(function(p,b){var E=o+u;M[i+b*4>>2]=E,ma(p,E),u+=p.length+1}),0}function Tu(i,o){var u=Ct();M[i>>2]=u.length;var p=0;return u.forEach(function(b){p+=b.length+1}),M[o>>2]=p,0}function Su(i){return 0}function yu(i,o,u,p){var b=lt.getStreamFromFD(i),E=lt.doReadv(b,o,u);return M[p>>2]=E,0}function Iu(i,o,u,p,b){}function Au(i,o,u,p){for(var b=0,E=0;E<u;E++){var T=M[o>>2],y=M[o+4>>2];o+=8;for(var S=0;S<y;S++)lt.printChar(i,le[T+S]);b+=y}return M[p>>2]=b,0}function Ru(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var i=new Uint8Array(1);return function(){return crypto.getRandomValues(i),i[0]}}else return function(){ut("randomDevice")}}function tr(i,o){tr.randomDevice||(tr.randomDevice=Ru());for(var u=0;u<o;u++)te[i+u>>0]=tr.randomDevice();return 0}function xu(i){var o=Date.now();return M[i>>2]=o/1e3|0,M[i+4>>2]=o%1e3*1e3|0,0}function rr(i){return i%4===0&&(i%100!==0||i%400===0)}function dn(i,o){for(var u=0,p=0;p<=o;u+=i[p++]);return u}var nr=[31,29,31,30,31,30,31,31,30,31,30,31],sr=[31,28,31,30,31,30,31,31,30,31,30,31];function ir(i,o){for(var u=new Date(i.getTime());o>0;){var p=rr(u.getFullYear()),b=u.getMonth(),E=(p?nr:sr)[b];if(o>E-u.getDate())o-=E-u.getDate()+1,u.setDate(1),b<11?u.setMonth(b+1):(u.setMonth(0),u.setFullYear(u.getFullYear()+1));else return u.setDate(u.getDate()+o),u}return u}function vu(i,o,u,p){var b=M[p+40>>2],E={tm_sec:M[p>>2],tm_min:M[p+4>>2],tm_hour:M[p+8>>2],tm_mday:M[p+12>>2],tm_mon:M[p+16>>2],tm_year:M[p+20>>2],tm_wday:M[p+24>>2],tm_yday:M[p+28>>2],tm_isdst:M[p+32>>2],tm_gmtoff:M[p+36>>2],tm_zone:b?Pt(b):""},T=Pt(u),y={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var S in y)T=T.replace(new RegExp(S,"g"),y[S]);var x=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],q=["January","February","March","April","May","June","July","August","September","October","November","December"];function Q(g,N,F){for(var z=typeof g=="number"?g.toString():g||"";z.length<N;)z=F[0]+z;return z}function W(g,N){return Q(g,N,"0")}function Z(g,N){function F(Se){return Se<0?-1:Se>0?1:0}var z;return(z=F(g.getFullYear()-N.getFullYear()))===0&&(z=F(g.getMonth()-N.getMonth()))===0&&(z=F(g.getDate()-N.getDate())),z}function G(g){switch(g.getDay()){case 0:return new Date(g.getFullYear()-1,11,29);case 1:return g;case 2:return new Date(g.getFullYear(),0,3);case 3:return new Date(g.getFullYear(),0,2);case 4:return new Date(g.getFullYear(),0,1);case 5:return new Date(g.getFullYear()-1,11,31);case 6:return new Date(g.getFullYear()-1,11,30)}}function se(g){var N=ir(new Date(g.tm_year+1900,0,1),g.tm_yday),F=new Date(N.getFullYear(),0,4),z=new Date(N.getFullYear()+1,0,4),Se=G(F),v=G(z);return Z(Se,N)<=0?Z(v,N)<=0?N.getFullYear()+1:N.getFullYear():N.getFullYear()-1}var K={"%a":function(g){return x[g.tm_wday].substring(0,3)},"%A":function(g){return x[g.tm_wday]},"%b":function(g){return q[g.tm_mon].substring(0,3)},"%B":function(g){return q[g.tm_mon]},"%C":function(g){var N=g.tm_year+1900;return W(N/100|0,2)},"%d":function(g){return W(g.tm_mday,2)},"%e":function(g){return Q(g.tm_mday,2," ")},"%g":function(g){return se(g).toString().substring(2)},"%G":function(g){return se(g)},"%H":function(g){return W(g.tm_hour,2)},"%I":function(g){var N=g.tm_hour;return N==0?N=12:N>12&&(N-=12),W(N,2)},"%j":function(g){return W(g.tm_mday+dn(rr(g.tm_year+1900)?nr:sr,g.tm_mon-1),3)},"%m":function(g){return W(g.tm_mon+1,2)},"%M":function(g){return W(g.tm_min,2)},"%n":function(){return`
17
- `},"%p":function(g){return g.tm_hour>=0&&g.tm_hour<12?"AM":"PM"},"%S":function(g){return W(g.tm_sec,2)},"%t":function(){return" "},"%u":function(g){return g.tm_wday||7},"%U":function(g){var N=new Date(g.tm_year+1900,0,1),F=N.getDay()===0?N:ir(N,7-N.getDay()),z=new Date(g.tm_year+1900,g.tm_mon,g.tm_mday);if(Z(F,z)<0){var Se=dn(rr(z.getFullYear())?nr:sr,z.getMonth()-1)-31,v=31-F.getDate(),Be=v+Se+z.getDate();return W(Math.ceil(Be/7),2)}return Z(F,N)===0?"01":"00"},"%V":function(g){var N=new Date(g.tm_year+1900,0,4),F=new Date(g.tm_year+1901,0,4),z=G(N),Se=G(F),v=ir(new Date(g.tm_year+1900,0,1),g.tm_yday);if(Z(v,z)<0)return"53";if(Z(Se,v)<=0)return"01";var Be;return z.getFullYear()<g.tm_year+1900?Be=g.tm_yday+32-z.getDate():Be=g.tm_yday+1-z.getDate(),W(Math.ceil(Be/7),2)},"%w":function(g){return g.tm_wday},"%W":function(g){var N=new Date(g.tm_year,0,1),F=N.getDay()===1?N:ir(N,N.getDay()===0?1:7-N.getDay()+1),z=new Date(g.tm_year+1900,g.tm_mon,g.tm_mday);if(Z(F,z)<0){var Se=dn(rr(z.getFullYear())?nr:sr,z.getMonth()-1)-31,v=31-F.getDate(),Be=v+Se+z.getDate();return W(Math.ceil(Be/7),2)}return Z(F,N)===0?"01":"00"},"%y":function(g){return(g.tm_year+1900).toString().substring(2)},"%Y":function(g){return g.tm_year+1900},"%z":function(g){var N=g.tm_gmtoff,F=N>=0;return N=Math.abs(N)/60,N=N/60*100+N%60,(F?"+":"-")+String("0000"+N).slice(-4)},"%Z":function(g){return g.tm_zone},"%%":function(){return"%"}};for(var S in K)T.includes(S)&&(T=T.replace(new RegExp(S,"g"),K[S](E)));var Ee=Ci(T,!1);return Ee.length>o?0:(_i(Ee,i),Ee.length-1)}function Uu(i,o,u,p){return vu(i,o,u,p)}function Ou(i){var o=Date.now()/1e3|0;return i&&(M[i>>2]=o),o}ka(),vi=e.BindingError=xi(Error,"BindingError"),Wa=e.InternalError=xi(Error,"InternalError"),Ka();function Ci(i,o,u){var p=u>0?u:mi(i)+1,b=new Array(p),E=di(i,b,0,b.length);return o&&(b.length=E),b}var Pu={g:Oa,a:Na,f:La,r:Ma,n:Ga,A:Ja,l:Qa,d:Za,c:eu,m:tu,i:ru,o:nu,e:su,j:au,b:fu,s:_u,t:bu,x:Eu,y:Tu,z:Su,u:yu,q:Iu,k:Au,v:tr,h:xu,w:Uu,p:Ou},ed=va(),Nu=e.___wasm_call_ctors=function(){return(Nu=e.___wasm_call_ctors=e.asm.C).apply(null,arguments)},Cu=e._CreateMediaProcessing=function(){return(Cu=e._CreateMediaProcessing=e.asm.D).apply(null,arguments)},wu=e._ReleaseMediaProcessing=function(){return(wu=e._ReleaseMediaProcessing=e.asm.E).apply(null,arguments)},Du=e._AddAudioChannel=function(){return(Du=e._AddAudioChannel=e.asm.F).apply(null,arguments)},Lu=e._DelAudioChannel=function(){return(Lu=e._DelAudioChannel=e.asm.G).apply(null,arguments)},Mu=e._AddVideoChannel=function(){return(Mu=e._AddVideoChannel=e.asm.H).apply(null,arguments)},ku=e._DelVideoChannel=function(){return(ku=e._DelVideoChannel=e.asm.I).apply(null,arguments)},Bu=e._ReceivedRawAudioPacket=function(){return(Bu=e._ReceivedRawAudioPacket=e.asm.J).apply(null,arguments)},Vu=e._ParseUdtMousePacket=function(){return(Vu=e._ParseUdtMousePacket=e.asm.K).apply(null,arguments)},Fu=e._ReceivedAudioUdtPacket=function(){return(Fu=e._ReceivedAudioUdtPacket=e.asm.L).apply(null,arguments)},Hu=e._ParseUdtAudioPacket=function(){return(Hu=e._ParseUdtAudioPacket=e.asm.M).apply(null,arguments)},qu=e._ReceivedVideoPacket=function(){return(qu=e._ReceivedVideoPacket=e.asm.N).apply(null,arguments)},Wu=e._SetAudioBuffer10Ms=function(){return(Wu=e._SetAudioBuffer10Ms=e.asm.O).apply(null,arguments)},Gu=e._SetAudioVolume=function(){return(Gu=e._SetAudioVolume=e.asm.P).apply(null,arguments)},ju=e._GetAudioFrame=function(){return(ju=e._GetAudioFrame=e.asm.Q).apply(null,arguments)},Yu=e._GetAudioFrameFloat=function(){return(Yu=e._GetAudioFrameFloat=e.asm.R).apply(null,arguments)},$u=e._GetAudioMixed=function(){return($u=e._GetAudioMixed=e.asm.S).apply(null,arguments)},Ku=e._GetAudioMixedFloat=function(){return(Ku=e._GetAudioMixedFloat=e.asm.T).apply(null,arguments)},Ju=e._GetAudioEnergy=function(){return(Ju=e._GetAudioEnergy=e.asm.U).apply(null,arguments)},Xu=e._SetAudioFrameFormat=function(){return(Xu=e._SetAudioFrameFormat=e.asm.V).apply(null,arguments)},Qu=e._SetAudioOutStreamFormat=function(){return(Qu=e._SetAudioOutStreamFormat=e.asm.W).apply(null,arguments)},zu=e._AudioProcess=function(){return(zu=e._AudioProcess=e.asm.X).apply(null,arguments)},Zu=e._AudioProcessFloat=function(){return(Zu=e._AudioProcessFloat=e.asm.Y).apply(null,arguments)},ec=e._AudioReverseProcess=function(){return(ec=e._AudioReverseProcess=e.asm.Z).apply(null,arguments)},tc=e._AudioReverseProcessFloat=function(){return(tc=e._AudioReverseProcessFloat=e.asm._).apply(null,arguments)},rc=e._InitOpusEncoder=function(){return(rc=e._InitOpusEncoder=e.asm.$).apply(null,arguments)},nc=e._SetOpusEncBitrate=function(){return(nc=e._SetOpusEncBitrate=e.asm.aa).apply(null,arguments)},sc=e._OpusEncode=function(){return(sc=e._OpusEncode=e.asm.ba).apply(null,arguments)},ic=e._UpdateStreamSync=function(){return(ic=e._UpdateStreamSync=e.asm.ca).apply(null,arguments)},oc=e._GetEncodedFrame=function(){return(oc=e._GetEncodedFrame=e.asm.da).apply(null,arguments)},ac=e._GetReceivedVideoStat=function(){return(ac=e._GetReceivedVideoStat=e.asm.ea).apply(null,arguments)},uc=e._CreateUdtPacketizer=function(){return(uc=e._CreateUdtPacketizer=e.asm.fa).apply(null,arguments)},cc=e._PacketizeVideoUdt=function(){return(cc=e._PacketizeVideoUdt=e.asm.ga).apply(null,arguments)},lc=e._PacketizeAudioUdt=function(){return(lc=e._PacketizeAudioUdt=e.asm.ha).apply(null,arguments)},dc=e._GetRetransPacket=function(){return(dc=e._GetRetransPacket=e.asm.ia).apply(null,arguments)},pc=e._CheckMissingPacket=function(){return(pc=e._CheckMissingPacket=e.asm.ja).apply(null,arguments)},mc=e._UseAINS=function(){return(mc=e._UseAINS=e.asm.ka).apply(null,arguments)},fc=e._EnableAEC=function(){return(fc=e._EnableAEC=e.asm.la).apply(null,arguments)},_c=e._SetCrypto=function(){return(_c=e._SetCrypto=e.asm.ma).apply(null,arguments)},or=e._malloc=function(){return(or=e._malloc=e.asm.oa).apply(null,arguments)},Ye=e._free=function(){return(Ye=e._free=e.asm.pa).apply(null,arguments)},wi=e.___errno_location=function(){return(wi=e.___errno_location=e.asm.qa).apply(null,arguments)},hc=e.___getTypeName=function(){return(hc=e.___getTypeName=e.asm.ra).apply(null,arguments)},bc=e.___embind_register_native_and_builtin_types=function(){return(bc=e.___embind_register_native_and_builtin_types=e.asm.sa).apply(null,arguments)},Di=e.stackSave=function(){return(Di=e.stackSave=e.asm.ta).apply(null,arguments)},Li=e.stackRestore=function(){return(Li=e.stackRestore=e.asm.ua).apply(null,arguments)},pn=e.stackAlloc=function(){return(pn=e.stackAlloc=e.asm.va).apply(null,arguments)},gc=e._emscripten_stack_init=function(){return(gc=e._emscripten_stack_init=e.asm.wa).apply(null,arguments)};e.ccall=ci,e.cwrap=aa,e.addFunction=sa,e.removeFunction=ia;var ar;function Ec(i){this.name="ExitStatus",this.message="Program terminated with exit("+i+")",this.status=i}Nt=function i(){ar||mn(),ar||(Nt=i)};function mn(i){if(i=i||f,tt>0||(ba(),tt>0))return;function o(){ar||(ar=!0,e.calledRun=!0,!ai&&(ga(),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),Ea()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),o()},1)):o()}if(e.run=mn,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return mn(),e.ready}}(),ea=Ql;Zo(ea);
15
+ `),E=cn(E[0]))}return o=o.replace(/\s+$/,""),o}function pu(i,o){i&24&&(o=o.replace(/\s+$/,""),o+=(o.length>0?`
16
+ `:"")+du(i)),i&1?i&4?ce(o):i&2?console.warn(o):i&512?console.info(o):i&256?console.debug(o):Ae(o):i&6?ce(o):Ae(o)}function mu(i,o,u){var p=lu(o,u),b=Qr(p,0);pu(i,b)}function fu(i,o,u){le.copyWithin(i,o,o+u)}function _u(i){try{return zt.grow(i-zr.byteLength+65535>>>16),bi(zt.buffer),1}catch(o){}}function hu(i){var o=le.length;i=i>>>0;var u=1073741824;if(i>u)return!1;for(var p=1;p<=4;p*=2){var b=o*(1+.2/p);b=Math.min(b,i+100663296);var E=Math.min(u,ma(Math.max(i,b),65536)),T=_u(E);if(T)return!0}return!1}var ln={};function bu(){return l||"./this.program"}function Ct(){if(!Ct.strings){var i=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",o={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:i,_:bu()};for(var u in ln)ln[u]===void 0?delete o[u]:o[u]=ln[u];var p=[];for(var u in o)p.push(u+"="+o[u]);Ct.strings=p}return Ct.strings}var lt={mappings:{},buffers:[null,[],[]],printChar:function(i,o){var u=lt.buffers[i];o===0||o===10?((i===1?Ae:ce)(Qr(u,0)),u.length=0):u.push(o)},varargs:void 0,get:function(){lt.varargs+=4;var i=M[lt.varargs-4>>2];return i},getStr:function(i){var o=Pt(i);return o},get64:function(i,o){return i}};function gu(i,o){var u=0;return Ct().forEach(function(p,b){var E=o+u;M[i+b*4>>2]=E,pa(p,E),u+=p.length+1}),0}function Eu(i,o){var u=Ct();M[i>>2]=u.length;var p=0;return u.forEach(function(b){p+=b.length+1}),M[o>>2]=p,0}function Tu(i){return 0}function Su(i,o,u,p){var b=lt.getStreamFromFD(i),E=lt.doReadv(b,o,u);return M[p>>2]=E,0}function yu(i,o,u,p,b){}function Iu(i,o,u,p){for(var b=0,E=0;E<u;E++){var T=M[o>>2],y=M[o+4>>2];o+=8;for(var S=0;S<y;S++)lt.printChar(i,le[T+S]);b+=y}return M[p>>2]=b,0}function Au(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var i=new Uint8Array(1);return function(){return crypto.getRandomValues(i),i[0]}}else return function(){ut("randomDevice")}}function tr(i,o){tr.randomDevice||(tr.randomDevice=Au());for(var u=0;u<o;u++)te[i+u>>0]=tr.randomDevice();return 0}function Ru(i){var o=Date.now();return M[i>>2]=o/1e3|0,M[i+4>>2]=o%1e3*1e3|0,0}function rr(i){return i%4===0&&(i%100!==0||i%400===0)}function dn(i,o){for(var u=0,p=0;p<=o;u+=i[p++]);return u}var nr=[31,29,31,30,31,30,31,31,30,31,30,31],sr=[31,28,31,30,31,30,31,31,30,31,30,31];function ir(i,o){for(var u=new Date(i.getTime());o>0;){var p=rr(u.getFullYear()),b=u.getMonth(),E=(p?nr:sr)[b];if(o>E-u.getDate())o-=E-u.getDate()+1,u.setDate(1),b<11?u.setMonth(b+1):(u.setMonth(0),u.setFullYear(u.getFullYear()+1));else return u.setDate(u.getDate()+o),u}return u}function xu(i,o,u,p){var b=M[p+40>>2],E={tm_sec:M[p>>2],tm_min:M[p+4>>2],tm_hour:M[p+8>>2],tm_mday:M[p+12>>2],tm_mon:M[p+16>>2],tm_year:M[p+20>>2],tm_wday:M[p+24>>2],tm_yday:M[p+28>>2],tm_isdst:M[p+32>>2],tm_gmtoff:M[p+36>>2],tm_zone:b?Pt(b):""},T=Pt(u),y={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var S in y)T=T.replace(new RegExp(S,"g"),y[S]);var x=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],q=["January","February","March","April","May","June","July","August","September","October","November","December"];function Q(g,N,F){for(var z=typeof g=="number"?g.toString():g||"";z.length<N;)z=F[0]+z;return z}function W(g,N){return Q(g,N,"0")}function Z(g,N){function F(Se){return Se<0?-1:Se>0?1:0}var z;return(z=F(g.getFullYear()-N.getFullYear()))===0&&(z=F(g.getMonth()-N.getMonth()))===0&&(z=F(g.getDate()-N.getDate())),z}function G(g){switch(g.getDay()){case 0:return new Date(g.getFullYear()-1,11,29);case 1:return g;case 2:return new Date(g.getFullYear(),0,3);case 3:return new Date(g.getFullYear(),0,2);case 4:return new Date(g.getFullYear(),0,1);case 5:return new Date(g.getFullYear()-1,11,31);case 6:return new Date(g.getFullYear()-1,11,30)}}function ne(g){var N=ir(new Date(g.tm_year+1900,0,1),g.tm_yday),F=new Date(N.getFullYear(),0,4),z=new Date(N.getFullYear()+1,0,4),Se=G(F),v=G(z);return Z(Se,N)<=0?Z(v,N)<=0?N.getFullYear()+1:N.getFullYear():N.getFullYear()-1}var K={"%a":function(g){return x[g.tm_wday].substring(0,3)},"%A":function(g){return x[g.tm_wday]},"%b":function(g){return q[g.tm_mon].substring(0,3)},"%B":function(g){return q[g.tm_mon]},"%C":function(g){var N=g.tm_year+1900;return W(N/100|0,2)},"%d":function(g){return W(g.tm_mday,2)},"%e":function(g){return Q(g.tm_mday,2," ")},"%g":function(g){return ne(g).toString().substring(2)},"%G":function(g){return ne(g)},"%H":function(g){return W(g.tm_hour,2)},"%I":function(g){var N=g.tm_hour;return N==0?N=12:N>12&&(N-=12),W(N,2)},"%j":function(g){return W(g.tm_mday+dn(rr(g.tm_year+1900)?nr:sr,g.tm_mon-1),3)},"%m":function(g){return W(g.tm_mon+1,2)},"%M":function(g){return W(g.tm_min,2)},"%n":function(){return`
17
+ `},"%p":function(g){return g.tm_hour>=0&&g.tm_hour<12?"AM":"PM"},"%S":function(g){return W(g.tm_sec,2)},"%t":function(){return" "},"%u":function(g){return g.tm_wday||7},"%U":function(g){var N=new Date(g.tm_year+1900,0,1),F=N.getDay()===0?N:ir(N,7-N.getDay()),z=new Date(g.tm_year+1900,g.tm_mon,g.tm_mday);if(Z(F,z)<0){var Se=dn(rr(z.getFullYear())?nr:sr,z.getMonth()-1)-31,v=31-F.getDate(),Be=v+Se+z.getDate();return W(Math.ceil(Be/7),2)}return Z(F,N)===0?"01":"00"},"%V":function(g){var N=new Date(g.tm_year+1900,0,4),F=new Date(g.tm_year+1901,0,4),z=G(N),Se=G(F),v=ir(new Date(g.tm_year+1900,0,1),g.tm_yday);if(Z(v,z)<0)return"53";if(Z(Se,v)<=0)return"01";var Be;return z.getFullYear()<g.tm_year+1900?Be=g.tm_yday+32-z.getDate():Be=g.tm_yday+1-z.getDate(),W(Math.ceil(Be/7),2)},"%w":function(g){return g.tm_wday},"%W":function(g){var N=new Date(g.tm_year,0,1),F=N.getDay()===1?N:ir(N,N.getDay()===0?1:7-N.getDay()+1),z=new Date(g.tm_year+1900,g.tm_mon,g.tm_mday);if(Z(F,z)<0){var Se=dn(rr(z.getFullYear())?nr:sr,z.getMonth()-1)-31,v=31-F.getDate(),Be=v+Se+z.getDate();return W(Math.ceil(Be/7),2)}return Z(F,N)===0?"01":"00"},"%y":function(g){return(g.tm_year+1900).toString().substring(2)},"%Y":function(g){return g.tm_year+1900},"%z":function(g){var N=g.tm_gmtoff,F=N>=0;return N=Math.abs(N)/60,N=N/60*100+N%60,(F?"+":"-")+String("0000"+N).slice(-4)},"%Z":function(g){return g.tm_zone},"%%":function(){return"%"}};for(var S in K)T.includes(S)&&(T=T.replace(new RegExp(S,"g"),K[S](E)));var Ee=Ci(T,!1);return Ee.length>o?0:(_i(Ee,i),Ee.length-1)}function vu(i,o,u,p){return xu(i,o,u,p)}function Uu(i){var o=Date.now()/1e3|0;return i&&(M[i>>2]=o),o}Ma(),vi=e.BindingError=xi(Error,"BindingError"),qa=e.InternalError=xi(Error,"InternalError"),$a();function Ci(i,o,u){var p=u>0?u:mi(i)+1,b=new Array(p),E=di(i,b,0,b.length);return o&&(b.length=E),b}var Ou={g:Ua,a:Pa,f:Da,r:La,n:Wa,A:Ka,l:Xa,d:za,c:Za,m:eu,i:tu,o:ru,e:nu,j:ou,b:mu,s:fu,t:hu,x:gu,y:Eu,z:Tu,u:Su,q:yu,k:Iu,v:tr,h:Ru,w:vu,p:Uu},Zl=xa(),Pu=e.___wasm_call_ctors=function(){return(Pu=e.___wasm_call_ctors=e.asm.C).apply(null,arguments)},Nu=e._CreateMediaProcessing=function(){return(Nu=e._CreateMediaProcessing=e.asm.D).apply(null,arguments)},Cu=e._ReleaseMediaProcessing=function(){return(Cu=e._ReleaseMediaProcessing=e.asm.E).apply(null,arguments)},wu=e._AddAudioChannel=function(){return(wu=e._AddAudioChannel=e.asm.F).apply(null,arguments)},Du=e._DelAudioChannel=function(){return(Du=e._DelAudioChannel=e.asm.G).apply(null,arguments)},Lu=e._AddVideoChannel=function(){return(Lu=e._AddVideoChannel=e.asm.H).apply(null,arguments)},Mu=e._DelVideoChannel=function(){return(Mu=e._DelVideoChannel=e.asm.I).apply(null,arguments)},ku=e._ReceivedRawAudioPacket=function(){return(ku=e._ReceivedRawAudioPacket=e.asm.J).apply(null,arguments)},Bu=e._ParseUdtMousePacket=function(){return(Bu=e._ParseUdtMousePacket=e.asm.K).apply(null,arguments)},Vu=e._ReceivedAudioUdtPacket=function(){return(Vu=e._ReceivedAudioUdtPacket=e.asm.L).apply(null,arguments)},Fu=e._ParseUdtAudioPacket=function(){return(Fu=e._ParseUdtAudioPacket=e.asm.M).apply(null,arguments)},Hu=e._ReceivedVideoPacket=function(){return(Hu=e._ReceivedVideoPacket=e.asm.N).apply(null,arguments)},qu=e._SetAudioBuffer10Ms=function(){return(qu=e._SetAudioBuffer10Ms=e.asm.O).apply(null,arguments)},Wu=e._SetAudioVolume=function(){return(Wu=e._SetAudioVolume=e.asm.P).apply(null,arguments)},Gu=e._GetAudioFrame=function(){return(Gu=e._GetAudioFrame=e.asm.Q).apply(null,arguments)},ju=e._GetAudioFrameFloat=function(){return(ju=e._GetAudioFrameFloat=e.asm.R).apply(null,arguments)},Yu=e._GetAudioMixed=function(){return(Yu=e._GetAudioMixed=e.asm.S).apply(null,arguments)},$u=e._GetAudioMixedFloat=function(){return($u=e._GetAudioMixedFloat=e.asm.T).apply(null,arguments)},Ku=e._GetAudioEnergy=function(){return(Ku=e._GetAudioEnergy=e.asm.U).apply(null,arguments)},Ju=e._SetAudioFrameFormat=function(){return(Ju=e._SetAudioFrameFormat=e.asm.V).apply(null,arguments)},Xu=e._SetAudioOutStreamFormat=function(){return(Xu=e._SetAudioOutStreamFormat=e.asm.W).apply(null,arguments)},Qu=e._AudioProcess=function(){return(Qu=e._AudioProcess=e.asm.X).apply(null,arguments)},zu=e._AudioProcessFloat=function(){return(zu=e._AudioProcessFloat=e.asm.Y).apply(null,arguments)},Zu=e._AudioReverseProcess=function(){return(Zu=e._AudioReverseProcess=e.asm.Z).apply(null,arguments)},ec=e._AudioReverseProcessFloat=function(){return(ec=e._AudioReverseProcessFloat=e.asm._).apply(null,arguments)},tc=e._InitOpusEncoder=function(){return(tc=e._InitOpusEncoder=e.asm.$).apply(null,arguments)},rc=e._SetOpusEncBitrate=function(){return(rc=e._SetOpusEncBitrate=e.asm.aa).apply(null,arguments)},nc=e._OpusEncode=function(){return(nc=e._OpusEncode=e.asm.ba).apply(null,arguments)},sc=e._UpdateStreamSync=function(){return(sc=e._UpdateStreamSync=e.asm.ca).apply(null,arguments)},ic=e._GetEncodedFrame=function(){return(ic=e._GetEncodedFrame=e.asm.da).apply(null,arguments)},oc=e._GetReceivedVideoStat=function(){return(oc=e._GetReceivedVideoStat=e.asm.ea).apply(null,arguments)},ac=e._CreateUdtPacketizer=function(){return(ac=e._CreateUdtPacketizer=e.asm.fa).apply(null,arguments)},uc=e._PacketizeVideoUdt=function(){return(uc=e._PacketizeVideoUdt=e.asm.ga).apply(null,arguments)},cc=e._PacketizeAudioUdt=function(){return(cc=e._PacketizeAudioUdt=e.asm.ha).apply(null,arguments)},lc=e._GetRetransPacket=function(){return(lc=e._GetRetransPacket=e.asm.ia).apply(null,arguments)},dc=e._CheckMissingPacket=function(){return(dc=e._CheckMissingPacket=e.asm.ja).apply(null,arguments)},pc=e._UseAINS=function(){return(pc=e._UseAINS=e.asm.ka).apply(null,arguments)},mc=e._EnableAEC=function(){return(mc=e._EnableAEC=e.asm.la).apply(null,arguments)},fc=e._SetCrypto=function(){return(fc=e._SetCrypto=e.asm.ma).apply(null,arguments)},or=e._malloc=function(){return(or=e._malloc=e.asm.oa).apply(null,arguments)},Ye=e._free=function(){return(Ye=e._free=e.asm.pa).apply(null,arguments)},wi=e.___errno_location=function(){return(wi=e.___errno_location=e.asm.qa).apply(null,arguments)},_c=e.___getTypeName=function(){return(_c=e.___getTypeName=e.asm.ra).apply(null,arguments)},hc=e.___embind_register_native_and_builtin_types=function(){return(hc=e.___embind_register_native_and_builtin_types=e.asm.sa).apply(null,arguments)},Di=e.stackSave=function(){return(Di=e.stackSave=e.asm.ta).apply(null,arguments)},Li=e.stackRestore=function(){return(Li=e.stackRestore=e.asm.ua).apply(null,arguments)},pn=e.stackAlloc=function(){return(pn=e.stackAlloc=e.asm.va).apply(null,arguments)},bc=e._emscripten_stack_init=function(){return(bc=e._emscripten_stack_init=e.asm.wa).apply(null,arguments)};e.ccall=ci,e.cwrap=oa,e.addFunction=na,e.removeFunction=sa;var ar;function gc(i){this.name="ExitStatus",this.message="Program terminated with exit("+i+")",this.status=i}Nt=function i(){ar||mn(),ar||(Nt=i)};function mn(i){if(i=i||f,tt>0||(ha(),tt>0))return;function o(){ar||(ar=!0,e.calledRun=!0,!ai&&(ba(),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),ga()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),o()},1)):o()}if(e.run=mn,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return mn(),e.ready}}(),Zo=Xl;zo(Zo);