@millicast/sdk
Version:
SDK for building a realtime broadcaster using the Millicast platform.
7 lines • 1.86 MB
JavaScript
(function(we,st){typeof exports=="object"&&typeof module<"u"?st(exports):typeof define=="function"&&define.amd?define(["exports"],st):(we=typeof globalThis<"u"?globalThis:we||self,st(we["millicast-debug"]={}))})(this,function(we){"use strict";var Zs;var st=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function gt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var xt={exports:{}};/*!
* js-logger - http://github.com/jonnyreeves/js-logger
* Jonny Reeves, http://jonnyreeves.co.uk/
* js-logger may be freely distributed under the MIT license.
*/var Gs=xt.exports,Di;function vs(){return Di||(Di=1,function(i){(function(e){var t={};t.VERSION="1.6.1";var n,r={},o=function(u,I){return function(){return I.apply(u,arguments)}},c=function(){var u=arguments,I=u[0],F,f;for(f=1;f<u.length;f++)for(F in u[f])!(F in I)&&u[f].hasOwnProperty(F)&&(I[F]=u[f][F]);return I},a=function(u,I){return{value:u,name:I}};t.TRACE=a(1,"TRACE"),t.DEBUG=a(2,"DEBUG"),t.INFO=a(3,"INFO"),t.TIME=a(4,"TIME"),t.WARN=a(5,"WARN"),t.ERROR=a(8,"ERROR"),t.OFF=a(99,"OFF");var g=function(u){this.context=u,this.setLevel(u.filterLevel),this.log=this.info};g.prototype={setLevel:function(u){u&&"value"in u&&(this.context.filterLevel=u)},getLevel:function(){return this.context.filterLevel},enabledFor:function(u){var I=this.context.filterLevel;return u.value>=I.value},trace:function(){this.invoke(t.TRACE,arguments)},debug:function(){this.invoke(t.DEBUG,arguments)},info:function(){this.invoke(t.INFO,arguments)},warn:function(){this.invoke(t.WARN,arguments)},error:function(){this.invoke(t.ERROR,arguments)},time:function(u){typeof u=="string"&&u.length>0&&this.invoke(t.TIME,[u,"start"])},timeEnd:function(u){typeof u=="string"&&u.length>0&&this.invoke(t.TIME,[u,"end"])},invoke:function(u,I){n&&this.enabledFor(u)&&n(I,c({level:u},this.context))}};var d=new g({filterLevel:t.OFF});(function(){var u=t;u.enabledFor=o(d,d.enabledFor),u.trace=o(d,d.trace),u.debug=o(d,d.debug),u.time=o(d,d.time),u.timeEnd=o(d,d.timeEnd),u.info=o(d,d.info),u.warn=o(d,d.warn),u.error=o(d,d.error),u.log=u.info})(),t.setHandler=function(u){n=u},t.setLevel=function(u){d.setLevel(u);for(var I in r)r.hasOwnProperty(I)&&r[I].setLevel(u)},t.getLevel=function(){return d.getLevel()},t.get=function(u){return r[u]||(r[u]=new g(c({name:u},d.context)))},t.createDefaultHandler=function(u){u=u||{},u.formatter=u.formatter||function(m,y){y.name&&m.unshift("["+y.name+"]")};var I={},F=function(f,m){Function.prototype.apply.call(f,console,m)};return typeof console>"u"?function(){}:function(f,m){f=Array.prototype.slice.call(f);var y=console.log,x;m.level===t.TIME?(x=(m.name?"["+m.name+"] ":"")+f[0],f[1]==="start"?console.time?console.time(x):I[x]=new Date().getTime():console.timeEnd?console.timeEnd(x):F(y,[x+": "+(new Date().getTime()-I[x])+"ms"])):(m.level===t.WARN&&console.warn?y=console.warn:m.level===t.ERROR&&console.error?y=console.error:m.level===t.INFO&&console.info?y=console.info:m.level===t.DEBUG&&console.debug?y=console.debug:m.level===t.TRACE&&console.trace&&(y=console.trace),u.formatter(f,m),F(y,f))}},t.useDefaults=function(u){t.setLevel(u&&u.defaultLevel||t.DEBUG),t.setHandler(t.createDefaultHandler(u))},t.setDefaults=t.useDefaults,i.exports?i.exports=t:(t._prevLogger=e.Logger,t.noConflict=function(){return e.Logger=t._prevLogger,t},e.Logger=t)})(Gs)}(xt)),xt.exports}var ws=vs();const Ke=gt(ws),Hi="0.6.1",Vt=60,Ls=((Zs=window==null?void 0:window.navigator)==null?void 0:Zs.userAgent)||"No user agent available";let Rt="",Ct="",Et="",ht="",ft="",Ji="",St="",Zt=0;const Gt=[];function Xs(i){function e(t,n){return{ts:Math.round(n.timestamp)||"",ot:t==="audio"?"a":"v",bl:n.jitterBufferDelay||0,br:Math.round(n.bitrateBitsPerSecond||0),pld:n.packetsLostDeltaPerSecond||0,j:n.jitter||0,mtp:n.packetRate||0,mid:n.mid||"",mimeType:n.mimeType||""}}return i.stats=i.stats.reduce((t,n)=>{const r=n.audio.inbounds.length!==0?n.audio.inbounds.map(c=>e("audio",c)):n.audio.outbounds.map(c=>e("audio",c)),o=n.video.inbounds.length!==0?n.video.inbounds.map(c=>e("video",c)):n.video.outbounds.map(c=>e("video",c));return t.concat([...r,...o])},[]),i}const xe={initAccountId:i=>{Rt=Rt===""?i:Rt},initStreamName:i=>{Ct=Ct===""?i:Ct},initSubscriberId:i=>{Et=Et===""?i:Et},initStreamViewId:i=>{ht=ht===""?i:ht},initFeedId:i=>{ft=ft===""?i:ft},setConnectionTime:i=>{Zt=Zt===0?i:Zt},setConnectionState:i=>{Ji=i},setClusterId:i=>{St=St===""?i:St},addStats:i=>{Gt.length===Vt&&Gt.shift(),Gt.push(i)},get:(i=Vt,e="JSON")=>{let t;!Number.isInteger(i)||i>Vt||i<=0?t=Vt:t=i;const n={client:"@millicast/millicast-sdk",version:Hi,timestamp:new Date().toISOString(),userAgent:Ls,clusterId:St,accountId:Rt,streamName:Ct,subscriberId:Et,connection:Ji,stats:Gt.slice(-t),connectionDurationMs:new Date().getTime()-Zt};return ft!==""?n.feedId=ft:ht!==""&&(n.streamViewId=ht),e==="CMCD"?Xs(n):n}};Ke.useDefaults({defaultLevel:Ke.TRACE});const vt=["TRACE","DEBUG","INFO","WARN","ERROR"],Yi=(i,e)=>{i.unshift(`[${e.name||"Global"}] ${new Date().toISOString()} - ${e.level.name} -`)},Mi=(i,e)=>e?i.value>=_e[e].value:i.value>=wt.value,As=(i,e)=>{i=Array.prototype.slice.call(i),i=i.map(t=>typeof t=="object"?JSON.stringify(t):t),Yi(i,e),mt!==0?(ot.push(i.join(" ")),ot.length>=mt&&(ot=ot.slice(-mt))):ot=[]},Ns=Ke.createDefaultHandler({formatter:Yi});Ke.setHandler((i,e)=>{As(i,e),Mi(e.level,e.name)&&Ns(i,e);for(const{handler:t,level:n}of Pi)e.level.value>=n.value&&t(i,e)});let mt=1e4,ot=[],wt=Ke.OFF;const _e={},Pi=[],Ne={...Ke,enabledFor:Mi,getHistory:()=>ot,getHistoryMaxSize:()=>mt,setHistoryMaxSize:i=>{mt=i},setLevel:i=>{wt=i;for(const e in _e)_e[e]=i},getLevel:()=>wt,get:i=>{_e[i]||(_e[i]=wt);const e=Ke.get(i);return e.setLevel=t=>{_e[i]=t},e.getLevel=()=>_e[i],e},setHandler:(i,e)=>{Pi.push({handler:i,level:e})},diagnose:(i={})=>{let e;const t={statsCount:60,historySize:1e3,minLogLevel:"TRACE",statsFormat:"JSON"};typeof i=="number"?(t.statsCount=i,e=t):e={...t,...i};const{statsCount:n,historySize:r,minLogLevel:o,statsFormat:c}=e,a=xe.get(n,c),g=Ne.getHistory();if(!Number.isInteger(r)||r<=0)throw new Error("Invalid Argument Exception : historySize must be a positive integer.");if(!vt.includes(o.toUpperCase()))throw new Error('Invalid Argument Exception : the minLogLevel parameter only excepts "trace", "debug", "info", "warn", and "error" as arguments.');if(vt.includes(o.toUpperCase())){const d=vt.slice(vt.indexOf(o.toUpperCase())),u=g.filter(I=>d.some(F=>I.includes(F)));a.history=u.slice(-r)}return a},JSON:"JSON",CMCD:"CMCD",VERSION:Hi};var Lt={exports:{}},zi;function an(){if(zi)return Lt.exports;zi=1;var i=typeof Reflect=="object"?Reflect:null,e=i&&typeof i.apply=="function"?i.apply:function(b,Q,B){return Function.prototype.apply.call(b,Q,B)},t;i&&typeof i.ownKeys=="function"?t=i.ownKeys:Object.getOwnPropertySymbols?t=function(b){return Object.getOwnPropertyNames(b).concat(Object.getOwnPropertySymbols(b))}:t=function(b){return Object.getOwnPropertyNames(b)};function n(U){console&&console.warn&&console.warn(U)}var r=Number.isNaN||function(b){return b!==b};function o(){o.init.call(this)}Lt.exports=o,Lt.exports.once=v,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var c=10;function a(U){if(typeof U!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof U)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(U){if(typeof U!="number"||U<0||r(U))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+U+".");c=U}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(b){if(typeof b!="number"||b<0||r(b))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+b+".");return this._maxListeners=b,this};function g(U){return U._maxListeners===void 0?o.defaultMaxListeners:U._maxListeners}o.prototype.getMaxListeners=function(){return g(this)},o.prototype.emit=function(b){for(var Q=[],B=1;B<arguments.length;B++)Q.push(arguments[B]);var R=b==="error",w=this._events;if(w!==void 0)R=R&&w.error===void 0;else if(!R)return!1;if(R){var E;if(Q.length>0&&(E=Q[0]),E instanceof Error)throw E;var N=new Error("Unhandled error."+(E?" ("+E.message+")":""));throw N.context=E,N}var K=w[b];if(K===void 0)return!1;if(typeof K=="function")e(K,this,Q);else for(var Y=K.length,ee=m(K,Y),B=0;B<Y;++B)e(ee[B],this,Q);return!0};function d(U,b,Q,B){var R,w,E;if(a(Q),w=U._events,w===void 0?(w=U._events=Object.create(null),U._eventsCount=0):(w.newListener!==void 0&&(U.emit("newListener",b,Q.listener?Q.listener:Q),w=U._events),E=w[b]),E===void 0)E=w[b]=Q,++U._eventsCount;else if(typeof E=="function"?E=w[b]=B?[Q,E]:[E,Q]:B?E.unshift(Q):E.push(Q),R=g(U),R>0&&E.length>R&&!E.warned){E.warned=!0;var N=new Error("Possible EventEmitter memory leak detected. "+E.length+" "+String(b)+" listeners added. Use emitter.setMaxListeners() to increase limit");N.name="MaxListenersExceededWarning",N.emitter=U,N.type=b,N.count=E.length,n(N)}return U}o.prototype.addListener=function(b,Q){return d(this,b,Q,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(b,Q){return d(this,b,Q,!0)};function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function I(U,b,Q){var B={fired:!1,wrapFn:void 0,target:U,type:b,listener:Q},R=u.bind(B);return R.listener=Q,B.wrapFn=R,R}o.prototype.once=function(b,Q){return a(Q),this.on(b,I(this,b,Q)),this},o.prototype.prependOnceListener=function(b,Q){return a(Q),this.prependListener(b,I(this,b,Q)),this},o.prototype.removeListener=function(b,Q){var B,R,w,E,N;if(a(Q),R=this._events,R===void 0)return this;if(B=R[b],B===void 0)return this;if(B===Q||B.listener===Q)--this._eventsCount===0?this._events=Object.create(null):(delete R[b],R.removeListener&&this.emit("removeListener",b,B.listener||Q));else if(typeof B!="function"){for(w=-1,E=B.length-1;E>=0;E--)if(B[E]===Q||B[E].listener===Q){N=B[E].listener,w=E;break}if(w<0)return this;w===0?B.shift():y(B,w),B.length===1&&(R[b]=B[0]),R.removeListener!==void 0&&this.emit("removeListener",b,N||Q)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(b){var Q,B,R;if(B=this._events,B===void 0)return this;if(B.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):B[b]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete B[b]),this;if(arguments.length===0){var w=Object.keys(B),E;for(R=0;R<w.length;++R)E=w[R],E!=="removeListener"&&this.removeAllListeners(E);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(Q=B[b],typeof Q=="function")this.removeListener(b,Q);else if(Q!==void 0)for(R=Q.length-1;R>=0;R--)this.removeListener(b,Q[R]);return this};function F(U,b,Q){var B=U._events;if(B===void 0)return[];var R=B[b];return R===void 0?[]:typeof R=="function"?Q?[R.listener||R]:[R]:Q?x(R):m(R,R.length)}o.prototype.listeners=function(b){return F(this,b,!0)},o.prototype.rawListeners=function(b){return F(this,b,!1)},o.listenerCount=function(U,b){return typeof U.listenerCount=="function"?U.listenerCount(b):f.call(U,b)},o.prototype.listenerCount=f;function f(U){var b=this._events;if(b!==void 0){var Q=b[U];if(typeof Q=="function")return 1;if(Q!==void 0)return Q.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function m(U,b){for(var Q=new Array(b),B=0;B<b;++B)Q[B]=U[B];return Q}function y(U,b){for(;b+1<U.length;b++)U[b]=U[b+1];U.pop()}function x(U){for(var b=new Array(U.length),Q=0;Q<b.length;++Q)b[Q]=U[Q].listener||U[Q];return b}function v(U,b){return new Promise(function(Q,B){function R(E){U.removeListener(b,w),B(E)}function w(){typeof U.removeListener=="function"&&U.removeListener("error",R),Q([].slice.call(arguments))}A(U,b,w,{once:!0}),b!=="error"&&L(U,R,{once:!0})})}function L(U,b,Q){typeof U.on=="function"&&A(U,"error",b,Q)}function A(U,b,Q,B){if(typeof U.on=="function")B.once?U.once(b,Q):U.on(b,Q);else if(typeof U.addEventListener=="function")U.addEventListener(b,function R(w){B.once&&U.removeEventListener(b,R),Q(w)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof U)}return Lt.exports}var Ws=an();const Xt=gt(Ws);var At={exports:{}},ji;function ks(){if(ji)return At.exports;ji=1,At.exports=e,At.exports.filter=t;var i=an().EventEmitter;function e(n,r,o){Array.isArray(o)||(o=[o]);var c=[];return o.forEach(function(a){var g=function(){var d=[].slice.call(arguments);d.unshift(a),r.emit.apply(r,d)};c.push(g),n.on(a,g)}),function(){o.forEach(function(g,d){n.removeListener(g,c[d])})}}function t(n,r){var o=new i;return e(n,o,r),o}return At.exports}var Ts=ks();const Nt=gt(Ts);var cn={exports:{}};/*! For license information please see webrtc-stats.js.LICENSE.txt */var Oi;function Ds(){return Oi||(Oi=1,function(i,e){(function(t,n){i.exports=n()})(self,()=>{return t={7:r=>{var o,c=typeof Reflect=="object"?Reflect:null,a=c&&typeof c.apply=="function"?c.apply:function(U,b,Q){return Function.prototype.apply.call(U,b,Q)};o=c&&typeof c.ownKeys=="function"?c.ownKeys:Object.getOwnPropertySymbols?function(U){return Object.getOwnPropertyNames(U).concat(Object.getOwnPropertySymbols(U))}:function(U){return Object.getOwnPropertyNames(U)};var g=Number.isNaN||function(U){return U!=U};function d(){d.init.call(this)}r.exports=d,r.exports.once=function(U,b){return new Promise(function(Q,B){function R(E){U.removeListener(b,w),B(E)}function w(){typeof U.removeListener=="function"&&U.removeListener("error",R),Q([].slice.call(arguments))}A(U,b,w,{once:!0}),b!=="error"&&function(E,N){typeof E.on=="function"&&A(E,"error",N,{once:!0})}(U,R)})},d.EventEmitter=d,d.prototype._events=void 0,d.prototype._eventsCount=0,d.prototype._maxListeners=void 0;var u=10;function I(U){if(typeof U!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof U)}function F(U){return U._maxListeners===void 0?d.defaultMaxListeners:U._maxListeners}function f(U,b,Q,B){var R,w,E,N;if(I(Q),(w=U._events)===void 0?(w=U._events=Object.create(null),U._eventsCount=0):(w.newListener!==void 0&&(U.emit("newListener",b,Q.listener?Q.listener:Q),w=U._events),E=w[b]),E===void 0)E=w[b]=Q,++U._eventsCount;else if(typeof E=="function"?E=w[b]=B?[Q,E]:[E,Q]:B?E.unshift(Q):E.push(Q),(R=F(U))>0&&E.length>R&&!E.warned){E.warned=!0;var K=new Error("Possible EventEmitter memory leak detected. "+E.length+" "+String(b)+" listeners added. Use emitter.setMaxListeners() to increase limit");K.name="MaxListenersExceededWarning",K.emitter=U,K.type=b,K.count=E.length,N=K,console&&console.warn&&console.warn(N)}return U}function m(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function y(U,b,Q){var B={fired:!1,wrapFn:void 0,target:U,type:b,listener:Q},R=m.bind(B);return R.listener=Q,B.wrapFn=R,R}function x(U,b,Q){var B=U._events;if(B===void 0)return[];var R=B[b];return R===void 0?[]:typeof R=="function"?Q?[R.listener||R]:[R]:Q?function(w){for(var E=new Array(w.length),N=0;N<E.length;++N)E[N]=w[N].listener||w[N];return E}(R):L(R,R.length)}function v(U){var b=this._events;if(b!==void 0){var Q=b[U];if(typeof Q=="function")return 1;if(Q!==void 0)return Q.length}return 0}function L(U,b){for(var Q=new Array(b),B=0;B<b;++B)Q[B]=U[B];return Q}function A(U,b,Q,B){if(typeof U.on=="function")B.once?U.once(b,Q):U.on(b,Q);else{if(typeof U.addEventListener!="function")throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof U);U.addEventListener(b,function R(w){B.once&&U.removeEventListener(b,R),Q(w)})}}Object.defineProperty(d,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(U){if(typeof U!="number"||U<0||g(U))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+U+".");u=U}}),d.init=function(){this._events!==void 0&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},d.prototype.setMaxListeners=function(U){if(typeof U!="number"||U<0||g(U))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+U+".");return this._maxListeners=U,this},d.prototype.getMaxListeners=function(){return F(this)},d.prototype.emit=function(U){for(var b=[],Q=1;Q<arguments.length;Q++)b.push(arguments[Q]);var B=U==="error",R=this._events;if(R!==void 0)B=B&&R.error===void 0;else if(!B)return!1;if(B){var w;if(b.length>0&&(w=b[0]),w instanceof Error)throw w;var E=new Error("Unhandled error."+(w?" ("+w.message+")":""));throw E.context=w,E}var N=R[U];if(N===void 0)return!1;if(typeof N=="function")a(N,this,b);else{var K=N.length,Y=L(N,K);for(Q=0;Q<K;++Q)a(Y[Q],this,b)}return!0},d.prototype.addListener=function(U,b){return f(this,U,b,!1)},d.prototype.on=d.prototype.addListener,d.prototype.prependListener=function(U,b){return f(this,U,b,!0)},d.prototype.once=function(U,b){return I(b),this.on(U,y(this,U,b)),this},d.prototype.prependOnceListener=function(U,b){return I(b),this.prependListener(U,y(this,U,b)),this},d.prototype.removeListener=function(U,b){var Q,B,R,w,E;if(I(b),(B=this._events)===void 0)return this;if((Q=B[U])===void 0)return this;if(Q===b||Q.listener===b)--this._eventsCount==0?this._events=Object.create(null):(delete B[U],B.removeListener&&this.emit("removeListener",U,Q.listener||b));else if(typeof Q!="function"){for(R=-1,w=Q.length-1;w>=0;w--)if(Q[w]===b||Q[w].listener===b){E=Q[w].listener,R=w;break}if(R<0)return this;R===0?Q.shift():function(N,K){for(;K+1<N.length;K++)N[K]=N[K+1];N.pop()}(Q,R),Q.length===1&&(B[U]=Q[0]),B.removeListener!==void 0&&this.emit("removeListener",U,E||b)}return this},d.prototype.off=d.prototype.removeListener,d.prototype.removeAllListeners=function(U){var b,Q,B;if((Q=this._events)===void 0)return this;if(Q.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):Q[U]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete Q[U]),this;if(arguments.length===0){var R,w=Object.keys(Q);for(B=0;B<w.length;++B)(R=w[B])!=="removeListener"&&this.removeAllListeners(R);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(typeof(b=Q[U])=="function")this.removeListener(U,b);else if(b!==void 0)for(B=b.length-1;B>=0;B--)this.removeListener(U,b[B]);return this},d.prototype.listeners=function(U){return x(this,U,!0)},d.prototype.rawListeners=function(U){return x(this,U,!1)},d.listenerCount=function(U,b){return typeof U.listenerCount=="function"?U.listenerCount(b):v.call(U,b)},d.prototype.listenerCount=v,d.prototype.eventNames=function(){return this._eventsCount>0?o(this._events):[]}},156:function(r,o,c){var a=this&&this.__createBinding||(Object.create?function(I,F,f,m){m===void 0&&(m=f);var y=Object.getOwnPropertyDescriptor(F,f);y&&!("get"in y?!F.__esModule:y.writable||y.configurable)||(y={enumerable:!0,get:function(){return F[f]}}),Object.defineProperty(I,m,y)}:function(I,F,f,m){m===void 0&&(m=f),I[m]=F[f]}),g=this&&this.__exportStar||function(I,F){for(var f in I)f==="default"||Object.prototype.hasOwnProperty.call(F,f)||a(F,I,f)},d=this&&this.__importDefault||function(I){return I&&I.__esModule?I:{default:I}};Object.defineProperty(o,"__esModule",{value:!0}),o.Logger=void 0;var u=c(586);Object.defineProperty(o,"Logger",{enumerable:!0,get:function(){return d(u).default}}),g(c(284),o),g(c(280),o),g(c(738),o),g(c(767),o)},185:(r,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.calculatePacketsLostRatio=o.calculateRate=o.getMediaKind=void 0,o.getMediaKind=c=>{let a=c.kind||c.mediaType;return["audio","video"].includes(a)||c.type!=="inbound-rtp"||(a=c.id.toLocaleLowerCase().includes("video")?"video":"audio"),a},o.calculateRate=(c,a,g,d)=>g&&d?(a-d)/((c-g)/1e3):0,o.calculatePacketsLostRatio=(c,a,g,d)=>{const u=c-(g??0),I=u+(a-(d??0));return I===0?0:u/I}},280:(r,o)=>{Object.defineProperty(o,"__esModule",{value:!0})},284:function(r,o,c){var a,g,d,u,I,F,f,m,y,x,v,L,A,U,b,Q,B=this&&this.__awaiter||function(D,X,T,j){return new(T||(T=Promise))(function(O,k){function W(P){try{M(j.next(P))}catch(z){k(z)}}function H(P){try{M(j.throw(P))}catch(z){k(z)}}function M(P){var z;P.done?O(P.value):(z=P.value,z instanceof T?z:new T(function(ie){ie(z)})).then(W,H)}M((j=j.apply(D,X||[])).next())})},R=this&&this.__classPrivateFieldSet||function(D,X,T,j,O){if(j==="m")throw new TypeError("Private method is not writable");if(j==="a"&&!O)throw new TypeError("Private accessor was defined without a setter");if(typeof X=="function"?D!==X||!O:!X.has(D))throw new TypeError("Cannot write private member to an object whose class did not declare it");return j==="a"?O.call(D,T):O?O.value=T:X.set(D,T),T},w=this&&this.__classPrivateFieldGet||function(D,X,T,j){if(T==="a"&&!j)throw new TypeError("Private accessor was defined without a getter");if(typeof X=="function"?D!==X||!j:!X.has(D))throw new TypeError("Cannot read private member from an object whose class did not declare it");return T==="m"?j:T==="a"?j.call(D):j?j.value:X.get(D)},E=this&&this.__importDefault||function(D){return D&&D.__esModule?D:{default:D}};Object.defineProperty(o,"__esModule",{value:!0}),o.WebRTCStats=void 0;const N=c(7),K=E(c(586)),Y=c(738),ee=c(185);class J extends N.EventEmitter{constructor(X){super(),a.add(this),g.set(this,void 0),d.set(this,void 0),u.set(this,void 0),I.set(this,null),F.set(this,void 0),f.set(this,null),this.start=()=>{w(this,F,"f").info("WebRTC statistics collection is starting..."),R(this,f,null,"f"),R(this,I,setInterval(w(this,m,"f"),w(this,d,"f")),"f")},this.stop=()=>{w(this,I,"f")&&(clearInterval(w(this,I,"f")),R(this,I,null,"f"),w(this,F,"f").info("WebRTC statistics collection has stopped."))},m.set(this,()=>B(this,void 0,void 0,function*(){let T,j;try{w(this,F,"f").trace("Requesting WebRTC statistics..."),T=yield w(this,g,"f").call(this),j=new Date().toISOString()}catch(W){return w(this,F,"f").error("Problem collecting the WebRTC statistics.",W),void this.emit("error",`Problem collecting the WebRTC statistics - ${W}`)}const O=Array.from(T.values()),k={timestamp:j,input:{audio:[],video:[]},output:{audio:[],video:[]}};w(this,u,"f")&&(k.rawStats=T);for(let W=0;W<Object.keys(O).length;W++){const H=O[W];switch(H.type){case"outbound-rtp":const M=H,P=(0,ee.getMediaKind)(M);P==="audio"?yield w(this,a,"m",v).call(this,T,M,k):P==="video"&&(yield w(this,a,"m",L).call(this,T,M,k));break;case"inbound-rtp":const z=H;let ie=(0,ee.getMediaKind)(z);ie==="audio"?yield w(this,a,"m",U).call(this,T,z,k):ie==="video"&&(yield w(this,a,"m",b).call(this,T,z,k));break;case"candidate-pair":const ge=H;ge.nominated&&w(this,a,"m",Q).call(this,ge,k)}}R(this,f,k,"f"),this.emit("stats",k)})),R(this,F,K.default.get("WebRTCStats"),"f"),R(this,g,X.getStats,"f"),R(this,d,X.getStatsInterval||1e3,"f"),R(this,u,!!X.includeRawStats,"f")}}o.WebRTCStats=J,g=new WeakMap,d=new WeakMap,u=new WeakMap,I=new WeakMap,F=new WeakMap,f=new WeakMap,m=new WeakMap,a=new WeakSet,y=function(D,X){if(X){const T=D.get(X);if(T)return{mimeType:T.mimeType}}return{}},x=function(D,X,T){return B(this,void 0,void 0,function*(){var j,O,k,W;const H=(0,ee.calculateRate)(X.timestamp,X.bytesSent,T==null?void 0:T.timestamp,T==null?void 0:T.totalBytesSent),M=(0,ee.calculateRate)(X.timestamp,X.packetsSent,T==null?void 0:T.timestamp,T==null?void 0:T.totalPacketsSent),P=w(this,a,"m",y).call(this,D,X.codecId);return Object.assign({id:X.id,timestamp:X.timestamp,mid:X.mid,totalBytesSent:X.bytesSent,bytesSentDelta:X.bytesSent-((j=T==null?void 0:T.totalBytesSent)!==null&&j!==void 0?j:0),totalPacketsSent:X.packetsSent,packetsSentDelta:X.packetsSent-((O=T==null?void 0:T.totalPacketsSent)!==null&&O!==void 0?O:0),bitrate:H,packetRate:M,targetBitrate:X.targetBitrate,retransmittedPacketsSent:X.retransmittedPacketsSent,retransmittedPacketsSentDelta:X.retransmittedPacketsSent-((k=T==null?void 0:T.retransmittedPacketsSent)!==null&&k!==void 0?k:0),retransmittedBytesSent:X.retransmittedBytesSent,retransmittedBytesSentDelta:X.retransmittedBytesSent-((W=T==null?void 0:T.retransmittedBytesSent)!==null&&W!==void 0?W:0)},P)})},v=function(D,X,T){return B(this,void 0,void 0,function*(){var j;const O=(j=w(this,f,"f"))===null||j===void 0?void 0:j.output.audio.find(H=>H.id===X.id);if(O&&X.timestamp-O.timestamp<=0)return;const k=yield w(this,a,"m",x).call(this,D,X,O),W=Object.assign({},k);T.output.audio.push(W)})},L=function(D,X,T){return B(this,void 0,void 0,function*(){var j;const O=(j=w(this,f,"f"))===null||j===void 0?void 0:j.output.video.find(M=>M.id===X.id);if(O&&X.timestamp-O.timestamp<=0)return;const k=yield w(this,a,"m",x).call(this,D,X,O);let W=Y.QualityLimitationReason.none;X.qualityLimitationReason&&(W=X.qualityLimitationReason);const H=Object.assign(Object.assign({},k),{frameWidth:X.frameWidth,frameHeight:X.frameHeight,framesPerSecond:X.framesPerSecond,framesSent:X.framesSent,qualityLimitationReason:W,qualityLimitationDurations:X.qualityLimitationDurations});T.output.video.push(H)})},A=function(D,X,T){return B(this,void 0,void 0,function*(){var j,O;const k=(0,ee.calculateRate)(X.timestamp,X.bytesReceived,T==null?void 0:T.timestamp,T==null?void 0:T.totalBytesReceived),W=(0,ee.calculateRate)(X.timestamp,X.packetsReceived,T==null?void 0:T.timestamp,T==null?void 0:T.totalPacketsReceived),H=(0,ee.calculatePacketsLostRatio)(X.packetsLost,X.packetsReceived,T==null?void 0:T.totalPacketsLost,T==null?void 0:T.totalPacketsReceived),M=((j=X.packetsLost)!==null&&j!==void 0?j:0)-((O=T==null?void 0:T.totalPacketsLost)!==null&&O!==void 0?O:0),P=w(this,a,"m",y).call(this,D,X.codecId);return Object.assign({id:X.id,timestamp:X.timestamp,mid:X.mid,trackIdentifier:X.trackIdentifier,jitter:X.jitter,jitterBufferDelay:X.jitterBufferDelay,jitterBufferEmittedCount:X.jitterBufferEmittedCount,totalBytesReceived:X.bytesReceived,totalPacketsReceived:X.packetsReceived,totalPacketsLost:X.packetsLost,bitrate:k,packetRate:W,packetLossRatio:H,packetLossDelta:M},P)})},U=function(D,X,T){return B(this,void 0,void 0,function*(){var j;const O=(j=w(this,f,"f"))===null||j===void 0?void 0:j.input.audio.find(W=>W.id===X.id);if(O&&X.timestamp-O.timestamp<=0)return;const k=yield w(this,a,"m",A).call(this,D,X,O);T.input.audio.push(k)})},b=function(D,X,T){return B(this,void 0,void 0,function*(){var j;const O=(j=w(this,f,"f"))===null||j===void 0?void 0:j.input.video.find(H=>H.id===X.id);if(O&&X.timestamp-O.timestamp<=0)return;const k=yield w(this,a,"m",A).call(this,D,X,O),W=Object.assign(Object.assign({},k),{keyFramesDecoded:X.keyFramesDecoded,frameHeight:X.frameHeight,frameWidth:X.frameWidth,framesDecoded:X.framesDecoded,framesDropped:X.framesDropped,framesPerSecond:X.framesPerSecond,framesReceived:X.framesReceived});T.input.video.push(W)})},Q=function(D,X){X.totalRoundTripTime=D.totalRoundTripTime,X.currentRoundTripTime=D.currentRoundTripTime,X.responsesReceived=D.responsesReceived,X.availableOutgoingBitrate=D.availableOutgoingBitrate,X.availableIncomingBitrate=D.availableIncomingBitrate}},586:function(r,o,c){var a,g;(function(){var d,u={VERSION:"1.6.1"},I={},F=function(L,A){return function(){return A.apply(L,arguments)}},f=function(){var L,A,U=arguments,b=U[0];for(A=1;A<U.length;A++)for(L in U[A])!(L in b)&&U[A].hasOwnProperty(L)&&(b[L]=U[A][L]);return b},m=function(L,A){return{value:L,name:A}};u.TRACE=m(1,"TRACE"),u.DEBUG=m(2,"DEBUG"),u.INFO=m(3,"INFO"),u.TIME=m(4,"TIME"),u.WARN=m(5,"WARN"),u.ERROR=m(8,"ERROR"),u.OFF=m(99,"OFF");var y=function(L){this.context=L,this.setLevel(L.filterLevel),this.log=this.info};y.prototype={setLevel:function(L){L&&"value"in L&&(this.context.filterLevel=L)},getLevel:function(){return this.context.filterLevel},enabledFor:function(L){var A=this.context.filterLevel;return L.value>=A.value},trace:function(){this.invoke(u.TRACE,arguments)},debug:function(){this.invoke(u.DEBUG,arguments)},info:function(){this.invoke(u.INFO,arguments)},warn:function(){this.invoke(u.WARN,arguments)},error:function(){this.invoke(u.ERROR,arguments)},time:function(L){typeof L=="string"&&L.length>0&&this.invoke(u.TIME,[L,"start"])},timeEnd:function(L){typeof L=="string"&&L.length>0&&this.invoke(u.TIME,[L,"end"])},invoke:function(L,A){d&&this.enabledFor(L)&&d(A,f({level:L},this.context))}};var x,v=new y({filterLevel:u.OFF});(x=u).enabledFor=F(v,v.enabledFor),x.trace=F(v,v.trace),x.debug=F(v,v.debug),x.time=F(v,v.time),x.timeEnd=F(v,v.timeEnd),x.info=F(v,v.info),x.warn=F(v,v.warn),x.error=F(v,v.error),x.log=x.info,u.setHandler=function(L){d=L},u.setLevel=function(L){for(var A in v.setLevel(L),I)I.hasOwnProperty(A)&&I[A].setLevel(L)},u.getLevel=function(){return v.getLevel()},u.get=function(L){return I[L]||(I[L]=new y(f({name:L},v.context)))},u.createDefaultHandler=function(L){(L=L||{}).formatter=L.formatter||function(b,Q){Q.name&&b.unshift("["+Q.name+"]")};var A={},U=function(b,Q){Function.prototype.apply.call(b,console,Q)};return typeof console>"u"?function(){}:function(b,Q){b=Array.prototype.slice.call(b);var B,R=console.log;Q.level===u.TIME?(B=(Q.name?"["+Q.name+"] ":"")+b[0],b[1]==="start"?console.time?console.time(B):A[B]=new Date().getTime():console.timeEnd?console.timeEnd(B):U(R,[B+": "+(new Date().getTime()-A[B])+"ms"])):(Q.level===u.WARN&&console.warn?R=console.warn:Q.level===u.ERROR&&console.error?R=console.error:Q.level===u.INFO&&console.info?R=console.info:Q.level===u.DEBUG&&console.debug?R=console.debug:Q.level===u.TRACE&&console.trace&&(R=console.trace),L.formatter(b,Q),U(R,b))}},u.useDefaults=function(L){u.setLevel(L&&L.defaultLevel||u.DEBUG),u.setHandler(u.createDefaultHandler(L))},u.setDefaults=u.useDefaults,(g=typeof(a=u)=="function"?a.call(o,c,o,r):a)===void 0||(r.exports=g)})()},738:(r,o)=>{var c;Object.defineProperty(o,"__esModule",{value:!0}),o.QualityLimitationReason=void 0,function(a){a[a.none=0]="none",a[a.cpu=1]="cpu",a[a.bandwidth=2]="bandwidth",a[a.other=3]="other"}(c||(o.QualityLimitationReason=c={}))},767:(r,o)=>{Object.defineProperty(o,"__esModule",{value:!0})}},n={},function r(o){var c=n[o];if(c!==void 0)return c.exports;var a=n[o]={exports:{}};return t[o].call(a.exports,a,a.exports,r),a.exports}(156);var t,n})}(cn)),cn.exports}var Hs=Ds();const Ft=Ne.get("PeerConnectionStats"),Ki={stats:"stats"},Js=i=>{const{input:e,output:t,rawStats:n,...r}=i;return{...r,audio:{inbounds:i.input.audio.map(({packetLossRatio:c,packetLossDelta:a,bitrate:g,...d})=>({packetsLostRatioPerSecond:c,packetsLostDeltaPerSecond:a,bitrateBitsPerSecond:g*8,bitrate:g,...d})),outbounds:i.output.audio.map(({packetLossRatio:c,packetLossDelta:a,bitrate:g,...d})=>({packetsLostRatioPerSecond:c,packetsLostDeltaPerSecond:a,bitrateBitsPerSecond:g*8,bitrate:g,...d}))},video:{inbounds:i.input.video.map(({packetLossRatio:c,packetLossDelta:a,bitrate:g,...d})=>({packetsLostRatioPerSecond:c,packetsLostDeltaPerSecond:a,bitrateBitsPerSecond:g*8,bitrate:g,...d})),outbounds:i.output.video.map(({packetLossRatio:c,packetLossDelta:a,bitrate:g,...d})=>({packetsLostRatioPerSecond:c,packetsLostDeltaPerSecond:a,bitrateBitsPerSecond:g*8,bitrate:g,...d}))},raw:i.rawStats}};class Ys extends Xt{constructor(e,t={statsIntervalMs:1e3,autoInitStats:!0}){super(),this.peer=e,this.collection=null,this.initialized=!1,t.autoInitStats&&this.init(t.statsIntervalMs)}init(e){if(this.initialized){Ft.warn("PeerConnectionStats.init() has already been called. Automatic initialization occurs when the PeerConnectionStats object is constructed.");return}Ft.info("Initializing peer connection stats");const t=this.peer;try{this.collection=new Hs.WebRTCStats({getStatsInterval:e,getStats:()=>t.getStats(),includeRawStats:!0}),this.collection.on("stats",n=>{const r=Js(n);xe.addStats(r),this.emit(Ki.stats,r)}),this.collection.start(),this.initialized=!0}catch(n){Ft.error(n)}}parseStats(e){return Ft.warn("The parseStats method is deprecated and will be removed in future releases."),null}stop(){Ft.info("Stopping peer connection stats"),this.collection.stop()}}var he={},We={},ln={},dn={exports:{}},_i;function qi(){if(_i)return dn.exports;_i=1;var i=dn.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return e.address!=null?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return e.subtype!=null?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return e.sessionConfig!=null?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=e.raddr!=null?" raddr %s rport %d":"%v%v",t+=e.tcptype!=null?" tcptype %s":"%v",e.generation!=null&&(t+=" generation %d"),t+=e["network-id"]!=null?" network-id %d":"%v",t+=e["network-cost"]!=null?" network-cost %d":"%v",t}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return e.attribute!=null&&(t+=" %s",e.value!=null&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return e.maxMessageSize!=null?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(e.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=e.id!=null?"id=%s %s":"%v%s",t+=e.mediaClockValue!=null?"=%s":"",t+=e.rateNumerator!=null?" rate=%s":"",t+=e.rateDenominator!=null?"/%s":"",t}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};return Object.keys(i).forEach(function(e){var t=i[e];t.forEach(function(n){n.reg||(n.reg=/(.*)/),n.format||(n.format="%s")})}),dn.exports}var $i;function Ms(){return $i||($i=1,function(i){var e=function(a){return String(Number(a))===a?Number(a):a},t=function(a,g,d,u){if(u&&!d)g[u]=e(a[1]);else for(var I=0;I<d.length;I+=1)a[I+1]!=null&&(g[d[I]]=e(a[I+1]))},n=function(a,g,d){var u=a.name&&a.names;a.push&&!g[a.push]?g[a.push]=[]:u&&!g[a.name]&&(g[a.name]={});var I=a.push?{}:u?g[a.name]:g;t(d.match(a.reg),I,a.names,a.name),a.push&&g[a.push].push(I)},r=qi(),o=RegExp.prototype.test.bind(/^([a-z])=(.*)/);i.parse=function(a){var g={},d=[],u=g;return a.split(/(\r\n|\r|\n)/).filter(o).forEach(function(I){var F=I[0],f=I.slice(2);F==="m"&&(d.push({rtp:[],fmtp:[]}),u=d[d.length-1]);for(var m=0;m<(r[F]||[]).length;m+=1){var y=r[F][m];if(y.reg.test(f))return n(y,u,f)}}),g.media=d,g};var c=function(a,g){var d=g.split(/=(.+)/,2);return d.length===2?a[d[0]]=e(d[1]):d.length===1&&g.length>1&&(a[d[0]]=void 0),a};i.parseParams=function(a){return a.split(/;\s?/).reduce(c,{})},i.parseFmtpConfig=i.parseParams,i.parsePayloads=function(a){return a.toString().split(" ").map(Number)},i.parseRemoteCandidates=function(a){for(var g=[],d=a.split(" ").map(e),u=0;u<d.length;u+=3)g.push({component:d[u],ip:d[u+1],port:d[u+2]});return g},i.parseImageAttributes=function(a){return a.split(" ").map(function(g){return g.substring(1,g.length-1).split(",").reduce(c,{})})},i.parseSimulcastStreamList=function(a){return a.split(";").map(function(g){return g.split(",").map(function(d){var u,I=!1;return d[0]!=="~"?u=e(d):(u=e(d.substring(1,d.length)),I=!0),{scid:u,paused:I}})})}}(ln)),ln}var un,er;function Ps(){if(er)return un;er=1;var i=qi(),e=/%[sdv%]/g,t=function(c){var a=1,g=arguments,d=g.length;return c.replace(e,function(u){if(a>=d)return u;var I=g[a];switch(a+=1,u){case"%%":return"%";case"%s":return String(I);case"%d":return Number(I);case"%v":return""}})},n=function(c,a,g){var d=a.format instanceof Function?a.format(a.push?g:g[a.name]):a.format,u=[c+"="+d];if(a.names)for(var I=0;I<a.names.length;I+=1){var F=a.names[I];a.name?u.push(g[a.name][F]):u.push(g[a.names[I]])}else u.push(g[a.name]);return t.apply(null,u)},r=["v","o","s","i","u","e","p","c","b","t","r","z","a"],o=["i","c","b","a"];return un=function(c,a){a=a||{},c.version==null&&(c.version=0),c.name==null&&(c.name=" "),c.media.forEach(function(I){I.payloads==null&&(I.payloads="")});var g=a.outerOrder||r,d=a.innerOrder||o,u=[];return g.forEach(function(I){i[I].forEach(function(F){F.name in c&&c[F.name]!=null?u.push(n(I,F,c)):F.push in c&&c[F.push]!=null&&c[F.push].forEach(function(f){u.push(n(I,F,f))})})}),c.media.forEach(function(I){u.push(n("m",i.m[0],I)),d.forEach(function(F){i[F].forEach(function(f){f.name in I&&I[f.name]!=null?u.push(n(F,f,I)):f.push in I&&I[f.push]!=null&&I[f.push].forEach(function(m){u.push(n(F,f,m))})})})}),u.join(`\r
`)+`\r
`},un}var tr;function zs(){if(tr)return We;tr=1;var i=Ms(),e=Ps();return We.write=e,We.parse=i.parse,We.parseParams=i.parseParams,We.parseFmtpConfig=i.parseFmtpConfig,We.parsePayloads=i.parsePayloads,We.parseRemoteCandidates=i.parseRemoteCandidates,We.parseImageAttributes=i.parseImageAttributes,We.parseSimulcastStreamList=i.parseSimulcastStreamList,We}var gn,nr;function js(){return nr||(nr=1,gn=function(i){const e=new Intl.Collator(i,{sensitivity:"base"});return(t,n)=>e.compare(t,n)==0}),gn}var hn,ir;function rr(){if(ir)return hn;ir=1;class i{constructor(t,n,r,o,c,a,g,d,u){this.foundation=t,this.componentId=n,this.transport=r,this.priority=o,this.address=c,this.port=a,this.type=g,this.relAddr=d,this.relPort=u}equals(t){return t.foundation===this.foundation&&t.componentId===this.componentId&&t.transport===this.transport&&t.priority===this.priority&&t.address===this.address&&t.port===this.port&&t.type===this.type&&t.relAddr===this.relAddr&&t.relPort===this.relPort}clone(){return new i(this.foundation,this.componentId,this.transport,this.priority,this.address,this.port,this.type,this.relAddr,this.relPort)}plain(){const t={foundation:this.foundation,componentId:this.componentId,transport:this.transport,priority:this.priority,address:this.address,port:this.port,type:this.type};return this.relAddr&&(t.relAddr=this.relAddr),this.relPort&&(t.relPort=this.relPort),t}getFoundation(){return this.foundation}getComponentId(){return this.componentId}getTransport(){return this.transport}getPriority(){return this.priority}getAddress(){return this.address}getPort(){return this.port}getType(){return this.type}getRelAddr(){return this.relAddr}getRelPort(){return this.relPort}}return i.expand=function(e){return e.constructor.name==="CandidateInfo"?e:(e=e,new i(e.foundation,e.componentId,e.transport,e.priority,e.address,e.port,e.type,e.relAddr,e.relPort))},i.clone=function(e){return e.constructor.name==="CandidateInfo"?e.clone():i.expand(e)},hn=i,hn}var fn,sr;function Wt(){if(sr)return fn;sr=1;class i{constructor(t,n){this.id=t,this.params=n||[]}clone(){return new i(this.id,this.params)}plain(){return this.params.length?{id:this.id,params:this.params}:{id:this.id}}getId(){return this.id}getParams(){return this.params}}return i.expand=function(e){return e.constructor.name==="RTCPFeedbackInfo"?e:(e=e,new i(e.id,e.params))},i.clone=function(e){return e.constructor.name==="RTCPFeedbackInfo"?e.clone():i.expand(e)},fn=i,fn}var mn,or;function kt(){if(or)return mn;or=1;const i=Wt();class e{constructor(n,r,o){this.codec=n,this.type=r,this.params={},this.rtcpfbs=new Set,o&&this.addParams(o)}clone(){const n=new e(this.codec,this.type,this.params);this.hasRTX()&&n.setRTX(this.getRTX());for(const r of this.rtcpfbs)n.addRTCPFeedback(r.clone());return this.hasChannels()&&n.setChannels(this.getChannels()),n}plain(){const n={codec:this.codec,type:this.type};this.rtx&&(n.rtx=this.rtx),this.channels&&(n.channels=this.channels),Object.keys(this.params).length&&(n.params=this.params);for(const r of this.rtcpfbs)n.rtcpfbs||(n.rtcpfbs=[]),n.rtcpfbs.push(r.plain());return n}setRTX(n){this.rtx=n}getType(){return this.type}setType(n){this.type=n}getCodec(){return this.codec}getParams(){return this.params}addParams(n){for(const r in n)this.params[r]=n[r]}addParam(n,r){this.params[n]=r}hasParam(n){return Object.hasOwnProperty.call(this.params,n)}getParam(n,r=void 0){if(this.hasParam(n))return this.params[n];if(r===void 0)throw new Error(`param ${n} not found and no default value provided`);return""+r}hasRTX(){return this.rtx}getRTX(){return this.rtx}hasChannels(){return this.channels}getChannels(){return this.channels}setChannels(n){this.channels=n}addRTCPFeedback(n){this.rtcpfbs.add(n)}getRTCPFeedbacks(){return this.rtcpfbs}}return e.expand=function(t){if(t.constructor.name==="CodecInfo")return t;t=t;const n=new e(t.codec,t.type,t.params);t.rtx&&n.setRTX(t.rtx),t.channels&&n.setChannels(t.channels);for(const r of t.rtcpfbs||[]){const o=i.expand(r);n.addRTCPFeedback(o)}return n},e.clone=function(t){return t.constructor.name==="CodecInfo"?t.clone():e.expand(t)},e.MapFromNames=function(t,n,r){var o;const c=new Map;let a=96;for(const g of t){let d;const u=g.split(";"),I=u.shift().toLowerCase().trim();I==="pcmu"?d=0:I==="pcma"?d=8:d=++a;const F=new e(I,d);I==="opus"?F.setChannels(2):I==="multiopus"&&F.setChannels(6),n&&I!=="ulpfec"&&I!=="flexfec-03"&&I!=="red"&&F.setRTX(++a);for(const f of r||[])F.addRTCPFeedback(new i(f.id,f.params));for(const f of u){let m=f.split("=");F.addParam(m[0].trim(),(o=m[1])===null||o===void 0?void 0:o.trim())}c.set(d,F)}return c},mn=e,mn}var Fn,ar;function pn(){if(ar)return Fn;ar=1;function i(){var e=this;if(!(this instanceof i))return new(Function.prototype.bind.apply(i,[null].concat(Array.prototype.slice.call(arguments))));Array.from(arguments).forEach(function(t){e[t]=Symbol.for("MEDOOZE_SEMANTIC_SDP_"+t)})}return Fn=i,Fn}var Un,cr;function In(){if(cr)return Un;cr=1;const e=pn()("ACTIVE","PASSIVE","ACTPASS","INACTIVE");return e.byValue=function(t){switch(t){case e.ACTIVE:case e.PASSIVE:case e.ACTPASS:case e.INACTIVE:return t}return e[t.toUpperCase()]},e.toString=function(t){switch(t){case e.ACTIVE:return"active";case e.PASSIVE:return"passive";case e.ACTPASS:return"actpass";case e.INACTIVE:return"inactive"}},e.reverse=function(t,n){switch(t){case e.ACTIVE:return e.PASSIVE;case e.PASSIVE:return e.ACTIVE;case e.ACTPASS:return n?e.ACTIVE:e.PASSIVE;case e.INACTIVE:return e.INACTIVE}},Un=e,Un}var Bn,lr;function dr(){if(lr)return Bn;lr=1;const i=In();class e{constructor(n,r,o){this.setup=n,this.hash=r,this.fingerprint=o}clone(){return new e(this.setup,this.hash,this.fingerprint)}plain(){return{setup:i.toString(this.setup),hash:this.hash,fingerprint:this.fingerprint}}getFingerprint(){return this.fingerprint}getHash(){return this.hash}getSetup(){return this.setup}setSetup(n){this.setup=n}}return e.expand=function(t){return t.constructor.name==="DTLSInfo"?t:(t=t,new e(t.setup?i.byValue(t.setup):i.ACTPASS,t.hash,t.fingerprint))},e.clone=function(t){return t.constructor.name==="DTLSInfo"?t.clone():e.expand(t)},Bn=e,Bn}var bn,ur;function gr(){if(ur)return bn;ur=1;class i{constructor(t,n,r,o){this.tag=t,this.suite=n,this.keyParams=r,this.sessionParams=o}clone(){return new i(this.tag,this.suite,this.keyParams,this.sessionParams)}plain(){return{tag:this.tag,suite:this.suite,keyParams:this.keyParams,sessionParams:this.sessionParams}}getSessionParams(){return this.sessionParams}getKeyParams(){return this.keyParams}getSuite(){return this.suite}getTag(){return this.tag}}return i.expand=function(e){return e.constructor.name==="CryptoInfo"?e:(e=e,new i(e.tag,e.suite,e.keyParams,e.sessionParams))},i.clone=function(e){return e.constructor.name==="CryptoInfo"?e.clone():i.expand(e)},bn=i,bn}var Tt={exports:{}},Dt={exports:{}},yn={},pt={},hr;function Os(){if(hr)return pt;hr=1,pt.byteLength=a,pt.toByteArray=d,pt.fromByteArray=F;for(var i=[],e=[],t=typeof Uint8Array<"u"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,o=n.length;r<o;++r)i[r]=n[r],e[n.charCodeAt(r)]=r;e[45]=62,e[95]=63;function c(f){var m=f.length;if(m%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var y=f.indexOf("=");y===-1&&(y=m);var x=y===m?0:4-y%4;return[y,x]}function a(f){var m=c(f),y=m[0],x=m[1];return(y+x)*3/4-x}function g(f,m,y){return(m+y)*3/4-y}function d(f){var m,y=c(f),x=y[0],v=y[1],L=new t(g(f,x,v)),A=0,U=v>0?x-4:x,b;for(b=0;b<U;b+=4)m=e[f.charCodeAt(b)]<<18|e[f.charCodeAt(b+1)]<<12|e[f.charCodeAt(b+2)]<<6|e[f.charCodeAt(b+3)],L[A++]=m>>16&255,L[A++]=m>>8&255,L[A++]=m&