@ylink-sdk/mobile-web 0.1.9-beta.1 → 0.1.9-beta.2
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/package.json +1 -1
- package/dist/e30037b8/VERSION +0 -6
- package/dist/e30037b8/libipvp-simd.d.ts +0 -474
- package/dist/e30037b8/libipvp-simd.js +0 -3267
- package/dist/e30037b8/libipvp-simd.prod.d.ts +0 -474
- package/dist/e30037b8/libipvp-simd.prod.js +0 -184
- package/dist/e30037b8/libipvp-simd.prod.wasm +0 -0
- package/dist/e30037b8/libipvp-simd.wasm +0 -0
- package/dist/e30037b8/libipvp.d.ts +0 -474
- package/dist/e30037b8/libipvp.js +0 -3267
- package/dist/e30037b8/libipvp.prod.d.ts +0 -474
- package/dist/e30037b8/libipvp.prod.js +0 -184
- package/dist/e30037b8/libipvp.prod.wasm +0 -0
- package/dist/e30037b8/libipvp.wasm +0 -0
- package/dist/e30037b8/librtc.d.ts +0 -438
- package/dist/e30037b8/librtc.global.js +0 -5863
- package/dist/e30037b8/librtc.global.prod.js +0 -15
- package/dist/e30037b8/libsfu-simd.d.ts +0 -767
- package/dist/e30037b8/libsfu-simd.js +0 -4822
- package/dist/e30037b8/libsfu-simd.prod.d.ts +0 -767
- package/dist/e30037b8/libsfu-simd.prod.js +0 -209
- package/dist/e30037b8/libsfu-simd.prod.wasm +0 -0
- package/dist/e30037b8/libsfu-simd.wasm +0 -0
- package/dist/e30037b8/libsfu.d.ts +0 -767
- package/dist/e30037b8/libsfu.js +0 -4822
- package/dist/e30037b8/libsfu.prod.d.ts +0 -767
- package/dist/e30037b8/libsfu.prod.js +0 -209
- package/dist/e30037b8/libsfu.prod.wasm +0 -0
- package/dist/e30037b8/libsfu.wasm +0 -0
- package/dist/e30037b8/libsvc-simd-m1.d.ts +0 -767
- package/dist/e30037b8/libsvc-simd-m1.js +0 -4921
- package/dist/e30037b8/libsvc-simd-m1.prod.d.ts +0 -767
- package/dist/e30037b8/libsvc-simd-m1.prod.js +0 -209
- package/dist/e30037b8/libsvc-simd-m1.prod.wasm +0 -0
- package/dist/e30037b8/libsvc-simd-m1.wasm +0 -0
- package/dist/e30037b8/libsvc-simd.d.ts +0 -767
- package/dist/e30037b8/libsvc-simd.js +0 -4857
- package/dist/e30037b8/libsvc-simd.prod.d.ts +0 -767
- package/dist/e30037b8/libsvc-simd.prod.js +0 -209
- package/dist/e30037b8/libsvc-simd.prod.wasm +0 -0
- package/dist/e30037b8/libsvc-simd.wasm +0 -0
- package/dist/e30037b8/libsvc.d.ts +0 -767
- package/dist/e30037b8/libsvc.js +0 -4857
- package/dist/e30037b8/libsvc.prod.d.ts +0 -767
- package/dist/e30037b8/libsvc.prod.js +0 -209
- package/dist/e30037b8/libsvc.prod.wasm +0 -0
- package/dist/e30037b8/libsvc.wasm +0 -0
- package/dist/e30037b8/native-audio-worker.global.js +0 -1583
- package/dist/e30037b8/native-audio-worker.global.prod.js +0 -15
- package/dist/e30037b8/native-video-worker.global.js +0 -1960
- package/dist/e30037b8/native-video-worker.global.prod.js +0 -15
- package/dist/e30037b8/worklet-audio-worker.global.js +0 -900
- package/dist/e30037b8/worklet-audio-worker.global.prod.js +0 -15
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var LIBRTC=function(e){"use strict";
|
|
2
|
-
/*! *****************************************************************************
|
|
3
|
-
Copyright (c) Microsoft Corporation.
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted.
|
|
7
|
-
|
|
8
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */function t(e,t,n,s){return new(n||(n=Promise))((function(i,o){function r(e){try{c(s.next(e))}catch(t){o(t)}}function a(e){try{c(s.throw(e))}catch(t){o(t)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}c((s=s.apply(e,t||[])).next())}))}var n,s,i;!function(e){e[e.kAudio=0]="kAudio",e[e.kVideo=1]="kVideo",e[e.kData=2]="kData"}(n||(n={}));class o{constructor(e){const{length:t,numberOfChannels:n=1,sampleRate:s}=e;let{data:i}=e;this.length=t,this.numberOfChannels=n,this.sampleRate=s,this.duration=t/s,i&&i.length&&i[0].length||(i=[...Array(n)].map((()=>new Float32Array(t)))),this.data=i}static From(e){const{sampleRate:t,numberOfChannels:n,length:s}=e,i=[...Array(n).keys()].map((t=>e.getChannelData(t).slice()));return new o({length:s,numberOfChannels:n,sampleRate:t,data:i})}static Copy(e,t){const{numberOfChannels:n}=e,{numberOfChannels:s}=t;for(let i=0;i<n;i++)e.copyToChannel(t.getChannelData(Math.min(i,s-1)),i)}static Clip(e,t,n){const{sampleRate:s,numberOfChannels:i}=e,r=o.Data(e,t,n),{length:a}=r[0];return new o({length:a,numberOfChannels:i,sampleRate:s,data:r})}static Data(e,t,n){return[...Array(e.numberOfChannels)].map(((s,i)=>e.getChannelData(i).subarray(t,n)))}static Builder(e){const{length:t,numberOfChannels:n,sampleRate:s}=e;return{length:t,numberOfChannels:n,sampleRate:s,data:o.Data(e)}}copyFromChannel(e,t=0,n=0){if(t>=this.numberOfChannels)return;const s=this.getChannelData(t);if(n>=s.length)return;const i=s.subarray(n);e.set(i.subarray(0,Math.min(i.length,e.length)))}copyToChannel(e,t=0,n=0){if(t>=this.numberOfChannels)return;const s=this.getChannelData(t);if(n>=this.length)return;const i=Math.min(this.length-n,e.length),o=e.subarray(0,i);s.set(o,n)}getChannelData(e){return this.data[e]}}!function(e){e[e.kVadActive=0]="kVadActive",e[e.kVadPassive=1]="kVadPassive",e[e.kVadUnknown=2]="kVadUnknown"}(s||(s={})),function(e){e[e.kNormalSpeech=0]="kNormalSpeech",e[e.kPLC=1]="kPLC",e[e.kCNG=2]="kCNG",e[e.kPLCCNG=3]="kPLCCNG",e[e.kCodecPLC=4]="kCodecPLC",e[e.kUndefined=5]="kUndefined"}(i||(i={}));class r{constructor(e){this.buffer=e.buffer,this.timestamp=e.timestamp,this.elapsedTimeMs=e.elapsedTimeMs,this.ntpTimeMs=e.ntpTimeMs,this.vad=e.vad||s.kVadUnknown,this.speech=e.speech||i.kUndefined}get sampleRate(){return this.buffer.sampleRate}get samples(){return this.buffer.length}get channels(){return this.buffer.numberOfChannels}get duration(){return this.buffer.duration}}function a(e,t=0,n,s=0,i=n.length){const{numberOfChannels:o}=e,{numberOfChannels:r}=n;for(let a=0;a<o;a++){const o=n.getChannelData(Math.min(a,r-1)).subarray(s,s+i);e.copyToChannel(o,a,t)}}class c{constructor(){this.queue=[],this.total=0,this.offset=0}get length(){return this.total}clear(){this.queue.length=0,this.total=0,this.offset=0}shift(){if(!this.total)return;return this.pull(this.queue[0].samples-this.offset)}push(e){const t=e=>{this.queue.push(e),this.total+=e.samples};if(!this.onpush)return void t(e);const{samples:n,callback:s,factory:i,reshape:c=!1}=this.onpush;let{reshaper:h}=this.onpush;for(c?(h||(h=function(e,t,n){let s,i=0;return c=>{const{samples:h,channels:l,sampleRate:d}=c;let u=0;for(;u<h;){const p=e-i,f=Math.min(h-u,p);p||(t(s),s=null),s||(s=n?n(e):new r({buffer:new o({length:e,numberOfChannels:l,sampleRate:d})}),i=0),a(s.buffer,i,c.buffer,u,f),u+=f,i+=f}}}(n,t,i),this.onpush.reshaper=h),h(e)):t(e);this.total-this.offset>=n;)s(c?this.shift():this.pull(n,i&&i(n)))}pull(e,t){if(e<=0)return;if(this.onpull){const{samples:t,callback:n,eager:s}=this.onpull;for(;this.total<Math.max(t,e)*(s?2:1);){const t=n(this.total,e);if(!t)break;this.queue.push(t),this.total+=t.samples}}if(this.total<e)return;let n=0,{offset:s}=this;for(;n<e;){const i=this.queue.shift(),c=i.samples-s,h=e-n,l=Math.min(c,h);if(c){if(!t&&!n&&c>=h){const e=o.Clip(i.buffer,s,s+h);t=new r({buffer:e}),c>h?(s+=l,this.queue.unshift(i)):s=0;break}if(!t){const n=new o({length:e,numberOfChannels:i.channels,sampleRate:i.sampleRate});t=new r({buffer:n})}if(a(t.buffer,n,i.buffer,s,l),n+=l,c>h){s+=l,this.queue.unshift(i);break}if(s=0,this.onpull){const{drain:e}=this.onpull;e&&e(i)}}}return this.total-=e,this.offset=s,t}}let h;class l{constructor(e=new AudioContext,t,n,s=e.destination){this.bufferPool=[],this.context=e,this.node=this.context.createScriptProcessor(h,n,n),this.processorBuffer=this.node.bufferSize,this.bufferSize=t||this.processorBuffer,this.channels=n,this.destination=s,this.inputBuffer=new c,this.outputBuffer=new c;const{sampleRate:i}=e;this.inputBuffer.onpush={samples:this.bufferSize,reshape:!0,factory:e=>{const t=this.bufferPool.shift();if(!t||t.buffer.length!==e){const t=new o({length:e,numberOfChannels:this.channels,sampleRate:i});return new r({buffer:t})}for(;this.bufferPool.length>4;)this.bufferPool.pop();return t},callback:e=>{this.onpush&&this.onpush(e)}},this.outputBuffer.onpull={samples:this.bufferSize,callback:()=>{if(this.onpull)return this.onpull(this.bufferSize,this.channels,i)},drain:e=>{this.bufferPool.push(e)}},this.node.onaudioprocess=e=>{const{inputBuffer:t,outputBuffer:n}=e;this.channels=t.numberOfChannels,this.inputBuffer.push(new r({buffer:t}));const s=new r({buffer:n});this.outputBuffer.pull(s.samples,s)?this.lastsample=o.Data(n).map((e=>e[e.length-1])):this.lastsample&&o.Data(n).forEach(((e,t)=>e.fill(this.lastsample[t])))}}static get PROCESSOR_BUFFER(){return h}static set PROCESSOR_BUFFER(e){h=e}haveCurrentData(e=this.outputBuffer.total){return e>this.processorBuffer}haveFutureData(e=this.outputBuffer.total){return e>2*this.processorBuffer}attach(e){this.source!==e&&(this.detach(),this.source=e,this.source.connect(this.node))}detach(){this.source&&(this.source.disconnect(this.node),this.source=null)}connect(e=this.destination){this.destination=e,this.node.connect(this.destination)}disconnect(){this.node.disconnect(this.destination)}resume(){"suspended"===this.context.state&&this.context.resume()}suspend(){"running"===this.context.state&&this.context.suspend()}}function d(e){return(n,s)=>{let i=-1;const o=o=>t(this,void 0,void 0,(function*(){if(o<=i)return;i=o;let t=e[o];return o===e.length&&(t=s),t?t.length>1?t(n,r):(yield t(n,r),r()):void 0})),r=()=>o(i+1);return r()}}class u{constructor(e,t){this.middleware=[],this.pipe=t||Math.random().toString(36).slice(3),this.channel=e}get valid(){return this.channel.has(this.pipe)}implement(e,n){const s=(s,i)=>t(this,void 0,void 0,(function*(){const{method:t,params:o,status:r,required:a,attached:c={}}=s.data;if(e!==t)return i();let h=!1;const l=[],d={},u=e=>{h||(h=!0,this.channel.send(Object.assign(Object.assign(Object.assign({},s.data),{params:void 0,attached:d}),e),l))},p={transfer:(...e)=>(a&&l.push(...e),p),resolve:e=>{a?u({resolve:e,status:r+1}):h=!0},reject:e=>{a?u({status:r-1,reject:e}):h=!0},set:(e,t)=>(a&&(d[e]=t),p),get:e=>c[e]};try{Date.now();yield n(p,o,s.ports)}catch(f){h||p.reject(`${f}`)}s.data.touched=!0,h||(yield i())}));this.middleware.unshift(s);return()=>{const e=this.middleware.findIndex((e=>e===s));~e&&this.middleware.splice(e,1)}}reject(e=""){this.channel.reject(this,e)}as(){return this}callback(){return(e,n)=>t(this,void 0,void 0,(function*(){const{pipe:t,status:s}=e.data;return t!==this.pipe||s?n():d(this.middleware)(e,n)}))}toString(){return`${this.pipe}`}}class p{constructor(e,t){this.sequence=0,this.pendings=new Map,this.pipe=t||Math.random().toString(36).slice(3),this.channel=e,this.accepted=f()}get ready(){return this.accepted.promise}get valid(){return this.channel.has(this.pipe)}make(e){const n=[],s={},i=e=>t(this,void 0,void 0,(function*(){try{yield this.ready}catch(e){throw e}})),o=(t,i)=>{this.channel.send({pipe:this.pipe,sequence:++this.sequence,timestamp:Date.now(),method:e,status:0,params:t,required:i,attached:s},n)},r={transfer:(...e)=>(n.push(...e),r),post:(...e)=>t(this,void 0,void 0,(function*(){yield i(),o(e)})),invoke:(...e)=>t(this,void 0,void 0,(function*(){yield i(),o(e,!0);const t=f();return this.pendings.set(this.sequence,t),t.promise})),set:(e,t)=>(s[e]=t,r),get:e=>s[e]};return r}break(e=""){this.channel.break(this,e),this.pendings.forEach((e=>e.reject("broken"))),this.pendings.clear(),this.accepted.reject("broken"),this.accepted.promise=Promise.reject("broken"),this.accepted.promise.catch(m)}callback(){return(e,n)=>t(this,void 0,void 0,(function*(){const{pipe:t,sequence:s,status:i,reject:o,resolve:r}=e.data;if(t!==this.pipe)return n();if(!i)return n();const a=this.pendings.get(s);a&&(i<0?a.reject(o):a.resolve(r),this.pendings.delete(s))}))}toString(){return`${this.pipe}`}}function f(){const e={};return e.promise=new Promise(((t,n)=>{e.resolve=t,e.reject=n})),e.promise.catch(m),e}const m=()=>{};class v{constructor(e){this.remotes=new Map,this.receivers=new Map,this.pendingReceivers=new Set;const t=e.onmessage;this.transport=e,this.transport.onmessage=e=>{const{data:n,ports:s=[]}=e;if(g(n)){if(/^mojo/.test(n)){const[,s]=n.split(":"),i=this.receivers.get(`${s}`);return i?(this.send(`accept:${i}`),this.oninvitation&&this.oninvitation(s,i),void(i.onready&&i.onready())):(this.pendingReceivers.add(s),this.oninvitation&&this.oninvitation(s),void(this.pendingReceivers.has(s)&&t&&t.call(this.transport,e)))}if(/^accept/.test(n)){const[,e]=n.split(":"),t=this.remotes.get(e);if(!t)return;return t.accepted.resolve(),void(t.onaccept&&t.onaccept())}if(/^reject/.test(n)){const[,e,t="rejected"]=n.split(":"),s=this.remotes.get(e);if(!s)return;return this.remotes.delete(e),s.accepted.reject(t),void(s.onreject&&s.onreject(t))}if(/^break/.test(n)){const[,e,t="breaked"]=n.split(":");if(this.pendingReceivers.has(e))return void this.pendingReceivers.delete(e);const s=this.receivers.get(e);if(!s)return;return this.receivers.delete(e),void(s.onbreak&&s.onbreak(t))}return t?void t.call(this.transport,e):void 0}const i={data:n,ports:s};d([...Array.from(this.remotes.values()).map((e=>e.callback())),...Array.from(this.receivers.values()).map((e=>e.callback()))])(i,(()=>{t&&t.call(this.transport,e)}))}}fork(){return new v(this.transport)}has(e){return this.remotes.has(e)||this.receivers.has(e)}close(){this.remotes.forEach((e=>e.break())),this.remotes.clear(),this.receivers.forEach((e=>e.reject())),this.receivers.clear(),this.transport.onmessage=null,this.transport=null}send(e,t){this.transport.postMessage(e,t)}reject(e,t=""){this.send(`reject:${e}:${t}`),this.receivers.delete(`${e}`)}break(e,t=""){this.remotes.has(`${e}`)&&(this.send(`break:${e}:${t}`),this.remotes.delete(`${e}`))}remote(e){const t=new p(this,e&&`${e}`);return this.remotes.set(`${t}`,t),this.send(`mojo:${t}`),t}receiver(e){e&&this.receivers.has(`${e}`);const t=new u(this,e&&`${e}`);return this.receivers.set(`${t}`,t),this.pendingReceivers.has(`${t}`)&&(this.send(`accept:${t}`),this.pendingReceivers.delete(`${t}`),t.onready&&t.onready()),t}}const g=e=>"string"==typeof e;let k="worklet-audio-worker.global.prod.js";class y{constructor(e=new AudioContext,t=2048,n=e.destination){this.context=e,this.bufferSize=t,this.channels=2,this.destination=n}static get WORKLET_URL(){return k}static set WORKLET_URL(e){k=e}init(e,n){return t(this,void 0,void 0,(function*(){const{context:s}=this;yield s.audioWorklet.addModule(k);const i=new AudioWorkletNode(s,"worklet-audio-transport"),a=new v(i.port);if(e){const i=()=>t(this,void 0,void 0,(function*(){const t=a.remote("worklet-audio-transport-host").make("setup");t.transfer(e),n&&t.transfer(n),yield t.invoke(this.sinkref)}));"running"===s.state?yield i():s.onstatechange=()=>{"running"===s.state&&(i(),s.onstatechange=null)}}else{const e=a.receiver("worklet-audio-processor-host");let n=0;e.implement("process",((e,[s])=>t(this,void 0,void 0,(function*(){const{onpush:t,onpull:i}=this;if(t){const e=new o(s);t(new r({buffer:e}))}const a=i&&i(s.length,s.numberOfChannels,s.sampleRate);if(n>0)return n--,void e.resolve();a?(s=o.Builder(a.buffer),e.transfer(...s.data.map((e=>e.buffer))).resolve(s)):e.resolve()})))),e.implement("processdelay",(e=>{n++,e.resolve()}))}this.node=i,this.channel=a}))}attach(e){this.detach(),this.source=e,this.source.connect(this.node)}detach(){this.source&&(this.source.disconnect(this.node),this.source=null)}connect(e=this.destination){this.destination=e,this.node.connect(this.destination)}disconnect(){this.node.disconnect(this.destination)}resume(){"suspended"===this.context.state&&this.context.resume()}suspend(){"running"===this.context.state&&this.context.suspend()}}function w(e,t,n){return Math.round(16+(65.738*e+129.057*t+25.064*n>>8))}function b(e,t,n){return Math.round(128+(-37.945*e-74.494*t+112.439*n>>8))}function E(e,t,n){return Math.round(128+(112.439*e-94.154*t-18.285*n>>8))}function O(e,t=0,n=255){return function(e,t,n){return Math.min(n,Math.max(t,e))}(e,t,n)}function S(e){let t=0,n=e>>1;for(;0!==n;)n>>=1,t++;if(e!==1<<t)throw Error(`chroma plane dimensions must be power of 2 ratio to luma plane dimensions; got ${e}`);return t}var x;!function(e){e[e.kNative=0]="kNative",e[e.kRGBA=1]="kRGBA",e[e.kABGR=2]="kABGR",e[e.kI420=3]="kI420",e[e.kI420A=4]="kI420A",e[e.kI444=5]="kI444"}(x||(x={}));class C{constructor(e){this.type=x.kNative,this.width=e.width,this.height=e.height,this.data=e.data,this.image=e}toI420(){const e=new R({width:this.width,height:this.height});return function(e,t){let n=0,s=0,i=0;const{dataY:o,dataU:r,dataV:a}=t,{width:c,height:h}=e,l=e.data;for(let d=0;d<h;d++)for(let e=0;e<c;e++){const t=d*c+e,h=255&l[4*t],u=255&l[4*t+1],p=255&l[4*t+2],f=w(h,u,p),m=b(h,u,p),v=E(h,u,p);o[n++]=O(f),d%2==0&&e%2==0&&(r[s++]=O(m),a[i++]=O(v))}}(this.image,e),e}getI420(){}getI420A(){}getI444(){}}class R{constructor(e){this.type=x.kI420,this.width=e.width,this.height=e.height,this.strideY=e.strideY||this.width,this.strideU=e.strideU||this.chromaWidth,this.strideV=e.strideV||this.chromaWidth;var t;this.data=!(e.dataY&&e.dataU&&e.dataV)&&function(e,t=64){return new ArrayBuffer(function(e,t=64){const n=e%t;return 0===n?e:e+t-n}(e,t))}(this.strideY*(t=this.height)+(this.strideU+this.strideV)*((t+1)/2)),this.dataY=e.dataY||new Uint8ClampedArray(this.data,0,this.strideY*this.height),this.dataU=e.dataU||new Uint8ClampedArray(this.data,this.strideY*this.height,this.strideU*this.chromaHeight),this.dataV=e.dataV||new Uint8ClampedArray(this.data,this.strideY*this.height+this.strideU*this.chromaHeight,this.strideV*this.chromaHeight)}get chromaWidth(){return Math.floor((this.width+1)/2)}get chromaHeight(){return Math.floor((this.height+1)/2)}toI420(){return this}getI420(){return this}getI420A(){}getI444(){}}class T{constructor(e){this.buffer=e.buffer}get width(){return this.buffer.width}get height(){return this.buffer.height}}let j=!1;"undefined"!=typeof document&&"undefined"!=typeof __INVISIBLE_SUSPEND__&&document.addEventListener("visibilitychange",(()=>{j="hidden"===document.visibilityState}));class P{constructor(){this.frameCounts=0,this.droppedFrameCounts=0,this.pending=!1}clear(){}render(e){}onFrame(e,t=!1){this.pending||j?this.droppedFrameCounts++:(t?this.render(e):requestAnimationFrame((()=>this.render(e))),requestAnimationFrame((()=>this.pending=!1)),this.pending=!0),this.frameCounts++}}class D{constructor(e,t){this.running=!1,this.working=!1,this.interval=0,this.times=0,this.config=e,this.backend=t||{setTimeout:setTimeout,clearTimeout:clearTimeout}}start(e=!0){return t(this,void 0,void 0,(function*(){this.running||(this.running=!0,yield L(this,e))}))}stop(){var e;this.running&&(this.timeout&&(clearTimeout(this.timeout),this.timeout=void 0),this.working&&(e=this).config.cancel&&e.config.cancel(),this.running=!1)}}function L(e,n=!0){return t(this,void 0,void 0,(function*(){const{interval:t=e.interval,work:s}=e.config;e.running&&(s&&n&&(e.working=!0,yield s(e.times++),e.working=!1),e.running&&(e.interval=A(t)?t(e.times):t,e.timeout=setTimeout(L,e.interval,e)))}))}const A=e=>"function"==typeof e;class N extends class{constructor(){this.sinks=new Set,this.framing=!1}addSink(e){this.sinks.has(e)||this.sinks.add(e),this.maybe()}removeSink(e){this.sinks.has(e)&&this.sinks.delete(e),this.maybe()}hasSink(e){return this.sinks.has(e)}get canstart(){return!!this.sinks.size}get canstop(){return!this.sinks.size}maybe(){!this.framing&&this.canstart&&(this.framing=!0,this.oncanstart&&this.oncanstart()),this.framing&&this.canstop&&(this.framing=!1,this.oncanstop&&this.oncanstop())}}{constructor(e,t=30){super(),this.frameRate=t,this.canvas=e,this.context=e.getContext("2d"),this.runner=new D({interval:()=>1e3/this.frameRate,work:()=>{if(!this.sinks.size)return;const e=this.capture();this.sinks.forEach((t=>t.onFrame(e)))}})}get playing(){return this.runner.running}pause(){this.runner.stop()}play(){this.runner.start()}capture(){const{width:e,height:t}=this.canvas,n=this.context.getImageData(0,0,I(e),I(t)),s=new C(n);return new T({buffer:s})}}function I(e){return e^1&e}class U extends P{constructor(e){super(),this.canvas=e,this.width=e.width,this.height=e.height,this.context=this.canvas.getContext("2d")}setSize(e,t){this.canvas.width=e,this.canvas.height=t,this.width=e,this.height=t}clear(){this.context.clearRect(0,0,this.width,this.height)}render(e){const{width:t,height:n,buffer:s}=e;let i;switch(t===this.width&&n===this.height||this.setSize(t,n),this.clear(),s.type){case x.kI420:i=this.context.createImageData(t,n),function(e,t,n=255){const{width:s,height:i,chromaWidth:o,chromaHeight:r,dataY:a,dataU:c,dataV:h,strideY:l,strideU:d,strideV:u}=e,p=t.data,f=0|S(s/o),m=0|S(i/r),v=s<<2;let g=0,k=0,y=0,w=0,b=0,E=0,O=0,x=0,C=0,R=0,T=0,j=0,P=0,D=0,L=0,A=0,N=0,I=0;if(1===f&&1===m)for(O=0,x=v,I=0,A=0;A<i;A+=2){for(k=A*l|0,y=k+l|0,w=I*d|0,b=I*u|0,L=0;L<s;L+=2)C=0|c[w++],R=0|h[b++],j=(409*R|0)-57088|0,P=(100*C|0)+(208*R|0)-34816|0,D=(516*C|0)-70912|0,T=298*a[k++]|0,p[O]=T+j>>8,p[O+1]=T-P>>8,p[O+2]=T+D>>8,p[O+3]=n,O+=4,T=298*a[k++]|0,p[O]=T+j>>8,p[O+1]=T-P>>8,p[O+2]=T+D>>8,p[O+3]=n,O+=4,T=298*a[y++]|0,p[x]=T+j>>8,p[x+1]=T-P>>8,p[x+2]=T+D>>8,p[x+3]=n,x+=4,T=298*a[y++]|0,p[x]=T+j>>8,p[x+1]=T-P>>8,p[x+2]=T+D>>8,p[x+3]=n,x+=4;O+=v,x+=v,I++}else for(E=0,A=0;A<i;A++)for(N=0,I=A>>m,g=A*l|0,w=I*d|0,b=I*u|0,L=0;L<s;L++)N=L>>f,C=0|c[w+N],R=0|h[b+N],j=(409*R|0)-57088|0,P=(100*C|0)+(208*R|0)-34816|0,D=(516*C|0)-70912|0,T=298*a[g++]|0,p[E]=T+j>>8,p[E+1]=T-P>>8,p[E+2]=T+D>>8,p[E+3]=n,E+=4}(s,i);break;case x.kABGR:i=s.toImage(this.context);break;case x.kNative:i=s.image;break;default:return}this.context.putImageData(i,0,0,0,0,t,n)}}class B extends N{constructor(e,n){if(super(document.createElement("canvas"),n||30),this.element=e,!1!==n){const e=()=>{this.runner.running||requestAnimationFrame((()=>t(this,void 0,void 0,(function*(){if(!this.sinks.size)return;const e=yield this.capture();this.sinks.forEach((t=>t.onFrame(e)))}))))},n=()=>{this.runner.start()},s=()=>{this.runner.stop()};this.element.addEventListener("canplaythrough",e),this.element.addEventListener("play",n),this.element.addEventListener("pause",s),this.element.addEventListener("ended",s),this.element.paused?this.element.readyState>2&&e():n()}}capture(){const{videoWidth:e,videoHeight:t}=this.element;return this.canvas.width=e,this.canvas.height=t,this.context.drawImage(this.element,0,0),super.capture()}}class W extends N{constructor(e,t){if(super(document.createElement("canvas"),t||30),this.element=document.createElement("video"),this.element.srcObject=e,this.element.muted=!0,this.stream=e,this.capturer=new ImageCapture(e.getVideoTracks()[0]),!1!==t){const e=()=>{this.runner.start()},t=()=>{this.runner.stop()};this.stream.addEventListener("active",e),this.stream.addEventListener("inactive",t),this.stream.active&&e()}}draw(){return t(this,void 0,void 0,(function*(){const{capturer:e,canvas:t,context:n}=this,{track:s}=e,i=yield this.capturer.grabFrame(),{width:o,height:r}=i;t.width=o,t.height=r,n.drawImage(i,0,0),i.close()}))}}class _ extends B{constructor(e,t){const n=document.createElement("video");if(n.srcObject=e,n.muted=!0,n.autoplay=!0,n.playsInline=!0,n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.width="1px",n.style.height="1px",n.style.zIndex="-1",super(n,t||30),this.element=n,this.stream=e,this.width=0,this.height=0,!1!==t){this.element.addEventListener("resize",(()=>{this.width=this.element.videoWidth,this.height=this.element.videoHeight,e()}));const e=()=>{this.width&&this.height&&(this.runner.start(),document.body.append(this.element))},t=()=>{this.runner.stop(),this.element.remove()};this.stream.addEventListener("active",e),this.stream.addEventListener("inactive",t),this.stream.active&&e()}}}function M(e,t,n){const s=e.createShader(t);return s?(e.shaderSource(s,n),e.compileShader(s),e.getShaderParameter(s,e.COMPILE_STATUS)?s:null):null}function F(e,t,n,s,i,o,r){const a={buffer:e.createBuffer(),location:-1,identifier:s,size:i,structure:o,count:r};switch(n){case"attribute":a.location=e.getAttribLocation(t,s);break;case"uniform":a.location=e.getUniformLocation(t,s)}return r&&(a.data=new Float32Array(r*i)),a}function V(e,t,n,s,i,o){const r={texture:e.createTexture(),textureId:i,location:e.getUniformLocation(t,s),identifier:s,unit:o};return e.activeTexture(i),e.bindTexture(e.TEXTURE_2D,r.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.uniform1i(r.location,o),r}function z(e,t,n){if(function(e){return!Number.isNaN(parseFloat(e))&&Number.isFinite(e)}(n))t.data[e*t.size]=n;else for(let s=n.length-1;s>=0;s--)t.data[e*t.size+s]=n[s]}function H(e,t,n,s,i){e.activeTexture(t.textureId),e.bindTexture(e.TEXTURE_2D,t.texture),e.texImage2D(e.TEXTURE_2D,0,e.LUMINANCE,s,i,0,e.LUMINANCE,e.UNSIGNED_BYTE,n);e.getError()}class $ extends P{constructor(e){super(),this.attributes=null,this.uniforms=null,this.textures=null,this.parameters={alpha:!0,antialias:!0,depth:!0,desynchronized:!0,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power",premultipliedAlpha:!0,preserveDrawingBuffer:!1,stencil:!0},this.canvas=e,this.width=e.width,this.height=e.height,this.gl=this.canvas.getContext("webgl"),this.gl.clearColor(0,0,0,0),this.gl.enable(this.gl.DEPTH_TEST),this.gl.depthFunc(this.gl.LEQUAL)}setSize(e,t){this.canvas.width=e,this.canvas.height=t,this.width=e,this.height=t,this.gl.viewport(0,0,e,t)}clear(){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT)}grab(){if(e=this.canvas,"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)return this.canvas.transferToImageBitmap();var e}dispose(){let e;(e=this.gl.getExtension("WEBGL_lose_context"))&&e.loseContext()}render(e){const{width:t,height:n,chromaHeight:s,dataY:i,dataU:o,dataV:r,strideY:a,strideU:c,strideV:h}=e.buffer;let l,d;this.gl.isContextLost()&&(this.gl=this.canvas.getContext("webgl")),t===this.width&&n===this.height||this.setSize(t,n),this.clear(),this.program||(this.program=function(e){const t=e.createProgram(),n=M(e,e.VERTEX_SHADER,"\nprecision mediump float;\n\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform vec2 uResolution;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void) {\n // convert the rectangle from pixels to 0.0 to 1.0\n vec2 zeroToOne = aVertexPosition / uResolution;\n \n // convert from 0 -> 1 to 0 -> 2\n vec2 zeroToTwo = zeroToOne * 2.0;\n \n // convert from 0 -> 2 to -1 -> +1 (clipspace)\n vec2 clipSpace = zeroToTwo - 1.0;\n\n gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);\n\n vTextureCoord = aTextureCoord;\n}\n"),s=M(e,e.FRAGMENT_SHADER,"\nprecision mediump float;\n\nuniform sampler2D uTextureY;\nuniform sampler2D uTextureU;\nuniform sampler2D uTextureV;\n\nvarying vec2 vTextureCoord;\n\nconst mat4 YUV2RGB = mat4( \n 1.1643828125, 0, 1.59602734375, -.87078515625,\n 1.1643828125, -.39176171875, -.81296875, .52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1\n);\n\nvoid main(void) {\n gl_FragColor = vec4(\n texture2D(uTextureY, vTextureCoord).x,\n texture2D(uTextureU, vTextureCoord).x,\n texture2D(uTextureV, vTextureCoord).x,\n 1\n ) * YUV2RGB;\n}\n");if(!t||!n||!s)return null;if(e.attachShader(t,n),e.attachShader(t,s),e.linkProgram(t),!e.getProgramParameter(t,e.LINK_STATUS))return e.getError(),e.getProgramParameter(t,e.VALIDATE_STATUS),null;return e.deleteShader(s),e.deleteShader(n),e.useProgram(t),t}(this.gl),this.attributes={position:F(this.gl,this.program,"attribute","aVertexPosition",2,"v2"),texcoord:F(this.gl,this.program,"attribute","aTextureCoord",2,"v2")},this.uniforms={resolution:F(this.gl,this.program,"uniform","uResolution",2,"2f",1)},this.textures={y:V(this.gl,this.program,0,"uTextureY",this.gl.TEXTURE0,0),u:V(this.gl,this.program,0,"uTextureU",this.gl.TEXTURE1,1),v:V(this.gl,this.program,0,"uTextureV",this.gl.TEXTURE2,2)});const u=0+t,p=0+n,f=new Float32Array([0,p,u,p,0,0,0,0,u,p,u,0]),m=t/a,v=new Float32Array([0,1,m,1,0,0,0,0,m,1,m,0]);Object.keys(this.attributes).forEach((e=>{switch(l=this.attributes[e],e){case"position":l.data=new Float32Array(f.length),z(0,l,f);break;case"texcoord":l.data=new Float32Array(v.length),z(0,l,v);break;default:return}!function(e,t){e.enableVertexAttribArray(t.location),e.bindBuffer(e.ARRAY_BUFFER,t.buffer),e.bufferData(e.ARRAY_BUFFER,t.data,e.STATIC_DRAW),e.vertexAttribPointer(t.location,t.size,e.FLOAT,!1,0,0)}(this.gl,l)})),z(0,this.uniforms.resolution,[t,n]);Object.keys(this.uniforms).forEach((e=>{l=this.uniforms[e],function(e,t){const n=t.location,s=t.data;switch(t.structure){case"2f":e.uniform2f(n,s[0],s[1]);break;case"2fv":e.uniform2fv(n,s);break;case"3f":e.uniform3f(n,s[0],s[1],s[2]);break;case"3fv":e.uniform3fv(n,s);break;case"4f":e.uniform4f(n,s[0],s[1],s[2],s[3]);break;case"4fv":e.uniform4fv(n,s)}}(this.gl,l)}));Object.keys(this.textures).forEach((e=>{switch(d=this.textures[e],e){case"y":H(this.gl,d,i,a,n);break;case"u":H(this.gl,d,o,c,s);break;case"v":H(this.gl,d,r,h,s)}})),this.gl.drawArrays(this.gl.TRIANGLES,0,f.length/2)}}var X,Y,J,G,K,Z,q,Q,ee,te,ne,se,ie,oe,re;(X=e.SFUTransportType||(e.SFUTransportType={}))[X.kAudio=1]="kAudio",X[X.kVideo=2]="kVideo",X[X.kData=3]="kData",X[X.kAnnotation=4]="kAnnotation",X[X.kMessage=5]="kMessage",function(e){e[e.kSend=1]="kSend",e[e.kRecv=2]="kRecv",e[e.kBoth=3]="kBoth"}(Y||(Y={})),(J=e.SFUUserRole||(e.SFUUserRole={}))[J.kInteractive=1]="kInteractive",J[J.kBroadcast=2]="kBroadcast",function(e){e[e.kOK=0]="kOK",e[e.kError=320200]="kError",e[e.kExisted=320201]="kExisted",e[e.kNetworkError=320202]="kNetworkError",e[e.kMCFailed=320203]="kMCFailed",e[e.kMSSFailed=320204]="kMSSFailed",e[e.kMSSLost=320205]="kMSSLost",e[e.kAuthFailed=320206]="kAuthFailed",e[e.kLoadFailed=320207]="kLoadFailed",e[e.kNoImplemented=320208]="kNoImplemented"}(G||(G={})),function(e){e[e.kReconnecting=320100]="kReconnecting",e[e.kReconnectOK=320101]="kReconnectOK",e[e.kReconnectNG=320102]="kReconnectNG"}(K||(K={})),function(e){e[e.kHandshakeOK=100]="kHandshakeOK",e[e.kHandshakeNG=101]="kHandshakeNG",e[e.kConnectOK=102]="kConnectOK",e[e.kConnectNG=103]="kConnectNG"}(Z||(Z={})),function(e){e[e.kSignal=0]="kSignal",e[e.kData=1]="kData"}(q||(q={})),function(e){e[e.kVeryfast=0]="kVeryfast",e[e.kUltrafast=1]="kUltrafast",e[e.kUltrafastPlus=2]="kUltrafastPlus"}(Q||(Q={})),function(e){e[e.kVideo=2]="kVideo",e[e.kData=3]="kData",e[e.kAnnotation=4]="kAnnotation",e[e.kMessage=5]="kMessage"}(ee||(ee={})),function(e){e[e.kInactive=0]="kInactive",e[e.kSend=1]="kSend",e[e.kRecv=2]="kRecv",e[e.kBoth=3]="kBoth"}(te||(te={})),function(e){e[e.kNormal=0]="kNormal",e[e.kSmooth=1]="kSmooth"}(ne||(ne={})),function(e){e[e.kRotation_0=0]="kRotation_0",e[e.kRotation_90=90]="kRotation_90",e[e.kRotation_180=180]="kRotation_180",e[e.kRotation_270=270]="kRotation_270"}(se||(se={})),(ie=e.DataType||(e.DataType={}))[ie.kCoopration=1]="kCoopration",ie[ie.kRemoteControl=2]="kRemoteControl",ie[ie.kSubtitleRealtime=3]="kSubtitleRealtime",ie[ie.kSubtitleRecord=4]="kSubtitleRecord",function(e){e[e.kCommon=0]="kCommon",e[e.kShareStart=1]="kShareStart",e[e.kShareEnd=2]="kShareEnd",e[e.kCoopStart=3]="kCoopStart",e[e.kCoopEnd=4]="kCoopEnd",e[e.kServiceOver=5]="kServiceOver"}(oe||(oe={})),function(e){e[e.kStart=0]="kStart",e[e.kChanging=1]="kChanging",e[e.kEnd=2]="kEnd"}(re||(re={}));class ae{constructor(e,t,n,s){this.nodes=new WeakMap,this.ssrc=e,this.engine=t,this.transport=n,this.dtmf=s}setParameters(e){}getParameters(){return null}setFrameEncryptor(e){}setSource(e){this.source=e;const{context:t}=this.transport,n=this.nodes.get(e)||(ce(e)?t.createMediaStreamSource(e):t.createMediaElementSource(e));if(this.transport.attach(n),this.transport.resume(),this.nodes.set(e,n),!ce(e)){const t=()=>this.transport.resume();e.paused&&e.addEventListener("play",t,{once:!0}),e.addEventListener("click",t,{once:!0}),this.cleanup=()=>{e.removeEventListener("play",t),e.removeEventListener("click",t)}}}getStats(){return t(this,void 0,void 0,(function*(){return this.engine.make("sendstats").invoke()}))}getStatsDetail(){return t(this,void 0,void 0,(function*(){return this.engine.make("sendstatsadv").invoke()}))}getStatsReport(){return t(this,void 0,void 0,(function*(){return this.engine.make("report").invoke()}))}stop(){this.transport.detach(),this.cleanup&&this.cleanup()}}function ce(e){return e instanceof MediaStream}const he=e=>"undefined"!==e,le=he(typeof AudioWorklet),de=he(typeof ImageCapture),ue=he(typeof RTCPeerConnection),pe=(()=>{try{const e=document.createElement("canvas");return!!e.getContext("webgl")}catch(e){return!1}})(),fe=(()=>{try{const e=document.createElement("canvas").getContext("webgl"),t=e.getExtension("WEBGL_debug_renderer_info"),n=e.getParameter(t.UNMASKED_RENDERER_WEBGL);return!!n.match(/Apple/)&&!n.match(/Apple GPU/)}catch(e){return!1}})(),me=he(typeof navigator),ve=he(typeof document),ge=(()=>me?navigator.userAgent.toLowerCase():"")(),ke=()=>/android/.test(ge),ye=()=>ke()&&/mobile/.test(ge),we=ke(),be=ye(),Ee=()=>/ipad.+?os (\d+)/.test(ge),Oe=()=>!Ee()&&/iphone(?:.+?os (\d+))?/.test(ge),Se=Ee(),xe=Oe(),Ce=(()=>/(?:firefox|fxios)\/(\d+)/.test(ge))(),Re=(()=>/version\/(\d+).+?safari/.test(ge))(),Te=(()=>/micromessenger\/(\d+)/.test(ge))(),je=(()=>/miniprogram\/(\d+)/.test(ge))()||he(typeof __wxjs_environment)&&"miniprogram"===__wxjs_environment,Pe=xe||Se,De=xe||be,Le=he(typeof importScripts),Ae=he(typeof wx)&&je,Ne=e=>{const t=wx.createWorker(e,{useExperimentalWorker:!0});return t.onMessage((e=>{t.onmessage&&t.onmessage({data:e})})),t},Ie=(e=>e=0!==e.indexOf("blob:")?e.substr(0,e.lastIndexOf("/")+1):"")((()=>Le?self.location.href:ve&&document.currentScript?document.currentScript.src:"")()),Ue=e=>!e||e.endsWith("/")?e:`${e}/`;let Be;const We=(e,t=Be||Ie)=>Ue(t)+e;class _e{constructor(e,t,n,s,i){this.ssrc=e,this.engine=t,this.transport=n,this.stream=s,this.element=i,this.start()}setParameters(e){}getParameters(){return null}setFrameDecryptor(e){}setSink(e){this.sink=e;let{stream:t}=this;if(!t){const e=this.transport.context.createMediaStreamDestination();this.transport.disconnect(),this.transport.connect(e),this.stream=t=e.stream}this.sink.srcObject=t,this.element&&(this.element.srcObject=null)}getStats(){return t(this,void 0,void 0,(function*(){return this.engine.make("recvstats").invoke(this.ssrc)}))}getStatsDetail(){return t(this,void 0,void 0,(function*(){return this.engine.make("recvstatsadv").invoke(this.ssrc)}))}getStatsReport(){return t(this,void 0,void 0,(function*(){return this.engine.make("report").invoke()}))}start(){if(this.transport.connect(),this.transport.resume(),ve){const e=()=>{this.sink&&this.sink.play(),this.transport.resume()};document.body.addEventListener("click",e,{once:!0}),this.cleanup=()=>document.body.removeEventListener("click",e)}}stop(){this.transport.disconnect(),this.cleanup&&this.cleanup()}}class Me{constructor(){this.m=new Map}reset(e){this.m=new Map(Object.entries(e))}has(e){return this.m.has(e)}get(e,t){const n=this.m.get(e);return void 0===n?t:n}set(e,t){this.m.set(e,t)}getBoolean(e,t=!1){const n=this.m.get(e);return void 0===n?!!this.m.has(e)||t:"false"!==n&&!!n}getNumber(e,t){const n=parseFloat(this.m.get(e));return Number.isNaN(n)?void 0!==t?t:NaN:n}}const Fe=new Me;function Ve(e={}){let t={};"undefined"!=typeof wx&&(t=wx.LIBRTC||t),"undefined"!=typeof window&&(t=window.LIBRTC||t),e=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e),function(e){try{const t=window.sessionStorage.getItem(e);return null!==t?JSON.parse(t):{}}catch(t){return{}}}("librtc-persist-config")),{persist:!1}),t.config),function(e){const t={};try{window.location.search.slice(1).split("&").map((e=>e.split("="))).reduce(((t,[n,s])=>((n=decodeURIComponent(n)).startsWith(e)&&(t[n.slice(e.length)]=void 0===s?s:decodeURIComponent(s)),t)),t)}catch(n){}return t}("librtc:")),Fe.reset(e)}const ze=!Ae,He=-1;class $e{constructor(e,t,s=new AudioContext){this.senders=new Map,this.receivers=new Map,this.stats={},this.cleanup=[],this.type=n.kAudio,this.transport=e,this.config=e.config,this.alloc=e.context.alloc,this.view=e.context.view,this.ssrc=e.config.ccid,this.track=0,this.description=this.alloc(2),this.factory=t,this.context=s,this.context.suspend(),this.transport.on("onjoin",(()=>{const{onopen:e}=this;e&&e()})),this.transport.on("onsendstats",(e=>{this.stats.send=e,this.encoder.make("fec").post(e.loss_rate)})),this.transport.on("onrecvstats",(e=>{this.stats.recv=e})),this.transport.on("onaudiosendstats",(e=>{this.stats.audiosend=e})),this.transport.on("onaudiorecvstats",(e=>{this.stats.audiorecv=e})),this.transport.on("ondata",((e,t,n,s,i)=>{if("running"!==this.context.state)return void("interrupted"===this.context.state&&this.context.resume());const o=this.view(e,t).slice();this.decoder.make("receive").transfer(o.buffer).post(n,o,i)}))}createSender(e=this.ssrc){let t=this.senders.get(e);if(!t){t=new ae(e,this.encoder,this.audioTransport,{get canInsertDtmf(){return!0},insertDtmf:e=>{this.encoder.make("dtmf").post(e)}}),this.senders.set(e,t)}return t}removeSender(e=this.ssrc){const t=this.senders.get(e);t&&(t.stop(),this.senders.delete(e)),this.senders.size||this.receivers.size||this.context.suspend()}createReceiver(e=-1){const t=this.receivers.get(e)||new _e(e,this.decoder,this.audioTransport,this.audioStream,this.audioElement);return this.receivers.set(e,t),this.transport.Subscribe([Xe(e,this.track,this.description)],[]),t}removeReceiver(e=-1){const t=this.receivers.get(e);t&&(t.stop(),this.receivers.delete(e),this.transport.Subscribe([],[Xe(e,this.track,this.description)])),this.senders.size||this.receivers.size||this.context.suspend()}addTrack(e){const t=Xe(He,e,this.description);this.transport.Subscribe([t],[])}removeTrack(e){const t=Xe(He,e,this.description);this.transport.Subscribe([],[t])}getStats(){return t(this,void 0,void 0,(function*(){const e=e=>t(this,void 0,void 0,(function*(){if(!e)return;const{loss_rate:t,rtt:n}=e,s=yield this.decoder.make("mos").invoke(t,n);e.mos=s}));return yield e(this.stats.send),yield e(this.stats.recv),this.stats}))}open(){return t(this,void 0,void 0,(function*(){const e=Fe.getBoolean("audioDedicatedWorker",ze),n=le&&Fe.getBoolean("audioWorklet",!Pe),s=ue&&Fe.getBoolean("builtinAEC",!Pe&&!we),i=e=>this.cleanup.push(e);if(yield Promise.all([(()=>t(this,void 0,void 0,(function*(){const[,e,t,n,s]=yield this.factory();t.implement("send",((e,[t,n])=>{if(t!==this.ssrc)return;const s=this.alloc(n.length);s.view().set(n);const i={channel:this.track,priority:0,key_flag:0,cursor_image_flag:0,timestamp:0};this.transport.SendData([s.tuple()],i),s.free(),e.resolve()})),n.implement("speaking",(e=>e.resolve())),n.implement("focusing",(e=>e.resolve())),n.implement("decodestart",(e=>e.resolve())),n.implement("decodestop",(e=>e.resolve())),n.implement("gainchange",(e=>e.resolve())),i(s),this.encoder=e})))(),(()=>t(this,void 0,void 0,(function*(){if(!e)return;const[,t,,n,s]=yield this.factory();n.implement("speaking",((e,[t,n])=>{t===this.ssrc&&(this.onspeaking&&this.onspeaking(n),e.resolve())})),n.implement("focusing",((e,[t,n])=>{t===this.ssrc&&(this.onfocusing&&this.onfocusing(n),e.resolve())})),n.implement("decodestart",((e,[t])=>{const n=this.receivers.get(He);n&&n.ondecodestart&&n.ondecodestart(t),e.resolve()})),n.implement("decodestop",((e,[t])=>{const n=this.receivers.get(He);n&&n.ondecodestop&&n.ondecodestop(t),e.resolve()})),n.implement("gainchange",((e,[t,n])=>{const s=this.receivers.get(He);s&&s.ongainchange&&s.ongainchange(t,n),e.resolve()})),i(s),this.decoder=t})))()]),e||(this.decoder=this.encoder),i((()=>this.context.close())),n){const t=new MessageChannel,n=new MessageChannel,i=new y(this.context);i.sinkref=!s&&Fe.getNumber("aecLevel",1)>0,yield i.init(t.port1,e?n.port1:void 0),e?yield Promise.all([this.encoder.make("setup").transfer(t.port2).invoke(this.ssrc,this.context.sampleRate,1),this.decoder.make("setup").transfer(n.port2).invoke(this.ssrc,this.context.sampleRate,2)]):this.encoder.make("setup").transfer(t.port2).invoke(this.ssrc,this.context.sampleRate,3),this.audioTransport=i}else{l.PROCESSOR_BUFFER=Fe.getNumber("audioBuffer");const{sampleRate:t}=this.context,n=1,i=new l(this.context,t/100*3,n),a=e=>{const t=o.Builder(e.buffer);this.encoder.make("push").transfer(...t.data.map((e=>e.buffer))).post(t)},c=[],h=e=>{i.haveFutureData(c.length*e)||this.decoder.make("pull").invoke(e,n,t).then((e=>{if(!e)return;const t=new o(e),n=new r({buffer:t});c.push(n)}))};i.onpush=e=>{a(e),h(e.samples)},i.onpull=()=>{const t=c.shift();if(e&&t&&!s&&Fe.getNumber("aecLevel",1)>0){const e=o.From(t.buffer);this.encoder.make("pushref").transfer(...e.data.map((e=>e.buffer))).post(e)}return t},e?yield Promise.all([this.encoder.make("setup").invoke(this.ssrc,t,1),this.decoder.make("setup").invoke(this.ssrc,t,2)]):this.encoder.make("setup").invoke(this.ssrc,t,3),this.audioTransport=i}if(s){const e=this.context.createMediaStreamDestination(),[n,s]=yield function(e){return t(this,void 0,void 0,(function*(){const t=new RTCPeerConnection,n=new RTCPeerConnection,s=new MediaStream;t.onicecandidate=({candidate:e})=>{e&&n.addIceCandidate(e)},n.onicecandidate=({candidate:e})=>{e&&t.addIceCandidate(e)},n.ontrack=({streams:e})=>{e[0].getTracks().forEach((e=>s.addTrack(e)))},e.getTracks().forEach((n=>t.addTrack(n,e)));const i=yield t.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1});t.setLocalDescription(i),n.setRemoteDescription(i);const o=yield n.createAnswer();return n.setLocalDescription(o),t.setRemoteDescription(o),[s,()=>{t.close(),n.close()}]}))}(e.stream);this.audioStream=n,this.audioElement=new Audio,this.audioElement.srcObject=n,this.audioElement.play().catch((()=>{const e=()=>this.audioTransport.resume();document.body.addEventListener("click",e,{once:!0}),i((()=>document.body.removeEventListener("click",e)))})),this.audioTransport.destination=e,i((()=>s()))}this.transport.Connect({feature:0,orient:Y.kBoth,target_incoming_bitrate:0,target_outgoing_bitrate:0,desc:[0,0]}),i((()=>this.transport.Disconnect())),i((()=>this.transport.off("ondata"))),i((()=>this.context.suspend())),i((()=>{this.audioTransport.detach(),this.audioTransport.disconnect()})),Fe.getBoolean("builtinANS",!0)&&this.encoder.make("ans").post(Fe.getNumber("ansLevel",2)),s||this.encoder.make("aec").post(Fe.getNumber("aecLevel",1))}))}close(){return t(this,void 0,void 0,(function*(){let e;for(;e=this.cleanup.pop();)try{yield e()}catch(t){}this.description.free(),this.transport.delete(),this.transport=null,this.onclose&&this.onclose()}))}ans(e){this.encoder.make("ans").post(e?2:0)}dsp(){return Promise.all([this.encoder.make("micschedule").invoke(),this.decoder.make("spkschedule").invoke()])}trackgain(e,t=this.track){this.decoder.make("trackgain").post(e,t)}}function Xe(e,t,n){return n.view().set([65280&t,255&t]),{ccid:e,desc:n.tuple()}}const Ye=(e=>{let t;return(...n)=>(t||(t=e()),t(...n))})((()=>function(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const s=Ze(n);return(e,n)=>s.then((s=>n(s.transaction(t,e).objectStore(t))))}("LINE-UI","key-value")));function Je(e,t=Ye){return t("readonly",(t=>Ze(t.get(e))))}function Ge(e,t,n=Ye){return n("readwrite",(n=>(n.put(t,e),Ze(n.transaction))))}function Ke(e=Ye){return e("readwrite",(e=>(e.clear(),Ze(e.transaction))))}function Ze(e){return new Promise(((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)}))}const qe=e=>t(void 0,void 0,void 0,(function*(){try{return yield e()}catch(t){}})),Qe=e=>t(void 0,void 0,void 0,(function*(){let t=yield Je(e);return t||(t=yield fetch(e).then((e=>e.arrayBuffer())),yield Ge(e,t)),t})),et="native-audio-worker.global.prod.js";let tt="libipvp.prod.js";class nt{init(){return t(this,void 0,void 0,(function*(){tt=tt.replace(/-simd/,""),Fe.getBoolean("simd")&&(tt=tt.replace(/[^.]+/,(e=>`${e}-simd`))),Ae||(yield qe((()=>t(this,void 0,void 0,(function*(){const e=We(tt.replace(/\.js$/,".wasm"));yield Qe(e),yield Qe(We(et))})))))}))}createChannel(e){return new $e(e,(()=>t(this,void 0,void 0,(function*(){let e,n=We(et,Fe.get("workerDir"));const s=Ae?null:yield Je(n).catch((()=>null));s&&(n=URL.createObjectURL(new Blob([s],{type:"application/javascript"})),e=!0);const i=Ae?Ne(n):new Worker(n),o=new v(i),r=o.remote("audio-engine-host"),a=o.receiver(),c=o.receiver(),h=Fe.getBoolean("verbose",!1);yield r.make("init").invoke(Ae?`./${tt}?${Fe.get("scriptDir","")}`:We(tt),`${a}`,`${c}`,h).catch((e=>{throw i.terminate(),e}));return[o,r,a,c,()=>t(this,void 0,void 0,(function*(){a.reject(),c.reject(),yield r.make("exit").invoke().catch(st),o.close(),i.terminate(),e&&URL.revokeObjectURL(n)}))]}))))}}const st=()=>{},it="HEAPU8";let ot=!1;function rt(){return t(this,void 0,void 0,(function*(){if(ot)return;let e;var n;Ve(),Fe.has(e="scriptDir")&&(n=Fe.get(e),Be=Ue(n));let s=We(y.WORKLET_URL);Ae||(yield qe((()=>t(this,void 0,void 0,(function*(){const e=yield Qe(s);s=URL.createObjectURL(new Blob([e],{type:"application/javascript"}))}))))),y.WORKLET_URL=s;const i=Fe.get("simdTrials",["AtKvAUzMJdGnBhp8lsmrGyXZwxkVP7SQ/5/nIe+wGNgJWxEgFT2rlkR/c2VDMnreKsW85BS2KUmK3nbyIwyrYg8AAAByeyJvcmlnaW4iOiJodHRwczovL21lZXRpbmdzLm9ueWVhbGluay5jb206NDQzIiwiZmVhdHVyZSI6IldlYkFzc2VtYmx5U2ltZCIsImV4cGlyeSI6MTY0OTgwNzk5OSwiaXNTdWJkb21haW4iOnRydWV9","AscoD9kPREl3eR5O/0pNLObxrgAn+T7WuycKRuY14Jg29ePvE8kJUQ2Cxs9aNm9DY/lHRX03x5xu2DDX8L6YwwoAAAB3eyJvcmlnaW4iOiJodHRwczovL21lZXRpbmdzLWludGwub255ZWFsaW5rLmNvbTo0NDMiLCJmZWF0dXJlIjoiV2ViQXNzZW1ibHlTaW1kIiwiZXhwaXJ5IjoxNjQ5ODA3OTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZX0=","AjICxd1SB8/eYwysXZv9lMNOkdBZlWWrkskmG76eykcE5+q0EHeTK4I3YjVULxW4MMRb72BoE4oNIVZa1j23FA4AAABueyJvcmlnaW4iOiJodHRwczovL21lZXRpbmdzLnlseXVuLmNvbTo0NDMiLCJmZWF0dXJlIjoiV2ViQXNzZW1ibHlTaW1kIiwiZXhwaXJ5IjoxNjQ5ODA3OTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZX0=","Aoegi1xVWRBa5p3dfujWOaPpD7+z41Yi/R0mNxGJugtQP5WL+WzNrDWgkDL1F3gg5GphoxMJqp/xv/Mx0wYNNgQAAAB3eyJvcmlnaW4iOiJodHRwczovL21lZXRpbmdzLnllYWxpbmttZWV0aW5nLmNvbTo0NDMiLCJmZWF0dXJlIjoiV2ViQXNzZW1ibHlTaW1kIiwiZXhwaXJ5IjoxNjQ5ODA3OTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZX0="].join()).split(",");Ae||i.forEach((e=>{const t=document.createElement("meta");t.httpEquiv="origin-trial",t.content=e,document.head.appendChild(t)})),Fe.has(e="libsfu")||"undefined"==typeof LIBSVC||Fe.m.set(e,LIBSVC),Fe.has(e="protobuf")||"undefined"==typeof protobuf||Fe.m.set(e,protobuf),Fe.has(e="simd")||Fe.m.set(e,!Ae&&(yield(async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11])))())),Fe.has(e="threads")||Fe.m.set(e,!Ae&&(yield(async e=>{try{return"undefined"!=typeof MessageChannel&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch(e){return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))),Ae||(yield qe((()=>t(this,void 0,void 0,(function*(){((yield Je("hash"))!==Ie||Fe.get("clean",!1))&&(yield Ke(),yield Ge("hash",Ie))}))))),ot=!0}))}let at,ct,ht,lt,dt="libsfu.prod.js";class ut{constructor(e,t){this.dtmf=null,this.running=!1,this.ssrc=e,this.encoder=t,this.channel=t.channel,this.parameters={width:640,height:360,frameRate:30}}setParameters(e){const{frameRate:t}=e;t&&(this.encoder.make("setframerate").post(t),this.parameters.frameRate=t)}getParameters(){return this.parameters}setFrameEncryptor(e){}setSource(e){let n;this.source=e,n=e instanceof MediaStream?de&&Fe.getBoolean("imageCapture",!Te)?new W(e,!1):new _(e,!1):new B(e,!1);const s=this.channel.receiver(),i=n instanceof W;let o=Promise.resolve();const r=Fe.getBoolean("elementVisible",Re||Pe),a=()=>{o=Promise.resolve(),i&&h(),n instanceof _&&r&&(document.body.append(n.element),n.element.play()),this.running=!0},c=()=>{o=Promise.reject(),o.catch((()=>{})),n instanceof _&&r&&n.element.remove(),this.running=!1},h=()=>t(this,void 0,void 0,(function*(){try{yield o,yield l(),h()}catch(e){this.running=!1,e&&console.warn(e)}})),l=()=>t(this,void 0,void 0,(function*(){yield n.draw();const e=n.capture(),{type:t,width:s,height:i,data:o}=e.buffer;t!==x.kNative&&t!==x.kABGR||(yield this.encoder.make("encode").transfer(o.buffer).invoke({width:s,height:i,data:o}))}));s.onbreak=()=>c(),s.implement("onstart",(e=>{a(),e.resolve(),this.onstart&&this.onstart()})),s.implement("onstop",(e=>{c(),e.resolve(),this.onstop&&this.onstop()})),s.implement("onbusy",((e,[t])=>{e.resolve(),this.onbusy&&this.onbusy(t)})),s.implement("capture",(e=>{const t=n.capture(),{type:s,width:i,height:o,data:r}=t.buffer;s!==x.kNative&&s!==x.kABGR?e.resolve():e.transfer(r.buffer).resolve({width:i,height:o,data:r})})),i&&s.implement("capture",(e=>e.resolve())),this.encoder.make("setsource").invoke(`${s}`,...[0].filter((()=>i))).then((e=>{e&&a(),this.running=e})),!i&&Fe.has("framerate")&&this.encoder.make("setframerate").post(Fe.getNumber("framerate",this.parameters.frameRate))}stop(){this.encoder.make("setsource").post()}getStats(){return this.encoder.make("sendstats").invoke()}getStatsDetail(){return this.encoder.make("sendreport").invoke()}}class pt{constructor(e,t){this.loadeddata=!1,this.ssrc=e,this.decoder=t,this.channel=t.channel,this.parameters={width:160,height:90},this.start()}setParameters(e){this.decoder.make("subscribe").post([Object.assign({ccid:this.ssrc},e)],[]),this.parameters=Object.assign({},e)}getParameters(){return this.parameters}setFrameDecryptor(e){}setSink(e,t=pe){if(this.sink=e,!e)return void this.decoder.make("setsink").post(this.ssrc);const n=this.channel.receiver(),s=[e];if(n.implement("onloadeddata",(e=>{e.resolve(),this.onloadeddata&&this.onloadeddata(),this.loadeddata=!0})),n.implement("onframechanged",((e,[t,n])=>{e.resolve(),this.width=t,this.height=n,this.onframechanged&&this.onframechanged(t,n)})),"number"!=typeof e){s.pop();const i=pe&&t?new $(e):new U(e);n.implement("onframe",((e,[t])=>{e.resolve();const n=new R(t);i.onFrame(new T({buffer:n}),!0)})),n.onbreak=()=>i.clear()}this.decoder.make("setsink").post(this.ssrc,`${n}`,...s)}start(){this.setParameters(this.parameters)}stop(){this.decoder.make("subscribe").post([],[this.ssrc]),this.decoder.make("setsink").post(this.ssrc),this.loadeddata=!1}getStats(){return this.decoder.make("recvstats").invoke(this.ssrc)}getStatsDetail(){return this.decoder.make("recvreport").invoke(this.ssrc)}}class ft{constructor(t,s){this.senders=new Map,this.receivers=new Map,this.stats={},this.cleanup=[],this.type=t.type===e.SFUTransportType.kVideo?n.kVideo:n.kData,this.transport=t,this.config=t.config,this.alloc=t.context.alloc,this.view=t.context.view,this.offscreen={load:(e,t)=>this.decoder.make("load").transfer(e).invoke(e,t),unload:e=>this.decoder.make("unload").invoke(e)},this.factory=s,this.transport.on("onjoin",((e,t,n)=>{const s=this.view(t,n).slice();this.encoder.make("onjoin").post(e,s),this.decoder.make("onjoin").transfer(s.buffer).post(e,s)})),this.transport.on("onleave",(e=>{this.encoder.make("onleave").post(e),this.decoder.make("onleave").post(e)})),this.transport.on("onstatus",((e,t)=>{this.encoder.make("onstatus").post(e,t),this.decoder.make("onstatus").post(e,t)})),this.transport.on("onsubscribe",((e,t,n,s)=>{const i=this.view(n,s).slice();this.decoder.make("onsubscribe").transfer(i.buffer).post(e,t,i);const o=this.receivers.get(e);o&&(t===G.kOK?o.onready&&o.onready():t===G.kError&&o.onfailed&&o.onfailed())})),this.transport.on("onsubscribeupdated",(e=>{this.encoder.make("onsubscribeupdated").post(e)})),this.transport.on("onbitrate",(e=>{this.encoder.make("onbitrate").post(e)})),this.transport.on("onsendstats",(e=>{this.stats.send=e,this.encoder.make("onsendstats").post(e)})),this.transport.on("onrecvstats",(e=>{this.stats.recv=e,this.decoder.make("onrecvstats").post(e)})),this.transport.on("onsendreport",(e=>{this.encoder.make("onsendreport").post(e)})),this.transport.on("ontimestamps",(()=>{this.decoder.make("ontimestamps").post()})),this.transport.on("onmediasync",(e=>{this.decoder.make("onmediasync").post(e)})),this.transport.on("onsignal",((e,t)=>{const n=this.view(e,t).slice();this.encoder.make("onsignal").transfer(n.buffer).post(n)})),this.transport.on("ondata",((e,t,n,s)=>{const i=this.view(e,t).slice();this.decoder.make("ondata").transfer(i.buffer).post(i,n,s)}))}createSender(e){const t=this.senders.get(e=e||this.transport.config.ccid)||new ut(e,this.encoder);return this.senders.set(e,t),mt(this),t}removeSender(e){const t=this.senders.get(e=e||this.transport.config.ccid);t&&(t.stop(),this.senders.delete(e)),mt(this)}createReceiver(e){const t=this.receivers.get(e)||new pt(e,this.decoder);return this.receivers.set(e,t),mt(this),t}removeReceiver(e){const t=this.receivers.get(e);t&&(t.stop(),this.receivers.delete(e)),mt(this)}getStats(){return t(this,void 0,void 0,(function*(){return this.stats}))}open(s){return t(this,void 0,void 0,(function*(){s=Object.assign({mode:ne.kNormal,max_width:this.type===n.kData?1920:640,max_height:this.type===n.kData?1080:360},s);const i=e=>this.cleanup.push(e),o=e=>{e.implement("connect",((e,[t])=>{const n=this.alloc(t.desc.length);n.view().set(t.desc),this.transport.Connect(Object.assign(Object.assign({},t),{desc:[n.pointer,n.bytes]})),n.free(),e.resolve()})),e.implement("disconnect",(e=>{this.transport.Disconnect(),e.resolve()})),e.implement("subscribe",((e,[t,n])=>{const s=[];this.transport.Subscribe(t.map((e=>{const t=this.alloc(e.desc.length);return t.view().set(e.desc),s.push(t),Object.assign(Object.assign({},e),{desc:t.tuple()})})),n.map((e=>({ccid:e,desc:[0,0]})))),s.forEach((e=>e.free())),e.resolve()})),e.implement("senddata",((e,[t,n])=>{const s=[];this.transport.SendData(t.map((e=>{const t=this.alloc(e.length);return t.view().set(e),s.push(t),t.tuple()})),n),s.forEach((e=>e.free())),e.resolve()})),e.implement("sendsignal",((e,[t,n])=>{const s=this.alloc(t.length);s.view().set(t),this.transport.SendSingal(s.pointer,s.bytes,n),s.free(),e.resolve()}))};yield Promise.all([(()=>t(this,void 0,void 0,(function*(){const[e,t,n]=yield this.factory(),s=e.receiver();o(s),i(n);const r=yield t.make("setup").invoke(`${s}`,this.transport.type);this.encoder=e.remote(r),i((()=>this.encoder.break())),i((()=>s.reject()))})))(),(()=>t(this,void 0,void 0,(function*(){const[t,n,s]=yield this.factory(),r=t.receiver();o(r),r.implement("connect",(e=>e.resolve())),r.implement("disconnect",(e=>e.resolve())),i(s);const a=yield n.make("setup").invoke(`${r}`,this.transport.type);if(this.decoder=t.remote(a),i((()=>this.decoder.break())),i((()=>r.reject())),ve&&this.transport.type!==e.SFUTransportType.kData){const e=()=>{"hidden"===document.visibilityState?n.make("suspend").post():n.make("resume").post()};document.addEventListener("visibilitychange",e),i((()=>document.removeEventListener("visibilitychange",e)))}})))()]),Fe.getBoolean("ultrafast",De)&&this.encoder.make("mode").post(Q.kUltrafastPlus),yield Promise.all([this.encoder.make("open").invoke(Object.assign(Object.assign({orient:te.kInactive},this.config),s)),this.decoder.make("open").invoke(Object.assign(Object.assign({orient:te.kInactive},this.config),s))]),i((()=>this.transport.Disconnect())),i((()=>this.transport.off("ondata"))),this.onopen&&this.onopen()}))}close(){return t(this,void 0,void 0,(function*(){let e;for(;e=this.cleanup.pop();)try{yield e()}catch(t){}this.transport.delete(),this.transport=null,this.onclose&&this.onclose()}))}}function mt(e){const{senders:t,receivers:n,encoder:s,decoder:i}=e,o=!!t.size,r=!!n.size,a=o&&r?te.kBoth:o?te.kSend:r?te.kRecv:te.kInactive;s.make("setorient").post(a),i.make("setorient").post(a)}const vt={8:65288,13:65293,16:65505,17:65507,18:65513,91:65515,93:65516,19:65299,27:65307,33:65365,34:65366,35:65367,36:65360,37:65361,38:65362,39:65363,40:65364,44:65377,45:65379,46:65535,9:65289,112:65470,113:65471,114:65472,115:65473,116:65474,117:65475,118:65476,119:65477,120:65478,121:65479,122:65480,123:65481},gt=[[417,260],[418,728],[419,321],[421,317],[422,346],[425,352],[426,350],[427,356],[428,377],[430,381],[431,379],[433,261],[434,731],[435,322],[437,318],[438,347],[439,711],[441,353],[442,351],[443,357],[444,378],[445,733],[446,382],[447,380],[448,340],[451,258],[453,313],[454,262],[456,268],[458,280],[460,282],[463,270],[464,272],[465,323],[466,327],[469,336],[472,344],[473,366],[475,368],[478,354],[480,341],[483,259],[485,314],[486,263],[488,269],[490,281],[492,283],[495,271],[496,273],[497,324],[498,328],[501,337],[504,345],[505,367],[507,369],[510,355],[511,729],[673,294],[678,292],[681,304],[683,286],[684,308],[689,295],[694,293],[697,305],[699,287],[700,309],[709,266],[710,264],[725,288],[728,284],[733,364],[734,348],[741,267],[742,265],[757,289],[760,285],[765,365],[766,349],[930,312],[931,342],[933,296],[934,315],[938,274],[939,290],[940,358],[947,343],[949,297],[950,316],[954,275],[955,291],[956,359],[957,330],[959,331],[960,256],[967,302],[972,278],[975,298],[977,325],[978,332],[979,310],[985,370],[989,360],[990,362],[992,257],[999,303],[1004,279],[1007,299],[1009,326],[1010,333],[1011,311],[1017,371],[1021,361],[1022,363],[1150,8254],[1185,12290],[1186,12300],[1187,12301],[1188,12289],[1189,12539],[1190,12530],[1191,12449],[1192,12451],[1193,12453],[1194,12455],[1195,12457],[1196,12515],[1197,12517],[1198,12519],[1199,12483],[1200,12540],[1201,12450],[1202,12452],[1203,12454],[1204,12456],[1205,12458],[1206,12459],[1207,12461],[1208,12463],[1209,12465],[1210,12467],[1211,12469],[1212,12471],[1213,12473],[1214,12475],[1215,12477],[1216,12479],[1217,12481],[1218,12484],[1219,12486],[1220,12488],[1221,12490],[1222,12491],[1223,12492],[1224,12493],[1225,12494],[1226,12495],[1227,12498],[1228,12501],[1229,12504],[1230,12507],[1231,12510],[1232,12511],[1233,12512],[1234,12513],[1235,12514],[1236,12516],[1237,12518],[1238,12520],[1239,12521],[1240,12522],[1241,12523],[1242,12524],[1243,12525],[1244,12527],[1245,12531],[1246,12443],[1247,12444],[1452,1548],[1467,1563],[1471,1567],[1473,1569],[1474,1570],[1475,1571],[1476,1572],[1477,1573],[1478,1574],[1479,1575],[1480,1576],[1481,1577],[1482,1578],[1483,1579],[1484,1580],[1485,1581],[1486,1582],[1487,1583],[1488,1584],[1489,1585],[1490,1586],[1491,1587],[1492,1588],[1493,1589],[1494,1590],[1495,1591],[1496,1592],[1497,1593],[1498,1594],[1504,1600],[1505,1601],[1506,1602],[1507,1603],[1508,1604],[1509,1605],[1510,1606],[1511,1607],[1512,1608],[1513,1609],[1514,1610],[1515,1611],[1516,1612],[1517,1613],[1518,1614],[1519,1615],[1520,1616],[1521,1617],[1522,1618],[1697,1106],[1698,1107],[1699,1105],[1700,1108],[1701,1109],[1702,1110],[1703,1111],[1704,1112],[1705,1113],[1706,1114],[1707,1115],[1708,1116],[1710,1118],[1711,1119],[1712,8470],[1713,1026],[1714,1027],[1715,1025],[1716,1028],[1717,1029],[1718,1030],[1719,1031],[1720,1032],[1721,1033],[1722,1034],[1723,1035],[1724,1036],[1726,1038],[1727,1039],[1728,1102],[1729,1072],[1730,1073],[1731,1094],[1732,1076],[1733,1077],[1734,1092],[1735,1075],[1736,1093],[1737,1080],[1738,1081],[1739,1082],[1740,1083],[1741,1084],[1742,1085],[1743,1086],[1744,1087],[1745,1103],[1746,1088],[1747,1089],[1748,1090],[1749,1091],[1750,1078],[1751,1074],[1752,1100],[1753,1099],[1754,1079],[1755,1096],[1756,1101],[1757,1097],[1758,1095],[1759,1098],[1760,1070],[1761,1040],[1762,1041],[1763,1062],[1764,1044],[1765,1045],[1766,1060],[1767,1043],[1768,1061],[1769,1048],[1770,1049],[1771,1050],[1772,1051],[1773,1052],[1774,1053],[1775,1054],[1776,1055],[1777,1071],[1778,1056],[1779,1057],[1780,1058],[1781,1059],[1782,1046],[1783,1042],[1784,1068],[1785,1067],[1786,1047],[1787,1064],[1788,1069],[1789,1065],[1790,1063],[1791,1066],[1953,902],[1954,904],[1955,905],[1956,906],[1957,938],[1959,908],[1960,910],[1961,939],[1963,911],[1966,901],[1967,8213],[1969,940],[1970,941],[1971,942],[1972,943],[1973,970],[1974,912],[1975,972],[1976,973],[1977,971],[1978,944],[1979,974],[1985,913],[1986,914],[1987,915],[1988,916],[1989,917],[1990,918],[1991,919],[1992,920],[1993,921],[1994,922],[1995,923],[1996,924],[1997,925],[1998,926],[1999,927],[2e3,928],[2001,929],[2002,931],[2004,932],[2005,933],[2006,934],[2007,935],[2008,936],[2009,937],[2017,945],[2018,946],[2019,947],[2020,948],[2021,949],[2022,950],[2023,951],[2024,952],[2025,953],[2026,954],[2027,955],[2028,956],[2029,957],[2030,958],[2031,959],[2032,960],[2033,961],[2034,963],[2035,962],[2036,964],[2037,965],[2038,966],[2039,967],[2040,968],[2041,969],[2209,9143],[2210,9484],[2211,9472],[2212,8992],[2213,8993],[2214,9474],[2215,9121],[2216,9123],[2217,9124],[2218,9126],[2219,9115],[2220,9117],[2221,9118],[2222,9120],[2223,9128],[2224,9132],[2236,8804],[2237,8800],[2238,8805],[2239,8747],[2240,8756],[2241,8733],[2242,8734],[2245,8711],[2248,8764],[2249,8771],[2253,8660],[2254,8658],[2255,8801],[2262,8730],[2266,8834],[2267,8835],[2268,8745],[2269,8746],[2270,8743],[2271,8744],[2287,8706],[2294,402],[2299,8592],[2300,8593],[2301,8594],[2302,8595],[2528,9670],[2529,9618],[2530,9225],[2531,9228],[2532,9229],[2533,9226],[2536,9252],[2537,9227],[2538,9496],[2539,9488],[2540,9484],[2541,9492],[2542,9532],[2543,9146],[2544,9147],[2545,9472],[2546,9148],[2547,9149],[2548,9500],[2549,9508],[2550,9524],[2551,9516],[2552,9474],[2721,8195],[2722,8194],[2723,8196],[2724,8197],[2725,8199],[2726,8200],[2727,8201],[2728,8202],[2729,8212],[2730,8211],[2734,8230],[2735,8229],[2736,8531],[2737,8532],[2738,8533],[2739,8534],[2740,8535],[2741,8536],[2742,8537],[2743,8538],[2744,8453],[2747,8210],[2748,9001],[2750,9002],[2755,8539],[2756,8540],[2757,8541],[2758,8542],[2761,8482],[2762,9747],[2764,9665],[2765,9655],[2766,9675],[2767,9647],[2768,8216],[2769,8217],[2770,8220],[2771,8221],[2772,8478],[2774,8242],[2775,8243],[2777,10013],[2779,9644],[2780,9664],[2781,9654],[2782,9679],[2783,9646],[2784,9702],[2785,9643],[2786,9645],[2787,9651],[2788,9661],[2789,9734],[2790,8226],[2791,9642],[2792,9650],[2793,9660],[2794,9756],[2795,9758],[2796,9827],[2797,9830],[2798,9829],[2800,10016],[2801,8224],[2802,8225],[2803,10003],[2804,10007],[2805,9839],[2806,9837],[2807,9794],[2808,9792],[2809,9742],[2810,8981],[2811,8471],[2812,8248],[2813,8218],[2814,8222],[2979,60],[2982,62],[2984,8744],[2985,8743],[3008,175],[3010,8869],[3011,8745],[3012,8970],[3014,95],[3018,8728],[3020,9109],[3022,8868],[3023,9675],[3027,8968],[3030,8746],[3032,8835],[3034,8834],[3036,8866],[3068,8867],[3295,8215],[3296,1488],[3297,1489],[3298,1490],[3299,1491],[3300,1492],[3301,1493],[3302,1494],[3303,1495],[3304,1496],[3305,1497],[3306,1498],[3307,1499],[3308,1500],[3309,1501],[3310,1502],[3311,1503],[3312,1504],[3313,1505],[3314,1506],[3315,1507],[3316,1508],[3317,1509],[3318,1510],[3319,1511],[3320,1512],[3321,1513],[3322,1514],[3489,3585],[3490,3586],[3491,3587],[3492,3588],[3493,3589],[3494,3590],[3495,3591],[3496,3592],[3497,3593],[3498,3594],[3499,3595],[3500,3596],[3501,3597],[3502,3598],[3503,3599],[3504,3600],[3505,3601],[3506,3602],[3507,3603],[3508,3604],[3509,3605],[3510,3606],[3511,3607],[3512,3608],[3513,3609],[3514,3610],[3515,3611],[3516,3612],[3517,3613],[3518,3614],[3519,3615],[3520,3616],[3521,3617],[3522,3618],[3523,3619],[3524,3620],[3525,3621],[3526,3622],[3527,3623],[3528,3624],[3529,3625],[3530,3626],[3531,3627],[3532,3628],[3533,3629],[3534,3630],[3535,3631],[3536,3632],[3537,3633],[3538,3634],[3539,3635],[3540,3636],[3541,3637],[3542,3638],[3543,3639],[3544,3640],[3545,3641],[3546,3642],[3551,3647],[3552,3648],[3553,3649],[3554,3650],[3555,3651],[3556,3652],[3557,3653],[3558,3654],[3559,3655],[3560,3656],[3561,3657],[3562,3658],[3563,3659],[3564,3660],[3565,3661],[3568,3664],[3569,3665],[3570,3666],[3571,3667],[3572,3668],[3573,3669],[3574,3670],[3575,3671],[3576,3672],[3577,3673],[3745,12593],[3746,12594],[3747,12595],[3748,12596],[3749,12597],[3750,12598],[3751,12599],[3752,12600],[3753,12601],[3754,12602],[3755,12603],[3756,12604],[3757,12605],[3758,12606],[3759,12607],[3760,12608],[3761,12609],[3762,12610],[3763,12611],[3764,12612],[3765,12613],[3766,12614],[3767,12615],[3768,12616],[3769,12617],[3770,12618],[3771,12619],[3772,12620],[3773,12621],[3774,12622],[3775,12623],[3776,12624],[3777,12625],[3778,12626],[3779,12627],[3780,12628],[3781,12629],[3782,12630],[3783,12631],[3784,12632],[3785,12633],[3786,12634],[3787,12635],[3788,12636],[3789,12637],[3790,12638],[3791,12639],[3792,12640],[3793,12641],[3794,12642],[3795,12643],[3796,4520],[3797,4521],[3798,4522],[3799,4523],[3800,4524],[3801,4525],[3802,4526],[3803,4527],[3804,4528],[3805,4529],[3806,4530],[3807,4531],[3808,4532],[3809,4533],[3810,4534],[3811,4535],[3812,4536],[3813,4537],[3814,4538],[3815,4539],[3816,4540],[3817,4541],[3818,4542],[3819,4543],[3820,4544],[3821,4545],[3822,4546],[3823,12653],[3824,12657],[3825,12664],[3826,12671],[3827,12673],[3828,12676],[3829,12678],[3830,12685],[3831,12686],[3832,4587],[3833,4592],[3834,4601],[3839,8361],[5052,338],[5053,339],[5054,376],[8364,8364],[65104,768],[65105,769],[65106,770],[65107,771],[65108,772],[65109,774],[65110,775],[65111,776],[65112,778],[65113,779],[65114,780],[65115,807],[65116,808],[65117,837],[65118,12441],[65119,12442],[65120,803]];class kt{constructor(e,t){this.type=e,this.host=t}write(e,t=[],n=!1){this.host.make("write").transfer(...n?[e.buffer]:[]).post(e,t,{direct:!!t.length,merge:!1})}subscribe(e,t=[]){this.host.make("subscribe").post(e,t)}}function yt(e,t,n,s){return e.addEventListener(t,n,s),()=>{e.removeEventListener(t,n,s)}}function wt(e,t){let n=0;if(e>=32&&e<=126||e>=160&&e<=255)return"Unidentified"!==t&&(n=t.charCodeAt(0)),0===n&&(n=e),n;const s=gt.find((([t,n])=>n===e));return s?s[0]:(n=16777216|e,n)}class bt{constructor(e,t){this.type=e,this.host=t}write(e,t=[]){this.host.make("write").post(e,t)}subscribe(e,t=[]){this.host.make("subscribe").post(e,t)}}class Et{constructor(e,t){this.streams=new Map,this.cleanup=[],this.factory=t,this.type=n.kData,this.transport=e,this.config=e.config,this.alloc=e.context.alloc,this.view=e.context.view,this.transport.on("onjoin",((e,t,n)=>{const s=this.view(t,n).slice();this.internal.make("onjoin").transfer(s.buffer).post(e,s);const{onopen:i}=this;i&&i()})),this.transport.on("onleave",(e=>{this.internal.make("onleave").post(e)})),this.transport.on("onstatus",((e,t)=>{this.internal.make("onstatus").post(e,t)})),this.transport.on("onsubscribe",((e,t,n,s)=>{const i=this.view(n,s).slice();this.internal.make("onsubscribe").transfer(i.buffer).post(e,t,i)})),this.transport.on("onsubscribeupdated",(e=>{this.internal.make("onsubscribeupdated").post(e)})),this.transport.on("onsignal",((e,t)=>{const n=this.view(e,t).slice();this.internal.make("onsignal").transfer(n.buffer).post(n)})),this.transport.on("ondata",((e,t,n,s)=>{const i=this.view(e,t).slice();this.internal.make("ondata").transfer(i.buffer).post(i,n,s)}))}createStream(e){return t(this,void 0,void 0,(function*(){let t=this.streams.get(e);if(!t){const n=this.internal.channel.receiver();n.implement("ondata",((e,[n,s])=>{e.resolve(),t.ondata&&t.ondata(n,s)}));const s=yield this.internal.make("datastream").invoke(e,`${n}`),i=this.internal.channel.remote(s);t=new kt(e,i)}return this.streams.set(e,t),t}))}closeStream(e){return t(this,void 0,void 0,(function*(){e.host.break(),this.streams.delete(e.type)}))}createSubtitleStream(n=e.DataType.kSubtitleRealtime){return t(this,void 0,void 0,(function*(){let e=this.streams.get(n);if(!e){const t=this.internal.channel.receiver();t.implement("ondata",((t,[n,s])=>{t.resolve(),e.ondata&&e.ondata(n,s)}));const s=yield this.internal.make("subtitlestream").invoke(n,`${t}`),i=this.internal.channel.remote(s);e=new bt(n,i)}return this.streams.set(n,e),e}))}closeSubtitleStream(e){return t(this,void 0,void 0,(function*(){e.host.break(),this.streams.delete(e.type)}))}open(e){return t(this,void 0,void 0,(function*(){const t=e=>this.cleanup.push(e),n=e=>{e.implement("connect",((e,[t])=>{const n=this.alloc(t.desc.length);n.view().set(t.desc),this.transport.Connect(Object.assign(Object.assign({},t),{desc:[n.pointer,n.bytes]})),n.free(),e.resolve()})),e.implement("disconnect",(e=>{this.transport.Disconnect(),e.resolve()})),e.implement("subscribe",((e,[t,n])=>{const s=[];this.transport.Subscribe(t.map((e=>{const t=this.alloc(e.desc.length);return t.view().set(e.desc),s.push(t),Object.assign(Object.assign({},e),{desc:t.tuple()})})),n.map((e=>({ccid:e,desc:[0,0]})))),s.forEach((e=>e.free())),e.resolve()})),e.implement("senddata",((e,[t,n])=>{const s=[];this.transport.SendData(t.map((e=>{const t=this.alloc(e.length);return t.view().set(e),s.push(t),t.tuple()})),n),s.forEach((e=>e.free())),e.resolve()})),e.implement("sendsignal",((e,[t,n])=>{const s=this.alloc(t.length);s.view().set(t),this.transport.SendSingal(s.pointer,s.bytes,n),s.free(),e.resolve()}))};{const[e,s,i]=yield this.factory(),o=e.receiver();n(o),t(i);const r=yield s.make("setup2").invoke(`${o}`,this.transport.type);this.internal=e.remote(r),t((()=>this.internal.break())),t((()=>o.reject()))}this.internal.make("open").invoke(Object.assign(Object.assign({},this.config),e)),t((()=>this.transport.Disconnect())),t((()=>this.transport.off("ondata")))}))}close(){return t(this,void 0,void 0,(function*(){let e;for(;e=this.cleanup.pop();)try{yield e()}catch(t){}this.transport.delete(),this.transport=null,this.onclose&&this.onclose()}))}}const Ot="native-video-worker.global.prod.js";let St="libsvc.prod.js";class xt{init(){return t(this,void 0,void 0,(function*(){if(St=St.replace(/-simd(-m1)?/,""),Fe.getBoolean("simd")){const e=Ce&&fe?"-m1":"";St=St.replace(/[^.]+/,(t=>`${t}-simd${e}`))}Ae||(yield qe((()=>t(this,void 0,void 0,(function*(){const e=We(St.replace(/\.js$/,".wasm"));yield Qe(e),yield Qe(We(Ot))})))))}))}createChannel(e){return new ft(e,(()=>t(this,void 0,void 0,(function*(){let e,n=We(Ot,Fe.get("workerDir"));const s=Ae?null:yield Je(n).catch((()=>null));s&&(n=URL.createObjectURL(new Blob([s],{type:"application/javascript"})),e=!0);const i=Ae?Ne(n):new Worker(n),o=new v(i),r=o.remote("video-engine-host"),a=Fe.getBoolean("verbose",!1);yield r.make("init").invoke(Ae?`./${St}?${Fe.get("scriptDir","")}`:We(St),a).catch((e=>{throw i.terminate(),e}));return[o,r,()=>t(this,void 0,void 0,(function*(){yield r.make("exit").invoke().catch(Ct),o.close(),i.terminate(),e&&URL.revokeObjectURL(n)}))]}))))}createDataChannel(e){return new Et(e,(()=>t(this,void 0,void 0,(function*(){let e,n=We(Ot);const s=Ae?null:yield Je(n).catch((()=>null));s&&(n=URL.createObjectURL(new Blob([s],{type:"application/javascript"})),e=!0);const i=new Worker(n),o=new v(i),r=o.remote("video-engine-host"),a=Fe.getBoolean("verbose",!1);yield r.make("init").invoke(We(St),a).catch((e=>{throw i.terminate(),e}));return[o,r,()=>t(this,void 0,void 0,(function*(){yield r.make("exit").invoke().catch(Ct),o.close(),i.terminate(),e&&URL.revokeObjectURL(n)}))]}))))}}const Ct=()=>{};return e.NativeAudioChannel=$e,e.NativeAudioEngine=nt,e.NativeAudioReceiver=_e,e.NativeAudioSender=ae,e.NativeDataChannel=Et,e.NativeDataStream=kt,e.NativeMediaEndpoint=class{constructor(e=[]){this.transports=[],this.mss=e}init(){return t(this,void 0,void 0,(function*(){if(this.endpoint)return;if(yield rt(),lt=Fe.getBoolean("verbose",!1),!at){dt=dt.replace(/-simd/,""),Fe.getBoolean("simd")&&(dt=dt.replace(/[^.]+/,(e=>`${e}-simd`)));const e=We(dt.replace(/\.js$/,".wasm"));let t=e;Ae||(t=yield Qe(e).catch((()=>null)));const n=Fe.get("libsfu");at=yield n({wasmBinary:t}).catch((e=>{throw Ke(),e})),ct=function(e,t){return n=>{const{BYTES_PER_ELEMENT:s}=e[t||it],i=n*s,o=e._malloc(i);return{BYTES_PER_ELEMENT:s,pointer:o,length:n,bytes:i,tuple:()=>[o,i],view:(i=!0)=>{const r=e[t||it].subarray(o/s,o+n);return i&&void 0!==r.constructor?new r.constructor(r.buffer,r.byteOffset,n):r},free:()=>e._free(o)}}}(at),ht=function(e,t){return(n,s,i=!0)=>{const o=e[t||it],{BYTES_PER_ELEMENT:r}=o,a=o.subarray(n/r,n+s);return i&&void 0!==a.constructor?new a.constructor(a.buffer,a.byteOffset,s):a}}(at);const s=new at.TimerFactory({start:(e,t)=>setInterval((()=>at.TimerFactory.Run(e)),t),stop:e=>clearInterval(e)});at.SFUEndpoint.Init(s,((e,t)=>{lt&&console.log(t)}))}let e,n,s,i=Promise.resolve(null);const o=()=>t(this,void 0,void 0,(function*(){if(this.onrefresh)try{this.mss=yield this.onrefresh()}catch(e){}})),r=()=>new Promise(((e,t)=>{if(!this.mss.length)return void t();let n=this.mss.length;const s=t=>{e(t),o.forEach((e=>e!==t&&e.close()))},i=e=>{--n||(this.mss.splice(this.mss.indexOf(e),1),t())},o=this.mss.map((e=>{let t;return Ae?(t=wx.connectSocket({url:e}),t.onOpen((()=>s(t))),t.onError((()=>i(e))),t.url=e):(t=new WebSocket(e),t.binaryType="arraybuffer",t.onopen=()=>s(t),t.onerror=()=>i(e)),t}))})),a=e=>{this.transports.push(e)},c=e=>{this.transports.splice(this.transports.indexOf(e),1)};this.transport_factory=new at.TransportFactory({create:(t,h)=>{if(t===q.kSignal){const l=new at.Transport({send:(e,t)=>{d.send(ht(e,t))},close:()=>{d&&d.close(),s&&s(),s=null,i=Promise.resolve(null)},destroy:()=>{d&&(c(d),d.onopen=null,d.onclose=null,d.onerror=null,d.onmessage=null,d.close(),d=null),l.delete()}},t,h);let d;return r().then((t=>{d=t,d.onclose=({wasClean:e,code:t})=>{l.onclose(!e,t)},d.onmessage=({data:e})=>{if("string"!=typeof e){const t=ct(e.byteLength);t.view().set(new Uint8Array(e)),l.onmessage(t.pointer,t.bytes),t.free()}else n(e)},Ae&&(d.onClose((e=>{d.onclose&&d.onclose(e)})),d.onMessage((e=>{d.onmessage&&d.onmessage(e)}))),e=e=>(i=i.then((()=>{const{promise:t,resolve:i,reject:o}=function(){const e={};return e.promise=new Promise(((t,n)=>{e.resolve=t,e.reject=n})),e}();return n=i,s=o,d.send(e),t})),i),a(d),l.onopen()})).catch((()=>{l.onerror(),o()})),l}if(t===q.kData){const n=new at.Transport({send:(e,t)=>{s.send(ht(e,t))},close:()=>{s.close()},destroy:()=>{s.onopen=null,s.onclose=null,s.onerror=null,s.onmessage=null,s.close(),s=null,r(),n.delete()}},t,h);let s=null;const i=()=>{s=l.createDataChannel(`channel-${Math.random().toString(36).slice(7)}`,{ordered:!1,reliable:!1}),s.binaryType="arraybuffer",s.onopen=()=>{n.onopen()},s.onclose=()=>{n.onclose(!0,-1)},s.onerror=e=>{n.onerror(),o()},s.onmessage=({data:e})=>{if("string"!=typeof e){const t=ct(e.byteLength);t.view().set(new Uint8Array(e)),n.onmessage(t.pointer,t.bytes),t.free()}}},r=()=>{l&&(c(l),l.onconnectionstatechange=null,l.onicecandidate=null,l.close(),l=null)};let l;l=new RTCPeerConnection({iceCandidatePoolSize:1}),l.onconnectionstatechange=()=>{"failed"===l.connectionState&&(r(),o())};const d=Fe.getBoolean("gathering",!1);d&&(l.onicecandidate=({candidate:e})=>{e||u()}),i();const u=()=>e(l.localDescription.sdp).then((e=>l.setRemoteDescription({type:"answer",sdp:e}))).catch(r);return l.createOffer().then((e=>l.setLocalDescription(e))).then((()=>{d&&"complete"!==l.iceGatheringState||u()})),a(l),n}throw new Error(`unknown type of transport: ${t}.`)}}),this.endpoint=new at.SFUEndpoint(this.transport_factory)}))}destroy(){this.endpoint.Stop(),this.endpoint.delete(),this.endpoint=null,this.transport_factory.delete(),this.transport_factory=null,this.transports.forEach((e=>e.close())),this.transports.length=0}start(e){return t(this,void 0,void 0,(function*(){if(!this.mss.length&&!this.onrefresh)throw new Error("mss is required. passing mss from constructor or provide 'onrefresh' callback");let t=3;for(;!this.mss.length&&t--;)try{this.mss=yield this.onrefresh()}catch(n){}if(!this.mss.length)throw new Error("init failed due to missing mss");e.meeting_number=e.meeting_number||"",e.meeting_param=e.meeting_param||"",e.client_type=e.client_type||"webapp",e.user_account=e.user_account||"",this.endpoint.Start(e),this.config=e}))}stop(){this.endpoint.Stop(),this.config=null}createTransport(e){const n=new at.SFUTransport(this.endpoint,e);return n.type=e,n.config=this.config,n.context={alloc:ct,view:ht},n.on("onstatus",((e,n)=>t(this,void 0,void 0,(function*(){this.onrefresh&&n===G.kMSSLost&&(this.mss=yield this.onrefresh())})))),n}},e.NativeMediaEngine=class{constructor(){this.audio=new nt,this.video=new xt,this.data=null}init(){return t(this,void 0,void 0,(function*(){yield rt(),yield Promise.all([this.audio.init(),this.video.init()])}))}},e.NativeSubtitleStream=bt,e.NativeVideoChannel=ft,e.NativeVideoEngine=xt,e.NativeVideoReceiver=pt,e.NativeVideoSender=ut,e.bootstrap=rt,e.setupRemoteControl=function(e,t,n){const s=function(e){const t=e.Reader,n=e.Writer,s=e.util,i=e.roots.default||(e.roots.default={});if(i.eventdefine)return i.eventdefine;const o=i.eventdefine={};return o.MouseEvent=function(){function o(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return o.prototype.button=0,o.prototype.down=!1,o.prototype.x=0,o.prototype.y=0,o.prototype.windowWidth=0,o.prototype.windowHeight=0,o.create=function(e){return new o(e)},o.encode=function(e,t){return t||(t=n.create()),null!=e.button&&Object.hasOwnProperty.call(e,"button")&&t.uint32(8).int32(e.button),null!=e.down&&Object.hasOwnProperty.call(e,"down")&&t.uint32(16).bool(e.down),null!=e.x&&Object.hasOwnProperty.call(e,"x")&&t.uint32(24).sint32(e.x),null!=e.y&&Object.hasOwnProperty.call(e,"y")&&t.uint32(32).sint32(e.y),null!=e.windowWidth&&Object.hasOwnProperty.call(e,"windowWidth")&&t.uint32(40).int32(e.windowWidth),null!=e.windowHeight&&Object.hasOwnProperty.call(e,"windowHeight")&&t.uint32(48).int32(e.windowHeight),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,n){e instanceof t||(e=t.create(e));let s=void 0===n?e.len:e.pos+n,o=new i.eventdefine.MouseEvent;for(;e.pos<s;){let t=e.uint32();switch(t>>>3){case 1:o.button=e.int32();break;case 2:o.down=e.bool();break;case 3:o.x=e.sint32();break;case 4:o.y=e.sint32();break;case 5:o.windowWidth=e.int32();break;case 6:o.windowHeight=e.int32();break;default:e.skipType(7&t)}}return o},o.decodeDelimited=function(e){return e instanceof t||(e=new t(e)),this.decode(e,e.uint32())},o.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.button&&e.hasOwnProperty("button")&&!s.isInteger(e.button)?"button: integer expected":null!=e.down&&e.hasOwnProperty("down")&&"boolean"!=typeof e.down?"down: boolean expected":null!=e.x&&e.hasOwnProperty("x")&&!s.isInteger(e.x)?"x: integer expected":null!=e.y&&e.hasOwnProperty("y")&&!s.isInteger(e.y)?"y: integer expected":null!=e.windowWidth&&e.hasOwnProperty("windowWidth")&&!s.isInteger(e.windowWidth)?"windowWidth: integer expected":null!=e.windowHeight&&e.hasOwnProperty("windowHeight")&&!s.isInteger(e.windowHeight)?"windowHeight: integer expected":null},o.fromObject=function(e){if(e instanceof i.eventdefine.MouseEvent)return e;let t=new i.eventdefine.MouseEvent;return null!=e.button&&(t.button=0|e.button),null!=e.down&&(t.down=Boolean(e.down)),null!=e.x&&(t.x=0|e.x),null!=e.y&&(t.y=0|e.y),null!=e.windowWidth&&(t.windowWidth=0|e.windowWidth),null!=e.windowHeight&&(t.windowHeight=0|e.windowHeight),t},o.toObject=function(e,t){t||(t={});let n={};return t.defaults&&(n.button=0,n.down=!1,n.x=0,n.y=0,n.windowWidth=0,n.windowHeight=0),null!=e.button&&e.hasOwnProperty("button")&&(n.button=e.button),null!=e.down&&e.hasOwnProperty("down")&&(n.down=e.down),null!=e.x&&e.hasOwnProperty("x")&&(n.x=e.x),null!=e.y&&e.hasOwnProperty("y")&&(n.y=e.y),null!=e.windowWidth&&e.hasOwnProperty("windowWidth")&&(n.windowWidth=e.windowWidth),null!=e.windowHeight&&e.hasOwnProperty("windowHeight")&&(n.windowHeight=e.windowHeight),n},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o}(),o.WheelEvent=function(){function o(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return o.prototype.horizon=0,o.prototype.vertical=0,o.create=function(e){return new o(e)},o.encode=function(e,t){return t||(t=n.create()),null!=e.horizon&&Object.hasOwnProperty.call(e,"horizon")&&t.uint32(8).sint32(e.horizon),null!=e.vertical&&Object.hasOwnProperty.call(e,"vertical")&&t.uint32(16).sint32(e.vertical),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,n){e instanceof t||(e=t.create(e));let s=void 0===n?e.len:e.pos+n,o=new i.eventdefine.WheelEvent;for(;e.pos<s;){let t=e.uint32();switch(t>>>3){case 1:o.horizon=e.sint32();break;case 2:o.vertical=e.sint32();break;default:e.skipType(7&t)}}return o},o.decodeDelimited=function(e){return e instanceof t||(e=new t(e)),this.decode(e,e.uint32())},o.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.horizon&&e.hasOwnProperty("horizon")&&!s.isInteger(e.horizon)?"horizon: integer expected":null!=e.vertical&&e.hasOwnProperty("vertical")&&!s.isInteger(e.vertical)?"vertical: integer expected":null},o.fromObject=function(e){if(e instanceof i.eventdefine.WheelEvent)return e;let t=new i.eventdefine.WheelEvent;return null!=e.horizon&&(t.horizon=0|e.horizon),null!=e.vertical&&(t.vertical=0|e.vertical),t},o.toObject=function(e,t){t||(t={});let n={};return t.defaults&&(n.horizon=0,n.vertical=0),null!=e.horizon&&e.hasOwnProperty("horizon")&&(n.horizon=e.horizon),null!=e.vertical&&e.hasOwnProperty("vertical")&&(n.vertical=e.vertical),n},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o}(),o.KeyEvent=function(){function o(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return o.prototype.keyCode=0,o.prototype.keySym=0,o.prototype.down=!1,o.create=function(e){return new o(e)},o.encode=function(e,t){return t||(t=n.create()),null!=e.keyCode&&Object.hasOwnProperty.call(e,"keyCode")&&t.uint32(8).int32(e.keyCode),null!=e.keySym&&Object.hasOwnProperty.call(e,"keySym")&&t.uint32(16).int32(e.keySym),null!=e.down&&Object.hasOwnProperty.call(e,"down")&&t.uint32(24).bool(e.down),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,n){e instanceof t||(e=t.create(e));let s=void 0===n?e.len:e.pos+n,o=new i.eventdefine.KeyEvent;for(;e.pos<s;){let t=e.uint32();switch(t>>>3){case 1:o.keyCode=e.int32();break;case 2:o.keySym=e.int32();break;case 3:o.down=e.bool();break;default:e.skipType(7&t)}}return o},o.decodeDelimited=function(e){return e instanceof t||(e=new t(e)),this.decode(e,e.uint32())},o.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.keyCode&&e.hasOwnProperty("keyCode")&&!s.isInteger(e.keyCode)?"keyCode: integer expected":null!=e.keySym&&e.hasOwnProperty("keySym")&&!s.isInteger(e.keySym)?"keySym: integer expected":null!=e.down&&e.hasOwnProperty("down")&&"boolean"!=typeof e.down?"down: boolean expected":null},o.fromObject=function(e){if(e instanceof i.eventdefine.KeyEvent)return e;let t=new i.eventdefine.KeyEvent;return null!=e.keyCode&&(t.keyCode=0|e.keyCode),null!=e.keySym&&(t.keySym=0|e.keySym),null!=e.down&&(t.down=Boolean(e.down)),t},o.toObject=function(e,t){t||(t={});let n={};return t.defaults&&(n.keyCode=0,n.keySym=0,n.down=!1),null!=e.keyCode&&e.hasOwnProperty("keyCode")&&(n.keyCode=e.keyCode),null!=e.keySym&&e.hasOwnProperty("keySym")&&(n.keySym=e.keySym),null!=e.down&&e.hasOwnProperty("down")&&(n.down=e.down),n},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o}(),o.ClipboardEvent=function(){function o(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return o.prototype.flag=0,o.prototype.data="",o.create=function(e){return new o(e)},o.encode=function(e,t){return t||(t=n.create()),null!=e.flag&&Object.hasOwnProperty.call(e,"flag")&&t.uint32(8).int32(e.flag),null!=e.data&&Object.hasOwnProperty.call(e,"data")&&t.uint32(18).string(e.data),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,n){e instanceof t||(e=t.create(e));let s=void 0===n?e.len:e.pos+n,o=new i.eventdefine.ClipboardEvent;for(;e.pos<s;){let t=e.uint32();switch(t>>>3){case 1:o.flag=e.int32();break;case 2:o.data=e.string();break;default:e.skipType(7&t)}}return o},o.decodeDelimited=function(e){return e instanceof t||(e=new t(e)),this.decode(e,e.uint32())},o.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.flag&&e.hasOwnProperty("flag")&&!s.isInteger(e.flag)?"flag: integer expected":null!=e.data&&e.hasOwnProperty("data")&&!s.isString(e.data)?"data: string expected":null},o.fromObject=function(e){if(e instanceof i.eventdefine.ClipboardEvent)return e;let t=new i.eventdefine.ClipboardEvent;return null!=e.flag&&(t.flag=0|e.flag),null!=e.data&&(t.data=String(e.data)),t},o.toObject=function(e,t){t||(t={});let n={};return t.defaults&&(n.flag=0,n.data=""),null!=e.flag&&e.hasOwnProperty("flag")&&(n.flag=e.flag),null!=e.data&&e.hasOwnProperty("data")&&(n.data=e.data),n},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o}(),o.RemoteControlEvent=function(){function o(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}let r;return o.prototype.timestamp=s.Long?s.Long.fromBits(0,0,!0):0,o.prototype.mouseEvent=null,o.prototype.wheelEvent=null,o.prototype.keyEvent=null,o.prototype.clipboardEvent=null,Object.defineProperty(o.prototype,"type",{get:s.oneOfGetter(r=["mouseEvent","wheelEvent","keyEvent","clipboardEvent"]),set:s.oneOfSetter(r)}),o.create=function(e){return new o(e)},o.encode=function(e,t){return t||(t=n.create()),null!=e.timestamp&&Object.hasOwnProperty.call(e,"timestamp")&&t.uint32(8).uint64(e.timestamp),null!=e.mouseEvent&&Object.hasOwnProperty.call(e,"mouseEvent")&&i.eventdefine.MouseEvent.encode(e.mouseEvent,t.uint32(18).fork()).ldelim(),null!=e.wheelEvent&&Object.hasOwnProperty.call(e,"wheelEvent")&&i.eventdefine.WheelEvent.encode(e.wheelEvent,t.uint32(26).fork()).ldelim(),null!=e.keyEvent&&Object.hasOwnProperty.call(e,"keyEvent")&&i.eventdefine.KeyEvent.encode(e.keyEvent,t.uint32(34).fork()).ldelim(),null!=e.clipboardEvent&&Object.hasOwnProperty.call(e,"clipboardEvent")&&i.eventdefine.ClipboardEvent.encode(e.clipboardEvent,t.uint32(42).fork()).ldelim(),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,n){e instanceof t||(e=t.create(e));let s=void 0===n?e.len:e.pos+n,o=new i.eventdefine.RemoteControlEvent;for(;e.pos<s;){let t=e.uint32();switch(t>>>3){case 1:o.timestamp=e.uint64();break;case 2:o.mouseEvent=i.eventdefine.MouseEvent.decode(e,e.uint32());break;case 3:o.wheelEvent=i.eventdefine.WheelEvent.decode(e,e.uint32());break;case 4:o.keyEvent=i.eventdefine.KeyEvent.decode(e,e.uint32());break;case 5:o.clipboardEvent=i.eventdefine.ClipboardEvent.decode(e,e.uint32());break;default:e.skipType(7&t)}}return o},o.decodeDelimited=function(e){return e instanceof t||(e=new t(e)),this.decode(e,e.uint32())},o.verify=function(e){if("object"!=typeof e||null===e)return"object expected";let t={};if(null!=e.timestamp&&e.hasOwnProperty("timestamp")&&!(s.isInteger(e.timestamp)||e.timestamp&&s.isInteger(e.timestamp.low)&&s.isInteger(e.timestamp.high)))return"timestamp: integer|Long expected";if(null!=e.mouseEvent&&e.hasOwnProperty("mouseEvent")){t.type=1;{let t=i.eventdefine.MouseEvent.verify(e.mouseEvent);if(t)return"mouseEvent."+t}}if(null!=e.wheelEvent&&e.hasOwnProperty("wheelEvent")){if(1===t.type)return"type: multiple values";t.type=1;{let t=i.eventdefine.WheelEvent.verify(e.wheelEvent);if(t)return"wheelEvent."+t}}if(null!=e.keyEvent&&e.hasOwnProperty("keyEvent")){if(1===t.type)return"type: multiple values";t.type=1;{let t=i.eventdefine.KeyEvent.verify(e.keyEvent);if(t)return"keyEvent."+t}}if(null!=e.clipboardEvent&&e.hasOwnProperty("clipboardEvent")){if(1===t.type)return"type: multiple values";t.type=1;{let t=i.eventdefine.ClipboardEvent.verify(e.clipboardEvent);if(t)return"clipboardEvent."+t}}return null},o.fromObject=function(e){if(e instanceof i.eventdefine.RemoteControlEvent)return e;let t=new i.eventdefine.RemoteControlEvent;if(null!=e.timestamp&&(s.Long?(t.timestamp=s.Long.fromValue(e.timestamp)).unsigned=!0:"string"==typeof e.timestamp?t.timestamp=parseInt(e.timestamp,10):"number"==typeof e.timestamp?t.timestamp=e.timestamp:"object"==typeof e.timestamp&&(t.timestamp=new s.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber(!0))),null!=e.mouseEvent){if("object"!=typeof e.mouseEvent)throw TypeError(".eventdefine.RemoteControlEvent.mouseEvent: object expected");t.mouseEvent=i.eventdefine.MouseEvent.fromObject(e.mouseEvent)}if(null!=e.wheelEvent){if("object"!=typeof e.wheelEvent)throw TypeError(".eventdefine.RemoteControlEvent.wheelEvent: object expected");t.wheelEvent=i.eventdefine.WheelEvent.fromObject(e.wheelEvent)}if(null!=e.keyEvent){if("object"!=typeof e.keyEvent)throw TypeError(".eventdefine.RemoteControlEvent.keyEvent: object expected");t.keyEvent=i.eventdefine.KeyEvent.fromObject(e.keyEvent)}if(null!=e.clipboardEvent){if("object"!=typeof e.clipboardEvent)throw TypeError(".eventdefine.RemoteControlEvent.clipboardEvent: object expected");t.clipboardEvent=i.eventdefine.ClipboardEvent.fromObject(e.clipboardEvent)}return t},o.toObject=function(e,t){t||(t={});let n={};if(t.defaults)if(s.Long){let e=new s.Long(0,0,!0);n.timestamp=t.longs===String?e.toString():t.longs===Number?e.toNumber():e}else n.timestamp=t.longs===String?"0":0;return null!=e.timestamp&&e.hasOwnProperty("timestamp")&&(n.timestamp="number"==typeof e.timestamp?t.longs===String?String(e.timestamp):e.timestamp:t.longs===String?s.Long.prototype.toString.call(e.timestamp):t.longs===Number?new s.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber(!0):e.timestamp),null!=e.mouseEvent&&e.hasOwnProperty("mouseEvent")&&(n.mouseEvent=i.eventdefine.MouseEvent.toObject(e.mouseEvent,t),t.oneofs&&(n.type="mouseEvent")),null!=e.wheelEvent&&e.hasOwnProperty("wheelEvent")&&(n.wheelEvent=i.eventdefine.WheelEvent.toObject(e.wheelEvent,t),t.oneofs&&(n.type="wheelEvent")),null!=e.keyEvent&&e.hasOwnProperty("keyEvent")&&(n.keyEvent=i.eventdefine.KeyEvent.toObject(e.keyEvent,t),t.oneofs&&(n.type="keyEvent")),null!=e.clipboardEvent&&e.hasOwnProperty("clipboardEvent")&&(n.clipboardEvent=i.eventdefine.ClipboardEvent.toObject(e.clipboardEvent,t),t.oneofs&&(n.type="clipboardEvent")),n},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o}(),o}(Fe.get("protobuf")),i=[],o={x:0,y:0,windowWidth:0,windowHeight:0,button:0},r=e=>{o.x=1*e.offsetX,o.y=1*e.offsetY,o.windowWidth=t.clientWidth,o.windowHeight=t.clientHeight},a=(t,i)=>{const o=s.RemoteControlEvent.fromObject({timestamp:Date.now(),[t]:i}),r=s.RemoteControlEvent.encode(o).finish();e.write(r,n)};return i.push(yt(t,"mousedown",(e=>{r(e),1===e.which?o.button|=1:2===e.which?o.button|=2:3===e.which&&(o.button|=4),a("mouseEvent",o)})),yt(t,"mouseup",(e=>{r(e),1===e.which?o.button&=-2:2===e.which?o.button&=-3:3===e.which&&(o.button&=-5),a("mouseEvent",o)})),yt(t,"mousemove",(e=>{r(e),a("mouseEvent",o)})),yt(t,"mouseleave",(e=>{r(e),a("mouseEvent",o)}))),i.push(yt(t,"wheel",(e=>{const t=e=>{const t=e/120;return Math.abs(t)>=1?t:t>0?-1:1};if(e.deltaX){const n=t(e.deltaX);a("wheelEvent",{horizon:n})}if(e.deltaY){const n=t(e.deltaY);a("wheelEvent",{vertical:n})}e.preventDefault()}))),i.push(yt(t,"keydown",(e=>{let t=vt[e.keyCode];if(!t){const n=e.keyCode;t=wt(e.ctrlKey&&n>0&&n<32?96+n:n,e.key)}a("keyEvent",{keyCode:e.keyCode,keySym:t,down:!0}),e.preventDefault()})),yt(t,"keyup",(e=>{let t=vt[e.keyCode];if(!t){const n=e.keyCode;t=wt(e.ctrlKey&&n>0&&n<32?96+n:n,e.key)}a("keyEvent",{keyCode:e.keyCode,keySym:t,down:!1}),e.preventDefault()})),yt(t,"keypress",(e=>{const t=e.which,n=wt(e.ctrlKey&&t>0&&t<32?96+t:t,e.key);a("keyEvent",{keyCode:0,keySym:n,down:!0}),a("keyEvent",{keyCode:0,keySym:n,down:!1}),e.preventDefault()})),yt(t,"blur",(()=>{}))),i.push(yt(t,"contextmenu",(e=>e.preventDefault())),yt(t,"selectstart",(e=>e.preventDefault()))),()=>{let e;for(;e=i.pop();)e()}},e}({});
|