trtc-sdk-v5 5.9.0-wasm.11 → 5.9.0-wasm.13
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/av_processing.wasm +0 -0
- package/assets/videodec.wasm +0 -0
- package/assets/videodec_simd.wasm +0 -0
- package/assets/worker.js +17 -0
- package/index.d.ts +0 -3
- package/package.json +4 -6
- package/plugins/cdn-streaming/package.json +1 -1
- package/plugins/cross-room/package.json +1 -1
- package/plugins/custom-encryption/custom-encryption.esm.d.ts +34 -0
- package/plugins/custom-encryption/custom-encryption.esm.js +36 -0
- package/plugins/custom-encryption/custom-encryption.iife.js +36 -0
- package/plugins/custom-encryption/package.json +7 -0
- package/plugins/device-detector/package.json +1 -1
- package/plugins/video-decoder/package.json +2 -2
- package/plugins/video-decoder/video-decoder.esm.js +38 -38
- package/plugins/video-decoder/video-decoder.iife.js +38 -38
- package/plugins/video-effect/basic-beauty/package.json +1 -1
- package/plugins/video-effect/beauty/package.json +1 -1
- package/plugins/video-effect/virtual-background/package.json +1 -1
- package/plugins/video-effect/watermark/package.json +1 -1
- package/trtc.esm.js +64 -41
- package/trtc.js +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/worker.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var fu=Object.create;var rr=Object.defineProperty;var Fs=Object.getOwnPropertyDescriptor;var hu=Object.getOwnPropertyNames,Vs=Object.getOwnPropertySymbols,bu=Object.getPrototypeOf,Hs=Object.prototype.hasOwnProperty,gu=Object.prototype.propertyIsEnumerable;var Zr=(n,t,e)=>t in n?rr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,en=(n,t)=>{for(var e in t||(t={}))Hs.call(t,e)&&Zr(n,e,t[e]);if(Vs)for(var e of Vs(t))gu.call(t,e)&&Zr(n,e,t[e]);return n};var Eu=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var Tu=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of hu(t))!Hs.call(n,i)&&i!==e&&rr(n,i,{get:()=>t[i],enumerable:!(r=Fs(t,i))||r.enumerable});return n};var nr=(n,t,e)=>(e=n!=null?fu(bu(n)):{},Tu(t||!n||!n.__esModule?rr(e,"default",{value:n,enumerable:!0}):e,n));var ce=(n,t,e,r)=>{for(var i=r>1?void 0:r?Fs(t,e):t,a=n.length-1,c;a>=0;a--)(c=n[a])&&(i=(r?c(t,e,i):c(i))||i);return r&&i&&rr(t,e,i),i};var d=(n,t,e)=>Zr(n,typeof t!="symbol"?t+"":t,e);var wt=Eu((td,Wn)=>{"use strict";var Pu=Object.prototype.hasOwnProperty,de="~";function Ct(){}Object.create&&(Ct.prototype=Object.create(null),new Ct().__proto__||(de=!1));function Nu(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function Xs(n,t,e,r,i){if(typeof e!="function")throw new TypeError("The listener must be a function");var a=new Nu(e,r||n,i),c=de?de+t:t;return n._events[c]?n._events[c].fn?n._events[c]=[n._events[c],a]:n._events[c].push(a):(n._events[c]=a,n._eventsCount++),n}function gr(n,t){--n._eventsCount===0?n._events=new Ct:delete n._events[t]}function ae(){this._events=new Ct,this._eventsCount=0}ae.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)Pu.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,a=r.length,c=new Array(a);i<a;i++)c[i]=r[i].fn;return c};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,a,c){var _=de?de+t:t;if(!this._events[_])return!1;var l=this._events[_],m=arguments.length,h,f;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,a),!0;case 6:return l.fn.call(l.context,e,r,i,a,c),!0}for(f=1,h=new Array(m-1);f<m;f++)h[f-1]=arguments[f];l.fn.apply(l.context,h)}else{var y=l.length,x;for(f=0;f<y;f++)switch(l[f].once&&this.removeListener(t,l[f].fn,void 0,!0),m){case 1:l[f].fn.call(l[f].context);break;case 2:l[f].fn.call(l[f].context,e);break;case 3:l[f].fn.call(l[f].context,e,r);break;case 4:l[f].fn.call(l[f].context,e,r,i);break;default:if(!h)for(x=1,h=new Array(m-1);x<m;x++)h[x-1]=arguments[x];l[f].fn.apply(l[f].context,h)}}return!0};ae.prototype.on=function(t,e,r){return Xs(this,t,e,r,!1)};ae.prototype.once=function(t,e,r){return Xs(this,t,e,r,!0)};ae.prototype.removeListener=function(t,e,r,i){var a=de?de+t:t;if(!this._events[a])return this;if(!e)return gr(this,a),this;var c=this._events[a];if(c.fn)c.fn===e&&(!i||c.once)&&(!r||c.context===r)&&gr(this,a);else{for(var _=0,l=[],m=c.length;_<m;_++)(c[_].fn!==e||i&&!c[_].once||r&&c[_].context!==r)&&l.push(c[_]);l.length?this._events[a]=l.length===1?l[0]:l:gr(this,a)}return this};ae.prototype.removeAllListeners=function(t){var e;return t?(e=de?de+t:t,this._events[e]&&gr(this,e)):(this._events=new Ct,this._eventsCount=0),this};ae.prototype.off=ae.prototype.removeListener;ae.prototype.addListener=ae.prototype.on;ae.prefixed=de;ae.EventEmitter=ae;typeof Wn!="undefined"&&(Wn.exports=ae)});function G(...n){}var Su=n=>n();function rn(){this.dispose()}var Iu=()=>typeof __FASTRX_DEVTOOLS__!="undefined",yu=1,Ne=class extends Function{toString(){return`${this.name}(${this.args.length?[...this.args].join(", "):""})`}subscribe(t){let e=new tn(t,this,this.streamId++);return ee.subscribe({id:this.id,end:!1},{nodeId:e.sourceId,streamId:e.id}),this(e),e}},ct=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=G,this.error=G,this.next=G,this.dispose=G,this.subscribe=G,this.doDefer()}subscribe(t){return t instanceof Ne?t.subscribe(this):t(this),this}get bindSubscribe(){return t=>this.subscribe(t)}doDefer(){this.defers.forEach(Su),this.defers.clear()}defer(t){this.defers.add(t)}removeDefer(t){this.defers.delete(t)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}},P=class extends ct{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)}},sr=class extends ct{constructor(t,e=G,r=G,i=G){if(super(),this._next=e,this._error=r,this._complete=i,this.then=G,t instanceof Ne){let a={toString:()=>"subscribe",id:0,source:t};this.defer(()=>{ee.defer(a,0)}),ee.create(a),ee.pipe(a),this.sourceId=a.id,this.subscribe(t),ee.subscribe({id:a.id,end:!0}),e==G?this._next=c=>ee.next(a,0,c):this.next=c=>{ee.next(a,0,c),e(c)},i==G?this._complete=()=>ee.complete(a,0):this.complete=()=>{this.dispose(),ee.complete(a,0),i()},r==G?this._error=c=>ee.complete(a,0,c):this.error=c=>{this.dispose(),ee.complete(a,0,c),r()}}else this.subscribe(t)}next(t){this._next(t)}complete(){this.dispose(),this._complete()}error(t){this.dispose(),this._error(t)}};function V(n,...t){return t.reduce((e,r)=>r(e),n)}function le(n,t,e){if(Iu()){let r=Object.defineProperties(Object.setPrototypeOf(n,Ne.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}});ee.create(r);for(let i=0;i<e.length;i++){let a=e[i];typeof a=="function"&&a instanceof Ne&&ee.addSource(r,a)}return r}return n}function w(n,t){return function(...e){return r=>{if(r instanceof Ne){let i=le(a=>{let c=new n(a,...e);c.sourceId=i.id,c.subscribe(r)},t,arguments);return i.source=r,ee.pipe(i),i}else return i=>r(new n(i,...e))}}}function He(n,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:n,payload:t}})}var tn=class extends P{constructor(t,e,r){super(t),this.source=e,this.id=r,this.sourceId=t.sourceId,this.defer(()=>{ee.defer(this.source,this.id)})}next(t){ee.next(this.source,this.id,t),this.sink.next(t)}complete(){ee.complete(this.source,this.id),this.sink.complete()}error(t){ee.complete(this.source,this.id,t),this.sink.error(t)}},ee={addSource(n,t){He("addSource",{id:n.id,name:n.toString(),source:{id:t.id,name:t.toString()}})},next(n,t,e){He("next",{id:n.id,streamId:t,data:e&&e.toString()})},subscribe({id:n,end:t},e){He("subscribe",{id:n,end:t,sink:{nodeId:e&&e.nodeId,streamId:e&&e.streamId}})},complete(n,t,e){He("complete",{id:n.id,streamId:t,err:e?e.toString():null})},defer(n,t){He("defer",{id:n.id,streamId:t})},pipe(n){He("pipe",{name:n.toString(),id:n.id,source:{id:n.source.id,name:n.source.toString()}})},update(n){He("update",{id:n.id,name:n.toString()})},create(n){n.id||(n.id=yu++),He("create",{name:n.toString(),id:n.id})}},ir=class extends Error{constructor(t){super(`timeout after ${t}ms`),this.timeout=t}};var nn=class extends ct{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 qe(){return n=>{let t=new nn(n);if(n instanceof Ne){let e=le(r=>{t.add(r)},"share",arguments);return t.sourceId=e.id,e.source=n,ee.pipe(e),e}return le(t.add.bind(t),"share",arguments)}}function qs(...n){return le(t=>{let e=new P(t),r=n.length;e.complete=()=>{--r===0&&t.complete()},n.forEach(e.bindSubscribe)},"merge",arguments)}function Au(...n){return le(t=>{let e=n.length,r=e,i=e,a=new Array(e),c=()=>{--i===0&&t.complete()},_=(l,m)=>{let h=new P(t);h.next=f=>{--r===0?(h.next=y=>{a[m]=y,t.next(a)},h.next(f)):a[m]=f},h.complete=c,h.subscribe(l)};n.forEach(_)},"combineLatest",arguments)}function Ws(...n){return le(t=>{let e=n.length,r=e,i=new Array(e),a=()=>{--r===0&&t.complete()},c=(_,l)=>{let m=new P(t),h=[];i[l]=h,m.next=f=>{h.push(f),i.every(y=>y.length)&&t.next(i.map(y=>y.shift()))},m.complete=a,m.subscribe(_)};n.forEach(c)},"zip",arguments)}var sn=class extends P{constructor(t,...e){super(t);let r=new P(this.sink);r.next=i=>this.buffer=i,r.complete=G,r.subscribe(Au(...e))}next(t){this.buffer&&this.sink.next([t,...this.buffer])}},Gc=w(sn,"withLatestFrom"),on=class extends P{constructor(t,e,r){super(t),this.bufferSize=e,this.startBufferEvery=r,this.buffer=[],this.count=0,this.startBufferEvery&&(this.buffers=[[]])}next(t){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach(e=>{e.push(t)}),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(t),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}complete(){this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach(t=>this.sink.next(t)),super.complete()}},jc=w(on,"bufferCount"),an=class extends P{constructor(t,e){super(t),this.buffer=[];let r=new P(t);r.next=i=>{t.next(this.buffer),this.buffer=[]},r.complete=G,r.subscribe(e)}next(t){this.buffer.push(t)}complete(){this.buffer.length&&this.sink.next(this.buffer),super.complete()}},Yc=w(an,"buffer");function Qe(n){let t=arguments,e=qe()(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=G,e.complete=G,e.error=G,e}function lt(n){return le(t=>{let e=0,r=setInterval(()=>t.next(e++),n);return t.defer(()=>{clearInterval(r)}),"interval"},"interval",arguments)}function Gs(n,t){return le(e=>{let r=0,i=setTimeout(()=>{if(e.removeDefer(a),e.next(r++),t){let c=setInterval(()=>e.next(r++),t);e.defer(()=>{clearInterval(c)})}else e.complete()},n),a=()=>{clearTimeout(i)};e.defer(a)},"timer",arguments)}function un(n,t){return e=>{let r=i=>e.next(i);e.defer(()=>t(r)),n(r)}}function Ee(n,t){if("on"in n&&"off"in n)return le(un(e=>n.on(t,e),e=>n.off(t,e)),"fromEvent",arguments);if("addListener"in n&&"removeListener"in n)return le(un(e=>n.addListener(t,e),e=>n.removeListener(t,e)),"fromEvent",arguments);if("addEventListener"in n)return le(un(e=>n.addEventListener(t,e),e=>n.removeEventListener(t,e)),"fromEvent",arguments);throw"target is not a EventDispachter"}var cn=class extends P{constructor(t,e,r){super(t),this.f=e;let i=()=>{this.sink.next(this.acc),this.sink.complete()};typeof r=="undefined"?this.next=a=>{this.acc=a,this.complete=i,this.resetNext()}:(this.acc=r,this.complete=i)}next(t){this.acc=this.f(this.acc,t)}},Ru=w(cn,"reduce");var ln=class extends P{constructor(t,e,r){super(t),this.filter=e,this.thisArg=r}next(t){this.filter.call(this.thisArg,t)&&this.sink.next(t)}},dt=w(ln,"filter"),dn=class extends P{next(t){}},rl=w(dn,"ignoreElements"),mn=class extends P{constructor(t,e){super(t),this.count=e}next(t){this.sink.next(t),--this.count===0&&this.complete()}},ar=w(mn,"take"),pn=class extends P{constructor(t,e){super(t);let r=new P(t);r.next=()=>t.complete(),r.complete=rn,r.subscribe(e)}},Re=w(pn,"takeUntil"),_n=class extends P{constructor(t,e){super(t),this.f=e}next(t){this.f(t)?this.sink.next(t):this.complete()}},vn=w(_n,"takeWhile");var fn=class extends P{constructor(t,e){super(t),this.count=e}next(t){--this.count===0&&(this.next=super.next)}},nl=w(fn,"skip"),hn=class extends P{constructor(t,e){super(t),t.next=G;let r=new P(t);r.next=()=>{r.dispose(),t.resetNext()},r.complete=rn,r.subscribe(e)}},sl=w(hn,"skipUntil"),bn=class extends P{constructor(t,e){super(t),this.f=e}next(t){this.f(t)||(this.next=super.next,this.next(t))}},js=w(bn,"skipWhile"),vu={leading:!0,trailing:!1},gn=class extends P{constructor(t,e,r){super(t),this.durationSelector=e,this.trailing=r}cacheValue(t){this.last=t,this.disposed&&this.throttle(t)}send(t){this.sink.next(t),this.throttle(t)}throttle(t){this.reset(),this.subscribe(this.durationSelector(t))}next(){this.complete()}complete(){this.dispose(),this.trailing&&this.send(this.last)}},En=class extends P{constructor(t,e,r=vu){super(t),this.durationSelector=e,this.config=r,this._throttle=new gn(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=G,this._throttle.complete(),super.complete()}},Ys=w(En,"throttle");var Tn=class extends P{next(){this.complete()}complete(){this.dispose(),this.sink.next(this.last)}},or=class extends P{constructor(t,e){super(t),this.durationSelector=e,this._debounce=new Tn(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()}},$s=w(or,"debounce"),Ks=n=>w(or,"debounceTime")(t=>Gs(n)),Sn=class extends P{constructor(t,e,r){super(t),this.count=e,this.defaultValue=r}next(t){this.count--===0&&(this.defaultValue=t,this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("not enough elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},il=w(Sn,"elementAt");var In=class extends P{constructor(t,e){super(t),this.f=e,this.i=0}next(t){this.f(t)?(this.sink.next(this.i++),this.complete()):++this.i}},ol=w(In,"findIndex"),yn=class extends P{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t,this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},al=w(yn,"first"),An=class extends P{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t)}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},ul=w(An,"last"),Rn=class extends P{constructor(t,e){super(t),this.predicate=e,this.index=0}next(t){this.predicate(t,this.index++)?this.result=!0:(this.result=!1,this.complete())}complete(){if(this.result===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.result);super.complete()}},cl=w(Rn,"every");var Un=class extends P{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))}},pl=w(Un,"scan"),xn=class extends P{constructor(){super(...arguments),this.hasLast=!1}next(t){this.hasLast?this.sink.next([this.last,t]):this.hasLast=!0,this.last=t}},_l=w(xn,"pairwise"),ur=class extends P{constructor(t,e,r){super(t),this.mapper=e,this.thisArg=r}next(t){super.next(this.mapper.call(this.thisArg,t))}},ze=w(ur,"map"),kn=n=>w(ur,"mapTo")(t=>n),mt=class extends P{constructor(t,e,r){super(t),this.data=e,this.context=r}next(t){let e=this.context.combineResults;e?this.sink.next(e(this.data,t)):this.sink.next(t)}tryComplete(){this.context.resetComplete(),this.dispose()}},pt=class extends P{constructor(t,e,r){super(t),this.makeSource=e,this.combineResults=r,this.index=0}subInner(t,e){let r=this.currentSink=new e(this.sink,t,this);this.complete=this.tryComplete,r.complete=r.tryComplete,r.subscribe(this.makeSource(t,this.index++))}tryComplete(){this.currentSink.resetComplete(),this.dispose()}},cr=class extends mt{},lr=class extends pt{next(t){this.subInner(t,cr),this.next=e=>{this.currentSink.dispose(),this.subInner(e,cr)}}},Bn=w(lr,"switchMap");function _r(n){return(t,e)=>n(()=>t,e)}var Pt=_r(w(lr,"switchMapTo")),On=class extends mt{tryComplete(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}},dr=class extends pt{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(),On),this.disposed&&this.sources.length===0&&this.currentSink.resetComplete()}tryComplete(){this.sources.length===0&&this.currentSink.resetComplete(),this.dispose()}},fl=w(dr,"concatMap"),hl=_r(w(dr,"concatMapTo")),Pn=class extends mt{tryComplete(){this.context.inners.delete(this),super.dispose(),this.context.inners.size===0&&this.context.resetComplete()}},mr=class extends pt{constructor(){super(...arguments),this.inners=new Set}next(t){this.subInner(t,Pn),this.inners.add(this.currentSink)}tryComplete(){this.inners.size===1?this.inners.forEach(t=>t.resetComplete()):this.dispose()}},bl=w(mr,"mergeMap"),gl=_r(w(mr,"mergeMapTo")),Nn=class extends mt{dispose(){this.context.resetNext(),super.dispose()}},pr=class extends pt{next(t){this.next=G,this.subInner(t,Nn)}},El=w(pr,"exhaustMap"),Tl=_r(w(pr,"exhaustMapTo")),Dn=class extends P{constructor(t,e){super(t),this.f=e,this.groups=new Map}next(t){let e=this.f(t),r=this.groups.get(e);typeof r=="undefined"&&(r=Qe(),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)}},Sl=w(Dn,"groupBy"),Cn=class extends P{constructor(){super(...arguments),this.start=new Date}next(t){this.sink.next({value:t,interval:Number(new Date)-Number(this.start)}),this.start=new Date}},Il=w(Cn,"timeInterval"),wn=class extends P{constructor(t,e){super(t),this.miniseconds=e,this.buffer=[],this.id=setInterval(()=>{this.sink.next(this.buffer.concat()),this.buffer.length=0},this.miniseconds)}next(t){this.buffer.push(t)}complete(){this.sink.next(this.buffer),super.complete()}dispose(){clearInterval(this.id),super.dispose()}},yl=w(wn,"bufferTime"),Mn=class extends P{constructor(t,e){super(t),this.buffer=[],this.delayTime=e}dispose(){clearTimeout(this.timeoutId),super.dispose()}delay(t){this.timeoutId=setTimeout(()=>{let e=this.buffer.shift();if(e){let{time:r,data: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)}},Al=w(Mn,"delay"),Ln=class extends P{constructor(t,e){super(t),this.selector=e}error(t){this.dispose(),this.selector(t)(this.sink)}},Rl=w(Ln,"catchError");var X=(n=G,t=G,e=G)=>r=>new sr(r,n,t,e),Vn=class extends P{constructor(t,e){super(t),e instanceof Function?this.next=r=>{e(r),t.next(r)}:(e.next&&(this.next=r=>{e.next(r),t.next(r)}),e.complete&&(this.complete=()=>{e.complete(),t.complete()}),e.error&&(this.error=r=>{e.error(r),t.error(r)}))}},fr=w(Vn,"tap"),Fn=class extends P{constructor(t,e){super(t),this.timeout=e,this.id=setTimeout(()=>this.error(new ir(this.timeout)),this.timeout)}next(t){super.next(t),clearTimeout(this.id),this.next=super.next}dispose(){clearTimeout(this.id),super.dispose()}},xl=w(Fn,"timeout");function Nt(n,t=!1){let e=Object.defineProperties(Qe(),{postMessage:{value:n.postMessage.bind(n)},port:{get(){return n},set(i){n.onmessage=G,n.onmessageerror=G,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 Hn=class extends P{constructor(t,e){super(t);let r=new P(t);r.next=G,e(r)}},Le=w(Hn,"takeUntilComplete");var re={useWt:!0,useAINS:!0,useHardDecoder:"prefer-software",useHardEncoder:"prefer-software",unreliable:!1,debug:!1,assetsPath:"",enableUpload:!0},Uu="__INLINE__WORKER__",xu="__INLINE__WASM__",{debug:hr}=console;re.debug||(console.debug=()=>{});var Gl=!Uu.startsWith("__"),jl=!xu.startsWith("__");var Js=V(lt(250),ze(()=>performance.now()),qe()),ve=n=>t=>{let e=0,r=performance.now();V(Js,ze(i=>(i-r)/n>>0),dt(i=>i!=e?(e=i,!0):!1))(t)},We=n=>t=>{let e=performance.now();V(Js,js(r=>r-e<n),ar(1))(t)};function Ge(n,t,e){let r=t.aborted?Promise.reject(t.reason):new Promise((i,a)=>{t.addEventListener("abort",()=>a(t.reason),{once:!0}),typeof n=="function"?n(i,a):n.then(i,a)});return e?r.catch(e):r}var Ou=new Intl.DateTimeFormat("zh-CN",{dateStyle:"short",timeStyle:"medium"}),Ze=()=>Ou.format(new Date),ne=(A=>(A[A.JOIN_ROOM=0]="JOIN_ROOM",A[A.LEAVE_ROOM=1]="LEAVE_ROOM",A[A.PUBLISH=2]="PUBLISH",A[A.UNPUBLISH=3]="UNPUBLISH",A[A.SUBSCRIBE=4]="SUBSCRIBE",A[A.UNSUBSCRIBE=5]="UNSUBSCRIBE",A[A.GET_WHOLE_LIST=6]="GET_WHOLE_LIST",A[A.QUALITY_REPORT=7]="QUALITY_REPORT",A[A.MUTE=8]="MUTE",A[A.UNMUTE=9]="UNMUTE",A[A.CONFIG=10]="CONFIG",A[A.REQUEST_PLI=11]="REQUEST_PLI",A[A.HEARTBEAT=12]="HEARTBEAT",A[A.START_PUSH_CDN=13]="START_PUSH_CDN",A[A.STOP_PUSH_CDN=14]="STOP_PUSH_CDN",A[A.START_MCU_MIX=15]="START_MCU_MIX",A[A.STOP_MCU_MIX=16]="STOP_MCU_MIX",A[A.UDPATE_TRACK=17]="UDPATE_TRACK",A[A.START_PUSHING=18]="START_PUSHING",A[A.STOP_PUSHING=19]="STOP_PUSHING",A[A.SWITCH_ROLE=20]="SWITCH_ROLE",A[A.WHOLE_LIST_UPDATE=255]="WHOLE_LIST_UPDATE",A[A.PEER_JOINED=256]="PEER_JOINED",A[A.PEER_LEFT=257]="PEER_LEFT",A[A.PEER_UDPATED_TRACK=258]="PEER_UDPATED_TRACK",A[A.SELECT_ABILITY=259]="SELECT_ABILITY",A[A.PEER_REQUEST_PLI=260]="PEER_REQUEST_PLI",A[A.AUDIO_DATA=4095]="AUDIO_DATA",A[A.VIDEO_DATA=4096]="VIDEO_DATA",A[A.SCREEN_DATA=4097]="SCREEN_DATA",A[A.NACK=4098]="NACK",A[A.ACK=4099]="ACK",A[A.REQUEST_RTT=4100]="REQUEST_RTT",A[A.RESPONSE_RTT=4101]="RESPONSE_RTT",A[A.PIP_DATA=4102]="PIP_DATA",A[A.LAYER_DATA=4103]="LAYER_DATA",A[A.MAX_FORCE=65535]="MAX_FORCE",A))(ne||{});function qn(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 Dt(n,t){let e=n>=255&&n<4095;e&&(t+=4);let i=(t>65535?1:0)?7:5,a=new DataView(new ArrayBuffer(i+t));qn(n,t,a),e&&(a.setUint32(i,0),i+=4),a=new DataView(a.buffer,i),i=0;let c=y=>{a.setUint8(i,y),i++},_=y=>{a.setUint16(i,y),i+=2},l=(y,x=!1)=>{a.setUint32(i,y,x),i+=4},m=y=>{a.setBigUint64(i,y),i+=8},h=y=>{let x=new Uint8Array(a.buffer,a.byteOffset+i,y);return i+=y,x};return{write8:c,write32:l,write16:_,write64:m,writeData:y=>h(y.length).set(y),dv:a,next:h}}function br(n,t,e){let r=JSON.stringify(t),{writeData:i,dv:a}=Dt(n,r.length+16);switch(i(e.split("").map(c=>c.charCodeAt(0))),i(r.split("").map(c=>c.charCodeAt(0))),n){case 11:case 12:case 7:console.debug("send",ne[n],e,t,a.buffer);break;default:n<255&&console.log(Ze(),"send",ne[n],e,t,a.buffer)}return a.buffer}var Qs=nr(wt()),he=class extends Qs.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 Ee(this.io,ne[e])}glog(e){self.postMessage({type:"glog",payload:e})}};var Mt=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 Mt,k=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(k,"global");var F=ue;var Er=class{constructor(t){d(this,"lastReceiveTime",-1);d(this,"blocking",!1);d(this,"blockCnt",0);d(this,"blockTime",0);d(this,"received",Qe());let e=We(t);V(this.received,$s(()=>(this.blockDone(),this.lastReceiveTime=Date.now(),e)),X(()=>{this.blocking=!0},G,()=>{this.blockDone()}))}blockDone(){this.blocking&&(this.blockCnt++,this.blockTime+=Date.now()-this.lastReceiveTime,this.blocking=!1)}clear(){this.blockCnt=0,this.blockTime=0}},yr=class yr{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 Er(500));d(this,"ssrc",yr.g_ssrc++);d(this,"framesFromStartPull",0);this.videoStatus.uint32_video_stream_type=t}getVideoStatus(){let t=en({},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:a}=this;i.uint32_video_receive++;let c=Date.now();i.uint32_video_total_bitrate+=e<<3,k.global.set(t);let _=F._ReceivedVideoPacket(k.global.point,e,c/1e3,c%1e3,r);_==0&&(this.lastReceiveTime>0&&c-this.lastReceiveTime>500&&console.debug("demuxPacket",c-this.lastReceiveTime),this.lastReceiveTime=c),a.received.next(_)}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(yr,"g_ssrc",1);var Tr=yr,Sr=class{constructor(t,e){this.writer=t;this.ssrc=e;d(this,"buffer",new k(960));d(this,"timestamp",0);F._AddAudioChannel(e,e)}feed(){}close(){F._DelAudioChannel(this.ssrc),this.buffer.free()}},Ir=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 k(4));d(this,"audioPuller");d(this,"mainPuller",new Tr(2));d(this,"screenPuller",new Tr(7));d(this,"aBlock",new Er(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=en({},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(a=>({t:a.uint32_video_stream_type,r_fps:a.uint32_video_receive_fps,c_fps:a.uint32_video_codec_fps,c_bps:a.uint32_video_codec_bitrate})),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,k.global.size);let e=F._GetEncodedFrame(k.global.point,this.lengthPoint.point,!1,t.ssrc),r=this.lengthPoint.getUint32(0);if(e==-1||r==0)return 10;let i=k.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),F._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 a=i?[2,1]:[7];t.videoPort=e,console.time(`${this.userId}${r.mediaType&2?"aux":"big"}`),V(e,X(({width:h,height:f})=>{t.videoStatus.uint32_video_width=h,t.videoStatus.uint32_video_height=f,t.videoStatus.uint32_video_decode_frame++,t.videoStatus.uint32_video_codec_fps++}));let c=h=>{delete t.videoPort,h?this.io.log_.error("stop pull",h):this.io.log_.info("stop pull",t),F._DelVideoChannel(t.ssrc),t.vBlock.received.complete(),i&&this.aBlock.received.complete()};F._AddVideoChannel(t.ssrc,t.ssrc);let _=0,l=0,m=()=>{Date.now()-l>2e3&&(l=Date.now(),this.io.sendReq(11,r))};V(this.io.wh.interval10ms,dt(h=>(_<=0&&(_=this.getNextVideoFrame(t),_>500&&(_=20)),_-=10,re.useWt&&(h&1)==0&&!a.every(f=>{let y=F._CheckMissingPacket(k.global.point,k.global.size,f,t.ssrc,this.io.rtt);return y>0&&(k.global.setBigUint64(5,BigInt(this.tinyId)),this.io.send(k.global.uint8Array(y))),y>=0}))),Le(e),X(m,c,c)),m(),V(ve(5e3),Le(e),X(m))}};var Du=1e8;function Cu(){let n=new k(500,[0]);return F._GetAudioEnergy(n.point,100),n}var _t=class _t extends he{constructor(){super(...arguments);d(this,"audioReceivedBuff",new k(2048));d(this,"levelsMap",new Map);d(this,"timestampBuff",new k(12))}decodeAudio(e,r){V(this.createResposeOb(4095),Le(r),X(({data:i})=>{let c=new DataView(i.buffer,i.byteOffset,i.byteLength).getBigUint64(9).toString();this.userMap_.has(c)&&(this.statReportReq.msg_net_stat_report.uint32_down_real_pkg++,this.statReportReq.msg_net_stat_report.uint32_down_recv_br+=i.byteLength,this.demuxPacket(i,this.userMap_.get(c),e&&r))})),e&&V(r,X(({timestamp:i,rtpTimestamp:a,seqNum:c,ssrc:_,data:l})=>{this.audioReceivedBuff.set(l),F._ReceivedRawAudioPacket(this.audioReceivedBuff.point,l.byteLength,i,a,c,_)}))}pullAudio({tinyId:e,writable:r}){let i=this.userMap_.get(e);i&&(i.audioPuller=new Sr(r.getWriter(),i.mainPuller.ssrc))}getAudioEnergy(e,r){_t.energys||(_t.energys=Cu());let{energys:i}=_t;V(ve(e),Le(r),X(()=>{let a=i.getInt8(0);for(let c=1;c<5*a;c+=5)this.levelsMap.set(i.getUint32(c),i.getInt8(c+4));if(this.userMap_.size>0){let c=[...this.userMap_.values()];r.postMessage(c.map(_=>{let l=Math.min(100,(this.levelsMap.get(_.mainPuller.ssrc)||0)*2);return _.msg_audio_status.uint32_audio_level=l*Du/100>>0,{userId:_.userId,volume:l}}))}else r.postMessage([])}))}demuxPacket(e,r,i){let{aBlock:a,msg_audio_status:c}=r;a.received.next(!0),c.uint32_audio_total_bitrate+=e.byteLength<<3,c.uint32_audio_codec_bitrate=c.uint32_audio_total_bitrate-31,this.audioReceivedBuff.set(e);let _=Date.now(),l=_/1e3,m=_%1e3;if(i){let h=F._ParseUdtAudioPacket(this.audioReceivedBuff.point,e.length,this.timestampBuff.point,this.timestampBuff.point+4,this.timestampBuff.point+8,this.audioReceivedBuff.point,r.mainPuller.ssrc);if(h>0){let f=this.audioReceivedBuff.getUint32(0),y=F.HEAPU8.slice(f,f+h);i.postMessage({timestamp:this.timestampBuff.getUint32(0),rtpTimestamp:this.timestampBuff.getUint32(4),seqNum:this.timestampBuff.getUint32(8),data:y,ssrc:r.mainPuller.ssrc},[y.buffer])}}else F._ReceivedAudioUdtPacket(this.audioReceivedBuff.point,e.length,l,m,r.mainPuller.ssrc)}};d(_t,"energys");var Lt=_t;var Zs=nr(wt(),1),zs=Symbol("instance"),kd=Symbol("abortCtrl"),vr=Symbol("cacheResult"),kt=class{constructor(t,e,r){this.oldState=t,this.newState=e,this.action=r,this.aborted=!1}abort(t){this.aborted=!0,Vt.call(t,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}},et=class extends Error{constructor(t,e,r){super(e),this.state=t,this.message=e,this.cause=r}};function wu(n){return typeof n=="object"&&n&&"then"in n}var Bt=new Map;function me(n,t,e={}){return(r,i,a)=>{let c=e.action||i;if(!e.context){let l=Bt.get(r)||[];Bt.has(r)||Bt.set(r,l),l.push({from:n,to:t,action:c})}let _=a.value;a.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[vr]:Promise.resolve(m[vr]);m.state instanceof kt&&m.state.action==e.abortAction&&m.state.abort(m);let h=null;Array.isArray(n)?n.length==0?m.state instanceof kt&&m.state.abort(m):(typeof m.state!="string"||!n.includes(m.state))&&(h=new et(m._state,`${m.name} ${c} to ${t} failed: current state ${m._state} not from ${n.join("|")}`)):n!==m.state&&(h=new et(m._state,`${m.name} ${c} to ${t} failed: current state ${m._state} not from ${n}`));let f=R=>{if(e.fail&&e.fail.call(this,R),e.sync){if(e.ignoreError)return R;throw R}else return e.ignoreError?Promise.resolve(R):Promise.reject(R)};if(h)return f(h);let y=m.state,x=new kt(y,t,c);Vt.call(m,x);let O=R=>{var C;return m[vr]=R,x.aborted||(Vt.call(m,t),(C=e.success)===null||C===void 0||C.call(this,m[vr])),R},Y=R=>(Vt.call(m,y,R),f(R));try{let R=_.apply(this,l);return wu(R)?R.then(O).catch(Y):e.sync?O(R):Promise.resolve(O(R))}catch(R){return Y(new et(m._state,`${m.name} ${c} from ${n} to ${t} failed: ${R}`,R instanceof Error?R:new Error(String(R))))}}}}var Mu=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 Vt(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 Zs.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[zs];i?this.name=i.name+"-"+i.count++:r[zs]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let t=Object.getPrototypeOf(this),e=Bt.get(t)||[],r=new Set,i=[],a=[],c=new Set,_=Object.getPrototypeOf(t);Bt.has(_)&&(_.stateDiagram.forEach(m=>r.add(m)),_.allStates.forEach(m=>c.add(m))),e.forEach(({from:m,to:h,action:f})=>{typeof m=="string"?i.push({from:m,to:h,action:f}):m.length?m.forEach(y=>{i.push({from:y,to:h,action:f})}):a.push({to:h,action:f})}),i.forEach(({from:m,to:h,action:f})=>{c.add(m),c.add(h),c.add(f+"ing"),r.add(`${m} --> ${f}ing : ${f}`),r.add(`${f}ing --> ${h} : ${f} \u{1F7E2}`),r.add(`${f}ing --> ${m} : ${f} \u{1F534}`)}),a.forEach(({to:m,action:h})=>{r.add(`${h}ing --> ${m} : ${h} \u{1F7E2}`),c.forEach(f=>{f!==m&&r.add(`${f} --> ${h}ing : ${h}`)})});let l=[...r];return Object.defineProperties(t,{stateDiagram:{value:l},allStates:{value:c}}),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={}){Mu(n.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(t){Vt.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 Lu=function(n,t,e,r){function i(a){return a instanceof e?a:new e(function(c){c(a)})}return new(e||(e=Promise))(function(a,c){function _(h){try{m(r.next(h))}catch(f){c(f)}}function l(h){try{m(r.throw(h))}catch(f){c(f)}}function m(h){h.done?a(h.value):i(h.value).then(_,l)}m((r=r.apply(n,t||[])).next())})},Gn=Symbol(32),jn=Symbol(16),Yn=Symbol(8),Ue=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 Lu(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=c=>{delete this.lastReadPromise,delete this.resolve,delete this.need,e(c)},this.demand(t,!0)||(i=this.pull)===null||i===void 0||i.call(this,t)})})}readU32(){return this.read(Gn)}readU16(){return this.read(jn)}readU8(){return this.read(Yn)}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=a=>e.length<(r=a);if(typeof this.need=="number"){if(i(this.need))return;t=e.subarray(0,r)}else if(this.need===Gn){if(i(4))return;t=e[0]<<24|e[1]<<16|e[2]<<8|e[3]}else if(this.need===jn){if(i(2))return;t=e[0]<<8|e[1]}else if(this.need===Yn){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}};Ue.U32=Gn;Ue.U16=jn;Ue.U8=Yn;var je=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",Ge((r,i)=>{e.onerror=a=>{e.onmessage=null,this.connectFSM.log_.error("websocket onerror",a),i(a.type)},e.onclose=a=>{e.onmessage=null,i(a),this.connectFSM.log_.info("websocket onclose",a),this.disconnect(a.reason,a.code)},e.onopen=a=>{console.timeEnd("WebSocket connect"),this.connectFSM.log_.info("websocket onopen")},e.onmessage=a=>{try{let c=JSON.parse(String(a.data));if(this.connectFSM.log_.info("websocket verify",c),c.err!==0)throw c.err;this.connectFSM.verify(c.verify,c.rebuild),this.ws=e,r(e);let _=this.connectFSM.createOputReceiver("w");e.onmessage=l=>_.write(l.data)}catch(c){i(c)}}},this.connectFSM.abortCtrl.signal)}disconnect(e="",r=0){return r===0&&this.ws&&(this.ws.onmessage=null,this.ws.close(1e3,e)),this.connectFSM.log_.warn("websocket disconnected :",r,e),this.connectFSM.disconnect(e)}close(){this.ws&&(this.ws.onmessage=null,this.ws.close(1e3,"close"))}sendReq(e,r,i){this.send(br(e,r,i||this.connectFSM.generateUUID()))}send(e){var r;this.state=="CONNECTED"&&((r=this.ws)==null||r.send(e))}};ce([me(["DISCONNECTED",Z.INIT],"CONNECTED")],je.prototype,"connect",1),ce([me("CONNECTED","DISCONNECTED",{sync:!0,ignoreError:!0})],je.prototype,"disconnect",1),ce([me([],Z.INIT,{sync:!0})],je.prototype,"close",1);var rm=new Uint32Array([Date.now()]),ku=V(lt(20),ze(()=>performance.now()),qe()),Kn=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),V(ku,vn(()=>this.chunk.size>0&&this.resentCount<20),Re(Ee(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:a}=await Promise.race([(async()=>{await Ge(e.ready,r);let _=await Ge(e.createBidirectionalStream(),r),l=_.readable.getReader();return this.writer=_.writable.getWriter(),this.dw=e.datagrams.writable.getWriter(),Ge(l.read(),r).then(({value:m})=>(l.releaseLock(),{value:m,stream:_}))})(),new Promise((_,l)=>setTimeout(()=>l(new Error("WebTransport connect timeout")),1e3))]),c=JSON.parse(String.fromCharCode(...i));if(this.connectFSM.log_.info("WebTransport connect result:",c),c.err!==0)throw c.err;this.connectFSM.verify(c.verify,c.rebuild),this.wt=e,V(Ee(this.connectFSM,ne[4099]),Re(Ee(this,"DISCONNECTED")),X(({data:_})=>{let l=_[0]&127,m=this.sentCache.get(l);m&&m.ack(_[1])})),Promise.race([e.datagrams.readable.pipeTo(new WritableStream(this.connectFSM.createOputReceiver("d"))),a.readable.pipeTo(new WritableStream(this.connectFSM.createOputReceiver("s"))),e.closed]).then(()=>this.disconnect(),this.disconnect.bind(this))}disconnect(e=""){var r;return(r=this.wt)==null||r.close(),this.connectFSM.disconnect(e)}close(){var e;return(e=this.wt)==null?void 0:e.close()}async sendReq(e,r,i){if(i||(i=this.connectFSM.generateUUID()),!this.wt)return new Error("WebTransport not connected");if(!re.unreliable){let x=br(e,r,i);return this.writer.write(x).then(()=>!0).catch(this.catchError)}let a=e>=255&&e<4095,c=JSON.stringify(r),_=0,l=c.length+(a?20:16),h=(l>65535?1:0)?7:5,f=Math.ceil(l/this.mtu),y=new Kn(this);console.debug("WebTransport send:",a?"ack":"",ne[e],i,"chunks:",f,y.groupId);for(let x=0;x<f;x++){let O=l-x*this.mtu,Y=Math.min(this.mtu,O),R=new Uint8Array(h+4+Y),C=qn(e,R.length-h,new DataView(R.buffer));if(R[0]|=2,R.set([1,2,(x==f-1?128:0)|y.groupId,x],C),C+=4,x==0){a&&(R.set([0,0,0,0],C),C+=4);for(let $=0;$<16;$++)R[C++]=i.charCodeAt($)}for(let $=0;C<R.length;$++)R[C++]=c.charCodeAt(_++);y.chunk.set(x,R),this.send(R.buffer)}}async send(e){if(!(!this.wt||!this.dw)){if(e instanceof ArrayBuffer){if(!e.byteLength)throw ei}else{if(!e.length)throw ei;e=e.slice(0)}return this.dw.write(e).catch(this.catchError)}}catchError(e){}};ce([me(["DISCONNECTED",Z.INIT],"CONNECTED")],Ye.prototype,"connect",1),ce([me("CONNECTED","DISCONNECTED",{sync:!0,ignoreError:!0})],Ye.prototype,"disconnect",1),ce([me([],Z.INIT,{sync:!0})],Ye.prototype,"close",1);var ei=new Error("WebTransport send empty datagram");var tt="5.0.0";var ti=typeof importScripts!="undefined",Ur=typeof registerProcessor!="undefined";var Jn="";var Bu="web.sdk.qcloud.com";var Vu=`https://${Bu}/trtc/webrtc/v5/doc`;var im=`${Vu}/zh-cn/`,ri="https://yun.tim.qq.com",ni="https://apisgp.my-imcloud.com";var si={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"};var ke=(c=>(c[c.TRACE=0]="TRACE",c[c.DEBUG=1]="DEBUG",c[c.INFO=2]="INFO",c[c.WARN=3]="WARN",c[c.ERROR=4]="ERROR",c[c.NONE=5]="NONE",c))(ke||{}),ii=18e3;var om=7*24*3600*1e3;var xr={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"};var ht=1,Or=2,Pr=4,bt=8,gt=64,Et=16;var am=xr.MAIN,um=xr.AUXILIARY;var oi=30;var cm=xr.BIG,lm=xr.SMALL,dm=10*1e3;var mm=Object.keys(ke),ai=["normal leave","timeout leave","kick","role change"];var pm=10*1e3;var li=nr(wt(),1);var Hu=n=>Number(n)<14e8,ui=function(n,t){let e;Jn?e=Jn:e=Hu(n)?ni:ri;let r=Math.floor(Math.random()*2**31);return`${e}/v5/AVQualityReportSvc/C2S?random=${r}&sdkappid=${n}&cmdtype=${t}`};var Am=typeof window!="undefined"&&typeof window.glog=="function"?window.glog:()=>{};var Nr=n=>typeof n=="undefined",Xn=n=>typeof n=="string",ci=n=>typeof n=="number";var{toString:Rm}=Object.prototype;function Qn(n,t){return{userId:t,hasAudio:!!(n&bt),hasVideo:!!(n&ht),hasAuxiliary:!!(n&Pr),hasSmall:!!(n&Or),audioMuted:!!(n>),videoMuted:!!(n&Et),audioAvailable:!!(n&bt)&&!(n>),videoAvailable:!!(n&ht)&&!(n&Et)}}var Dr=class extends li.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:a,role:c}=e;if(this.userMap.has(r))return;let _={userId:i,tinyId:a,role:c===20?"anchor":"audience"};this.userMap.set(r,_),this.emit("1",_)}deleteUser(e,r){let i=this.userMap.get(e);if(!i)return;let a=`peer leave [${e}]`;Nr(r)||(a+=`:${ai[r]}`),this._log.info(a);let c=this.remotePublishedUserMap.get(e);if(c){let _=c.muteState;c.flag=0,this.emit("5",c.userId),this.deleteRemotePublishedUser(e),this.emit("6",{prevMuteState:_,muteState:c.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(a=>a[this.key]===r[this.key])<0){this._log.info(`remote [${i}] unpublish`);let a=r.muteState;r.flag=0,this.emit("5",r.userId),this.deleteRemotePublishedUser(i),this.emit("6",{prevMuteState:a,muteState:r.muteState,flag:0})}}),e.forEach(r=>{var h;let i=r[this.key];if(i===this.mySelfId)return;let{flag:a,userId:c,tinyId:_}=r,l=Qn(a,c),m=(h=this.remotePublishedUserMap.get(i))==null?void 0:h.muteState;if(m){let f=this.remotePublishedUserMap.get(i);f&&f.flag!==a&&(f.flag=a,this._log.info(`remote publish updated: ${JSON.stringify(f.muteState)}`),this.emit("6",{prevMuteState:m,muteState:l,flag:a}))}else this._log.info(`remote publish. state: ${JSON.stringify(l)}`),this.addUser({userId:c,tinyId:_,role:20}),this.emit("3",r),this.emit("6",{prevMuteState:Qn(0,c),muteState:l,flag:a})})}clear(){this.userMap.clear(),this.remotePublishedUserMap.clear()}};var km=new Date().getTime(),qu=0;var zn=function(){return new Date().getTime()+qu},di=function(){let n=new Date;return n.setTime(zn()),n.toLocaleString()};function mi({url:n,body:t,method:e="POST",timeout:r,priority:i}){return new Promise((a,c)=>{if("fetch"in window)return fetch(n,{method:e,body:t,priority:i}).then(l=>l.text()).then(l=>{try{a({data:JSON.parse(l)})}catch(m){a({data:l})}},c);let _=new XMLHttpRequest;_.onreadystatechange=()=>{if(_.readyState===4)if(_.status>=200&&_.status<300)try{let l=JSON.parse(_.response);a({data:l})}catch(l){a({data:_.response})}else c({status:_.status,statusText:_.statusText||"request failed!"})},_.timeout=r||5e3,_.open(e,n,!0),_.send(t)})}var Wu=Object.prototype.hasOwnProperty;var St=n=>typeof n=="function",pi=n=>typeof n=="undefined";var _i=n=>typeof n=="boolean";var Gu=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 fi(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(Gu(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(Wu.call(n,t))return!1;return!0}}return!1}var ju=0,Yu=1,hi=2;function $u({retryFunction:n,settings:t,onError:e,onRetrying:r,onRetryFailed:i,onRetrySuccess:a,context:c}){return function(..._){let{retries:l=5,timeout:m=1e3}=t,h=0,f=-1,y=ju,x=async(O,Y)=>{let R=c||this;try{let C=await n.apply(R,_);h>0&&a&&a.call(this,h),h=0,O(C)}catch(C){let $=()=>{clearTimeout(f),h=0,y=hi,Y(C)},Te=()=>{y!==hi&&h<(St(l)?l():l)?(h++,y=Yu,St(r)&&r.call(this,h,$),f=window.setTimeout(()=>{f=-1,x(O,Y)},St(m)?m(h):m)):($(),St(i)&&i.call(this,C))};St(e)?e.call(this,{error:C,retry:Te,reject:Y,retryFuncArgs:_,retriedCount:h}):Te()}};return new Promise(x)}}var bi=$u;var Ft=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=_i(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}`:""}]`),Tt.log(t,e,pi(this.userId)||fi(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 De=typeof navigator=="undefined"?"":navigator.userAgent,L=n=>new RegExp(n,"i").test(De),se=n=>{if(L(n)){let t=new RegExp(`${n}\\/([\\d.]+)`),e=De.match(t);if(e&&e[1])return e[1]}return""},Zn=n=>{if(L(n)){let t=new RegExp(`${n}\\/(\\d+)`),e=De.match(t);if(e&&e[1])return parseFloat(e[1])}return NaN},gi=/AppleWebKit\/([\d.]+)/i.exec(De),Ku=gi?parseFloat(gi[1]):NaN,Ti=L("iPad"),Si=typeof navigator!="undefined"&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&L("Macintosh"),Ii=L("iPhone")&&!Ti,Ju=L("iPod"),Cr=Ii||Ti||Ju||Si,It=L("Android"),yi=function(){if(It){let n=De.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}(),Qm=It&&L("webkit")&&yi<2.3,zm=It&&yi<5&&Ku<537,Xu=L("Firefox"),Qu=se("Firefox"),Zm=Zn("Firefox"),Ai=L("Edge"),zu=se("Edge"),Ri=L("Edg"),Zu=se("Edg"),ep=Zn("Edg"),vi=L("SogouMobileBrowser"),ec=se("SogouMobileBrowser"),Ui=L("MetaSr\\s"),tc=se("MetaSr\\s"),rt=L("TBS"),rc=se("TBS"),xi=L("XWEB"),nc=se("XWEB"),tp=L("MSIE\\s8\\.0"),sc=L("MSIE\\/\\d+"),rp=function(){if(sc){let n=/MSIE\s(\d+)\.\d/.exec(De),t=n&&parseFloat(n[1]);return!t&&/Trident\/7.0/i.test(De)&&/rv:11.0/.test(De)&&(t=11),t}return NaN}(),ic=L("(micromessenger|webbrowser)"),oc=se("MicroMessenger"),es=!rt&&L("MQQBrowser")&&L("COVC"),ts=!rt&&L("MQQBrowser")&&!L("COVC"),Ei=ts||es?se("MQQBrowser"):"",Oi=!rt&&L(" QQBrowser"),ac=se(" QQBrowser"),Pi=!rt&&L("QQBrowserLite"),uc=se("QQBrowserLite"),Ni=!rt&&L("MQBHD"),cc=se("MQBHD"),np=L("Windows"),sp=!Cr&&L("MAC OS X"),ip=!It&&L("Linux"),op=L("CrOS"),ap=L("MicroMessenger"),up=L("UCBrowser"),cp=L("Electron"),Di=L("MiuiBrowser"),lc=se("MiuiBrowser"),Ci=L("HuaweiBrowser"),lp=L("Huawei")||L("HUAWEI"),dp=L("Honor")||L("HONOR"),dc=se("HuaweiBrowser"),wi=L("SamsungBrowser"),mc=se("SamsungBrowser"),Mi=L("HeyTapBrowser"),pc=se("HeyTapBrowser"),Li=L("VivoBrowser"),_c=se("VivoBrowser"),fc=()=>Zn("Chrome"),ki=L("Chrome"),hc=!Ai&&!Ui&&!vi&&!rt&&!xi&&!Ri&&!Oi&&!Di&&!Ci&&!wi&&!Mi&&!Li&&ki,Bi=L("HeadlessChrome"),mp=fc(),bc=se("Chrome"),gc=!ki&&!ts&&!es&&!Pi&&!Ni&&L("Safari");var Vi=se("Version"),pp=/Android.*(wv|.0.0.0)/.test(De),Fi=(()=>{if(Si)return Vi;if(Cr){let n=De.match(/OS (\d+)_(\d+)/i);if(n&&n[1]){let t=n[1];return n[2]&&(t+=`.${n[2]}`),t}}return""})(),_p=Number(Fi.split(".")[0]);var fp=(()=>{let n=Number(Fi.split(".")[0]);return n===14||n===13})(),hp=typeof location=="undefined"?!1:location.protocol==="file:"||location.hostname==="localhost"||location.hostname==="127.0.0.1";var bp=Ec();function Ec(){let n=new Map([[Xu,["Firefox",Qu]],[Ri,["Edg",Zu]],[hc,["Chrome",bc]],[gc,["Safari",Vi]],[rt,["TBS",rc]],[xi,["XWEB",nc]],[ic&&Ii,["WeChat",oc]],[Oi,["QQ(Win)",ac]],[ts,["QQ(Mobile)",Ei]],[es,["QQ(Mobile X5)",Ei]],[Pi,["QQ(Mac)",uc]],[Ni,["QQ(iPad)",cc]],[Di,["MI",lc]],[Ci,["HW",dc]],[wi,["Samsung",mc]],[Mi,["OPPO",pc]],[Li,["VIVO",_c]],[Ai,["EDGE",zu]],[vi,["SogouMobile",ec]],[Ui,["Sogou",tc]]]),t="unknown",e="unknown";return n.has(!0)&&([t,e]=n.get(!0)),{name:t,version:e}}var Hi=nr(wt(),1),Tc=new Hi.default,yt=Tc;var rs=(D=>(D.ROOM_DESTROY="1",D.JOIN_START="21",D.JOIN_SCHEDULE_SUCCESS="22",D.JOIN_SIGNAL_CONNECTION_START="23",D.JOIN_SIGNAL_CONNECTION_END="24",D.JOIN_SEND_CMD="25",D.JOIN_RECEIVED_CMD_RES="26",D.JOIN_SUCCESS="27",D.JOIN_FAILED="28",D.LEAVE_START="51",D.LEAVE_SEND_CMD="52",D.LEAVE_SUCCESS="53",D.PUBLISH_START="61",D.SEND_FIRST_VIDEO_FRAME="62",D.PUBLISH_FAILED="63",D.SUBSCRIBE_START="81",D.SUBSCRIBE_SUCCESS="82",D.SUBSCRIBE_FAILED="84",D.UNSUBSCRIBE_SUCCESS="83",D.LOCAL_TRACK_CAPTURE_START="101",D.LOCAL_TRACK_CAPTURE_SUCCESS="102",D.LOCAL_TRACK_CAPTURE_FAILED="103",D.LOCAL_TRACK_PUBLISHED="104",D.LOCAL_TRACK_UNPUBLISHED="105",D.LOCAL_TRACK_REPLACED="106",D.SWITCH_DEVICE_SUCCESS="107",D.TRACK_MUTED="108",D.TRACK_UNMUTED="109",D.REMOTE_TRACK_SUBSCRIBED="110",D.REMOTE_TRACK_UNSUBSCRIBED="111",D.LOCAL_TRACK_RECAPTURE="112",D.PLAY_TRACK_START="151",D.PLAYER_STATE_CHANGED="152",D.VIDEO_LOADED_DATA="153",D.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",D.SIGNAL_CONNECTION_STATE_CHANGED="201",D.PEER_CONNECTION_STATE_CHANGED="202",D.SINGLE_CONNECTION_STAT="203",D.SPC_RECONNECTED="204",D.HEARTBEAT_REPORT="251",D.RECEIVED_PUBLISHED_USER_LIST="252",D.REMOTE_PUBLISH_STATE_CHANGED="253",D.AUDIO_LEVEL_INTERVAL="260",D.NETWORK_QUALITY="261",D.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",D.QUALITY_LIMITATION_CHANGED="263",D.LOG="264",D))(rs||{});var $e=rs;var Sc="%cTRTC%c%s",Ic="padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;",yc="display: inline",wr=class wr{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);!ti&&!Ur&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&this._timeoutId!==-1}installEvents(){yt.on($e.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)}),yt.on($e.JOIN_SUCCESS,({room:t})=>{this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()}),yt.once($e.JOIN_FAILED,()=>{this.startUpload()}),yt.on($e.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:a})=>{t.map.has(i)?t.map.get(i).logs.push(r):t.map.set(i,{userId:i,sdkAppId:a,logs:[r]})});else if(Xn(r.userId)&&ci(r.sdkAppId)){let{userId:i,sdkAppId:a}=r;t.map.has(i)?t.map.get(i).logs.push(r):t.map.set(i,{userId:i,sdkAppId:a,logs:[r]})}}return t.map.size>0&&(t.splicedQueue=this._queue.splice(0,e)),t}async upload(){if(this._queue.length===0||!this._isEnableUploadLog)return;let{map:t,splicedQueue:e}=this.getLogsToUpload();if(t.size===0)return;try{let i=[...t.values()];for(let a=0;a<i.length;a++){let{userId:c,sdkAppId:_,logs:l}=i[a];await this.uploadLogWithRetry(JSON.stringify({timestamp:di(),sdkAppId:String(_),userId:c,version:tt,log:l.map(m=>m.log).join(`
|
|
2
|
+
`)}),_),l.forEach(m=>m.uploaded=!0)}}catch(i){}let r=e.filter(i=>!i.uploaded);r.length>0&&(this._queue=r.concat(this._queue))}uploadLogWithRetry(t,e){return bi({retryFunction:()=>mi({url:ui(e,si.LOG),body:t,timeout:5e3,priority:"low"}),settings:{retries:3,timeout:2e3},onError:({retry:r})=>{r()}})()}getPrefix(t){let e=new Date;e.setTime(zn());let r=String(e.getMilliseconds());return"padStart"in String.prototype&&(r=r.toString().padStart(3,"0")),`[${e.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")}:${r}] <${ke[t]}>`}getLogLevel(){return this._logLevel}setLogLevel(t){Nr(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(Xn(t))return t;try{return t instanceof Error?t.toString():JSON.stringify(t)}catch(e){return""}}log(t,e,r=!0,i,a){var l;e.unshift(this.getPrefix(t));let c={log:e.reduce((m,h)=>`${m} ${this.logChunkToString(h)}`.trim(),""),level:t,userId:i,sdkAppId:a,forAllJoinedClients:r};if(yt.emit($e.LOG,{log:c}),this._isEnableUploadLog&&t>=this._logLevelToUpload&&this._queue.push(c),t<this._logLevel)return;let _=((l=ke[t])==null?void 0:l.toLowerCase())||"info";wr.PRINT_LOG_TAG?console[_](Sc,Ic,yc,...e):console[_](...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 Ft(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(wr,"PRINT_LOG_TAG",!(Cr||It||Bi));var ns=wr,Tt=new ns;function qi(n,t=1,e=1){return n<=1?e:qi(n-1,e,t+e)}function Uc(n){return n>8?30*1e3:qi(n)*1e3}function xc(n,t){return{userId:t,hasAudio:!!(n&bt),hasVideo:!!(n&ht),hasAuxiliary:!!(n&Pr),hasSmall:!!(n&Or),audioMuted:!!(n>),videoMuted:!!(n&Et),audioAvailable:!!(n&bt)&&!(n>),videoAvailable:!!(n&ht)&&!(n&Et)}}var ss=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}}},be=class be 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 ss(this));d(this,"reqPromise",new Map);d(this,"rebuild");d(this,"osName");d(this,"browserInfo");d(this,"tinyId_",new k(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",Ee(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_=Tt.createLogger({id:`wc${e}`,userId:this.params.userId,sdkAppId:this.params.sdkAppId}),this.proxy_unified?re.useWt=!1:(this.proxy_ws||this.proxy_wt)&&(re.useWt=!!this.proxy_wt),re.useWt?this.wFSM=new Ye(this):this.wFSM=new je(this),this.userManager=new Dr("",this.log_,"tinyId");let a=c=>this.userManager.on(c,_=>this.postMessage({cmd:c,payload:_}));this.userManager.on("3",({flag:c,userId:_,tinyId:l})=>{let m={flag:c,userId:_,tinyId:l,get muteState(){return xc(this.flag,this.userId)},subscribe:0,removing:!1};this.log_.debug("create user",m),this.postMessage({cmd:"3",payload:m}),this.userManager.addRemotePublishedUser(new Ir(m,this))}),a("6"),a("5"),a("1"),a("2"),this.statReportReq={tinyid:"",stat:{msg_audio_stat_report:{msg_audio_enc_stat:{uint32_audio_enc_br:0,uint32_audio_frame_interval:0},msg_audio_send_stat:{uint32_audio_send_br:0,uint32_audio_fec_br:0,uint32_audio_arq_br:0}},rpt_msg_video_stat_report:[{uint32_video_type:2,msg_video_enc_stat:{uint32_video_enc_fps:0,uint32_video_enc_br:0,uint32_video_encrd:1},msg_video_send_stat:{uint32_video_send_br:0,uint32_video_fec_br:0,uint32_video_arq_br:0}}],msg_net_stat_report:{uint32_total_send_br:0,uint32_rtt:0,uint32_down_expect_pkg:0,uint32_down_real_pkg:0,uint32_down_recv_br:0},msg_rtt_info_req:{uint64_last_server_timestamp_ms:0,uint32_delay_since_last_server_timestamp_ms:0,uint64_client_timestamp_ms:0},msg_system_load_report:{uint32_total_cpu_rate:0},msg_down_bandwidth_est:{uint32_bandwidth_br:0,uint32_avg_bandwidth_br:0,uint32_jitter:0,uint32_jitter_in_frm:0},msg_play_report:{uint32_video_jitter_receive_fps_ratio:0}}},this.qualityReportReq={tinyid:"",report:{str_sdk_version:this.joinReq.jsSdkVersion,uint32_groupid:0,uint64_datetime:Date.now(),msg_user_info:{str_identifier:"",uint64_tinyid:0},msg_device_info:{uint32_terminal_type:this.joinReq.AbilityOption.GeneralLimit.uint32_terminal_type,str_device_name:this.browserInfo.browserName,str_os_version:this.osName,uint32_net_type:this.joinReq.AbilityOption.GeneralLimit.uint32_net_type,uint32_app_cpu:0,uint32_system_cpu:0,uint32_app_memory:0,uint32_background:0,uint32_headset:0},msg_up_stream_info:{msg_audio_status:{uint32_audio_format:11,uint32_audio_sample_rate:48e3,uint32_audio_codec_bitrate:0,uint32_audio_receive:0},msg_video_status:[{uint32_video_stream_type:2,uint32_video_decode_frame:0,uint32_video_total_frame:0,uint32_video_capture_fps:0,uint32_video_codec_fps:0,uint32_video_enc_fps:0,uint32_video_codec_bitrate:0,uint32_video_total_bitrate:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0,uint32_jitter:0},msg_qos:[]},msg_down_stream_info:[],msg_event_msg:[],str_acc_ip:"",str_client_ip:"",str_groupid:""}}}get aborted(){return this.abortCtrl.signal.aborted}get wtDomain(){return this.env?`${this.env}.rtc.qq.com:8080`:this.proxy_wt?this.proxy_wt:this.domains.length?`${this.domains[this.selectDomain]}:80`:"wasm.rtc.qq.com:80"}get wsDomain(){return this.env?`${this.env}.rtc.qq.com:8687`:this.proxy_cloud.length?this.proxy_cloud[this.selectCloudDomain].replace("wss://",""):this.proxy_ws?this.proxy_ws:this.domains.length?this.domains[this.selectDomain]:"wasm.rtc.qq.com"}get wtUrl(){return`https://${this.wtDomain}/v1/wt?${this.connectParams}`}get wsUrl(){var r;let e=((r=this.domains)==null?void 0:r[this.selectDomain])||"wasm.rtc.qq.com";return`wss://${this.wsDomain}/v1/ws?${this.connectParams}&realHost=${e}`}async connect(){let e=this.wFSM.connect(),r=(i,a=!1)=>c=>{if(this.aborted||typeof c=="number")throw c;return this.selectDomain=i,this.wFSM=a?new Ye(this):new je(this),console.warn(c),console.warn("downgrade to",a?"WebTransport":"WebSocket",this.selectDomain?"\u5907\u7528\u57DF\u540D":"\u4E3B\u57DF\u540D"),this.wFSM.connect()};return re.useWt&&(this.proxy_ws||!this.proxy_wt)&&(e=e.catch(r(0))),!this.proxy_wt&&!this.proxy_ws&&(e=e.catch(r(1,re.useWt)),re.useWt&&(e=e.catch(r(1)))),e}async joinRoom(){let{dataport:e,stunport:r,relayip:i,socketid:a,checkSigSeq:c}=this.signalInfo_,_=await this.sendReq(0,Object.assign(this.joinReq,{dataport:e,stunport:r,relayip:i,socketid:a,checkSigSeq:c}));if(_.err===0)this.setJoinRes(_.data);else throw _.err;return _}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(Ze(),"retry",e),e>oi){this.close();return}let r=We(Uc(e));V(e?Ws(r,this.reconnectOB):r,ar(1),Re(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),Ge((a,c)=>this.reqPromise.set(i,{resolve:a,reject:c,startTime:Date.now()}),this.abortCtrl.signal,a=>(console.log("abort",ne[e]),{err:a}))}postReq(e,r){return this.wFSM.sendReq(e,r,this.generateUUID())}async sendReq(e,r){return this.recovery.onSendReq(e,r),this._sendReq(e,r)}send(e){return this.wFSM.send(e)}setJoinRes(e){this.joinRes=e,this.userManager.mySelfId=e.tinyid,this.statReportReq.tinyid=e.tinyid,this.qualityReportReq.tinyid=e.tinyid,this.qualityReportReq.report.str_acc_ip=e.relayip,this.qualityReportReq.report.str_client_ip=e.clientip,this.qualityReportReq.report.msg_user_info.str_identifier=e.openid,this.qualityReportReq.report.msg_user_info.uint64_tinyid=Number(e.tinyid),this.tinyId_.set([...e.tinyid].map(r=>r.charCodeAt(0)).concat(0)),[1,2,3,7].forEach(r=>{F._CreateUdtPacketizer(e.roomid,this.tinyId_.point,e.locationid,r,F.udtver,this.id)}),this.wFSM.sendReq(6,{})}onReceive(e,r,i){let a="",c=0,_=new DataView(i.buffer,i.byteOffset);r<255&&(c=_.getUint32(0),i=i.subarray(4)),r<4095&&(a=String.fromCharCode(...i.subarray(0,16)),i=i.subarray(16));let l=i;if(!a)_=new DataView(i.buffer,i.byteOffset,i.byteLength);else{let h="";for(let f=0,y=i.length,x=32768;f<y;f+=x)h+=String.fromCharCode.apply(null,i.subarray(f,Math.min(f+x,y)));if(c)l=h;else try{l=JSON.parse(h)}catch(f){l=h}}let m=ne[r];switch(r){case 259:this.joinRes&&this.wFSM.sendReq(r,{tinyid:this.joinRes.tinyid}),console.debug(e,"receive:",m,a,l);break;case 256:l.userlist.forEach(R=>{if(this.userManager.addUser({userId:R.userid,tinyId:R.srctinyid,role:R.role}),this.joinRes&&R.srctinyid!=this.joinRes.tinyid&&this.userManager.userMap.has(R.srctinyid)){let C=this.userManager.userMap.get(R.srctinyid);this.sendSubscribe(C)}}),this.log_.info(e,"receive:",m,a,l),this.wFSM.sendReq(r,{count:this.userManager.userMap.size});break;case 257:this.userManager.deleteUser(l.userlist.srctinyid),this.log_.info(e,"receive:",m,a,l),this.wFSM.sendReq(r,{count:this.userManager.userMap.size});break;case 6:this.userManager.setUserList(l.userlist.map(R=>({userId:R.userid,tinyId:R.srctinyid,role:R.role})));break;case 255:this.wFSM.sendReq(r,{count:this.userManager.userMap.size});{let R=l.userlist.map(C=>({userId:C.userid,tinyId:C.srctinyid,flag:C.flag,terminalType:C.terminaltype}));this.firstReceiveUserlist||(this.firstReceiveUserlist=!0,this.postMessage({cmd:$e.RECEIVED_PUBLISHED_USER_LIST,payload:{publishedUserList:R}})),this.userManager.setRemotePublishedUserList(R),this.recovery.recovering&&this.recovery.recoverRemote(this.userManager.remotePublishedUserMap)}break;case 4100:this.rtt=_.getUint32(4),console.debug(e,"receive:",m,a,l,this.rtt);let{dv:h,writeData:f}=Dt(4101,8);f(i.subarray(0,4)),this.send(h.buffer);break;case 12:this.reqPromise.forEach(R=>{Date.now()-R.startTime>5e3&&(R.reject(new Error("heartbeat timeout")),this.reqPromise.delete(R.uuid))}),self.postMessage({type:"glog",payload:{heartbeatReceive:1}});case 11:case 260:console.debug(e,"receive:",m,a,l);case 7:case 4095:break;case 4096:case 4097:{let R=i.length;this.statReportReq.stat.msg_net_stat_report.uint32_down_real_pkg++,this.statReportReq.stat.msg_net_stat_report.uint32_down_recv_br+=R<<3;let C=_.getBigUint64(9).toString(),$=this.userManager.getPublishedUser(C);$?r===4096?($.mainPuller.videoStatus.uint32_video_receive||console.timeLog(`${$.userId}big`,"first video data"),$.mainPuller.demuxPacket(i)):($.screenPuller.videoStatus.uint32_video_receive||console.timeLog(`${$.userId}aux`,"first video data"),$.screenPuller.demuxPacket(i)):console.warn(e,"receive:",m,a,l,"user not found")}break;case 4102:case 4103:case 4099:break;case 4103:F.HEAPU8.set(i,k.global.point+8);let y=F._ParseUdtMousePacket(k.global.point+8,i.length,k.global.point),x=i.subarray(y),O=k.global.getBigUint64(0).toString(),Y=this.userManager.userMap.get(O);Y&&this.postMessage({cmd:"layerData",payload:{userId:Y.userId,tinyId:O,layerData:x}}),console.debug(e,"receive:",m,y,l,O,x);break;case 4098:{let R=_.getUint8(8);for(let C=9;C<i.length;C+=6){let $=_.getUint32(C),Te=_.getUint16(C+4);for(let Se=0;Se<=16;Se++){if(Se>0&&(Te>>16-Se&1)==0)continue;let Ie=F._GetRetransPacket(R,$+Se,k.global.point,this.id),ie=k.global.getUint32(0),pe=F.HEAPU8.subarray(ie,ie+Ie);Ie>0&&this.send(pe)}}}break;case 1:this.log_.info(e,"receive:",m,a,l),l>0&&l!==3&&(this.postMessage({cmd:"banned",payload:l}),this.close());break;case 258:this.log_.info(e,"receive:",m,a||"",l);break;default:this.log_.info(e,"receive:",m||r,a||"",l)}this.reqPromise.has(a)&&(c&&this.log_.warn(c,l,a),this.reqPromise.get(a).resolve({err:c,data:l,uuid:a}),this.reqPromise.delete(a)),this.emit(m,a?{uuid:a,err:c,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(a=>r&a).map(a=>({mediaType:a,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]}))},userId:e.userId,srctinyid:e.tinyId};this._sendReq(4,i)}createOputReceiver(e){return new Ue(this.unMarshal(e))}*unMarshal(e){let r=null,i=new Map;for(;;){let a=0,c=0;try{r=yield 1;let _=r[0]>>4,l=r[0]&2,m=r[0]&1;r=yield 4+m*2;let h=new DataView(r.buffer,r.byteOffset);if(c=h.getUint16(0),a=m==1?h.getUint32(2):h.getUint16(2),r=yield a,l){let f=r[0]&63,y=r[1],x=r.subarray(2,2+y);switch(f){case 1:let O=x[0]>>7,Y=x[0]&127,R=x[1],{dv:C,write8:$}=Dt(4099,2);$(Y),$(R),this.send(C.buffer);let Te=Y%64;for(let Ie=0;Ie<64;Ie++){let ie=Y-Ie;ie<0&&(ie+=64);let pe=Te-Ie;pe<0&&(pe+=64),i.has(pe)&&i.get(pe).groupId!=ie&&i.delete(pe)}let Se=i.get(Te);if(Se||i.set(Te,Se=new is(Y)),r=Se.push(R,r.slice(2+y),O!=0),r)i.delete(Te);else continue}}this.onReceive(e,c,r)}catch(_){this.log_.error(e,_,a,c,r)}}}generateUUID(){return"xxxxxxxxxxxxxxxx".replace(/[xy]/g,e=>{let r=Math.random()*16|0;return(e=="x"?r:r&3|8).toString(16)})}};d(be,"JOINED","joined"),d(be,"CLOSED","closed"),ce([me(Z.INIT,"CONNECTED")],be.prototype,"connect",1),ce([me("CONNECTED",be.JOINED)],be.prototype,"joinRoom",1),ce([me("RECONNECTED",be.JOINED,{fail(){this.close()}})],be.prototype,"rejoinRoom",1),ce([me("DISCONNECTED","RECONNECTED")],be.prototype,"reconnect",1),ce([me([],"DISCONNECTED",{sync:!0})],be.prototype,"disconnect",1),ce([me([],be.CLOSED,{sync:!0})],be.prototype,"close",1);var Ke=be,is=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 a=0;a<this.chunks.length;a++)if(!this.chunks[a])return null;let i=new Uint8Array(this.totalLen);for(;this.chunks.length;){let a=this.chunks.pop();i.set(a,this.totalLen-=a.length)}return i}return null}};var Ht=class extends he{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,a={mcuMix:{reqUser:this.io.reqUser_,roomid:t.roomId,sdkAppID:this.appId,socketid:this.io.joinRes.socketid,mcuRequestTime:t.mcuRequestTime,outputSessionId:t.outputSessionId},inputParam:r.map(c=>({userid:c.userId,width:c.width,height:c.height,locationX:c.locationX,locationY:c.locationY,zOrder:c.zOrder,streamType:c.streamType,inputType:c.inputType})),outputParam:{streamId: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,a).then(e.postMessage)}stopMcuMix(t,e){let r={mcuMix:{reqUser:this.io.reqUser_,roomid:this.roomId,sdkAppID:this.appId,socketid:this.io.joinRes.socketid,mcuRequestTime:t.mcuRequestTime,outputSessionId:t.outputSessionId},userid:this.userId,streamType:t.streamType};return console.info("stop mcuMix:",t),this.send(16,r).then(e.postMessage)}};var Oc=1200;var Pc=31,Nc=6,Dc=6;var Wi={1:1,audio:1,video:4,2:4,auxVideo:2,7:2,3:8};var h_=Date.now(),b_=Pc+Nc+6+Dc+Oc+1;var qt=class extends he{constructor(){super(...arguments);d(this,"videoEncBuffer_",new k(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:a},c,_){var x;let l=new k(e*r*2),m=O=>{this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_level=O.volume*1e8/100>>0;let{data:Y}=O,R=Y.length;l.set(Y),this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_enc_br+=R<<3,this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_frame_interval++,this.audioStats.packetsSent++;let C=F._PacketizeAudioUdt(l.point,R,O.timestamp,e,r,O.energy,k.global.point,k.global.size,this.io.id,!!_);if(C<=0){console.warn("audio pack len is 0");return}this.io.send(k.global.uint8Array(C)),this.audioStats.bytesSent+=C,this.statReportReq.msg_audio_stat_report.msg_audio_send_stat.uint32_audio_send_br+=C<<3,this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_receive++},h=O=>{l.free(),this.send(3,{mediaType:1})},f=new MessageChannel;(x=this.io.wh.playPort)==null||x.postMessage({cmd:"pushAudio",payload:{numberOfChannels:r,bitrate:i},encrypt:!!_,index:a},[f.port2,c.port]);let y=Nt(f.port1);_&&V(y,X()),V(_||y,X(m,h,h))}createSelectAbilityOb(e,r){let i=r.bitrate;return V(this.createResposeOb(259),Ys(()=>We(2e3)),ze(a=>{var c;return(c=a.data.ability.rpt_msg_video_control_info)==null?void 0:c.find(_=>_.uint32_video_type===e)}),dt(a=>{if(!a)return!1;let c=a.uint32_video_enc_br,_=c*Math.pow(1-this.qualityReport.msg_up_stream_info.msg_network_status.uint32_lost/100,2),l=Math.min(i,_);a.uint32_video_enc_br=l,this.glog({[`confBr${e}`]:[c,_,l]});let m=!1;return((f,y)=>{a[y]&&a[y]!==r[f]&&(m=!0,r[f]=a[y])})("bitrate","uint32_video_enc_br"),m}),kn(r))}pushVideo({profile:{width:e,height:r,frameRate:i,bitrate:a},type:c,trackType:_},l){this.videoStats.frameWidth=e,this.videoStats.frameHeight=r;let m=0,h=Wi[c];this.videoTypeIndexMap.has(c)?m=this.videoTypeIndexMap.get(c):(m=this.statReportReq.rpt_msg_video_stat_report.length,this.requestTypeMap.set(m,c===7?4097:4096),this.videoTypeIndexMap.set(c,m),this.statReportReq.rpt_msg_video_stat_report.push({uint32_video_type:c,msg_video_enc_stat:{uint32_video_enc_fps:0,uint32_video_enc_br:0,uint32_video_encrd:1},msg_video_send_stat:{uint32_video_send_br:0,uint32_video_fec_br:0,uint32_video_arq_br:0}}),this.qualityReport.msg_up_stream_info.msg_video_status.push({uint32_video_codec_bitrate:0,uint32_video_total_bitrate:0,uint32_video_enc_fps:0,uint32_video_capture_fps:0,uint32_video_codec_fps:0,uint32_video_stream_type:c,uint32_video_codec_type:0,uint32_video_decode_frame:0,uint32_video_total_frame:0,uint32_video_width:e,uint32_video_height:r}));let f={width:e,height:r,bitrate:a*1e3,framerate:i};Object.assign(this.qualityReport.msg_up_stream_info.msg_video_status[m],{uint32_video_width:e,uint32_video_height:r});let y=0,x=!1,O=R=>{this.send(3,{mediaType:h})};V(this.createSelectAbilityOb(c,f),X(()=>{l.postMessage(f)}));let Y=l;_!="camera"&&(this.io.log_.info(`push ${_} track`),Y=qs(l,V(l,Ks(2e3),Bn(R=>(this.io.log_.warn("start push last video frame"),V(ve(2e3),kn(R),Re(l),fr({complete:()=>this.io.log_.warn("stop push last video frame")})))),Le(l)))),V(Y,X(R=>{let C=this.getVideoStatus(m);C.uint32_video_total_frame++,y++,this.videoStats.framesSent++,C.uint32_video_capture_fps++,y%300==0&&l.postMessage(260),this.handleVideoEncoded(R,c)},O,O)),V(this.createResposeOb(260),Le(l),X(()=>l.postMessage(260)))}getVideoStatus(e){return this.qualityReport.msg_up_stream_info.msg_video_status[e]}handleVideoEncoded(e,r){let{chunk:i,timestamp:a}=e;this.videoStats.framesEncoded++;let c=this.videoTypeIndexMap.get(r),_=this.getVideoStatus(c);_.uint32_video_decode_frame++,_.uint32_video_codec_fps++,_.uint32_video_enc_fps++,this.statReportReq.rpt_msg_video_stat_report[c].msg_video_enc_stat.uint32_video_enc_fps++;let l="byteLength"in i?i.byteLength:i.data.length;if(this.statReportReq.rpt_msg_video_stat_report[c].msg_video_enc_stat.uint32_video_enc_br+=l<<3,l>this.videoEncBuffer_.size){console.log("buffer too small!");return}"byteLength"in i?i.copyTo(this.videoEncBuffer_.uint8Array(l)):this.videoEncBuffer_.set(i.data),k.global.fill();let m=F._PacketizeVideoUdt(this.videoEncBuffer_.point,l,a,i.type=="key"?1:0,r,k.global.point,this.io.id);this.sendUdtv3Video(m,c)}sendUdtv3Video(e,r){let i=0,a=k.global.uint8Array();for(let c=0;c<e;c++){let _=k.global.getUint32(i);if(_<=0){this.io.log_.warn("sendUdtv3Video pktSize is ",_);continue}this.io.send(a.subarray(i+=4,i+=_)),this.statReportReq.rpt_msg_video_stat_report[r].msg_video_send_stat.uint32_video_send_br+=_<<3,this.videoStats.bytesSent+=_,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(a=>e&a).map(a=>({mediaType:a,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]}))}};this.send(2,i).then(a=>{r.postMessage(a),r.postMessage(null)})}};var Cc=2,Wt=class extends he{addEventMsgs(t){this.qualityReport.msg_event_msg=t}constructor(t){super(t);let e,r=Ee(t,Ke.JOINED),i=Ee(t,Ke.CLOSED),a={};V(r,Pt(ve(1e3)),Re(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((f,y)=>f+y.msg_video_send_stat.uint32_video_send_br,0),a.bandwidth=this.statReportReq.msg_down_bandwidth_est.uint32_avg_bandwidth_br,a.heartbeatSend=1;let h=[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((f,y)=>{let x=this.statReportReq.rpt_msg_video_stat_report[y];f.uint32_video_total_bitrate=x.msg_video_send_stat.uint32_video_send_br,h[x.uint32_video_type==7?3:x.uint32_video_type-1]=f.uint32_video_codec_bitrate=x.msg_video_enc_stat.uint32_video_enc_br}),a.localBr=h,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(f=>{f.msg_video_send_stat.uint32_video_send_br=0,f.msg_video_enc_stat.uint32_video_enc_br=0,f.msg_video_enc_stat.uint32_video_enc_fps=0}),this.statReportReq.msg_net_stat_report.uint32_down_recv_br=0}));let c=V(this.createResposeOb(12),fr(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))}));V(r,Pt(c),Pt(We(ii)),Re(i),X(()=>{this.io.log_.warn("ping timeout,lastrecv:",e,"now:",Date.now()),this.io.state==Ke.JOINED&&this.io.wFSM.disconnect("ping timeout")}));let _=new k(52);V(r,Pt(ve(Cc*1e3)),Re(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(O=>{var C,$;let Y=O.toDownStreamInfo(O,l%10===0),R=[Y.msg_audio_status.uint32_audio_codec_bitrate];return R[1]=Y.msg_video_status[0].uint32_video_codec_bitrate,R[2]=((C=Y.msg_video_status[1])==null?void 0:C.uint32_video_codec_bitrate)||0,a[`RemoteBr_${O.userId}`]=R,a[`RemoteBlock_${O.userId}`]=[Y.msg_audio_status.uint32_audio_block_cnt,Y.msg_video_status[0].uint32_video_block_cnt,(($=Y.msg_video_status[1])==null?void 0:$.uint32_video_block_cnt)||0],Y}),this.glog(a),a={};let h=this.qualityReport.msg_down_stream_info.map(O=>({userId:O.msg_user_info.str_identifier,rtt:O.msg_network_status.uint32_rtt,loss:O.msg_network_status.uint32_lost})),f=wc(h),y=this.qualityReport.msg_up_stream_info.msg_network_status.uint32_rtt,x=this.qualityReport.msg_up_stream_info.msg_network_status.uint32_lost;this.postMessage("network-quality",{uplinkNetworkQuality:this.io.state!="DISCONNECTED"?Gi(x,y):6,downlinkNetworkQuality:Gi(f.loss,f.rtt),uplinkInfo:this.qualityReport.msg_up_stream_info,msg_down_stream_info:this.qualityReport.msg_down_stream_info,downlinkInfo:h,uplinkRTT:y,uplinkLoss:x,downlinkRTT:f.rtt,downlinkLoss:f.loss}),this.qualityReport.msg_up_stream_info.msg_video_status.forEach(O=>{O.uint32_video_capture_fps>>=1,O.uint32_video_codec_fps>>=1,l%10===0&&console.log(Ze(),"video uplink fps:",O.uint32_video_stream_type,O.uint32_video_capture_fps,O.uint32_video_codec_fps)}),this.post(7,this.io.qualityReportReq),this.qualityReport.msg_event_msg=[],this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_level=0,this.qualityReport.msg_up_stream_info.msg_video_status.forEach(O=>{O.uint32_video_capture_fps=0,O.uint32_video_codec_fps=0,O.uint32_video_enc_fps=0})},l=>{},()=>{this.qualityReport.msg_down_stream_info=[...this.userMap_.values()].map(l=>l.toDownStreamInfo(l,!1)),this.post(7,this.io.qualityReportReq),_.free()}))}};function wc(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 Gi(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 Gt=class extends he{async subscribe(t,e){let{mediaType:r,srctinyid:i}=t,a=this.userMap_.get(i);if(a){if(a.subscribe|=t.mediaType,t.mediaType=a.subscribe,e)e.postMessage(await this.send(4,t));else return this.send(4,t);r===1&&a.startPullOnlyAudio(a.mainPuller,e,{mediaType:r,srctinyid:i})}}async unSubscribe(t,e){let{mediaType:r,srctinyid:i}=t,a=this.userMap_.get(i);if(a){let c=a.subscribe;a.subscribe&=~r,c!==a.subscribe&&e.postMessage(await this.send(a.subscribe===0?5:4,t))}}pullVideo({mediaType:t,tinyId:e},r){let 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 a=i.subscribe;e===8?(i.subscribe|=8,i.subscribe&=-5):e===4&&(i.subscribe|=4,i.subscribe&=-9),a!=i.subscribe&&(t.mediaType=i.subscribe,this.send(4,t))}}};var os=class extends Mt{constructor(e,r,i,a){super();this.seq=e;this.player=r;this.numberOfChannels=i;this.bitrate=a;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(re.useAINS),this._SetAudioFrameFormat(sampleRate,this.numberOfChannels),this._InitOpusEncoder(sampleRate,this.numberOfChannels,1),this.bitrate&&this._SetOpusEncBitrate(this.bitrate*1e3),console.log(tt,"audio worklet initialized",sampleRate,this.numberOfChannels,this.seq),this.oput=new Ue,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 a=0;for(;this.bufferLen-this.pos>=this.tenms;){let c=this.player.delay+(this.bufferLen-this.pos)/(sampleRate/1e3)+20>>0,_=this._AudioProcessFloat(this.encodePrt+this.pos*4,this.tenms,c);if(a<_&&(a=_),this.pos+=this.tenms,this.pos>=this.numberOfFrames){if(this.dumpPort){let f=this.float32Array.slice(0,this.numberOfFrames);this.dumpPort.postMessage({data:f},[f.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),h=a*100/32768;this.mainPort.postMessage(h),this.outputPort.postMessage({data:m,volume:h,energy:a,timestamp:Date.now()},[m.buffer]),a=0,this.float32Array.copyWithin(0,this.numberOfFrames,this.bufferLen),this.bufferLen-=this.numberOfFrames,this.pos-=this.numberOfFrames}}break}}close(){this._free(this.aecPtr),this._free(this.encodePrt)}};function ji(n){class t extends AudioWorkletProcessor{constructor(i){super();d(this,"oput",new Ue);d(this,"wasm");d(this,"encoders",[]);d(this,"useAINS",!0);console.log("worklet created:",sampleRate),this.wasm=i.processorOptions.wasm,Object.assign(re,i.processorOptions.flag),this.port.onmessage=a=>this.pushAudio(a)}get delay(){var i;return(((i=this.oput.buffer)==null?void 0:i.length)||0)/(sampleRate*4/1e3)}process(i,a){return this.oput.demand(a[0][0],!0),this.encoders.forEach((c,_)=>c.encode(...i[_])),!0}pushAudio(i){if(i.data instanceof Uint8Array){let{data:a}=i;this.encoders.forEach(c=>a=c.aec(i.data)),this.oput.malloc(a.length).set(a);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":re.useAINS=i.data.payload,this.encoders.forEach(a=>a._UseAINS(i.data.payload));break;case"enableAEC":this.encoders.forEach(a=>a._EnableAEC(i.data.payload));break;case"enableDebug":console.debug=i.data.payload?hr:()=>{};break;case"pushAudio":{let[a,c]=i.ports,{payload:{numberOfChannels:_,bitrate:l},encrypt:m,index:h}=i.data,f=this.encoders[h]||new os(h,this,_,l);this.encoders[h]?(f.bitrate=l,f._SetOpusEncBitrate(l*1e3)):n(f),f.reset(),f.mainPort=c,f.workerPort=a,f.outputPort=m?c:a,c.onmessage=y=>{y.data?f.encode(y.data):(console.log(Ze(),"encoder",h,"stopped"),a.postMessage(null))}}}}}registerProcessor("global-audio-player",t)}var as=class{constructor(){d(this,"playPort");d(this,"dumpPort");d(this,"downlinkAudioCount",0);d(this,"interval10ms",V(lt(10),qe()));d(this,"ios")}glog(t){self.postMessage({type:"glog",payload:t})}async joinRoom(t){let{data:{id:e,payload:r},ports:i}=t,a=new Ke(e,i[0],r);a.wh=this;let c=[new qt(a),new Gt(a),new Lt(a),new Wt(a),new Ht(a)],_=(m="leave room")=>{a.leaveRoom().catch(),a.abort(m),this.ios.delete(a)},l=setTimeout(a.abort,5e3,"timeout");V(Nt(a.port,!0),X(({data:{cmd:m,payload:h},ports:f})=>{switch(console.log(self.name,"received message",m),m){case"setAudioWorkletPort":this.playPort=f[0];break;case"switchRole":a.sendReq(20,{role:h,privateMapKey:a.params.privateMapKey}).then(x=>f[0].postMessage(x));break;default:let y=f.map(x=>Nt(x));typeof h!="undefined"&&y.unshift(h),c.forEach(x=>{var O;(O=x[m])==null||O.call(x,...y)})}},_,_));try{await a.connect(),postMessage({id:e,payload:await a.joinRoom()}),clearTimeout(l),this.ios.add(a)}catch(m){m instanceof WebTransportError?m=`Transport initialization failed.
|
|
3
|
+
Reason: ${m.message}.
|
|
4
|
+
Source: ${m.source}.
|
|
5
|
+
Error code: ${m.streamErrorCode}.`:m instanceof et?m=m.cause:m instanceof Event&&(m=m.type),postMessage({id:e,payload:{err:m}}),a.close()}}};function Lc(n){self.onmessage=async t=>{let e=setTimeout(()=>{self.postMessage({type:"error",payload:"timeout"})},5e3);try{t.data.wasm&&(F.wasmBinary=t.data.wasm),Object.assign(re,t.data.flag),console.time(`Worker[${self.name}${tt}]`),F.postRun=[()=>{k.global=new k(1920*1080*3>>1),F._CreateMediaProcessing(0,1,0,!1),console.timeEnd(`Worker[${self.name}${tt}]`),F._UseAINS(re.useAINS),this.ios=new Set,t.ports[0].onmessage=l=>{var f,y,x;let[m,h]=l.data;switch(m){case"dump":switch(h){case"audio":this.dumpPort=l.ports[0];break;case"mic0":(f=this.playPort)==null||f.postMessage({cmd:m,payload:h},l.ports);break}break;case"useAINS":F._UseAINS(h),(y=this.playPort)==null||y.postMessage({cmd:m,payload:h});break;case"enableDebug":console.debug=h?hr:()=>{},(x=this.playPort)==null||x.postMessage({cmd:m,payload:h});break;case"useV2":F.udtver=h?2:3;break;case"useWt":re.useWt=h;break;case"enableAEC":F._EnableAEC(h);break}};let r=0,i=Date.now(),a=0;V(ve(1e3),X(()=>{let h=(Date.now()-i)/10-r;console.debug("interval10ms:",h,h-a),a=h,F._UpdateStreamSync()})),F._SetAudioOutStreamFormat(48e3,1);let c=F._malloc(3*4),_=new k(1920);V(this.interval10ms,X(()=>{if(r++,F._GetAudioMixedFloat(_.point,48e3,c)>=0){if(this.playPort){let m=_.uint8Slice();this.playPort.postMessage(m,[m.buffer])}if(this.dumpPort){let m=_.uint8Slice();this.dumpPort.postMessage(m,[m.buffer])}this.ios.forEach(m=>m.userManager.remotePublishedUserMap.forEach(h=>{var f;return(f=h.audioPuller)==null?void 0:f.feed()}))}})),self.onmessage=this.joinRoom.bind(this),clearTimeout(e),self.postMessage({type:"ready"})}],n(F)}catch(r){self.postMessage({type:"error",err:r})}}}var Yi=Ur?ji:Lc.bind(new as);var kc=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,o){r=s,i=o});var a={},c;for(c in e)e.hasOwnProperty(c)&&(a[c]=e[c]);var _=[],l="./this.program",m=function(s,o){throw o},h=typeof window=="object",f=typeof importScripts=="function",y=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",x=!h&&!y&&!f,O="";function Y(s){return e.locateFile?e.locateFile(s,O):O+s}var R,C,$,Te;function Se(s){if(!(s instanceof pu)){var o=s;ie("exiting due to exception: "+o)}}x?(typeof read!="undefined"&&(R=function(o){return read(o)}),$=function(o){var u;return typeof readbuffer=="function"?new Uint8Array(readbuffer(o)):(u=read(o,"binary"),cs(typeof u=="object"),u)},C=function(o,u,p){setTimeout(function(){u($(o))},0)},typeof scriptArgs!="undefined"?_=scriptArgs:typeof arguments!="undefined"&&(_=arguments),typeof quit=="function"&&(m=function(s,o){Se(o),quit(s)}),typeof print!="undefined"&&(typeof console=="undefined"&&(console={}),console.log=print,console.warn=console.error=typeof printErr!="undefined"?printErr:print)):(h||f)&&(f?O=self.location.href:typeof document!="undefined"&&document.currentScript&&(O=document.currentScript.src),n&&(O=n),O.indexOf("blob:")!==0?O=O.substr(0,O.replace(/[?#].*/,"").lastIndexOf("/")+1):O="",R=function(s){var o=new XMLHttpRequest;return o.open("GET",s,!1),o.send(null),o.responseText},f&&($=function(s){var o=new XMLHttpRequest;return o.open("GET",s,!1),o.responseType="arraybuffer",o.send(null),new Uint8Array(o.response)}),C=function(s,o,u){var p=new XMLHttpRequest;p.open("GET",s,!0),p.responseType="arraybuffer",p.onload=function(){if(p.status==200||p.status==0&&p.response){o(p.response);return}u()},p.onerror=u,p.send(null)},Te=function(s){document.title=s});var Ie=e.print||console.log.bind(console),ie=e.printErr||console.warn.bind(console);for(c in a)a.hasOwnProperty(c)&&(e[c]=a[c]);a=null,e.arguments&&(_=e.arguments),e.thisProgram&&(l=e.thisProgram),e.quit&&(m=e.quit);function pe(s){pe.shown||(pe.shown={}),pe.shown[s]||(pe.shown[s]=1,ie(s))}function Ki(s,o){if(typeof WebAssembly.Function=="function"){for(var u={i:"i32",j:"i64",f:"f32",d:"f64"},p={parameters:[],results:o[0]=="v"?[]:[u[o[0]]]},b=1;b<o.length;++b)p.parameters.push(u[o[b]]);return new WebAssembly.Function(p,s)}var E=[1,0,1,96],T=o.slice(0,1),I=o.slice(1),S={i:127,j:126,f:125,d:124};E.push(I.length);for(var b=0;b<I.length;++b)E.push(S[I[b]]);T=="v"?E.push(0):E=E.concat([1,S[T]]),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])),H=new WebAssembly.Module(v),K=new WebAssembly.Instance(H,{e:{f:s}}),q=K.exports.f;return q}var Mr=[],Je;function Ji(){if(Mr.length)return Mr.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 Xi(s,o){for(var u=s;u<s+o;u++){var p=$t(u);p&&Je.set(p,u)}}function Qi(s,o){if(Je||(Je=new WeakMap,Xi(0,st.length)),Je.has(s))return Je.get(s);var u=Ji();try{As(u,s)}catch(b){if(!(b instanceof TypeError))throw b;var p=Ki(s,o);As(u,p)}return Je.set(s,u),u}function zi(s){Je.delete($t(s)),Mr.push(s)}var At;e.wasmBinary&&(At=e.wasmBinary);var Bc=e.noExitRuntime||!1;typeof WebAssembly!="object"&&it("no native wasm support detected");var jt,us=!1,Zi;function cs(s,o){s||it("Assertion failed: "+o)}function A(s){var o=e["_"+s];return cs(o,"Cannot call unknown function "+s+", make sure it is exported"),o}function ls(s,o,u,p,b){var E={string:function(W){var te=0;if(W!=null&&W!==0){var j=(W.length<<2)+1;te=Xr(j),ps(W,te,j)}return te},array:function(W){var te=Xr(W.length);return hs(W,te),te}};function T(W){return o==="string"?Rt(W):o==="boolean"?!!W:W}var I=A(s),S=[],v=0;if(p)for(var H=0;H<p.length;H++){var K=E[u[H]];K?(v===0&&(v=Ms()),S[H]=K(p[H])):S[H]=p[H]}var q=I.apply(null,S);function Q(W){return v!==0&&Ls(v),T(W)}return q=Q(q),q}function eo(s,o,u,p){u=u||[];var b=u.every(function(T){return T==="number"}),E=o!=="string";return E&&b&&!p?A(s):function(){return ls(s,o,u,arguments,p)}}var ds=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function Lr(s,o,u){for(var p=o+u,b=o;s[b]&&!(b>=p);)++b;if(b-o>16&&s.subarray&&ds)return ds.decode(s.subarray(o,b));for(var E="";o<b;){var T=s[o++];if(!(T&128)){E+=String.fromCharCode(T);continue}var I=s[o++]&63;if((T&224)==192){E+=String.fromCharCode((T&31)<<6|I);continue}var S=s[o++]&63;if((T&240)==224?T=(T&15)<<12|I<<6|S:T=(T&7)<<18|I<<12|S<<6|s[o++]&63,T<65536)E+=String.fromCharCode(T);else{var v=T-65536;E+=String.fromCharCode(55296|v>>10,56320|v&1023)}}return E}function Rt(s,o){return s?Lr(oe,s,o):""}function ms(s,o,u,p){if(!(p>0))return 0;for(var b=u,E=u+p-1,T=0;T<s.length;++T){var I=s.charCodeAt(T);if(I>=55296&&I<=57343){var S=s.charCodeAt(++T);I=65536+((I&1023)<<10)|S&1023}if(I<=127){if(u>=E)break;o[u++]=I}else if(I<=2047){if(u+1>=E)break;o[u++]=192|I>>6,o[u++]=128|I&63}else if(I<=65535){if(u+2>=E)break;o[u++]=224|I>>12,o[u++]=128|I>>6&63,o[u++]=128|I&63}else{if(u+3>=E)break;o[u++]=240|I>>18,o[u++]=128|I>>12&63,o[u++]=128|I>>6&63,o[u++]=128|I&63}}return o[u]=0,u-b}function ps(s,o,u){return ms(s,oe,o,u)}function _s(s){for(var o=0,u=0;u<s.length;++u){var p=s.charCodeAt(u);p>=55296&&p<=57343&&(p=65536+((p&1023)<<10)|s.charCodeAt(++u)&1023),p<=127?++o:p<=2047?o+=2:p<=65535?o+=3:o+=4}return o}var fs=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function D(s,o){for(var u=s,p=u>>1,b=p+o/2;!(p>=b)&&Yt[p];)++p;if(u=p<<1,u-s>32&&fs)return fs.decode(oe.subarray(s,u));for(var E="",T=0;!(T>=o/2);++T){var I=nt[s+T*2>>1];if(I==0)break;E+=String.fromCharCode(I)}return E}function to(s,o,u){if(u===void 0&&(u=2147483647),u<2)return 0;u-=2;for(var p=o,b=u<s.length*2?u/2:s.length,E=0;E<b;++E){var T=s.charCodeAt(E);nt[o>>1]=T,o+=2}return nt[o>>1]=0,o-p}function ro(s){return s.length*2}function no(s,o){for(var u=0,p="";!(u>=o/4);){var b=M[s+u*4>>2];if(b==0)break;if(++u,b>=65536){var E=b-65536;p+=String.fromCharCode(55296|E>>10,56320|E&1023)}else p+=String.fromCharCode(b)}return p}function so(s,o,u){if(u===void 0&&(u=2147483647),u<4)return 0;for(var p=o,b=p+u-4,E=0;E<s.length;++E){var T=s.charCodeAt(E);if(T>=55296&&T<=57343){var I=s.charCodeAt(++E);T=65536+((T&1023)<<10)|I&1023}if(M[o>>2]=T,o+=4,o+4>b)break}return M[o>>2]=0,o-p}function io(s){for(var o=0,u=0;u<s.length;++u){var p=s.charCodeAt(u);p>=55296&&p<=57343&&++u,o+=4}return o}function hs(s,o){z.set(s,o)}function oo(s,o,u){for(var p=0;p<s.length;++p)z[o++>>0]=s.charCodeAt(p);u||(z[o>>0]=0)}function ao(s,o){return s%o>0&&(s+=o-s%o),s}var kr,z,oe,nt,Yt,M,Ce,bs,Br;function gs(s){kr=s,e.HEAP8=z=new Int8Array(s),e.HEAP16=nt=new Int16Array(s),e.HEAP32=M=new Int32Array(s),e.HEAPU8=oe=new Uint8Array(s),e.HEAPU16=Yt=new Uint16Array(s),e.HEAPU32=Ce=new Uint32Array(s),e.HEAPF32=bs=new Float32Array(s),e.HEAPF64=Br=new Float64Array(s)}var Vc=e.INITIAL_MEMORY||134217728,st,Es=[],Ts=[],uo=[],Ss=[],co=!1;function lo(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)_o(e.preRun.shift());Fr(Es)}function mo(){co=!0,Fr(Ts)}function po(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)ho(e.postRun.shift());Fr(Ss)}function _o(s){Es.unshift(s)}function fo(s){Ts.unshift(s)}function ho(s){Ss.unshift(s)}var Xe=0,Vr=null,vt=null;function bo(s){Xe++,e.monitorRunDependencies&&e.monitorRunDependencies(Xe)}function go(s){if(Xe--,e.monitorRunDependencies&&e.monitorRunDependencies(Xe),Xe==0&&(Vr!==null&&(clearInterval(Vr),Vr=null),vt)){var o=vt;vt=null,o()}}e.preloadedImages={},e.preloadedAudios={};function it(s){e.onAbort&&e.onAbort(s),s="Aborted("+s+")",ie(s),us=!0,Zi=1,s+=". Build with -s ASSERTIONS=1 for more info.";var o=new WebAssembly.RuntimeError(s);throw i(o),o}var Eo="data:application/octet-stream;base64,";function Is(s){return s.startsWith(Eo)}var ye;ye="av_processing.wasm",Is(ye)||(ye=Y(ye));function ys(s){try{if(s==ye&&At)return new Uint8Array(At);if($)return $(s);throw"both async and sync fetching of the wasm failed"}catch(o){it(o)}}function To(){return!At&&(h||f)&&typeof fetch=="function"?fetch(ye,{credentials:"same-origin"}).then(function(s){if(!s.ok)throw"failed to load wasm binary file at '"+ye+"'";return s.arrayBuffer()}).catch(function(){return ys(ye)}):Promise.resolve().then(function(){return ys(ye)})}function So(){var s={a:Aa};function o(T,I){var S=T.exports;e.asm=S,jt=e.asm.B,gs(jt.buffer),st=e.asm.na,fo(e.asm.C),go("wasm-instantiate")}bo("wasm-instantiate");function u(T){o(T.instance)}function p(T){return To().then(function(I){return WebAssembly.instantiate(I,s)}).then(function(I){return I}).then(T,function(I){ie("failed to asynchronously prepare wasm: "+I),it(I)})}function b(){return!At&&typeof WebAssembly.instantiateStreaming=="function"&&!Is(ye)&&typeof fetch=="function"?fetch(ye,{credentials:"same-origin"}).then(function(T){var I=WebAssembly.instantiateStreaming(T,s);return I.then(u,function(S){return ie("wasm streaming compile failed: "+S),ie("falling back to ArrayBuffer instantiation"),p(u)})}):p(u)}if(e.instantiateWasm)try{var E=e.instantiateWasm(s,o);return E}catch(T){return ie("Module.instantiateWasm callback failed with error: "+T),!1}return b().catch(i),{}}function Fr(s){for(;s.length>0;){var o=s.shift();if(typeof o=="function"){o(e);continue}var u=o.func;typeof u=="number"?o.arg===void 0?$t(u)():$t(u)(o.arg):u(o.arg===void 0?null:o.arg)}}function $t(s){return st.get(s)}function Io(){var s=new Error;if(!s.stack){try{throw new Error}catch(o){s=o}if(!s.stack)return"(no stack trace available)"}return s.stack.toString()}function As(s,o){st.set(s,o)}function yo(s){return Zt(s+16)+16}function Ao(s,o){uo.unshift({func:s,arg:o})}function Ro(s,o){return Ao(s,o)}function vo(s){this.excPtr=s,this.ptr=s-16,this.set_type=function(o){M[this.ptr+4>>2]=o},this.get_type=function(){return M[this.ptr+4>>2]},this.set_destructor=function(o){M[this.ptr+8>>2]=o},this.get_destructor=function(){return M[this.ptr+8>>2]},this.set_refcount=function(o){M[this.ptr>>2]=o},this.set_caught=function(o){o=o?1:0,z[this.ptr+12>>0]=o},this.get_caught=function(){return z[this.ptr+12>>0]!=0},this.set_rethrown=function(o){o=o?1:0,z[this.ptr+13>>0]=o},this.get_rethrown=function(){return z[this.ptr+13>>0]!=0},this.init=function(o,u){this.set_type(o),this.set_destructor(u),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var o=M[this.ptr>>2];M[this.ptr>>2]=o+1},this.release_ref=function(){var o=M[this.ptr>>2];return M[this.ptr>>2]=o-1,o===1}}var Uo=0,xo=0;function Oo(s,o,u){var p=new vo(s);throw p.init(o,u),Uo=s,xo++,s}function Po(s,o,u,p,b){}function Hr(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 No(){for(var s=new Array(256),o=0;o<256;++o)s[o]=String.fromCharCode(o);Rs=s}var Rs=void 0;function Be(s){for(var o="",u=s;oe[u];)o+=Rs[oe[u++]];return o}var qr={},vs={},Do={},Co=48,wo=57;function Mo(s){if(s===void 0)return"_unknown";s=s.replace(/[^a-zA-Z0-9_]/g,"$");var o=s.charCodeAt(0);return o>=Co&&o<=wo?"_"+s:s}function Lo(s,o){return s=Mo(s),new Function("body","return function "+s+`() {
|
|
6
|
+
"use strict"; return body.apply(this, arguments);
|
|
7
|
+
};
|
|
8
|
+
`)(o)}function Us(s,o){var u=Lo(o,function(p){this.name=o,this.message=p;var b=new Error(p).stack;b!==void 0&&(this.stack=this.toString()+`
|
|
9
|
+
`+b.replace(/^Error(:[^\n]*)?\n/,""))});return u.prototype=Object.create(s.prototype),u.prototype.constructor=u,u.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},u}var xs=void 0;function ot(s){throw new xs(s)}var ko=void 0;function Ve(s,o,u){if(u=u||{},!("argPackAdvance"in o))throw new TypeError("registerType registeredInstance requires argPackAdvance");var p=o.name;if(s||ot('type "'+p+'" must have a positive integer typeid pointer'),vs.hasOwnProperty(s)){if(u.ignoreDuplicateRegistrations)return;ot("Cannot register type '"+p+"' twice")}if(vs[s]=o,delete Do[s],qr.hasOwnProperty(s)){var b=qr[s];delete qr[s],b.forEach(function(E){E()})}}function Bo(s,o,u,p,b){var E=Hr(u);o=Be(o),Ve(s,{name:o,fromWireType:function(T){return!!T},toWireType:function(T,I){return I?p:b},argPackAdvance:8,readValueFromPointer:function(T){var I;if(u===1)I=z;else if(u===2)I=nt;else if(u===4)I=M;else throw new TypeError("Unknown boolean type size: "+o);return this.fromWireType(I[T>>E])},destructorFunction:null})}var Wr=[],xe=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Vo(s){s>4&&--xe[s].refcount===0&&(xe[s]=void 0,Wr.push(s))}function Fo(){for(var s=0,o=5;o<xe.length;++o)xe[o]!==void 0&&++s;return s}function Ho(){for(var s=5;s<xe.length;++s)if(xe[s]!==void 0)return xe[s];return null}function qo(){e.count_emval_handles=Fo,e.get_first_emval=Ho}var Os={toValue:function(s){return s||ot("Cannot use deleted val. handle = "+s),xe[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 o=Wr.length?Wr.pop():xe.length;return xe[o]={refcount:1,value:s},o}}}};function Gr(s){return this.fromWireType(Ce[s>>2])}function Wo(s,o){o=Be(o),Ve(s,{name:o,fromWireType:function(u){var p=Os.toValue(u);return Vo(u),p},toWireType:function(u,p){return Os.toHandle(p)},argPackAdvance:8,readValueFromPointer:Gr,destructorFunction:null})}function jr(s){if(s===null)return"null";var o=typeof s;return o==="object"||o==="array"||o==="function"?s.toString():""+s}function Go(s,o){switch(o){case 2:return function(u){return this.fromWireType(bs[u>>2])};case 3:return function(u){return this.fromWireType(Br[u>>3])};default:throw new TypeError("Unknown float type: "+s)}}function jo(s,o,u){var p=Hr(u);o=Be(o),Ve(s,{name:o,fromWireType:function(b){return b},toWireType:function(b,E){if(typeof E!="number"&&typeof E!="boolean")throw new TypeError('Cannot convert "'+jr(E)+'" to '+this.name);return E},argPackAdvance:8,readValueFromPointer:Go(o,p),destructorFunction:null})}function Yo(s,o,u){switch(o){case 0:return u?function(b){return z[b]}:function(b){return oe[b]};case 1:return u?function(b){return nt[b>>1]}:function(b){return Yt[b>>1]};case 2:return u?function(b){return M[b>>2]}:function(b){return Ce[b>>2]};default:throw new TypeError("Unknown integer type: "+s)}}function $o(s,o,u,p,b){o=Be(o),b===-1&&(b=4294967295);var E=Hr(u),T=function(v){return v};if(p===0){var I=32-8*u;T=function(v){return v<<I>>>I}}var S=o.includes("unsigned");Ve(s,{name:o,fromWireType:T,toWireType:function(v,H){if(typeof H!="number"&&typeof H!="boolean")throw new TypeError('Cannot convert "'+jr(H)+'" to '+this.name);if(H<p||H>b)throw new TypeError('Passing a number "'+jr(H)+'" from JS side to C/C++ side to an argument of type "'+o+'", which is outside the valid range ['+p+", "+b+"]!");return S?H>>>0:H|0},argPackAdvance:8,readValueFromPointer:Yo(o,E,p!==0),destructorFunction:null})}function Ko(s,o,u){var p=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],b=p[o];function E(T){T=T>>2;var I=Ce,S=I[T],v=I[T+1];return new b(kr,v,S)}u=Be(u),Ve(s,{name:u,fromWireType:E,argPackAdvance:8,readValueFromPointer:E},{ignoreDuplicateRegistrations:!0})}function Jo(s,o){o=Be(o);var u=o==="std::string";Ve(s,{name:o,fromWireType:function(p){var b=Ce[p>>2],E;if(u)for(var T=p+4,I=0;I<=b;++I){var S=p+4+I;if(I==b||oe[S]==0){var v=S-T,H=Rt(T,v);E===void 0?E=H:(E+="\0",E+=H),T=S+1}}else{for(var K=new Array(b),I=0;I<b;++I)K[I]=String.fromCharCode(oe[p+4+I]);E=K.join("")}return Fe(p),E},toWireType:function(p,b){b instanceof ArrayBuffer&&(b=new Uint8Array(b));var E,T=typeof b=="string";T||b instanceof Uint8Array||b instanceof Uint8ClampedArray||b instanceof Int8Array||ot("Cannot pass non-string to std::string"),u&&T?E=function(){return _s(b)}:E=function(){return b.length};var I=E(),S=Zt(4+I+1);if(Ce[S>>2]=I,u&&T)ps(b,S+4,I+1);else if(T)for(var v=0;v<I;++v){var H=b.charCodeAt(v);H>255&&(Fe(S),ot("String has UTF-16 code units that do not fit in 8 bits")),oe[S+4+v]=H}else for(var v=0;v<I;++v)oe[S+4+v]=b[v];return p!==null&&p.push(Fe,S),S},argPackAdvance:8,readValueFromPointer:Gr,destructorFunction:function(p){Fe(p)}})}function Xo(s,o,u){u=Be(u);var p,b,E,T,I;o===2?(p=D,b=to,T=ro,E=function(){return Yt},I=1):o===4&&(p=no,b=so,T=io,E=function(){return Ce},I=2),Ve(s,{name:u,fromWireType:function(S){for(var v=Ce[S>>2],H=E(),K,q=S+4,Q=0;Q<=v;++Q){var W=S+4+Q*o;if(Q==v||H[W>>I]==0){var te=W-q,j=p(q,te);K===void 0?K=j:(K+="\0",K+=j),q=W+o}}return Fe(S),K},toWireType:function(S,v){typeof v!="string"&&ot("Cannot pass non-string to C++ string type "+u);var H=T(v),K=Zt(4+H+o);return Ce[K>>2]=H>>I,b(v,K+4,H+o),S!==null&&S.push(Fe,K),K},argPackAdvance:8,readValueFromPointer:Gr,destructorFunction:function(S){Fe(S)}})}function Qo(s,o){o=Be(o),Ve(s,{isVoid:!0,name:o,argPackAdvance:0,fromWireType:function(){},toWireType:function(u,p){}})}function zo(){it("")}var Yr;typeof dateNow!="undefined"?Yr=dateNow:Yr=function(){return performance.now()};var Zo=!0;function ea(s){return M[ws()>>2]=s,s}function ta(s,o){var u;if(s===0)u=Date.now();else if((s===1||s===4)&&Zo)u=Yr();else return ea(28),-1;return M[o>>2]=u/1e3|0,M[o+4>>2]=u%1e3*1e3*1e3|0,0}function ra(s){return s<0||s===0&&1/s===-1/0}function na(s,o){return(s>>>0)+o*4294967296}function sa(s,o){return(s>>>0)+(o>>>0)*4294967296}function Ps(s,o){if(s<=0)return s;var u=o<=32?Math.abs(1<<o-1):Math.pow(2,o-1);return s>=u&&(o<=32||s>u)&&(s=-2*u+s),s}function Ns(s,o){return s>=0?s:o<=32?2*Math.abs(1<<o-1)+s:Math.pow(2,o)+s}function Ds(s){for(var o=s;oe[o];)++o;return o-s}e._strlen=Ds;function ia(s,o){var u=s,p=o;function b(Pe,Me){return(Me==="double"||Me==="i64")&&Pe&7&&(Pe+=4),Pe}function E(Pe){var Me;return p=b(p,Pe),Pe==="double"?(Me=Number(Br[p>>3]),p+=8):Pe=="i64"?(Me=[M[p>>2],M[p+4>>2]],p+=8):(Pe="i32",Me=M[p>>2],p+=4),Me}for(var T=[],I,S,v;;){var H=u;if(I=z[u>>0],I===0)break;if(S=z[u+1>>0],I==37){var K=!1,q=!1,Q=!1,W=!1,te=!1;e:for(;;){switch(S){case 43:K=!0;break;case 45:q=!0;break;case 35:Q=!0;break;case 48:if(W)break e;W=!0;break;case 32:te=!0;break;default:break e}u++,S=z[u+1>>0]}var j=0;if(S==42)j=E("i32"),u++,S=z[u+1>>0];else for(;S>=48&&S<=57;)j=j*10+(S-48),u++,S=z[u+1>>0];var fe=!1,g=-1;if(S==46){if(g=0,fe=!0,u++,S=z[u+1>>0],S==42)g=E("i32"),u++;else for(;;){var N=z[u+1>>0];if(N<48||N>57)break;g=g*10+(N-48),u++}S=z[u+1>>0]}g<0&&(g=6,fe=!1);var B;switch(String.fromCharCode(S)){case"h":var J=z[u+2>>0];J==104?(u++,B=1):B=2;break;case"l":var J=z[u+2>>0];J==108?(u++,B=8):B=4;break;case"L":case"q":case"j":B=8;break;case"z":case"t":case"I":B=4;break;default:B=null}switch(B&&u++,S=z[u+1>>0],String.fromCharCode(S)){case"d":case"i":case"u":case"o":case"x":case"X":case"p":{var ge=S==100||S==105;B=B||4,v=E("i"+B*8);var U;if(B==8&&(v=S==117?sa(v[0],v[1]):na(v[0],v[1])),B<=4){var we=Math.pow(256,B)-1;v=(ge?Ps:Ns)(v&we,B*8)}var xt=Math.abs(v),_e="";if(S==100||S==105)U=Ps(v,8*B,1).toString(10);else if(S==117)U=Ns(v,8*B,1).toString(10),v=Math.abs(v);else if(S==111)U=(Q?"0":"")+xt.toString(8);else if(S==120||S==88){if(_e=Q&&v!=0?"0x":"",v<0){v=-v,U=(xt-1).toString(16);for(var ks=[],Oe=0;Oe<U.length;Oe++)ks.push((15-parseInt(U[Oe],16)).toString(16));for(U=ks.join("");U.length<B*2;)U="f"+U}else U=xt.toString(16);S==88&&(_e=_e.toUpperCase(),U=U.toUpperCase())}else S==112&&(xt===0?U="(nil)":(_e="0x",U=xt.toString(16)));if(fe)for(;U.length<g;)U="0"+U;for(v>=0&&(K?_e="+"+_e:te&&(_e=" "+_e)),U.charAt(0)=="-"&&(_e="-"+_e,U=U.substr(1));_e.length+U.length<j;)q?U+=" ":W?U="0"+U:_e=" "+_e;U=_e+U,U.split("").forEach(function(Pe){T.push(Pe.charCodeAt(0))});break}case"f":case"F":case"e":case"E":case"g":case"G":{v=E("double");var U;if(isNaN(v))U="nan",W=!1;else if(!isFinite(v))U=(v<0?"-":"")+"inf",W=!1;else{var Bs=!1,Ot=Math.min(g,20);if(S==103||S==71){Bs=!0,g=g||1;var zr=parseInt(v.toExponential(Ot).split("e")[1],10);g>zr&&zr>=-4?(S=(S==103?"f":"F").charCodeAt(0),g-=zr+1):(S=(S==103?"e":"E").charCodeAt(0),g--),Ot=Math.min(g,20)}S==101||S==69?(U=v.toExponential(Ot),/[eE][-+]\d$/.test(U)&&(U=U.slice(0,-1)+"0"+U.slice(-1))):(S==102||S==70)&&(U=v.toFixed(Ot),v===0&&ra(v)&&(U="-"+U));var Ae=U.split("e");if(Bs&&!Q)for(;Ae[0].length>1&&Ae[0].includes(".")&&(Ae[0].slice(-1)=="0"||Ae[0].slice(-1)==".");)Ae[0]=Ae[0].slice(0,-1);else for(Q&&U.indexOf(".")==-1&&(Ae[0]+=".");g>Ot++;)Ae[0]+="0";U=Ae[0]+(Ae.length>1?"e"+Ae[1]:""),S==69&&(U=U.toUpperCase()),v>=0&&(K?U="+"+U:te&&(U=" "+U))}for(;U.length<j;)q?U+=" ":W&&(U[0]=="-"||U[0]=="+")?U=U[0]+"0"+U.slice(1):U=(W?"0":" ")+U;S<97&&(U=U.toUpperCase()),U.split("").forEach(function(Me){T.push(Me.charCodeAt(0))});break}case"s":{var tr=E("i8*"),ut=tr?Ds(tr):6;if(fe&&(ut=Math.min(ut,g)),!q)for(;ut<j--;)T.push(32);if(tr)for(var Oe=0;Oe<ut;Oe++)T.push(oe[tr++>>0]);else T=T.concat(Cs("(null)".substr(0,ut),!0));if(q)for(;ut<j--;)T.push(32);break}case"c":{for(q&&T.push(E("i8"));--j>0;)T.push(32);q||T.push(E("i8"));break}case"n":{var _u=E("i32*");M[_u>>2]=T.length;break}case"%":{T.push(I);break}default:for(var Oe=H;Oe<u+2;Oe++)T.push(z[Oe>>0])}u+=2}else T.push(I),u+=1}return T}function $r(s){if(!s||!s.callee||!s.callee.name)return[null,"",""];var o=s.callee.toString(),u=s.callee.name,p="(",b=!0;for(var E in s){var T=s[E];b||(p+=", "),b=!1,typeof T=="number"||typeof T=="string"?p+=T:p+="("+typeof T+")"}p+=")";var I=s.callee.caller;return s=I?I.arguments:[],b&&(p=""),[s,u,p]}function oa(s){var o=Io(),u=o.lastIndexOf("_emscripten_log"),p=o.lastIndexOf("_emscripten_get_callstack"),b=o.indexOf(`
|
|
10
|
+
`,Math.max(u,p))+1;o=o.slice(b),s&32&&pe("EM_LOG_DEMANGLE is deprecated; ignoring"),s&8&&typeof emscripten_source_map=="undefined"&&(pe('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=$r(arguments);E[1].includes("_emscripten_");)E=$r(E[0]);var T=o.split(`
|
|
11
|
+
`);o="";var I=new RegExp("\\s*(.*?)@(.*?):([0-9]+):([0-9]+)"),S=new RegExp("\\s*(.*?)@(.*):(.*)(:(.*))?"),v=new RegExp("\\s*at (.*?) \\((.*):(.*):(.*)\\)");for(var H in T){var K=T[H],q="",Q="",W=0,te=0,j=v.exec(K);if(j&&j.length==5)q=j[1],Q=j[2],W=j[3],te=j[4];else if(j=I.exec(K),j||(j=S.exec(K)),j&&j.length>=4)q=j[1],Q=j[2],W=j[3],te=j[4]|0;else{o+=K+`
|
|
12
|
+
`;continue}var fe=!1;if(s&8){var g=emscripten_source_map.originalPositionFor({line:W,column:te});fe=g&&g.source,fe&&(s&64&&(g.source=g.source.substring(g.source.replace(/\\/g,"/").lastIndexOf("/")+1)),o+=" at "+q+" ("+g.source+":"+g.line+":"+g.column+`)
|
|
13
|
+
`)}(s&16||!fe)&&(s&64&&(Q=Q.substring(Q.replace(/\\/g,"/").lastIndexOf("/")+1)),o+=(fe?" = "+q:" at "+q)+" ("+Q+":"+W+":"+te+`)
|
|
14
|
+
`),s&128&&E[0]&&(E[1]==q&&E[2].length>0&&(o=o.replace(/\s+$/,""),o+=" with values: "+E[1]+E[2]+`
|
|
15
|
+
`),E=$r(E[0]))}return o=o.replace(/\s+$/,""),o}function aa(s,o){s&24&&(o=o.replace(/\s+$/,""),o+=(o.length>0?`
|
|
16
|
+
`:"")+oa(s)),s&1?s&4?ie(o):s&2?console.warn(o):s&512?console.info(o):s&256?console.debug(o):Ie(o):s&6?ie(o):Ie(o)}function ua(s,o,u){var p=ia(o,u),b=Lr(p,0);aa(s,b)}function ca(s,o,u){oe.copyWithin(s,o,o+u)}function la(s){try{return jt.grow(s-kr.byteLength+65535>>>16),gs(jt.buffer),1}catch(o){}}function da(s){var o=oe.length;s=s>>>0;var u=1073741824;if(s>u)return!1;for(var p=1;p<=4;p*=2){var b=o*(1+.2/p);b=Math.min(b,s+100663296);var E=Math.min(u,ao(Math.max(s,b),65536)),T=la(E);if(T)return!0}return!1}var Kr={};function ma(){return l||"./this.program"}function Ut(){if(!Ut.strings){var s=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",o={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:s,_:ma()};for(var u in Kr)Kr[u]===void 0?delete o[u]:o[u]=Kr[u];var p=[];for(var u in o)p.push(u+"="+o[u]);Ut.strings=p}return Ut.strings}var at={mappings:{},buffers:[null,[],[]],printChar:function(s,o){var u=at.buffers[s];o===0||o===10?((s===1?Ie:ie)(Lr(u,0)),u.length=0):u.push(o)},varargs:void 0,get:function(){at.varargs+=4;var s=M[at.varargs-4>>2];return s},getStr:function(s){var o=Rt(s);return o},get64:function(s,o){return s}};function pa(s,o){var u=0;return Ut().forEach(function(p,b){var E=o+u;M[s+b*4>>2]=E,oo(p,E),u+=p.length+1}),0}function _a(s,o){var u=Ut();M[s>>2]=u.length;var p=0;return u.forEach(function(b){p+=b.length+1}),M[o>>2]=p,0}function fa(s){return 0}function ha(s,o,u,p){var b=at.getStreamFromFD(s),E=at.doReadv(b,o,u);return M[p>>2]=E,0}function ba(s,o,u,p,b){}function ga(s,o,u,p){for(var b=0,E=0;E<u;E++){var T=M[o>>2],I=M[o+4>>2];o+=8;for(var S=0;S<I;S++)at.printChar(s,oe[T+S]);b+=I}return M[p>>2]=b,0}function Ea(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var s=new Uint8Array(1);return function(){return crypto.getRandomValues(s),s[0]}}else return function(){it("randomDevice")}}function Kt(s,o){Kt.randomDevice||(Kt.randomDevice=Ea());for(var u=0;u<o;u++)z[s+u>>0]=Kt.randomDevice();return 0}function Ta(s){var o=Date.now();return M[s>>2]=o/1e3|0,M[s+4>>2]=o%1e3*1e3|0,0}function Jt(s){return s%4===0&&(s%100!==0||s%400===0)}function Jr(s,o){for(var u=0,p=0;p<=o;u+=s[p++]);return u}var Xt=[31,29,31,30,31,30,31,31,30,31,30,31],Qt=[31,28,31,30,31,30,31,31,30,31,30,31];function zt(s,o){for(var u=new Date(s.getTime());o>0;){var p=Jt(u.getFullYear()),b=u.getMonth(),E=(p?Xt:Qt)[b];if(o>E-u.getDate())o-=E-u.getDate()+1,u.setDate(1),b<11?u.setMonth(b+1):(u.setMonth(0),u.setFullYear(u.getFullYear()+1));else return u.setDate(u.getDate()+o),u}return u}function Sa(s,o,u,p){var b=M[p+40>>2],E={tm_sec:M[p>>2],tm_min:M[p+4>>2],tm_hour:M[p+8>>2],tm_mday:M[p+12>>2],tm_mon:M[p+16>>2],tm_year:M[p+20>>2],tm_wday:M[p+24>>2],tm_yday:M[p+28>>2],tm_isdst:M[p+32>>2],tm_gmtoff:M[p+36>>2],tm_zone:b?Rt(b):""},T=Rt(u),I={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var S in I)T=T.replace(new RegExp(S,"g"),I[S]);var v=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],H=["January","February","March","April","May","June","July","August","September","October","November","December"];function K(g,N,B){for(var J=typeof g=="number"?g.toString():g||"";J.length<N;)J=B[0]+J;return J}function q(g,N){return K(g,N,"0")}function Q(g,N){function B(ge){return ge<0?-1:ge>0?1:0}var J;return(J=B(g.getFullYear()-N.getFullYear()))===0&&(J=B(g.getMonth()-N.getMonth()))===0&&(J=B(g.getDate()-N.getDate())),J}function W(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 te(g){var N=zt(new Date(g.tm_year+1900,0,1),g.tm_yday),B=new Date(N.getFullYear(),0,4),J=new Date(N.getFullYear()+1,0,4),ge=W(B),U=W(J);return Q(ge,N)<=0?Q(U,N)<=0?N.getFullYear()+1:N.getFullYear():N.getFullYear()-1}var j={"%a":function(g){return v[g.tm_wday].substring(0,3)},"%A":function(g){return v[g.tm_wday]},"%b":function(g){return H[g.tm_mon].substring(0,3)},"%B":function(g){return H[g.tm_mon]},"%C":function(g){var N=g.tm_year+1900;return q(N/100|0,2)},"%d":function(g){return q(g.tm_mday,2)},"%e":function(g){return K(g.tm_mday,2," ")},"%g":function(g){return te(g).toString().substring(2)},"%G":function(g){return te(g)},"%H":function(g){return q(g.tm_hour,2)},"%I":function(g){var N=g.tm_hour;return N==0?N=12:N>12&&(N-=12),q(N,2)},"%j":function(g){return q(g.tm_mday+Jr(Jt(g.tm_year+1900)?Xt:Qt,g.tm_mon-1),3)},"%m":function(g){return q(g.tm_mon+1,2)},"%M":function(g){return q(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 q(g.tm_sec,2)},"%t":function(){return" "},"%u":function(g){return g.tm_wday||7},"%U":function(g){var N=new Date(g.tm_year+1900,0,1),B=N.getDay()===0?N:zt(N,7-N.getDay()),J=new Date(g.tm_year+1900,g.tm_mon,g.tm_mday);if(Q(B,J)<0){var ge=Jr(Jt(J.getFullYear())?Xt:Qt,J.getMonth()-1)-31,U=31-B.getDate(),we=U+ge+J.getDate();return q(Math.ceil(we/7),2)}return Q(B,N)===0?"01":"00"},"%V":function(g){var N=new Date(g.tm_year+1900,0,4),B=new Date(g.tm_year+1901,0,4),J=W(N),ge=W(B),U=zt(new Date(g.tm_year+1900,0,1),g.tm_yday);if(Q(U,J)<0)return"53";if(Q(ge,U)<=0)return"01";var we;return J.getFullYear()<g.tm_year+1900?we=g.tm_yday+32-J.getDate():we=g.tm_yday+1-J.getDate(),q(Math.ceil(we/7),2)},"%w":function(g){return g.tm_wday},"%W":function(g){var N=new Date(g.tm_year,0,1),B=N.getDay()===1?N:zt(N,N.getDay()===0?1:7-N.getDay()+1),J=new Date(g.tm_year+1900,g.tm_mon,g.tm_mday);if(Q(B,J)<0){var ge=Jr(Jt(J.getFullYear())?Xt:Qt,J.getMonth()-1)-31,U=31-B.getDate(),we=U+ge+J.getDate();return q(Math.ceil(we/7),2)}return Q(B,N)===0?"01":"00"},"%y":function(g){return(g.tm_year+1900).toString().substring(2)},"%Y":function(g){return g.tm_year+1900},"%z":function(g){var N=g.tm_gmtoff,B=N>=0;return N=Math.abs(N)/60,N=N/60*100+N%60,(B?"+":"-")+("0000"+N).slice(-4)},"%Z":function(g){return g.tm_zone},"%%":function(){return"%"}};for(var S in j)T.includes(S)&&(T=T.replace(new RegExp(S,"g"),j[S](E)));var fe=Cs(T,!1);return fe.length>o?0:(hs(fe,s),fe.length-1)}function Ia(s,o,u,p){return Sa(s,o,u,p)}function ya(s){var o=Date.now()/1e3|0;return s&&(M[s>>2]=o),o}No(),xs=e.BindingError=Us(Error,"BindingError"),ko=e.InternalError=Us(Error,"InternalError"),qo();function Cs(s,o,u){var p=u>0?u:_s(s)+1,b=new Array(p),E=ms(s,b,0,b.length);return o&&(b.length=E),b}var Aa={g:yo,a:Ro,f:Oo,r:Po,n:Bo,A:Wo,l:jo,d:$o,c:Ko,m:Jo,i:Xo,o:Qo,e:zo,j:ta,b:ua,s:ca,t:da,x:pa,y:_a,z:fa,u:ha,q:ba,k:ga,v:Kt,h:Ta,w:Ia,p:ya},Fc=So(),Ra=e.___wasm_call_ctors=function(){return(Ra=e.___wasm_call_ctors=e.asm.C).apply(null,arguments)},va=e._CreateMediaProcessing=function(){return(va=e._CreateMediaProcessing=e.asm.D).apply(null,arguments)},Ua=e._ReleaseMediaProcessing=function(){return(Ua=e._ReleaseMediaProcessing=e.asm.E).apply(null,arguments)},xa=e._AddAudioChannel=function(){return(xa=e._AddAudioChannel=e.asm.F).apply(null,arguments)},Oa=e._DelAudioChannel=function(){return(Oa=e._DelAudioChannel=e.asm.G).apply(null,arguments)},Pa=e._AddVideoChannel=function(){return(Pa=e._AddVideoChannel=e.asm.H).apply(null,arguments)},Na=e._DelVideoChannel=function(){return(Na=e._DelVideoChannel=e.asm.I).apply(null,arguments)},Da=e._ReceivedRawAudioPacket=function(){return(Da=e._ReceivedRawAudioPacket=e.asm.J).apply(null,arguments)},Ca=e._ParseUdtMousePacket=function(){return(Ca=e._ParseUdtMousePacket=e.asm.K).apply(null,arguments)},wa=e._ReceivedAudioUdtPacket=function(){return(wa=e._ReceivedAudioUdtPacket=e.asm.L).apply(null,arguments)},Ma=e._ParseUdtAudioPacket=function(){return(Ma=e._ParseUdtAudioPacket=e.asm.M).apply(null,arguments)},La=e._ReceivedVideoPacket=function(){return(La=e._ReceivedVideoPacket=e.asm.N).apply(null,arguments)},ka=e._SetAudioBuffer10Ms=function(){return(ka=e._SetAudioBuffer10Ms=e.asm.O).apply(null,arguments)},Ba=e._SetAudioVolume=function(){return(Ba=e._SetAudioVolume=e.asm.P).apply(null,arguments)},Va=e._GetAudioFrame=function(){return(Va=e._GetAudioFrame=e.asm.Q).apply(null,arguments)},Fa=e._GetAudioFrameFloat=function(){return(Fa=e._GetAudioFrameFloat=e.asm.R).apply(null,arguments)},Ha=e._GetAudioMixed=function(){return(Ha=e._GetAudioMixed=e.asm.S).apply(null,arguments)},qa=e._GetAudioMixedFloat=function(){return(qa=e._GetAudioMixedFloat=e.asm.T).apply(null,arguments)},Wa=e._GetAudioEnergy=function(){return(Wa=e._GetAudioEnergy=e.asm.U).apply(null,arguments)},Ga=e._SetAudioFrameFormat=function(){return(Ga=e._SetAudioFrameFormat=e.asm.V).apply(null,arguments)},ja=e._SetAudioOutStreamFormat=function(){return(ja=e._SetAudioOutStreamFormat=e.asm.W).apply(null,arguments)},Ya=e._AudioProcess=function(){return(Ya=e._AudioProcess=e.asm.X).apply(null,arguments)},$a=e._AudioProcessFloat=function(){return($a=e._AudioProcessFloat=e.asm.Y).apply(null,arguments)},Ka=e._AudioReverseProcess=function(){return(Ka=e._AudioReverseProcess=e.asm.Z).apply(null,arguments)},Ja=e._AudioReverseProcessFloat=function(){return(Ja=e._AudioReverseProcessFloat=e.asm._).apply(null,arguments)},Xa=e._InitOpusEncoder=function(){return(Xa=e._InitOpusEncoder=e.asm.$).apply(null,arguments)},Qa=e._SetOpusEncBitrate=function(){return(Qa=e._SetOpusEncBitrate=e.asm.aa).apply(null,arguments)},za=e._OpusEncode=function(){return(za=e._OpusEncode=e.asm.ba).apply(null,arguments)},Za=e._UpdateStreamSync=function(){return(Za=e._UpdateStreamSync=e.asm.ca).apply(null,arguments)},eu=e._GetEncodedFrame=function(){return(eu=e._GetEncodedFrame=e.asm.da).apply(null,arguments)},tu=e._GetReceivedVideoStat=function(){return(tu=e._GetReceivedVideoStat=e.asm.ea).apply(null,arguments)},ru=e._CreateUdtPacketizer=function(){return(ru=e._CreateUdtPacketizer=e.asm.fa).apply(null,arguments)},nu=e._PacketizeVideoUdt=function(){return(nu=e._PacketizeVideoUdt=e.asm.ga).apply(null,arguments)},su=e._PacketizeAudioUdt=function(){return(su=e._PacketizeAudioUdt=e.asm.ha).apply(null,arguments)},iu=e._GetRetransPacket=function(){return(iu=e._GetRetransPacket=e.asm.ia).apply(null,arguments)},ou=e._CheckMissingPacket=function(){return(ou=e._CheckMissingPacket=e.asm.ja).apply(null,arguments)},au=e._UseAINS=function(){return(au=e._UseAINS=e.asm.ka).apply(null,arguments)},uu=e._EnableAEC=function(){return(uu=e._EnableAEC=e.asm.la).apply(null,arguments)},cu=e._SetCrypto=function(){return(cu=e._SetCrypto=e.asm.ma).apply(null,arguments)},Zt=e._malloc=function(){return(Zt=e._malloc=e.asm.oa).apply(null,arguments)},Fe=e._free=function(){return(Fe=e._free=e.asm.pa).apply(null,arguments)},ws=e.___errno_location=function(){return(ws=e.___errno_location=e.asm.qa).apply(null,arguments)},lu=e.___getTypeName=function(){return(lu=e.___getTypeName=e.asm.ra).apply(null,arguments)},du=e.___embind_register_native_and_builtin_types=function(){return(du=e.___embind_register_native_and_builtin_types=e.asm.sa).apply(null,arguments)},Ms=e.stackSave=function(){return(Ms=e.stackSave=e.asm.ta).apply(null,arguments)},Ls=e.stackRestore=function(){return(Ls=e.stackRestore=e.asm.ua).apply(null,arguments)},Xr=e.stackAlloc=function(){return(Xr=e.stackAlloc=e.asm.va).apply(null,arguments)},mu=e._emscripten_stack_init=function(){return(mu=e._emscripten_stack_init=e.asm.wa).apply(null,arguments)};e.ccall=ls,e.cwrap=eo,e.addFunction=Qi,e.removeFunction=zi;var er;function pu(s){this.name="ExitStatus",this.message="Program terminated with exit("+s+")",this.status=s}vt=function s(){er||Qr(),er||(vt=s)};function Qr(s){if(s=s||_,Xe>0||(lo(),Xe>0))return;function o(){er||(er=!0,e.calledRun=!0,!us&&(mo(),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),po()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),o()},1)):o()}if(e.run=Qr,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return Qr(),e.ready}}(),$i=kc;Yi($i);
|
package/index.d.ts
CHANGED
|
@@ -731,8 +731,6 @@ export declare const TRTCEvent: {
|
|
|
731
731
|
* // Guide user to click the page, SDK will resume playback automatically when user click the page.
|
|
732
732
|
* // Since v5.1.3+, you can get userId on this event.
|
|
733
733
|
* console.log(event.userId);
|
|
734
|
-
* // Since v5.9.0+, you can call the `resume` method to restore playback of the stream corresponding to event.userId.
|
|
735
|
-
* event.resume();
|
|
736
734
|
* });
|
|
737
735
|
*/
|
|
738
736
|
readonly AUTOPLAY_FAILED: 'autoplay-failed';
|
|
@@ -1109,7 +1107,6 @@ export declare interface TRTCEventTypes {
|
|
|
1109
1107
|
[TRTCEvent.ERROR]: [RtcError];
|
|
1110
1108
|
[TRTCEvent.AUTOPLAY_FAILED]: [{
|
|
1111
1109
|
userId: string;
|
|
1112
|
-
resume: () => Promise<void>;
|
|
1113
1110
|
}];
|
|
1114
1111
|
[TRTCEvent.KICKED_OUT]: [{
|
|
1115
1112
|
reason: Exclude<BannedReason, 'user_time_out'>;
|
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trtc-sdk-v5",
|
|
3
|
-
"version": "5.9.0-wasm.
|
|
3
|
+
"version": "5.9.0-wasm.13",
|
|
4
4
|
"description": "Tencent Cloud RTC SDK for Web",
|
|
5
|
-
"
|
|
5
|
+
"module": "trtc.esm.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"types": "index.d.ts",
|
|
7
|
-
"dependencies": {
|
|
8
|
-
"webrtc-adapter": "^8.2.3"
|
|
9
|
-
},
|
|
10
8
|
"keywords": [
|
|
11
9
|
"webrtc",
|
|
12
10
|
"TRTC",
|
|
@@ -29,4 +27,4 @@
|
|
|
29
27
|
},
|
|
30
28
|
"author": "Tencent Cloud Client R&D Center",
|
|
31
29
|
"license": "ISC"
|
|
32
|
-
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
interface CustomCryptors {
|
|
2
|
+
encryptor: Cryptor;
|
|
3
|
+
decryptor: Cryptor;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare const enum TRTCEncryptionAlgorithm {
|
|
7
|
+
Aes128Gcm = 'aes128gcm',
|
|
8
|
+
Aes256Gcm = 'aes256gcm'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type Cryptor = (data: Uint8Array) => Uint8Array;
|
|
12
|
+
interface BuiltinOptions {
|
|
13
|
+
algorithm: TRTCEncryptionAlgorithm;
|
|
14
|
+
secretKey: Uint8Array;
|
|
15
|
+
salt?: Uint8Array;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface EncryptionOptions {
|
|
19
|
+
// 自定义:传 customCryptors;内置:传后三个参数
|
|
20
|
+
customCryptors?: CustomCryptors;
|
|
21
|
+
builtinOptions?: BuiltinOptions;
|
|
22
|
+
mode: 'webrtc' | 'udt3';
|
|
23
|
+
audio: boolean;
|
|
24
|
+
video: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare class CustomEncryption {
|
|
28
|
+
start(options: EncryptionOptions): Promise<void>;
|
|
29
|
+
update(options: EncryptionOptions): Promise<void>;
|
|
30
|
+
stop(options: EncryptionOptions): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { CustomEncryption };
|
|
34
|
+
export default CustomEncryption;
|