trtc-sdk-v5 5.13.1-wasm.5 → 5.13.1-wasm.7

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 Hu=Object.create;var lr=Object.defineProperty,Fu=Object.defineProperties,rs=Object.getOwnPropertyDescriptor,qu=Object.getOwnPropertyDescriptors,Wu=Object.getOwnPropertyNames,ts=Object.getOwnPropertySymbols,Gu=Object.getPrototypeOf,ns=Object.prototype.hasOwnProperty,ju=Object.prototype.propertyIsEnumerable;var mn=(n,t,e)=>t in n?lr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,wt=(n,t)=>{for(var e in t||(t={}))ns.call(t,e)&&mn(n,e,t[e]);if(ts)for(var e of ts(t))ju.call(t,e)&&mn(n,e,t[e]);return n},is=(n,t)=>Fu(n,qu(t));var $u=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var Yu=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Wu(t))!ns.call(n,i)&&i!==e&&lr(n,i,{get:()=>t[i],enumerable:!(r=rs(t,i))||r.enumerable});return n};var mr=(n,t,e)=>(e=n!=null?Hu(Gu(n)):{},Yu(t||!n||!n.__esModule?lr(e,"default",{value:n,enumerable:!0}):e,n));var ce=(n,t,e,r)=>{for(var i=r>1?void 0:r?rs(t,e):t,o=n.length-1,u;o>=0;o--)(u=n[o])&&(i=(r?u(t,e,i):u(i))||i);return r&&i&&lr(t,e,i),i};var d=(n,t,e)=>mn(n,typeof t!="symbol"?t+"":t,e);var qt=$u((Rd,li)=>{"use strict";var _c=Object.prototype.hasOwnProperty,de="~";function Ft(){}Object.create&&(Ft.prototype=Object.create(null),new Ft().__proto__||(de=!1));function hc(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function Rs(n,t,e,r,i){if(typeof e!="function")throw new TypeError("The listener must be a function");var o=new hc(e,r||n,i),u=de?de+t:t;return n._events[u]?n._events[u].fn?n._events[u]=[n._events[u],o]:n._events[u].push(o):(n._events[u]=o,n._eventsCount++),n}function Dr(n,t){--n._eventsCount===0?n._events=new Ft:delete n._events[t]}function ae(){this._events=new Ft,this._eventsCount=0}ae.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)_c.call(e,r)&&t.push(de?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};ae.prototype.listeners=function(t){var e=de?de+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,u=new Array(o);i<o;i++)u[i]=r[i].fn;return u};ae.prototype.listenerCount=function(t){var e=de?de+t:t,r=this._events[e];return r?r.fn?1:r.length:0};ae.prototype.emit=function(t,e,r,i,o,u){var p=de?de+t:t;if(!this._events[p])return!1;var l=this._events[p],m=arguments.length,_,h;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),m){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,i),!0;case 5:return l.fn.call(l.context,e,r,i,o),!0;case 6:return l.fn.call(l.context,e,r,i,o,u),!0}for(h=1,_=new Array(m-1);h<m;h++)_[h-1]=arguments[h];l.fn.apply(l.context,_)}else{var T=l.length,I;for(h=0;h<T;h++)switch(l[h].once&&this.removeListener(t,l[h].fn,void 0,!0),m){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,i);break;default:if(!_)for(I=1,_=new Array(m-1);I<m;I++)_[I-1]=arguments[I];l[h].fn.apply(l[h].context,_)}}return!0};ae.prototype.on=function(t,e,r){return Rs(this,t,e,r,!1)};ae.prototype.once=function(t,e,r){return Rs(this,t,e,r,!0)};ae.prototype.removeListener=function(t,e,r,i){var o=de?de+t:t;if(!this._events[o])return this;if(!e)return Dr(this,o),this;var u=this._events[o];if(u.fn)u.fn===e&&(!i||u.once)&&(!r||u.context===r)&&Dr(this,o);else{for(var p=0,l=[],m=u.length;p<m;p++)(u[p].fn!==e||i&&!u[p].once||r&&u[p].context!==r)&&l.push(u[p]);l.length?this._events[o]=l.length===1?l[0]:l:Dr(this,o)}return this};ae.prototype.removeAllListeners=function(t){var e;return t?(e=de?de+t:t,this._events[e]&&Dr(this,e)):(this._events=new Ft,this._eventsCount=0),this};ae.prototype.off=ae.prototype.removeListener;ae.prototype.addListener=ae.prototype.on;ae.prefixed=de;ae.EventEmitter=ae;typeof li!="undefined"&&(li.exports=ae)});function $(...n){}var Ku=n=>n();function pn(){this.dispose()}var Ju=()=>typeof __FASTRX_DEVTOOLS__!="undefined",Xu=1,De=class extends Function{toString(){return`${this.name}(${this.args.length?[...this.args].join(", "):""})`}subscribe(t){let e=new dn(t,this,this.streamId++);return Z.subscribe({id:this.id,end:!1},{nodeId:e.sourceId,streamId:e.id}),this(e),e}},lt=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=$,this.error=$,this.next=$,this.dispose=$,this.subscribe=$,this.doDefer()}subscribe(t){return t instanceof De?t.subscribe(this):t(this),this}get bindSubscribe(){return t=>this.subscribe(t)}doDefer(){this.defers.forEach(Ku),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}},D=class extends lt{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 lt{constructor(t,e=$,r=$,i=$){if(super(),this._next=e,this._error=r,this._complete=i,this.then=$,t instanceof De){let o={toString:()=>"subscribe",id:0,source:t};this.defer(()=>{Z.defer(o,0)}),Z.create(o),Z.pipe(o),this.sourceId=o.id,this.subscribe(t),Z.subscribe({id:o.id,end:!0}),e==$?this._next=u=>Z.next(o,0,u):this.next=u=>{Z.next(o,0,u),e(u)},i==$?this._complete=()=>Z.complete(o,0):this.complete=()=>{this.dispose(),Z.complete(o,0),i()},r==$?this._error=u=>Z.complete(o,0,u):this.error=u=>{this.dispose(),Z.complete(o,0,u),r()}}else this.subscribe(t)}next(t){this._next(t)}complete(){this.dispose(),this._complete()}error(t){this.dispose(),this._error(t)}};function F(n,...t){return t.reduce((e,r)=>r(e),n)}function le(n,t,e){if(Ju()){let r=Object.defineProperties(Object.setPrototypeOf(n,De.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}});Z.create(r);for(let i=0;i<e.length;i++){let o=e[i];typeof o=="function"&&o instanceof De&&Z.addSource(r,o)}return r}return n}function L(n,t){return function(...e){return r=>{if(r instanceof De){let i=le(o=>{let u=new n(o,...e);u.sourceId=i.id,u.subscribe(r)},t,arguments);return i.source=r,Z.pipe(i),i}else return i=>r(new n(i,...e))}}}function qe(n,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:n,payload:t}})}var dn=class extends D{constructor(t,e,r){super(t),this.source=e,this.id=r,this.sourceId=t.sourceId,this.defer(()=>{Z.defer(this.source,this.id)})}next(t){Z.next(this.source,this.id,t),this.sink.next(t)}complete(){Z.complete(this.source,this.id),this.sink.complete()}error(t){Z.complete(this.source,this.id,t),this.sink.error(t)}},Z={addSource(n,t){qe("addSource",{id:n.id,name:n.toString(),source:{id:t.id,name:t.toString()}})},next(n,t,e){qe("next",{id:n.id,streamId:t,data:e&&e.toString()})},subscribe({id:n,end:t},e){qe("subscribe",{id:n,end:t,sink:{nodeId:e&&e.nodeId,streamId:e&&e.streamId}})},complete(n,t,e){qe("complete",{id:n.id,streamId:t,err:e?e.toString():null})},defer(n,t){qe("defer",{id:n.id,streamId:t})},pipe(n){qe("pipe",{name:n.toString(),id:n.id,source:{id:n.source.id,name:n.source.toString()}})},update(n){qe("update",{id:n.id,name:n.toString()})},create(n){n.id||(n.id=Xu++),qe("create",{name:n.toString(),id:n.id})}},pr=class extends Error{constructor(t){super(`timeout after ${t}ms`),this.timeout=t}};var fn=class extends lt{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 We(){return n=>{let t=new fn(n);if(n instanceof De){let e=le(r=>{t.add(r)},"share",arguments);return t.sourceId=e.id,e.source=n,Z.pipe(e),e}return le(t.add.bind(t),"share",arguments)}}function ss(...n){return le(t=>{let e=new D(t),r=n.length;e.complete=()=>{--r===0&&t.complete()},n.forEach(e.bindSubscribe)},"merge",arguments)}function Qu(...n){return le(t=>{let e=n.length,r=e,i=e,o=new Array(e),u=()=>{--i===0&&t.complete()},p=(l,m)=>{let _=new D(t);_.next=h=>{--r===0?(_.next=T=>{o[m]=T,t.next(o)},_.next(h)):o[m]=h},_.complete=u,_.subscribe(l)};n.forEach(p)},"combineLatest",arguments)}function os(...n){return le(t=>{let e=n.length,r=e,i=new Array(e),o=()=>{--r===0&&t.complete()},u=(p,l)=>{let m=new D(t),_=[];i[l]=_,m.next=h=>{_.push(h),i.every(T=>T.length)&&t.next(i.map(T=>T.shift()))},m.complete=o,m.subscribe(p)};n.forEach(u)},"zip",arguments)}var _n=class extends D{constructor(t,...e){super(t);let r=new D(this.sink);r.next=i=>this.buffer=i,r.complete=$,r.subscribe(Qu(...e))}next(t){this.buffer&&this.sink.next([t,...this.buffer])}},Ul=L(_n,"withLatestFrom"),hn=class extends D{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()}},xl=L(hn,"bufferCount"),bn=class extends D{constructor(t,e){super(t),this.buffer=[];let r=new D(t);r.next=i=>{t.next(this.buffer),this.buffer=[]},r.complete=$,r.subscribe(e)}next(t){this.buffer.push(t)}complete(){this.buffer.length&&this.sink.next(this.buffer),super.complete()}},Ol=L(bn,"buffer");function ze(n){let t=arguments,e=We()(le(r=>{e.next=i=>r.next(i),e.complete=()=>r.complete(),e.error=i=>r.error(i),n&&r.subscribe(n)},"subject",t));return e.next=$,e.complete=$,e.error=$,e}function mt(n){return le(t=>{let e=0,r=setInterval(()=>t.next(e++),n);return t.defer(()=>{clearInterval(r)}),"interval"},"interval",arguments)}function as(n,t){return le(e=>{let r=0,i=setTimeout(()=>{if(e.removeDefer(o),e.next(r++),t){let u=setInterval(()=>e.next(r++),t);e.defer(()=>{clearInterval(u)})}else e.complete()},n),o=()=>{clearTimeout(i)};e.defer(o)},"timer",arguments)}function gn(n,t){return e=>{let r=i=>e.next(i);e.defer(()=>t(r)),n(r)}}function Te(n,t){if("on"in n&&"off"in n)return le(gn(e=>n.on(t,e),e=>n.off(t,e)),"fromEvent",arguments);if("addListener"in n&&"removeListener"in n)return le(gn(e=>n.addListener(t,e),e=>n.removeListener(t,e)),"fromEvent",arguments);if("addEventListener"in n)return le(gn(e=>n.addEventListener(t,e),e=>n.removeEventListener(t,e)),"fromEvent",arguments);throw"target is not a EventDispachter"}var En=class extends D{constructor(t,e,r){super(t),this.f=e;let i=()=>{this.sink.next(this.acc),this.sink.complete()};typeof r=="undefined"?this.next=o=>{this.acc=o,this.complete=i,this.resetNext()}:(this.acc=r,this.complete=i)}next(t){this.acc=this.f(this.acc,t)}},zu=L(En,"reduce");var Tn=class extends D{constructor(t,e,r){super(t),this.filter=e,this.thisArg=r}next(t){this.filter.call(this.thisArg,t)&&this.sink.next(t)}},dt=L(Tn,"filter"),Sn=class extends D{next(t){}},Bl=L(Sn,"ignoreElements"),yn=class extends D{constructor(t,e){super(t),this.count=e}next(t){this.sink.next(t),--this.count===0&&this.complete()}},_r=L(yn,"take"),An=class extends D{constructor(t,e){super(t);let r=new D(t);r.next=()=>t.complete(),r.complete=pn,r.subscribe(e)}},Ue=L(An,"takeUntil"),In=class extends D{constructor(t,e){super(t),this.f=e}next(t){this.f(t)?this.sink.next(t):this.complete()}},Mn=L(In,"takeWhile");var Rn=class extends D{constructor(t,e){super(t),this.count=e}next(t){--this.count===0&&(this.next=super.next)}},Vl=L(Rn,"skip"),Un=class extends D{constructor(t,e){super(t),t.next=$;let r=new D(t);r.next=()=>{r.dispose(),t.resetNext()},r.complete=pn,r.subscribe(e)}},Hl=L(Un,"skipUntil"),xn=class extends D{constructor(t,e){super(t),this.f=e}next(t){this.f(t)||(this.next=super.next,this.next(t))}},us=L(xn,"skipWhile"),Zu={leading:!0,trailing:!1},On=class extends D{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)}},vn=class extends D{constructor(t,e,r=Zu){super(t),this.durationSelector=e,this.config=r,this._throttle=new On(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=$,this._throttle.complete(),super.complete()}},cs=L(vn,"throttle");var Pn=class extends D{next(){this.complete()}complete(){this.dispose(),this.sink.next(this.last)}},fr=class extends D{constructor(t,e){super(t),this.durationSelector=e,this._debounce=new Pn(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()}},ls=L(fr,"debounce"),ms=n=>L(fr,"debounceTime")(t=>as(n)),Nn=class extends D{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()}},Fl=L(Nn,"elementAt");var Dn=class extends D{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}},ql=L(Dn,"findIndex"),wn=class extends D{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()}},Wl=L(wn,"first"),Cn=class extends D{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()}},Gl=L(Cn,"last"),Ln=class extends D{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()}},jl=L(Ln,"every");var kn=class extends D{constructor(t,e,r){super(t),this.f=e,typeof r=="undefined"?this.next=i=>{this.acc=i,this.resetNext(),this.sink.next(this.acc)}:this.acc=r}next(t){this.sink.next(this.acc=this.f(this.acc,t))}},Jl=L(kn,"scan"),Bn=class extends D{constructor(){super(...arguments),this.hasLast=!1}next(t){this.hasLast?this.sink.next([this.last,t]):this.hasLast=!0,this.last=t}},Xl=L(Bn,"pairwise"),hr=class extends D{constructor(t,e,r){super(t),this.mapper=e,this.thisArg=r}next(t){super.next(this.mapper.call(this.thisArg,t))}},Ze=L(hr,"map"),Yn=n=>L(hr,"mapTo")(t=>n),pt=class extends D{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()}},ft=class extends D{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 pt{},gr=class extends ft{next(t){this.subInner(t,br),this.next=e=>{this.currentSink.dispose(),this.subInner(e,br)}}},Kn=L(gr,"switchMap");function yr(n){return(t,e)=>n(()=>t,e)}var Ct=yr(L(gr,"switchMapTo")),Vn=class extends pt{tryComplete(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}},Er=class extends ft{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(),Vn),this.disposed&&this.sources.length===0&&this.currentSink.resetComplete()}tryComplete(){this.sources.length===0&&this.currentSink.resetComplete(),this.dispose()}},Ql=L(Er,"concatMap"),zl=yr(L(Er,"concatMapTo")),Hn=class extends pt{tryComplete(){this.context.inners.delete(this),super.dispose(),this.context.inners.size===0&&this.context.resetComplete()}},Tr=class extends ft{constructor(){super(...arguments),this.inners=new Set}next(t){this.subInner(t,Hn),this.inners.add(this.currentSink)}tryComplete(){this.inners.size===1?this.inners.forEach(t=>t.resetComplete()):this.dispose()}},Zl=L(Tr,"mergeMap"),em=yr(L(Tr,"mergeMapTo")),Fn=class extends pt{dispose(){this.context.resetNext(),super.dispose()}},Sr=class extends ft{next(t){this.next=$,this.subInner(t,Fn)}},tm=L(Sr,"exhaustMap"),rm=yr(L(Sr,"exhaustMapTo")),qn=class extends D{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=ze(),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)}},nm=L(qn,"groupBy"),Wn=class extends D{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}},im=L(Wn,"timeInterval"),Gn=class extends D{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()}},sm=L(Gn,"bufferTime"),jn=class extends D{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:i}=e;super.next(i),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)}},om=L(jn,"delay"),$n=class extends D{constructor(t,e){super(t),this.selector=e}error(t){this.dispose(),this.selector(t)(this.sink)}},am=L($n,"catchError");var X=(n=$,t=$,e=$)=>r=>new dr(r,n,t,e),Jn=class extends D{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=L(Jn,"tap"),Xn=class extends D{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()}},lm=L(Xn,"timeout");var et="5.0.0";var ds=typeof importScripts!="undefined",Ir=typeof registerProcessor!="undefined";var Qn="";var ec="web.sdk.qcloud.com";var tc=`https://${ec}/trtc/webrtc/v5/doc`,Tm=`${tc}/zh-cn/`,ps="https://yun.tim.qq.com",fs="https://apisgp.my-imcloud.com";var _s={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"};var ke=(u=>(u[u.TRACE=0]="TRACE",u[u.DEBUG=1]="DEBUG",u[u.INFO=2]="INFO",u[u.WARN=3]="WARN",u[u.ERROR=4]="ERROR",u[u.NONE=5]="NONE",u))(ke||{}),hs=18e3;var Sm=7*24*3600*1e3;var bs={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},ym=bs["480p_2"],Am=bs["120p_2"];var Lt={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",LOADEDMETADATA:"loadedmetadata",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",RESIZE:"resize",TIME_UPDATE:"timeupdate"};var _t=1,Rr=2,Ur=4,ht=8,bt=64,gt=16;var Im=Lt.MAIN,Rm=Lt.AUXILIARY;var gs=30;var Um=Lt.BIG,xm=Lt.SMALL,Om=10*1e3;var vm=Object.keys(ke),Es=["normal leave","timeout leave","kick","role change"];var Pm=10*1e3;var nc=function(n,t,e,r){function i(o){return o instanceof e?o:new e(function(u){u(o)})}return new(e||(e=Promise))(function(o,u){function p(_){try{m(r.next(_))}catch(h){u(h)}}function l(_){try{m(r.throw(_))}catch(h){u(h)}}function m(_){_.done?o(_.value):i(_.value).then(p,l)}m((r=r.apply(n,t||[])).next())})},zn=Symbol(32),Zn=Symbol(16),ei=Symbol(8),me=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 nc(this,void 0,void 0,function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise((e,r)=>{var i;this.reject=r,this.resolve=u=>{delete this.lastReadPromise,delete this.resolve,delete this.need,e(u)},this.demand(t,!0)||(i=this.pull)===null||i===void 0||i.call(this,t)})})}readU32(){return this.read(zn)}readU16(){return this.read(Zn)}readU8(){return this.read(ei)}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,i=o=>e.length<(r=o);if(typeof this.need=="number"){if(i(this.need))return;t=e.subarray(0,r)}else if(this.need===zn){if(i(4))return;t=e[0]<<24|e[1]<<16|e[2]<<8|e[3]}else if(this.need===Zn){if(i(2))return;t=e[0]<<8|e[1]}else if(this.need===ei){if(i(1))return;t=e[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(i(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(i(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 i=new Uint8Array(r);i.set(this.buffer),this.buffer=i}return this.buffer.subarray(e,r)}else return this.buffer=new Uint8Array(t),this.buffer}};me.U32=zn;me.U16=Zn;me.U8=ei;var ic=128,sc=127,Bm=~sc,Vm=Math.pow(2,31);function ti(n){let t=new me;for(;n>=128;)t.malloc(1)[0]=n&255|ic,n>>>=7;return t.malloc(1)[0]=n&255,t.buffer||new Uint8Array(0)}function xr(n,t=0){let e=new me,r=t<<3;switch(typeof n){case"boolean":let i=e.malloc(2);i[0]=r,i[1]=n?1:0;break;case"number":e.malloc(1)[0]=r,e.write(ti(n));break;case"string":e.malloc(1)[0]=r|2;let o=new TextEncoder().encode(n);e.write(ti(o.length));let u=e.malloc(o.length);for(let l=0;l<o.length;l++)u[l]=o[l];break;case"object":let p=new me;if(Array.isArray(n))for(let l=0;l<n.length;l++){let m=xr(n[l],l+1);m&&p.write(m)}else{let l=1;for(let m in n){let _=xr(n[m],l++);_&&p.write(_)}}t===0?p.buffer&&e.write(p.buffer):(e.malloc(1)[0]=r|2,p.buffer&&(e.write(ti(p.buffer.length)),e.write(p.buffer)))}return e.buffer||new Uint8Array(0)}var Mt=class{constructor(){d(this,"buffer");this.buffer=[]}get data(){return this.buffer}get length(){return this.buffer.length}writeInt32(t){this.buffer.push(t>>>24&255),this.buffer.push(t>>>16&255),this.buffer.push(t>>>8&255),this.buffer.push(t&255)}writeInt16(t){this.buffer.push(t>>>8&255),this.buffer.push(t&255)}writeByte(t){this.buffer.push(t&255)}writeBytes(t){for(let e=0;e<t.length;e++)this.buffer.push(t[e])}};function ri(n,t,e){n[e]=t>>>24&255,n[e+1]=t>>>16&255,n[e+2]=t>>>8&255,n[e+3]=t&255}function oe(n,t){return n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3]}function ni(n,t){return n[t]}function Et(n,t,e){return new TextDecoder().decode(oc(n,t,e))}function oc(n,t,e){return n.slice(t,t+e)}var ii=0,Or=2654435769,vr=16,oi=4,Tt=2,St=7;function ac(n,t,e,r="AVQualityReportSvc.C2S",i=2e3,o=2,u=30){return{version:i,encryption:o,d2:"",d2Len:0,uinType:u,uin:"",uinLen:0,reqHead:{seqNumber:e,appId:n,appidAtThird:new Uint8Array(0),a2:"",a2Len:0,serviceCmd:r,serviceCmdLen:0,cookie:"",cookieLen:0,imei:"",imeiLen:0,ksid:"",ksidLen:0,clientVersionInfo:"",clientVersionInfoLen:0},busiBuff:t}}function Ts(n,t){let e=new Mt,r=ac(t,n,ii);ii=ii+1&2147483647,e.writeInt32(0),e.writeInt32(r.version),e.writeByte(r.encryption);let i=new TextEncoder().encode(r.d2);e.writeInt32(i.length+4),i&&e.writeBytes(i),e.writeByte(r.uinType);let o=new TextEncoder().encode(r.uin);e.writeInt32(o.length+4),o.length&&e.writeBytes(o);let u=new Mt;u.writeInt32(0),u.writeInt32(r.reqHead.seqNumber),u.writeInt32(r.reqHead.appId),u.writeByte(r.reqHead.appId>>>24&255),u.writeByte(r.reqHead.appId>>>16&255),u.writeByte(r.reqHead.appId>>>8&255),u.writeByte(r.reqHead.appId&255);for(let W=4;W<16;W++)u.writeByte(0);let p=new TextEncoder().encode(r.reqHead.a2);u.writeInt32(p.length+4),p.length&&u.writeBytes(p);let l=new TextEncoder().encode(r.reqHead.serviceCmd);u.writeInt32(l.length+4),l.length&&u.writeBytes(l);let m=new TextEncoder().encode(r.reqHead.cookie);u.writeInt32(m.length+4),m.length&&u.writeBytes(m);let _=new TextEncoder().encode(r.reqHead.imei);u.writeInt32(_.length+4),_.length&&u.writeBytes(_);let h=new TextEncoder().encode(r.reqHead.ksid);u.writeInt32(h.length+4),h.length&&u.writeBytes(h);let T=new TextEncoder().encode(r.reqHead.clientVersionInfo);u.writeInt16(T.length+2),T.length&&u.writeBytes(T);let I=u.length;u.data[0]=I>>>24&255,u.data[1]=I>>>16&255,u.data[2]=I>>>8&255,u.data[3]=I&255,kt(n)&&(n=new TextEncoder().encode(n)),u.writeInt32(n.length+4),n.length&&u.writeBytes(n);let U=new Uint8Array(u.data),C=null;r.encryption===1?C=new TextEncoder().encode(r.uin):r.encryption===2&&(C=new Uint8Array(16)),C&&(U=uc(U,C)),e.writeBytes(U);let x=new Uint8Array(e.data),N=x.length;return x[0]=N>>>24&255,x[1]=N>>>16&255,x[2]=N>>>8&255,x[3]=N&255,x}function uc(n,t){let e=n.length,i=(e+1+Tt+St)%8;i&&(i=8-i);let o=e+1+Tt+St+i,u=new Uint8Array(o),p=0,l=new Uint8Array(8),m=new Uint8Array(8),_=new Uint8Array(8),h=0;l[0]=Math.floor(Math.random()*256)&248|i,h=1;for(let I=0;I<i;I++)l[h]=Math.floor(Math.random()*256)&255,h+=1;for(let I=0;I<Tt;)if(h<8&&(l[h]=Math.floor(Math.random()*256)&255,h+=1,I+=1),h===8){si(l,t,m,_,u,p),p+=8,h=0;for(let U=0;U<8;U++)_[U]=u[p-8+U]}let T=0;for(;T<e;)if(h<8&&(l[h]=n[T],h+=1,T+=1),h===8){si(l,t,m,_,u,p),p+=8,h=0;for(let I=0;I<8;I++)_[I]=u[p-8+I]}for(let I=0;I<St;)if(h<8&&(l[h]=0,h+=1,I+=1),h===8){si(l,t,m,_,u,p),p+=8,h=0;for(let U=0;U<8;U++)_[U]=u[p-8+U]}return u}function si(n,t,e,r,i,o){for(let u=0;u<8;u++)n[u]^=r[u];cc(n,t,i,o);for(let u=0;u<8;u++)i[o+u]^=e[u];for(let u=0;u<8;u++)e[u]=n[u]}function cc(n,t,e,r){let i=oe(n,0),o=oe(n,4),u=[];for(let l=0;l<4;l++)u[l]=oe(t,l*4);let p=0;for(let l=0;l<vr;l++)p+=Or,p=p>>>0,i+=(o<<4)+u[0]^o+p^(o>>>5)+u[1],i=i>>>0,o+=(i<<4)+u[2]^i+p^(i>>>5)+u[3],o=o>>>0;ri(e,i,r),ri(e,o,r+4)}var lc=n=>Number(n)<14e8,Ss=function(n,t){let e;Qn?e=Qn:e=lc(n)?fs:ps;let r=Math.floor(Math.random()*2**31);return`${e}/v5/AVQualityReportSvc/C2S?random=${r}&sdkappid=${n}&cmdtype=${t}`};var Zm=typeof window!="undefined"&&typeof window.glog=="function"?window.glog:()=>{};var Bt=n=>typeof n=="undefined",kt=n=>typeof n=="string",ys=n=>typeof n=="number";var ed=typeof HTMLMediaElement!="undefined"&&"setSinkId"in HTMLMediaElement.prototype;var{toString:td}=Object.prototype;function ai(n,t){return{userId:t,hasAudio:!!(n&ht),hasVideo:!!(n&_t),hasAuxiliary:!!(n&Ur),hasSmall:!!(n&Rr),audioMuted:!!(n&bt),videoMuted:!!(n&gt),audioAvailable:!!(n&ht)&&!(n&bt),videoAvailable:!!(n&_t)&&!(n&gt)}}function mc(n,t,e,r){let i={data:n,random:Math.floor(Math.random()*2147483648),sdkAppId:e};return Bt(r)||(i=is(wt({},i),{gzip:+r})),{uint32_sdkappid:0,uint64_from_uin:0,uint32_timestamp:0,uint32_seq:0,msg_common_info:{msg_device_info:{enum_device_type:0,str_device_brand:"",str_device_model:"",str_device_board:"",str_device_cpu_abi:""},msg_system_info:{enum_os_type:0,str_os_version:"",msg_network_info:0},msg_network_info:{enum_network_type:0}},msg_report_content:{uint32_type:t,bytes_report_data:JSON.stringify(i)}}}function As(n,t,e,r){try{let i=mc(n,t,e,r),o=xr(i);return Ts(o,e)}catch(i){return JSON.stringify(n)}}function Vt(n,t=!1){let e=Object.defineProperties(ze(),{postMessage:{value:n.postMessage.bind(n)},port:{get(){return n},set(i){n.onmessage=$,n.onmessageerror=$,n=i,r()}}});function r(){n.onmessage=i=>{i.data?i.ports.length||t?e.next(i):e.next(i.data):(e.complete(),n.close())},n.onmessageerror=i=>{e.error(i),n.close()}}return r(),e}var ui=class extends D{constructor(t,e){super(t);let r=new D(t);r.next=$,e(r)}},Be=L(ui,"takeUntilComplete");var te={useWt:!0,useAINS:!0,useHardDecoder:"prefer-software",useHardEncoder:"prefer-software",unreliable:!1,debug:!1,assetsPath:"",enableUpload:!0},dc="__INLINE__WORKER__",pc="__INLINE__WASM__",{debug:Pr}=console;te.debug||(console.debug=()=>{});var fd=!dc.startsWith("__"),_d=!pc.startsWith("__");var Is=F(mt(250),Ze(()=>performance.now()),We()),xe=n=>t=>{let e=0,r=performance.now();F(Is,Ze(i=>(i-r)/n>>0),dt(i=>i!=e?(e=i,!0):!1))(t)},Ge=n=>t=>{let e=performance.now();F(Is,us(r=>r-e<n),_r(1))(t)};function je(n,t,e){let r=t.aborted?Promise.reject(t.reason):new Promise((i,o)=>{t.addEventListener("abort",()=>o(t.reason),{once:!0}),typeof n=="function"?n(i,o):n.then(i,o)});return e?r.catch(e):r}var fc=new Intl.DateTimeFormat("zh-CN",{dateStyle:"short",timeStyle:"medium"}),tt=()=>fc.format(new Date),ne=(O=>(O[O.JOIN_ROOM=0]="JOIN_ROOM",O[O.LEAVE_ROOM=1]="LEAVE_ROOM",O[O.PUBLISH=2]="PUBLISH",O[O.UNPUBLISH=3]="UNPUBLISH",O[O.SUBSCRIBE=4]="SUBSCRIBE",O[O.UNSUBSCRIBE=5]="UNSUBSCRIBE",O[O.GET_WHOLE_LIST=6]="GET_WHOLE_LIST",O[O.QUALITY_REPORT=7]="QUALITY_REPORT",O[O.MUTE=8]="MUTE",O[O.UNMUTE=9]="UNMUTE",O[O.CONFIG=10]="CONFIG",O[O.REQUEST_PLI=11]="REQUEST_PLI",O[O.HEARTBEAT=12]="HEARTBEAT",O[O.START_PUSH_CDN=13]="START_PUSH_CDN",O[O.STOP_PUSH_CDN=14]="STOP_PUSH_CDN",O[O.START_MCU_MIX=15]="START_MCU_MIX",O[O.STOP_MCU_MIX=16]="STOP_MCU_MIX",O[O.UDPATE_TRACK=17]="UDPATE_TRACK",O[O.START_PUSHING=18]="START_PUSHING",O[O.STOP_PUSHING=19]="STOP_PUSHING",O[O.SWITCH_ROLE=20]="SWITCH_ROLE",O[O.WHOLE_LIST_UPDATE=255]="WHOLE_LIST_UPDATE",O[O.PEER_JOINED=256]="PEER_JOINED",O[O.PEER_LEFT=257]="PEER_LEFT",O[O.PEER_UDPATED_TRACK=258]="PEER_UDPATED_TRACK",O[O.SELECT_ABILITY=259]="SELECT_ABILITY",O[O.PEER_REQUEST_PLI=260]="PEER_REQUEST_PLI",O[O.AUDIO_DATA=4095]="AUDIO_DATA",O[O.VIDEO_DATA=4096]="VIDEO_DATA",O[O.SCREEN_DATA=4097]="SCREEN_DATA",O[O.NACK=4098]="NACK",O[O.ACK=4099]="ACK",O[O.REQUEST_RTT=4100]="REQUEST_RTT",O[O.RESPONSE_RTT=4101]="RESPONSE_RTT",O[O.PIP_DATA=4102]="PIP_DATA",O[O.LAYER_DATA=4103]="LAYER_DATA",O[O.MAX_FORCE=65535]="MAX_FORCE",O))(ne||{});function ci(n,t,e){let r=t>65535?1:0;return e.setUint8(0,0<<4|r),e.setUint16(1,n),r?e.setUint32(3,t):e.setUint16(3,t),r?7:5}function Ht(n,t){let e=n>=255&&n<4095;e&&(t+=4);let i=(t>65535?1:0)?7:5,o=new DataView(new ArrayBuffer(i+t));ci(n,t,o),e&&(o.setUint32(i,0),i+=4),o=new DataView(o.buffer,i),i=0;let u=T=>{o.setUint8(i,T),i++},p=T=>{o.setUint16(i,T),i+=2},l=(T,I=!1)=>{o.setUint32(i,T,I),i+=4},m=T=>{o.setBigUint64(i,T),i+=8},_=T=>{let I=new Uint8Array(o.buffer,o.byteOffset+i,T);return i+=T,I};return{write8:u,write32:l,write16:p,write64:m,writeData:T=>_(T.length).set(T),dv:o,next:_}}function Nr(n,t,e){let r=JSON.stringify(t),{writeData:i,dv:o}=Ht(n,r.length+16);switch(i(e.split("").map(u=>u.charCodeAt(0))),i(r.split("").map(u=>u.charCodeAt(0))),n){case 11:case 12:case 7:console.debug("send",ne[n],e,t,o.buffer);break;default:n<255&&console.log(tt(),"send",ne[n],e,t,o.buffer)}return o.buffer}var Us=mr(qt()),be=class extends Us.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 Te(this.io,ne[e])}glog(e){self.postMessage({type:"glog",payload:e})}};var Wt=class{constructor(){d(this,"arguments");d(this,"environment");d(this,"preInit");d(this,"preRun");d(this,"postRun");d(this,"onAbort");d(this,"preinitializedWebGLContext");d(this,"noInitialRun");d(this,"noExitRuntime");d(this,"logReadFiles");d(this,"filePackagePrefixURL");d(this,"wasmBinary");d(this,"HEAP");d(this,"IHEAP");d(this,"FHEAP");d(this,"HEAP8");d(this,"HEAP16");d(this,"HEAP32");d(this,"HEAPU8");d(this,"HEAPU16");d(this,"HEAPU32");d(this,"HEAPF32");d(this,"HEAPF64");d(this,"TOTAL_STACK");d(this,"TOTAL_MEMORY");d(this,"FAST_MEMORY");d(this,"preloadedImages");d(this,"preloadedAudios");d(this,"_GetEncodedFrame");d(this,"_ReceivedAudioPacket");d(this,"_CreateUdtPacketizer");d(this,"_PacketizeVideoUdt");d(this,"udtver",3)}onRuntimeInitialized(){}print(t){console.debug(t)}printErr(t){console.debug(t)}},ue=new Wt,B=class{constructor(t,e){this.size=t;d(this,"point");this.point=ue._malloc(t),e&&this.set(e)}set(t){t.length>this.size&&this.grow(t.length),ue.HEAPU8.set(t,this.point)}setUint32(t,e){new DataView(ue.HEAPU8.buffer).setUint32(this.point+t,e)}setBigUint64(t,e){new DataView(ue.HEAPU8.buffer).setBigUint64(this.point+t,e)}getBigUint64(t){return new DataView(ue.HEAPU8.buffer).getBigUint64(this.point+t)}getUint32(t){return ue.HEAPU8[this.point+t]|ue.HEAPU8[this.point+t+1]<<8|ue.HEAPU8[this.point+t+2]<<16|ue.HEAPU8[this.point+t+3]<<24}getInt8(t){return ue.HEAPU8[this.point+t]}uint8Array(t=NaN){return new Uint8Array(ue.HEAPU8.buffer,this.point,t>=0?t:this.size)}uint8Slice(t=NaN){return ue.HEAPU8.slice(this.point,this.point+(t>=0?t:this.size))}fill(t=0,e=this.point,r=this.point+this.size){ue.HEAPU8.fill(t,e,r)}free(){ue._free(this.point)}grow(t){t>this.size&&(this.free(),this.size=t,this.point=ue._malloc(t))}};d(B,"global");var V=ue;var wr=class{constructor(t){d(this,"lastReceiveTime",-1);d(this,"blocking",!1);d(this,"blockCnt",0);d(this,"blockTime",0);d(this,"received",ze());let e=Ge(t);F(this.received,ls(()=>(this.blockDone(),this.lastReceiveTime=Date.now(),e)),X(()=>{this.blocking=!0},$,()=>{this.blockDone()}))}blockDone(){this.blocking&&(this.blockCnt++,this.blockTime+=Date.now()-this.lastReceiveTime,this.blocking=!1)}clear(){this.blockCnt=0,this.blockTime=0}},kr=class kr{constructor(t=2){d(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});d(this,"videoPort");d(this,"control");d(this,"lastReceiveTime",-1);d(this,"vBlock",new wr(500));d(this,"ssrc",kr.g_ssrc++);d(this,"framesFromStartPull",0);this.videoStatus.uint32_video_stream_type=t}getVideoStatus(){let t=wt({},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:i,vBlock:o}=this;i.uint32_video_receive++;let u=Date.now();i.uint32_video_total_bitrate+=e<<3,B.global.set(t);let p=V._ReceivedVideoPacket(B.global.point,e,u/1e3,u%1e3,r);p==0&&(this.lastReceiveTime>0&&u-this.lastReceiveTime>500&&console.debug("demuxPacket",u-this.lastReceiveTime),this.lastReceiveTime=u),o.received.next(p)}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])}};d(kr,"g_ssrc",1);var Cr=kr,Lr=class{constructor(t,e){this.writer=t;this.ssrc=e;d(this,"buffer",new B(960));d(this,"timestamp",0);V._SetAudioBuffer10Ms(this.buffer.point,e),V._AddAudioChannel(e,e)}feed(){this.writer.write(new AudioData({format:"s16",numberOfChannels:1,numberOfFrames:480,sampleRate:48e3,timestamp:this.timestamp+=1e4,data:this.buffer.uint8Array()}))}close(){V._DelAudioChannel(this.ssrc),this.buffer.free()}},Mr=class{constructor(t,e){this.io=e;d(this,"userId");d(this,"tinyId");d(this,"role");d(this,"terminalType");d(this,"lastCapNtpMs",-1);d(this,"startTimestamp",Date.now());d(this,"alastReceivedTimestamp",-1);d(this,"lengthPoint",new B(4));d(this,"audioPuller");d(this,"mainPuller",new Cr(2));d(this,"screenPuller",new Cr(7));d(this,"aBlock",new wr(250));d(this,"events",[]);d(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});d(this,"subscribe",0);d(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 i=wt({},this.msg_audio_status);return i.uint32_audio_codec_bitrate>>=1,i.uint32_audio_total_bitrate>>=1,i.uint32_audio_block_cnt=this.aBlock.blockCnt,i.uint32_audio_block_time=this.aBlock.blockTime,e&&console.log(new Date().toLocaleString(),t.userId,r.map(o=>({t:o.uint32_video_stream_type,r_fps:o.uint32_video_receive_fps,c_fps:o.uint32_video_codec_fps,c_bps:o.uint32_video_codec_bitrate})),i.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:i,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=V._GetEncodedFrame(B.global.point,this.lengthPoint.point,!1,t.ssrc),r=this.lengthPoint.getUint32(0);if(e==-1||r==0)return 10;let i=B.global.uint8Array(r);return t.videoStatus.uint32_video_total_frame||console.timeEnd(`${this.userId}${t==this.mainPuller?"big":"aux"}`),t.gotVideoFrame(i),e}startPullOnlyAudio(t,e,r){this.io.log_.info("start pull only audio",t),V._AddAudioChannel(t.ssrc,t.ssrc)}startPull(t,e,r){this.io.log_.info("start pull",t,r);let i=t===this.mainPuller;if(t.videoPort){t.framesFromStartPull=0,t.videoPort.port=e.port;return}let o=i?[2,1]:[7];t.videoPort=e,console.time(`${this.userId}${r.mediaType&2?"aux":"big"}`),F(e,X(({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 u=_=>{delete t.videoPort,_?this.io.log_.error("stop pull",_):this.io.log_.info("stop pull",t),V._DelVideoChannel(t.ssrc),t.vBlock.received.complete(),i&&this.aBlock.received.complete()};V._AddVideoChannel(t.ssrc,t.ssrc);let p=0,l=0,m=()=>{Date.now()-l>2e3&&(l=Date.now(),this.io.sendReq(11,r))};F(this.io.wh.interval10ms,dt(_=>(p<=0&&(p=this.getNextVideoFrame(t),p>500&&(p=20)),p-=10,te.useWt&&(_&1)==0&&!o.every(h=>{let T=V._CheckMissingPacket(B.global.point,B.global.size,h,t.ssrc,this.io.rtt);return T>0&&(B.global.setBigUint64(5,BigInt(this.tinyId)),this.io.send(B.global.uint8Array(T))),T>=0}))),Be(e),X(m,u,u)),m(),F(xe(5e3),Be(e),X(m))}};var bc=1e8;function gc(){let n=new B(500,[0]);return V._GetAudioEnergy(n.point,100),n}var yt=class yt extends be{constructor(){super(...arguments);d(this,"audioReceivedBuff",new B(2048));d(this,"levelsMap",new Map);d(this,"timestampBuff",new B(12))}decodeAudio(e,r){F(this.createResposeOb(4095),Be(r),X(({data:i})=>{let u=new DataView(i.buffer,i.byteOffset,i.byteLength).getBigUint64(9).toString();this.userMap_.has(u)&&(this.statReportReq.msg_net_stat_report.uint32_down_real_pkg++,this.statReportReq.msg_net_stat_report.uint32_down_recv_br+=i.byteLength,this.demuxPacket(i,this.userMap_.get(u),e&&r))})),e&&F(r,X(({timestamp:i,rtpTimestamp:o,seqNum:u,ssrc:p,data:l})=>{this.audioReceivedBuff.set(l),V._ReceivedRawAudioPacket(this.audioReceivedBuff.point,l.byteLength,i,o,u,p)}))}pullAudio({tinyId:e,writable:r}){let i=this.userMap_.get(e);i&&(i.audioPuller=new Lr(r.getWriter(),i.mainPuller.ssrc))}getAudioEnergy(e,r){yt.energys||(yt.energys=gc());let{energys:i}=yt;F(xe(e),Be(r),X(()=>{let o=i.getInt8(0);for(let u=1;u<5*o;u+=5)this.levelsMap.set(i.getUint32(u),i.getInt8(u+4));if(this.userMap_.size>0){let u=[...this.userMap_.values()];r.postMessage(u.map(p=>{let l=Math.min(100,(this.levelsMap.get(p.mainPuller.ssrc)||0)*2);return p.msg_audio_status.uint32_audio_level=l*bc/100>>0,{userId:p.userId,volume:l}}))}else r.postMessage([])}))}demuxPacket(e,r,i){let{aBlock:o,msg_audio_status:u}=r;o.received.next(!0),u.uint32_audio_total_bitrate+=e.byteLength<<3,u.uint32_audio_codec_bitrate=u.uint32_audio_total_bitrate-31,this.audioReceivedBuff.set(e);let p=Date.now(),l=p/1e3,m=p%1e3;if(i){let _=V._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),T=V.HEAPU8.slice(h,h+_);i.postMessage({timestamp:this.timestampBuff.getUint32(0),rtpTimestamp:this.timestampBuff.getUint32(4),seqNum:this.timestampBuff.getUint32(8),data:T,ssrc:r.mainPuller.ssrc},[T.buffer])}}else V._ReceivedAudioUdtPacket(this.audioReceivedBuff.point,e.length,l,m,r.mainPuller.ssrc)}};d(yt,"energys");var Gt=yt;var Os=mr(qt(),1),xs=Symbol("instance"),ap=Symbol("abortCtrl"),Hr=Symbol("cacheResult"),jt=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`}},rt=class extends Error{constructor(t,e,r){super(e),this.state=t,this.message=e,this.cause=r}};function Ec(n){return typeof n=="object"&&n&&"then"in n}var $t=new Map;function pe(n,t,e={}){return(r,i,o)=>{let u=e.action||i;if(!e.context){let l=$t.get(r)||[];$t.has(r)||$t.set(r,l),l.push({from:n,to:t,action:u})}let p=o.value;o.value=function(...l){let m=this;if(e.context&&(m=z.get(typeof e.context=="function"?e.context.call(this,...l):e.context)),m.state===t)return e.sync?m[Hr]:Promise.resolve(m[Hr]);m.state instanceof jt&&m.state.action==e.abortAction&&m.state.abort(m);let _=null;Array.isArray(n)?n.length==0?m.state instanceof jt&&m.state.abort(m):(typeof m.state!="string"||!n.includes(m.state))&&(_=new rt(m._state,`${m.name} ${u} to ${t} failed: current state ${m._state} not from ${n.join("|")}`)):n!==m.state&&(_=new rt(m._state,`${m.name} ${u} to ${t} failed: current state ${m._state} not from ${n}`));let h=x=>{if(e.fail&&e.fail.call(this,x),e.sync){if(e.ignoreError)return x;throw x}else return e.ignoreError?Promise.resolve(x):Promise.reject(x)};if(_)return h(_);let T=m.state,I=new jt(T,t,u);Yt.call(m,I);let U=x=>{var N;return m[Hr]=x,I.aborted||(Yt.call(m,t),(N=e.success)===null||N===void 0||N.call(this,m[Hr])),x},C=x=>(Yt.call(m,T,x),h(x));try{let x=p.apply(this,l);return Ec(x)?x.then(U).catch(C):e.sync?U(x):Promise.resolve(U(x))}catch(x){return C(new rt(m._state,`${m.name} ${u} from ${n} to ${t} failed: ${x}`,x instanceof Error?x:new Error(String(x))))}}}}var Tc=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(z.STATECHANGED,n,e,t),this.updateDevTools({value:n,old:e,err:t instanceof Error?t.message:String(t)})}var z=class n extends Os.default{constructor(t,e,r){super(),this.name=t,this.groupName=e,this._state=n.INIT,t||(t=Date.now().toString(36)),r?Object.setPrototypeOf(this,r):r=Object.getPrototypeOf(this),e||(this.groupName=this.constructor.name);let i=r[xs];i?this.name=i.name+"-"+i.count++:r[xs]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let t=Object.getPrototypeOf(this),e=$t.get(t)||[],r=new Set,i=[],o=[],u=new Set,p=Object.getPrototypeOf(t);$t.has(p)&&(p.stateDiagram.forEach(m=>r.add(m)),p.allStates.forEach(m=>u.add(m))),e.forEach(({from:m,to:_,action:h})=>{typeof m=="string"?i.push({from:m,to:_,action:h}):m.length?m.forEach(T=>{i.push({from:T,to:_,action:h})}):o.push({to:_,action:h})}),i.forEach(({from:m,to:_,action:h})=>{u.add(m),u.add(_),u.add(h+"ing"),r.add(`${m} --> ${h}ing : ${h}`),r.add(`${h}ing --> ${_} : ${h} \u{1F7E2}`),r.add(`${h}ing --> ${m} : ${h} \u{1F534}`)}),o.forEach(({to:m,action:_})=>{r.add(`${_}ing --> ${m} : ${_} \u{1F7E2}`),u.forEach(h=>{h!==m&&r.add(`${h} --> ${_}ing : ${_}`)})});let l=[...r];return Object.defineProperties(t,{stateDiagram:{value:l},allStates:{value:u}}),l}static get(t){let e;return typeof t=="string"?(e=n.instances.get(t),e||n.instances.set(t,e=new n(t,void 0,Object.create(n.prototype)))):(e=n.instances2.get(t),e||n.instances2.set(t,e=new n(t.constructor.name,void 0,Object.create(n.prototype)))),e}static getState(t){var e;return(e=n.get(t))===null||e===void 0?void 0:e.state}updateDevTools(t={}){Tc(n.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(t){Yt.call(this,t)}};z.STATECHANGED="stateChanged";z.UPDATEAFSM="updateAFSM";z.INIT="[*]";z.ON="on";z.OFF="off";z.instances=new Map;z.instances2=new WeakMap;var $e=class extends z{constructor(e){super(e.params.userId,"WebSocket");this.connectFSM=e;d(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",je((r,i)=>{e.onerror=o=>{e.onmessage=null,this.connectFSM.log_.error("websocket onerror",o),i(o.type)},e.onclose=o=>{e.onmessage=null,i(o),this.connectFSM.log_.info("websocket onclose",o),this.disconnect(o.reason,o.code)},e.onopen=o=>{console.timeEnd("WebSocket connect"),this.connectFSM.log_.info("websocket onopen")},e.onmessage=o=>{try{let u=JSON.parse(String(o.data));if(this.connectFSM.log_.info("websocket verify",u),u.err!==0)throw u.err;this.connectFSM.verify(u.verify,u.rebuild),this.ws=e,r(e);let p=this.connectFSM.createOputReceiver("w");e.onmessage=l=>p.write(l.data)}catch(u){i(u)}}},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,i){this.send(Nr(e,r,i||this.connectFSM.generateUUID()))}send(e){var r;this.state=="CONNECTED"&&((r=this.ws)==null||r.send(e))}};ce([pe(["DISCONNECTED",z.INIT],"CONNECTED")],$e.prototype,"connect",1),ce([pe("CONNECTED","DISCONNECTED",{sync:!0,ignoreError:!0})],$e.prototype,"disconnect",1),ce([pe([],z.INIT,{sync:!0})],$e.prototype,"close",1);var Rp=new Uint32Array([Date.now()]),Sc=F(mt(20),Ze(()=>performance.now()),We()),di=class{constructor(t){this.wt=t;d(this,"chunk",new Map);d(this,"timestamp",performance.now());d(this,"groupId");d(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),F(Sc,Mn(()=>this.chunk.size>0&&this.resentCount<20),Ue(Te(t,"DISCONNECTED")),X(e=>{e-this.timestamp>2*t.connectFSM.rtt+10&&(this.chunk.forEach((r,i)=>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)}},Ye=class extends z{constructor(e){super(e.params.userId,"WebTransport");this.connectFSM=e;d(this,"wt");d(this,"writer");d(this,"dw");d(this,"sentCache",new Map);d(this,"groupid",0);d(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:i,stream:o}=await Promise.race([(async()=>{await je(e.ready,r);let p=await je(e.createBidirectionalStream(),r),l=p.readable.getReader();return this.writer=p.writable.getWriter(),this.dw=e.datagrams.writable.getWriter(),je(l.read(),r).then(({value:m})=>(l.releaseLock(),{value:m,stream:p}))})(),new Promise((p,l)=>setTimeout(()=>l(new Error("WebTransport connect timeout")),1e3))]),u=JSON.parse(String.fromCharCode(...i));if(this.connectFSM.log_.info("WebTransport connect result:",u),u.err!==0)throw u.err;this.connectFSM.verify(u.verify,u.rebuild),this.wt=e,F(Te(this.connectFSM,ne[4099]),Ue(Te(this,"DISCONNECTED")),X(({data:p})=>{let l=p[0]&127,m=this.sentCache.get(l);m&&m.ack(p[1])})),Promise.race([e.datagrams.readable.pipeTo(new WritableStream(this.connectFSM.createOputReceiver("d"))),o.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,i){if(i||(i=this.connectFSM.generateUUID()),!this.wt)return new Error("WebTransport not connected");if(!te.unreliable){let I=Nr(e,r,i);return this.writer.write(I).then(()=>!0).catch(this.catchError)}let o=e>=255&&e<4095,u=JSON.stringify(r),p=0,l=u.length+(o?20:16),_=(l>65535?1:0)?7:5,h=Math.ceil(l/this.mtu),T=new di(this);console.debug("WebTransport send:",o?"ack":"",ne[e],i,"chunks:",h,T.groupId);for(let I=0;I<h;I++){let U=l-I*this.mtu,C=Math.min(this.mtu,U),x=new Uint8Array(_+4+C),N=ci(e,x.length-_,new DataView(x.buffer));if(x[0]|=2,x.set([1,2,(I==h-1?128:0)|T.groupId,I],N),N+=4,I==0){o&&(x.set([0,0,0,0],N),N+=4);for(let W=0;W<16;W++)x[N++]=i.charCodeAt(W)}for(let W=0;N<x.length;W++)x[N++]=u.charCodeAt(p++);T.chunk.set(I,x),this.send(x.buffer)}}async send(e){if(!(!this.wt||!this.dw)){if(e instanceof ArrayBuffer){if(!e.byteLength)throw vs}else{if(!e.length)throw vs;e=e.slice(0)}return this.dw.write(e).catch(this.catchError)}}catchError(e){}};ce([pe(["DISCONNECTED",z.INIT],"CONNECTED")],Ye.prototype,"connect",1),ce([pe("CONNECTED","DISCONNECTED",{sync:!0,ignoreError:!0})],Ye.prototype,"disconnect",1),ce([pe([],z.INIT,{sync:!0})],Ye.prototype,"close",1);var vs=new Error("WebTransport send empty datagram");var Ps=mr(qt(),1);var Fr=class extends Ps.EventEmitter{constructor(e,r,i="userId"){super();this.mySelfId=e;this._log=r;this.key=i;d(this,"userMap",new Map);d(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:i,tinyId:o,role:u}=e;if(this.userMap.has(r))return;let p={userId:i,tinyId:o,role:u===20?"anchor":"audience"};this.userMap.set(r,p),this.emit("1",p)}deleteUser(e,r){let i=this.userMap.get(e);if(!i)return;let o=`peer leave [${e}]`;Bt(r)||(o+=`:${Es[r]}`),this._log.info(o);let u=this.remotePublishedUserMap.get(e);if(u){let p=u.muteState;u.flag=0,this.emit("5",u.userId),this.deleteRemotePublishedUser(e),this.emit("6",{prevMuteState:p,muteState:u.muteState,flag:0})}this.userMap.delete(e),this.emit("2",i.userId)}setUserList(e){this.userMap.forEach(r=>{e.findIndex(i=>i[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 i=r[this.key];if(e.findIndex(o=>o[this.key]===r[this.key])<0){this._log.info(`remote [${i}] unpublish`);let o=r.muteState;r.flag=0,this.emit("5",r.userId),this.deleteRemotePublishedUser(i),this.emit("6",{prevMuteState:o,muteState:r.muteState,flag:0})}}),e.forEach(r=>{var _;let i=r[this.key];if(i===this.mySelfId){this.emit("7",r);return}let{flag:o,userId:u,tinyId:p}=r,l=ai(o,u),m=(_=this.remotePublishedUserMap.get(i))==null?void 0:_.muteState;if(m){let h=this.remotePublishedUserMap.get(i);h&&h.flag!==o&&(h.flag=o,this._log.info(`remote publish updated: ${JSON.stringify(h.muteState)}`),this.emit("6",{prevMuteState:m,muteState:l,flag:o}))}else this._log.info(`remote publish. state: ${JSON.stringify(l)}`),this.addUser({userId:u,tinyId:p,role:20}),this.emit("3",r),this.emit("6",{prevMuteState:ai(0,u),muteState:l,flag:o})})}clear(){this.userMap.clear(),this.remotePublishedUserMap.clear()}};var yc=0;var pi=function(){return Date.now()+yc},Ns=function(){let n=new Date;return n.setTime(pi()),n.toLocaleString()},Ds=function(n){let t=String(n.getMilliseconds());return"padStart"in String.prototype&&(t=t.toString().padStart(3,"0")),`${n.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")}:${t}`};function ws(n){let t=Ac(n);return t==null?void 0:t.busiBuff}function Ac(n){try{let t={},e=0;t.totalLength=oe(n,e),e+=4,t.version=oe(n,e),e+=4,t.encryption=ni(n,e),e+=1,t.uinType=ni(n,e),e+=1,t.uinLength=oe(n,e),e+=4,t.uin=t.uinLength>4?Et(n,e,t.uinLength-4):"",e+=t.uinLength-4;let r=n.slice(e);if(t.encryption===2){let i=new Uint8Array(16).fill(0);n=Ic(r,i),t.decrypted=!0,e=0}else n=r,e=0;return t.rspHeadLength=oe(n,e),e+=4,t.seqNo=oe(n,e),e+=4,t.retCode=oe(n,e),e+=4,t.retStrLength=oe(n,e),e+=4,t.retStr=t.retStrLength?Et(n,e,t.retStrLength-4):"",e+=t.retStrLength-4,t.serviceCmdLength=oe(n,e),e+=4,t.serviceCmd=t.serviceCmdLength?Et(n,e,t.serviceCmdLength-4):"",e+=t.serviceCmdLength-4,t.cookieLength=oe(n,e),e+=4,t.cookie=t.cookieLength?Et(n,e,t.cookieLength-4):"",e+=t.cookieLength-4,t.flag=oe(n,e),e+=4,t.busiBuffLength=oe(n,e),e+=4,t.busiBuff=t.busiBuffLength?Et(n,e,t.busiBuffLength-4):"",e+=t.busiBuffLength-4,t}catch(t){}}function Cs(n,t){let e=n[0]<<24|n[1]<<16|n[2]<<8|n[3],r=n[4]<<24|n[5]<<16|n[6]<<8|n[7];e=e>>>0,r=r>>>0;let i=Or*vr>>>0;for(let o=0;o<vr;o++)r-=(e<<oi)+t[2]^e+i^(e>>>5)+t[3],r=r>>>0,e-=(r<<oi)+t[0]^r+i^(r>>>5)+t[1],e=e>>>0,i-=Or,i=i>>>0;return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,e&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255])}function Ic(n,t){let e=0,r=new Uint8Array(8).fill(0),i=new Uint8Array(n.slice(0,8)),o=Cs(i,t),u=o[0]&7,p=n.length-1-u-Tt-St,l=new Uint8Array(p),m=0,_=r,h=n.slice(0,8);e=8;let T=1;T+=u;for(let U=1;U<=Tt;)if(T<8)T++,U++;else if(T===8){let C=fi(n,e,_,h,o,t);_=C.ivPreCrypt,h=C.ivCurCrypt,o=C.debiBuf,e=C.bufPos,T=0}let I=p;for(;I>0;)if(T<8)l[m++]=o[T]^_[T],T++,I--;else if(T===8){let U=fi(n,e,_,h,o,t);_=U.ivPreCrypt,h=U.ivCurCrypt,o=U.debiBuf,e=U.bufPos,T=0}for(let U=1;U<=St;)if(T<8)o[T]^_[T],T++,U++;else if(T===8){if(e>=n.length)break;let C=fi(n,e,_,h,o,t);if(!C.success)break;_=C.ivPreCrypt,h=C.ivCurCrypt,o=C.debiBuf,e=C.bufPos,T=0}return l}function fi(n,t,e,r,i,o){if(t+8>n.length)return{success:!1};let u=new Uint8Array(r),p=n.slice(t,t+8),l=new Uint8Array(8);for(let _=0;_<8;_++)l[_]=i[_]^p[_];let m=Cs(l,o);return{success:!0,ivPreCrypt:u,ivCurCrypt:p,debiBuf:m,bufPos:t+8}}var Ls=typeof TextDecoder!="undefined"?new TextDecoder:void 0;function Ms({url:n,body:t,method:e="POST",timeout:r,priority:i}){return new Promise((o,u)=>{if("fetch"in window)return fetch(n,{method:e,body:t,priority:i}).then(l=>l.clone().json().then(m=>({data:m}),()=>l.arrayBuffer().then(m=>({data:ws(new Uint8Array(m))||(Ls?Ls.decode(m):m)})))).then(o,u);let p=new XMLHttpRequest;p.onreadystatechange=()=>{if(p.readyState===4)if(p.status>=200&&p.status<300)try{let l=JSON.parse(p.response);o({data:l})}catch(l){o({data:p.response})}else u({status:p.status,statusText:p.statusText||"request failed!"})},p.timeout=r||5e3,p.open(e,n,!0),p.send(t)})}var Rc=Object.prototype.hasOwnProperty;var Rt=n=>typeof n=="function",ks=n=>typeof n=="undefined";var Bs=n=>typeof n=="boolean";var Uc=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 Vs(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(Uc(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(Rc.call(n,t))return!1;return!0}}return!1}var xc=0,Oc=1,Hs=2;function vc({retryFunction:n,settings:t,onError:e,onRetrying:r,onRetryFailed:i,onRetrySuccess:o,context:u}){return function(...p){let{retries:l=5,timeout:m=1e3}=t,_=0,h=-1,T=xc,I=async(U,C)=>{let x=u||this;try{let N=await n.apply(x,p);_>0&&o&&o.call(this,_),_=0,U(N)}catch(N){let W=()=>{clearTimeout(h),_=0,T=Hs,C(N)},Se=()=>{T!==Hs&&_<(Rt(l)?l():l)?(_++,T=Oc,Rt(r)&&r.call(this,_,W),h=window.setTimeout(()=>{h=-1,I(U,C)},Rt(m)?m(_):m)):(W(),Rt(i)&&i.call(this,N))};Rt(e)?e.call(this,{error:N,retry:Se,reject:C,retryFuncArgs:p,retriedCount:_}):Se()}};return new Promise(I)}}var Fs=vc;var Kt=class{constructor(t){d(this,"userId");d(this,"remoteUserId");d(this,"id");d(this,"sdkAppId");d(this,"type");d(this,"isLocal");this.id=t.id,this.userId=t.userId,this.sdkAppId=t.sdkAppId,this.remoteUserId=t.remoteUserId,this.isLocal=Bs(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}`:""}]`),It.log(t,e,ks(this.userId)||Vs(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 we=typeof navigator=="undefined"?"":navigator.userAgent,M=n=>new RegExp(n,"i").test(we),re=n=>{if(M(n)){let t=new RegExp(`${n}\\/([\\d.]+)`),e=we.match(t);if(e&&e[1])return e[1]}return""},qr=n=>{if(M(n)){let t=new RegExp(`${n}\\/(\\d+)`),e=we.match(t);if(e&&e[1])return parseFloat(e[1])}return NaN},qs=/AppleWebKit\/([\d.]+)/i.exec(we),Pc=qs?parseFloat(qs[1]):NaN,Gs=M("iPad"),js=typeof navigator!="undefined"&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&M("Macintosh"),$s=M("iPhone")&&!Gs,Nc=M("iPod"),Wr=$s||Gs||Nc||js,Ut=M("Android"),Ys=function(){if(Ut){let n=we.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}(),rf=Ut&&M("webkit")&&Ys<2.3,nf=Ut&&Ys<5&&Pc<537,Dc=M("Firefox"),wc=re("Firefox"),sf=qr("Firefox"),Ks=M("Edge"),Cc=re("Edge"),Js=M("Edg"),Lc=re("Edg"),of=qr("Edg"),Xs=M("SogouMobileBrowser"),Mc=re("SogouMobileBrowser"),Qs=M("MetaSr\\s"),kc=re("MetaSr\\s"),nt=M("TBS"),Bc=re("TBS"),zs=M("XWEB"),Vc=re("XWEB"),af=M("MSIE\\s8\\.0"),Hc=M("MSIE\\/\\d+"),uf=function(){if(Hc){let n=/MSIE\s(\d+)\.\d/.exec(we),t=n&&parseFloat(n[1]);return!t&&/Trident\/7.0/i.test(we)&&/rv:11.0/.test(we)&&(t=11),t}return NaN}(),Fc=M("(micromessenger|webbrowser)"),qc=re("MicroMessenger"),_i=!nt&&M("MQQBrowser")&&M("COVC"),hi=!nt&&M("MQQBrowser")&&!M("COVC"),Ws=hi||_i?re("MQQBrowser"):"",Zs=!nt&&M(" QQBrowser"),Wc=re(" QQBrowser"),eo=!nt&&M("QQBrowserLite"),Gc=re("QQBrowserLite"),to=!nt&&M("MQBHD"),jc=re("MQBHD"),cf=M("Windows"),lf=!Wr&&M("MAC OS X"),mf=!Ut&&M("Linux"),df=M("CrOS"),pf=M("MicroMessenger"),ff=M("UCBrowser"),_f=M("Electron"),ro=M("MiuiBrowser"),$c=re("MiuiBrowser"),no=M("HuaweiBrowser"),hf=M("Huawei")||M("HUAWEI"),bf=M("Honor")||M("HONOR"),Yc=re("HuaweiBrowser"),io=M("SamsungBrowser"),Kc=re("SamsungBrowser"),so=M("HeyTapBrowser"),Jc=re("HeyTapBrowser"),oo=M("VivoBrowser"),Xc=re("VivoBrowser"),gf=M("OpenHarmony"),Ef=re("OpenHarmony"),Qc=()=>qr("Chrome"),ao=M("Chrome"),zc=!Ks&&!Qs&&!Xs&&!nt&&!zs&&!Js&&!Zs&&!ro&&!no&&!io&&!so&&!oo&&ao,uo=M("HeadlessChrome"),Tf=Qc(),Zc=re("Chrome"),Sf=qr("Electron"),el=!ao&&!hi&&!_i&&!eo&&!to&&M("Safari");var co=re("Version"),yf=/Android.*(wv|.0.0.0)/.test(we),lo=(()=>{if(js)return co;if(Wr){let n=we.match(/OS (\d+)_(\d+)/i);if(n&&n[1]){let t=n[1];return n[2]&&(t+=`.${n[2]}`),t}}return""})();var Af=Number(lo.split(".")[0]);var If=(()=>{let n=Number(lo.split(".")[0]);return n===14||n===13})(),Rf=M("CriOS");var Uf=typeof location=="undefined"?!1:location.protocol==="file:"||location.hostname==="localhost"||location.hostname==="127.0.0.1";var xf=tl();function tl(){let n=new Map([[Dc,["Firefox",wc]],[Js,["Edg",Lc]],[zc,["Chrome",Zc]],[el,["Safari",co]],[nt,["TBS",Bc]],[zs,["XWEB",Vc]],[Fc&&$s,["WeChat",qc]],[Zs,["QQ(Win)",Wc]],[hi,["QQ(Mobile)",Ws]],[_i,["QQ(Mobile X5)",Ws]],[eo,["QQ(Mac)",Gc]],[to,["QQ(iPad)",jc]],[ro,["MI",$c]],[no,["HW",Yc]],[io,["Samsung",Kc]],[so,["OPPO",Jc]],[oo,["VIVO",Xc]],[Ks,["EDGE",Cc]],[Xs,["SogouMobile",Mc]],[Qs,["Sogou",kc]]]),t="unknown",e="unknown";return n.has(!0)&&([t,e]=n.get(!0)),{name:t,version:e}}var mo=mr(qt(),1),rl=new mo.default,Oe=rl;var Gr=(R=>(R.ROOM_DESTROY="1",R.JOIN_START="21",R.JOIN_SCHEDULE_SUCCESS="22",R.JOIN_SIGNAL_CONNECTION_START="23",R.JOIN_SIGNAL_CONNECTION_END="24",R.JOIN_SEND_CMD="25",R.JOIN_RECEIVED_CMD_RES="26",R.JOIN_SUCCESS="27",R.JOIN_FAILED="28",R.LEAVE_START="51",R.LEAVE_SEND_CMD="52",R.LEAVE_SUCCESS="53",R.PUBLISH_START="61",R.SEND_FIRST_VIDEO_FRAME="62",R.PUBLISH_FAILED="63",R.SUBSCRIBE_START="81",R.SUBSCRIBE_SUCCESS="82",R.SUBSCRIBE_FAILED="84",R.UNSUBSCRIBE_SUCCESS="83",R.LOCAL_TRACK_CAPTURE_START="101",R.LOCAL_TRACK_CAPTURE_SUCCESS="102",R.LOCAL_TRACK_CAPTURE_FAILED="103",R.LOCAL_TRACK_PUBLISHED="104",R.LOCAL_TRACK_UNPUBLISHED="105",R.LOCAL_TRACK_REPLACED="106",R.SWITCH_DEVICE_SUCCESS="107",R.TRACK_MUTED="108",R.TRACK_UNMUTED="109",R.REMOTE_TRACK_SUBSCRIBED="110",R.REMOTE_TRACK_UNSUBSCRIBED="111",R.LOCAL_TRACK_RECAPTURE="112",R.LOCAL_AUDIO_STARTED="113",R.LOCAL_AUDIO_STOPPED="114",R.REMOTE_AUDIO_STARTED="115",R.REMOTE_AUDIO_STOPPED="116",R.PLAY_TRACK_START="151",R.PLAYER_STATE_CHANGED="152",R.VIDEO_LOADED_DATA="153",R.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",R.AUDIO_CONTEXT_LONG_SUSPENDED="155",R.SIGNAL_CONNECTION_STATE_CHANGED="201",R.PEER_CONNECTION_STATE_CHANGED="202",R.SINGLE_CONNECTION_STAT="203",R.SPC_RECONNECTED="204",R.HEARTBEAT_REPORT="251",R.RECEIVED_PUBLISHED_USER_LIST="252",R.REMOTE_PUBLISH_STATE_CHANGED="253",R.AUDIO_LEVEL_INTERVAL="260",R.NETWORK_QUALITY="261",R.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",R.QUALITY_LIMITATION_CHANGED="263",R.LOG="264",R.AUDIO_PROCESSOR_DEBUG="265",R.SSO_SWITCH="266",R.SWITCH_ROOM_START="401",R.SWITCH_ROOM_SUCCESS="407",R.SWITCH_ROOM_FAILED="408",R))(Gr||{});var Ke=Gr;var bi=class{constructor(){d(this,"enable",!1);d(this,"ssoFailCount",0);Oe.on("22",({schedule:t})=>{var e;(e=t==null?void 0:t.config)!=null&&e.sso&&Oe.emit("266",{enable:!0})}),Oe.on("266",({enable:t})=>{this.enable=t})}handleUploadFailed(){this.ssoFailCount++,this.ssoFailCount>3&&Oe.emit("266",{enable:!1})}},gi=new bi;var nl="%cTRTC%c%s",il="padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;",sl="display: inline",jr=class jr{constructor(){d(this,"_isEnableUploadLog",!0);d(this,"_localJoinedUser",new Map);d(this,"_queue",[]);d(this,"_timeoutId",-1);d(this,"_logLevel",1);d(this,"_logLevelToUpload",2);!ds&&!Ir&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&this._timeoutId!==-1}installEvents(){Oe.on(Ke.JOIN_SCHEDULE_SUCCESS,({schedule:t})=>{var e;(e=t==null?void 0:t.config)!=null&&e.logLevelToUpload&&ke[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)}),Oe.on(Ke.JOIN_SUCCESS,({room:t})=>{this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()}),Oe.once(Ke.JOIN_FAILED,()=>{this.startUpload()}),Oe.on(Ke.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:i,sdkAppId:o})=>{t.map.has(i)?t.map.get(i).logs.push(r):t.map.set(i,{userId:i,sdkAppId:o,logs:[r]})});else if(kt(r.userId)&&ys(r.sdkAppId)){let{userId:i,sdkAppId:o}=r;t.map.has(i)?t.map.get(i).logs.push(r):t.map.set(i,{userId:i,sdkAppId:o,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 i=[...t.values()];for(let o=0;o<i.length;o++){let{userId:u,sdkAppId:p,logs:l}=i[o],m={timestamp:Ns(),sdkAppId:String(p),userId:u,version:et,log:l.map(T=>T.log).join(`
2
- `)},_=JSON.stringify(m),h=gi.enable?As(m,2002,p):_;await this.uploadLogWithRetry(h,p,h instanceof Uint8Array,_),l.forEach(T=>T.uploaded=!0)}}catch(i){}let r=e.filter(i=>!i.uploaded);r.length>0&&(this._queue=r.concat(this._queue))}uploadLogWithRetry(t,e,r,i){return Fs({retryFunction:()=>Ms({url:Ss(e,_s.LOG),body:t,timeout:5e3,priority:"low"}).then(o=>{r&&o.data!=="ok"&&(gi.handleUploadFailed(),this.uploadLogWithRetry(i,e,!1,i))}),settings:{retries:3,timeout:2e3},onError:({retry:o})=>{o()}})()}getPrefix(t){let e=new Date;return e.setTime(pi()),`[${Ds(e)}] <${ke[t]}>`}getLogLevel(){return this._logLevel}setLogLevel(t){Bt(ke[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(kt(t))return t;try{return t instanceof Error?t.toString():JSON.stringify(t)}catch(e){return""}}addLogToQueue(t,e,r=!0,i,o){let u={log:e.reduce((p,l)=>`${p} ${this.logChunkToString(l)}`.trim(),""),level:t,userId:i,sdkAppId:o,forAllJoinedClients:r};Oe.emit(Ke.LOG,{log:u}),this._isEnableUploadLog&&t>=this._logLevelToUpload&&this._queue.push(u)}log(t,e,r=!0,i,o){var p;if(e.unshift(this.getPrefix(t)),this.addLogToQueue(t,e,r,i,o),t<this._logLevel)return;let u=((p=ke[t])==null?void 0:p.toLowerCase())||"info";jr.PRINT_LOG_TAG?console[u](nl,il,sl,...e):console[u](...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 Kt(t)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),r=e?Number(e):-1;ke[r]&&(this._logLevelToUpload=r)}getQueue(){return this._queue}};d(jr,"PRINT_LOG_TAG",!(Wr||Ut||uo));var Ei=jr,It=new Ei;function po(n,t=1,e=1){return n<=1?e:po(n-1,e,t+e)}function cl(n){return n>8?30*1e3:po(n)*1e3}function ll(n,t){return{userId:t,hasAudio:!!(n&ht),hasVideo:!!(n&_t),hasAuxiliary:!!(n&Ur),hasSmall:!!(n&Rr),audioMuted:!!(n&bt),videoMuted:!!(n&gt),audioAvailable:!!(n&ht)&&!(n&bt),videoAvailable:!!(n&_t)&&!(n&gt)}}var Ti=class{constructor(t){this.connect=t;d(this,"publishReq");d(this,"recovering",!1);d(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}}},ge=class ge extends z{constructor(e,r,i){super(i.joinReq.roomid,"Connection");this.id=e;this.port=r;d(this,"signalInfo_");d(this,"reqUser_");d(this,"joinReq");d(this,"frameWorkType");d(this,"userManager");d(this,"joinRes");d(this,"statReportReq");d(this,"qualityReportReq");d(this,"wFSM");d(this,"rtt",50);d(this,"recovery",new Ti(this));d(this,"reqPromise",new Map);d(this,"rebuild");d(this,"osName");d(this,"browserInfo");d(this,"tinyId_",new B(32));d(this,"tinyId");d(this,"domains");d(this,"log_");d(this,"params");d(this,"proxy_ws");d(this,"proxy_wt");d(this,"proxy_cloud");d(this,"proxy_unified");d(this,"env");d(this,"wh");d(this,"abortCtrl",new AbortController);d(this,"firstReceiveUserlist");d(this,"connectParams");d(this,"selectDomain",0);d(this,"selectCloudDomain",0);d(this,"abort",this.abortCtrl.abort.bind(this.abortCtrl));d(this,"reconnectedOB",Te(this,"RECONNECTED"));d(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,i),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_=It.createLogger({id:`wc${e}`,userId:this.params.userId,sdkAppId:this.params.sdkAppId}),this.proxy_unified?te.useWt=!1:(this.proxy_ws||this.proxy_wt)&&(te.useWt=!!this.proxy_wt),te.useWt?this.wFSM=new Ye(this):this.wFSM=new $e(this),this.userManager=new Fr("",this.log_,"tinyId");let o=u=>this.userManager.on(u,p=>this.postMessage({cmd:u,payload:p}));this.userManager.on("3",({flag:u,userId:p,tinyId:l})=>{let m={flag:u,userId:p,tinyId:l,get muteState(){return ll(this.flag,this.userId)},subscribe:0,removing:!1};this.log_.debug("create user",m),this.postMessage({cmd:"3",payload:m}),this.userManager.addRemotePublishedUser(new Mr(m,this))}),o("6"),o("5"),o("1"),o("2"),o("7"),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=(i,o=!1)=>u=>{if(this.aborted||typeof u=="number")throw u;return this.selectDomain=i,this.wFSM=o?new Ye(this):new $e(this),console.warn(u),console.warn("downgrade to",o?"WebTransport":"WebSocket",this.selectDomain?"\u5907\u7528\u57DF\u540D":"\u4E3B\u57DF\u540D"),this.wFSM.connect()};return te.useWt&&(this.proxy_ws||!this.proxy_wt)&&(e=e.catch(r(0))),!this.proxy_wt&&!this.proxy_ws&&(e=e.catch(r(1,te.useWt)),te.useWt&&(e=e.catch(r(1)))),e}async joinRoom(){let{dataport:e,stunport:r,relayip:i,socketid:o,checkSigSeq:u}=this.signalInfo_,p=await this.sendReq(0,Object.assign(this.joinReq,{dataport:e,stunport:r,relayip:i,socketid:o,checkSigSeq:u}));if(p.err===0)this.setJoinRes(p.data);else throw p.err;return p}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(tt(),"retry",e),e>gs){this.close();return}let r=Ge(cl(e));F(e?os(r,this.reconnectOB):r,_r(1),Ue(this.reconnectedOB),X(i=>{typeof i!="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 i=this.generateUUID();return await this.wFSM.sendReq(e,r,i),je((o,u)=>this.reqPromise.set(i,{resolve:o,reject:u,startTime:Date.now()}),this.abortCtrl.signal,o=>(console.log("abort",ne[e]),{err:o}))}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=>{V._CreateUdtPacketizer(e.roomid,this.tinyId_.point,e.locationid,r,V.udtver,this.id)}),this.wFSM.sendReq(6,{})}onReceive(e,r,i){let o="",u=0,p=new DataView(i.buffer,i.byteOffset);r<255&&(u=p.getUint32(0),i=i.subarray(4)),r<4095&&(o=String.fromCharCode(...i.subarray(0,16)),i=i.subarray(16));let l=i;if(!o)p=new DataView(i.buffer,i.byteOffset,i.byteLength);else{let _="";for(let h=0,T=i.length,I=32768;h<T;h+=I)_+=String.fromCharCode.apply(null,i.subarray(h,Math.min(h+I,T)));if(u)l=_;else try{l=JSON.parse(_)}catch(h){l=_}}let m=ne[r];switch(r){case 259:this.joinRes&&this.wFSM.sendReq(r,{tinyid:this.joinRes.tinyid}),console.debug(e,"receive:",m,o,l);break;case 256:l.userlist.forEach(x=>{if(this.userManager.addUser({userId:x.userid,tinyId:x.srctinyid,role:x.role}),this.joinRes&&x.srctinyid!=this.joinRes.tinyid&&this.userManager.userMap.has(x.srctinyid)){let N=this.userManager.userMap.get(x.srctinyid);this.sendSubscribe(N)}}),this.log_.info(e,"receive:",m,o,l),this.wFSM.sendReq(r,{count:this.userManager.userMap.size});break;case 257:this.userManager.deleteUser(l.userlist.srctinyid),this.log_.info(e,"receive:",m,o,l),this.wFSM.sendReq(r,{count:this.userManager.userMap.size});break;case 6:this.userManager.setUserList(l.userlist.map(x=>({userId:x.userid,tinyId:x.srctinyid,role:x.role})));break;case 255:this.wFSM.sendReq(r,{count:this.userManager.userMap.size});{let x=l.userlist.map(N=>({userId:N.userid,tinyId:N.srctinyid,flag:N.flag,terminalType:N.terminaltype}));this.firstReceiveUserlist||(this.firstReceiveUserlist=!0,this.postMessage({cmd:Ke.RECEIVED_PUBLISHED_USER_LIST,payload:{publishedUserList:x}})),this.userManager.setRemotePublishedUserList(x),this.recovery.recovering&&this.recovery.recoverRemote(this.userManager.remotePublishedUserMap)}break;case 4100:this.rtt=p.getUint32(4),console.debug(e,"receive:",m,o,l,this.rtt);let{dv:_,writeData:h}=Ht(4101,8);h(i.subarray(0,4)),this.send(_.buffer);break;case 12:this.reqPromise.forEach(x=>{Date.now()-x.startTime>5e3&&(x.reject(new Error("heartbeat timeout")),this.reqPromise.delete(x.uuid))}),self.postMessage({type:"glog",payload:{heartbeatReceive:1}});case 11:case 260:console.debug(e,"receive:",m,o,l);case 7:case 4095:break;case 4096:case 4097:{let x=i.length;this.statReportReq.stat.msg_net_stat_report.uint32_down_real_pkg++,this.statReportReq.stat.msg_net_stat_report.uint32_down_recv_br+=x<<3;let N=p.getBigUint64(9).toString(),W=this.userManager.getPublishedUser(N);W?r===4096?(W.mainPuller.videoStatus.uint32_video_receive||console.timeLog(`${W.userId}big`,"first video data"),W.mainPuller.demuxPacket(i)):(W.screenPuller.videoStatus.uint32_video_receive||console.timeLog(`${W.userId}aux`,"first video data"),W.screenPuller.demuxPacket(i)):console.warn(e,"receive:",m,o,l,"user not found")}break;case 4102:case 4103:case 4099:break;case 4103:V.HEAPU8.set(i,B.global.point+8);let T=V._ParseUdtMousePacket(B.global.point+8,i.length,B.global.point),I=i.subarray(T),U=B.global.getBigUint64(0).toString(),C=this.userManager.userMap.get(U);C&&this.postMessage({cmd:"layerData",payload:{userId:C.userId,tinyId:U,layerData:I}}),console.debug(e,"receive:",m,T,l,U,I);break;case 4098:{let x=p.getUint8(8);for(let N=9;N<i.length;N+=6){let W=p.getUint32(N),Se=p.getUint16(N+4);for(let ye=0;ye<=16;ye++){if(ye>0&&(Se>>16-ye&1)==0)continue;let Ae=V._GetRetransPacket(x,W+ye,B.global.point,this.id),ie=B.global.getUint32(0),fe=V.HEAPU8.subarray(ie,ie+Ae);Ae>0&&this.send(fe)}}}break;case 1:this.log_.info(e,"receive:",m,o,l),l>0&&l!==3&&(this.postMessage({cmd:"banned",payload:l}),this.close());break;case 258:this.log_.info(e,"receive:",m,o||"",l);break;default:this.log_.info(e,"receive:",m||r,o||"",l)}this.reqPromise.has(o)&&(u&&this.log_.warn(u,l,o),this.reqPromise.get(o).resolve({err:u,data:l,uuid:o}),this.reqPromise.delete(o)),this.emit(m,o?{uuid:o,err:u,data:l}:{data:l})}sendSubscribe(e){let r=e.subscribe;if(r==0)return;let i={mediaType:r,mediaDescription:{audioParam:r&1?{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]}:void 0,videoParam:[4,8,2].filter(o=>r&o).map(o=>({mediaType:o,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]}))},userId:e.userId,srctinyid:e.tinyId};this._sendReq(4,i)}createOputReceiver(e){return new me(this.unMarshal(e))}*unMarshal(e){let r=null,i=new Map;for(;;){let o=0,u=0;try{r=yield 1;let p=r[0]>>4,l=r[0]&2,m=r[0]&1;r=yield 4+m*2;let _=new DataView(r.buffer,r.byteOffset);if(u=_.getUint16(0),o=m==1?_.getUint32(2):_.getUint16(2),r=yield o,l){let h=r[0]&63,T=r[1],I=r.subarray(2,2+T);switch(h){case 1:let U=I[0]>>7,C=I[0]&127,x=I[1],{dv:N,write8:W}=Ht(4099,2);W(C),W(x),this.send(N.buffer);let Se=C%64;for(let Ae=0;Ae<64;Ae++){let ie=C-Ae;ie<0&&(ie+=64);let fe=Se-Ae;fe<0&&(fe+=64),i.has(fe)&&i.get(fe).groupId!=ie&&i.delete(fe)}let ye=i.get(Se);if(ye||i.set(Se,ye=new Si(C)),r=ye.push(x,r.slice(2+T),U!=0),r)i.delete(Se);else continue}}this.onReceive(e,u,r)}catch(p){this.log_.error(e,p,o,u,r)}}}generateUUID(){return"xxxxxxxxxxxxxxxx".replace(/[xy]/g,e=>{let r=Math.random()*16|0;return(e=="x"?r:r&3|8).toString(16)})}};d(ge,"JOINED","joined"),d(ge,"CLOSED","closed"),ce([pe(z.INIT,"CONNECTED")],ge.prototype,"connect",1),ce([pe("CONNECTED",ge.JOINED)],ge.prototype,"joinRoom",1),ce([pe("RECONNECTED",ge.JOINED,{fail(){this.close()}})],ge.prototype,"rejoinRoom",1),ce([pe("DISCONNECTED","RECONNECTED")],ge.prototype,"reconnect",1),ce([pe([],"DISCONNECTED",{sync:!0})],ge.prototype,"disconnect",1),ce([pe([],ge.CLOSED,{sync:!0})],ge.prototype,"close",1);var Je=ge,Si=class{constructor(t){this.groupId=t;d(this,"chunks",[]);d(this,"totalLen",0);d(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 o=0;o<this.chunks.length;o++)if(!this.chunks[o])return null;let i=new Uint8Array(this.totalLen);for(;this.chunks.length;){let o=this.chunks.pop();i.set(o,this.totalLen-=o.length)}return i}return null}};var Jt=class extends be{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:i}=t,o={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(u=>({userid:u.userId,width:u.width,height:u.height,locationX:u.locationX,locationY:u.locationY,zOrder:u.zOrder,streamType:u.streamType,inputType:u.inputType})),outputParam:{streamId:i.streamId,streamType:i.streamType,videoWidth:i.width,videoHeight:i.height,videoBitrate:i.videoBps,videoFramerate:i.fps,vidoeGOP:i.gop,audioSampleRate:i.audioSampleRate,audioBitrate:i.audioBps,audioChannels:i.audioChannels,backgroundColor:i.backgroundColor,backgroundImage:i.backgroundImg,extraInfo:i.extraInfo,VCodec:i.videoCodec,ACodec:i.audioCodec}};return this.send(15,o).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 ml=1200;var dl=31,pl=6,fl=6;var fo={1:1,audio:1,video:4,2:4,auxVideo:2,7:2,3:8};var D_=Date.now(),w_=dl+pl+6+fl+ml+1;var Xt=class extends be{constructor(){super(...arguments);d(this,"videoEncBuffer_",new B(1920*1080*3>>1));d(this,"videoStats",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0});d(this,"audioStats",{bytesSent:0,packetsSent:0});d(this,"videoTypeIndexMap",new Map([[2,0]]));d(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:i,index:o},u,p){var I;let l=new B(e*r*2),m=U=>{this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_level=U.volume*1e8/100>>0;let{data:C}=U,x=C.length;l.set(C),this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_enc_br+=x<<3,this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_frame_interval++,this.audioStats.packetsSent++;let N=V._PacketizeAudioUdt(l.point,x,U.timestamp,e,r,U.energy,B.global.point,B.global.size,this.io.id,!!p);if(N<=0){console.warn("audio pack len is 0");return}this.io.send(B.global.uint8Array(N)),this.audioStats.bytesSent+=N,this.statReportReq.msg_audio_stat_report.msg_audio_send_stat.uint32_audio_send_br+=N<<3,this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_receive++},_=U=>{l.free(),this.send(3,{mediaType:1})},h=new MessageChannel;(I=this.io.wh.playPort)==null||I.postMessage({cmd:"pushAudio",payload:{numberOfChannels:r,bitrate:i},encrypt:!!p,index:o},[h.port2,u.port]);let T=Vt(h.port1);p&&F(T,X()),F(p||T,X(m,_,_))}createSelectAbilityOb(e,r){let i=r.bitrate;return F(this.createResposeOb(259),cs(()=>Ge(2e3)),Ze(o=>{var u;return(u=o.data.ability.rpt_msg_video_control_info)==null?void 0:u.find(p=>p.uint32_video_type===e)}),dt(o=>{if(!o)return!1;let u=o.uint32_video_enc_br,p=u*Math.pow(1-this.qualityReport.msg_up_stream_info.msg_network_status.uint32_lost/100,2),l=Math.min(i,p);o.uint32_video_enc_br=l,this.glog({[`confBr${e}`]:[u,p,l]});let m=!1;return((h,T)=>{o[T]&&o[T]!==r[h]&&(m=!0,r[h]=o[T])})("bitrate","uint32_video_enc_br"),m}),Yn(r))}pushVideo({profile:{width:e,height:r,frameRate:i,bitrate:o},type:u,trackType:p,crypto:l},m){this.videoStats.frameWidth=e,this.videoStats.frameHeight=r;let _=0,h=fo[u];this.videoTypeIndexMap.has(u)?_=this.videoTypeIndexMap.get(u):(_=this.statReportReq.rpt_msg_video_stat_report.length,this.requestTypeMap.set(_,u===7?4097:4096),this.videoTypeIndexMap.set(u,_),this.statReportReq.rpt_msg_video_stat_report.push({uint32_video_type:u,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:u,uint32_video_codec_type:0,uint32_video_decode_frame:0,uint32_video_total_frame:0,uint32_video_width:e,uint32_video_height:r}));let T={width:e,height:r,bitrate:o*1e3,framerate:i};Object.assign(this.qualityReport.msg_up_stream_info.msg_video_status[_],{uint32_video_width:e,uint32_video_height:r});let I=0,U=!1,C=N=>{this.send(3,{mediaType:h})};F(this.createSelectAbilityOb(u,T),X(()=>{m.postMessage(T)}));let x=m;p!="camera"&&(this.io.log_.info(`push ${p} track`),x=ss(m,F(m,ms(2e3),Kn(N=>(this.io.log_.warn("start push last video frame"),F(xe(2e3),Yn(N),Ue(m),Ar({complete:()=>this.io.log_.warn("stop push last video frame")})))),Be(m)))),F(x,X(N=>{let W=this.getVideoStatus(_);W.uint32_video_total_frame++,I++,this.videoStats.framesSent++,W.uint32_video_capture_fps++,I%300==0&&m.postMessage(260),this.handleVideoEncoded(N,u,l)},C,C)),F(this.createResposeOb(260),Be(m),X(()=>m.postMessage(260)))}getVideoStatus(e){return this.qualityReport.msg_up_stream_info.msg_video_status[e]}handleVideoEncoded(e,r,i){let{chunk:o,timestamp:u}=e;this.videoStats.framesEncoded++;let p=this.videoTypeIndexMap.get(r),l=this.getVideoStatus(p);l.uint32_video_decode_frame++,l.uint32_video_codec_fps++,l.uint32_video_enc_fps++,this.statReportReq.rpt_msg_video_stat_report[p].msg_video_enc_stat.uint32_video_enc_fps++;let m="byteLength"in o?o.byteLength:o.data.length;if(this.statReportReq.rpt_msg_video_stat_report[p].msg_video_enc_stat.uint32_video_enc_br+=m<<3,m>this.videoEncBuffer_.size){console.log("buffer too small!");return}"byteLength"in o?o.copyTo(this.videoEncBuffer_.uint8Array(m)):this.videoEncBuffer_.set(o.data),B.global.fill();let _=V._PacketizeVideoUdt(this.videoEncBuffer_.point,m,u,o.type=="key"?1:0,r,B.global.point,this.io.id,i);this.sendUdtv3Video(_,p)}sendUdtv3Video(e,r){let i=0,o=B.global.uint8Array();for(let u=0;u<e;u++){let p=B.global.getUint32(i);if(p<=0){this.io.log_.warn("sendUdtv3Video pktSize is ",p);continue}this.io.send(o.subarray(i+=4,i+=p)),this.statReportReq.rpt_msg_video_stat_report[r].msg_video_send_stat.uint32_video_send_br+=p<<3,this.videoStats.bytesSent+=p,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 i={mediaType:e,mediaDescription:{audioParam:e&1?{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]}:void 0,videoParam:[4,8,2].filter(o=>e&o).map(o=>({mediaType:o,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]}))}};this.send(2,i).then(o=>{r.postMessage(o),r.postMessage(null)})}};var _l=2,Qt=class extends be{addEventMsgs(t){this.qualityReport.msg_event_msg=t}constructor(t){super(t);let e,r=Te(t,Je.JOINED),i=Te(t,Je.CLOSED),o={};F(r,Ct(xe(1e3)),Ue(i),X(l=>{let m=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=m,this.statReportReq.msg_rtt_info_req.uint32_delay_since_last_server_timestamp_ms=e&&m-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,T)=>h+T.msg_video_send_stat.uint32_video_send_br,0),o.bandwidth=this.statReportReq.msg_down_bandwidth_est.uint32_avg_bandwidth_br,o.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,T)=>{let I=this.statReportReq.rpt_msg_video_stat_report[T];h.uint32_video_total_bitrate=I.msg_video_send_stat.uint32_video_send_br,_[I.uint32_video_type==7?3:I.uint32_video_type-1]=h.uint32_video_codec_bitrate=I.msg_video_enc_stat.uint32_video_enc_br}),o.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 u=F(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))}));F(r,Ct(u),Ct(Ge(hs)),Ue(i),X(()=>{this.io.log_.warn("ping timeout,lastrecv:",e,"now:",Date.now()),this.io.state==Je.JOINED&&this.io.wFSM.disconnect("ping timeout")}));let p=new B(52);F(r,Ct(xe(_l*1e3)),Ue(i),X(l=>{let m=[...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=m.map(U=>{var N,W;let C=U.toDownStreamInfo(U,l%10===0),x=[C.msg_audio_status.uint32_audio_codec_bitrate];return x[1]=C.msg_video_status[0].uint32_video_codec_bitrate,x[2]=((N=C.msg_video_status[1])==null?void 0:N.uint32_video_codec_bitrate)||0,o[`RemoteBr_${U.userId}`]=x,o[`RemoteBlock_${U.userId}`]=[C.msg_audio_status.uint32_audio_block_cnt,C.msg_video_status[0].uint32_video_block_cnt,((W=C.msg_video_status[1])==null?void 0:W.uint32_video_block_cnt)||0],C}),this.glog(o),o={};let _=this.qualityReport.msg_down_stream_info.map(U=>({userId:U.msg_user_info.str_identifier,rtt:U.msg_network_status.uint32_rtt,loss:U.msg_network_status.uint32_lost})),h=hl(_),T=this.qualityReport.msg_up_stream_info.msg_network_status.uint32_rtt,I=this.qualityReport.msg_up_stream_info.msg_network_status.uint32_lost;this.postMessage("network-quality",{uplinkNetworkQuality:this.io.state!="DISCONNECTED"?_o(I,T):6,downlinkNetworkQuality:_o(h.loss,h.rtt),uplinkInfo:this.qualityReport.msg_up_stream_info,msg_down_stream_info:this.qualityReport.msg_down_stream_info,downlinkInfo:_,uplinkRTT:T,uplinkLoss:I,downlinkRTT:h.rtt,downlinkLoss:h.loss}),this.qualityReport.msg_up_stream_info.msg_video_status.forEach(U=>{U.uint32_video_capture_fps>>=1,U.uint32_video_codec_fps>>=1,l%10===0&&console.log(tt(),"video uplink fps:",U.uint32_video_stream_type,U.uint32_video_capture_fps,U.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(U=>{U.uint32_video_capture_fps=0,U.uint32_video_codec_fps=0,U.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),p.free()}))}};function hl(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 _o(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 zt=class extends be{async subscribe(t,e){let{mediaType:r,srctinyid:i}=t,o=this.userMap_.get(i);if(o){if(o.subscribe|=t.mediaType,t.mediaType=o.subscribe,e)e.postMessage(await this.send(4,t));else return this.send(4,t);r===1&&o.startPullOnlyAudio(o.mainPuller,e,{mediaType:r,srctinyid:i})}}async unSubscribe(t,e){let{mediaType:r,srctinyid:i}=t,o=this.userMap_.get(i);if(o){let u=o.subscribe;o.subscribe&=~r,u!==o.subscribe&&e.postMessage(await(o.subscribe===0?this.send(5,t):this.io.sendSubscribe(o)))}}pullVideo({mediaType:t,tinyId:e},r){let i=this.userMap_.get(e);i&&i.startPull(t===2?i.screenPuller:i.mainPuller,r,{mediaType:t,srctinyid:e})}changetype(t){let{mediaType:e,srctinyid:r}=t,i=this.userMap_.get(r);if(i){let o=i.subscribe;e===8?(i.subscribe|=8,i.subscribe&=-5):e===4&&(i.subscribe|=4,i.subscribe&=-9),o!=i.subscribe&&(t.mediaType=i.subscribe,this.send(4,t))}}};var yi=class extends Wt{constructor(e,r,i,o){super();this.seq=e;this.player=r;this.numberOfChannels=i;this.bitrate=o;d(this,"aecPtr");d(this,"encodePrt");d(this,"tenms",sampleRate/100);d(this,"numberOfFrames",this.tenms<<1);d(this,"float32Array");d(this,"pos",0);d(this,"bufferLen",0);d(this,"outputPort");d(this,"mainPort");d(this,"workerPort");d(this,"outPrt");d(this,"audioCaptBuff");d(this,"oput");d(this,"first10ms");d(this,"dumpPort");d(this,"encodeCount",0);this.wasmBinary=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(te.useAINS),this._SetAudioFrameFormat(sampleRate,this.numberOfChannels),this._InitOpusEncoder(sampleRate,this.numberOfChannels,1),this.bitrate&&this._SetOpusEncBitrate(this.bitrate*1e3),console.log(et,"audio worklet initialized",sampleRate,this.numberOfChannels,this.seq),this.oput=new me,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 i of e){this.float32Array.set(i,this.bufferLen),this.bufferLen+=i.length;let o=0;for(;this.bufferLen-this.pos>=this.tenms;){let u=this.player.delay+(this.bufferLen-this.pos)/(sampleRate/1e3)+20>>0,p=this._AudioProcessFloat(this.encodePrt+this.pos*4,this.tenms,u);if(o<p&&(o=p),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 m=this.HEAPU8.slice(this.outPrt,this.outPrt+l),_=o*100/32768;this.mainPort.postMessage(_),this.outputPort.postMessage({data:m,volume:_,energy:o,timestamp:Date.now()},[m.buffer]),o=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 ho(n){class t extends AudioWorkletProcessor{constructor(i){super();d(this,"oput",new me);d(this,"wasm");d(this,"encoders",[]);d(this,"useAINS",!0);console.log("worklet created:",sampleRate),this.wasm=i.processorOptions.wasm,Object.assign(te,i.processorOptions.flag),this.port.onmessage=o=>{o.ports[0].onmessage=u=>this.pushAudio(u)}}get delay(){var i;return(((i=this.oput.buffer)==null?void 0:i.length)||0)/(sampleRate*4/1e3)}process(i,o){return this.oput.demand(o[0][0],!0),this.encoders.forEach((u,p)=>u.encode(...i[p])),!0}pushAudio(i){if(i.data instanceof Uint8Array){let{data:o}=i;this.encoders.forEach(u=>o=u.aec(i.data)),this.oput.malloc(o.length).set(o);return}switch(console.log("worklet receive",i.data.cmd),i.data.cmd){case"dump":switch(i.data.payload){case"mic0":this.encoders[0].dumpPort=i.ports[0];break}break;case"useAINS":te.useAINS=i.data.payload,this.encoders.forEach(o=>o._UseAINS(i.data.payload));break;case"enableAEC":this.encoders.forEach(o=>o._EnableAEC(i.data.payload));break;case"enableDebug":console.debug=i.data.payload?Pr:()=>{};break;case"pushAudio":{let[o,u]=i.ports,{payload:{numberOfChannels:p,bitrate:l},encrypt:m,index:_}=i.data,h=this.encoders[_]||new yi(_,this,p,l);this.encoders[_]?(h.bitrate=l,h._SetOpusEncBitrate(l*1e3)):n(h),h.reset(),h.mainPort=u,h.workerPort=o,h.outputPort=m?u:o,u.onmessage=T=>{T.data?h.encode(T.data):(console.log(tt(),"encoder",_,"stopped"),o.postMessage(null))}}}}}registerProcessor("global-audio-player",t)}var Ai=class{constructor(){d(this,"playPort");d(this,"dumpPort");d(this,"downlinkAudioCount",0);d(this,"interval10ms",F(mt(10),We()));d(this,"ios")}glog(t){self.postMessage({type:"glog",payload:t})}async joinRoom(t){let{data:{id:e,payload:r},ports:i}=t,o=new Je(e,i[0],r);o.wh=this;let u=[new Xt(o),new zt(o),new Gt(o),new Qt(o),new Jt(o)],p=(m="leave room")=>{o.leaveRoom().catch(),o.abort(m),this.ios.delete(o)},l=setTimeout(o.abort,5e3,"timeout");F(Vt(o.port,!0),X(({data:{cmd:m,payload:_},ports:h})=>{switch(console.log(self.name,"received message",m),m){case"setAudioWorkletPort":this.playPort=h[0];break;case"switchRole":o.sendReq(20,{role:_,privateMapKey:o.params.privateMapKey}).then(I=>h[0].postMessage(I));break;default:let T=h.map(I=>Vt(I));typeof _!="undefined"&&T.unshift(_),u.forEach(I=>{var U;(U=I[m])==null||U.call(I,...T)})}},p,p));try{await o.connect(),postMessage({id:e,payload:await o.joinRoom()}),clearTimeout(l),this.ios.add(o)}catch(m){m instanceof WebTransportError?m=`Transport initialization failed.
1
+ var Wu=Object.create;var lr=Object.defineProperty,Gu=Object.defineProperties,ss=Object.getOwnPropertyDescriptor,ju=Object.getOwnPropertyDescriptors,$u=Object.getOwnPropertyNames,is=Object.getOwnPropertySymbols,Yu=Object.getPrototypeOf,os=Object.prototype.hasOwnProperty,Ku=Object.prototype.propertyIsEnumerable;var dn=(n,t,e)=>t in n?lr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ct=(n,t)=>{for(var e in t||(t={}))os.call(t,e)&&dn(n,e,t[e]);if(is)for(var e of is(t))Ku.call(t,e)&&dn(n,e,t[e]);return n},as=(n,t)=>Gu(n,ju(t));var Ju=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var Xu=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of $u(t))!os.call(n,i)&&i!==e&&lr(n,i,{get:()=>t[i],enumerable:!(r=ss(t,i))||r.enumerable});return n};var mr=(n,t,e)=>(e=n!=null?Wu(Yu(n)):{},Xu(t||!n||!n.__esModule?lr(e,"default",{value:n,enumerable:!0}):e,n));var ce=(n,t,e,r)=>{for(var i=r>1?void 0:r?ss(t,e):t,o=n.length-1,u;o>=0;o--)(u=n[o])&&(i=(r?u(t,e,i):u(i))||i);return r&&i&&lr(t,e,i),i};var d=(n,t,e)=>dn(n,typeof t!="symbol"?t+"":t,e);var qt=Ju((Nd,pi)=>{"use strict";var Ec=Object.prototype.hasOwnProperty,de="~";function Ft(){}Object.create&&(Ft.prototype=Object.create(null),new Ft().__proto__||(de=!1));function Tc(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function Os(n,t,e,r,i){if(typeof e!="function")throw new TypeError("The listener must be a function");var o=new Tc(e,r||n,i),u=de?de+t:t;return n._events[u]?n._events[u].fn?n._events[u]=[n._events[u],o]:n._events[u].push(o):(n._events[u]=o,n._eventsCount++),n}function Cr(n,t){--n._eventsCount===0?n._events=new Ft:delete n._events[t]}function ae(){this._events=new Ft,this._eventsCount=0}ae.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)Ec.call(e,r)&&t.push(de?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};ae.prototype.listeners=function(t){var e=de?de+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,u=new Array(o);i<o;i++)u[i]=r[i].fn;return u};ae.prototype.listenerCount=function(t){var e=de?de+t:t,r=this._events[e];return r?r.fn?1:r.length:0};ae.prototype.emit=function(t,e,r,i,o,u){var p=de?de+t:t;if(!this._events[p])return!1;var l=this._events[p],m=arguments.length,_,h;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),m){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,i),!0;case 5:return l.fn.call(l.context,e,r,i,o),!0;case 6:return l.fn.call(l.context,e,r,i,o,u),!0}for(h=1,_=new Array(m-1);h<m;h++)_[h-1]=arguments[h];l.fn.apply(l.context,_)}else{var T=l.length,I;for(h=0;h<T;h++)switch(l[h].once&&this.removeListener(t,l[h].fn,void 0,!0),m){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,i);break;default:if(!_)for(I=1,_=new Array(m-1);I<m;I++)_[I-1]=arguments[I];l[h].fn.apply(l[h].context,_)}}return!0};ae.prototype.on=function(t,e,r){return Os(this,t,e,r,!1)};ae.prototype.once=function(t,e,r){return Os(this,t,e,r,!0)};ae.prototype.removeListener=function(t,e,r,i){var o=de?de+t:t;if(!this._events[o])return this;if(!e)return Cr(this,o),this;var u=this._events[o];if(u.fn)u.fn===e&&(!i||u.once)&&(!r||u.context===r)&&Cr(this,o);else{for(var p=0,l=[],m=u.length;p<m;p++)(u[p].fn!==e||i&&!u[p].once||r&&u[p].context!==r)&&l.push(u[p]);l.length?this._events[o]=l.length===1?l[0]:l:Cr(this,o)}return this};ae.prototype.removeAllListeners=function(t){var e;return t?(e=de?de+t:t,this._events[e]&&Cr(this,e)):(this._events=new Ft,this._eventsCount=0),this};ae.prototype.off=ae.prototype.removeListener;ae.prototype.addListener=ae.prototype.on;ae.prefixed=de;ae.EventEmitter=ae;typeof pi!="undefined"&&(pi.exports=ae)});function $(...n){}var Qu=n=>n();function fn(){this.dispose()}var zu=()=>typeof __FASTRX_DEVTOOLS__!="undefined",Zu=1,De=class extends Function{toString(){return`${this.name}(${this.args.length?[...this.args].join(", "):""})`}subscribe(t){let e=new pn(t,this,this.streamId++);return Z.subscribe({id:this.id,end:!1},{nodeId:e.sourceId,streamId:e.id}),this(e),e}},dt=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=$,this.error=$,this.next=$,this.dispose=$,this.subscribe=$,this.doDefer()}subscribe(t){return t instanceof De?t.subscribe(this):t(this),this}get bindSubscribe(){return t=>this.subscribe(t)}doDefer(){this.defers.forEach(Qu),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}},D=class extends dt{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 dt{constructor(t,e=$,r=$,i=$){if(super(),this._next=e,this._error=r,this._complete=i,this.then=$,t instanceof De){let o={toString:()=>"subscribe",id:0,source:t};this.defer(()=>{Z.defer(o,0)}),Z.create(o),Z.pipe(o),this.sourceId=o.id,this.subscribe(t),Z.subscribe({id:o.id,end:!0}),e==$?this._next=u=>Z.next(o,0,u):this.next=u=>{Z.next(o,0,u),e(u)},i==$?this._complete=()=>Z.complete(o,0):this.complete=()=>{this.dispose(),Z.complete(o,0),i()},r==$?this._error=u=>Z.complete(o,0,u):this.error=u=>{this.dispose(),Z.complete(o,0,u),r(u)}}else this.subscribe(t)}next(t){this._next(t)}complete(){this.dispose(),this._complete()}error(t){this.dispose(),this._error(t)}};function F(n,...t){return t.reduce((e,r)=>r(e),n)}function le(n,t,e){if(zu()){let r=Object.defineProperties(Object.setPrototypeOf(n,De.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}});Z.create(r);for(let i=0;i<e.length;i++){let o=e[i];typeof o=="function"&&o instanceof De&&Z.addSource(r,o)}return r}return n}function L(n,t){return function(...e){return r=>{if(r instanceof De){let i=le(o=>{let u=new n(o,...e);u.sourceId=i.id,u.subscribe(r)},t,arguments);return i.source=r,Z.pipe(i),i}else return i=>r(new n(i,...e))}}}function qe(n,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:n,payload:t}})}var pn=class extends D{constructor(t,e,r){super(t),this.source=e,this.id=r,this.sourceId=t.sourceId,this.defer(()=>{Z.defer(this.source,this.id)})}next(t){Z.next(this.source,this.id,t),this.sink.next(t)}complete(){Z.complete(this.source,this.id),this.sink.complete()}error(t){Z.complete(this.source,this.id,t),this.sink.error(t)}},Z={addSource(n,t){qe("addSource",{id:n.id,name:n.toString(),source:{id:t.id,name:t.toString()}})},next(n,t,e){qe("next",{id:n.id,streamId:t,data:e&&e.toString()})},subscribe({id:n,end:t},e){qe("subscribe",{id:n,end:t,sink:{nodeId:e&&e.nodeId,streamId:e&&e.streamId}})},complete(n,t,e){qe("complete",{id:n.id,streamId:t,err:e?e.toString():null})},defer(n,t){qe("defer",{id:n.id,streamId:t})},pipe(n){qe("pipe",{name:n.toString(),id:n.id,source:{id:n.source.id,name:n.source.toString()}})},update(n){qe("update",{id:n.id,name:n.toString()})},create(n){n.id||(n.id=Zu++),qe("create",{name:n.toString(),id:n.id})}},pr=class extends Error{constructor(t){super(`timeout after ${t}ms`),this.timeout=t}};var _n=class extends dt{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 We(){return n=>{let t=new _n(n);if(n instanceof De){let e=le(r=>{t.add(r)},"share",arguments);return t.sourceId=e.id,e.source=n,Z.pipe(e),e}return le(t.add.bind(t),"share",arguments)}}function us(...n){return le(t=>{let e=new D(t),r=n.length;e.complete=()=>{--r===0&&t.complete()},n.forEach(e.bindSubscribe)},"merge",arguments)}function ec(...n){return le(t=>{let e=n.length,r=e,i=e,o=new Array(e),u=()=>{--i===0&&t.complete()},p=(l,m)=>{let _=new D(t);_.next=h=>{r--,_.next=T=>{o[m]=T,r===0&&t.next(o)},_.next(h)},_.complete=u,_.subscribe(l)};n.forEach(p)},"combineLatest",arguments)}function cs(...n){return le(t=>{let e=n.length,r=e,i=new Array(e),o=()=>{--r===0&&t.complete()},u=(p,l)=>{let m=new D(t),_=[];i[l]=_,m.next=h=>{_.push(h),i.every(T=>T.length)&&t.next(i.map(T=>T.shift()))},m.complete=o,m.subscribe(p)};n.forEach(u)},"zip",arguments)}var hn=class extends D{constructor(t,...e){super(t);let r=new D(this.sink);r.next=i=>this.buffer=i,r.complete=$,r.subscribe(ec(...e))}next(t){this.buffer&&this.sink.next([t,...this.buffer])}},Pl=L(hn,"withLatestFrom"),bn=class extends D{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()}},Nl=L(bn,"bufferCount"),gn=class extends D{constructor(t,e){super(t),this.buffer=[];let r=new D(t);r.next=i=>{t.next(this.buffer),this.buffer=[]},r.complete=$,r.subscribe(e)}next(t){this.buffer.push(t)}complete(){this.buffer.length&&this.sink.next(this.buffer),super.complete()}},Dl=L(gn,"buffer");function ze(n){let t=arguments,e=We()(le(r=>{e.next=i=>r.next(i),e.complete=()=>r.complete(),e.error=i=>r.error(i),n&&r.subscribe(n)},"subject",t));return e.next=$,e.complete=$,e.error=$,e}var fr={promise:n=>{Promise.resolve().then(n)},setImmediate:typeof setImmediate!="undefined"?n=>setImmediate(n):null,setTimeout:n=>setTimeout(n,0)},tc=()=>typeof Promise!="undefined"?fr.promise:fr.setImmediate?fr.setImmediate:fr.setTimeout,Ml=tc();function pt(n){return le(t=>{let e=0,r=setInterval(()=>t.next(e++),n);return t.defer(()=>{clearInterval(r)}),"interval"},"interval",arguments)}function ls(n,t){return le(e=>{let r=0,i=setTimeout(()=>{if(e.removeDefer(o),e.next(r++),t){let u=setInterval(()=>e.next(r++),t);e.defer(()=>{clearInterval(u)})}else e.complete()},n),o=()=>clearTimeout(i);e.defer(o)},"timer",arguments)}function En(n,t){return e=>{let r=i=>e.next(i);e.defer(()=>t(r)),n(r)}}function Te(n,t){if("on"in n&&"off"in n)return le(En(e=>n.on(t,e),e=>n.off(t,e)),"fromEvent",arguments);if("addListener"in n&&"removeListener"in n)return le(En(e=>n.addListener(t,e),e=>n.removeListener(t,e)),"fromEvent",arguments);if("addEventListener"in n)return le(En(e=>n.addEventListener(t,e),e=>n.removeEventListener(t,e)),"fromEvent",arguments);throw"target is not a EventDispachter"}var Tn=class extends D{constructor(t,e,r){super(t),this.f=e;let i=()=>{this.sink.next(this.acc),this.sink.complete()};typeof r=="undefined"?this.next=o=>{this.acc=o,this.complete=i,this.resetNext()}:(this.acc=r,this.complete=i)}next(t){this.acc=this.f(this.acc,t)}},rc=L(Tn,"reduce");var Sn=class extends D{constructor(t,e,r){super(t),this.filter=e,this.thisArg=r}next(t){this.filter.call(this.thisArg,t)&&this.sink.next(t)}},ft=L(Sn,"filter"),yn=class extends D{next(t){}},Wl=L(yn,"ignoreElements"),An=class extends D{constructor(t,e){super(t),this.count=e}next(t){this.sink.next(t),--this.count===0&&(this.doDefer(),this.complete())}},hr=L(An,"take"),In=class extends D{constructor(t,e){super(t);let r=new D(t);r.next=()=>{r.doDefer(),t.complete()},r.complete=fn,r.subscribe(e)}},Ue=L(In,"takeUntil"),Rn=class extends D{constructor(t,e){super(t),this.f=e}next(t){this.f(t)?this.sink.next(t):(this.doDefer(),this.complete())}},kn=L(Rn,"takeWhile");var Un=class extends D{constructor(t,e){super(t),this.count=e}next(t){--this.count===0&&(this.next=super.next)}},Gl=L(Un,"skip"),xn=class extends D{constructor(t,e){super(t),t.next=$;let r=new D(t);r.next=()=>{r.doDefer(),t.resetNext()},r.complete=fn,r.subscribe(e)}},jl=L(xn,"skipUntil"),On=class extends D{constructor(t,e){super(t),this.f=e}next(t){this.f(t)||(this.next=super.next,this.next(t))}},ms=L(On,"skipWhile"),nc={leading:!0,trailing:!1},vn=class extends D{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)}},Pn=class extends D{constructor(t,e,r=nc){super(t),this.durationSelector=e,this.config=r,this._throttle=new vn(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=$,this._throttle.complete(),super.complete()}},ds=L(Pn,"throttle");var Nn=class extends D{next(){this.complete()}complete(){this.dispose(),this.sink.next(this.last)}},_r=class extends D{constructor(t,e){super(t),this.durationSelector=e,this._debounce=new Nn(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()}},ps=L(_r,"debounce"),fs=n=>L(_r,"debounceTime")(t=>ls(n)),Dn=class extends D{constructor(t,e,r){super(t),this.count=e,this.defaultValue=r}next(t){this.count--===0&&(this.defaultValue=t,this.doDefer(),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()}},$l=L(Dn,"elementAt");var Cn=class extends D{constructor(t,e){super(t),this.f=e,this.i=0}next(t){this.f(t)?(this.sink.next(this.i++),this.doDefer(),this.complete()):++this.i}},Yl=L(Cn,"findIndex"),wn=class extends D{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.doDefer(),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()}},Kl=L(wn,"first"),Ln=class extends D{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()}},Jl=L(Ln,"last"),Mn=class extends D{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.doDefer(),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()}},Xl=L(Mn,"every");var Bn=class extends D{constructor(t,e,r){super(t),this.f=e,typeof r=="undefined"?this.next=i=>{this.acc=i,this.resetNext(),this.sink.next(this.acc)}:this.acc=r}next(t){this.sink.next(this.acc=this.f(this.acc,t))}},em=L(Bn,"scan"),Vn=class extends D{constructor(){super(...arguments),this.hasLast=!1}next(t){this.hasLast?this.sink.next([this.last,t]):this.hasLast=!0,this.last=t}},tm=L(Vn,"pairwise"),br=class extends D{constructor(t,e,r){super(t),this.mapper=e,this.thisArg=r}next(t){super.next(this.mapper.call(this.thisArg,t))}},tt=L(br,"map"),Xn=n=>L(br,"mapTo")(t=>n),Ze=class extends D{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()}},et=class n extends D{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===n.prototype.complete&&(this.complete=this.tryComplete),r.complete=r.tryComplete,r.subscribe(this.makeSource(t,this.index++))}complete(){this.sink.complete()}tryComplete(){this.currentSink.resetComplete(),this.dispose()}},gr=class extends Ze{},Er=class extends et{next(t){this.subInner(t,gr),this.next=e=>{this.currentSink.dispose(),this.subInner(e,gr)}}},Qn=L(Er,"switchMap");function Ar(n){return(t,e)=>n(()=>t,e)}var wt=Ar(L(Er,"switchMapTo")),Hn=class extends Ze{tryComplete(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}},Tr=class extends et{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(),Hn),this.disposed&&this.sources.length===0&&this.currentSink.resetComplete()}tryComplete(){this.sources.length===0&&this.currentSink.resetComplete(),this.dispose()}},rm=L(Tr,"concatMap"),nm=Ar(L(Tr,"concatMapTo")),Fn=class extends Ze{tryComplete(){this.context.inners.delete(this),super.dispose(),this.context.inners.size===0&&this.context.resetComplete()}},Sr=class extends et{constructor(){super(...arguments),this.inners=new Set}next(t){this.subInner(t,Fn),this.inners.add(this.currentSink)}tryComplete(){this.inners.size===1?this.inners.forEach(t=>t.resetComplete()):this.dispose()}},im=L(Sr,"mergeMap"),sm=Ar(L(Sr,"mergeMapTo")),qn=class extends Ze{dispose(){this.context.resetNext(),super.dispose()}},yr=class extends et{next(t){this.next=$,this.subInner(t,qn)}},om=L(yr,"exhaustMap"),am=Ar(L(yr,"exhaustMapTo")),Wn=class extends D{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=ze(),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)}},um=L(Wn,"groupBy"),Gn=class extends D{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}},cm=L(Gn,"timeInterval"),jn=class extends D{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()}},lm=L(jn,"bufferTime"),$n=class extends D{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:i}=e;super.next(i),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)}},mm=L($n,"delay"),Yn=class extends D{constructor(t,e){super(t),this.selector=e}error(t){this.dispose(),this.selector(t)(this.sink)}},dm=L(Yn,"catchError"),Kn=class extends Ze{tryComplete(){let t=this.context.inners.delete(this);super.dispose(),t&&this.context.checkComplete()}next(t){this.sink.next(t),this.context.expandValue(t)}},Jn=class extends et{constructor(t,e){super(t,e),this.project=e,this.inners=new Set,this.sourceCompleted=!1}next(t){this.sink.next(t),this.expandValue(t)}expandValue(t){let e=new Kn(this.sink,t,this);this.currentSink=e,this.complete=this.tryComplete,e.complete=e.tryComplete,this.inners.add(e),e.subscribe(this.makeSource(t,this.index++))}complete(){this.sourceCompleted=!0,this.checkComplete()}checkComplete(){this.sourceCompleted&&this.inners.size===0&&(this.resetComplete(),super.complete())}tryComplete(){this.sourceCompleted=!0,this.checkComplete()}},pm=L(Jn,"expand");var X=(n=$,t=$,e=$)=>r=>new dr(r,n,t,e),zn=class extends D{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)}))}},Ir=L(zn,"tap"),Zn=class extends D{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()}},hm=L(Zn,"timeout");var rt="5.0.0";var _s=typeof importScripts!="undefined",Rr=typeof registerProcessor!="undefined";var ei="";var ic="web.sdk.qcloud.com";var sc=`https://${ic}/trtc/webrtc/v5/doc`,Um=`${sc}/zh-cn/`,hs="https://yun.tim.qq.com",bs="https://apisgp.my-imcloud.com";var gs={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"};var ke=(u=>(u[u.TRACE=0]="TRACE",u[u.DEBUG=1]="DEBUG",u[u.INFO=2]="INFO",u[u.WARN=3]="WARN",u[u.ERROR=4]="ERROR",u[u.NONE=5]="NONE",u))(ke||{}),Es=18e3;var xm=7*24*3600*1e3;var Ts={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},Om=Ts["480p_2"],vm=Ts["120p_2"];var Lt={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",LOADEDMETADATA:"loadedmetadata",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",RESIZE:"resize",TIME_UPDATE:"timeupdate"};var _t=1,Ur=2,xr=4,ht=8,bt=64,gt=16;var Pm=Lt.MAIN,Nm=Lt.AUXILIARY;var Ss=30;var Dm=Lt.BIG,Cm=Lt.SMALL,wm=10*1e3;var Lm=Object.keys(ke),ys=["normal leave","timeout leave","kick","role change"];var Mm=10*1e3;var ac=function(n,t,e,r){function i(o){return o instanceof e?o:new e(function(u){u(o)})}return new(e||(e=Promise))(function(o,u){function p(_){try{m(r.next(_))}catch(h){u(h)}}function l(_){try{m(r.throw(_))}catch(h){u(h)}}function m(_){_.done?o(_.value):i(_.value).then(p,l)}m((r=r.apply(n,t||[])).next())})},ti=Symbol(32),ri=Symbol(16),ni=Symbol(8),me=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 ac(this,void 0,void 0,function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise((e,r)=>{var i;this.reject=r,this.resolve=u=>{delete this.lastReadPromise,delete this.resolve,delete this.need,e(u)},this.demand(t,!0)||(i=this.pull)===null||i===void 0||i.call(this,t)})})}readU32(){return this.read(ti)}readU16(){return this.read(ri)}readU8(){return this.read(ni)}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,i=o=>e.length<(r=o);if(typeof this.need=="number"){if(i(this.need))return;t=e.subarray(0,r)}else if(this.need===ti){if(i(4))return;t=e[0]<<24|e[1]<<16|e[2]<<8|e[3]}else if(this.need===ri){if(i(2))return;t=e[0]<<8|e[1]}else if(this.need===ni){if(i(1))return;t=e[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(i(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(i(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 i=new Uint8Array(r);i.set(this.buffer),this.buffer=i}return this.buffer.subarray(e,r)}else return this.buffer=new Uint8Array(t),this.buffer}};me.U32=ti;me.U16=ri;me.U8=ni;var uc=128,cc=127,Gm=~cc,jm=Math.pow(2,31);function ii(n){let t=new me;for(;n>=128;)t.malloc(1)[0]=n&255|uc,n>>>=7;return t.malloc(1)[0]=n&255,t.buffer||new Uint8Array(0)}function Or(n,t=0){let e=new me,r=t<<3;switch(typeof n){case"boolean":let i=e.malloc(2);i[0]=r,i[1]=n?1:0;break;case"number":e.malloc(1)[0]=r,e.write(ii(n));break;case"string":e.malloc(1)[0]=r|2;let o=new TextEncoder().encode(n);e.write(ii(o.length));let u=e.malloc(o.length);for(let l=0;l<o.length;l++)u[l]=o[l];break;case"object":let p=new me;if(Array.isArray(n))for(let l=0;l<n.length;l++){let m=Or(n[l],l+1);m&&p.write(m)}else{let l=1;for(let m in n){let _=Or(n[m],l++);_&&p.write(_)}}t===0?p.buffer&&e.write(p.buffer):(e.malloc(1)[0]=r|2,p.buffer&&(e.write(ii(p.buffer.length)),e.write(p.buffer)))}return e.buffer||new Uint8Array(0)}var Mt=class{constructor(){d(this,"buffer");this.buffer=[]}get data(){return this.buffer}get length(){return this.buffer.length}writeInt32(t){this.buffer.push(t>>>24&255),this.buffer.push(t>>>16&255),this.buffer.push(t>>>8&255),this.buffer.push(t&255)}writeInt16(t){this.buffer.push(t>>>8&255),this.buffer.push(t&255)}writeByte(t){this.buffer.push(t&255)}writeBytes(t){for(let e=0;e<t.length;e++)this.buffer.push(t[e])}};function si(n,t,e){n[e]=t>>>24&255,n[e+1]=t>>>16&255,n[e+2]=t>>>8&255,n[e+3]=t&255}function oe(n,t){return n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3]}function oi(n,t){return n[t]}function Et(n,t,e){return new TextDecoder().decode(lc(n,t,e))}function lc(n,t,e){return n.slice(t,t+e)}var ai=0,vr=2654435769,Pr=16,ci=4,Tt=2,St=7;function mc(n,t,e,r="AVQualityReportSvc.C2S",i=2e3,o=2,u=30){return{version:i,encryption:o,d2:"",d2Len:0,uinType:u,uin:"",uinLen:0,reqHead:{seqNumber:e,appId:n,appidAtThird:new Uint8Array(0),a2:"",a2Len:0,serviceCmd:r,serviceCmdLen:0,cookie:"",cookieLen:0,imei:"",imeiLen:0,ksid:"",ksidLen:0,clientVersionInfo:"",clientVersionInfoLen:0},busiBuff:t}}function As(n,t){let e=new Mt,r=mc(t,n,ai);ai=ai+1&2147483647,e.writeInt32(0),e.writeInt32(r.version),e.writeByte(r.encryption);let i=new TextEncoder().encode(r.d2);e.writeInt32(i.length+4),i&&e.writeBytes(i),e.writeByte(r.uinType);let o=new TextEncoder().encode(r.uin);e.writeInt32(o.length+4),o.length&&e.writeBytes(o);let u=new Mt;u.writeInt32(0),u.writeInt32(r.reqHead.seqNumber),u.writeInt32(r.reqHead.appId),u.writeByte(r.reqHead.appId>>>24&255),u.writeByte(r.reqHead.appId>>>16&255),u.writeByte(r.reqHead.appId>>>8&255),u.writeByte(r.reqHead.appId&255);for(let W=4;W<16;W++)u.writeByte(0);let p=new TextEncoder().encode(r.reqHead.a2);u.writeInt32(p.length+4),p.length&&u.writeBytes(p);let l=new TextEncoder().encode(r.reqHead.serviceCmd);u.writeInt32(l.length+4),l.length&&u.writeBytes(l);let m=new TextEncoder().encode(r.reqHead.cookie);u.writeInt32(m.length+4),m.length&&u.writeBytes(m);let _=new TextEncoder().encode(r.reqHead.imei);u.writeInt32(_.length+4),_.length&&u.writeBytes(_);let h=new TextEncoder().encode(r.reqHead.ksid);u.writeInt32(h.length+4),h.length&&u.writeBytes(h);let T=new TextEncoder().encode(r.reqHead.clientVersionInfo);u.writeInt16(T.length+2),T.length&&u.writeBytes(T);let I=u.length;u.data[0]=I>>>24&255,u.data[1]=I>>>16&255,u.data[2]=I>>>8&255,u.data[3]=I&255,kt(n)&&(n=new TextEncoder().encode(n)),u.writeInt32(n.length+4),n.length&&u.writeBytes(n);let U=new Uint8Array(u.data),w=null;r.encryption===1?w=new TextEncoder().encode(r.uin):r.encryption===2&&(w=new Uint8Array(16)),w&&(U=dc(U,w)),e.writeBytes(U);let x=new Uint8Array(e.data),N=x.length;return x[0]=N>>>24&255,x[1]=N>>>16&255,x[2]=N>>>8&255,x[3]=N&255,x}function dc(n,t){let e=n.length,i=(e+1+Tt+St)%8;i&&(i=8-i);let o=e+1+Tt+St+i,u=new Uint8Array(o),p=0,l=new Uint8Array(8),m=new Uint8Array(8),_=new Uint8Array(8),h=0;l[0]=Math.floor(Math.random()*256)&248|i,h=1;for(let I=0;I<i;I++)l[h]=Math.floor(Math.random()*256)&255,h+=1;for(let I=0;I<Tt;)if(h<8&&(l[h]=Math.floor(Math.random()*256)&255,h+=1,I+=1),h===8){ui(l,t,m,_,u,p),p+=8,h=0;for(let U=0;U<8;U++)_[U]=u[p-8+U]}let T=0;for(;T<e;)if(h<8&&(l[h]=n[T],h+=1,T+=1),h===8){ui(l,t,m,_,u,p),p+=8,h=0;for(let I=0;I<8;I++)_[I]=u[p-8+I]}for(let I=0;I<St;)if(h<8&&(l[h]=0,h+=1,I+=1),h===8){ui(l,t,m,_,u,p),p+=8,h=0;for(let U=0;U<8;U++)_[U]=u[p-8+U]}return u}function ui(n,t,e,r,i,o){for(let u=0;u<8;u++)n[u]^=r[u];pc(n,t,i,o);for(let u=0;u<8;u++)i[o+u]^=e[u];for(let u=0;u<8;u++)e[u]=n[u]}function pc(n,t,e,r){let i=oe(n,0),o=oe(n,4),u=[];for(let l=0;l<4;l++)u[l]=oe(t,l*4);let p=0;for(let l=0;l<Pr;l++)p+=vr,p=p>>>0,i+=(o<<4)+u[0]^o+p^(o>>>5)+u[1],i=i>>>0,o+=(i<<4)+u[2]^i+p^(i>>>5)+u[3],o=o>>>0;si(e,i,r),si(e,o,r+4)}var fc=n=>Number(n)<14e8,Is=function(n,t){let e;ei?e=ei:e=fc(n)?bs:hs;let r=Math.floor(Math.random()*2**31);return`${e}/v5/AVQualityReportSvc/C2S?random=${r}&sdkappid=${n}&cmdtype=${t}`};var sd=typeof window!="undefined"&&typeof window.glog=="function"?window.glog:()=>{};var Bt=n=>typeof n=="undefined",kt=n=>typeof n=="string",Rs=n=>typeof n=="number";var od=typeof HTMLMediaElement!="undefined"&&"setSinkId"in HTMLMediaElement.prototype;var{toString:ad}=Object.prototype;function li(n,t){return{userId:t,hasAudio:!!(n&ht),hasVideo:!!(n&_t),hasAuxiliary:!!(n&xr),hasSmall:!!(n&Ur),audioMuted:!!(n&bt),videoMuted:!!(n&gt),audioAvailable:!!(n&ht)&&!(n&bt),videoAvailable:!!(n&_t)&&!(n&gt)}}function _c(n,t,e,r){let i={data:n,random:Math.floor(Math.random()*2147483648),sdkAppId:e};return Bt(r)||(i=as(Ct({},i),{gzip:+r})),{uint32_sdkappid:0,uint64_from_uin:0,uint32_timestamp:0,uint32_seq:0,msg_common_info:{msg_device_info:{enum_device_type:0,str_device_brand:"",str_device_model:"",str_device_board:"",str_device_cpu_abi:""},msg_system_info:{enum_os_type:0,str_os_version:"",msg_network_info:0},msg_network_info:{enum_network_type:0}},msg_report_content:{uint32_type:t,bytes_report_data:JSON.stringify(i)}}}function Us(n,t,e,r){try{let i=_c(n,t,e,r),o=Or(i);return As(o,e)}catch(i){return JSON.stringify(n)}}function Vt(n,t=!1){let e=Object.defineProperties(ze(),{postMessage:{value:n.postMessage.bind(n)},port:{get(){return n},set(i){n.onmessage=$,n.onmessageerror=$,n=i,r()}}});function r(){n.onmessage=i=>{i.data?i.ports.length||t?e.next(i):e.next(i.data):(e.complete(),n.close())},n.onmessageerror=i=>{e.error(i),n.close()}}return r(),e}var mi=class extends D{constructor(t,e){super(t);let r=new D(t);r.next=$,e(r)}},Be=L(mi,"takeUntilComplete");var te={useWt:!0,useAINS:!0,useHardDecoder:"prefer-software",useHardEncoder:"prefer-software",unreliable:!1,debug:!1,assetsPath:"",enableUpload:!0},hc="__INLINE__WORKER__",bc="__INLINE__WASM__",{debug:Nr}=console;te.debug||(console.debug=()=>{});var Td=!hc.startsWith("__"),Sd=!bc.startsWith("__");var xs=F(pt(250),tt(()=>performance.now()),We()),xe=n=>t=>{let e=0,r=performance.now();F(xs,tt(i=>(i-r)/n>>0),ft(i=>i!=e?(e=i,!0):!1))(t)},Ge=n=>t=>{let e=performance.now();F(xs,ms(r=>r-e<n),hr(1))(t)};function je(n,t,e){let r=t.aborted?Promise.reject(t.reason):new Promise((i,o)=>{t.addEventListener("abort",()=>o(t.reason),{once:!0}),typeof n=="function"?n(i,o):n.then(i,o)});return e?r.catch(e):r}var gc=new Intl.DateTimeFormat("zh-CN",{dateStyle:"short",timeStyle:"medium"}),nt=()=>gc.format(new Date),ne=(O=>(O[O.JOIN_ROOM=0]="JOIN_ROOM",O[O.LEAVE_ROOM=1]="LEAVE_ROOM",O[O.PUBLISH=2]="PUBLISH",O[O.UNPUBLISH=3]="UNPUBLISH",O[O.SUBSCRIBE=4]="SUBSCRIBE",O[O.UNSUBSCRIBE=5]="UNSUBSCRIBE",O[O.GET_WHOLE_LIST=6]="GET_WHOLE_LIST",O[O.QUALITY_REPORT=7]="QUALITY_REPORT",O[O.MUTE=8]="MUTE",O[O.UNMUTE=9]="UNMUTE",O[O.CONFIG=10]="CONFIG",O[O.REQUEST_PLI=11]="REQUEST_PLI",O[O.HEARTBEAT=12]="HEARTBEAT",O[O.START_PUSH_CDN=13]="START_PUSH_CDN",O[O.STOP_PUSH_CDN=14]="STOP_PUSH_CDN",O[O.START_MCU_MIX=15]="START_MCU_MIX",O[O.STOP_MCU_MIX=16]="STOP_MCU_MIX",O[O.UDPATE_TRACK=17]="UDPATE_TRACK",O[O.START_PUSHING=18]="START_PUSHING",O[O.STOP_PUSHING=19]="STOP_PUSHING",O[O.SWITCH_ROLE=20]="SWITCH_ROLE",O[O.WHOLE_LIST_UPDATE=255]="WHOLE_LIST_UPDATE",O[O.PEER_JOINED=256]="PEER_JOINED",O[O.PEER_LEFT=257]="PEER_LEFT",O[O.PEER_UDPATED_TRACK=258]="PEER_UDPATED_TRACK",O[O.SELECT_ABILITY=259]="SELECT_ABILITY",O[O.PEER_REQUEST_PLI=260]="PEER_REQUEST_PLI",O[O.AUDIO_DATA=4095]="AUDIO_DATA",O[O.VIDEO_DATA=4096]="VIDEO_DATA",O[O.SCREEN_DATA=4097]="SCREEN_DATA",O[O.NACK=4098]="NACK",O[O.ACK=4099]="ACK",O[O.REQUEST_RTT=4100]="REQUEST_RTT",O[O.RESPONSE_RTT=4101]="RESPONSE_RTT",O[O.PIP_DATA=4102]="PIP_DATA",O[O.LAYER_DATA=4103]="LAYER_DATA",O[O.MAX_FORCE=65535]="MAX_FORCE",O))(ne||{});function di(n,t,e){let r=t>65535?1:0;return e.setUint8(0,0<<4|r),e.setUint16(1,n),r?e.setUint32(3,t):e.setUint16(3,t),r?7:5}function Ht(n,t){let e=n>=255&&n<4095;e&&(t+=4);let i=(t>65535?1:0)?7:5,o=new DataView(new ArrayBuffer(i+t));di(n,t,o),e&&(o.setUint32(i,0),i+=4),o=new DataView(o.buffer,i),i=0;let u=T=>{o.setUint8(i,T),i++},p=T=>{o.setUint16(i,T),i+=2},l=(T,I=!1)=>{o.setUint32(i,T,I),i+=4},m=T=>{o.setBigUint64(i,T),i+=8},_=T=>{let I=new Uint8Array(o.buffer,o.byteOffset+i,T);return i+=T,I};return{write8:u,write32:l,write16:p,write64:m,writeData:T=>_(T.length).set(T),dv:o,next:_}}function Dr(n,t,e){let r=JSON.stringify(t),{writeData:i,dv:o}=Ht(n,r.length+16);switch(i(e.split("").map(u=>u.charCodeAt(0))),i(r.split("").map(u=>u.charCodeAt(0))),n){case 11:case 12:case 7:console.debug("send",ne[n],e,t,o.buffer);break;default:n<255&&console.log(nt(),"send",ne[n],e,t,o.buffer)}return o.buffer}var vs=mr(qt()),be=class extends vs.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 Te(this.io,ne[e])}glog(e){self.postMessage({type:"glog",payload:e})}};var Wt=class{constructor(){d(this,"arguments");d(this,"environment");d(this,"preInit");d(this,"preRun");d(this,"postRun");d(this,"onAbort");d(this,"preinitializedWebGLContext");d(this,"noInitialRun");d(this,"noExitRuntime");d(this,"logReadFiles");d(this,"filePackagePrefixURL");d(this,"wasmBinary");d(this,"HEAP");d(this,"IHEAP");d(this,"FHEAP");d(this,"HEAP8");d(this,"HEAP16");d(this,"HEAP32");d(this,"HEAPU8");d(this,"HEAPU16");d(this,"HEAPU32");d(this,"HEAPF32");d(this,"HEAPF64");d(this,"TOTAL_STACK");d(this,"TOTAL_MEMORY");d(this,"FAST_MEMORY");d(this,"preloadedImages");d(this,"preloadedAudios");d(this,"_GetEncodedFrame");d(this,"_ReceivedAudioPacket");d(this,"_CreateUdtPacketizer");d(this,"_PacketizeVideoUdt");d(this,"udtver",3)}onRuntimeInitialized(){}print(t){console.debug(t)}printErr(t){console.debug(t)}},ue=new Wt,B=class{constructor(t,e){this.size=t;d(this,"point");this.point=ue._malloc(t),e&&this.set(e)}set(t){t.length>this.size&&this.grow(t.length),ue.HEAPU8.set(t,this.point)}setUint32(t,e){new DataView(ue.HEAPU8.buffer).setUint32(this.point+t,e)}setBigUint64(t,e){new DataView(ue.HEAPU8.buffer).setBigUint64(this.point+t,e)}getBigUint64(t){return new DataView(ue.HEAPU8.buffer).getBigUint64(this.point+t)}getUint32(t){return ue.HEAPU8[this.point+t]|ue.HEAPU8[this.point+t+1]<<8|ue.HEAPU8[this.point+t+2]<<16|ue.HEAPU8[this.point+t+3]<<24}getInt8(t){return ue.HEAPU8[this.point+t]}uint8Array(t=NaN){return new Uint8Array(ue.HEAPU8.buffer,this.point,t>=0?t:this.size)}uint8Slice(t=NaN){return ue.HEAPU8.slice(this.point,this.point+(t>=0?t:this.size))}fill(t=0,e=this.point,r=this.point+this.size){ue.HEAPU8.fill(t,e,r)}free(){ue._free(this.point)}grow(t){t>this.size&&(this.free(),this.size=t,this.point=ue._malloc(t))}};d(B,"global");var V=ue;var wr=class{constructor(t){d(this,"lastReceiveTime",-1);d(this,"blocking",!1);d(this,"blockCnt",0);d(this,"blockTime",0);d(this,"received",ze());let e=Ge(t);F(this.received,ps(()=>(this.blockDone(),this.lastReceiveTime=Date.now(),e)),X(()=>{this.blocking=!0},$,()=>{this.blockDone()}))}blockDone(){this.blocking&&(this.blockCnt++,this.blockTime+=Date.now()-this.lastReceiveTime,this.blocking=!1)}clear(){this.blockCnt=0,this.blockTime=0}},Br=class Br{constructor(t=2){d(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});d(this,"videoPort");d(this,"control");d(this,"lastReceiveTime",-1);d(this,"vBlock",new wr(500));d(this,"ssrc",Br.g_ssrc++);d(this,"framesFromStartPull",0);this.videoStatus.uint32_video_stream_type=t}getVideoStatus(){let t=Ct({},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:i,vBlock:o}=this;i.uint32_video_receive++;let u=Date.now();i.uint32_video_total_bitrate+=e<<3,B.global.set(t);let p=V._ReceivedVideoPacket(B.global.point,e,u/1e3,u%1e3,r);p==0&&(this.lastReceiveTime>0&&u-this.lastReceiveTime>500&&console.debug("demuxPacket",u-this.lastReceiveTime),this.lastReceiveTime=u),o.received.next(p)}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])}};d(Br,"g_ssrc",1);var Lr=Br,Mr=class{constructor(t,e){this.writer=t;this.ssrc=e;d(this,"buffer",new B(960));d(this,"timestamp",0);V._SetAudioBuffer10Ms(this.buffer.point,e),V._AddAudioChannel(e,e)}feed(){this.writer.write(new AudioData({format:"s16",numberOfChannels:1,numberOfFrames:480,sampleRate:48e3,timestamp:this.timestamp+=1e4,data:this.buffer.uint8Array()}))}close(){V._DelAudioChannel(this.ssrc),this.buffer.free()}},kr=class{constructor(t,e){this.io=e;d(this,"userId");d(this,"tinyId");d(this,"role");d(this,"terminalType");d(this,"lastCapNtpMs",-1);d(this,"startTimestamp",Date.now());d(this,"alastReceivedTimestamp",-1);d(this,"lengthPoint",new B(4));d(this,"audioPuller");d(this,"mainPuller",new Lr(2));d(this,"screenPuller",new Lr(7));d(this,"aBlock",new wr(250));d(this,"events",[]);d(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});d(this,"subscribe",0);d(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 i=Ct({},this.msg_audio_status);return i.uint32_audio_codec_bitrate>>=1,i.uint32_audio_total_bitrate>>=1,i.uint32_audio_block_cnt=this.aBlock.blockCnt,i.uint32_audio_block_time=this.aBlock.blockTime,e&&console.log(new Date().toLocaleString(),t.userId,r.map(o=>({t:o.uint32_video_stream_type,r_fps:o.uint32_video_receive_fps,c_fps:o.uint32_video_codec_fps,c_bps:o.uint32_video_codec_bitrate})),i.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:i,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=V._GetEncodedFrame(B.global.point,this.lengthPoint.point,!1,t.ssrc),r=this.lengthPoint.getUint32(0);if(e==-1||r==0)return 10;let i=B.global.uint8Array(r);return t.videoStatus.uint32_video_total_frame||console.timeEnd(`${this.userId}${t==this.mainPuller?"big":"aux"}`),t.gotVideoFrame(i),e}startPullOnlyAudio(t,e,r){this.io.log_.info("start pull only audio",t),V._AddAudioChannel(t.ssrc,t.ssrc)}startPull(t,e,r){this.io.log_.info("start pull",t,r);let i=t===this.mainPuller;if(t.videoPort){t.framesFromStartPull=0,t.videoPort.port=e.port;return}let o=i?[2,1]:[7];t.videoPort=e,console.time(`${this.userId}${r.mediaType&2?"aux":"big"}`),F(e,X(({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 u=_=>{delete t.videoPort,_?this.io.log_.error("stop pull",_):this.io.log_.info("stop pull",t),V._DelVideoChannel(t.ssrc),t.vBlock.received.complete(),i&&this.aBlock.received.complete()};V._AddVideoChannel(t.ssrc,t.ssrc);let p=0,l=0,m=()=>{Date.now()-l>2e3&&(l=Date.now(),this.io.sendReq(11,r))};F(this.io.wh.interval10ms,ft(_=>(p<=0&&(p=this.getNextVideoFrame(t),p>500&&(p=20)),p-=10,te.useWt&&(_&1)==0&&!o.every(h=>{let T=V._CheckMissingPacket(B.global.point,B.global.size,h,t.ssrc,this.io.rtt);return T>0&&(B.global.setBigUint64(5,BigInt(this.tinyId)),this.io.send(B.global.uint8Array(T))),T>=0}))),Be(e),X(m,u,u)),m(),F(xe(5e3),Be(e),X(m))}};var Sc=1e8;function yc(){let n=new B(500,[0]);return V._GetAudioEnergy(n.point,100),n}var yt=class yt extends be{constructor(){super(...arguments);d(this,"audioReceivedBuff",new B(2048));d(this,"levelsMap",new Map);d(this,"timestampBuff",new B(12))}decodeAudio(e,r){F(this.createResposeOb(4095),Be(r),X(({data:i})=>{let u=new DataView(i.buffer,i.byteOffset,i.byteLength).getBigUint64(9).toString();this.userMap_.has(u)&&(this.statReportReq.msg_net_stat_report.uint32_down_real_pkg++,this.statReportReq.msg_net_stat_report.uint32_down_recv_br+=i.byteLength,this.demuxPacket(i,this.userMap_.get(u),e&&r))})),e&&F(r,X(({timestamp:i,rtpTimestamp:o,seqNum:u,ssrc:p,data:l})=>{this.audioReceivedBuff.set(l),V._ReceivedRawAudioPacket(this.audioReceivedBuff.point,l.byteLength,i,o,u,p)}))}pullAudio({tinyId:e,writable:r}){let i=this.userMap_.get(e);i&&(i.audioPuller=new Mr(r.getWriter(),i.mainPuller.ssrc))}getAudioEnergy(e,r){yt.energys||(yt.energys=yc());let{energys:i}=yt;F(xe(e),Be(r),X(()=>{let o=i.getInt8(0);for(let u=1;u<5*o;u+=5)this.levelsMap.set(i.getUint32(u),i.getInt8(u+4));if(this.userMap_.size>0){let u=[...this.userMap_.values()];r.postMessage(u.map(p=>{let l=Math.min(100,(this.levelsMap.get(p.mainPuller.ssrc)||0)*2);return p.msg_audio_status.uint32_audio_level=l*Sc/100>>0,{userId:p.userId,volume:l}}))}else r.postMessage([])}))}demuxPacket(e,r,i){let{aBlock:o,msg_audio_status:u}=r;o.received.next(!0),u.uint32_audio_total_bitrate+=e.byteLength<<3,u.uint32_audio_codec_bitrate=u.uint32_audio_total_bitrate-31,this.audioReceivedBuff.set(e);let p=Date.now(),l=p/1e3,m=p%1e3;if(i){let _=V._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),T=V.HEAPU8.slice(h,h+_);i.postMessage({timestamp:this.timestampBuff.getUint32(0),rtpTimestamp:this.timestampBuff.getUint32(4),seqNum:this.timestampBuff.getUint32(8),data:T,ssrc:r.mainPuller.ssrc},[T.buffer])}}else V._ReceivedAudioUdtPacket(this.audioReceivedBuff.point,e.length,l,m,r.mainPuller.ssrc)}};d(yt,"energys");var Gt=yt;var Ns=mr(qt(),1),Ps=Symbol("instance"),pp=Symbol("abortCtrl"),Fr=Symbol("cacheResult"),jt=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`}},it=class extends Error{constructor(t,e,r){super(e),this.state=t,this.message=e,this.cause=r}};function Ac(n){return typeof n=="object"&&n&&"then"in n}var $t=new Map;function pe(n,t,e={}){return(r,i,o)=>{let u=e.action||i;if(!e.context){let l=$t.get(r)||[];$t.has(r)||$t.set(r,l),l.push({from:n,to:t,action:u})}let p=o.value;o.value=function(...l){let m=this;if(e.context&&(m=z.get(typeof e.context=="function"?e.context.call(this,...l):e.context)),m.state===t)return e.sync?m[Fr]:Promise.resolve(m[Fr]);m.state instanceof jt&&m.state.action==e.abortAction&&m.state.abort(m);let _=null;Array.isArray(n)?n.length==0?m.state instanceof jt&&m.state.abort(m):(typeof m.state!="string"||!n.includes(m.state))&&(_=new it(m._state,`${m.name} ${u} to ${t} failed: current state ${m._state} not from ${n.join("|")}`)):n!==m.state&&(_=new it(m._state,`${m.name} ${u} to ${t} failed: current state ${m._state} not from ${n}`));let h=x=>{if(e.fail&&e.fail.call(this,x),e.sync){if(e.ignoreError)return x;throw x}else return e.ignoreError?Promise.resolve(x):Promise.reject(x)};if(_)return h(_);let T=m.state,I=new jt(T,t,u);Yt.call(m,I);let U=x=>{var N;return m[Fr]=x,I.aborted||(Yt.call(m,t),(N=e.success)===null||N===void 0||N.call(this,m[Fr])),x},w=x=>(Yt.call(m,T,x),h(x));try{let x=p.apply(this,l);return Ac(x)?x.then(U).catch(w):e.sync?U(x):Promise.resolve(U(x))}catch(x){return w(new it(m._state,`${m.name} ${u} from ${n} to ${t} failed: ${x}`,x instanceof Error?x:new Error(String(x))))}}}}var Ic=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(z.STATECHANGED,n,e,t),this.updateDevTools({value:n,old:e,err:t instanceof Error?t.message:String(t)})}var z=class n extends Ns.default{constructor(t,e,r){super(),this.name=t,this.groupName=e,this._state=n.INIT,t||(t=Date.now().toString(36)),r?Object.setPrototypeOf(this,r):r=Object.getPrototypeOf(this),e||(this.groupName=this.constructor.name);let i=r[Ps];i?this.name=i.name+"-"+i.count++:r[Ps]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let t=Object.getPrototypeOf(this),e=$t.get(t)||[],r=new Set,i=[],o=[],u=new Set,p=Object.getPrototypeOf(t);$t.has(p)&&(p.stateDiagram.forEach(m=>r.add(m)),p.allStates.forEach(m=>u.add(m))),e.forEach(({from:m,to:_,action:h})=>{typeof m=="string"?i.push({from:m,to:_,action:h}):m.length?m.forEach(T=>{i.push({from:T,to:_,action:h})}):o.push({to:_,action:h})}),i.forEach(({from:m,to:_,action:h})=>{u.add(m),u.add(_),u.add(h+"ing"),r.add(`${m} --> ${h}ing : ${h}`),r.add(`${h}ing --> ${_} : ${h} \u{1F7E2}`),r.add(`${h}ing --> ${m} : ${h} \u{1F534}`)}),o.forEach(({to:m,action:_})=>{r.add(`${_}ing --> ${m} : ${_} \u{1F7E2}`),u.forEach(h=>{h!==m&&r.add(`${h} --> ${_}ing : ${_}`)})});let l=[...r];return Object.defineProperties(t,{stateDiagram:{value:l},allStates:{value:u}}),l}static get(t){let e;return typeof t=="string"?(e=n.instances.get(t),e||n.instances.set(t,e=new n(t,void 0,Object.create(n.prototype)))):(e=n.instances2.get(t),e||n.instances2.set(t,e=new n(t.constructor.name,void 0,Object.create(n.prototype)))),e}static getState(t){var e;return(e=n.get(t))===null||e===void 0?void 0:e.state}updateDevTools(t={}){Ic(n.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(t){Yt.call(this,t)}};z.STATECHANGED="stateChanged";z.UPDATEAFSM="updateAFSM";z.INIT="[*]";z.ON="on";z.OFF="off";z.instances=new Map;z.instances2=new WeakMap;var $e=class extends z{constructor(e){super(e.params.userId,"WebSocket");this.connectFSM=e;d(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",je((r,i)=>{e.onerror=o=>{e.onmessage=null,this.connectFSM.log_.error("websocket onerror",o),i(o.type)},e.onclose=o=>{e.onmessage=null,i(o),this.connectFSM.log_.info("websocket onclose",o),this.disconnect(o.reason,o.code)},e.onopen=o=>{console.timeEnd("WebSocket connect"),this.connectFSM.log_.info("websocket onopen")},e.onmessage=o=>{try{let u=JSON.parse(String(o.data));if(this.connectFSM.log_.info("websocket verify",u),u.err!==0)throw u.err;this.connectFSM.verify(u.verify,u.rebuild),this.ws=e,r(e);let p=this.connectFSM.createOputReceiver("w");e.onmessage=l=>p.write(l.data)}catch(u){i(u)}}},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,i){this.send(Dr(e,r,i||this.connectFSM.generateUUID()))}send(e){var r;this.state=="CONNECTED"&&((r=this.ws)==null||r.send(e))}};ce([pe(["DISCONNECTED",z.INIT],"CONNECTED")],$e.prototype,"connect",1),ce([pe("CONNECTED","DISCONNECTED",{sync:!0,ignoreError:!0})],$e.prototype,"disconnect",1),ce([pe([],z.INIT,{sync:!0})],$e.prototype,"close",1);var Np=new Uint32Array([Date.now()]),Rc=F(pt(20),tt(()=>performance.now()),We()),_i=class{constructor(t){this.wt=t;d(this,"chunk",new Map);d(this,"timestamp",performance.now());d(this,"groupId");d(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),F(Rc,kn(()=>this.chunk.size>0&&this.resentCount<20),Ue(Te(t,"DISCONNECTED")),X(e=>{e-this.timestamp>2*t.connectFSM.rtt+10&&(this.chunk.forEach((r,i)=>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)}},Ye=class extends z{constructor(e){super(e.params.userId,"WebTransport");this.connectFSM=e;d(this,"wt");d(this,"writer");d(this,"dw");d(this,"sentCache",new Map);d(this,"groupid",0);d(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:i,stream:o}=await Promise.race([(async()=>{await je(e.ready,r);let p=await je(e.createBidirectionalStream(),r),l=p.readable.getReader();return this.writer=p.writable.getWriter(),this.dw=e.datagrams.writable.getWriter(),je(l.read(),r).then(({value:m})=>(l.releaseLock(),{value:m,stream:p}))})(),new Promise((p,l)=>setTimeout(()=>l(new Error("WebTransport connect timeout")),1e3))]),u=JSON.parse(String.fromCharCode(...i));if(this.connectFSM.log_.info("WebTransport connect result:",u),u.err!==0)throw u.err;this.connectFSM.verify(u.verify,u.rebuild),this.wt=e,F(Te(this.connectFSM,ne[4099]),Ue(Te(this,"DISCONNECTED")),X(({data:p})=>{let l=p[0]&127,m=this.sentCache.get(l);m&&m.ack(p[1])})),Promise.race([e.datagrams.readable.pipeTo(new WritableStream(this.connectFSM.createOputReceiver("d"))),o.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,i){if(i||(i=this.connectFSM.generateUUID()),!this.wt)return new Error("WebTransport not connected");if(!te.unreliable){let I=Dr(e,r,i);return this.writer.write(I).then(()=>!0).catch(this.catchError)}let o=e>=255&&e<4095,u=JSON.stringify(r),p=0,l=u.length+(o?20:16),_=(l>65535?1:0)?7:5,h=Math.ceil(l/this.mtu),T=new _i(this);console.debug("WebTransport send:",o?"ack":"",ne[e],i,"chunks:",h,T.groupId);for(let I=0;I<h;I++){let U=l-I*this.mtu,w=Math.min(this.mtu,U),x=new Uint8Array(_+4+w),N=di(e,x.length-_,new DataView(x.buffer));if(x[0]|=2,x.set([1,2,(I==h-1?128:0)|T.groupId,I],N),N+=4,I==0){o&&(x.set([0,0,0,0],N),N+=4);for(let W=0;W<16;W++)x[N++]=i.charCodeAt(W)}for(let W=0;N<x.length;W++)x[N++]=u.charCodeAt(p++);T.chunk.set(I,x),this.send(x.buffer)}}async send(e){if(!(!this.wt||!this.dw)){if(e instanceof ArrayBuffer){if(!e.byteLength)throw Ds}else{if(!e.length)throw Ds;e=e.slice(0)}return this.dw.write(e).catch(this.catchError)}}catchError(e){}};ce([pe(["DISCONNECTED",z.INIT],"CONNECTED")],Ye.prototype,"connect",1),ce([pe("CONNECTED","DISCONNECTED",{sync:!0,ignoreError:!0})],Ye.prototype,"disconnect",1),ce([pe([],z.INIT,{sync:!0})],Ye.prototype,"close",1);var Ds=new Error("WebTransport send empty datagram");var Cs=mr(qt(),1);var qr=class extends Cs.EventEmitter{constructor(e,r,i="userId"){super();this.mySelfId=e;this._log=r;this.key=i;d(this,"userMap",new Map);d(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:i,tinyId:o,role:u}=e;if(this.userMap.has(r))return;let p={userId:i,tinyId:o,role:u===20?"anchor":"audience"};this.userMap.set(r,p),this.emit("1",p)}deleteUser(e,r){let i=this.userMap.get(e);if(!i)return;let o=`peer leave [${e}]`;Bt(r)||(o+=`:${ys[r]}`),this._log.info(o);let u=this.remotePublishedUserMap.get(e);if(u){let p=u.muteState;u.flag=0,this.emit("5",u.userId),this.deleteRemotePublishedUser(e),this.emit("6",{prevMuteState:p,muteState:u.muteState,flag:0})}this.userMap.delete(e),this.emit("2",i.userId)}setUserList(e){this.userMap.forEach(r=>{e.findIndex(i=>i[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 i=r[this.key];if(e.findIndex(o=>o[this.key]===r[this.key])<0){this._log.info(`remote [${i}] unpublish`);let o=r.muteState;r.flag=0,this.emit("5",r.userId),this.deleteRemotePublishedUser(i),this.emit("6",{prevMuteState:o,muteState:r.muteState,flag:0})}}),e.forEach(r=>{var _;let i=r[this.key];if(i===this.mySelfId){this.emit("7",r);return}let{flag:o,userId:u,tinyId:p}=r,l=li(o,u),m=(_=this.remotePublishedUserMap.get(i))==null?void 0:_.muteState;if(m){let h=this.remotePublishedUserMap.get(i);h&&h.flag!==o&&(h.flag=o,this._log.info(`remote publish updated: ${JSON.stringify(h.muteState)}`),this.emit("6",{prevMuteState:m,muteState:l,flag:o}))}else this._log.info(`remote publish. state: ${JSON.stringify(l)}`),this.addUser({userId:u,tinyId:p,role:20}),this.emit("3",r),this.emit("6",{prevMuteState:li(0,u),muteState:l,flag:o})})}clear(){this.userMap.clear(),this.remotePublishedUserMap.clear()}};var Uc=0;var hi=function(){return Date.now()+Uc},ws=function(){let n=new Date;return n.setTime(hi()),n.toLocaleString()},Ls=function(n){let t=String(n.getMilliseconds());return"padStart"in String.prototype&&(t=t.toString().padStart(3,"0")),`${n.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")}:${t}`};function Ms(n){let t=xc(n);return t==null?void 0:t.busiBuff}function xc(n){try{let t={},e=0;t.totalLength=oe(n,e),e+=4,t.version=oe(n,e),e+=4,t.encryption=oi(n,e),e+=1,t.uinType=oi(n,e),e+=1,t.uinLength=oe(n,e),e+=4,t.uin=t.uinLength>4?Et(n,e,t.uinLength-4):"",e+=t.uinLength-4;let r=n.slice(e);if(t.encryption===2){let i=new Uint8Array(16).fill(0);n=Oc(r,i),t.decrypted=!0,e=0}else n=r,e=0;return t.rspHeadLength=oe(n,e),e+=4,t.seqNo=oe(n,e),e+=4,t.retCode=oe(n,e),e+=4,t.retStrLength=oe(n,e),e+=4,t.retStr=t.retStrLength?Et(n,e,t.retStrLength-4):"",e+=t.retStrLength-4,t.serviceCmdLength=oe(n,e),e+=4,t.serviceCmd=t.serviceCmdLength?Et(n,e,t.serviceCmdLength-4):"",e+=t.serviceCmdLength-4,t.cookieLength=oe(n,e),e+=4,t.cookie=t.cookieLength?Et(n,e,t.cookieLength-4):"",e+=t.cookieLength-4,t.flag=oe(n,e),e+=4,t.busiBuffLength=oe(n,e),e+=4,t.busiBuff=t.busiBuffLength?Et(n,e,t.busiBuffLength-4):"",e+=t.busiBuffLength-4,t}catch(t){}}function ks(n,t){let e=n[0]<<24|n[1]<<16|n[2]<<8|n[3],r=n[4]<<24|n[5]<<16|n[6]<<8|n[7];e=e>>>0,r=r>>>0;let i=vr*Pr>>>0;for(let o=0;o<Pr;o++)r-=(e<<ci)+t[2]^e+i^(e>>>5)+t[3],r=r>>>0,e-=(r<<ci)+t[0]^r+i^(r>>>5)+t[1],e=e>>>0,i-=vr,i=i>>>0;return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,e&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255])}function Oc(n,t){let e=0,r=new Uint8Array(8).fill(0),i=new Uint8Array(n.slice(0,8)),o=ks(i,t),u=o[0]&7,p=n.length-1-u-Tt-St,l=new Uint8Array(p),m=0,_=r,h=n.slice(0,8);e=8;let T=1;T+=u;for(let U=1;U<=Tt;)if(T<8)T++,U++;else if(T===8){let w=bi(n,e,_,h,o,t);_=w.ivPreCrypt,h=w.ivCurCrypt,o=w.debiBuf,e=w.bufPos,T=0}let I=p;for(;I>0;)if(T<8)l[m++]=o[T]^_[T],T++,I--;else if(T===8){let U=bi(n,e,_,h,o,t);_=U.ivPreCrypt,h=U.ivCurCrypt,o=U.debiBuf,e=U.bufPos,T=0}for(let U=1;U<=St;)if(T<8)o[T]^_[T],T++,U++;else if(T===8){if(e>=n.length)break;let w=bi(n,e,_,h,o,t);if(!w.success)break;_=w.ivPreCrypt,h=w.ivCurCrypt,o=w.debiBuf,e=w.bufPos,T=0}return l}function bi(n,t,e,r,i,o){if(t+8>n.length)return{success:!1};let u=new Uint8Array(r),p=n.slice(t,t+8),l=new Uint8Array(8);for(let _=0;_<8;_++)l[_]=i[_]^p[_];let m=ks(l,o);return{success:!0,ivPreCrypt:u,ivCurCrypt:p,debiBuf:m,bufPos:t+8}}var Bs=typeof TextDecoder!="undefined"?new TextDecoder:void 0;function Vs({url:n,body:t,method:e="POST",timeout:r,priority:i}){return new Promise((o,u)=>{if("fetch"in window)return fetch(n,{method:e,body:t,priority:i}).then(l=>l.clone().json().then(m=>({data:m}),()=>l.arrayBuffer().then(m=>({data:Ms(new Uint8Array(m))||(Bs?Bs.decode(m):m)})))).then(o,u);let p=new XMLHttpRequest;p.onreadystatechange=()=>{if(p.readyState===4)if(p.status>=200&&p.status<300)try{let l=JSON.parse(p.response);o({data:l})}catch(l){o({data:p.response})}else u({status:p.status,statusText:p.statusText||"request failed!"})},p.timeout=r||5e3,p.open(e,n,!0),p.send(t)})}var vc=Object.prototype.hasOwnProperty;var Rt=n=>typeof n=="function",Hs=n=>typeof n=="undefined";var Fs=n=>typeof n=="boolean";var Pc=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 qs(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(Pc(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(vc.call(n,t))return!1;return!0}}return!1}var Nc=0,Dc=1,Ws=2;function Cc({retryFunction:n,settings:t,onError:e,onRetrying:r,onRetryFailed:i,onRetrySuccess:o,context:u}){return function(...p){let{retries:l=5,timeout:m=1e3}=t,_=0,h=-1,T=Nc,I=async(U,w)=>{let x=u||this;try{let N=await n.apply(x,p);_>0&&o&&o.call(this,_),_=0,U(N)}catch(N){let W=()=>{clearTimeout(h),_=0,T=Ws,w(N)},Se=()=>{T!==Ws&&_<(Rt(l)?l():l)?(_++,T=Dc,Rt(r)&&r.call(this,_,W),h=window.setTimeout(()=>{h=-1,I(U,w)},Rt(m)?m(_):m)):(W(),Rt(i)&&i.call(this,N))};Rt(e)?e.call(this,{error:N,retry:Se,reject:w,retryFuncArgs:p,retriedCount:_}):Se()}};return new Promise(I)}}var Gs=Cc;var Kt=class{constructor(t){d(this,"userId");d(this,"remoteUserId");d(this,"id");d(this,"sdkAppId");d(this,"type");d(this,"isLocal");this.id=t.id,this.userId=t.userId,this.sdkAppId=t.sdkAppId,this.remoteUserId=t.remoteUserId,this.isLocal=Fs(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}`:""}]`),It.log(t,e,Hs(this.userId)||qs(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 Ce=typeof navigator=="undefined"?"":navigator.userAgent,M=n=>new RegExp(n,"i").test(Ce),re=n=>{if(M(n)){let t=new RegExp(`${n}\\/([\\d.]+)`),e=Ce.match(t);if(e&&e[1])return e[1]}return""},Wr=n=>{if(M(n)){let t=new RegExp(`${n}\\/(\\d+)`),e=Ce.match(t);if(e&&e[1])return parseFloat(e[1])}return NaN},js=/AppleWebKit\/([\d.]+)/i.exec(Ce),wc=js?parseFloat(js[1]):NaN,Ys=M("iPad"),Ks=typeof navigator!="undefined"&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&M("Macintosh"),Js=M("iPhone")&&!Ys,Lc=M("iPod"),Gr=Js||Ys||Lc||Ks,Ut=M("Android"),Xs=function(){if(Ut){let n=Ce.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}(),cf=Ut&&M("webkit")&&Xs<2.3,lf=Ut&&Xs<5&&wc<537,Mc=M("Firefox"),kc=re("Firefox"),mf=Wr("Firefox"),Qs=M("Edge"),Bc=re("Edge"),zs=M("Edg"),Vc=re("Edg"),df=Wr("Edg"),Zs=M("SogouMobileBrowser"),Hc=re("SogouMobileBrowser"),eo=M("MetaSr\\s"),Fc=re("MetaSr\\s"),st=M("TBS"),qc=re("TBS"),to=M("XWEB"),Wc=re("XWEB"),pf=M("MSIE\\s8\\.0"),Gc=M("MSIE\\/\\d+"),ff=function(){if(Gc){let n=/MSIE\s(\d+)\.\d/.exec(Ce),t=n&&parseFloat(n[1]);return!t&&/Trident\/7.0/i.test(Ce)&&/rv:11.0/.test(Ce)&&(t=11),t}return NaN}(),jc=M("(micromessenger|webbrowser)"),$c=re("MicroMessenger"),gi=!st&&M("MQQBrowser")&&M("COVC"),Ei=!st&&M("MQQBrowser")&&!M("COVC"),$s=Ei||gi?re("MQQBrowser"):"",ro=!st&&M(" QQBrowser"),Yc=re(" QQBrowser"),no=!st&&M("QQBrowserLite"),Kc=re("QQBrowserLite"),io=!st&&M("MQBHD"),Jc=re("MQBHD"),_f=M("Windows"),hf=!Gr&&M("MAC OS X"),bf=!Ut&&M("Linux"),gf=M("CrOS"),Ef=M("MicroMessenger"),Tf=M("UCBrowser"),Sf=M("Electron"),so=M("MiuiBrowser"),Xc=re("MiuiBrowser"),oo=M("HuaweiBrowser"),yf=M("Huawei")||M("HUAWEI"),Af=M("Honor")||M("HONOR"),Qc=re("HuaweiBrowser"),ao=M("SamsungBrowser"),zc=re("SamsungBrowser"),uo=M("HeyTapBrowser"),Zc=re("HeyTapBrowser"),co=M("VivoBrowser"),el=re("VivoBrowser"),If=M("OpenHarmony"),Rf=re("OpenHarmony"),tl=()=>Wr("Chrome"),lo=M("Chrome"),rl=!Qs&&!eo&&!Zs&&!st&&!to&&!zs&&!ro&&!so&&!oo&&!ao&&!uo&&!co&&lo,mo=M("HeadlessChrome"),Uf=tl(),nl=re("Chrome"),xf=Wr("Electron"),il=!lo&&!Ei&&!gi&&!no&&!io&&M("Safari");var po=re("Version"),Of=/Android.*(wv|.0.0.0)/.test(Ce),fo=(()=>{if(Ks)return po;if(Gr){let n=Ce.match(/OS (\d+)_(\d+)/i);if(n&&n[1]){let t=n[1];return n[2]&&(t+=`.${n[2]}`),t}}return""})();var vf=Number(fo.split(".")[0]);var Pf=(()=>{let n=Number(fo.split(".")[0]);return n===14||n===13})(),Nf=M("CriOS");var Df=typeof location=="undefined"?!1:location.protocol==="file:"||location.hostname==="localhost"||location.hostname==="127.0.0.1";var Cf=sl();function sl(){let n=new Map([[Mc,["Firefox",kc]],[zs,["Edg",Vc]],[rl,["Chrome",nl]],[il,["Safari",po]],[st,["TBS",qc]],[to,["XWEB",Wc]],[jc&&Js,["WeChat",$c]],[ro,["QQ(Win)",Yc]],[Ei,["QQ(Mobile)",$s]],[gi,["QQ(Mobile X5)",$s]],[no,["QQ(Mac)",Kc]],[io,["QQ(iPad)",Jc]],[so,["MI",Xc]],[oo,["HW",Qc]],[ao,["Samsung",zc]],[uo,["OPPO",Zc]],[co,["VIVO",el]],[Qs,["EDGE",Bc]],[Zs,["SogouMobile",Hc]],[eo,["Sogou",Fc]]]),t="unknown",e="unknown";return n.has(!0)&&([t,e]=n.get(!0)),{name:t,version:e}}var _o=mr(qt(),1),ol=new _o.default,Oe=ol;var jr=(R=>(R.ROOM_DESTROY="1",R.JOIN_START="21",R.JOIN_SCHEDULE_SUCCESS="22",R.JOIN_SIGNAL_CONNECTION_START="23",R.JOIN_SIGNAL_CONNECTION_END="24",R.JOIN_SEND_CMD="25",R.JOIN_RECEIVED_CMD_RES="26",R.JOIN_SUCCESS="27",R.JOIN_FAILED="28",R.LEAVE_START="51",R.LEAVE_SEND_CMD="52",R.LEAVE_SUCCESS="53",R.PUBLISH_START="61",R.SEND_FIRST_VIDEO_FRAME="62",R.PUBLISH_FAILED="63",R.SUBSCRIBE_START="81",R.SUBSCRIBE_SUCCESS="82",R.SUBSCRIBE_FAILED="84",R.UNSUBSCRIBE_SUCCESS="83",R.LOCAL_TRACK_CAPTURE_START="101",R.LOCAL_TRACK_CAPTURE_SUCCESS="102",R.LOCAL_TRACK_CAPTURE_FAILED="103",R.LOCAL_TRACK_PUBLISHED="104",R.LOCAL_TRACK_UNPUBLISHED="105",R.LOCAL_TRACK_REPLACED="106",R.SWITCH_DEVICE_SUCCESS="107",R.TRACK_MUTED="108",R.TRACK_UNMUTED="109",R.REMOTE_TRACK_SUBSCRIBED="110",R.REMOTE_TRACK_UNSUBSCRIBED="111",R.LOCAL_TRACK_RECAPTURE="112",R.LOCAL_AUDIO_STARTED="113",R.LOCAL_AUDIO_STOPPED="114",R.REMOTE_AUDIO_STARTED="115",R.REMOTE_AUDIO_STOPPED="116",R.PLAY_TRACK_START="151",R.PLAYER_STATE_CHANGED="152",R.VIDEO_LOADED_DATA="153",R.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",R.AUDIO_CONTEXT_LONG_SUSPENDED="155",R.SIGNAL_CONNECTION_STATE_CHANGED="201",R.PEER_CONNECTION_STATE_CHANGED="202",R.SINGLE_CONNECTION_STAT="203",R.SPC_RECONNECTED="204",R.HEARTBEAT_REPORT="251",R.RECEIVED_PUBLISHED_USER_LIST="252",R.REMOTE_PUBLISH_STATE_CHANGED="253",R.AUDIO_LEVEL_INTERVAL="260",R.NETWORK_QUALITY="261",R.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",R.QUALITY_LIMITATION_CHANGED="263",R.LOG="264",R.AUDIO_PROCESSOR_DEBUG="265",R.SSO_SWITCH="266",R.SWITCH_ROOM_START="401",R.SWITCH_ROOM_SUCCESS="407",R.SWITCH_ROOM_FAILED="408",R))(jr||{});var Ke=jr;var Ti=class{constructor(){d(this,"enable",!1);d(this,"ssoFailCount",0);Oe.on("22",({schedule:t})=>{var e;(e=t==null?void 0:t.config)!=null&&e.sso&&Oe.emit("266",{enable:!0})}),Oe.on("266",({enable:t})=>{this.enable=t})}handleUploadFailed(){this.ssoFailCount++,this.ssoFailCount>3&&Oe.emit("266",{enable:!1})}},Si=new Ti;var al="%cTRTC%c%s",ul="padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;",cl="display: inline",$r=class $r{constructor(){d(this,"_isEnableUploadLog",!0);d(this,"_localJoinedUser",new Map);d(this,"_queue",[]);d(this,"_timeoutId",-1);d(this,"_logLevel",1);d(this,"_logLevelToUpload",2);!_s&&!Rr&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&this._timeoutId!==-1}installEvents(){Oe.on(Ke.JOIN_SCHEDULE_SUCCESS,({schedule:t})=>{var e;(e=t==null?void 0:t.config)!=null&&e.logLevelToUpload&&ke[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)}),Oe.on(Ke.JOIN_SUCCESS,({room:t})=>{this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()}),Oe.once(Ke.JOIN_FAILED,()=>{this.startUpload()}),Oe.on(Ke.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:i,sdkAppId:o})=>{t.map.has(i)?t.map.get(i).logs.push(r):t.map.set(i,{userId:i,sdkAppId:o,logs:[r]})});else if(kt(r.userId)&&Rs(r.sdkAppId)){let{userId:i,sdkAppId:o}=r;t.map.has(i)?t.map.get(i).logs.push(r):t.map.set(i,{userId:i,sdkAppId:o,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 i=[...t.values()];for(let o=0;o<i.length;o++){let{userId:u,sdkAppId:p,logs:l}=i[o],m={timestamp:ws(),sdkAppId:String(p),userId:u,version:rt,log:l.map(T=>T.log).join(`
2
+ `)},_=JSON.stringify(m),h=Si.enable?Us(m,2002,p):_;await this.uploadLogWithRetry(h,p,h instanceof Uint8Array,_),l.forEach(T=>T.uploaded=!0)}}catch(i){}let r=e.filter(i=>!i.uploaded);r.length>0&&(this._queue=r.concat(this._queue))}uploadLogWithRetry(t,e,r,i){return Gs({retryFunction:()=>Vs({url:Is(e,gs.LOG),body:t,timeout:5e3,priority:"low"}).then(o=>{r&&o.data!=="ok"&&(Si.handleUploadFailed(),this.uploadLogWithRetry(i,e,!1,i))}),settings:{retries:3,timeout:2e3},onError:({retry:o})=>{o()}})()}getPrefix(t){let e=new Date;return e.setTime(hi()),`[${Ls(e)}] <${ke[t]}>`}getLogLevel(){return this._logLevel}setLogLevel(t){Bt(ke[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(kt(t))return t;try{return t instanceof Error?t.toString():JSON.stringify(t)}catch(e){return""}}addLogToQueue(t,e,r=!0,i,o){let u={log:e.reduce((p,l)=>`${p} ${this.logChunkToString(l)}`.trim(),""),level:t,userId:i,sdkAppId:o,forAllJoinedClients:r};Oe.emit(Ke.LOG,{log:u}),this._isEnableUploadLog&&t>=this._logLevelToUpload&&this._queue.push(u)}log(t,e,r=!0,i,o){var p;if(e.unshift(this.getPrefix(t)),this.addLogToQueue(t,e,r,i,o),t<this._logLevel)return;let u=((p=ke[t])==null?void 0:p.toLowerCase())||"info";$r.PRINT_LOG_TAG?console[u](al,ul,cl,...e):console[u](...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 Kt(t)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),r=e?Number(e):-1;ke[r]&&(this._logLevelToUpload=r)}getQueue(){return this._queue}};d($r,"PRINT_LOG_TAG",!(Gr||Ut||mo));var yi=$r,It=new yi;function ho(n,t=1,e=1){return n<=1?e:ho(n-1,e,t+e)}function pl(n){return n>8?30*1e3:ho(n)*1e3}function fl(n,t){return{userId:t,hasAudio:!!(n&ht),hasVideo:!!(n&_t),hasAuxiliary:!!(n&xr),hasSmall:!!(n&Ur),audioMuted:!!(n&bt),videoMuted:!!(n&gt),audioAvailable:!!(n&ht)&&!(n&bt),videoAvailable:!!(n&_t)&&!(n&gt)}}var Ai=class{constructor(t){this.connect=t;d(this,"publishReq");d(this,"recovering",!1);d(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}}},ge=class ge extends z{constructor(e,r,i){super(i.joinReq.roomid,"Connection");this.id=e;this.port=r;d(this,"signalInfo_");d(this,"reqUser_");d(this,"joinReq");d(this,"frameWorkType");d(this,"userManager");d(this,"joinRes");d(this,"statReportReq");d(this,"qualityReportReq");d(this,"wFSM");d(this,"rtt",50);d(this,"recovery",new Ai(this));d(this,"reqPromise",new Map);d(this,"rebuild");d(this,"osName");d(this,"browserInfo");d(this,"tinyId_",new B(32));d(this,"tinyId");d(this,"domains");d(this,"log_");d(this,"params");d(this,"proxy_ws");d(this,"proxy_wt");d(this,"proxy_cloud");d(this,"proxy_unified");d(this,"env");d(this,"wh");d(this,"abortCtrl",new AbortController);d(this,"firstReceiveUserlist");d(this,"connectParams");d(this,"selectDomain",0);d(this,"selectCloudDomain",0);d(this,"abort",this.abortCtrl.abort.bind(this.abortCtrl));d(this,"reconnectedOB",Te(this,"RECONNECTED"));d(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,i),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_=It.createLogger({id:`wc${e}`,userId:this.params.userId,sdkAppId:this.params.sdkAppId}),this.proxy_unified?te.useWt=!1:(this.proxy_ws||this.proxy_wt)&&(te.useWt=!!this.proxy_wt),te.useWt?this.wFSM=new Ye(this):this.wFSM=new $e(this),this.userManager=new qr("",this.log_,"tinyId");let o=u=>this.userManager.on(u,p=>this.postMessage({cmd:u,payload:p}));this.userManager.on("3",({flag:u,userId:p,tinyId:l})=>{let m={flag:u,userId:p,tinyId:l,get muteState(){return fl(this.flag,this.userId)},subscribe:0,removing:!1};this.log_.debug("create user",m),this.postMessage({cmd:"3",payload:m}),this.userManager.addRemotePublishedUser(new kr(m,this))}),o("6"),o("5"),o("1"),o("2"),o("7"),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=(i,o=!1)=>u=>{if(this.aborted||typeof u=="number")throw u;return this.selectDomain=i,this.wFSM=o?new Ye(this):new $e(this),console.warn(u),console.warn("downgrade to",o?"WebTransport":"WebSocket",this.selectDomain?"\u5907\u7528\u57DF\u540D":"\u4E3B\u57DF\u540D"),this.wFSM.connect()};return te.useWt&&(this.proxy_ws||!this.proxy_wt)&&(e=e.catch(r(0))),!this.proxy_wt&&!this.proxy_ws&&(e=e.catch(r(1,te.useWt)),te.useWt&&(e=e.catch(r(1)))),e}async joinRoom(){let{dataport:e,stunport:r,relayip:i,socketid:o,checkSigSeq:u}=this.signalInfo_,p=await this.sendReq(0,Object.assign(this.joinReq,{dataport:e,stunport:r,relayip:i,socketid:o,checkSigSeq:u}));if(p.err===0)this.setJoinRes(p.data);else throw p.err;return p}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(nt(),"retry",e),e>Ss){this.close();return}let r=Ge(pl(e));F(e?cs(r,this.reconnectOB):this.reconnectOB,hr(1),Ue(this.reconnectedOB),X(i=>{typeof i!="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 i=this.generateUUID();return await this.wFSM.sendReq(e,r,i),je((o,u)=>this.reqPromise.set(i,{resolve:o,reject:u,startTime:Date.now()}),this.abortCtrl.signal,o=>(console.log("abort",ne[e]),{err:o}))}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=>{V._CreateUdtPacketizer(e.roomid,this.tinyId_.point,e.locationid,r,V.udtver,this.id)}),this.wFSM.sendReq(6,{})}onReceive(e,r,i){let o="",u=0,p=new DataView(i.buffer,i.byteOffset);r<255&&(u=p.getUint32(0),i=i.subarray(4)),r<4095&&(o=String.fromCharCode(...i.subarray(0,16)),i=i.subarray(16));let l=i;if(!o)p=new DataView(i.buffer,i.byteOffset,i.byteLength);else{let _="";for(let h=0,T=i.length,I=32768;h<T;h+=I)_+=String.fromCharCode.apply(null,i.subarray(h,Math.min(h+I,T)));if(u)l=_;else try{l=JSON.parse(_)}catch(h){l=_}}let m=ne[r];switch(r){case 259:this.joinRes&&this.wFSM.sendReq(r,{tinyid:this.joinRes.tinyid}),console.debug(e,"receive:",m,o,l);break;case 256:l.userlist.forEach(x=>{if(this.userManager.addUser({userId:x.userid,tinyId:x.srctinyid,role:x.role}),this.joinRes&&x.srctinyid!=this.joinRes.tinyid&&this.userManager.userMap.has(x.srctinyid)){let N=this.userManager.userMap.get(x.srctinyid);this.sendSubscribe(N)}}),this.log_.info(e,"receive:",m,o,l),this.wFSM.sendReq(r,{count:this.userManager.userMap.size});break;case 257:this.userManager.deleteUser(l.userlist.srctinyid),this.log_.info(e,"receive:",m,o,l),this.wFSM.sendReq(r,{count:this.userManager.userMap.size});break;case 6:this.userManager.setUserList(l.userlist.map(x=>({userId:x.userid,tinyId:x.srctinyid,role:x.role})));break;case 255:this.wFSM.sendReq(r,{count:this.userManager.userMap.size});{let x=l.userlist.map(N=>({userId:N.userid,tinyId:N.srctinyid,flag:N.flag,terminalType:N.terminaltype}));this.firstReceiveUserlist||(this.firstReceiveUserlist=!0,this.postMessage({cmd:Ke.RECEIVED_PUBLISHED_USER_LIST,payload:{publishedUserList:x}})),this.userManager.setRemotePublishedUserList(x),this.recovery.recovering&&this.recovery.recoverRemote(this.userManager.remotePublishedUserMap)}break;case 4100:this.rtt=p.getUint32(4),console.debug(e,"receive:",m,o,l,this.rtt);let{dv:_,writeData:h}=Ht(4101,8);h(i.subarray(0,4)),this.send(_.buffer);break;case 12:this.reqPromise.forEach(x=>{Date.now()-x.startTime>5e3&&(x.reject(new Error("heartbeat timeout")),this.reqPromise.delete(x.uuid))}),self.postMessage({type:"glog",payload:{heartbeatReceive:1}});case 11:case 260:console.debug(e,"receive:",m,o,l);case 7:case 4095:break;case 4096:case 4097:{let x=i.length;this.statReportReq.stat.msg_net_stat_report.uint32_down_real_pkg++,this.statReportReq.stat.msg_net_stat_report.uint32_down_recv_br+=x<<3;let N=p.getBigUint64(9).toString(),W=this.userManager.getPublishedUser(N);W?r===4096?(W.mainPuller.videoStatus.uint32_video_receive||console.timeLog(`${W.userId}big`,"first video data"),W.mainPuller.demuxPacket(i)):(W.screenPuller.videoStatus.uint32_video_receive||console.timeLog(`${W.userId}aux`,"first video data"),W.screenPuller.demuxPacket(i)):console.warn(e,"receive:",m,o,l,"user not found")}break;case 4102:case 4103:case 4099:break;case 4103:V.HEAPU8.set(i,B.global.point+8);let T=V._ParseUdtMousePacket(B.global.point+8,i.length,B.global.point),I=i.subarray(T),U=B.global.getBigUint64(0).toString(),w=this.userManager.userMap.get(U);w&&this.postMessage({cmd:"layerData",payload:{userId:w.userId,tinyId:U,layerData:I}}),console.debug(e,"receive:",m,T,l,U,I);break;case 4098:{let x=p.getUint8(8);for(let N=9;N<i.length;N+=6){let W=p.getUint32(N),Se=p.getUint16(N+4);for(let ye=0;ye<=16;ye++){if(ye>0&&(Se>>16-ye&1)==0)continue;let Ae=V._GetRetransPacket(x,W+ye,B.global.point,this.id),ie=B.global.getUint32(0),fe=V.HEAPU8.subarray(ie,ie+Ae);Ae>0&&this.send(fe)}}}break;case 1:this.log_.info(e,"receive:",m,o,l),l>0&&l!==3&&(this.postMessage({cmd:"banned",payload:l}),this.close());break;case 258:this.log_.info(e,"receive:",m,o||"",l);break;default:this.log_.info(e,"receive:",m||r,o||"",l)}this.reqPromise.has(o)&&(u&&this.log_.warn(u,l,o),this.reqPromise.get(o).resolve({err:u,data:l,uuid:o}),this.reqPromise.delete(o)),this.emit(m,o?{uuid:o,err:u,data:l}:{data:l})}sendSubscribe(e){let r=e.subscribe;if(r==0)return;let i={mediaType:r,mediaDescription:{audioParam:r&1?{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]}:void 0,videoParam:[4,8,2].filter(o=>r&o).map(o=>({mediaType:o,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]}))},userId:e.userId,srctinyid:e.tinyId};this._sendReq(4,i)}createOputReceiver(e){return new me(this.unMarshal(e))}*unMarshal(e){let r=null,i=new Map;for(;;){let o=0,u=0;try{r=yield 1;let p=r[0]>>4,l=r[0]&2,m=r[0]&1;r=yield 4+m*2;let _=new DataView(r.buffer,r.byteOffset);if(u=_.getUint16(0),o=m==1?_.getUint32(2):_.getUint16(2),r=yield o,l){let h=r[0]&63,T=r[1],I=r.subarray(2,2+T);switch(h){case 1:let U=I[0]>>7,w=I[0]&127,x=I[1],{dv:N,write8:W}=Ht(4099,2);W(w),W(x),this.send(N.buffer);let Se=w%64;for(let Ae=0;Ae<64;Ae++){let ie=w-Ae;ie<0&&(ie+=64);let fe=Se-Ae;fe<0&&(fe+=64),i.has(fe)&&i.get(fe).groupId!=ie&&i.delete(fe)}let ye=i.get(Se);if(ye||i.set(Se,ye=new Ii(w)),r=ye.push(x,r.slice(2+T),U!=0),r)i.delete(Se);else continue}}this.onReceive(e,u,r)}catch(p){this.log_.error(e,p,o,u,r)}}}generateUUID(){return"xxxxxxxxxxxxxxxx".replace(/[xy]/g,e=>{let r=Math.random()*16|0;return(e=="x"?r:r&3|8).toString(16)})}};d(ge,"JOINED","joined"),d(ge,"CLOSED","closed"),ce([pe(z.INIT,"CONNECTED")],ge.prototype,"connect",1),ce([pe("CONNECTED",ge.JOINED)],ge.prototype,"joinRoom",1),ce([pe("RECONNECTED",ge.JOINED,{fail(){this.close()}})],ge.prototype,"rejoinRoom",1),ce([pe("DISCONNECTED","RECONNECTED")],ge.prototype,"reconnect",1),ce([pe([],"DISCONNECTED",{sync:!0})],ge.prototype,"disconnect",1),ce([pe([],ge.CLOSED,{sync:!0})],ge.prototype,"close",1);var Je=ge,Ii=class{constructor(t){this.groupId=t;d(this,"chunks",[]);d(this,"totalLen",0);d(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 o=0;o<this.chunks.length;o++)if(!this.chunks[o])return null;let i=new Uint8Array(this.totalLen);for(;this.chunks.length;){let o=this.chunks.pop();i.set(o,this.totalLen-=o.length)}return i}return null}};var Jt=class extends be{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:i}=t,o={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(u=>({userid:u.userId,width:u.width,height:u.height,locationX:u.locationX,locationY:u.locationY,zOrder:u.zOrder,streamType:u.streamType,inputType:u.inputType})),outputParam:{streamId:i.streamId,streamType:i.streamType,videoWidth:i.width,videoHeight:i.height,videoBitrate:i.videoBps,videoFramerate:i.fps,vidoeGOP:i.gop,audioSampleRate:i.audioSampleRate,audioBitrate:i.audioBps,audioChannels:i.audioChannels,backgroundColor:i.backgroundColor,backgroundImage:i.backgroundImg,extraInfo:i.extraInfo,VCodec:i.videoCodec,ACodec:i.audioCodec}};return this.send(15,o).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 _l=1200;var hl=31,bl=6,gl=6;var bo={1:1,audio:1,video:4,2:4,auxVideo:2,7:2,3:8};var B_=Date.now(),V_=hl+bl+6+gl+_l+1;var Xt=class extends be{constructor(){super(...arguments);d(this,"videoEncBuffer_",new B(1920*1080*3>>1));d(this,"videoStats",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0});d(this,"audioStats",{bytesSent:0,packetsSent:0});d(this,"videoTypeIndexMap",new Map([[2,0]]));d(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:i,index:o},u,p){var I;let l=new B(e*r*2),m=U=>{this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_level=U.volume*1e8/100>>0;let{data:w}=U,x=w.length;l.set(w),this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_enc_br+=x<<3,this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_frame_interval++,this.audioStats.packetsSent++;let N=V._PacketizeAudioUdt(l.point,x,U.timestamp,e,r,U.energy,B.global.point,B.global.size,this.io.id,!!p);if(N<=0){console.warn("audio pack len is 0");return}this.io.send(B.global.uint8Array(N)),this.audioStats.bytesSent+=N,this.statReportReq.msg_audio_stat_report.msg_audio_send_stat.uint32_audio_send_br+=N<<3,this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_receive++},_=U=>{l.free(),this.send(3,{mediaType:1})},h=new MessageChannel;(I=this.io.wh.playPort)==null||I.postMessage({cmd:"pushAudio",payload:{numberOfChannels:r,bitrate:i},encrypt:!!p,index:o},[h.port2,u.port]);let T=Vt(h.port1);p&&F(T,X()),F(p||T,X(m,_,_))}createSelectAbilityOb(e,r){let i=r.bitrate;return F(this.createResposeOb(259),ds(()=>Ge(2e3)),tt(o=>{var u;return(u=o.data.ability.rpt_msg_video_control_info)==null?void 0:u.find(p=>p.uint32_video_type===e)}),ft(o=>{if(!o)return!1;let u=o.uint32_video_enc_br,p=u*Math.pow(1-this.qualityReport.msg_up_stream_info.msg_network_status.uint32_lost/100,2),l=Math.min(i,p);o.uint32_video_enc_br=l,this.glog({[`confBr${e}`]:[u,p,l]});let m=!1;return((h,T)=>{o[T]&&o[T]!==r[h]&&(m=!0,r[h]=o[T])})("bitrate","uint32_video_enc_br"),m}),Xn(r))}pushVideo({profile:{width:e,height:r,frameRate:i,bitrate:o},type:u,trackType:p,crypto:l},m){this.videoStats.frameWidth=e,this.videoStats.frameHeight=r;let _=0,h=bo[u];this.videoTypeIndexMap.has(u)?_=this.videoTypeIndexMap.get(u):(_=this.statReportReq.rpt_msg_video_stat_report.length,this.requestTypeMap.set(_,u===7?4097:4096),this.videoTypeIndexMap.set(u,_),this.statReportReq.rpt_msg_video_stat_report.push({uint32_video_type:u,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:u,uint32_video_codec_type:0,uint32_video_decode_frame:0,uint32_video_total_frame:0,uint32_video_width:e,uint32_video_height:r}));let T={width:e,height:r,bitrate:o*1e3,framerate:i};Object.assign(this.qualityReport.msg_up_stream_info.msg_video_status[_],{uint32_video_width:e,uint32_video_height:r});let I=0,U=!1,w=N=>{this.send(3,{mediaType:h})};F(this.createSelectAbilityOb(u,T),X(()=>{m.postMessage(T)}));let x=m;p!="camera"&&(this.io.log_.info(`push ${p} track`),x=us(m,F(m,fs(2e3),Qn(N=>(this.io.log_.warn("start push last video frame"),F(xe(2e3),Xn(N),Ue(m),Ir({complete:()=>this.io.log_.warn("stop push last video frame")})))),Be(m)))),F(x,X(N=>{let W=this.getVideoStatus(_);W.uint32_video_total_frame++,I++,this.videoStats.framesSent++,W.uint32_video_capture_fps++,I%300==0&&m.postMessage(260),this.handleVideoEncoded(N,u,l)},w,w)),F(this.createResposeOb(260),Be(m),X(()=>m.postMessage(260)))}getVideoStatus(e){return this.qualityReport.msg_up_stream_info.msg_video_status[e]}handleVideoEncoded(e,r,i){let{chunk:o,timestamp:u}=e;this.videoStats.framesEncoded++;let p=this.videoTypeIndexMap.get(r),l=this.getVideoStatus(p);l.uint32_video_decode_frame++,l.uint32_video_codec_fps++,l.uint32_video_enc_fps++,this.statReportReq.rpt_msg_video_stat_report[p].msg_video_enc_stat.uint32_video_enc_fps++;let m="byteLength"in o?o.byteLength:o.data.length;if(this.statReportReq.rpt_msg_video_stat_report[p].msg_video_enc_stat.uint32_video_enc_br+=m<<3,m>this.videoEncBuffer_.size){console.log("buffer too small!");return}"byteLength"in o?o.copyTo(this.videoEncBuffer_.uint8Array(m)):this.videoEncBuffer_.set(o.data),B.global.fill();let _=V._PacketizeVideoUdt(this.videoEncBuffer_.point,m,u,o.type=="key"?1:0,r,B.global.point,this.io.id,i);this.sendUdtv3Video(_,p)}sendUdtv3Video(e,r){let i=0,o=B.global.uint8Array();for(let u=0;u<e;u++){let p=B.global.getUint32(i);if(p<=0){this.io.log_.warn("sendUdtv3Video pktSize is ",p);continue}this.io.send(o.subarray(i+=4,i+=p)),this.statReportReq.rpt_msg_video_stat_report[r].msg_video_send_stat.uint32_video_send_br+=p<<3,this.videoStats.bytesSent+=p,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 i={mediaType:e,mediaDescription:{audioParam:e&1?{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]}:void 0,videoParam:[4,8,2].filter(o=>e&o).map(o=>({mediaType:o,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]}))}};this.send(2,i).then(o=>{r.postMessage(o),r.postMessage(null)})}};var El=2,Qt=class extends be{addEventMsgs(t){this.qualityReport.msg_event_msg=t}constructor(t){super(t);let e,r=Te(t,Je.JOINED),i=Te(t,Je.CLOSED),o={};F(r,wt(xe(1e3)),Ue(i),X(l=>{let m=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=m,this.statReportReq.msg_rtt_info_req.uint32_delay_since_last_server_timestamp_ms=e&&m-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,T)=>h+T.msg_video_send_stat.uint32_video_send_br,0),o.bandwidth=this.statReportReq.msg_down_bandwidth_est.uint32_avg_bandwidth_br,o.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,T)=>{let I=this.statReportReq.rpt_msg_video_stat_report[T];h.uint32_video_total_bitrate=I.msg_video_send_stat.uint32_video_send_br,_[I.uint32_video_type==7?3:I.uint32_video_type-1]=h.uint32_video_codec_bitrate=I.msg_video_enc_stat.uint32_video_enc_br}),o.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 u=F(this.createResposeOb(12),Ir(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))}));F(r,wt(u),wt(Ge(Es)),Ue(i),X(()=>{this.io.log_.warn("ping timeout,lastrecv:",e,"now:",Date.now()),this.io.state==Je.JOINED&&this.io.wFSM.disconnect("ping timeout")}));let p=new B(52);F(r,wt(xe(El*1e3)),Ue(i),X(l=>{let m=[...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=m.map(U=>{var N,W;let w=U.toDownStreamInfo(U,l%10===0),x=[w.msg_audio_status.uint32_audio_codec_bitrate];return x[1]=w.msg_video_status[0].uint32_video_codec_bitrate,x[2]=((N=w.msg_video_status[1])==null?void 0:N.uint32_video_codec_bitrate)||0,o[`RemoteBr_${U.userId}`]=x,o[`RemoteBlock_${U.userId}`]=[w.msg_audio_status.uint32_audio_block_cnt,w.msg_video_status[0].uint32_video_block_cnt,((W=w.msg_video_status[1])==null?void 0:W.uint32_video_block_cnt)||0],w}),this.glog(o),o={};let _=this.qualityReport.msg_down_stream_info.map(U=>({userId:U.msg_user_info.str_identifier,rtt:U.msg_network_status.uint32_rtt,loss:U.msg_network_status.uint32_lost})),h=Tl(_),T=this.qualityReport.msg_up_stream_info.msg_network_status.uint32_rtt,I=this.qualityReport.msg_up_stream_info.msg_network_status.uint32_lost;this.postMessage("network-quality",{uplinkNetworkQuality:this.io.state!="DISCONNECTED"?go(I,T):6,downlinkNetworkQuality:go(h.loss,h.rtt),uplinkInfo:this.qualityReport.msg_up_stream_info,msg_down_stream_info:this.qualityReport.msg_down_stream_info,downlinkInfo:_,uplinkRTT:T,uplinkLoss:I,downlinkRTT:h.rtt,downlinkLoss:h.loss}),this.qualityReport.msg_up_stream_info.msg_video_status.forEach(U=>{U.uint32_video_capture_fps>>=1,U.uint32_video_codec_fps>>=1,l%10===0&&console.log(nt(),"video uplink fps:",U.uint32_video_stream_type,U.uint32_video_capture_fps,U.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(U=>{U.uint32_video_capture_fps=0,U.uint32_video_codec_fps=0,U.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),p.free()}))}};function Tl(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 go(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 zt=class extends be{async subscribe(t,e){let{mediaType:r,srctinyid:i}=t,o=this.userMap_.get(i);if(o){if(o.subscribe|=t.mediaType,t.mediaType=o.subscribe,e)e.postMessage(await this.send(4,t));else return this.send(4,t);r===1&&o.startPullOnlyAudio(o.mainPuller,e,{mediaType:r,srctinyid:i})}}async unSubscribe(t,e){let{mediaType:r,srctinyid:i}=t,o=this.userMap_.get(i);if(o){let u=o.subscribe;o.subscribe&=~r,u!==o.subscribe&&e.postMessage(await(o.subscribe===0?this.send(5,t):this.io.sendSubscribe(o)))}}pullVideo({mediaType:t,tinyId:e},r){let i=this.userMap_.get(e);i&&i.startPull(t===2?i.screenPuller:i.mainPuller,r,{mediaType:t,srctinyid:e})}changetype(t){let{mediaType:e,srctinyid:r}=t,i=this.userMap_.get(r);if(i){let o=i.subscribe;e===8?(i.subscribe|=8,i.subscribe&=-5):e===4&&(i.subscribe|=4,i.subscribe&=-9),o!=i.subscribe&&(t.mediaType=i.subscribe,this.send(4,t))}}};var Ri=class extends Wt{constructor(e,r,i,o){super();this.seq=e;this.player=r;this.numberOfChannels=i;this.bitrate=o;d(this,"aecPtr");d(this,"encodePrt");d(this,"tenms",sampleRate/100);d(this,"numberOfFrames",this.tenms<<1);d(this,"float32Array");d(this,"pos",0);d(this,"bufferLen",0);d(this,"outputPort");d(this,"mainPort");d(this,"workerPort");d(this,"outPrt");d(this,"audioCaptBuff");d(this,"oput");d(this,"first10ms");d(this,"dumpPort");d(this,"encodeCount",0);this.wasmBinary=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(te.useAINS),this._SetAudioFrameFormat(sampleRate,this.numberOfChannels),this._InitOpusEncoder(sampleRate,this.numberOfChannels,1),this.bitrate&&this._SetOpusEncBitrate(this.bitrate*1e3),console.log(rt,"audio worklet initialized",sampleRate,this.numberOfChannels,this.seq),this.oput=new me,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 i of e){this.float32Array.set(i,this.bufferLen),this.bufferLen+=i.length;let o=0;for(;this.bufferLen-this.pos>=this.tenms;){let u=this.player.delay+(this.bufferLen-this.pos)/(sampleRate/1e3)+20>>0,p=this._AudioProcessFloat(this.encodePrt+this.pos*4,this.tenms,u);if(o<p&&(o=p),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 m=this.HEAPU8.slice(this.outPrt,this.outPrt+l),_=o*100/32768;this.mainPort.postMessage(_),this.outputPort.postMessage({data:m,volume:_,energy:o,timestamp:Date.now()},[m.buffer]),o=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 Eo(n){class t extends AudioWorkletProcessor{constructor(i){super();d(this,"oput",new me);d(this,"wasm");d(this,"encoders",[]);d(this,"useAINS",!0);console.log("worklet created:",sampleRate),this.wasm=i.processorOptions.wasm,Object.assign(te,i.processorOptions.flag),this.port.onmessage=o=>{o.ports[0].onmessage=u=>this.pushAudio(u)}}get delay(){var i;return(((i=this.oput.buffer)==null?void 0:i.length)||0)/(sampleRate*4/1e3)}process(i,o){return this.oput.demand(o[0][0],!0),this.encoders.forEach((u,p)=>u.encode(...i[p])),!0}pushAudio(i){if(i.data instanceof Uint8Array){let{data:o}=i;this.encoders.forEach(u=>o=u.aec(i.data)),this.oput.malloc(o.length).set(o);return}switch(console.log("worklet receive",i.data.cmd),i.data.cmd){case"dump":switch(i.data.payload){case"mic0":this.encoders[0].dumpPort=i.ports[0];break}break;case"useAINS":te.useAINS=i.data.payload,this.encoders.forEach(o=>o._UseAINS(i.data.payload));break;case"enableAEC":this.encoders.forEach(o=>o._EnableAEC(i.data.payload));break;case"enableDebug":console.debug=i.data.payload?Nr:()=>{};break;case"pushAudio":{let[o,u]=i.ports,{payload:{numberOfChannels:p,bitrate:l},encrypt:m,index:_}=i.data,h=this.encoders[_]||new Ri(_,this,p,l);this.encoders[_]?(h.bitrate=l,h._SetOpusEncBitrate(l*1e3)):n(h),h.reset(),h.mainPort=u,h.workerPort=o,h.outputPort=m?u:o,u.onmessage=T=>{T.data?h.encode(T.data):(console.log(nt(),"encoder",_,"stopped"),o.postMessage(null))}}}}}registerProcessor("global-audio-player",t)}var Ui=class{constructor(){d(this,"playPort");d(this,"dumpPort");d(this,"downlinkAudioCount",0);d(this,"interval10ms",F(pt(10),We()));d(this,"ios")}glog(t){self.postMessage({type:"glog",payload:t})}async joinRoom(t){let{data:{id:e,payload:r},ports:i}=t,o=new Je(e,i[0],r);o.wh=this;let u=[new Xt(o),new zt(o),new Gt(o),new Qt(o),new Jt(o)],p=(m="leave room")=>{o.leaveRoom().catch(),o.abort(m),this.ios.delete(o)},l=setTimeout(o.abort,5e3,"timeout");F(Vt(o.port,!0),X(({data:{cmd:m,payload:_},ports:h})=>{switch(console.log(self.name,"received message",m),m){case"setAudioWorkletPort":this.playPort=h[0];break;case"switchRole":o.sendReq(20,{role:_,privateMapKey:o.params.privateMapKey}).then(I=>h[0].postMessage(I));break;default:let T=h.map(I=>Vt(I));typeof _!="undefined"&&T.unshift(_),u.forEach(I=>{var U;(U=I[m])==null||U.call(I,...T)})}},p,p));try{await o.connect(),postMessage({id:e,payload:await o.joinRoom()}),clearTimeout(l),this.ios.add(o)}catch(m){m instanceof WebTransportError?m=`Transport initialization failed.
3
3
  Reason: ${m.message}.
4
4
  Source: ${m.source}.
5
- Error code: ${m.streamErrorCode}.`:m instanceof rt?m=m.cause:m instanceof Event&&(m=m.type),postMessage({id:e,payload:{err:m}}),o.close()}}};function gl(n){self.onmessage=async t=>{let e=setTimeout(()=>{self.postMessage({type:"error",payload:"timeout"})},5e3);try{t.data.wasm&&(V.wasmBinary=t.data.wasm),Object.assign(te,t.data.flag),console.time(`Worker[${self.name}${et}]`),V.postRun=[()=>{B.global=new B(1920*1080*3>>1),V._CreateMediaProcessing(0,1,0,!1),console.timeEnd(`Worker[${self.name}${et}]`),V._UseAINS(te.useAINS),this.ios=new Set,t.ports[0].onmessage=l=>{var h,T,I;let[m,_]=l.data;switch(m){case"dump":switch(_){case"audio":this.dumpPort=l.ports[0];break;case"mic0":(h=this.playPort)==null||h.postMessage({cmd:m,payload:_},l.ports);break}break;case"useAINS":V._UseAINS(_),(T=this.playPort)==null||T.postMessage({cmd:m,payload:_});break;case"enableDebug":console.debug=_?Pr:()=>{},(I=this.playPort)==null||I.postMessage({cmd:m,payload:_});break;case"useV2":V.udtver=_?2:3;break;case"useWt":te.useWt=_;break;case"enableAEC":V._EnableAEC(_);break}};let r=0,i=Date.now(),o=0;F(xe(1e3),X(()=>{let _=(Date.now()-i)/10-r;console.debug("interval10ms:",_,_-o),o=_,V._UpdateStreamSync()})),V._SetAudioOutStreamFormat(48e3,1);let u=V._malloc(3*4),p=new B(1920);F(this.interval10ms,X(()=>{if(r++,V._GetAudioMixedFloat(p.point,48e3,u)>=0){if(this.playPort){let m=p.uint8Slice();this.playPort.postMessage(m,[m.buffer])}if(this.dumpPort){let m=p.uint8Slice();this.dumpPort.postMessage(m,[m.buffer])}this.ios.forEach(m=>m.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(V)}catch(r){self.postMessage({type:"error",err:r})}}}var bo=Ir?ho:gl.bind(new Ai);var El=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,i;e.ready=new Promise(function(s,a){r=s,i=a});var o={},u;for(u in e)e.hasOwnProperty(u)&&(o[u]=e[u]);var p=[],l="./this.program",m=function(s,a){throw a},_=typeof window=="object",h=typeof importScripts=="function",T=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",I=!_&&!T&&!h,U="";function C(s){return e.locateFile?e.locateFile(s,U):U+s}var x,N,W,Se;function ye(s){if(!(s instanceof Bu)){var a=s;ie("exiting due to exception: "+a)}}I?(typeof read!="undefined"&&(x=function(a){return read(a)}),W=function(a){var c;return typeof readbuffer=="function"?new Uint8Array(readbuffer(a)):(c=read(a,"binary"),Ri(typeof c=="object"),c)},N=function(a,c,f){setTimeout(function(){c(W(a))},0)},typeof scriptArgs!="undefined"?p=scriptArgs:typeof arguments!="undefined"&&(p=arguments),typeof quit=="function"&&(m=function(s,a){ye(a),quit(s)}),typeof print!="undefined"&&(typeof console=="undefined"&&(console={}),console.log=print,console.warn=console.error=typeof printErr!="undefined"?printErr:print)):(_||h)&&(h?U=self.location.href:typeof document!="undefined"&&document.currentScript&&(U=document.currentScript.src),n&&(U=n),U.indexOf("blob:")!==0?U=U.substr(0,U.replace(/[?#].*/,"").lastIndexOf("/")+1):U="",x=function(s){var a=new XMLHttpRequest;return a.open("GET",s,!1),a.send(null),a.responseText},h&&(W=function(s){var a=new XMLHttpRequest;return a.open("GET",s,!1),a.responseType="arraybuffer",a.send(null),new Uint8Array(a.response)}),N=function(s,a,c){var f=new XMLHttpRequest;f.open("GET",s,!0),f.responseType="arraybuffer",f.onload=function(){if(f.status==200||f.status==0&&f.response){a(f.response);return}c()},f.onerror=c,f.send(null)},Se=function(s){document.title=s});var Ae=e.print||console.log.bind(console),ie=e.printErr||console.warn.bind(console);for(u in o)o.hasOwnProperty(u)&&(e[u]=o[u]);o=null,e.arguments&&(p=e.arguments),e.thisProgram&&(l=e.thisProgram),e.quit&&(m=e.quit);function fe(s){fe.shown||(fe.shown={}),fe.shown[s]||(fe.shown[s]=1,ie(s))}function Eo(s,a){if(typeof WebAssembly.Function=="function"){for(var c={i:"i32",j:"i64",f:"f32",d:"f64"},f={parameters:[],results:a[0]=="v"?[]:[c[a[0]]]},b=1;b<a.length;++b)f.parameters.push(c[a[b]]);return new WebAssembly.Function(f,s)}var E=[1,0,1,96],S=a.slice(0,1),A=a.slice(1),y={i:127,j:126,f:125,d:124};E.push(A.length);for(var b=0;b<A.length;++b)E.push(y[A[b]]);S=="v"?E.push(0):E=E.concat([1,y[S]]),E[1]=E.length-2;var v=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(v),K=new WebAssembly.Instance(q,{e:{f:s}}),G=K.exports.f;return G}var $r=[],Xe;function To(){if($r.length)return $r.pop();try{st.grow(1)}catch(s){throw s instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":s}return st.length-1}function So(s,a){for(var c=s;c<s+a;c++){var f=tr(c);f&&Xe.set(f,c)}}function yo(s,a){if(Xe||(Xe=new WeakMap,So(0,st.length)),Xe.has(s))return Xe.get(s);var c=To();try{Hi(c,s)}catch(b){if(!(b instanceof TypeError))throw b;var f=Eo(s,a);Hi(c,f)}return Xe.set(s,c),c}function Ao(s){Xe.delete(tr(s)),$r.push(s)}var xt;e.wasmBinary&&(xt=e.wasmBinary);var Tl=e.noExitRuntime||!1;typeof WebAssembly!="object"&&ot("no native wasm support detected");var Zt,Ii=!1,Io;function Ri(s,a){s||ot("Assertion failed: "+a)}function O(s){var a=e["_"+s];return Ri(a,"Cannot call unknown function "+s+", make sure it is exported"),a}function Ui(s,a,c,f,b){var E={string:function(j){var ee=0;if(j!=null&&j!==0){var Y=(j.length<<2)+1;ee=un(Y),vi(j,ee,Y)}return ee},array:function(j){var ee=un(j.length);return Di(j,ee),ee}};function S(j){return a==="string"?Ot(j):a==="boolean"?!!j:j}var A=O(s),y=[],v=0;if(f)for(var q=0;q<f.length;q++){var K=E[c[q]];K?(v===0&&(v=Qi()),y[q]=K(f[q])):y[q]=f[q]}var G=A.apply(null,y);function Q(j){return v!==0&&zi(v),S(j)}return G=Q(G),G}function Ro(s,a,c,f){c=c||[];var b=c.every(function(S){return S==="number"}),E=a!=="string";return E&&b&&!f?O(s):function(){return Ui(s,a,c,arguments,f)}}var xi=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function Yr(s,a,c){for(var f=a+c,b=a;s[b]&&!(b>=f);)++b;if(b-a>16&&s.subarray&&xi)return xi.decode(s.subarray(a,b));for(var E="";a<b;){var S=s[a++];if(!(S&128)){E+=String.fromCharCode(S);continue}var A=s[a++]&63;if((S&224)==192){E+=String.fromCharCode((S&31)<<6|A);continue}var y=s[a++]&63;if((S&240)==224?S=(S&15)<<12|A<<6|y:S=(S&7)<<18|A<<12|y<<6|s[a++]&63,S<65536)E+=String.fromCharCode(S);else{var v=S-65536;E+=String.fromCharCode(55296|v>>10,56320|v&1023)}}return E}function Ot(s,a){return s?Yr(se,s,a):""}function Oi(s,a,c,f){if(!(f>0))return 0;for(var b=c,E=c+f-1,S=0;S<s.length;++S){var A=s.charCodeAt(S);if(A>=55296&&A<=57343){var y=s.charCodeAt(++S);A=65536+((A&1023)<<10)|y&1023}if(A<=127){if(c>=E)break;a[c++]=A}else if(A<=2047){if(c+1>=E)break;a[c++]=192|A>>6,a[c++]=128|A&63}else if(A<=65535){if(c+2>=E)break;a[c++]=224|A>>12,a[c++]=128|A>>6&63,a[c++]=128|A&63}else{if(c+3>=E)break;a[c++]=240|A>>18,a[c++]=128|A>>12&63,a[c++]=128|A>>6&63,a[c++]=128|A&63}}return a[c]=0,c-b}function vi(s,a,c){return Oi(s,se,a,c)}function Pi(s){for(var a=0,c=0;c<s.length;++c){var f=s.charCodeAt(c);f>=55296&&f<=57343&&(f=65536+((f&1023)<<10)|s.charCodeAt(++c)&1023),f<=127?++a:f<=2047?a+=2:f<=65535?a+=3:a+=4}return a}var Ni=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function Uo(s,a){for(var c=s,f=c>>1,b=f+a/2;!(f>=b)&&er[f];)++f;if(c=f<<1,c-s>32&&Ni)return Ni.decode(se.subarray(s,c));for(var E="",S=0;!(S>=a/2);++S){var A=it[s+S*2>>1];if(A==0)break;E+=String.fromCharCode(A)}return E}function xo(s,a,c){if(c===void 0&&(c=2147483647),c<2)return 0;c-=2;for(var f=a,b=c<s.length*2?c/2:s.length,E=0;E<b;++E){var S=s.charCodeAt(E);it[a>>1]=S,a+=2}return it[a>>1]=0,a-f}function Oo(s){return s.length*2}function vo(s,a){for(var c=0,f="";!(c>=a/4);){var b=k[s+c*4>>2];if(b==0)break;if(++c,b>=65536){var E=b-65536;f+=String.fromCharCode(55296|E>>10,56320|E&1023)}else f+=String.fromCharCode(b)}return f}function Po(s,a,c){if(c===void 0&&(c=2147483647),c<4)return 0;for(var f=a,b=f+c-4,E=0;E<s.length;++E){var S=s.charCodeAt(E);if(S>=55296&&S<=57343){var A=s.charCodeAt(++E);S=65536+((S&1023)<<10)|A&1023}if(k[a>>2]=S,a+=4,a+4>b)break}return k[a>>2]=0,a-f}function No(s){for(var a=0,c=0;c<s.length;++c){var f=s.charCodeAt(c);f>=55296&&f<=57343&&++c,a+=4}return a}function Di(s,a){R.set(s,a)}function Do(s,a,c){for(var f=0;f<s.length;++f)R[a++>>0]=s.charCodeAt(f);c||(R[a>>0]=0)}function wo(s,a){return s%a>0&&(s+=a-s%a),s}var Kr,R,se,it,er,k,Ce,wi,Jr;function Ci(s){Kr=s,e.HEAP8=R=new Int8Array(s),e.HEAP16=it=new Int16Array(s),e.HEAP32=k=new Int32Array(s),e.HEAPU8=se=new Uint8Array(s),e.HEAPU16=er=new Uint16Array(s),e.HEAPU32=Ce=new Uint32Array(s),e.HEAPF32=wi=new Float32Array(s),e.HEAPF64=Jr=new Float64Array(s)}var Sl=e.INITIAL_MEMORY||134217728,st,Li=[],Mi=[],Co=[],ki=[],Lo=!1;function Mo(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Vo(e.preRun.shift());Qr(Li)}function ko(){Lo=!0,Qr(Mi)}function Bo(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Fo(e.postRun.shift());Qr(ki)}function Vo(s){Li.unshift(s)}function Ho(s){Mi.unshift(s)}function Fo(s){ki.unshift(s)}var Qe=0,Xr=null,vt=null;function qo(s){Qe++,e.monitorRunDependencies&&e.monitorRunDependencies(Qe)}function Wo(s){if(Qe--,e.monitorRunDependencies&&e.monitorRunDependencies(Qe),Qe==0&&(Xr!==null&&(clearInterval(Xr),Xr=null),vt)){var a=vt;vt=null,a()}}e.preloadedImages={},e.preloadedAudios={};function ot(s){e.onAbort&&e.onAbort(s),s="Aborted("+s+")",ie(s),Ii=!0,Io=1,s+=". Build with -s ASSERTIONS=1 for more info.";var a=new WebAssembly.RuntimeError(s);throw i(a),a}var Go="data:application/octet-stream;base64,";function Bi(s){return s.startsWith(Go)}var Ie;Ie="av_processing.wasm",Bi(Ie)||(Ie=C(Ie));function Vi(s){try{if(s==Ie&&xt)return new Uint8Array(xt);if(W)return W(s);throw"both async and sync fetching of the wasm failed"}catch(a){ot(a)}}function jo(){return!xt&&(_||h)&&typeof fetch=="function"?fetch(Ie,{credentials:"same-origin"}).then(function(s){if(!s.ok)throw"failed to load wasm binary file at '"+Ie+"'";return s.arrayBuffer()}).catch(function(){return Vi(Ie)}):Promise.resolve().then(function(){return Vi(Ie)})}function $o(){var s={a:Ja};function a(S,A){var y=S.exports;e.asm=y,Zt=e.asm.B,Ci(Zt.buffer),st=e.asm.na,Ho(e.asm.C),Wo("wasm-instantiate")}qo("wasm-instantiate");function c(S){a(S.instance)}function f(S){return jo().then(function(A){return WebAssembly.instantiate(A,s)}).then(function(A){return A}).then(S,function(A){ie("failed to asynchronously prepare wasm: "+A),ot(A)})}function b(){return!xt&&typeof WebAssembly.instantiateStreaming=="function"&&!Bi(Ie)&&typeof fetch=="function"?fetch(Ie,{credentials:"same-origin"}).then(function(S){var A=WebAssembly.instantiateStreaming(S,s);return A.then(c,function(y){return ie("wasm streaming compile failed: "+y),ie("falling back to ArrayBuffer instantiation"),f(c)})}):f(c)}if(e.instantiateWasm)try{var E=e.instantiateWasm(s,a);return E}catch(S){return ie("Module.instantiateWasm callback failed with error: "+S),!1}return b().catch(i),{}}function Qr(s){for(;s.length>0;){var a=s.shift();if(typeof a=="function"){a(e);continue}var c=a.func;typeof c=="number"?a.arg===void 0?tr(c)():tr(c)(a.arg):c(a.arg===void 0?null:a.arg)}}function tr(s){return st.get(s)}function Yo(){var s=new Error;if(!s.stack){try{throw new Error}catch(a){s=a}if(!s.stack)return"(no stack trace available)"}return s.stack.toString()}function Hi(s,a){st.set(s,a)}function Ko(s){return ar(s+16)+16}function Jo(s,a){Co.unshift({func:s,arg:a})}function Xo(s,a){return Jo(s,a)}function Qo(s){this.excPtr=s,this.ptr=s-16,this.set_type=function(a){k[this.ptr+4>>2]=a},this.get_type=function(){return k[this.ptr+4>>2]},this.set_destructor=function(a){k[this.ptr+8>>2]=a},this.get_destructor=function(){return k[this.ptr+8>>2]},this.set_refcount=function(a){k[this.ptr>>2]=a},this.set_caught=function(a){a=a?1:0,R[this.ptr+12>>0]=a},this.get_caught=function(){return R[this.ptr+12>>0]!=0},this.set_rethrown=function(a){a=a?1:0,R[this.ptr+13>>0]=a},this.get_rethrown=function(){return R[this.ptr+13>>0]!=0},this.init=function(a,c){this.set_type(a),this.set_destructor(c),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var a=k[this.ptr>>2];k[this.ptr>>2]=a+1},this.release_ref=function(){var a=k[this.ptr>>2];return k[this.ptr>>2]=a-1,a===1}}var zo=0,Zo=0;function ea(s,a,c){var f=new Qo(s);throw f.init(a,c),zo=s,Zo++,s}function ta(s,a,c,f,b){}function zr(s){switch(s){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+s)}}function ra(){for(var s=new Array(256),a=0;a<256;++a)s[a]=String.fromCharCode(a);Fi=s}var Fi=void 0;function Ve(s){for(var a="",c=s;se[c];)a+=Fi[se[c++]];return a}var Zr={},qi={},na={},ia=48,sa=57;function oa(s){if(s===void 0)return"_unknown";s=s.replace(/[^a-zA-Z0-9_]/g,"$");var a=s.charCodeAt(0);return a>=ia&&a<=sa?"_"+s:s}function aa(s,a){return s=oa(s),new Function("body","return function "+s+`() {
5
+ Error code: ${m.streamErrorCode}.`:m instanceof it?m=m.cause:m instanceof Event&&(m=m.type),postMessage({id:e,payload:{err:m}}),o.close()}}};function yl(n){self.onmessage=async t=>{let e=setTimeout(()=>{self.postMessage({type:"error",payload:"timeout"})},5e3);try{t.data.wasm&&(V.wasmBinary=t.data.wasm),Object.assign(te,t.data.flag),console.time(`Worker[${self.name}${rt}]`),V.postRun=[()=>{B.global=new B(1920*1080*3>>1),V._CreateMediaProcessing(0,1,0,!1),console.timeEnd(`Worker[${self.name}${rt}]`),V._UseAINS(te.useAINS),this.ios=new Set,t.ports[0].onmessage=l=>{var h,T,I;let[m,_]=l.data;switch(m){case"dump":switch(_){case"audio":this.dumpPort=l.ports[0];break;case"mic0":(h=this.playPort)==null||h.postMessage({cmd:m,payload:_},l.ports);break}break;case"useAINS":V._UseAINS(_),(T=this.playPort)==null||T.postMessage({cmd:m,payload:_});break;case"enableDebug":console.debug=_?Nr:()=>{},(I=this.playPort)==null||I.postMessage({cmd:m,payload:_});break;case"useV2":V.udtver=_?2:3;break;case"useWt":te.useWt=_;break;case"enableAEC":V._EnableAEC(_);break}};let r=0,i=Date.now(),o=0;F(xe(1e3),X(()=>{let _=(Date.now()-i)/10-r;console.debug("interval10ms:",_,_-o),o=_,V._UpdateStreamSync()})),V._SetAudioOutStreamFormat(48e3,1);let u=V._malloc(3*4),p=new B(1920);F(this.interval10ms,X(()=>{if(r++,V._GetAudioMixedFloat(p.point,48e3,u)>=0){if(this.playPort){let m=p.uint8Slice();this.playPort.postMessage(m,[m.buffer])}if(this.dumpPort){let m=p.uint8Slice();this.dumpPort.postMessage(m,[m.buffer])}this.ios.forEach(m=>m.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(V)}catch(r){self.postMessage({type:"error",err:r})}}}var To=Rr?Eo:yl.bind(new Ui);var Al=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,i;e.ready=new Promise(function(s,a){r=s,i=a});var o={},u;for(u in e)e.hasOwnProperty(u)&&(o[u]=e[u]);var p=[],l="./this.program",m=function(s,a){throw a},_=typeof window=="object",h=typeof importScripts=="function",T=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",I=!_&&!T&&!h,U="";function w(s){return e.locateFile?e.locateFile(s,U):U+s}var x,N,W,Se;function ye(s){if(!(s instanceof Fu)){var a=s;ie("exiting due to exception: "+a)}}I?(typeof read!="undefined"&&(x=function(a){return read(a)}),W=function(a){var c;return typeof readbuffer=="function"?new Uint8Array(readbuffer(a)):(c=read(a,"binary"),Oi(typeof c=="object"),c)},N=function(a,c,f){setTimeout(function(){c(W(a))},0)},typeof scriptArgs!="undefined"?p=scriptArgs:typeof arguments!="undefined"&&(p=arguments),typeof quit=="function"&&(m=function(s,a){ye(a),quit(s)}),typeof print!="undefined"&&(typeof console=="undefined"&&(console={}),console.log=print,console.warn=console.error=typeof printErr!="undefined"?printErr:print)):(_||h)&&(h?U=self.location.href:typeof document!="undefined"&&document.currentScript&&(U=document.currentScript.src),n&&(U=n),U.indexOf("blob:")!==0?U=U.substr(0,U.replace(/[?#].*/,"").lastIndexOf("/")+1):U="",x=function(s){var a=new XMLHttpRequest;return a.open("GET",s,!1),a.send(null),a.responseText},h&&(W=function(s){var a=new XMLHttpRequest;return a.open("GET",s,!1),a.responseType="arraybuffer",a.send(null),new Uint8Array(a.response)}),N=function(s,a,c){var f=new XMLHttpRequest;f.open("GET",s,!0),f.responseType="arraybuffer",f.onload=function(){if(f.status==200||f.status==0&&f.response){a(f.response);return}c()},f.onerror=c,f.send(null)},Se=function(s){document.title=s});var Ae=e.print||console.log.bind(console),ie=e.printErr||console.warn.bind(console);for(u in o)o.hasOwnProperty(u)&&(e[u]=o[u]);o=null,e.arguments&&(p=e.arguments),e.thisProgram&&(l=e.thisProgram),e.quit&&(m=e.quit);function fe(s){fe.shown||(fe.shown={}),fe.shown[s]||(fe.shown[s]=1,ie(s))}function yo(s,a){if(typeof WebAssembly.Function=="function"){for(var c={i:"i32",j:"i64",f:"f32",d:"f64"},f={parameters:[],results:a[0]=="v"?[]:[c[a[0]]]},b=1;b<a.length;++b)f.parameters.push(c[a[b]]);return new WebAssembly.Function(f,s)}var E=[1,0,1,96],S=a.slice(0,1),A=a.slice(1),y={i:127,j:126,f:125,d:124};E.push(A.length);for(var b=0;b<A.length;++b)E.push(y[A[b]]);S=="v"?E.push(0):E=E.concat([1,y[S]]),E[1]=E.length-2;var v=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(v),K=new WebAssembly.Instance(q,{e:{f:s}}),G=K.exports.f;return G}var Yr=[],Xe;function Ao(){if(Yr.length)return Yr.pop();try{at.grow(1)}catch(s){throw s instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":s}return at.length-1}function Io(s,a){for(var c=s;c<s+a;c++){var f=tr(c);f&&Xe.set(f,c)}}function Ro(s,a){if(Xe||(Xe=new WeakMap,Io(0,at.length)),Xe.has(s))return Xe.get(s);var c=Ao();try{Wi(c,s)}catch(b){if(!(b instanceof TypeError))throw b;var f=yo(s,a);Wi(c,f)}return Xe.set(s,c),c}function Uo(s){Xe.delete(tr(s)),Yr.push(s)}var xt;e.wasmBinary&&(xt=e.wasmBinary);var Il=e.noExitRuntime||!1;typeof WebAssembly!="object"&&ut("no native wasm support detected");var Zt,xi=!1,xo;function Oi(s,a){s||ut("Assertion failed: "+a)}function O(s){var a=e["_"+s];return Oi(a,"Cannot call unknown function "+s+", make sure it is exported"),a}function vi(s,a,c,f,b){var E={string:function(j){var ee=0;if(j!=null&&j!==0){var Y=(j.length<<2)+1;ee=cn(Y),Di(j,ee,Y)}return ee},array:function(j){var ee=cn(j.length);return Li(j,ee),ee}};function S(j){return a==="string"?Ot(j):a==="boolean"?!!j:j}var A=O(s),y=[],v=0;if(f)for(var q=0;q<f.length;q++){var K=E[c[q]];K?(v===0&&(v=es()),y[q]=K(f[q])):y[q]=f[q]}var G=A.apply(null,y);function Q(j){return v!==0&&ts(v),S(j)}return G=Q(G),G}function Oo(s,a,c,f){c=c||[];var b=c.every(function(S){return S==="number"}),E=a!=="string";return E&&b&&!f?O(s):function(){return vi(s,a,c,arguments,f)}}var Pi=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function Kr(s,a,c){for(var f=a+c,b=a;s[b]&&!(b>=f);)++b;if(b-a>16&&s.subarray&&Pi)return Pi.decode(s.subarray(a,b));for(var E="";a<b;){var S=s[a++];if(!(S&128)){E+=String.fromCharCode(S);continue}var A=s[a++]&63;if((S&224)==192){E+=String.fromCharCode((S&31)<<6|A);continue}var y=s[a++]&63;if((S&240)==224?S=(S&15)<<12|A<<6|y:S=(S&7)<<18|A<<12|y<<6|s[a++]&63,S<65536)E+=String.fromCharCode(S);else{var v=S-65536;E+=String.fromCharCode(55296|v>>10,56320|v&1023)}}return E}function Ot(s,a){return s?Kr(se,s,a):""}function Ni(s,a,c,f){if(!(f>0))return 0;for(var b=c,E=c+f-1,S=0;S<s.length;++S){var A=s.charCodeAt(S);if(A>=55296&&A<=57343){var y=s.charCodeAt(++S);A=65536+((A&1023)<<10)|y&1023}if(A<=127){if(c>=E)break;a[c++]=A}else if(A<=2047){if(c+1>=E)break;a[c++]=192|A>>6,a[c++]=128|A&63}else if(A<=65535){if(c+2>=E)break;a[c++]=224|A>>12,a[c++]=128|A>>6&63,a[c++]=128|A&63}else{if(c+3>=E)break;a[c++]=240|A>>18,a[c++]=128|A>>12&63,a[c++]=128|A>>6&63,a[c++]=128|A&63}}return a[c]=0,c-b}function Di(s,a,c){return Ni(s,se,a,c)}function Ci(s){for(var a=0,c=0;c<s.length;++c){var f=s.charCodeAt(c);f>=55296&&f<=57343&&(f=65536+((f&1023)<<10)|s.charCodeAt(++c)&1023),f<=127?++a:f<=2047?a+=2:f<=65535?a+=3:a+=4}return a}var wi=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function vo(s,a){for(var c=s,f=c>>1,b=f+a/2;!(f>=b)&&er[f];)++f;if(c=f<<1,c-s>32&&wi)return wi.decode(se.subarray(s,c));for(var E="",S=0;!(S>=a/2);++S){var A=ot[s+S*2>>1];if(A==0)break;E+=String.fromCharCode(A)}return E}function Po(s,a,c){if(c===void 0&&(c=2147483647),c<2)return 0;c-=2;for(var f=a,b=c<s.length*2?c/2:s.length,E=0;E<b;++E){var S=s.charCodeAt(E);ot[a>>1]=S,a+=2}return ot[a>>1]=0,a-f}function No(s){return s.length*2}function Do(s,a){for(var c=0,f="";!(c>=a/4);){var b=k[s+c*4>>2];if(b==0)break;if(++c,b>=65536){var E=b-65536;f+=String.fromCharCode(55296|E>>10,56320|E&1023)}else f+=String.fromCharCode(b)}return f}function Co(s,a,c){if(c===void 0&&(c=2147483647),c<4)return 0;for(var f=a,b=f+c-4,E=0;E<s.length;++E){var S=s.charCodeAt(E);if(S>=55296&&S<=57343){var A=s.charCodeAt(++E);S=65536+((S&1023)<<10)|A&1023}if(k[a>>2]=S,a+=4,a+4>b)break}return k[a>>2]=0,a-f}function wo(s){for(var a=0,c=0;c<s.length;++c){var f=s.charCodeAt(c);f>=55296&&f<=57343&&++c,a+=4}return a}function Li(s,a){R.set(s,a)}function Lo(s,a,c){for(var f=0;f<s.length;++f)R[a++>>0]=s.charCodeAt(f);c||(R[a>>0]=0)}function Mo(s,a){return s%a>0&&(s+=a-s%a),s}var Jr,R,se,ot,er,k,we,Mi,Xr;function ki(s){Jr=s,e.HEAP8=R=new Int8Array(s),e.HEAP16=ot=new Int16Array(s),e.HEAP32=k=new Int32Array(s),e.HEAPU8=se=new Uint8Array(s),e.HEAPU16=er=new Uint16Array(s),e.HEAPU32=we=new Uint32Array(s),e.HEAPF32=Mi=new Float32Array(s),e.HEAPF64=Xr=new Float64Array(s)}var Rl=e.INITIAL_MEMORY||134217728,at,Bi=[],Vi=[],ko=[],Hi=[],Bo=!1;function Vo(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)qo(e.preRun.shift());zr(Bi)}function Ho(){Bo=!0,zr(Vi)}function Fo(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Go(e.postRun.shift());zr(Hi)}function qo(s){Bi.unshift(s)}function Wo(s){Vi.unshift(s)}function Go(s){Hi.unshift(s)}var Qe=0,Qr=null,vt=null;function jo(s){Qe++,e.monitorRunDependencies&&e.monitorRunDependencies(Qe)}function $o(s){if(Qe--,e.monitorRunDependencies&&e.monitorRunDependencies(Qe),Qe==0&&(Qr!==null&&(clearInterval(Qr),Qr=null),vt)){var a=vt;vt=null,a()}}e.preloadedImages={},e.preloadedAudios={};function ut(s){e.onAbort&&e.onAbort(s),s="Aborted("+s+")",ie(s),xi=!0,xo=1,s+=". Build with -s ASSERTIONS=1 for more info.";var a=new WebAssembly.RuntimeError(s);throw i(a),a}var Yo="data:application/octet-stream;base64,";function Fi(s){return s.startsWith(Yo)}var Ie;Ie="av_processing.wasm",Fi(Ie)||(Ie=w(Ie));function qi(s){try{if(s==Ie&&xt)return new Uint8Array(xt);if(W)return W(s);throw"both async and sync fetching of the wasm failed"}catch(a){ut(a)}}function Ko(){return!xt&&(_||h)&&typeof fetch=="function"?fetch(Ie,{credentials:"same-origin"}).then(function(s){if(!s.ok)throw"failed to load wasm binary file at '"+Ie+"'";return s.arrayBuffer()}).catch(function(){return qi(Ie)}):Promise.resolve().then(function(){return qi(Ie)})}function Jo(){var s={a:za};function a(S,A){var y=S.exports;e.asm=y,Zt=e.asm.B,ki(Zt.buffer),at=e.asm.na,Wo(e.asm.C),$o("wasm-instantiate")}jo("wasm-instantiate");function c(S){a(S.instance)}function f(S){return Ko().then(function(A){return WebAssembly.instantiate(A,s)}).then(function(A){return A}).then(S,function(A){ie("failed to asynchronously prepare wasm: "+A),ut(A)})}function b(){return!xt&&typeof WebAssembly.instantiateStreaming=="function"&&!Fi(Ie)&&typeof fetch=="function"?fetch(Ie,{credentials:"same-origin"}).then(function(S){var A=WebAssembly.instantiateStreaming(S,s);return A.then(c,function(y){return ie("wasm streaming compile failed: "+y),ie("falling back to ArrayBuffer instantiation"),f(c)})}):f(c)}if(e.instantiateWasm)try{var E=e.instantiateWasm(s,a);return E}catch(S){return ie("Module.instantiateWasm callback failed with error: "+S),!1}return b().catch(i),{}}function zr(s){for(;s.length>0;){var a=s.shift();if(typeof a=="function"){a(e);continue}var c=a.func;typeof c=="number"?a.arg===void 0?tr(c)():tr(c)(a.arg):c(a.arg===void 0?null:a.arg)}}function tr(s){return at.get(s)}function Xo(){var s=new Error;if(!s.stack){try{throw new Error}catch(a){s=a}if(!s.stack)return"(no stack trace available)"}return s.stack.toString()}function Wi(s,a){at.set(s,a)}function Qo(s){return ar(s+16)+16}function zo(s,a){ko.unshift({func:s,arg:a})}function Zo(s,a){return zo(s,a)}function ea(s){this.excPtr=s,this.ptr=s-16,this.set_type=function(a){k[this.ptr+4>>2]=a},this.get_type=function(){return k[this.ptr+4>>2]},this.set_destructor=function(a){k[this.ptr+8>>2]=a},this.get_destructor=function(){return k[this.ptr+8>>2]},this.set_refcount=function(a){k[this.ptr>>2]=a},this.set_caught=function(a){a=a?1:0,R[this.ptr+12>>0]=a},this.get_caught=function(){return R[this.ptr+12>>0]!=0},this.set_rethrown=function(a){a=a?1:0,R[this.ptr+13>>0]=a},this.get_rethrown=function(){return R[this.ptr+13>>0]!=0},this.init=function(a,c){this.set_type(a),this.set_destructor(c),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var a=k[this.ptr>>2];k[this.ptr>>2]=a+1},this.release_ref=function(){var a=k[this.ptr>>2];return k[this.ptr>>2]=a-1,a===1}}var ta=0,ra=0;function na(s,a,c){var f=new ea(s);throw f.init(a,c),ta=s,ra++,s}function ia(s,a,c,f,b){}function Zr(s){switch(s){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+s)}}function sa(){for(var s=new Array(256),a=0;a<256;++a)s[a]=String.fromCharCode(a);Gi=s}var Gi=void 0;function Ve(s){for(var a="",c=s;se[c];)a+=Gi[se[c++]];return a}var en={},ji={},oa={},aa=48,ua=57;function ca(s){if(s===void 0)return"_unknown";s=s.replace(/[^a-zA-Z0-9_]/g,"$");var a=s.charCodeAt(0);return a>=aa&&a<=ua?"_"+s:s}function la(s,a){return s=ca(s),new Function("body","return function "+s+`() {
6
6
  "use strict"; return body.apply(this, arguments);
7
7
  };
8
- `)(a)}function Wi(s,a){var c=aa(a,function(f){this.name=a,this.message=f;var b=new Error(f).stack;b!==void 0&&(this.stack=this.toString()+`
9
- `+b.replace(/^Error(:[^\n]*)?\n/,""))});return c.prototype=Object.create(s.prototype),c.prototype.constructor=c,c.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},c}var Gi=void 0;function at(s){throw new Gi(s)}var ua=void 0;function He(s,a,c){if(c=c||{},!("argPackAdvance"in a))throw new TypeError("registerType registeredInstance requires argPackAdvance");var f=a.name;if(s||at('type "'+f+'" must have a positive integer typeid pointer'),qi.hasOwnProperty(s)){if(c.ignoreDuplicateRegistrations)return;at("Cannot register type '"+f+"' twice")}if(qi[s]=a,delete na[s],Zr.hasOwnProperty(s)){var b=Zr[s];delete Zr[s],b.forEach(function(E){E()})}}function ca(s,a,c,f,b){var E=zr(c);a=Ve(a),He(s,{name:a,fromWireType:function(S){return!!S},toWireType:function(S,A){return A?f:b},argPackAdvance:8,readValueFromPointer:function(S){var A;if(c===1)A=R;else if(c===2)A=it;else if(c===4)A=k;else throw new TypeError("Unknown boolean type size: "+a);return this.fromWireType(A[S>>E])},destructorFunction:null})}var en=[],ve=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function la(s){s>4&&--ve[s].refcount===0&&(ve[s]=void 0,en.push(s))}function ma(){for(var s=0,a=5;a<ve.length;++a)ve[a]!==void 0&&++s;return s}function da(){for(var s=5;s<ve.length;++s)if(ve[s]!==void 0)return ve[s];return null}function pa(){e.count_emval_handles=ma,e.get_first_emval=da}var ji={toValue:function(s){return s||at("Cannot use deleted val. handle = "+s),ve[s].value},toHandle:function(s){switch(s){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:{var a=en.length?en.pop():ve.length;return ve[a]={refcount:1,value:s},a}}}};function tn(s){return this.fromWireType(Ce[s>>2])}function fa(s,a){a=Ve(a),He(s,{name:a,fromWireType:function(c){var f=ji.toValue(c);return la(c),f},toWireType:function(c,f){return ji.toHandle(f)},argPackAdvance:8,readValueFromPointer:tn,destructorFunction:null})}function rn(s){if(s===null)return"null";var a=typeof s;return a==="object"||a==="array"||a==="function"?s.toString():""+s}function _a(s,a){switch(a){case 2:return function(c){return this.fromWireType(wi[c>>2])};case 3:return function(c){return this.fromWireType(Jr[c>>3])};default:throw new TypeError("Unknown float type: "+s)}}function ha(s,a,c){var f=zr(c);a=Ve(a),He(s,{name:a,fromWireType:function(b){return b},toWireType:function(b,E){if(typeof E!="number"&&typeof E!="boolean")throw new TypeError('Cannot convert "'+rn(E)+'" to '+this.name);return E},argPackAdvance:8,readValueFromPointer:_a(a,f),destructorFunction:null})}function ba(s,a,c){switch(a){case 0:return c?function(b){return R[b]}:function(b){return se[b]};case 1:return c?function(b){return it[b>>1]}:function(b){return er[b>>1]};case 2:return c?function(b){return k[b>>2]}:function(b){return Ce[b>>2]};default:throw new TypeError("Unknown integer type: "+s)}}function ga(s,a,c,f,b){a=Ve(a),b===-1&&(b=4294967295);var E=zr(c),S=function(v){return v};if(f===0){var A=32-8*c;S=function(v){return v<<A>>>A}}var y=a.includes("unsigned");He(s,{name:a,fromWireType:S,toWireType:function(v,q){if(typeof q!="number"&&typeof q!="boolean")throw new TypeError('Cannot convert "'+rn(q)+'" to '+this.name);if(q<f||q>b)throw new TypeError('Passing a number "'+rn(q)+'" from JS side to C/C++ side to an argument of type "'+a+'", which is outside the valid range ['+f+", "+b+"]!");return y?q>>>0:q|0},argPackAdvance:8,readValueFromPointer:ba(a,E,f!==0),destructorFunction:null})}function Ea(s,a,c){var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],b=f[a];function E(S){S=S>>2;var A=Ce,y=A[S],v=A[S+1];return new b(Kr,v,y)}c=Ve(c),He(s,{name:c,fromWireType:E,argPackAdvance:8,readValueFromPointer:E},{ignoreDuplicateRegistrations:!0})}function Ta(s,a){a=Ve(a);var c=a==="std::string";He(s,{name:a,fromWireType:function(f){var b=Ce[f>>2],E;if(c)for(var S=f+4,A=0;A<=b;++A){var y=f+4+A;if(A==b||se[y]==0){var v=y-S,q=Ot(S,v);E===void 0?E=q:(E+="\0",E+=q),S=y+1}}else{for(var K=new Array(b),A=0;A<b;++A)K[A]=String.fromCharCode(se[f+4+A]);E=K.join("")}return Fe(f),E},toWireType:function(f,b){b instanceof ArrayBuffer&&(b=new Uint8Array(b));var E,S=typeof b=="string";S||b instanceof Uint8Array||b instanceof Uint8ClampedArray||b instanceof Int8Array||at("Cannot pass non-string to std::string"),c&&S?E=function(){return Pi(b)}:E=function(){return b.length};var A=E(),y=ar(4+A+1);if(Ce[y>>2]=A,c&&S)vi(b,y+4,A+1);else if(S)for(var v=0;v<A;++v){var q=b.charCodeAt(v);q>255&&(Fe(y),at("String has UTF-16 code units that do not fit in 8 bits")),se[y+4+v]=q}else for(var v=0;v<A;++v)se[y+4+v]=b[v];return f!==null&&f.push(Fe,y),y},argPackAdvance:8,readValueFromPointer:tn,destructorFunction:function(f){Fe(f)}})}function Sa(s,a,c){c=Ve(c);var f,b,E,S,A;a===2?(f=Uo,b=xo,S=Oo,E=function(){return er},A=1):a===4&&(f=vo,b=Po,S=No,E=function(){return Ce},A=2),He(s,{name:c,fromWireType:function(y){for(var v=Ce[y>>2],q=E(),K,G=y+4,Q=0;Q<=v;++Q){var j=y+4+Q*a;if(Q==v||q[j>>A]==0){var ee=j-G,Y=f(G,ee);K===void 0?K=Y:(K+="\0",K+=Y),G=j+a}}return Fe(y),K},toWireType:function(y,v){typeof v!="string"&&at("Cannot pass non-string to C++ string type "+c);var q=S(v),K=ar(4+q+a);return Ce[K>>2]=q>>A,b(v,K+4,q+a),y!==null&&y.push(Fe,K),K},argPackAdvance:8,readValueFromPointer:tn,destructorFunction:function(y){Fe(y)}})}function ya(s,a){a=Ve(a),He(s,{isVoid:!0,name:a,argPackAdvance:0,fromWireType:function(){},toWireType:function(c,f){}})}function Aa(){ot("")}var nn;typeof dateNow!="undefined"?nn=dateNow:nn=function(){return performance.now()};var Ia=!0;function Ra(s){return k[Xi()>>2]=s,s}function Ua(s,a){var c;if(s===0)c=Date.now();else if((s===1||s===4)&&Ia)c=nn();else return Ra(28),-1;return k[a>>2]=c/1e3|0,k[a+4>>2]=c%1e3*1e3*1e3|0,0}function xa(s){return s<0||s===0&&1/s===-1/0}function Oa(s,a){return(s>>>0)+a*4294967296}function va(s,a){return(s>>>0)+(a>>>0)*4294967296}function $i(s,a){if(s<=0)return s;var c=a<=32?Math.abs(1<<a-1):Math.pow(2,a-1);return s>=c&&(a<=32||s>c)&&(s=-2*c+s),s}function Yi(s,a){return s>=0?s:a<=32?2*Math.abs(1<<a-1)+s:Math.pow(2,a)+s}function Ki(s){for(var a=s;se[a];)++a;return a-s}e._strlen=Ki;function Pa(s,a){var c=s,f=a;function b(Ne,Me){return(Me==="double"||Me==="i64")&&Ne&7&&(Ne+=4),Ne}function E(Ne){var Me;return f=b(f,Ne),Ne==="double"?(Me=Number(Jr[f>>3]),f+=8):Ne=="i64"?(Me=[k[f>>2],k[f+4>>2]],f+=8):(Ne="i32",Me=k[f>>2],f+=4),Me}for(var S=[],A,y,v;;){var q=c;if(A=R[c>>0],A===0)break;if(y=R[c+1>>0],A==37){var K=!1,G=!1,Q=!1,j=!1,ee=!1;e:for(;;){switch(y){case 43:K=!0;break;case 45:G=!0;break;case 35:Q=!0;break;case 48:if(j)break e;j=!0;break;case 32:ee=!0;break;default:break e}c++,y=R[c+1>>0]}var Y=0;if(y==42)Y=E("i32"),c++,y=R[c+1>>0];else for(;y>=48&&y<=57;)Y=Y*10+(y-48),c++,y=R[c+1>>0];var he=!1,g=-1;if(y==46){if(g=0,he=!0,c++,y=R[c+1>>0],y==42)g=E("i32"),c++;else for(;;){var w=R[c+1>>0];if(w<48||w>57)break;g=g*10+(w-48),c++}y=R[c+1>>0]}g<0&&(g=6,he=!1);var H;switch(String.fromCharCode(y)){case"h":var J=R[c+2>>0];J==104?(c++,H=1):H=2;break;case"l":var J=R[c+2>>0];J==108?(c++,H=8):H=4;break;case"L":case"q":case"j":H=8;break;case"z":case"t":case"I":H=4;break;default:H=null}switch(H&&c++,y=R[c+1>>0],String.fromCharCode(y)){case"d":case"i":case"u":case"o":case"x":case"X":case"p":{var Ee=y==100||y==105;H=H||4,v=E("i"+H*8);var P;if(H==8&&(v=y==117?va(v[0],v[1]):Oa(v[0],v[1])),H<=4){var Le=Math.pow(256,H)-1;v=(Ee?$i:Yi)(v&Le,H*8)}var Nt=Math.abs(v),_e="";if(y==100||y==105)P=$i(v,8*H,1).toString(10);else if(y==117)P=Yi(v,8*H,1).toString(10),v=Math.abs(v);else if(y==111)P=(Q?"0":"")+Nt.toString(8);else if(y==120||y==88){if(_e=Q&&v!=0?"0x":"",v<0){v=-v,P=(Nt-1).toString(16);for(var Zi=[],Pe=0;Pe<P.length;Pe++)Zi.push((15-parseInt(P[Pe],16)).toString(16));for(P=Zi.join("");P.length<H*2;)P="f"+P}else P=Nt.toString(16);y==88&&(_e=_e.toUpperCase(),P=P.toUpperCase())}else y==112&&(Nt===0?P="(nil)":(_e="0x",P=Nt.toString(16)));if(he)for(;P.length<g;)P="0"+P;for(v>=0&&(K?_e="+"+_e:ee&&(_e=" "+_e)),P.charAt(0)=="-"&&(_e="-"+_e,P=P.substr(1));_e.length+P.length<Y;)G?P+=" ":j?P="0"+P:_e=" "+_e;P=_e+P,P.split("").forEach(function(Ne){S.push(Ne.charCodeAt(0))});break}case"f":case"F":case"e":case"E":case"g":case"G":{v=E("double");var P;if(isNaN(v))P="nan",j=!1;else if(!isFinite(v))P=(v<0?"-":"")+"inf",j=!1;else{var es=!1,Dt=Math.min(g,20);if(y==103||y==71){es=!0,g=g||1;var ln=parseInt(v.toExponential(Dt).split("e")[1],10);g>ln&&ln>=-4?(y=(y==103?"f":"F").charCodeAt(0),g-=ln+1):(y=(y==103?"e":"E").charCodeAt(0),g--),Dt=Math.min(g,20)}y==101||y==69?(P=v.toExponential(Dt),/[eE][-+]\d$/.test(P)&&(P=P.slice(0,-1)+"0"+P.slice(-1))):(y==102||y==70)&&(P=v.toFixed(Dt),v===0&&xa(v)&&(P="-"+P));var Re=P.split("e");if(es&&!Q)for(;Re[0].length>1&&Re[0].includes(".")&&(Re[0].slice(-1)=="0"||Re[0].slice(-1)==".");)Re[0]=Re[0].slice(0,-1);else for(Q&&P.indexOf(".")==-1&&(Re[0]+=".");g>Dt++;)Re[0]+="0";P=Re[0]+(Re.length>1?"e"+Re[1]:""),y==69&&(P=P.toUpperCase()),v>=0&&(K?P="+"+P:ee&&(P=" "+P))}for(;P.length<Y;)G?P+=" ":j&&(P[0]=="-"||P[0]=="+")?P=P[0]+"0"+P.slice(1):P=(j?"0":" ")+P;y<97&&(P=P.toUpperCase()),P.split("").forEach(function(Me){S.push(Me.charCodeAt(0))});break}case"s":{var cr=E("i8*"),ct=cr?Ki(cr):6;if(he&&(ct=Math.min(ct,g)),!G)for(;ct<Y--;)S.push(32);if(cr)for(var Pe=0;Pe<ct;Pe++)S.push(se[cr++>>0]);else S=S.concat(Ji("(null)".substr(0,ct),!0));if(G)for(;ct<Y--;)S.push(32);break}case"c":{for(G&&S.push(E("i8"));--Y>0;)S.push(32);G||S.push(E("i8"));break}case"n":{var Vu=E("i32*");k[Vu>>2]=S.length;break}case"%":{S.push(A);break}default:for(var Pe=q;Pe<c+2;Pe++)S.push(R[Pe>>0])}c+=2}else S.push(A),c+=1}return S}function sn(s){if(!s||!s.callee||!s.callee.name)return[null,"",""];var a=s.callee.toString(),c=s.callee.name,f="(",b=!0;for(var E in s){var S=s[E];b||(f+=", "),b=!1,typeof S=="number"||typeof S=="string"?f+=S:f+="("+typeof S+")"}f+=")";var A=s.callee.caller;return s=A?A.arguments:[],b&&(f=""),[s,c,f]}function Na(s){var a=Yo(),c=a.lastIndexOf("_emscripten_log"),f=a.lastIndexOf("_emscripten_get_callstack"),b=a.indexOf(`
10
- `,Math.max(c,f))+1;a=a.slice(b),s&32&&fe("EM_LOG_DEMANGLE is deprecated; ignoring"),s&8&&typeof emscripten_source_map=="undefined"&&(fe('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.'),s^=8,s|=16);var E=null;if(s&128)for(E=sn(arguments);E[1].includes("_emscripten_");)E=sn(E[0]);var S=a.split(`
8
+ `)(a)}function $i(s,a){var c=la(a,function(f){this.name=a,this.message=f;var b=new Error(f).stack;b!==void 0&&(this.stack=this.toString()+`
9
+ `+b.replace(/^Error(:[^\n]*)?\n/,""))});return c.prototype=Object.create(s.prototype),c.prototype.constructor=c,c.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},c}var Yi=void 0;function ct(s){throw new Yi(s)}var ma=void 0;function He(s,a,c){if(c=c||{},!("argPackAdvance"in a))throw new TypeError("registerType registeredInstance requires argPackAdvance");var f=a.name;if(s||ct('type "'+f+'" must have a positive integer typeid pointer'),ji.hasOwnProperty(s)){if(c.ignoreDuplicateRegistrations)return;ct("Cannot register type '"+f+"' twice")}if(ji[s]=a,delete oa[s],en.hasOwnProperty(s)){var b=en[s];delete en[s],b.forEach(function(E){E()})}}function da(s,a,c,f,b){var E=Zr(c);a=Ve(a),He(s,{name:a,fromWireType:function(S){return!!S},toWireType:function(S,A){return A?f:b},argPackAdvance:8,readValueFromPointer:function(S){var A;if(c===1)A=R;else if(c===2)A=ot;else if(c===4)A=k;else throw new TypeError("Unknown boolean type size: "+a);return this.fromWireType(A[S>>E])},destructorFunction:null})}var tn=[],ve=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function pa(s){s>4&&--ve[s].refcount===0&&(ve[s]=void 0,tn.push(s))}function fa(){for(var s=0,a=5;a<ve.length;++a)ve[a]!==void 0&&++s;return s}function _a(){for(var s=5;s<ve.length;++s)if(ve[s]!==void 0)return ve[s];return null}function ha(){e.count_emval_handles=fa,e.get_first_emval=_a}var Ki={toValue:function(s){return s||ct("Cannot use deleted val. handle = "+s),ve[s].value},toHandle:function(s){switch(s){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:{var a=tn.length?tn.pop():ve.length;return ve[a]={refcount:1,value:s},a}}}};function rn(s){return this.fromWireType(we[s>>2])}function ba(s,a){a=Ve(a),He(s,{name:a,fromWireType:function(c){var f=Ki.toValue(c);return pa(c),f},toWireType:function(c,f){return Ki.toHandle(f)},argPackAdvance:8,readValueFromPointer:rn,destructorFunction:null})}function nn(s){if(s===null)return"null";var a=typeof s;return a==="object"||a==="array"||a==="function"?s.toString():""+s}function ga(s,a){switch(a){case 2:return function(c){return this.fromWireType(Mi[c>>2])};case 3:return function(c){return this.fromWireType(Xr[c>>3])};default:throw new TypeError("Unknown float type: "+s)}}function Ea(s,a,c){var f=Zr(c);a=Ve(a),He(s,{name:a,fromWireType:function(b){return b},toWireType:function(b,E){if(typeof E!="number"&&typeof E!="boolean")throw new TypeError('Cannot convert "'+nn(E)+'" to '+this.name);return E},argPackAdvance:8,readValueFromPointer:ga(a,f),destructorFunction:null})}function Ta(s,a,c){switch(a){case 0:return c?function(b){return R[b]}:function(b){return se[b]};case 1:return c?function(b){return ot[b>>1]}:function(b){return er[b>>1]};case 2:return c?function(b){return k[b>>2]}:function(b){return we[b>>2]};default:throw new TypeError("Unknown integer type: "+s)}}function Sa(s,a,c,f,b){a=Ve(a),b===-1&&(b=4294967295);var E=Zr(c),S=function(v){return v};if(f===0){var A=32-8*c;S=function(v){return v<<A>>>A}}var y=a.includes("unsigned");He(s,{name:a,fromWireType:S,toWireType:function(v,q){if(typeof q!="number"&&typeof q!="boolean")throw new TypeError('Cannot convert "'+nn(q)+'" to '+this.name);if(q<f||q>b)throw new TypeError('Passing a number "'+nn(q)+'" from JS side to C/C++ side to an argument of type "'+a+'", which is outside the valid range ['+f+", "+b+"]!");return y?q>>>0:q|0},argPackAdvance:8,readValueFromPointer:Ta(a,E,f!==0),destructorFunction:null})}function ya(s,a,c){var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],b=f[a];function E(S){S=S>>2;var A=we,y=A[S],v=A[S+1];return new b(Jr,v,y)}c=Ve(c),He(s,{name:c,fromWireType:E,argPackAdvance:8,readValueFromPointer:E},{ignoreDuplicateRegistrations:!0})}function Aa(s,a){a=Ve(a);var c=a==="std::string";He(s,{name:a,fromWireType:function(f){var b=we[f>>2],E;if(c)for(var S=f+4,A=0;A<=b;++A){var y=f+4+A;if(A==b||se[y]==0){var v=y-S,q=Ot(S,v);E===void 0?E=q:(E+="\0",E+=q),S=y+1}}else{for(var K=new Array(b),A=0;A<b;++A)K[A]=String.fromCharCode(se[f+4+A]);E=K.join("")}return Fe(f),E},toWireType:function(f,b){b instanceof ArrayBuffer&&(b=new Uint8Array(b));var E,S=typeof b=="string";S||b instanceof Uint8Array||b instanceof Uint8ClampedArray||b instanceof Int8Array||ct("Cannot pass non-string to std::string"),c&&S?E=function(){return Ci(b)}:E=function(){return b.length};var A=E(),y=ar(4+A+1);if(we[y>>2]=A,c&&S)Di(b,y+4,A+1);else if(S)for(var v=0;v<A;++v){var q=b.charCodeAt(v);q>255&&(Fe(y),ct("String has UTF-16 code units that do not fit in 8 bits")),se[y+4+v]=q}else for(var v=0;v<A;++v)se[y+4+v]=b[v];return f!==null&&f.push(Fe,y),y},argPackAdvance:8,readValueFromPointer:rn,destructorFunction:function(f){Fe(f)}})}function Ia(s,a,c){c=Ve(c);var f,b,E,S,A;a===2?(f=vo,b=Po,S=No,E=function(){return er},A=1):a===4&&(f=Do,b=Co,S=wo,E=function(){return we},A=2),He(s,{name:c,fromWireType:function(y){for(var v=we[y>>2],q=E(),K,G=y+4,Q=0;Q<=v;++Q){var j=y+4+Q*a;if(Q==v||q[j>>A]==0){var ee=j-G,Y=f(G,ee);K===void 0?K=Y:(K+="\0",K+=Y),G=j+a}}return Fe(y),K},toWireType:function(y,v){typeof v!="string"&&ct("Cannot pass non-string to C++ string type "+c);var q=S(v),K=ar(4+q+a);return we[K>>2]=q>>A,b(v,K+4,q+a),y!==null&&y.push(Fe,K),K},argPackAdvance:8,readValueFromPointer:rn,destructorFunction:function(y){Fe(y)}})}function Ra(s,a){a=Ve(a),He(s,{isVoid:!0,name:a,argPackAdvance:0,fromWireType:function(){},toWireType:function(c,f){}})}function Ua(){ut("")}var sn;typeof dateNow!="undefined"?sn=dateNow:sn=function(){return performance.now()};var xa=!0;function Oa(s){return k[Zi()>>2]=s,s}function va(s,a){var c;if(s===0)c=Date.now();else if((s===1||s===4)&&xa)c=sn();else return Oa(28),-1;return k[a>>2]=c/1e3|0,k[a+4>>2]=c%1e3*1e3*1e3|0,0}function Pa(s){return s<0||s===0&&1/s===-1/0}function Na(s,a){return(s>>>0)+a*4294967296}function Da(s,a){return(s>>>0)+(a>>>0)*4294967296}function Ji(s,a){if(s<=0)return s;var c=a<=32?Math.abs(1<<a-1):Math.pow(2,a-1);return s>=c&&(a<=32||s>c)&&(s=-2*c+s),s}function Xi(s,a){return s>=0?s:a<=32?2*Math.abs(1<<a-1)+s:Math.pow(2,a)+s}function Qi(s){for(var a=s;se[a];)++a;return a-s}e._strlen=Qi;function Ca(s,a){var c=s,f=a;function b(Ne,Me){return(Me==="double"||Me==="i64")&&Ne&7&&(Ne+=4),Ne}function E(Ne){var Me;return f=b(f,Ne),Ne==="double"?(Me=Number(Xr[f>>3]),f+=8):Ne=="i64"?(Me=[k[f>>2],k[f+4>>2]],f+=8):(Ne="i32",Me=k[f>>2],f+=4),Me}for(var S=[],A,y,v;;){var q=c;if(A=R[c>>0],A===0)break;if(y=R[c+1>>0],A==37){var K=!1,G=!1,Q=!1,j=!1,ee=!1;e:for(;;){switch(y){case 43:K=!0;break;case 45:G=!0;break;case 35:Q=!0;break;case 48:if(j)break e;j=!0;break;case 32:ee=!0;break;default:break e}c++,y=R[c+1>>0]}var Y=0;if(y==42)Y=E("i32"),c++,y=R[c+1>>0];else for(;y>=48&&y<=57;)Y=Y*10+(y-48),c++,y=R[c+1>>0];var he=!1,g=-1;if(y==46){if(g=0,he=!0,c++,y=R[c+1>>0],y==42)g=E("i32"),c++;else for(;;){var C=R[c+1>>0];if(C<48||C>57)break;g=g*10+(C-48),c++}y=R[c+1>>0]}g<0&&(g=6,he=!1);var H;switch(String.fromCharCode(y)){case"h":var J=R[c+2>>0];J==104?(c++,H=1):H=2;break;case"l":var J=R[c+2>>0];J==108?(c++,H=8):H=4;break;case"L":case"q":case"j":H=8;break;case"z":case"t":case"I":H=4;break;default:H=null}switch(H&&c++,y=R[c+1>>0],String.fromCharCode(y)){case"d":case"i":case"u":case"o":case"x":case"X":case"p":{var Ee=y==100||y==105;H=H||4,v=E("i"+H*8);var P;if(H==8&&(v=y==117?Da(v[0],v[1]):Na(v[0],v[1])),H<=4){var Le=Math.pow(256,H)-1;v=(Ee?Ji:Xi)(v&Le,H*8)}var Nt=Math.abs(v),_e="";if(y==100||y==105)P=Ji(v,8*H,1).toString(10);else if(y==117)P=Xi(v,8*H,1).toString(10),v=Math.abs(v);else if(y==111)P=(Q?"0":"")+Nt.toString(8);else if(y==120||y==88){if(_e=Q&&v!=0?"0x":"",v<0){v=-v,P=(Nt-1).toString(16);for(var rs=[],Pe=0;Pe<P.length;Pe++)rs.push((15-parseInt(P[Pe],16)).toString(16));for(P=rs.join("");P.length<H*2;)P="f"+P}else P=Nt.toString(16);y==88&&(_e=_e.toUpperCase(),P=P.toUpperCase())}else y==112&&(Nt===0?P="(nil)":(_e="0x",P=Nt.toString(16)));if(he)for(;P.length<g;)P="0"+P;for(v>=0&&(K?_e="+"+_e:ee&&(_e=" "+_e)),P.charAt(0)=="-"&&(_e="-"+_e,P=P.substr(1));_e.length+P.length<Y;)G?P+=" ":j?P="0"+P:_e=" "+_e;P=_e+P,P.split("").forEach(function(Ne){S.push(Ne.charCodeAt(0))});break}case"f":case"F":case"e":case"E":case"g":case"G":{v=E("double");var P;if(isNaN(v))P="nan",j=!1;else if(!isFinite(v))P=(v<0?"-":"")+"inf",j=!1;else{var ns=!1,Dt=Math.min(g,20);if(y==103||y==71){ns=!0,g=g||1;var mn=parseInt(v.toExponential(Dt).split("e")[1],10);g>mn&&mn>=-4?(y=(y==103?"f":"F").charCodeAt(0),g-=mn+1):(y=(y==103?"e":"E").charCodeAt(0),g--),Dt=Math.min(g,20)}y==101||y==69?(P=v.toExponential(Dt),/[eE][-+]\d$/.test(P)&&(P=P.slice(0,-1)+"0"+P.slice(-1))):(y==102||y==70)&&(P=v.toFixed(Dt),v===0&&Pa(v)&&(P="-"+P));var Re=P.split("e");if(ns&&!Q)for(;Re[0].length>1&&Re[0].includes(".")&&(Re[0].slice(-1)=="0"||Re[0].slice(-1)==".");)Re[0]=Re[0].slice(0,-1);else for(Q&&P.indexOf(".")==-1&&(Re[0]+=".");g>Dt++;)Re[0]+="0";P=Re[0]+(Re.length>1?"e"+Re[1]:""),y==69&&(P=P.toUpperCase()),v>=0&&(K?P="+"+P:ee&&(P=" "+P))}for(;P.length<Y;)G?P+=" ":j&&(P[0]=="-"||P[0]=="+")?P=P[0]+"0"+P.slice(1):P=(j?"0":" ")+P;y<97&&(P=P.toUpperCase()),P.split("").forEach(function(Me){S.push(Me.charCodeAt(0))});break}case"s":{var cr=E("i8*"),mt=cr?Qi(cr):6;if(he&&(mt=Math.min(mt,g)),!G)for(;mt<Y--;)S.push(32);if(cr)for(var Pe=0;Pe<mt;Pe++)S.push(se[cr++>>0]);else S=S.concat(zi("(null)".substr(0,mt),!0));if(G)for(;mt<Y--;)S.push(32);break}case"c":{for(G&&S.push(E("i8"));--Y>0;)S.push(32);G||S.push(E("i8"));break}case"n":{var qu=E("i32*");k[qu>>2]=S.length;break}case"%":{S.push(A);break}default:for(var Pe=q;Pe<c+2;Pe++)S.push(R[Pe>>0])}c+=2}else S.push(A),c+=1}return S}function on(s){if(!s||!s.callee||!s.callee.name)return[null,"",""];var a=s.callee.toString(),c=s.callee.name,f="(",b=!0;for(var E in s){var S=s[E];b||(f+=", "),b=!1,typeof S=="number"||typeof S=="string"?f+=S:f+="("+typeof S+")"}f+=")";var A=s.callee.caller;return s=A?A.arguments:[],b&&(f=""),[s,c,f]}function wa(s){var a=Xo(),c=a.lastIndexOf("_emscripten_log"),f=a.lastIndexOf("_emscripten_get_callstack"),b=a.indexOf(`
10
+ `,Math.max(c,f))+1;a=a.slice(b),s&32&&fe("EM_LOG_DEMANGLE is deprecated; ignoring"),s&8&&typeof emscripten_source_map=="undefined"&&(fe('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.'),s^=8,s|=16);var E=null;if(s&128)for(E=on(arguments);E[1].includes("_emscripten_");)E=on(E[0]);var S=a.split(`
11
11
  `);a="";var A=new RegExp("\\s*(.*?)@(.*?):([0-9]+):([0-9]+)"),y=new RegExp("\\s*(.*?)@(.*):(.*)(:(.*))?"),v=new RegExp("\\s*at (.*?) \\((.*):(.*):(.*)\\)");for(var q in S){var K=S[q],G="",Q="",j=0,ee=0,Y=v.exec(K);if(Y&&Y.length==5)G=Y[1],Q=Y[2],j=Y[3],ee=Y[4];else if(Y=A.exec(K),Y||(Y=y.exec(K)),Y&&Y.length>=4)G=Y[1],Q=Y[2],j=Y[3],ee=Y[4]|0;else{a+=K+`
12
12
  `;continue}var he=!1;if(s&8){var g=emscripten_source_map.originalPositionFor({line:j,column:ee});he=g&&g.source,he&&(s&64&&(g.source=g.source.substring(g.source.replace(/\\/g,"/").lastIndexOf("/")+1)),a+=" at "+G+" ("+g.source+":"+g.line+":"+g.column+`)
13
13
  `)}(s&16||!he)&&(s&64&&(Q=Q.substring(Q.replace(/\\/g,"/").lastIndexOf("/")+1)),a+=(he?" = "+G:" at "+G)+" ("+Q+":"+j+":"+ee+`)
14
14
  `),s&128&&E[0]&&(E[1]==G&&E[2].length>0&&(a=a.replace(/\s+$/,""),a+=" with values: "+E[1]+E[2]+`
15
- `),E=sn(E[0]))}return a=a.replace(/\s+$/,""),a}function Da(s,a){s&24&&(a=a.replace(/\s+$/,""),a+=(a.length>0?`
16
- `:"")+Na(s)),s&1?s&4?ie(a):s&2?console.warn(a):s&512?console.info(a):s&256?console.debug(a):Ae(a):s&6?ie(a):Ae(a)}function wa(s,a,c){var f=Pa(a,c),b=Yr(f,0);Da(s,b)}function Ca(s,a,c){se.copyWithin(s,a,a+c)}function La(s){try{return Zt.grow(s-Kr.byteLength+65535>>>16),Ci(Zt.buffer),1}catch(a){}}function Ma(s){var a=se.length;s=s>>>0;var c=1073741824;if(s>c)return!1;for(var f=1;f<=4;f*=2){var b=a*(1+.2/f);b=Math.min(b,s+100663296);var E=Math.min(c,wo(Math.max(s,b),65536)),S=La(E);if(S)return!0}return!1}var on={};function ka(){return l||"./this.program"}function Pt(){if(!Pt.strings){var s=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:s,_:ka()};for(var c in on)on[c]===void 0?delete a[c]:a[c]=on[c];var f=[];for(var c in a)f.push(c+"="+a[c]);Pt.strings=f}return Pt.strings}var ut={mappings:{},buffers:[null,[],[]],printChar:function(s,a){var c=ut.buffers[s];a===0||a===10?((s===1?Ae:ie)(Yr(c,0)),c.length=0):c.push(a)},varargs:void 0,get:function(){ut.varargs+=4;var s=k[ut.varargs-4>>2];return s},getStr:function(s){var a=Ot(s);return a},get64:function(s,a){return s}};function Ba(s,a){var c=0;return Pt().forEach(function(f,b){var E=a+c;k[s+b*4>>2]=E,Do(f,E),c+=f.length+1}),0}function Va(s,a){var c=Pt();k[s>>2]=c.length;var f=0;return c.forEach(function(b){f+=b.length+1}),k[a>>2]=f,0}function Ha(s){return 0}function Fa(s,a,c,f){var b=ut.getStreamFromFD(s),E=ut.doReadv(b,a,c);return k[f>>2]=E,0}function qa(s,a,c,f,b){}function Wa(s,a,c,f){for(var b=0,E=0;E<c;E++){var S=k[a>>2],A=k[a+4>>2];a+=8;for(var y=0;y<A;y++)ut.printChar(s,se[S+y]);b+=A}return k[f>>2]=b,0}function Ga(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var s=new Uint8Array(1);return function(){return crypto.getRandomValues(s),s[0]}}else return function(){ot("randomDevice")}}function rr(s,a){rr.randomDevice||(rr.randomDevice=Ga());for(var c=0;c<a;c++)R[s+c>>0]=rr.randomDevice();return 0}function ja(s){var a=Date.now();return k[s>>2]=a/1e3|0,k[s+4>>2]=a%1e3*1e3|0,0}function nr(s){return s%4===0&&(s%100!==0||s%400===0)}function an(s,a){for(var c=0,f=0;f<=a;c+=s[f++]);return c}var ir=[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 or(s,a){for(var c=new Date(s.getTime());a>0;){var f=nr(c.getFullYear()),b=c.getMonth(),E=(f?ir:sr)[b];if(a>E-c.getDate())a-=E-c.getDate()+1,c.setDate(1),b<11?c.setMonth(b+1):(c.setMonth(0),c.setFullYear(c.getFullYear()+1));else return c.setDate(c.getDate()+a),c}return c}function $a(s,a,c,f){var b=k[f+40>>2],E={tm_sec:k[f>>2],tm_min:k[f+4>>2],tm_hour:k[f+8>>2],tm_mday:k[f+12>>2],tm_mon:k[f+16>>2],tm_year:k[f+20>>2],tm_wday:k[f+24>>2],tm_yday:k[f+28>>2],tm_isdst:k[f+32>>2],tm_gmtoff:k[f+36>>2],tm_zone:b?Ot(b):""},S=Ot(c),A={"%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 y in A)S=S.replace(new RegExp(y,"g"),A[y]);var v=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],q=["January","February","March","April","May","June","July","August","September","October","November","December"];function K(g,w,H){for(var J=typeof g=="number"?g.toString():g||"";J.length<w;)J=H[0]+J;return J}function G(g,w){return K(g,w,"0")}function Q(g,w){function H(Ee){return Ee<0?-1:Ee>0?1:0}var J;return(J=H(g.getFullYear()-w.getFullYear()))===0&&(J=H(g.getMonth()-w.getMonth()))===0&&(J=H(g.getDate()-w.getDate())),J}function j(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 ee(g){var w=or(new Date(g.tm_year+1900,0,1),g.tm_yday),H=new Date(w.getFullYear(),0,4),J=new Date(w.getFullYear()+1,0,4),Ee=j(H),P=j(J);return Q(Ee,w)<=0?Q(P,w)<=0?w.getFullYear()+1:w.getFullYear():w.getFullYear()-1}var Y={"%a":function(g){return v[g.tm_wday].substring(0,3)},"%A":function(g){return v[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 w=g.tm_year+1900;return G(w/100|0,2)},"%d":function(g){return G(g.tm_mday,2)},"%e":function(g){return K(g.tm_mday,2," ")},"%g":function(g){return ee(g).toString().substring(2)},"%G":function(g){return ee(g)},"%H":function(g){return G(g.tm_hour,2)},"%I":function(g){var w=g.tm_hour;return w==0?w=12:w>12&&(w-=12),G(w,2)},"%j":function(g){return G(g.tm_mday+an(nr(g.tm_year+1900)?ir:sr,g.tm_mon-1),3)},"%m":function(g){return G(g.tm_mon+1,2)},"%M":function(g){return G(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 G(g.tm_sec,2)},"%t":function(){return" "},"%u":function(g){return g.tm_wday||7},"%U":function(g){var w=new Date(g.tm_year+1900,0,1),H=w.getDay()===0?w:or(w,7-w.getDay()),J=new Date(g.tm_year+1900,g.tm_mon,g.tm_mday);if(Q(H,J)<0){var Ee=an(nr(J.getFullYear())?ir:sr,J.getMonth()-1)-31,P=31-H.getDate(),Le=P+Ee+J.getDate();return G(Math.ceil(Le/7),2)}return Q(H,w)===0?"01":"00"},"%V":function(g){var w=new Date(g.tm_year+1900,0,4),H=new Date(g.tm_year+1901,0,4),J=j(w),Ee=j(H),P=or(new Date(g.tm_year+1900,0,1),g.tm_yday);if(Q(P,J)<0)return"53";if(Q(Ee,P)<=0)return"01";var Le;return J.getFullYear()<g.tm_year+1900?Le=g.tm_yday+32-J.getDate():Le=g.tm_yday+1-J.getDate(),G(Math.ceil(Le/7),2)},"%w":function(g){return g.tm_wday},"%W":function(g){var w=new Date(g.tm_year,0,1),H=w.getDay()===1?w:or(w,w.getDay()===0?1:7-w.getDay()+1),J=new Date(g.tm_year+1900,g.tm_mon,g.tm_mday);if(Q(H,J)<0){var Ee=an(nr(J.getFullYear())?ir:sr,J.getMonth()-1)-31,P=31-H.getDate(),Le=P+Ee+J.getDate();return G(Math.ceil(Le/7),2)}return Q(H,w)===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 w=g.tm_gmtoff,H=w>=0;return w=Math.abs(w)/60,w=w/60*100+w%60,(H?"+":"-")+("0000"+w).slice(-4)},"%Z":function(g){return g.tm_zone},"%%":function(){return"%"}};for(var y in Y)S.includes(y)&&(S=S.replace(new RegExp(y,"g"),Y[y](E)));var he=Ji(S,!1);return he.length>a?0:(Di(he,s),he.length-1)}function Ya(s,a,c,f){return $a(s,a,c,f)}function Ka(s){var a=Date.now()/1e3|0;return s&&(k[s>>2]=a),a}ra(),Gi=e.BindingError=Wi(Error,"BindingError"),ua=e.InternalError=Wi(Error,"InternalError"),pa();function Ji(s,a,c){var f=c>0?c:Pi(s)+1,b=new Array(f),E=Oi(s,b,0,b.length);return a&&(b.length=E),b}var Ja={g:Ko,a:Xo,f:ea,r:ta,n:ca,A:fa,l:ha,d:ga,c:Ea,m:Ta,i:Sa,o:ya,e:Aa,j:Ua,b:wa,s:Ca,t:Ma,x:Ba,y:Va,z:Ha,u:Fa,q:qa,k:Wa,v:rr,h:ja,w:Ya,p:Ka},yl=$o(),Xa=e.___wasm_call_ctors=function(){return(Xa=e.___wasm_call_ctors=e.asm.C).apply(null,arguments)},Qa=e._CreateMediaProcessing=function(){return(Qa=e._CreateMediaProcessing=e.asm.D).apply(null,arguments)},za=e._ReleaseMediaProcessing=function(){return(za=e._ReleaseMediaProcessing=e.asm.E).apply(null,arguments)},Za=e._AddAudioChannel=function(){return(Za=e._AddAudioChannel=e.asm.F).apply(null,arguments)},eu=e._DelAudioChannel=function(){return(eu=e._DelAudioChannel=e.asm.G).apply(null,arguments)},tu=e._AddVideoChannel=function(){return(tu=e._AddVideoChannel=e.asm.H).apply(null,arguments)},ru=e._DelVideoChannel=function(){return(ru=e._DelVideoChannel=e.asm.I).apply(null,arguments)},nu=e._ReceivedRawAudioPacket=function(){return(nu=e._ReceivedRawAudioPacket=e.asm.J).apply(null,arguments)},iu=e._ParseUdtMousePacket=function(){return(iu=e._ParseUdtMousePacket=e.asm.K).apply(null,arguments)},su=e._ReceivedAudioUdtPacket=function(){return(su=e._ReceivedAudioUdtPacket=e.asm.L).apply(null,arguments)},ou=e._ParseUdtAudioPacket=function(){return(ou=e._ParseUdtAudioPacket=e.asm.M).apply(null,arguments)},au=e._ReceivedVideoPacket=function(){return(au=e._ReceivedVideoPacket=e.asm.N).apply(null,arguments)},uu=e._SetAudioBuffer10Ms=function(){return(uu=e._SetAudioBuffer10Ms=e.asm.O).apply(null,arguments)},cu=e._SetAudioVolume=function(){return(cu=e._SetAudioVolume=e.asm.P).apply(null,arguments)},lu=e._GetAudioFrame=function(){return(lu=e._GetAudioFrame=e.asm.Q).apply(null,arguments)},mu=e._GetAudioFrameFloat=function(){return(mu=e._GetAudioFrameFloat=e.asm.R).apply(null,arguments)},du=e._GetAudioMixed=function(){return(du=e._GetAudioMixed=e.asm.S).apply(null,arguments)},pu=e._GetAudioMixedFloat=function(){return(pu=e._GetAudioMixedFloat=e.asm.T).apply(null,arguments)},fu=e._GetAudioEnergy=function(){return(fu=e._GetAudioEnergy=e.asm.U).apply(null,arguments)},_u=e._SetAudioFrameFormat=function(){return(_u=e._SetAudioFrameFormat=e.asm.V).apply(null,arguments)},hu=e._SetAudioOutStreamFormat=function(){return(hu=e._SetAudioOutStreamFormat=e.asm.W).apply(null,arguments)},bu=e._AudioProcess=function(){return(bu=e._AudioProcess=e.asm.X).apply(null,arguments)},gu=e._AudioProcessFloat=function(){return(gu=e._AudioProcessFloat=e.asm.Y).apply(null,arguments)},Eu=e._AudioReverseProcess=function(){return(Eu=e._AudioReverseProcess=e.asm.Z).apply(null,arguments)},Tu=e._AudioReverseProcessFloat=function(){return(Tu=e._AudioReverseProcessFloat=e.asm._).apply(null,arguments)},Su=e._InitOpusEncoder=function(){return(Su=e._InitOpusEncoder=e.asm.$).apply(null,arguments)},yu=e._SetOpusEncBitrate=function(){return(yu=e._SetOpusEncBitrate=e.asm.aa).apply(null,arguments)},Au=e._OpusEncode=function(){return(Au=e._OpusEncode=e.asm.ba).apply(null,arguments)},Iu=e._UpdateStreamSync=function(){return(Iu=e._UpdateStreamSync=e.asm.ca).apply(null,arguments)},Ru=e._GetEncodedFrame=function(){return(Ru=e._GetEncodedFrame=e.asm.da).apply(null,arguments)},Uu=e._GetReceivedVideoStat=function(){return(Uu=e._GetReceivedVideoStat=e.asm.ea).apply(null,arguments)},xu=e._CreateUdtPacketizer=function(){return(xu=e._CreateUdtPacketizer=e.asm.fa).apply(null,arguments)},Ou=e._PacketizeVideoUdt=function(){return(Ou=e._PacketizeVideoUdt=e.asm.ga).apply(null,arguments)},vu=e._PacketizeAudioUdt=function(){return(vu=e._PacketizeAudioUdt=e.asm.ha).apply(null,arguments)},Pu=e._GetRetransPacket=function(){return(Pu=e._GetRetransPacket=e.asm.ia).apply(null,arguments)},Nu=e._CheckMissingPacket=function(){return(Nu=e._CheckMissingPacket=e.asm.ja).apply(null,arguments)},Du=e._UseAINS=function(){return(Du=e._UseAINS=e.asm.ka).apply(null,arguments)},wu=e._EnableAEC=function(){return(wu=e._EnableAEC=e.asm.la).apply(null,arguments)},Cu=e._SetCrypto=function(){return(Cu=e._SetCrypto=e.asm.ma).apply(null,arguments)},ar=e._malloc=function(){return(ar=e._malloc=e.asm.oa).apply(null,arguments)},Fe=e._free=function(){return(Fe=e._free=e.asm.pa).apply(null,arguments)},Xi=e.___errno_location=function(){return(Xi=e.___errno_location=e.asm.qa).apply(null,arguments)},Lu=e.___getTypeName=function(){return(Lu=e.___getTypeName=e.asm.ra).apply(null,arguments)},Mu=e.___embind_register_native_and_builtin_types=function(){return(Mu=e.___embind_register_native_and_builtin_types=e.asm.sa).apply(null,arguments)},Qi=e.stackSave=function(){return(Qi=e.stackSave=e.asm.ta).apply(null,arguments)},zi=e.stackRestore=function(){return(zi=e.stackRestore=e.asm.ua).apply(null,arguments)},un=e.stackAlloc=function(){return(un=e.stackAlloc=e.asm.va).apply(null,arguments)},ku=e._emscripten_stack_init=function(){return(ku=e._emscripten_stack_init=e.asm.wa).apply(null,arguments)};e.ccall=Ui,e.cwrap=Ro,e.addFunction=yo,e.removeFunction=Ao;var ur;function Bu(s){this.name="ExitStatus",this.message="Program terminated with exit("+s+")",this.status=s}vt=function s(){ur||cn(),ur||(vt=s)};function cn(s){if(s=s||p,Qe>0||(Mo(),Qe>0))return;function a(){ur||(ur=!0,e.calledRun=!0,!Ii&&(ko(),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),Bo()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),a()},1)):a()}if(e.run=cn,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return cn(),e.ready}}(),go=El;bo(go);
15
+ `),E=on(E[0]))}return a=a.replace(/\s+$/,""),a}function La(s,a){s&24&&(a=a.replace(/\s+$/,""),a+=(a.length>0?`
16
+ `:"")+wa(s)),s&1?s&4?ie(a):s&2?console.warn(a):s&512?console.info(a):s&256?console.debug(a):Ae(a):s&6?ie(a):Ae(a)}function Ma(s,a,c){var f=Ca(a,c),b=Kr(f,0);La(s,b)}function ka(s,a,c){se.copyWithin(s,a,a+c)}function Ba(s){try{return Zt.grow(s-Jr.byteLength+65535>>>16),ki(Zt.buffer),1}catch(a){}}function Va(s){var a=se.length;s=s>>>0;var c=1073741824;if(s>c)return!1;for(var f=1;f<=4;f*=2){var b=a*(1+.2/f);b=Math.min(b,s+100663296);var E=Math.min(c,Mo(Math.max(s,b),65536)),S=Ba(E);if(S)return!0}return!1}var an={};function Ha(){return l||"./this.program"}function Pt(){if(!Pt.strings){var s=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:s,_:Ha()};for(var c in an)an[c]===void 0?delete a[c]:a[c]=an[c];var f=[];for(var c in a)f.push(c+"="+a[c]);Pt.strings=f}return Pt.strings}var lt={mappings:{},buffers:[null,[],[]],printChar:function(s,a){var c=lt.buffers[s];a===0||a===10?((s===1?Ae:ie)(Kr(c,0)),c.length=0):c.push(a)},varargs:void 0,get:function(){lt.varargs+=4;var s=k[lt.varargs-4>>2];return s},getStr:function(s){var a=Ot(s);return a},get64:function(s,a){return s}};function Fa(s,a){var c=0;return Pt().forEach(function(f,b){var E=a+c;k[s+b*4>>2]=E,Lo(f,E),c+=f.length+1}),0}function qa(s,a){var c=Pt();k[s>>2]=c.length;var f=0;return c.forEach(function(b){f+=b.length+1}),k[a>>2]=f,0}function Wa(s){return 0}function Ga(s,a,c,f){var b=lt.getStreamFromFD(s),E=lt.doReadv(b,a,c);return k[f>>2]=E,0}function ja(s,a,c,f,b){}function $a(s,a,c,f){for(var b=0,E=0;E<c;E++){var S=k[a>>2],A=k[a+4>>2];a+=8;for(var y=0;y<A;y++)lt.printChar(s,se[S+y]);b+=A}return k[f>>2]=b,0}function Ya(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var s=new Uint8Array(1);return function(){return crypto.getRandomValues(s),s[0]}}else return function(){ut("randomDevice")}}function rr(s,a){rr.randomDevice||(rr.randomDevice=Ya());for(var c=0;c<a;c++)R[s+c>>0]=rr.randomDevice();return 0}function Ka(s){var a=Date.now();return k[s>>2]=a/1e3|0,k[s+4>>2]=a%1e3*1e3|0,0}function nr(s){return s%4===0&&(s%100!==0||s%400===0)}function un(s,a){for(var c=0,f=0;f<=a;c+=s[f++]);return c}var ir=[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 or(s,a){for(var c=new Date(s.getTime());a>0;){var f=nr(c.getFullYear()),b=c.getMonth(),E=(f?ir:sr)[b];if(a>E-c.getDate())a-=E-c.getDate()+1,c.setDate(1),b<11?c.setMonth(b+1):(c.setMonth(0),c.setFullYear(c.getFullYear()+1));else return c.setDate(c.getDate()+a),c}return c}function Ja(s,a,c,f){var b=k[f+40>>2],E={tm_sec:k[f>>2],tm_min:k[f+4>>2],tm_hour:k[f+8>>2],tm_mday:k[f+12>>2],tm_mon:k[f+16>>2],tm_year:k[f+20>>2],tm_wday:k[f+24>>2],tm_yday:k[f+28>>2],tm_isdst:k[f+32>>2],tm_gmtoff:k[f+36>>2],tm_zone:b?Ot(b):""},S=Ot(c),A={"%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 y in A)S=S.replace(new RegExp(y,"g"),A[y]);var v=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],q=["January","February","March","April","May","June","July","August","September","October","November","December"];function K(g,C,H){for(var J=typeof g=="number"?g.toString():g||"";J.length<C;)J=H[0]+J;return J}function G(g,C){return K(g,C,"0")}function Q(g,C){function H(Ee){return Ee<0?-1:Ee>0?1:0}var J;return(J=H(g.getFullYear()-C.getFullYear()))===0&&(J=H(g.getMonth()-C.getMonth()))===0&&(J=H(g.getDate()-C.getDate())),J}function j(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 ee(g){var C=or(new Date(g.tm_year+1900,0,1),g.tm_yday),H=new Date(C.getFullYear(),0,4),J=new Date(C.getFullYear()+1,0,4),Ee=j(H),P=j(J);return Q(Ee,C)<=0?Q(P,C)<=0?C.getFullYear()+1:C.getFullYear():C.getFullYear()-1}var Y={"%a":function(g){return v[g.tm_wday].substring(0,3)},"%A":function(g){return v[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 C=g.tm_year+1900;return G(C/100|0,2)},"%d":function(g){return G(g.tm_mday,2)},"%e":function(g){return K(g.tm_mday,2," ")},"%g":function(g){return ee(g).toString().substring(2)},"%G":function(g){return ee(g)},"%H":function(g){return G(g.tm_hour,2)},"%I":function(g){var C=g.tm_hour;return C==0?C=12:C>12&&(C-=12),G(C,2)},"%j":function(g){return G(g.tm_mday+un(nr(g.tm_year+1900)?ir:sr,g.tm_mon-1),3)},"%m":function(g){return G(g.tm_mon+1,2)},"%M":function(g){return G(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 G(g.tm_sec,2)},"%t":function(){return" "},"%u":function(g){return g.tm_wday||7},"%U":function(g){var C=new Date(g.tm_year+1900,0,1),H=C.getDay()===0?C:or(C,7-C.getDay()),J=new Date(g.tm_year+1900,g.tm_mon,g.tm_mday);if(Q(H,J)<0){var Ee=un(nr(J.getFullYear())?ir:sr,J.getMonth()-1)-31,P=31-H.getDate(),Le=P+Ee+J.getDate();return G(Math.ceil(Le/7),2)}return Q(H,C)===0?"01":"00"},"%V":function(g){var C=new Date(g.tm_year+1900,0,4),H=new Date(g.tm_year+1901,0,4),J=j(C),Ee=j(H),P=or(new Date(g.tm_year+1900,0,1),g.tm_yday);if(Q(P,J)<0)return"53";if(Q(Ee,P)<=0)return"01";var Le;return J.getFullYear()<g.tm_year+1900?Le=g.tm_yday+32-J.getDate():Le=g.tm_yday+1-J.getDate(),G(Math.ceil(Le/7),2)},"%w":function(g){return g.tm_wday},"%W":function(g){var C=new Date(g.tm_year,0,1),H=C.getDay()===1?C:or(C,C.getDay()===0?1:7-C.getDay()+1),J=new Date(g.tm_year+1900,g.tm_mon,g.tm_mday);if(Q(H,J)<0){var Ee=un(nr(J.getFullYear())?ir:sr,J.getMonth()-1)-31,P=31-H.getDate(),Le=P+Ee+J.getDate();return G(Math.ceil(Le/7),2)}return Q(H,C)===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 C=g.tm_gmtoff,H=C>=0;return C=Math.abs(C)/60,C=C/60*100+C%60,(H?"+":"-")+("0000"+C).slice(-4)},"%Z":function(g){return g.tm_zone},"%%":function(){return"%"}};for(var y in Y)S.includes(y)&&(S=S.replace(new RegExp(y,"g"),Y[y](E)));var he=zi(S,!1);return he.length>a?0:(Li(he,s),he.length-1)}function Xa(s,a,c,f){return Ja(s,a,c,f)}function Qa(s){var a=Date.now()/1e3|0;return s&&(k[s>>2]=a),a}sa(),Yi=e.BindingError=$i(Error,"BindingError"),ma=e.InternalError=$i(Error,"InternalError"),ha();function zi(s,a,c){var f=c>0?c:Ci(s)+1,b=new Array(f),E=Ni(s,b,0,b.length);return a&&(b.length=E),b}var za={g:Qo,a:Zo,f:na,r:ia,n:da,A:ba,l:Ea,d:Sa,c:ya,m:Aa,i:Ia,o:Ra,e:Ua,j:va,b:Ma,s:ka,t:Va,x:Fa,y:qa,z:Wa,u:Ga,q:ja,k:$a,v:rr,h:Ka,w:Xa,p:Qa},Ul=Jo(),Za=e.___wasm_call_ctors=function(){return(Za=e.___wasm_call_ctors=e.asm.C).apply(null,arguments)},eu=e._CreateMediaProcessing=function(){return(eu=e._CreateMediaProcessing=e.asm.D).apply(null,arguments)},tu=e._ReleaseMediaProcessing=function(){return(tu=e._ReleaseMediaProcessing=e.asm.E).apply(null,arguments)},ru=e._AddAudioChannel=function(){return(ru=e._AddAudioChannel=e.asm.F).apply(null,arguments)},nu=e._DelAudioChannel=function(){return(nu=e._DelAudioChannel=e.asm.G).apply(null,arguments)},iu=e._AddVideoChannel=function(){return(iu=e._AddVideoChannel=e.asm.H).apply(null,arguments)},su=e._DelVideoChannel=function(){return(su=e._DelVideoChannel=e.asm.I).apply(null,arguments)},ou=e._ReceivedRawAudioPacket=function(){return(ou=e._ReceivedRawAudioPacket=e.asm.J).apply(null,arguments)},au=e._ParseUdtMousePacket=function(){return(au=e._ParseUdtMousePacket=e.asm.K).apply(null,arguments)},uu=e._ReceivedAudioUdtPacket=function(){return(uu=e._ReceivedAudioUdtPacket=e.asm.L).apply(null,arguments)},cu=e._ParseUdtAudioPacket=function(){return(cu=e._ParseUdtAudioPacket=e.asm.M).apply(null,arguments)},lu=e._ReceivedVideoPacket=function(){return(lu=e._ReceivedVideoPacket=e.asm.N).apply(null,arguments)},mu=e._SetAudioBuffer10Ms=function(){return(mu=e._SetAudioBuffer10Ms=e.asm.O).apply(null,arguments)},du=e._SetAudioVolume=function(){return(du=e._SetAudioVolume=e.asm.P).apply(null,arguments)},pu=e._GetAudioFrame=function(){return(pu=e._GetAudioFrame=e.asm.Q).apply(null,arguments)},fu=e._GetAudioFrameFloat=function(){return(fu=e._GetAudioFrameFloat=e.asm.R).apply(null,arguments)},_u=e._GetAudioMixed=function(){return(_u=e._GetAudioMixed=e.asm.S).apply(null,arguments)},hu=e._GetAudioMixedFloat=function(){return(hu=e._GetAudioMixedFloat=e.asm.T).apply(null,arguments)},bu=e._GetAudioEnergy=function(){return(bu=e._GetAudioEnergy=e.asm.U).apply(null,arguments)},gu=e._SetAudioFrameFormat=function(){return(gu=e._SetAudioFrameFormat=e.asm.V).apply(null,arguments)},Eu=e._SetAudioOutStreamFormat=function(){return(Eu=e._SetAudioOutStreamFormat=e.asm.W).apply(null,arguments)},Tu=e._AudioProcess=function(){return(Tu=e._AudioProcess=e.asm.X).apply(null,arguments)},Su=e._AudioProcessFloat=function(){return(Su=e._AudioProcessFloat=e.asm.Y).apply(null,arguments)},yu=e._AudioReverseProcess=function(){return(yu=e._AudioReverseProcess=e.asm.Z).apply(null,arguments)},Au=e._AudioReverseProcessFloat=function(){return(Au=e._AudioReverseProcessFloat=e.asm._).apply(null,arguments)},Iu=e._InitOpusEncoder=function(){return(Iu=e._InitOpusEncoder=e.asm.$).apply(null,arguments)},Ru=e._SetOpusEncBitrate=function(){return(Ru=e._SetOpusEncBitrate=e.asm.aa).apply(null,arguments)},Uu=e._OpusEncode=function(){return(Uu=e._OpusEncode=e.asm.ba).apply(null,arguments)},xu=e._UpdateStreamSync=function(){return(xu=e._UpdateStreamSync=e.asm.ca).apply(null,arguments)},Ou=e._GetEncodedFrame=function(){return(Ou=e._GetEncodedFrame=e.asm.da).apply(null,arguments)},vu=e._GetReceivedVideoStat=function(){return(vu=e._GetReceivedVideoStat=e.asm.ea).apply(null,arguments)},Pu=e._CreateUdtPacketizer=function(){return(Pu=e._CreateUdtPacketizer=e.asm.fa).apply(null,arguments)},Nu=e._PacketizeVideoUdt=function(){return(Nu=e._PacketizeVideoUdt=e.asm.ga).apply(null,arguments)},Du=e._PacketizeAudioUdt=function(){return(Du=e._PacketizeAudioUdt=e.asm.ha).apply(null,arguments)},Cu=e._GetRetransPacket=function(){return(Cu=e._GetRetransPacket=e.asm.ia).apply(null,arguments)},wu=e._CheckMissingPacket=function(){return(wu=e._CheckMissingPacket=e.asm.ja).apply(null,arguments)},Lu=e._UseAINS=function(){return(Lu=e._UseAINS=e.asm.ka).apply(null,arguments)},Mu=e._EnableAEC=function(){return(Mu=e._EnableAEC=e.asm.la).apply(null,arguments)},ku=e._SetCrypto=function(){return(ku=e._SetCrypto=e.asm.ma).apply(null,arguments)},ar=e._malloc=function(){return(ar=e._malloc=e.asm.oa).apply(null,arguments)},Fe=e._free=function(){return(Fe=e._free=e.asm.pa).apply(null,arguments)},Zi=e.___errno_location=function(){return(Zi=e.___errno_location=e.asm.qa).apply(null,arguments)},Bu=e.___getTypeName=function(){return(Bu=e.___getTypeName=e.asm.ra).apply(null,arguments)},Vu=e.___embind_register_native_and_builtin_types=function(){return(Vu=e.___embind_register_native_and_builtin_types=e.asm.sa).apply(null,arguments)},es=e.stackSave=function(){return(es=e.stackSave=e.asm.ta).apply(null,arguments)},ts=e.stackRestore=function(){return(ts=e.stackRestore=e.asm.ua).apply(null,arguments)},cn=e.stackAlloc=function(){return(cn=e.stackAlloc=e.asm.va).apply(null,arguments)},Hu=e._emscripten_stack_init=function(){return(Hu=e._emscripten_stack_init=e.asm.wa).apply(null,arguments)};e.ccall=vi,e.cwrap=Oo,e.addFunction=Ro,e.removeFunction=Uo;var ur;function Fu(s){this.name="ExitStatus",this.message="Program terminated with exit("+s+")",this.status=s}vt=function s(){ur||ln(),ur||(vt=s)};function ln(s){if(s=s||p,Qe>0||(Vo(),Qe>0))return;function a(){ur||(ur=!0,e.calledRun=!0,!xi&&(Ho(),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),Fo()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),a()},1)):a()}if(e.run=ln,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return ln(),e.ready}}(),So=Al;To(So);