TrtcWrapper.2.0.0-dev.0.0.2.bundle.js 582 KB

1
  1. !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.TrtcWrapper=t():e.TrtcWrapper=t()}(self,(()=>(()=>{var e={134:function(e,t,n){e.exports=function(e){function t(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function r(e){return function(){var n=this,r=arguments;return new Promise((function(i,o){var a=e.apply(n,r);function s(e){t(a,i,o,s,c,"next",e)}function c(e){t(a,i,o,s,c,"throw",e)}s(void 0)}))}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;var s=function(e){try{return!!e()}catch(e){return!0}},c={}.toString,u=function(e){return c.call(e).slice(8,-1)},l="".split,d=s((function(){return!Object("z").propertyIsEnumerable(0)}))?function(e){return"String"==u(e)?l.call(e,""):Object(e)}:Object,h=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},p=function(e){return d(h(e))},f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{};function m(e,t){return e(t={exports:{}},t.exports),t.exports}var v,_,g=function(e){return e&&e.Math==Math&&e},y=g("object"==typeof globalThis&&globalThis)||g("object"==typeof window&&window)||g("object"==typeof self&&self)||g("object"==typeof f&&f)||function(){return this}()||Function("return this")(),S=function(e,t){try{Object.defineProperty(y,e,{value:t,configurable:!0,writable:!0})}catch(n){y[e]=t}return t},b=y["__core-js_shared__"]||S("__core-js_shared__",{}),k=m((function(e){(e.exports=function(e,t){return b[e]||(b[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.16.0",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),I=function(e){return Object(h(e))},T={}.hasOwnProperty,w=Object.hasOwn||function(e,t){return T.call(I(e),t)},R=0,E=Math.random(),C=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++R+E).toString(36)},x=function(e){return"function"==typeof e?e:void 0},A=function(e,t){return arguments.length<2?x(y[e]):y[e]&&y[e][t]},P=A("navigator","userAgent")||"",D=y.process,L=y.Deno,M=D&&D.versions||L&&L.version,N=M&&M.v8;N?_=(v=N.split("."))[0]<4?1:v[0]+v[1]:P&&(!(v=P.match(/Edge\/(\d+)/))||v[1]>=74)&&(v=P.match(/Chrome\/(\d+)/))&&(_=v[1]);var O,U=_&&+_,V=!!Object.getOwnPropertySymbols&&!s((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&U&&U<41})),F=V&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,j=k("wks"),B=y.Symbol,H=F?B:B&&B.withoutSetter||C,z=function(e){return w(j,e)&&(V||"string"==typeof j[e])||(V&&w(B,e)?j[e]=B[e]:j[e]=H("Symbol."+e)),j[e]},G=function(e){return"object"==typeof e?null!==e:"function"==typeof e},W=function(e){if(!G(e))throw TypeError(String(e)+" is not an object");return e},J=!s((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),q=y.document,K=G(q)&&G(q.createElement),Q=function(e){return K?q.createElement(e):{}},X=!J&&!s((function(){return 7!=Object.defineProperty(Q("div"),"a",{get:function(){return 7}}).a})),$=F?function(e){return"symbol"==typeof e}:function(e){var t=A("Symbol");return"function"==typeof t&&Object(e)instanceof t},Y=z("toPrimitive"),Z=function(e){var t=function(e,t){if(!G(e)||$(e))return e;var n,r=e[Y];if(void 0!==r){if(void 0===t&&(t="default"),n=r.call(e,t),!G(n)||$(n))return n;throw TypeError("Can't convert object to primitive value")}return void 0===t&&(t="number"),function(e,t){var n,r;if("string"===t&&"function"==typeof(n=e.toString)&&!G(r=n.call(e)))return r;if("function"==typeof(n=e.valueOf)&&!G(r=n.call(e)))return r;if("string"!==t&&"function"==typeof(n=e.toString)&&!G(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")}(e,t)}(e,"string");return $(t)?t:String(t)},ee=Object.defineProperty,te={f:J?ee:function(e,t,n){if(W(e),t=Z(t),W(n),X)try{return ee(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},ne=Math.ceil,re=Math.floor,ie=function(e){return isNaN(e=+e)?0:(e>0?re:ne)(e)},oe=Math.min,ae=function(e){return e>0?oe(ie(e),9007199254740991):0},se=Math.max,ce=Math.min,ue=function(e){return function(t,n,r){var i,o=p(t),a=ae(o.length),s=function(e,t){var n=ie(e);return n<0?se(n+t,0):ce(n,t)}(r,a);if(e&&n!=n){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===n)return e||s||0;return!e&&-1}},le={includes:ue(!0),indexOf:ue(!1)},de={},he=le.indexOf,pe=function(e,t){var n,r=p(e),i=0,o=[];for(n in r)!w(de,n)&&w(r,n)&&o.push(n);for(;t.length>i;)w(r,n=t[i++])&&(~he(o,n)||o.push(n));return o},fe=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],me=Object.keys||function(e){return pe(e,fe)},ve=J?Object.defineProperties:function(e,t){W(e);for(var n,r=me(t),i=r.length,o=0;i>o;)te.f(e,n=r[o++],t[n]);return e},_e=A("document","documentElement"),ge=k("keys"),ye=function(e){return ge[e]||(ge[e]=C(e))},Se=ye("IE_PROTO"),be=function(){},ke=function(e){return"<script>"+e+"<\/script>"},Ie=function(e){e.write(ke("")),e.close();var t=e.parentWindow.Object;return e=null,t},Te=function(){try{O=new ActiveXObject("htmlfile")}catch(e){}Te=document.domain&&O?Ie(O):function(){var e,t=Q("iframe");if(t.style)return t.style.display="none",_e.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(ke("document.F=Object")),e.close(),e.F}()||Ie(O);for(var e=fe.length;e--;)delete Te.prototype[fe[e]];return Te()};de[Se]=!0;var we=Object.create||function(e,t){var n;return null!==e?(be.prototype=W(e),n=new be,be.prototype=null,n[Se]=e):n=Te(),void 0===t?n:ve(n,t)},Re=z("unscopables"),Ee=Array.prototype;null==Ee[Re]&&te.f(Ee,Re,{configurable:!0,value:we(null)});var Ce=function(e){Ee[Re][e]=!0},xe={},Ae=Function.toString;"function"!=typeof b.inspectSource&&(b.inspectSource=function(e){return Ae.call(e)});var Pe,De,Le,Me=b.inspectSource,Ne=y.WeakMap,Oe="function"==typeof Ne&&/native code/.test(Me(Ne)),Ue=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Ve=J?function(e,t,n){return te.f(e,t,Ue(1,n))}:function(e,t,n){return e[t]=n,e},Fe=y.WeakMap;if(Oe||b.state){var je=b.state||(b.state=new Fe),Be=je.get,He=je.has,ze=je.set;Pe=function(e,t){if(He.call(je,e))throw new TypeError("Object already initialized");return t.facade=e,ze.call(je,e,t),t},De=function(e){return Be.call(je,e)||{}},Le=function(e){return He.call(je,e)}}else{var Ge=ye("state");de[Ge]=!0,Pe=function(e,t){if(w(e,Ge))throw new TypeError("Object already initialized");return t.facade=e,Ve(e,Ge,t),t},De=function(e){return w(e,Ge)?e[Ge]:{}},Le=function(e){return w(e,Ge)}}var We,Je,qe,Ke={set:Pe,get:De,has:Le,enforce:function(e){return Le(e)?De(e):Pe(e,{})},getterFor:function(e){return function(t){var n;if(!G(t)||(n=De(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}},Qe={}.propertyIsEnumerable,Xe=Object.getOwnPropertyDescriptor,$e={f:Xe&&!Qe.call({1:2},1)?function(e){var t=Xe(this,e);return!!t&&t.enumerable}:Qe},Ye=Object.getOwnPropertyDescriptor,Ze={f:J?Ye:function(e,t){if(e=p(e),t=Z(t),X)try{return Ye(e,t)}catch(e){}if(w(e,t))return Ue(!$e.f.call(e,t),e[t])}},et=m((function(e){var t=Ke.get,n=Ke.enforce,r=String(String).split("String");(e.exports=function(e,t,i,o){var a,s=!!o&&!!o.unsafe,c=!!o&&!!o.enumerable,u=!!o&&!!o.noTargetGet;"function"==typeof i&&("string"!=typeof t||w(i,"name")||Ve(i,"name",t),(a=n(i)).source||(a.source=r.join("string"==typeof t?t:""))),e!==y?(s?!u&&e[t]&&(c=!0):delete e[t],c?e[t]=i:Ve(e,t,i)):c?e[t]=i:S(t,i)})(Function.prototype,"toString",(function(){return"function"==typeof this&&t(this).source||Me(this)}))})),tt=fe.concat("length","prototype"),nt={f:Object.getOwnPropertyNames||function(e){return pe(e,tt)}},rt={f:Object.getOwnPropertySymbols},it=A("Reflect","ownKeys")||function(e){var t=nt.f(W(e)),n=rt.f;return n?t.concat(n(e)):t},ot=function(e,t){for(var n=it(t),r=te.f,i=Ze.f,o=0;o<n.length;o++){var a=n[o];w(e,a)||r(e,a,i(t,a))}},at=/#|\.prototype\./,st=function(e,t){var n=ut[ct(e)];return n==dt||n!=lt&&("function"==typeof t?s(t):!!t)},ct=st.normalize=function(e){return String(e).replace(at,".").toLowerCase()},ut=st.data={},lt=st.NATIVE="N",dt=st.POLYFILL="P",ht=st,pt=Ze.f,ft=function(e,t){var n,r,i,o,a,s=e.target,c=e.global,u=e.stat;if(n=c?y:u?y[s]||S(s,{}):(y[s]||{}).prototype)for(r in t){if(o=t[r],i=e.noTargetGet?(a=pt(n,r))&&a.value:n[r],!ht(c?r:s+(u?".":"#")+r,e.forced)&&void 0!==i){if(typeof o==typeof i)continue;ot(o,i)}(e.sham||i&&i.sham)&&Ve(o,"sham",!0),et(n,r,o,e)}},mt=!s((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),vt=ye("IE_PROTO"),_t=Object.prototype,gt=mt?Object.getPrototypeOf:function(e){return e=I(e),w(e,vt)?e[vt]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?_t:null},yt=z("iterator"),St=!1;[].keys&&("next"in(qe=[].keys())?(Je=gt(gt(qe)))!==Object.prototype&&(We=Je):St=!0),(null==We||s((function(){var e={};return We[yt].call(e)!==e})))&&(We={}),w(We,yt)||Ve(We,yt,(function(){return this}));var bt={IteratorPrototype:We,BUGGY_SAFARI_ITERATORS:St},kt=te.f,It=z("toStringTag"),Tt=function(e,t,n){e&&!w(e=n?e:e.prototype,It)&&kt(e,It,{configurable:!0,value:t})},wt=bt.IteratorPrototype,Rt=function(){return this},Et=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(n,[]),t=n instanceof Array}catch(e){}return function(n,r){return W(n),function(e){if(!G(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype")}(r),t?e.call(n,r):n.__proto__=r,n}}():void 0),Ct=bt.IteratorPrototype,xt=bt.BUGGY_SAFARI_ITERATORS,At=z("iterator"),Pt=function(){return this},Dt=function(e,t,n,r,i,o,a){!function(e,t,n){var r=t+" Iterator";e.prototype=we(wt,{next:Ue(1,n)}),Tt(e,r,!1),xe[r]=Rt}(n,t,r);var s,c,u,l=function(e){if(e===i&&m)return m;if(!xt&&e in p)return p[e];switch(e){case"keys":case"values":case"entries":return function(){return new n(this,e)}}return function(){return new n(this)}},d=t+" Iterator",h=!1,p=e.prototype,f=p[At]||p["@@iterator"]||i&&p[i],m=!xt&&f||l(i),v="Array"==t&&p.entries||f;if(v&&(s=gt(v.call(new e)),Ct!==Object.prototype&&s.next&&(gt(s)!==Ct&&(Et?Et(s,Ct):"function"!=typeof s[At]&&Ve(s,At,Pt)),Tt(s,d,!0))),"values"==i&&f&&"values"!==f.name&&(h=!0,m=function(){return f.call(this)}),p[At]!==m&&Ve(p,At,m),xe[t]=m,i)if(c={values:l("values"),keys:o?m:l("keys"),entries:l("entries")},a)for(u in c)(xt||h||!(u in p))&&et(p,u,c[u]);else ft({target:t,proto:!0,forced:xt||h},c);return c},Lt=Ke.set,Mt=Ke.getterFor("Array Iterator"),Nt=Dt(Array,"Array",(function(e,t){Lt(this,{type:"Array Iterator",target:p(e),index:0,kind:t})}),(function(){var e=Mt(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:t[r],done:!1}:{value:[r,t[r]],done:!1}}),"values");xe.Arguments=xe.Array,Ce("keys"),Ce("values"),Ce("entries");var Ot=nt.f,Ut={}.toString,Vt="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Ft={f:function(e){return Vt&&"[object Window]"==Ut.call(e)?function(e){try{return Ot(e)}catch(e){return Vt.slice()}}(e):Ot(p(e))}},jt=!s((function(){return Object.isExtensible(Object.preventExtensions({}))})),Bt=m((function(e){var t=te.f,n=!1,r=C("meta"),i=0,o=Object.isExtensible||function(){return!0},a=function(e){t(e,r,{value:{objectID:"O"+i++,weakData:{}}})},s=e.exports={enable:function(){s.enable=function(){},n=!0;var e=nt.f,t=[].splice,i={};i[r]=1,e(i).length&&(nt.f=function(n){for(var i=e(n),o=0,a=i.length;o<a;o++)if(i[o]===r){t.call(i,o,1);break}return i},ft({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Ft.f}))},fastKey:function(e,t){if(!G(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!w(e,r)){if(!o(e))return"F";if(!t)return"E";a(e)}return e[r].objectID},getWeakData:function(e,t){if(!w(e,r)){if(!o(e))return!0;if(!t)return!1;a(e)}return e[r].weakData},onFreeze:function(e){return jt&&n&&o(e)&&!w(e,r)&&a(e),e}};de[r]=!0})),Ht=(Bt.enable,Bt.fastKey,Bt.getWeakData,Bt.onFreeze,z("iterator")),zt=Array.prototype,Gt=function(e,t,n){if(function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function")}(e),void 0===t)return e;switch(n){case 0:return function(){return e.call(t)};case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}},Wt={};Wt[z("toStringTag")]="z";var Jt="[object z]"===String(Wt),qt=z("toStringTag"),Kt="Arguments"==u(function(){return arguments}()),Qt=Jt?u:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),qt))?n:Kt?u(t):"Object"==(r=u(t))&&"function"==typeof t.callee?"Arguments":r},Xt=z("iterator"),$t=function(e){var t=e.return;if(void 0!==t)return W(t.call(e)).value},Yt=function(e,t){this.stopped=e,this.result=t},Zt=function(e,t,n){var r,i,o,a,s,c,u,l,d=n&&n.that,h=!(!n||!n.AS_ENTRIES),p=!(!n||!n.IS_ITERATOR),f=!(!n||!n.INTERRUPTED),m=Gt(t,d,1+h+f),v=function(e){return r&&$t(r),new Yt(!0,e)},_=function(e){return h?(W(e),f?m(e[0],e[1],v):m(e[0],e[1])):f?m(e,v):m(e)};if(p)r=e;else{if("function"!=typeof(i=function(e){if(null!=e)return e[Xt]||e["@@iterator"]||xe[Qt(e)]}(e)))throw TypeError("Target is not iterable");if(void 0!==(l=i)&&(xe.Array===l||zt[Ht]===l)){for(o=0,a=ae(e.length);a>o;o++)if((s=_(e[o]))&&s instanceof Yt)return s;return new Yt(!1)}r=i.call(e)}for(c=r.next;!(u=c.call(r)).done;){try{s=_(u.value)}catch(e){throw $t(r),e}if("object"==typeof s&&s&&s instanceof Yt)return s}return new Yt(!1)},en=function(e,t,n){if(!(e instanceof t))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return e},tn=z("iterator"),nn=!1;try{var rn=0,on={next:function(){return{done:!!rn++}},return:function(){nn=!0}};on[tn]=function(){return this},Array.from(on,(function(){throw 2}))}catch(e){}var an=function(e,t,n){for(var r in t)et(e,r,t[r],n);return e},sn=z("species"),cn=te.f,un=Bt.fastKey,ln=Ke.set,dn=Ke.getterFor,hn=(function(e,t,n){var r=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),o=r?"set":"add",a=y[e],c=a&&a.prototype,u=a,l={},d=function(e){var t=c[e];et(c,e,"add"==e?function(e){return t.call(this,0===e?0:e),this}:"delete"==e?function(e){return!(i&&!G(e))&&t.call(this,0===e?0:e)}:"get"==e?function(e){return i&&!G(e)?void 0:t.call(this,0===e?0:e)}:"has"==e?function(e){return!(i&&!G(e))&&t.call(this,0===e?0:e)}:function(e,n){return t.call(this,0===e?0:e,n),this})};if(ht(e,"function"!=typeof a||!(i||c.forEach&&!s((function(){(new a).entries().next()})))))u=n.getConstructor(t,e,r,o),Bt.enable();else if(ht(e,!0)){var h=new u,p=h[o](i?{}:-0,1)!=h,f=s((function(){h.has(1)})),m=function(e,t){if(!nn)return!1;var n=!1;try{var r={};r[tn]=function(){return{next:function(){return{done:n=!0}}}},function(e){new a(e)}(r)}catch(e){}return n}(),v=!i&&s((function(){for(var e=new a,t=5;t--;)e[o](t,t);return!e.has(-0)}));m||((u=t((function(t,n){en(t,u,e);var i=function(e,t,n){var r,i;return Et&&"function"==typeof(r=t.constructor)&&r!==n&&G(i=r.prototype)&&i!==n.prototype&&Et(e,i),e}(new a,t,u);return null!=n&&Zt(n,i[o],{that:i,AS_ENTRIES:r}),i}))).prototype=c,c.constructor=u),(f||v)&&(d("delete"),d("has"),r&&d("get")),(v||p)&&d(o),i&&c.clear&&delete c.clear}l[e]=u,ft({global:!0,forced:u!=a},l),Tt(u,e),i||n.setStrong(u,e,r)}("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),{getConstructor:function(e,t,n,r){var i=e((function(e,o){en(e,i,t),ln(e,{type:t,index:we(null),first:void 0,last:void 0,size:0}),J||(e.size=0),null!=o&&Zt(o,e[r],{that:e,AS_ENTRIES:n})})),o=dn(t),a=function(e,t,n){var r,i,a=o(e),c=s(e,t);return c?c.value=n:(a.last=c={index:i=un(t,!0),key:t,value:n,previous:r=a.last,next:void 0,removed:!1},a.first||(a.first=c),r&&(r.next=c),J?a.size++:e.size++,"F"!==i&&(a.index[i]=c)),e},s=function(e,t){var n,r=o(e),i=un(t);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key==t)return n};return an(i.prototype,{clear:function(){for(var e=o(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete t[n.index],n=n.next;e.first=e.last=void 0,J?e.size=0:this.size=0},delete:function(e){var t=o(this),n=s(this,e);if(n){var r=n.next,i=n.previous;delete t.index[n.index],n.removed=!0,i&&(i.next=r),r&&(r.previous=i),t.first==n&&(t.first=r),t.last==n&&(t.last=i),J?t.size--:this.size--}return!!n},forEach:function(e){for(var t,n=o(this),r=Gt(e,arguments.length>1?arguments[1]:void 0,3);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!s(this,e)}}),an(i.prototype,n?{get:function(e){var t=s(this,e);return t&&t.value},set:function(e,t){return a(this,0===e?0:e,t)}}:{add:function(e){return a(this,e=0===e?0:e,e)}}),J&&cn(i.prototype,"size",{get:function(){return o(this).size}}),i},setStrong:function(e,t,n){var r=t+" Iterator",i=dn(t),o=dn(r);Dt(e,t,(function(e,t){ln(this,{type:r,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=o(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?"keys"==t?{value:n.key,done:!1}:"values"==t?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(e.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),function(e){var t=A(e),n=te.f;J&&t&&!t[sn]&&n(t,sn,{configurable:!0,get:function(){return this}})}(t)}}),Jt?{}.toString:function(){return"[object "+Qt(this)+"]"});Jt||et(Object.prototype,"toString",hn,{unsafe:!0});var pn=function(e){if($(e))throw TypeError("Cannot convert a Symbol value to a string");return String(e)},fn=function(e){return function(t,n){var r,i,o=pn(h(t)),a=ie(n),s=o.length;return a<0||a>=s?e?"":void 0:(r=o.charCodeAt(a))<55296||r>56319||a+1===s||(i=o.charCodeAt(a+1))<56320||i>57343?e?o.charAt(a):r:e?o.slice(a,a+2):i-56320+(r-55296<<10)+65536}},mn={codeAt:fn(!1),charAt:fn(!0)},vn=mn.charAt,_n=Ke.set,gn=Ke.getterFor("String Iterator");Dt(String,"String",(function(e){_n(this,{type:"String Iterator",string:pn(e),index:0})}),(function(){var e,t=gn(this),n=t.string,r=t.index;return r>=n.length?{value:void 0,done:!0}:(e=vn(n,r),t.index+=e.length,{value:e,done:!1})}));var yn={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Sn=z("iterator"),bn=z("toStringTag"),kn=Nt.values;for(var In in yn){var Tn=y[In],wn=Tn&&Tn.prototype;if(wn){if(wn[Sn]!==kn)try{Ve(wn,Sn,kn)}catch(e){wn[Sn]=kn}if(wn[bn]||Ve(wn,bn,In),yn[In])for(var Rn in Nt)if(wn[Rn]!==Nt[Rn])try{Ve(wn,Rn,Nt[Rn])}catch(e){wn[Rn]=Nt[Rn]}}}var En=Array.isArray||function(e){return"Array"==u(e)},Cn=z("species"),xn=function(e,t){return new(function(e){var t;return En(e)&&("function"!=typeof(t=e.constructor)||t!==Array&&!En(t.prototype)?G(t)&&null===(t=t[Cn])&&(t=void 0):t=void 0),void 0===t?Array:t}(e))(0===t?0:t)},An=[].push,Pn=function(e){var t=1==e,n=2==e,r=3==e,i=4==e,o=6==e,a=7==e,s=5==e||o;return function(c,u,l,h){for(var p,f,m=I(c),v=d(m),_=Gt(u,l,3),g=ae(v.length),y=0,S=h||xn,b=t?S(c,g):n||a?S(c,0):void 0;g>y;y++)if((s||y in v)&&(f=_(p=v[y],y,m),e))if(t)b[y]=f;else if(f)switch(e){case 3:return!0;case 5:return p;case 6:return y;case 2:An.call(b,p)}else switch(e){case 4:return!1;case 7:An.call(b,p)}return o?-1:r||i?i:b}},Dn={forEach:Pn(0),map:Pn(1),filter:Pn(2),some:Pn(3),every:Pn(4),find:Pn(5),findIndex:Pn(6),filterReject:Pn(7)},Ln=function(e,t){var n=[][e];return!!n&&s((function(){n.call(null,t||function(){throw 1},1)}))},Mn=Dn.forEach,Nn=Ln("forEach")?[].forEach:function(e){return Mn(this,e,arguments.length>1?arguments[1]:void 0)};for(var On in ft({target:"Array",proto:!0,forced:[].forEach!=Nn},{forEach:Nn}),yn){var Un=y[On],Vn=Un&&Un.prototype;if(Vn&&Vn.forEach!==Nn)try{Ve(Vn,"forEach",Nn)}catch(e){Vn.forEach=Nn}}var Fn=Math.min,jn=[].lastIndexOf,Bn=!!jn&&1/[1].lastIndexOf(1,-0)<0,Hn=Ln("lastIndexOf"),zn=Bn||!Hn?function(e){if(Bn)return jn.apply(this,arguments)||0;var t=p(this),n=ae(t.length),r=n-1;for(arguments.length>1&&(r=Fn(r,ie(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}:jn;ft({target:"Array",proto:!0,forced:zn!==[].lastIndexOf},{lastIndexOf:zn});var Gn=le.indexOf,Wn=[].indexOf,Jn=!!Wn&&1/[1].indexOf(1,-0)<0,qn=Ln("indexOf");ft({target:"Array",proto:!0,forced:Jn||!qn},{indexOf:function(e){return Jn?Wn.apply(this,arguments)||0:Gn(this,e,arguments.length>1?arguments[1]:void 0)}});var Kn,Qn=z("match"),Xn=function(e){if(function(e){var t;return G(e)&&(void 0!==(t=e[Qn])?!!t:"RegExp"==u(e))}(e))throw TypeError("The method doesn't accept regular expressions");return e},$n=z("match"),Yn=Ze.f,Zn="".startsWith,er=Math.min,tr=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[$n]=!1,"/./"[e](t)}catch(e){}}return!1}("startsWith"),nr=!(tr||(Kn=Yn(String.prototype,"startsWith"),!Kn||Kn.writable));ft({target:"String",proto:!0,forced:!nr&&!tr},{startsWith:function(e){var t=pn(h(this));Xn(e);var n=ae(er(arguments.length>1?arguments[1]:void 0,t.length)),r=pn(e);return Zn?Zn.call(t,r,n):t.slice(n,n+r.length)===r}}),ft({target:"Array",stat:!0},{isArray:En}),m((function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var i=t&&t.prototype instanceof d?t:d,o=Object.create(i.prototype),a=new I(r||[]);return o._invoke=function(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var s=S(a,n);if(s){if(s===l)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=u(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(e,n,a),o}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var l={};function d(){}function h(){}function p(){}var f={};s(f,i,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(T([])));v&&v!==t&&n.call(v,i)&&(f=v);var _=p.prototype=d.prototype=Object.create(f);function g(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){var r;this._invoke=function(i,o){function a(){return new t((function(r,a){!function r(i,o,a,s){var c=u(e[i],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(d).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,s)}))}s(c.arg)}(i,o,r,a)}))}return r=r?r.then(a,a):a()}}function S(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,S(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=u(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,l;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function T(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:w}}function w(){return{value:void 0,done:!0}}return h.prototype=p,s(_,"constructor",p),s(p,"constructor",h),h.displayName=s(p,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s(e,a,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},g(y.prototype),s(y.prototype,o,(function(){return this})),e.AsyncIterator=y,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new y(c(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(_),s(_,a,"Generator"),s(_,i,(function(){return this})),s(_,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=T,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;k(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:T(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}));var rr=z("species"),ir=function(e){return U>=51||!s((function(){var t=[];return(t.constructor={})[rr]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},or=Dn.map,ar=ir("map");ft({target:"Array",proto:!0,forced:!ar},{map:function(e){return or(this,e,arguments.length>1?arguments[1]:void 0)}});var sr=Dn.filter,cr=ir("filter");ft({target:"Array",proto:!0,forced:!cr},{filter:function(e){return sr(this,e,arguments.length>1?arguments[1]:void 0)}});var ur=Dn.findIndex,lr=!0;"findIndex"in[]&&Array(1).findIndex((function(){lr=!1})),ft({target:"Array",proto:!0,forced:lr},{findIndex:function(e){return ur(this,e,arguments.length>1?arguments[1]:void 0)}}),Ce("findIndex");var dr,hr,pr=function(){var e=W(this),t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t},fr=function(e,t){return RegExp(e,t)},mr={UNSUPPORTED_Y:s((function(){var e=fr("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),BROKEN_CARET:s((function(){var e=fr("^r","gy");return e.lastIndex=2,null!=e.exec("str")}))},vr=s((function(){var e=RegExp(".","string".charAt(0));return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),_r=s((function(){var e=RegExp("(?<a>b)","string".charAt(5));return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),gr=Ke.get,yr=RegExp.prototype.exec,Sr=k("native-string-replace",String.prototype.replace),br=yr,kr=(dr=/a/,hr=/b*/g,yr.call(dr,"a"),yr.call(hr,"a"),0!==dr.lastIndex||0!==hr.lastIndex),Ir=mr.UNSUPPORTED_Y||mr.BROKEN_CARET,Tr=void 0!==/()??/.exec("")[1];(kr||Tr||Ir||vr||_r)&&(br=function(e){var t,n,r,i,o,a,s,c=this,u=gr(c),l=pn(e),d=u.raw;if(d)return d.lastIndex=c.lastIndex,t=br.call(d,l),c.lastIndex=d.lastIndex,t;var h=u.groups,p=Ir&&c.sticky,f=pr.call(c),m=c.source,v=0,_=l;if(p&&(-1===(f=f.replace("y","")).indexOf("g")&&(f+="g"),_=l.slice(c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==l.charAt(c.lastIndex-1))&&(m="(?: "+m+")",_=" "+_,v++),n=new RegExp("^(?:"+m+")",f)),Tr&&(n=new RegExp("^"+m+"$(?!\\s)",f)),kr&&(r=c.lastIndex),i=yr.call(p?n:c,_),p?i?(i.input=i.input.slice(v),i[0]=i[0].slice(v),i.index=c.lastIndex,c.lastIndex+=i[0].length):c.lastIndex=0:kr&&i&&(c.lastIndex=c.global?i.index+i[0].length:r),Tr&&i&&i.length>1&&Sr.call(i[0],n,(function(){for(o=1;o<arguments.length-2;o++)void 0===arguments[o]&&(i[o]=void 0)})),i&&h)for(i.groups=a=we(null),o=0;o<h.length;o++)a[(s=h[o])[0]]=i[s[1]];return i});var wr=br;ft({target:"RegExp",proto:!0,forced:/./.exec!==wr},{exec:wr});var Rr="[\t\n\v\f\r                 \u2028\u2029\ufeff]",Er=RegExp("^"+Rr+Rr+"*"),Cr=RegExp(Rr+Rr+"*$"),xr=function(e){return function(t){var n=pn(h(t));return 1&e&&(n=n.replace(Er,"")),2&e&&(n=n.replace(Cr,"")),n}},Ar=(xr(1),xr(2),xr(3)),Pr=y.parseFloat,Dr=1/Pr("\t\n\v\f\r                 \u2028\u2029\ufeff-0")!=-1/0?function(e){var t=Ar(pn(e)),n=Pr(t);return 0===n&&"-"==t.charAt(0)?-0:n}:Pr;ft({global:!0,forced:parseFloat!=Dr},{parseFloat:Dr});z("species");var Lr=RegExp.prototype,Mr=mn.charAt,Nr=function(e,t,n){return t+(n?Mr(e,t).length:1)},Or=function(e,t){var n=e.exec;if("function"==typeof n){var r=n.call(e,t);if("object"!=typeof r)throw TypeError("RegExp exec method returned something other than an Object or null");return r}if("RegExp"!==u(e))throw TypeError("RegExp#exec called on incompatible receiver");return wr.call(e,t)};!function(e,t,n,r){var i=z(e),o=!s((function(){var t={};return t[i]=function(){return 7},7!=""[e](t)})),a=o&&!s((function(){var e=!1,t=/a/;return t.exec=function(){return e=!0,null},t[i](""),!e}));if(!o||!a){var c=/./[i],u=function(e,t,n){return[function(t){var n=h(this),r=null==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](pn(n))},function(e){var r=W(this),i=pn(e),o=n(t,r,i);if(o.done)return o.value;if(!r.global)return Or(r,i);var a=r.unicode;r.lastIndex=0;for(var s,c=[],u=0;null!==(s=Or(r,i));){var l=pn(s[0]);c[u]=l,""===l&&(r.lastIndex=Nr(i,ae(r.lastIndex),a)),u++}return 0===u?null:c}]}(i,""[e],(function(e,t,n,r,i){var a=t.exec;return a===wr||a===Lr.exec?o&&!i?{done:!0,value:c.call(t,n,r)}:{done:!0,value:e.call(n,t,r)}:{done:!1}}));et(String.prototype,e,u[0]),et(Lr,i,u[1])}}("match");var Ur=function(e,t,n){var r=Z(t);r in e?te.f(e,r,Ue(0,n)):e[r]=n},Vr=z("isConcatSpreadable"),Fr=U>=51||!s((function(){var e=[];return e[Vr]=!1,e.concat()[0]!==e})),jr=ir("concat"),Br=function(e){if(!G(e))return!1;var t=e[Vr];return void 0!==t?!!t:En(e)};ft({target:"Array",proto:!0,forced:!Fr||!jr},{concat:function(e){var t,n,r,i,o,a=I(this),s=xn(a,0),c=0;for(t=-1,r=arguments.length;t<r;t++)if(Br(o=-1===t?a:arguments[t])){if(c+(i=ae(o.length))>9007199254740991)throw TypeError("Maximum allowed index exceeded");for(n=0;n<i;n++,c++)n in o&&Ur(s,c,o[n])}else{if(c>=9007199254740991)throw TypeError("Maximum allowed index exceeded");Ur(s,c++,o)}return s.length=c,s}});var Hr=window.navigator&&window.navigator.userAgent||"",zr=/AppleWebKit\/([\d.]+)/i.exec(Hr),Gr=(zr&&parseFloat(zr.pop()),/iPad/i.test(Hr)),Wr=/iPhone/i.test(Hr)&&!Gr,Jr=/iPod/i.test(Hr),qr=Wr||Gr||Jr,Kr=(function(){var e=Hr.match(/OS (\d+)_/i);e&&e[1]&&e[1]}(),/Android/i.test(Hr)),Qr=(function(){var e=Hr.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;var t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);t&&n&&parseFloat("".concat(e[1],".").concat(e[2]))}(),Kr&&/webkit/i.test(Hr),/Firefox/i.test(Hr)),Xr=function(){var e=Hr.match(/Firefox\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),$r=/Edge\//i.test(Hr),Yr=/Edg\//i.test(Hr),Zr=function(){var e=Hr.match(/Edg\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),ei=!$r&&/Chrome/i.test(Hr),ti=(function(){var e=Hr.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}(),function(){var e=Hr.match(/Chrome\/([\d.]+)/);return e&&e[1]?e[1]:null}()),ni=(/MSIE\s8\.0/.test(Hr),function(){var e=/MSIE\s(\d+)\.\d/.exec(Hr),t=e&&parseFloat(e[1]);!t&&/Trident\/7.0/i.test(Hr)&&/rv:11.0/.test(Hr)&&(t=11)}(),/Safari/i.test(Hr)&&!ei&&!Kr&&!$r),ri=function(){var e=Hr.match(/Version\/([\d.]+)/);return e&&e[1]?e[1]:null}(),ii=/TBS\/\d+/i.test(Hr),oi=(function(){var e=Hr.match(/TBS\/(\d+)/i);e&&e[1]&&e[1]}(),!ii&&/MQQBrowser\/\d+/i.test(Hr),!ii&&/ QQBrowser\/\d+/i.test(Hr),/(micromessenger|webbrowser)/i.test(Hr),/Windows/i.test(Hr),/MAC OS X/i.test(Hr),/Linux/i.test(Hr),/MicroMessenger/i.test(Hr),/UCBrowser/i.test(Hr),/MiuiBrowser/i.test(Hr),/HuaweiBrowser/i.test(Hr),"file:"===location.protocol||"localhost"===location.hostname||/^\d+\.\d+\.\d+\.\d+$/.test(location.hostname)),ai=function(){return!(ei&&ti<56||ni&&ri<11||Yr&&Zr<80||Qr&&Xr<56||qr&&ri<14||("undefined"!=typeof AudioContext&&(e=new AudioContext),void 0!==window.webkitAudioContext&&(e=new window.webkitAudioContext),void 0!==window.mozAudioContext&&(e=new window.mozAudioContext),!(e.createMediaElementSource&&e.createMediaStreamDestination&&e.createMediaStreamSource)));var e},si=function(e){return"string"==typeof e},ci=function(){return"undefined"!=typeof AudioContext?new AudioContext:void 0!==window.webkitAudioContext?new window.webkitAudioContext:void 0!==window.mozAudioContext?new window.mozAudioContext:void 0},ui=function(){var e=r(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!di()&&!li()){e.next=2;break}return e.abrupt("return",[]);case 2:return e.next=4,navigator.mediaDevices.enumerateDevices();case 4:return t=e.sent,e.abrupt("return",t.filter((function(e){return"audioinput"===e.kind})).map((function(e,t){var n=e.label;e.label||(n="microphone_".concat(t));var r={label:n,deviceId:e.deviceId,kind:e.kind};return e.groupId&&(r.groupId=e.groupId),r})));case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),li=function(){return void 0===navigator.mediaDevices&&(console.error("navigator.mediaDevices is not supported on your browser"),!0)},di=function(){return"http:"===location.protocol&&!oi&&(console.error("you should use "),!0)},hi=function(){var e=r(regeneratorRuntime.mark((function e(t){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!("getSettings"in MediaStreamTrack.prototype)){e.next=8;break}if(n=t.getSettings(),r=n.deviceId,!si(r)||!r.startsWith("WebAudio")){e.next=4;break}return e.abrupt("return",!1);case 4:return e.next=6,ui();case 6:return i=e.sent,e.abrupt("return",i.findIndex((function(e){return e.deviceId===r}))>=0);case 8:return e.abrupt("return",!1);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),pi=m((function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new i(r,o||e,a),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,r,i=[];if(0===this._eventsCount)return i;for(r in e=this._events)t.call(e,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,a=new Array(o);i<o;i++)a[i]=r[i].fn;return a},s.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,i,o,a){var s=n?n+e:e;if(!this._events[s])return!1;var c,u,l=this._events[s],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,i),!0;case 5:return l.fn.call(l.context,t,r,i,o),!0;case 6:return l.fn.call(l.context,t,r,i,o,a),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var h,p=l.length;for(u=0;u<p;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,r);break;case 4:l[u].fn.call(l[u].context,t,r,i);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];l[u].fn.apply(l[u].context,c)}}return!0},s.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,r,i){var o=n?n+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||r&&s.context!==r||a(this,o);else{for(var c=0,u=[],l=s.length;c<l;c++)(s[c].fn!==t||i&&!s[c].once||r&&s[c].context!==r)&&u.push(s[c]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(this,t)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s})),fi=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","interruptbegin","interruptend","loadedmetadata","loadstart","mozaudioavailable","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],mi=function(){function e(t){i(this,e),this.emitter=new pi,this.audioContext=ci(),this.destination=this.audioContext.createMediaStreamDestination(),this.source=null,this.audio=this.createEl(t)}return a(e,[{key:"createEl",value:function(e){var t=this,n=document.createElement("audio");return this.audio=n,n.crossOrigin="anonymous",n.src=e.url,this.source=this.audioContext.createMediaElementSource(n),this.source.connect(this.destination),fi.forEach((function(e){n.addEventListener(e,(function(n){t.emitter.emit(e,n)}))})),"boolean"==typeof e.loop&&(this.audio.loop=e.loop),e.volume&&this.setVolume(e.volume),n}},{key:"getStream",value:function(){return this.destination.stream}},{key:"play",value:function(){var e=this;this.audio&&this.audio.play().then((function(){console.log("Audio ".concat(e.audio.src," play success"))})).catch((function(t){e.emitter.emit("error",t)}))}},{key:"pause",value:function(){this.audio&&this.audio.pause()}},{key:"resume",value:function(){this.audio&&(this.audio.pause(),this.audio.currentTime=0)}},{key:"stop",value:function(){this.audio&&(this.audio.pause(),this.audio.currentTime=0)}},{key:"setPosition",value:function(e){if(e<0&&e>this.duration())throw new Error("时间超出歌曲时长");this.audio&&(this.audio.currentTime=e)}},{key:"getPosition",value:function(){if(this.audio)return this.audio.currentTime}},{key:"setVolume",value:function(e){if(e>1&&e<0)throw new Error("音量超出限制");this.audio&&(this.audio.volume=e)}},{key:"getVolume",value:function(){if(this.audio)return this.audio.volume}},{key:"setPlayBackRate",value:function(e){if(e>8&&e<0)throw new Error("速率超出限制");this.audio&&(this.audio.playbackRate=e)}},{key:"getPlayBackRate",value:function(){if(this.audio)return this.audio.playbackRate}},{key:"duration",value:function(){if(this.audio)return this.audio.duration||0}},{key:"loop",value:function(e){if(void 0===e)return this.audio.loop;"boolean"==typeof e&&(this.audio.loop=e)}},{key:"on",value:function(e,t){this.emitter.on(e,t)}},{key:"off",value:function(e,t){"*"===e?this.emitter.removeAllListeners():this.emitter.off(e,t)}}]),e}(),vi=new(function(){function e(){i(this,e),this.audioTrackMap=new Map}return a(e,[{key:"createAudioSource",value:function(e){return this.checkAudioSourceParams(e),new mi(e)}},{key:"mix",value:function(e){this.checkMixParams(e);var t=e.targetTrack,n=e.sourceList,r=e.trackList,i=ci(),o=i.createMediaStreamDestination();if(t){var a=new MediaStream;a.addTrack(t),i.createMediaStreamSource(a).connect(o)}n&&n.forEach((function(e){var t=document.createElement("audio");t.srcObject=e.getStream(),t.play().then((function(){console.log("".concat(e.audio.src," mix success"))})).catch((function(){throw new Error("".concat(e.audio.src," mix error"))}));var n=i.createMediaStreamSource(e.destination.stream),r=i.createGain();n.connect(r),r.connect(o)})),r&&r.forEach((function(e){var t=new MediaStream;t.addTrack(e);var n=i.createMediaStreamSource(t),r=i.createGain();n.connect(r),r.connect(o)}));var s=o.stream.getAudioTracks()[0];return this.setAudioTrackMap({targetTrack:t,sourceList:n,trackList:r,id:s.id}),s}},{key:"setAudioTrackMap",value:function(e){var t=this,n=e.targetTrack,r=e.sourceList,i=e.id,o=!1,a=null;n?hi(n).then((function(e){if(e)o=e,a=n;else{var r=t.audioTrackMap.get(n.id);if(r){var i=r.hasMicrophone,s=r.microphoneTrack;o=i,a=s}else o=!1,a=null}})):(o=!1,a=null),this.audioTrackMap.set(i,{sourceList:r,targetTrack:n,hasMicrophone:o,microphoneTrack:a})}},{key:"checkAudioSourceParams",value:function(e){var t=e.url,n=e.loop,r=e.volume;if(!si(t))throw new Error("url is invalid.");if(n&&"boolean"!=typeof n)throw new Error("loop is invalid.");if(r&&(!function(e){return"number"==typeof e}(r)||r<0||r>1))throw new Error("volume is invalid.");var i=t.lastIndexOf("."),o=t.substr(i+1),a=["mp3","ogg","wav","flac"].indexOf(o)>=0,s=t.startsWith("blob"),c=t.startsWith("data");if(!(a||s||c))throw new Error("url is invalid.")}},{key:"checkMixParams",value:function(e){if(!ai())throw new Error("Your browser is not compatible with AudioMixerPlugin");var t=e.targetTrack,n=e.sourceList,r=e.trackList;if(t&&"audio"!==t.kind)throw new Error("targetTrack is invalid.");if(!n&&!r)throw new Error("params is invalid.");n&&Array.isArray(n)&&n.forEach((function(e){if(!(e instanceof mi))throw new Error("sourceList is invalid.")})),r&&Array.isArray(r)&&r.forEach((function(e){if(!(e instanceof MediaStreamTrack&&"audio"===e.kind))throw new Error("audioTracks is invalid")}))}},{key:"getAudioTrackMap",value:function(){return this.audioTrackMap}}]),e}());if(vi.isSupported=function(){return ai()},!e)throw new Error("没有加载 TRTC");return e.AudioMixerPlugin=vi,vi}(n(24))},24:function(e,t,n){e.exports=function(){function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){u(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,c,"next",e)}function c(e){i(a,r,o,s,c,"throw",e)}s(void 0)}))}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&h(e,t)}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function f(e,t,n){return(f=p()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&h(i,n.prototype),i}).apply(null,arguments)}function m(e){var t="function"==typeof Map?new Map:void 0;return(m=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return f(e,arguments,d(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,e)})(e)}function v(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function _(e){var t=p();return function(){var n,r=d(e);if(t){var i=d(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return v(this,n)}}function g(e,t,n){return(g="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=d(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(n):i.value}})(e,t,n||e)}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}(e,t)||b(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e){return function(e){if(Array.isArray(e))return k(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||b(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){if(e){if("string"==typeof e)return k(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?k(e,t):void 0}}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function I(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=b(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function T(e,t,n,r,i){var o={};return Object.keys(r).forEach((function(e){o[e]=r[e]})),o.enumerable=!!o.enumerable,o.configurable=!!o.configurable,("value"in o||o.initializer)&&(o.writable=!0),o=n.slice().reverse().reduce((function(n,r){return r(e,t,n)||n}),o),i&&void 0!==o.initializer&&(o.value=o.initializer?o.initializer.call(i):void 0,o.initializer=void 0),void 0===o.initializer&&(Object.defineProperty(e,t,o),o=null),o}var w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{};function R(e,t){return e(t={exports:{}},t.exports),t.exports}var E,C,x=function(e){return e&&e.Math==Math&&e},A=x("object"==typeof globalThis&&globalThis)||x("object"==typeof window&&window)||x("object"==typeof self&&self)||x("object"==typeof w&&w)||function(){return this}()||Function("return this")(),P=function(e){try{return!!e()}catch(e){return!0}},D=!P((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),L={}.propertyIsEnumerable,M=Object.getOwnPropertyDescriptor,N={f:M&&!L.call({1:2},1)?function(e){var t=M(this,e);return!!t&&t.enumerable}:L},O=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},U={}.toString,V=function(e){return U.call(e).slice(8,-1)},F="".split,j=P((function(){return!Object("z").propertyIsEnumerable(0)}))?function(e){return"String"==V(e)?F.call(e,""):Object(e)}:Object,B=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},H=function(e){return j(B(e))},z=function(e){return"function"==typeof e},G=function(e){return"object"==typeof e?null!==e:z(e)},W=function(e){return z(e)?e:void 0},J=function(e,t){return arguments.length<2?W(A[e]):A[e]&&A[e][t]},q=J("navigator","userAgent")||"",K=A.process,Q=A.Deno,X=K&&K.versions||Q&&Q.version,$=X&&X.v8;$?C=(E=$.split("."))[0]<4?1:E[0]+E[1]:q&&(!(E=q.match(/Edge\/(\d+)/))||E[1]>=74)&&(E=q.match(/Chrome\/(\d+)/))&&(C=E[1]);var Y=C&&+C,Z=!!Object.getOwnPropertySymbols&&!P((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Y&&Y<41})),ee=Z&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,te=ee?function(e){return"symbol"==typeof e}:function(e){var t=J("Symbol");return z(t)&&Object(e)instanceof t},ne=function(e){try{return String(e)}catch(e){return"Object"}},re=function(e){if(z(e))return e;throw TypeError(ne(e)+" is not a function")},ie=function(e,t){var n=e[t];return null==n?void 0:re(n)},oe=function(e,t){try{Object.defineProperty(A,e,{value:t,configurable:!0,writable:!0})}catch(n){A[e]=t}return t},ae=A["__core-js_shared__"]||oe("__core-js_shared__",{}),se=R((function(e){(e.exports=function(e,t){return ae[e]||(ae[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.18.2",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),ce=function(e){return Object(B(e))},ue={}.hasOwnProperty,le=Object.hasOwn||function(e,t){return ue.call(ce(e),t)},de=0,he=Math.random(),pe=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++de+he).toString(36)},fe=se("wks"),me=A.Symbol,ve=ee?me:me&&me.withoutSetter||pe,_e=function(e){return le(fe,e)&&(Z||"string"==typeof fe[e])||(Z&&le(me,e)?fe[e]=me[e]:fe[e]=ve("Symbol."+e)),fe[e]},ge=_e("toPrimitive"),ye=function(e,t){if(!G(e)||te(e))return e;var n,r=ie(e,ge);if(r){if(void 0===t&&(t="default"),n=r.call(e,t),!G(n)||te(n))return n;throw TypeError("Can't convert object to primitive value")}return void 0===t&&(t="number"),function(e,t){var n,r;if("string"===t&&z(n=e.toString)&&!G(r=n.call(e)))return r;if(z(n=e.valueOf)&&!G(r=n.call(e)))return r;if("string"!==t&&z(n=e.toString)&&!G(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")}(e,t)},Se=function(e){var t=ye(e,"string");return te(t)?t:String(t)},be=A.document,ke=G(be)&&G(be.createElement),Ie=function(e){return ke?be.createElement(e):{}},Te=!D&&!P((function(){return 7!=Object.defineProperty(Ie("div"),"a",{get:function(){return 7}}).a})),we=Object.getOwnPropertyDescriptor,Re={f:D?we:function(e,t){if(e=H(e),t=Se(t),Te)try{return we(e,t)}catch(e){}if(le(e,t))return O(!N.f.call(e,t),e[t])}},Ee=function(e){if(G(e))return e;throw TypeError(String(e)+" is not an object")},Ce=Object.defineProperty,xe={f:D?Ce:function(e,t,n){if(Ee(e),t=Se(t),Ee(n),Te)try{return Ce(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},Ae=D?function(e,t,n){return xe.f(e,t,O(1,n))}:function(e,t,n){return e[t]=n,e},Pe=Function.toString;z(ae.inspectSource)||(ae.inspectSource=function(e){return Pe.call(e)});var De,Le,Me,Ne=ae.inspectSource,Oe=A.WeakMap,Ue=z(Oe)&&/native code/.test(Ne(Oe)),Ve=se("keys"),Fe=function(e){return Ve[e]||(Ve[e]=pe(e))},je={},Be=A.WeakMap;if(Ue||ae.state){var He=ae.state||(ae.state=new Be),ze=He.get,Ge=He.has,We=He.set;De=function(e,t){if(Ge.call(He,e))throw new TypeError("Object already initialized");return t.facade=e,We.call(He,e,t),t},Le=function(e){return ze.call(He,e)||{}},Me=function(e){return Ge.call(He,e)}}else{var Je=Fe("state");je[Je]=!0,De=function(e,t){if(le(e,Je))throw new TypeError("Object already initialized");return t.facade=e,Ae(e,Je,t),t},Le=function(e){return le(e,Je)?e[Je]:{}},Me=function(e){return le(e,Je)}}var qe={set:De,get:Le,has:Me,enforce:function(e){return Me(e)?Le(e):De(e,{})},getterFor:function(e){return function(t){var n;if(!G(t)||(n=Le(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}},Ke=Function.prototype,Qe=D&&Object.getOwnPropertyDescriptor,Xe=le(Ke,"name"),$e={EXISTS:Xe,PROPER:Xe&&"something"===function(){}.name,CONFIGURABLE:Xe&&(!D||D&&Qe(Ke,"name").configurable)},Ye=R((function(e){var t=$e.CONFIGURABLE,n=qe.get,r=qe.enforce,i=String(String).split("String");(e.exports=function(e,n,o,a){var s,c=!!a&&!!a.unsafe,u=!!a&&!!a.enumerable,l=!!a&&!!a.noTargetGet,d=a&&void 0!==a.name?a.name:n;z(o)&&("Symbol("===String(d).slice(0,7)&&(d="["+String(d).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!le(o,"name")||t&&o.name!==d)&&Ae(o,"name",d),(s=r(o)).source||(s.source=i.join("string"==typeof d?d:""))),e!==A?(c?!l&&e[n]&&(u=!0):delete e[n],u?e[n]=o:Ae(e,n,o)):u?e[n]=o:oe(n,o)})(Function.prototype,"toString",(function(){return z(this)&&n(this).source||Ne(this)}))})),Ze=Math.ceil,et=Math.floor,tt=function(e){var t=+e;return t!=t||0===t?0:(t>0?et:Ze)(t)},nt=Math.max,rt=Math.min,it=function(e,t){var n=tt(e);return n<0?nt(n+t,0):rt(n,t)},ot=Math.min,at=function(e){return e>0?ot(tt(e),9007199254740991):0},st=function(e){return at(e.length)},ct=function(e){return function(t,n,r){var i,o=H(t),a=st(o),s=it(r,a);if(e&&n!=n){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===n)return e||s||0;return!e&&-1}},ut={includes:ct(!0),indexOf:ct(!1)},lt=ut.indexOf,dt=function(e,t){var n,r=H(e),i=0,o=[];for(n in r)!le(je,n)&&le(r,n)&&o.push(n);for(;t.length>i;)le(r,n=t[i++])&&(~lt(o,n)||o.push(n));return o},ht=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],pt=ht.concat("length","prototype"),ft={f:Object.getOwnPropertyNames||function(e){return dt(e,pt)}},mt={f:Object.getOwnPropertySymbols},vt=J("Reflect","ownKeys")||function(e){var t=ft.f(Ee(e)),n=mt.f;return n?t.concat(n(e)):t},_t=function(e,t){for(var n=vt(t),r=xe.f,i=Re.f,o=0;o<n.length;o++){var a=n[o];le(e,a)||r(e,a,i(t,a))}},gt=/#|\.prototype\./,yt=function(e,t){var n=bt[St(e)];return n==It||n!=kt&&(z(t)?P(t):!!t)},St=yt.normalize=function(e){return String(e).replace(gt,".").toLowerCase()},bt=yt.data={},kt=yt.NATIVE="N",It=yt.POLYFILL="P",Tt=yt,wt=Re.f,Rt=function(e,t){var n,r,i,o,a,s=e.target,c=e.global,u=e.stat;if(n=c?A:u?A[s]||oe(s,{}):(A[s]||{}).prototype)for(r in t){if(o=t[r],i=e.noTargetGet?(a=wt(n,r))&&a.value:n[r],!Tt(c?r:s+(u?".":"#")+r,e.forced)&&void 0!==i){if(typeof o==typeof i)continue;_t(o,i)}(e.sham||i&&i.sham)&&Ae(o,"sham",!0),Ye(n,r,o,e)}},Et=function(e,t,n){if(re(e),void 0===t)return e;switch(n){case 0:return function(){return e.call(t)};case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}},Ct=Array.isArray||function(e){return"Array"==V(e)},xt={};xt[_e("toStringTag")]="z";var At="[object z]"===String(xt),Pt=_e("toStringTag"),Dt="Arguments"==V(function(){return arguments}()),Lt=At?V:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),Pt))?n:Dt?V(t):"Object"==(r=V(t))&&z(t.callee)?"Arguments":r},Mt=[],Nt=J("Reflect","construct"),Ot=/^\s*(?:class|function)\b/,Ut=Ot.exec,Vt=!Ot.exec((function(){})),Ft=function(e){if(!z(e))return!1;try{return Nt(Object,Mt,e),!0}catch(e){return!1}},jt=!Nt||P((function(){var e;return Ft(Ft.call)||!Ft(Object)||!Ft((function(){e=!0}))||e}))?function(e){if(!z(e))return!1;switch(Lt(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}return Vt||!!Ut.call(Ot,Ne(e))}:Ft,Bt=_e("species"),Ht=function(e,t){return new(function(e){var t;return Ct(e)&&(t=e.constructor,(jt(t)&&(t===Array||Ct(t.prototype))||G(t)&&null===(t=t[Bt]))&&(t=void 0)),void 0===t?Array:t}(e))(0===t?0:t)},zt=[].push,Gt=function(e){var t=1==e,n=2==e,r=3==e,i=4==e,o=6==e,a=7==e,s=5==e||o;return function(c,u,l,d){for(var h,p,f=ce(c),m=j(f),v=Et(u,l,3),_=st(m),g=0,y=d||Ht,S=t?y(c,_):n||a?y(c,0):void 0;_>g;g++)if((s||g in m)&&(p=v(h=m[g],g,f),e))if(t)S[g]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return g;case 2:zt.call(S,h)}else switch(e){case 4:return!1;case 7:zt.call(S,h)}return o?-1:r||i?i:S}},Wt={forEach:Gt(0),map:Gt(1),filter:Gt(2),some:Gt(3),every:Gt(4),find:Gt(5),findIndex:Gt(6),filterReject:Gt(7)},Jt=_e("species"),qt=function(e){return Y>=51||!P((function(){var t=[];return(t.constructor={})[Jt]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Kt=Wt.map,Qt=qt("map");Rt({target:"Array",proto:!0,forced:!Qt},{map:function(e){return Kt(this,e,arguments.length>1?arguments[1]:void 0)}});var Xt=Wt.filter,$t=qt("filter");Rt({target:"Array",proto:!0,forced:!$t},{filter:function(e){return Xt(this,e,arguments.length>1?arguments[1]:void 0)}});var Yt=Re.f,Zt=P((function(){Yt(1)}));Rt({target:"Object",stat:!0,forced:!D||Zt,sham:!D},{getOwnPropertyDescriptor:function(e,t){return Yt(H(e),t)}}),R((function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var i=t&&t.prototype instanceof d?t:d,o=Object.create(i.prototype),a=new I(r||[]);return o._invoke=function(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var s=S(a,n);if(s){if(s===l)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=u(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(e,n,a),o}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var l={};function d(){}function h(){}function p(){}var f={};s(f,i,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(T([])));v&&v!==t&&n.call(v,i)&&(f=v);var _=p.prototype=d.prototype=Object.create(f);function g(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){var r;this._invoke=function(i,o){function a(){return new t((function(r,a){!function r(i,o,a,s){var c=u(e[i],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(d).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,s)}))}s(c.arg)}(i,o,r,a)}))}return r=r?r.then(a,a):a()}}function S(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,S(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=u(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,l;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function T(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:w}}function w(){return{value:void 0,done:!0}}return h.prototype=p,s(_,"constructor",p),s(p,"constructor",h),h.displayName=s(p,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s(e,a,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},g(y.prototype),s(y.prototype,o,(function(){return this})),e.AsyncIterator=y,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new y(c(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(_),s(_,a,"Generator"),s(_,i,(function(){return this})),s(_,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=T,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;k(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:T(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}));let en=!0,tn=!0;function nn(e,t,n){const r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function rn(e,t,n){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);const o=e=>{const t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,o),i.apply(this,[e,o])};const o=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(n))return o.apply(this,arguments);const r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function on(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(en=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function an(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(tn=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function sn(){if("object"==typeof window){if(en)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function cn(e,t){tn&&console.warn(e+" is deprecated, please use "+t+" instead.")}function un(e){return"[object Object]"===Object.prototype.toString.call(e)}function ln(e){return un(e)?Object.keys(e).reduce((function(t,n){const r=un(e[n]),i=r?ln(e[n]):e[n],o=r&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,{[n]:i})}),{}):e}function dn(e,t,n){const r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((n=>{n.type===r&&n.trackId===t.id&&function e(t,n,r){n&&!r.has(n.id)&&(r.set(n.id,n),Object.keys(n).forEach((i=>{i.endsWith("Id")?e(t,t.get(n[i]),r):i.endsWith("Ids")&&n[i].forEach((n=>{e(t,t.get(n),r)}))})))}(e,n,i)}))})),i}const hn=sn;function pn(e,t){const n=e&&e.navigator;if(!n.mediaDevices)return;const r=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((n=>{if("require"===n||"advanced"===n||"mediaSource"===n)return;const r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];let e={};"number"==typeof r.ideal?(e[i("min",n)]=r.ideal,t.optional.push(e),e={},e[i("max",n)]=r.ideal,t.optional.push(e)):(e[i("",n)]=r.ideal,t.optional.push(e))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach((e=>{void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});const a=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||a)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return n.mediaDevices.enumerateDevices().then((n=>{let a=(n=n.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!a&&n.length&&t.includes("back")&&(a=n[n.length-1]),a&&(e.video.deviceId=o.exact?{exact:a.deviceId}:{ideal:a.deviceId}),e.video=r(e.video),hn("chrome: "+JSON.stringify(e)),i(e)}))}e.video=r(e.video)}return hn("chrome: "+JSON.stringify(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,r){i(e,(e=>{n.webkitGetUserMedia(e,t,(e=>{r&&r(o(e))}))}))}.bind(n),n.mediaDevices.getUserMedia){const e=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(t){return i(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(o(e))))))}}}function fn(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function mn(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.track.id)):{track:n.track};const i=new Event("track");i.track=n.track,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)})),t.stream.getTracks().forEach((n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.id)):{track:n};const i=new Event("track");i.track=n,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else rn(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function vn(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){let i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function _n(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,n,r]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const i=function(e){const t={};return e.result().forEach((e=>{const n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{n[t]=e.stat(t)})),t[n.id]=n})),t},o=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const r=function(e){n(o(i(e)))};return t.apply(this,[r,e])}return new Promise(((e,n)=>{t.apply(this,[function(t){e(o(i(t)))},n])})).then(n,r)}}function gn(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>dn(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),rn(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>dn(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,n,r;return this.getSenders().forEach((n=>{n.track===e&&(t?r=!0:t=n)})),this.getReceivers().forEach((t=>(t.track===e&&(n?r=!0:n=t),t.track===e))),r||t&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function yn(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(r)&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();n.apply(this,arguments);const r=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(r)};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const n=this._shimmedLocalStreams[t].indexOf(e);-1!==n&&this._shimmedLocalStreams[t].splice(n,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),i.apply(this,arguments)}}function Sn(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return yn(e);const n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=n.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const n=new e.MediaStream(t.getTracks());this._streams[t.id]=n,this._reverseStreams[n.id]=t,t=n}r.apply(this,[t])};const i=e.RTCPeerConnection.prototype.removeStream;function o(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:n})}function a(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:n})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const r=[].slice.call(arguments,1);if(1!==r.length||!r[0].getTracks().find((e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");const i=this.getSenders().find((e=>e.track===t));if(i)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const o=this._streams[n.id];if(o)o.addTrack(t),Promise.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const r=new e.MediaStream([t]);this._streams[n.id]=r,this._reverseStreams[r.id]=n,this.addStream(r)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?n.apply(this,[t=>{const n=o(this,t);e[0].apply(null,[n])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):n.apply(this,arguments).then((e=>o(this,e)))}};e.RTCPeerConnection.prototype[t]=r[t]}));const s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=a(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};const c=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=c.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(e._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach((n=>{this._streams[n].getTracks().find((t=>e.track===t))&&(t=this._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function bn(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}))}function kn(e,t){rn(e,"negotiationneeded",(e=>{const n=e.target;if(!(t.version<72||n.getConfiguration&&"plan-b"===n.getConfiguration().sdpSemantics)||"stable"===n.signalingState)return e}))}var In=Object.freeze({__proto__:null,shimMediaStream:fn,shimOnTrack:mn,shimGetSendersWithDtmf:vn,shimGetStats:_n,shimSenderReceiverGetStats:gn,shimAddTrackRemoveTrackWithNative:yn,shimAddTrackRemoveTrack:Sn,shimPeerConnection:bn,fixNegotiationNeeded:kn,shimGetUserMedia:pn,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(n){return t(n).then((t=>{const r=n.video&&n.video.width,i=n.video&&n.video.height,o=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},r&&(n.video.mandatory.maxWidth=r),i&&(n.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(n)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}}),Tn=R((function(e){var t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},t.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},t.getDescription=function(e){var n=t.splitSections(e);return n&&n[0]},t.getMediaSections=function(e){var n=t.splitSections(e);return n.shift(),n},t.matchPrefix=function(e,n){return t.splitLines(e).filter((function(e){return 0===e.indexOf(n)}))},t.parseCandidate=function(e){for(var t,n={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;case"ufrag":n.ufrag=t[r+1],n.usernameFragment=t[r+1];break;default:n[t[r]]=t[r+1]}return n},t.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.parseRtpMap=function(e){var t=e.substr(9).split(" "),n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},t.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},t.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},t.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<r.length;i++)n[(t=r[i].trim().split("="))[0].trim()]=t[1];return n},t.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach((function(t){e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)})),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){var t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},t.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},t.getMid=function(e){var n=t.matchPrefix(e,"a=mid:")[0];if(n)return n.substr(6)},t.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},t.getDtlsParameters=function(e,n){return{role:"auto",fingerprints:t.matchPrefix(e+n,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),n},t.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,n){return t.matchPrefix(e+n,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,n){var r=t.matchPrefix(e+n,"a=ice-ufrag:")[0],i=t.matchPrefix(e+n,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substr(12),password:i.substr(10)}:null},t.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},t.parseRtpParameters=function(e){for(var n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(" "),i=3;i<r.length;i++){var o=r[i],a=t.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(a){var s=t.parseRtpMap(a),c=t.matchPrefix(e,"a=fmtp:"+o+" ");switch(s.parameters=c.length?t.parseFmtp(c[0]):{},s.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(t.parseRtcpFb),n.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":n.fecMechanisms.push(s.name.toUpperCase())}}}return t.matchPrefix(e,"a=extmap:").forEach((function(e){n.headerExtensions.push(t.parseExtmap(e))})),n},t.writeRtpDescription=function(e,n){var r="";r+="m="+e+" ",r+=n.codecs.length>0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=n.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",n.codecs.forEach((function(e){r+=t.writeRtpMap(e),r+=t.writeFmtp(e),r+=t.writeRtcpFb(e)}));var i=0;return n.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(r+="a=maxptime:"+i+"\r\n"),r+="a=rtcp-mux\r\n",n.headerExtensions&&n.headerExtensions.forEach((function(e){r+=t.writeExtmap(e)})),r},t.parseRtpEncodingParameters=function(e){var n,r=[],i=t.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),a=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=s.length>0&&s[0].ssrc,u=t.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substr(17).split(" ").map((function(e){return parseInt(e,10)}))}));u.length>0&&u[0].length>1&&u[0][0]===c&&(n=u[0][1]),i.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&n&&(t.rtx={ssrc:n}),r.push(t),o&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},r.push(t))}})),0===r.length&&c&&r.push({ssrc:c});var l=t.matchPrefix(e,"b=");return l.length&&(l=0===l[0].indexOf("b=TIAS:")?parseInt(l[0].substr(7),10):0===l[0].indexOf("b=AS:")?1e3*parseInt(l[0].substr(5),10)*.95-16e3:void 0,r.forEach((function(e){e.maxBitrate=l}))),r},t.parseRtcpParameters=function(e){var n={},r=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];r&&(n.cname=r.value,n.ssrc=r.ssrc);var i=t.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=i.length>0,n.compound=0===i.length;var o=t.matchPrefix(e,"a=rtcp-mux");return n.mux=o.length>0,n},t.parseMsid=function(e){var n,r=t.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(n=r[0].substr(7).split(" "))[0],track:n[1]};var i=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return i.length>0?{stream:(n=i[0].value.split(" "))[0],track:n[1]}:void 0},t.parseSctpDescription=function(e){var n,r=t.parseMLine(e),i=t.matchPrefix(e,"a=max-message-size:");i.length>0&&(n=parseInt(i[0].substr(19),10)),isNaN(n)&&(n=65536);var o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:r.fmt,maxMessageSize:n};if(t.matchPrefix(e,"a=sctpmap:").length>0){var a=t.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(a[0],10),protocol:a[1],maxMessageSize:n}}},t.writeSctpDescription=function(e,t){var n=[];return n="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&n.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),n.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,n,r){var i=void 0!==n?n:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.writeMediaSection=function(e,n,r,i){var o=t.writeRtpDescription(e.kind,n);if(o+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":"active"),o+="a=mid:"+e.mid+"\r\n",e.direction?o+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?o+="a=sendrecv\r\n":e.rtpSender?o+="a=sendonly\r\n":e.rtpReceiver?o+="a=recvonly\r\n":o+="a=inactive\r\n",e.rtpSender){var a="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";o+="a="+a,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+"\r\n"),o},t.getDirection=function(e,n){for(var r=t.splitLines(e),i=0;i<r.length;i++)switch(r[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[i].substr(2)}return n?t.getDirection(n):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substr(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){var n=t.splitLines(e)[0].substr(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},t.parseOLine=function(e){var n=t.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:n[0],sessionId:n[1],sessionVersion:parseInt(n[2],10),netType:n[3],addressType:n[4],address:n[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var n=t.splitLines(e),r=0;r<n.length;r++)if(n[r].length<2||"="!==n[r].charAt(1))return!1;return!0},e.exports=t}));function wn(e,t,n,r,i){var o=Tn.writeRtpDescription(e.kind,t);if(o+=Tn.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=Tn.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":i||"active"),o+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?o+="a=sendrecv\r\n":e.rtpSender?o+="a=sendonly\r\n":e.rtpReceiver?o+="a=recvonly\r\n":o+="a=inactive\r\n",e.rtpSender){var a=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=a;var s="msid:"+(r?r.id:"-")+" "+a+"\r\n";o+="a="+s,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+s,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+s,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+Tn.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+Tn.localCName+"\r\n"),o}function Rn(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var n=0;n<t.length;n++)if(t[n].payloadType===e||t[n].preferredPayloadType===e)return t[n]},i=function(e,t,n,i){var o=r(e.parameters.apt,n),a=r(t.parameters.apt,i);return o&&a&&o.name.toLowerCase()===a.name.toLowerCase()};return e.codecs.forEach((function(r){for(var o=0;o<t.codecs.length;o++){var a=t.codecs[o];if(r.name.toLowerCase()===a.name.toLowerCase()&&r.clockRate===a.clockRate){if("rtx"===r.name.toLowerCase()&&r.parameters&&a.parameters.apt&&!i(r,a,e.codecs,t.codecs))continue;(a=JSON.parse(JSON.stringify(a))).numChannels=Math.min(r.numChannels,a.numChannels),n.codecs.push(a),a.rtcpFeedback=a.rtcpFeedback.filter((function(e){for(var t=0;t<r.rtcpFeedback.length;t++)if(r.rtcpFeedback[t].type===e.type&&r.rtcpFeedback[t].parameter===e.parameter)return!0;return!1}));break}}})),e.headerExtensions.forEach((function(e){for(var r=0;r<t.headerExtensions.length;r++){var i=t.headerExtensions[r];if(e.uri===i.uri){n.headerExtensions.push(i);break}}})),n}function En(e,t,n){return-1!=={offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(n)}function Cn(e,t){var n=e.getRemoteCandidates().find((function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type}));return n||e.addRemoteCandidate(t),!n}function xn(e,t){var n=new Error(t);return n.name=e,n.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],n}function An(e){const t=e&&e.navigator,n=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return n(e).catch((e=>Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString(){return this.name}}}(e))))}}function Pn(e){"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)))}function Dn(e,t){if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){const t=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(e){t.set.call(this,e);const n=new Event("enabled");n.enabled=e,this.dispatchEvent(n)}})}e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)&&Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);const n=function(e,t){function n(t,n){n.addTrack(t),n.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function r(t,n,r,i){var o=new Event("track");o.track=n,o.receiver=r,o.transceiver={receiver:r},o.streams=i,e.setTimeout((function(){t._dispatchEvent("track",o)}))}var i=function(n){var r=this,i=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach((function(e){r[e]=i[e].bind(i)})),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",n=JSON.parse(JSON.stringify(n||{})),this.usingBundle="max-bundle"===n.bundlePolicy,"negotiate"===n.rtcpMuxPolicy)throw xn("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(n.rtcpMuxPolicy||(n.rtcpMuxPolicy="require"),n.iceTransportPolicy){case"all":case"relay":break;default:n.iceTransportPolicy="all"}switch(n.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:n.bundlePolicy="balanced"}if(n.iceServers=function(e,t){var n=!1;return(e=JSON.parse(JSON.stringify(e))).filter((function(e){if(e&&(e.urls||e.url)){var r=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var i="string"==typeof r;return i&&(r=[r]),r=r.filter((function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||n?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(n=!0,!0)})),delete e.url,e.urls=i?r[0]:r,!!r.length}}))}(n.iceServers||[],t),this._iceGatherers=[],n.iceCandidatePoolSize)for(var o=n.iceCandidatePoolSize;o>0;o--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:n.iceServers,gatherPolicy:n.iceTransportPolicy}));else n.iceCandidatePoolSize=0;this._config=n,this.transceivers=[],this._sdpSessionId=Tn.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(i.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(i.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),i.prototype.onicecandidate=null,i.prototype.onaddstream=null,i.prototype.ontrack=null,i.prototype.onremovestream=null,i.prototype.onsignalingstatechange=null,i.prototype.oniceconnectionstatechange=null,i.prototype.onconnectionstatechange=null,i.prototype.onicegatheringstatechange=null,i.prototype.onnegotiationneeded=null,i.prototype.ondatachannel=null,i.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},i.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},i.prototype.getConfiguration=function(){return this._config},i.prototype.getLocalStreams=function(){return this.localStreams},i.prototype.getRemoteStreams=function(){return this.remoteStreams},i.prototype._createTransceiver=function(e,t){var n=this.transceivers.length>0,r={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&n)r.iceTransport=this.transceivers[0].iceTransport,r.dtlsTransport=this.transceivers[0].dtlsTransport;else{var i=this._createIceAndDtlsTransports();r.iceTransport=i.iceTransport,r.dtlsTransport=i.dtlsTransport}return t||this.transceivers.push(r),r},i.prototype.addTrack=function(t,n){if(this._isClosed)throw xn("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var r;if(this.transceivers.find((function(e){return e.track===t})))throw xn("InvalidAccessError","Track already exists.");for(var i=0;i<this.transceivers.length;i++)this.transceivers[i].track||this.transceivers[i].kind!==t.kind||(r=this.transceivers[i]);return r||(r=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(n)&&this.localStreams.push(n),r.track=t,r.stream=n,r.rtpSender=new e.RTCRtpSender(t,r.dtlsTransport),r.rtpSender},i.prototype.addStream=function(e){var n=this;if(t>=15025)e.getTracks().forEach((function(t){n.addTrack(t,e)}));else{var r=e.clone();e.getTracks().forEach((function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",(function(e){n.enabled=e.enabled}))})),r.getTracks().forEach((function(e){n.addTrack(e,r)}))}},i.prototype.removeTrack=function(t){if(this._isClosed)throw xn("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var n=this.transceivers.find((function(e){return e.rtpSender===t}));if(!n)throw xn("InvalidAccessError","Sender was not created by this connection.");var r=n.stream;n.rtpSender.stop(),n.rtpSender=null,n.track=null,n.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(r)&&this.localStreams.indexOf(r)>-1&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},i.prototype.removeStream=function(e){var t=this;e.getTracks().forEach((function(e){var n=t.getSenders().find((function(t){return t.track===e}));n&&t.removeTrack(n)}))},i.prototype.getSenders=function(){return this.transceivers.filter((function(e){return!!e.rtpSender})).map((function(e){return e.rtpSender}))},i.prototype.getReceivers=function(){return this.transceivers.filter((function(e){return!!e.rtpReceiver})).map((function(e){return e.rtpReceiver}))},i.prototype._createIceGatherer=function(t,n){var r=this;if(n&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var n=!e.candidate||0===Object.keys(e.candidate).length;i.state=n?"completed":"gathering",null!==r.transceivers[t].bufferedCandidateEvents&&r.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},i.prototype._gather=function(t,n){var r=this,i=this.transceivers[n].iceGatherer;if(!i.onlocalcandidate){var o=this.transceivers[n].bufferedCandidateEvents;this.transceivers[n].bufferedCandidateEvents=null,i.removeEventListener("localcandidate",this.transceivers[n].bufferCandidates),i.onlocalcandidate=function(e){if(!(r.usingBundle&&n>0)){var o=new Event("icecandidate");o.candidate={sdpMid:t,sdpMLineIndex:n};var a=e.candidate,s=!a||0===Object.keys(a).length;if(s)"new"!==i.state&&"gathering"!==i.state||(i.state="completed");else{"new"===i.state&&(i.state="gathering"),a.component=1,a.ufrag=i.getLocalParameters().usernameFragment;var c=Tn.writeCandidate(a);o.candidate=Object.assign(o.candidate,Tn.parseCandidate(c)),o.candidate.candidate=c,o.candidate.toJSON=function(){return{candidate:o.candidate.candidate,sdpMid:o.candidate.sdpMid,sdpMLineIndex:o.candidate.sdpMLineIndex,usernameFragment:o.candidate.usernameFragment}}}var u=Tn.getMediaSections(r._localDescription.sdp);u[o.candidate.sdpMLineIndex]+=s?"a=end-of-candidates\r\n":"a="+o.candidate.candidate+"\r\n",r._localDescription.sdp=Tn.getDescription(r._localDescription.sdp)+u.join("");var l=r.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==r.iceGatheringState&&(r.iceGatheringState="gathering",r._emitGatheringStateChange()),s||r._dispatchEvent("icecandidate",o),l&&(r._dispatchEvent("icecandidate",new Event("icecandidate")),r.iceGatheringState="complete",r._emitGatheringStateChange())}},e.setTimeout((function(){o.forEach((function(e){i.onlocalcandidate(e)}))}),0)}},i.prototype._createIceAndDtlsTransports=function(){var t=this,n=new e.RTCIceTransport(null);n.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var r=new e.RTCDtlsTransport(n);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:n,dtlsTransport:r}},i.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},i.prototype._transceive=function(e,n,r){var i=Rn(e.localCapabilities,e.remoteCapabilities);n&&e.rtpSender&&(i.encodings=e.sendEncodingParameters,i.rtcp={cname:Tn.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(i.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(i)),r&&e.rtpReceiver&&i.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach((function(e){delete e.rtx})),e.recvEncodingParameters.length?i.encodings=e.recvEncodingParameters:i.encodings=[{}],i.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(i.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(i.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(i))},i.prototype.setLocalDescription=function(e){var t,n,r=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(xn("TypeError",'Unsupported type "'+e.type+'"'));if(!En("setLocalDescription",e.type,r.signalingState)||r._isClosed)return Promise.reject(xn("InvalidStateError","Can not set local "+e.type+" in state "+r.signalingState));if("offer"===e.type)t=Tn.splitSections(e.sdp),n=t.shift(),t.forEach((function(e,t){var n=Tn.parseRtpParameters(e);r.transceivers[t].localCapabilities=n})),r.transceivers.forEach((function(e,t){r._gather(e.mid,t)}));else if("answer"===e.type){t=Tn.splitSections(r._remoteDescription.sdp),n=t.shift();var i=Tn.matchPrefix(n,"a=ice-lite").length>0;t.forEach((function(e,t){var o=r.transceivers[t],a=o.iceGatherer,s=o.iceTransport,c=o.dtlsTransport,u=o.localCapabilities,l=o.remoteCapabilities;if(!(Tn.isRejected(e)&&0===Tn.matchPrefix(e,"a=bundle-only").length||o.rejected)){var d=Tn.getIceParameters(e,n),h=Tn.getDtlsParameters(e,n);i&&(h.role="server"),r.usingBundle&&0!==t||(r._gather(o.mid,t),"new"===s.state&&s.start(a,d,i?"controlling":"controlled"),"new"===c.state&&c.start(h));var p=Rn(u,l);r._transceive(o,p.codecs.length>0,!1)}}))}return r._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?r._updateSignalingState("have-local-offer"):r._updateSignalingState("stable"),Promise.resolve()},i.prototype.setRemoteDescription=function(i){var o=this;if(-1===["offer","answer"].indexOf(i.type))return Promise.reject(xn("TypeError",'Unsupported type "'+i.type+'"'));if(!En("setRemoteDescription",i.type,o.signalingState)||o._isClosed)return Promise.reject(xn("InvalidStateError","Can not set remote "+i.type+" in state "+o.signalingState));var a={};o.remoteStreams.forEach((function(e){a[e.id]=e}));var s=[],c=Tn.splitSections(i.sdp),u=c.shift(),l=Tn.matchPrefix(u,"a=ice-lite").length>0,d=Tn.matchPrefix(u,"a=group:BUNDLE ").length>0;o.usingBundle=d;var h=Tn.matchPrefix(u,"a=ice-options:")[0];return o.canTrickleIceCandidates=!!h&&h.substr(14).split(" ").indexOf("trickle")>=0,c.forEach((function(r,c){var h=Tn.splitLines(r),p=Tn.getKind(r),f=Tn.isRejected(r)&&0===Tn.matchPrefix(r,"a=bundle-only").length,m=h[0].substr(2).split(" ")[2],v=Tn.getDirection(r,u),_=Tn.parseMsid(r),g=Tn.getMid(r)||Tn.generateIdentifier();if(f||"application"===p&&("DTLS/SCTP"===m||"UDP/DTLS/SCTP"===m))o.transceivers[c]={mid:g,kind:p,protocol:m,rejected:!0};else{var y,S,b,k,I,T,w,R,E;!f&&o.transceivers[c]&&o.transceivers[c].rejected&&(o.transceivers[c]=o._createTransceiver(p,!0));var C,x,A=Tn.parseRtpParameters(r);f||(C=Tn.getIceParameters(r,u),(x=Tn.getDtlsParameters(r,u)).role="client"),w=Tn.parseRtpEncodingParameters(r);var P=Tn.parseRtcpParameters(r),D=Tn.matchPrefix(r,"a=end-of-candidates",u).length>0,L=Tn.matchPrefix(r,"a=candidate:").map((function(e){return Tn.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===i.type||"answer"===i.type)&&!f&&d&&c>0&&o.transceivers[c]&&(o._disposeIceAndDtlsTransports(c),o.transceivers[c].iceGatherer=o.transceivers[0].iceGatherer,o.transceivers[c].iceTransport=o.transceivers[0].iceTransport,o.transceivers[c].dtlsTransport=o.transceivers[0].dtlsTransport,o.transceivers[c].rtpSender&&o.transceivers[c].rtpSender.setTransport(o.transceivers[0].dtlsTransport),o.transceivers[c].rtpReceiver&&o.transceivers[c].rtpReceiver.setTransport(o.transceivers[0].dtlsTransport)),"offer"!==i.type||f)"answer"!==i.type||f||(S=(y=o.transceivers[c]).iceGatherer,b=y.iceTransport,k=y.dtlsTransport,I=y.rtpReceiver,T=y.sendEncodingParameters,R=y.localCapabilities,o.transceivers[c].recvEncodingParameters=w,o.transceivers[c].remoteCapabilities=A,o.transceivers[c].rtcpParameters=P,L.length&&"new"===b.state&&(!l&&!D||d&&0!==c?L.forEach((function(e){Cn(y.iceTransport,e)})):b.setRemoteCandidates(L)),d&&0!==c||("new"===b.state&&b.start(S,C,"controlling"),"new"===k.state&&k.start(x)),!Rn(y.localCapabilities,y.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&y.sendEncodingParameters[0].rtx&&delete y.sendEncodingParameters[0].rtx,o._transceive(y,"sendrecv"===v||"recvonly"===v,"sendrecv"===v||"sendonly"===v),!I||"sendrecv"!==v&&"sendonly"!==v?delete y.rtpReceiver:(E=I.track,_?(a[_.stream]||(a[_.stream]=new e.MediaStream),n(E,a[_.stream]),s.push([E,I,a[_.stream]])):(a.default||(a.default=new e.MediaStream),n(E,a.default),s.push([E,I,a.default]))));else{(y=o.transceivers[c]||o._createTransceiver(p)).mid=g,y.iceGatherer||(y.iceGatherer=o._createIceGatherer(c,d)),L.length&&"new"===y.iceTransport.state&&(!D||d&&0!==c?L.forEach((function(e){Cn(y.iceTransport,e)})):y.iceTransport.setRemoteCandidates(L)),R=e.RTCRtpReceiver.getCapabilities(p),t<15019&&(R.codecs=R.codecs.filter((function(e){return"rtx"!==e.name}))),T=y.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var M,N=!1;"sendrecv"===v||"sendonly"===v?(N=!y.rtpReceiver,I=y.rtpReceiver||new e.RTCRtpReceiver(y.dtlsTransport,p),N&&(E=I.track,_&&"-"===_.stream||(_?(a[_.stream]||(a[_.stream]=new e.MediaStream,Object.defineProperty(a[_.stream],"id",{get:function(){return _.stream}})),Object.defineProperty(E,"id",{get:function(){return _.track}}),M=a[_.stream]):(a.default||(a.default=new e.MediaStream),M=a.default)),M&&(n(E,M),y.associatedRemoteMediaStreams.push(M)),s.push([E,I,M]))):y.rtpReceiver&&y.rtpReceiver.track&&(y.associatedRemoteMediaStreams.forEach((function(t){var n=t.getTracks().find((function(e){return e.id===y.rtpReceiver.track.id}));n&&function(t,n){n.removeTrack(t),n.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(n,t)})),y.associatedRemoteMediaStreams=[]),y.localCapabilities=R,y.remoteCapabilities=A,y.rtpReceiver=I,y.rtcpParameters=P,y.sendEncodingParameters=T,y.recvEncodingParameters=w,o._transceive(o.transceivers[c],!1,N)}}})),void 0===o._dtlsRole&&(o._dtlsRole="offer"===i.type?"active":"passive"),o._remoteDescription={type:i.type,sdp:i.sdp},"offer"===i.type?o._updateSignalingState("have-remote-offer"):o._updateSignalingState("stable"),Object.keys(a).forEach((function(t){var n=a[t];if(n.getTracks().length){if(-1===o.remoteStreams.indexOf(n)){o.remoteStreams.push(n);var i=new Event("addstream");i.stream=n,e.setTimeout((function(){o._dispatchEvent("addstream",i)}))}s.forEach((function(e){var t=e[0],i=e[1];n.id===e[2].id&&r(o,t,i,[n])}))}})),s.forEach((function(e){e[2]||r(o,e[0],e[1],[])})),e.setTimeout((function(){o&&o.transceivers&&o.transceivers.forEach((function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))}))}),4e3),Promise.resolve()},i.prototype.close=function(){this.transceivers.forEach((function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()})),this._isClosed=!0,this._updateSignalingState("closed")},i.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},i.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout((function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}}),0))},i.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++})),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",n)}},i.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++)})),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var n=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",n)}},i.prototype.createOffer=function(){var n=this;if(n._isClosed)return Promise.reject(xn("InvalidStateError","Can not call createOffer after close"));var r=n.transceivers.filter((function(e){return"audio"===e.kind})).length,i=n.transceivers.filter((function(e){return"video"===e.kind})).length,o=arguments[0];if(o){if(o.mandatory||o.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==o.offerToReceiveAudio&&(r=!0===o.offerToReceiveAudio?1:!1===o.offerToReceiveAudio?0:o.offerToReceiveAudio),void 0!==o.offerToReceiveVideo&&(i=!0===o.offerToReceiveVideo?1:!1===o.offerToReceiveVideo?0:o.offerToReceiveVideo)}for(n.transceivers.forEach((function(e){"audio"===e.kind?--r<0&&(e.wantReceive=!1):"video"===e.kind&&--i<0&&(e.wantReceive=!1)}));r>0||i>0;)r>0&&(n._createTransceiver("audio"),r--),i>0&&(n._createTransceiver("video"),i--);var a=Tn.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.transceivers.forEach((function(r,i){var o=r.track,a=r.kind,s=r.mid||Tn.generateIdentifier();r.mid=s,r.iceGatherer||(r.iceGatherer=n._createIceGatherer(i,n.usingBundle));var c=e.RTCRtpSender.getCapabilities(a);t<15019&&(c.codecs=c.codecs.filter((function(e){return"rtx"!==e.name}))),c.codecs.forEach((function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),r.remoteCapabilities&&r.remoteCapabilities.codecs&&r.remoteCapabilities.codecs.forEach((function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)}))})),c.headerExtensions.forEach((function(e){(r.remoteCapabilities&&r.remoteCapabilities.headerExtensions||[]).forEach((function(t){e.uri===t.uri&&(e.id=t.id)}))}));var u=r.sendEncodingParameters||[{ssrc:1001*(2*i+1)}];o&&t>=15019&&"video"===a&&!u[0].rtx&&(u[0].rtx={ssrc:u[0].ssrc+1}),r.wantReceive&&(r.rtpReceiver=new e.RTCRtpReceiver(r.dtlsTransport,a)),r.localCapabilities=c,r.sendEncodingParameters=u})),"max-compat"!==n._config.bundlePolicy&&(a+="a=group:BUNDLE "+n.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),a+="a=ice-options:trickle\r\n",n.transceivers.forEach((function(e,t){a+=wn(e,e.localCapabilities,"offer",e.stream,n._dtlsRole),a+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===n.iceGatheringState||0!==t&&n.usingBundle||(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,a+="a="+Tn.writeCandidate(e)+"\r\n"})),"completed"===e.iceGatherer.state&&(a+="a=end-of-candidates\r\n"))}));var s=new e.RTCSessionDescription({type:"offer",sdp:a});return Promise.resolve(s)},i.prototype.createAnswer=function(){var n=this;if(n._isClosed)return Promise.reject(xn("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==n.signalingState&&"have-local-pranswer"!==n.signalingState)return Promise.reject(xn("InvalidStateError","Can not call createAnswer in signalingState "+n.signalingState));var r=Tn.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.usingBundle&&(r+="a=group:BUNDLE "+n.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),r+="a=ice-options:trickle\r\n";var i=Tn.getMediaSections(n._remoteDescription.sdp).length;n.transceivers.forEach((function(e,o){if(!(o+1>i)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?r+="m=application 0 DTLS/SCTP 5000\r\n":r+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?r+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(r+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(r+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var a;e.stream&&("audio"===e.kind?a=e.stream.getAudioTracks()[0]:"video"===e.kind&&(a=e.stream.getVideoTracks()[0]),a&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1}));var s=Rn(e.localCapabilities,e.remoteCapabilities);!s.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,r+=wn(e,s,"answer",e.stream,n._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(r+="a=rtcp-rsize\r\n")}}));var o=new e.RTCSessionDescription({type:"answer",sdp:r});return Promise.resolve(o)},i.prototype.addIceCandidate=function(e){var t,n=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise((function(r,i){if(!n._remoteDescription)return i(xn("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var o=e.sdpMLineIndex;if(e.sdpMid)for(var a=0;a<n.transceivers.length;a++)if(n.transceivers[a].mid===e.sdpMid){o=a;break}var s=n.transceivers[o];if(!s)return i(xn("OperationError","Can not add ICE candidate"));if(s.rejected)return r();var c=Object.keys(e.candidate).length>0?Tn.parseCandidate(e.candidate):{};if("tcp"===c.protocol&&(0===c.port||9===c.port))return r();if(c.component&&1!==c.component)return r();if((0===o||o>0&&s.iceTransport!==n.transceivers[0].iceTransport)&&!Cn(s.iceTransport,c))return i(xn("OperationError","Can not add ICE candidate"));var u=e.candidate.trim();0===u.indexOf("a=")&&(u=u.substr(2)),(t=Tn.getMediaSections(n._remoteDescription.sdp))[o]+="a="+(c.type?u:"end-of-candidates")+"\r\n",n._remoteDescription.sdp=Tn.getDescription(n._remoteDescription.sdp)+t.join("")}else for(var l=0;l<n.transceivers.length&&(n.transceivers[l].rejected||(n.transceivers[l].iceTransport.addRemoteCandidate({}),(t=Tn.getMediaSections(n._remoteDescription.sdp))[l]+="a=end-of-candidates\r\n",n._remoteDescription.sdp=Tn.getDescription(n._remoteDescription.sdp)+t.join(""),!n.usingBundle));l++);r()}))},i.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var n=null;if(this.transceivers.forEach((function(e){e.rtpSender&&e.rtpSender.track===t?n=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(n=e.rtpReceiver)})),!n)throw xn("InvalidAccessError","Invalid selector.");return n.getStats()}var r=[];return this.transceivers.forEach((function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach((function(t){e[t]&&r.push(e[t].getStats())}))})),Promise.all(r).then((function(e){var t=new Map;return e.forEach((function(e){e.forEach((function(e){t.set(e.id,e)}))})),t}))},["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach((function(t){var n=e[t];if(n&&n.prototype&&n.prototype.getStats){var r=n.prototype.getStats;n.prototype.getStats=function(){return r.apply(this).then((function(e){var t=new Map;return Object.keys(e).forEach((function(n){var r;e[n].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(r=e[n]).type]||r.type,t.set(n,e[n])})),t}))}}}));var o=["createOffer","createAnswer"];return o.forEach((function(e){var t=i.prototype[e];i.prototype[e]=function(){var e=arguments;return"function"==typeof e[0]||"function"==typeof e[1]?t.apply(this,[arguments[2]]).then((function(t){"function"==typeof e[0]&&e[0].apply(null,[t])}),(function(t){"function"==typeof e[1]&&e[1].apply(null,[t])})):t.apply(this,arguments)}})),(o=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach((function(e){var t=i.prototype[e];i.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]||"function"==typeof e[2]?t.apply(this,arguments).then((function(){"function"==typeof e[1]&&e[1].apply(null)}),(function(t){"function"==typeof e[2]&&e[2].apply(null,[t])})):t.apply(this,arguments)}})),["getStats"].forEach((function(e){var t=i.prototype[e];i.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]?t.apply(this,arguments).then((function(){"function"==typeof e[1]&&e[1].apply(null)})):t.apply(this,arguments)}})),i}(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=function(e,t){let n=!1;return(e=JSON.parse(JSON.stringify(e))).filter((e=>{if(e&&(e.urls||e.url)){let t=e.urls||e.url;e.url&&!e.urls&&cn("RTCIceServer.url","RTCIceServer.urls");const r="string"==typeof t;return r&&(t=[t]),t=t.filter((e=>{if(0===e.indexOf("stun:"))return!1;const t=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return t&&!n?(n=!0,!0):t&&!n})),delete e.url,e.urls=r?t[0]:t,!!t.length}}))}(e.iceServers,t.version),sn("ICE servers after filtering:",e.iceServers)),new n(e)},e.RTCPeerConnection.prototype=n.prototype}function Ln(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}var Mn=Object.freeze({__proto__:null,shimPeerConnection:Dn,shimReplaceTrack:Ln,shimGetUserMedia:An,shimGetDisplayMedia:Pn});function Nn(e,t){const n=e&&e.navigator,r=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,r){cn("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){const e=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},t=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(n){return"object"==typeof n&&"object"==typeof n.audio&&(n=JSON.parse(JSON.stringify(n)),e(n.audio,"autoGainControl","mozAutoGainControl"),e(n.audio,"noiseSuppression","mozNoiseSuppression")),t(n)},r&&r.prototype.getSettings){const t=r.prototype.getSettings;r.prototype.getSettings=function(){const n=t.apply(this,arguments);return e(n,"mozAutoGainControl","autoGainControl"),e(n,"mozNoiseSuppression","noiseSuppression"),n}}if(r&&r.prototype.applyConstraints){const t=r.prototype.applyConstraints;r.prototype.applyConstraints=function(n){return"audio"===this.kind&&"object"==typeof n&&(n=JSON.parse(JSON.stringify(n)),e(n,"autoGainControl","mozAutoGainControl"),e(n,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[n])}}}}function On(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Un(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}));const n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,o]=arguments;return r.apply(this,[e||null]).then((e=>{if(t.version<53&&!i)try{e.forEach((e=>{e.type=n[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach(((t,r)=>{e.set(r,Object.assign({},t,{type:n[t.type]||t.type}))}))}return e})).then(i,o)}}function Vn(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function Fn(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),rn(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function jn(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){cn("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function Bn(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function Hn(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],n=e&&"sendEncodings"in e;n&&e.sendEncodings.forEach((e=>{if("rid"in e&&!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));const r=t.apply(this,arguments);if(n){const{sender:t}=r,n=t.getParameters();(!("encodings"in n)||1===n.encodings.length&&0===Object.keys(n.encodings[0]).length)&&(n.encodings=e.sendEncodings,t.sendEncodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(n).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return r})}function zn(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function Gn(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function Wn(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}var Jn=Object.freeze({__proto__:null,shimOnTrack:On,shimPeerConnection:Un,shimSenderGetStats:Vn,shimReceiverGetStats:Fn,shimRemoveStream:jn,shimRTCDataChannel:Bn,shimAddTransceiver:Hn,shimGetParameters:zn,shimCreateOffer:Gn,shimCreateAnswer:Wn,shimGetUserMedia:Nn,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===n.video?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})}});function qn(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((n=>t.call(this,n,e))),e.getVideoTracks().forEach((n=>t.call(this,n,e)))},e.RTCPeerConnection.prototype.addTrack=function(e,...n){return n&&n.forEach((e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const n=e.getTracks();this.getSenders().forEach((e=>{n.includes(e.track)&&this.removeTrack(e)}))})}}function Kn(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach((e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)}))})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}))}),t.apply(e,arguments)}}}function Qn(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};let s=function(e,t,n){const r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=s,s=function(e,t,n){const r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=s,s=function(e,t,n){const r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=s}function Xn(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,n=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>n($n(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t))}function $n(e){return e&&void 0!==e.video?Object.assign({},e,{video:ln(e.video)}):e}function Yn(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){const t=[];for(let n=0;n<e.iceServers.length;n++){let r=e.iceServers[n];!r.hasOwnProperty("urls")&&r.hasOwnProperty("url")?(cn("RTCIceServer.url","RTCIceServer.urls"),r=JSON.parse(JSON.stringify(r)),r.urls=r.url,delete r.url,t.push(r)):t.push(e.iceServers[n])}e.iceServers=t}return new t(e,n)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function Zn(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function er(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find((e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const n=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&n?"sendrecv"===n.direction?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":"recvonly"===n.direction&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):!0!==e.offerToReceiveVideo||n||this.addTransceiver("video")}return t.apply(this,arguments)}}function tr(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var nr=Object.freeze({__proto__:null,shimLocalStreamsAPI:qn,shimRemoteStreamsAPI:Kn,shimCallbacksAPI:Qn,shimGetUserMedia:Xn,shimConstraints:$n,shimRTCIceServerUrls:Yn,shimTrackEventTransceiver:Zn,shimCreateOfferLegacy:er,shimAudioContext:tr});function rr(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const n=new t(e),r=Tn.parseCandidate(e.candidate),i=Object.assign(n,r);return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,rn(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function ir(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const n=function(e){if(!e||!e.sdp)return!1;const t=Tn.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=Tn.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))},r=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const n=parseInt(t[1],10);return n!=n?-1:n},i=function(e){let n=65536;return"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),n},o=function(e,n){let r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);const i=Tn.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?r=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==n&&(r=2147483637),r},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(n(arguments[0])){const e=r(arguments[0]),t=i(e),n=o(arguments[0],e);let a;a=0===t&&0===n?Number.POSITIVE_INFINITY:0===t||0===n?Math.max(t,n):Math.min(t,n);const s={};Object.defineProperty(s,"maxMessageSize",{get:()=>a}),this._sctp=s}return a.apply(this,arguments)}}function or(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const n=e.send;e.send=function(){const r=arguments[0],i=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return n.apply(e,arguments)}}const n=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=n.apply(this,arguments);return t(e,this),e},rn(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function ar(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((e=>{const n=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const n=new Event("connectionstatechange",e);t.dispatchEvent(n)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}}))}function sr(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const n=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==e.trim())).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:n}):t.sdp=n}return n.apply(this,arguments)}}function cr(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const n=e.RTCPeerConnection.prototype.addIceCandidate;n&&0!==n.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var ur=Object.freeze({__proto__:null,shimRTCIceCandidate:rr,shimMaxMessageSize:ir,shimSendThrowTypeError:or,shimConnectionState:ar,removeExtmapAllowMixed:sr,shimAddIceCandidateNullOrEmpty:cr});!function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const n=sn,r=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;const{navigator:n}=e;if(n.mozGetUserMedia)t.browser="firefox",t.version=nn(n.userAgent,/Firefox\/(\d+)\./,1);else if(n.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=nn(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(n.mediaDevices&&n.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=nn(n.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!n.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=nn(n.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),i={browserDetails:r,commonShim:ur,extractVersion:nn,disableLog:on,disableWarnings:an};switch(r.browser){case"chrome":if(!In||!bn||!t.shimChrome)return n("Chrome shim is not included in this adapter release."),i;if(null===r.version)return n("Chrome shim can not determine version, not shimming."),i;n("adapter.js shimming chrome."),i.browserShim=In,cr(e,r),pn(e,r),fn(e),bn(e,r),mn(e),Sn(e,r),vn(e),_n(e),gn(e),kn(e,r),rr(e),ar(e),ir(e,r),or(e),sr(e,r);break;case"firefox":if(!Jn||!Un||!t.shimFirefox)return n("Firefox shim is not included in this adapter release."),i;n("adapter.js shimming firefox."),i.browserShim=Jn,cr(e,r),Nn(e,r),Un(e,r),On(e),jn(e),Vn(e),Fn(e),Bn(e),Hn(e),zn(e),Gn(e),Wn(e),rr(e),ar(e),ir(e,r),or(e);break;case"edge":if(!Mn||!Dn||!t.shimEdge)return n("MS edge shim is not included in this adapter release."),i;n("adapter.js shimming edge."),i.browserShim=Mn,An(e),Pn(e),Dn(e,r),Ln(e),ir(e,r),or(e);break;case"safari":if(!nr||!t.shimSafari)return n("Safari shim is not included in this adapter release."),i;n("adapter.js shimming safari."),i.browserShim=nr,cr(e,r),Yn(e),er(e),Qn(e),qn(e),Kn(e),Zn(e),Xn(e),tr(e),rr(e),ir(e,r),or(e),sr(e,r);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});var lr=[].slice,dr=/MSIE .\./.test(q),hr=function(e){return function(t,n){var r=arguments.length>2,i=r?lr.call(arguments,2):void 0;return e(r?function(){(z(t)?t:Function(t)).apply(this,i)}:t,n)}};Rt({global:!0,bind:!0,forced:dr},{setTimeout:hr(A.setTimeout),setInterval:hr(A.setInterval)});var pr,fr=Object.keys||function(e){return dt(e,ht)},mr=D?Object.defineProperties:function(e,t){Ee(e);for(var n,r=fr(t),i=r.length,o=0;i>o;)xe.f(e,n=r[o++],t[n]);return e},vr=J("document","documentElement"),_r=Fe("IE_PROTO"),gr=function(){},yr=function(e){return"<script>"+e+"<\/script>"},Sr=function(e){e.write(yr("")),e.close();var t=e.parentWindow.Object;return e=null,t},br=function(){try{pr=new ActiveXObject("htmlfile")}catch(e){}var e,t;br="undefined"!=typeof document?document.domain&&pr?Sr(pr):((t=Ie("iframe")).style.display="none",vr.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(yr("document.F=Object")),e.close(),e.F):Sr(pr);for(var n=ht.length;n--;)delete br.prototype[ht[n]];return br()};je[_r]=!0;var kr=Object.create||function(e,t){var n;return null!==e?(gr.prototype=Ee(e),n=new gr,gr.prototype=null,n[_r]=e):n=br(),void 0===t?n:mr(n,t)},Ir=_e("unscopables"),Tr=Array.prototype;null==Tr[Ir]&&xe.f(Tr,Ir,{configurable:!0,value:kr(null)});var wr,Rr,Er,Cr=function(e){Tr[Ir][e]=!0},xr={},Ar=!P((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Pr=Fe("IE_PROTO"),Dr=Object.prototype,Lr=Ar?Object.getPrototypeOf:function(e){var t=ce(e);if(le(t,Pr))return t[Pr];var n=t.constructor;return z(n)&&t instanceof n?n.prototype:t instanceof Object?Dr:null},Mr=_e("iterator"),Nr=!1;[].keys&&("next"in(Er=[].keys())?(Rr=Lr(Lr(Er)))!==Object.prototype&&(wr=Rr):Nr=!0),(null==wr||P((function(){var e={};return wr[Mr].call(e)!==e})))&&(wr={}),z(wr[Mr])||Ye(wr,Mr,(function(){return this}));var Or={IteratorPrototype:wr,BUGGY_SAFARI_ITERATORS:Nr},Ur=xe.f,Vr=_e("toStringTag"),Fr=function(e,t,n){e&&!le(e=n?e:e.prototype,Vr)&&Ur(e,Vr,{configurable:!0,value:t})},jr=Or.IteratorPrototype,Br=function(){return this},Hr=function(e,t,n){var r=t+" Iterator";return e.prototype=kr(jr,{next:O(1,n)}),Fr(e,r,!1),xr[r]=Br,e},zr=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(n,[]),t=n instanceof Array}catch(e){}return function(n,r){return Ee(n),function(e){if("object"==typeof e||z(e))return e;throw TypeError("Can't set "+String(e)+" as a prototype")}(r),t?e.call(n,r):n.__proto__=r,n}}():void 0),Gr=$e.PROPER,Wr=$e.CONFIGURABLE,Jr=Or.IteratorPrototype,qr=Or.BUGGY_SAFARI_ITERATORS,Kr=_e("iterator"),Qr=function(){return this},Xr=function(e,t,n,r,i,o,a){Hr(n,t,r);var s,c,u,l=function(e){if(e===i&&m)return m;if(!qr&&e in p)return p[e];switch(e){case"keys":case"values":case"entries":return function(){return new n(this,e)}}return function(){return new n(this)}},d=t+" Iterator",h=!1,p=e.prototype,f=p[Kr]||p["@@iterator"]||i&&p[i],m=!qr&&f||l(i),v="Array"==t&&p.entries||f;if(v&&(s=Lr(v.call(new e)))!==Object.prototype&&s.next&&(Lr(s)!==Jr&&(zr?zr(s,Jr):z(s[Kr])||Ye(s,Kr,Qr)),Fr(s,d,!0)),Gr&&"values"==i&&f&&"values"!==f.name&&(Wr?Ae(p,"name","values"):(h=!0,m=function(){return f.call(this)})),i)if(c={values:l("values"),keys:o?m:l("keys"),entries:l("entries")},a)for(u in c)(qr||h||!(u in p))&&Ye(p,u,c[u]);else Rt({target:t,proto:!0,forced:qr||h},c);return p[Kr]!==m&&Ye(p,Kr,m,{name:i}),xr[t]=m,c},$r=qe.set,Yr=qe.getterFor("Array Iterator"),Zr=Xr(Array,"Array",(function(e,t){$r(this,{type:"Array Iterator",target:H(e),index:0,kind:t})}),(function(){var e=Yr(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:t[r],done:!1}:{value:[r,t[r]],done:!1}}),"values");xr.Arguments=xr.Array,Cr("keys"),Cr("values"),Cr("entries");var ei=ft.f,ti={}.toString,ni="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],ri={f:function(e){return ni&&"[object Window]"==ti.call(e)?function(e){try{return ei(e)}catch(e){return ni.slice()}}(e):ei(H(e))}},ii=!P((function(){return Object.isExtensible(Object.preventExtensions({}))})),oi=R((function(e){var t=xe.f,n=!1,r=pe("meta"),i=0,o=Object.isExtensible||function(){return!0},a=function(e){t(e,r,{value:{objectID:"O"+i++,weakData:{}}})},s=e.exports={enable:function(){s.enable=function(){},n=!0;var e=ft.f,t=[].splice,i={};i[r]=1,e(i).length&&(ft.f=function(n){for(var i=e(n),o=0,a=i.length;o<a;o++)if(i[o]===r){t.call(i,o,1);break}return i},Rt({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:ri.f}))},fastKey:function(e,t){if(!G(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!le(e,r)){if(!o(e))return"F";if(!t)return"E";a(e)}return e[r].objectID},getWeakData:function(e,t){if(!le(e,r)){if(!o(e))return!0;if(!t)return!1;a(e)}return e[r].weakData},onFreeze:function(e){return ii&&n&&o(e)&&!le(e,r)&&a(e),e}};je[r]=!0})),ai=(oi.enable,oi.fastKey,oi.getWeakData,oi.onFreeze,_e("iterator")),si=Array.prototype,ci=function(e){return void 0!==e&&(xr.Array===e||si[ai]===e)},ui=_e("iterator"),li=function(e){if(null!=e)return ie(e,ui)||ie(e,"@@iterator")||xr[Lt(e)]},di=function(e,t){var n=arguments.length<2?li(e):t;if(re(n))return Ee(n.call(e));throw TypeError(String(e)+" is not iterable")},hi=function(e,t,n){var r,i;Ee(e);try{if(!(r=ie(e,"return"))){if("throw"===t)throw n;return n}r=r.call(e)}catch(e){i=!0,r=e}if("throw"===t)throw n;if(i)throw r;return Ee(r),n},pi=function(e,t){this.stopped=e,this.result=t},fi=function(e,t,n){var r,i,o,a,s,c,u,l=n&&n.that,d=!(!n||!n.AS_ENTRIES),h=!(!n||!n.IS_ITERATOR),p=!(!n||!n.INTERRUPTED),f=Et(t,l,1+d+p),m=function(e){return r&&hi(r,"normal",e),new pi(!0,e)},v=function(e){return d?(Ee(e),p?f(e[0],e[1],m):f(e[0],e[1])):p?f(e,m):f(e)};if(h)r=e;else{if(!(i=li(e)))throw TypeError(String(e)+" is not iterable");if(ci(i)){for(o=0,a=st(e);a>o;o++)if((s=v(e[o]))&&s instanceof pi)return s;return new pi(!1)}r=di(e,i)}for(c=r.next;!(u=c.call(r)).done;){try{s=v(u.value)}catch(e){hi(r,"throw",e)}if("object"==typeof s&&s&&s instanceof pi)return s}return new pi(!1)},mi=function(e,t,n){if(e instanceof t)return e;throw TypeError("Incorrect "+(n?n+" ":"")+"invocation")},vi=_e("iterator"),_i=!1;try{var gi=0,yi={next:function(){return{done:!!gi++}},return:function(){_i=!0}};yi[vi]=function(){return this},Array.from(yi,(function(){throw 2}))}catch(e){}var Si=function(e,t){if(!t&&!_i)return!1;var n=!1;try{var r={};r[vi]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(e){}return n},bi=function(e,t,n){var r,i;return zr&&z(r=t.constructor)&&r!==n&&G(i=r.prototype)&&i!==n.prototype&&zr(e,i),e},ki=function(e,t,n){var r=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),o=r?"set":"add",a=A[e],s=a&&a.prototype,c=a,u={},l=function(e){var t=s[e];Ye(s,e,"add"==e?function(e){return t.call(this,0===e?0:e),this}:"delete"==e?function(e){return!(i&&!G(e))&&t.call(this,0===e?0:e)}:"get"==e?function(e){return i&&!G(e)?void 0:t.call(this,0===e?0:e)}:"has"==e?function(e){return!(i&&!G(e))&&t.call(this,0===e?0:e)}:function(e,n){return t.call(this,0===e?0:e,n),this})};if(Tt(e,!z(a)||!(i||s.forEach&&!P((function(){(new a).entries().next()})))))c=n.getConstructor(t,e,r,o),oi.enable();else if(Tt(e,!0)){var d=new c,h=d[o](i?{}:-0,1)!=d,p=P((function(){d.has(1)})),f=Si((function(e){new a(e)})),m=!i&&P((function(){for(var e=new a,t=5;t--;)e[o](t,t);return!e.has(-0)}));f||((c=t((function(t,n){mi(t,c,e);var i=bi(new a,t,c);return null!=n&&fi(n,i[o],{that:i,AS_ENTRIES:r}),i}))).prototype=s,s.constructor=c),(p||m)&&(l("delete"),l("has"),r&&l("get")),(m||h)&&l(o),i&&s.clear&&delete s.clear}return u[e]=c,Rt({global:!0,forced:c!=a},u),Fr(c,e),i||n.setStrong(c,e,r),c},Ii=function(e,t,n){for(var r in t)Ye(e,r,t[r],n);return e},Ti=_e("species"),wi=function(e){var t=J(e),n=xe.f;D&&t&&!t[Ti]&&n(t,Ti,{configurable:!0,get:function(){return this}})},Ri=xe.f,Ei=oi.fastKey,Ci=qe.set,xi=qe.getterFor,Ai={getConstructor:function(e,t,n,r){var i=e((function(e,o){mi(e,i,t),Ci(e,{type:t,index:kr(null),first:void 0,last:void 0,size:0}),D||(e.size=0),null!=o&&fi(o,e[r],{that:e,AS_ENTRIES:n})})),o=xi(t),a=function(e,t,n){var r,i,a=o(e),c=s(e,t);return c?c.value=n:(a.last=c={index:i=Ei(t,!0),key:t,value:n,previous:r=a.last,next:void 0,removed:!1},a.first||(a.first=c),r&&(r.next=c),D?a.size++:e.size++,"F"!==i&&(a.index[i]=c)),e},s=function(e,t){var n,r=o(e),i=Ei(t);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key==t)return n};return Ii(i.prototype,{clear:function(){for(var e=o(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete t[n.index],n=n.next;e.first=e.last=void 0,D?e.size=0:this.size=0},delete:function(e){var t=o(this),n=s(this,e);if(n){var r=n.next,i=n.previous;delete t.index[n.index],n.removed=!0,i&&(i.next=r),r&&(r.previous=i),t.first==n&&(t.first=r),t.last==n&&(t.last=i),D?t.size--:this.size--}return!!n},forEach:function(e){for(var t,n=o(this),r=Et(e,arguments.length>1?arguments[1]:void 0,3);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!s(this,e)}}),Ii(i.prototype,n?{get:function(e){var t=s(this,e);return t&&t.value},set:function(e,t){return a(this,0===e?0:e,t)}}:{add:function(e){return a(this,e=0===e?0:e,e)}}),D&&Ri(i.prototype,"size",{get:function(){return o(this).size}}),i},setStrong:function(e,t,n){var r=t+" Iterator",i=xi(t),o=xi(r);Xr(e,t,(function(e,t){Ci(this,{type:r,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=o(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?"keys"==t?{value:n.key,done:!1}:"values"==t?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(e.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),wi(t)}},Pi=(ki("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Ai),At?{}.toString:function(){return"[object "+Lt(this)+"]"});At||Ye(Object.prototype,"toString",Pi,{unsafe:!0});var Di=function(e){if("Symbol"===Lt(e))throw TypeError("Cannot convert a Symbol value to a string");return String(e)},Li=function(e){return function(t,n){var r,i,o=Di(B(t)),a=tt(n),s=o.length;return a<0||a>=s?e?"":void 0:(r=o.charCodeAt(a))<55296||r>56319||a+1===s||(i=o.charCodeAt(a+1))<56320||i>57343?e?o.charAt(a):r:e?o.slice(a,a+2):i-56320+(r-55296<<10)+65536}},Mi={codeAt:Li(!1),charAt:Li(!0)},Ni=Mi.charAt,Oi=qe.set,Ui=qe.getterFor("String Iterator");Xr(String,"String",(function(e){Oi(this,{type:"String Iterator",string:Di(e),index:0})}),(function(){var e,t=Ui(this),n=t.string,r=t.index;return r>=n.length?{value:void 0,done:!0}:(e=Ni(n,r),t.index+=e.length,{value:e,done:!1})}));var Vi={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Fi=Ie("span").classList,ji=Fi&&Fi.constructor&&Fi.constructor.prototype,Bi=ji===Object.prototype?void 0:ji,Hi=_e("iterator"),zi=_e("toStringTag"),Gi=Zr.values,Wi=function(e,t){if(e){if(e[Hi]!==Gi)try{Ae(e,Hi,Gi)}catch(t){e[Hi]=Gi}if(e[zi]||Ae(e,zi,t),Vi[t])for(var n in Zr)if(e[n]!==Zr[n])try{Ae(e,n,Zr[n])}catch(t){e[n]=Zr[n]}}};for(var Ji in Vi)Wi(A[Ji]&&A[Ji].prototype,Ji);Wi(Bi,"DOMTokenList");var qi=function(e,t,n){var r=Se(t);r in e?xe.f(e,r,O(0,n)):e[r]=n},Ki=qt("splice"),Qi=Math.max,Xi=Math.min;Rt({target:"Array",proto:!0,forced:!Ki},{splice:function(e,t){var n,r,i,o,a,s,c=ce(this),u=st(c),l=it(e,u),d=arguments.length;if(0===d?n=r=0:1===d?(n=0,r=u-l):(n=d-2,r=Xi(Qi(tt(t),0),u-l)),u+n-r>9007199254740991)throw TypeError("Maximum allowed length exceeded");for(i=Ht(c,r),o=0;o<r;o++)(a=l+o)in c&&qi(i,o,c[a]);if(i.length=r,n<r){for(o=l;o<u-r;o++)s=o+n,(a=o+r)in c?c[s]=c[a]:delete c[s];for(o=u;o>u-r+n;o--)delete c[o-1]}else if(n>r)for(o=u-r;o>l;o--)s=o+n-1,(a=o+r-1)in c?c[s]=c[a]:delete c[s];for(o=0;o<n;o++)c[o+l]=arguments[o+2];return c.length=u-r+n,i}});var $i=function(e,t){var n=[][e];return!!n&&P((function(){n.call(null,t||function(){throw 1},1)}))},Yi=Wt.forEach,Zi=$i("forEach")?[].forEach:function(e){return Yi(this,e,arguments.length>1?arguments[1]:void 0)};Rt({target:"Array",proto:!0,forced:[].forEach!=Zi},{forEach:Zi});var eo=function(e){if(e&&e.forEach!==Zi)try{Ae(e,"forEach",Zi)}catch(t){e.forEach=Zi}};for(var to in Vi)Vi[to]&&eo(A[to]&&A[to].prototype);eo(Bi);var no=[].join,ro=j!=Object,io=$i("join",",");Rt({target:"Array",proto:!0,forced:ro||!io},{join:function(e){return no.call(H(this),void 0===e?",":e)}});var oo=_e("isConcatSpreadable"),ao=Y>=51||!P((function(){var e=[];return e[oo]=!1,e.concat()[0]!==e})),so=qt("concat"),co=function(e){if(!G(e))return!1;var t=e[oo];return void 0!==t?!!t:Ct(e)};Rt({target:"Array",proto:!0,forced:!ao||!so},{concat:function(e){var t,n,r,i,o,a=ce(this),s=Ht(a,0),c=0;for(t=-1,r=arguments.length;t<r;t++)if(co(o=-1===t?a:arguments[t])){if(c+(i=st(o))>9007199254740991)throw TypeError("Maximum allowed index exceeded");for(n=0;n<i;n++,c++)n in o&&qi(s,c,o[n])}else{if(c>=9007199254740991)throw TypeError("Maximum allowed index exceeded");qi(s,c++,o)}return s.length=c,s}});var uo=Date.prototype,lo=uo.toString,ho=uo.getTime;"Invalid Date"!=String(new Date(NaN))&&Ye(uo,"toString",(function(){var e=ho.call(this);return e==e?lo.call(this):"Invalid Date"}));var po=function(){var e=Ee(this),t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t},fo=A.RegExp,mo={UNSUPPORTED_Y:P((function(){var e=fo("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),BROKEN_CARET:P((function(){var e=fo("^r","gy");return e.lastIndex=2,null!=e.exec("str")}))},vo=A.RegExp,_o=P((function(){var e=vo(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),go=A.RegExp,yo=P((function(){var e=go("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),So=qe.get,bo=RegExp.prototype.exec,ko=se("native-string-replace",String.prototype.replace),Io=bo,To=function(){var e=/a/,t=/b*/g;return bo.call(e,"a"),bo.call(t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),wo=mo.UNSUPPORTED_Y||mo.BROKEN_CARET,Ro=void 0!==/()??/.exec("")[1];(To||Ro||wo||_o||yo)&&(Io=function(e){var t,n,r,i,o,a,s,c=this,u=So(c),l=Di(e),d=u.raw;if(d)return d.lastIndex=c.lastIndex,t=Io.call(d,l),c.lastIndex=d.lastIndex,t;var h=u.groups,p=wo&&c.sticky,f=po.call(c),m=c.source,v=0,_=l;if(p&&(-1===(f=f.replace("y","")).indexOf("g")&&(f+="g"),_=l.slice(c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==l.charAt(c.lastIndex-1))&&(m="(?: "+m+")",_=" "+_,v++),n=new RegExp("^(?:"+m+")",f)),Ro&&(n=new RegExp("^"+m+"$(?!\\s)",f)),To&&(r=c.lastIndex),i=bo.call(p?n:c,_),p?i?(i.input=i.input.slice(v),i[0]=i[0].slice(v),i.index=c.lastIndex,c.lastIndex+=i[0].length):c.lastIndex=0:To&&i&&(c.lastIndex=c.global?i.index+i[0].length:r),Ro&&i&&i.length>1&&ko.call(i[0],n,(function(){for(o=1;o<arguments.length-2;o++)void 0===arguments[o]&&(i[o]=void 0)})),i&&h)for(i.groups=a=kr(null),o=0;o<h.length;o++)a[(s=h[o])[0]]=i[s[1]];return i});var Eo=Io;Rt({target:"RegExp",proto:!0,forced:/./.exec!==Eo},{exec:Eo});var Co=_e("species"),xo=RegExp.prototype,Ao=function(e,t,n,r){var i=_e(e),o=!P((function(){var t={};return t[i]=function(){return 7},7!=""[e](t)})),a=o&&!P((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[Co]=function(){return n},n.flags="",n[i]=/./[i]),n.exec=function(){return t=!0,null},n[i](""),!t}));if(!o||!a||n){var s=/./[i],c=t(i,""[e],(function(e,t,n,r,i){var a=t.exec;return a===Eo||a===xo.exec?o&&!i?{done:!0,value:s.call(t,n,r)}:{done:!0,value:e.call(n,t,r)}:{done:!1}}));Ye(String.prototype,e,c[0]),Ye(xo,i,c[1])}r&&Ae(xo[i],"sham",!0)},Po=Mi.charAt,Do=function(e,t,n){return t+(n?Po(e,t).length:1)},Lo=Math.floor,Mo="".replace,No=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,Oo=/\$([$&'`]|\d{1,2})/g,Uo=function(e,t,n,r,i,o){var a=n+e.length,s=r.length,c=Oo;return void 0!==i&&(i=ce(i),c=No),Mo.call(o,c,(function(o,c){var u;switch(c.charAt(0)){case"$":return"$";case"&":return e;case"`":return t.slice(0,n);case"'":return t.slice(a);case"<":u=i[c.slice(1,-1)];break;default:var l=+c;if(0===l)return o;if(l>s){var d=Lo(l/10);return 0===d?o:d<=s?void 0===r[d-1]?c.charAt(1):r[d-1]+c.charAt(1):o}u=r[l-1]}return void 0===u?"":u}))},Vo=function(e,t){var n=e.exec;if(z(n)){var r=n.call(e,t);return null!==r&&Ee(r),r}if("RegExp"===V(e))return Eo.call(e,t);throw TypeError("RegExp#exec called on incompatible receiver")},Fo=_e("replace"),jo=Math.max,Bo=Math.min,Ho="$0"==="a".replace(/./,"$0"),zo=!!/./[Fo]&&""===/./[Fo]("a","$0");Ao("replace",(function(e,t,n){var r=zo?"$":"$0";return[function(e,n){var r=B(this),i=null==e?void 0:ie(e,Fo);return i?i.call(e,r,n):t.call(Di(r),e,n)},function(e,i){var o=Ee(this),a=Di(e);if("string"==typeof i&&-1===i.indexOf(r)&&-1===i.indexOf("$<")){var s=n(t,o,a,i);if(s.done)return s.value}var c=z(i);c||(i=Di(i));var u=o.global;if(u){var l=o.unicode;o.lastIndex=0}for(var d=[];;){var h=Vo(o,a);if(null===h)break;if(d.push(h),!u)break;""===Di(h[0])&&(o.lastIndex=Do(a,at(o.lastIndex),l))}for(var p,f="",m=0,v=0;v<d.length;v++){h=d[v];for(var _=Di(h[0]),g=jo(Bo(tt(h.index),a.length),0),y=[],S=1;S<h.length;S++)y.push(void 0===(p=h[S])?p:String(p));var b=h.groups;if(c){var k=[_].concat(y,g,a);void 0!==b&&k.push(b);var I=Di(i.apply(void 0,k))}else I=Uo(_,a,g,y,b,i);g>=m&&(f+=a.slice(m,g)+I,m=g+_.length)}return f+a.slice(m)}]}),!!P((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}))||!Ho||zo);var Go=_e("iterator"),Wo=!P((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),n+=r+e})),!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[Go]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host})),Jo=J("fetch"),qo=J("Request"),Ko=qo&&qo.prototype,Qo=J("Headers"),Xo=_e("iterator"),$o=qe.set,Yo=qe.getterFor("URLSearchParams"),Zo=qe.getterFor("URLSearchParamsIterator"),ea=/\+/g,ta=Array(4),na=function(e){return ta[e-1]||(ta[e-1]=RegExp("((?:%[\\da-f]{2}){"+e+"})","gi"))},ra=function(e){try{return decodeURIComponent(e)}catch(t){return e}},ia=function(e){var t=e.replace(ea," "),n=4;try{return decodeURIComponent(t)}catch(e){for(;n;)t=t.replace(na(n--),ra);return t}},oa=/[!'()~]|%20/g,aa={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},sa=function(e){return aa[e]},ca=function(e){return encodeURIComponent(e).replace(oa,sa)},ua=function(e,t){if(t)for(var n,r,i=t.split("&"),o=0;o<i.length;)(n=i[o++]).length&&(r=n.split("="),e.push({key:ia(r.shift()),value:ia(r.join("="))}))},la=function(e){this.entries.length=0,ua(this.entries,e)},da=function(e,t){if(e<t)throw TypeError("Not enough arguments")},ha=Hr((function(e,t){$o(this,{type:"URLSearchParamsIterator",iterator:di(Yo(e).entries),kind:t})}),"Iterator",(function(){var e=Zo(this),t=e.kind,n=e.iterator.next(),r=n.value;return n.done||(n.value="keys"===t?r.key:"values"===t?r.value:[r.key,r.value]),n})),pa=function(){mi(this,pa,"URLSearchParams");var e,t,n,r,i,o,a,s,c,u=arguments.length>0?arguments[0]:void 0,l=[];if($o(this,{type:"URLSearchParams",entries:l,updateURL:function(){},updateSearchParams:la}),void 0!==u)if(G(u))if(e=li(u))for(n=(t=di(u,e)).next;!(r=n.call(t)).done;){if((a=(o=(i=di(Ee(r.value))).next).call(i)).done||(s=o.call(i)).done||!o.call(i).done)throw TypeError("Expected sequence with length 2");l.push({key:Di(a.value),value:Di(s.value)})}else for(c in u)le(u,c)&&l.push({key:c,value:Di(u[c])});else ua(l,"string"==typeof u?"?"===u.charAt(0)?u.slice(1):u:Di(u))},fa=pa.prototype;if(Ii(fa,{append:function(e,t){da(arguments.length,2);var n=Yo(this);n.entries.push({key:Di(e),value:Di(t)}),n.updateURL()},delete:function(e){da(arguments.length,1);for(var t=Yo(this),n=t.entries,r=Di(e),i=0;i<n.length;)n[i].key===r?n.splice(i,1):i++;t.updateURL()},get:function(e){da(arguments.length,1);for(var t=Yo(this).entries,n=Di(e),r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){da(arguments.length,1);for(var t=Yo(this).entries,n=Di(e),r=[],i=0;i<t.length;i++)t[i].key===n&&r.push(t[i].value);return r},has:function(e){da(arguments.length,1);for(var t=Yo(this).entries,n=Di(e),r=0;r<t.length;)if(t[r++].key===n)return!0;return!1},set:function(e,t){da(arguments.length,1);for(var n,r=Yo(this),i=r.entries,o=!1,a=Di(e),s=Di(t),c=0;c<i.length;c++)(n=i[c]).key===a&&(o?i.splice(c--,1):(o=!0,n.value=s));o||i.push({key:a,value:s}),r.updateURL()},sort:function(){var e,t,n,r=Yo(this),i=r.entries,o=i.slice();for(i.length=0,n=0;n<o.length;n++){for(e=o[n],t=0;t<n;t++)if(i[t].key>e.key){i.splice(t,0,e);break}t===n&&i.push(e)}r.updateURL()},forEach:function(e){for(var t,n=Yo(this).entries,r=Et(e,arguments.length>1?arguments[1]:void 0,3),i=0;i<n.length;)r((t=n[i++]).value,t.key,this)},keys:function(){return new ha(this,"keys")},values:function(){return new ha(this,"values")},entries:function(){return new ha(this,"entries")}},{enumerable:!0}),Ye(fa,Xo,fa.entries,{name:"entries"}),Ye(fa,"toString",(function(){for(var e,t=Yo(this).entries,n=[],r=0;r<t.length;)e=t[r++],n.push(ca(e.key)+"="+ca(e.value));return n.join("&")}),{enumerable:!0}),Fr(pa,"URLSearchParams"),Rt({global:!0,forced:!Wo},{URLSearchParams:pa}),!Wo&&z(Qo)){var ma=function(e){if(G(e)){var t,n=e.body;if("URLSearchParams"===Lt(n))return(t=e.headers?new Qo(e.headers):new Qo).has("content-type")||t.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),kr(e,{body:O(0,String(n)),headers:O(0,t)})}return e};if(z(Jo)&&Rt({global:!0,enumerable:!0,forced:!0},{fetch:function(e){return Jo(e,arguments.length>1?ma(arguments[1]):{})}}),z(qo)){var va=function(e){return mi(this,va,"Request"),new qo(e,arguments.length>1?ma(arguments[1]):{})};Ko.constructor=va,va.prototype=Ko,Rt({global:!0,forced:!0},{Request:va})}}var _a={URLSearchParams:pa,getState:Yo},ga=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t};Ao("search",(function(e,t,n){return[function(t){var n=B(this),r=null==t?void 0:ie(t,e);return r?r.call(t,n):new RegExp(t)[e](Di(n))},function(e){var r=Ee(this),i=Di(e),o=n(t,r,i);if(o.done)return o.value;var a=r.lastIndex;ga(a,0)||(r.lastIndex=0);var s=Vo(r,i);return ga(r.lastIndex,a)||(r.lastIndex=a),null===s?-1:s.index}]})),(new Date).getTime();var ya=0,Sa=function(){return(new Date).getTime()+ya},ba=function(){var e=new Date;return e.setTime(Sa()),e.toLocaleString()};Ao("match",(function(e,t,n){return[function(t){var n=B(this),r=null==t?void 0:ie(t,e);return r?r.call(t,n):new RegExp(t)[e](Di(n))},function(e){var r=Ee(this),i=Di(e),o=n(t,r,i);if(o.done)return o.value;if(!r.global)return Vo(r,i);var a=r.unicode;r.lastIndex=0;for(var s,c=[],u=0;null!==(s=Vo(r,i));){var l=Di(s[0]);c[u]=l,""===l&&(r.lastIndex=Do(i,at(r.lastIndex),a)),u++}return 0===u?null:c}]}));var ka=_e("match"),Ia=function(e){var t;return G(e)&&(void 0!==(t=e[ka])?!!t:"RegExp"==V(e))},Ta=xe.f,wa=ft.f,Ra=qe.enforce,Ea=_e("match"),Ca=A.RegExp,xa=Ca.prototype,Aa=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Pa=/a/g,Da=/a/g,La=new Ca(Pa)!==Pa,Ma=mo.UNSUPPORTED_Y,Na=D&&(!La||Ma||_o||yo||P((function(){return Da[Ea]=!1,Ca(Pa)!=Pa||Ca(Da)==Da||"/a/i"!=Ca(Pa,"i")})));if(Tt("RegExp",Na)){for(var Oa=function(e,t){var n,r,i,o,a,s,c=this instanceof Oa,u=Ia(e),l=void 0===t,d=[],h=e;if(!c&&u&&l&&e.constructor===Oa)return e;if((u||e instanceof Oa)&&(e=e.source,l&&(t="flags"in h?h.flags:po.call(h))),e=void 0===e?"":Di(e),t=void 0===t?"":Di(t),h=e,_o&&"dotAll"in Pa&&(r=!!t&&t.indexOf("s")>-1)&&(t=t.replace(/s/g,"")),n=t,Ma&&"sticky"in Pa&&(i=!!t&&t.indexOf("y")>-1)&&(t=t.replace(/y/g,"")),yo&&(e=(o=function(e){for(var t,n=e.length,r=0,i="",o=[],a={},s=!1,c=!1,u=0,l="";r<=n;r++){if("\\"===(t=e.charAt(r)))t+=e.charAt(++r);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:Aa.test(e.slice(r+1))&&(r+=2,c=!0),i+=t,u++;continue;case">"===t&&c:if(""===l||le(a,l))throw new SyntaxError("Invalid capture group name");a[l]=!0,o.push([l,u]),c=!1,l="";continue}c?l+=t:i+=t}return[i,o]}(e))[0],d=o[1]),a=bi(Ca(e,t),c?this:xa,Oa),(r||i||d.length)&&(s=Ra(a),r&&(s.dotAll=!0,s.raw=Oa(function(e){for(var t,n=e.length,r=0,i="",o=!1;r<=n;r++)"\\"!==(t=e.charAt(r))?o||"."!==t?("["===t?o=!0:"]"===t&&(o=!1),i+=t):i+="[\\s\\S]":i+=t+e.charAt(++r);return i}(e),n)),i&&(s.sticky=!0),d.length&&(s.groups=d)),e!==h)try{Ae(a,"source",""===h?"(?:)":h)}catch(e){}return a},Ua=function(e){e in Oa||Ta(Oa,e,{configurable:!0,get:function(){return Ca[e]},set:function(t){Ca[e]=t}})},Va=wa(Ca),Fa=0;Va.length>Fa;)Ua(Va[Fa++]);xa.constructor=Oa,Oa.prototype=xa,Ye(A,"RegExp",Oa)}wi("RegExp");var ja=$e.PROPER,Ba=RegExp.prototype,Ha=Ba.toString,za=P((function(){return"/a/b"!=Ha.call({source:"a",flags:"b"})})),Ga=ja&&"toString"!=Ha.name;(za||Ga)&&Ye(RegExp.prototype,"toString",(function(){var e=Ee(this),t=Di(e.source),n=e.flags;return"/"+t+"/"+Di(void 0===n&&e instanceof RegExp&&!("flags"in Ba)?po.call(e):n)}),{unsafe:!0});var Wa=1..valueOf,Ja=function(e){return Wa.call(e)},qa="\t\n\v\f\r                 \u2028\u2029\ufeff",Ka="["+qa+"]",Qa=RegExp("^"+Ka+Ka+"*"),Xa=RegExp(Ka+Ka+"*$"),$a=function(e){return function(t){var n=Di(B(t));return 1&e&&(n=n.replace(Qa,"")),2&e&&(n=n.replace(Xa,"")),n}},Ya={start:$a(1),end:$a(2),trim:$a(3)},Za=ft.f,es=Re.f,ts=xe.f,ns=Ya.trim,rs=A.Number,is=rs.prototype,os=function(e){var t=ye(e,"number");return"bigint"==typeof t?t:as(t)},as=function(e){var t,n,r,i,o,a,s,c,u=ye(e,"number");if(te(u))throw TypeError("Cannot convert a Symbol value to a number");if("string"==typeof u&&u.length>2)if(43===(t=(u=ns(u)).charCodeAt(0))||45===t){if(88===(n=u.charCodeAt(2))||120===n)return NaN}else if(48===t){switch(u.charCodeAt(1)){case 66:case 98:r=2,i=49;break;case 79:case 111:r=8,i=55;break;default:return+u}for(a=(o=u.slice(2)).length,s=0;s<a;s++)if((c=o.charCodeAt(s))<48||c>i)return NaN;return parseInt(o,r)}return+u};if(Tt("Number",!rs(" 0o1")||!rs("0b1")||rs("+0x1"))){for(var ss,cs=function(e){var t=arguments.length<1?0:rs(os(e)),n=this;return n instanceof cs&&P((function(){Ja(n)}))?bi(Object(t),n,cs):t},us=D?Za(rs):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),ls=0;us.length>ls;ls++)le(rs,ss=us[ls])&&!le(cs,ss)&&ts(cs,ss,es(rs,ss));cs.prototype=is,is.constructor=cs,Ye(A,"Number",cs)}var ds=ut.indexOf,hs=[].indexOf,ps=!!hs&&1/[1].indexOf(1,-0)<0,fs=$i("indexOf");Rt({target:"Array",proto:!0,forced:ps||!fs},{indexOf:function(e){return ps?hs.apply(this,arguments)||0:ds(this,e,arguments.length>1?arguments[1]:void 0)}});var ms=P((function(){Lr(1)}));Rt({target:"Object",stat:!0,forced:ms,sham:!Ar},{getPrototypeOf:function(e){return Lr(ce(e))}});var vs=J("Reflect","apply"),_s=Function.apply,gs=!P((function(){vs((function(){}))}));Rt({target:"Reflect",stat:!0,forced:gs},{apply:function(e,t,n){return re(e),Ee(n),vs?vs(e,t,n):_s.call(e,t,n)}});var ys=$e.EXISTS,Ss=xe.f,bs=Function.prototype,ks=bs.toString,Is=/^\s*function ([^ (]*)/;D&&!ys&&Ss(bs,"name",{configurable:!0,get:function(){try{return ks.call(this).match(Is)[1]}catch(e){return""}}}),Rt({target:"Date",stat:!0},{now:function(){return(new Date).getTime()}});var Ts=_e("species"),ws=function(e,t){var n,r=Ee(e).constructor;return void 0===r||null==(n=Ee(r)[Ts])?t:function(e){if(jt(e))return e;throw TypeError(ne(e)+" is not a constructor")}(n)},Rs=mo.UNSUPPORTED_Y,Es=[].push,Cs=Math.min;Ao("split",(function(e,t,n){var r;return r="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(e,n){var r=Di(B(this)),i=void 0===n?4294967295:n>>>0;if(0===i)return[];if(void 0===e)return[r];if(!Ia(e))return t.call(r,e,i);for(var o,a,s,c=[],u=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),l=0,d=new RegExp(e.source,u+"g");(o=Eo.call(d,r))&&!((a=d.lastIndex)>l&&(c.push(r.slice(l,o.index)),o.length>1&&o.index<r.length&&Es.apply(c,o.slice(1)),s=o[0].length,l=a,c.length>=i));)d.lastIndex===o.index&&d.lastIndex++;return l===r.length?!s&&d.test("")||c.push(""):c.push(r.slice(l)),c.length>i?c.slice(0,i):c}:"0".split(void 0,0).length?function(e,n){return void 0===e&&0===n?[]:t.call(this,e,n)}:t,[function(t,n){var i=B(this),o=null==t?void 0:ie(t,e);return o?o.call(t,i,n):r.call(Di(i),t,n)},function(e,i){var o=Ee(this),a=Di(e),s=n(r,o,a,i,r!==t);if(s.done)return s.value;var c=ws(o,RegExp),u=o.unicode,l=(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.unicode?"u":"")+(Rs?"g":"y"),d=new c(Rs?"^(?:"+o.source+")":o,l),h=void 0===i?4294967295:i>>>0;if(0===h)return[];if(0===a.length)return null===Vo(d,a)?[a]:[];for(var p=0,f=0,m=[];f<a.length;){d.lastIndex=Rs?0:f;var v,_=Vo(d,Rs?a.slice(f):a);if(null===_||(v=Cs(at(d.lastIndex+(Rs?f:0)),a.length))===p)f=Do(a,f,u);else{if(m.push(a.slice(p,f)),m.length===h)return m;for(var g=1;g<=_.length-1;g++)if(m.push(_[g]),m.length===h)return m;f=p=v}}return m.push(a.slice(p)),m}]}),!!P((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return 2!==n.length||"a"!==n[0]||"b"!==n[1]})),Rs);var xs,As,Ps,Ds,Ls=A.Promise,Ms=/(?:ipad|iphone|ipod).*applewebkit/i.test(q),Ns="process"==V(A.process),Os=A.setImmediate,Us=A.clearImmediate,Vs=A.process,Fs=A.MessageChannel,js=A.Dispatch,Bs=0,Hs={};try{xs=A.location}catch(e){}var zs=function(e){if(Hs.hasOwnProperty(e)){var t=Hs[e];delete Hs[e],t()}},Gs=function(e){return function(){zs(e)}},Ws=function(e){zs(e.data)},Js=function(e){A.postMessage(String(e),xs.protocol+"//"+xs.host)};Os&&Us||(Os=function(e){for(var t=[],n=arguments.length,r=1;n>r;)t.push(arguments[r++]);return Hs[++Bs]=function(){(z(e)?e:Function(e)).apply(void 0,t)},As(Bs),Bs},Us=function(e){delete Hs[e]},Ns?As=function(e){Vs.nextTick(Gs(e))}:js&&js.now?As=function(e){js.now(Gs(e))}:Fs&&!Ms?(Ds=(Ps=new Fs).port2,Ps.port1.onmessage=Ws,As=Et(Ds.postMessage,Ds,1)):A.addEventListener&&z(A.postMessage)&&!A.importScripts&&xs&&"file:"!==xs.protocol&&!P(Js)?(As=Js,A.addEventListener("message",Ws,!1)):As="onreadystatechange"in Ie("script")?function(e){vr.appendChild(Ie("script")).onreadystatechange=function(){vr.removeChild(this),zs(e)}}:function(e){setTimeout(Gs(e),0)});var qs,Ks,Qs,Xs,$s,Ys,Zs,ec,tc={set:Os,clear:Us},nc=/ipad|iphone|ipod/i.test(q)&&void 0!==A.Pebble,rc=/web0s(?!.*chrome)/i.test(q),ic=Re.f,oc=tc.set,ac=A.MutationObserver||A.WebKitMutationObserver,sc=A.document,cc=A.process,uc=A.Promise,lc=ic(A,"queueMicrotask"),dc=lc&&lc.value;dc||(qs=function(){var e,t;for(Ns&&(e=cc.domain)&&e.exit();Ks;){t=Ks.fn,Ks=Ks.next;try{t()}catch(e){throw Ks?Xs():Qs=void 0,e}}Qs=void 0,e&&e.enter()},Ms||Ns||rc||!ac||!sc?!nc&&uc&&uc.resolve?((Zs=uc.resolve(void 0)).constructor=uc,ec=Zs.then,Xs=function(){ec.call(Zs,qs)}):Xs=Ns?function(){cc.nextTick(qs)}:function(){oc.call(A,qs)}:($s=!0,Ys=sc.createTextNode(""),new ac(qs).observe(Ys,{characterData:!0}),Xs=function(){Ys.data=$s=!$s}));var hc,pc,fc,mc,vc=dc||function(e){var t={fn:e,next:void 0};Qs&&(Qs.next=t),Ks||(Ks=t,Xs()),Qs=t},_c=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r})),this.resolve=re(t),this.reject=re(n)},gc={f:function(e){return new _c(e)}},yc=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},Sc="object"==typeof window,bc=tc.set,kc=_e("species"),Ic="Promise",Tc=qe.get,wc=qe.set,Rc=qe.getterFor(Ic),Ec=Ls&&Ls.prototype,Cc=Ls,xc=Ec,Ac=A.TypeError,Pc=A.document,Dc=A.process,Lc=gc.f,Mc=Lc,Nc=!!(Pc&&Pc.createEvent&&A.dispatchEvent),Oc=z(A.PromiseRejectionEvent),Uc=!1,Vc=Tt(Ic,(function(){var e=Ne(Cc),t=e!==String(Cc);if(!t&&66===Y)return!0;if(Y>=51&&/native code/.test(e))return!1;var n=new Cc((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};return(n.constructor={})[kc]=r,!(Uc=n.then((function(){}))instanceof r)||!t&&Sc&&!Oc})),Fc=Vc||!Si((function(e){Cc.all(e).catch((function(){}))})),jc=function(e){var t;return!(!G(e)||!z(t=e.then))&&t},Bc=function(e,t){if(!e.notified){e.notified=!0;var n=e.reactions;vc((function(){for(var r=e.value,i=1==e.state,o=0;n.length>o;){var a,s,c,u=n[o++],l=i?u.ok:u.fail,d=u.resolve,h=u.reject,p=u.domain;try{l?(i||(2===e.rejection&&Wc(e),e.rejection=1),!0===l?a=r:(p&&p.enter(),a=l(r),p&&(p.exit(),c=!0)),a===u.promise?h(Ac("Promise-chain cycle")):(s=jc(a))?s.call(a,d,h):d(a)):h(r)}catch(e){p&&!c&&p.exit(),h(e)}}e.reactions=[],e.notified=!1,t&&!e.rejection&&zc(e)}))}},Hc=function(e,t,n){var r,i;Nc?((r=Pc.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),A.dispatchEvent(r)):r={promise:t,reason:n},!Oc&&(i=A["on"+e])?i(r):"unhandledrejection"===e&&function(e,t){var n=A.console;n&&n.error&&(1===arguments.length?n.error(e):n.error(e,t))}("Unhandled promise rejection",n)},zc=function(e){bc.call(A,(function(){var t,n=e.facade,r=e.value;if(Gc(e)&&(t=yc((function(){Ns?Dc.emit("unhandledRejection",r,n):Hc("unhandledrejection",n,r)})),e.rejection=Ns||Gc(e)?2:1,t.error))throw t.value}))},Gc=function(e){return 1!==e.rejection&&!e.parent},Wc=function(e){bc.call(A,(function(){var t=e.facade;Ns?Dc.emit("rejectionHandled",t):Hc("rejectionhandled",t,e.value)}))},Jc=function(e,t,n){return function(r){e(t,r,n)}},qc=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,Bc(e,!0))},Kc=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw Ac("Promise can't be resolved itself");var r=jc(t);r?vc((function(){var n={done:!1};try{r.call(t,Jc(Kc,n,e),Jc(qc,n,e))}catch(t){qc(n,t,e)}})):(e.value=t,e.state=1,Bc(e,!1))}catch(t){qc({done:!1},t,e)}}};if(Vc&&(xc=(Cc=function(e){mi(this,Cc,Ic),re(e),hc.call(this);var t=Tc(this);try{e(Jc(Kc,t),Jc(qc,t))}catch(e){qc(t,e)}}).prototype,(hc=function(e){wc(this,{type:Ic,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=Ii(xc,{then:function(e,t){var n=Rc(this),r=Lc(ws(this,Cc));return r.ok=!z(e)||e,r.fail=z(t)&&t,r.domain=Ns?Dc.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&Bc(n,!1),r.promise},catch:function(e){return this.then(void 0,e)}}),pc=function(){var e=new hc,t=Tc(e);this.promise=e,this.resolve=Jc(Kc,t),this.reject=Jc(qc,t)},gc.f=Lc=function(e){return e===Cc||e===fc?new pc(e):Mc(e)},z(Ls)&&Ec!==Object.prototype)){mc=Ec.then,Uc||(Ye(Ec,"then",(function(e,t){var n=this;return new Cc((function(e,t){mc.call(n,e,t)})).then(e,t)}),{unsafe:!0}),Ye(Ec,"catch",xc.catch,{unsafe:!0}));try{delete Ec.constructor}catch(e){}zr&&zr(Ec,xc)}Rt({global:!0,wrap:!0,forced:Vc},{Promise:Cc}),Fr(Cc,Ic,!1),wi(Ic),fc=J(Ic),Rt({target:Ic,stat:!0,forced:Vc},{reject:function(e){var t=Lc(this);return t.reject.call(void 0,e),t.promise}}),Rt({target:Ic,stat:!0,forced:Vc},{resolve:function(e){return function(e,t){if(Ee(e),G(t)&&t.constructor===e)return t;var n=gc.f(e);return(0,n.resolve)(t),n.promise}(this,e)}}),Rt({target:Ic,stat:!0,forced:Fc},{all:function(e){var t=this,n=Lc(t),r=n.resolve,i=n.reject,o=yc((function(){var n=re(t.resolve),o=[],a=0,s=1;fi(e,(function(e){var c=a++,u=!1;o.push(void 0),s++,n.call(t,e).then((function(e){u||(u=!0,o[c]=e,--s||r(o))}),i)})),--s||r(o)}));return o.error&&i(o.value),n.promise},race:function(e){var t=this,n=Lc(t),r=n.reject,i=yc((function(){var i=re(t.resolve);fi(e,(function(e){i.call(t,e).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}});var Qc=Ya.trim,Xc=A.parseFloat,$c=A.Symbol,Yc=$c&&$c.iterator,Zc=1/Xc(qa+"-0")!=-1/0||Yc&&!P((function(){Xc(Object(Yc))}))?function(e){var t=Qc(Di(e)),n=Xc(t);return 0===n&&"-"==t.charAt(0)?-0:n}:Xc;Rt({global:!0,forced:parseFloat!=Zc},{parseFloat:Zc});var eu,tu=window.navigator&&window.navigator.userAgent||"",nu=/AppleWebKit\/([\d.]+)/i.exec(tu),ru=(nu&&parseFloat(nu.pop()),/iPad/i.test(tu)),iu=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/Macintosh/.test(tu),ou=/iPhone/i.test(tu)&&!ru,au=/iPod/i.test(tu),su=ou||ru||au||iu,cu=/Android/i.test(tu),uu=(cu&&function(){var e=tu.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;var t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);t&&n&&parseFloat(e[1]+"."+e[2])}(),cu&&/webkit/i.test(tu),/Firefox/i.test(tu)),lu=uu&&function(){var e=tu.match(/Firefox\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),du=/Edge\//i.test(tu),hu=du&&function(){var e=tu.match(/Edge\/(\d+)/i);if(e&&e[1])return e[1]}(),pu=/Edg\//i.test(tu),fu=pu&&function(){var e=tu.match(/Edg\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),mu=/SogouMobileBrowser\//i.test(tu),vu=mu&&function(){var e=tu.match(/SogouMobileBrowser\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),_u=/MetaSr\s/i.test(tu),gu=_u&&function(){var e=tu.match(/MetaSr(\s\d+(\.\d+)+)/);return e&&e[1]?parseFloat(e[1]):null}(),yu=/TBS\/\d+/i.test(tu),Su=yu&&function(){var e=tu.match(/TBS\/(\d+)/i);if(e&&e[1])return e[1]}(),bu=/XWEB\/\d+/i.test(tu),ku=bu&&function(){var e=tu.match(/XWEB\/(\d+)/i);if(e&&e[1])return e[1]}(),Iu=(/MSIE\s8\.0/.test(tu),/MSIE\/\d+/i.test(tu)&&function(){var e=/MSIE\s(\d+)\.\d/.exec(tu),t=e&&parseFloat(e[1]);!t&&/Trident\/7.0/i.test(tu)&&/rv:11.0/.test(tu)&&(t=11)}(),/(micromessenger|webbrowser)/i.test(tu)),Tu=Iu&&function(){var e=tu.match(/MicroMessenger\/(\d+)/i);if(e&&e[1])return e[1]}(),wu=!yu&&/MQQBrowser\/\d+/i.test(tu)&&/COVC\/\d+/i.test(tu),Ru=!yu&&/MQQBrowser\/\d+/i.test(tu)&&!/COVC\/\d+/i.test(tu),Eu=(Ru||wu)&&function(){var e=tu.match(/ MQQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Cu=!yu&&/ QQBrowser\/\d+/i.test(tu),xu=Cu&&function(){var e=tu.match(/ QQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Au=!yu&&/QQBrowserLite\/\d+/i.test(tu),Pu=Au&&function(){var e=tu.match(/QQBrowserLite\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Du=!yu&&/MQBHD\/\d+/i.test(tu),Lu=Du&&function(){var e=tu.match(/MQBHD\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Mu=/Windows/i.test(tu),Nu=!su&&/MAC OS X/i.test(tu),Ou=!cu&&/Linux/i.test(tu),Uu=(/MicroMessenger/i.test(tu),/UCBrowser/i.test(tu)),Vu=(/Electron/i.test(tu),/MiuiBrowser/i.test(tu)),Fu=Vu&&function(){var e=tu.match(/MiuiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),ju=/HuaweiBrowser/i.test(tu),Bu=/Huawei/i.test(tu),Hu=ju&&function(){var e=tu.match(/HuaweiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),zu=/SamsungBrowser/i.test(tu),Gu=zu&&function(){var e=tu.match(/SamsungBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Wu=/HeyTapBrowser/i.test(tu),Ju=Wu&&function(){var e=tu.match(/HeyTapBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),qu=/VivoBrowser/i.test(tu),Ku=qu&&function(){var e=tu.match(/VivoBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Qu=function(){var e=tu.match(/Chrome\/(\d+)/);return e&&e[1]?Number(e[1]):null},Xu=/Chrome/i.test(tu),$u=!du&&!_u&&!mu&&!yu&&!bu&&!pu&&!Cu&&!Vu&&!ju&&!zu&&!Wu&&!qu&&/Chrome/i.test(tu),Yu=$u&&Qu(),Zu=$u&&function(){var e=tu.match(/Chrome\/([\d.]+)/);return e&&e[1]?e[1]:null}(),el=!Xu&&!Ru&&!wu&&!Au&&!Du&&/Safari/i.test(tu),tl=el&&function(){var e=tu.match(/Version\/([\d.]+)/);return e&&e[1]?e[1]:null}(),nl=/Android.*(wv|.0.0.0)/.test(tu),rl=function(){if(iu)return tl;if(su){var e=tu.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}(),il="15.1"===rl,ol="file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname,al=function(){if(Kd(eu))try{eu=window.localStorage}catch(e){Pp.warn(e),eu=!1}return eu},sl=new Map([[uu,["Firefox",lu]],[pu,["Edg",fu]],[$u,["Chrome",Zu]],[el,["Safari",tl]],[yu,["TBS",Su]],[bu,["XWEB",ku]],[Iu&&ou,["WeChat",Tu]],[Cu,["QQ(Win)",xu]],[Ru,["QQ(Mobile)",Eu]],[wu,["QQ(Mobile X5)",Eu]],[Au,["QQ(Mac)",Pu]],[Du,["QQ(iPad)",Lu]],[Vu,["MI",Fu]],[ju,["HW",Hu]],[zu,["Samsung",Gu]],[Wu,["OPPO",Ju]],[qu,["VIVO",Ku]],[du,["EDGE",hu]],[mu,["SogouMobile",vu]],[_u,["Sogou",gu]]]);function cl(){var e="unknown",t="unknown";return sl.get(!0)&&(e=sl.get(!0)[0],t=sl.get(!0)[1]),{name:e,version:t}}var ul=P((function(){fr(1)}));Rt({target:"Object",stat:!0,forced:ul},{keys:function(e){return fr(ce(e))}});var ll="audio",dl="video",hl="auxiliary",pl="user",fl="environment",ml="mute",vl="unmute",_l="ended",gl="playing",yl="pause",Sl="error",bl="loadeddata",kl="audioinput",Il="videoinput",Tl="detail",wl="main",Rl="backup",El="qcloud",Cl="",xl="jssdk_log",Al=20,Pl="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",Dl="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",Ll=wl,Ml=hl,Nl="DISCONNECTED",Ol="CONNECTING",Ul="RECONNECTING",Vl="CONNECTED",Fl="connecting",jl="failed",Bl="closed",Hl="connected",zl="join",Gl="rejoin",Wl="publish",Jl="unpublish",ql="subscribe",Kl="unsubscribe",Ql="uplink-connection",Xl="uplink-reconnection",$l="downlink-connection",Yl="downlink-reconnection",Zl="setLocalDescription",ed="setRemoteDescription",td="iceConnectionState",nd="stream-initialize",rd="websocketConnectionState",id="websocketReconnectionState",od="update-stream",ad="recover-subscription",sd="start-mix-transcode",cd="stop-mix-transcode",ud="player-error",ld="schedule",dd="load-worklet",hd="unsubscribe",pd="subscribe_change",fd="manual",md="preset-layout",vd="$PLACE_HOLDER_REMOTE$",_d=0,gd=4,yd="string",Sd="number",bd="boolean",kd="object",Id="add",Td="remove",wd={unknown:0,wifi:1,"4g":2,"3g":3,"2g":4,wired:5},Rd="schedule.rtc.qq.com",Ed="schedule.rtc.qcloud.com",Cd="intl-schedule.rtc.qq.com",xd="intl-schedule.rtc.qcloud.com",Ad="TRTC",Pd="LocalStream",Dd="RemoteStream",Ld="web.sdk.qcloud.com",Md="web.sdk.tencent.cn",Nd="web.sdk.cloud.tencent.cn",Od="https://".concat(Ld,"/trtc/webrtc/doc"),Ud="".concat(Od,"/zh-cn/"),Vd={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,NONE:5},Fd=Object.keys(Vd),jd=["normal leave","timeout leave","kick","role change"],Bd=function(){return function(e){var t=window.location.search.match(new RegExp("(\\?|&)trtc_env=([^&]*)(&|$)"));return t?decodeURIComponent(t[2]):""}()},Hd=function(e){return Number(e)<14e8},zd=function(e,t){var n;n=Cl||(Hd(e)?"https://videoapi-sgp.im.qcloud.com":"https://yun.tim.qq.com");var r=Math.floor(Math.random()*Math.pow(2,31));return"".concat(n,"/v5/AVQualityReportSvc/C2S?random=").concat(r,"&sdkappid=").concat(e,"&cmdtype=").concat(t)};function Gd(){var e=navigator.userAgent,t=navigator.connection,n=e.match(/NetType\/\w+/)?e.match(/NetType\/\w+/)[0]:"";"3gnet"===(n=n.toLowerCase().replace("nettype/",""))&&(n="3g");var r=t&&t.type&&t.type.toLowerCase(),i=t&&t.effectiveType&&t.effectiveType.toLowerCase();"slow-2"===i&&(i="2g");var o=n||"unknown";if(r)switch(r){case"cellular":case"wimax":o=i||"unknown";break;case"wifi":o="wifi";break;case"ethernet":o="wired";break;case"none":case"other":case"unknown":o="unknown"}return o}var Wd=function(e){if(!e||"object"!==r(e)||"[object Object]"!=Object.prototype.toString.call(e))return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object)};function Jd(e){var t=Math.round(e/2)+1;return t>6?13e3:1e3*function e(t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return t<=1?n:e(t-1,n,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+n)}(t)}var qd=function(e){return"function"==typeof e},Kd=function(e){return void 0===e},Qd=function(e){return"string"==typeof e},Xd=function(e){return"number"==typeof e},$d=function(e){return"boolean"==typeof e},Yd=function(e){return"array"===eh(e)},Zd=function(e){return eh(e)==="MediaStreamTrack".toLowerCase()};function eh(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}function th(e){var t={};return t.urls="turn:".concat(e.url),Kd(e.username)||Kd(e.credential)||(t.username=e.username,t.credential=e.credential,t.credentialType="password",Kd(e.credentialType)||(t.credentialType=e.credentialType)),t}function nh(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}function rh(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"big";if(!Qd(e))return 0;var n=e.split(".");return"big"===t?(Number(n[0])<<24|Number(n[1])<<16|Number(n[2])<<8|Number(n[3]))>>>0:(Number(n[3])<<24|Number(n[2])<<16|Number(n[1])<<8|Number(n[0]))>>>0}var ih,oh,ah=function(){return"zh"===(navigator.language||navigator.userLanguage).substr(0,2)},sh=(ih=!1,oh=document.visibilityState,function(){document.visibilityState!==oh&&Pp.info("visibility change: ".concat(document.visibilityState)),ih||(document.addEventListener("visibilitychange",(function(){Pp.info("visibility change: "+document.visibilityState),oh=document.visibilityState})),ih=!0)}),ch=!!window.AudioWorkletNode,uh=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}},lh=Object.prototype.toString;function dh(e){return"[object Array]"===lh.call(e)}function hh(e){return void 0===e}function ph(e){return null!==e&&"object"==typeof e}function fh(e){return"[object Function]"===lh.call(e)}function mh(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),dh(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}var vh={isArray:dh,isArrayBuffer:function(e){return"[object ArrayBuffer]"===lh.call(e)},isBuffer:function(e){return null!==e&&!hh(e)&&null!==e.constructor&&!hh(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:ph,isUndefined:hh,isDate:function(e){return"[object Date]"===lh.call(e)},isFile:function(e){return"[object File]"===lh.call(e)},isBlob:function(e){return"[object Blob]"===lh.call(e)},isFunction:fh,isStream:function(e){return ph(e)&&fh(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:mh,merge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]=n}for(var r=0,i=arguments.length;r<i;r++)mh(arguments[r],n);return t},deepMerge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]="object"==typeof n?e({},n):n}for(var r=0,i=arguments.length;r<i;r++)mh(arguments[r],n);return t},extend:function(e,t,n){return mh(t,(function(t,r){e[r]=n&&"function"==typeof t?uh(t,n):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}};function _h(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var gh=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(vh.isURLSearchParams(t))r=t.toString();else{var i=[];vh.forEach(t,(function(e,t){null!=e&&(vh.isArray(e)?t+="[]":e=[e],vh.forEach(e,(function(e){vh.isDate(e)?e=e.toISOString():vh.isObject(e)&&(e=JSON.stringify(e)),i.push(_h(t)+"="+_h(e))})))})),r=i.join("&")}if(r){var o=e.indexOf("#");-1!==o&&(e=e.slice(0,o)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e};function yh(){this.handlers=[]}yh.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},yh.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},yh.prototype.forEach=function(e){vh.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var Sh=yh,bh=function(e,t,n){return vh.forEach(n,(function(n){e=n(e,t)})),e},kh=function(e){return!(!e||!e.__CANCEL__)},Ih=void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function Th(){throw new Error("setTimeout has not been defined")}function wh(){throw new Error("clearTimeout has not been defined")}var Rh=Th,Eh=wh;function Ch(e){if(Rh===setTimeout)return setTimeout(e,0);if((Rh===Th||!Rh)&&setTimeout)return Rh=setTimeout,setTimeout(e,0);try{return Rh(e,0)}catch(t){try{return Rh.call(null,e,0)}catch(t){return Rh.call(this,e,0)}}}"function"==typeof Ih.setTimeout&&(Rh=setTimeout),"function"==typeof Ih.clearTimeout&&(Eh=clearTimeout);var xh,Ah=[],Ph=!1,Dh=-1;function Lh(){Ph&&xh&&(Ph=!1,xh.length?Ah=xh.concat(Ah):Dh=-1,Ah.length&&Mh())}function Mh(){if(!Ph){var e=Ch(Lh);Ph=!0;for(var t=Ah.length;t;){for(xh=Ah,Ah=[];++Dh<t;)xh&&xh[Dh].run();Dh=-1,t=Ah.length}xh=null,Ph=!1,function(e){if(Eh===clearTimeout)return clearTimeout(e);if((Eh===wh||!Eh)&&clearTimeout)return Eh=clearTimeout,clearTimeout(e);try{Eh(e)}catch(t){try{return Eh.call(null,e)}catch(t){return Eh.call(this,e)}}}(e)}}function Nh(e,t){this.fun=e,this.array=t}function Oh(){}Nh.prototype.run=function(){this.fun.apply(null,this.array)};var Uh=Oh,Vh=Oh,Fh=Oh,jh=Oh,Bh=Oh,Hh=Oh,zh=Oh,Gh=Ih.performance||{},Wh=Gh.now||Gh.mozNow||Gh.msNow||Gh.oNow||Gh.webkitNow||function(){return(new Date).getTime()},Jh=new Date,qh={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];Ah.push(new Nh(e,t)),1!==Ah.length||Ph||Ch(Mh)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:Uh,addListener:Vh,once:Fh,off:jh,removeListener:Bh,removeAllListeners:Hh,emit:zh,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*Wh.call(Gh),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Jh)/1e3}},Kh=function(e,t){vh.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},Qh=function(e,t,n,r,i){return function(e,t,n,r,i){return e.config=t,n&&(e.code=n),e.request=r,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}(new Error(e),t,n,r,i)},Xh=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],$h=vh.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=vh.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},Yh=vh.isStandardBrowserEnv()?{write:function(e,t,n,r,i,o){var a=[];a.push(e+"="+encodeURIComponent(t)),vh.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),vh.isString(r)&&a.push("path="+r),vh.isString(i)&&a.push("domain="+i),!0===o&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Zh=function(e){return new Promise((function(t,n){var r=e.data,i=e.headers;vh.isFormData(r)&&delete i["Content-Type"];var o=new XMLHttpRequest;if(e.auth){var a=e.auth.username||"",s=e.auth.password||"";i.Authorization="Basic "+btoa(a+":"+s)}var c,u,l=(c=e.baseURL,u=e.url,c&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(u)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(c,u):u);if(o.open(e.method.toUpperCase(),gh(l,e.params,e.paramsSerializer),!0),o.timeout=e.timeout,o.onreadystatechange=function(){if(o&&4===o.readyState&&(0!==o.status||o.responseURL&&0===o.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in o?function(e){var t,n,r,i={};return e?(vh.forEach(e.split("\n"),(function(e){if(r=e.indexOf(":"),t=vh.trim(e.substr(0,r)).toLowerCase(),n=vh.trim(e.substr(r+1)),t){if(i[t]&&Xh.indexOf(t)>=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([n]):i[t]?i[t]+", "+n:n}})),i):i}(o.getAllResponseHeaders()):null,i={data:e.responseType&&"text"!==e.responseType?o.response:o.responseText,status:o.status,statusText:o.statusText,headers:r,config:e,request:o};!function(e,t,n){var r=n.config.validateStatus;!r||r(n.status)?e(n):t(Qh("Request failed with status code "+n.status,n.config,null,n.request,n))}(t,n,i),o=null}},o.onabort=function(){o&&(n(Qh("Request aborted",e,"ECONNABORTED",o)),o=null)},o.onerror=function(){n(Qh("Network Error",e,null,o)),o=null},o.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(Qh(t,e,"ECONNABORTED",o)),o=null},vh.isStandardBrowserEnv()){var d=Yh,h=(e.withCredentials||$h(l))&&e.xsrfCookieName?d.read(e.xsrfCookieName):void 0;h&&(i[e.xsrfHeaderName]=h)}if("setRequestHeader"in o&&vh.forEach(i,(function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete i[t]:o.setRequestHeader(t,e)})),vh.isUndefined(e.withCredentials)||(o.withCredentials=!!e.withCredentials),e.responseType)try{o.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&o.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&o.upload&&o.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){o&&(o.abort(),n(e),o=null)})),void 0===r&&(r=null),o.send(r)}))},ep={"Content-Type":"application/x-www-form-urlencoded"};function tp(e,t){!vh.isUndefined(e)&&vh.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var np={adapter:function(){var e;return("undefined"!=typeof XMLHttpRequest||void 0!==qh&&"[object process]"===Object.prototype.toString.call(qh))&&(e=Zh),e}(),transformRequest:[function(e,t){return Kh(t,"Accept"),Kh(t,"Content-Type"),vh.isFormData(e)||vh.isArrayBuffer(e)||vh.isBuffer(e)||vh.isStream(e)||vh.isFile(e)||vh.isBlob(e)?e:vh.isArrayBufferView(e)?e.buffer:vh.isURLSearchParams(e)?(tp(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):vh.isObject(e)?(tp(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};vh.forEach(["delete","get","head"],(function(e){np.headers[e]={}})),vh.forEach(["post","put","patch"],(function(e){np.headers[e]=vh.merge(ep)}));var rp=np;function ip(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var op=function(e){return ip(e),e.headers=e.headers||{},e.data=bh(e.data,e.headers,e.transformRequest),e.headers=vh.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),vh.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||rp.adapter)(e).then((function(t){return ip(e),t.data=bh(t.data,t.headers,e.transformResponse),t}),(function(t){return kh(t)||(ip(e),t&&t.response&&(t.response.data=bh(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},ap=function(e,t){t=t||{};var n={},r=["url","method","params","data"],i=["headers","auth","proxy"],o=["baseURL","url","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"];vh.forEach(r,(function(e){void 0!==t[e]&&(n[e]=t[e])})),vh.forEach(i,(function(r){vh.isObject(t[r])?n[r]=vh.deepMerge(e[r],t[r]):void 0!==t[r]?n[r]=t[r]:vh.isObject(e[r])?n[r]=vh.deepMerge(e[r]):void 0!==e[r]&&(n[r]=e[r])})),vh.forEach(o,(function(r){void 0!==t[r]?n[r]=t[r]:void 0!==e[r]&&(n[r]=e[r])}));var a=r.concat(i).concat(o),s=Object.keys(t).filter((function(e){return-1===a.indexOf(e)}));return vh.forEach(s,(function(r){void 0!==t[r]?n[r]=t[r]:void 0!==e[r]&&(n[r]=e[r])})),n};function sp(e){this.defaults=e,this.interceptors={request:new Sh,response:new Sh}}sp.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=ap(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[op,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)n=n.then(t.shift(),t.shift());return n},sp.prototype.getUri=function(e){return e=ap(this.defaults,e),gh(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},vh.forEach(["delete","get","head","options"],(function(e){sp.prototype[e]=function(t,n){return this.request(vh.merge(n||{},{method:e,url:t}))}})),vh.forEach(["post","put","patch"],(function(e){sp.prototype[e]=function(t,n,r){return this.request(vh.merge(r||{},{method:e,url:t,data:n}))}}));var cp=sp;function up(e){this.message=e}up.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},up.prototype.__CANCEL__=!0;var lp=up;function dp(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;e((function(e){n.reason||(n.reason=new lp(e),t(n.reason))}))}dp.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},dp.source=function(){var e;return{token:new dp((function(t){e=t})),cancel:e}};var hp=dp;function pp(e){var t=new cp(e),n=uh(cp.prototype.request,t);return vh.extend(n,cp.prototype,t),vh.extend(n,t),n}var fp=pp(rp);fp.Axios=cp,fp.create=function(e){return pp(ap(fp.defaults,e))},fp.Cancel=lp,fp.CancelToken=hp,fp.isCancel=kh,fp.all=function(e){return Promise.all(e)},fp.spread=function(e){return function(t){return e.apply(null,t)}};var mp=fp,vp=fp;mp.default=vp;var _p=mp,gp=R((function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new i(r,o||e,a),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,r,i=[];if(0===this._eventsCount)return i;for(r in e=this._events)t.call(e,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,a=new Array(o);i<o;i++)a[i]=r[i].fn;return a},s.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,i,o,a){var s=n?n+e:e;if(!this._events[s])return!1;var c,u,l=this._events[s],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,i),!0;case 5:return l.fn.call(l.context,t,r,i,o),!0;case 6:return l.fn.call(l.context,t,r,i,o,a),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var h,p=l.length;for(u=0;u<p;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,r);break;case 4:l[u].fn.call(l[u].context,t,r,i);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];l[u].fn.apply(l[u].context,c)}}return!0},s.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,r,i){var o=n?n+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||r&&s.context!==r||a(this,o);else{for(var c=0,u=[],l=s.length;c<l;c++)(s[c].fn!==t||i&&!s[c].once||r&&s[c].context!==r)&&u.push(s[c]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(this,t)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s})),yp=new gp,Sp=102,bp=110,kp=111,Ip=113,Tp=114,wp=116,Rp=130,Ep=301;function Cp(e){var t=e.retryFunction,n=e.settings,r=e.onError,i=e.onRetrying,a=e.context;return function(){for(var e=this,s=arguments.length,c=new Array(s),u=0;u<s;u++)c[u]=arguments[u];var l=n.retries||5,d=0,h=-1,p=0,f=function(){var s=o(regeneratorRuntime.mark((function o(s,u){var m,v,_,g;return regeneratorRuntime.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,m=a||e,o.next=4,t.apply(m,c);case 4:v=o.sent,d=0,s(v),o.next=14;break;case 9:o.prev=9,o.t0=o.catch(0),_=function(){clearTimeout(h),d=0,p=2,u(o.t0)},g=function(){2!==p&&d<l?(d++,p=1,qd(i)&&i(d,_),h=setTimeout((function(){h=-1,f(s,u)}),Kd(n.timeout)?1e3:n.timeout)):_()},qd(r)?r(o.t0,g,u):g();case 14:case"end":return o.stop()}}),o,null,[[0,9]])})));return function(e,t){return s.apply(this,arguments)}}();return new Promise(f)}}var xp=function e(t){a(this,e),this.log=t.log,this.level=t.level,this.userId=t.userId,this.sdkAppId=t.sdkAppId,this.forAllJoinedClients=t.forAllJoinedClients,this.uploaded=!1},Ap=function(){function e(t){a(this,e),this.id_=t.id,this.userId_=t.userId,this.sdkAppId_=t.sdkAppId,this.type_=t.type,this.isLocal_=!$d(t.isLocal)||t.isLocal}return c(e,[{key:"setUserId",value:function(e){this.userId_=e}},{key:"setSdkAppId",value:function(e){this.sdkAppId_=e}},{key:"log",value:function(e,t){Pp.log({log:"[".concat(this.isLocal_?"":"*").concat(this.id_,"] ").concat(this.type_?this.type_+" ":"").concat(t),level:e,forAllJoinedClients:Kd(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_})}},{key:"info",value:function(e){this.log(Vd.INFO,e)}},{key:"debug",value:function(e){this.log(Vd.DEBUG,e)}},{key:"warn",value:function(e){this.log(Vd.WARN,e)}},{key:"error",value:function(e){this.log(Vd.ERROR,e)}}]),e}(),Pp=new(function(){function e(){var t=this;a(this,e),this.clients_=[],this.queue_=[],this.timeoutId_=-1,this.logLevel_=Vd.DEBUG,this.logLevelToUpload_=Vd.INFO,this.enableUploadLog_=!0,this.isAbleToUpload_=!1,this.startUpload(),this.checkURLParam(),yp.on(30,(function(e){var n=e.client;return t.clients_.push(n)})),yp.on(31,(function(e){e&&Wd(e.config)&&Fd[e.config.logLevelToUpload]&&(t.logLevelToUpload_=e.config.logLevelToUpload)})),yp.on(4,this.setIsAbleToUpload,this),yp.on(5,this.setIsAbleToUpload,this)}var t,n;return c(e,[{key:"getIsAbleToUpload",value:function(){return this.isAbleToUpload_}},{key:"setIsAbleToUpload",value:function(){this.isAbleToUpload_=!0,yp.off(4,this.setIsAbleToUpload,this),yp.off(5,this.setIsAbleToUpload,this)}},{key:"startUpload",value:(n=o(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.upload();case 3:e.next=7;break;case 5:e.prev=5,e.t0=e.catch(0);case 7:this.timeoutId_=setTimeout((function(){return t.startUpload()}),2e3);case 8:case"end":return e.stop()}}),e,this,[[0,5]])}))),function(){return n.apply(this,arguments)})},{key:"stopUpload",value:function(){-1!==this.timeoutId_&&(clearTimeout(this.timeoutId_),this.timeoutId_=-1)}},{key:"getLogsToUpload",value:function(){var e=this,t={map:new Map,splicedQueue:[]};if(this.queue_[0].forAllJoinedClients&&0===this.clients_.length)return t;for(var n=0,r=function(){if(50===n)return"break";var r=e.queue_[n];r.forAllJoinedClients?e.clients_.forEach((function(e){if(e.getIsJoined()){var n=e.getUserId(),i=e.getSDKAppId();t.map.has(n)?t.map.get(n).logs.push(r):t.map.set(n,{userId:n,sdkAppId:i,logs:[r]})}})):t.map.has(r.userId)?t.map.get(r.userId).logs.push(r):t.map.set(r.userId,{userId:r.userId,sdkAppId:r.sdkAppId,logs:[r]})};n<this.queue_.length&&"break"!==r();n++);return t.map.size>0&&(t.splicedQueue=this.queue_.splice(0,n)),t}},{key:"upload",value:(t=o(regeneratorRuntime.mark((function e(){var t,n,r,i,o,a,s,c,u,l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this.queue_.length&&this.isAbleToUpload_){e.next=2;break}return e.abrupt("return");case 2:if(t=this.getLogsToUpload(),n=t.map,r=t.splicedQueue,0!==n.size){e.next=5;break}return e.abrupt("return");case 5:e.prev=5,i=S(n.values()),o=0;case 8:if(!(o<i.length)){e.next=16;break}return a=i[o],s=a.userId,c=a.sdkAppId,u=a.logs,e.next=12,this.uploadLogWithRetry(JSON.stringify({timestamp:ba(),sdkAppId:String(c),userId:s,version:"4.12.2",log:u.map((function(e){return e.log})).join("\n")}),c);case 12:u.forEach((function(e){return e.uploaded=!0}));case 13:o++,e.next=8;break;case 16:e.next=20;break;case 18:e.prev=18,e.t0=e.catch(5);case 20:(l=r.filter((function(e){return!e.uploaded}))).length>0&&(this.queue_=l.concat(this.queue_));case 22:case"end":return e.stop()}}),e,this,[[5,18]])}))),function(){return t.apply(this,arguments)})},{key:"uploadLogWithRetry",value:function(e,t){return Cp({retryFunction:function(){return _p.post(zd(t,xl),e,{timeout:5e3})},settings:{retries:3,timeout:1e3},onError:function(e,t){t()}})()}},{key:"getPrefix",value:function(e){var t=new Date;return t.setTime(Sa()),"[".concat(t.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(t.getMilliseconds(),"] <").concat(Fd[e],">")}},{key:"getLogLevel",value:function(){return this.logLevel_}},{key:"setLogLevel",value:function(e){Kd(Fd[e])||(this.logLevel_!==e&&this.info("setLogLevel ".concat(e)),this.logLevel_=e)}},{key:"enableUploadLog",value:function(){this.enableUploadLog_=!0}},{key:"disableUploadLog",value:function(){this.enableUploadLog_=!1}},{key:"log",value:function(e){var t=e.log,n=e.level,r=e.forAllJoinedClients,i=void 0===r||r,o=e.userId,a=e.sdkAppId;if(t="".concat(this.getPrefix(n)," ").concat(t),this.enableUploadLog_&&n>=this.logLevelToUpload_&&this.queue_.push(new xp({log:t,level:n,userId:o,sdkAppId:a,forAllJoinedClients:i})),!(n<this.logLevel_))switch(n){case Vd.ERROR:console.error(t);break;case Vd.WARN:console.warn(t);break;case Vd.INFO:console.log(t);break;case Vd.DEBUG:console.debug(t)}}},{key:"debug",value:function(e){this.log({log:e,level:Vd.DEBUG})}},{key:"info",value:function(e){this.log({log:e,level:Vd.INFO})}},{key:"warn",value:function(e){this.log({log:e,level:Vd.WARN})}},{key:"error",value:function(e){this.log({log:e,level:Vd.ERROR})}},{key:"createLogger",value:function(e){return new Ap(e)}},{key:"checkURLParam",value:function(){var e=new URLSearchParams(location.search).get("logLevelToUpload");Fd[e]&&(this.logLevelToUpload_=e)}}]),e}()),Dp=!0,Lp=Math.floor,Mp=Number.isInteger||function(e){return!G(e)&&isFinite(e)&&Lp(e)===e};Rt({target:"Number",stat:!0},{isInteger:Mp});var Np,Op=function(e){if(Ia(e))throw TypeError("The method doesn't accept regular expressions");return e},Up=_e("match"),Vp=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[Up]=!1,"/./"[e](t)}catch(e){}}return!1},Fp=Re.f,jp="".startsWith,Bp=Math.min,Hp=Vp("startsWith"),zp=!(Hp||(Np=Fp(String.prototype,"startsWith"),!Np||Np.writable));Rt({target:"String",proto:!0,forced:!zp&&!Hp},{startsWith:function(e){var t=Di(B(this));Op(e);var n=at(Bp(arguments.length>1?arguments[1]:void 0,t.length)),r=Di(e);return jp?jp.call(t,r,n):t.slice(n,n+r.length)===r}}),Rt({target:"Array",stat:!0},{isArray:Ct});var Gp=Ya.trim,Wp=A.parseInt,Jp=A.Symbol,qp=Jp&&Jp.iterator,Kp=/^[+-]?0[Xx]/,Qp=8!==Wp(qa+"08")||22!==Wp(qa+"0x16")||qp&&!P((function(){Wp(Object(qp))}))?function(e,t){var n=Gp(Di(e));return Wp(n,t>>>0||(Kp.test(n)?16:10))}:Wp;Rt({global:!0,forced:parseInt!=Qp},{parseInt:Qp});var Xp=[].slice,$p={},Yp=function(e,t,n){if(!(t in $p)){for(var r=[],i=0;i<t;i++)r[i]="a["+i+"]";$p[t]=Function("C,a","return new C("+r.join(",")+")")}return $p[t](e,n)},Zp=Function.bind||function(e){var t=re(this),n=Xp.call(arguments,1),r=function(){var i=n.concat(Xp.call(arguments));return this instanceof r?Yp(t,i.length,i):t.apply(e,i)};return G(t.prototype)&&(r.prototype=t.prototype),r};Rt({target:"Function",proto:!0},{bind:Zp});var ef=Wt.findIndex,tf=!0;"findIndex"in[]&&Array(1).findIndex((function(){tf=!1})),Rt({target:"Array",proto:!0,forced:tf},{findIndex:function(e){return ef(this,e,arguments.length>1?arguments[1]:void 0)}}),Cr("findIndex");var nf=N.f,rf=function(e){return function(t){for(var n,r=H(t),i=fr(r),o=i.length,a=0,s=[];o>a;)n=i[a++],D&&!nf.call(r,n)||s.push(e?[n,r[n]]:r[n]);return s}},of=(rf(!0),rf(!1));Rt({target:"Object",stat:!0},{values:function(e){return of(e)}});var af=ut.includes;Rt({target:"Array",proto:!0},{includes:function(e){return af(this,e,arguments.length>1?arguments[1]:void 0)}}),Cr("includes"),Rt({target:"String",proto:!0,forced:!Vp("includes")},{includes:function(e){return!!~Di(B(this)).indexOf(Di(Op(e)),arguments.length>1?arguments[1]:void 0)}});var sf="DISCONNECTED",cf="CONNECTING",uf="RECONNECTING",lf="CONNECTED",df={CLINET_BANNED:9,CHANNEL_SETUP_RESULT:19,CHANNEL_RECONNECT_RESULT:514,JOIN_ROOM_RESULT:20,PEER_JOIN:4134,PEER_LEAVE:4135,STREAM_ADDED:16,STREAM_REMOVED:18,UPLINK_NETWORK_STATS:22,UPDATE_REMOTE_MUTE_STAT:23,PUBLISH_RESULT:4098,UNPUBLISH_RESULT:4100,SUBSCRIBE_RESULT:4102,UNSUBSCRIBE_RESULT:4104,SUBSCRIBE_CHANGE_RESULT:4106,MUTE_RESULT:4108,UPDATE_OFFER_RESULT:4128,START_PUBLISH_TENCENT_CDN_RES:1286,STOP_PUBLISH_TENCENT_CDN_RES:1288,START_PUBLISH_GIVEN_CDN_RES:777,STOP_PUBLISH_GIVEN_CDN_RES:779,START_MIX_TRANSCODE_RES:781,STOP_MIX_TRANSCODE_RES:783,USER_LIST_RES:4137,SWITCH_ROLE_RES:4110},hf=[df.UPDATE_REMOTE_MUTE_STAT,df.UPLINK_NETWORK_STATS,df.USER_LIST_RES,df.MUTE_RESULT],pf={CLINET_BANNED:"client-banned",CHANNEL_SETUP_RESULT:"channel-setup-result",CHANNEL_RECONNECT_RESULT:"channel-reconnect-result",JOIN_ROOM_RESULT:"join-room-result",PEER_JOIN:"peer-join",PEER_LEAVE:"peer-leave",STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",UPLINK_NETWORK_STATS:"uplink-network-stats",UPDATE_REMOTE_MUTE_STAT:"update-remote-mute-stat",PUBLISH_RESULT:"publish-result",UNPUBLISH_RESULT:"unpublish-result",SUBSCRIBE_RESULT:"subscribe-result",SUBSCRIBE_CHANGE_RESULT:"subscribe-change-result",UNSUBSCRIBE_RESULT:"unsubscribe-result",UPDATE_OFFER_RESULT:"update-offer-result",START_PUBLISH_TENCENT_CDN_RES:"start-publish-tencent-cdn-res",STOP_PUBLISH_TENCENT_CDN_RES:"stop-publish-tencent-cdn-res",START_PUBLISH_GIVEN_CDN_RES:"start-publish-given-cdn-res",STOP_PUBLISH_GIVEN_CDN_RES:"stop-publish-given-cdn-res",START_MIX_TRANSCODE_RES:"start-mix-transcode-res",STOP_MIX_TRANSCODE_RES:"stop-mix-transcode-res",USER_LIST_RES:"user-list-res",SWITCH_ROLE_RES:"switch_role_res",MUTE_RESULT:"mute-result"},ff="unpublish",mf={INVALID_PARAMETER:4096,INVALID_OPERATION:4097,NOT_SUPPORTED:4098,DEVICE_NOT_FOUND:4099,INITIALIZE_FAILED:4100,SIGNAL_CHANNEL_SETUP_FAILED:16385,SIGNAL_CHANNEL_ERROR:16386,ICE_TRANSPORT_ERROR:16387,JOIN_ROOM_FAILED:16388,CREATE_OFFER_FAILED:16389,SIGNAL_CHANNEL_RECONNECTION_FAILED:16390,UPLINK_RECONNECTION_FAILED:16391,DOWNLINK_RECONNECTION_FAILED:16392,REMOTE_STREAM_NOT_EXIST:16400,CLIENT_BANNED:16448,SERVER_TIMEOUT:16449,SUBSCRIPTION_TIMEOUT:16450,PLAY_NOT_ALLOWED:16451,DEVICE_AUTO_RECOVER_FAILED:16452,START_PUBLISH_CDN_FAILED:16453,STOP_PUBLISH_CDN_FAILED:16454,START_MIX_TRANSCODE_FAILED:16455,STOP_MIX_TRANSCODE_FAILED:16456,NOT_SUPPORTED_H264:16457,SWITCH_ROLE_FAILED:16458,API_CALL_TIMEOUT:16459,SCHEDULE_FAILED:16460,UNKNOWN:65535},vf=function(e){l(n,e);var t=_(n);function n(e){var r,i=e.name,o=void 0===i?"RtcError":i,s=e.message,c=e.code,u=void 0===c?mf.UNKNOWN:c,l=e.extraCode,d=void 0===l?0:l,h=e.constraint;return a(this,n),(r=t.call(this,s+"".concat(h?" constraint: ".concat(h):"")+" <".concat(function(e){for(var t in mf)if(mf[t]===e)return t;return"UNKNOWN"}(u)," 0x").concat(u.toString(16),">"))).code_=u,r.extraCode_=d,r.name=o,r.message_=s,h&&(r.constraint=h),r}return c(n,[{key:"getCode",value:function(){return this.code_}},{key:"getExtraCode",value:function(){return this.extraCode_}}]),n}(m(Error)),_f=32779,gf=new Map,yf=function(e,t){var n=gf.get(e);n||(gf.set(e,[]),n=gf.get(e)),n.push(t)},Sf=function(e){var t=gf.get(e),n=[];return t?(gf.delete(e),n=t.map((function(e){return{uint32_event_id:e.eventId,uint64_date:e.timestamp,str_userid:e.remoteUserId,str_event_json:e.eventDesc}}))):n=[],n},bf=Object.prototype.hasOwnProperty;function kf(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(Wd(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(var t in e)if(bf.call(e,t))return!1;return!0}return!1}var If=/"/g,Tf=function(e,t,n,r){var i=Di(B(e)),o="<"+t;return""!==n&&(o+=" "+n+'="'+Di(r).replace(If,"&quot;")+'"'),o+">"+i+"</"+t+">"},wf=function(e){return P((function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}))};Rt({target:"String",proto:!0,forced:wf("link")},{link:function(e){return Tf(this,"a","href",e)}});var Rf="AVOID_REPEATED_CALL",Ef="INVALID_PARAMETER_TYPE",Cf="INVALID_PARAMETER_INSTANCE",xf="SIGNAL_CHANNEL_RECONNECTION_FAILED",Af="JOIN_ROOM_FAILED",Pf="INVALID_REMOTE_STREAM",Df="INVALID_OPERATION_START_PUBLISH_CDN",Lf="START_PUBLISH_CDN_FAILED",Mf="STOP_PUBLISH_CDN_FAILED",Nf="INVALID_AUDIO_VOLUME",Of="INVALID_REPLACE_TRACK",Uf="INVALID_STREAM_INITIALIZED",Vf="NOT_SUPPORTED_H264ENCODE",Ff="NOT_SUPPORTED_H264DECODE",jf="SIGNAL_RESPONSE_FAILED",Bf={AVOID_REPEATED_CALL:function(e){return"previous ".concat(e.name,"() is ongoing, please avoid repeated calls.")},INVALID_PARAMETER_REQUIRED:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value;return"'".concat(t||n.name,"' is a required param when calling ").concat(r,"(), received: ").concat(i,".")},INVALID_PARAMETER_TYPE:function(e){var t,n=e.key,r=e.rule,i=e.fnName,o=e.value,a="".concat(n||r.name);return t=Array.isArray(r.type)?r.type.join("|"):r.type,"'".concat(a,"' must be type of ").concat(t," when calling ").concat(i,"(), received type: ").concat(eh(o),".")},INVALID_PARAMETER_EMPTY:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value;return"'".concat(t||n.name,"' cannot be '").concat(i,"' when calling ").concat(r,"().")},INVALID_PARAMETER_INSTANCE:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value,o="".concat(t||n.name),a="".concat(n.instanceOf.name||n.instanceOf);return"'".concat(o,"' must be instanceof ").concat(a," when calling ").concat(r,"(), received type: ").concat(eh(i),".")},INVALID_PARAMETER_RANGE:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value;return"'".concat(t||n.name,"' must be one of ").concat(n.values.join("|")," when calling ").concat(r,"(), received: ").concat(i,".")},API_CALL_TIMEOUT:function(e){return"".concat(e.commandDesc||e.command," timeout observed.")},SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:function(e){return"SignalChannel setup failure: (errorCode: ".concat(e.errorCode,", errorMsg: ").concat(e.errorMsg," }).")},ERROR_MESSAGE:function(e){var t="".concat(e.type," failed");return e.message&&(t="".concat(t,": ").concat(e.message,".")),t},SUBSCRIPTION_TIMEOUT:"remote server does not respond to the subscription.",EXCHANGE_SDP_TIMEOUT:"exchange sdp timeout.",DOWNLINK_RECONNECTION_FAILED:"downlink reconnection failed, please check your network and re-join room.",EXCHANGE_SDP_FAILED:function(e){return"exchange sdp failed ".concat(e.errMsg,".")},UPDATE_OFFER_TIMEOUT:"update offer timeout observed.",UPLINK_RECONNECTION_FAILED:"uplink reconnection failed, please check your network and publish again.",AUDIO:function(e){return e.error.toString()+" <audio>"},VIDEO:function(e){return e.error.toString()+" <video>"},INVALID_RECORDID:"recordId must be an integer number.",INVALID_PURE_AUDIO:"pureAudioPushMode must be 1 or 2.",INVALID_STREAMID:"streamId must be a sting literal within 64 bytes, and not be empty.",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId must be a sting literal contains (a-zA-Z),(0-9), underline and hyphen, within 64 bytes, and not be empty.",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs must be a sting literal within 256 bytes, and not be empty.",INVALID_PROXY:'proxy server url must start with "wss://".',INVALID_JOIN:"duplicate join() called.",INVALID_ROOMID_STRING:function(e){return"'".concat(e,"' must be validate string when useStringRoomId is true.")},INVALID_ROOMID_INTEGER:function(e){return"'".concat(e,"' must be an integer between [1, 4294967294] when useStringRoomId is false.")},INVALID_SIGNAL_CHANNEL:"SignalChannel is not ready yet.",JOIN_ROOM_TIMEOUT:"join room timeout.",JOIN_ROOM_FAILED:function(e){var t=e.error,n=e.code;return"Failed to join room - ".concat(t," code: ").concat(n)},REJOIN_ROOM_FAILED:function(e){return"reJoin room: ".concat(e.roomId," failed, please check your network.")},INVALID_LEAVE:"please call leave() before destroy().",INVALID_PUBLISH:"please call join() before publish().",INVALID_UNPUBLISH:"stream has not been published yet.",INVALID_AUDIENCE:"no permission to publish() under live/".concat("audience",', please call switchRole("').concat("anchor",'") firstly before publish().'),INVALID_INITIALIZE:"cannot publish stream because stream is not initialized or is switching device.",INVALID_DUPLICATE_PUBLISHING:"duplicate publishing, please unpublish and then re-publish.",INVALID_SUBSCRIBE_UNDEFINED:"stream is undefined or null.",INVALID_SUBSCRIBE_LOCAL:"stream cannot be LocalStream.",INVALID_REMOTE_STREAM:"remoteStream does not exist because it has been unpublished by remote peer.",SUBSCRIBE_FAILED:function(e){return"failed to subscribe stream, reason: ".concat(e.message,".")},INVALID_ROLE:"switchRole can only be called in live mode.",INVALID_PARAMETER_SWITCH_ROLE:"role could only be set to a value as ".concat("anchor"," or ").concat("audience","."),INVALID_OPERATION_SWITCH_ROLE:"please call join() before switchRole().",SWITCH_ROLE_TIMEOUT:"switchRole timeout.",SWITCH_ROLE_FAILED:function(e){return"switchRole failed, errCode: ".concat(e.errCode," errMsg: ").concat(e.errMsg,".")},CLIENT_BANNED:function(e){return"client was banned because of "+e.reason+"."},INVALID_OPERATION_START_PUBLISH_CDN:"please call publish() before startPublishCDNStream().",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED:function(e){return"startPublishCDNStream failed, errMsg: ".concat(e.message,".")},STOP_PUBLISH_CDN_FAILED:function(e){return"stopPublishCDNStream failed, errMsg: ".concat(e.message,".")},INVALID_STREAM_ID:function(e){return"'".concat(e,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},START_MIX_TRANSCODE:"please call startMixTranscode() after join().",STOP_MIX_TRANSCODE:"please call stopMixTranscode() after startMixTranscode().",INVALID_AUDIO_VOLUME:"interval must be a number.",ENABLE_SMALL_STREAM_PUBLISHED:"Cannot enable small stream after localStream published.",DISABLE_SMALL_STREAM_PUBLISHED:"Cannot disable small stream after localStream published.",NOT_SUPPORTED_SMALL_STREAM:"your browser does not support opening small stream.",INVALID_SMALL_STREAM_PROFILE:"small stream profile is invalid.",INVALID_PARAMETER_REMOTE_STREAM:"remoteStream is invalid.",INVALID_OPERATION_CHANGE_SMALL:"cannot switch to the small stream without subscribing to the video of remoteStream.",REMOTE_NOT_PUBLISH_SMALL_STREAM:"remote peer does not publish small stream.",INVALID_SWITCH_DEVICE:"cannot switch device on current stream.",INVALID_SWITCH_DEVICE_PUBLISHING:"cannot switch device when publishing localStream.",INVALID_REPLACE_TRACK:"cannot replace track when publishing localStream.",INVALID_INITIALIZE_LOCAL_STREAM:"local stream has not initialized yet.",INVALID_ADD_TRACK_REPETITIVE:"previous addTrack is ongoing, please avoid repetitive execution.",INVALID_ADD_TRACK_REMOVING:"cannot add track when a track is removing.",INVALID_ADD_TRACK_PUBLISHING:"cannot add track when publishing localStream.",INVALID_STREAM_INITIALIZED:"your local stream haven't been initialized yet.",INVALID_ADD_TRACK_NUMBER:"a Stream has at most one audio track and one video track.",INVALID_REMOVE_AUDIO_TRACK:"remove audio track is not supported.",INVALID_REMOVE_AUDIO_ADDING:"cannot remove track when a track is adding.",INVALID_REMOVE_AUDIO_ON:"previous removeTrack is ongoing, please avoid repetitive execution.",INVALID_REMOVE_TRACK_PUBLISHING:"cannot remove track when publishing localStream.",INVALID_REMOVE_TRACK_NOT_PUBLISHING:"the track to be removed is not being publishing.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REMOVE_TRACK_NOT_PUBLISHED:function(e){return"try to replace ".concat(e.kind," track but there's no previous ").concat(e.kind," being published.")},START_MIX_TRANSCODE_FAILED:function(e){return"startMixTranscode failed, errMsg: ".concat(e.message,".")},STOP_MIX_TRANSCODE_FAILED:function(e){return"stopMixTranscode failed, errMsg: ".concat(e.message,".")},MIX_TRANSCODE_NOT_STARTED:"mixTranscode has not been started.",CANNOT_LESS_THAN_ZERO:function(e){var t=e.key,n=e.rule,r=e.fnName;return e.value,"'".concat(t||n.name,"' cannot be less than 0 when calling ").concat(r,"().")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' should be an integer between 0 and 30, excluding 0.",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' should be an integer between 1 and 8.",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' should be an integer between 32 and 192.",MIX_PARAMS_USER_Z_ORDER:function(e){return"'".concat(e,"' is required and must be between 1 and 15.")},MIX_PARAMS_NOT_SELF:"'config.mixUsers' must contain self.",MIX_PARAMS_USER_STREAM:"'config.videoWidth' and 'config.videoHeight' of output stream should be contain all mix stream.",INVALID_PLAY:"duplicate play() call observed, please stop() firstly.",INVALID_ELEMENT_ID:function(e){var t=e.key,n=e.fnName;return"'".concat(t,"' is not found in the document object when calling ").concat(n,"().")},INVALID_ELEMENT_ID_TYPE:function(e){var t=e.key,n=e.fnName,r=e.type;return"the element corresponding to '".concat(t,"' must be instanceof HTMLDivElement when calling ").concat(n,"(), received: ").concat(r,".")},INVALID_USERID:"userId cannot be all spaces.",INVALID_CREATE_STREAM_SOURCE:"LocalStream must be created by createStream() with either audio/video or audioSource/videoSource, but can not be mixed with audio/video and audioSource/videoSource.",INVALID_CREATE_STREAM_SCREEN:"screen/video cannot be both true.",INVALID_CREATE_STREAM_AUDIO:"audio/screenAudio cannot be both true.",INVALID_CREATE_STREAM_SCREEN_AUDIO:"when screen is true, screenAudio can be configured.",NOT_SUPPORTED_HTTP:"not supported in http protocol, please use https protocol.",NOT_SUPPORTED_WEBRTC:"your browser does NOT support WebRTC!",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser does not support navigator.mediaDevices.",NOT_SUPPORTED_H264ENCODE:"your device does not support H.264 encoding.",NOT_SUPPORTED_H264DECODE:"your device does not support H.264 decoding.",NOT_SUPPORTED_REPLACE_TRACK:"replaceTrack is not supported in this browser, please use switchDevice or addTrack instead.",NOT_SUPPORTED_CAPTURE:"captureScreen is not supported, please use chrome.",MICROPHONE_NOT_FOUND:"no microphone detected, please check your microphone and the configuration on TRTC.createStream.",CAMERA_NOT_FOUND:"no camera detected, please check your camera and the configuration on TRTC.createStream.",SIGNAL_RESPONSE_FAILED:function(e){return"".concat(e.signalResponse," failed, response code is ").concat(e.code," , errMsg: ").concat(e.message,".")}},Hf=Ud+"module-ErrorCode.html";function zf(e){var t=e.key,n=e.data,r=e.link,i="",o="",a="";qd(Bf[t])?i=Bf[t](n):Qd(Bf[t])&&(i=Bf[t]);var s=function(){if(window.TRTC_ERROR_INFO&&window.TRTC_ERROR_LINK)return{TRTC_ERROR_INFO:window.TRTC_ERROR_INFO,TRTC_ERROR_LINK:window.TRTC_ERROR_LINK};var e=localStorage.getItem("trtc_error_assistance");if(e){e=JSON.parse(e);var t=document.createElement("script");t.type="text/javascript",t.text=e.message,document.body.appendChild(t);var n=window.TRTC_ERROR_INFO,r=window.TRTC_ERROR_LINK;return document.body.removeChild(t),{TRTC_ERROR_INFO:n,TRTC_ERROR_LINK:r}}return{}}(),c=s.TRTC_ERROR_INFO,u=s.TRTC_ERROR_LINK;c&&c[t]&&(qd(c[t])?o=c[t](n):Qd(c[t])&&(o=c[t])),r?a=Ud+"".concat(r.className,".html#").concat(r.className===Ad?".":"").concat(r.fnName):u&&u[t]&&(a=Ud+u[t]);var l=i;return(l+=" "+o)+(o?a?"查看文档:"+a:"查看文档:"+Hf:a?"Refer to:"+a:"Refer to:"+Hf)}var Gf=new(function(){function e(){a(this,e);var t=cl(),n=t.name,r=t.version;this.roomIdMap_=new Map,this.configs_={sdkAppId:"",userId:"",version:"4.12.2",env:El,browserVersion:n+r,ua:navigator.userAgent}}return c(e,[{key:"setConfig",value:function(e){var t=e.sdkAppId,n=e.env,r=e.userId,i=e.roomId;t!==this.configs_.sdkAppId&&(this.configs_.sdkAppId=String(t)),this.configs_.env=n,this.configs_.userId=r,this.roomIdMap_.set(r,String(i))}},{key:"logEvent",value:function(e){if(!ol){var n=t(t(t({},e),this.configs_),{},{userId:e.userId||this.configs_.userId});Kd(n.code)&&(n.code="failed"===n.result?mf.UNKNOWN:0),this.sendRequest(zd(this.configs_.sdkAppId,"jssdk_event"),n)}}},{key:"logSuccessEvent",value:function(e){ol||(this.logEvent(t(t({},e),{},{result:"success",roomId:this.roomIdMap_.get(e.userId)})),this.configs_.env===El&&this.uploadEventToKibana(t(t({},e),{},{result:"success"})))}},{key:"logFailedEvent",value:function(e){if(!ol){var n=e.eventType,r=e.code,i=e.error,o=e.userId,a={roomId:this.roomIdMap_.get(o),userId:o,eventType:n,result:"failed",code:r||(i instanceof vf?i.getExtraCode()||i.getCode():mf.UNKNOWN)};this.logEvent(a),this.configs_.env===El&&this.uploadEventToKibana(t(t({},a),{},{error:i}))}}},{key:"uploadEventToKibana",value:function(e){var t="stat-".concat(e.eventType,"-").concat(e.result);"delta-join"!==e.eventType&&"delta-leave"!==e.eventType&&"delta-publish"!==e.eventType||(t="".concat(e.eventType,":").concat(e.delta)),this.uploadEvent({log:t,userId:e.userId}),"failed"===e.result&&(t="stat-".concat(e.eventType,"-").concat(e.result,"-").concat(e.code),this.uploadEvent({log:t,userId:e.userId,error:e.error}))}},{key:"uploadEvent",value:function(e){var t=e.log,n=e.userId,r=e.error,i={timestamp:ba(),sdkAppId:this.configs_.sdkAppId,userId:n||this.configs_.userId,version:this.configs_.version,log:t};r&&(i.errorInfo=r.message),this.sendRequest(zd(this.configs_.sdkAppId,xl),i)}},{key:"sendRequest",value:function(e,t){var n=this;Pp.getIsAbleToUpload()?_p.post(e,JSON.stringify(t)).catch((function(){})):setTimeout((function(){n.sendRequest(e,t)}),1e3)}}]),e}()),Wf=function(){function e(t){a(this,e),this.client_=t.client,this.sdkAppId_=t.sdkAppId,this.userId_=t.userId,this.userSig_=t.userSig,this.url_=t.url,this.backupUrl_=t.backupUrl,this.version_=t.version;var n="?sdkAppId=".concat(encodeURIComponent(this.sdkAppId_),"&userId=").concat(encodeURIComponent(this.userId_),"&userSig=").concat(encodeURIComponent(this.userSig_));this.urlWithParam_="".concat(this.url_).concat(n),this.backupUrlWithParam_="".concat(this.backupUrl_).concat(n),this.isConnected_=!1,this.isConnecting_=!1,this.socketInUse_=null,this.socket_=null,this.backupSocket_=null,this.backupTimer_=-1,this.signalInfo_={},this.currentState_=sf,this.reconnectionCount_=0,this.reconnectionTimer_=-1,this.seq_=0,this.log_=Pp.createLogger({id:"ws|"+this.userId_,userId:this.userId_,sdkAppId:this.sdkAppId_}),this.emitter_=new gp}return c(e,[{key:"connect",value:function(){var e=this;this.log_.info("connect to url: ".concat(this.urlWithParam_)),this.emitConnectionStateChanged(cf),this.socket_=new WebSocket(this.urlWithParam_),this.bindSocket(this.socket_),this.backupTimer_=setTimeout((function(){e.isConnected_||(e.log_.info("trying to connect to backupUrl"),e.tryConnectBackup())}),5e3)}},{key:"tryConnectBackup",value:function(){this.backupSocket_||(this.unbindAndCloseSocket(wl),this.log_.debug("try to connect to url: ".concat(this.backupUrlWithParam_)),this.backupSocket_=new WebSocket(this.backupUrlWithParam_),this.bindSocket(this.backupSocket_))}},{key:"bindSocket",value:function(e){e.onopen=this.onopen.bind(this),e.onclose=this.onclose.bind(this),e.onerror=this.onerror.bind(this),e.onmessage=this.onmessage.bind(this)}},{key:"unbindSocket",value:function(e){e.onopen=function(){},e.onclose=function(){},e.onerror=function(){},e.onmessage=function(){}}},{key:"unbindAndCloseSocket",value:function(e){if(e===wl){if(this.socket_){this.unbindSocket(this.socket_);try{this.socket_.close(1e3)}catch(e){}this.socket_=null}}else if(this.backupSocket_){this.unbindSocket(this.backupSocket_);try{this.backupSocket_.close(1e3)}catch(e){}this.backupSocket_=null}}},{key:"clearBackupTimer",value:function(){-1!==this.backupTimer_&&(clearTimeout(this.backupTimer_),this.backupTimer_=-1)}},{key:"clearReconnectionTimer",value:function(){-1!==this.reconnectionTimer_&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"onopen",value:function(e){if(!this.isConnected_){this.isConnected_=!0,this.isConnecting_=!1,this.clearBackupTimer(),e.target===this.socket_?(this.unbindAndCloseSocket(Rl),this.socketInUse_=this.socket_):(this.unbindAndCloseSocket(wl),this.socketInUse_=this.backupSocket_);var t=e.target.url;this.log_.info("websocket[".concat(t,"] is connected")),this.currentState_===cf?this.addSignalEvent(32791,"signal channel is connected"):this.currentState_===uf&&this.addSignalEvent(32795,"signal channel reconnect success"),this.emitConnectionStateChanged(lf),this.emitter_.emit(3)}}},{key:"onclose",value:function(e){var t=e.target.url,n=e.target===this.socketInUse_;this.log_.info("websocket[".concat(t," InUse: ").concat(n,"] is closed with code: ").concat(e.code)),e.target===this.socketInUse_&&(this.isConnected_=!1,this.emitConnectionStateChanged(sf),this.addSignalEvent(32790,"signal channel is disconnected"),e.wasClean&&1e3===e.code||(this.log_.warn("onclose code:".concat(e.code," reason:").concat(e.reason)),this.log_.warn("close current websocket and schedule a reconnect timeout"),this.socketInUse_.onclose=function(){},this.socketInUse_.close(4011),this.socket_=this.backupSocket_=this.socketInUse_=null,this.reconnect(wl)))}},{key:"onerror",value:function(e){var t=e.target.url;this.log_.error("websocket[".concat(t,"] error observed")),this.isConnected_?e.target===this.socketInUse_&&(this.isConnected_=!1,this.unbindAndCloseSocket(wl),this.unbindAndCloseSocket(Rl),this.socketInUse_=null,this.reconnect(wl)):(this.isReconnecting_||Gf.logFailedEvent({userId:this.client_.getUserId(),eventType:rd,code:mf.UNKNOWN}),e.target==this.socket_?(this.unbindAndCloseSocket(wl),this.reconnect(Rl)):(this.unbindAndCloseSocket(Rl),this.reconnect(wl))),this.isConnecting_=!1,this.isConnected_=!1}},{key:"onmessage",value:function(e){if(this.isConnected_){var t=JSON.parse(e.data),n=t.cmd,r=t.data,i=Object.values(df),o=Object.keys(df)[i.indexOf(n)],a=pf[o];if(!hf.includes(n)){var s=e.target==this.socket_?this.url_:this.backupUrl_;this.log_.debug("websocket[".concat(s,"] received message: ").concat(e.data)),this.log_.info("Received event: [ ".concat(a||"unknown cmd: "+n," ]"))}switch(n){case df.CHANNEL_SETUP_RESULT:if(0===t.code)this.signalInfo_.clientIp=r.clientIp,this.signalInfo_.signalIp=r.signalInnerIp,this.signalInfo_.tinyId=t.tinyId,r.svrTime&&function(e){ya=e-(new Date).getTime();var t=new Date;t.setTime(e),Pp.info("baseTime from server: "+t+" offset: "+ya)}(r.svrTime),this.log_.info("ChannelSetup Success"),Gf.logSuccessEvent({userId:this.userId_,eventType:rd}),this.emitter_.emit(1,{signalInfo:this.signalInfo_});else{var c=new vf({code:mf.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:t.code,message:zf({key:"SIGNAL_CHANNEL_SETUP_FAILED",data:{errorCode:t.code,errorMsg:t.message}})});this.close(),Gf.logFailedEvent({userId:this.userId_,eventType:rd,error:c}),this.emitter_.emit(4,c)}break;case df.JOIN_ROOM_RESULT:0===t.code&&(this.signalInfo_.relayIp=r.relayOuterIp,this.signalInfo_.relayInnerIp=r.relayInnerIp,this.signalInfo_.relayPort=r.relayPort,this.log_.info("signalIp:".concat(this.signalInfo_.signalIp," clientIp:").concat(this.signalInfo_.clientIp," relayIp: ").concat(this.signalInfo_.relayIp))),this.emitter_.emit(a,{data:t});break;case df.CHANNEL_RECONNECT_RESULT:0===t.code?(this.log_.warn("reconnect success"),this.stopReconnection(),Gf.logSuccessEvent({userId:this.userId_,eventType:id}),this.client_.syncUserList(),this.client_.checkConnectionsToReconnect()):(this.log_.warn("reconnect failed, ".concat(t.code," ").concat(t.message)),this.client_.reJoin());break;default:this.emitter_.emit(a,{data:t})}}}},{key:"addSignalEvent",value:function(e,t){yf(this.userId_,{eventId:e,eventDesc:t,timestamp:Sa(),userId:this.userId_,tinyId:this.signalInfo_.tinyId})}},{key:"reconnect",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:wl;if(this.isConnecting_||-1!==this.reconnectionTimer_)this.log_.info("signal channel is reconnecting, ignoring current reconnection");else{if(this.reconnectionCount_>=30){this.log_.warn("SDK has tried reconnect signal channel for ".concat(30," times, but all failed. please check your network"));var n=new vf({code:mf.SIGNAL_CHANNEL_RECONNECTION_FAILED,message:zf({key:xf})});return Gf.logFailedEvent({userId:this.client_.getUserId(),eventType:id,error:n}),this.addSignalEvent(32796,"signal channel reconnect fail"),void this.emitter_.emit(4,n)}this.isConnecting_=!0,this.reconnectionCount_++,this.currentState_!==uf&&(this.emitConnectionStateChanged(uf),this.addSignalEvent(32794,"signal channel is reconnecting")),this.log_.warn("reconnecting to ".concat(t," signal channel [").concat(this.reconnectionCount_,"/").concat(30,"]"));var r=this.getReconnectionUrl(t);t===wl?(this.socket_=new WebSocket(r),this.bindSocket(this.socket_)):(this.backupSocket_=new WebSocket(r),this.bindSocket(this.backupSocket_));var i=Jd(this.reconnectionCount_);this.reconnectionTimer_=setTimeout((function(){e.log_.warn("reconnect ".concat(t," signal channel timeout(").concat(i/1e3,"s), close and try again")),e.isConnecting_=!1,e.clearReconnectionTimer(),e.unbindAndCloseSocket(t),e.reconnect(t===wl?Rl:wl)}),i)}}},{key:"isConnected",value:function(){return this.isConnected_}},{key:"isReconnecting_",get:function(){return-1!==this.reconnectionTimer_}},{key:"getReconnectionUrl",value:function(e){var t=e===wl?this.urlWithParam_:this.backupUrlWithParam_;if(!kf(this.signalInfo_)&&-1===t.indexOf("&rc=1")){var n=this.client_.getRoomId(),r=this.client_.getUseStringRoomId();t+="&rc=1&relayInnerIp=".concat(this.signalInfo_.relayInnerIp,"&relayOuterIp=").concat(this.signalInfo_.relayIp,"&relayPort=").concat(this.signalInfo_.relayPort,"&roomId=").concat(n,"&useStringRoomId=").concat(r)}return t}},{key:"send",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.isConnected_){var n={cmd:e,data:t,userId:this.userId_,tinyId:this.signalInfo_.tinyId,seq:++this.seq_};return this.socketInUse_.send(JSON.stringify(n)),n.seq}}},{key:"sendWaitForResponse",value:function(e){var t=this,n=e.command,r=e.data,i=e.timeout,o=void 0===i?5e3:i,a=e.responseCommand,s=e.commandDesc;return new Promise((function(e,i){var c=setTimeout((function(){t.off(a,u);var e=new vf({code:mf.API_CALL_TIMEOUT,message:zf({key:"API_CALL_TIMEOUT",data:{commandDesc:s,command:n}})});t.log_.warn(e),i(e)}),o),u=function n(r){r.data.seq===l&&(clearTimeout(c),t.off(a,n),e(r))};t.on(a,u);var l=t.send(n,r)}))}},{key:"sendWaitForResponseWithRetry",value:function(){var e=this,t=arguments.length<=0?void 0:arguments[0],n=t.commandDesc,r=t.retries,i=void 0===r?0:r,o=t.retryTimeout,a=void 0===o?0:o;return Cp({retryFunction:this.sendWaitForResponse,onRetrying:function(t){e.log_.warn("".concat(n," timeout observed, retrying [").concat(t,"/").concat(i,"]"))},settings:{retries:i,timeout:a},context:this}).apply(void 0,arguments)}},{key:"getCurrentState",value:function(){return this.currentState_}},{key:"getSignalInfo",value:function(){return this.signalInfo_}},{key:"stopReconnection",value:function(){this.isReconnecting_&&(this.reconnectionCount_=0,this.clearReconnectionTimer())}},{key:"close",value:function(){this.log_.info("close SignalChannel"),this.clearBackupTimer(),this.stopReconnection(),this.isConnecting_=!1,this.isConnected_=!1,this.socketInUse_=null,this.unbindAndCloseSocket(wl),this.unbindAndCloseSocket(Rl),this.emitConnectionStateChanged(sf)}},{key:"on",value:function(e,t,n){this.emitter_.on(e,t,n)}},{key:"removeListener",value:function(e,t,n){this.emitter_.removeListener(e,t,n)}},{key:"once",value:function(e,t,n){this.emitter_.once(e,t,n)}},{key:"off",value:function(e,t,n){this.emitter_.off(e,t,n)}},{key:"emitConnectionStateChanged",value:function(e){e!==this.currentState_&&(this.emitter_.emit(2,{prevState:this.currentState_,state:e}),this.currentState_=e)}}]),e}(),Jf=Wt.find,qf=!0;"find"in[]&&Array(1).find((function(){qf=!1})),Rt({target:"Array",proto:!0,forced:qf},{find:function(e){return Jf(this,e,arguments.length>1?arguments[1]:void 0)}}),Cr("find"),ki("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Ai);var Kf=R((function(e){var t=e.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 null!=e.address?"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 null!=e.subtype?"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 null!=e.sessionConfig?"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+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),(t+=null!=e["network-id"]?" network-id %d":"%v")+(null!=e["network-cost"]?" network-cost %d":"%v")}},{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 null!=e.attribute&&(t+=" %s",null!=e.value&&(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 null!=e.maxMessageSize?"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"+(null!=e.clksrcExt?"=%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+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",(t+=null!=e.rateNumerator?" rate=%s":"")+(null!=e.rateDenominator?"/%s":"")}},{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"]}]};Object.keys(t).forEach((function(e){t[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))})),Qf=(Kf.v,Kf.o,Kf.s,Kf.i,Kf.u,Kf.e,Kf.p,Kf.z,Kf.r,Kf.t,Kf.c,Kf.b,Kf.m,Kf.a,R((function(e,t){var n=function(e){return String(Number(e))===e?Number(e):e},r=function(e,t,r){var i=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:i&&!t[e.name]&&(t[e.name]={});var o=e.push?{}:i?t[e.name]:t;!function(e,t,r,i){if(i&&!r)t[i]=n(e[1]);else for(var o=0;o<r.length;o+=1)null!=e[o+1]&&(t[r[o]]=n(e[o+1]))}(r.match(e.reg),o,e.names,e.name),e.push&&t[e.push].push(o)},i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);t.parse=function(e){var t={},n=[],o=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(n.push({rtp:[],fmtp:[]}),o=n[n.length-1]);for(var a=0;a<(Kf[t]||[]).length;a+=1){var s=Kf[t][a];if(s.reg.test(i))return r(s,o,i)}})),t.media=n,t};var o=function(e,t){var r=t.split(/=(.+)/,2);return 2===r.length?e[r[0]]=n(r[1]):1===r.length&&t.length>1&&(e[r[0]]=void 0),e};t.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(e){return e.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(e){for(var t=[],r=e.split(" ").map(n),i=0;i<r.length;i+=3)t.push({component:r[i],ip:r[i+1],port:r[i+2]});return t},t.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})}))},t.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var t,r=!1;return"~"!==e[0]?t=n(e):(t=n(e.substring(1,e.length)),r=!0),{scid:t,paused:r}}))}))}}))),Xf=(Qf.parse,Qf.parseParams,Qf.parseFmtpConfig,Qf.parsePayloads,Qf.parseRemoteCandidates,Qf.parseImageAttributes,Qf.parseSimulcastStreamList,/%[sdv%]/g),$f=function(e){var t=1,n=arguments,r=n.length;return e.replace(Xf,(function(e){if(t>=r)return e;var i=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},Yf=function(e,t,n){var r=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var o=t.names[i];t.name?r.push(n[t.name][o]):r.push(n[t.names[i]])}else r.push(n[t.name]);return $f.apply(null,r)},Zf=["v","o","s","i","u","e","p","c","b","t","r","z","a"],em=["i","c","b","a"],tm={write:function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var n=t.outerOrder||Zf,r=t.innerOrder||em,i=[];return n.forEach((function(t){Kf[t].forEach((function(n){n.name in e&&null!=e[n.name]?i.push(Yf(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){i.push(Yf(t,n,e))}))}))})),e.media.forEach((function(e){i.push(Yf("m",Kf.m[0],e)),r.forEach((function(t){Kf[t].forEach((function(n){n.name in e&&null!=e[n.name]?i.push(Yf(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){i.push(Yf(t,n,e))}))}))}))})),i.join("\r\n")+"\r\n"},parse:Qf.parse,parseParams:Qf.parseParams,parseFmtpConfig:Qf.parseFmtpConfig,parsePayloads:Qf.parsePayloads,parseRemoteCandidates:Qf.parseRemoteCandidates,parseImageAttributes:Qf.parseImageAttributes,parseSimulcastStreamList:Qf.parseSimulcastStreamList},nm=function(e){return tm.parse(e)},rm=function(e){return tm.write(e)},im=function(e){var t=nm(e);return t.media.forEach((function(e){e.type===ll&&e.fmtp.forEach((function(e){e.config+=";sprop-stereo=1;stereo=1"}))})),rm(t)};function om(e){var t=nm(e);return t.media.forEach((function(e){if(e.type===dl){var t=new Set;e.rtp.forEach((function(e){var n=e.payload;return"H264"===e.codec&&t.add(n)})),e.fmtp.forEach((function(e){var n=e.payload,r=e.config.match(/apt=(\d+)/);r&&r[1]&&t.has(Number(r[1]))&&t.add(n)}));var n=function(e){var n=e.payload;return!t.has(n)};e.rtp=e.rtp.filter(n),e.rtcpFb=e.rtcpFb.filter(n),e.fmtp=e.fmtp.filter(n),e.payloads=e.payloads.split(" ").filter((function(e){return!t.has(Number(e))})).join(" ")}})),rm(t)}var am,sm=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},cm=new(function(){function e(){a(this,e),this.intervalMap_=new Map}return c(e,[{key:"setInterval",value:function(e){function t(t,n){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e,t){var n=this,r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!window||!window.requestAnimationFrame)return setInterval(e,t);var i=sm(),o=nh(),a=o;this.intervalMap_.set(i,{rafId:null,timeoutId:null,onVisibilityChange:null});var s=function s(){if(r&&document.hidden){if(e(),!n.intervalMap_.has(i))return;var c=setTimeout(s,t);n.setTimeoutId(i,c),o=nh(),a=o}else{if((a=nh())-o>=t&&(o=a,e(),!n.intervalMap_.has(i)))return;var u=requestAnimationFrame(s);n.setRafId(i,u)}},c=requestAnimationFrame(s);if(this.setRafId(i,c),r){var u=function(){if(document.hidden){var e=nh()-o;if(e>=t)s();else{var r=setTimeout(s,t-e);n.setTimeoutId(i,r)}}};document.addEventListener("visibilitychange",u),this.setOnVisibilityChange(i,u),document.hidden&&u()}return i}))},{key:"clearInterval",value:function(e){if(this.intervalMap_.has(e)){var t=this.intervalMap_.get(e),n=t.rafId,r=t.timeoutId,i=t.onVisibilityChange;cancelAnimationFrame(n),clearTimeout(r),document.removeEventListener("visibilitychange",i),this.intervalMap_.delete(e)}}},{key:"setTimeoutId",value:function(e,t){if(this.intervalMap_.has(e)){var n=this.intervalMap_.get(e);n.timeoutId&&clearTimeout(n.timeoutId),n.timeoutId=t}}},{key:"setRafId",value:function(e,t){if(this.intervalMap_.has(e)){var n=this.intervalMap_.get(e);n.rafId&&cancelAnimationFrame(n.rafId),n.rafId=t}}},{key:"setOnVisibilityChange",value:function(e,t){this.intervalMap_.has(e)&&(this.intervalMap_.get(e).onVisibilityChange=t)}}]),e}()),um=new(function(){function e(){a(this,e),this.prefix_="TRTC",this.queue_=new Map,this.intervalId_=cm.setInterval(this.doFlush.bind(this),2e4),this.checkStorage()}return c(e,[{key:"getRealKey",value:function(e){return"".concat(this.prefix_,"_").concat(e)}},{key:"checkStorage",value:function(){var e=this;al()&&Object.keys(localStorage).filter((function(t){if(t.startsWith(e.prefix_)){var n=JSON.parse(localStorage.getItem(t));if(n&&n.expiresIn<Date.now())return!0}return!1})).forEach((function(e){return localStorage.removeItem(e)}))}},{key:"doFlush",value:function(){if(al())try{var e,t=I(this.queue_);try{for(t.s();!(e=t.n()).done;){var n=y(e.value,2),r=n[0],i=n[1];localStorage.setItem(r,JSON.stringify(i))}}catch(e){t.e(e)}finally{t.f()}}catch(e){Pp.warn(e)}}},{key:"getItem",value:function(e){if(!al())return null;try{var t=JSON.parse(localStorage.getItem(this.getRealKey(e)));return t&&t.expiresIn>=Date.now()?t.value:null}catch(e){Pp.warn(e)}}},{key:"setItem",value:function(e,t){if(al())try{var n={expiresIn:Date.now()+6048e5,value:t};this.queue_.set(this.getRealKey(e),n)}catch(e){Pp.warn(e)}}},{key:"deleteItem",value:function(e){if(!al())return!1;try{return e=this.getRealKey(e),this.queue_.delete(e),localStorage.removeItem(e),!0}catch(e){return Pp.warn(e),!1}}},{key:"clear",value:function(){if(al())try{localStorage.clear()}catch(e){Pp.warn(e)}}}]),e}()),lm={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isMediaDevicesSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}};(am=um.getItem("checkResult"))&&am.ua===navigator.userAgent&&(lm=am.checkResult,ym());var dm=function(){return!(Uu||du||pu&&fu<80||uu&&lu<56)},hm=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter((function(e){return e in window})).length>0},pm=function(){if(!navigator.mediaDevices)return!1;var e=["getUserMedia","enumerateDevices"];return e.filter((function(e){return e in navigator.mediaDevices})).length===e.length},fm=function(){var e=o(regeneratorRuntime.mark((function e(){var t,n,r,i,o,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!lm.detail.isH264EncodeSupported&&!lm.detail.isVp8EncodeSupported){e.next=2;break}return e.abrupt("return",{isH264EncodeSupported:lm.detail.isH264EncodeSupported,isVp8EncodeSupported:lm.detail.isVp8EncodeSupported});case 2:return t="",n=!1,r=!1,e.prev=5,i=new RTCPeerConnection,(o=document.createElement("canvas")).getContext("2d"),a=o.captureStream(0),i.addTrack(a.getVideoTracks()[0],a),e.next=13,i.createOffer();case 13:return-1!==(t=e.sent).sdp.toLowerCase().indexOf("h264")&&(n=!0),-1!==t.sdp.toLowerCase().indexOf("vp8")&&(r=!0),i.close(),lm.detail.isH264EncodeSupported=n,lm.detail.isVp8EncodeSupported=r,e.abrupt("return",{isH264EncodeSupported:lm.detail.isH264EncodeSupported,isVp8EncodeSupported:lm.detail.isVp8EncodeSupported});case 22:return e.prev=22,e.t0=e.catch(5),e.abrupt("return",{isH264EncodeSupported:!1,isVp8EncodeSupported:!1});case 25:case"end":return e.stop()}}),e,null,[[5,22]])})));return function(){return e.apply(this,arguments)}}();function mm(){return vm.apply(this,arguments)}function vm(){return(vm=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(){var e=o(regeneratorRuntime.mark((function e(t){var n,r,i,a,s,c,u,l,d,h,p,f,m,v;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={encode:!1,decode:!1},r=null,e.prev=2,i=document.createElement("canvas"),a=i.getContext("2d"),i.width=640,i.height=480,s=setInterval((function(){a.fillText("test",Math.floor(640*Math.random()),Math.floor(480*Math.random()))}),33),c=-1,u=-1,r=function(){clearInterval(c),clearInterval(s),clearTimeout(u),d.close(),h.close(),l.getTracks().forEach((function(e){return e.stop()}))},u=setTimeout((function(){r(),t(n)}),3e3),l=i.captureStream(),d=new RTCPeerConnection({}),h=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),d.addEventListener("icecandidate",(function(e){return h.addIceCandidate(e.candidate)})),h.addEventListener("icecandidate",(function(e){return d.addIceCandidate(e.candidate)})),d.addTrack(l.getVideoTracks()[0],l),e.next=20,d.createOffer();case 20:return p=e.sent,e.next=23,d.setLocalDescription(p);case 23:return e.next=25,h.setRemoteDescription(p);case 25:return e.next=27,h.createAnswer();case 27:return f=e.sent,m=nm(f.sdp),v=m.media[0].rtp.findIndex((function(e){return"H264"===e.codec})),m.media[0].rtp=[m.media[0].rtp[v]],m.media[0].fmtp=m.media[0].fmtp.filter((function(e){return e.payload===m.media[0].rtp[0].payload})),m.media[0].rtcpFb=m.media[0].rtcpFb.filter((function(e){return e.payload===m.media[0].rtp[0].payload})),f.sdp=rm(m),e.next=36,h.setLocalDescription(f);case 36:return e.next=38,d.setRemoteDescription(f);case 38:c=setInterval(o(regeneratorRuntime.mark((function e(){var i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.encode&&n.decode&&(r(),t(n)),e.next=3,d.getStats();case 3:return i=e.sent,e.next=6,h.getStats();case 6:o=e.sent,n.encode||i.forEach((function(e){"outbound-rtp"===e.type&&e.mediaType===dl&&e.framesEncoded>0&&(n.encode=!0)})),n.decode||o.forEach((function(e){"inbound-rtp"===e.type&&e.mediaType===dl&&e.framesDecoded>0&&(n.decode=!0)}));case 9:case"end":return e.stop()}}),e)}))),500),e.next=46;break;case 41:e.prev=41,e.t0=e.catch(2),r(),Pp.warn(e.t0),t(n);case 46:case"end":return e.stop()}}),e,null,[[2,41]])})));return function(t){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var _m=function(){var e=o(regeneratorRuntime.mark((function e(){var t,n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!lm.detail.isH264DecodeSupported&&!lm.detail.isVp8DecodeSupported){e.next=2;break}return e.abrupt("return",{isH264DecodeSupported:lm.detail.isH264DecodeSupported,isVp8DecodeSupported:lm.detail.isVp8DecodeSupported});case 2:return t="",n=!1,r=!1,e.prev=5,i=new RTCPeerConnection,e.next=9,i.createOffer({offerToReceiveAudio:1,offerToReceiveVideo:1});case 9:return-1!==(t=e.sent).sdp.toLowerCase().indexOf("h264")&&(n=!0),-1!==t.sdp.toLowerCase().indexOf("vp8")&&(r=!0),i.close(),e.abrupt("return",{isH264DecodeSupported:n,isVp8DecodeSupported:r});case 16:return e.prev=16,e.t0=e.catch(5),e.abrupt("return",{isH264DecodeSupported:!1,isVp8DecodeSupported:!1});case 19:case"end":return e.stop()}}),e,null,[[5,16]])})));return function(){return e.apply(this,arguments)}}(),gm=function(e,t){var n=null;return function(){if(n)return n;for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return(n=e.apply(this,r)).then((function(e){return n=null,e})).catch((function(e){throw n=null,e})),n}}(function(){var e=o(regeneratorRuntime.mark((function e(){var t,n,r,i,o,a,s,c,u,l,d,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!lm.result){e.next=2;break}return e.abrupt("return",lm);case 2:return t=dm(),n=hm(),r=pm(),e.next=7,fm();case 7:return i=e.sent,o=i.isH264EncodeSupported,a=i.isVp8EncodeSupported,e.next=12,_m();case 12:if(s=e.sent,c=s.isH264DecodeSupported,u=s.isVp8DecodeSupported,!(o&&c&&(Wu||qu||nl)&&!yu&&Qu()<79)){e.next=23;break}return e.next=18,mm();case 18:l=e.sent,d=l.encode,h=l.decode,o=d,c=h;case 23:return lm.result=t&&n&&r&&(o||a)&&(c||u),lm.detail.isBrowserSupported=t,lm.detail.isWebRTCSupported=n,lm.detail.isMediaDevicesSupported=r,lm.detail.isH264EncodeSupported=o,lm.detail.isVp8EncodeSupported=a,lm.detail.isH264DecodeSupported=c,lm.detail.isVp8DecodeSupported=u,ym(),um.setItem("checkResult",{ua:navigator.userAgent,checkResult:lm}),e.abrupt("return",lm);case 34:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}());function ym(){Object.keys(lm.detail).findIndex((function(e){return!lm.detail[e]}))>=0&&Pp.error("".concat(navigator.userAgent," ").concat(JSON.stringify(lm.detail)))}var Sm=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},bm=function(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype},km=function(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype},Im=function(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype},Tm=function(){return"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype&&km()},wm=function(){return!!Kd(navigator.mediaDevices)&&(Pp.error(Bf.NOT_SUPPORTED_MEDIA),!0)},Rm=function(){return"http:"===location.protocol&&!ol&&(Pp.error(Bf.NOT_SUPPORTED_HTTP),!0)},Em=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state||$d(e.selected)&&!e.selected)},Cm=new Map([[cu,"Android"],[su,"iOS"],[Mu,"Windows"],[Nu,"MacOS"],[Ou,"Linux"]]),xm=function(){var e="unknown";return Cm.get(!0)&&(e=Cm.get(!0)),e};function Am(){var e="";return screen.width&&(e+=(screen.width?screen.width*window.devicePixelRatio:"")+" * "+(screen.height?screen.height*window.devicePixelRatio:"")),e}function Pm(){var e=!1;return(navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)&&(e=!0),e}function Dm(){for(var e={isSupported:!1},t=["AudioContext","webkitAudioContext","mozAudioContext","msAudioContext"],n=0;n<t.length;n++)if(t[n]in window){e.isSupported=!0;break}return e.isSupported}function Lm(){return!Iu&&!su&&!(!dm()||!("captureStream"in HTMLCanvasElement.prototype))}var Mm="getSettings"in MediaStreamTrack.prototype,Nm="getCapabilities"in MediaStreamTrack.prototype;gm();var Om="stream-added",Um="stream-removed",Vm="stream-updated",Fm="stream-subscribed",jm="error",Bm="connection-state-changed",Hm="stream-added",zm="peer-join",Gm="mute-audio",Wm="mute-video",Jm="unmute-audio",qm="unmute-video",Km="network-quality",Qm="audio-volume",Xm="error",$m="player-state-changed",Ym="error",Zm="player-state-changed",ev=function(){function e(t){a(this,e);var n=t.getUserId();this.log_=Pp.createLogger({id:n,userId:n,sdkAppId:t.getSDKAppId()}),this.prevReport_={},this.prevEncoderImplementation_="",this.prevQualityLimitationReason_="",this.prevDecoderImplementationMap_=new Map}var t,n,r,i;return c(e,[{key:"getSenderStats",value:(i=o(regeneratorRuntime.mark((function e(t){var n,r,i,o=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={audio:{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0},video:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0,smallFramesEncoded:0,smallFPSCapture:0,smallFramesSent:0},rtt:0},r=t.getPeerConnection(),i=t.getSSRC(),!r){e.next=14;break}return e.prev=4,e.next=7,r.getStats();case 7:e.sent.forEach((function(e){if("outbound-rtp"===e.type)if(e.mediaType===dl){if(!uu&&Kd(e.trackId))return;e.ssrc!==i.video||Kd(e.encoderImplementation)||o.prevEncoderImplementation_===e.encoderImplementation||(o.log_.info("encoderImplementation change to ".concat(e.encoderImplementation)),o.prevEncoderImplementation_=e.encoderImplementation),e.ssrc!==i.video||Kd(e.qualityLimitationReason)||o.prevQualityLimitationReason_===e.qualityLimitationReason||(o.log_.info("qualityLimitationReason change to ".concat(e.qualityLimitationReason)),o.prevQualityLimitationReason_=e.qualityLimitationReason);var r=t.getSSRC();e.ssrc===r.video?(n.video.bytesSent=e.bytesSent,n.video.packetsSent=e.packetsSent,n.video.framesEncoded=e.framesEncoded):(n.video.smallBytesSent=e.bytesSent,n.video.smallFramesEncoded=e.framesEncoded)}else e.mediaType===ll&&(n.audio.bytesSent=e.bytesSent,n.audio.packetsSent=e.packetsSent);else"candidate-pair"===e.type?Em(e)&&Xd(e.currentRoundTripTime)&&(n.rtt=Math.floor(1e3*e.currentRoundTripTime)):"track"===e.type?(Kd(e.frameWidth)||(e.trackIdentifier===t.getLocalStreamVideoTrackId()?(n.video.frameWidth=e.frameWidth,n.video.frameHeight=e.frameHeight,n.video.framesSent=e.framesSent):(n.video.smallFrameWidth=e.frameWidth,n.video.smallFrameHeight=e.frameHeight,n.video.smallFramesSent=e.framesSent)),Kd(e.audioLevel)||(n.audio.audioLevel=e.audioLevel||0)):"media-source"===e.type&&(e.kind===ll?(n.audio.audioLevel=e.audioLevel||0,n.audio.totalAudioEnergy=e.totalAudioEnergy||0):e.kind===dl&&(e.trackIdentifier===t.getLocalStreamVideoTrackId()?n.video.fpsCapture=e.framesPerSecond:n.video.smallFPSCapture=e.framesPerSecond))})),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(4),this.log_.warn("failed to getStats on sender connection");case 14:return e.abrupt("return",n);case 15:case"end":return e.stop()}}),e,this,[[4,11]])}))),function(e){return i.apply(this,arguments)})},{key:"getReceiverStats",value:(r=o(regeneratorRuntime.mark((function e(t){var n,r,i=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={tinyId:t.getTinyId(),userId:t.getUserId(),rtt:0,hasAudio:!1,hasVideo:!1,hasAuxiliary:!1,audio:{bytesReceived:0,packetsReceived:0,packetsLost:0,jitter:0,audioLevel:0,totalAudioEnergy:0},video:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0},auxiliary:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0}},!(r=t.getPeerConnection())){e.next=13;break}return e.prev=3,e.next=6,r.getStats();case 6:e.sent.forEach((function(e){if("inbound-rtp"===e.type){if(e.mediaType===ll)n.audio.packetsReceived=e.packetsReceived,n.audio.bytesReceived=e.bytesReceived,n.audio.packetsLost=e.packetsLost,n.audio.jitter=e.jitter,n.hasAudio=!0;else if(e.mediaType===dl){if(uu&&0===e.bytesReceived)return;var r=t.getSSRC();e.ssrc===r.video&&(n.video.packetsReceived=e.packetsReceived,n.video.bytesReceived=e.bytesReceived,n.video.packetsLost=e.packetsLost,n.video.framesReceived=e.framesReceived,n.video.framesDecoded=e.framesDecoded,n.video.fpsDecoded=e.framesPerSecond,n.hasVideo=!0,!e.decoderImplementation||i.prevDecoderImplementationMap_.has(n.userId)&&i.prevDecoderImplementationMap_.get(n.userId)===e.decoderImplementation||(Pp.info("[".concat(n.userId,"] decoderImplementation change to ").concat(e.decoderImplementation)),i.prevDecoderImplementationMap_.set(n.userId,e.decoderImplementation))),e.ssrc===r.auxiliary&&(n.auxiliary.packetsReceived=e.packetsReceived,n.auxiliary.bytesReceived=e.bytesReceived,n.auxiliary.packetsLost=e.packetsLost,n.auxiliary.framesReceived=e.framesReceived,n.auxiliary.framesDecoded=e.framesDecoded,n.auxiliary.fpsDecoded=e.framesPerSecond,n.hasAuxiliary=!0)}}else"track"===e.type?(Kd(e.frameWidth)||(e.trackIdentifier===t.getMainStreamVideoTrackId()&&(n.video.frameWidth=e.frameWidth,n.video.frameHeight=e.frameHeight),e.trackIdentifier===t.getAuxStreamVideoTrackId()&&(n.auxiliary.frameWidth=e.frameWidth,n.auxiliary.frameHeight=e.frameHeight)),e.kind===ll&&(n.audio.audioLevel=e.audioLevel||0,n.audio.totalAudioEnergy=e.totalAudioEnergy||0)):"candidate-pair"===e.type&&Em(e)&&Xd(e.currentRoundTripTime)&&(n.rtt=Math.floor(1e3*e.currentRoundTripTime))})),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(3),this.log_.warn("failed to getStats on receiver connection");case 13:return e.abrupt("return",n);case 14:case"end":return e.stop()}}),e,this,[[3,10]])}))),function(e){return r.apply(this,arguments)})},{key:"getStats",value:(n=o(regeneratorRuntime.mark((function e(t,n){var r,i,o,a,s,c,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r={},!t){e.next=5;break}return e.next=4,this.getSenderStats(t);case 4:r=e.sent;case 5:i=[],o=I(n),e.prev=7,o.s();case 9:if((a=o.n()).done){e.next=17;break}return(s=y(a.value,2))[0],c=s[1],e.next=13,this.getReceiverStats(c);case 13:u=e.sent,i.push(u);case 15:e.next=9;break;case 17:e.next=22;break;case 19:e.prev=19,e.t0=e.catch(7),o.e(e.t0);case 22:return e.prev=22,o.f(),e.finish(22);case 25:return e.abrupt("return",{senderStats:r,receiverStats:i});case 26:case"end":return e.stop()}}),e,this,[[7,19,22,25]])}))),function(e,t){return n.apply(this,arguments)})},{key:"getDifferenceValue",value:function(e,t){if(kf(e))return t;var n=t-e;return n<0?0:n}},{key:"prepareReport",value:function(e){var t=this,n=e.stats,r=e.report,i=e.freezeMap;if(!kf(n.senderStats)){var o={uint32_audio_level:1e8*n.senderStats.audio.audioLevel,uint32_audio_energy:1e6*n.senderStats.audio.totalAudioEnergy,uint32_audio_codec_bitrate:n.senderStats.audio.bytesSent,audioLevel:n.senderStats.audio.audioLevel},a=[],s={uint32_video_stream_type:2,uint32_video_codec_fps:n.senderStats.video.framesSent,uint32_video_capture_fps:n.senderStats.video.fpsCapture,uint32_video_width:n.senderStats.video.frameWidth,uint32_video_height:n.senderStats.video.frameHeight,uint32_video_codec_bitrate:n.senderStats.video.bytesSent,uint32_video_enc_fps:n.senderStats.video.framesEncoded};if(a.push(s),n.senderStats.video.smallBytesSent){var c={uint32_video_stream_type:3,uint32_video_codec_fps:n.senderStats.video.smallFramesSent||0,uint32_video_capture_fps:n.senderStats.video.smallFPSCapture||0,uint32_video_width:n.senderStats.video.smallFrameWidth||0,uint32_video_height:n.senderStats.video.smallFrameHeight||0,uint32_video_codec_bitrate:n.senderStats.video.smallBytesSent,uint32_video_enc_fps:n.senderStats.video.smallFramesEncoded||0};a.push(c)}var u={uint32_bitrate:"",uint32_rtt:n.senderStats.rtt};r.msg_up_stream_info={msg_audio_status:o,msg_video_status:a,msg_network_status:u}}r.msg_down_stream_info=[],n.receiverStats.forEach((function(e){var t={};if(t.msg_user_info={str_identifier:e.userId,uint64_tinyid:e.tinyId},t.msg_network_status={uint32_rtt:e.rtt},t.msg_video_status={},e.hasAudio){var n={uint32_audio_codec_bitrate:e.audio.bytesReceived,uint32_audio_total_bitrate:e.audio.bytesReceived,uint32_audio_level:1e8*e.audio.audioLevel,uint32_audio_energy:1e6*e.audio.totalAudioEnergy,uint32_audio_receive:e.audio.packetsReceived,uint32_audio_origin_lost:e.audio.packetsLost,audioLevel:e.audio.audioLevel};t.msg_audio_status=n}if(t.msg_video_status=[],e.hasVideo){var o=i.get(e.userId+"_"+Ll),a=o?o.duration:0,s={uint32_video_stream_type:2,uint32_video_receive_fps:e.video.framesReceived,uint32_video_width:e.video.frameWidth,uint32_video_height:e.video.frameHeight,uint32_video_codec_bitrate:e.video.bytesReceived,uint32_video_receive:e.video.packetsReceived,uint32_video_origin_lost:e.video.packetsLost,uint32_video_block_time:a,uint32_video_dec_fps:e.video.fpsDecoded};t.msg_video_status.push(s)}if(e.hasAuxiliary){var c=i.get(e.userId+"_"+Ml),u=c?c.duration:0,l={uint32_video_stream_type:7,uint32_video_receive_fps:e.auxiliary.framesReceived,uint32_video_width:e.auxiliary.frameWidth,uint32_video_height:e.auxiliary.frameHeight,uint32_video_codec_bitrate:e.auxiliary.bytesReceived,uint32_video_receive:e.auxiliary.packetsReceived+e.auxiliary.packetsLost,uint32_video_origin_lost:e.auxiliary.packetsLost,uint32_video_block_time:u,uint32_video_dec_fps:e.auxiliary.fpsDecoded};t.msg_video_status.push(l)}r.msg_down_stream_info.push(t)}));var l=this.prevReport_;this.prevReport_=JSON.parse(JSON.stringify(r));var d=l.msg_up_stream_info.msg_audio_status,h=r.msg_up_stream_info.msg_audio_status,p=this.getDifferenceValue(d.uint32_audio_codec_bitrate,h.uint32_audio_codec_bitrate);h.uint32_audio_codec_bitrate=8*p/2;var f=l.msg_up_stream_info.msg_video_status;r.msg_up_stream_info.msg_video_status.forEach((function(e,n){var r=f[n],i=0,o=0,a=0;r&&(i=r.uint32_video_codec_bitrate,o=r.uint32_video_enc_fps,a=r.uint32_video_codec_fps);var s=t.getDifferenceValue(i,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=8*s/2,e.uint32_video_enc_fps=t.getDifferenceValue(o,e.uint32_video_enc_fps)/2,e.uint32_video_codec_fps=t.getDifferenceValue(a,e.uint32_video_codec_fps)/2}));var m=r.msg_down_stream_info,v=l.msg_down_stream_info;return m.forEach((function(e){var n=v.find((function(t){return t.msg_user_info.uint64_tinyid===e.msg_user_info.uint64_tinyid}));if(n){if(e.msg_audio_status&&n.msg_audio_status){var r=e.msg_audio_status,i=n.msg_audio_status;r.uint32_audio_origin_lost=t.getDifferenceValue(i.uint32_audio_origin_lost,r.uint32_audio_origin_lost),r.uint32_audio_receive=t.getDifferenceValue(i.uint32_audio_receive,r.uint32_audio_receive),r.uint32_audio_receive+=r.uint32_audio_origin_lost;var o=t.getDifferenceValue(i.uint32_audio_codec_bitrate,r.uint32_audio_codec_bitrate);r.uint32_audio_codec_bitrate=8*o/2,r.uint32_audio_total_bitrate=8*o/2}if(e.msg_video_status&&n.msg_video_status){var a=e.msg_video_status,s=n.msg_video_status;a.forEach((function(e,n){var r=s[n],i=0,o=0,a=0,c=0;r&&(i=r.uint32_video_receive,o=r.uint32_video_origin_lost,a=r.uint32_video_codec_bitrate,c=r.uint32_video_receive_fps),e.uint32_video_origin_lost=t.getDifferenceValue(o,e.uint32_video_origin_lost),e.uint32_video_receive=t.getDifferenceValue(i,e.uint32_video_receive)+e.uint32_video_origin_lost;var u=t.getDifferenceValue(a,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=8*u/2;var l=t.getDifferenceValue(c,e.uint32_video_receive_fps);e.uint32_video_receive_fps=l/2}))}}})),r.msg_up_stream_info.msg_network_status.uint32_bitrate=r.msg_up_stream_info.msg_audio_status.uint32_audio_codec_bitrate+r.msg_up_stream_info.msg_video_status[0].uint32_video_codec_bitrate,r}},{key:"getStatsReport",value:(t=o(regeneratorRuntime.mark((function e(t){var n,r,i,o,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.uplinkConnection,r=t.downlinkConnections,i=t.freezeMap,o={msg_up_stream_info:{msg_audio_status:{uint32_audio_format:0,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_level:0,uint32_audio_energy:0,audioLevel:0},msg_video_status:[{uint32_video_stream_type:0,uint32_video_codec_fps:0,uint32_video_capture_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_bitrate:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_final_lost:0,uint32_video_enc_fps:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0},msg_qos:[{uint32_video_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_bitrate:0,uint32_audio_bitrate:0,uint32_video_stream_type:0}]},msg_down_stream_info:[{msg_user_info:{str_identifier:"",uint64_tinyid:""},msg_audio_status:{uint32_audio_format:0,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_total_bitrate:0,uint32_audio_level:0,uint32_audio_energy:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_final_lost:0,audioLevel:0},msg_video_status:[{uint32_video_stream_type:0,uint32_video_receive_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_bitrate:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_block_time:0,uint32_video_dec_fps:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0,uint32_jitter:0},msg_qos:[{uint32_video_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_bitrate:0,uint32_audio_bitrate:0,uint32_video_stream_type:0}]}]},"{}"===JSON.stringify(this.prevReport_)&&(this.prevReport_=JSON.parse(JSON.stringify(o))),e.next=5,this.getStats(n,r);case 5:return a=e.sent,this.prepareReport({stats:a,report:o,freezeMap:i}),e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}(),tv=function(){function e(t){var n=t.signalChannel,r=t.connections,i=t.client;a(this,e),this.client_=i,this.signalChannel_=n,this.connections_=r,this.client_=i,this.log_=Pp.createLogger({id:"q|"+this.client_.getUserId(),userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId()}),this.uplinkConnection_=null,this.uplinkNetworkQuality_=0,this.uplinkRTT_=0,this.uplinkLoss_=0,this.downlinkNetworkQuality_=0,this.downlinkRTT_=0,this.downlinkLoss_=0,this.downlinkPrevStatMap_=new Map,this.downlinkLossAndRTTMap_=new Map,this.interval_=-1,this.emitter_=new gp,this.initialize()}var t,n;return c(e,[{key:"uplinkNetworkQuality",get:function(){return this.uplinkNetworkQuality_},set:function(e){e!==this.uplinkNetworkQuality_&&this.log_.info("uplink network quality change ".concat(this.uplinkNetworkQuality," -> ").concat(e,", rtt: ").concat(this.uplinkRTT_,", loss: ").concat(this.uplinkLoss_)),this.uplinkNetworkQuality_=e}},{key:"downlinkNetworkQuality",get:function(){return this.downlinkNetworkQuality_},set:function(e){if(e!==this.downlinkNetworkQuality_){var t=this.getAverageLossAndRTT(S(this.downlinkLossAndRTTMap_.values())),n=t.rtt,r=t.loss;this.log_.info("downlink network quality change ".concat(this.downlinkNetworkQuality," -> ").concat(e,", rtt: ").concat(n,", loss: ").concat(r))}this.downlinkNetworkQuality_=e}},{key:"initialize",value:function(){var e=this;this.signalChannel_.on(pf.UPLINK_NETWORK_STATS,(function(t){e.handleUplinkNetworkQuality(t)})),this.signalChannel_.on(2,this.handleSignalConnectionStateChange.bind(this)),this.start()}},{key:"handleUplinkNetworkQuality",value:function(e){if(!this.uplinkConnection_)return this.uplinkNetworkQuality=0,this.uplinkLoss_=0,void(this.uplinkRTT_=0);var t=this.uplinkConnection_.getPeerConnection();if(t&&this.isPeerConnectionDisconnected(t))return this.uplinkNetworkQuality=6,this.uplinkLoss_=0,void(this.uplinkRTT_=0);if(0===e.data.code){var n=e.data.data,r=n.expectAudPkg+n.expectVidPkg,i=n.recvAudPkg+n.recvVidPkg,o=r-i,a=n.delay;if(a&&this.updateDelay(a),0===r&&0===i)return;this.uplinkLoss_=o<=0?0:Math.round(o/r*100),this.uplinkRTT_=n.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this.uplinkLoss_,this.uplinkRTT_)}}},{key:"handleDownlinkNetworkQuality",value:(n=o(regeneratorRuntime.mark((function e(){var t,n,r,i,o,a,s,c,u,l,d,h,p,f,m,v=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connections_&&0!==this.connections_.size){e.next=3;break}return this.downlinkNetworkQuality=0,e.abrupt("return");case 3:if(t=S(this.connections_.values()),n=t.filter((function(e){return e.getPeerConnection()&&e.getPeerConnection().connectionState===Hl})),t.filter((function(e){return e.getPeerConnection()&&v.isPeerConnectionDisconnected(e.getPeerConnection())})).length!==t.length){e.next=9;break}return this.downlinkNetworkQuality=6,e.abrupt("return");case 9:r=0;case 10:if(!(r<n.length)){e.next=31;break}return i=n[r].getPeerConnection(),e.next=14,this.getStat(i);case 14:if(o=e.sent,a=o.rtt,s=o.totalPacketsLost,c=o.totalPacketsReceived,this.downlinkPrevStatMap_.has(i)){e.next=21;break}return this.downlinkPrevStatMap_.set(i,{totalPacketsLost:s,totalPacketsReceived:c}),e.abrupt("continue",28);case 21:0,l=this.downlinkPrevStatMap_.get(i),d=s-l.totalPacketsLost,h=c-l.totalPacketsReceived,u=d<=0||h<0?0:Math.round(d/(d+h)*100),this.downlinkPrevStatMap_.set(i,{totalPacketsLost:s,totalPacketsReceived:c}),this.downlinkLossAndRTTMap_.set(i,{rtt:a,loss:u,userId:n[r].getUserId()});case 28:r++,e.next=10;break;case 31:if(S(this.downlinkPrevStatMap_.keys()).forEach((function(e){v.isPeerConnectionDisconnected(e)&&(v.downlinkPrevStatMap_.delete(e),v.downlinkLossAndRTTMap_.delete(e))})),0!==this.downlinkLossAndRTTMap_.size){e.next=34;break}return e.abrupt("return");case 34:p=this.getAverageLossAndRTT(S(this.downlinkLossAndRTTMap_.values())),f=p.rtt,m=p.loss,this.downlinkRTT_=f,this.downlinkLoss_=m,this.downlinkNetworkQuality=this.getNetworkQuality(m,f);case 38:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getStat",value:(t=o(regeneratorRuntime.mark((function e(t){var n,r,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={rtt:0,totalPacketsLost:0,totalPacketsReceived:0},t&&bm()){e.next=3;break}return e.abrupt("return",n);case 3:r=t.getReceivers(),e.prev=4,i=0;case 6:if(!(i<r.length)){e.next=15;break}return o=r[i],e.next=10,o.getStats();case 10:e.sent.forEach((function(e){"candidate-pair"===e.type&&Xd(e.currentRoundTripTime)&&(n.rtt=Math.round(1e3*e.currentRoundTripTime)),"inbound-rtp"!==e.type||e.mediaType!==ll&&e.mediaType!==dl||(n.totalPacketsLost+=e.packetsLost,n.totalPacketsReceived+=e.packetsReceived)}));case 12:i++,e.next=6;break;case 15:return e.abrupt("return",n);case 18:return e.prev=18,e.t0=e.catch(4),e.abrupt("return",n);case 21:case"end":return e.stop()}}),e,null,[[4,18]])}))),function(e){return t.apply(this,arguments)})},{key:"getAverageLossAndRTT",value:function(e){var t={rtt:0,loss:0};return Array.isArray(e)&&e.length>0&&(e.forEach((function(e){t.rtt+=e.rtt,t.loss+=e.loss})),Object.keys(t).forEach((function(n){t[n]=Math.round(t[n]/e.length)}))),t}},{key:"getNetworkQuality",value:function(e,t){return e>50||t>500?5:e>30||t>350?4:e>20||t>200?3:e>10||t>100?2:e>=0||t>=0?1:0}},{key:"handleSignalConnectionStateChange",value:function(e){e.state===sf?(this.uplinkRTT_=0,this.uplinkLoss_=0,this.uplinkNetworkQuality=6):e.state===lf&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}},{key:"handleUplinkConnectionStateChange",value:function(e){var t=e.state;t===Nl?(this.uplinkLoss_=0,this.uplinkRTT_=0,this.uplinkNetworkQuality=6):t===Vl&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}},{key:"isPeerConnectionDisconnected",value:function(e){return!(!e||"disconnected"!==e.connectionState&&e.connectionState!==jl&&e.connectionState!==Bl)}},{key:"setUplinkConnection",value:function(e){this.uplinkConnection_=e,this.uplinkConnection_?this.uplinkConnection_.on(Bm,this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this.uplinkRTT_=0,this.uplinkLoss_=0)}},{key:"start",value:function(){var e=this;-1===this.interval_?(this.log_.info("start network quality calculating"),this.interval_=cm.setInterval((function(){e.handleDownlinkNetworkQuality(),yp.emit(300,{client:e.client_,uplinkNetworkQuality:e.uplinkNetworkQuality,downlinkNetworkQuality:e.downlinkNetworkQuality,uplinkRTT:e.uplinkRTT_,uplinkLoss:e.uplinkLoss_,downlinkRTT:e.downlinkRTT_,downlinkLoss:e.downlinkLoss_,downlinkLossAndRTTMap:e.downlinkLossAndRTTMap_}),e.emitter_.emit(Km,{uplinkNetworkQuality:e.uplinkNetworkQuality,downlinkNetworkQuality:e.downlinkNetworkQuality,uplinkRTT:e.uplinkRTT_,uplinkLoss:e.uplinkLoss_,downlinkRTT:e.downlinkRTT_,downlinkLoss:e.downlinkLoss_})}),2e3)):this.log_.info("network quality calculating is already started")}},{key:"stop",value:function(){this.log_.info("stop network quality calculating"),-1!==this.interval_&&(cm.clearInterval(this.interval_),this.interval_=-1)}},{key:"on",value:function(e,t){this.emitter_.on(e,t)}},{key:"updateDelay",value:function(e){var t=this;e.forEach((function(e){var n=e.srcTinyId,r=e.videoDelay,i=e.audioDelay,o=t.connections_.get(n);o&&o.setDelay({videoDelay:r,audioDelay:i})}))}}]),e}(),nv=function(){function e(t){a(this,e),this.log_=Pp.createLogger({id:t.client.getUserId(),userId:t.client.getUserId(),sdkAppId:t.client.getSDKAppId()}),this.localStream_=null,this.prevDevices_=[],this.initialize()}var t,n,r;return c(e,[{key:"initialize",value:(r=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:navigator.mediaDevices&&navigator.mediaDevices.addEventListener("devicechange",this.onDeviceChange.bind(this));case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"onDeviceChange",value:(n=o(regeneratorRuntime.mark((function e(){var t,n,r,i=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.localStream_&&this.localStream_.getMediaStream()&&!this.localStream_.getScreen()){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,Wy.getDevices();case 4:t=e.sent,n=t.filter((function(e){return i.prevDevices_.findIndex((function(t){var n=t.deviceId;return e.deviceId===n}))<0})),r=this.prevDevices_.filter((function(e){return t.findIndex((function(t){var n=t.deviceId;return e.deviceId===n}))<0})),n.length>0&&this.handleDeviceAdded(this.prevDevices_,n),r.length>0&&this.handleDeviceRemoved(t,r),this.prevDevices_=t;case 10:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"setLocalStream",value:(t=o(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=4;break}return e.next=3,Wy.getDevices();case 3:this.prevDevices_=e.sent;case 4:this.localStream_=t;case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"handleDeviceAdded",value:function(e,t){this.log_.warn("devicesAdded: ".concat(JSON.stringify(t))),this.localStream_.updateDeviceIdInUse();var n=t.filter((function(e){return e.kind===Il})),r=t.filter((function(e){return e.kind===kl})),i=e.filter((function(e){return e.kind===Il})),o=e.filter((function(e){return e.kind===kl})),a=n.length>0&&0===i.length&&this.localStream_.getVideo(),s=r.length>0&&0===o.length&&this.localStream_.getAudio();if(s&&a)return this.log_.info("new microphone and camera detected, but there was no device before."),void this.localStream_.updateStream({audio:!0,video:!0,cameraId:n[0].deviceId,microphoneId:r[0].deviceId});a&&(this.log_.info("new camera detected, but there was no camera before."),this.localStream_.updateStream({audio:!1,video:!0,cameraId:n[0].deviceId})),s&&(this.log_.info("new microphone detected, but there was no microphone before."),this.localStream_.updateStream({audio:!0,video:!1,microphoneId:r[0].deviceId}))}},{key:"handleDeviceRemoved",value:function(e,t){this.log_.warn("devicesRemoved: ".concat(JSON.stringify(t))),this.localStream_.updateDeviceIdInUse();var n=!1,r=!1,i=this.localStream_.getCameraId(),o=this.localStream_.getMicrophoneId();if("default"===o){var a=this.localStream_.getMicrophoneGroupId(),s=e.filter((function(e){return"default"===e.deviceId&&e.kind===kl}))[0];s&&s.groupId!==a&&(r=!0)}if(t.forEach((function(e){var t=e.deviceId;i.length>0&&t===i?n=!0:o.length>0&&t===o&&(r=!0)})),n&&r)return this.log_.warn("current camera and microphone in use is lost, cameraId: ".concat(i,", microphoneId: ").concat(o)),void((this.localStream_.getAudio()||this.localStream_.getVideo())&&this.localStream_.updateStream({video:!0,audio:!0}));n&&(this.log_.warn("current camera in use is lost, deviceId: ".concat(i)),this.localStream_.getVideo()&&this.localStream_.updateStream({video:!0,audio:!1})),r&&(this.log_.warn("current microphone in use is lost, deviceId: ".concat(o)),this.localStream_.getAudio()&&this.localStream_.updateStream({video:!1,audio:!0}))}}]),e}(),rv=function(e){var t=Di(B(this)),n="",r=tt(e);if(r<0||1/0==r)throw RangeError("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n},iv=1..toFixed,ov=Math.floor,av=function(e,t,n){return 0===t?n:t%2==1?av(e,t-1,n*e):av(e*e,t/2,n)},sv=function(e,t,n){for(var r=-1,i=n;++r<6;)i+=t*e[r],e[r]=i%1e7,i=ov(i/1e7)},cv=function(e,t){for(var n=6,r=0;--n>=0;)r+=e[n],e[n]=ov(r/t),r=r%t*1e7},uv=function(e){for(var t=6,n="";--t>=0;)if(""!==n||0===t||0!==e[t]){var r=String(e[t]);n=""===n?r:n+rv.call("0",7-r.length)+r}return n},lv=iv&&("0.000"!==8e-5.toFixed(3)||"1"!==.9.toFixed(0)||"1.25"!==1.255.toFixed(2)||"1000000000000000128"!==(0xde0b6b3a7640080).toFixed(0))||!P((function(){iv.call({})}));Rt({target:"Number",proto:!0,forced:lv},{toFixed:function(e){var t,n,r,i,o=Ja(this),a=tt(e),s=[0,0,0,0,0,0],c="",u="0";if(a<0||a>20)throw RangeError("Incorrect fraction digits");if(o!=o)return"NaN";if(o<=-1e21||o>=1e21)return String(o);if(o<0&&(c="-",o=-o),o>1e-21)if(n=(t=function(e){for(var t=0,n=e;n>=4096;)t+=12,n/=4096;for(;n>=2;)t+=1,n/=2;return t}(o*av(2,69,1))-69)<0?o*av(2,-t,1):o/av(2,t,1),n*=4503599627370496,(t=52-t)>0){for(sv(s,0,n),r=a;r>=7;)sv(s,1e7,0),r-=7;for(sv(s,av(10,r,1),0),r=t-1;r>=23;)cv(s,1<<23),r-=23;cv(s,1<<r),sv(s,1,1),cv(s,2),u=uv(s)}else sv(s,0,n),sv(s,1<<-t,0),u=uv(s)+rv.call("0",a);return a>0?c+((i=u.length)<=a?"0."+rv.call("0",a-i)+u:u.slice(0,i-a)+"."+u.slice(i-a)):c+u}});var dv,hv=Object.assign,pv=Object.defineProperty,fv=!hv||P((function(){if(D&&1!==hv({b:1},hv(pv({},"a",{enumerable:!0,get:function(){pv(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol();return e[n]=7,"abcdefghijklmnopqrst".split("").forEach((function(e){t[e]=e})),7!=hv({},e)[n]||"abcdefghijklmnopqrst"!=fr(hv({},t)).join("")}))?function(e,t){for(var n=ce(e),r=arguments.length,i=1,o=mt.f,a=N.f;r>i;)for(var s,c=j(arguments[i++]),u=o?fr(c).concat(o(c)):fr(c),l=u.length,d=0;l>d;)s=u[d++],D&&!a.call(c,s)||(n[s]=c[s]);return n}:hv,mv=function(e,t,n,r){try{return r?t(Ee(n)[0],n[1]):t(n)}catch(t){hi(e,"throw",t)}},vv=function(e){var t=ce(e),n=jt(this),r=arguments.length,i=r>1?arguments[1]:void 0,o=void 0!==i;o&&(i=Et(i,r>2?arguments[2]:void 0,2));var a,s,c,u,l,d,h=li(t),p=0;if(!h||this==Array&&ci(h))for(a=st(t),s=n?new this(a):Array(a);a>p;p++)d=o?i(t[p],p):t[p],qi(s,p,d);else for(l=(u=di(t,h)).next,s=n?new this:[];!(c=l.call(u)).done;p++)d=o?mv(u,i,[c.value,p],!0):c.value,qi(s,p,d);return s.length=p,s},_v=/[^\0-\u007E]/,gv=/[.\u3002\uFF0E\uFF61]/g,yv="Overflow: input needs wider integers to process",Sv=Math.floor,bv=String.fromCharCode,kv=function(e){return e+22+75*(e<26)},Iv=function(e,t,n){var r=0;for(e=n?Sv(e/700):e>>1,e+=Sv(e/t);e>455;r+=36)e=Sv(e/35);return Sv(r+36*e/(e+38))},Tv=function(e){var t,n,r=[],i=(e=function(e){for(var t=[],n=0,r=e.length;n<r;){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){var o=e.charCodeAt(n++);56320==(64512&o)?t.push(((1023&i)<<10)+(1023&o)+65536):(t.push(i),n--)}else t.push(i)}return t}(e)).length,o=128,a=0,s=72;for(t=0;t<e.length;t++)(n=e[t])<128&&r.push(bv(n));var c=r.length,u=c;for(c&&r.push("-");u<i;){var l=2147483647;for(t=0;t<e.length;t++)(n=e[t])>=o&&n<l&&(l=n);var d=u+1;if(l-o>Sv((2147483647-a)/d))throw RangeError(yv);for(a+=(l-o)*d,o=l,t=0;t<e.length;t++){if((n=e[t])<o&&++a>2147483647)throw RangeError(yv);if(n==o){for(var h=a,p=36;;p+=36){var f=p<=s?1:p>=s+26?26:p-s;if(h<f)break;var m=h-f,v=36-f;r.push(bv(kv(f+m%v))),h=Sv(m/v)}r.push(bv(kv(h))),s=Iv(a,d,u==c),a=0,++u}}++a,++o}return r.join("")},wv=Mi.codeAt,Rv=A.URL,Ev=_a.URLSearchParams,Cv=_a.getState,xv=qe.set,Av=qe.getterFor("URL"),Pv=Math.floor,Dv=Math.pow,Lv=/[A-Za-z]/,Mv=/[\d+-.A-Za-z]/,Nv=/\d/,Ov=/^0x/i,Uv=/^[0-7]+$/,Vv=/^\d+$/,Fv=/^[\dA-Fa-f]+$/,jv=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Bv=/[\0\t\n\r #/:<>?@[\\\]^|]/,Hv=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,zv=/[\t\n\r]/g,Gv=function(e,t){var n,r,i;if("["==t.charAt(0)){if("]"!=t.charAt(t.length-1))return"Invalid host";if(!(n=Jv(t.slice(1,-1))))return"Invalid host";e.host=n}else if(e_(e)){if(t=function(e){var t,n,r=[],i=e.toLowerCase().replace(gv,".").split(".");for(t=0;t<i.length;t++)n=i[t],r.push(_v.test(n)?"xn--"+Tv(n):n);return r.join(".")}(t),jv.test(t))return"Invalid host";if(null===(n=Wv(t)))return"Invalid host";e.host=n}else{if(Bv.test(t))return"Invalid host";for(n="",r=vv(t),i=0;i<r.length;i++)n+=Yv(r[i],Kv);e.host=n}},Wv=function(e){var t,n,r,i,o,a,s,c=e.split(".");if(c.length&&""==c[c.length-1]&&c.pop(),(t=c.length)>4)return e;for(n=[],r=0;r<t;r++){if(""==(i=c[r]))return e;if(o=10,i.length>1&&"0"==i.charAt(0)&&(o=Ov.test(i)?16:8,i=i.slice(8==o?1:2)),""===i)a=0;else{if(!(10==o?Vv:8==o?Uv:Fv).test(i))return e;a=parseInt(i,o)}n.push(a)}for(r=0;r<t;r++)if(a=n[r],r==t-1){if(a>=Dv(256,5-t))return null}else if(a>255)return null;for(s=n.pop(),r=0;r<n.length;r++)s+=n[r]*Dv(256,3-r);return s},Jv=function(e){var t,n,r,i,o,a,s,c=[0,0,0,0,0,0,0,0],u=0,l=null,d=0,h=function(){return e.charAt(d)};if(":"==h()){if(":"!=e.charAt(1))return;d+=2,l=++u}for(;h();){if(8==u)return;if(":"!=h()){for(t=n=0;n<4&&Fv.test(h());)t=16*t+parseInt(h(),16),d++,n++;if("."==h()){if(0==n)return;if(d-=n,u>6)return;for(r=0;h();){if(i=null,r>0){if(!("."==h()&&r<4))return;d++}if(!Nv.test(h()))return;for(;Nv.test(h());){if(o=parseInt(h(),10),null===i)i=o;else{if(0==i)return;i=10*i+o}if(i>255)return;d++}c[u]=256*c[u]+i,2!=++r&&4!=r||u++}if(4!=r)return;break}if(":"==h()){if(d++,!h())return}else if(h())return;c[u++]=t}else{if(null!==l)return;d++,l=++u}}if(null!==l)for(a=u-l,u=7;0!=u&&a>0;)s=c[u],c[u--]=c[l+a-1],c[l+--a]=s;else if(8!=u)return;return c},qv=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)t.unshift(e%256),e=Pv(e/256);return t.join(".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,n=1,r=null,i=0,o=0;o<8;o++)0!==e[o]?(i>n&&(t=r,n=i),r=null,i=0):(null===r&&(r=o),++i);return i>n&&(t=r,n=i),t}(e),n=0;n<8;n++)i&&0===e[n]||(i&&(i=!1),r===n?(t+=n?":":"::",i=!0):(t+=e[n].toString(16),n<7&&(t+=":")));return"["+t+"]"}return e},Kv={},Qv=fv({},Kv,{" ":1,'"':1,"<":1,">":1,"`":1}),Xv=fv({},Qv,{"#":1,"?":1,"{":1,"}":1}),$v=fv({},Xv,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Yv=function(e,t){var n=wv(e,0);return n>32&&n<127&&!le(t,e)?e:encodeURIComponent(e)},Zv={ftp:21,file:null,http:80,https:443,ws:80,wss:443},e_=function(e){return le(Zv,e.scheme)},t_=function(e){return""!=e.username||""!=e.password},n_=function(e){return!e.host||e.cannotBeABaseURL||"file"==e.scheme},r_=function(e,t){var n;return 2==e.length&&Lv.test(e.charAt(0))&&(":"==(n=e.charAt(1))||!t&&"|"==n)},i_=function(e){var t;return e.length>1&&r_(e.slice(0,2))&&(2==e.length||"/"===(t=e.charAt(2))||"\\"===t||"?"===t||"#"===t)},o_=function(e){var t=e.path,n=t.length;!n||"file"==e.scheme&&1==n&&r_(t[0],!0)||t.pop()},a_=function(e){return"."===e||"%2e"===e.toLowerCase()},s_={},c_={},u_={},l_={},d_={},h_={},p_={},f_={},m_={},v_={},__={},g_={},y_={},S_={},b_={},k_={},I_={},T_={},w_={},R_={},E_={},C_=function(e,t,n,r){var i,o,a,s,c,u=n||s_,l=0,d="",h=!1,p=!1,f=!1;for(n||(e.scheme="",e.username="",e.password="",e.host=null,e.port=null,e.path=[],e.query=null,e.fragment=null,e.cannotBeABaseURL=!1,t=t.replace(Hv,"")),t=t.replace(zv,""),i=vv(t);l<=i.length;){switch(o=i[l],u){case s_:if(!o||!Lv.test(o)){if(n)return"Invalid scheme";u=u_;continue}d+=o.toLowerCase(),u=c_;break;case c_:if(o&&(Mv.test(o)||"+"==o||"-"==o||"."==o))d+=o.toLowerCase();else{if(":"!=o){if(n)return"Invalid scheme";d="",u=u_,l=0;continue}if(n&&(e_(e)!=le(Zv,d)||"file"==d&&(t_(e)||null!==e.port)||"file"==e.scheme&&!e.host))return;if(e.scheme=d,n)return void(e_(e)&&Zv[e.scheme]==e.port&&(e.port=null));d="","file"==e.scheme?u=S_:e_(e)&&r&&r.scheme==e.scheme?u=l_:e_(e)?u=f_:"/"==i[l+1]?(u=d_,l++):(e.cannotBeABaseURL=!0,e.path.push(""),u=w_)}break;case u_:if(!r||r.cannotBeABaseURL&&"#"!=o)return"Invalid scheme";if(r.cannotBeABaseURL&&"#"==o){e.scheme=r.scheme,e.path=r.path.slice(),e.query=r.query,e.fragment="",e.cannotBeABaseURL=!0,u=E_;break}u="file"==r.scheme?S_:h_;continue;case l_:if("/"!=o||"/"!=i[l+1]){u=h_;continue}u=m_,l++;break;case d_:if("/"==o){u=v_;break}u=T_;continue;case h_:if(e.scheme=r.scheme,o==dv)e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query=r.query;else if("/"==o||"\\"==o&&e_(e))u=p_;else if("?"==o)e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query="",u=R_;else{if("#"!=o){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.path.pop(),u=T_;continue}e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query=r.query,e.fragment="",u=E_}break;case p_:if(!e_(e)||"/"!=o&&"\\"!=o){if("/"!=o){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,u=T_;continue}u=v_}else u=m_;break;case f_:if(u=m_,"/"!=o||"/"!=d.charAt(l+1))continue;l++;break;case m_:if("/"!=o&&"\\"!=o){u=v_;continue}break;case v_:if("@"==o){h&&(d="%40"+d),h=!0,a=vv(d);for(var m=0;m<a.length;m++){var v=a[m];if(":"!=v||f){var _=Yv(v,$v);f?e.password+=_:e.username+=_}else f=!0}d=""}else if(o==dv||"/"==o||"?"==o||"#"==o||"\\"==o&&e_(e)){if(h&&""==d)return"Invalid authority";l-=vv(d).length+1,d="",u=__}else d+=o;break;case __:case g_:if(n&&"file"==e.scheme){u=k_;continue}if(":"!=o||p){if(o==dv||"/"==o||"?"==o||"#"==o||"\\"==o&&e_(e)){if(e_(e)&&""==d)return"Invalid host";if(n&&""==d&&(t_(e)||null!==e.port))return;if(s=Gv(e,d))return s;if(d="",u=I_,n)return;continue}"["==o?p=!0:"]"==o&&(p=!1),d+=o}else{if(""==d)return"Invalid host";if(s=Gv(e,d))return s;if(d="",u=y_,n==g_)return}break;case y_:if(!Nv.test(o)){if(o==dv||"/"==o||"?"==o||"#"==o||"\\"==o&&e_(e)||n){if(""!=d){var g=parseInt(d,10);if(g>65535)return"Invalid port";e.port=e_(e)&&g===Zv[e.scheme]?null:g,d=""}if(n)return;u=I_;continue}return"Invalid port"}d+=o;break;case S_:if(e.scheme="file","/"==o||"\\"==o)u=b_;else{if(!r||"file"!=r.scheme){u=T_;continue}if(o==dv)e.host=r.host,e.path=r.path.slice(),e.query=r.query;else if("?"==o)e.host=r.host,e.path=r.path.slice(),e.query="",u=R_;else{if("#"!=o){i_(i.slice(l).join(""))||(e.host=r.host,e.path=r.path.slice(),o_(e)),u=T_;continue}e.host=r.host,e.path=r.path.slice(),e.query=r.query,e.fragment="",u=E_}}break;case b_:if("/"==o||"\\"==o){u=k_;break}r&&"file"==r.scheme&&!i_(i.slice(l).join(""))&&(r_(r.path[0],!0)?e.path.push(r.path[0]):e.host=r.host),u=T_;continue;case k_:if(o==dv||"/"==o||"\\"==o||"?"==o||"#"==o){if(!n&&r_(d))u=T_;else if(""==d){if(e.host="",n)return;u=I_}else{if(s=Gv(e,d))return s;if("localhost"==e.host&&(e.host=""),n)return;d="",u=I_}continue}d+=o;break;case I_:if(e_(e)){if(u=T_,"/"!=o&&"\\"!=o)continue}else if(n||"?"!=o)if(n||"#"!=o){if(o!=dv&&(u=T_,"/"!=o))continue}else e.fragment="",u=E_;else e.query="",u=R_;break;case T_:if(o==dv||"/"==o||"\\"==o&&e_(e)||!n&&("?"==o||"#"==o)){if(".."===(c=(c=d).toLowerCase())||"%2e."===c||".%2e"===c||"%2e%2e"===c?(o_(e),"/"==o||"\\"==o&&e_(e)||e.path.push("")):a_(d)?"/"==o||"\\"==o&&e_(e)||e.path.push(""):("file"==e.scheme&&!e.path.length&&r_(d)&&(e.host&&(e.host=""),d=d.charAt(0)+":"),e.path.push(d)),d="","file"==e.scheme&&(o==dv||"?"==o||"#"==o))for(;e.path.length>1&&""===e.path[0];)e.path.shift();"?"==o?(e.query="",u=R_):"#"==o&&(e.fragment="",u=E_)}else d+=Yv(o,Xv);break;case w_:"?"==o?(e.query="",u=R_):"#"==o?(e.fragment="",u=E_):o!=dv&&(e.path[0]+=Yv(o,Kv));break;case R_:n||"#"!=o?o!=dv&&("'"==o&&e_(e)?e.query+="%27":e.query+="#"==o?"%23":Yv(o,Kv)):(e.fragment="",u=E_);break;case E_:o!=dv&&(e.fragment+=Yv(o,Qv))}l++}},x_=function(e){var t,n,r=mi(this,x_,"URL"),i=arguments.length>1?arguments[1]:void 0,o=Di(e),a=xv(r,{type:"URL"});if(void 0!==i)if(i instanceof x_)t=Av(i);else if(n=C_(t={},Di(i)))throw TypeError(n);if(n=C_(a,o,null,t))throw TypeError(n);var s=a.searchParams=new Ev,c=Cv(s);c.updateSearchParams(a.query),c.updateURL=function(){a.query=String(s)||null},D||(r.href=P_.call(r),r.origin=D_.call(r),r.protocol=L_.call(r),r.username=M_.call(r),r.password=N_.call(r),r.host=O_.call(r),r.hostname=U_.call(r),r.port=V_.call(r),r.pathname=F_.call(r),r.search=j_.call(r),r.searchParams=B_.call(r),r.hash=H_.call(r))},A_=x_.prototype,P_=function(){var e=Av(this),t=e.scheme,n=e.username,r=e.password,i=e.host,o=e.port,a=e.path,s=e.query,c=e.fragment,u=t+":";return null!==i?(u+="//",t_(e)&&(u+=n+(r?":"+r:"")+"@"),u+=qv(i),null!==o&&(u+=":"+o)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+a.join("/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},D_=function(){var e=Av(this),t=e.scheme,n=e.port;if("blob"==t)try{return new x_(t.path[0]).origin}catch(e){return"null"}return"file"!=t&&e_(e)?t+"://"+qv(e.host)+(null!==n?":"+n:""):"null"},L_=function(){return Av(this).scheme+":"},M_=function(){return Av(this).username},N_=function(){return Av(this).password},O_=function(){var e=Av(this),t=e.host,n=e.port;return null===t?"":null===n?qv(t):qv(t)+":"+n},U_=function(){var e=Av(this).host;return null===e?"":qv(e)},V_=function(){var e=Av(this).port;return null===e?"":String(e)},F_=function(){var e=Av(this),t=e.path;return e.cannotBeABaseURL?t[0]:t.length?"/"+t.join("/"):""},j_=function(){var e=Av(this).query;return e?"?"+e:""},B_=function(){return Av(this).searchParams},H_=function(){var e=Av(this).fragment;return e?"#"+e:""},z_=function(e,t){return{get:e,set:t,configurable:!0,enumerable:!0}};if(D&&mr(A_,{href:z_(P_,(function(e){var t=Av(this),n=Di(e),r=C_(t,n);if(r)throw TypeError(r);Cv(t.searchParams).updateSearchParams(t.query)})),origin:z_(D_),protocol:z_(L_,(function(e){var t=Av(this);C_(t,Di(e)+":",s_)})),username:z_(M_,(function(e){var t=Av(this),n=vv(Di(e));if(!n_(t)){t.username="";for(var r=0;r<n.length;r++)t.username+=Yv(n[r],$v)}})),password:z_(N_,(function(e){var t=Av(this),n=vv(Di(e));if(!n_(t)){t.password="";for(var r=0;r<n.length;r++)t.password+=Yv(n[r],$v)}})),host:z_(O_,(function(e){var t=Av(this);t.cannotBeABaseURL||C_(t,Di(e),__)})),hostname:z_(U_,(function(e){var t=Av(this);t.cannotBeABaseURL||C_(t,Di(e),g_)})),port:z_(V_,(function(e){var t=Av(this);n_(t)||(""==(e=Di(e))?t.port=null:C_(t,e,y_))})),pathname:z_(F_,(function(e){var t=Av(this);t.cannotBeABaseURL||(t.path=[],C_(t,Di(e),I_))})),search:z_(j_,(function(e){var t=Av(this);""==(e=Di(e))?t.query=null:("?"==e.charAt(0)&&(e=e.slice(1)),t.query="",C_(t,e,R_)),Cv(t.searchParams).updateSearchParams(t.query)})),searchParams:z_(B_),hash:z_(H_,(function(e){var t=Av(this);""!=(e=Di(e))?("#"==e.charAt(0)&&(e=e.slice(1)),t.fragment="",C_(t,e,E_)):t.fragment=null}))}),Ye(A_,"toJSON",(function(){return P_.call(this)}),{enumerable:!0}),Ye(A_,"toString",(function(){return P_.call(this)}),{enumerable:!0}),Rv){var G_=Rv.createObjectURL,W_=Rv.revokeObjectURL;G_&&Ye(x_,"createObjectURL",(function(e){return G_.apply(Rv,arguments)})),W_&&Ye(x_,"revokeObjectURL",(function(e){return W_.apply(Rv,arguments)}))}Fr(x_,"URL"),Rt({global:!0,forced:!Wo,sham:!D},{URL:x_});var J_,q_,K_,Q_=new Blob(["class VolumeMeter extends AudioWorkletProcessor{constructor(){super();this.volume=0;this.intervalTime=200;this.tick=this.intervalTime;this.isStop=false;this.port.onmessage=event=>{const{data}=event;switch(data.name){case'setIntervalTime':this.intervalTime=data.intervalTime;break;case'stop':this.isStop=true;break}}}process(inputs){const input=inputs[0];if(this.isStop){return false}if(input.length>0){const firstChannel=input[0];let sum=0;let rms;for(let i=0;i<firstChannel.length;++i){sum+=firstChannel[i]*firstChannel[i]}rms=Math.sqrt(sum/firstChannel.length);this.volume=Math.max(rms,this.volume*0.95);this.tick-=firstChannel.length;if(this.tick<0){this.tick+=(this.intervalTime/1000)*sampleRate;this.port.postMessage({volume:this.volume})}}return true}}registerProcessor('volume-meter',VolumeMeter);"],{type:"application/javascript"}),X_=!1,$_=function(){function e(t){a(this,e),this.context_=t.context,this.addModuleToContext()}var t;return c(e,[{key:"addModuleToContext",value:(t=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.context_.audioWorklet.addModule(URL.createObjectURL(Q_));case 3:Pp.info("worklet addModule success"),yp.emit(302),X_=!0,e.next=12;break;case 8:e.prev=8,e.t0=e.catch(0),Pp.info("worklet addModule catch error. ".concat(e.t0.message)),yp.emit(303);case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(){return t.apply(this,arguments)})},{key:"initWorkletSuccess",get:function(){return X_}}]),e}(),Y_=function(){function e(t){a(this,e);var n=t.track,r=t.log,i=t.stream;this.volume_=0,this.log_=r,this.track_=n,this.stream_=i,J_||(window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext,J_=new window.AudioContext),this.audioCtx_=J_,this.destination_=this.audioCtx_.destination;var o=new MediaStream;o.addTrack(this.track_),this.streamSource_=this.audioCtx_.createMediaStreamSource(o),this.audioWorkletNode_=null,this.scriptProcessorNode_=null,this.interval_=200,yp.on(Ep,this.resume,this),yp.on(32,this.handleAudioLevelInterval,this),ch?(yp.on(302,this.initAudioWorklet,this),yp.on(303,this.initScriptProcessor,this),this.preload()):this.initScriptProcessor()}return c(e,[{key:"preload",value:function(){q_?q_.initWorkletSuccess&&this.initAudioWorklet():q_=new $_({context:J_})}},{key:"initAudioWorklet",value:function(){var e=this;if(!this.audioWorkletNode_)try{this.audioWorkletNode_=new AudioWorkletNode(this.audioCtx_,"volume-meter"),this.audioWorkletNode_.port.onmessage=function(t){e.volume_=t.data.volume.toFixed(2)||0},this.streamSource_.connect(this.audioWorkletNode_).connect(this.destination_),this.handleAudioLevelInterval({interval:this.interval_}),Gf.logSuccessEvent({userId:this.stream_.getUserId(),eventType:dd})}catch(e){Gf.logFailedEvent({userId:this.stream_.getUserId(),eventType:dd}),this.initScriptProcessor()}}},{key:"initScriptProcessor",value:function(){var e=this;if(!this.scriptProcessorNode_)try{this.scriptProcessorNode_=this.audioCtx_.createScriptProcessor(2048,1,1),this.scriptProcessorNode_.onaudioprocess=function(t){for(var n=t.inputBuffer.getChannelData(0),r=0,i=0;i<n.length;++i)r+=n[i]*n[i];e.volume_=Math.sqrt(r/n.length).toFixed(2)||0},this.streamSource_.connect(this.scriptProcessorNode_).connect(this.destination_)}catch(e){this.log_.error("volumeMeter init script processor error: "+e)}}},{key:"destroy",value:function(){this.streamSource_&&this.streamSource_.disconnect(),this.scriptProcessorNode_&&this.scriptProcessorNode_.disconnect(),this.audioWorkletNode_&&(this.audioWorkletNode_.port.postMessage({name:"stop"}),this.audioWorkletNode_.disconnect()),this.audioWorkletNode_=null,this.scriptProcessorNode_=null,this.audioCtx_=null,yp.off(Ep,this.resume,this),yp.off(32,this.handleAudioLevelInterval,this),yp.off(302,this.initAudioWorklet,this),yp.off(303,this.initScriptProcessor,this)}},{key:"resume",value:function(){this.audioCtx_&&this.audioCtx_.resume()}},{key:"getCalculatedVolume",value:function(){return this.volume_}},{key:"handleAudioLevelInterval",value:function(e){var t=e.interval;this.interval_=t,this.audioWorkletNode_&&this.audioWorkletNode_.port.postMessage({name:"setIntervalTime",intervalTime:t})}}]),e}(),Z_=function(){function e(t){a(this,e),this.stream_=t.stream,this.userId_=t.stream.getUserId(),this.log_=this.stream_.getLogger(),this.track_=t.track,this.div_=t.div,this.muted_=t.muted,this.outputDeviceId_=t.outputDeviceId,this.volume_=t.volume,this.emitter_=new gp,this.initializeElement(),this.state_="NONE",this.volumeMeter_=new Y_({stream:this.stream_,track:this.track_,log:this.log_})}var t,n,r,i;return c(e,[{key:"isPlaying",get:function(){return"PLAYING"===this.state_}},{key:"initializeElement",value:function(){if(this.isAudioElementInit()){var e=new MediaStream;e.addTrack(this.track_);var t=document.createElement(ll);t.srcObject=e,t.muted=this.muted_,t.setAttribute("id","audio_".concat(this.stream_.getId())),t.setAttribute("autoplay","autoplay"),t.setAttribute("playsinline","playsinline"),this.div_.appendChild(t),this.element_=t}this.handleEvents()}},{key:"setMuted",value:function(e){this.element_&&(this.element_.muted=e,this.muted_=e)}},{key:"play",value:(i=o(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.outputDeviceId_||!this.element_){e.next=3;break}return e.next=3,this.element_.setSinkId(this.outputDeviceId_);case 3:if(this.setVolume(this.volume_),e.prev=4,!this.element_){e.next=8;break}return e.next=8,this.element_.play();case 8:e.next=16;break;case 10:if(e.prev=10,e.t0=e.catch(4),this.log_.warn("<audio> play() error: "+e.t0),!(t=e.t0.toString()+" <audio>").startsWith("NotAllowedError")){e.next=16;break}throw new vf({code:mf.PLAY_NOT_ALLOWED,message:t});case 16:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return i.apply(this,arguments)})},{key:"handleEvents",value:function(){this.handleElementEvent=this.handleElementEvent.bind(this),this.handleTrackEvent=this.handleTrackEvent.bind(this),this.element_&&(this.element_.addEventListener(gl,this.handleElementEvent),this.element_.addEventListener(_l,this.handleElementEvent),this.element_.addEventListener(yl,this.handleElementEvent),this.element_.addEventListener(Sl,this.handleElementEvent)),this.track_.addEventListener(_l,this.handleTrackEvent),this.track_.addEventListener(ml,this.handleTrackEvent),this.track_.addEventListener(vl,this.handleTrackEvent),this.track_.readyState===_l&&this.handleTrackEvent({type:_l}),this.track_.muted&&this.handleTrackEvent({type:ml})}},{key:"handleElementEvent",value:(r=o(regeneratorRuntime.mark((function e(t){var n,r,i,o,a,s=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.type,e.t0=n,e.next=e.t0===gl?4:e.t0===_l?9:e.t0===yl?12:e.t0===Sl?16:27;break;case 4:return this.log_.info("stream - audio player is starting playing"),this.state_="PLAYING",yp.emit(103,{stream:this.stream_}),this.emitter_.emit(Zm,{state:this.state_,reason:gl}),e.abrupt("break",27);case 9:return this.log_.info("stream - audio player is ended"),"STOPPED"!==this.state_&&(this.state_="STOPPED",this.emitter_.emit(Zm,{state:this.state_,reason:_l})),e.abrupt("break",27);case 12:return this.log_.info("stream - audio player is paused"),this.state_="PAUSED",this.emitter_.emit(Zm,{state:this.state_,reason:yl}),e.abrupt("break",27);case 16:if(!this.element_||!this.element_.error){e.next=26;break}return r="".concat(xm(),"/").concat(cl().name,"/").concat(cl().version),e.next=20,Wy.getSpeakers();case 20:i=e.sent,o=i[0].label,(a=i.find((function(e){return e.deviceId===s.outputDeviceId_})))&&(o=a.label),this.log_.error("stream - audio player error observed. code: ".concat(this.element_.error.code," message: ").concat(this.element_.error.message," deviceInfo: ").concat(r," speaker: ").concat(o)),Gf.uploadEvent("stat-".concat(this.stream_.getType(),"-audio-").concat(ud,"-").concat(this.element_.error.code,"-").concat(r,"-").concat(o),this.element_.error);case 26:return e.abrupt("break",27);case 27:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"handleTrackEvent",value:function(e){var t=e.type;switch(t){case _l:this.log_.info("stream - audio player track is ended"),"STOPPED"!==this.state_&&(this.state_="STOPPED",this.emitter_.emit(Zm,{state:this.state_,reason:_l})),yp.emit(137,{stream:this.stream_,type:t});break;case ml:this.log_.info("stream - audio track is unable to provide media output"),this.stream_.isRemote()||sh(),"PAUSED"!==this.state_&&(this.state_="PAUSED",this.emitter_.emit(Zm,{state:this.state_,reason:ml})),yp.emit(136,{stream:this.stream_,type:t});break;case vl:this.log_.info("stream - audio track is able to provide media output"),"PAUSED"===this.state_&&(this.state_="PLAYING",this.emitter_.emit(Zm,{state:this.state_,reason:vl}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(gl,this.handleElementEvent),this.element_.removeEventListener(_l,this.handleElementEvent),this.element_.removeEventListener(yl,this.handleElementEvent),this.element_.removeEventListener(Sl,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(_l,this.handleTrackEvent),this.track_.removeEventListener(ml,this.handleTrackEvent),this.track_.removeEventListener(vl,this.handleTrackEvent))}},{key:"setSinkId",value:(n=o(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.outputDeviceId_===t){e.next=5;break}if(!this.element_){e.next=4;break}return e.next=4,this.element_.setSinkId(t);case 4:this.outputDeviceId_=t;case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setVolume",value:function(e){this.element_&&(this.log_.info("stream - audioElement setVolume to : ".concat(e)),this.element_.volume=e)}},{key:"getAudioLevel",value:function(){return this.volumeMeter_.getCalculatedVolume()}},{key:"stop",value:function(){this.unbindEvents(),this.element_&&(this.div_.removeChild(this.element_),this.element_.srcObject=null,this.element_=null),this.volumeMeter_&&(this.volumeMeter_.destroy(),this.volumeMeter_=null)}},{key:"resume",value:(t=o(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,this.volumeMeter_&&this.volumeMeter_.resume(),!this.element_){e.next=5;break}return e.next=5,this.element_.play();case 5:e.next=13;break;case 7:if(e.prev=7,e.t0=e.catch(0),this.log_.warn("<audio> play() error: "+e.t0),!(t=zf({key:"AUDIO",data:{error:e.t0}})).startsWith("NotAllowedError")){e.next=13;break}throw new vf({code:mf.PLAY_NOT_ALLOWED,message:t});case 13:case"end":return e.stop()}}),e,this,[[0,7]])}))),function(){return t.apply(this,arguments)})},{key:"on",value:function(e,t){this.emitter_.on(e,t)}},{key:"isAudioElementInit",value:function(){return!("15.2"===rl||"15.3"===rl||"15.4"===rl)||"local"!==this.stream_.getType()||!this.muted_||(this.log_.info("audioElement is muted."),!1)}}]),e}(),eg=$e.PROPER,tg=Ya.trim;Rt({target:"String",proto:!0,forced:(K_="trim",P((function(){return!!qa[K_]()||"​…᠎"!=="​…᠎"[K_]()||eg&&qa[K_].name!==K_})))},{trim:function(){return tg(this)}});var ng="".concat("trtc_autoplay","_mask"),rg="".concat("trtc_autoplay","_wrapper"),ig="".concat("trtc_autoplay","_header"),og="".concat("trtc_autoplay","_content"),ag="".concat("trtc_autoplay","_action_wrapper"),sg="".concat("trtc_autoplay","_question"),cg="".concat("trtc_autoplay","_collapse"),ug="".concat("trtc_autoplay","_action_confirm"),lg="".concat("trtc_autoplay","_detail"),dg="".concat("dialog","-show"),hg="".concat("dialog","-1"),pg="".concat("dialog","-2"),fg=!1,mg=function(){return!!document.querySelector(".".concat(rg))},vg="".concat(Od,"/").concat(ah()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),_g="<br><a href='".concat(vg,"' target='_blank'>").concat(ah()?"其他方案?":"Any other solution?","</a>"),gg="".concat(ah()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(_g):"Autoplay Policy: Before user interacts with the web page (clicking, touching), page will not be allowed to play media with sound. This Dialog is used to help users resume playback. ".concat(_g)),yg=function(){function e(){if(a(this,e),this.dialogNode_=null,this.bodyPosition_="",this.content="音视频播放被浏览器拦截,请点击“恢复播放”。",ah()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!fg){var t=document.createElement("style");t.innerHTML=".".concat(ng,"{position:fixed;top:0;left:0;right:0;bottom:0;width:100vw;height:100vh;display:flex;justify-content:center;align-items:center;background:rgba(0,0,0,0.5);z-index:1500;}.").concat(ng," div:not(.").concat(ag,"){display:block !important;}.").concat(rg,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(rg," a{color:").concat("#2473E8",";}.").concat(ig,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(og,"{margin:8px 0;}.").concat(ag,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(cg,"{margin-right:auto;cursor:pointer}.").concat(sg,"{height:100%;line-height:16px;cursor:pointer;}.").concat(ug,"{margin-left:8px;color:#fff;background:").concat("#2473E8",";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(ug,":hover{opacity:0.9;}.").concat(cg,",.").concat(ug,",.").concat(og,",.").concat(sg,"{font-size:14px;}@media screen and (max-width:750px){.").concat(rg,"{width:80vw;}}"),document.head.appendChild(t),fg=!0}this.showDetail_=!1,this.isCollapseClicked_=!1,this.isQuestionClicked_=!1,this.addDiaLog()}return c(e,[{key:"createDiaLog",value:function(){var e=document.createElement("template");e.innerHTML='<div class="'.concat(ng,"\"><div class='").concat(rg,"'><div class='").concat(ig,"'>").concat(location.host,"</div><div class='").concat(og,"'>").concat(this.content,"</div><div class='").concat(lg,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(gg,"</div><div class='").concat(ag,"'></div></div></div>").trim();var t=document.createElement("button");t.className=ug,t.innerText=ah()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);var n=document.createElement("div");n.className=sg,n.innerHTML='<?xml version="1.0" encoding="UTF-8"?>\n <svg class="icon" width="18" height="18" p-id="2030" t="1639646523624" version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">\n <path d="m464 784.35c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" p-id="2031"/>\n <path d="m512 960c-247.04 0-448-200.96-448-448s200.96-448 448-448 448 200.96 448 448-200.96 448-448 448zm0-831.71c-211.58 0-383.71 172.13-383.71 383.71 0 211.55 172.13 383.71 383.71 383.71 211.55 0 383.71-172.16 383.71-383.71 0-211.58-172.16-383.71-383.71-383.71z" p-id="2032"/>\n <path d="m512 673.7c-17.665 0-32.001-14.336-32.001-31.999v-54.112c0-52.353 40-92.352 75.328-127.65 25.887-25.92 52.672-52.672 52.672-74.017 0-53.343-43.072-96.735-95.999-96.735-53.823 0-95.999 41.536-95.999 94.559 0 17.665-14.336 31.999-32.001 31.999s-32.001-14.336-32.001-31.999c0-87.424 71.775-158.56 160-158.56s160 72.095 160 160.74c0 47.904-36.32 84.192-71.424 119.3-27.84 27.776-56.576 56.512-56.576 82.336v54.112c0 17.665-14.336 32.032-32.001 32.032z" p-id="2033"/>\n </svg>\n ',n.onclick=this.onQuestionClick.bind(this);var r=document.createElement("div");r.className=cg,r.innerText="".concat(ah()?"详情 >":"Detail >"),r.onclick=this.onCollapseClick.bind(this);var i=e.content.firstChild,o=i.querySelector(".".concat(ag));return o.appendChild(r),o.appendChild(n),o.appendChild(t),i}},{key:"addDiaLog",value:function(){mg()||(this.dialogNode_=this.createDiaLog(),document.body.appendChild(this.dialogNode_),this.dialogNode_.onclick=this.onConfirm.bind(this),this.dialogNode_.querySelector(".".concat(rg)).onclick=function(e){return e.stopPropagation()},this.bodyPosition_=document.body.style.position,document.body.style.position="fixed",Pp.warn("show autoplay dialog"),Gf.uploadEvent({log:dg}))}},{key:"deleteDiaLog",value:function(){this.dialogNode_&&(document.body.removeChild(this.dialogNode_),document.body.style.position=this.bodyPosition_,this.dialogNode_=null)}},{key:"onConfirm",value:function(){Pp.warn("confirm clicked, try resume stream"),yp.emit(Ep),this.deleteDiaLog()}},{key:"onCollapseClick",value:function(){var e=this.dialogNode_.querySelector(".".concat(lg));e.style.visibility="".concat(this.showDetail_?"hidden":"visible"),e.style.height="".concat(this.showDetail_?0:"fit-content"),this.showDetail_=!this.showDetail_,this.isCollapseClicked_||Gf.uploadEvent({log:hg}),this.isCollapseClicked_=!0}},{key:"onQuestionClick",value:function(){window.open(vg,"_blank"),this.isQuestionClicked_||Gf.uploadEvent({log:pg}),this.isQuestionClicked_=!0}}]),e}(),Sg=function(){function e(t){a(this,e),this.stream_=t.stream,this.userId_=t.stream.getUserId(),this.log_=this.stream_.getLogger(),this.track_=t.track,this.div_=t.div,this.muted_=t.muted,this.objectFit_=t.objectFit,this.mirror_=t.mirror,this.emitter_=new gp,this.initializeElement(),this.state_="NONE",this.pausedRetryCount_=5}var t,n;return c(e,[{key:"isPlaying",get:function(){return"PLAYING"===this.state_}},{key:"initializeElement",value:function(){var e=new MediaStream;e.addTrack(this.track_);var t=document.createElement(dl);t.srcObject=e,t.muted=!0;var n="width: 100%; height: 100%; object-fit: ".concat(this.objectFit_,";");this.mirror_&&(n+="transform: rotateY(180deg);"),t.setAttribute("id","video_".concat(this.stream_.getId())),t.setAttribute("style",n),t.setAttribute("autoplay","autoplay"),t.setAttribute("playsinline","playsinline"),this.div_&&this.div_.appendChild(t),this.element_=t,this.handleEvents()}},{key:"setRect",value:function(e){var t=e.width,n=e.height;this.element_&&(this.element_.style.width=t+"px",this.element_.style.height=n+"px")}},{key:"setMirror",value:function(e){this.element_&&(this.element_.style.transform=e?"rotateY(180deg)":"",this.mirror_=e)}},{key:"setObjectFit",value:function(e){this.element_&&(this.element_.style.objectFit="".concat(e),this.objectFit_=e)}},{key:"play",value:(n=o(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.element_.play();case 3:e.next=11;break;case 5:if(e.prev=5,e.t0=e.catch(0),this.log_.warn("<video> play() error: "+e.t0),!(t=e.t0.toString()+" <video>").startsWith("NotAllowedError")){e.next=11;break}throw new vf({code:mf.PLAY_NOT_ALLOWED,message:t});case 11:case"end":return e.stop()}}),e,this,[[0,5]])}))),function(){return n.apply(this,arguments)})},{key:"handleEvents",value:function(){this.handleElementEvent=this.handleElementEvent.bind(this),this.handleTrackEvent=this.handleTrackEvent.bind(this),this.element_.addEventListener(gl,this.handleElementEvent),this.element_.addEventListener(_l,this.handleElementEvent),this.element_.addEventListener(yl,this.handleElementEvent),this.element_.addEventListener(Sl,this.handleElementEvent),this.element_.addEventListener(bl,this.handleElementEvent),this.track_.addEventListener(_l,this.handleTrackEvent),this.track_.addEventListener(ml,this.handleTrackEvent),this.track_.addEventListener(vl,this.handleTrackEvent),this.track_.readyState===_l&&this.handleTrackEvent({type:_l}),this.track_.muted&&this.handleTrackEvent({type:ml})}},{key:"handleElementEvent",value:function(e){switch(e.type){case gl:this.log_.info("stream - video player is starting playing"),this.state_="PLAYING",yp.emit(Sp,{stream:this.stream_}),this.emitter_.emit(Zm,{state:this.state_,reason:gl});break;case _l:this.log_.info("stream - video player is ended"),"STOPPED"!==this.state_&&(this.state_="STOPPED",this.emitter_.emit(Zm,{state:this.state_,reason:_l}));break;case yl:this.log_.info("stream - video player is paused"),this.div_&&!document.getElementById(this.div_.id)&&this.log_.warn("video container is not in DOM"),this.state_="PAUSED",this.emitter_.emit(Zm,{state:this.state_,reason:yl}),this.pausedRetryCount_>0&&!mg()&&(this.log_.info("auto resume when video paused"),this.resume(),this.pausedRetryCount_--);break;case Sl:if(this.element_&&this.element_.error){var t="".concat(xm(),"/").concat(cl().name,"/").concat(cl().version);this.log_.error("stream - video player error observed. code: ".concat(this.element_.error.code," message: ").concat(this.element_.error.message," deviceInfo: ").concat(t)),Gf.uploadEvent("stat-".concat(this.stream_.getType(),"-video-").concat(ud,"-").concat(this.element_.error.code,"-").concat(t),this.element_.error)}break;case bl:yp.emit(133,{stream:this.stream_})}}},{key:"handleTrackEvent",value:function(e){var t=e.type;switch(t){case _l:this.log_.info("stream - video player track is ended"),yp.emit(135,{stream:this.stream_,type:t}),"STOPPED"!==this.state_&&(this.state_="STOPPED",this.emitter_.emit(Zm,{state:this.state_,reason:_l}));break;case ml:this.log_.info("stream - video track is unable to provide media output"),this.stream_.isRemote()||sh(),yp.emit(Rp,{stream:this.stream_,type:t}),"PAUSED"!==this.state_&&(this.state_="PAUSED",this.emitter_.emit(Zm,{state:this.state_,reason:ml}));break;case vl:this.log_.info("stream - video track is able to provide media output"),yp.emit(131,{stream:this.stream_}),"PAUSED"===this.state_&&(this.state_="PLAYING",this.emitter_.emit(Zm,{state:this.state_,reason:vl}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(gl,this.handleElementEvent),this.element_.removeEventListener(_l,this.handleElementEvent),this.element_.removeEventListener(yl,this.handleElementEvent),this.element_.removeEventListener(Sl,this.handleElementEvent),this.element_.removeEventListener(bl,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(_l,this.handleTrackEvent),this.track_.removeEventListener(ml,this.handleTrackEvent),this.track_.removeEventListener(vl,this.handleTrackEvent))}},{key:"stop",value:function(){this.unbindEvents(),this.div_&&this.div_.removeChild(this.element_),this.element_.srcObject=null,this.element_=null}},{key:"resume",value:(t=o(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.element_.play();case 3:e.next=11;break;case 5:if(e.prev=5,e.t0=e.catch(0),this.log_.warn("<video> play() error: "+e.t0),!(t=zf({key:"VIDEO",data:{error:e.t0}})).startsWith("NotAllowedError")){e.next=11;break}throw new vf({code:mf.PLAY_NOT_ALLOWED,message:t});case 11:case"end":return e.stop()}}),e,this,[[0,5]])}))),function(){return t.apply(this,arguments)})},{key:"getVideoFrame",value:function(){var e=document.createElement("canvas");return e.width=this.element_.videoWidth,e.height=this.element_.videoHeight,e.getContext("2d").drawImage(this.element_,0,0),e.toDataURL("image/png")}},{key:"on",value:function(e,t){this.emitter_.on(e,t)}},{key:"getElement",value:function(){return this.element_?this.element_:null}}]),e}(),bg=function(){function e(t){a(this,e),this.userId_=t.userId,this.tinyId_=t.tinyId,this.client_=t.client,this.sdpSemantics_=t.client.getSdpSemantics(),this.isUplink_=t.isUplink,this.log_=Pp.createLogger({id:"n|"+this.userId_,userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId(),isLocal:this.isUplink_}),this.signalChannel_=t.signalChannel,this.peerConnection_=null,this.connectTimer_=-1,this.isErrorObserved_=!1,this.emitter_=new gp,this.currentState_=Nl,this.waitForPeerConnectionConnectedPromise_=null,this.isReconnecting_=!1,this.reconnectionCount_=0,this.reconnectionTimer_=-1,this.isFirstConnection_=!0,this.delay_={audioDelay:0,videoDelay:0}}var t;return c(e,[{key:"initialize",value:function(){var e={iceServers:this.client_.getIceServers(),iceTransportPolicy:this.client_.getIceTransportPolicy(),sdpSemantics:this.sdpSemantics_,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};this.peerConnection_=new RTCPeerConnection(e),this.peerConnection_.onconnectionstatechange=this.onConnectionStateChange.bind(this)}},{key:"close",value:function(){this.log_.info("closing connection"),this.closePeerConnection()}},{key:"closePeerConnection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.peerConnection_&&(this.peerConnection_.onconnectionstatechange=function(){},this.peerConnection_.close(),this.peerConnection_=null,e&&this.emitConnectionStateChangedEvent(Nl))}},{key:"getDTLSTransportState",value:function(){if(!this.peerConnection_)return"unknown";var e=null;if(this.isUplink_){if(!km()||0===this.peerConnection_.getSenders().length)return"unknown";e=this.peerConnection_.getSenders()[0].transport}else{if(!bm()||0===this.peerConnection_.getReceivers().length)return"unknown";e=this.peerConnection_.getReceivers()[0].transport}return e?e.state:"unknown"}},{key:"onConnectionStateChange",value:function(e){var t=this.peerConnection_.iceConnectionState,n=this.getDTLSTransportState();if(this.log_.info("onConnectionStateChange() connectionState: "+e.target.connectionState),this.log_.info("ICE Transport state: ".concat(t,", DTLS Transport state: ").concat(n)),e.target.connectionState===Fl&&this.emitConnectionStateChangedEvent(Ol),e.target.connectionState===jl||e.target.connectionState===Bl){var r="".concat(this.isUplink_?"uplink":"downlink"," ICE/DTLS Transport connection ").concat(e.target.connectionState,". ICE Transport state: ").concat(t,", DTLS Transport state: ").concat(n),i=new vf({message:r,code:mf.ICE_TRANSPORT_ERROR});Gf.logFailedEvent({userId:this.client_.getUserId(),eventType:td,error:i}),this.emitConnectionStateChangedEvent(Nl),this.isErrorObserved_||this.emitter_.emit(jm,i)}e.target.connectionState!==Hl&&"completed"!==e.target.connectionState||(this.logSelectedCandidate(),Gf.logSuccessEvent({userId:this.client_.getUserId(),eventType:td}),this.emitConnectionStateChangedEvent(Vl))}},{key:"emitConnectionStateChangedEvent",value:function(e){e!==this.currentState_&&(this.currentState_===Ul&&e===Ol||(yp.emit(200,{client:this.client_,connection:this,prevState:this.currentState_,state:e}),this.emitter_.emit(Bm,{prevState:this.currentState_,state:e}),this.currentState_=e))}},{key:"hitTest",value:function(e){return(0===e||"0"===e)&&this.isUplink_||e===this.tinyId_}},{key:"addEventInternal",value:function(e,t){var n=this.client_.getUserId(),r={eventId:e,eventDesc:t,timestamp:Sa(),userId:n,tinyId:this.client_.getTinyId()};this.isUplink_||(r.remoteUserId=this.userId_,r.remoteTinyId=this.tinyId_),yf(n,r)}},{key:"getPeerConnection",value:function(){return this.peerConnection_}},{key:"getClient",value:function(){return this.client_}},{key:"getUserId",value:function(){return this.userId_}},{key:"getTinyId",value:function(){return this.tinyId_}},{key:"logSelectedCandidate",value:(t=o(regeneratorRuntime.mark((function e(){var t,n,r,i,o,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.peerConnection_){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.peerConnection_.getStats();case 4:t=e.sent,n=I(t),e.prev=6,n.s();case 8:if((r=n.n()).done){e.next=18;break}if((i=y(r.value,2))[0],o=i[1],!Em(o)){e.next=16;break}return a=t.get(o.localCandidateId),s=t.get(o.remoteCandidateId),a&&this.log_.info("local candidate: ".concat(a.candidateType," ").concat(a.protocol,":").concat(a.ip||a.address,":").concat(a.port," ").concat(a.networkType||""," ").concat("relay"===a.candidateType?"relayProtocol:"+a.relayProtocol:"")),s&&this.log_.info("remote candidate: ".concat(s.candidateType," ").concat(s.protocol,":").concat(s.ip||s.address,":").concat(s.port)),e.abrupt("break",18);case 16:e.next=8;break;case 18:e.next=23;break;case 20:e.prev=20,e.t0=e.catch(6),n.e(e.t0);case 23:return e.prev=23,n.f(),e.finish(23);case 26:case"end":return e.stop()}}),e,this,[[6,20,23,26]])}))),function(){return t.apply(this,arguments)})},{key:"getCurrentState",value:function(){return this.currentState_}},{key:"waitForPeerConnectionConnected",value:function(){var e=this;return this.waitForPeerConnectionConnectedPromise_||(this.waitForPeerConnectionConnectedPromise_=new Promise((function(t,n){if(e.currentState_===Vl)return t();var r=-1,i=function n(i){i.state===Vl&&(clearTimeout(r),e.emitter_.off(Bm,n,e),t())};r=setTimeout((function(){e.emitter_.off(Bm,i,e);var t=new vf({code:mf.API_CALL_TIMEOUT,message:"connection timeout"});e.peerConnection_||e.isUplink_||(t=e.genRemoteStreamNotExistError()),n(t)}),1e4),e.emitter_.on(Bm,i,e)})),this.waitForPeerConnectionConnectedPromise_=this.waitForPeerConnectionConnectedPromise_.then((function(t){return e.waitForPeerConnectionConnectedPromise_=null,t})).catch((function(t){throw e.waitForPeerConnectionConnectedPromise_=null,t}))),this.waitForPeerConnectionConnectedPromise_}},{key:"getReconnectionCount",value:function(){return this.reconnectionCount_}},{key:"startReconnection",value:function(){this.isReconnecting_=!0,this.emitConnectionStateChangedEvent(Ul),this.reconnect(),this.addEventInternal(this.isUplink_?32797:32800,"".concat(this.isUplink_?"uplink":"downlink","-connection is reconnecting"))}},{key:"stopReconnection",value:function(){this.log_.info("stop reconnection"),this.isReconnecting_=!1,this.reconnectionCount_=0,this.clearReconnectionTimer(),this.signalChannel_.off(3,this.reconnect,this)}},{key:"on",value:function(e,t,n){this.emitter_.on(e,t,n)}},{key:"off",value:function(e,t,n){this.emitter_.off(e,t,n)}},{key:"genRemoteStreamNotExistError",value:function(){return new vf({code:mf.REMOTE_STREAM_NOT_EXIST,message:"because the remote user ".concat(this.userId_," unpublished stream")})}},{key:"setDelay",value:function(e){var t=e.audioDelay,n=e.videoDelay;this.delay_={audioDelay:t,videoDelay:n}}},{key:"getDelay",value:function(){return this.delay_}}]),e}();function kg(e,t,n,r){if(this.useStringRoomId_){if(!Qd(e)||!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e))throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_ROOMID_STRING",data:t,link:{className:r,fnName:n}})})}else if(!(Xd(e)&&/^[1-9]\d*$/.test(String(e))&&e<4294967295))throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_ROOMID_INTEGER",data:t,link:{className:r,fnName:n}})})}function Ig(e,t,n,r){if(!/^[A-Za-z\d_-]*$/.test(e))throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_STREAM_ID",data:t,link:{className:r,fnName:n}})})}var Tg,wg,Rg={TRTC:{createClient:{name:"clientConfig",required:!0,type:kd,properties:{sdkAppId:{required:!0,type:Sd,allowEmpty:!1},userId:{required:!0,type:yd,allowEmpty:!1},userSig:{required:!0,type:yd,allowEmpty:!1},mode:{required:!0,type:yd,values:["rtc","live"]},useStringRoomId:{type:bd},autoSubscribe:{type:bd},enableAutoPlayDialog:{type:bd},streamId:{type:yd},userDefineRecordId:{type:yd},pureAudioPushMode:{type:Sd,values:[1,2]}}},createStream:{name:"streamConfig",required:!0,type:kd,properties:{userId:{type:yd},audio:{type:bd},video:{type:bd},screen:{type:bd},screenAudio:{type:bd},microphoneId:{type:yd},cameraId:{type:yd},facingMode:{type:yd,values:[pl,fl]},audioSource:{instanceOf:MediaStreamTrack},videoSource:{instanceOf:MediaStreamTrack}},validate:function(e){if(!Kd(e.screen)&&e.screen&&Kd(e.audio)&&(e.audio=!1),!(Kd(e.audio)&&Kd(e.video)||Kd(e.audioSource)&&Kd(e.videoSource)))throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_CREATE_STREAM_SOURCE"})});if(!Kd(e.screen)&&!0===e.screen&&!0===e.video)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_CREATE_STREAM_SCREEN"})});if(e.audio&&e.screenAudio)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_CREATE_STREAM_AUDIO"})});if(!0!==e.screen&&!0===e.screenAudio)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_CREATE_STREAM_SCREEN_AUDIO"})});if(!Kd(e.screen)&&!0===e.screen&&!this.isScreenShareSupported())throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"NOT_SUPPORTED_CAPTURE"})})}}},CLIENT:{join:{name:"options",required:!0,properties:{roomId:{required:!0,type:[Sd,yd],allowEmpty:!1,validate:kg},role:{type:[yd],values:["anchor","audience"]}}},publish:{name:"stream",required:!0,instanceOf:Pd,validate:function(e){if(!this.isJoined_)throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_PUBLISH"})});if("live"===this.mode_&&"audience"===this.role_)throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_AUDIENCE"})});if(this.localStream_)throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_DUPLICATE_PUBLISHING"})});if(!e.getIsReadyToPublish())throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_INITIALIZE"})});if(this.notPublishWithoutH264Supported_)throw new vf({code:mf.NOT_SUPPORTED_H264,message:zf({key:Vf})})}},unpublish:{name:"stream",required:!0,instanceOf:Pd,validate:function(e){if(e!==this.localStream_)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_UNPUBLISH"})})}},subscribe:[{name:"stream",required:!0,instanceOf:Dd,validate:function(e){if(!e.getConnection())throw new vf({code:mf.INVALID_OPERATION,message:zf({key:Pf})});if(this.notSubscribeWithoutH264Supported_)throw new vf({code:mf.NOT_SUPPORTED_H264,message:zf({key:Ff})})}},{name:"options",type:kd,properties:{audio:{type:bd},video:{type:bd}}}],unsubscribe:{name:"stream",required:!0,instanceOf:Dd,validate:function(e){if(!e.getConnection())throw new vf({code:mf.INVALID_OPERATION,message:zf({key:Pf})})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate:function(){if("live"!==this.mode_)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_ROLE"})});if(!this.isJoined_)throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_OPERATION_SWITCH_ROLE"})})}},startPublishCDNStream:{name:"options",required:!1,properties:{streamId:{type:yd,validate:Ig},appId:{type:Sd,allowEmpty:!1},bizId:{type:Sd,allowEmpty:!1},url:{type:yd,allowEmpty:!1}}},startMixTranscode:{name:"config",required:!0,type:kd,properties:{mode:{type:yd,values:["preset-layout","manual"]},streamId:{type:yd,validate:Ig},videoWidth:{type:Sd,notLessThanZero:!0},videoHeight:{type:Sd,notLessThanZero:!0},videoBitrate:{type:Sd,notLessThanZero:!0,allowEmpty:!1},videoFramerate:{type:Sd,validate:function(e,t,n,r){if(e<=0||e>30)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"MIX_PARAMS_VIDEO_FRAMERATE",link:{className:r,fnName:n}})})}},videoGop:{type:Sd,validate:function(e,t,n,r){if(e<1||e>8)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"MIX_PARAMS_VIDEO_GOP",link:{className:r,fnName:n}})})}},audioSampleRate:{type:Sd,notLessThanZero:!0},audioBitrate:{type:Sd,validate:function(e,t,n,r){if(e<32||e>192)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"MIX_PARAMS_AUDIO_BITRATE",link:{className:r,fnName:n}})})}},audioChannels:{type:Sd,values:[1,2]},backgroundColor:{type:Sd},backgroundImage:{type:yd},mixUsers:{required:!0,type:"array",arrayItem:{require:!0,type:kd,properties:{userId:{required:!0,type:yd},roomId:{type:[yd,Sd],validate:kg},pureAudio:{type:bd},width:{type:Sd,notLessThanZero:!0},height:{type:Sd,notLessThanZero:!0},locationX:{type:Sd,notLessThanZero:!0},locationY:{type:Sd,notLessThanZero:!0},zOrder:{type:Sd},streamType:{type:yd,values:["main","auxiliary"]}}}}},validate:function(e,t,n,r,i){var o=0,a=0,s=e.mixUsers,c=[];if(s.forEach((function(e,t){if(c.push(e.userId),!e.pureAudio){if(!e.zOrder||e.zOrder<1||e>15)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"MIX_PARAMS_USER_Z_ORDER",data:"config.mixUsers[".concat(t,"].zOrder"),link:{className:r,fnName:n}})});e.width+e.locationX>o&&(o=e.width+e.locationX),e.height+e.locationY>a&&(a=e.height+e.locationY)}})),c.indexOf(this.getUserId())<0)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"MIX_PARAMS_NOT_SELF",link:{className:r,fnName:n}})});if(e.videoWidth<o||e.videoHeight<a)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"MIX_PARAMS_USER_STREAM",link:{className:r,fnName:n}})})}}},LOCAL_STREAM:{switchDevice:[{name:"type",required:!0,type:yd,values:[ll,dl]},{name:"deviceId",required:!0,type:yd,validate:function(){if(this.screen_&&!this.audio_||this.audioSource_||this.videoSource_)throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_SWITCH_DEVICE"})});if(0===this.publishState_)throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_SWITCH_DEVICE_PUBLISHING"})})}}]},STREAM:{play:[{name:"elementId",required:!0,type:[yd,"HTMLDivElement"],validate:function(e,t,n){if(Qd(e)){var r=document.getElementById(e);if(!r)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_ELEMENT_ID",data:{key:t,fnName:n}})});if(!(r instanceof HTMLDivElement))throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_ELEMENT_ID_TYPE",data:{key:t,fnName:n,type:eh(r)}})})}}},{name:"options",type:kd,properties:{objectFit:{type:yd,values:["contain","cover","fill"]},muted:{type:bd},mirror:{type:bd}}}]}};function Eg(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e,n,r){var i=r.value;return r.value=function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];return xg.call(this,t,r,n,this.name_),i.apply(this,r)},r}}function Cg(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e,n,r){var i=r.value;return r.value=o(regeneratorRuntime.mark((function e(){var r,o,a,s=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r=s.length,o=new Array(r),a=0;a<r;a++)o[a]=s[a];return xg.call(this,t,o,n,this.name_),e.abrupt("return",i.apply(this,o));case 3:case"end":return e.stop()}}),e,this)}))),r}}function xg(e,t,n,r){try{for(var i=0;i<e.length;i++)Ag.call(this,{rule:e[i],value:t[i],key:e[i].name,fnName:n,className:r})}catch(e){throw Pp.error(e),e}}function Ag(e){var t=this,n=e.rule,r=e.value,i=e.key,o=e.fnName,a=e.className;if(Kd(r)){if(n.required)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_PARAMETER_REQUIRED",data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})})}else{if(Array.isArray(n.type)){if(!n.type.map((function(e){return e.toLowerCase()})).includes(eh(r)))throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:Ef,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})})}else if(!Kd(n.type)&&eh(r)!==n.type)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:Ef,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})});if(!1===n.allowEmpty){var s=Xd(r)&&(0===r||Number.isNaN(r)),c=Qd(r)&&""===r.trim();if(s||c)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_PARAMETER_EMPTY",data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})})}if(n.notLessThanZero&&Xd(r)&&r<0)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"CANNOT_LESS_THAN_ZERO",data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})});if(Qd(n.instanceOf)){if(!r||r.name_!==n.instanceOf)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:Cf,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})})}else if(qd(n.instanceOf)&&!(r instanceof n.instanceOf))throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:Cf,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})});if(n.values&&!n.values.includes(r))throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_PARAMETER_RANGE",data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})});var u=n.properties;Wd(u)&&"object"===eh(r)&&Object.keys(u).forEach((function(e){Ag.call(t,{rule:u[e],value:r&&r[e],key:"".concat(i,".").concat(e),fnName:o,className:a})}));var l=n.arrayItem;Wd(l)&&Yd(r)&&r.forEach((function(e,n){Ag.call(t,{rule:l,value:e,key:"".concat(i,"[").concat(n,"]"),fnName:o,className:a})})),qd(n.validate)&&n.validate.call(this,r,i,o,a,this)}}Rt({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var Pg=(Tg=Cg.apply(void 0,S(Rg.STREAM.play)),T((wg=function(){function e(t){a(this,e),this.name_="Stream",this.userId_=t.userId,this.isRemote_=t.isRemote,this.type_=t.type,this.log_=Pp.createLogger({id:"s".concat(t.seq?t.seq:"","|").concat(this.userId_),userId:Kd(t.client)?void 0:t.client.getUserId(),sdkAppId:Kd(t.client)?void 0:t.client.getSDKAppId(),isLocal:!this.isRemote_,type:this.isRemote_?this.type_:""}),this.client_=null,Kd(t.client)||(this.client_=t.client),this.mediaStream_=null,this.div_=null,this.isPlaying_=!1,this.connection_=null,this.audioPlayer_=null,this.videoPlayer_=null,this.muted_=!1,this.objectFit_="cover",this.mirror_=!1,this.id_=sm(),this.audioOutputDeviceId_=0,this.audioVolume_=1,this.emitter_=new gp,this.connectionState_=Nl,this.installEvents(),Kd(t.mirror)||this.log_.warn('TRTC.createStream "mirror" option was deprecated since v4.12.1,please use localStream.play to set up preview mirror. refer to '.concat(Od,"/en/LocalStream.html#play. TRTC.createStream 接口的 mirror 选项从 v4.12.1 开始被废弃,请使用 localStream.play 设置本地流预览镜像,参考文档:").concat(Od,"/zh-cn/LocalStream.html#play。"))}var n,r,i,s,u;return c(e,[{key:"installEvents",value:function(){yp.on(Ep,this.restartPlayback,this)}},{key:"uninstallEvents",value:function(){yp.off(Ep,this.restartPlayback,this)}},{key:"getType",value:function(){return this.type_}},{key:"getLogger",value:function(){return this.log_}},{key:"isSubscribed",get:function(){return this.type_===Ll&&this.connection_.isMainStreamSubscribed||this.type_===Ml&&this.connection_.isAuxStreamSubscribed}},{key:"isMainVideoSubscribed",get:function(){var e=this.getSubscribedState();return this.type_===Ll&&e&&e.video}},{key:"isMainAudioSubscribed",get:function(){var e=this.getSubscribedState();return this.type_===Ll&&e&&e.audio}},{key:"isAuxVideoSubscribed",get:function(){var e=this.getSubscribedState();return this.type_===Ml&&e&&e.auxiliary}},{key:"isSmallVideoSubscribed",get:function(){var e=this.getSubscribedState();return this.type_===Ll&&e&&e.smallVideo}},{key:"emitConnectionStateChanged",value:function(e){e.state!==this.connectionState_&&(e.state!==Nl&&this.isRemote_&&!this.isSubscribed||(this.emitter_.emit("connection-state-changed",e),this.connectionState_=e.state))}},{key:"setConnection",value:function(e){this.connection_!==e&&(e instanceof bg?(null!==this.connection_&&this.connection_.off(Bm,this.emitConnectionStateChanged,this),e.on(Bm,this.emitConnectionStateChanged,this)):null===e&&this.connection_.off(Bm,this.emitConnectionStateChanged,this),this.connection_=e)}},{key:"getConnection",value:function(){return this.connection_}},{key:"play",value:(u=o(regeneratorRuntime.mark((function e(t,n){var r,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.log_.info("stream ".concat(this.isPlaying_?"update":"start to"," play with elementId: ").concat(t," and options: ").concat(JSON.stringify(n),".")),!this.isPlaying_){e.next=9;break}return n&&!Kd(n.muted)&&(this.muted_=n.muted),n&&!Kd(n.objectFit)&&(this.objectFit_=n.objectFit),this.isScreenShare()?this.mirror_=!1:n&&!Kd(n.mirror)&&(this.mirror_=n.mirror),this.audioPlayer_&&this.audioPlayer_.setMuted(this.muted_),this.videoPlayer_&&(this.videoPlayer_.setObjectFit(this.objectFit_),this.videoPlayer_.setMirror(this.mirror_)),this.elementId_!==t&&(r=t,Qd(t)&&(r=document.getElementById(t)),r.appendChild(this.div_),this.elementId_=t),e.abrupt("return");case 9:return this.isPlaying_=!0,(i=document.createElement("div")).setAttribute("id","player_".concat(this.id_)),i.setAttribute("style","width: 100%; height: 100%; position: relative; background-color: black; overflow: hidden;"),o=t,Qd(t)&&(o=document.getElementById(t)),o.appendChild(i),this.elementId_=t,this.div_=i,this.isRemote_||(this.muted_=!0),n&&!Kd(n.muted)&&(this.muted_=n.muted),this.isScreenShare()&&(this.objectFit_="contain"),n&&!Kd(n.objectFit)&&(this.objectFit_=n.objectFit),this.isScreenShare()?this.mirror_=!1:(this.isRemote_||(this.mirror_=!0),n&&!Kd(n.mirror)&&(this.mirror_=n.mirror)),yp.emit(132,{stream:this}),e.next=26,Promise.all([this.playAudio(),this.playVideo()]);case 26:yp.emit(100,{stream:this});case 27:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"playAudio",value:(s=o(regeneratorRuntime.mark((function e(){var n,r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasAudio()&&(!this.isRemote_||this.isMainAudioSubscribed)){e.next=2;break}return e.abrupt("return");case 2:if(n=this.getAudioTrack(),this.audioPlayer_||!n){e.next=17;break}return this.log_.info("stream - create AudioPlayer and play"),this.audioPlayer_=new Z_({stream:this,track:n,div:this.div_,muted:this.muted_,outputDeviceId:this.audioOutputDeviceId_,volume:this.audioVolume_}),this.audioPlayer_.on(Zm,(function(e){var n={type:ll,state:e.state,reason:e.reason};yp.emit(101,t({stream:r},n)),r.emitter_.emit($m,n)})),e.prev=7,e.next=10,this.audioPlayer_.play();case 10:e.next=17;break;case 12:throw e.prev=12,e.t0=e.catch(7),this.client_&&this.client_.getEnableAutoPlayDialog()&&new yg,this.emitter_.emit(Ym,e.t0),e.t0;case 17:case"end":return e.stop()}}),e,this,[[7,12]])}))),function(){return s.apply(this,arguments)})},{key:"playVideo",value:(i=o(regeneratorRuntime.mark((function e(){var n,r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasVideo()&&(!this.isRemote_||this.isMainVideoSubscribed||this.isAuxVideoSubscribed||this.isSmallVideoSubscribed)){e.next=2;break}return e.abrupt("return");case 2:if(n=this.getVideoTrack(),this.videoPlayer_||!n){e.next=18;break}return yp.emit(134,{stream:this}),this.log_.info("stream - create VideoPlayer and play"),this.videoPlayer_=new Sg({stream:this,track:n,div:this.div_,muted:this.muted_,objectFit:this.objectFit_,mirror:this.mirror_}),this.videoPlayer_.on(Zm,(function(e){var n={type:dl,state:e.state,reason:e.reason};yp.emit(101,t({stream:r},n)),r.emitter_.emit($m,n)})),e.prev=8,e.next=11,this.videoPlayer_.play();case 11:e.next=18;break;case 13:throw e.prev=13,e.t0=e.catch(8),this.client_&&this.client_.getEnableAutoPlayDialog()&&new yg,this.emitter_.emit(Ym,e.t0),e.t0;case 18:case"end":return e.stop()}}),e,this,[[8,13]])}))),function(){return i.apply(this,arguments)})},{key:"stopAudio",value:function(){this.audioPlayer_&&(this.log_.info("stream - stop AudioPlayer"),this.audioPlayer_.stop(),this.audioPlayer_=null)}},{key:"stopVideo",value:function(){this.videoPlayer_&&(this.log_.info("stream - stop VideoPlayer"),this.videoPlayer_.stop(),this.videoPlayer_=null)}},{key:"restartPlayback",value:function(){this.audioPlayer_&&!this.audioPlayer_.isPlaying&&this.restartAudio(),this.videoPlayer_&&!this.videoPlayer_.isPlaying&&this.restartVideo()}},{key:"restartAudio",value:function(){this.isPlaying_&&(this.stopAudio(),this.playAudio().catch((function(e){})))}},{key:"restartVideo",value:function(){this.isPlaying_&&(this.stopVideo(),this.playVideo().catch((function(e){})))}},{key:"stop",value:function(){this.isPlaying_&&(this.isPlaying_=!1,this.stopAudio(),this.stopVideo(),this.div_.parentNode.removeChild(this.div_))}},{key:"resume",value:(r=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isPlaying_){e.next=2;break}return e.abrupt("return");case 2:if(this.log_.info("stream - resume"),!this.audioPlayer_){e.next=6;break}return e.next=6,this.audioPlayer_.resume();case 6:if(!this.videoPlayer_){e.next=9;break}return e.next=9,this.videoPlayer_.resume();case 9:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"close",value:function(){this.isPlaying_&&this.stop(),this.isRemote_||(this.mediaStream_&&(this.mediaStream_.preventEvent=1,this.mediaStream_.getTracks().forEach((function(e){e.stop()})),this.mediaStream_=null),this.uninstallEvents())}},{key:"muteAudio",value:function(){return this.addRemoteEvent(!0,ll),this.doEnableTrack(ll,!1)}},{key:"muteVideo",value:function(){return this.addRemoteEvent(!0,dl),this.doEnableTrack(dl,!1)}},{key:"unmuteAudio",value:function(){return this.addRemoteEvent(!1,ll),this.doEnableTrack(ll,!0)}},{key:"unmuteVideo",value:function(){return this.addRemoteEvent(!1,dl),this.doEnableTrack(dl,!0)}},{key:"addRemoteEvent",value:function(e,t){if(this.isRemote_&&this.client_){var n=this.client_.getUserId(),r="".concat(e?ml:vl," remote ").concat(t);yf(n,{eventId:t===ll?e?32785:32787:e?32784:32786,eventDesc:r,timestamp:(new Date).getTime(),userId:n,tinyId:this.client_.getTinyId(),remoteUserId:this.userId_,remoteTinyId:this.connection_.getTinyId()})}}},{key:"doEnableTrack",value:function(e,t){var n=!1;return e===ll?this.mediaStream_.getAudioTracks().forEach((function(e){n=!0,e.enabled=t})):this.mediaStream_.getVideoTracks().forEach((function(e){n=!0,e.enabled=t})),n}},{key:"getId",value:function(){return this.id_}},{key:"getUserId",value:function(){return this.userId_}},{key:"getTinyId",value:function(){return this.connection_?this.connection_.getTinyId():""}},{key:"isPlaying",value:function(){return this.isPlaying_}},{key:"setAudioOutput",value:(n=o(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.audioOutputDeviceId_=t,!this.audioPlayer_){e.next=4;break}return e.next=4,this.audioPlayer_.setSinkId(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setAudioVolume",value:function(e){this.audioVolume_=e,this.log_.info("setAudioVolume to ".concat(e)),this.audioPlayer_&&this.audioPlayer_.setVolume(e)}},{key:"getAudioLevel",value:function(){var e=0;return this.audioPlayer_&&(e=this.audioPlayer_.getAudioLevel()),e}},{key:"hasAudio",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var e=this.connection_.getTrackState();return this.type_===Ll&&e.audio}return!!this.getAudioTrack()}},{key:"hasVideo",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var e=this.connection_.getTrackState();return this.type_===Ml?e.auxiliary:e.video}return!!this.getVideoTrack()}},{key:"getSubscribedState",value:function(){return this.isRemote_&&this.connection_?this.connection_.getSubscribeState():null}},{key:"getAudioTrack",value:function(){var e=null;if(this.mediaStream_){var t=this.mediaStream_.getAudioTracks();t.length>0&&(e=t[0])}return e}},{key:"getVideoTrack",value:function(){var e=null;if(this.mediaStream_){var t=this.mediaStream_.getVideoTracks();t.length>0&&(e=t[0])}return e}},{key:"getVideoFrame",value:function(){return this.videoPlayer_?this.videoPlayer_.getVideoFrame():null}},{key:"getMediaStream",value:function(){return this.mediaStream_}},{key:"setMediaStream",value:function(e){e!==this.mediaStream_&&(this.mediaStream_&&this.mediaStream_.getTracks().forEach((function(e){return e.stop()})),this.mediaStream_=e)}},{key:"updateVideoPlayingState",value:function(e){this.isPlaying_&&(e?(this.log_.info("playing state updated, play video"),this.playVideo().catch((function(e){}))):(this.log_.info("playing state updated, stop video"),this.stopVideo()))}},{key:"updateAudioPlayingState",value:function(e){this.isPlaying_&&(e?(this.log_.info("playing state updated, play audio"),this.playAudio().catch((function(e){}))):(this.log_.info("playing state updated, stop audio"),this.stopAudio()))}},{key:"on",value:function(e,t,n){this.emitter_.on(e,t,n)}},{key:"off",value:function(e,t,n){"*"===e?this.emitter_.removeAllListeners():this.emitter_.off(e,t,n)}},{key:"isRemote",value:function(){return this.isRemote_}},{key:"isScreenShare",value:function(){return!this.isRemote_&&this.screen_||this.isRemote_&&this.getType()===hl}},{key:"getDiv",value:function(){return this.div_}},{key:"getObjectFit",value:function(){return this.objectFit_}},{key:"getMuted",value:function(){return this.muted_}},{key:"getClient",value:function(){return this.client_}}]),e}()).prototype,"play",[Tg],Object.getOwnPropertyDescriptor(wg.prototype,"play"),wg.prototype),wg),Dg=function(e){l(r,e);var n=_(r);function r(e){var i;a(this,r);var o={isRemote:!0,type:e.type},s=t(t({},e),o);return(i=n.call(this,s)).name_=Dd,i.isInSubscriptionCycle_=!1,i.isStreamAddedEventEmitted_=!1,i.isAbleToCallSubscription_=!0,i}return c(r,[{key:"installEvents",value:function(){g(d(r.prototype),"installEvents",this).call(this),yp.on(Ip,this.handleStreamSubscribed,this),yp.on(Tp,this.handleStreamUnsubscribed,this)}},{key:"uninstallEvents",value:function(){g(d(r.prototype),"uninstallEvents",this).call(this),yp.off(Ip,this.handleStreamSubscribed,this),yp.off(Tp,this.handleStreamUnsubscribed,this)}},{key:"handleStreamSubscribed",value:function(e){e.client===this.client_&&e.stream===this&&this.connection_.getCurrentState()===Vl&&this.emitConnectionStateChanged({prevState:Nl,state:Vl})}},{key:"handleStreamUnsubscribed",value:function(e){e.client===this.client_&&e.stream===this&&this.emitConnectionStateChanged({prevState:Vl,state:Nl})}},{key:"getType",value:function(){return g(d(r.prototype),"getType",this).call(this)}},{key:"getIsAbleToCallSubscription",value:function(){return this.isAbleToCallSubscription_}},{key:"setIsAbleToCallSubscription",value:function(e){this.isAbleToCallSubscription_=e}},{key:"setInSubscriptionCycle",value:function(e){this.isInSubscriptionCycle_=e}},{key:"isInSubscriptionCycle",value:function(){return this.isInSubscriptionCycle_}},{key:"setIsStreamAddedEventEmitted",value:function(e){this.isStreamAddedEventEmitted_=e}},{key:"getIsStreamAddedEventEmitted",value:function(){return this.isStreamAddedEventEmitted_}},{key:"getAudioTrack",value:function(){return this.connection_&&this.connection_.getTrackState().audio?g(d(r.prototype),"getAudioTrack",this).call(this):null}},{key:"getVideoTrack",value:function(){if(!this.connection_)return null;var e=this.connection_.getTrackState();return this.type_===Ll&&!e.video||this.type_===Ml&&!e.auxiliary?null:g(d(r.prototype),"getVideoTrack",this).call(this)}},{key:"close",value:function(){g(d(r.prototype),"close",this).call(this)}}]),r}(Pg),Lg=function(){function e(t){a(this,e),this.client_=t.client,this.subscribedStreams_=new Map,this.unsubscribedStreams_=new Map,this.subscriptedOptions_=new Map,this.autoRecoveryFlags_=new Map}var t,n,r;return c(e,[{key:"isEnabled",get:function(){return"webrtc"!==this.client_.getEnv()}},{key:"recover",value:(r=o(regeneratorRuntime.mark((function e(t){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.getUserId(),r=t.getType(),this.hasAutoRecoveryFlag(n,r)){e.next=5;break}return e.abrupt("return");case 5:if(i=this.getUnsubscribedStream(n,r)?"unsubscribe":"subscribe",e.prev=6,Pp.warn("recover() try to recover subscription [".concat(i,"][").concat(n,"][").concat(r,"]")),"subscribe"!==i){e.next=13;break}return e.next=11,this.recoverSubscription(n,t);case 11:e.next=15;break;case 13:return e.next=15,this.recoverUnsubscription(n,t);case 15:Gf.logSuccessEvent({userId:this.client_.getUserId(),eventType:ad}),Pp.warn("recover() recover successfully [".concat(i,"][").concat(n,"][").concat(r,"]")),e.next=23;break;case 19:e.prev=19,e.t0=e.catch(6),Pp.error("recover() recover failed [".concat(i,"][").concat(n,"][").concat(r,"]"),e.t0),Gf.logFailedEvent({userId:this.client_.getUserId(),eventType:ad,error:e.t0});case 23:this.deleteAutoRecoveryFlag(n,r);case 24:case"end":return e.stop()}}),e,this,[[6,19]])}))),function(e){return r.apply(this,arguments)})},{key:"recoverSubscription",value:(n=o(regeneratorRuntime.mark((function e(t,n){var r,i,o,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getOptions(t,n.getType()),i=this.getSubscribedStream(t,n.getType()),r&&i){e.next=4;break}return e.abrupt("return");case 4:o=this.getStreamMuteState(i),a=o.isAudioMuted,s=o.isVideoMuted,this.mergeStream(i,n),this.recoverPlayingState(i),a&&i.doEnableTrack(ll,!1),s&&i.doEnableTrack(dl,!1);case 9:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"recoverUnsubscription",value:(t=o(regeneratorRuntime.mark((function e(t,n){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getUnsubscribedStream(t,n.getType())){e.next=3;break}return e.abrupt("return");case 3:this.mergeStream(r,n);case 4:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"getStreamMuteState",value:function(e){var t={isAudioMuted:!1,isVideoMuted:!1},n=e.getMediaStream();return n&&(t.isAudioMuted=n.getAudioTracks().map((function(e){return e.enabled})).includes(!1),t.isVideoMuted=n.getVideoTracks().map((function(e){return e.enabled})).includes(!1)),t}},{key:"recoverPlayingState",value:function(e){var t=e.isPlaying(),n=e.getDiv();if(t&&n){var r=n.parentNode;e.stop(),e.play(r,{objectFit:e.getObjectFit(),muted:e.getMuted()})}}},{key:"mergeStream",value:function(e,t){var n=t.getConnection(),r=t.getMediaStream();e.setConnection(n),n.setRemoteStream(r.id,e),e.setMediaStream(r),e.updateAudioPlayingState(t.hasAudio()),e.updateVideoPlayingState(t.hasVideo())}},{key:"addSubscriptionRecord",value:function(e,t,n){var r=t.getType();if(this.subscribedStreams_.has(e))this.subscribedStreams_.get(e).set(r,t);else{var i=new Map;i.set(t.getType(),t),this.subscribedStreams_.set(e,i)}if(this.subscriptedOptions_.has(e))this.subscriptedOptions_.get(e).set(r,n);else{var o=new Map;o.set(t.getType(),n),this.subscriptedOptions_.set(e,o)}this.deleteUnsubscriptionRecord(e,r)}},{key:"addUnsubscriptionRecord",value:function(e,t){if(this.unsubscribedStreams_.has(e))this.unsubscribedStreams_.get(e).set(t.getType(),t);else{var n=new Map;n.set(t.getType(),t),this.unsubscribedStreams_.set(e,n)}this.deleteSubscriptionRecord(e,t.getType())}},{key:"getSubscribedStream",value:function(e,t){return this.subscribedStreams_.has(e)&&this.subscribedStreams_.get(e).has(t)?this.subscribedStreams_.get(e).get(t):null}},{key:"getOptions",value:function(e,t){return this.subscriptedOptions_.has(e)&&this.subscriptedOptions_.get(e).has(t)?this.subscriptedOptions_.get(e).get(t):null}},{key:"getUnsubscribedStream",value:function(e,t){return this.unsubscribedStreams_.has(e)&&this.unsubscribedStreams_.get(e).has(t)?this.unsubscribedStreams_.get(e).get(t):null}},{key:"deleteSubscriptionRecord",value:function(e,t){this.subscribedStreams_.has(e)&&this.subscribedStreams_.get(e).delete(t),this.subscriptedOptions_.has(e)&&this.subscriptedOptions_.get(e).delete(t)}},{key:"deleteUnsubscriptionRecord",value:function(e,t){this.unsubscribedStreams_.has(e)&&this.unsubscribedStreams_.get(e).delete(t)}},{key:"markAllStream",value:function(){for(var e=0,t=S(this.subscribedStreams_.entries());e<t.length;e++)for(var n=y(t[e],2),r=n[0],i=0,o=S(n[1].entries());i<o.length;i++){var a=y(o[i],1)[0];this.setAutoRecoveryFlag(r,a)}for(var s=0,c=S(this.unsubscribedStreams_.entries());s<c.length;s++)for(var u=y(c[s],2),l=u[0],d=0,h=S(u[1].entries());d<h.length;d++){var p=y(h[d],1)[0];this.setAutoRecoveryFlag(l,p)}}},{key:"setAutoRecoveryFlag",value:function(e,t){if(Pp.info("setAutoRecoveryFlag() mark [".concat(e,"][").concat(t,"]")),this.autoRecoveryFlags_.has(e))this.autoRecoveryFlags_.get(e).set(t);else{var n=new Map;n.set(t),this.autoRecoveryFlags_.set(e,n)}}},{key:"hasAutoRecoveryFlag",value:function(e,t){return!!this.isEnabled&&this.autoRecoveryFlags_.has(e)&&this.autoRecoveryFlags_.get(e).has(t)}},{key:"deleteAutoRecoveryFlag",value:function(e,t){this.autoRecoveryFlags_.has(e)&&this.autoRecoveryFlags_.get(e).delete(t)}},{key:"delete",value:function(e){this.unsubscribedStreams_.delete(e),this.subscribedStreams_.delete(e),this.subscriptedOptions_.delete(e),this.autoRecoveryFlags_.delete(e)}}]),e}(),Mg=qt("slice"),Ng=_e("species"),Og=[].slice,Ug=Math.max;Rt({target:"Array",proto:!0,forced:!Mg},{slice:function(e,t){var n,r,i,o=H(this),a=st(o),s=it(e,a),c=it(void 0===t?a:t,a);if(Ct(o)&&(n=o.constructor,(jt(n)&&(n===Array||Ct(n.prototype))||G(n)&&null===(n=n[Ng]))&&(n=void 0),n===Array||void 0===n))return Og.call(o,s,c);for(r=new(void 0===n?Array:n)(Ug(c-s,0)),i=0;s<c;s++,i++)s in o&&qi(r,i,o[s]);return r.length=i,r}}),Rt({target:"String",proto:!0,forced:wf("small")},{small:function(){return Tf(this,"small","","")}});var Vg=function(){function e(t){a(this,e),this.player_=t,this.canvas_=document.createElement("canvas"),this.canvasCtx_=this.canvas_.getContext("2d")}return c(e,[{key:"setCanvasRect",value:function(e,t){this.canvas_.width=e,this.canvas_.height=t}},{key:"drawVideoToCanvas",value:function(){var e=this.player_.getElement();this.canvasCtx_.drawImage(e,0,0,this.canvas_.width,this.canvas_.height)}},{key:"generateVideoTrackFromCanvasCapture",value:function(e){return this.canvas_.captureStream(e).getVideoTracks()[0]}},{key:"generateStreamFromTrack",value:function(e){var t=new MediaStream;return t.addTrack(e),t}},{key:"destroy",value:function(){this.player_.stop(),this.canvas_=null,this.canvasCtx_=null}},{key:"canvas",get:function(){return this.canvas_}},{key:"canvasCtx",get:function(){return this.canvasCtx_}},{key:"canDrawVideoToCanvas",get:function(){if(this.player_){var e=this.player_.getElement();if(e)return e.readyState===e.HAVE_ENOUGH_DATA}return!1}}]),e}(),Fg=function(){function e(t){a(this,e),this.localStream_=t,this.player_=new Sg({stream:t,track:t.getVideoTrack(),muted:!0,objectFit:"cover",mirror:!1}),this.player_.play().then((function(){Pp.info("VideoGenerator: play local video success")})).catch((function(){Pp.error("VideoGenerator: Failed to play local video")})),this.processor_=new Vg(this.player_)}return c(e,[{key:"generateSmallVideoTrack",value:function(e){var t=this.getSmallVideoProfile(e);this.processor_.setCanvasRect(t.width,t.height),this.player_.setRect({width:t.width,height:t.height});var n=this.processor_.generateVideoTrackFromCanvasCapture(t.frameRate);return this.interval_=cm.setInterval(this.render.bind(this),Math.ceil(1e3/t.frameRate)),n}},{key:"render",value:function(){this.processor_.canDrawVideoToCanvas&&this.processor_.drawVideoToCanvas()}},{key:"destroy",value:function(){cm.clearInterval(this.interval_),this.processor_&&this.processor_.destroy()}},{key:"getSmallVideoProfile",value:function(e){var t,n=this.localStream_.getVideoTrack(),r=this.localStream_.getVideoProfile(),i=n.getSettings(),o=i&&i.width&&i.height?{width:i.width,height:i.height}:r,a=o.width*o.height,s=e.width*e.height;return Pp.log("big stream resolution: ".concat(o.height,"*").concat(o.width," small stream resolution: ").concat(e.height,"*").concat(e.width," ")),a>s?t=a/s:(Pp.warn("Small stream resolution is larger than big stream, which is invalid. big: ".concat(o.width," * ").concat(o.height," small: ").concat(e.width," * ").concat(e.height)),t=a/19200),{width:parseInt(o.width/Math.sqrt(t)),height:parseInt(o.height/Math.sqrt(t)),frameRate:e.frameRate}}}]),e}(),jg={voiceActivityDetection:!1},Bg=function(e){l(k,e);var t,n,r,i,s,u,h,p,f,m,v,y,S,b=_(k);function k(e){var t;return a(this,k),(t=b.call(this,e)).localStream_=null,t.exchangeSDPTimeout_=-1,t.smallGenerator_=null,t.isSDPExchanging_=!1,t.ssrc_={audio:0,video:0,small:0},t.canvasTrack_=null,t}return c(k,[{key:"initialize",value:function(){g(d(k.prototype),"initialize",this).call(this),this.installEvents()}},{key:"reset",value:function(){g(d(k.prototype),"close",this).call(this),this.uninstallEvents(),this.clearExchangeSDPTimeout(),this.canvasTrack_=null,this.localStream_&&this.localStream_.clearCanvas()}},{key:"close",value:function(){this.reset(),this.emitConnectionStateChangedEvent(Nl),this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null)}},{key:"installEvents",value:function(){this.emitter_.on(jm,this.handleError,this),this.emitter_.on(Bm,this.handleConnectionStateChange,this)}},{key:"uninstallEvents",value:function(){this.emitter_.off(jm,this.handleError,this),this.emitter_.off(Bm,this.handleConnectionStateChange,this)}},{key:"publish",value:(S=o(regeneratorRuntime.mark((function e(t){var n,r,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.localStream_=t,n=t.getMediaStream(),this.log_.info("is publishing stream: ".concat(t.getId())),r=this.localStream_.getAudioTrack(),i=this.localStream_.getVideoTrack(),r&&this.peerConnection_.addTrack(r,n),i&&(il&&Zd(i)?(this.canvasTrack_=this.localStream_.genCanvasTrack(i),this.peerConnection_.addTrack(this.canvasTrack_,n)):this.peerConnection_.addTrack(i,n),this.client_.getIsEnableSmallStream()&&(this.smallGenerator_=new Fg(this.localStream_),o=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),this.peerConnection_.addTrack(o,n))),e.next=9,this.connect();case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"updateMediaSettings",value:function(e){var t=this,n=this.client_.getSystemResult().detail,r=n.isH264EncodeSupported,i=n.isVp8EncodeSupported,o="";r?o="H264":i&&(o="VP8");var a={videoCodec:o,videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0};return Mm?e.getTracks().forEach((function(e){var n=e.getSettings();if(e.kind===ll){var r=1;n.channelCount&&(r=n.channelCount),a.audioChannel=r,a.audioBps=1e3*t.localStream_.getAudioBitrate(),a.audioFs=n.sampleRate}else e.kind===dl&&(t.client_.getIsEnableSmallStream()&&(a.smallVideoWidth=t.client_.smallStreamConfig.width,a.smallVideoHeight=t.client_.smallStreamConfig.height,a.smallVideoFps=t.client_.smallStreamConfig.framerate,a.smallVideoBps=1e3*t.client_.smallStreamConfig.bitrate),a.videoWidth=n.width,a.videoHeight=n.height,a.videoFps=n.frameRate,a.videoBps=1e3*t.localStream_.getVideoBitrate())})):a=this.getMediaSettingsFromProfile(a),this.log_.info("updateMediaSettings: "+JSON.stringify(a)),a}},{key:"getMediaSettingsFromProfile",value:function(e){var t=this.localStream_;if(t){if(t.getAudioTrack()){var n=t.getAudioProfile();e.audioChannel=n.channelCount,e.audioBps=1e3*n.bitrate,e.audioFs=n.sampleRate}if(t.getVideoTrack()){var r=t.getVideoProfile();e.videoWidth=r.width,e.videoHeight=r.height,e.videoFps=r.frameRate,e.videoBps=1e3*r.bitrate}}return e}},{key:"addTrack",value:(y=o(regeneratorRuntime.mark((function e(t){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.peerConnection_){e.next=19;break}if(t.kind===dl&&il&&Zd(t)&&(t=this.canvasTrack_=this.localStream_.genCanvasTrack(t)),this.log_.info("is adding ".concat(t.kind," track to current published local stream")),!(Im()&&this.peerConnection_.getTransceivers().findIndex((function(e){return"stopped"===e.direction}))>=0)){e.next=7;break}return this.log_.warn("transceiver is stopping, negotiate sdp first"),e.next=7,this.updateOffer(Td,t);case 7:if(!(n=this.peerConnection_.getSenders().find((function(e){return e.track&&e.track.kind===t.kind})))){e.next=14;break}return this.log_.warn("sender already exists, remove sender first"),r=n.track,this.removeSender(n),e.next=14,this.updateOffer(Td,r);case 14:return i=this.localStream_.getMediaStream(),this.peerConnection_.addTrack(t,i),e.next=18,this.updateOffer(Id,t);case 18:yf(this.userId_,{eventId:t.kind===ll?32769:32768,eventDesc:"add ".concat(t.kind," track to current published stream"),timestamp:Sa(),userId:this.userId_,tinyId:this.tinyId_});case 19:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"isNeedToResetOfferOrder",value:function(){if("plan-b"===this.sdpSemantics_||!this.peerConnection_||!this.peerConnection_.localDescription)return!1;for(var e=this.peerConnection_.localDescription.sdp,t=nm(e),n=0;n<t.media.length;n++)if(0===t.media[n].mid&&t.media[n].type===dl)return!0;return!1}},{key:"removeSender",value:function(e){var t=null;Im()&&(t=this.peerConnection_.getTransceivers().find((function(t){return t.sender&&t.sender.track===e.track}))),this.peerConnection_.removeTrack(e),t&&qd(t.stop)&&(this.log_.info("stop transceiver"),t.stop())}},{key:"removeTrack",value:(v=o(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.peerConnection_||!km()){e.next=14;break}if(t.kind===dl&&il&&this.canvasTrack_&&(t=this.canvasTrack_,this.localStream_.clearCanvas()),this.log_.info("is removing ".concat(t.kind," track from current published local stream")),t.kind!==dl||!this.isNeedToResetOfferOrder()){e.next=9;break}return this.reset(),this.initialize(),e.next=8,this.publish(this.localStream_);case 8:return e.abrupt("return");case 9:return(n=this.peerConnection_.getSenders().find((function(e){return e.track===t})))&&this.removeSender(n),e.next=13,this.updateOffer(Td,t);case 13:yf(this.userId_,{eventId:t.kind===ll?32771:32770,eventDesc:"remove ".concat(t.kind," track from current published stream"),timestamp:Sa(),userId:this.userId_,tinyId:this.tinyId_});case 14:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"isReplaceTrackAvailable",value:function(){return"RTCRtpSender"in window&&"replaceTrack"in window.RTCRtpSender.prototype}},{key:"replaceTrack",value:(m=o(regeneratorRuntime.mark((function e(t){var n,r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.kind!==dl||!il||!this.canvasTrack_){e.next=2;break}return e.abrupt("return");case 2:if(this.isReplaceTrackAvailable()&&km()){e.next=4;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"NOT_SUPPORTED_REPLACE_TRACK"})});case 4:if(this.peerConnection_){e.next=6;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:Of})});case 6:if(0!==(n=this.peerConnection_.getSenders()).length){e.next=9;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:Of})});case 9:n.forEach((function(e){e.track&&e.track.kind===t.kind&&(r.log_.info("is replacing ".concat(t.kind," track to current published local stream")),e.replaceTrack(t))})),yf(this.userId_,{eventId:t.kind===ll?32783:32782,eventDesc:"replace ".concat(t.kind," track from current published stream"),timestamp:Sa(),userId:this.userId_,tinyId:this.tinyId_});case 11:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"setBandwidth",value:(f=o(regeneratorRuntime.mark((function e(t,n,r){var i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isUplink_){e.next=2;break}return e.abrupt("return",r);case 2:if(Tm()){e.next=4;break}return e.abrupt("return",n===dl?this.updateVideoBandwidthRestriction(r,t):this.updateAudioBandwidthRestriction(r,t));case 4:if(!(i=this.peerConnection_.getSenders().find((function(e){return e.track&&e.track.kind===n})))){e.next=20;break}return(o=i.getParameters()).encodings&&0!==o.encodings.length||(o.encodings=[{}]),"unlimited"===t?delete o.encodings[0].maxBitrate:o.encodings[0].maxBitrate=1e3*t,e.prev=9,e.next=12,i.setParameters(o);case 12:return this.log_.info(n+" bandwidth was set to "+t+" kbps"),e.abrupt("return",r);case 16:return e.prev=16,e.t0=e.catch(9),this.log_.info("failed to set bandwidth by setting maxBitrate: "+e.t0),e.abrupt("return",n===dl?this.updateVideoBandwidthRestriction(r,t):this.updateAudioBandwidthRestriction(r,t));case 20:return e.abrupt("return",r);case 21:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n){return f.apply(this,arguments)})},{key:"setSmallStreamBandwidth",value:(p=o(regeneratorRuntime.mark((function e(t,n){var r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isUplink_){e.next=2;break}return e.abrupt("return",n);case 2:if(Tm()){e.next=4;break}return e.abrupt("return",this.updateSmallVideoBandwidthRestriction(n,t));case 4:if(!(r=this.peerConnection_.getSenders().filter((function(e){return e.track&&e.track.kind===dl}))[1])){e.next=20;break}return(i=r.getParameters()).encodings&&0!==i.encodings.length||(i.encodings=[{}]),"unlimited"===t?delete i.encodings[0].maxBitrate:i.encodings[0].maxBitrate=1e3*t,e.prev=9,e.next=12,r.setParameters(i);case 12:return this.log_.info("small stream bandwidth was set to "+t+" kbps"),e.abrupt("return",n);case 16:return e.prev=16,e.t0=e.catch(9),this.log_.info("failed to set small stream bandwidth by setting maxBitrate: "+e.t0),e.abrupt("return",this.updateSmallVideoBandwidthRestriction(n,t));case 20:return e.abrupt("return",n);case 21:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t){return p.apply(this,arguments)})},{key:"updateVideoBandwidthRestriction",value:function(e,t){var n="AS";return uu&&(n="TIAS",t*=1e3),-1===e.indexOf("b="+n+":")?e.replace(/m=video (.*)\r\nc=IN (.*)\r\n/,"m=video $1\r\nc=IN $2\r\nb="+n+":"+t+"\r\n"):e.replace(new RegExp("b="+n+":.*\r\n"),"b="+n+":"+t+"\r\n")}},{key:"updateAudioBandwidthRestriction",value:function(e,t){var n="AS";return uu&&(n="TIAS",t*=1e3),e.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,"m=audio $1\r\nc=IN $2\r\nb="+n+":"+t+"\r\n")}},{key:"updateSmallVideoBandwidthRestriction",value:function(e,t){var n="AS";uu&&(n="TIAS",t*=1e3);var r=/m=video (.*)\r\nc=IN (.*)\r\n/g,i=[],o=r.exec(e);for(i.push(o);null!==o;)o=r.exec(e),i.push(o);var a=i[i.length-2],s=e.slice(0,a.index),c=e.slice(a.index);return-1===e.indexOf("b="+n+":")?s+(c=c.replace(/m=video (.*)\r\nc=IN (.*)\r\n/,"m=video $1\r\nc=IN $2\r\nb="+n+":"+t+"\r\n")):s+(c=c.replace(new RegExp("b="+n+":.*\r\n"),"b="+n+":"+t+"\r\n"))}},{key:"removeBandwidthRestriction",value:function(e){return e.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}},{key:"removeVideoOrientation",value:function(e){return e.replace(/urn:3gpp:video-orientation/,"")}},{key:"connect",value:(h=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.exchangeSDP();case 3:return e.next=5,this.waitForPeerConnectionConnected();case 5:e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(0),this.closePeerConnection(!0),e.t0;case 11:case"end":return e.stop()}}),e,this,[[0,7]])}))),function(){return h.apply(this,arguments)})},{key:"exchangeSDP",value:(u=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,this.isSDPExchanging_=!0,e.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),e.next=7,this.doExchangeSDP();case 7:this.isSDPExchanging_=!1,e.next=14;break;case 10:throw e.prev=10,e.t0=e.catch(0),this.isSDPExchanging_=!1,e.t0;case 14:case"end":return e.stop()}}),e,this,[[0,10]])}))),function(){return u.apply(this,arguments)})},{key:"createOffer",value:(s=o(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.peerConnection_.createOffer(jg);case 3:return t=e.sent,e.next=6,this.peerConnection_.setLocalDescription(t);case 6:this.updateSSRC(t.sdp),Gf.logSuccessEvent({userId:this.client_.getUserId(),eventType:Zl,kind:"offer"}),e.next=14;break;case 10:throw e.prev=10,e.t0=e.catch(0),Gf.logFailedEvent({userId:this.client_.getUserId(),eventType:Zl,kind:"offer",error:e.t0}),e.t0;case 14:case"end":return e.stop()}}),e,this,[[0,10]])}))),function(){return s.apply(this,arguments)})},{key:"doExchangeSDP",value:function(){var e=this;return new Promise((function(t,n){e.exchangeSDPTimeout_=setTimeout((function(){e.signalChannel_.off(pf.PUBLISH_RESULT,r),e.clearExchangeSDPTimeout();var t=new vf({code:mf.API_CALL_TIMEOUT,message:zf({key:"EXCHANGE_SDP_TIMEOUT"})});n(t)}),5e3);var r=function(){var r=o(regeneratorRuntime.mark((function r(i){var o,a,s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(r.prev=0,e.clearExchangeSDPTimeout(),o=i.data,a=o.code,s=o.message,0!==a){r.next=9;break}return r.next=6,e.acceptAnswer(i.data.data);case 6:t(),r.next=10;break;case 9:e.checkPublishResultCode(a,s);case 10:r.next=15;break;case 12:r.prev=12,r.t0=r.catch(0),n(r.t0);case 15:case"end":return r.stop()}}),r,null,[[0,12]])})));return function(e){return r.apply(this,arguments)}}(),i=e.updateMediaSettings(e.localStream_.getMediaStream()),a={type:e.peerConnection_.localDescription.type,sdp:e.removeVideoOrientation(e.peerConnection_.localDescription.sdp),screen:e.localStream_.hasScreenTrack(),constraintConfig:i};e.signalChannel_.once(pf.PUBLISH_RESULT,r),e.log_.debug("sending sdp offer: "+a.sdp),e.signalChannel_.send("publish",a)}))}},{key:"setSDPDirection",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"all",r=nm(e);return r.media.forEach((function(e){"all"!==n&&e.type!==n||(e.direction=t)})),rm(r)}},{key:"updateOffer",value:(i=o(regeneratorRuntime.mark((function e(t,n){var r,i,o,a,s,c,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.peerConnection_.createOffer(jg);case 3:return r=e.sent,uu&&(r.sdp=this.setSDPDirection(r.sdp,"sendrecv")),e.next=7,this.peerConnection_.setLocalDescription(r);case 7:return i=this.updateMediaSettings(this.localStream_.getMediaStream()),o={action:t,trackId:n.id,kind:n.kind===dl?"bigVideo":n.kind,type:"offer",sdp:this.peerConnection_.localDescription.sdp,constraintConfig:i},this.log_.info("createOffer success, sending updated offer to remote server"),this.log_.debug("updatedOffer: "+o.sdp),e.next=13,this.signalChannel_.sendWaitForResponse({command:"publish_change",data:o,responseCommand:pf.UPDATE_OFFER_RESULT,timeout:1e4,commandDesc:"update offer"});case 13:return a=e.sent,s=a.data,c=s.code,u=s.message,0!==c&&this.checkPublishResultCode(c,u),e.next=18,this.acceptAnswer(a.data.data);case 18:this.updateSSRC(r.sdp),Gf.logSuccessEvent({userId:this.client_.getUserId(),eventType:Zl,kind:"offer"}),e.next=27;break;case 22:throw e.prev=22,e.t0=e.catch(0),this.log_.error(e.t0),Gf.logFailedEvent({userId:this.client_.getUserId(),eventType:Zl,kind:"offer",error:e.t0}),e.t0;case 27:case"end":return e.stop()}}),e,this,[[0,22]])}))),function(e,t){return i.apply(this,arguments)})},{key:"acceptAnswer",value:(r=o(regeneratorRuntime.mark((function e(t){var n,r,i,o,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.localStream_.getVideoBitrate(),r=this.localStream_.getAudioBitrate(),e.prev=2,i=this.removeVideoOrientation(t.sdp),e.next=6,this.setBandwidth(n,dl,i);case 6:return i=e.sent,e.next=9,this.setBandwidth(r,ll,i);case 9:if(i=e.sent,!this.client_.getIsEnableSmallStream()){e.next=15;break}return o=this.client_.smallStreamConfig,e.next=14,this.setSmallStreamBandwidth(o.bitrate,i);case 14:i=e.sent;case 15:return a={type:t.type,sdp:i},e.next=18,this.peerConnection_.setRemoteDescription(a);case 18:this.log_.debug("accepted answer: "+i),Gf.logSuccessEvent({userId:this.client_.getUserId(),eventType:ed,kind:"answer"}),e.next=27;break;case 22:throw e.prev=22,e.t0=e.catch(2),Gf.logFailedEvent({userId:this.client_.getUserId(),eventType:ed,kind:"answer",error:e.t0}),this.log_.error("failed to accept remote answer "+e.t0),e.t0;case 27:case"end":return e.stop()}}),e,this,[[2,22]])}))),function(e){return r.apply(this,arguments)})},{key:"sendMutedFlag",value:function(e){var t={audio:e.audio,bigVideo:e.video,auxVideo:e.auxVideo};this.log_.info("send muted state: ".concat(JSON.stringify(t))),this.signalChannel_.send("mute_uplink",t)}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"reconnect",value:(n=o(regeneratorRuntime.mark((function e(){var t,n,r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(-1===this.reconnectionTimer_){e.next=3;break}return this.log_.warn("reconnect() uplink is reconnecting, ignore current reconnection"),e.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){e.next=12;break}return this.log_.warn("SDK has tried reconnect uplink for ".concat(30," times, but all failed, please check your network")),this.stopReconnection(),t=new vf({code:mf.UPLINK_RECONNECTION_FAILED,message:zf({key:"UPLINK_RECONNECTION_FAILED"})}),Gf.logFailedEvent({userId:this.client_.getUserId(),eventType:Xl,error:t}),this.addEventInternal(32799,"uplink-connection reconnect fail"),this.emitConnectionStateChangedEvent(Nl),this.emitter_.emit(jm,t),e.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===lf){e.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(3,this.reconnect,this),e.abrupt("return");case 16:if(this.reconnectionCount_++,e.prev=17,this.log_.warn("reconnect() try to reconnect uplink [".concat(this.reconnectionCount_,"/").concat(30,"]")),n=Jd(this.reconnectionCount_),this.reconnectionTimer_=setTimeout((function(){r.log_.warn("reconnect() uplink reconnect timeout(".concat(n/1e3,"s), try again")),r.signalChannel_.off(pf.UNPUBLISH_RESULT,r.onUnpublishResult,r),r.clearReconnectionTimer(),r.reconnect()}),n),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Fl)){e.next=23;break}return e.abrupt("return");case 23:this.signalChannel_.send(ff),this.signalChannel_.once(pf.UNPUBLISH_RESULT,this.onUnpublishResult,this),e.next=29;break;case 27:e.prev=27,e.t0=e.catch(17);case 29:case"end":return e.stop()}}),e,this,[[17,27]])}))),function(){return n.apply(this,arguments)})},{key:"onUnpublishResult",value:(t=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,this.reset(),this.initialize(),e.next=5,this.publish(this.localStream_);case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(0);case 9:case"end":return e.stop()}}),e,this,[[0,7]])}))),function(){return t.apply(this,arguments)})},{key:"clearExchangeSDPTimeout",value:function(){-1!==this.exchangeSDPTimeout_&&(clearTimeout(this.exchangeSDPTimeout_),this.exchangeSDPTimeout_=-1)}},{key:"clearReconnectionTimer",value:function(){-1!==this.reconnectionTimer_&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"handleError",value:function(e){e.getCode()===mf.ICE_TRANSPORT_ERROR&&(this.isFirstConnection_&&(this.isFirstConnection_=!1,Gf.logFailedEvent({userId:this.client_.getUserId(),eventType:Ql,error:e})),this.isReconnecting_||this.startReconnection())}},{key:"handleConnectionStateChange",value:function(e){e.state===Vl&&(this.isFirstConnection_&&(this.isFirstConnection_=!1,Gf.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ql}),this.addEventInternal(32792,"uplink-connection is connected")),this.isReconnecting_&&(Gf.logSuccessEvent({userId:this.client_.getUserId(),eventType:Xl}),this.log_.warn("reconnect() uplink reconnect successfully"),this.addEventInternal(32798,"uplink-connection reconnect success"),this.stopReconnection()))}},{key:"updateSSRC",value:function(e){var t=this;try{var n=0;nm(e).media.forEach((function(e){if(e.type===ll){var r=e.ssrcs[0];r&&(t.ssrc_.audio=r.id)}else{var i=e.ssrcs[0];switch(n+=1){case 1:i&&(t.ssrc_.video=i.id);break;case 2:i&&(t.ssrc_.small=i.id)}}}))}catch(e){}}},{key:"getLocalStreamVideoTrackId",value:function(){if(this.peerConnection_){var e=this.peerConnection_.getSenders().filter((function(e){return e.track&&e.track.kind===dl}));if(e[0])return e[0].track.id}if(this.localStream_){var t=this.localStream_.getVideoTrack();if(t)return t.id}return""}},{key:"getSSRC",value:function(){return this.ssrc_}},{key:"checkPublishResultCode",value:function(e,t){if(0!==e)throw 1028===e?(this.log_.error(Bf.NOT_SUPPORTED_H264ENCODE),new vf({code:mf.NOT_SUPPORTED_H264,message:zf({key:Vf})})):new vf({code:mf.UNKNOWN,message:zf({key:jf,data:{signalResponse:pf.PUBLISH_RESULT,code:e,message:t}})})}}]),k}(bg),Hg=function(e){l(f,e);var t,n,r,i,s,u,h,p=_(f);function f(e){var t;return a(this,f),(t=p.call(this,e)).remoteStreams_=new Map,t.autoSubscribe=e.autoSubscribe,t.trackState_={audio:e.trackState.audio,video:e.trackState.video,auxiliary:e.trackState.auxiliary,smallVideo:e.trackState.smallVideo},t.ssrc_={audio:0,video:0,auxiliary:0},t.subscribeState_={audio:e.autoSubscribe,video:e.autoSubscribe,auxiliary:e.autoSubscribe,smallVideo:!1},t.pendingSubscription_=[],t.pendingStreams_=[],t.subscriptionTimeout_=-1,t.subscriptionRetryCount_=0,t.isSubscriptionPending_=!1,t.isSDPExchanging_=!1,t.installEvents(),t}return c(f,[{key:"isMainStreamSubscribed",get:function(){return(this.subscribeState_.audio||this.subscribeState_.video||this.subscribeState_.smallVideo)&&(this.trackState_.audio||this.trackState_.video||this.trackState_.smallVideo)}},{key:"isAuxStreamSubscribed",get:function(){return this.subscribeState_.auxiliary&&this.trackState_.auxiliary}},{key:"initialize",value:function(){g(d(f.prototype),"initialize",this).call(this),this.peerConnection_.ontrack=this.onTrack.bind(this)}},{key:"close",value:function(){var e=this;g(d(f.prototype),"close",this).call(this),this.trackState_.audio=!1,this.trackState_.video=!1,this.trackState_.auxiliary=!1,this.emitConnectionStateChangedEvent(Nl),-1!==this.subscriptionTimeout_&&(clearTimeout(this.subscriptionTimeout_),this.subscriptionTimeout_=-1),this.remoteStreams_.forEach((function(t){var n=t;n.setConnection(null),n.getIsStreamAddedEventEmitted()&&e.emitter_.emit(Um,{stream:n})})),this.remoteStreams_.clear(),this.uninstallEvents()}},{key:"installEvents",value:function(){var e=this;yp.on(bp,this.onRemoteStreamUpdate,this),this.signalChannel_.on(pf.SUBSCRIBE_CHANGE_RESULT,this.onSubscribeChangeResult,this),this.signalChannel_.on(pf.UNSUBSCRIBE_RESULT,this.onUnsubscribeResult,this),this.emitter_.on(jm,(function(t){t.getCode()===mf.ICE_TRANSPORT_ERROR&&(e.isFirstConnection_&&(e.isFirstConnection_=!1,Gf.logFailedEvent({userId:e.client_.getUserId(),eventType:$l,error:t})),e.isReconnecting_||e.startReconnection())})),this.emitter_.on(Bm,(function(t){t.state===Vl&&e.isFirstConnection_&&(e.isFirstConnection_=!1,Gf.logSuccessEvent({userId:e.client_.getUserId(),eventType:$l}),e.addEventInternal(32793,"downlink-connection is connected"))}))}},{key:"uninstallEvents",value:function(){yp.removeListener(bp,this.onRemoteStreamUpdate,this),this.signalChannel_.removeListener(pf.SUBSCRIBE_CHANGE_RESULT,this.onSubscribeChangeResult,this),this.signalChannel_.removeListener(pf.UNSUBSCRIBE_RESULT,this.onUnsubscribeResult,this)}},{key:"onRemoteStreamUpdate",value:function(e){if(this.hitTest(e.tinyId)&&e.client===this.client_){this.updateTrackState(e.action,e.kind);var t=e.kind===hl?Dl:Pl,n=this.remoteStreams_.get(t);if(!n)return;e.action===Id?this.handleRemoteAddTrack(e.kind,n):this.handleRemoteRemoveTrack(e.kind,n)}}},{key:"handleRemoteAddTrack",value:function(e,t){this.log_.info("remote add ".concat(e," track")),e===ll?t.updateAudioPlayingState(this.subscribeState_.audio):t.updateVideoPlayingState(e===hl?this.subscribeState_.auxiliary:this.subscribeState_.video||this.subscribeState_.smallVideo),t.getIsStreamAddedEventEmitted()?this.emitter_.emit(Vm,{stream:t}):(this.emitter_.emit(Om,{stream:t}),this.currentState_===Vl&&t.emitConnectionStateChanged({prevState:Nl,state:Vl}))}},{key:"handleRemoteRemoveTrack",value:function(e,t){t.getIsStreamAddedEventEmitted()&&(this.log_.info("remote remove ".concat(e," track")),e!==hl&&(this.trackState_.audio||this.trackState_.video)||t.isInSubscriptionCycle()?(e===ll?t.updateAudioPlayingState(!1):t.updateVideoPlayingState(!1),this.emitter_.emit(Vm,{stream:t})):(this.log_.info("remote stream ".concat(t.getType()," removed")),this.currentState_===Vl&&t.emitConnectionStateChanged({prevState:Vl,state:Nl}),this.emitter_.emit(Um,{stream:t})))}},{key:"updateTrackState",value:function(e,t){var n=e===Id;switch(t){case ll:this.trackState_.audio=n;break;case dl:this.trackState_.video=n;break;case hl:this.trackState_.auxiliary=n}this.log_.info("trackState updated: ".concat(JSON.stringify(this.trackState_)))}},{key:"onTrack",value:function(e){var t=e.streams[0],n=e.track;if(this.log_.info("ontrack() kind: ".concat(n.kind," id: ").concat(n.id," streamId: ").concat(t.id)),"unified-plan"===this.sdpSemantics_){var r=function(e){var t=tm.parse(e),n={audio:[],video:[]};return t.media.forEach((function(e){if(e.ssrcs){var t=e.ssrcs[0].id>>16&255;if(e.type===ll)n.audio.push(Pl);else if(e.type==dl){var r=2===t?Pl:Dl;n.video.push(r)}}})),n}(this.peerConnection_.remoteDescription.sdp);if(n.kind===ll){if(0===r.audio.length||t.id!==Pl)return void this.log_.debug("skip this invalid audio track")}else if(-1===r.video.indexOf(t.id))return void this.log_.debug("skip this invalid video track: ".concat(n.id," msid: ").concat(t.id))}Gf.logEvent({eventType:"ontrack",kind:n.kind});var i=!1,o=this.remoteStreams_.get(t.id),a=t.id===Pl?Ll:Ml;if(Kd(o)&&((o=new Dg({type:a,userId:this.userId_,client:this.client_})).setConnection(this),this.remoteStreams_.set(t.id,o),i=!0),o.setMediaStream(t),n.kind===ll?o.updateAudioPlayingState(this.subscribeState_.audio):a===Ll?o.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo):o.updateVideoPlayingState(this.subscribeState_.auxiliary),(a!==Ml||this.trackState_.auxiliary)&&(a!==Ll||this.trackState_.audio||this.trackState_.video)){var s=this.client_.getSubscriptionManager();s&&s.hasAutoRecoveryFlag(this.userId_,a)||(i?this.emitter_.emit(Om,{stream:o}):this.emitter_.emit(Vm,{stream:o}))}}},{key:"addRRTRLine",value:function(e){var t=e.split("\r\n"),n=new Map;t.forEach((function(e,r){/^a=rtcp-fb:/.test(e)&&t[r+1]&&!/^a=rtcp-fb:/.test(t[r+1])&&n.set(r+1,e.match(/^a=rtcp-fb:\d+/)[0]+" rrtr")}));for(var r=S(n),i=0;i<r.length;i++){var o=y(r[i],2),a=o[0],s=o[1];t.splice(a+i,0,s)}return t.join("\r\n")}},{key:"addSPSDescription",value:function(e){var t=nm(e);return t.media.forEach((function(e){e.type===dl&&e.fmtp.forEach((function(e){e.config+=";sps-pps-idr-in-keyframe=1"}))})),rm(t)}},{key:"removeSDESDescription",value:function(e){var t=["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"],n=nm(e);return n.media.forEach((function(e){e.ext=e.ext.filter((function(e){return!t.includes(e.uri)}))})),rm(n)}},{key:"isSubscriptionStateNotChanged",value:function(e,t){return e.getType()===Ll?!Kd(t.audio)&&!Kd(t.video)&&t.audio===this.subscribeState_.audio&&t.video===this.subscribeState_.video:e.getType()===Ml?!Kd(t.video)&&this.subscribeState_.auxiliary===t.video:void 0}},{key:"subscribe",value:(h=o(regeneratorRuntime.mark((function e(t,n){var r,i,o,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.emitEvent,i=void 0===r||r,o=t.getType(),!this.peerConnection_||"new"!==this.peerConnection_.connectionState&&this.peerConnection_.connectionState!==Fl){e.next=5;break}return e.next=5,this.waitForPeerConnectionConnected();case 5:if(!this.isSubscriptionStateNotChanged(t,n)){e.next=12;break}if(this.peerConnection_){e.next=10;break}return this.initialize(),e.next=10,this.connect();case 10:case 25:return i&&Kd(n.smallVideo)&&this.emitter_.emit(Fm,{stream:t,result:!0}),e.abrupt("return",t);case 12:if(o===wl?(Kd(n.audio)||(this.subscribeState_.audio=n.audio),Kd(n.video)||(this.subscribeState_.video=n.video),Kd(n.smallVideo)||(this.subscribeState_.smallVideo=n.smallVideo),this.addEventInternal(this.subscribeState_.audio?32777:_f,this.subscribeState_.audio?"subscribe audio":"unsubscribe audio"),this.addEventInternal(this.subscribeState_.video?32777:_f,this.subscribeState_.video?"subscribe video":"unsubscribe video"),this.addEventInternal(this.subscribeState_.smallVideo?32803:32804,this.subscribeState_.smallVideo?"subscribe smallVideo":"unsubscribe smallVideo")):Kd(n.video)||(this.subscribeState_.auxiliary=n.video),this.log_.info("subscribe ".concat(o," stream with options ").concat(JSON.stringify(n)," current state: ").concat(JSON.stringify(this.subscribeState_))),!this.peerConnection_&&!this.isSDPExchanging_){e.next=22;break}return a=pd,this.isMainStreamSubscribed||this.isAuxStreamSubscribed||(a=hd),e.next=19,this.sendSubscription(t,a);case 19:o===wl?(t.updateAudioPlayingState(this.subscribeState_.audio),t.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo)):t.updateVideoPlayingState(this.subscribeState_.auxiliary),e.next=25;break;case 22:return this.initialize(),e.next=25,this.connect();case 27:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"unsubscribe",value:(u=o(regeneratorRuntime.mark((function e(t){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=t.getType())!==wl){e.next=10;break}if(this.isMainStreamSubscribed){e.next=5;break}return this.log_.info("main stream already unsubscribed"),e.abrupt("return",t);case 5:this.subscribeState_.audio=!1,this.subscribeState_.video=!1,this.subscribeState_.smallVideo=!1,e.next=14;break;case 10:if(this.isAuxStreamSubscribed){e.next=13;break}return this.log_.info("auxiliary stream already unsubscribed"),e.abrupt("return",t);case 13:this.subscribeState_.auxiliary=!1;case 14:return r=hd,(n===Ll&&this.isAuxStreamSubscribed||n===Ml&&this.isMainStreamSubscribed)&&(r=pd),this.log_.info("unsubscribe ".concat(n," stream with ").concat(JSON.stringify(this.subscribeState_))),e.next=19,this.sendSubscription(t,r);case 19:return t.updateVideoPlayingState(!1),t.updateAudioPlayingState(!1),r===hd&&((i=t.getMediaStream())&&i.getTracks().forEach((function(e){return i.removeTrack(e)})),this.closePeerConnection(),this.emitConnectionStateChangedEvent(Nl)),this.addEventInternal(_f,"unsubscribe audio"),this.addEventInternal(32778,"unsubscribe video"),e.abrupt("return",t);case 25:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"sendSubscription",value:function(e,t){var n=this;return new Promise((function(r,i){var o={srcTinyId:n.tinyId_,srcUserId:n.userId_};t===pd&&(o={audio:n.subscribeState_.audio,bigVideo:n.subscribeState_.video,auxVideo:n.subscribeState_.auxiliary,smallVideo:n.subscribeState_.smallVideo,srcTinyId:n.tinyId_}),n.pendingSubscription_.length>0?n.log_.debug("queue the subscription for later handling"):n.doSendSubscription(o,e,t),n.pendingSubscription_.push({stream:e,type:t,data:o,callback:function(e){var o=e.code,a=e.message;if(0===o)r();else{var s=new vf({code:o,message:zf({key:"ERROR_MESSAGE",data:{type:t,message:a}})});n.log_.error(s),i(s)}}}),e.setInSubscriptionCycle(!0)}))}},{key:"doSendSubscription",value:function(e,t,n){var r=this;t&&this.pendingStreams_.push(t),this.log_.debug("doSendSubscription() send SUBSCRIBE command with data: ".concat(JSON.stringify(e))),n===pd?this.signalChannel_.send("subscribe_change",e):n===hd&&this.signalChannel_.send("unsubscribe",e),this.isSubscriptionPending_=!0,this.subscriptionTimeout_=setTimeout((function(){if(r.isSubscriptionPending_)if(r.log_.debug("subscription timeout"),r.subscriptionRetryCount_+=1,r.subscriptionRetryCount_<=3){r.log_.debug("resend subscription");var e=r.pendingSubscription_[0].data;r.doSendSubscription(e,t,n)}else r.log_.error(Bf.SUBSCRIPTION_TIMEOUT),r.pendingSubscription_.shift(),r.pendingStreams_.shift(),r.isSubscriptionPending_=!1,r.subscriptionRetryCount_=0,r.emitter_.emit(jm,new vf({code:mf.SUBSCRIPTION_TIMEOUT,message:zf({key:"SUBSCRIPTION_TIMEOUT"})}))}),5e3)}},{key:"onSubscribeChangeResult",value:function(e){var t=e&&e.data||{},n=t.code,r=t.message,i=t.data.srcTinyId;if(this.hitTest(i)){var o=this.pendingSubscription_[0];o&&o.type===pd&&o.callback({code:n,message:r}),this.sendNextSubscription()}}},{key:"onUnsubscribeResult",value:function(e){var t=e&&e.data||{},n=t.code,r=t.message,i=t.data.srcTinyId;if(this.hitTest(i)){var o=this.pendingSubscription_[0];o&&o.type===hd&&o.callback({code:n,message:r}),this.sendNextSubscription()}}},{key:"connect",value:(s=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.exchangeSDP();case 3:return e.next=5,this.waitForPeerConnectionConnected();case 5:e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(0),this.closePeerConnection(!0),e.t0;case 11:case"end":return e.stop()}}),e,this,[[0,7]])}))),function(){return s.apply(this,arguments)})},{key:"exchangeSDP",value:(i=o(regeneratorRuntime.mark((function e(){var t,n,r,i,o,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,this.isSDPExchanging_=!0,e.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),t=this.peerConnection_.localDescription,n=t.type,r=t.sdp,i={type:n,sdp:r,srcUserId:this.userId_,srcTinyId:this.tinyId_,audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo},yp.emit(201,{client:this.client_,connection:this,userId:this.userId_,tinyId:this.tinyId_,role:Al,subscribeState:this.subscribeState_,trackState:this.trackState_}),e.next=10,this.signalChannel_.sendWaitForResponse({command:"subscribe",commandDesc:"exchange sdp",data:i,responseCommand:pf.SUBSCRIBE_RESULT});case 10:if(o=e.sent,this.peerConnection_){e.next=15;break}throw a=this.genRemoteStreamNotExistError(),this.log_.warn(a),a;case 15:return e.next=17,this.onSubscribeResult(o);case 17:this.isSDPExchanging_=!1,e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(0),this.isSDPExchanging_=!1,e.t0;case 24:case"end":return e.stop()}}),e,this,[[0,20]])}))),function(){return i.apply(this,arguments)})},{key:"createOffer",value:(r=o(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={voiceActivityDetection:!1},"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype&&"unified-plan"===this.sdpSemantics_?(this.peerConnection_.addTransceiver(ll,{direction:"recvonly"}),this.peerConnection_.addTransceiver(dl,{direction:"recvonly"}),this.peerConnection_.addTransceiver(dl,{direction:"recvonly"})):(t.offerToReceiveAudio=!0,t.offerToReceiveVideo=!0),e.next=4,this.peerConnection_.createOffer(t);case 4:return n=e.sent,e.next=7,_m();case 7:return e.sent.isH264DecodeSupported||(this.log_.warn("remove h264 desc from sdp"),n.sdp=om(n.sdp)),n.sdp=this.addRRTRLine(n.sdp),n.sdp=this.addSPSDescription(n.sdp),n.sdp=im(n.sdp),"unified-plan"===this.sdpSemantics_&&(n.sdp=this.removeSDESDescription(n.sdp)),e.next=16,this.peerConnection_.setLocalDescription(n);case 16:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"onSubscribeResult",value:(n=o(regeneratorRuntime.mark((function e(t){var n,r,i,o,a,s,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t&&t.data||{},r=n.code,i=n.message,o=void 0===i?"":i,a=t&&t.data&&t.data.data||{},s=a.type,c=a.sdp,77393!==r){e.next=5;break}throw this.log_.error(Bf.NOT_SUPPORTED_H264DECODE),new vf({code:mf.NOT_SUPPORTED_H264,message:zf({key:Ff})});case 5:if(e.prev=5,0===r){e.next=8;break}throw new vf({code:r,message:zf({key:"EXCHANGE_SDP_FAILED",data:{errMsg:o}})});case 8:return this.log_.debug("accept remote answer: "+c),e.next=11,this.peerConnection_.setRemoteDescription({type:s,sdp:c});case 11:this.updateSSRC(c),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(5),this.log_.error(e.t0),e.t0;case 18:case"end":return e.stop()}}),e,this,[[5,14]])}))),function(e){return n.apply(this,arguments)})},{key:"updateSSRC",value:function(e){var t=this;try{nm(e).media.forEach((function(e){if(e.type===ll){var n=e.ssrcs.find((function(e){return e.value.includes(Pl)}));n&&(t.ssrc_.audio=n.id)}else{var r=e.ssrcs.find((function(e){return e.value.includes(Pl)})),i=e.ssrcs.find((function(e){return e.value.includes(Dl)}));r&&(t.ssrc_.video=r.id),i&&(t.ssrc_.auxiliary=i.id)}}))}catch(e){}}},{key:"sendNextSubscription",value:function(){void 0!==this.pendingSubscription_.shift()&&(this.subscriptionRetryCount_=0,this.isSubscriptionPending_=!1,-1!==this.subscriptionTimeout_&&(clearTimeout(this.subscriptionTimeout_),this.subscriptionTimeout_=-1));var e=this.pendingStreams_.shift();if(e&&(this.log_.debug("mark ".concat(e.getType()," stream exit subscription cycle")),e.setInSubscriptionCycle(!1)),this.pendingSubscription_.length>0){var t=this.pendingSubscription_[0];this.log_.info("schedule a pending subscription"),this.doSendSubscription(t.data,t.stream,t.type)}}},{key:"setRemoteStream",value:function(e,t){this.remoteStreams_.set(e,t)}},{key:"getSubscribeState",value:function(){return this.subscribeState_}},{key:"getTrackState",value:function(){return this.trackState_}},{key:"getSSRC",value:function(){return this.ssrc_}},{key:"getMainStream",value:function(){return this.remoteStreams_.get(Pl)}},{key:"getAuxStream",value:function(){return this.remoteStreams_.get(Dl)}},{key:"getMainStreamVideoTrackId",value:function(){var e=this.getMainStream();if(e){var t=e.getVideoTrack();if(t)return t.id}return""}},{key:"getAuxStreamVideoTrackId",value:function(){var e=this.getAuxStream();if(e){var t=e.getVideoTrack();if(t)return t.id}return""}},{key:"reconnect",value:(t=o(regeneratorRuntime.mark((function e(){var t,n,r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(-1===this.reconnectionTimer_){e.next=3;break}return this.log_.warn("reconnect() downlink is reconnecting, ignore current reconnection"),e.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){e.next=12;break}return this.log_.warn("SDK has tried reconnect downlink [".concat(this.userId_,"] for ").concat(30," times, but all failed, please check your network")),this.stopReconnection(),t=new vf({code:mf.DOWNLINK_RECONNECTION_FAILED,message:zf({key:"DOWNLINK_RECONNECTION_FAILED"})}),Gf.logFailedEvent({userId:this.client_.getUserId(),eventType:Yl,error:t}),this.addEventInternal(32802,"downlink-connection reconnect fail"),this.emitConnectionStateChangedEvent(Nl),this.emitter_.emit(jm,t),e.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===lf){e.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(3,this.reconnect,this),e.abrupt("return");case 16:if(this.reconnectionCount_++,this.log_.warn("reconnect() try to reconnect downlink [".concat(this.reconnectionCount_,"/").concat(30,"]")),n=Jd(this.reconnectionCount_),this.reconnectionTimer_=setTimeout((function(){r.log_.warn("reconnect() downlink [".concat(r.userId_,"] reconnect timeout(").concat(n/1e3,"s), try again")),r.clearReconnectionTimer(),r.reconnect()}),n),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Fl)){e.next=22;break}return e.abrupt("return");case 22:return e.prev=22,this.closePeerConnection(),this.initialize(),e.next=27,this.connect();case 27:this.stopReconnection(),this.log_.warn("reconnect() downlink reconnect successfully"),Gf.logSuccessEvent({userId:this.client_.getUserId(),eventType:Yl}),this.addEventInternal(32801,"downlink-connection reconnect success"),this.recoverSubscription(),e.next=36;break;case 34:e.prev=34,e.t0=e.catch(22);case 36:case"end":return e.stop()}}),e,this,[[22,34]])}))),function(){return t.apply(this,arguments)})},{key:"recoverSubscription",value:function(){var e=this,t=this.client_.getSubscriptionManager();t&&S(this.remoteStreams_.values()).forEach((function(n){t.hasAutoRecoveryFlag(e.userId_,n.getType())&&t.recover(n)}))}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"getSubscribedMainStream",value:function(){var e=null;return this.isMainStreamSubscribed&&(e=this.remoteStreams_.get(Pl)),e}},{key:"clearReconnectionTimer",value:function(){-1!==this.reconnectionTimer_&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"startReconnection",value:function(){var e=this.client_.getSubscriptionManager();if(e){var t,n=I(this.remoteStreams_.values());try{for(n.s();!(t=n.n()).done;){var r=t.value,i=r.getType();(i===Ll&&(this.trackState_.audio||this.trackState_.video)||i===Ml&&this.trackState_.auxiliary)&&e.setAutoRecoveryFlag(this.userId_,r.getType())}}catch(e){n.e(e)}finally{n.f()}}g(d(f.prototype),"startReconnection",this).call(this)}},{key:"getCurrentState",value:function(){return this.currentState_}}]),f}(bg),zg=function(e){return function(t,n,r,i){re(n);var o=ce(t),a=j(o),s=st(o),c=e?s-1:0,u=e?-1:1;if(r<2)for(;;){if(c in a){i=a[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw TypeError("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=u)c in a&&(i=n(i,a[c],c,o));return i}},Gg=[zg(!1),zg(!0)][0],Wg=$i("reduce");Rt({target:"Array",proto:!0,forced:!Wg||!Ns&&Y>79&&Y<83},{reduce:function(e){return Gg(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var Jg=function(){function e(){a(this,e),this.startTime=0,this.endTime=0,this.start()}return c(e,[{key:"start",value:function(){0===this.startTime&&(this.startTime=nh())}},{key:"stop",value:function(){0===this.endTime&&(this.endTime=nh())}},{key:"getDuration",value:function(){return 0===this.endTime?nh()-this.startTime:this.endTime-this.startTime}}]),e}(),qg=function(){function e(t){a(this,e),this.client_=t.client,this.intervalId_=-1,this.statsCalculator_=t.stats,this.prevStats_=null,this.renderFreezeMap_=new Map,this.remoteStreamMap_=new Map,this.dataFreezeMap_=new Map,this.monitorFreezeData_=new Map}var t,n,r;return c(e,[{key:"installEvents",value:function(){yp.on(134,this.handlePlayVideoStart,this),yp.on(Rp,this.onVideoTrackMuted,this),yp.on(131,this.onVideoTrackUnmuted,this),yp.on(wp,this.handleStreamStopped,this),yp.on(Tp,this.handleStreamStopped,this),yp.on(Sp,this.handleVideoPlaying,this)}},{key:"uninstallEvents",value:function(){yp.off(134,this.handlePlayVideoStart,this),yp.off(Rp,this.onVideoTrackMuted,this),yp.off(131,this.onVideoTrackUnmuted,this),yp.off(wp,this.handleStreamStopped,this),yp.off(Tp,this.handleStreamStopped,this),yp.off(Sp,this.handleVideoPlaying,this)}},{key:"start",value:function(){var e=this;-1===this.intervalId_&&(this.installEvents(),this.intervalId_=cm.setInterval(o(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.detectFPS();case 3:t.next=7;break;case 5:t.prev=5,t.t0=t.catch(0);case 7:case"end":return t.stop()}}),t,null,[[0,5]])}))),1e3))}},{key:"stop",value:function(){-1!==this.intervalId_&&(this.uninstallEvents(),cm.clearInterval(this.intervalId_),this.intervalId_=-1,this.renderFreezeMap_.clear(),this.dataFreezeMap_.clear(),this.remoteStreamMap_.clear())}},{key:"onVideoTrackMuted",value:function(e){var t=e.stream;if(t.getClient()===this.client_&&t.isRemote()){var n=t.userId_,r=t.type_,i="".concat(n,"_").concat(r),o=this.dataFreezeMap_.get(i),a=new Jg;o?o.durationItemList.push(a):this.dataFreezeMap_.set(i,{userId:n,type:r,durationItemList:[a],isFreezing:function(){var e=this.durationItemList[this.durationItemList.length-1];return e&&0===e.endTime}})}}},{key:"onVideoTrackUnmuted",value:function(e){var t=e.stream;if(t.getClient()===this.client_&&t.isRemote()){var n=t.userId_,r=t.type_,i="".concat(n,"_").concat(r);this.stopDataFreeze({key:i,userId:n,type:r})}}},{key:"handleStreamStopped",value:function(e){var t=e.client,n=e.stream;if(t===this.client_){var r=n.getUserId(),i=n.getType(),o="".concat(r,"_").concat(i);this.stopDataFreeze({key:o,userId:r,type:i})}}},{key:"stopDataFreeze",value:function(e){var t=e.key,n=e.userId,r=e.type,i=this.dataFreezeMap_.get(t);if(i&&i.isFreezing()){var o=i.durationItemList[i.durationItemList.length-1];o.stop();var a=o.getDuration();a>500?(Gf.logEvent({eventType:"videoFrozenCount",delta:a}),this.monitorFreezeData_.set(t,{userId:n,type:r,duration:a})):i.durationItemList.pop()}}},{key:"getTotalDuration",value:function(e){return e.reduce((function(e,t){var n=t.getDuration();return e+Math.min(n,5e3)}),0)}},{key:"getStats",value:(r=o(regeneratorRuntime.mark((function e(){var t,n,r,i,o,a,s,c,u,l,d;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.client_.getConnections(),n={},r=I(t),e.prev=3,r.s();case 5:if((i=r.n()).done){e.next=20;break}if(o=y(i.value,2),a=o[0],(s=o[1]).getPeerConnection()){e.next=9;break}return e.abrupt("continue",18);case 9:return c=s.getSubscribeState(),u=s.getTrackState(),e.next=13,this.statsCalculator_.getReceiverStats(s);case 13:l=e.sent,(d={userId:l.userId,tinyId:a,hasVideo:u.video&&c.video,hasAuxiliary:u.auxiliary&&c.auxiliary,video:{framesDecoded:0},auxiliary:{framesDecoded:0}}).hasVideo&&(d.video.framesDecoded=l.video.framesDecoded),d.hasAuxiliary&&(d.auxiliary.framesDecoded=l.auxiliary.framesDecoded),n[l.userId]=d;case 18:e.next=5;break;case 20:e.next=25;break;case 22:e.prev=22,e.t0=e.catch(3),r.e(e.t0);case 25:return e.prev=25,r.f(),e.finish(25);case 28:return e.abrupt("return",n);case 29:case"end":return e.stop()}}),e,this,[[3,22,25,28]])}))),function(){return r.apply(this,arguments)})},{key:"detectFPS",value:(n=o(regeneratorRuntime.mark((function e(){var t,n,r,i,o,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getStats();case 2:if(t=e.sent,this.prevStats_){e.next=6;break}return this.prevStats_=t,e.abrupt("return");case 6:e.t0=regeneratorRuntime.keys(t);case 7:if((e.t1=e.t0()).done){e.next=17;break}if(n=e.t1.value,this.prevStats_[n]){e.next=11;break}return e.abrupt("continue",7);case 11:r=t[n].tinyId,i=this.client_.getMutedStates(),t[n].hasVideo&&this.prevStats_[n].hasVideo&&i.has(r)&&!i.get(r).videoMuted&&(o=t[n].video.framesDecoded-this.prevStats_[n].video.framesDecoded,this.handleRenderFreeze({userId:n,type:Ll,fps:o})),t[n].hasAuxiliary&&this.prevStats_[n].hasAuxiliary&&(a=t[n].auxiliary.framesDecoded-this.prevStats_[n].auxiliary.framesDecoded,this.handleRenderFreeze({userId:n,type:Ml,fps:a})),e.next=7;break;case 17:this.prevStats_=t;case 18:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"handleRenderFreeze",value:(t=o(regeneratorRuntime.mark((function e(t){var n,r,i,o,a,s,c,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.userId,r=t.fps,i=t.type,o="".concat(n,"_").concat(i),a=this.renderFreezeMap_.get(o),r<=2?(s=nh(),a&&!a.isFreeze&&(a.freezeTimeline.push({startTime:s,endTime:void 0}),a.isFreeze=!0),a||this.renderFreezeMap_.set(o,{userId:n,type:i,isFreeze:!0,freezeTimeline:[{startTime:s,endTime:void 0}],renderFreezeTotal:0})):a&&a.isFreeze&&(a.isFreeze=!1,(c=a.freezeTimeline.pop()).endTime=nh(),u=c.endTime-c.startTime,a.freezeTimeline.push(c),a.renderFreezeTotal+=Math.min(5e3,u));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"handlePlayVideoStart",value:function(e){var t=e.stream;if(t.getClient()===this.client_&&t.isRemote()&&t.hasVideo()){var n="".concat(t.getUserId(),"_").concat(t.getType());this.remoteStreamMap_.has(n)?this.remoteStreamMap_.get(n).remoteStream=t:this.remoteStreamMap_.set(n,{isPlayingFired:!1,remoteStream:t})}}},{key:"handleVideoPlaying",value:function(e){var t=e.stream;if(t.isRemote()&&t.getClient()===this.client_){var n="".concat(t.getUserId(),"_").concat(t.getType());this.remoteStreamMap_.has(n)&&(this.remoteStreamMap_.get(n).isPlayingFired=!0)}}},{key:"getDataFreezeDuration",value:function(e){var t={dataFreeze:0,count:0},n=this.dataFreezeMap_.get(e);if(n){if(n.isFreezing()){var r=n.durationItemList[n.durationItemList.length-1];r.stop(),r.getDuration()<500&&n.durationItemList.pop()}t.dataFreeze=this.getTotalDuration(n.durationItemList),t.count=n.durationItemList.length}return t}},{key:"getRenderFreezeDuration",value:function(e){var t=this.renderFreezeMap_.get(e),n=0,r=0;if(t)if(t.isFreeze){var i=nh()-t.freezeTimeline[t.freezeTimeline.length-1].startTime;n=t.renderFreezeTotal+Math.min(i,5e3),r=t.freezeTimeline.length}else n=t.renderFreezeTotal;return{renderFreeze:n,count:r}}},{key:"getMonitorFreeze",value:function(){return this.monitorFreezeData_}},{key:"isBlackStream",value:function(e){return!!this.remoteStreamMap_.has(e)&&!this.remoteStreamMap_.get(e).isPlayingFired}},{key:"resetMonitor",value:function(){this.monitorFreezeData_.clear()}}]),e}(),Kg=function e(t){a(this,e),this.userId=t.userId,this.tinyId=t.tinyId,this.role=t.role===Al?"anchor":"audience"},Qg=R((function(e){!function(t){function n(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function r(e,t,r,i,o,a){return n((s=n(n(t,e),n(i,a)))<<(c=o)|s>>>32-c,r);var s,c}function i(e,t,n,i,o,a,s){return r(t&n|~t&i,e,t,o,a,s)}function o(e,t,n,i,o,a,s){return r(t&i|n&~i,e,t,o,a,s)}function a(e,t,n,i,o,a,s){return r(t^n^i,e,t,o,a,s)}function s(e,t,n,i,o,a,s){return r(n^(t|~i),e,t,o,a,s)}function c(e,t){var r,c,u,l,d;e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;var h=1732584193,p=-271733879,f=-1732584194,m=271733878;for(r=0;r<e.length;r+=16)c=h,u=p,l=f,d=m,h=i(h,p,f,m,e[r],7,-680876936),m=i(m,h,p,f,e[r+1],12,-389564586),f=i(f,m,h,p,e[r+2],17,606105819),p=i(p,f,m,h,e[r+3],22,-1044525330),h=i(h,p,f,m,e[r+4],7,-176418897),m=i(m,h,p,f,e[r+5],12,1200080426),f=i(f,m,h,p,e[r+6],17,-1473231341),p=i(p,f,m,h,e[r+7],22,-45705983),h=i(h,p,f,m,e[r+8],7,1770035416),m=i(m,h,p,f,e[r+9],12,-1958414417),f=i(f,m,h,p,e[r+10],17,-42063),p=i(p,f,m,h,e[r+11],22,-1990404162),h=i(h,p,f,m,e[r+12],7,1804603682),m=i(m,h,p,f,e[r+13],12,-40341101),f=i(f,m,h,p,e[r+14],17,-1502002290),h=o(h,p=i(p,f,m,h,e[r+15],22,1236535329),f,m,e[r+1],5,-165796510),m=o(m,h,p,f,e[r+6],9,-1069501632),f=o(f,m,h,p,e[r+11],14,643717713),p=o(p,f,m,h,e[r],20,-373897302),h=o(h,p,f,m,e[r+5],5,-701558691),m=o(m,h,p,f,e[r+10],9,38016083),f=o(f,m,h,p,e[r+15],14,-660478335),p=o(p,f,m,h,e[r+4],20,-405537848),h=o(h,p,f,m,e[r+9],5,568446438),m=o(m,h,p,f,e[r+14],9,-1019803690),f=o(f,m,h,p,e[r+3],14,-187363961),p=o(p,f,m,h,e[r+8],20,1163531501),h=o(h,p,f,m,e[r+13],5,-1444681467),m=o(m,h,p,f,e[r+2],9,-51403784),f=o(f,m,h,p,e[r+7],14,1735328473),h=a(h,p=o(p,f,m,h,e[r+12],20,-1926607734),f,m,e[r+5],4,-378558),m=a(m,h,p,f,e[r+8],11,-2022574463),f=a(f,m,h,p,e[r+11],16,1839030562),p=a(p,f,m,h,e[r+14],23,-35309556),h=a(h,p,f,m,e[r+1],4,-1530992060),m=a(m,h,p,f,e[r+4],11,1272893353),f=a(f,m,h,p,e[r+7],16,-155497632),p=a(p,f,m,h,e[r+10],23,-1094730640),h=a(h,p,f,m,e[r+13],4,681279174),m=a(m,h,p,f,e[r],11,-358537222),f=a(f,m,h,p,e[r+3],16,-722521979),p=a(p,f,m,h,e[r+6],23,76029189),h=a(h,p,f,m,e[r+9],4,-640364487),m=a(m,h,p,f,e[r+12],11,-421815835),f=a(f,m,h,p,e[r+15],16,530742520),h=s(h,p=a(p,f,m,h,e[r+2],23,-995338651),f,m,e[r],6,-198630844),m=s(m,h,p,f,e[r+7],10,1126891415),f=s(f,m,h,p,e[r+14],15,-1416354905),p=s(p,f,m,h,e[r+5],21,-57434055),h=s(h,p,f,m,e[r+12],6,1700485571),m=s(m,h,p,f,e[r+3],10,-1894986606),f=s(f,m,h,p,e[r+10],15,-1051523),p=s(p,f,m,h,e[r+1],21,-2054922799),h=s(h,p,f,m,e[r+8],6,1873313359),m=s(m,h,p,f,e[r+15],10,-30611744),f=s(f,m,h,p,e[r+6],15,-1560198380),p=s(p,f,m,h,e[r+13],21,1309151649),h=s(h,p,f,m,e[r+4],6,-145523070),m=s(m,h,p,f,e[r+11],10,-1120210379),f=s(f,m,h,p,e[r+2],15,718787259),p=s(p,f,m,h,e[r+9],21,-343485551),h=n(h,c),p=n(p,u),f=n(f,l),m=n(m,d);return[h,p,f,m]}function u(e){var t,n="",r=32*e.length;for(t=0;t<r;t+=8)n+=String.fromCharCode(e[t>>5]>>>t%32&255);return n}function l(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t<n.length;t+=1)n[t]=0;var r=8*e.length;for(t=0;t<r;t+=8)n[t>>5]|=(255&e.charCodeAt(t/8))<<t%32;return n}function d(e){var t,n,r="";for(n=0;n<e.length;n+=1)t=e.charCodeAt(n),r+="0123456789abcdef".charAt(t>>>4&15)+"0123456789abcdef".charAt(15&t);return r}function h(e){return unescape(encodeURIComponent(e))}function p(e){return function(e){return u(c(l(e),8*e.length))}(h(e))}function f(e,t){return function(e,t){var n,r,i=l(e),o=[],a=[];for(o[15]=a[15]=void 0,i.length>16&&(i=c(i,8*e.length)),n=0;n<16;n+=1)o[n]=909522486^i[n],a[n]=1549556828^i[n];return r=c(o.concat(l(t)),512+8*t.length),u(c(a.concat(r),640))}(h(e),h(t))}function m(e,t,n){return t?n?f(t,e):d(f(t,e)):n?p(e):d(p(e))}e.exports?e.exports=m:t.md5=m}(w)})),Xg=function(){function e(t){a(this,e),this.client_=t.client,this.signalChannel_=t.signalChannel,this.log_=Pp.createLogger({id:"mix|"+this.client_.getUserId(),userId:t.client.getUserId(),sdkAppId:t.client.getSDKAppId()}),this.isMixing_=!1,this.config_=null,this.data_=null,this.remoteStreamMap_=new Map,this.installEvents()}var t,n,r,i;return c(e,[{key:"isPresetLayoutMode",get:function(){return this.config_&&this.config_.mode===md}},{key:"installEvents",value:function(){yp.on(Ip,this.onStreamSubscribed,this),yp.on(Tp,this.onStreamUnsubscribed,this),this.client_.on("stream-removed",this.onStreamRemoved,this)}},{key:"uninstallEvents",value:function(){yp.off(Ip,this.onStreamSubscribed,this),yp.off(Tp,this.onStreamUnsubscribed,this),this.client_.off("stream-removed",this.onStreamRemoved,this)}},{key:"stop",value:function(){this.uninstallEvents()}},{key:"onStreamSubscribed",value:function(e){var t=e.client,n=e.stream;t===this.client_&&(this.remoteStreamMap_.set(n.getId(),{remoteStream:n,isUsed:!1}),this.isMixing_&&this.hasAvailablePlaceHolder()&&this.startMixTranscode(this.config_))}},{key:"onStreamUnsubscribed",value:function(e){var t=e.client,n=e.stream;t===this.client_&&this.onStreamRemoved({stream:n})}},{key:"onStreamRemoved",value:function(e){var t=e.stream;if(this.remoteStreamMap_.has(t.getId())){var n=this.remoteStreamMap_.get(t.getId()).isUsed;this.remoteStreamMap_.delete(t.getId()),this.isMixing_&&this.isPresetLayoutMode&&n&&this.startMixTranscode(this.config_)}}},{key:"startMixTranscode",value:(i=o(regeneratorRuntime.mark((function e(t){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,this.resetIsUsedFlag(),this.config_=t,n=this.getInputParam(t,this.remoteStreamMap_),r=this.getOutputParam(t),i=this.getOutputSessionId({config:t,roomId:this.client_.getRoomId(),userId:this.client_.getUserId()}),!this.isMixing_||!this.data_||i===this.data_.outputSessionId){e.next=10;break}return this.log_.info("startMixTranscode() streamId changed, stop mixing before start"),e.next=10,this.doStopMixTranscode();case 10:return e.next=12,this.doStartMixTranscode({outputSessionId:i,inputParam:n,outputParam:r});case 12:e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(0),this.resetIsUsedFlag(),e.t0;case 18:case"end":return e.stop()}}),e,this,[[0,14]])}))),function(e){return i.apply(this,arguments)})},{key:"doStartMixTranscode",value:(r=o(regeneratorRuntime.mark((function e(t){var n,r,i,o,a,s,c,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.outputSessionId,r=t.inputParam,i=t.outputParam,o={roomId:String(this.client_.getRoomId()),mcuRequestTime:Date.now(),outputSessionId:n,inputParam:r,outputParam:i},this.data_=o,this.log_.info("startMixTranscode: ".concat(JSON.stringify(o))),this.isMixing_=!0,e.prev=5,e.next=8,this.signalChannel_.sendWaitForResponse({command:"start_mcu_mix",data:o,timeout:5e3,responseCommand:pf.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"});case 8:if(a=e.sent,s=a.data,c=s.code,u=s.message,0===c){e.next=15;break}throw-102083===c&&(u="Please enable relayed-push in ".concat("https://console.cloud.tencent.com/trtc"," and try later, refer to ").concat(Ud,"tutorial-26-advanced-publish-cdn-stream.html")),this.log_.error("startMixTranscode failed, errCode: ".concat(c," errMsg: ").concat(u)),this.isMixing_=!1,new vf({code:mf.START_MIX_TRANSCODE_FAILED,message:zf({key:"START_MIX_TRANSCODE_FAILED",data:{message:u},link:{className:"Client",fnName:"startMixTranscode"}})});case 15:e.next=21;break;case 17:throw e.prev=17,e.t0=e.catch(5),this.isMixing_=!1,e.t0;case 21:case"end":return e.stop()}}),e,this,[[5,17]])}))),function(e){return r.apply(this,arguments)})},{key:"stopMixTranscode",value:(n=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMixing_){e.next=2;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"MIX_TRANSCODE_NOT_STARTED"})});case 2:return e.next=4,this.doStopMixTranscode();case 4:this.resetIsUsedFlag();case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"doStopMixTranscode",value:(t=o(regeneratorRuntime.mark((function e(){var t,n,r,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={mcuRequestTime:Date.now(),outputSessionId:this.data_.outputSessionId,streamType:this.data_.outputParam.streamType},this.log_.info("stopMixTranscode: ".concat(JSON.stringify(t))),e.next=4,this.signalChannel_.sendWaitForResponse({command:"stop_mcu_mix",data:t,timeout:5e3,responseCommand:pf.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"});case 4:if(n=e.sent,r=n.data,i=r.code,o=r.message,0!==i){e.next=10;break}this.isMixing_=!1,e.next=12;break;case 10:throw this.log_.error("stopMixTranscode failed, errCode: ".concat(i," errMsg: ").concat(o)),new vf({code:mf.STOP_MIX_TRANSCODE_FAILED,message:zf({key:"STOP_MIX_TRANSCODE_FAILED",data:{message:o},link:{className:"Client",fnName:"stopMixTranscode"}})});case 12:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getOutputSessionId",value:function(e){var t=e.config,n=e.userId,r=e.roomId;return Qd(t.streamId)&&t.streamId.length>0?t.streamId:Qg("".concat(r,"_").concat(n,"_main"))}},{key:"getInputParam",value:function(e,t){var n=this,r=e.mixUsers.map((function(e){return{userId:e.userId,roomId:String(e.roomId||n.client_.getRoomId()),width:e.width||0,height:e.height||0,locationX:e.locationX||0,locationY:e.locationY||0,zOrder:e.zOrder,streamType:Kd(e.streamType)||e.streamType!==Ml?0:1,inputType:e.pureAudio?gd:_d}}));return e.mode===md&&(r.forEach((function(e){if(e.userId===vd){var n=S(t.values()).find((function(e){return!e.isUsed}));n&&(e.userId=n.remoteStream.getUserId(),e.streamType=n.remoteStream.getType()===Ml?1:0,n.isUsed=!0)}})),r=r.filter((function(e){return e.userId!==vd}))),r}},{key:"getOutputParam",value:function(e){var t=e.streamId||"";return{streamId:t,streamType:t.length>0?1:0,width:Kd(e.videoWidth)?640:e.videoWidth,height:Kd(e.videoHeight)?480:e.videoHeight,videoBps:e.videoBitrate||0,fps:e.videoFramerate||15,gop:e.videoGOP||2,audioSampleRate:e.audioSampleRate||48e3,audioBps:e.audioBitrate||64,audioChannels:e.audioChannels||1,backgroundColor:e.backgroundColor||0,backgroundImg:e.backgroundImage||"",extraInfo:"",videoCodec:2,audioCodec:0}}},{key:"hasAvailablePlaceHolder",value:function(){return!!this.isPresetLayoutMode&&this.data_.inputParam.length!==this.config_.mixUsers.length}},{key:"resetIsUsedFlag",value:function(){this.remoteStreamMap_.forEach((function(e){return e.isUsed=!1}))}}]),e}(),$g=function(){function e(t){a(this,e),this.client_=t.client,this.signalChannel_=t.signalChannel,this.isPublishingTencentCDN_=!1,this.publishTencentStreamRetryCount_=0,this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1}var t,n,r,i,s;return c(e,[{key:"getIsPublishingTencentCDN",value:function(){return this.isPublishingTencentCDN_}},{key:"getIsPublishingGivenCDN",value:function(){return this.isPublishingGivenCDN_}},{key:"startPublishTencentCDN",value:(s=o(regeneratorRuntime.mark((function e(t){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=t.streamId)||(r="".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_main"),/^[A-Za-z\d_-]*$/.test(r)||(r=Qg(r)),n="".concat(this.client_.getSDKAppId(),"_").concat(r)),i={requestTime:Date.now(),sessionId:Qg("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_main")),streamId:n,streamType:0},this.isPublishingTencentCDN_=!0,this.publishTencentStreamRetryCount_=0,e.next=7,this.doStartPublishTencentCDN(i);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"doStartPublishTencentCDN",value:(i=o(regeneratorRuntime.mark((function e(t){var n,r,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,Pp.info("startPublishTencentCDN: "+JSON.stringify(t)),e.next=4,this.signalChannel_.sendWaitForResponseWithRetry({command:"start_publishing",data:t,timeout:2e3,responseCommand:pf.START_PUBLISH_TENCENT_CDN_RES,commandDesc:"startPublishCDNStream",retries:2});case 4:if(n=e.sent,r=n.data,i=r.code,o=r.message,0===i){e.next=11;break}throw this.isPublishingTencentCDN_=!1,-102083===i&&(o="Please enable relayed-push in ".concat("https://console.cloud.tencent.com/trtc"," and try later, refer to ").concat(Ud,"tutorial-26-advanced-publish-cdn-stream.html")),Pp.error("startPublishTencentCDN failed, errCode: ".concat(i,", errMsg: ").concat(o)),new vf({code:mf.START_PUBLISH_CDN_FAILED,message:zf({key:Lf,data:{message:o},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 11:e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(0),this.isPublishingTencentCDN_=!1,e.t0;case 17:case"end":return e.stop()}}),e,this,[[0,13]])}))),function(e){return i.apply(this,arguments)})},{key:"stopPublishTencentCDN",value:(r=o(regeneratorRuntime.mark((function e(){var t,n,r,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={requestTime:Date.now(),sessionId:Qg("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_main"))},Pp.info("stopPublishTencentCDN: "+JSON.stringify(t)),e.next=4,this.signalChannel_.sendWaitForResponse({command:"stop_publishing",data:t,timeout:5e3,responseCommand:pf.STOP_PUBLISH_TENCENT_CDN_RES,commandDesc:"stopPublishCDNStream"});case 4:if(n=e.sent,r=n.data,i=r.code,o=r.message,0!==i){e.next=10;break}this.isPublishingTencentCDN_=!1,e.next=17;break;case 10:if(-102069!==i){e.next=15;break}Pp.warn("stopPublishTencentCDN failed, can not stopPublishTencentCDN in auto relayed-push mode"),this.isPublishingTencentCDN_=!1,e.next=17;break;case 15:throw Pp.error("stopPublishTencentCDN failed, errCode: ".concat(i," errMsg: ").concat(o)),new vf({code:mf.STOP_PUBLISH_CDN_FAILED,message:zf({key:Mf,data:{message:o},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 17:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"startPublishGivenCDN",value:(n=o(regeneratorRuntime.mark((function e(t){var n,r,i,o,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={pushRequestTime:Date.now(),pushAppId:t.appId,pushBizId:t.bizId,pushCdnUrl:t.url,pushStreamType:"main"},Pp.info("startPublishGivenCDN: "+JSON.stringify(n)),this.publishGivenCDNData_=n,this.isPublishingGivenCDN_=!0,e.prev=4,e.next=7,this.signalChannel_.sendWaitForResponse({command:"start_push_user_cdn",data:n,timeout:5e3,responseCommand:pf.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDNStream"});case 7:if(r=e.sent,i=r.data,o=i.code,a=i.message,0===o){e.next=13;break}throw Pp.error("startPublishGivenCDN failed, errCode: ".concat(o,", errMsg: ").concat(a)),this.isPublishingGivenCDN_=!1,new vf({code:mf.START_PUBLISH_CDN_FAILED,message:zf({key:Lf,data:{message:a},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 13:e.next=19;break;case 15:throw e.prev=15,e.t0=e.catch(4),this.isPublishingGivenCDN_=!1,e.t0;case 19:case"end":return e.stop()}}),e,this,[[4,15]])}))),function(e){return n.apply(this,arguments)})},{key:"stopPublishGivenCDN",value:(t=o(regeneratorRuntime.mark((function e(){var t,n,r,i,o,a,s,c,u,l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.publishGivenCDNData_,n=t.pushAppId,r=t.pushBizId,i=t.pushCdnUrl,o=t.pushStreamType,a={pushRequestTime:Date.now(),pushAppId:n,pushBizId:r,pushCdnUrl:i,pushStreamType:o},Pp.info("stopPublishGivenCDN: "+JSON.stringify(a)),e.next=5,this.signalChannel_.sendWaitForResponse({command:"stop_push_user_cdn",data:a,timeout:5e3,responseCommand:pf.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDNStream"});case 5:if(s=e.sent,c=s.data,u=c.code,l=c.message,0!==u){e.next=11;break}this.isPublishingGivenCDN_=!1,e.next=13;break;case 11:throw Pp.error("stopPublishGivenCDN failed, errCode: ".concat(u," errMsg: ").concat(l)),new vf({code:mf.STOP_PUBLISH_CDN_FAILED,message:zf({key:Mf,data:{message:l},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),Yg=function(){function e(t){a(this,e),this.client_=t.client,this.durationMap_=new Map,this.installEvents()}return c(e,[{key:"installEvents",value:function(){yp.on(Ip,this.handleSubscribed,this),yp.on(bp,this.handleStreamTrackUpdated,this),yp.on(Tp,this.handleStreamStopped,this),yp.on(wp,this.handleStreamStopped,this)}},{key:"uninstallEvents",value:function(){yp.off(Ip,this.handleSubscribed,this),yp.off(115,this.handleStreamTrackUpdated,this),yp.off(Tp,this.handleStreamStopped,this),yp.off(wp,this.handleStreamStopped,this)}},{key:"handleSubscribed",value:function(e){var t=e.client,n=e.stream;if(t===this.client_){var r=n.getUserId(),i=n.getType(),o="".concat(r,"_").concat(i);if(n.hasAudio())if(n.isMainAudioSubscribed){var a=new Jg,s=this.durationMap_.get(o);s?this.isRecording(s.audio)||s.audio.push(a):this.durationMap_.set(o,{userId:r,type:i,audio:[a],video:[]})}else this.stopDurationItem(o,ll);if(n.hasVideo())if(i===Ll&&n.isMainVideoSubscribed||i===Ml&&n.isAuxVideoSubscribed){var c=new Jg,u=this.durationMap_.get(o);u?this.isRecording(u.video)||u.video.push(c):this.durationMap_.set(o,{userId:r,type:i,audio:[],video:[c]})}else this.stopDurationItem(o,dl)}}},{key:"handleStreamStopped",value:function(e){var t=e.client,n=e.stream;if(this.clientHitTest(t)){var r=n.getUserId(),i=n.getType(),o="".concat(r,"_").concat(i);this.stopDurationItem(o,ll),this.stopDurationItem(o,dl)}}},{key:"handleStreamTrackUpdated",value:function(e){var t=e.client,n=e.userId,r=e.tinyId,i=e.kind,o=e.action;if(this.clientHitTest(t)&&this.client_.getConnections().has(r)){var a=i===hl?i:Ll,s="".concat(n,"_").concat(a);if(o===Id){var c=this.client_.getConnections().get(r).getSubscribeState();if(i===ll&&!c.audio||i===dl&&!c.video||i===hl&&!c.auxiliary)return;var u=new Jg,l=this.durationMap_.get(s);l?(i!==ll||this.isRecording(l.audio)||l.audio.push(u),i===ll||this.isRecording(l.video)||l.video.push(u)):this.durationMap_.set(s,{userId:n,type:a,audio:i===ll?[u]:[],video:i===ll?[]:[u]})}else this.stopDurationItem(s,i===ll?ll:dl)}}},{key:"isRecording",value:function(e){return e.findIndex((function(e){return 0===e.endTime}))>=0}},{key:"stopDurationItem",value:function(e,t){if(this.durationMap_.has(e)){var n=this.durationMap_.get(e)[t].find((function(e){return 0===e.endTime}));n&&n.stop()}}},{key:"clientHitTest",value:function(e){return this.client_===e}},{key:"getDuration",value:function(e,t){return this.durationMap_.has(e)?this.durationMap_.get(e)[t].reduce((function(e,t){return e+t.getDuration()}),0):0}},{key:"getDurationMap",value:function(){return this.durationMap_}},{key:"reset",value:function(){this.durationMap_.clear()}}]),e}(),Zg=ri.f,ey=P((function(){return!Object.getOwnPropertyNames(1)}));Rt({target:"Object",stat:!0,forced:ey},{getOwnPropertyNames:Zg});var ty={msg_user_info:0,uint32_video_avg_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_avg_bitrate:0,uint32_video_block_time:0,uint32_video_play_time:0,uint32_audio_block_time:0,uint32_audio_play_time:0,uint32_audio_play_db:0,uint32_avg_down_loss:0,uint32_stream_type:0,uint32_video_render_first:0,uint32_video_block_count:0,uint32_audio_block_count:0,uint32_audio_bitrate:0,uint32_video_black_screen_subjective:0,uint32_audio_recv_bitrate:0,uint32_video_external_block_time:0},ny=function e(t){a(this,e),this.str_identifier=String(t.userId),this.uint64_tinyid=Number(t.tinyId),this.uint32_role=t.role},ry=function(){function e(t){var n=this;a(this,e),this.frameWorkType_=t.frameWorkType||30,this.client_=t.client,this.keyPrefix_="key_point",this.storageKey_="".concat(this.keyPrefix_,"_").concat(this.client_.getUserId()),this.log_=Pp.createLogger({id:"kpm|"+this.client_.getUserId(),userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId()}),this.upload=Cp({retryFunction:this.upload,settings:{timeout:500,retries:3},onError:function(e,t){return t()}}),Object.getOwnPropertyNames(this.__proto__).forEach((function(e){e.startsWith("handle")&&qd(n[e])&&(n[e]=function(e){var t=e.fn,n=e.context;return o(regeneratorRuntime.mark((function e(){var r,i,o,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(e.prev=0,r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=4,t.apply(n||this,i);case 4:return e.abrupt("return",e.sent);case 7:e.prev=7,e.t0=e.catch(0),Pp.error("".concat(t.name,"() error observed ")+e.t0);case 10:case"end":return e.stop()}}),e,this,[[0,7]])})))}({fn:n[e],context:n}))})),this.initData(),this.installEvents(),this.intervalId_=cm.setInterval(this.setStorage.bind(this),2e4)}var n,r,i;return c(e,[{key:"initData",value:function(){this.firstPublishedUserList_=[],this.networkQuality_={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this.basicInfo={string_sdk_version:"4.12.2",uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:"live"===this.client_.getMode()?1:0,uint32_joining_duration:0,uint32_networkType:wd[Gd()],uint32_framework:this.frameWorkType_},this.pathJoinRoom_={uint64_start_time:0,uint64_init_audio_start_time:0,uint64_init_audio_end_time:0,uint64_init_camera_start_time:0,uint64_init_camera_end_time:0,uint64_send_request_acc_ip_cmd_start_time:0,uint64_send_request_acc_ip_cmd_end_time:0,uint64_send_request_enter_room_cmd_start_time:0,uint64_send_request_enter_room_cmd_end_time:0,uint64_send_first_video_frame_time:0,uint64_recv_userlist_time:0,uint64_end_time:0,int32_init_audio_ret:0,int32_init_camera_ret:0,int32_send_request_acc_ip_cmd_ret:0,int32_send_request_enter_room_cmd_ret:0,int32_end_ret:0},this.pathLeaveRoom_={uint64_start_time:0,uint64_send_request_exit_room_cmd_start_time:0,uint64_send_request_exit_room_cmd_end_time:0,uint64_end_time:0,int32_send_request_exit_room_cmd_ret:0,int32_end_ret:0},this.pathMainVideoMap_=new Map,this.pathMainAudioMap_=new Map,this.pathAuxiliaryMap_=new Map,this.localStreamStats_={totalVideoBitrate:0,totalVideoFPS:0,totalVideoHeight:0,totalVideoWidth:0,totalAudioLevel:0,videoCount:0,audioLevelCount:0,publishStartTime:0,statsToReport:{uint32_audio_capture_db:0,uint32_video_big_capture_fps:0,uint32_video_big_bitrate:0,uint32_video_big_resolution:0}},this.remoteStreamStatsMap_=new Map}},{key:"installEvents",value:function(){yp.on(1,this.handleJoinStart,this),yp.on(28,this.handleWSStart,this),yp.on(29,this.handleWSEnd,this),yp.on(2,this.handleJoinSendCMD,this),yp.on(3,this.handleJoinReceivedCMDResponce,this),yp.on(4,this.handleJoinSuccess,this),yp.on(5,this.handleJoinFailed,this),yp.on(24,this.handleReceivedPublishUserList,this),yp.on(200,this.handleConnectionStateChanged,this),yp.on(20,this.handleLeaveStart,this),yp.on(22,this.handleLeaveSuccess,this),yp.on(21,this.handleLeaveSendCMD,this),yp.on(201,this.handleSendSubscribeCMD,this),yp.on(Sp,this.handleVideoPlaying,this),yp.on(103,this.handleAudioPlaying,this),yp.on(300,this.handleNetworkQuality,this),yp.on(23,this.handleHeartbeatStats,this),yp.on(kp,this.handleRemoteStreamAdded,this),yp.on(112,this.handleRemoteStreamSubscribeStart,this),yp.on(Ip,this.handleRemoteStreamSubscribed,this),yp.on(133,this.handleVideoLoadedData,this),yp.on(132,this.handlePlayStream,this),yp.on(27,this.handlePublishStart,this),yp.on(121,this.handleLocalStreamInitStart,this),yp.on(122,this.handleLocalStreamInitEnd,this),yp.on(123,this.handleLocalStreamInitFailed,this)}},{key:"uninstallEvents",value:function(){yp.off(1,this.handleJoinStart,this),yp.off(28,this.handleWSStart,this),yp.off(29,this.handleWSEnd,this),yp.off(2,this.handleJoinSendCMD,this),yp.off(3,this.handleJoinReceivedCMDResponce,this),yp.off(24,this.handleReceivedPublishUserList,this),yp.off(200,this.handleConnectionStateChanged,this),yp.off(20,this.handleLeaveStart,this),yp.off(22,this.handleLeaveSuccess,this),yp.off(4,this.handleJoinSuccess,this),yp.off(5,this.handleJoinFailed,this),yp.off(21,this.handleLeaveSendCMD,this),yp.off(201,this.handleSendSubscribeCMD,this),yp.off(Sp,this.handleVideoPlaying,this),yp.off(103,this.handleAudioPlaying,this),yp.off(300,this.handleNetworkQuality,this),yp.off(23,this.handleHeartbeatStats,this),yp.off(kp,this.handleRemoteStreamAdded,this),yp.off(112,this.handleRemoteStreamSubscribeStart,this),yp.off(Ip,this.handleRemoteStreamSubscribed,this),yp.off(133,this.handleVideoLoadedData,this),yp.off(132,this.handlePlayStream,this),yp.off(27,this.handlePublishStart,this),yp.off(121,this.handleLocalStreamInitStart,this),yp.off(122,this.handleLocalStreamInitEnd,this),yp.off(123,this.handleLocalStreamInitFailed,this)}},{key:"handleJoinStart",value:function(e){this.hitTest(e.client)&&0===this.pathJoinRoom_.uint64_start_time&&(this.pathJoinRoom_.uint64_start_time=Date.now(),this.checkStorage())}},{key:"handleWSStart",value:function(e){var t=e.client;this.hitTest(t)&&0===this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_start_time&&(this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_start_time=Date.now())}},{key:"handleWSEnd",value:function(e){var t=e.client,n=e.error;this.hitTest(t)&&0===this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_end_time&&(this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_end_time=Date.now(),n&&(this.pathJoinRoom_.int32_send_request_acc_ip_cmd_ret=n instanceof vf?Number(n.getExtraCode()||n.getCode()):mf.UNKNOWN,this.pathJoinRoom_.int32_end_ret=2))}},{key:"handleJoinSendCMD",value:function(e){this.hitTest(e.client)&&0===this.pathJoinRoom_.uint64_send_request_enter_room_cmd_start_time&&(this.pathJoinRoom_.uint64_send_request_enter_room_cmd_start_time=Date.now())}},{key:"handleJoinReceivedCMDResponce",value:function(e){this.hitTest(e.client)&&0===this.pathJoinRoom_.uint64_send_request_enter_room_cmd_end_time&&(this.pathJoinRoom_.uint64_send_request_enter_room_cmd_end_time=Date.now(),this.pathJoinRoom_.int32_send_request_enter_room_cmd_ret=e.code,0!==e.code&&(this.pathJoinRoom_.int32_end_ret=3))}},{key:"handleJoinSuccess",value:function(e){this.hitTest(e.client)&&0===this.pathJoinRoom_.uint64_end_time&&(this.pathJoinRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.int32_end_ret=0)}},{key:"handleJoinFailed",value:function(e){var t=e.client;this.hitTest(t)&&(this.pathJoinRoom_.uint64_end_time=Date.now(),0===this.pathJoinRoom_.int32_end_ret&&(this.pathJoinRoom_.int32_end_ret=3),this.prepareReport(),this.report())}},{key:"handleReceivedPublishUserList",value:function(e){this.hitTest(e.client)&&0===this.pathJoinRoom_.uint64_recv_userlist_time&&(this.pathJoinRoom_.uint64_recv_userlist_time=Date.now(),this.firstPublishedUserList_=e.data.data&&e.data.data.userList||[])}},{key:"handleConnectionStateChanged",value:function(e){var t=e.client,n=e.state,r=e.connection;if(this.hitTest(t)&&n===Vl){this.client_.getUplinkConnection()===r&&0===this.pathJoinRoom_.uint64_send_first_video_frame_time&&this.localStreamStats_.publishStartTime>this.pathJoinRoom_.uint64_end_time&&this.localStreamStats_.publishStartTime-this.pathJoinRoom_.uint64_end_time<=100&&(this.pathJoinRoom_.uint64_send_first_video_frame_time=Date.now());var i=this.pathMainVideoMap_.get("".concat(r.getUserId(),"_").concat(Ll));i&&0===i.statsToReport.uint64_pc_connected_time&&(i.statsToReport.uint64_pc_connected_time=Date.now())}}},{key:"handleLeaveStart",value:function(e){this.hitTest(e.client)&&(this.pathLeaveRoom_.uint64_start_time=Date.now())}},{key:"handleLeaveSuccess",value:function(e){this.hitTest(e.client)&&0===this.pathLeaveRoom_.uint64_end_time&&(this.pathLeaveRoom_.uint64_end_time=Date.now(),0!==this.pathJoinRoom_.uint64_end_time?this.basicInfo.uint32_joining_duration=this.pathLeaveRoom_.uint64_end_time-this.pathJoinRoom_.uint64_end_time:this.log_.warn("pathJoinRoom endTime is 0"),this.report())}},{key:"handleLeaveSendCMD",value:function(e){this.hitTest(e.client)&&(this.pathLeaveRoom_.uint64_send_request_exit_room_cmd_start_time=Date.now(),this.pathLeaveRoom_.uint64_send_request_exit_room_cmd_end_time=Date.now())}},{key:"handleRemoteStreamAdded",value:function(e){var n=e.client,r=e.stream;if(this.hitTest(n)){var i=r.getUserId(),o=r.getType(),a="".concat(i,"_").concat(o),s=this.remoteStreamStatsMap_.get(a);if(s)s.stream=r;else{var c={userId:i,totalVideoFPS:0,totalVideoBitrate:0,totalAudioLevel:0,totalAudioBitrate:0,totalLoss:0,audioCount:0,audioLevelCount:0,videoCount:0,networkQualityCount:0,streamAddedTime:Date.now(),subscribeStartTime:0,subscribedTime:0,playStreamTime:0,statsToReport:t({},ty),stream:r};c.statsToReport.msg_user_info=new ny({userId:i,tinyId:r.getTinyId(),role:Al}),c.statsToReport.uint32_stream_type=o===Ll?2:7,this.remoteStreamStatsMap_.set(a,c)}}}},{key:"handleRemoteStreamSubscribeStart",value:function(e){var t=e.client,n=e.stream;if(this.hitTest(t)){var r=n.getUserId(),i=n.getType(),o="".concat(r,"_").concat(i),a=this.remoteStreamStatsMap_.get(o);a&&0===a.subscribeStartTime&&(a.subscribeStartTime=Date.now())}}},{key:"handleSendSubscribeCMD",value:function(e){if(this.hitTest(e.client)){var t=new ny(e),n=Date.now(),r="".concat(e.userId,"_").concat(Ll);e.trackState.video&&e.subscribeState.video&&!this.pathMainVideoMap_.has(r)&&this.pathMainVideoMap_.set(r,{statsToReport:{msg_user_info:t,uint64_start_enter_time:this.pathJoinRoom_.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0,uint64_pc_connected_time:0},userId:e.userId,sendSubscribeCMDTime:n}),e.trackState.audio&&e.subscribeState.audio&&!this.pathMainAudioMap_.has(r)&&this.pathMainAudioMap_.set(r,{statsToReport:{msg_user_info:t,uint64_start_enter_time:this.pathJoinRoom_.uint64_start_time,uint64_play_first_frame_time:0},userId:e.userId,sendSubscribeCMDTime:n});var i="".concat(e.userId,"_").concat(Ml);e.trackState.auxiliary&&e.subscribeState.auxiliary&&!this.pathAuxiliaryMap_.has(i)&&this.pathAuxiliaryMap_.set(i,{sendSubscribeCMDTime:n})}}},{key:"handleRemoteStreamSubscribed",value:function(e){var t=e.client,n=e.stream;if(this.hitTest(t)){var r=n.getUserId(),i=n.getType(),o="".concat(r,"_").concat(i),a=this.remoteStreamStatsMap_.get(o);a&&0===a.subscribedTime&&(a.subscribedTime=Date.now(),a.stream=n)}}},{key:"handlePlayStream",value:function(e){var t=e.stream;if(t.isRemote()&&t.getConnection()&&this.hitTest(t.getConnection().getClient())){var n=t.getConnection().getUserId(),r="".concat(n,"_").concat(t.getType());if(this.remoteStreamStatsMap_.has(r)){var i=this.remoteStreamStatsMap_.get(r);0===i.playStreamTime&&(i.playStreamTime=Date.now())}}}},{key:"handleVideoLoadedData",value:function(e){var t=e.stream;if(t.isRemote()&&t.getConnection()&&this.hitTest(t.getConnection().getClient())){var n=t.getConnection().getUserId(),r="".concat(n,"_").concat(t.getType());if(this.pathMainVideoMap_.has(r)){var i=this.pathMainVideoMap_.get(r);0===i.statsToReport.uint64_combine_first_frame_time&&(i.statsToReport.uint64_combine_first_frame_time=Date.now())}}}},{key:"handleVideoPlaying",value:function(e){var t=e.stream;if(t.isRemote()&&t.getConnection()&&this.hitTest(t.getConnection().getClient())){var n=t.getConnection().getUserId(),r="".concat(n,"_").concat(t.getType()),i=Date.now();if(this.pathMainVideoMap_.has(r)){var o=this.pathMainVideoMap_.get(r);if(0===o.statsToReport.uint64_render_first_frame_time&&(o.statsToReport.uint64_render_first_frame_time=i),this.remoteStreamStatsMap_.has(r)){var a=this.remoteStreamStatsMap_.get(r),s=a.statsToReport,c=a.playStreamTime,u=a.subscribedTime;0===s.uint32_video_render_first&&c-u<=100&&(s.uint32_video_render_first=i-o.sendSubscribeCMDTime)}}if(t.getType()===Ml&&this.pathAuxiliaryMap_.has(r)&&this.remoteStreamStatsMap_.has(r)){var l=this.remoteStreamStatsMap_.get(r),d=l.statsToReport,h=l.playStreamTime,p=l.subscribedTime;0===d.uint32_video_render_first&&h-p<=100&&(d.uint32_video_render_first=i-this.pathAuxiliaryMap_.get(r).sendSubscribeCMDTime)}}}},{key:"handleAudioPlaying",value:function(e){if(e.stream.isRemote()&&e.stream.getConnection()&&this.hitTest(e.stream.getConnection().getClient())){var t=e.stream.getConnection().getUserId(),n="".concat(t,"_").concat(e.stream.getType());if(this.pathMainAudioMap_.has(n)){var r=this.pathMainAudioMap_.get(n);0===r.statsToReport.uint64_play_first_frame_time&&(r.statsToReport.uint64_play_first_frame_time=Date.now())}}}},{key:"handleNetworkQuality",value:function(e){var t=this;this.hitTest(e.client)&&(this.networkQuality_.totalUplinkLoss+=e.uplinkLoss,this.networkQuality_.totalUplinkRTT+=e.uplinkRTT,this.networkQuality_.count++,e.downlinkLossAndRTTMap.forEach((function(e){var n=e.rtt,r=e.loss,i=e.userId,o=t.networkQuality_.totalDownlinkRTTAndLossMap.get(i);o?(o.totalRTT+=n,o.totalLoss+=r,o.count++):t.networkQuality_.totalDownlinkRTTAndLossMap.set(i,{totalRTT:n,totalLoss:r,count:1})})))}},{key:"handleHeartbeatStats",value:function(e){var t=this;if(this.hitTest(e.client)){var n=e.stats,r=n.msg_up_stream_info,i=n.msg_down_stream_info;if(r.msg_video_status[0]){var o=r.msg_video_status[0],a=o.uint32_video_codec_bitrate,s=o.uint32_video_enc_fps,c=o.uint32_video_width,u=o.uint32_video_height;this.localStreamStats_.totalVideoBitrate+=a,this.localStreamStats_.totalVideoFPS+=s,this.localStreamStats_.totalVideoWidth+=c,this.localStreamStats_.totalVideoHeight+=u,this.localStreamStats_.videoCount++}var l=r.msg_audio_status.audioLevel;Math.floor(100*l)>0&&(this.localStreamStats_.totalAudioLevel+=l,this.localStreamStats_.audioLevelCount++),i.forEach((function(e){var n=e.msg_user_info,r=e.msg_audio_status,i=e.msg_video_status,o=n.str_identifier;if(i.forEach((function(e){var n=2===e.uint32_video_stream_type,r=7===e.uint32_video_stream_type,i="".concat(o,"_").concat(n?Ll:Ml);if(t.remoteStreamStatsMap_.has(i)){var a=t.remoteStreamStatsMap_.get(i);(n&&a.stream.isMainVideoSubscribed||r&&a.stream.isAuxVideoSubscribed)&&(a.totalVideoFPS+=e.uint32_video_receive_fps,a.totalVideoBitrate+=e.uint32_video_codec_bitrate,a.videoCount++,0===a.statsToReport.uint32_video_width&&(a.statsToReport.uint32_video_width=e.uint32_video_width),0===a.statsToReport.uint32_video_height&&(a.statsToReport.uint32_video_height=e.uint32_video_height))}})),r){var a="".concat(o,"_").concat(Ll);if(t.remoteStreamStatsMap_.has(a)){var s=t.remoteStreamStatsMap_.get(a);s.stream.isMainAudioSubscribed&&(s.totalAudioBitrate+=r.uint32_audio_codec_bitrate,s.audioCount++,Math.floor(100*r.audioLevel)>0&&(s.totalAudioLevel+=r.audioLevel,s.audioLevelCount++))}}}))}}},{key:"handlePublishStart",value:function(e){var t=e.client;this.hitTest(t)&&0===this.localStreamStats_.publishStartTime&&(this.localStreamStats_.publishStartTime=Date.now())}},{key:"handleLocalStreamInitStart",value:function(e){var t=e.audio,n=e.video;t&&0===this.pathJoinRoom_.uint64_init_audio_start_time&&(this.pathJoinRoom_.uint64_init_audio_start_time=Date.now()),n&&0===this.pathJoinRoom_.uint64_init_camera_start_time&&(this.pathJoinRoom_.uint64_init_camera_start_time=Date.now())}},{key:"handleLocalStreamInitEnd",value:function(e){var t=e.audio,n=e.video;t&&0===this.pathJoinRoom_.uint64_init_audio_end_time&&(this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),n&&0===this.pathJoinRoom_.uint64_init_camera_end_time&&(this.pathJoinRoom_.uint64_init_camera_end_time=Date.now())}},{key:"handleLocalStreamInitFailed",value:function(e){var t=e.audio,n=e.video,r=e.error,i=r instanceof vf?r.getExtraCode()||r.getCode():{NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5}[r.name]||mf.UNKNOWN;t&&0===this.pathJoinRoom_.uint64_init_audio_end_time&&(this.pathJoinRoom_.int32_init_audio_ret=i,this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),n&&0===this.pathJoinRoom_.uint64_init_camera_end_time&&(this.pathJoinRoom_.int32_init_camera_ret=i,this.pathJoinRoom_.uint64_init_camera_end_time=Date.now())}},{key:"hasVideoFlag",value:function(e){return this.firstPublishedUserList_.findIndex((function(t){return t.userId===e&&1&t.flag}))>=0}},{key:"hasAudioFlag",value:function(e){return this.firstPublishedUserList_.findIndex((function(t){return t.userId===e&&8&t.flag}))>=0}},{key:"hasAuxFlag",value:function(e){return this.firstPublishedUserList_.findIndex((function(t){return t.userId===e&&4&t.flag}))>=0}},{key:"hitTest",value:function(e){return e===this.client_}},{key:"checkStorage",value:(i=o(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!(t=um.getItem(this.storageKey_))){e.next=6;break}return e.next=5,this.upload(t);case 5:um.deleteItem(this.storageKey_);case 6:e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),this.log_.warn(e.t0);case 11:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(){return i.apply(this,arguments)})},{key:"setStorage",value:function(){this.prepareReport();var e=this.getReportData();0!==e.msg_path_enter_room.uint64_start_time&&um.setItem(this.storageKey_,e)}},{key:"prepareReport",value:function(){var e=this;if(this.networkQuality_.count>0&&(this.basicInfo.uint32_avg_rtt=Math.floor(this.networkQuality_.totalUplinkRTT/this.networkQuality_.count),this.basicInfo.uint32_avg_up_loss=Math.floor(this.networkQuality_.totalUplinkLoss/this.networkQuality_.count)),this.localStreamStats_.videoCount>0){this.localStreamStats_.statsToReport.uint32_video_big_capture_fps=Math.floor(this.localStreamStats_.totalVideoFPS/this.localStreamStats_.videoCount),this.localStreamStats_.statsToReport.uint32_video_big_bitrate=Math.floor(this.localStreamStats_.totalVideoBitrate/this.localStreamStats_.videoCount);var t=Math.floor(this.localStreamStats_.totalVideoWidth/this.localStreamStats_.videoCount),n=Math.floor(this.localStreamStats_.totalVideoHeight/this.localStreamStats_.videoCount);this.localStreamStats_.statsToReport.uint32_video_big_resolution=t<<16|n}this.localStreamStats_.audioLevelCount>0&&(this.localStreamStats_.statsToReport.uint32_audio_capture_db=Math.floor(this.localStreamStats_.totalAudioLevel/this.localStreamStats_.audioLevelCount*100)),this.remoteStreamStatsMap_.forEach((function(t,n){var r=t.userId;if(e.networkQuality_.totalDownlinkRTTAndLossMap.has(r)){var i=e.networkQuality_.totalDownlinkRTTAndLossMap.get(r),o=i.totalLoss,a=i.count;t.statsToReport.uint32_avg_down_loss=Math.floor(o/a)}t.videoCount>0&&(t.statsToReport.uint32_video_avg_fps=Math.floor(t.totalVideoFPS/t.videoCount),t.statsToReport.uint32_video_avg_bitrate=Math.floor(t.totalVideoBitrate/t.videoCount)),t.audioCount>0&&(t.statsToReport.uint32_audio_recv_bitrate=t.statsToReport.uint32_audio_bitrate=Math.floor(t.totalAudioBitrate/t.audioCount)),t.audioLevelCount>0&&(t.statsToReport.uint32_audio_play_db=Math.floor(t.totalAudioLevel/t.audioLevelCount*100));var s=e.client_.getCallDurationCalculator();s&&(t.statsToReport.uint32_audio_play_time=s.getDuration(n,ll),t.statsToReport.uint32_video_play_time=s.getDuration(n,dl)),t.statsToReport.uint32_video_render_first=Math.min(t.statsToReport.uint32_video_render_first,5e3);var c=e.client_.getBadCaseDetector();if(c){var u=c.getDataFreezeDuration(n),l=u.dataFreeze,d=u.count,h=c.getRenderFreezeDuration(n).renderFreeze;t.statsToReport.uint32_video_block_count=d,t.statsToReport.uint32_video_block_time=Math.min(l,t.statsToReport.uint32_video_play_time),t.statsToReport.uint32_video_external_block_time=Math.min(h,t.statsToReport.uint32_video_play_time),c.isBlackStream(n)&&0===t.statsToReport.uint32_video_avg_fps?t.statsToReport.uint32_video_black_screen_subjective=1:t.statsToReport.uint32_video_black_screen_subjective=0}(0===t.subscribeStartTime||t.subscribeStartTime-t.streamAddedTime>100||0===t.playStreamTime)&&(e.pathMainAudioMap_.delete(n),e.pathMainVideoMap_.delete(n),t.statsToReport.uint32_video_render_first=0)})),this.pathMainAudioMap_.forEach((function(t,n){e.hasAudioFlag(t.userId)?t.statsToReport.uint64_play_first_frame_time-t.statsToReport.uint64_start_enter_time>5e3&&(t.statsToReport.uint64_play_first_frame_time=t.statsToReport.uint64_start_enter_time+5e3):e.pathMainAudioMap_.delete(n)})),this.pathMainVideoMap_.forEach((function(t,n){e.hasVideoFlag(t.userId)?t.statsToReport.uint64_render_first_frame_time-t.statsToReport.uint64_start_enter_time>5e3&&(t.statsToReport.uint64_render_first_frame_time=t.statsToReport.uint64_start_enter_time+5e3):e.pathMainVideoMap_.delete(n)})),this.pathJoinRoom_.uint64_end_time-this.pathJoinRoom_.uint64_start_time>5e3&&(this.pathJoinRoom_.uint64_end_time=this.pathJoinRoom_.uint64_start_time+5e3)}},{key:"getReportData",value:function(){var e=this.client_.getSignalInfo();return{uint32_sdk_app_id:Number(this.client_.getSDKAppId()),msg_user_info:new ny({userId:this.client_.getUserId(),tinyId:this.client_.getTinyId(),role:"anchor"===this.client_.getRole()?Al:21}),msg_basic_info:this.basicInfo,uint32_acc_ip:rh(e.relayIp),uint32_client_ip:rh(e.clientIp,"small"),uint32_acc_port:0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(Math.random()*Math.pow(2,31)),msg_path_enter_room:this.pathJoinRoom_,msg_path_exit_room:this.pathLeaveRoom_,msg_path_recv_video:S(this.pathMainVideoMap_.values()).map((function(e){return e.statsToReport})),msg_quality_statistics:S(this.remoteStreamStatsMap_.values()).map((function(e){return e.statsToReport})),str_room_name:String(this.client_.getRoomId()),msg_path_recv_audio:S(this.pathMainAudioMap_.values()).map((function(e){return e.statsToReport})),uint32_info_client_ip:rh(e.clientIp,"small"),error_code:[],msg_local_statistics:this.localStreamStats_.statsToReport}}},{key:"report",value:(r=o(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=this.getReportData(),e.next=4,this.upload(t);case 4:um.deleteItem(this.storageKey_),this.initData(),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),this.log_.warn(e.t0);case 11:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(){return r.apply(this,arguments)})},{key:"upload",value:(n=o(regeneratorRuntime.mark((function e(t){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(ol||0===t.msg_path_enter_room.uint64_start_time||[Ld,Md,Nd].findIndex((function(e){return e===location.host}))>=0)){e.next=2;break}return e.abrupt("return");case 2:return n=Number(this.client_.getSDKAppId()),r=zd(n,"jssdk_new_endreport"),e.next=6,_p.post(r,JSON.stringify(t));case 6:if("ok"===(i=e.sent).data){e.next=9;break}throw"key point upload failed: ".concat(i.data);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})}]),e}();function iy(){return function(e,t,n){var r=n.value,i=new Map;return n.value=o(regeneratorRuntime.mark((function e(){var n,o,a,s,c=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!i.get(this)){e.next=2;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:Rf,data:{name:t}})});case 2:for(e.prev=2,i.set(this,!0),n=c.length,o=new Array(n),a=0;a<n;a++)o[a]=c[a];return e.next=7,r.apply(this,o);case 7:return s=e.sent,i.set(this,!1),e.abrupt("return",s);case 12:throw e.prev=12,e.t0=e.catch(2),i.set(this,!1),e.t0;case 16:case"end":return e.stop()}}),e,this,[[2,12]])}))),n}}function oy(e){return ay.apply(this,arguments)}function ay(){return(ay=o(regeneratorRuntime.mark((function e(t){var n,r,i,o,a,s,c,u,l,d,h,p,f;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.userId,r=t.sdkAppId,i=t.useStringRoomId,o=t.roomId,a=t.userSig,s={delta:0,count:[1,1],msg:[]},e.prev=2,(c=new FormData).append("userId",String(n)),c.append("sdkAppId",String(r)),c.append("isStrGroupId",i),c.append("groupId",String(o)),c.append("sdkVersion","4.12.2"),c.append("userSig",String(a)),u=nh(),e.next=13,wy(c,s,r);case 13:return l=e.sent,s.delta=nh()-u,sy({stat:s,userId:n}),e.abrupt("return",l);case 19:throw e.prev=19,e.t0=e.catch(2),d=Yd(e.t0)?e.t0[0]:e.t0,h=Xd(d.code)?d.code:0,p="get websocket url failed: ".concat(d.message.includes("timeout")?"timeout":d.message),f=new vf({code:mf.SCHEDULE_FAILED,extraCode:h,message:zf({key:Af,data:{error:p,code:h}})}),Pp.error(f),sy({stat:s,userId:n,roomId:o,error:f}),f;case 28:case"end":return e.stop()}}),e,null,[[2,19]])})))).apply(this,arguments)}function sy(e){var t=e.stat,n=e.userId,r=e.error;r?Gf.logFailedEvent({eventType:ld,error:r,userId:n}):Gf.logSuccessEvent({eventType:ld,delta:t.delta,userId:n}),Gf.uploadEvent({log:"stat-schedule:"+JSON.stringify(t),userId:n})}function cy(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:wl;return t=Hd(e)?n===wl?Cd:xd:n===wl?Rd:Ed,"https://".concat(t,"/api/v1/config")}function uy(e,t,n){return new Promise((function(r,i){_p.post(e,t,n).then((function(e){0===e.data.code?r(e.data.data):i({code:e.data.code,message:e.data.msg})})).catch(i)}))}var ly,dy,hy,py,fy,my,vy,_y,gy,yy,Sy,by,ky,Iy,Ty=function(e,t){return Cp({retryFunction:uy,settings:{retries:3,timeout:0},onError:t,onRetrying:e})};function wy(e,t,n){return new Promise((function(r,i){var o,a=null;(o=[Ty((function(e){return t.count[0]=e+1}),(function(e,n){t.msg[0]=e.message,a||n()}))(cy(n,wl),e,{timeout:2e3}),Ty((function(e){return t.count[1]=e+1}),(function(e,n){t.msg[1]=e.message,a||n()}))(cy(n,Rl),e,{timeout:2e3})],new Promise((function(e,t){var n=[];o.forEach((function(r){r.then(e).catch((function(e){n.push(e),n.length===o.length&&t(n)}))}))}))).then((function(e){r(a=e)})).catch(i)}))}var Ry=(ly=iy(),dy=Cg(Rg.CLIENT.join),hy=iy(),py=iy(),fy=Cg(Rg.CLIENT.publish),my=iy(),vy=Cg(Rg.CLIENT.unpublish),_y=Cg.apply(void 0,S(Rg.CLIENT.subscribe)),gy=Cg(Rg.CLIENT.unsubscribe),yy=iy(),Sy=Cg(Rg.CLIENT.switchRole),by=Cg(Rg.CLIENT.startPublishCDNStream),ky=Cg(Rg.CLIENT.startMixTranscode),T((Iy=function(){function e(t){if(a(this,e),this.name_="Client",this.mode_=t.mode,this.sdpSemantics_="plan-b",Kd(t.sdpSemantics)?function(){if(!("RTCRtpTransceiver"in window)||!("stop"in window.RTCRtpTransceiver.prototype))return!1;if(Kd(window.RTCRtpTransceiver))return!1;if(!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var e=new RTCPeerConnection,t=!1;try{e.addTransceiver(ll),t=!0}catch(e){}return e.close(),t}()&&(this.sdpSemantics_="unified-plan"):this.sdpSemantics_=t.sdpSemantics,this.sdkAppId_=t.sdkAppId,this.userId_=t.userId,this.log_=Pp.createLogger({id:"c".concat(t.seq,"|").concat(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_}),this.userSig_=t.userSig,this.roomId_=0,this.useStringRoomId_=t.useStringRoomId||!1,this.recordId_=null,this.pureAudioPushMode_=null,this.version_=t.version,this.log_.info("using sdpSemantics: "+this.sdpSemantics_),!Kd(t.recordId)){if(!Number.isInteger(Number(t.recordId)))throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_RECORDID"})});this.recordId_=t.recordId}var n;this.signalChannel_=null,this.isScreenShareOnly_=0,Kd(t.isScreenShareOnly)||(this.isScreenShareOnly_=t.isScreenShareOnly?1:0),this.role_="anchor",this.privateMapKey_="",this.tinyId_=0,this.env_="",this.proxy_=null,this.connections_=new Map,this.mutedStates_=new Map,this.userMap_=new Map,this.syncUserListInterval_=-1,this.localStream_=null,this.uplinkConnection_=null,this.emitter_=new gp,this.isSignalReady_=!1,this.isJoined_=!1,this.heartbeat_=-1,this.lastHeartBeatTime_=-1,this.stats_=new ev(this),this.joinTimeout_=-1,this.networkQuality_=null,this.badCaseDetector_=null,this.networkType_=Gd(),this.autoSubscribe_=!!Kd(t.autoSubscribe)||t.autoSubscribe,this.startJoinTimestamp_=0,this.joinedTimestamp_=0,this.joinOptions_={},this.basis_={browser:cl().name+"/"+cl().version,os:xm(),displayResolution:Am(),isScreenShareSupported:Sm(),isWebRTCSupported:hm(),isGetUserMediaSupported:Pm(),isWebAudioSupported:Dm(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:(n={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1},Kd(window.AudioDecoder)||(n.AudioDecoder=!0),Kd(window.AudioEncoder)||(n.AudioEncoder=!0),Kd(window.VideoDecoder)||(n.VideoDecoder=!0),Kd(window.VideoEncoder)||(n.VideoEncoder=!0),Kd(window.ImageDecoder)||(n.ImageDecoder=!0),n),isMediaSessionSupported:"mediaSession"in navigator&&!Kd(navigator.mediaSession.setActionHandler),isWebTransportSupported:!Kd(window.WebTransport)},this.initBussinessInfo_(t),this.publishedCDN_=!1,this.publishCDNData_=null,this.mixedMCU_=!1,this.mixTranscodeData_=null,this.checkSystemResult_=null,this.enableAudioVolumeEvaluation_=!1,this.audioVolumeIntervalId_=null,this.mixTranscodeManager_=null,this.publishCDNManager_=null,this.keyPointManager_=new ry({client:this,frameWorkType:t.frameWorkType}),this.getUserList=Cp({retryFunction:this.getUserList,settings:{retries:3},onError:function(e,t){return t()}}),this.isPublishing_=!1,this.isEnableSmallStream_=!1,this.smallStreamConfig_={bitrate:100,frameRate:15,height:120,width:160},this.turnServers_=[],this.iceTransportPolicy_=t.iceTransportPolicy,this.schedule_={domains:null,iceServers:null,iceTransportPolicy:null},this.enableAutoPlayDialog_=!!Kd(t.enableAutoPlayDialog)||t.enableAutoPlayDialog,this.signalInfo_={}}var n,r,i,s,u,l,d,h,p,f,m,v,_,g,b,k,T,w,R,E,C,x,A,P,D,L;return c(e,[{key:"initBussinessInfo_",value:function(e){this.bussinessInfo_=e.bussinessInfo;var t={};if(Qd(e.bussinessInfo)&&(t=JSON.parse(e.bussinessInfo)),!Kd(e.pureAudioPushMode)){if(!Number.isInteger(Number(e.pureAudioPushMode)))throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_PURE_AUDIO"})});this.pureAudioPushMode_=e.pureAudioPushMode,t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.pure_audio_push_mod=this.pureAudioPushMode_}if(!Kd(e.streamId)){if(!(Qd(e.streamId)&&String(e.streamId)&&String(e.streamId).length<=64))throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_STREAMID"})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_streamid_main=e.streamId}if(!Kd(e.userDefineRecordId)){if(null===e.userDefineRecordId.match(/^[A-Za-z0-9_-]{1,64}$/gi))throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_USER_DEFINE_RECORDID"})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_record_id=e.userDefineRecordId}if(!Kd(e.userDefinePushArgs)){if(!(Qd(e.userDefinePushArgs)&&String(e.userDefinePushArgs)&&String(e.userDefinePushArgs).length<=256))throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_USER_DEFINE_PUSH_ARGS"})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_push_args=e.userDefinePushArgs}kf(t)||(this.bussinessInfo_=JSON.stringify(t))}},{key:"setProxyServer",value:function(e){if(this.log_.info("set proxy server: ".concat(JSON.stringify(e))),Qd(e)){if(!e.startsWith("wss://"))throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_PROXY"})});this.proxy_=e}else if(Wd(e)){var t=e.websocketProxy,n=e.loggerProxy;t&&(this.proxy_=t),n&&function(e){Cl=e}(n)}}},{key:"schedule",value:(L=o(regeneratorRuntime.mark((function e(n){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,oy({userId:this.userId_,sdkAppId:this.sdkAppId_,roomId:n,useStringRoomId:this.useStringRoomId_,version:this.version_,userSig:this.userSig_});case 2:(r=e.sent)&&(this.log_.info("schedule: ".concat(JSON.stringify(r))),this.schedule_=t(t({},this.schedule_),r),yp.emit(31,this.schedule_));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return L.apply(this,arguments)})},{key:"getSignalChannelUrl",value:function(){var e={mainUrl:"",backupUrl:""},t=Bd();return t?e.mainUrl=e.backupUrl="wss://".concat(t,".rtc.qq.com"):this.proxy_?e.mainUrl=e.backupUrl=this.proxy_:Array.isArray(this.schedule_.domains)&&this.schedule_.domains.length>0&&(e.mainUrl=e.backupUrl="wss://".concat(this.schedule_.domains[0]),this.schedule_.domains[1]&&(e.backupUrl="wss://".concat(this.schedule_.domains[1]))),e}},{key:"getUserId",value:function(){return this.userId_}},{key:"getUserSig",value:function(){return this.userSig_}},{key:"getRole",value:function(){return this.role_}},{key:"getSignalInfo",value:function(){return this.signalInfo_}},{key:"getRoomId",value:function(){return this.roomId_}},{key:"getSDKAppId",value:function(){return this.sdkAppId_}},{key:"getTinyId",value:function(){return this.tinyId_}},{key:"setTurnServer",value:function(e){this.log_.info("set turn server: "+JSON.stringify(e));var t=[];Array.isArray(e)?e.forEach((function(e){return t.push(th(e))})):Wd(e)&&t.push(th(e)),this.turnServers_=t}},{key:"getIceTransportPolicy",value:function(){return this.iceTransportPolicy_||this.schedule_.iceTransportPolicy||"all"}},{key:"initialize",value:function(){var e=this;return new Promise((function(t,n){e.log_.info("setup signal channel");var r=e.getSignalChannelUrl(),i=r.mainUrl,o=r.backupUrl;e.signalChannel_=new Wf({sdkAppId:e.sdkAppId_,userId:e.userId_,userSig:e.userSig_,url:i,backupUrl:o,version:e.version_,client:e}),e.networkQuality_||(e.networkQuality_=new tv({connections:e.connections_,signalChannel:e.signalChannel_,userId:e.userId_,client:e}),e.networkQuality_.on(Km,(function(t){e.emitter_.emit(Km,t)}))),e.deviceDetector_||(e.deviceDetector_=new nv({client:e})),e.subscriptionManager_||(e.subscriptionManager_=new Lg({client:e})),e.badCaseDetector_||(e.badCaseDetector_=new qg({client:e,stats:e.stats_})),e.callDurationCalculator_||(e.callDurationCalculator_=new Yg({client:e})),e.mixTranscodeManager_||(e.mixTranscodeManager_=new Xg({client:e,signalChannel:e.signalChannel_})),e.publishCDNManager_||(e.publishCDNManager_=new $g({client:e,signalChannel:e.signalChannel_})),e.signalChannel_.on(2,(function(t){e.log_.info("SignalChannel state changed from ".concat(t.prevState," to ").concat(t.state)),e.emitter_.emit("connection-state-changed",t)})),e.signalChannel_.on(4,(function(t){e.isSignalReady_?(e.reset(),e.emitter_.emit(Xm,t)):(yp.emit(29,{client:e,error:t}),n(t))})),e.signalChannel_.on(1,(function(n){e.tinyId_=n.signalInfo.tinyId,e.isSignalReady_||(e.isSignalReady_=!0,yp.emit(29,{client:e}),t())})),e.signalChannel_.on(pf.PEER_JOIN,e.onPeerJoin,e),e.signalChannel_.on(pf.PEER_LEAVE,e.onPeerLeave,e),e.signalChannel_.on(pf.UPDATE_REMOTE_MUTE_STAT,(function(t){Date.now()-e.lastHeartBeatTime_>=1e4&&e.doHeartbeat(),yp.emit(24,{client:e,data:t.data}),e.onPublishedUserList(t.data),e.onUpdateRemoteMuteStat(t.data)})),e.signalChannel_.on(pf.CLINET_BANNED,(function(t){var n=t.data.data,r=n.reason;if(Gf.uploadEvent({log:"stat-banned:".concat(r),userId:e.userId_}),"banned"===r)r="you got banned by account admin";else if("kick"===r)r="duplicated userId joining the room";else if("user_time_out"===r)return e.log_.warn("".concat(r," last heart beat time: ").concat(e.lastHeartBeatTime_," interval: ").concat(Date.now()-e.lastHeartBeatTime_,", visibility: ").concat(document.visibilityState)),void e.reJoin();e.log_.error("user was banned because of [".concat(n.reason,"]")),e.reset(),e.onClientBanned(r)})),yp.emit(28,{client:e}),e.signalChannel_.connect()}))}},{key:"join",value:(D=o(regeneratorRuntime.mark((function e(t){var n,r,i,o,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isJoined_){e.next=2;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_JOIN"})});case 2:return e.next=4,gm();case 4:if(this.checkSystemResult_=e.sent,(n=Bd())||(n=El,this.proxy_&&(this.proxy_.startsWith("wss://trtc.rtc.qq.com")?n="trtc":this.proxy_.startsWith("wss://webrtc.qq.com")&&(n="webrtc"))),this.env_=n,Gf.setConfig({env:n,sdkAppId:this.sdkAppId_,userId:this.userId_,roomId:t.roomId}),this.uploadTrtcStats(),r=this.checkSystemResult_.detail,i=r.isH264EncodeSupported,o=r.isVp8EncodeSupported,hm()&&(i||o)){e.next=13;break}throw new vf({code:mf.NOT_SUPPORTED,message:zf({key:"NOT_SUPPORTED_WEBRTC"})});case 13:if(this.joinOptions_=t,this.startJoinTimestamp_=nh(),yp.emit(1,{client:this}),yf(this.userId_,{eventId:32788,eventDesc:"joining room",timestamp:Sa(),userId:this.userId_,tinyId:this.tinyId_}),e.prev=17,this.proxy_||this.schedule_.domains){e.next=21;break}return e.next=21,this.schedule(t.roomId);case 21:return e.next=23,this.initialize(t);case 23:return e.next=25,this.doJoin(t);case 25:this.signalInfo_=this.signalChannel_.getSignalInfo(),yp.emit(4,{client:this}),this.joinedTimestamp_=nh(),a=this.joinedTimestamp_-this.startJoinTimestamp_,Gf.logSuccessEvent({userId:this.userId_,eventType:"delta-join",delta:a}),Gf.logSuccessEvent({userId:this.userId_,eventType:zl}),Gf.uploadEvent({log:"stat-autoplay-dialog:".concat(this.enableAutoPlayDialog_),userId:this.userId_}),Gf.uploadEvent({log:"stat-conv-".concat(ol,"-").concat(location.hostname),userId:this.userId_}),e.next=41;break;case 35:throw e.prev=35,e.t0=e.catch(17),yp.emit(5,{client:this,error:e.t0}),Gf.logFailedEvent({userId:this.userId_,eventType:zl,error:e.t0}),this.reset(),e.t0;case 41:case"end":return e.stop()}}),e,this,[[17,35]])}))),function(e){return D.apply(this,arguments)})},{key:"uploadTrtcStats",value:(P=o(regeneratorRuntime.mark((function e(){var t,n,r,i,o,a,s,c,u,l,d,h,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Wy.getMicrophones();case 3:r=e.sent,t=r&&r.length,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(0);case 9:return e.prev=9,e.next=12,Wy.getCameras();case 12:i=e.sent,n=i&&i.length,e.next=18;break;case 16:e.prev=16,e.t1=e.catch(9);case 18:o={microphone:t,camera:n},a=this.checkSystemResult_.detail,s=a.isH264EncodeSupported,c=a.isVp8EncodeSupported,u=a.isH264DecodeSupported,l=a.isVp8DecodeSupported,d={webRTC:this.basis_.isWebRTCSupported,getUserMedia:this.basis_.isGetUserMediaSupported,webSocket:this.basis_.isWebSocketsSupported,screenShare:this.basis_.isScreenShareSupported,webAudio:this.basis_.isWebAudioSupported,h264Encode:s,h264Decode:u,vp8Encode:c,vp8Decode:l},h={browser:this.basis_.browser,os:this.basis_.os,trtc:d,devices:o},p={isWebCodecSupported:this.basis_.isWebCodecSupported,isMediaSessionSupported:this.basis_.isMediaSessionSupported,isWebTransportSupported:this.basis_.isWebTransportSupported},Gf.uploadEvent({log:"trtcstats-"+JSON.stringify(h),userId:this.userId_}),this.log_.info("TrtcStats-"+JSON.stringify(h)),Gf.uploadEvent({log:"trtcadvancedstats-"+JSON.stringify(p),userId:this.userId_});case 26:case"end":return e.stop()}}),e,this,[[0,7],[9,16]])}))),function(){return P.apply(this,arguments)})},{key:"getVersion",value:function(){var e=this.version_.split(".");return 1e3*parseInt(e[0])+100*parseInt(e[1])+parseInt(e[2])}},{key:"doJoin",value:function(e){var t=this;return new Promise((function(n,r){if(!t.isSignalReady_)throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_SIGNAL_CHANNEL"})});t.roomId_=e.roomId,Kd(e.role)||(t.role_=e.role);var i="";Kd(e.privateMapKey)||(i=e.privateMapKey),t.privateMapKey_=i,t.log_.info("Join() => joining room: ".concat(e.roomId," useStringRoomId: ").concat(t.useStringRoomId_," mode: ").concat(t.mode_," role: ").concat(t.role_));var o={roomId:String(e.roomId),useStringRoomId:t.useStringRoomId_,privateMapKey:i,trtcRole:"anchor"===t.role_?Al:21,trtcScene:"live"===t.mode_?2:1,sdpSemantics:t.sdpSemantics_,version:t.version_,ua:navigator&&navigator.userAgent||"",autoSubscribe:t.autoSubscribe_,terminalType:cu?4:ou?2:ru?3:Nu?12:Mu?5:Ou?13:1,netType:wd[Gd()],bussinessInfo:t.bussinessInfo_};t.joinTimeout_=setTimeout((function(){t.log_.error("join room timeout observed"),r(new vf({code:mf.JOIN_ROOM_FAILED,message:zf({key:"JOIN_ROOM_TIMEOUT"})}))}),5e3),yp.emit(2,{client:t}),t.signalChannel_.send("join",o),t.signalChannel_.once(pf.JOIN_ROOM_RESULT,(function(e){clearTimeout(t.joinTimeout_),t.joinTimeout_=-1;var i=e.data,o=i.code,a=i.message;yp.emit(3,{client:t,code:o}),0===o?(t.isJoined_=!0,t.log_.info("Join room success, start heartbeat"),t.startHeartbeat(),t.badCaseDetector_&&t.badCaseDetector_.start(),t.syncUserList(),t.startSyncUserListInterval(),n()):(t.log_.error("Join room failed result: "+o+" error: "+a),r(new vf({code:mf.JOIN_ROOM_FAILED,extraCode:o,message:zf({key:Af,data:{error:a,code:o}})})))}))}))}},{key:"connectSignalBeforeReJoin",value:function(){var e=this;return new Promise((function(t,n){e.log_.warn("connectSignalBeforeReJoin() try to connect signal before reJoin"),e.isSignalReady_=!1,e.signalChannel_.close(),e.signalChannel_.once(1,(function(n){e.log_.warn("connectSignalBeforeReJoin() signal setup successfully"),t()})),e.signalChannel_.once(4,(function(t){e.log_.warn("connectSignalBeforeReJoin() signal setup failed"),n(t)})),e.signalChannel_.connect()}))}},{key:"reJoin",value:(A=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isJoined_){e.next=3;break}return this.log_.warn("reJoin() you haven't join room yet, abort reJoin"),e.abrupt("return");case 3:return this.isJoined_=!1,e.prev=4,this.log_.warn("reJoin() try to reJoin room: ".concat(this.joinOptions_.roomId)),this.subscriptionManager_&&this.subscriptionManager_.markAllStream(),e.next=9,this.connectSignalBeforeReJoin();case 9:return e.next=11,this.doJoin(this.joinOptions_);case 11:if(this.log_.warn("reJoin() reJoin successfully"),Gf.logSuccessEvent({userId:this.userId_,eventType:Gl}),this.checkConnectionsToReconnect(),e.prev=14,!this.uplinkConnection_||!this.localStream_||this.uplinkConnection_.getIsReconnecting()){e.next=18;break}return e.next=18,this.republish();case 18:e.next=22;break;case 20:e.prev=20,e.t0=e.catch(14);case 22:e.next=29;break;case 24:e.prev=24,e.t1=e.catch(4),this.log_.warn("reJoin() reJoin failed"+e.t1),Gf.logFailedEvent({userId:this.userId_,eventType:Gl,error:e.t1}),this.emitter_.emit(Xm,new vf({code:mf.JOIN_ROOM_FAILED,message:zf({key:"REJOIN_ROOM_FAILED",data:{roomId:this.joinOptions_.roomId}})}));case 29:case"end":return e.stop()}}),e,this,[[4,24],[14,20]])}))),function(){return A.apply(this,arguments)})},{key:"republish",value:(x=o(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,this.log_.warn("republish() try to re-publish localStream"),t=this.localStream_,e.next=5,this.doUnpublish(t);case 5:return e.next=7,this.publish(t);case 7:this.log_.warn("republish() re-publish localStream successfully"),e.next=14;break;case 10:throw e.prev=10,e.t0=e.catch(0),this.log_.warn("republish() re-publish localStream failed "+e.t0),e.t0;case 14:case"end":return e.stop()}}),e,this,[[0,10]])}))),function(){return x.apply(this,arguments)})},{key:"leave",value:(C=o(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yp.emit(20,{client:this}),yf(this.userId_,{eventId:32789,eventDesc:"leaving room",timestamp:Sa(),userId:this.userId_,tinyId:this.tinyId_}),e.prev=2,e.next=5,this.doHeartbeat();case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(2);case 9:this.doLeave(),yp.emit(22,{client:this}),Gf.logSuccessEvent({userId:this.userId_,eventType:"leave"}),t=Math.floor((nh()-this.joinedTimestamp_)/1e3),Gf.logSuccessEvent({userId:this.userId_,eventType:"delta-leave",delta:t});case 14:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(){return C.apply(this,arguments)})},{key:"doLeave",value:function(){this.isJoined_&&(yp.emit(21,{client:this}),this.log_.info("leave() => leaving room"),this.signalChannel_.send("leave"),this.reset())}},{key:"clearNetworkQuality",value:function(){this.networkQuality_&&(this.networkQuality_.stop(),this.networkQuality_=null)}},{key:"closeConnections",value:function(){var e=this;this.connections_.forEach((function(t){e.closeDownLink(t.getTinyId())}))}},{key:"destroy",value:function(){if(this.isJoined_)throw this.log_.warn("please call leave() before destroy() client"),new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_LEAVE"})});this.log_.info("destroying SignalChannel"),this.signalChannel_&&(this.signalChannel_.close(),this.signalChannel_=null)}},{key:"reset",value:function(){this.keyPointManager_&&this.keyPointManager_.prepareReport(),this.mixTranscodeManager_&&(this.mixTranscodeManager_.stop(),this.mixTranscodeManager_=null),this.publishCDNManager_&&(this.publishCDNManager_=null),this.userMap_.clear(),this.stopSyncUserListInterval(),this.stopHeartbeat(),this.closeConnections(),this.mutedStates_.clear(),this.clearNetworkQuality(),this.badCaseDetector_&&this.callDurationCalculator_&&this.uploadAllCallStats(),this.closeUplink(),this.isJoined_=!1,this.isSignalReady_=!1,this.destroy()}},{key:"startSyncUserListInterval",value:function(){-1===this.syncUserListInterval_&&(this.syncUserListInterval_=cm.setInterval(this.syncUserList.bind(this),1e4))}},{key:"stopSyncUserListInterval",value:function(){cm.clearInterval(this.syncUserListInterval_),this.syncUserListInterval_=-1}},{key:"syncUserList",value:(E=o(regeneratorRuntime.mark((function e(){var t,n=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.getUserList();case 3:t=e.sent,0!==this.userMap_.size&&this.userMap_.forEach((function(e){t.findIndex((function(t){return t.userId===e.userId}))<0&&(n.log_.info("peer leave detected: ".concat(e.userId)),n.cleanUser({userId:e.userId,tinyId:e.tinyId}))})),t.forEach((function(e){var t=e.userId;n.userMap_.has(t)||t===n.userId_||(n.userMap_.set(t,e),n.emitter_.emit(zm,{userId:t}))})),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),this.log_.warn("sync user list failed: "+e.t0);case 11:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(){return E.apply(this,arguments)})},{key:"getUserList",value:function(){var e=this;return new Promise((function(t,n){e.signalChannel_.send("get_user_list"),e.signalChannel_.once(pf.USER_LIST_RES,(function(e){var r=e.data,i=r.code,o=r.message;if(0!==i){var a=zf({key:jf,data:{signalResponse:pf.USER_LIST_RES,code:i,message:o}});n(a)}else{var s=(e.data.data&&e.data.data.userList||[]).map((function(e){var t=e.userId,n=e.srcTinyId,r=e.role;return new Kg({userId:t,tinyId:n,role:r})}));t(s)}})),setTimeout(n,2e3)}))}},{key:"publish",value:(R=o(regeneratorRuntime.mark((function e(t){var n,r,i,o,a=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.setPublishState(0),this.isPublishing_=!0,n=nh(),yp.emit(27,{client:this,stream:t}),this.log_.info("publish() => publishing local stream"),r=new Bg({userId:this.userId_,tinyId:this.tinyId_,client:this,isUplink:!0,signalChannel:this.signalChannel_}),t.setConnection(r),r.initialize(),r.on(jm,(function(e){var t=e.getCode();t!==mf.ICE_TRANSPORT_ERROR&&(t===mf.UPLINK_RECONNECTION_FAILED&&a.closeUplink(),a.emitter_.emit(Xm,e))})),e.prev=9,e.next=12,r.publish(t);case 12:this.localStream_=e.sent,this.localStream_.getBeautyStatus()&&this.log_.info("beauty stream is published successfully"),this.log_.info("local stream is published successfully"),this.isPublishing_=!1,t.setPublishState(1),this.uplinkConnection_=r,i=nh(),o=i-n,Gf.logSuccessEvent({userId:this.userId_,eventType:Wl}),Gf.logSuccessEvent({userId:this.userId_,eventType:"delta-publish",delta:o}),t.hasAudio()&&yf(this.userId_,{eventId:32769,eventDesc:"publish audio track",timestamp:Sa(),userId:this.userId_,tinyId:this.tinyId_}),t.hasVideo()&&yf(this.userId_,{eventId:32768,eventDesc:"publish video track",timestamp:Sa(),userId:this.userId_,tinyId:this.tinyId_}),this.networkQuality_&&this.networkQuality_.setUplinkConnection(this.uplinkConnection_),this.deviceDetector_&&this.deviceDetector_.setLocalStream(this.localStream_),yp.emit(120,{localStream:this.localStream_,client:this}),this.notPublishWithoutH264Supported_=!1,e.next=39;break;case 30:throw e.prev=30,e.t0=e.catch(9),e.t0 instanceof vf&&e.t0.getCode()===mf.NOT_SUPPORTED_H264&&(this.notPublishWithoutH264Supported_=!0),t.setPublishState(-1),r.close(),this.log_.error("failed to publish stream "+e.t0),this.isPublishing_=!1,Gf.logFailedEvent({userId:this.userId_,eventType:Wl,error:e.t0}),e.t0;case 39:case"end":return e.stop()}}),e,this,[[9,30]])}))),function(e){return R.apply(this,arguments)})},{key:"unpublish",value:(w=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.log_.info("unpublish() => unpublishing local stream"),e.prev=1,e.next=4,this.doUnpublish();case 4:Gf.logSuccessEvent({userId:this.userId_,eventType:Jl}),e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(1),Gf.logFailedEvent({userId:this.userId_,eventType:Jl,error:e.t0}),e.t0;case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(){return w.apply(this,arguments)})},{key:"doUnpublish",value:function(){var e=this;return this.signalChannel_.sendWaitForResponse({command:ff,commandDesc:"unpublish",responseCommand:pf.UNPUBLISH_RESULT}).then((function(){e.closeUplink()})).catch((function(){e.closeUplink()}))}},{key:"closeUplink",value:function(){this.uplinkConnection_&&(this.uplinkConnection_.getIsReconnecting()&&this.uplinkConnection_.stopReconnection(),this.uplinkConnection_.close(),this.uplinkConnection_=null,this.networkQuality_&&this.networkQuality_.setUplinkConnection(null),this.localStream_.hasAudio()&&yf(this.userId_,{eventId:32771,eventDesc:"unpublish audio track",timestamp:Sa(),userId:this.userId_,tinyId:this.tinyId_}),this.localStream_.hasVideo()&&yf(this.userId_,{eventId:32770,eventDesc:"unpublish video track",timestamp:Sa(),userId:this.userId_,tinyId:this.tinyId_}),this.localStream_.setConnection(null),this.localStream_=null,this.deviceDetector_&&this.deviceDetector_.setLocalStream(null))}},{key:"closeDownLink",value:function(e){var t=this.connections_.get(e);t&&(t.getIsReconnecting()&&t.stopReconnection(),this.subscriptionManager_&&this.subscriptionManager_.delete(t.getUserId()),t.close(),this.connections_.delete(e),this.mutedStates_.delete(e))}},{key:"subscribe",value:(T=o(regeneratorRuntime.mark((function e(t,n){var r,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.log_.info("subscribe() => subscribe to [".concat(t.getUserId(),"] ").concat(t.getType()," stream with options: ").concat(JSON.stringify(n))),Kd(n)&&(n={audio:!0,video:!0}),Kd(n.video)&&(n.video=!0),Kd(n.audio)&&(n.audio=!0),e.prev=4,r=t.getConnection(),yp.emit(112,{client:this,stream:t}),e.next=9,r.subscribe(t,n);case 9:this.subscriptionManager_&&this.subscriptionManager_.addSubscriptionRecord(t.getUserId(),t,n),this.notSubscribeWithoutH264Supported_=!1,Gf.logSuccessEvent({userId:this.userId_,eventType:ql}),e.next=22;break;case 14:throw e.prev=14,e.t0=e.catch(4),(i=e.t0 instanceof vf?e.t0.getCode():mf.UNKNOWN)===mf.NOT_SUPPORTED_H264&&(this.notSubscribeWithoutH264Supported_=!0),o=new vf({code:i,message:zf({key:"SUBSCRIBE_FAILED",data:{message:e.t0.message}})}),Gf.logFailedEvent({userId:this.userId_,eventType:ql,error:o}),this.log_.error(o),o;case 22:case"end":return e.stop()}}),e,this,[[4,14]])}))),function(e,t){return T.apply(this,arguments)})},{key:"unsubscribe",value:(k=o(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.log_.info("unsubscribe() => unsubscribe to [".concat(t.getUserId(),"] ").concat(t.getType()," stream")),e.prev=1,n=t.getConnection(),e.next=5,n.unsubscribe(t);case 5:this.subscriptionManager_&&this.subscriptionManager_.addUnsubscriptionRecord(t.getUserId(),t),yp.emit(Tp,{client:this,stream:t}),Gf.logSuccessEvent({userId:this.userId_,eventType:Kl}),e.next=14;break;case 10:throw e.prev=10,e.t0=e.catch(1),Gf.logFailedEvent({userId:this.userId_,eventType:Kl,error:e.t0}),e.t0;case 14:case"end":return e.stop()}}),e,this,[[1,10]])}))),function(e){return k.apply(this,arguments)})},{key:"switchRole",value:(b=o(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.role_!==t){e.next=2;break}return e.abrupt("return");case 2:if("audience"!==t||!this.localStream_){e.next=5;break}return e.next=5,this.unpublish(this.localStream_);case 5:return this.log_.info("switchRole() => switch role to: "+t),e.next=8,this.doSwitchRole(t);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"doSwitchRole",value:function(e){var t=this;return new Promise((function(n,r){var i={role:"anchor"===e?Al:21};t.log_.info("switchRole signal data: "+JSON.stringify(i));var o=setTimeout((function(){t.log_.error("switchRole timeout observed"),t.signalChannel_.off(pf.SWITCH_ROLE_RES,a),r(new vf({code:mf.SWITCH_ROLE_FAILED,message:zf({key:"SWITCH_ROLE_TIMEOUT"})}))}),5e3),a=function(i){clearTimeout(o);var a=i.data,s=a.code,c=a.message;0===s?(t.role_=e,n()):(t.log_.error("switchRole failed, errCode: ".concat(s,", errMsg: ").concat(c)),r(new vf({code:mf.SWITCH_ROLE_FAILED,message:zf({key:"SWITCH_ROLE_FAILED",data:{errMsg:c,errCode:s}})})))};t.signalChannel_.once(pf.SWITCH_ROLE_RES,a),t.signalChannel_.send("change_role",i)}))}},{key:"on",value:function(e,t,n){this.emitter_.on(e,t,n)}},{key:"off",value:function(e,t,n){"*"===e?this.emitter_.removeAllListeners():this.emitter_.off(e,t,n)}},{key:"getRemoteMutedState",value:function(){var e=this,n=[];return this.mutedStates_.forEach((function(r,i,o){var a=e.connections_.get(i);a&&n.push(t({userId:a.getUserId()},r))})),n}},{key:"getTransportStats",value:(g=o(regeneratorRuntime.mark((function e(){var t,n,r,i,o,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={rtt:0,downlinksRTT:{}},!this.uplinkConnection_){e.next=6;break}return e.next=4,this.stats_.getSenderStats(this.uplinkConnection_);case 4:n=e.sent,t.rtt=n.rtt;case 6:r=I(this.connections_),e.prev=7,r.s();case 9:if((i=r.n()).done){e.next=17;break}return(o=y(i.value,2))[0],a=o[1],e.next=13,this.stats_.getReceiverStats(a);case 13:s=e.sent,t.downlinksRTT[s.userId]=s.rtt;case 15:e.next=9;break;case 17:e.next=22;break;case 19:e.prev=19,e.t0=e.catch(7),r.e(e.t0);case 22:return e.prev=22,r.f(),e.finish(22);case 25:return e.abrupt("return",t);case 26:case"end":return e.stop()}}),e,this,[[7,19,22,25]])}))),function(){return g.apply(this,arguments)})},{key:"getLocalAudioStats",value:(_=o(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((t={})[this.userId_]={bytesSent:0,packetsSent:0},!this.uplinkConnection_){e.next=7;break}return e.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:n=e.sent,t[this.userId_]={bytesSent:n.audio.bytesSent,packetsSent:n.audio.packetsSent};case 7:return e.abrupt("return",t);case 8:case"end":return e.stop()}}),e,this)}))),function(){return _.apply(this,arguments)})},{key:"getLocalVideoStats",value:(v=o(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((t={})[this.userId_]={bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0},!this.uplinkConnection_){e.next=7;break}return e.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:n=e.sent,t[this.userId_]={bytesSent:n.video.bytesSent,packetsSent:n.video.packetsSent,framesEncoded:n.video.framesEncoded,framesSent:n.video.framesSent,frameWidth:n.video.frameWidth,frameHeight:n.video.frameHeight};case 7:return e.abrupt("return",t);case 8:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"getRemoteAudioStats",value:(m=o(regeneratorRuntime.mark((function e(){var t,n,r,i,o,a,s,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t={},n=I(this.connections_),e.prev=2,n.s();case 4:if((r=n.n()).done){e.next=13;break}return(i=y(r.value,2))[0],o=i[1],a=o.getDelay(),s=a.audioDelay,e.next=9,this.stats_.getReceiverStats(o);case 9:(c=e.sent).hasAudio&&(t[c.userId]={bytesReceived:c.audio.bytesReceived,packetsReceived:c.audio.packetsReceived,packetsLost:c.audio.packetsLost,end2EndDelay:s});case 11:e.next=4;break;case 13:e.next=18;break;case 15:e.prev=15,e.t0=e.catch(2),n.e(e.t0);case 18:return e.prev=18,n.f(),e.finish(18);case 21:return e.abrupt("return",t);case 22:case"end":return e.stop()}}),e,this,[[2,15,18,21]])}))),function(){return m.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(f=o(regeneratorRuntime.mark((function e(){var t,n,r,i,o,a,s,c,u,l=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=l.length>0&&void 0!==l[0]?l[0]:Ll,n={},r=I(this.connections_),e.prev=3,r.s();case 5:if((i=r.n()).done){e.next=15;break}return(o=y(i.value,2))[0],a=o[1],e.next=9,this.stats_.getReceiverStats(a);case 9:s=e.sent,c=a.getDelay(),u=c.videoDelay,t===Ll&&s.hasVideo&&(n[s.userId]={bytesReceived:s.video.bytesReceived,packetsReceived:s.video.packetsReceived,packetsLost:s.video.packetsLost,framesDecoded:s.video.framesDecoded,frameWidth:s.video.frameWidth,frameHeight:s.video.frameHeight,end2EndDelay:u}),t===Ml&&s.hasAuxiliary&&(n[s.userId]={bytesReceived:s.auxiliary.bytesReceived,packetsReceived:s.auxiliary.packetsReceived,packetsLost:s.auxiliary.packetsLost,framesDecoded:s.auxiliary.framesDecoded,frameWidth:s.auxiliary.frameWidth,frameHeight:s.auxiliary.frameHeight,end2EndDelay:u});case 13:e.next=5;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(3),r.e(e.t0);case 20:return e.prev=20,r.f(),e.finish(20);case 23:return e.abrupt("return",n);case 24:case"end":return e.stop()}}),e,this,[[3,17,20,23]])}))),function(){return f.apply(this,arguments)})},{key:"getSdpSemantics",value:function(){return this.sdpSemantics_}},{key:"getIceServers",value:function(){return 0===this.turnServers_.length&&this.schedule_.iceServers?this.schedule_.iceServers:this.turnServers_}},{key:"getConnections",value:function(){return this.connections_}},{key:"getMutedStates",value:function(){return this.mutedStates_}},{key:"startHeartbeat",value:function(){-1===this.heartbeat_&&(this.log_.info("startHeartbeat..."),this.heartbeat_=cm.setInterval(this.doHeartbeat.bind(this),2e3))}},{key:"stopHeartbeat",value:function(){-1!==this.heartbeat_&&(this.log_.info("stopHeartbeat"),cm.clearInterval(this.heartbeat_),this.heartbeat_=-1,this.lastHeartBeatTime_=-1)}},{key:"doHeartbeat",value:(p=o(regeneratorRuntime.mark((function e(){var n,r,i,o,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.badCaseDetector_.getMonitorFreeze(),e.next=3,this.stats_.getStatsReport({uplinkConnection:this.uplinkConnection_,downlinkConnections:this.connections_,freezeMap:n});case 3:if(r=e.sent,yp.emit(23,{client:this,stats:r}),this.badCaseDetector_.resetMonitor(),this.signalChannel_){e.next=8;break}return e.abrupt("return");case 8:i=this.signalChannel_.isConnected()?Sf(this.userId_):[],o=t(t({str_sdk_version:"4.12.2",uint64_datetime:(new Date).getTime(),msg_user_info:{str_identifier:this.userId_,uint64_tinyid:this.tinyId_},msg_device_info:{uint32_terminal_type:15,str_device_name:navigator.platform,str_os_version:"",uint32_net_type:wd[this.networkType_]}},r),{},{msg_event_msg:i}),this.signalChannel_.send("quality_report",o),a=Date.now(),this.lastHeartBeatTime_>0&&a-this.lastHeartBeatTime_>1e4&&this.log_.warn("heartbeat took ".concat(a-this.lastHeartBeatTime_)),this.lastHeartBeatTime_=a,this.isRelayMaybeFailed()&&this.reJoin();case 15:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"onRemoteStreamAdded",value:function(e){var t=e.content,n=t.userId,r=t.tinyId,i=t.audio,o=t.bigVideo,a=t.auxVideo,s=t.smallVideo;if(null!==n){this.userMap_.has(n)||(this.userMap_.set(n,new Kg({userId:n,tinyId:r,role:"anchor"})),this.emitter_.emit(zm,{userId:n}));var c=this.connections_.get(r);if(c){if(c.getIsReconnecting())return;this.log_.warn("duplicated stream-added observed, rebuild the connection"),c.close(),this.connections_.delete(r)}var u={audio:i,video:o,auxiliary:a,smallVideo:s};this.log_.info("remote peer [".concat(n,"] published stream. trackState: ").concat(JSON.stringify(u))),this.createDownlinkConnection({userId:n,tinyId:r,trackState:u})}else this.log_.warn("received null userId on stream added")}},{key:"createDownlinkConnection",value:function(e){var t=this,n=e.userId,r=e.tinyId,i=e.trackState,o=new Hg({userId:n,tinyId:r,client:this,isUplink:!1,signalChannel:this.signalChannel_,autoSubscribe:this.autoSubscribe_,trackState:i});this.connections_.set(r,o),this.installDownlinkEvents(o,n,r),this.autoSubscribe_?(o.initialize(),o.connect().catch((function(){var e=o.getTrackState();o.getMainStream()||!e.audio&&!e.video||t.initRemoteStream({type:Ll,userId:n,downlinkConnection:o}),!o.getAuxStream()&&e.auxiliary&&t.initRemoteStream({type:Ml,userId:n,downlinkConnection:o})}))):((i.audio||i.video)&&this.initRemoteStream({type:Ll,userId:n,downlinkConnection:o}),i.auxiliary&&this.initRemoteStream({type:Ml,userId:n,downlinkConnection:o}))}},{key:"initRemoteStream",value:function(e){var t=e.type,n=e.userId,r=e.downlinkConnection,i=new Dg({type:t,userId:n,client:this});i.setConnection(r),r.setRemoteStream(t===Ll?Pl:Dl,i),i.setIsStreamAddedEventEmitted(!0),yp.emit(kp,{client:this,stream:i}),this.emitter_.emit(Hm,{stream:i})}},{key:"installDownlinkEvents",value:function(e,t,n){var r=this;e.on(Om,(function(e){e.stream.setIsStreamAddedEventEmitted(!0),yp.emit(kp,{client:r,stream:e.stream}),r.emitter_.emit(Hm,{stream:e.stream})})),e.on(Um,(function(e){e.stream.stop(),e.stream.setIsStreamAddedEventEmitted(!1),r.subscriptionManager_&&r.subscriptionManager_.deleteAutoRecoveryFlag(e.stream.getUserId(),e.stream.getType()),yp.emit(wp,{client:r,stream:e.stream}),r.emitter_.emit("stream-removed",{stream:e.stream})})),e.on(Vm,(function(e){yp.emit(115,{client:r,stream:e.stream}),r.emitter_.emit("stream-updated",{stream:e.stream})})),e.on(Fm,(function(e){yp.emit(Ip,{client:r,stream:e.stream}),r.emitter_.emit("stream-subscribed",{stream:e.stream})})),e.on(jm,(function(e){var t=e.getCode();t!==mf.ICE_TRANSPORT_ERROR&&(t===mf.DOWNLINK_RECONNECTION_FAILED&&r.closeDownLink(n),r.emitter_.emit(Xm,e))}))}},{key:"onPeerJoin",value:function(e){var t=e.data.data,n=t.srcTinyId,r=t.userId,i=t.role;this.userMap_.has(r)||(this.userMap_.set(r,new Kg({userId:r,tinyId:n,role:i})),this.emitter_.emit(zm,{userId:r}))}},{key:"onPeerLeave",value:function(e){var t=e.data.data,n=t.srcTinyId,r=t.userId,i=t.reason,o=void 0===i?0:i;this.log_.info("peer leave [".concat(r,"]: ").concat(jd[o])),this.cleanUser({userId:r,tinyId:n})}},{key:"cleanUser",value:function(e){var t=e.userId,n=e.tinyId;this.userMap_.delete(t),this.closeDownLink(n),this.emitter_.emit("peer-leave",{userId:t})}},{key:"onPublishedUserList",value:function(e){var t=this;try{var n=e.data.userList.map((function(e){return e.userId}));this.connections_.forEach((function(e){var r=e.getUserId(),i=e.getTinyId();n.findIndex((function(e){return e===r}))<0&&(t.log_.info("peer unpublished detected [".concat(r,"]")),t.closeDownLink(i))})),e.data.userList.forEach((function(e){var n=e.userId,r=e.srcTinyId,i=e.flag;if(n!==t.userId_){var o=!!(1&i),a=!!(8&i),s=!!(4&i),c=!!(2&i);if(t.connections_.has(r)){var u=t.connections_.get(r).getTrackState(),l=u.audio,d=u.video,h=u.auxiliary;!d&&o&&yp.emit(bp,{client:t,tinyId:r,userId:n,action:Id,kind:dl}),!l&&a&&yp.emit(bp,{client:t,tinyId:r,userId:n,action:Id,kind:ll}),!h&&s&&yp.emit(bp,{client:t,tinyId:r,userId:n,action:Id,kind:hl}),d&&!o&&yp.emit(bp,{client:t,tinyId:r,userId:n,action:Td,kind:dl}),l&&!a&&yp.emit(bp,{client:t,tinyId:r,userId:n,action:Td,kind:ll}),h&&!s&&yp.emit(bp,{client:t,tinyId:r,userId:n,action:Td,kind:hl})}else t.log_.info("peer published detected [".concat(n,"]")),t.onRemoteStreamAdded({content:{audio:a,bigVideo:o,auxVideo:s,smallVideo:c,userId:n,tinyId:r}})}}))}catch(e){}}},{key:"onUpdateRemoteMuteStat",value:function(e){var t=this,n=e.data;(n&&n.userList||[]).forEach((function(e){var n=e.srcTinyId,r=e.userId;if(0!==n&&n!==t.tinyId_){var i=t.connections_.get(n);if(i){var o=i.getMainStream();if(o&&o.getIsStreamAddedEventEmitted()){var a=!!(1&e.flag),s=!!(8&e.flag),c=!!(2&e.flag),u=!!(64&e.flag),l=!!(16&e.flag),d=t.mutedStates_.get(n);if(void 0===d)return t.mutedStates_.set(n,{hasAudio:s,hasVideo:a,hasSmall:c,audioMuted:u,videoMuted:l}),a?l?t.emitter_.emit(Wm,{userId:r}):t.emitter_.emit(qm,{userId:r}):t.emitter_.emit(Wm,{userId:r}),void(s?u?t.emitter_.emit(Gm,{userId:r}):t.emitter_.emit(Jm,{userId:r}):t.emitter_.emit(Gm,{userId:r}));var h=!u&&s;(!d.audioMuted&&d.hasAudio)!==h&&(h?t.emitter_.emit(Jm,{userId:r}):t.emitter_.emit(Gm,{userId:r}));var p=!l&&a;(!d.videoMuted&&d.hasVideo)!==p&&(p?t.emitter_.emit(qm,{userId:r}):t.emitter_.emit(Wm,{userId:r})),t.mutedStates_.set(n,{hasAudio:s,hasVideo:a,hasSmall:c,audioMuted:u,videoMuted:l})}}else t.mutedStates_.delete(n)}}))}},{key:"onClientBanned",value:function(e){this.emitter_.emit("client-banned",new vf({code:mf.CLIENT_BANNED,message:zf({key:"CLIENT_BANNED",data:{reason:e}})}))}},{key:"getEnv",value:function(){return this.env_}},{key:"getSubscriptionManager",value:function(){return this.subscriptionManager_}},{key:"startPublishCDNStream",value:(h=o(regeneratorRuntime.mark((function e(){var t,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.length>0&&void 0!==n[0]?n[0]:{},this.localStream_){e.next=3;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:Df})});case 3:return this.log_.info("startPublishCDNStream params: ".concat(JSON.stringify(t))),e.next=6,this.publishCDNManager_.startPublishTencentCDN(t);case 6:if(!(t.appId&&t.bizId&&t.url)){e.next=9;break}return e.next=9,this.publishCDNManager_.startPublishGivenCDN(t);case 9:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"stopPublishCDNStream",value:(d=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.publishCDNManager_.getIsPublishingTencentCDN()){e.next=2;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_OPERATION_STOP_PUBLISH_CDN"})});case 2:return this.log_.info("stopPublishCDNStream"),e.next=5,this.publishCDNManager_.stopPublishTencentCDN();case 5:if(!this.publishCDNManager_.getIsPublishingGivenCDN()){e.next=8;break}return e.next=8,this.publishCDNManager_.stopPublishGivenCDN();case 8:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"startMixTranscode",value:(l=o(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){e.next=2;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"START_MIX_TRANSCODE"})});case 2:return Kd(t.mode)&&(t.mode=fd),e.prev=3,this.log_.info("startMixTranscode with config ".concat(JSON.stringify(t))),Gf.uploadEvent({log:"mix-transcode-mode:".concat(t.mode),userId:this.userId_}),e.next=8,this.mixTranscodeManager_.startMixTranscode(t);case 8:Gf.logSuccessEvent({userId:this.userId_,eventType:sd}),e.next=15;break;case 11:throw e.prev=11,e.t0=e.catch(3),Gf.logFailedEvent({userId:this.userId_,eventType:sd,error:e.t0}),e.t0;case 15:case"end":return e.stop()}}),e,this,[[3,11]])}))),function(e){return l.apply(this,arguments)})},{key:"stopMixTranscode",value:(u=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){e.next=2;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"STOP_MIX_TRANSCODE"})});case 2:return e.prev=2,e.next=5,this.mixTranscodeManager_.stopMixTranscode();case 5:Gf.logSuccessEvent({userId:this.userId_,eventType:cd}),e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(2),Gf.logFailedEvent({userId:this.userId_,eventType:cd,error:e.t0}),e.t0;case 12:case"end":return e.stop()}}),e,this,[[2,8]])}))),function(){return u.apply(this,arguments)})},{key:"getSystemResult",value:function(){return this.checkSystemResult_}},{key:"enableAudioVolumeEvaluation",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!Xd(t))throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:Nf})});if(this.log_.info("enableAudioVolumeEvaluation with interval: "+t),t<=0)return this.enableAudioVolumeEvaluation_=!1,cm.clearInterval(this.audioVolumeIntervalId_),void(this.audioVolumeIntervalId_=null);t=Math.floor(Math.max(t,16)),yp.emit(32,{interval:t}),this.audioVolumeIntervalId_&&(cm.clearInterval(this.audioVolumeIntervalId_),this.audioVolumeIntervalId_=null),this.enableAudioVolumeEvaluation_=!0,this.audioVolumeIntervalId_=cm.setInterval((function(){var t=[];if(e.localStream_){var n=Math.floor(100*e.localStream_.getAudioLevel());t.push({userId:e.userId_,audioVolume:n,stream:e.localStream_})}e.connections_.forEach((function(e){var n=e.getSubscribedMainStream();if(n){var r=Math.floor(100*n.getAudioLevel());t.push({userId:e.getUserId(),audioVolume:r,stream:n})}})),e.emitter_.emit(Qm,{result:t})}),t,n)}},{key:"uploadAllCallStats",value:function(){var e=this;this.callDurationCalculator_.getDurationMap().forEach((function(t,n){var r={userId:t.userId,type:t.type,duration:e.callDurationCalculator_.getDuration(n,dl),dataFreeze:e.badCaseDetector_.getDataFreezeDuration(n).dataFreeze,renderFreeze:e.badCaseDetector_.getRenderFreezeDuration(n).renderFreeze};Gf.uploadEvent({log:"callStats-"+JSON.stringify(r),userId:e.userId_})})),this.badCaseDetector_.stop(),this.callDurationCalculator_.reset()}},{key:"enableSmallStream",value:(s=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isPublished()&&!this.isPublishing_){e.next=2;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"ENABLE_SMALL_STREAM_PUBLISHED"})});case 2:if(!Lm()){e.next=7;break}this.setIsEnableSmallStream(!0),this.log_.info("SmallStream successfully enabled"),e.next=8;break;case 7:throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"NOT_SUPPORTED_SMALL_STREAM"})});case 8:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"disableSmallStream",value:(i=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isPublished()&&!this.isPublishing_){e.next=2;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"DISABLE_SMALL_STREAM_PUBLISHED"})});case 2:this.setIsEnableSmallStream(!1),this.log_.info("SmallStream successfully disabled");case 4:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"setSmallStreamProfile",value:function(e){var t=this;e&&e.framerate&&(e.frameRate=e.framerate),Object.keys(this.smallStreamConfig_).forEach((function(n){e[n]&&(t.smallStreamConfig_[n]=e[n])})),this.log_.info("setSmallStreamProfile: bitrate=".concat(this.smallStreamConfig_.bitrate,", frameRate=").concat(this.smallStreamConfig_.frameRate,", height=").concat(this.smallStreamConfig_.height,", width=").concat(this.smallStreamConfig_.width));var n=this.smallStreamConfig_,r=n.width,i=n.height,o=n.bitrate,a=n.frameRate;if(r<0||i<0||o<0||a<0)throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_SMALL_STREAM_PROFILE"})})}},{key:"setRemoteVideoStreamType",value:(r=o(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=n,e.next="big"===e.t0||"small"===e.t0?3:6;break;case 3:return e.next=5,this.changeVideoType(t,n);case 5:case 6:return e.abrupt("break",7);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"changeVideoType",value:(n=o(regeneratorRuntime.mark((function e(t,n){var r,i,o,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t instanceof Dg){e.next=2;break}throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_PARAMETER_REMOTE_STREAM"})});case 2:if(t.getConnection()){e.next=4;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:Pf})});case 4:if((r=t.getConnection().getSubscribeState()).video){e.next=8;break}if(r.smallVideo){e.next=8;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_OPERATION_CHANGE_SMALL"})});case 8:if(i=this.getRemoteMutedState().filter((function(e){return e.userId===t.getUserId()}))[0],"small"!==n||i&&i.hasSmall){e.next=11;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"REMOTE_NOT_PUBLISH_SMALL_STREAM"})});case 11:return this.log_.info("change video type: streamType=".concat(t.getType(),", set ").concat(n)),o=t.getConnection(),a={video:"big"===n,smallVideo:"small"===n},e.next=16,o.subscribe(t,a);case 16:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"setIsEnableSmallStream",value:function(e){this.isEnableSmallStream_=e}},{key:"getIsEnableSmallStream",value:function(){return this.isEnableSmallStream_}},{key:"smallStreamConfig",get:function(){return this.smallStreamConfig_}},{key:"isPublished",value:function(){return!!this.localStream_}},{key:"getUplinkConnection",value:function(){return this.uplinkConnection_}},{key:"getLocalStream",value:function(){return this.localStream_}},{key:"getMode",value:function(){return this.mode_}},{key:"getBadCaseDetector",value:function(){return this.badCaseDetector_}},{key:"getCallDurationCalculator",value:function(){return this.callDurationCalculator_}},{key:"getIsJoined",value:function(){return this.isJoined_}},{key:"getAllConnections",value:function(){var e=S(this.connections_.values());return this.uplinkConnection_&&e.push(this.uplinkConnection_),e}},{key:"isRelayMaybeFailed",value:function(){var e=this.getAllConnections();if(0===e.length)return!1;for(var t=0;t<e.length;t++)if(e[t].getReconnectionCount()<6)return!1;return!0}},{key:"getUseStringRoomId",value:function(){return this.useStringRoomId_}},{key:"checkConnectionsToReconnect",value:function(){var e=this;this.getAllConnections().forEach((function(t){if(!t.getIsReconnecting()){var n=t.getPeerConnection();n&&n.connectionState===Bl&&(e.log_.warn("[".concat(t.getUserId(),"] pc is closed but not reconnect")),t.startReconnection())}}))}},{key:"getEnableAutoPlayDialog",value:function(){return this.enableAutoPlayDialog_}}]),e}()).prototype,"join",[ly,dy],Object.getOwnPropertyDescriptor(Iy.prototype,"join"),Iy.prototype),T(Iy.prototype,"leave",[hy],Object.getOwnPropertyDescriptor(Iy.prototype,"leave"),Iy.prototype),T(Iy.prototype,"publish",[py,fy],Object.getOwnPropertyDescriptor(Iy.prototype,"publish"),Iy.prototype),T(Iy.prototype,"unpublish",[my,vy],Object.getOwnPropertyDescriptor(Iy.prototype,"unpublish"),Iy.prototype),T(Iy.prototype,"subscribe",[_y],Object.getOwnPropertyDescriptor(Iy.prototype,"subscribe"),Iy.prototype),T(Iy.prototype,"unsubscribe",[gy],Object.getOwnPropertyDescriptor(Iy.prototype,"unsubscribe"),Iy.prototype),T(Iy.prototype,"switchRole",[yy,Sy],Object.getOwnPropertyDescriptor(Iy.prototype,"switchRole"),Iy.prototype),T(Iy.prototype,"startPublishCDNStream",[by],Object.getOwnPropertyDescriptor(Iy.prototype,"startPublishCDNStream"),Iy.prototype),T(Iy.prototype,"startMixTranscode",[ky],Object.getOwnPropertyDescriptor(Iy.prototype,"startMixTranscode"),Iy.prototype),Iy),Ey=Cp({retryFunction:function(){var e=o(regeneratorRuntime.mark((function e(t){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!wm()){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,Cy(t);case 4:if(n=e.sent,Pp.info("getUserMedia with constraints: "+JSON.stringify(n)),!n.audio){e.next=11;break}return e.next=9,Wy.getMicrophones();case 9:r=e.sent,Pp.info("microphones: ".concat(JSON.stringify(r)));case 11:if(!n.video){e.next=16;break}return e.next=14,Wy.getCameras();case 14:i=e.sent,Pp.info("cameras: ".concat(JSON.stringify(i)));case 16:return e.prev=16,e.next=19,navigator.mediaDevices.getUserMedia(n);case 19:return e.abrupt("return",e.sent);case 22:if(e.prev=22,e.t0=e.catch(16),"NotFoundError"!==e.t0.name){e.next=29;break}if(!i||0!==i.length){e.next=27;break}throw new vf({code:mf.DEVICE_NOT_FOUND,message:zf({key:"CAMERA_NOT_FOUND"})});case 27:if(!r||0!==r.length){e.next=29;break}throw new vf({code:mf.DEVICE_NOT_FOUND,message:zf({key:"MICROPHONE_NOT_FOUND"})});case 29:throw new vf({code:mf.INITIALIZE_FAILED,name:e.t0.name,message:e.t0.message,constraint:e.t0.constraint});case 30:case"end":return e.stop()}}),e,null,[[16,22]])})));return function(t){return e.apply(this,arguments)}}(),settings:{retries:3,timeout:500},onError:function(e,t,n){"NotReadableError"===e.name?t():n(e)},onRetrying:function(e){Pp.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))}});function Cy(e){return xy.apply(this,arguments)}function xy(){return(xy=o(regeneratorRuntime.mark((function e(n){var r,i,o,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r={echoCancellation:n.echoCancellation,autoGainControl:n.autoGainControl,noiseSuppression:n.noiseSuppression},n.audio){e.next=5;break}r=!1,e.next=15;break;case 5:if(kf(n.microphoneId)){e.next=9;break}r=t({deviceId:{exact:n.microphoneId},sampleRate:n.sampleRate,channelCount:n.channelCount},r),e.next=15;break;case 9:return r=t({sampleRate:n.sampleRate,channelCount:n.channelCount},r),e.next=12,Wy.getMicrophones();case 12:i=e.sent,(o=i.filter((function(e){return e.deviceId.length>0}))).length>0&&(r.deviceId={exact:o[0].deviceId});case 15:return{},a=!Kd(n.facingMode)&&n.video?{facingMode:n.facingMode,width:n.width,height:n.height,frameRate:n.frameRate}:!kf(n.cameraId)&&n.video?{deviceId:{exact:n.cameraId},width:n.width,height:n.height,frameRate:n.frameRate}:!!n.video&&(!!Kd(n.width)||{width:n.width,height:n.height,frameRate:n.frameRate}),e.abrupt("return",{audio:r,video:a});case 18:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ay=function(){var e=o(regeneratorRuntime.mark((function e(t){var n,r,i,o,a,s,c,u,l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!wm()){e.next=2;break}return e.abrupt("return");case 2:if(n=null,!($u&&Yu<74||el)){e.next=27;break}return r=Dy(t),Pp.info("getDisplayMedia with constraints: "+JSON.stringify(r)),e.next=8,navigator.mediaDevices.getDisplayMedia(r);case 8:if(i=e.sent,!t.screenAudio){e.next=14;break}return Pp.warn("Your browser not support capture system audio"),e.abrupt("return",i);case 14:if(!t.audio){e.next=24;break}return o=Py(t),Pp.info("getUserMedia with constraints: "+JSON.stringify(o)),e.next=19,navigator.mediaDevices.getUserMedia(o);case 19:return n=e.sent,i.addTrack(n.getAudioTracks()[0]),e.abrupt("return",i);case 24:return e.abrupt("return",i);case 25:e.next=53;break;case 27:if(!t.screenAudio){e.next=37;break}return t.audioConstraints={echoCancellation:!0,noiseSuppression:!0,sampleRate:44100},a=Dy(t),Pp.info("getDisplayMedia with constraints: "+JSON.stringify(a)),e.next=33,navigator.mediaDevices.getDisplayMedia(a);case 33:return s=e.sent,e.abrupt("return",s);case 37:return c=Dy(t),Pp.info("getDisplayMedia with constraints: "+JSON.stringify(c)),e.next=41,navigator.mediaDevices.getDisplayMedia(c);case 41:if(u=e.sent,!t.audio){e.next=52;break}return l=Py(t),Pp.info("getUserMedia with constraints: "+JSON.stringify(l)),e.next=47,navigator.mediaDevices.getUserMedia(l);case 47:return n=e.sent,u.addTrack(n.getAudioTracks()[0]),e.abrupt("return",u);case 52:return e.abrupt("return",u);case 53:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function Py(e){var t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return Kd(e.microphoneId)||(t.deviceId={exact:e.microphoneId}),{audio:t,video:!1}}function Dy(e){var t={},n={width:e.width,height:e.height,frameRate:e.frameRate};return Kd(e.screenSource)||(n.displaySurface=e.screenSource),t.video=n,Kd(e.audioConstraints)||(t.audio=e.audioConstraints),t}var Ly=new Map;Ly.set("120p",{width:160,height:120,frameRate:15,bitrate:200}),Ly.set("180p",{width:320,height:180,frameRate:15,bitrate:350}),Ly.set("240p",{width:320,height:240,frameRate:15,bitrate:400}),Ly.set("360p",{width:640,height:360,frameRate:15,bitrate:800}),Ly.set("480p",{width:640,height:480,frameRate:15,bitrate:900}),Ly.set("720p",{width:1280,height:720,frameRate:15,bitrate:1500}),Ly.set("1080p",{width:1920,height:1080,frameRate:15,bitrate:2e3}),Ly.set("1440p",{width:2560,height:1440,frameRate:30,bitrate:4860}),Ly.set("4K",{width:3840,height:2160,frameRate:30,bitrate:9e3});var My=new Map;My.set("480p",{width:640,height:480,frameRate:5,bitrate:900}),My.set("480p_2",{width:640,height:480,frameRate:30,bitrate:1e3}),My.set("720p",{width:1280,height:720,frameRate:5,bitrate:1200}),My.set("720p_2",{width:1280,height:720,frameRate:30,bitrate:3e3}),My.set("1080p",{width:1920,height:1080,frameRate:5,bitrate:1600}),My.set("1080p_2",{width:1920,height:1080,frameRate:30,bitrate:4e3});var Ny,Oy,Uy=new Map;Uy.set("standard",{sampleRate:48e3,channelCount:1,bitrate:40}),Uy.set("standard-stereo",{sampleRate:48e3,channelCount:2,bitrate:64}),Uy.set("high",{sampleRate:48e3,channelCount:1,bitrate:128}),Uy.set("high-stereo",{sampleRate:48e3,channelCount:2,bitrate:192});var Vy,Fy,jy,By=(Ny=Cg.apply(void 0,S(Rg.LOCAL_STREAM.switchDevice)),T((Oy=function(e){l(S,e);var n,i,s,u,h,p,f,m,v,y=_(S);function S(e){var n;a(this,S);var r=t(t({},e),{isRemote:!1,type:"local"});return(n=y.call(this,r)).name_=Pd,n.client_=null,n.video_=e.video,n.audio_=e.audio,n.cameraId_=e.cameraId,n.cameraGroupId_="",n.facingMode_=e.facingMode,n.microphoneId_=e.microphoneId,n.microphoneGroupId_="",n.videoSource_=e.videoSource,n.audioSource_=e.audioSource,n.screen_=e.screen,n.screenSource_=e.screenSource,n.screenAudio_=e.screenAudio,n.audioProfile_={echoCancellation:!!Kd(e.echoCancellation)||e.echoCancellation,autoGainControl:!!Kd(e.autoGainControl)||e.autoGainControl,noiseSuppression:!!Kd(e.noiseSuppression)||e.noiseSuppression,sampleRate:48e3,channelCount:1,bitrate:40},n.videoProfile_={width:640,height:480,frameRate:15,bitrate:900},n.screenProfile_={width:1920,height:1080,frameRate:5,bitrate:1600},n.videoBitrate_=n.screen_?1600:900,n.videoSetting_=null,n.muteState_={video:!1,audio:!1,auxVideo:!1},n.beautyStatus_=!1,n.recoverCaptureCount_=0,n.initState(),n.canvas_=null,n.canvasInterval_=-1,n.log_.info("stream created: "+n.id_),n}return c(S,[{key:"initState",value:function(){this.isAddingTrack_=!1,this.isRemovingTrack_=!1,this.setIsReadyToPublish(!1),this.setPublishState(-1)}},{key:"installEvents",value:function(){g(d(S.prototype),"installEvents",this).call(this),yp.on(120,this.onStreamPublished,this),yp.on(135,this.onVideoTrackStopped,this),yp.on(Rp,this.onVideoTrackStopped,this),yp.on(137,this.onAudioTrackStopped,this),yp.on(136,this.onAudioTrackStopped,this)}},{key:"uninstallEvents",value:function(){g(d(S.prototype),"uninstallEvents",this).call(this),yp.off(120,this.onStreamPublished,this),yp.off(135,this.onVideoTrackStopped,this),yp.off(Rp,this.onVideoTrackStopped,this),yp.off(137,this.onAudioTrackStopped,this),yp.off(136,this.onAudioTrackStopped,this)}},{key:"initialize",value:function(){var e=this;return new Promise((function(t,n){if(Rm())n(new vf({code:mf.INVALID_OPERATION,message:zf({key:"NOT_SUPPORTED_HTTP"})}));else{if(Kd(e.audio_)){var r=new MediaStream;return Kd(e.audioSource_)||(r.addTrack(e.audioSource_),e.updateAudioPlayingState(!0)),Kd(e.videoSource_)||(r.addTrack(e.videoSource_),e.updateVideoPlayingState(!0)),e.setMediaStream(r),Gf.logSuccessEvent({userId:e.client_?e.client_.getUserId():e.userId_,eventType:nd,kind:"custom"}),e.setIsReadyToPublish(!0),t()}e.screen_?(e.log_.info("initialize stream audio: "+e.audio_+" screenAudio: "+e.screenAudio_+" screen: "+e.screen_),Ay({audio:e.audio_,screenAudio:e.screenAudio_,microphoneId:e.microphoneId_,screenSource:e.screenSource_,width:e.screenProfile_.width,height:e.screenProfile_.height,frameRate:e.screenProfile_.frameRate,sampleRate:e.audioProfile_.sampleRate,channelCount:e.audioProfile_.channelCount,autoGainControl:e.audioProfile_.autoGainControl,noiseSuppression:e.audioProfile_.noiseSuppression,echoCancellation:e.audioProfile_.echoCancellation}).then((function(n){e.setMediaStream(n),e.updateAudioPlayingState(e.audio_||e.screenAudio_),e.updateVideoPlayingState(!0);var r=e.getVideoTrack();return e.listenForScreenSharingStopped(r),e.setVideoContentHint(Tl),e.updateDeviceIdInUse(),e.setIsReadyToPublish(!0),e.log_.info(JSON.stringify(r.getSettings())),Gf.logSuccessEvent({userId:e.client_?e.client_.getUserId():e.userId_,eventType:nd,kind:"getDisplayMedia"}),t()})).catch((function(t){Gf.logFailedEvent({userId:e.client_?e.client_.getUserId():e.userId_,eventType:nd,kind:"getDisplayMedia",error:t}),e.log_.error("getDisplayMedia error observed "+t),n(t instanceof vf?t:new vf({code:mf.INITIALIZE_FAILED,name:t.name,message:t.message}))}))):(yp.emit(121,{stream:e,audio:e.audio_,video:e.video_}),e.log_.info("initialize stream audio: "+e.audio_+" video: "+e.video_),Ey({audio:e.audio_,video:e.video_,facingMode:e.facingMode_,cameraId:e.cameraId_,microphoneId:e.microphoneId_,width:e.videoProfile_.width,height:e.videoProfile_.height,frameRate:e.videoProfile_.frameRate,sampleRate:e.audioProfile_.sampleRate,channelCount:e.audioProfile_.channelCount,autoGainControl:e.audioProfile_.autoGainControl,noiseSuppression:e.audioProfile_.noiseSuppression,echoCancellation:e.audioProfile_.echoCancellation}).then((function(n){yp.emit(122,{stream:e,audio:e.audio_,video:e.video_}),e.setMediaStream(n);var r=e.getVideoTrack();return r&&(Mm&&(e.videoSetting_=r.getSettings()),Nm&&e.log_.info("video capabilities: "+JSON.stringify(r.getCapabilities()))),e.updateAudioPlayingState(e.audio_),e.updateVideoPlayingState(e.video_),e.updateDeviceIdInUse(),e.log_.info("gotStream hasAudio: "+e.hasAudio()+" hasVideo: "+e.hasVideo()),e.setIsReadyToPublish(!0),Gf.logSuccessEvent({userId:e.client_?e.client_.getUserId():e.userId_,eventType:nd,kind:"getUserMedia"}),t()})).catch((function(t){yp.emit(123,{stream:e,audio:e.audio_,video:e.video_,error:t}),Gf.logFailedEvent({userId:e.client_?e.client_.getUserId():e.userId_,eventType:nd,kind:"getUserMedia",error:t}),e.log_.error("getUserMedia error observed "+t),n(t)})))}}))}},{key:"listenForScreenSharingStopped",value:function(e){var t=this;e.addEventListener("ended",(function(e){t.log_.info("screen sharing was stopped because the video track is ended"),t.emitter_.emit("screen-sharing-stopped")}))}},{key:"muteAudio",value:function(){var e=g(d(S.prototype),"muteAudio",this).call(this);return e&&(this.log_.info("localStream mute audio"),this.sendMutedFlag(ll,!0)),e}},{key:"muteVideo",value:function(){var e=g(d(S.prototype),"muteVideo",this).call(this);return e&&(this.log_.info("localStream mute video"),this.sendMutedFlag(dl,!0)),e}},{key:"unmuteAudio",value:function(){var e=g(d(S.prototype),"unmuteAudio",this).call(this);return e&&(this.log_.info("localStream unmute audio"),this.sendMutedFlag(ll,!1)),e}},{key:"unmuteVideo",value:function(){var e=g(d(S.prototype),"unmuteVideo",this).call(this);return e&&(this.log_.info("localStream unmute video"),this.sendMutedFlag(dl,!1)),e}},{key:"sendMutedFlag",value:function(e,t){this.setMuteState(e,t);var n=this.getConnection();if(n){n.sendMutedFlag(this.muteState_);var r=n.getUserId(),i=n.getTinyId(),o="".concat(t?ml:vl," local ").concat(e," track");yf(r,{eventId:e===ll?t?32772:32774:t?32773:32775,eventDesc:o,timestamp:Sa(),userId:r,tinyId:i})}}},{key:"setMuteState",value:function(e,t){this.muteState_[e]=t,this.log_.info("set ".concat(e," muted state: [").concat(t?"mute":"unmute","]"))}},{key:"setAudioProfile",value:function(e){var n;"object"===r(e)?n=e:void 0===(n=Uy.get(e))&&(n=Uy.get("standard")),this.log_.info("setAudioProfile: "+JSON.stringify(n)),this.audioProfile_=t(t({},this.audioProfile_),n)}},{key:"setVideoProfile",value:(v=o(regeneratorRuntime.mark((function e(n){var r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.connection_||Tm()){e.next=2;break}throw new vf({code:mf.NOT_SUPPORTED,message:zf({key:"NOT_SUPPORTED_PROFILE"})});case 2:if(Wd(n)?r=t(t({},this.videoProfile_),n):Qd(n)&&(r=Ly.get(n),Kd(r)&&(r=Ly.get("480p"))),this.log_.info("setVideoProfile "+JSON.stringify(r)),!(i=this.getVideoTrack())){e.next=8;break}return e.next=8,i.applyConstraints(r);case 8:if(this.videoBitrate_===r.bitrate){e.next=13;break}if(!this.connection_){e.next=12;break}return e.next=12,this.connection_.setBandwidth(r.bitrate,dl);case 12:this.videoBitrate_=r.bitrate;case 13:this.videoProfile_=r;case 14:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"getVideoBitrate",value:function(){return this.videoBitrate_}},{key:"getAudioBitrate",value:function(){return this.audioProfile_.bitrate}},{key:"setScreenProfile",value:function(e){var t=e;"object"!==r(e)&&void 0===(t=My.get(e))&&(t=My.get("1080p")),this.log_.info("setScreenProfile "+JSON.stringify(e)),this.screenProfile_=t,this.videoBitrate_=t.bitrate}},{key:"getVideoProfile",value:function(){return this.screen_?this.screenProfile_:this.videoProfile_}},{key:"getAudioProfile",value:function(){return this.audioProfile_}},{key:"setVideoContentHint",value:function(e){var t=this.getVideoTrack();t&&"contentHint"in t&&(this.log_.info("set video track contentHint to: "+e),t.contentHint=e,t.contentHint!==e&&this.log_.warn("Invalid video track contentHint: "+e))}},{key:"switchDevice",value:(m=o(regeneratorRuntime.mark((function e(t,n){var r,i,o,a,s,c,u,l,d,h,p,f,m,v,_,g,y;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=t===ll)){e.next=8;break}if(this.microphoneId_!==n){e.next=4;break}return e.abrupt("return");case 4:this.microphoneId_=n,this.audio_=!0,e.next=12;break;case 8:if(this.cameraId_!==n){e.next=10;break}return e.abrupt("return");case 10:n===pl||n===fl?this.facingMode_=n:this.cameraId_=n,this.video_=!0;case 12:if(this.getMediaStream()){e.next=14;break}return e.abrupt("return");case 14:return this.setIsReadyToPublish(!1),this.log_.info("switchDevice "+t+" to: "+n),r||((i=this.getVideoTrack())&&i.stop(),Bu&&(o=this.getAudioTrack())&&(this.log_.info("stop audio track first in huawei env"),o.stop())),r&&(a=this.getAudioTrack(),s=this.getMicrophoneTrackMixed(),a&&a.stop(),s&&s.stop()),e.next=20,Ey({audio:this.audio_&&t===ll||Bu,video:this.video_&&t===dl,facingMode:n===pl||n===fl?n:void 0,cameraId:this.cameraId_,microphoneId:this.microphoneId_,width:this.videoProfile_.width,height:this.videoProfile_.height,frameRate:this.videoProfile_.frameRate,sampleRate:this.audioProfile_.sampleRate,channelCount:this.audioProfile_.channelCount});case 20:if(c=e.sent,u=null,!r){e.next=27;break}(l=c.getAudioTracks()[0])&&this.isAudioTrackMixed()?(d=this.getAudioTrack(),h=Wy.AudioMixerPlugin.getAudioTrackMap(),p=Wy.AudioMixerPlugin.mix({targetTrack:l,sourceList:h.get(d.id).sourceList,trackList:h.get(d.id).trackList}),u=p):u=l,e.next=36;break;case 27:if(!(u=c.getVideoTracks()[0])||!this.isVideoTrackBeautified()){e.next=32;break}return e.next=31,this.generateBeautyTrack(u);case 31:u=e.sent;case 32:if(!(f=c.getAudioTracks()[0])||!Bu){e.next=36;break}return e.next=36,this.replaceTrack_(f);case 36:return e.next=38,this.replaceTrack_(u);case 38:this.updateDeviceIdInUse(),(m=this.getConnection())&&(v=m.getUserId(),_=m.getTinyId(),g=32780,y="switch camera",r&&(g=32781,y="switch microphone"),yf(v,{eventId:g,eventDesc:y,timestamp:Sa(),userId:v,tinyId:_})),this.log_.info("switch ".concat(r?"microphone":"camera"," success ")),this.setIsReadyToPublish(!0);case 43:case"end":return e.stop()}}),e,this)}))),function(e,t){return m.apply(this,arguments)})},{key:"addTrack",value:(f=o(regeneratorRuntime.mark((function e(t){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isAddingTrack_){e.next=2;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_ADD_TRACK_REPETITIVE"})});case 2:if(!this.isRemovingTrack_){e.next=4;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_ADD_TRACK_REMOVING"})});case 4:if(0!==this.publishState_){e.next=6;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_ADD_TRACK_PUBLISHING"})});case 6:if(n=this.getMediaStream()){e.next=9;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:Uf})});case 9:if(!(t.kind===ll&&n.getAudioTracks().length>0||t.kind===dl&&n.getVideoTracks().length>0)){e.next=11;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_ADD_TRACK_NUMBER"})});case 11:if(t.kind===dl&&Mm&&(r=t.getSettings(),!this.videoSetting_||r.width===this.videoSetting_.width&&r.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(r.width," x ").concat(r.height,") shall be kept the same as the previous: ").concat(this.videoSetting_.width," x ").concat(this.videoSetting_.height,". It may cause abnormal Cloud Recording."))),e.prev=12,this.isAddingTrack_=!0,this.keepMuteState(t),n.addTrack(t),!(i=this.getConnection())){e.next=20;break}return e.next=20,i.addTrack(t);case 20:t.kind===ll?(this.audio_=!0,this.updateAudioPlayingState(!0)):(this.video_=!0,this.updateVideoPlayingState(!0)),this.isAddingTrack_=!1,e.next=29;break;case 24:throw e.prev=24,e.t0=e.catch(12),n.removeTrack(t),this.isAddingTrack_=!1,e.t0;case 29:case"end":return e.stop()}}),e,this,[[12,24]])}))),function(e){return f.apply(this,arguments)})},{key:"removeTrack",value:(p=o(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.kind!==ll){e.next=2;break}throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_REMOVE_AUDIO_TRACK"})});case 2:if(!this.isAddingTrack_){e.next=4;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_REMOVE_AUDIO_ADDING"})});case 4:if(!this.isRemovingTrack_){e.next=6;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_REMOVE_AUDIO_ON"})});case 6:if(0!==this.publishState_){e.next=8;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_REMOVE_TRACK_PUBLISHING"})});case 8:if(n=this.getMediaStream()){e.next=11;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:Uf})});case 11:if(-1!==n.getTracks().indexOf(t)){e.next=13;break}throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_REMOVE_TRACK_NOT_PUBLISHING"})});case 13:if(1!==n.getTracks().length){e.next=15;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_REMOVE_TRACK_NUMBER"})});case 15:if(e.prev=15,this.isRemovingTrack_=!0,!(r=this.getConnection())){e.next=21;break}return e.next=21,r.removeTrack(t);case 21:n.removeTrack(t),t.kind===ll?(this.audio_=!1,this.updateAudioPlayingState(!1)):(this.video_=!1,this.updateVideoPlayingState(!1)),this.isRemovingTrack_=!1,e.next=30;break;case 26:throw e.prev=26,e.t0=e.catch(15),this.isRemovingTrack_=!1,e.t0;case 30:case"end":return e.stop()}}),e,this,[[15,26]])}))),function(e){return p.apply(this,arguments)})},{key:"replaceTrack",value:(h=o(regeneratorRuntime.mark((function e(t){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.getMediaStream()){e.next=3;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:"INVALID_INITIALIZE_LOCAL_STREAM"})});case 3:if(0!==this.publishState_){e.next=5;break}throw new vf({code:mf.INVALID_OPERATION,message:zf({key:Of})});case 5:if(!(t.kind===ll&&n.getAudioTracks().length<=0||t.kind===dl&&n.getVideoTracks().length<=0)){e.next=7;break}throw new vf({code:mf.INVALID_PARAMETER,message:zf({key:"INVALID_REMOVE_TRACK_NOT_PUBLISHED",data:t})});case 7:if(t.kind===dl&&Mm&&(r=t.getSettings(),!this.videoSetting_||r.width===this.videoSetting_.width&&r.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(r.width," x ").concat(r.height,") shall be kept the same as the previous: ").concat(this.videoSetting_.width," x ").concat(this.videoSetting_.height,". It may cause abnormal Cloud Recording."))),this.keepMuteState(t),t.kind===ll?(n.removeTrack(n.getAudioTracks()[0]),n.addTrack(t),g(d(S.prototype),"restartAudio",this).call(this)):(n.removeTrack(n.getVideoTracks()[0]),n.addTrack(t),g(d(S.prototype),"restartVideo",this).call(this)),!(i=this.getConnection())){e.next=14;break}return e.next=14,i.replaceTrack(t);case 14:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"updateStream",value:(u=o(regeneratorRuntime.mark((function e(t){var n,r,i,o,a,s,c,u,l,d,h,p,f,m,v;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mediaStream_){e.next=2;break}return e.abrupt("return");case 2:return this.log_.info("updateStream() try to recover local stream"),e.prev=3,e.next=6,Wy.getCameras();case 6:return n=e.sent,e.next=9,Wy.getMicrophones();case 9:if(r=e.sent,i=this.audio_&&t.audio,(o=this.video_&&t.video)&&0===n.length&&(o=!1,this.log_.info("updateStream() video flag is true, but no camera detected, set video to false")),i&&0===r.length&&(i=!1,this.log_.info("updateStream() audio flag is true, but no microphone detected, set audio to false")),!1!==i||!1!==o){e.next=17;break}return this.log_.info("updateStream() both audio and video are false, recover stream aborted"),e.abrupt("return");case 17:return a=t&&n.findIndex((function(e){return e.deviceId===t.cameraId}))>=0,s=t&&r.findIndex((function(e){return e.deviceId===t.microphoneId}))>=0,e.next=21,Ey({audio:i,video:o,cameraId:a?t.cameraId:void 0,microphoneId:s?t.microphoneId:void 0,facingMode:this.facingMode_,width:this.videoProfile_.width,height:this.videoProfile_.height,frameRate:this.videoProfile_.frameRate,sampleRate:this.audioProfile_.sampleRate,channelCount:this.audioProfile_.channelCount});case 21:c=e.sent,u=c.getTracks(),l=0;case 24:if(!(l<u.length)){e.next=49;break}if((d=u[l]).kind!==ll||!this.isAudioTrackMixed()){e.next=37;break}if(h=this.getAudioTrack(),p=Wy.AudioMixerPlugin.getAudioTrackMap(),(f=p.get(h.id)).hasMicrophone){e.next=33;break}return d.stop(),e.abrupt("continue",46);case 33:return m=Wy.AudioMixerPlugin.mix({targetTrack:d,sourceList:f.sourceList,trackList:f.trackList}),e.next=36,this.replaceTrack_(m);case 36:return e.abrupt("continue",46);case 37:if(d.kind!==dl||!this.isVideoTrackBeautified()){e.next=44;break}return e.next=40,this.generateBeautyTrack(d);case 40:return v=e.sent,e.next=43,this.replaceTrack_(v);case 43:return e.abrupt("continue",46);case 44:return e.next=46,this.replaceTrack_(d);case 46:l++,e.next=24;break;case 49:this.updateDeviceIdInUse(),Gf.logSuccessEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:od}),this.log_.info("updateStream() recover local stream successfully"),e.next=59;break;case 54:e.prev=54,e.t0=e.catch(3),Gf.logFailedEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:od,error:e.t0}),this.log_.error("updateStream() failed to recover local stream, "+e.t0),this.emitter_.emit(Ym,new vf({code:mf.DEVICE_AUTO_RECOVER_FAILED,message:e.t0.message}));case 59:case"end":return e.stop()}}),e,this,[[3,54]])}))),function(e){return u.apply(this,arguments)})},{key:"replaceTrack_",value:(s=o(regeneratorRuntime.mark((function e(t){var n,r,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.mediaStream_.getAudioTracks(),r=this.mediaStream_.getVideoTracks(),!(t.kind===ll&&n.length<=0||t.kind===dl&&r.length<=0)){e.next=5;break}return this.log_.info("there is no previous ".concat(t.kind," track, replacement ignored")),e.abrupt("return");case 5:if(this.keepMuteState(t),t.kind===ll?(this.mediaStream_.removeTrack(n[0]),this.mediaStream_.addTrack(t),g(d(S.prototype),"restartAudio",this).call(this)):(Mm&&(i=t.getSettings(),!this.videoSetting_||i.width===this.videoSetting_.width&&i.height===this.videoSetting_.height||this.log_.warn("the resolution of video track to be replaced (".concat(i.width," x ").concat(i.height,") is different from the previous video settings (").concat(this.videoSetting_.width," x ").concat(this.videoSetting_.height,"). It may cause a cloud recording exception"))),this.mediaStream_.removeTrack(r[0]),this.mediaStream_.addTrack(t),g(d(S.prototype),"restartVideo",this).call(this)),!(o=this.getConnection())){e.next=11;break}return e.next=11,o.replaceTrack(t);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"updateDeviceIdInUse",value:function(){var e=this;if(!this.mediaStream_)return this.cameraId_="",this.cameraGroupId_="",this.microphoneId_="",void(this.microphoneGroupId_="");Mm&&this.mediaStream_.getTracks().forEach((function(t){if(t.kind===ll&&e.isAudioTrackMixed()){var n=e.getMicrophoneTrackMixed();if(n){var r=n.getSettings(),i=r.deviceId,o=r.groupId;i&&(e.microphoneId_=i,e.microphoneGroupId_=o)}}else if(t.kind===dl&&e.isVideoTrackBeautified()){var a=e.getBeautyOriginTrack();if(a){var s=a.getSettings(),c=s.deviceId,u=s.groupId;c&&(e.cameraId_=c,e.cameraGroupId_=u)}}else{var l=t.getSettings(),d=l.deviceId,h=l.groupId;d&&(t.kind===ll?(e.microphoneId_=d,e.microphoneGroupId_=h):t.kind!==dl||e.screen_||(e.cameraId_=d,e.cameraGroupId_=h))}}));var t=this.mediaStream_.getAudioTracks(),n=this.mediaStream_.getVideoTracks();t&&0===t.length&&(this.microphoneId_="",this.microphoneGroupId_=""),n&&0===n.length&&(this.cameraId_="",this.cameraGroupId_="")}},{key:"isAudioTrackMixed",value:function(){if(Wy.AudioMixerPlugin){var e=Wy.AudioMixerPlugin.getAudioTrackMap(),t=this.getAudioTrack();if(e&&t&&e.has(t.id))return!0}return!1}},{key:"getMicrophoneTrackMixed",value:function(){if(Wy.AudioMixerPlugin){var e=Wy.AudioMixerPlugin.getAudioTrackMap(),t=this.getAudioTrack();if(e&&t&&e.has(t.id)){var n=e.get(t.id);return n.hasMicrophone?n.microphoneTrack:null}}return null}},{key:"isVideoTrackBeautified",value:function(){if(Wy.beautyTrackMap){var e=Wy.beautyTrackMap,t=this.getVideoTrack();if(t&&e.has(t.id))return!0}return!1}},{key:"getBeautyOriginTrack",value:function(){if(Wy.beautyTrackMap){var e=Wy.beautyTrackMap,t=this.getVideoTrack();if(t&&e.has(t.id)){var n=e.get(t.id);if(n.originTrack)return n.originTrack}}return null}},{key:"generateBeautyTrack",value:(i=o(regeneratorRuntime.mark((function e(t){var n,r,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=null,r=this.getVideoTrack(),i=Wy.beautyTrackMap.get(r.id),o=i.param,i.type){e.next=8;break}n=i.pluginInstance.generateBeautyTrack(t),e.next=22;break;case 8:e.t0=i.type,e.next="beauty"===e.t0?11:"virtual"===e.t0?13:"mixed"===e.t0?17:21;break;case 11:return n=i.pluginInstance.generateBeautyTrack(t),e.abrupt("break",22);case 13:return e.next=15,i.pluginInstance.generateVirtualTrack({videoTrack:t,type:o.type,img:o.img});case 15:case 19:return n=e.sent,e.abrupt("break",22);case 17:return e.next=19,i.pluginInstance.generateMixedTrack({videoTrack:t,type:o.type,img:o.img});case 21:return e.abrupt("break",22);case 22:return i.pluginInstance.deleteSource(r.id),this.log_.info("regenerate beauty track, track id = ".concat(t.id)),e.abrupt("return",n);case 25:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getScreen",value:function(){return this.screen_}},{key:"hasScreenTrack",value:function(){if(this.screen_)return!0;var e=this.getVideoTrack();return!!e&&(e.contentHint===Tl||"text"===e.contentHint)}},{key:"getVideo",value:function(){return this.video_}},{key:"getAudio",value:function(){return this.audio_}},{key:"getCameraId",value:function(){return this.cameraId_}},{key:"getMicrophoneId",value:function(){return this.microphoneId_}},{key:"getMicrophoneGroupId",value:function(){return this.microphoneGroupId_}},{key:"getIsReadyToPublish",value:function(){return this.isReadyToPublish_}},{key:"setIsReadyToPublish",value:function(e){this.isReadyToPublish_=e}},{key:"setPublishState",value:function(e){this.publishState_=e}},{key:"setBeautyStatus",value:function(e){this.beautyStatus_=!!e}},{key:"getBeautyStatus",value:function(){return this.beautyStatus_}},{key:"onStreamPublished",value:function(e){var t=e.localStream,n=e.client;if(t===this){this.client_=n,this.log_.setUserId(n.getUserId()),this.log_.setSdkAppId(n.getSDKAppId());var r=this.getAudioTrack(),i=this.getVideoTrack();if(r){var o=!r.enabled;this.setMuteState(ll,o)}if(i){var a=!i.enabled;this.setMuteState(dl,a)}this.connection_&&this.connection_.sendMutedFlag(this.muteState_)}}},{key:"keepMuteState",value:function(e){e instanceof MediaStreamTrack&&this.muteState_[e.kind]&&(e.enabled=!1,this.log_.warn("prev ".concat(e.kind," track is muted, keep mute state")))}},{key:"onVideoTrackStopped",value:(n=o(regeneratorRuntime.mark((function e(t){var n,r,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.stream,r=t.type,!(n!==this||!this.video_||!this.cameraId_||this.recoverCaptureCount_>10||(su||cu)&&r===ml)){e.next=3;break}return e.abrupt("return");case 3:if(!(i=this.getVideoTrack())){e.next=11;break}return o=i.getSettings().deviceId,e.next=8,Wy.getCameras();case 8:if(!(e.sent.findIndex((function(e){return e.deviceId===o}))<0)){e.next=11;break}return e.abrupt("return");case 11:this.recoverCaptureCount_+=1,Gf.uploadEvent({log:"stat-local-video-".concat(r),userId:this.userId_}),this.updateStream({audio:!1,video:!0,cameraId:this.cameraId_});case 14:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"onAudioTrackStopped",value:function(e){var t=e.stream,n=e.type;t!==this||!this.audio_||!this.microphoneId_||this.recoverCaptureCount_>10||(su||cu)&&n===ml||(this.recoverCaptureCount_+=1,Gf.uploadEvent({log:"stat-local-audio-".concat(n),userId:this.userId_}),this.updateStream({audio:!0,video:!1,microphoneId:this.microphoneId_}))}},{key:"setAudioVolume",value:function(e){g(d(S.prototype),"setAudioVolume",this).call(this,e)}},{key:"clearCanvas",value:function(){this.canvasInterval_&&(cm.clearInterval(this.canvasInterval_),this.canvasInterval_=-1,this.canvas_=null)}},{key:"genCanvasTrack",value:function(e){var t=this;this.log_.info("gen canvas track");var n=e.getSettings(),r=n.width,i=n.height,o=n.frameRate;this.canvas_=document.createElement("canvas");var a=this.canvas_.getContext("2d");return this.canvas_.width=r,this.canvas_.height=i,this.canvasInterval_=cm.setInterval((function(){if(t.hasVideo()){var e=t.getVideoTrack().getSettings();e.width===t.canvas_.width&&e.height===t.canvas_.height||(t.canvas_.width=e.width,t.canvas_.height=e.height)}t.videoPlayer_&&t.videoPlayer_.element_&&a.drawImage(t.videoPlayer_.element_,0,0,t.canvas_.width,t.canvas_.height)}),Math.max(66,Math.floor(1e3/o))),this.canvas_.captureStream().getVideoTracks()[0]}}]),S}(Pg)).prototype,"switchDevice",[Ny],Object.getOwnPropertyDescriptor(Oy.prototype,"switchDevice"),Oy.prototype),Oy),Hy=0,zy=0,Gy=(Vy=Eg(Rg.TRTC.createClient),Fy=Eg(Rg.TRTC.createStream),T((jy=function(){function e(){a(this,e),this.name_=Ad,this.VERSION="4.12.2",this.Logger={loggerManager:Pp,LogLevel:{TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,NONE:5},setLogLevel:function(e){Pp.setLogLevel(e),ah()&&e<=1&&function(){if(!al())return!1;var e=localStorage.getItem("trtc_error_assistance");e&&!function(e){var t=e.saveTime&&(new Date).getTime()-e.saveTime>=6048e5,n=!e.saveVersion||"4.12.2"!==e.saveVersion;return t||n}(JSON.parse(e))||(Pp.log("request error info"),function(){var e=new XMLHttpRequest;if(e.open("GET","https://web.sdk.qcloud.com/trtc/webrtc/download/error-message/0.0.1/script.js",!1),e.send(null),4===e.readyState&&200===e.status){var t=document.createElement("script");t.type="text/javascript",t.text=e.responseText,document.body.appendChild(t),localStorage.setItem("trtc_error_assistance",JSON.stringify({message:e.responseText,saveTime:(new Date).getTime(),saveVersion:"4.12.2"})),document.body.removeChild(t)}}())}()},enableUploadLog:function(){Pp.enableUploadLog()},disableUploadLog:function(){Pp.disableUploadLog()}}}var n,r,i,s,u;return c(e,[{key:"checkSystemRequirements",value:(u=o(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,gm();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),function(){return u.apply(this,arguments)})},{key:"isScreenShareSupported",value:function(){return Sm()}},{key:"isSmallStreamSupported",value:function(){return Lm()}},{key:"getDevices",value:(s=o(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Rm()&&!wm()){e.next=2;break}return e.abrupt("return",[]);case 2:return e.next=4,navigator.mediaDevices.enumerateDevices();case 4:return t=e.sent,e.abrupt("return",t.filter((function(e){return e.kind!==kl||"communications"!=e.deviceId})).map((function(e,t){var n=e.label;e.label||(n=e.kind+"_"+t);var r={label:n,deviceId:e.deviceId,kind:e.kind};return e.groupId&&(r.groupId=e.groupId),r})));case 6:case"end":return e.stop()}}),e)}))),function(){return s.apply(this,arguments)})},{key:"getCameras",value:(i=o(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Rm()&&!wm()){e.next=2;break}return e.abrupt("return",[]);case 2:return e.next=4,navigator.mediaDevices.enumerateDevices();case 4:return t=e.sent,e.abrupt("return",t.filter((function(e){return e.kind===Il})).map((function(e,t){var n=e.label;e.label||(n="camera_"+t);var r={label:n,deviceId:e.deviceId,kind:e.kind};return e.groupId&&(r.groupId=e.groupId),r})));case 6:case"end":return e.stop()}}),e)}))),function(){return i.apply(this,arguments)})},{key:"getMicrophones",value:(r=o(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Rm()&&!wm()){e.next=2;break}return e.abrupt("return",[]);case 2:return e.next=4,navigator.mediaDevices.enumerateDevices();case 4:return t=e.sent,e.abrupt("return",t.filter((function(e){return e.kind===kl&&"communications"!==e.deviceId})).map((function(e,t){var n=e.label;e.label||(n="microphone_"+t);var r={label:n,deviceId:e.deviceId,kind:e.kind};return e.groupId&&(r.groupId=e.groupId),r})));case 6:case"end":return e.stop()}}),e)}))),function(){return r.apply(this,arguments)})},{key:"getSpeakers",value:(n=o(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Rm()&&!wm()){e.next=2;break}return e.abrupt("return",[]);case 2:return e.next=4,navigator.mediaDevices.enumerateDevices();case 4:return t=e.sent,e.abrupt("return",t.filter((function(e){return"audiooutput"===e.kind})).map((function(e,t){var n=e.label;e.label||(n="speaker_"+t);var r={label:n,deviceId:e.deviceId,kind:e.kind};return e.groupId&&(r.groupId=e.groupId),r})));case 6:case"end":return e.stop()}}),e)}))),function(){return n.apply(this,arguments)})},{key:"createClient",value:function(e){Dp&&(Dp=!1,Pp.getLogLevel()!=Wy.Logger.LogLevel.NONE&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: "+"".concat(Ud,"index.html")),console.info("* Changelog: https://cloud.tencent.com/document/product/647/38958"),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),Pp.info("TRTC Web SDK Version: 4.12.2"),Pp.info("UserAgent: "+navigator.userAgent),Pp.info("URL of current page: "+location.href));var n={version:this.VERSION},r=new Ry(t(t(t({},n),e),{},{seq:++Hy}));return yp.emit(30,{client:r}),r}},{key:"createStream",value:function(e){return new By(t(t({},e),{},{seq:++zy}))}}]),e}()).prototype,"createClient",[Vy],Object.getOwnPropertyDescriptor(jy.prototype,"createClient"),jy.prototype),T(jy.prototype,"createStream",[Fy],Object.getOwnPropertyDescriptor(jy.prototype,"createStream"),jy.prototype),jy);Rm();var Wy=new Gy;return Wy}()},809:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=n(802),o=r(n(134)),a=function(){function e(e){this.localStream=e,this.lowMix=null,this.already=[]}return e.prototype.createMusic=function(e){this.lowMix=o.default.createAudioSource({url:e,volume:.2,loop:!0}),this.lowMix.on("play",(function(e){(0,i.logInfo)("event: play"+e)})),this.lowMix.on("end",(function(e){(0,i.logInfo)("event: end"+e)})),this.lowMix.on("error",(function(e){(0,i.logInfo)("event: error"+e)}))},e.prototype.addLowMix=function(){if(this.lowMix){this.already.push(this.lowMix),(0,i.logInfo)("already mix"+this.already);var e=this.localStream.getAudioTrack(),t=o.default.mix({targetTrack:e,sourceList:this.already});this.localStream.replaceTrack(t),this.updateAlready()}},e.prototype.leaveRoom=function(){this.lowMixStop(),this.lowMix=null},e.prototype.lowMixStart=function(){this.lowMix&&this.lowMix.play()},e.prototype.lowMixPause=function(){this.lowMix&&this.lowMix.pause()},e.prototype.lowMixStop=function(){this.lowMix&&this.lowMix.stop()},e.prototype.lowMixResume=function(){this.lowMix&&this.lowMix.resume(),this.lowMix&&this.lowMix.play()},e.prototype.updateAlready=function(){(0,i.logInfo)("already mixed audio: "+(this.already||[]).length)},e}();t.default=a},996:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var a=n(802),s=o(n(24)),c=function(){function e(){this._currentDevice=new Map}return e.prototype.getDevicesList=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=(0,a.getFlutterArgs)(e,"type"),n=[],0!==t?[3,2]:[4,s.default.getMicrophones()];case 1:return n=r.sent(),[3,6];case 2:return 1!==t?[3,4]:[4,s.default.getSpeakers()];case 3:return n=r.sent(),[3,6];case 4:return 2!==t?[3,6]:[4,s.default.getCameras()];case 5:n=r.sent(),r.label=6;case 6:return[2,JSON.stringify(n)]}}))}))},e.prototype.setCurrentDevice=function(e,t){return r(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:n=(0,a.getFlutterArgs)(t,"type"),r=(0,a.getFlutterArgs)(t,"deviceId"),i.label=1;case 1:return i.trys.push([1,4,,5]),e?[4,e.switchDevice(2===n?"video":"audio",r)]:[3,3];case 2:i.sent(),i.label=3;case 3:return this._currentDevice[n]=r,[3,5];case 4:return o=i.sent(),(0,a.logError)("setCurrentDevice failed "+o),[3,5];case 5:return[2,0]}}))}))},e.prototype.getCurrentDevice=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o;return i(this,(function(i){switch(i.label){case 0:return t=(0,a.getFlutterArgs)(e,"type"),this._currentDevice[t]&&(n=this._currentDevice[t]),r=[],0!==t?[3,2]:[4,s.default.getMicrophones()];case 1:return r=i.sent(),[3,6];case 2:return 1!==t?[3,4]:[4,s.default.getSpeakers()];case 3:return r=i.sent(),[3,6];case 4:return 2!==t?[3,6]:[4,s.default.getCameras()];case 5:r=i.sent(),i.label=6;case 6:return n&&""!==n&&(o=r.find((function(e){return e.deviceId==n})))?[2,JSON.stringify(o)]:[2,JSON.stringify(r[0])]}}))}))},e.prototype.setCurrentDeviceVolume=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,a.noSupportFunction)("setCurrentDeviceVolume"),[2,0]}))}))},e.prototype.getCurrentDeviceVolume=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,a.noSupportFunction)("getCurrentDeviceVolume"),[2,0]}))}))},e.prototype.setCurrentDeviceMute=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,a.noSupportFunction)("setCurrentDeviceMute"),[2,0]}))}))},e.prototype.getCurrentDeviceMute=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,a.noSupportFunction)("getCurrentDeviceMute"),[2,!0]}))}))},e.prototype.startCameraDeviceTest=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,a.noSupportFunction)("startCameraDeviceTest"),[2,0]}))}))},e.prototype.stopCameraDeviceTest=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,a.noSupportFunction)("stopCameraDeviceTest"),[2,0]}))}))},e.prototype.startMicDeviceTest=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,a.noSupportFunction)("startMicDeviceTest"),[2,0]}))}))},e.prototype.stopMicDeviceTest=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,a.noSupportFunction)("stopMicDeviceTest"),[2,0]}))}))},e.prototype.startSpeakerDeviceTest=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,a.noSupportFunction)("startSpeakerDeviceTest"),[2,0]}))}))},e.prototype.stopSpeakerDeviceTest=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,a.noSupportFunction)("stopSpeakerDeviceTest"),[2,0]}))}))},e}();t.default=c},627:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.onError="onError",e.onWarning="onWarning",e.onEnterRoom="onEnterRoom",e.onExitRoom="onExitRoom",e.onSwitchRole="onSwitchRole",e.onRemoteUserEnterRoom="onRemoteUserEnterRoom",e.onRemoteUserLeaveRoom="onRemoteUserLeaveRoom",e.onConnectOtherRoom="onConnectOtherRoom",e.onDisConnectOtherRoom="onDisConnectOtherRoom",e.onSwitchRoom="onSwitchRoom",e.onUserVideoAvailable="onUserVideoAvailable",e.onUserSubStreamAvailable="onUserSubStreamAvailable",e.onUserAudioAvailable="onUserAudioAvailable",e.onFirstVideoFrame="onFirstVideoFrame",e.onFirstAudioFrame="onFirstAudioFrame",e.onSendFirstLocalVideoFrame="onSendFirstLocalVideoFrame",e.onSendFirstLocalAudioFrame="onSendFirstLocalAudioFrame",e.onNetworkQuality="onNetworkQuality",e.onStatistics="onStatistics",e.onConnectionLost="onConnectionLost",e.onTryToReconnect="onTryToReconnect",e.onConnectionRecovery="onConnectionRecovery",e.onSpeedTest="onSpeedTest",e.onCameraDidReady="onCameraDidReady",e.onMicDidReady="onMicDidReady",e.onUserVoiceVolume="onUserVoiceVolume",e.onRecvCustomCmdMsg="onRecvCustomCmdMsg",e.onMissCustomCmdMsg="onMissCustomCmdMsg",e.onRecvSEIMsg="onRecvSEIMsg",e.onStartPublishing="onStartPublishing",e.onStopPublishing="onStopPublishing",e.onStartPublishCDNStream="onStartPublishCDNStream",e.onStopPublishCDNStream="onStopPublishCDNStream",e.onSetMixTranscodingConfig="onSetMixTranscodingConfig",e.onMusicObserverStart="onMusicObserverStart",e.onMusicObserverPlayProgress="onMusicObserverPlayProgress",e.onMusicObserverComplete="onMusicObserverComplete",e.onSnapshotComplete="onSnapshotComplete",e.onScreenCaptureStarted="onScreenCaptureStarted",e.onScreenCapturePaused="onScreenCapturePaused",e.onScreenCaptureResumed="onScreenCaptureResumed",e.onScreenCaptureStoped="onScreenCaptureStoped",e.onDeviceChange="onDeviceChange",e.onTestMicVolume="onTestMicVolume",e.onTestSpeakerVolume="onTestSpeakerVolume"}(n||(n={})),t.default=n},935:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var a=n(802),s=o(n(627)),c=o(n(24)),u=function(){function e(e,t,n,r){this._roomId="0",this._emitEvent=e,this._roomId=t,this._strRoomId=n,this._sdkAppId=r}return e.prototype.startScreenCapture=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,u,l,d=this;return i(this,(function(i){switch(i.label){case 0:t=(0,a.getFlutterArgs)(e,"shareUserId"),n=(0,a.getFlutterArgs)(e,"shareUserSig"),this._shareClient=c.default.createClient({mode:"rtc",sdkAppId:this._sdkAppId,userId:t,userSig:n,frameWorkType:7,useStringRoomId:!(!this._strRoomId||""===this._strRoomId)}),(r=c.default.createStream({audio:!1,screen:!0,userId:t})).on("screen-sharing-stopped",(function(){d.stopScreenCapture({})})),this._shareStream=r,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,r.initialize()];case 2:return i.sent(),(0,a.logSuccess)("shareStream initialize success"),[3,4];case 3:switch(o=i.sent(),(0,a.logError)("shareStream.initialize error: "+o.name),o.name){case"NotReadableError":default:return[2];case"NotAllowedError":return o.message,[2]}return[3,4];case 4:return i.trys.push([4,6,,7]),[4,this._shareClient.join({roomId:this._strRoomId&&""!==this._strRoomId?this._strRoomId:parseInt(this._roomId,10)})];case 5:return i.sent(),(0,a.logSuccess)("ShareClient join room success"),this._emitEvent(s.default.onScreenCaptureStarted,0),[3,7];case 6:return u=i.sent(),(0,a.logError)(u),[3,7];case 7:return i.trys.push([7,9,,10]),[4,this._shareClient.publish(this._shareStream)];case 8:return i.sent(),(0,a.logSuccess)("ShareClient publish success"),[3,10];case 9:return l=i.sent(),(0,a.logError)("ShareClient publish failed"+l),[3,10];case 10:return[2]}}))}))},e.prototype.stopScreenCapture=function(e){return r(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:if(!this._shareStream)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this._shareClient.unpublish(this._shareStream)];case 2:return t.sent(),(0,a.logSuccess)("shareClient.unpublish success"),[3,4];case 3:return e=t.sent(),(0,a.logError)("shareClient.unpublish failed"+e),[3,4];case 4:try{this._shareStream.close(),(0,a.logSuccess)("shareClient.close success")}catch(e){(0,a.logError)("shareClient.close failed"+e)}return[4,this._shareClient.leave()];case 5:return t.sent(),this._emitEvent(s.default.onScreenCaptureStoped,0),this._shareStream=null,this._shareClient=null,[2]}}))}))},e.prototype.pauseScreenCapture=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this._shareStream?[4,this._shareClient.unpublish(this._shareStream)]:[2];case 1:return e.sent(),this._emitEvent(s.default.onScreenCapturePaused,0),[2]}}))}))},e.prototype.resumeScreenCapture=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this._shareStream?[4,this._shareClient.publish(this._shareStream)]:[2];case 1:return e.sent(),this._emitEvent(s.default.onScreenCaptureResumed,0),[2]}}))}))},e}();t.default=u},315:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var a=o(n(809)),s=n(802),c=o(n(996)),u=o(n(627)),l=o(n(935)),d=o(n(24)),h=function(){function e(){this._joinCallList=new Map,this._remoteStream=new Map,this._remoteHtml=new Map,this._roomId="0",this._muteInitLocalAudio=!1,this._muteInitLocalVideo=!1,(0,s.logSuccess)("TrtcWrapper new come"),this._deviceManage=new c.default,this._muteInitLocalAudio=!1,this._muteInitLocalVideo=!1,this._isHadJoined=!1,this._joinCallList.clear()}return e.prototype.getSDKVersion=function(){return d.default.VERSION},e.prototype.enterRoom=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o,a,c,u,l,d,h;return i(this,(function(i){switch(i.label){case 0:return(0,s.logSuccess)("begin enterRoom"),t=(0,s.getFlutterArgs)(e,"userId"),n=(0,s.getFlutterArgs)(e,"sdkAppId"),r=(0,s.getFlutterArgs)(e,"userSig"),o=(0,s.getFlutterArgs)(e,"roomId"),a=(0,s.getFlutterArgs)(e,"strRoomId"),c=(0,s.getFlutterArgs)(e,"role"),u=(0,s.getFlutterArgs)(e,"streamId"),l=(0,s.getFlutterArgs)(e,"userDefineRecordId"),d=(0,s.getFlutterArgs)(e,"privateMapKey"),this._userId=t,this._sdkAppId=n,this._roomId=o,this._strRoomId=a,h={sdkAppId:n,userId:t,userSig:r,mode:"rtc",autoSubscribe:!0,frameWorkType:7,useStringRoomId:!(!a||""===a)},""!==u&&(h.streamId=u),""!==l&&(h.userDefineRecordId=l),[4,this._initClient(h,a,o,c,d)];case 1:return i.sent(),[2]}}))}))},e.prototype.exitRoom=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.stopScreenCapture({})];case 1:return e.sent(),this._localStream?[4,this._client.unpublish(this._localStream)]:[3,3];case 2:e.sent(),e.label=3;case 3:return this._localStream?[4,this._localStream.stop()]:[3,5];case 4:e.sent(),e.label=5;case 5:return this._localStream?[4,this._localStream.close()]:[3,7];case 6:e.sent(),e.label=7;case 7:return(0,s.logSuccess)("localStream stop & close success"),this._client?[4,this._client.leave()]:[3,9];case 8:e.sent(),e.label=9;case 9:return window.DestoryLocalStreamCallBack(),this._client&&this._client.off("*"),this._remoteStream.clear(),this._remoteHtml.forEach((function(e){e.remove()})),this._remoteHtml.clear(),this._muteInitLocalAudio=!1,this._muteInitLocalVideo=!1,this._isHadJoined=!1,this._joinCallList.clear(),this._localStream=null,this._client=null,(0,s.logSuccess)("exitRoom success"),[2]}}))}))},e.prototype.switchRole=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return 21!==(t=(0,s.getFlutterArgs)(e,"role"))?[3,2]:[4,this._client.switchRole("anchor")];case 1:return n.sent(),[3,5];case 2:return 20!==t?[3,4]:[4,this._client.switchRole("audience")];case 3:return n.sent(),[3,5];case 4:(0,s.logError)("switchRole role ".concat(t," not supper ")),n.label=5;case 5:return[2]}}))}))},e.prototype.switchRoom=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,s.noSupportFunction)("switchRoom"),[2]}))}))},e.prototype.connectOtherRoom=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,s.noSupportFunction)("connectOtherRoom"),[2]}))}))},e.prototype.disconnectOtherRoom=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,s.noSupportFunction)("disconnectOtherRoom"),[2]}))}))},e.prototype.setDefaultStreamRecvMode=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,s.noSupportFunction)("setDefaultStreamRecvMode"),[2]}))}))},e.prototype.createSubCloud=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,s.noSupportFunction)("createSubCloud"),[2]}))}))},e.prototype.destroySubCloud=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,s.noSupportFunction)("destroySubCloud"),[2]}))}))},e.prototype.startLocalAudio=function(){return r(this,void 0,void 0,(function(){var e,t;return i(this,(function(n){switch(n.label){case 0:return this._muteInitLocalAudio=!0,[4,this._createNPublishLocalStream()];case 1:return n.sent(),this._localStream.hasAudio()?[3,5]:[4,(e=d.default.createStream({audio:!0,video:!1})).initialize()];case 2:return n.sent(),t=e.getAudioTrack(),this._localStream?[4,this._localStream.addTrack(t)]:[3,4];case 3:n.sent(),n.label=4;case 4:n.label=5;case 5:return this._localStream&&this._localStream.unmuteAudio(),[2]}}))}))},e.prototype.stopLocalAudio=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return this._localStream&&this._localStream.muteAudio(),[2]}))}))},e.prototype.muteLocalAudio=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this._localStream?(0,s.getFlutterArgs)(e,"mute")?[4,this._localStream.muteAudio()]:[3,2]:[2];case 1:return t.sent(),[3,4];case 2:return[4,this._localStream.unmuteAudio()];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},e.prototype.muteLocalVideo=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this._localStream?(0,s.getFlutterArgs)(e,"mute")?[4,this._localStream.muteVideo()]:[3,2]:[2];case 1:return t.sent(),[3,4];case 2:return[4,this._localStream.unmuteVideo()];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},e.prototype.stopLocalPreview=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this._localStream?[4,this._localStream.stop()]:[2];case 1:return e.sent(),[4,this._localStream.muteVideo()];case 2:return e.sent(),[2]}}))}))},e.prototype.startLocalPreview=function(e,t,n){return r(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return this._muteInitLocalVideo=!0,[4,this._createNPublishLocalStream()];case 1:return r.sent(),this._localStream.hasVideo()?[3,4]:[4,(e=d.default.createStream({audio:!1,video:!0})).initialize()];case 2:return r.sent(),n=e.getVideoTrack(),[4,this._localStream.addTrack(n)];case 3:r.sent(),this._muteInitLocalVideo&&window.InitLocalStreamCallBack(this._localStream),r.label=4;case 4:return[4,this._localStream.unmuteVideo()];case 5:return r.sent(),[4,this._localStream.play(t,{objectFit:"cover",muted:!0})];case 6:return r.sent(),this._localPreviewId=t,[4,this._localStream.resume()];case 7:return r.sent(),[2]}}))}))},e.prototype.setAudioCaptureVolume=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,s.noSupportFunction)("setAudioCaptureVolume"),[2]}))}))},e.prototype.getAudioCaptureVolume=function(e){return 100*this._localStream.getAudioLevel()},e.prototype.setAudioPlayoutVolume=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(n){return t=(0,s.getFlutterArgs)(e,"volume"),this._localStream&&this._localStream.setAudioVolume(t/100),[2]}))}))},e.prototype.getAudioPlayoutVolume=function(e){return this._localStream?100*this._localStream.getAudioLevel():0},e.prototype.setAudioRoute=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,s.noSupportFunction)("setAudioRoute"),[2]}))}))},e.prototype.switchCamera=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,s.noSupportFunction)("switchCamera"),[2]}))}))},e.prototype.setLocalRenderParams=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,s.noSupportFunction)("setLocalRenderParams"),[2]}))}))},e.prototype.setVideoEncoderParam=function(e){return r(this,void 0,void 0,(function(){var t,n,r,o;return i(this,(function(i){return t=JSON.parse(e),n=(0,s.getVideoResolution)(t.videoResolution).split("*"),r=n[0],o=n[1],this._localStream.setVideoProfile({width:o,height:r,frameRate:t.videoFps,bitrate:t.videoBitrate}),[2]}))}))},e.prototype.enableEncSmallVideoStream=function(e){return this._client?((0,s.getFlutterArgs)(e,"enable")?this._client.enableSmallStream():this._client.disableSmallStream(),0):-1},e.prototype.setRemoteVideoStreamType=function(e){var t=(0,s.getFlutterArgs)(e,"userId"),n=(0,s.getFlutterArgs)(e,"streamType");if(this._remoteStream&&this._remoteStream.has(t)){var r=this._remoteStream.get(t);this._client&&this._client.setRemoteVideoStreamType(r,1===n?"small":"big")}return 0},e.prototype.enableAudioVolumeEvaluation=function(e){var t=(0,s.getFlutterArgs)(e,"intervalMs");return this._client&&this._client.enableAudioVolumeEvaluation(t),0},e.prototype.startRemoteView=function(e,t,n){return r(this,void 0,void 0,(function(){var r,o,a,c;return i(this,(function(i){switch(i.label){case 0:return r=(0,s.getFlutterArgs)(n,"userId"),this._remoteStream&&this._remoteStream.has(r)?[4,(o=this._remoteStream.get(r)).unmuteVideo()]:[3,4];case 1:if(i.sent(),!(a=this._remoteHtml.get(r)))return[3,3];try{(0,s.logInfo)("startRemoteView ".concat(t," removeChild ").concat(r," view")),document.body&&document.body.removeChild&&document.body.removeChild(a)}catch(e){(0,s.logInfo)("startRemoteView removeChild failed, It does not affect the use of ".concat(e))}return(c=document.getElementById(t))?c.appendChild(a):(e.appendChild(a),console.error(e),(0,s.logError)("startRemoteView ".concat(t," not find "))),a.style.visibility="visible",(0,s.logInfo)("startRemoteView ".concat(t," appendChild ").concat(r," view")),[4,o.resume()];case 2:return i.sent(),[3,4];case 3:(0,s.logError)("startRemoteView ".concat(t," oDiv not find ").concat(r," view")),i.label=4;case 4:return[2]}}))}))},e.prototype.stopRemoteView=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=(0,s.getFlutterArgs)(e,"userId"),this._remoteStream&&this._remoteStream.has(t)?[4,this._remoteStream.get(t).muteVideo()]:[3,2];case 1:r.sent(),(n=this._remoteHtml.get(t))&&(n.style.visibility="hidden"),r.label=2;case 2:return[2]}}))}))},e.prototype.stopAllRemoteView=function(e){return r(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return this._remoteStream&&this._remoteStream.forEach((function(t,n){return r(e,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return[4,t.muteVideo()];case 1:return r.sent(),(e=this._remoteHtml.get(n))&&(e.style.visibility="hidden"),[2]}}))}))})),[2]}))}))},e.prototype.muteRemoteVideoStream=function(e){return r(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return t=(0,s.getFlutterArgs)(e,"mute"),n=(0,s.getFlutterArgs)(e,"userId"),this._remoteStream&&this._remoteStream.has(n)?(r=this._remoteStream.get(n),t?[4,r.muteVideo()]:[3,2]):[3,5];case 1:return i.sent(),[3,4];case 2:return[4,r.unmuteVideo()];case 3:i.sent(),i.label=4;case 4:t||r.resume(),i.label=5;case 5:return[2]}}))}))},e.prototype.muteAllRemoteVideoStreams=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return i(this,(function(o){return t=(0,s.getFlutterArgs)(e,"mute"),this._remoteStream&&this._remoteStream.forEach((function(e){return r(n,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return n=e,t?[4,n.muteVideo()]:[3,2];case 1:return r.sent(),[3,4];case 2:return[4,n.unmuteVideo()];case 3:r.sent(),r.label=4;case 4:return t||n.resume(),[2]}}))}))})),[2]}))}))},e.prototype.muteRemoteAudio=function(e){return r(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return t=(0,s.getFlutterArgs)(e,"userId"),n=(0,s.getFlutterArgs)(e,"mute"),this._remoteStream&&this._remoteStream.has(t)?(r=this._remoteStream.get(t),n?[4,r.muteAudio()]:[3,2]):[3,5];case 1:return i.sent(),[3,4];case 2:return[4,r.unmuteAudio()];case 3:i.sent(),i.label=4;case 4:n||r.resume(),i.label=5;case 5:return[2]}}))}))},e.prototype.muteAllRemoteAudio=function(e){return r(this,void 0,void 0,(function(){var t,n=this;return i(this,(function(o){return t=(0,s.getFlutterArgs)(e,"mute"),this._remoteStream&&this._remoteStream.forEach((function(e){return r(n,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return n=e,t?[4,n.muteAudio()]:[3,2];case 1:return r.sent(),[3,4];case 2:return[4,n.unmuteAudio()];case 3:r.sent(),r.label=4;case 4:return t||n.resume(),[2]}}))}))})),[2]}))}))},e.prototype.setRemoteAudioVolume=function(e){return r(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){return t=(0,s.getFlutterArgs)(e,"userId"),n=(0,s.getFlutterArgs)(e,"volume"),this._remoteStream&&this._remoteStream.has(t)&&this._remoteStream.get(t).setAudioVolume(n/100),[2]}))}))},e.prototype.startAudioRecording=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},e.prototype.stopAudioRecording=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},e.prototype.startLocalRecording=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},e.prototype.stopLocalRecording=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},e.prototype.updateLocalView=function(e,t,n){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,s.noSupportFunction)("updateLocalView"),[2]}))}))},e.prototype.updateRemoteView=function(e,t,n){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,s.noSupportFunction)("updateLocalView"),[2]}))}))},e.prototype.setLogLevel=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(n){return t=(0,s.getFlutterArgs)(e,"level"),d.default.Logger.setLogLevel(t),[2]}))}))},e.prototype.setConsoleEnabled=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return(0,s.getFlutterArgs)(e,"enabled")?d.default.Logger.enableUploadLog():d.default.Logger.disableUploadLog(),[2]}))}))},e.prototype.setLogCompressEnabled=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},e.prototype.setLogDirPath=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},e.prototype.setLogDelegate=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},e.prototype.showDebugView=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},e.prototype.setDebugViewMargin=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},e.prototype.callExperimentalAPI=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},e.prototype.startPublishing=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:if(!this._client)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._client.startPublishCDNStream({streamId:(0,s.getFlutterArgs)(e,"streamId")})];case 2:return n.sent(),(0,s.logSuccess)("startPublishing Success"),[3,4];case 3:return t=n.sent(),(0,s.logError)(t),[3,4];case 4:return[2]}}))}))},e.prototype.stopPublishing=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this._client?[4,this._client.stopPublishCDNStream()]:[2];case 1:return e.sent(),[2]}}))}))},e.prototype.startPublishCDNStream=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:if(!this._client)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._client.startPublishCDNStream({appId:(0,s.getFlutterArgs)(e,"appId"),bizId:(0,s.getFlutterArgs)(e,"bizId"),url:(0,s.getFlutterArgs)(e,"url")})];case 2:return n.sent(),(0,s.logSuccess)("startPublishCDNStream Success"),[3,4];case 3:return t=n.sent(),(0,s.logError)(t),[3,4];case 4:return[2]}}))}))},e.prototype.stopPublishCDNStream=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this._client?[4,this._client.stopPublishCDNStream()]:[2];case 1:return e.sent(),[2]}}))}))},e.prototype.setMixTranscodingConfig=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:if(!this._client)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._client.startMixTranscode(JSON.parse(e.replace('"backgroundImage":null','"backgroundImage":""').replace('"streamId":null','"streamId":""')))];case 2:return n.sent(),(0,s.logSuccess)("startMixTranscode Success"),[3,4];case 3:return t=n.sent(),(0,s.logError)(t),[3,4];case 4:return[2]}}))}))},e.prototype.startScreenCapture=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return this._shareScreenManage=new l.default(this._emitEvent,this._roomId,this._strRoomId,this._sdkAppId),this._shareScreenManage.startScreenCapture(e),[2]}))}))},e.prototype.stopScreenCapture=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return this._shareScreenManage&&this._shareScreenManage.stopScreenCapture(e),[2]}))}))},e.prototype.pauseScreenCapture=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return this._shareScreenManage&&this._shareScreenManage.pauseScreenCapture(e),[2]}))}))},e.prototype.resumeScreenCapture=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return this._shareScreenManage&&this._shareScreenManage.resumeScreenCapture(e),[2]}))}))},e.prototype.getDevicesList=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._deviceManage.getDevicesList(e)]}))}))},e.prototype.setCurrentDevice=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._deviceManage.setCurrentDevice(this._localStream,e)]}))}))},e.prototype.getCurrentDevice=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._deviceManage.getCurrentDevice(e)]}))}))},e.prototype.setCurrentDeviceVolume=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._deviceManage.setCurrentDeviceVolume(e)]}))}))},e.prototype.getCurrentDeviceVolume=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._deviceManage.getCurrentDeviceVolume(e)]}))}))},e.prototype.setCurrentDeviceMute=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._deviceManage.setCurrentDeviceMute(e)]}))}))},e.prototype.getCurrentDeviceMute=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._deviceManage.getCurrentDeviceMute(e)]}))}))},e.prototype.startCameraDeviceTest=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._deviceManage.startCameraDeviceTest(e)]}))}))},e.prototype.stopCameraDeviceTest=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._deviceManage.stopCameraDeviceTest(e)]}))}))},e.prototype.startMicDeviceTest=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._deviceManage.startMicDeviceTest(e)]}))}))},e.prototype.stopMicDeviceTest=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._deviceManage.stopMicDeviceTest(e)]}))}))},e.prototype.startSpeakerDeviceTest=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._deviceManage.startSpeakerDeviceTest(e)]}))}))},e.prototype.stopSpeakerDeviceTest=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._deviceManage.stopSpeakerDeviceTest(e)]}))}))},e.prototype.setWatermark=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return(0,s.noSupportFunction)("setWatermark"),[2]}))}))},e.prototype.startPlayMusic=function(e){return r(this,void 0,void 0,(function(){var t;return i(this,(function(n){return t=JSON.parse((0,s.getFlutterArgs)(e,"musicParam")).path,this._audioMixMusic.createMusic(t),this._audioMixMusic.addLowMix(),this._audioMixMusic.lowMixStart(),[2]}))}))},e.prototype.stopPlayMusic=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){return this._audioMixMusic.lowMixStop(),[2]}))}))},e.prototype.resumePlayMusic=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return this._audioMixMusic.lowMixResume(),[2]}))}))},e.prototype.pausePlayMusic=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(e){return this._audioMixMusic.lowMixPause(),[2]}))}))},e.prototype.setEventHandler=function(e){this.handler=e},e.prototype.sharedInstance=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2]}))}))},e.prototype.destroySharedInstance=function(){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this._client?[4,this.exitRoom()]:[3,2];case 1:e.sent(),(0,s.logSuccess)("destroySharedInstance success"),e.label=2;case 2:return[2]}}))}))},e.prototype.getDeviceManager=function(){},e.prototype.getBeautyManager=function(){},e.prototype.getAudioEffectManager=function(){},e.prototype._createNPublishLocalStream=function(){return r(this,void 0,void 0,(function(){var e,t=this;return i(this,(function(n){return this._localStream?[2]:((0,s.logSuccess)("begin create ".concat(this._userId," Stream")),this._localStream=d.default.createStream({userId:this._userId,audio:this._muteInitLocalAudio,video:this._muteInitLocalVideo}),e=new Promise((function(e,n){return r(t,void 0,void 0,(function(){var t,o,c=this;return i(this,(function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),(0,s.logSuccess)("begin LocalStream initialize"),[4,this._localStream.initialize()];case 1:return u.sent(),this._muteInitLocalVideo&&window.InitLocalStreamCallBack(this._localStream),this._audioMixMusic=new a.default(this._localStream),(0,s.logSuccess)("LocalStream initialize success"),[3,3];case 2:return t=u.sent(),(0,s.logError)("failed initialize localStream "+t),[3,3];case 3:try{o=function(){return r(c,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return window.LocalBeautyStream?[4,this._client.publish(window.LocalBeautyStream)]:[3,2];case 1:return e.sent(),[3,4];case 2:return[4,this._client.publish(this._localStream)];case 3:e.sent(),e.label=4;case 4:return(0,s.logSuccess)("success initialize localStream & publish success"),[2]}}))}))},this._isHadJoined?o():this._joinCallList.set("publish",o),e()}catch(e){(0,s.logError)("failed publish localStream "+e),n()}return[2]}}))}))})),[2,e])}))}))},e.prototype._emitEvent=function(e,t){var n;(t instanceof Array||"object"==typeof t)&&(t=JSON.stringify(t)),null===(n=this.handler)||void 0===n||n.call(this,e.toString(),t)},e.prototype._addListener=function(){var e=this;this._client&&(this._client.on("error",(function(t){e._emitEvent(u.default.onError,{errCode:t.getCode(),errMsg:t.getMessage()})})),this._client.on("client-banned",(function(t){e._emitEvent(u.default.onWarning,{errCode:t.getCode(),errMsg:"同名用户登录或者是被账户管理员主动踢出房间"})})),this._client.on("network-quality",(function(t){e._emitEvent(u.default.onNetworkQuality,t)})),this._client.on("peer-join",(function(t){var n=t.userId;e._emitEvent(u.default.onRemoteUserEnterRoom,n)})),this._client.on("peer-leave",(function(t){var n=t.userId;e._emitEvent(u.default.onRemoteUserLeaveRoom,{userId:n,reason:0})})),this._client.on("stream-added",(function(t){var n=t.stream,r=n.getUserId();if(e._remoteStream.set(r,n),e._remoteHtml.has(r))(0,s.logInfo)("user ".concat(r," div had exist"));else{var i=document.createElement("div");i.id="stream-added-stream_"+r,i.style.visibility="hidden",i.style.height="100%",i.style.width="100%",(0,s.logInfo)("stream-added ".concat(r)),e._remoteHtml.set(r,i)}n.play(e._remoteHtml.get(r),{objectFit:"cover",muted:!1}),n.resume()})),this._client.on("stream-removed",(function(t){var n=t.stream,r=n.getUserId();e._remoteStream.delete(r),(0,s.logInfo)("user ".concat(r," stream-removed")),e._emitEvent(u.default.onUserVideoAvailable,{userId:r,available:!1}),e._emitEvent(u.default.onUserAudioAvailable,{userId:r,available:!1}),n.stop()})),this._client.on("mute-audio",(function(t){var n=t.userId;e._emitEvent(u.default.onUserAudioAvailable,{userId:n,available:!1})})),this._client.on("mute-video",(function(t){var n=t.userId;e._emitEvent(u.default.onUserVideoAvailable,{userId:n,available:!1})})),this._client.on("unmute-audio",(function(t){var n=t.userId;e._emitEvent(u.default.onUserAudioAvailable,{userId:n,available:!0})})),this._client.on("unmute-video",(function(t){var n=t.userId;(0,s.logInfo)("user ".concat(n," unmute-video")),e._emitEvent(u.default.onUserVideoAvailable,{userId:n,available:!0})})),this._client.on("stream-subscribed",(function(t){var n=t.stream.getUserId();e._emitEvent(u.default.onUserSubStreamAvailable,{userId:n,available:!0})})),this._client.on("audio-volume",(function(t){var n=[],r=0;t.result.forEach((function(e){var t=e.userId,i=e.audioVolume;n.push({userId:t,volume:i}),r+=i})),e._emitEvent(u.default.onUserVoiceVolume,{userVolumes:n,totalVolume:r})})))},e.prototype._initClient=function(e,t,n,o,a){return r(this,void 0,void 0,(function(){var r=this;return i(this,(function(i){return this._client=d.default.createClient(e),[2,new Promise((function(e,i){(0,s.logSuccess)("begin join room"),r._client.join({roomId:t&&""!==t?t:parseInt(n,10),role:21==o?"audience":"anchor",privateMapKey:a}).then((function(){(0,s.logSuccess)("join room success"),r._addListener(),e(),r._isHadJoined=!0,r._joinCallList.size>0&&(r._joinCallList.forEach((function(e,t){(0,s.logInfo)("after join room call ".concat(t," func")),e()})),r._joinCallList.clear())})).catch((function(e){(0,s.logError)("Join room failed: "+e),i()}))}))]}))}))},e}();t.default=h},802:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getVideoResolution=t.logError=t.logInfo=t.logSuccess=t.noSupportFunction=t.getFlutterArgs=void 0;var n="<TRTC Wrapper>";function r(){var e=new Date,t="hh:mm:ss:S",n={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};for(var r in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),n)new RegExp("("+r+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?n[r]:("00"+n[r]).substr((""+n[r]).length)));return t}function i(e){console.error("%c [".concat(r(),"] ").concat(n," ").concat(e),"color:red;font-size:18px")}t.getFlutterArgs=function(e,t){try{return JSON.parse(e)[t]}catch(n){i("_getFlutterArgs error _args: ".concat(e," ,key:").concat(t))}},t.noSupportFunction=function(e){console.warn("[".concat(r(),"] ").concat(n," web sdk not supper ").concat(e))},t.logSuccess=function(e){console.info("%c [".concat(r(),"] ").concat(n," ").concat(e),"color:green;font-size:18px;")},t.logInfo=function(e){console.info("%c [".concat(r(),"] ").concat(n," ").concat(e),"font-size:18px;color:blue;")},t.logError=i,t.getVideoResolution=function(e){var t="120*120 = 1;\n 160*160 = 3;\n 270*270 = 5;\n 480*480 = 7;\n 160*120 = 50;\n 240*180 = 52;\n 280*210 = 54;\n 320*240 = 56;\n 400*300 = 58;\n 480*360 = 60;\n 640*480 = 62;\n 960*720 = 64;\n 160*90 = 100;\n 256*144 = 102;\n 320*180 = 104;\n 480*270 = 106;\n 640*360 = 108;\n 960*540 = 110;\n 1280*720 = 112;\n 1920*1080 = 114;".split(";"),n="360*360";return t.forEach((function(t){if(t.indexOf("=")>=0&&t.endsWith("= ".concat(e)))return n=t.split("=")[0].trim().replace(/\n/g,"")})),n}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var r=n(315);return r.default})()));