@lingoace/lingo-trtc-rtc 0.0.18 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/trtc-lingo.js +36 -38
package/trtc-lingo.js CHANGED
@@ -1,11 +1,11 @@
1
- var f7=Object.create;var md=Object.defineProperty,p7=Object.defineProperties,$x=Object.getOwnPropertyDescriptor,m7=Object.getOwnPropertyDescriptors,v7=Object.getOwnPropertyNames,Yx=Object.getOwnPropertySymbols,g7=Object.getPrototypeOf,Zx=Object.prototype.hasOwnProperty,_7=Object.prototype.propertyIsEnumerable;var Zv=(ne,q,p)=>q in ne?md(ne,q,{enumerable:!0,configurable:!0,writable:!0,value:p}):ne[q]=p,Kr=(ne,q)=>{for(var p in q||(q={}))Zx.call(q,p)&&Zv(ne,p,q[p]);if(Yx)for(var p of Yx(q))_7.call(q,p)&&Zv(ne,p,q[p]);return ne},vd=(ne,q)=>p7(ne,m7(q));var eg=(ne,q)=>()=>(q||ne((q={exports:{}}).exports,q),q.exports);var y7=(ne,q,p,G)=>{if(q&&typeof q=="object"||typeof q=="function")for(let $ of v7(q))!Zx.call(ne,$)&&$!==p&&md(ne,$,{get:()=>q[$],enumerable:!(G=$x(q,$))||G.enumerable});return ne};var lr=(ne,q,p)=>(p=ne!=null?f7(g7(ne)):{},y7(q||!ne||!ne.__esModule?md(p,"default",{value:ne,enumerable:!0}):p,ne));var wn=(ne,q,p,G)=>{for(var $=G>1?void 0:G?$x(q,p):q,H=ne.length-1,Q;H>=0;H--)(Q=ne[H])&&($=(G?Q(q,p,$):Q($))||$);return G&&$&&md(q,p,$),$};var Ve=(ne,q,p)=>(Zv(ne,typeof q!="symbol"?q+"":q,p),p);var Er=eg((tg,ng)=>{(function(ne,q){typeof tg=="object"&&typeof ng!="undefined"?ng.exports=q():typeof define=="function"&&define.amd?define(q):(ne=typeof globalThis!="undefined"?globalThis:ne||self).TRTC=q()})(tg,function(){function ne(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,i)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ne(Object(n),!0).forEach(function(i){$e(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ne(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function p(){p=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=typeof Symbol=="function"?Symbol:{},r=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function a(P,U,k){return Object.defineProperty(P,U,{value:k,enumerable:!0,configurable:!0,writable:!0}),P[U]}try{a({},"")}catch(P){a=function(U,k,f){return U[k]=f}}function s(P,U,k,f){var y=U&&U.prototype instanceof h?U:h,A=Object.create(y.prototype),D=new _(f||[]);return A._invoke=function(j,K,J){var se="suspendedStart";return function(ie,Je){if(se==="executing")throw new Error("Generator is already running");if(se==="completed"){if(ie==="throw")throw Je;return R()}for(J.method=ie,J.arg=Je;;){var Ue=J.delegate;if(Ue){var Fe=L(Ue,J);if(Fe){if(Fe===u)continue;return Fe}}if(J.method==="next")J.sent=J._sent=J.arg;else if(J.method==="throw"){if(se==="suspendedStart")throw se="completed",J.arg;J.dispatchException(J.arg)}else J.method==="return"&&J.abrupt("return",J.arg);se="executing";var ht=l(j,K,J);if(ht.type==="normal"){if(se=J.done?"completed":"suspendedYield",ht.arg===u)continue;return{value:ht.arg,done:J.done}}ht.type==="throw"&&(se="completed",J.method="throw",J.arg=ht.arg)}}}(P,k,D),A}function l(P,U,k){try{return{type:"normal",arg:P.call(U,k)}}catch(f){return{type:"throw",arg:f}}}e.wrap=s;var u={};function h(){}function S(){}function I(){}var E={};a(E,r,function(){return this});var x=Object.getPrototypeOf,m=x&&x(x(b([])));m&&m!==t&&n.call(m,r)&&(E=m);var T=I.prototype=h.prototype=Object.create(E);function v(P){["next","throw","return"].forEach(function(U){a(P,U,function(k){return this._invoke(U,k)})})}function w(P,U){function k(y,A,D,j){var K=l(P[y],P,A);if(K.type!=="throw"){var J=K.arg,se=J.value;return se&&typeof se=="object"&&n.call(se,"__await")?U.resolve(se.__await).then(function(ie){k("next",ie,D,j)},function(ie){k("throw",ie,D,j)}):U.resolve(se).then(function(ie){J.value=ie,D(J)},function(ie){return k("throw",ie,D,j)})}j(K.arg)}var f;this._invoke=function(y,A){function D(){return new U(function(j,K){k(y,A,j,K)})}return f=f?f.then(D,D):D()}}function L(P,U){var k=P.iterator[U.method];if(k===void 0){if(U.delegate=null,U.method==="throw"){if(P.iterator.return&&(U.method="return",U.arg=void 0,L(P,U),U.method==="throw"))return u;U.method="throw",U.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var f=l(k,P.iterator,U.arg);if(f.type==="throw")return U.method="throw",U.arg=f.arg,U.delegate=null,u;var y=f.arg;return y?y.done?(U[P.resultName]=y.value,U.next=P.nextLoc,U.method!=="return"&&(U.method="next",U.arg=void 0),U.delegate=null,u):y:(U.method="throw",U.arg=new TypeError("iterator result is not an object"),U.delegate=null,u)}function N(P){var U={tryLoc:P[0]};1 in P&&(U.catchLoc=P[1]),2 in P&&(U.finallyLoc=P[2],U.afterLoc=P[3]),this.tryEntries.push(U)}function V(P){var U=P.completion||{};U.type="normal",delete U.arg,P.completion=U}function _(P){this.tryEntries=[{tryLoc:"root"}],P.forEach(N,this),this.reset(!0)}function b(P){if(P){var U=P[r];if(U)return U.call(P);if(typeof P.next=="function")return P;if(!isNaN(P.length)){var k=-1,f=function y(){for(;++k<P.length;)if(n.call(P,k))return y.value=P[k],y.done=!1,y;return y.value=void 0,y.done=!0,y};return f.next=f}}return{next:R}}function R(){return{value:void 0,done:!0}}return S.prototype=I,a(T,"constructor",I),a(I,"constructor",S),S.displayName=a(I,c,"GeneratorFunction"),e.isGeneratorFunction=function(P){var U=typeof P=="function"&&P.constructor;return!!U&&(U===S||(U.displayName||U.name)==="GeneratorFunction")},e.mark=function(P){return Object.setPrototypeOf?Object.setPrototypeOf(P,I):(P.__proto__=I,a(P,c,"GeneratorFunction")),P.prototype=Object.create(T),P},e.awrap=function(P){return{__await:P}},v(w.prototype),a(w.prototype,o,function(){return this}),e.AsyncIterator=w,e.async=function(P,U,k,f,y){y===void 0&&(y=Promise);var A=new w(s(P,U,k,f),y);return e.isGeneratorFunction(U)?A:A.next().then(function(D){return D.done?D.value:A.next()})},v(T),a(T,c,"Generator"),a(T,r,function(){return this}),a(T,"toString",function(){return"[object Generator]"}),e.keys=function(P){var U=[];for(var k in P)U.push(k);return U.reverse(),function f(){for(;U.length;){var y=U.pop();if(y in P)return f.value=y,f.done=!1,f}return f.done=!0,f}},e.values=b,_.prototype={constructor:_,reset:function(P){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(V),!P)for(var U in this)U.charAt(0)==="t"&&n.call(this,U)&&!isNaN(+U.slice(1))&&(this[U]=void 0)},stop:function(){this.done=!0;var P=this.tryEntries[0].completion;if(P.type==="throw")throw P.arg;return this.rval},dispatchException:function(P){if(this.done)throw P;var U=this;function k(K,J){return A.type="throw",A.arg=P,U.next=K,J&&(U.method="next",U.arg=void 0),!!J}for(var f=this.tryEntries.length-1;f>=0;--f){var y=this.tryEntries[f],A=y.completion;if(y.tryLoc==="root")return k("end");if(y.tryLoc<=this.prev){var D=n.call(y,"catchLoc"),j=n.call(y,"finallyLoc");if(D&&j){if(this.prev<y.catchLoc)return k(y.catchLoc,!0);if(this.prev<y.finallyLoc)return k(y.finallyLoc)}else if(D){if(this.prev<y.catchLoc)return k(y.catchLoc,!0)}else{if(!j)throw new Error("try statement without catch or finally");if(this.prev<y.finallyLoc)return k(y.finallyLoc)}}}},abrupt:function(P,U){for(var k=this.tryEntries.length-1;k>=0;--k){var f=this.tryEntries[k];if(f.tryLoc<=this.prev&&n.call(f,"finallyLoc")&&this.prev<f.finallyLoc){var y=f;break}}y&&(P==="break"||P==="continue")&&y.tryLoc<=U&&U<=y.finallyLoc&&(y=null);var A=y?y.completion:{};return A.type=P,A.arg=U,y?(this.method="next",this.next=y.finallyLoc,u):this.complete(A)},complete:function(P,U){if(P.type==="throw")throw P.arg;return P.type==="break"||P.type==="continue"?this.next=P.arg:P.type==="return"?(this.rval=this.arg=P.arg,this.method="return",this.next="end"):P.type==="normal"&&U&&(this.next=U),u},finish:function(P){for(var U=this.tryEntries.length-1;U>=0;--U){var k=this.tryEntries[U];if(k.finallyLoc===P)return this.complete(k.completion,k.afterLoc),V(k),u}},catch:function(P){for(var U=this.tryEntries.length-1;U>=0;--U){var k=this.tryEntries[U];if(k.tryLoc===P){var f=k.completion;if(f.type==="throw"){var y=f.arg;V(k)}return y}}throw new Error("illegal catch attempt")},delegateYield:function(P,U,k){return this.delegate={iterator:b(P),resultName:U,nextLoc:k},this.method==="next"&&(this.arg=void 0),u}},e}function G(e){return G=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},G(e)}function $(e,t,n,i,r,o,c){try{var a=e[o](c),s=a.value}catch(l){return void n(l)}a.done?t(s):Promise.resolve(s).then(i,r)}function H(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function c(s){$(o,i,r,c,a,"next",s)}function a(s){$(o,i,r,c,a,"throw",s)}c(void 0)})}}function Q(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Re(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function xe(e,t,n){return t&&Re(e.prototype,t),n&&Re(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function $e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Et(e,t){if(typeof t!="function"&&t!==null)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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&dr(e,t)}function Ye(e){return Ye=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ye(e)}function dr(e,t){return dr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},dr(e,t)}function Pc(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function Wo(e,t,n){return Wo=Pc()?Reflect.construct.bind():function(i,r,o){var c=[null];c.push.apply(c,r);var a=new(Function.bind.apply(i,c));return o&&dr(a,o.prototype),a},Wo.apply(null,arguments)}function zo(e){var t=typeof Map=="function"?new Map:void 0;return zo=function(n){if(n===null||(i=n,Function.toString.call(i).indexOf("[native code]")===-1))return n;var i;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(t!==void 0){if(t.has(n))return t.get(n);t.set(n,r)}function r(){return Wo(n,arguments,Ye(this).constructor)}return r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),dr(r,n)},zo(e)}function Jo(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}(e)}function Rr(e){var t=Pc();return function(){var n,i=Ye(e);if(t){var r=Ye(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return Jo(this,n)}}function Dc(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=Ye(e))!==null;);return e}function le(){return le=typeof Reflect!="undefined"&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=Dc(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},le.apply(this,arguments)}function Te(e,t){return function(n){if(Array.isArray(n))return n}(e)||function(n,i){var r=n==null?null:typeof Symbol!="undefined"&&n[Symbol.iterator]||n["@@iterator"];if(r!=null){var o,c,a=[],s=!0,l=!1;try{for(r=r.call(n);!(s=(o=r.next()).done)&&(a.push(o.value),!i||a.length!==i);s=!0);}catch(u){l=!0,c=u}finally{try{s||r.return==null||r.return()}finally{if(l)throw c}}return a}}(e,t)||je(e,t)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ var f7=Object.create;var fd=Object.defineProperty,p7=Object.defineProperties,$x=Object.getOwnPropertyDescriptor,m7=Object.getOwnPropertyDescriptors,v7=Object.getOwnPropertyNames,Yx=Object.getOwnPropertySymbols,g7=Object.getPrototypeOf,Zx=Object.prototype.hasOwnProperty,_7=Object.prototype.propertyIsEnumerable;var Zv=(ne,J,f)=>J in ne?fd(ne,J,{enumerable:!0,configurable:!0,writable:!0,value:f}):ne[J]=f,Kr=(ne,J)=>{for(var f in J||(J={}))Zx.call(J,f)&&Zv(ne,f,J[f]);if(Yx)for(var f of Yx(J))_7.call(J,f)&&Zv(ne,f,J[f]);return ne},pd=(ne,J)=>p7(ne,m7(J));var eg=(ne,J)=>()=>(J||ne((J={exports:{}}).exports,J),J.exports);var y7=(ne,J,f,G)=>{if(J&&typeof J=="object"||typeof J=="function")for(let $ of v7(J))!Zx.call(ne,$)&&$!==f&&fd(ne,$,{get:()=>J[$],enumerable:!(G=$x(J,$))||G.enumerable});return ne};var lr=(ne,J,f)=>(f=ne!=null?f7(g7(ne)):{},y7(J||!ne||!ne.__esModule?fd(f,"default",{value:ne,enumerable:!0}):f,ne));var wn=(ne,J,f,G)=>{for(var $=G>1?void 0:G?$x(J,f):J,H=ne.length-1,Q;H>=0;H--)(Q=ne[H])&&($=(G?Q(J,f,$):Q($))||$);return G&&$&&fd(J,f,$),$};var Ve=(ne,J,f)=>(Zv(ne,typeof J!="symbol"?J+"":J,f),f);var Er=eg((tg,ng)=>{(function(ne,J){typeof tg=="object"&&typeof ng!="undefined"?ng.exports=J():typeof define=="function"&&define.amd?define(J):(ne=typeof globalThis!="undefined"?globalThis:ne||self).TRTC=J()})(tg,function(){function ne(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,i)}return n}function J(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ne(Object(n),!0).forEach(function(i){Ye(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ne(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function f(){f=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=typeof Symbol=="function"?Symbol:{},r=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function a(A,U,S){return Object.defineProperty(A,U,{value:S,enumerable:!0,configurable:!0,writable:!0}),A[U]}try{a({},"")}catch(A){a=function(U,S,p){return U[S]=p}}function s(A,U,S,p){var _=U&&U.prototype instanceof h?U:h,P=Object.create(_.prototype),M=new T(p||[]);return P._invoke=function(B,X,q){var le="suspendedStart";return function(ce,Ze){if(le==="executing")throw new Error("Generator is already running");if(le==="completed"){if(ce==="throw")throw Ze;return D()}for(q.method=ce,q.arg=Ze;;){var Ue=q.delegate;if(Ue){var Fe=L(Ue,q);if(Fe){if(Fe===u)continue;return Fe}}if(q.method==="next")q.sent=q._sent=q.arg;else if(q.method==="throw"){if(le==="suspendedStart")throw le="completed",q.arg;q.dispatchException(q.arg)}else q.method==="return"&&q.abrupt("return",q.arg);le="executing";var ht=l(B,X,q);if(ht.type==="normal"){if(le=q.done?"completed":"suspendedYield",ht.arg===u)continue;return{value:ht.arg,done:q.done}}ht.type==="throw"&&(le="completed",q.method="throw",q.arg=ht.arg)}}}(A,S,M),P}function l(A,U,S){try{return{type:"normal",arg:A.call(U,S)}}catch(p){return{type:"throw",arg:p}}}e.wrap=s;var u={};function h(){}function b(){}function I(){}var R={};a(R,r,function(){return this});var x=Object.getPrototypeOf,m=x&&x(x(y([])));m&&m!==t&&n.call(m,r)&&(R=m);var k=I.prototype=h.prototype=Object.create(R);function v(A){["next","throw","return"].forEach(function(U){a(A,U,function(S){return this._invoke(U,S)})})}function w(A,U){function S(_,P,M,B){var X=l(A[_],A,P);if(X.type!=="throw"){var q=X.arg,le=q.value;return le&&typeof le=="object"&&n.call(le,"__await")?U.resolve(le.__await).then(function(ce){S("next",ce,M,B)},function(ce){S("throw",ce,M,B)}):U.resolve(le).then(function(ce){q.value=ce,M(q)},function(ce){return S("throw",ce,M,B)})}B(X.arg)}var p;this._invoke=function(_,P){function M(){return new U(function(B,X){S(_,P,B,X)})}return p=p?p.then(M,M):M()}}function L(A,U){var S=A.iterator[U.method];if(S===void 0){if(U.delegate=null,U.method==="throw"){if(A.iterator.return&&(U.method="return",U.arg=void 0,L(A,U),U.method==="throw"))return u;U.method="throw",U.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var p=l(S,A.iterator,U.arg);if(p.type==="throw")return U.method="throw",U.arg=p.arg,U.delegate=null,u;var _=p.arg;return _?_.done?(U[A.resultName]=_.value,U.next=A.nextLoc,U.method!=="return"&&(U.method="next",U.arg=void 0),U.delegate=null,u):_:(U.method="throw",U.arg=new TypeError("iterator result is not an object"),U.delegate=null,u)}function E(A){var U={tryLoc:A[0]};1 in A&&(U.catchLoc=A[1]),2 in A&&(U.finallyLoc=A[2],U.afterLoc=A[3]),this.tryEntries.push(U)}function N(A){var U=A.completion||{};U.type="normal",delete U.arg,A.completion=U}function T(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(E,this),this.reset(!0)}function y(A){if(A){var U=A[r];if(U)return U.call(A);if(typeof A.next=="function")return A;if(!isNaN(A.length)){var S=-1,p=function _(){for(;++S<A.length;)if(n.call(A,S))return _.value=A[S],_.done=!1,_;return _.value=void 0,_.done=!0,_};return p.next=p}}return{next:D}}function D(){return{value:void 0,done:!0}}return b.prototype=I,a(k,"constructor",I),a(I,"constructor",b),b.displayName=a(I,c,"GeneratorFunction"),e.isGeneratorFunction=function(A){var U=typeof A=="function"&&A.constructor;return!!U&&(U===b||(U.displayName||U.name)==="GeneratorFunction")},e.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,I):(A.__proto__=I,a(A,c,"GeneratorFunction")),A.prototype=Object.create(k),A},e.awrap=function(A){return{__await:A}},v(w.prototype),a(w.prototype,o,function(){return this}),e.AsyncIterator=w,e.async=function(A,U,S,p,_){_===void 0&&(_=Promise);var P=new w(s(A,U,S,p),_);return e.isGeneratorFunction(U)?P:P.next().then(function(M){return M.done?M.value:P.next()})},v(k),a(k,c,"Generator"),a(k,r,function(){return this}),a(k,"toString",function(){return"[object Generator]"}),e.keys=function(A){var U=[];for(var S in A)U.push(S);return U.reverse(),function p(){for(;U.length;){var _=U.pop();if(_ in A)return p.value=_,p.done=!1,p}return p.done=!0,p}},e.values=y,T.prototype={constructor:T,reset:function(A){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(N),!A)for(var U in this)U.charAt(0)==="t"&&n.call(this,U)&&!isNaN(+U.slice(1))&&(this[U]=void 0)},stop:function(){this.done=!0;var A=this.tryEntries[0].completion;if(A.type==="throw")throw A.arg;return this.rval},dispatchException:function(A){if(this.done)throw A;var U=this;function S(X,q){return P.type="throw",P.arg=A,U.next=X,q&&(U.method="next",U.arg=void 0),!!q}for(var p=this.tryEntries.length-1;p>=0;--p){var _=this.tryEntries[p],P=_.completion;if(_.tryLoc==="root")return S("end");if(_.tryLoc<=this.prev){var M=n.call(_,"catchLoc"),B=n.call(_,"finallyLoc");if(M&&B){if(this.prev<_.catchLoc)return S(_.catchLoc,!0);if(this.prev<_.finallyLoc)return S(_.finallyLoc)}else if(M){if(this.prev<_.catchLoc)return S(_.catchLoc,!0)}else{if(!B)throw new Error("try statement without catch or finally");if(this.prev<_.finallyLoc)return S(_.finallyLoc)}}}},abrupt:function(A,U){for(var S=this.tryEntries.length-1;S>=0;--S){var p=this.tryEntries[S];if(p.tryLoc<=this.prev&&n.call(p,"finallyLoc")&&this.prev<p.finallyLoc){var _=p;break}}_&&(A==="break"||A==="continue")&&_.tryLoc<=U&&U<=_.finallyLoc&&(_=null);var P=_?_.completion:{};return P.type=A,P.arg=U,_?(this.method="next",this.next=_.finallyLoc,u):this.complete(P)},complete:function(A,U){if(A.type==="throw")throw A.arg;return A.type==="break"||A.type==="continue"?this.next=A.arg:A.type==="return"?(this.rval=this.arg=A.arg,this.method="return",this.next="end"):A.type==="normal"&&U&&(this.next=U),u},finish:function(A){for(var U=this.tryEntries.length-1;U>=0;--U){var S=this.tryEntries[U];if(S.finallyLoc===A)return this.complete(S.completion,S.afterLoc),N(S),u}},catch:function(A){for(var U=this.tryEntries.length-1;U>=0;--U){var S=this.tryEntries[U];if(S.tryLoc===A){var p=S.completion;if(p.type==="throw"){var _=p.arg;N(S)}return _}}throw new Error("illegal catch attempt")},delegateYield:function(A,U,S){return this.delegate={iterator:y(A),resultName:U,nextLoc:S},this.method==="next"&&(this.arg=void 0),u}},e}function G(e){return G=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},G(e)}function $(e,t,n,i,r,o,c){try{var a=e[o](c),s=a.value}catch(l){return void n(l)}a.done?t(s):Promise.resolve(s).then(i,r)}function H(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function c(s){$(o,i,r,c,a,"next",s)}function a(s){$(o,i,r,c,a,"throw",s)}c(void 0)})}}function Q(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function we(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function xe(e,t,n){return t&&we(e.prototype,t),n&&we(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ye(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Et(e,t){if(typeof t!="function"&&t!==null)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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&dr(e,t)}function Qe(e){return Qe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Qe(e)}function dr(e,t){return dr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},dr(e,t)}function Ac(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function zo(e,t,n){return zo=Ac()?Reflect.construct.bind():function(i,r,o){var c=[null];c.push.apply(c,r);var a=new(Function.bind.apply(i,c));return o&&dr(a,o.prototype),a},zo.apply(null,arguments)}function Wo(e){var t=typeof Map=="function"?new Map:void 0;return Wo=function(n){if(n===null||(i=n,Function.toString.call(i).indexOf("[native code]")===-1))return n;var i;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(t!==void 0){if(t.has(n))return t.get(n);t.set(n,r)}function r(){return zo(n,arguments,Qe(this).constructor)}return r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),dr(r,n)},Wo(e)}function Jo(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}(e)}function Rr(e){var t=Ac();return function(){var n,i=Qe(e);if(t){var r=Qe(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return Jo(this,n)}}function Pc(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=Qe(e))!==null;);return e}function ue(){return ue=typeof Reflect!="undefined"&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=Pc(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},ue.apply(this,arguments)}function Te(e,t){return function(n){if(Array.isArray(n))return n}(e)||function(n,i){var r=n==null?null:typeof Symbol!="undefined"&&n[Symbol.iterator]||n["@@iterator"];if(r!=null){var o,c,a=[],s=!0,l=!1;try{for(r=r.call(n);!(s=(o=r.next()).done)&&(a.push(o.value),!i||a.length!==i);s=!0);}catch(u){l=!0,c=u}finally{try{s||r.return==null||r.return()}finally{if(l)throw c}}return a}}(e,t)||je(e,t)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Se(e){return function(t){if(Array.isArray(t))return He(t)}(e)||function(t){if(typeof Symbol!="undefined"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}(e)||je(e)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
3
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function je(e,t){if(e){if(typeof e=="string")return He(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?He(e,t):void 0}}function He(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function oe(e,t){var n=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=je(e))||t&&e&&typeof e.length=="number"){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(s){throw s},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
4
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o,c=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var s=n.next();return c=s.done,s},e:function(s){a=!0,o=s},f:function(){try{c||n.return==null||n.return()}finally{if(a)throw o}}}}function X(e,t,n,i,r){var o={};return Object.keys(i).forEach(function(c){o[c]=i[c]}),o.enumerable=!!o.enumerable,o.configurable=!!o.configurable,("value"in o||o.initializer)&&(o.writable=!0),o=n.slice().reverse().reduce(function(c,a){return a(e,t,c)||c},o),r&&o.initializer!==void 0&&(o.value=o.initializer?o.initializer.call(r):void 0,o.initializer=void 0),o.initializer===void 0&&(Object.defineProperty(e,t,o),o=null),o}var ce=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},W=function(e){return e&&e.Math==Math&&e},re=W(typeof globalThis=="object"&&globalThis)||W(typeof window=="object"&&window)||W(typeof self=="object"&&self)||W(typeof ce=="object"&&ce)||function(){return this}()||Function("return this")(),be={},ue=function(e){try{return!!e()}catch(t){return!0}},ye=!ue(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Me=!ue(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),Jt=Me,Zt=Function.prototype.call,Ke=Jt?Zt.bind(Zt):function(){return Zt.apply(Zt,arguments)},qt={},ft={}.propertyIsEnumerable,Jn=Object.getOwnPropertyDescriptor,hr=Jn&&!ft.call({1:2},1);qt.f=hr?function(e){var t=Jn(this,e);return!!t&&t.enumerable}:ft;var Ht,Rn,Ze=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Gt=Me,qn=Function.prototype,he=qn.call,de=Gt&&qn.bind.bind(he,he),Ne=function(e){return Gt?de(e):function(){return he.apply(e,arguments)}},ze=Ne,De=ze({}.toString),ut=ze("".slice),rt=function(e){return ut(De(e),8,-1)},Ut=rt,en=Ne,pe=function(e){if(Ut(e)==="Function")return en(e)},Ot=ue,Kt=rt,fr=Object,Di=pe("".split),yn=Ot(function(){return!fr("z").propertyIsEnumerable(0)})?function(e){return Kt(e)=="String"?Di(e,""):fr(e)}:fr,Rt=function(e){return e==null},Rd=Rt,Lt=TypeError,pt=function(e){if(Rd(e))throw Lt("Can't call method on "+e);return e},Oc=yn,Lc=pt,bn=function(e){return Oc(Lc(e))},ba=typeof document=="object"&&document.all,Oi={all:ba,IS_HTMLDDA:ba===void 0&&ba!==void 0},Mc=Oi.all,it=Oi.IS_HTMLDDA?function(e){return typeof e=="function"||e===Mc}:function(e){return typeof e=="function"},Sa=it,Nc=Oi.all,at=Oi.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:Sa(e)||e===Nc}:function(e){return typeof e=="object"?e!==null:Sa(e)},ka=re,qo=it,Uc=function(e){return qo(e)?e:void 0},An=function(e,t){return arguments.length<2?Uc(ka[e]):ka[e]&&ka[e][t]},Sn=pe({}.isPrototypeOf),Kn=An("navigator","userAgent")||"",Vc=re,Ta=Kn,Xr=Vc.process,Ia=Vc.Deno,Ko=Xr&&Xr.versions||Ia&&Ia.version,Xo=Ko&&Ko.v8;Xo&&(Rn=(Ht=Xo.split("."))[0]>0&&Ht[0]<4?1:+(Ht[0]+Ht[1])),!Rn&&Ta&&(!(Ht=Ta.match(/Edge\/(\d+)/))||Ht[1]>=74)&&(Ht=Ta.match(/Chrome\/(\d+)/))&&(Rn=+Ht[1]);var pr=Rn,mr=pr,Li=ue,Qo=!!Object.getOwnPropertySymbols&&!Li(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&mr&&mr<41}),Yo=Qo&&!Symbol.sham&&typeof Symbol.iterator=="symbol",$o=An,jc=it,Ar=Sn,Zo=Object,Mi=Yo?function(e){return typeof e=="symbol"}:function(e){var t=$o("Symbol");return jc(t)&&Ar(t.prototype,Zo(e))},xa=String,Xn=function(e){try{return xa(e)}catch(t){return"Object"}},Ad=it,Qr=Xn,Qn=TypeError,Vt=function(e){if(Ad(e))return e;throw Qn(Qr(e)+" is not a function")},Bc=Vt,xt=Rt,Xt=function(e,t){var n=e[t];return xt(n)?void 0:Bc(n)},Ni=Ke,es=it,Yr=at,ts=TypeError,Pr={exports:{}},$r=re,wa=Object.defineProperty,Ca=function(e,t){try{wa($r,e,{value:t,configurable:!0,writable:!0})}catch(n){$r[e]=t}return t},ns=Ca,Ea="__core-js_shared__",Ra=re[Ea]||ns(Ea,{}),pn=Ra;(Pr.exports=function(e,t){return pn[e]||(pn[e]=t!==void 0?t:{})})("versions",[]).push({version:"3.25.5",mode:"global",copyright:"\xA9 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.25.5/LICENSE",source:"https://github.com/zloirock/core-js"});var Pn=pt,Ui=Object,Mt=function(e){return Ui(Pn(e))},rs=Mt,Fc=pe({}.hasOwnProperty),kt=Object.hasOwn||function(e,t){return Fc(rs(e),t)},Dn=pe,Hc=0,Aa=Math.random(),On=Dn(1 .toString),Vi=function(e){return"Symbol("+(e===void 0?"":e)+")_"+On(++Hc+Aa,36)},is=re,Pd=Pr.exports,Gc=kt,Wc=Vi,as=Qo,os=Yo,Zr=Pd("wks"),At=is.Symbol,ss=At&&At.for,zc=os?At:At&&At.withoutSetter||Wc,tt=function(e){if(!Gc(Zr,e)||!as&&typeof Zr[e]!="string"){var t="Symbol."+e;as&&Gc(At,e)?Zr[e]=At[e]:Zr[e]=os&&ss?ss(t):zc(t)}return Zr[e]},Jc=Ke,cs=at,qc=Mi,Kc=Xt,Xc=function(e,t){var n,i;if(t==="string"&&es(n=e.toString)&&!Yr(i=Ni(n,e))||es(n=e.valueOf)&&!Yr(i=Ni(n,e))||t!=="string"&&es(n=e.toString)&&!Yr(i=Ni(n,e)))return i;throw ts("Can't convert object to primitive value")},Pa=TypeError,Qc=tt("toPrimitive"),ji=function(e,t){if(!cs(e)||qc(e))return e;var n,i=Kc(e,Qc);if(i){if(t===void 0&&(t="default"),n=Jc(i,e,t),!cs(n)||qc(n))return n;throw Pa("Can't convert object to primitive value")}return t===void 0&&(t="number"),Xc(e,t)},Bi=ji,Dd=Mi,Da=function(e){var t=Bi(e,"string");return Dd(t)?t:t+""},Yc=at,us=re.document,ls=Yc(us)&&Yc(us.createElement),vr=function(e){return ls?us.createElement(e):{}},Od=vr,$c=!ye&&!ue(function(){return Object.defineProperty(Od("div"),"a",{get:function(){return 7}}).a!=7}),Ld=ye,Md=Ke,ds=qt,Zc=Ze,eu=bn,Fi=Da,kn=kt,Nd=$c,tu=Object.getOwnPropertyDescriptor;be.f=Ld?tu:function(e,t){if(e=eu(e),t=Fi(t),Nd)try{return tu(e,t)}catch(n){}if(kn(e,t))return Zc(!Md(ds.f,e,t),e[t])};var Pt={},hs=ye&&ue(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),fs=at,ps=String,ei=TypeError,Tt=function(e){if(fs(e))return e;throw ei(ps(e)+" is not an object")},ms=ye,Ud=$c,Vd=hs,gr=Tt,vs=Da,nu=TypeError,gs=Object.defineProperty,jd=Object.getOwnPropertyDescriptor,Oa="enumerable",ru="configurable",Bd="writable";Pt.f=ms?Vd?function(e,t,n){if(gr(e),t=vs(t),gr(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Bd in n&&!n.writable){var i=jd(e,t);i&&i.writable&&(e[t]=n.value,n={configurable:ru in n?n.configurable:i.configurable,enumerable:Oa in n?n.enumerable:i.enumerable,writable:!1})}return gs(e,t,n)}:gs:function(e,t,n){if(gr(e),t=vs(t),gr(n),Ud)try{return gs(e,t,n)}catch(i){}if("get"in n||"set"in n)throw nu("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var iu=Pt,Fd=Ze,Ln=ye?function(e,t,n){return iu.f(e,t,Fd(1,n))}:function(e,t,n){return e[t]=n,e},Hi={exports:{}},La=ye,Hd=kt,au=Function.prototype,Gd=La&&Object.getOwnPropertyDescriptor,Ma=Hd(au,"name"),Yn={EXISTS:Ma,PROPER:Ma&&function(){}.name==="something",CONFIGURABLE:Ma&&(!La||La&&Gd(au,"name").configurable)},Wd=it,ti=Ra,zd=pe(Function.toString);Wd(ti.inspectSource)||(ti.inspectSource=function(e){return zd(e)});var Na,ni,Gi,d=ti.inspectSource,g=it,C=re.WeakMap,O=g(C)&&/native code/.test(String(C)),B=Pr.exports,M=Vi,F=B("keys"),z=function(e){return F[e]||(F[e]=M(e))},ee={},fe=O,me=re,we=at,Ae=Ln,ve=kt,Oe=Ra,Be=z,ot=ee,lt="Object already initialized",jt=me.TypeError,mn=me.WeakMap;if(fe||Oe.state){var bt=Oe.state||(Oe.state=new mn);bt.get=bt.get,bt.has=bt.has,bt.set=bt.set,Na=function(e,t){if(bt.has(e))throw jt(lt);return t.facade=e,bt.set(e,t),t},ni=function(e){return bt.get(e)||{}},Gi=function(e){return bt.has(e)}}else{var qe=Be("state");ot[qe]=!0,Na=function(e,t){if(ve(e,qe))throw jt(lt);return t.facade=e,Ae(e,qe,t),t},ni=function(e){return ve(e,qe)?e[qe]:{}},Gi=function(e){return ve(e,qe)}}var Xe={set:Na,get:ni,has:Gi,enforce:function(e){return Gi(e)?ni(e):Na(e,{})},getterFor:function(e){return function(t){var n;if(!we(t)||(n=ni(t)).type!==e)throw jt("Incompatible receiver, "+e+" required");return n}}},_r=ue,Ua=it,Mn=kt,Va=ye,ri=Yn.CONFIGURABLE,ja=d,_s=Xe.enforce,yw=Xe.get,ou=Object.defineProperty,bw=Va&&!_r(function(){return ou(function(){},"length",{value:8}).length!==8}),Sw=String(String).split("String"),kw=Hi.exports=function(e,t,n){String(t).slice(0,7)==="Symbol("&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!Mn(e,"name")||ri&&e.name!==t)&&(Va?ou(e,"name",{value:t,configurable:!0}):e.name=t),bw&&n&&Mn(n,"arity")&&e.length!==n.arity&&ou(e,"length",{value:n.arity});try{n&&Mn(n,"constructor")&&n.constructor?Va&&ou(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(r){}var i=_s(e);return Mn(i,"source")||(i.source=Sw.join(typeof t=="string"?t:"")),e};Function.prototype.toString=kw(function(){return Ua(this)&&yw(this).source||ja(this)},"toString");var Tw=it,Iw=Pt,xw=Hi.exports,ww=Ca,Qt=function(e,t,n,i){i||(i={});var r=i.enumerable,o=i.name!==void 0?i.name:t;if(Tw(n)&&xw(n,o,i),i.global)r?e[t]=n:ww(t,n);else{try{i.unsafe?e[t]&&(r=!0):delete e[t]}catch(c){}r?e[t]=n:Iw.f(e,t,{value:n,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return e},ii={},Cw=Math.ceil,Ew=Math.floor,Rw=Math.trunc||function(e){var t=+e;return(t>0?Ew:Cw)(t)},$n=function(e){var t=+e;return t!=t||t===0?0:Rw(t)},Aw=$n,Pw=Math.max,Dw=Math.min,ai=function(e,t){var n=Aw(e);return n<0?Pw(n+t,0):Dw(n,t)},Ow=$n,Lw=Math.min,yr=function(e){return e>0?Lw(Ow(e),9007199254740991):0},Mw=yr,nn=function(e){return Mw(e.length)},Nw=bn,Uw=ai,Vw=nn,pg=function(e){return function(t,n,i){var r,o=Nw(t),c=Vw(o),a=Uw(i,c);if(e&&n!=n){for(;c>a;)if((r=o[a++])!=r)return!0}else for(;c>a;a++)if((e||a in o)&&o[a]===n)return e||a||0;return!e&&-1}},ys={includes:pg(!0),indexOf:pg(!1)},Jd=kt,jw=bn,Bw=ys.indexOf,Fw=ee,mg=pe([].push),vg=function(e,t){var n,i=jw(e),r=0,o=[];for(n in i)!Jd(Fw,n)&&Jd(i,n)&&mg(o,n);for(;t.length>r;)Jd(i,n=t[r++])&&(~Bw(o,n)||mg(o,n));return o},qd=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Hw=vg,Gw=qd.concat("length","prototype");ii.f=Object.getOwnPropertyNames||function(e){return Hw(e,Gw)};var Kd={};Kd.f=Object.getOwnPropertySymbols;var Ww=An,zw=ii,Jw=Kd,qw=Tt,Kw=pe([].concat),Xw=Ww("Reflect","ownKeys")||function(e){var t=zw.f(qw(e)),n=Jw.f;return n?Kw(t,n(e)):t},gg=kt,Qw=Xw,Yw=be,$w=Pt,Zw=ue,eC=it,tC=/#|\.prototype\./,bs=function(e,t){var n=rC[nC(e)];return n==aC||n!=iC&&(eC(t)?Zw(t):!!t)},nC=bs.normalize=function(e){return String(e).replace(tC,".").toLowerCase()},rC=bs.data={},iC=bs.NATIVE="N",aC=bs.POLYFILL="P",Ss=bs,Xd=re,oC=be.f,sC=Ln,cC=Qt,uC=Ca,lC=function(e,t,n){for(var i=Qw(t),r=$w.f,o=Yw.f,c=0;c<i.length;c++){var a=i[c];gg(e,a)||n&&gg(n,a)||r(e,a,o(t,a))}},dC=Ss,Le=function(e,t){var n,i,r,o,c,a=e.target,s=e.global,l=e.stat;if(n=s?Xd:l?Xd[a]||uC(a,{}):(Xd[a]||{}).prototype)for(i in t){if(o=t[i],r=e.dontCallGetSet?(c=oC(n,i))&&c.value:n[i],!dC(s?i:a+(l?".":"#")+i,e.forced)&&r!==void 0){if(typeof o==typeof r)continue;lC(o,r)}(e.sham||r&&r.sham)&&sC(o,"sham",!0),cC(n,i,o,e)}},hC=Le,fC=ue,pC=bn,_g=be.f,yg=ye,mC=fC(function(){_g(1)});function Qd(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}hC({target:"Object",stat:!0,forced:!yg||mC,sham:!yg},{getOwnPropertyDescriptor:function(e,t){return _g(pC(e),t)}}),function(e,t){e.exports=function(){function n(i,r,o){function c(l,u){if(!r[l]){if(!i[l]){if(!u&&Qd)return Qd(l);if(a)return a(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var S=r[l]={exports:{}};i[l][0].call(S.exports,function(I){return c(i[l][1][I]||I)},S,S.exports,n,i,r,o)}return r[l].exports}for(var a=Qd,s=0;s<o.length;s++)c(o[s]);return c}return n}()({1:[function(n,i,r){var o=(0,n("./adapter_factory.js").adapterFactory)({window:typeof window=="undefined"?void 0:window});i.exports=o},{"./adapter_factory.js":2}],2:[function(n,i,r){function o(x){return o=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},o(x)}Object.defineProperty(r,"__esModule",{value:!0}),r.adapterFactory=E;var c=I(n("./utils")),a=I(n("./chrome/chrome_shim")),s=I(n("./firefox/firefox_shim")),l=I(n("./safari/safari_shim")),u=I(n("./common_shim")),h=I(n("sdp"));function S(x){if(typeof WeakMap!="function")return null;var m=new WeakMap,T=new WeakMap;return(S=function(v){return v?T:m})(x)}function I(x,m){if(!m&&x&&x.__esModule)return x;if(x===null||o(x)!=="object"&&typeof x!="function")return{default:x};var T=S(m);if(T&&T.has(x))return T.get(x);var v={},w=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var L in x)if(L!=="default"&&Object.prototype.hasOwnProperty.call(x,L)){var N=w?Object.getOwnPropertyDescriptor(x,L):null;N&&(N.get||N.set)?Object.defineProperty(v,L,N):v[L]=x[L]}return v.default=x,T&&T.set(x,v),v}function E(){var x=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).window,m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},T=c.log,v=c.detectBrowser(x),w={browserDetails:v,commonShim:u,extractVersion:c.extractVersion,disableLog:c.disableLog,disableWarnings:c.disableWarnings,sdp:h};switch(v.browser){case"chrome":if(!a||!a.shimPeerConnection||!m.shimChrome)return T("Chrome shim is not included in this adapter release."),w;if(v.version===null)return T("Chrome shim can not determine version, not shimming."),w;T("adapter.js shimming chrome."),w.browserShim=a,u.shimAddIceCandidateNullOrEmpty(x,v),u.shimParameterlessSetLocalDescription(x,v),a.shimGetUserMedia(x,v),a.shimMediaStream(x,v),a.shimPeerConnection(x,v),a.shimOnTrack(x,v),a.shimAddTrackRemoveTrack(x,v),a.shimGetSendersWithDtmf(x,v),a.shimGetStats(x,v),a.shimSenderReceiverGetStats(x,v),a.fixNegotiationNeeded(x,v),u.shimRTCIceCandidate(x,v),u.shimRTCIceCandidateRelayProtocol(x,v),u.shimConnectionState(x,v),u.shimMaxMessageSize(x,v),u.shimSendThrowTypeError(x,v),u.removeExtmapAllowMixed(x,v);break;case"firefox":if(!s||!s.shimPeerConnection||!m.shimFirefox)return T("Firefox shim is not included in this adapter release."),w;T("adapter.js shimming firefox."),w.browserShim=s,u.shimAddIceCandidateNullOrEmpty(x,v),u.shimParameterlessSetLocalDescription(x,v),s.shimGetUserMedia(x,v),s.shimPeerConnection(x,v),s.shimOnTrack(x,v),s.shimRemoveStream(x,v),s.shimSenderGetStats(x,v),s.shimReceiverGetStats(x,v),s.shimRTCDataChannel(x,v),s.shimAddTransceiver(x,v),s.shimGetParameters(x,v),s.shimCreateOffer(x,v),s.shimCreateAnswer(x,v),u.shimRTCIceCandidate(x,v),u.shimConnectionState(x,v),u.shimMaxMessageSize(x,v),u.shimSendThrowTypeError(x,v);break;case"safari":if(!l||!m.shimSafari)return T("Safari shim is not included in this adapter release."),w;T("adapter.js shimming safari."),w.browserShim=l,u.shimAddIceCandidateNullOrEmpty(x,v),u.shimParameterlessSetLocalDescription(x,v),l.shimRTCIceServerUrls(x,v),l.shimCreateOfferLegacy(x,v),l.shimCallbacksAPI(x,v),l.shimLocalStreamsAPI(x,v),l.shimRemoteStreamsAPI(x,v),l.shimTrackEventTransceiver(x,v),l.shimGetUserMedia(x,v),l.shimAudioContext(x,v),u.shimRTCIceCandidate(x,v),u.shimRTCIceCandidateRelayProtocol(x,v),u.shimMaxMessageSize(x,v),u.shimSendThrowTypeError(x,v),u.removeExtmapAllowMixed(x,v);break;default:T("Unsupported browser!")}return w}},{"./chrome/chrome_shim":3,"./common_shim":6,"./firefox/firefox_shim":7,"./safari/safari_shim":10,"./utils":11,sdp:12}],3:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fixNegotiationNeeded=V,r.shimAddTrackRemoveTrack=L,r.shimAddTrackRemoveTrackWithNative=w,Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimGetSendersWithDtmf=m,r.shimGetStats=T,Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return c.shimGetUserMedia}}),r.shimMediaStream=E,r.shimOnTrack=x,r.shimPeerConnection=N,r.shimSenderReceiverGetStats=v;var o=l(n("../utils.js")),c=n("./getusermedia"),a=n("./getdisplaymedia");function s(_){if(typeof WeakMap!="function")return null;var b=new WeakMap,R=new WeakMap;return(s=function(P){return P?R:b})(_)}function l(_,b){if(!b&&_&&_.__esModule)return _;if(_===null||I(_)!=="object"&&typeof _!="function")return{default:_};var R=s(b);if(R&&R.has(_))return R.get(_);var P={},U=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var k in _)if(k!=="default"&&Object.prototype.hasOwnProperty.call(_,k)){var f=U?Object.getOwnPropertyDescriptor(_,k):null;f&&(f.get||f.set)?Object.defineProperty(P,k,f):P[k]=_[k]}return P.default=_,R&&R.set(_,P),P}function u(_,b,R){return(b=h(b))in _?Object.defineProperty(_,b,{value:R,enumerable:!0,configurable:!0,writable:!0}):_[b]=R,_}function h(_){var b=S(_,"string");return I(b)==="symbol"?b:String(b)}function S(_,b){if(I(_)!=="object"||_===null)return _;var R=_[Symbol.toPrimitive];if(R!==void 0){var P=R.call(_,b||"default");if(I(P)!=="object")return P;throw new TypeError("@@toPrimitive must return a primitive value.")}return(b==="string"?String:Number)(_)}function I(_){return I=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(b){return typeof b}:function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},I(_)}function E(_){_.MediaStream=_.MediaStream||_.webkitMediaStream}function x(_){if(I(_)==="object"&&_.RTCPeerConnection&&!("ontrack"in _.RTCPeerConnection.prototype)){Object.defineProperty(_.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(R){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=R)},enumerable:!0,configurable:!0});var b=_.RTCPeerConnection.prototype.setRemoteDescription;_.RTCPeerConnection.prototype.setRemoteDescription=function(){var R=this;return this._ontrackpoly||(this._ontrackpoly=function(P){P.stream.addEventListener("addtrack",function(U){var k;k=_.RTCPeerConnection.prototype.getReceivers?R.getReceivers().find(function(y){return y.track&&y.track.id===U.track.id}):{track:U.track};var f=new Event("track");f.track=U.track,f.receiver=k,f.transceiver={receiver:k},f.streams=[P.stream],R.dispatchEvent(f)}),P.stream.getTracks().forEach(function(U){var k;k=_.RTCPeerConnection.prototype.getReceivers?R.getReceivers().find(function(y){return y.track&&y.track.id===U.id}):{track:U};var f=new Event("track");f.track=U,f.receiver=k,f.transceiver={receiver:k},f.streams=[P.stream],R.dispatchEvent(f)})},this.addEventListener("addstream",this._ontrackpoly)),b.apply(this,arguments)}}else o.wrapPeerConnectionEvent(_,"track",function(R){return R.transceiver||Object.defineProperty(R,"transceiver",{value:{receiver:R.receiver}}),R})}function m(_){if(I(_)==="object"&&_.RTCPeerConnection&&!("getSenders"in _.RTCPeerConnection.prototype)&&"createDTMFSender"in _.RTCPeerConnection.prototype){var b=function(y,A){return{track:A,get dtmf(){return this._dtmf===void 0&&(A.kind==="audio"?this._dtmf=y.createDTMFSender(A):this._dtmf=null),this._dtmf},_pc:y}};if(!_.RTCPeerConnection.prototype.getSenders){_.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var R=_.RTCPeerConnection.prototype.addTrack;_.RTCPeerConnection.prototype.addTrack=function(y,A){var D=R.apply(this,arguments);return D||(D=b(this,y),this._senders.push(D)),D};var P=_.RTCPeerConnection.prototype.removeTrack;_.RTCPeerConnection.prototype.removeTrack=function(y){P.apply(this,arguments);var A=this._senders.indexOf(y);A!==-1&&this._senders.splice(A,1)}}var U=_.RTCPeerConnection.prototype.addStream;_.RTCPeerConnection.prototype.addStream=function(y){var A=this;this._senders=this._senders||[],U.apply(this,[y]),y.getTracks().forEach(function(D){A._senders.push(b(A,D))})};var k=_.RTCPeerConnection.prototype.removeStream;_.RTCPeerConnection.prototype.removeStream=function(y){var A=this;this._senders=this._senders||[],k.apply(this,[y]),y.getTracks().forEach(function(D){var j=A._senders.find(function(K){return K.track===D});j&&A._senders.splice(A._senders.indexOf(j),1)})}}else if(I(_)==="object"&&_.RTCPeerConnection&&"getSenders"in _.RTCPeerConnection.prototype&&"createDTMFSender"in _.RTCPeerConnection.prototype&&_.RTCRtpSender&&!("dtmf"in _.RTCRtpSender.prototype)){var f=_.RTCPeerConnection.prototype.getSenders;_.RTCPeerConnection.prototype.getSenders=function(){var y=this,A=f.apply(this,[]);return A.forEach(function(D){return D._pc=y}),A},Object.defineProperty(_.RTCRtpSender.prototype,"dtmf",{get:function(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function T(_){if(_.RTCPeerConnection){var b=_.RTCPeerConnection.prototype.getStats;_.RTCPeerConnection.prototype.getStats=function(){var R=this,P=Array.prototype.slice.call(arguments),U=P[0],k=P[1],f=P[2];if(arguments.length>0&&typeof U=="function")return b.apply(this,arguments);if(b.length===0&&(arguments.length===0||typeof U!="function"))return b.apply(this,[]);var y=function(j){var K={};return j.result().forEach(function(J){var se={id:J.id,timestamp:J.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[J.type]||J.type};J.names().forEach(function(ie){se[ie]=J.stat(ie)}),K[se.id]=se}),K},A=function(j){return new Map(Object.keys(j).map(function(K){return[K,j[K]]}))};if(arguments.length>=2){var D=function(j){k(A(y(j)))};return b.apply(this,[D,U])}return new Promise(function(j,K){b.apply(R,[function(J){j(A(y(J)))},K])}).then(k,f)}}}function v(_){if(I(_)==="object"&&_.RTCPeerConnection&&_.RTCRtpSender&&_.RTCRtpReceiver){if(!("getStats"in _.RTCRtpSender.prototype)){var b=_.RTCPeerConnection.prototype.getSenders;b&&(_.RTCPeerConnection.prototype.getSenders=function(){var k=this,f=b.apply(this,[]);return f.forEach(function(y){return y._pc=k}),f});var R=_.RTCPeerConnection.prototype.addTrack;R&&(_.RTCPeerConnection.prototype.addTrack=function(){var k=R.apply(this,arguments);return k._pc=this,k}),_.RTCRtpSender.prototype.getStats=function(){var k=this;return this._pc.getStats().then(function(f){return o.filterStats(f,k.track,!0)})}}if(!("getStats"in _.RTCRtpReceiver.prototype)){var P=_.RTCPeerConnection.prototype.getReceivers;P&&(_.RTCPeerConnection.prototype.getReceivers=function(){var k=this,f=P.apply(this,[]);return f.forEach(function(y){return y._pc=k}),f}),o.wrapPeerConnectionEvent(_,"track",function(k){return k.receiver._pc=k.srcElement,k}),_.RTCRtpReceiver.prototype.getStats=function(){var k=this;return this._pc.getStats().then(function(f){return o.filterStats(f,k.track,!1)})}}if("getStats"in _.RTCRtpSender.prototype&&"getStats"in _.RTCRtpReceiver.prototype){var U=_.RTCPeerConnection.prototype.getStats;_.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof _.MediaStreamTrack){var k,f,y,A=arguments[0];return this.getSenders().forEach(function(D){D.track===A&&(k?y=!0:k=D)}),this.getReceivers().forEach(function(D){return D.track===A&&(f?y=!0:f=D),D.track===A}),y||k&&f?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):k?k.getStats():f?f.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return U.apply(this,arguments)}}}}function w(_){_.RTCPeerConnection.prototype.getLocalStreams=function(){var k=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(f){return k._shimmedLocalStreams[f][0]})};var b=_.RTCPeerConnection.prototype.addTrack;_.RTCPeerConnection.prototype.addTrack=function(k,f){if(!f)return b.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var y=b.apply(this,arguments);return this._shimmedLocalStreams[f.id]?this._shimmedLocalStreams[f.id].indexOf(y)===-1&&this._shimmedLocalStreams[f.id].push(y):this._shimmedLocalStreams[f.id]=[f,y],y};var R=_.RTCPeerConnection.prototype.addStream;_.RTCPeerConnection.prototype.addStream=function(k){var f=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},k.getTracks().forEach(function(D){if(f.getSenders().find(function(j){return j.track===D}))throw new DOMException("Track already exists.","InvalidAccessError")});var y=this.getSenders();R.apply(this,arguments);var A=this.getSenders().filter(function(D){return y.indexOf(D)===-1});this._shimmedLocalStreams[k.id]=[k].concat(A)};var P=_.RTCPeerConnection.prototype.removeStream;_.RTCPeerConnection.prototype.removeStream=function(k){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[k.id],P.apply(this,arguments)};var U=_.RTCPeerConnection.prototype.removeTrack;_.RTCPeerConnection.prototype.removeTrack=function(k){var f=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},k&&Object.keys(this._shimmedLocalStreams).forEach(function(y){var A=f._shimmedLocalStreams[y].indexOf(k);A!==-1&&f._shimmedLocalStreams[y].splice(A,1),f._shimmedLocalStreams[y].length===1&&delete f._shimmedLocalStreams[y]}),U.apply(this,arguments)}}function L(_,b){if(_.RTCPeerConnection){if(_.RTCPeerConnection.prototype.addTrack&&b.version>=65)return w(_);var R=_.RTCPeerConnection.prototype.getLocalStreams;_.RTCPeerConnection.prototype.getLocalStreams=function(){var D=this,j=R.apply(this);return this._reverseStreams=this._reverseStreams||{},j.map(function(K){return D._reverseStreams[K.id]})};var P=_.RTCPeerConnection.prototype.addStream;_.RTCPeerConnection.prototype.addStream=function(D){var j=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},D.getTracks().forEach(function(J){if(j.getSenders().find(function(se){return se.track===J}))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[D.id]){var K=new _.MediaStream(D.getTracks());this._streams[D.id]=K,this._reverseStreams[K.id]=D,D=K}P.apply(this,[D])};var U=_.RTCPeerConnection.prototype.removeStream;_.RTCPeerConnection.prototype.removeStream=function(D){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},U.apply(this,[this._streams[D.id]||D]),delete this._reverseStreams[this._streams[D.id]?this._streams[D.id].id:D.id],delete this._streams[D.id]},_.RTCPeerConnection.prototype.addTrack=function(D,j){var K=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var J=[].slice.call(arguments,1);if(J.length!==1||!J[0].getTracks().find(function(Je){return Je===D}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(function(Je){return Je.track===D}))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var se=this._streams[j.id];if(se)se.addTrack(D),Promise.resolve().then(function(){K.dispatchEvent(new Event("negotiationneeded"))});else{var ie=new _.MediaStream([D]);this._streams[j.id]=ie,this._reverseStreams[ie.id]=j,this.addStream(ie)}return this.getSenders().find(function(Je){return Je.track===D})},["createOffer","createAnswer"].forEach(function(D){var j=_.RTCPeerConnection.prototype[D],K=u({},D,function(){var J=this,se=arguments;return arguments.length&&typeof arguments[0]=="function"?j.apply(this,[function(ie){var Je=y(J,ie);se[0].apply(null,[Je])},function(ie){se[1]&&se[1].apply(null,ie)},arguments[2]]):j.apply(this,arguments).then(function(ie){return y(J,ie)})});_.RTCPeerConnection.prototype[D]=K[D]});var k=_.RTCPeerConnection.prototype.setLocalDescription;_.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=A(this,arguments[0]),k.apply(this,arguments)):k.apply(this,arguments)};var f=Object.getOwnPropertyDescriptor(_.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(_.RTCPeerConnection.prototype,"localDescription",{get:function(){var D=f.get.apply(this);return D.type===""?D:y(this,D)}}),_.RTCPeerConnection.prototype.removeTrack=function(D){var j,K=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!D._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(D._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{},Object.keys(this._streams).forEach(function(J){K._streams[J].getTracks().find(function(se){return D.track===se})&&(j=K._streams[J])}),j&&(j.getTracks().length===1?this.removeStream(this._reverseStreams[j.id]):j.removeTrack(D.track),this.dispatchEvent(new Event("negotiationneeded")))}}function y(D,j){var K=j.sdp;return Object.keys(D._reverseStreams||[]).forEach(function(J){var se=D._reverseStreams[J],ie=D._streams[se.id];K=K.replace(new RegExp(ie.id,"g"),se.id)}),new RTCSessionDescription({type:j.type,sdp:K})}function A(D,j){var K=j.sdp;return Object.keys(D._reverseStreams||[]).forEach(function(J){var se=D._reverseStreams[J],ie=D._streams[se.id];K=K.replace(new RegExp(se.id,"g"),ie.id)}),new RTCSessionDescription({type:j.type,sdp:K})}}function N(_,b){!_.RTCPeerConnection&&_.webkitRTCPeerConnection&&(_.RTCPeerConnection=_.webkitRTCPeerConnection),_.RTCPeerConnection&&b.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(R){var P=_.RTCPeerConnection.prototype[R],U=u({},R,function(){return arguments[0]=new(R==="addIceCandidate"?_.RTCIceCandidate:_.RTCSessionDescription)(arguments[0]),P.apply(this,arguments)});_.RTCPeerConnection.prototype[R]=U[R]})}function V(_,b){o.wrapPeerConnectionEvent(_,"negotiationneeded",function(R){var P=R.target;if(!(b.version<72||P.getConfiguration&&P.getConfiguration().sdpSemantics==="plan-b")||P.signalingState==="stable")return R})}},{"../utils.js":11,"./getdisplaymedia":4,"./getusermedia":5}],4:[function(n,i,r){function o(c,a){c.navigator.mediaDevices&&"getDisplayMedia"in c.navigator.mediaDevices||c.navigator.mediaDevices&&(typeof a=="function"?c.navigator.mediaDevices.getDisplayMedia=function(s){return a(s).then(function(l){var u=s.video&&s.video.width,h=s.video&&s.video.height,S=s.video&&s.video.frameRate;return s.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:l,maxFrameRate:S||3}},u&&(s.video.mandatory.maxWidth=u),h&&(s.video.mandatory.maxHeight=h),c.navigator.mediaDevices.getUserMedia(s)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=o},{}],5:[function(n,i,r){function o(u){if(typeof WeakMap!="function")return null;var h=new WeakMap,S=new WeakMap;return(o=function(I){return I?S:h})(u)}function c(u,h){if(!h&&u&&u.__esModule)return u;if(u===null||a(u)!=="object"&&typeof u!="function")return{default:u};var S=o(h);if(S&&S.has(u))return S.get(u);var I={},E=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var x in u)if(x!=="default"&&Object.prototype.hasOwnProperty.call(u,x)){var m=E?Object.getOwnPropertyDescriptor(u,x):null;m&&(m.get||m.set)?Object.defineProperty(I,x,m):I[x]=u[x]}return I.default=u,S&&S.set(u,I),I}function a(u){return a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},a(u)}Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetUserMedia=l;var s=c(n("../utils.js")).log;function l(u,h){var S=u&&u.navigator;if(S.mediaDevices){var I=function(v){if(a(v)!=="object"||v.mandatory||v.optional)return v;var w={};return Object.keys(v).forEach(function(L){if(L!=="require"&&L!=="advanced"&&L!=="mediaSource"){var N=a(v[L])==="object"?v[L]:{ideal:v[L]};N.exact!==void 0&&typeof N.exact=="number"&&(N.min=N.max=N.exact);var V=function(b,R){return b?b+R.charAt(0).toUpperCase()+R.slice(1):R==="deviceId"?"sourceId":R};if(N.ideal!==void 0){w.optional=w.optional||[];var _={};typeof N.ideal=="number"?(_[V("min",L)]=N.ideal,w.optional.push(_),(_={})[V("max",L)]=N.ideal,w.optional.push(_)):(_[V("",L)]=N.ideal,w.optional.push(_))}N.exact!==void 0&&typeof N.exact!="number"?(w.mandatory=w.mandatory||{},w.mandatory[V("",L)]=N.exact):["min","max"].forEach(function(b){N[b]!==void 0&&(w.mandatory=w.mandatory||{},w.mandatory[V(b,L)]=N[b])})}}),v.advanced&&(w.optional=(w.optional||[]).concat(v.advanced)),w},E=function(v,w){if(h.version>=61)return w(v);if((v=JSON.parse(JSON.stringify(v)))&&a(v.audio)==="object"){var L=function(b,R,P){R in b&&!(P in b)&&(b[P]=b[R],delete b[R])};L((v=JSON.parse(JSON.stringify(v))).audio,"autoGainControl","googAutoGainControl"),L(v.audio,"noiseSuppression","googNoiseSuppression"),v.audio=I(v.audio)}if(v&&a(v.video)==="object"){var N=v.video.facingMode;N=N&&(a(N)==="object"?N:{ideal:N});var V,_=h.version<66;if(N&&(N.exact==="user"||N.exact==="environment"||N.ideal==="user"||N.ideal==="environment")&&(!S.mediaDevices.getSupportedConstraints||!S.mediaDevices.getSupportedConstraints().facingMode||_)&&(delete v.video.facingMode,N.exact==="environment"||N.ideal==="environment"?V=["back","rear"]:N.exact!=="user"&&N.ideal!=="user"||(V=["front"]),V))return S.mediaDevices.enumerateDevices().then(function(b){var R=(b=b.filter(function(P){return P.kind==="videoinput"})).find(function(P){return V.some(function(U){return P.label.toLowerCase().includes(U)})});return!R&&b.length&&V.includes("back")&&(R=b[b.length-1]),R&&(v.video.deviceId=N.exact?{exact:R.deviceId}:{ideal:R.deviceId}),v.video=I(v.video),s("chrome: "+JSON.stringify(v)),w(v)});v.video=I(v.video)}return s("chrome: "+JSON.stringify(v)),w(v)},x=function(v){return h.version>=64?v:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[v.name]||v.name,message:v.message,constraint:v.constraint||v.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},m=function(v,w,L){E(v,function(N){S.webkitGetUserMedia(N,w,function(V){L&&L(x(V))})})};if(S.getUserMedia=m.bind(S),S.mediaDevices.getUserMedia){var T=S.mediaDevices.getUserMedia.bind(S.mediaDevices);S.mediaDevices.getUserMedia=function(v){return E(v,function(w){return T(w).then(function(L){if(w.audio&&!L.getAudioTracks().length||w.video&&!L.getVideoTracks().length)throw L.getTracks().forEach(function(N){N.stop()}),new DOMException("","NotFoundError");return L},function(L){return Promise.reject(x(L))})})}}}}},{"../utils.js":11}],6:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.removeExtmapAllowMixed=m,r.shimAddIceCandidateNullOrEmpty=T,r.shimConnectionState=x,r.shimMaxMessageSize=I,r.shimParameterlessSetLocalDescription=v,r.shimRTCIceCandidate=h,r.shimRTCIceCandidateRelayProtocol=S,r.shimSendThrowTypeError=E;var o=l(n("sdp")),c=s(n("./utils"));function a(w){if(typeof WeakMap!="function")return null;var L=new WeakMap,N=new WeakMap;return(a=function(V){return V?N:L})(w)}function s(w,L){if(!L&&w&&w.__esModule)return w;if(w===null||u(w)!=="object"&&typeof w!="function")return{default:w};var N=a(L);if(N&&N.has(w))return N.get(w);var V={},_=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var b in w)if(b!=="default"&&Object.prototype.hasOwnProperty.call(w,b)){var R=_?Object.getOwnPropertyDescriptor(w,b):null;R&&(R.get||R.set)?Object.defineProperty(V,b,R):V[b]=w[b]}return V.default=w,N&&N.set(w,V),V}function l(w){return w&&w.__esModule?w:{default:w}}function u(w){return u=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(L){return typeof L}:function(L){return L&&typeof Symbol=="function"&&L.constructor===Symbol&&L!==Symbol.prototype?"symbol":typeof L},u(w)}function h(w){if(!(!w.RTCIceCandidate||w.RTCIceCandidate&&"foundation"in w.RTCIceCandidate.prototype)){var L=w.RTCIceCandidate;w.RTCIceCandidate=function(N){if(u(N)==="object"&&N.candidate&&N.candidate.indexOf("a=")===0&&((N=JSON.parse(JSON.stringify(N))).candidate=N.candidate.substring(2)),N.candidate&&N.candidate.length){var V=new L(N),_=o.default.parseCandidate(N.candidate);for(var b in _)b in V||Object.defineProperty(V,b,{value:_[b]});return V.toJSON=function(){return{candidate:V.candidate,sdpMid:V.sdpMid,sdpMLineIndex:V.sdpMLineIndex,usernameFragment:V.usernameFragment}},V}return new L(N)},w.RTCIceCandidate.prototype=L.prototype,c.wrapPeerConnectionEvent(w,"icecandidate",function(N){return N.candidate&&Object.defineProperty(N,"candidate",{value:new w.RTCIceCandidate(N.candidate),writable:"false"}),N})}}function S(w){!w.RTCIceCandidate||w.RTCIceCandidate&&"relayProtocol"in w.RTCIceCandidate.prototype||c.wrapPeerConnectionEvent(w,"icecandidate",function(L){if(L.candidate){var N=o.default.parseCandidate(L.candidate.candidate);N.type==="relay"&&(L.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[N.priority>>24])}return L})}function I(w,L){if(w.RTCPeerConnection){"sctp"in w.RTCPeerConnection.prototype||Object.defineProperty(w.RTCPeerConnection.prototype,"sctp",{get:function(){return this._sctp===void 0?null:this._sctp}});var N=function(P){if(!P||!P.sdp)return!1;var U=o.default.splitSections(P.sdp);return U.shift(),U.some(function(k){var f=o.default.parseMLine(k);return f&&f.kind==="application"&&f.protocol.indexOf("SCTP")!==-1})},V=function(P){var U=P.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(U===null||U.length<2)return-1;var k=parseInt(U[1],10);return k!=k?-1:k},_=function(P){var U=65536;return L.browser==="firefox"&&(U=L.version<57?P===-1?16384:2147483637:L.version<60?L.version===57?65535:65536:2147483637),U},b=function(P,U){var k=65536;L.browser==="firefox"&&L.version===57&&(k=65535);var f=o.default.matchPrefix(P.sdp,"a=max-message-size:");return f.length>0?k=parseInt(f[0].substring(19),10):L.browser==="firefox"&&U!==-1&&(k=2147483637),k},R=w.RTCPeerConnection.prototype.setRemoteDescription;w.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,L.browser==="chrome"&&L.version>=76&&this.getConfiguration().sdpSemantics==="plan-b"&&Object.defineProperty(this,"sctp",{get:function(){return this._sctp===void 0?null:this._sctp},enumerable:!0,configurable:!0}),N(arguments[0])){var P,U=V(arguments[0]),k=_(U),f=b(arguments[0],U);P=k===0&&f===0?Number.POSITIVE_INFINITY:k===0||f===0?Math.max(k,f):Math.min(k,f);var y={};Object.defineProperty(y,"maxMessageSize",{get:function(){return P}}),this._sctp=y}return R.apply(this,arguments)}}}function E(w){if(w.RTCPeerConnection&&"createDataChannel"in w.RTCPeerConnection.prototype){var L=w.RTCPeerConnection.prototype.createDataChannel;w.RTCPeerConnection.prototype.createDataChannel=function(){var V=L.apply(this,arguments);return N(V,this),V},c.wrapPeerConnectionEvent(w,"datachannel",function(V){return N(V.channel,V.target),V})}function N(V,_){var b=V.send;V.send=function(){var R=arguments[0],P=R.length||R.size||R.byteLength;if(V.readyState==="open"&&_.sctp&&P>_.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+_.sctp.maxMessageSize+" bytes)");return b.apply(V,arguments)}}}function x(w){if(w.RTCPeerConnection&&!("connectionState"in w.RTCPeerConnection.prototype)){var L=w.RTCPeerConnection.prototype;Object.defineProperty(L,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(L,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(N){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),N&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=N)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(function(N){var V=L[N];L[N]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(_){var b=_.target;if(b._lastConnectionState!==b.connectionState){b._lastConnectionState=b.connectionState;var R=new Event("connectionstatechange",_);b.dispatchEvent(R)}return _},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),V.apply(this,arguments)}})}}function m(w,L){if(w.RTCPeerConnection&&!(L.browser==="chrome"&&L.version>=71||L.browser==="safari"&&L.version>=605)){var N=w.RTCPeerConnection.prototype.setRemoteDescription;w.RTCPeerConnection.prototype.setRemoteDescription=function(V){if(V&&V.sdp&&V.sdp.indexOf(`
5
- a=extmap-allow-mixed`)!==-1){var _=V.sdp.split(`
6
- `).filter(function(b){return b.trim()!=="a=extmap-allow-mixed"}).join(`
7
- `);w.RTCSessionDescription&&V instanceof w.RTCSessionDescription?arguments[0]=new w.RTCSessionDescription({type:V.type,sdp:_}):V.sdp=_}return N.apply(this,arguments)}}}function T(w,L){if(w.RTCPeerConnection&&w.RTCPeerConnection.prototype){var N=w.RTCPeerConnection.prototype.addIceCandidate;N&&N.length!==0&&(w.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(L.browser==="chrome"&&L.version<78||L.browser==="firefox"&&L.version<68||L.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():N.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}}function v(w,L){if(w.RTCPeerConnection&&w.RTCPeerConnection.prototype){var N=w.RTCPeerConnection.prototype.setLocalDescription;N&&N.length!==0&&(w.RTCPeerConnection.prototype.setLocalDescription=function(){var V=this,_=arguments[0]||{};if(u(_)!=="object"||_.type&&_.sdp)return N.apply(this,arguments);if(!(_={type:_.type,sdp:_.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":_.type="offer";break;default:_.type="answer"}return _.sdp||_.type!=="offer"&&_.type!=="answer"?N.apply(this,[_]):(_.type==="offer"?this.createOffer:this.createAnswer).apply(this).then(function(b){return N.apply(V,[b])})})}}},{"./utils":11,sdp:12}],7:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimAddTransceiver=P,r.shimCreateAnswer=f,r.shimCreateOffer=k,Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimGetParameters=U,Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return c.shimGetUserMedia}}),r.shimOnTrack=L,r.shimPeerConnection=N,r.shimRTCDataChannel=R,r.shimReceiverGetStats=_,r.shimRemoveStream=b,r.shimSenderGetStats=V;var o=l(n("../utils")),c=n("./getusermedia"),a=n("./getdisplaymedia");function s(y){if(typeof WeakMap!="function")return null;var A=new WeakMap,D=new WeakMap;return(s=function(j){return j?D:A})(y)}function l(y,A){if(!A&&y&&y.__esModule)return y;if(y===null||w(y)!=="object"&&typeof y!="function")return{default:y};var D=s(A);if(D&&D.has(y))return D.get(y);var j={},K=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var J in y)if(J!=="default"&&Object.prototype.hasOwnProperty.call(y,J)){var se=K?Object.getOwnPropertyDescriptor(y,J):null;se&&(se.get||se.set)?Object.defineProperty(j,J,se):j[J]=y[J]}return j.default=y,D&&D.set(y,j),j}function u(y){return E(y)||I(y)||S(y)||h()}function h(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
8
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function S(y,A){if(y){if(typeof y=="string")return x(y,A);var D=Object.prototype.toString.call(y).slice(8,-1);return D==="Object"&&y.constructor&&(D=y.constructor.name),D==="Map"||D==="Set"?Array.from(y):D==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(D)?x(y,A):void 0}}function I(y){if(typeof Symbol!="undefined"&&y[Symbol.iterator]!=null||y["@@iterator"]!=null)return Array.from(y)}function E(y){if(Array.isArray(y))return x(y)}function x(y,A){(A==null||A>y.length)&&(A=y.length);for(var D=0,j=new Array(A);D<A;D++)j[D]=y[D];return j}function m(y,A,D){return(A=T(A))in y?Object.defineProperty(y,A,{value:D,enumerable:!0,configurable:!0,writable:!0}):y[A]=D,y}function T(y){var A=v(y,"string");return w(A)==="symbol"?A:String(A)}function v(y,A){if(w(y)!=="object"||y===null)return y;var D=y[Symbol.toPrimitive];if(D!==void 0){var j=D.call(y,A||"default");if(w(j)!=="object")return j;throw new TypeError("@@toPrimitive must return a primitive value.")}return(A==="string"?String:Number)(y)}function w(y){return w=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},w(y)}function L(y){w(y)==="object"&&y.RTCTrackEvent&&"receiver"in y.RTCTrackEvent.prototype&&!("transceiver"in y.RTCTrackEvent.prototype)&&Object.defineProperty(y.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function N(y,A){if(w(y)==="object"&&(y.RTCPeerConnection||y.mozRTCPeerConnection)){!y.RTCPeerConnection&&y.mozRTCPeerConnection&&(y.RTCPeerConnection=y.mozRTCPeerConnection),A.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(K){var J=y.RTCPeerConnection.prototype[K],se=m({},K,function(){return arguments[0]=new(K==="addIceCandidate"?y.RTCIceCandidate:y.RTCSessionDescription)(arguments[0]),J.apply(this,arguments)});y.RTCPeerConnection.prototype[K]=se[K]});var D={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},j=y.RTCPeerConnection.prototype.getStats;y.RTCPeerConnection.prototype.getStats=function(){var K=Array.prototype.slice.call(arguments),J=K[0],se=K[1],ie=K[2];return j.apply(this,[J||null]).then(function(Je){if(A.version<53&&!se)try{Je.forEach(function(Ue){Ue.type=D[Ue.type]||Ue.type})}catch(Ue){if(Ue.name!=="TypeError")throw Ue;Je.forEach(function(Fe,ht){Je.set(ht,Object.assign({},Fe,{type:D[Fe.type]||Fe.type}))})}return Je}).then(se,ie)}}}function V(y){if(w(y)==="object"&&y.RTCPeerConnection&&y.RTCRtpSender&&(!y.RTCRtpSender||!("getStats"in y.RTCRtpSender.prototype))){var A=y.RTCPeerConnection.prototype.getSenders;A&&(y.RTCPeerConnection.prototype.getSenders=function(){var j=this,K=A.apply(this,[]);return K.forEach(function(J){return J._pc=j}),K});var D=y.RTCPeerConnection.prototype.addTrack;D&&(y.RTCPeerConnection.prototype.addTrack=function(){var j=D.apply(this,arguments);return j._pc=this,j}),y.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}}function _(y){if(w(y)==="object"&&y.RTCPeerConnection&&y.RTCRtpSender&&(!y.RTCRtpSender||!("getStats"in y.RTCRtpReceiver.prototype))){var A=y.RTCPeerConnection.prototype.getReceivers;A&&(y.RTCPeerConnection.prototype.getReceivers=function(){var D=this,j=A.apply(this,[]);return j.forEach(function(K){return K._pc=D}),j}),o.wrapPeerConnectionEvent(y,"track",function(D){return D.receiver._pc=D.srcElement,D}),y.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function b(y){y.RTCPeerConnection&&!("removeStream"in y.RTCPeerConnection.prototype)&&(y.RTCPeerConnection.prototype.removeStream=function(A){var D=this;o.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(j){j.track&&A.getTracks().includes(j.track)&&D.removeTrack(j)})})}function R(y){y.DataChannel&&!y.RTCDataChannel&&(y.RTCDataChannel=y.DataChannel)}function P(y){if(w(y)==="object"&&y.RTCPeerConnection){var A=y.RTCPeerConnection.prototype.addTransceiver;A&&(y.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var D=arguments[1]&&arguments[1].sendEncodings;D===void 0&&(D=[]);var j=(D=u(D)).length>0;j&&D.forEach(function(ie){if("rid"in ie&&!/^[a-z0-9]{0,16}$/i.test(ie.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in ie&&!(parseFloat(ie.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in ie&&!(parseFloat(ie.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});var K=A.apply(this,arguments);if(j){var J=K.sender,se=J.getParameters();(!("encodings"in se)||se.encodings.length===1&&Object.keys(se.encodings[0]).length===0)&&(se.encodings=D,J.sendEncodings=D,this.setParametersPromises.push(J.setParameters(se).then(function(){delete J.sendEncodings}).catch(function(){delete J.sendEncodings})))}return K})}}function U(y){if(w(y)==="object"&&y.RTCRtpSender){var A=y.RTCRtpSender.prototype.getParameters;A&&(y.RTCRtpSender.prototype.getParameters=function(){var D=A.apply(this,arguments);return"encodings"in D||(D.encodings=[].concat(this.sendEncodings||[{}])),D})}}function k(y){if(w(y)==="object"&&y.RTCPeerConnection){var A=y.RTCPeerConnection.prototype.createOffer;y.RTCPeerConnection.prototype.createOffer=function(){var D=arguments,j=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return A.apply(j,D)}).finally(function(){j.setParametersPromises=[]}):A.apply(this,arguments)}}}function f(y){if(w(y)==="object"&&y.RTCPeerConnection){var A=y.RTCPeerConnection.prototype.createAnswer;y.RTCPeerConnection.prototype.createAnswer=function(){var D=arguments,j=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return A.apply(j,D)}).finally(function(){j.setParametersPromises=[]}):A.apply(this,arguments)}}}},{"../utils":11,"./getdisplaymedia":8,"./getusermedia":9}],8:[function(n,i,r){function o(c,a){c.navigator.mediaDevices&&"getDisplayMedia"in c.navigator.mediaDevices||c.navigator.mediaDevices&&(c.navigator.mediaDevices.getDisplayMedia=function(s){if(!s||!s.video){var l=new DOMException("getDisplayMedia without video constraints is undefined");return l.name="NotFoundError",l.code=8,Promise.reject(l)}return s.video===!0?s.video={mediaSource:a}:s.video.mediaSource=a,c.navigator.mediaDevices.getUserMedia(s)})}Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=o},{}],9:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetUserMedia=l;var o=a(n("../utils"));function c(u){if(typeof WeakMap!="function")return null;var h=new WeakMap,S=new WeakMap;return(c=function(I){return I?S:h})(u)}function a(u,h){if(!h&&u&&u.__esModule)return u;if(u===null||s(u)!=="object"&&typeof u!="function")return{default:u};var S=c(h);if(S&&S.has(u))return S.get(u);var I={},E=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var x in u)if(x!=="default"&&Object.prototype.hasOwnProperty.call(u,x)){var m=E?Object.getOwnPropertyDescriptor(u,x):null;m&&(m.get||m.set)?Object.defineProperty(I,x,m):I[x]=u[x]}return I.default=u,S&&S.set(u,I),I}function s(u){return s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},s(u)}function l(u,h){var S=u&&u.navigator,I=u&&u.MediaStreamTrack;if(S.getUserMedia=function(v,w,L){o.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),S.mediaDevices.getUserMedia(v).then(w,L)},!(h.version>55&&"autoGainControl"in S.mediaDevices.getSupportedConstraints())){var E=function(v,w,L){w in v&&!(L in v)&&(v[L]=v[w],delete v[w])},x=S.mediaDevices.getUserMedia.bind(S.mediaDevices);if(S.mediaDevices.getUserMedia=function(v){return s(v)==="object"&&s(v.audio)==="object"&&(v=JSON.parse(JSON.stringify(v)),E(v.audio,"autoGainControl","mozAutoGainControl"),E(v.audio,"noiseSuppression","mozNoiseSuppression")),x(v)},I&&I.prototype.getSettings){var m=I.prototype.getSettings;I.prototype.getSettings=function(){var v=m.apply(this,arguments);return E(v,"mozAutoGainControl","autoGainControl"),E(v,"mozNoiseSuppression","noiseSuppression"),v}}if(I&&I.prototype.applyConstraints){var T=I.prototype.applyConstraints;I.prototype.applyConstraints=function(v){return this.kind==="audio"&&s(v)==="object"&&(v=JSON.parse(JSON.stringify(v)),E(v,"autoGainControl","mozAutoGainControl"),E(v,"noiseSuppression","mozNoiseSuppression")),T.apply(this,[v])}}}}},{"../utils":11}],10:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimAudioContext=T,r.shimCallbacksAPI=h,r.shimConstraints=I,r.shimCreateOfferLegacy=m,r.shimGetUserMedia=S,r.shimLocalStreamsAPI=l,r.shimRTCIceServerUrls=E,r.shimRemoteStreamsAPI=u,r.shimTrackEventTransceiver=x;var o=a(n("../utils"));function c(v){if(typeof WeakMap!="function")return null;var w=new WeakMap,L=new WeakMap;return(c=function(N){return N?L:w})(v)}function a(v,w){if(!w&&v&&v.__esModule)return v;if(v===null||s(v)!=="object"&&typeof v!="function")return{default:v};var L=c(w);if(L&&L.has(v))return L.get(v);var N={},V=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var _ in v)if(_!=="default"&&Object.prototype.hasOwnProperty.call(v,_)){var b=V?Object.getOwnPropertyDescriptor(v,_):null;b&&(b.get||b.set)?Object.defineProperty(N,_,b):N[_]=v[_]}return N.default=v,L&&L.set(v,N),N}function s(v){return s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(w){return typeof w}:function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},s(v)}function l(v){if(s(v)==="object"&&v.RTCPeerConnection){if("getLocalStreams"in v.RTCPeerConnection.prototype||(v.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in v.RTCPeerConnection.prototype)){var w=v.RTCPeerConnection.prototype.addTrack;v.RTCPeerConnection.prototype.addStream=function(L){var N=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(L)||this._localStreams.push(L),L.getAudioTracks().forEach(function(V){return w.call(N,V,L)}),L.getVideoTracks().forEach(function(V){return w.call(N,V,L)})},v.RTCPeerConnection.prototype.addTrack=function(L){for(var N=this,V=arguments.length,_=new Array(V>1?V-1:0),b=1;b<V;b++)_[b-1]=arguments[b];return _&&_.forEach(function(R){N._localStreams?N._localStreams.includes(R)||N._localStreams.push(R):N._localStreams=[R]}),w.apply(this,arguments)}}"removeStream"in v.RTCPeerConnection.prototype||(v.RTCPeerConnection.prototype.removeStream=function(L){var N=this;this._localStreams||(this._localStreams=[]);var V=this._localStreams.indexOf(L);if(V!==-1){this._localStreams.splice(V,1);var _=L.getTracks();this.getSenders().forEach(function(b){_.includes(b.track)&&N.removeTrack(b)})}})}}function u(v){if(s(v)==="object"&&v.RTCPeerConnection&&("getRemoteStreams"in v.RTCPeerConnection.prototype||(v.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in v.RTCPeerConnection.prototype))){Object.defineProperty(v.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(L){var N=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=L),this.addEventListener("track",this._onaddstreampoly=function(V){V.streams.forEach(function(_){if(N._remoteStreams||(N._remoteStreams=[]),!N._remoteStreams.includes(_)){N._remoteStreams.push(_);var b=new Event("addstream");b.stream=_,N.dispatchEvent(b)}})})}});var w=v.RTCPeerConnection.prototype.setRemoteDescription;v.RTCPeerConnection.prototype.setRemoteDescription=function(){var L=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(N){N.streams.forEach(function(V){if(L._remoteStreams||(L._remoteStreams=[]),!(L._remoteStreams.indexOf(V)>=0)){L._remoteStreams.push(V);var _=new Event("addstream");_.stream=V,L.dispatchEvent(_)}})}),w.apply(L,arguments)}}}function h(v){if(s(v)==="object"&&v.RTCPeerConnection){var w=v.RTCPeerConnection.prototype,L=w.createOffer,N=w.createAnswer,V=w.setLocalDescription,_=w.setRemoteDescription,b=w.addIceCandidate;w.createOffer=function(P,U){var k=arguments.length>=2?arguments[2]:arguments[0],f=L.apply(this,[k]);return U?(f.then(P,U),Promise.resolve()):f},w.createAnswer=function(P,U){var k=arguments.length>=2?arguments[2]:arguments[0],f=N.apply(this,[k]);return U?(f.then(P,U),Promise.resolve()):f};var R=function(P,U,k){var f=V.apply(this,[P]);return k?(f.then(U,k),Promise.resolve()):f};w.setLocalDescription=R,R=function(P,U,k){var f=_.apply(this,[P]);return k?(f.then(U,k),Promise.resolve()):f},w.setRemoteDescription=R,R=function(P,U,k){var f=b.apply(this,[P]);return k?(f.then(U,k),Promise.resolve()):f},w.addIceCandidate=R}}function S(v){var w=v&&v.navigator;if(w.mediaDevices&&w.mediaDevices.getUserMedia){var L=w.mediaDevices,N=L.getUserMedia.bind(L);w.mediaDevices.getUserMedia=function(V){return N(I(V))}}!w.getUserMedia&&w.mediaDevices&&w.mediaDevices.getUserMedia&&(w.getUserMedia=function(V,_,b){w.mediaDevices.getUserMedia(V).then(_,b)}.bind(w))}function I(v){return v&&v.video!==void 0?Object.assign({},v,{video:o.compactObject(v.video)}):v}function E(v){if(v.RTCPeerConnection){var w=v.RTCPeerConnection;v.RTCPeerConnection=function(L,N){if(L&&L.iceServers){for(var V=[],_=0;_<L.iceServers.length;_++){var b=L.iceServers[_];b.urls===void 0&&b.url?(o.deprecated("RTCIceServer.url","RTCIceServer.urls"),(b=JSON.parse(JSON.stringify(b))).urls=b.url,delete b.url,V.push(b)):V.push(L.iceServers[_])}L.iceServers=V}return new w(L,N)},v.RTCPeerConnection.prototype=w.prototype,"generateCertificate"in w&&Object.defineProperty(v.RTCPeerConnection,"generateCertificate",{get:function(){return w.generateCertificate}})}}function x(v){s(v)==="object"&&v.RTCTrackEvent&&"receiver"in v.RTCTrackEvent.prototype&&!("transceiver"in v.RTCTrackEvent.prototype)&&Object.defineProperty(v.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function m(v){var w=v.RTCPeerConnection.prototype.createOffer;v.RTCPeerConnection.prototype.createOffer=function(L){if(L){L.offerToReceiveAudio!==void 0&&(L.offerToReceiveAudio=!!L.offerToReceiveAudio);var N=this.getTransceivers().find(function(_){return _.receiver.track.kind==="audio"});L.offerToReceiveAudio===!1&&N?N.direction==="sendrecv"?N.setDirection?N.setDirection("sendonly"):N.direction="sendonly":N.direction==="recvonly"&&(N.setDirection?N.setDirection("inactive"):N.direction="inactive"):L.offerToReceiveAudio!==!0||N||this.addTransceiver("audio",{direction:"recvonly"}),L.offerToReceiveVideo!==void 0&&(L.offerToReceiveVideo=!!L.offerToReceiveVideo);var V=this.getTransceivers().find(function(_){return _.receiver.track.kind==="video"});L.offerToReceiveVideo===!1&&V?V.direction==="sendrecv"?V.setDirection?V.setDirection("sendonly"):V.direction="sendonly":V.direction==="recvonly"&&(V.setDirection?V.setDirection("inactive"):V.direction="inactive"):L.offerToReceiveVideo!==!0||V||this.addTransceiver("video",{direction:"recvonly"})}return w.apply(this,arguments)}}function T(v){s(v)!=="object"||v.AudioContext||(v.AudioContext=v.webkitAudioContext)}},{"../utils":11}],11:[function(n,i,r){function o(V,_,b){return(_=c(_))in V?Object.defineProperty(V,_,{value:b,enumerable:!0,configurable:!0,writable:!0}):V[_]=b,V}function c(V){var _=a(V,"string");return s(_)==="symbol"?_:String(_)}function a(V,_){if(s(V)!=="object"||V===null)return V;var b=V[Symbol.toPrimitive];if(b!==void 0){var R=b.call(V,_||"default");if(s(R)!=="object")return R;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(V)}function s(V){return s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _},s(V)}Object.defineProperty(r,"__esModule",{value:!0}),r.compactObject=w,r.deprecated=m,r.detectBrowser=T,r.disableLog=I,r.disableWarnings=E,r.extractVersion=h,r.filterStats=N,r.log=x,r.walkStats=L,r.wrapPeerConnectionEvent=S;var l=!0,u=!0;function h(V,_,b){var R=V.match(_);return R&&R.length>=b&&parseInt(R[b],10)}function S(V,_,b){if(V.RTCPeerConnection){var R=V.RTCPeerConnection.prototype,P=R.addEventListener;R.addEventListener=function(k,f){if(k!==_)return P.apply(this,arguments);var y=function(A){var D=b(A);D&&(f.handleEvent?f.handleEvent(D):f(D))};return this._eventMap=this._eventMap||{},this._eventMap[_]||(this._eventMap[_]=new Map),this._eventMap[_].set(f,y),P.apply(this,[k,y])};var U=R.removeEventListener;R.removeEventListener=function(k,f){if(k!==_||!this._eventMap||!this._eventMap[_])return U.apply(this,arguments);if(!this._eventMap[_].has(f))return U.apply(this,arguments);var y=this._eventMap[_].get(f);return this._eventMap[_].delete(f),this._eventMap[_].size===0&&delete this._eventMap[_],Object.keys(this._eventMap).length===0&&delete this._eventMap,U.apply(this,[k,y])},Object.defineProperty(R,"on"+_,{get:function(){return this["_on"+_]},set:function(k){this["_on"+_]&&(this.removeEventListener(_,this["_on"+_]),delete this["_on"+_]),k&&this.addEventListener(_,this["_on"+_]=k)},enumerable:!0,configurable:!0})}}function I(V){return typeof V!="boolean"?new Error("Argument type: "+s(V)+". Please use a boolean."):(l=V,V?"adapter.js logging disabled":"adapter.js logging enabled")}function E(V){return typeof V!="boolean"?new Error("Argument type: "+s(V)+". Please use a boolean."):(u=!V,"adapter.js deprecation warnings "+(V?"disabled":"enabled"))}function x(){if((typeof window=="undefined"?"undefined":s(window))==="object"){if(l)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function m(V,_){u&&console.warn(V+" is deprecated, please use "+_+" instead.")}function T(V){var _={browser:null,version:null};if(V===void 0||!V.navigator||!V.navigator.userAgent)return _.browser="Not a browser.",_;var b=V.navigator;if(b.mozGetUserMedia)_.browser="firefox",_.version=h(b.userAgent,/Firefox\/(\d+)\./,1);else if(b.webkitGetUserMedia||V.isSecureContext===!1&&V.webkitRTCPeerConnection)_.browser="chrome",_.version=h(b.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!V.RTCPeerConnection||!b.userAgent.match(/AppleWebKit\/(\d+)\./))return _.browser="Not a supported browser.",_;_.browser="safari",_.version=h(b.userAgent,/AppleWebKit\/(\d+)\./,1),_.supportsUnifiedPlan=V.RTCRtpTransceiver&&"currentDirection"in V.RTCRtpTransceiver.prototype}return _}function v(V){return Object.prototype.toString.call(V)==="[object Object]"}function w(V){return v(V)?Object.keys(V).reduce(function(_,b){var R=v(V[b]),P=R?w(V[b]):V[b],U=R&&!Object.keys(P).length;return P===void 0||U?_:Object.assign(_,o({},b,P))},{}):V}function L(V,_,b){_&&!b.has(_.id)&&(b.set(_.id,_),Object.keys(_).forEach(function(R){R.endsWith("Id")?L(V,V.get(_[R]),b):R.endsWith("Ids")&&_[R].forEach(function(P){L(V,V.get(P),b)})}))}function N(V,_,b){var R=b?"outbound-rtp":"inbound-rtp",P=new Map;if(_===null)return P;var U=[];return V.forEach(function(k){k.type==="track"&&k.trackIdentifier===_.id&&U.push(k)}),U.forEach(function(k){V.forEach(function(f){f.type===R&&f.trackId===k.id&&L(V,f,P)})}),P}},{}],12:[function(n,i,r){var o=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},c={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};c.localCName=c.generateIdentifier(),c.splitLines=function(a){return a.trim().split(`
3
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function je(e,t){if(e){if(typeof e=="string")return He(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?He(e,t):void 0}}function He(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function ae(e,t){var n=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=je(e))||t&&e&&typeof e.length=="number"){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(s){throw s},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
4
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o,c=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var s=n.next();return c=s.done,s},e:function(s){a=!0,o=s},f:function(){try{c||n.return==null||n.return()}finally{if(a)throw o}}}}function K(e,t,n,i,r){var o={};return Object.keys(i).forEach(function(c){o[c]=i[c]}),o.enumerable=!!o.enumerable,o.configurable=!!o.configurable,("value"in o||o.initializer)&&(o.writable=!0),o=n.slice().reverse().reduce(function(c,a){return a(e,t,c)||c},o),r&&o.initializer!==void 0&&(o.value=o.initializer?o.initializer.call(r):void 0,o.initializer=void 0),o.initializer===void 0&&(Object.defineProperty(e,t,o),o=null),o}var oe=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},z=function(e){return e&&e.Math==Math&&e},re=z(typeof globalThis=="object"&&globalThis)||z(typeof window=="object"&&window)||z(typeof self=="object"&&self)||z(typeof oe=="object"&&oe)||function(){return this}()||Function("return this")(),be={},se=function(e){try{return!!e()}catch(t){return!0}},ye=!se(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Me=!se(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),Jt=Me,Zt=Function.prototype.call,qe=Jt?Zt.bind(Zt):function(){return Zt.apply(Zt,arguments)},qt={},ft={}.propertyIsEnumerable,Jn=Object.getOwnPropertyDescriptor,hr=Jn&&!ft.call({1:2},1);qt.f=hr?function(e){var t=Jn(this,e);return!!t&&t.enumerable}:ft;var Ht,Rn,$e=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Gt=Me,qn=Function.prototype,he=qn.call,de=Gt&&qn.bind.bind(he,he),Ne=function(e){return Gt?de(e):function(){return he.apply(e,arguments)}},We=Ne,De=We({}.toString),ut=We("".slice),rt=function(e){return ut(De(e),8,-1)},Ut=rt,en=Ne,pe=function(e){if(Ut(e)==="Function")return en(e)},Ot=se,Kt=rt,fr=Object,Di=pe("".split),yn=Ot(function(){return!fr("z").propertyIsEnumerable(0)})?function(e){return Kt(e)=="String"?Di(e,""):fr(e)}:fr,Rt=function(e){return e==null},Cd=Rt,Lt=TypeError,pt=function(e){if(Cd(e))throw Lt("Can't call method on "+e);return e},Dc=yn,Oc=pt,bn=function(e){return Dc(Oc(e))},ba=typeof document=="object"&&document.all,Oi={all:ba,IS_HTMLDDA:ba===void 0&&ba!==void 0},Lc=Oi.all,it=Oi.IS_HTMLDDA?function(e){return typeof e=="function"||e===Lc}:function(e){return typeof e=="function"},Sa=it,Mc=Oi.all,at=Oi.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:Sa(e)||e===Mc}:function(e){return typeof e=="object"?e!==null:Sa(e)},ka=re,qo=it,Nc=function(e){return qo(e)?e:void 0},An=function(e,t){return arguments.length<2?Nc(ka[e]):ka[e]&&ka[e][t]},Sn=pe({}.isPrototypeOf),Kn=An("navigator","userAgent")||"",Uc=re,Ta=Kn,Xr=Uc.process,Ia=Uc.Deno,Ko=Xr&&Xr.versions||Ia&&Ia.version,Xo=Ko&&Ko.v8;Xo&&(Rn=(Ht=Xo.split("."))[0]>0&&Ht[0]<4?1:+(Ht[0]+Ht[1])),!Rn&&Ta&&(!(Ht=Ta.match(/Edge\/(\d+)/))||Ht[1]>=74)&&(Ht=Ta.match(/Chrome\/(\d+)/))&&(Rn=+Ht[1]);var pr=Rn,mr=pr,Li=se,Qo=!!Object.getOwnPropertySymbols&&!Li(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&mr&&mr<41}),Yo=Qo&&!Symbol.sham&&typeof Symbol.iterator=="symbol",$o=An,Vc=it,Ar=Sn,Zo=Object,Mi=Yo?function(e){return typeof e=="symbol"}:function(e){var t=$o("Symbol");return Vc(t)&&Ar(t.prototype,Zo(e))},xa=String,Xn=function(e){try{return xa(e)}catch(t){return"Object"}},Ed=it,Qr=Xn,Qn=TypeError,Vt=function(e){if(Ed(e))return e;throw Qn(Qr(e)+" is not a function")},jc=Vt,xt=Rt,Xt=function(e,t){var n=e[t];return xt(n)?void 0:jc(n)},Ni=qe,es=it,Yr=at,ts=TypeError,Pr={exports:{}},$r=re,wa=Object.defineProperty,Ca=function(e,t){try{wa($r,e,{value:t,configurable:!0,writable:!0})}catch(n){$r[e]=t}return t},ns=Ca,Ea="__core-js_shared__",Ra=re[Ea]||ns(Ea,{}),pn=Ra;(Pr.exports=function(e,t){return pn[e]||(pn[e]=t!==void 0?t:{})})("versions",[]).push({version:"3.25.5",mode:"global",copyright:"\xA9 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.25.5/LICENSE",source:"https://github.com/zloirock/core-js"});var Pn=pt,Ui=Object,Mt=function(e){return Ui(Pn(e))},rs=Mt,Bc=pe({}.hasOwnProperty),kt=Object.hasOwn||function(e,t){return Bc(rs(e),t)},Dn=pe,Fc=0,Aa=Math.random(),On=Dn(1 .toString),Vi=function(e){return"Symbol("+(e===void 0?"":e)+")_"+On(++Fc+Aa,36)},is=re,Rd=Pr.exports,Hc=kt,Gc=Vi,as=Qo,os=Yo,Zr=Rd("wks"),At=is.Symbol,ss=At&&At.for,zc=os?At:At&&At.withoutSetter||Gc,tt=function(e){if(!Hc(Zr,e)||!as&&typeof Zr[e]!="string"){var t="Symbol."+e;as&&Hc(At,e)?Zr[e]=At[e]:Zr[e]=os&&ss?ss(t):zc(t)}return Zr[e]},Wc=qe,cs=at,Jc=Mi,qc=Xt,Kc=function(e,t){var n,i;if(t==="string"&&es(n=e.toString)&&!Yr(i=Ni(n,e))||es(n=e.valueOf)&&!Yr(i=Ni(n,e))||t!=="string"&&es(n=e.toString)&&!Yr(i=Ni(n,e)))return i;throw ts("Can't convert object to primitive value")},Pa=TypeError,Xc=tt("toPrimitive"),ji=function(e,t){if(!cs(e)||Jc(e))return e;var n,i=qc(e,Xc);if(i){if(t===void 0&&(t="default"),n=Wc(i,e,t),!cs(n)||Jc(n))return n;throw Pa("Can't convert object to primitive value")}return t===void 0&&(t="number"),Kc(e,t)},Bi=ji,Ad=Mi,Da=function(e){var t=Bi(e,"string");return Ad(t)?t:t+""},Qc=at,us=re.document,ls=Qc(us)&&Qc(us.createElement),vr=function(e){return ls?us.createElement(e):{}},Pd=vr,Yc=!ye&&!se(function(){return Object.defineProperty(Pd("div"),"a",{get:function(){return 7}}).a!=7}),Dd=ye,Od=qe,ds=qt,$c=$e,Zc=bn,Fi=Da,kn=kt,Ld=Yc,eu=Object.getOwnPropertyDescriptor;be.f=Dd?eu:function(e,t){if(e=Zc(e),t=Fi(t),Ld)try{return eu(e,t)}catch(n){}if(kn(e,t))return $c(!Od(ds.f,e,t),e[t])};var Pt={},hs=ye&&se(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),fs=at,ps=String,ei=TypeError,Tt=function(e){if(fs(e))return e;throw ei(ps(e)+" is not an object")},ms=ye,Md=Yc,Nd=hs,gr=Tt,vs=Da,tu=TypeError,gs=Object.defineProperty,Ud=Object.getOwnPropertyDescriptor,Oa="enumerable",nu="configurable",Vd="writable";Pt.f=ms?Nd?function(e,t,n){if(gr(e),t=vs(t),gr(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Vd in n&&!n.writable){var i=Ud(e,t);i&&i.writable&&(e[t]=n.value,n={configurable:nu in n?n.configurable:i.configurable,enumerable:Oa in n?n.enumerable:i.enumerable,writable:!1})}return gs(e,t,n)}:gs:function(e,t,n){if(gr(e),t=vs(t),gr(n),Md)try{return gs(e,t,n)}catch(i){}if("get"in n||"set"in n)throw tu("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var ru=Pt,jd=$e,Ln=ye?function(e,t,n){return ru.f(e,t,jd(1,n))}:function(e,t,n){return e[t]=n,e},Hi={exports:{}},La=ye,Bd=kt,iu=Function.prototype,Fd=La&&Object.getOwnPropertyDescriptor,Ma=Bd(iu,"name"),Yn={EXISTS:Ma,PROPER:Ma&&function(){}.name==="something",CONFIGURABLE:Ma&&(!La||La&&Fd(iu,"name").configurable)},Hd=it,ti=Ra,Gd=pe(Function.toString);Hd(ti.inspectSource)||(ti.inspectSource=function(e){return Gd(e)});var Na,ni,Gi,d=ti.inspectSource,g=it,C=re.WeakMap,O=g(C)&&/native code/.test(String(C)),j=Pr.exports,V=Vi,F=j("keys"),W=function(e){return F[e]||(F[e]=V(e))},ee={},fe=O,me=re,Ce=at,Ae=Ln,ve=kt,Oe=Ra,Be=W,ot=ee,lt="Object already initialized",jt=me.TypeError,mn=me.WeakMap;if(fe||Oe.state){var bt=Oe.state||(Oe.state=new mn);bt.get=bt.get,bt.has=bt.has,bt.set=bt.set,Na=function(e,t){if(bt.has(e))throw jt(lt);return t.facade=e,bt.set(e,t),t},ni=function(e){return bt.get(e)||{}},Gi=function(e){return bt.has(e)}}else{var Je=Be("state");ot[Je]=!0,Na=function(e,t){if(ve(e,Je))throw jt(lt);return t.facade=e,Ae(e,Je,t),t},ni=function(e){return ve(e,Je)?e[Je]:{}},Gi=function(e){return ve(e,Je)}}var Ke={set:Na,get:ni,has:Gi,enforce:function(e){return Gi(e)?ni(e):Na(e,{})},getterFor:function(e){return function(t){var n;if(!Ce(t)||(n=ni(t)).type!==e)throw jt("Incompatible receiver, "+e+" required");return n}}},_r=se,Ua=it,Mn=kt,Va=ye,ri=Yn.CONFIGURABLE,ja=d,_s=Ke.enforce,yw=Ke.get,au=Object.defineProperty,bw=Va&&!_r(function(){return au(function(){},"length",{value:8}).length!==8}),Sw=String(String).split("String"),kw=Hi.exports=function(e,t,n){String(t).slice(0,7)==="Symbol("&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!Mn(e,"name")||ri&&e.name!==t)&&(Va?au(e,"name",{value:t,configurable:!0}):e.name=t),bw&&n&&Mn(n,"arity")&&e.length!==n.arity&&au(e,"length",{value:n.arity});try{n&&Mn(n,"constructor")&&n.constructor?Va&&au(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(r){}var i=_s(e);return Mn(i,"source")||(i.source=Sw.join(typeof t=="string"?t:"")),e};Function.prototype.toString=kw(function(){return Ua(this)&&yw(this).source||ja(this)},"toString");var Tw=it,Iw=Pt,xw=Hi.exports,ww=Ca,Qt=function(e,t,n,i){i||(i={});var r=i.enumerable,o=i.name!==void 0?i.name:t;if(Tw(n)&&xw(n,o,i),i.global)r?e[t]=n:ww(t,n);else{try{i.unsafe?e[t]&&(r=!0):delete e[t]}catch(c){}r?e[t]=n:Iw.f(e,t,{value:n,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return e},ii={},Cw=Math.ceil,Ew=Math.floor,Rw=Math.trunc||function(e){var t=+e;return(t>0?Ew:Cw)(t)},$n=function(e){var t=+e;return t!=t||t===0?0:Rw(t)},Aw=$n,Pw=Math.max,Dw=Math.min,ai=function(e,t){var n=Aw(e);return n<0?Pw(n+t,0):Dw(n,t)},Ow=$n,Lw=Math.min,yr=function(e){return e>0?Lw(Ow(e),9007199254740991):0},Mw=yr,nn=function(e){return Mw(e.length)},Nw=bn,Uw=ai,Vw=nn,pg=function(e){return function(t,n,i){var r,o=Nw(t),c=Vw(o),a=Uw(i,c);if(e&&n!=n){for(;c>a;)if((r=o[a++])!=r)return!0}else for(;c>a;a++)if((e||a in o)&&o[a]===n)return e||a||0;return!e&&-1}},ys={includes:pg(!0),indexOf:pg(!1)},zd=kt,jw=bn,Bw=ys.indexOf,Fw=ee,mg=pe([].push),vg=function(e,t){var n,i=jw(e),r=0,o=[];for(n in i)!zd(Fw,n)&&zd(i,n)&&mg(o,n);for(;t.length>r;)zd(i,n=t[r++])&&(~Bw(o,n)||mg(o,n));return o},Wd=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Hw=vg,Gw=Wd.concat("length","prototype");ii.f=Object.getOwnPropertyNames||function(e){return Hw(e,Gw)};var Jd={};Jd.f=Object.getOwnPropertySymbols;var zw=An,Ww=ii,Jw=Jd,qw=Tt,Kw=pe([].concat),Xw=zw("Reflect","ownKeys")||function(e){var t=Ww.f(qw(e)),n=Jw.f;return n?Kw(t,n(e)):t},gg=kt,Qw=Xw,Yw=be,$w=Pt,Zw=se,eC=it,tC=/#|\.prototype\./,bs=function(e,t){var n=rC[nC(e)];return n==aC||n!=iC&&(eC(t)?Zw(t):!!t)},nC=bs.normalize=function(e){return String(e).replace(tC,".").toLowerCase()},rC=bs.data={},iC=bs.NATIVE="N",aC=bs.POLYFILL="P",Ss=bs,qd=re,oC=be.f,sC=Ln,cC=Qt,uC=Ca,lC=function(e,t,n){for(var i=Qw(t),r=$w.f,o=Yw.f,c=0;c<i.length;c++){var a=i[c];gg(e,a)||n&&gg(n,a)||r(e,a,o(t,a))}},dC=Ss,Le=function(e,t){var n,i,r,o,c,a=e.target,s=e.global,l=e.stat;if(n=s?qd:l?qd[a]||uC(a,{}):(qd[a]||{}).prototype)for(i in t){if(o=t[i],r=e.dontCallGetSet?(c=oC(n,i))&&c.value:n[i],!dC(s?i:a+(l?".":"#")+i,e.forced)&&r!==void 0){if(typeof o==typeof r)continue;lC(o,r)}(e.sham||r&&r.sham)&&sC(o,"sham",!0),cC(n,i,o,e)}},hC=Le,fC=se,pC=bn,_g=be.f,yg=ye,mC=fC(function(){_g(1)});function Kd(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}hC({target:"Object",stat:!0,forced:!yg||mC,sham:!yg},{getOwnPropertyDescriptor:function(e,t){return _g(pC(e),t)}}),function(e,t){e.exports=function(){function n(i,r,o){function c(l,u){if(!r[l]){if(!i[l]){if(!u&&Kd)return Kd(l);if(a)return a(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var b=r[l]={exports:{}};i[l][0].call(b.exports,function(I){return c(i[l][1][I]||I)},b,b.exports,n,i,r,o)}return r[l].exports}for(var a=Kd,s=0;s<o.length;s++)c(o[s]);return c}return n}()({1:[function(n,i,r){var o=(0,n("./adapter_factory.js").adapterFactory)({window:typeof window=="undefined"?void 0:window});i.exports=o},{"./adapter_factory.js":2}],2:[function(n,i,r){function o(x){return o=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},o(x)}Object.defineProperty(r,"__esModule",{value:!0}),r.adapterFactory=R;var c=I(n("./utils")),a=I(n("./chrome/chrome_shim")),s=I(n("./firefox/firefox_shim")),l=I(n("./safari/safari_shim")),u=I(n("./common_shim")),h=I(n("sdp"));function b(x){if(typeof WeakMap!="function")return null;var m=new WeakMap,k=new WeakMap;return(b=function(v){return v?k:m})(x)}function I(x,m){if(!m&&x&&x.__esModule)return x;if(x===null||o(x)!="object"&&typeof x!="function")return{default:x};var k=b(m);if(k&&k.has(x))return k.get(x);var v={__proto__:null},w=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var L in x)if(L!=="default"&&{}.hasOwnProperty.call(x,L)){var E=w?Object.getOwnPropertyDescriptor(x,L):null;E&&(E.get||E.set)?Object.defineProperty(v,L,E):v[L]=x[L]}return v.default=x,k&&k.set(x,v),v}function R(){var x=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).window,m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},k=c.log,v=c.detectBrowser(x),w={browserDetails:v,commonShim:u,extractVersion:c.extractVersion,disableLog:c.disableLog,disableWarnings:c.disableWarnings,sdp:h};switch(v.browser){case"chrome":if(!a||!a.shimPeerConnection||!m.shimChrome)return k("Chrome shim is not included in this adapter release."),w;if(v.version===null)return k("Chrome shim can not determine version, not shimming."),w;k("adapter.js shimming chrome."),w.browserShim=a,u.shimAddIceCandidateNullOrEmpty(x,v),u.shimParameterlessSetLocalDescription(x,v),a.shimGetUserMedia(x,v),a.shimMediaStream(x,v),a.shimPeerConnection(x,v),a.shimOnTrack(x,v),a.shimAddTrackRemoveTrack(x,v),a.shimGetSendersWithDtmf(x,v),a.shimSenderReceiverGetStats(x,v),a.fixNegotiationNeeded(x,v),u.shimRTCIceCandidate(x,v),u.shimRTCIceCandidateRelayProtocol(x,v),u.shimConnectionState(x,v),u.shimMaxMessageSize(x,v),u.shimSendThrowTypeError(x,v),u.removeExtmapAllowMixed(x,v);break;case"firefox":if(!s||!s.shimPeerConnection||!m.shimFirefox)return k("Firefox shim is not included in this adapter release."),w;k("adapter.js shimming firefox."),w.browserShim=s,u.shimAddIceCandidateNullOrEmpty(x,v),u.shimParameterlessSetLocalDescription(x,v),s.shimGetUserMedia(x,v),s.shimPeerConnection(x,v),s.shimOnTrack(x,v),s.shimRemoveStream(x,v),s.shimSenderGetStats(x,v),s.shimReceiverGetStats(x,v),s.shimRTCDataChannel(x,v),s.shimAddTransceiver(x,v),s.shimGetParameters(x,v),s.shimCreateOffer(x,v),s.shimCreateAnswer(x,v),u.shimRTCIceCandidate(x,v),u.shimConnectionState(x,v),u.shimMaxMessageSize(x,v),u.shimSendThrowTypeError(x,v);break;case"safari":if(!l||!m.shimSafari)return k("Safari shim is not included in this adapter release."),w;k("adapter.js shimming safari."),w.browserShim=l,u.shimAddIceCandidateNullOrEmpty(x,v),u.shimParameterlessSetLocalDescription(x,v),l.shimRTCIceServerUrls(x,v),l.shimCreateOfferLegacy(x,v),l.shimCallbacksAPI(x,v),l.shimLocalStreamsAPI(x,v),l.shimRemoteStreamsAPI(x,v),l.shimTrackEventTransceiver(x,v),l.shimGetUserMedia(x,v),l.shimAudioContext(x,v),u.shimRTCIceCandidate(x,v),u.shimRTCIceCandidateRelayProtocol(x,v),u.shimMaxMessageSize(x,v),u.shimSendThrowTypeError(x,v),u.removeExtmapAllowMixed(x,v);break;default:k("Unsupported browser!")}return w}},{"./chrome/chrome_shim":3,"./common_shim":5,"./firefox/firefox_shim":6,"./safari/safari_shim":9,"./utils":10,sdp:11}],3:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fixNegotiationNeeded=L,r.shimAddTrackRemoveTrack=v,r.shimAddTrackRemoveTrackWithNative=k,r.shimGetSendersWithDtmf=x,Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return c.shimGetUserMedia}}),r.shimMediaStream=I,r.shimOnTrack=R,r.shimPeerConnection=w,r.shimSenderReceiverGetStats=m;var o=s(n("../utils.js")),c=n("./getusermedia");function a(E){if(typeof WeakMap!="function")return null;var N=new WeakMap,T=new WeakMap;return(a=function(y){return y?T:N})(E)}function s(E,N){if(!N&&E&&E.__esModule)return E;if(E===null||b(E)!="object"&&typeof E!="function")return{default:E};var T=a(N);if(T&&T.has(E))return T.get(E);var y={__proto__:null},D=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var A in E)if(A!=="default"&&{}.hasOwnProperty.call(E,A)){var U=D?Object.getOwnPropertyDescriptor(E,A):null;U&&(U.get||U.set)?Object.defineProperty(y,A,U):y[A]=E[A]}return y.default=E,T&&T.set(E,y),y}function l(E,N,T){return(N=u(N))in E?Object.defineProperty(E,N,{value:T,enumerable:!0,configurable:!0,writable:!0}):E[N]=T,E}function u(E){var N=h(E,"string");return b(N)=="symbol"?N:N+""}function h(E,N){if(b(E)!="object"||!E)return E;var T=E[Symbol.toPrimitive];if(T!==void 0){var y=T.call(E,N||"default");if(b(y)!="object")return y;throw new TypeError("@@toPrimitive must return a primitive value.")}return(N==="string"?String:Number)(E)}function b(E){return b=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(N){return typeof N}:function(N){return N&&typeof Symbol=="function"&&N.constructor===Symbol&&N!==Symbol.prototype?"symbol":typeof N},b(E)}function I(E){E.MediaStream=E.MediaStream||E.webkitMediaStream}function R(E){if(b(E)==="object"&&E.RTCPeerConnection&&!("ontrack"in E.RTCPeerConnection.prototype)){Object.defineProperty(E.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(T){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=T)},enumerable:!0,configurable:!0});var N=E.RTCPeerConnection.prototype.setRemoteDescription;E.RTCPeerConnection.prototype.setRemoteDescription=function(){var T=this;return this._ontrackpoly||(this._ontrackpoly=function(y){y.stream.addEventListener("addtrack",function(D){var A;A=E.RTCPeerConnection.prototype.getReceivers?T.getReceivers().find(function(S){return S.track&&S.track.id===D.track.id}):{track:D.track};var U=new Event("track");U.track=D.track,U.receiver=A,U.transceiver={receiver:A},U.streams=[y.stream],T.dispatchEvent(U)}),y.stream.getTracks().forEach(function(D){var A;A=E.RTCPeerConnection.prototype.getReceivers?T.getReceivers().find(function(S){return S.track&&S.track.id===D.id}):{track:D};var U=new Event("track");U.track=D,U.receiver=A,U.transceiver={receiver:A},U.streams=[y.stream],T.dispatchEvent(U)})},this.addEventListener("addstream",this._ontrackpoly)),N.apply(this,arguments)}}else o.wrapPeerConnectionEvent(E,"track",function(T){return T.transceiver||Object.defineProperty(T,"transceiver",{value:{receiver:T.receiver}}),T})}function x(E){if(b(E)==="object"&&E.RTCPeerConnection&&!("getSenders"in E.RTCPeerConnection.prototype)&&"createDTMFSender"in E.RTCPeerConnection.prototype){var N=function(S,p){return{track:p,get dtmf(){return this._dtmf===void 0&&(p.kind==="audio"?this._dtmf=S.createDTMFSender(p):this._dtmf=null),this._dtmf},_pc:S}};if(!E.RTCPeerConnection.prototype.getSenders){E.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var T=E.RTCPeerConnection.prototype.addTrack;E.RTCPeerConnection.prototype.addTrack=function(S,p){var _=T.apply(this,arguments);return _||(_=N(this,S),this._senders.push(_)),_};var y=E.RTCPeerConnection.prototype.removeTrack;E.RTCPeerConnection.prototype.removeTrack=function(S){y.apply(this,arguments);var p=this._senders.indexOf(S);p!==-1&&this._senders.splice(p,1)}}var D=E.RTCPeerConnection.prototype.addStream;E.RTCPeerConnection.prototype.addStream=function(S){var p=this;this._senders=this._senders||[],D.apply(this,[S]),S.getTracks().forEach(function(_){p._senders.push(N(p,_))})};var A=E.RTCPeerConnection.prototype.removeStream;E.RTCPeerConnection.prototype.removeStream=function(S){var p=this;this._senders=this._senders||[],A.apply(this,[S]),S.getTracks().forEach(function(_){var P=p._senders.find(function(M){return M.track===_});P&&p._senders.splice(p._senders.indexOf(P),1)})}}else if(b(E)==="object"&&E.RTCPeerConnection&&"getSenders"in E.RTCPeerConnection.prototype&&"createDTMFSender"in E.RTCPeerConnection.prototype&&E.RTCRtpSender&&!("dtmf"in E.RTCRtpSender.prototype)){var U=E.RTCPeerConnection.prototype.getSenders;E.RTCPeerConnection.prototype.getSenders=function(){var S=this,p=U.apply(this,[]);return p.forEach(function(_){return _._pc=S}),p},Object.defineProperty(E.RTCRtpSender.prototype,"dtmf",{get:function(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function m(E){if(b(E)==="object"&&E.RTCPeerConnection&&E.RTCRtpSender&&E.RTCRtpReceiver){if(!("getStats"in E.RTCRtpSender.prototype)){var N=E.RTCPeerConnection.prototype.getSenders;N&&(E.RTCPeerConnection.prototype.getSenders=function(){var A=this,U=N.apply(this,[]);return U.forEach(function(S){return S._pc=A}),U});var T=E.RTCPeerConnection.prototype.addTrack;T&&(E.RTCPeerConnection.prototype.addTrack=function(){var A=T.apply(this,arguments);return A._pc=this,A}),E.RTCRtpSender.prototype.getStats=function(){var A=this;return this._pc.getStats().then(function(U){return o.filterStats(U,A.track,!0)})}}if(!("getStats"in E.RTCRtpReceiver.prototype)){var y=E.RTCPeerConnection.prototype.getReceivers;y&&(E.RTCPeerConnection.prototype.getReceivers=function(){var A=this,U=y.apply(this,[]);return U.forEach(function(S){return S._pc=A}),U}),o.wrapPeerConnectionEvent(E,"track",function(A){return A.receiver._pc=A.srcElement,A}),E.RTCRtpReceiver.prototype.getStats=function(){var A=this;return this._pc.getStats().then(function(U){return o.filterStats(U,A.track,!1)})}}if("getStats"in E.RTCRtpSender.prototype&&"getStats"in E.RTCRtpReceiver.prototype){var D=E.RTCPeerConnection.prototype.getStats;E.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof E.MediaStreamTrack){var A,U,S,p=arguments[0];return this.getSenders().forEach(function(_){_.track===p&&(A?S=!0:A=_)}),this.getReceivers().forEach(function(_){return _.track===p&&(U?S=!0:U=_),_.track===p}),S||A&&U?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):A?A.getStats():U?U.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return D.apply(this,arguments)}}}}function k(E){E.RTCPeerConnection.prototype.getLocalStreams=function(){var A=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(U){return A._shimmedLocalStreams[U][0]})};var N=E.RTCPeerConnection.prototype.addTrack;E.RTCPeerConnection.prototype.addTrack=function(A,U){if(!U)return N.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var S=N.apply(this,arguments);return this._shimmedLocalStreams[U.id]?this._shimmedLocalStreams[U.id].indexOf(S)===-1&&this._shimmedLocalStreams[U.id].push(S):this._shimmedLocalStreams[U.id]=[U,S],S};var T=E.RTCPeerConnection.prototype.addStream;E.RTCPeerConnection.prototype.addStream=function(A){var U=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},A.getTracks().forEach(function(_){if(U.getSenders().find(function(P){return P.track===_}))throw new DOMException("Track already exists.","InvalidAccessError")});var S=this.getSenders();T.apply(this,arguments);var p=this.getSenders().filter(function(_){return S.indexOf(_)===-1});this._shimmedLocalStreams[A.id]=[A].concat(p)};var y=E.RTCPeerConnection.prototype.removeStream;E.RTCPeerConnection.prototype.removeStream=function(A){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[A.id],y.apply(this,arguments)};var D=E.RTCPeerConnection.prototype.removeTrack;E.RTCPeerConnection.prototype.removeTrack=function(A){var U=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},A&&Object.keys(this._shimmedLocalStreams).forEach(function(S){var p=U._shimmedLocalStreams[S].indexOf(A);p!==-1&&U._shimmedLocalStreams[S].splice(p,1),U._shimmedLocalStreams[S].length===1&&delete U._shimmedLocalStreams[S]}),D.apply(this,arguments)}}function v(E,N){if(E.RTCPeerConnection){if(E.RTCPeerConnection.prototype.addTrack&&N.version>=65)return k(E);var T=E.RTCPeerConnection.prototype.getLocalStreams;E.RTCPeerConnection.prototype.getLocalStreams=function(){var _=this,P=T.apply(this);return this._reverseStreams=this._reverseStreams||{},P.map(function(M){return _._reverseStreams[M.id]})};var y=E.RTCPeerConnection.prototype.addStream;E.RTCPeerConnection.prototype.addStream=function(_){var P=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},_.getTracks().forEach(function(B){if(P.getSenders().find(function(X){return X.track===B}))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[_.id]){var M=new E.MediaStream(_.getTracks());this._streams[_.id]=M,this._reverseStreams[M.id]=_,_=M}y.apply(this,[_])};var D=E.RTCPeerConnection.prototype.removeStream;E.RTCPeerConnection.prototype.removeStream=function(_){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},D.apply(this,[this._streams[_.id]||_]),delete this._reverseStreams[this._streams[_.id]?this._streams[_.id].id:_.id],delete this._streams[_.id]},E.RTCPeerConnection.prototype.addTrack=function(_,P){var M=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var B=[].slice.call(arguments,1);if(B.length!==1||!B[0].getTracks().find(function(le){return le===_}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(function(le){return le.track===_}))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var X=this._streams[P.id];if(X)X.addTrack(_),Promise.resolve().then(function(){M.dispatchEvent(new Event("negotiationneeded"))});else{var q=new E.MediaStream([_]);this._streams[P.id]=q,this._reverseStreams[q.id]=P,this.addStream(q)}return this.getSenders().find(function(le){return le.track===_})},["createOffer","createAnswer"].forEach(function(_){var P=E.RTCPeerConnection.prototype[_],M=l({},_,function(){var B=this,X=arguments;return arguments.length&&typeof arguments[0]=="function"?P.apply(this,[function(q){var le=S(B,q);X[0].apply(null,[le])},function(q){X[1]&&X[1].apply(null,q)},arguments[2]]):P.apply(this,arguments).then(function(q){return S(B,q)})});E.RTCPeerConnection.prototype[_]=M[_]});var A=E.RTCPeerConnection.prototype.setLocalDescription;E.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=p(this,arguments[0]),A.apply(this,arguments)):A.apply(this,arguments)};var U=Object.getOwnPropertyDescriptor(E.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(E.RTCPeerConnection.prototype,"localDescription",{get:function(){var _=U.get.apply(this);return _.type===""?_:S(this,_)}}),E.RTCPeerConnection.prototype.removeTrack=function(_){var P,M=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!_._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(_._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{},Object.keys(this._streams).forEach(function(B){M._streams[B].getTracks().find(function(X){return _.track===X})&&(P=M._streams[B])}),P&&(P.getTracks().length===1?this.removeStream(this._reverseStreams[P.id]):P.removeTrack(_.track),this.dispatchEvent(new Event("negotiationneeded")))}}function S(_,P){var M=P.sdp;return Object.keys(_._reverseStreams||[]).forEach(function(B){var X=_._reverseStreams[B],q=_._streams[X.id];M=M.replace(new RegExp(q.id,"g"),X.id)}),new RTCSessionDescription({type:P.type,sdp:M})}function p(_,P){var M=P.sdp;return Object.keys(_._reverseStreams||[]).forEach(function(B){var X=_._reverseStreams[B],q=_._streams[X.id];M=M.replace(new RegExp(X.id,"g"),q.id)}),new RTCSessionDescription({type:P.type,sdp:M})}}function w(E,N){!E.RTCPeerConnection&&E.webkitRTCPeerConnection&&(E.RTCPeerConnection=E.webkitRTCPeerConnection),E.RTCPeerConnection&&N.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(T){var y=E.RTCPeerConnection.prototype[T],D=l({},T,function(){return arguments[0]=new(T==="addIceCandidate"?E.RTCIceCandidate:E.RTCSessionDescription)(arguments[0]),y.apply(this,arguments)});E.RTCPeerConnection.prototype[T]=D[T]})}function L(E,N){o.wrapPeerConnectionEvent(E,"negotiationneeded",function(T){var y=T.target;if(!(N.version<72||y.getConfiguration&&y.getConfiguration().sdpSemantics==="plan-b")||y.signalingState==="stable")return T})}},{"../utils.js":10,"./getusermedia":4}],4:[function(n,i,r){function o(u){if(typeof WeakMap!="function")return null;var h=new WeakMap,b=new WeakMap;return(o=function(I){return I?b:h})(u)}function c(u,h){if(!h&&u&&u.__esModule)return u;if(u===null||a(u)!="object"&&typeof u!="function")return{default:u};var b=o(h);if(b&&b.has(u))return b.get(u);var I={__proto__:null},R=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var x in u)if(x!=="default"&&{}.hasOwnProperty.call(u,x)){var m=R?Object.getOwnPropertyDescriptor(u,x):null;m&&(m.get||m.set)?Object.defineProperty(I,x,m):I[x]=u[x]}return I.default=u,b&&b.set(u,I),I}function a(u){return a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},a(u)}Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetUserMedia=l;var s=c(n("../utils.js")).log;function l(u,h){var b=u&&u.navigator;if(b.mediaDevices){var I=function(v){if(a(v)!=="object"||v.mandatory||v.optional)return v;var w={};return Object.keys(v).forEach(function(L){if(L!=="require"&&L!=="advanced"&&L!=="mediaSource"){var E=a(v[L])==="object"?v[L]:{ideal:v[L]};E.exact!==void 0&&typeof E.exact=="number"&&(E.min=E.max=E.exact);var N=function(y,D){return y?y+D.charAt(0).toUpperCase()+D.slice(1):D==="deviceId"?"sourceId":D};if(E.ideal!==void 0){w.optional=w.optional||[];var T={};typeof E.ideal=="number"?(T[N("min",L)]=E.ideal,w.optional.push(T),(T={})[N("max",L)]=E.ideal,w.optional.push(T)):(T[N("",L)]=E.ideal,w.optional.push(T))}E.exact!==void 0&&typeof E.exact!="number"?(w.mandatory=w.mandatory||{},w.mandatory[N("",L)]=E.exact):["min","max"].forEach(function(y){E[y]!==void 0&&(w.mandatory=w.mandatory||{},w.mandatory[N(y,L)]=E[y])})}}),v.advanced&&(w.optional=(w.optional||[]).concat(v.advanced)),w},R=function(v,w){if(h.version>=61)return w(v);if((v=JSON.parse(JSON.stringify(v)))&&a(v.audio)==="object"){var L=function(y,D,A){D in y&&!(A in y)&&(y[A]=y[D],delete y[D])};L((v=JSON.parse(JSON.stringify(v))).audio,"autoGainControl","googAutoGainControl"),L(v.audio,"noiseSuppression","googNoiseSuppression"),v.audio=I(v.audio)}if(v&&a(v.video)==="object"){var E=v.video.facingMode;E=E&&(a(E)==="object"?E:{ideal:E});var N,T=h.version<66;if(E&&(E.exact==="user"||E.exact==="environment"||E.ideal==="user"||E.ideal==="environment")&&(!b.mediaDevices.getSupportedConstraints||!b.mediaDevices.getSupportedConstraints().facingMode||T)&&(delete v.video.facingMode,E.exact==="environment"||E.ideal==="environment"?N=["back","rear"]:E.exact!=="user"&&E.ideal!=="user"||(N=["front"]),N))return b.mediaDevices.enumerateDevices().then(function(y){var D=(y=y.filter(function(A){return A.kind==="videoinput"})).find(function(A){return N.some(function(U){return A.label.toLowerCase().includes(U)})});return!D&&y.length&&N.includes("back")&&(D=y[y.length-1]),D&&(v.video.deviceId=E.exact?{exact:D.deviceId}:{ideal:D.deviceId}),v.video=I(v.video),s("chrome: "+JSON.stringify(v)),w(v)});v.video=I(v.video)}return s("chrome: "+JSON.stringify(v)),w(v)},x=function(v){return h.version>=64?v:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[v.name]||v.name,message:v.message,constraint:v.constraint||v.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},m=function(v,w,L){R(v,function(E){b.webkitGetUserMedia(E,w,function(N){L&&L(x(N))})})};if(b.getUserMedia=m.bind(b),b.mediaDevices.getUserMedia){var k=b.mediaDevices.getUserMedia.bind(b.mediaDevices);b.mediaDevices.getUserMedia=function(v){return R(v,function(w){return k(w).then(function(L){if(w.audio&&!L.getAudioTracks().length||w.video&&!L.getVideoTracks().length)throw L.getTracks().forEach(function(E){E.stop()}),new DOMException("","NotFoundError");return L},function(L){return Promise.reject(x(L))})})}}}}},{"../utils.js":10}],5:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.removeExtmapAllowMixed=m,r.shimAddIceCandidateNullOrEmpty=k,r.shimConnectionState=x,r.shimMaxMessageSize=I,r.shimParameterlessSetLocalDescription=v,r.shimRTCIceCandidate=h,r.shimRTCIceCandidateRelayProtocol=b,r.shimSendThrowTypeError=R;var o=l(n("sdp")),c=s(n("./utils"));function a(w){if(typeof WeakMap!="function")return null;var L=new WeakMap,E=new WeakMap;return(a=function(N){return N?E:L})(w)}function s(w,L){if(!L&&w&&w.__esModule)return w;if(w===null||u(w)!="object"&&typeof w!="function")return{default:w};var E=a(L);if(E&&E.has(w))return E.get(w);var N={__proto__:null},T=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var y in w)if(y!=="default"&&{}.hasOwnProperty.call(w,y)){var D=T?Object.getOwnPropertyDescriptor(w,y):null;D&&(D.get||D.set)?Object.defineProperty(N,y,D):N[y]=w[y]}return N.default=w,E&&E.set(w,N),N}function l(w){return w&&w.__esModule?w:{default:w}}function u(w){return u=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(L){return typeof L}:function(L){return L&&typeof Symbol=="function"&&L.constructor===Symbol&&L!==Symbol.prototype?"symbol":typeof L},u(w)}function h(w){if(!(!w.RTCIceCandidate||w.RTCIceCandidate&&"foundation"in w.RTCIceCandidate.prototype)){var L=w.RTCIceCandidate;w.RTCIceCandidate=function(E){if(u(E)==="object"&&E.candidate&&E.candidate.indexOf("a=")===0&&((E=JSON.parse(JSON.stringify(E))).candidate=E.candidate.substring(2)),E.candidate&&E.candidate.length){var N=new L(E),T=o.default.parseCandidate(E.candidate);for(var y in T)y in N||Object.defineProperty(N,y,{value:T[y]});return N.toJSON=function(){return{candidate:N.candidate,sdpMid:N.sdpMid,sdpMLineIndex:N.sdpMLineIndex,usernameFragment:N.usernameFragment}},N}return new L(E)},w.RTCIceCandidate.prototype=L.prototype,c.wrapPeerConnectionEvent(w,"icecandidate",function(E){return E.candidate&&Object.defineProperty(E,"candidate",{value:new w.RTCIceCandidate(E.candidate),writable:"false"}),E})}}function b(w){!w.RTCIceCandidate||w.RTCIceCandidate&&"relayProtocol"in w.RTCIceCandidate.prototype||c.wrapPeerConnectionEvent(w,"icecandidate",function(L){if(L.candidate){var E=o.default.parseCandidate(L.candidate.candidate);E.type==="relay"&&(L.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[E.priority>>24])}return L})}function I(w,L){if(w.RTCPeerConnection){"sctp"in w.RTCPeerConnection.prototype||Object.defineProperty(w.RTCPeerConnection.prototype,"sctp",{get:function(){return this._sctp===void 0?null:this._sctp}});var E=function(A){if(!A||!A.sdp)return!1;var U=o.default.splitSections(A.sdp);return U.shift(),U.some(function(S){var p=o.default.parseMLine(S);return p&&p.kind==="application"&&p.protocol.indexOf("SCTP")!==-1})},N=function(A){var U=A.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(U===null||U.length<2)return-1;var S=parseInt(U[1],10);return S!=S?-1:S},T=function(A){var U=65536;return L.browser==="firefox"&&(U=L.version<57?A===-1?16384:2147483637:L.version<60?L.version===57?65535:65536:2147483637),U},y=function(A,U){var S=65536;L.browser==="firefox"&&L.version===57&&(S=65535);var p=o.default.matchPrefix(A.sdp,"a=max-message-size:");return p.length>0?S=parseInt(p[0].substring(19),10):L.browser==="firefox"&&U!==-1&&(S=2147483637),S},D=w.RTCPeerConnection.prototype.setRemoteDescription;w.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,L.browser==="chrome"&&L.version>=76&&this.getConfiguration().sdpSemantics==="plan-b"&&Object.defineProperty(this,"sctp",{get:function(){return this._sctp===void 0?null:this._sctp},enumerable:!0,configurable:!0}),E(arguments[0])){var A,U=N(arguments[0]),S=T(U),p=y(arguments[0],U);A=S===0&&p===0?Number.POSITIVE_INFINITY:S===0||p===0?Math.max(S,p):Math.min(S,p);var _={};Object.defineProperty(_,"maxMessageSize",{get:function(){return A}}),this._sctp=_}return D.apply(this,arguments)}}}function R(w){if(w.RTCPeerConnection&&"createDataChannel"in w.RTCPeerConnection.prototype){var L=w.RTCPeerConnection.prototype.createDataChannel;w.RTCPeerConnection.prototype.createDataChannel=function(){var N=L.apply(this,arguments);return E(N,this),N},c.wrapPeerConnectionEvent(w,"datachannel",function(N){return E(N.channel,N.target),N})}function E(N,T){var y=N.send;N.send=function(){var D=arguments[0],A=D.length||D.size||D.byteLength;if(N.readyState==="open"&&T.sctp&&A>T.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+T.sctp.maxMessageSize+" bytes)");return y.apply(N,arguments)}}}function x(w){if(w.RTCPeerConnection&&!("connectionState"in w.RTCPeerConnection.prototype)){var L=w.RTCPeerConnection.prototype;Object.defineProperty(L,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(L,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(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(function(E){var N=L[E];L[E]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(T){var y=T.target;if(y._lastConnectionState!==y.connectionState){y._lastConnectionState=y.connectionState;var D=new Event("connectionstatechange",T);y.dispatchEvent(D)}return T},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),N.apply(this,arguments)}})}}function m(w,L){if(w.RTCPeerConnection&&!(L.browser==="chrome"&&L.version>=71||L.browser==="safari"&&L.version>=605)){var E=w.RTCPeerConnection.prototype.setRemoteDescription;w.RTCPeerConnection.prototype.setRemoteDescription=function(N){if(N&&N.sdp&&N.sdp.indexOf(`
5
+ a=extmap-allow-mixed`)!==-1){var T=N.sdp.split(`
6
+ `).filter(function(y){return y.trim()!=="a=extmap-allow-mixed"}).join(`
7
+ `);w.RTCSessionDescription&&N instanceof w.RTCSessionDescription?arguments[0]=new w.RTCSessionDescription({type:N.type,sdp:T}):N.sdp=T}return E.apply(this,arguments)}}}function k(w,L){if(w.RTCPeerConnection&&w.RTCPeerConnection.prototype){var E=w.RTCPeerConnection.prototype.addIceCandidate;E&&E.length!==0&&(w.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(L.browser==="chrome"&&L.version<78||L.browser==="firefox"&&L.version<68||L.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():E.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}}function v(w,L){if(w.RTCPeerConnection&&w.RTCPeerConnection.prototype){var E=w.RTCPeerConnection.prototype.setLocalDescription;E&&E.length!==0&&(w.RTCPeerConnection.prototype.setLocalDescription=function(){var N=this,T=arguments[0]||{};if(u(T)!=="object"||T.type&&T.sdp)return E.apply(this,arguments);if(!(T={type:T.type,sdp:T.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":T.type="offer";break;default:T.type="answer"}return T.sdp||T.type!=="offer"&&T.type!=="answer"?E.apply(this,[T]):(T.type==="offer"?this.createOffer:this.createAnswer).apply(this).then(function(y){return E.apply(N,[y])})})}}},{"./utils":10,sdp:11}],6:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimAddTransceiver=A,r.shimCreateAnswer=p,r.shimCreateOffer=S,Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimGetParameters=U,Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return c.shimGetUserMedia}}),r.shimOnTrack=L,r.shimPeerConnection=E,r.shimRTCDataChannel=D,r.shimReceiverGetStats=T,r.shimRemoveStream=y,r.shimSenderGetStats=N;var o=l(n("../utils")),c=n("./getusermedia"),a=n("./getdisplaymedia");function s(_){if(typeof WeakMap!="function")return null;var P=new WeakMap,M=new WeakMap;return(s=function(B){return B?M:P})(_)}function l(_,P){if(!P&&_&&_.__esModule)return _;if(_===null||w(_)!="object"&&typeof _!="function")return{default:_};var M=s(P);if(M&&M.has(_))return M.get(_);var B={__proto__:null},X=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var q in _)if(q!=="default"&&{}.hasOwnProperty.call(_,q)){var le=X?Object.getOwnPropertyDescriptor(_,q):null;le&&(le.get||le.set)?Object.defineProperty(B,q,le):B[q]=_[q]}return B.default=_,M&&M.set(_,B),B}function u(_){return R(_)||I(_)||b(_)||h()}function h(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
8
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function b(_,P){if(_){if(typeof _=="string")return x(_,P);var M=Object.prototype.toString.call(_).slice(8,-1);return M==="Object"&&_.constructor&&(M=_.constructor.name),M==="Map"||M==="Set"?Array.from(_):M==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(M)?x(_,P):void 0}}function I(_){if(typeof Symbol!="undefined"&&_[Symbol.iterator]!=null||_["@@iterator"]!=null)return Array.from(_)}function R(_){if(Array.isArray(_))return x(_)}function x(_,P){(P==null||P>_.length)&&(P=_.length);for(var M=0,B=new Array(P);M<P;M++)B[M]=_[M];return B}function m(_,P,M){return(P=k(P))in _?Object.defineProperty(_,P,{value:M,enumerable:!0,configurable:!0,writable:!0}):_[P]=M,_}function k(_){var P=v(_,"string");return w(P)=="symbol"?P:P+""}function v(_,P){if(w(_)!="object"||!_)return _;var M=_[Symbol.toPrimitive];if(M!==void 0){var B=M.call(_,P||"default");if(w(B)!="object")return B;throw new TypeError("@@toPrimitive must return a primitive value.")}return(P==="string"?String:Number)(_)}function w(_){return w=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(P){return typeof P}:function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},w(_)}function L(_){w(_)==="object"&&_.RTCTrackEvent&&"receiver"in _.RTCTrackEvent.prototype&&!("transceiver"in _.RTCTrackEvent.prototype)&&Object.defineProperty(_.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function E(_,P){if(w(_)==="object"&&(_.RTCPeerConnection||_.mozRTCPeerConnection)){!_.RTCPeerConnection&&_.mozRTCPeerConnection&&(_.RTCPeerConnection=_.mozRTCPeerConnection),P.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(X){var q=_.RTCPeerConnection.prototype[X],le=m({},X,function(){return arguments[0]=new(X==="addIceCandidate"?_.RTCIceCandidate:_.RTCSessionDescription)(arguments[0]),q.apply(this,arguments)});_.RTCPeerConnection.prototype[X]=le[X]});var M={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},B=_.RTCPeerConnection.prototype.getStats;_.RTCPeerConnection.prototype.getStats=function(){var X=Array.prototype.slice.call(arguments),q=X[0],le=X[1],ce=X[2];return B.apply(this,[q||null]).then(function(Ze){if(P.version<53&&!le)try{Ze.forEach(function(Ue){Ue.type=M[Ue.type]||Ue.type})}catch(Ue){if(Ue.name!=="TypeError")throw Ue;Ze.forEach(function(Fe,ht){Ze.set(ht,Object.assign({},Fe,{type:M[Fe.type]||Fe.type}))})}return Ze}).then(le,ce)}}}function N(_){if(w(_)==="object"&&_.RTCPeerConnection&&_.RTCRtpSender&&(!_.RTCRtpSender||!("getStats"in _.RTCRtpSender.prototype))){var P=_.RTCPeerConnection.prototype.getSenders;P&&(_.RTCPeerConnection.prototype.getSenders=function(){var B=this,X=P.apply(this,[]);return X.forEach(function(q){return q._pc=B}),X});var M=_.RTCPeerConnection.prototype.addTrack;M&&(_.RTCPeerConnection.prototype.addTrack=function(){var B=M.apply(this,arguments);return B._pc=this,B}),_.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}}function T(_){if(w(_)==="object"&&_.RTCPeerConnection&&_.RTCRtpSender&&(!_.RTCRtpSender||!("getStats"in _.RTCRtpReceiver.prototype))){var P=_.RTCPeerConnection.prototype.getReceivers;P&&(_.RTCPeerConnection.prototype.getReceivers=function(){var M=this,B=P.apply(this,[]);return B.forEach(function(X){return X._pc=M}),B}),o.wrapPeerConnectionEvent(_,"track",function(M){return M.receiver._pc=M.srcElement,M}),_.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function y(_){_.RTCPeerConnection&&!("removeStream"in _.RTCPeerConnection.prototype)&&(_.RTCPeerConnection.prototype.removeStream=function(P){var M=this;o.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(B){B.track&&P.getTracks().includes(B.track)&&M.removeTrack(B)})})}function D(_){_.DataChannel&&!_.RTCDataChannel&&(_.RTCDataChannel=_.DataChannel)}function A(_){if(w(_)==="object"&&_.RTCPeerConnection){var P=_.RTCPeerConnection.prototype.addTransceiver;P&&(_.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var M=arguments[1]&&arguments[1].sendEncodings;M===void 0&&(M=[]);var B=(M=u(M)).length>0;B&&M.forEach(function(ce){if("rid"in ce&&!/^[a-z0-9]{0,16}$/i.test(ce.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in ce&&!(parseFloat(ce.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in ce&&!(parseFloat(ce.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});var X=P.apply(this,arguments);if(B){var q=X.sender,le=q.getParameters();(!("encodings"in le)||le.encodings.length===1&&Object.keys(le.encodings[0]).length===0)&&(le.encodings=M,q.sendEncodings=M,this.setParametersPromises.push(q.setParameters(le).then(function(){delete q.sendEncodings}).catch(function(){delete q.sendEncodings})))}return X})}}function U(_){if(w(_)==="object"&&_.RTCRtpSender){var P=_.RTCRtpSender.prototype.getParameters;P&&(_.RTCRtpSender.prototype.getParameters=function(){var M=P.apply(this,arguments);return"encodings"in M||(M.encodings=[].concat(this.sendEncodings||[{}])),M})}}function S(_){if(w(_)==="object"&&_.RTCPeerConnection){var P=_.RTCPeerConnection.prototype.createOffer;_.RTCPeerConnection.prototype.createOffer=function(){var M=arguments,B=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return P.apply(B,M)}).finally(function(){B.setParametersPromises=[]}):P.apply(this,arguments)}}}function p(_){if(w(_)==="object"&&_.RTCPeerConnection){var P=_.RTCPeerConnection.prototype.createAnswer;_.RTCPeerConnection.prototype.createAnswer=function(){var M=arguments,B=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return P.apply(B,M)}).finally(function(){B.setParametersPromises=[]}):P.apply(this,arguments)}}}},{"../utils":10,"./getdisplaymedia":7,"./getusermedia":8}],7:[function(n,i,r){function o(c,a){c.navigator.mediaDevices&&"getDisplayMedia"in c.navigator.mediaDevices||c.navigator.mediaDevices&&(c.navigator.mediaDevices.getDisplayMedia=function(s){if(!s||!s.video){var l=new DOMException("getDisplayMedia without video constraints is undefined");return l.name="NotFoundError",l.code=8,Promise.reject(l)}return s.video===!0?s.video={mediaSource:a}:s.video.mediaSource=a,c.navigator.mediaDevices.getUserMedia(s)})}Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=o},{}],8:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetUserMedia=l;var o=a(n("../utils"));function c(u){if(typeof WeakMap!="function")return null;var h=new WeakMap,b=new WeakMap;return(c=function(I){return I?b:h})(u)}function a(u,h){if(!h&&u&&u.__esModule)return u;if(u===null||s(u)!="object"&&typeof u!="function")return{default:u};var b=c(h);if(b&&b.has(u))return b.get(u);var I={__proto__:null},R=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var x in u)if(x!=="default"&&{}.hasOwnProperty.call(u,x)){var m=R?Object.getOwnPropertyDescriptor(u,x):null;m&&(m.get||m.set)?Object.defineProperty(I,x,m):I[x]=u[x]}return I.default=u,b&&b.set(u,I),I}function s(u){return s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},s(u)}function l(u,h){var b=u&&u.navigator,I=u&&u.MediaStreamTrack;if(b.getUserMedia=function(v,w,L){o.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),b.mediaDevices.getUserMedia(v).then(w,L)},!(h.version>55&&"autoGainControl"in b.mediaDevices.getSupportedConstraints())){var R=function(v,w,L){w in v&&!(L in v)&&(v[L]=v[w],delete v[w])},x=b.mediaDevices.getUserMedia.bind(b.mediaDevices);if(b.mediaDevices.getUserMedia=function(v){return s(v)==="object"&&s(v.audio)==="object"&&(v=JSON.parse(JSON.stringify(v)),R(v.audio,"autoGainControl","mozAutoGainControl"),R(v.audio,"noiseSuppression","mozNoiseSuppression")),x(v)},I&&I.prototype.getSettings){var m=I.prototype.getSettings;I.prototype.getSettings=function(){var v=m.apply(this,arguments);return R(v,"mozAutoGainControl","autoGainControl"),R(v,"mozNoiseSuppression","noiseSuppression"),v}}if(I&&I.prototype.applyConstraints){var k=I.prototype.applyConstraints;I.prototype.applyConstraints=function(v){return this.kind==="audio"&&s(v)==="object"&&(v=JSON.parse(JSON.stringify(v)),R(v,"autoGainControl","mozAutoGainControl"),R(v,"noiseSuppression","mozNoiseSuppression")),k.apply(this,[v])}}}}},{"../utils":10}],9:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimAudioContext=k,r.shimCallbacksAPI=h,r.shimConstraints=I,r.shimCreateOfferLegacy=m,r.shimGetUserMedia=b,r.shimLocalStreamsAPI=l,r.shimRTCIceServerUrls=R,r.shimRemoteStreamsAPI=u,r.shimTrackEventTransceiver=x;var o=a(n("../utils"));function c(v){if(typeof WeakMap!="function")return null;var w=new WeakMap,L=new WeakMap;return(c=function(E){return E?L:w})(v)}function a(v,w){if(!w&&v&&v.__esModule)return v;if(v===null||s(v)!="object"&&typeof v!="function")return{default:v};var L=c(w);if(L&&L.has(v))return L.get(v);var E={__proto__:null},N=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var T in v)if(T!=="default"&&{}.hasOwnProperty.call(v,T)){var y=N?Object.getOwnPropertyDescriptor(v,T):null;y&&(y.get||y.set)?Object.defineProperty(E,T,y):E[T]=v[T]}return E.default=v,L&&L.set(v,E),E}function s(v){return s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(w){return typeof w}:function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},s(v)}function l(v){if(s(v)==="object"&&v.RTCPeerConnection){if("getLocalStreams"in v.RTCPeerConnection.prototype||(v.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in v.RTCPeerConnection.prototype)){var w=v.RTCPeerConnection.prototype.addTrack;v.RTCPeerConnection.prototype.addStream=function(L){var E=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(L)||this._localStreams.push(L),L.getAudioTracks().forEach(function(N){return w.call(E,N,L)}),L.getVideoTracks().forEach(function(N){return w.call(E,N,L)})},v.RTCPeerConnection.prototype.addTrack=function(L){for(var E=this,N=arguments.length,T=new Array(N>1?N-1:0),y=1;y<N;y++)T[y-1]=arguments[y];return T&&T.forEach(function(D){E._localStreams?E._localStreams.includes(D)||E._localStreams.push(D):E._localStreams=[D]}),w.apply(this,arguments)}}"removeStream"in v.RTCPeerConnection.prototype||(v.RTCPeerConnection.prototype.removeStream=function(L){var E=this;this._localStreams||(this._localStreams=[]);var N=this._localStreams.indexOf(L);if(N!==-1){this._localStreams.splice(N,1);var T=L.getTracks();this.getSenders().forEach(function(y){T.includes(y.track)&&E.removeTrack(y)})}})}}function u(v){if(s(v)==="object"&&v.RTCPeerConnection&&("getRemoteStreams"in v.RTCPeerConnection.prototype||(v.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in v.RTCPeerConnection.prototype))){Object.defineProperty(v.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(L){var E=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=L),this.addEventListener("track",this._onaddstreampoly=function(N){N.streams.forEach(function(T){if(E._remoteStreams||(E._remoteStreams=[]),!E._remoteStreams.includes(T)){E._remoteStreams.push(T);var y=new Event("addstream");y.stream=T,E.dispatchEvent(y)}})})}});var w=v.RTCPeerConnection.prototype.setRemoteDescription;v.RTCPeerConnection.prototype.setRemoteDescription=function(){var L=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(E){E.streams.forEach(function(N){if(L._remoteStreams||(L._remoteStreams=[]),!(L._remoteStreams.indexOf(N)>=0)){L._remoteStreams.push(N);var T=new Event("addstream");T.stream=N,L.dispatchEvent(T)}})}),w.apply(L,arguments)}}}function h(v){if(s(v)==="object"&&v.RTCPeerConnection){var w=v.RTCPeerConnection.prototype,L=w.createOffer,E=w.createAnswer,N=w.setLocalDescription,T=w.setRemoteDescription,y=w.addIceCandidate;w.createOffer=function(A,U){var S=arguments.length>=2?arguments[2]:arguments[0],p=L.apply(this,[S]);return U?(p.then(A,U),Promise.resolve()):p},w.createAnswer=function(A,U){var S=arguments.length>=2?arguments[2]:arguments[0],p=E.apply(this,[S]);return U?(p.then(A,U),Promise.resolve()):p};var D=function(A,U,S){var p=N.apply(this,[A]);return S?(p.then(U,S),Promise.resolve()):p};w.setLocalDescription=D,D=function(A,U,S){var p=T.apply(this,[A]);return S?(p.then(U,S),Promise.resolve()):p},w.setRemoteDescription=D,D=function(A,U,S){var p=y.apply(this,[A]);return S?(p.then(U,S),Promise.resolve()):p},w.addIceCandidate=D}}function b(v){var w=v&&v.navigator;if(w.mediaDevices&&w.mediaDevices.getUserMedia){var L=w.mediaDevices,E=L.getUserMedia.bind(L);w.mediaDevices.getUserMedia=function(N){return E(I(N))}}!w.getUserMedia&&w.mediaDevices&&w.mediaDevices.getUserMedia&&(w.getUserMedia=function(N,T,y){w.mediaDevices.getUserMedia(N).then(T,y)}.bind(w))}function I(v){return v&&v.video!==void 0?Object.assign({},v,{video:o.compactObject(v.video)}):v}function R(v){if(v.RTCPeerConnection){var w=v.RTCPeerConnection;v.RTCPeerConnection=function(L,E){if(L&&L.iceServers){for(var N=[],T=0;T<L.iceServers.length;T++){var y=L.iceServers[T];y.urls===void 0&&y.url?(o.deprecated("RTCIceServer.url","RTCIceServer.urls"),(y=JSON.parse(JSON.stringify(y))).urls=y.url,delete y.url,N.push(y)):N.push(L.iceServers[T])}L.iceServers=N}return new w(L,E)},v.RTCPeerConnection.prototype=w.prototype,"generateCertificate"in w&&Object.defineProperty(v.RTCPeerConnection,"generateCertificate",{get:function(){return w.generateCertificate}})}}function x(v){s(v)==="object"&&v.RTCTrackEvent&&"receiver"in v.RTCTrackEvent.prototype&&!("transceiver"in v.RTCTrackEvent.prototype)&&Object.defineProperty(v.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function m(v){var w=v.RTCPeerConnection.prototype.createOffer;v.RTCPeerConnection.prototype.createOffer=function(L){if(L){L.offerToReceiveAudio!==void 0&&(L.offerToReceiveAudio=!!L.offerToReceiveAudio);var E=this.getTransceivers().find(function(T){return T.receiver.track.kind==="audio"});L.offerToReceiveAudio===!1&&E?E.direction==="sendrecv"?E.setDirection?E.setDirection("sendonly"):E.direction="sendonly":E.direction==="recvonly"&&(E.setDirection?E.setDirection("inactive"):E.direction="inactive"):L.offerToReceiveAudio!==!0||E||this.addTransceiver("audio",{direction:"recvonly"}),L.offerToReceiveVideo!==void 0&&(L.offerToReceiveVideo=!!L.offerToReceiveVideo);var N=this.getTransceivers().find(function(T){return T.receiver.track.kind==="video"});L.offerToReceiveVideo===!1&&N?N.direction==="sendrecv"?N.setDirection?N.setDirection("sendonly"):N.direction="sendonly":N.direction==="recvonly"&&(N.setDirection?N.setDirection("inactive"):N.direction="inactive"):L.offerToReceiveVideo!==!0||N||this.addTransceiver("video",{direction:"recvonly"})}return w.apply(this,arguments)}}function k(v){s(v)!=="object"||v.AudioContext||(v.AudioContext=v.webkitAudioContext)}},{"../utils":10}],10:[function(n,i,r){function o(N,T,y){return(T=c(T))in N?Object.defineProperty(N,T,{value:y,enumerable:!0,configurable:!0,writable:!0}):N[T]=y,N}function c(N){var T=a(N,"string");return s(T)=="symbol"?T:T+""}function a(N,T){if(s(N)!="object"||!N)return N;var y=N[Symbol.toPrimitive];if(y!==void 0){var D=y.call(N,T||"default");if(s(D)!="object")return D;throw new TypeError("@@toPrimitive must return a primitive value.")}return(T==="string"?String:Number)(N)}function s(N){return s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(T){return typeof T}:function(T){return T&&typeof Symbol=="function"&&T.constructor===Symbol&&T!==Symbol.prototype?"symbol":typeof T},s(N)}Object.defineProperty(r,"__esModule",{value:!0}),r.compactObject=w,r.deprecated=m,r.detectBrowser=k,r.disableLog=I,r.disableWarnings=R,r.extractVersion=h,r.filterStats=E,r.log=x,r.walkStats=L,r.wrapPeerConnectionEvent=b;var l=!0,u=!0;function h(N,T,y){var D=N.match(T);return D&&D.length>=y&&parseInt(D[y],10)}function b(N,T,y){if(N.RTCPeerConnection){var D=N.RTCPeerConnection.prototype,A=D.addEventListener;D.addEventListener=function(S,p){if(S!==T)return A.apply(this,arguments);var _=function(P){var M=y(P);M&&(p.handleEvent?p.handleEvent(M):p(M))};return this._eventMap=this._eventMap||{},this._eventMap[T]||(this._eventMap[T]=new Map),this._eventMap[T].set(p,_),A.apply(this,[S,_])};var U=D.removeEventListener;D.removeEventListener=function(S,p){if(S!==T||!this._eventMap||!this._eventMap[T])return U.apply(this,arguments);if(!this._eventMap[T].has(p))return U.apply(this,arguments);var _=this._eventMap[T].get(p);return this._eventMap[T].delete(p),this._eventMap[T].size===0&&delete this._eventMap[T],Object.keys(this._eventMap).length===0&&delete this._eventMap,U.apply(this,[S,_])},Object.defineProperty(D,"on"+T,{get:function(){return this["_on"+T]},set:function(S){this["_on"+T]&&(this.removeEventListener(T,this["_on"+T]),delete this["_on"+T]),S&&this.addEventListener(T,this["_on"+T]=S)},enumerable:!0,configurable:!0})}}function I(N){return typeof N!="boolean"?new Error("Argument type: "+s(N)+". Please use a boolean."):(l=N,N?"adapter.js logging disabled":"adapter.js logging enabled")}function R(N){return typeof N!="boolean"?new Error("Argument type: "+s(N)+". Please use a boolean."):(u=!N,"adapter.js deprecation warnings "+(N?"disabled":"enabled"))}function x(){if((typeof window=="undefined"?"undefined":s(window))==="object"){if(l)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function m(N,T){u&&console.warn(N+" is deprecated, please use "+T+" instead.")}function k(N){var T={browser:null,version:null};if(N===void 0||!N.navigator||!N.navigator.userAgent)return T.browser="Not a browser.",T;var y=N.navigator;if(y.userAgentData&&y.userAgentData.brands){var D=y.userAgentData.brands.find(function(A){return A.brand==="Chromium"});if(D)return{browser:"chrome",version:parseInt(D.version,10)}}if(y.mozGetUserMedia)T.browser="firefox",T.version=h(y.userAgent,/Firefox\/(\d+)\./,1);else if(y.webkitGetUserMedia||N.isSecureContext===!1&&N.webkitRTCPeerConnection)T.browser="chrome",T.version=h(y.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!N.RTCPeerConnection||!y.userAgent.match(/AppleWebKit\/(\d+)\./))return T.browser="Not a supported browser.",T;T.browser="safari",T.version=h(y.userAgent,/AppleWebKit\/(\d+)\./,1),T.supportsUnifiedPlan=N.RTCRtpTransceiver&&"currentDirection"in N.RTCRtpTransceiver.prototype}return T}function v(N){return Object.prototype.toString.call(N)==="[object Object]"}function w(N){return v(N)?Object.keys(N).reduce(function(T,y){var D=v(N[y]),A=D?w(N[y]):N[y],U=D&&!Object.keys(A).length;return A===void 0||U?T:Object.assign(T,o({},y,A))},{}):N}function L(N,T,y){T&&!y.has(T.id)&&(y.set(T.id,T),Object.keys(T).forEach(function(D){D.endsWith("Id")?L(N,N.get(T[D]),y):D.endsWith("Ids")&&T[D].forEach(function(A){L(N,N.get(A),y)})}))}function E(N,T,y){var D=y?"outbound-rtp":"inbound-rtp",A=new Map;if(T===null)return A;var U=[];return N.forEach(function(S){S.type==="track"&&S.trackIdentifier===T.id&&U.push(S)}),U.forEach(function(S){N.forEach(function(p){p.type===D&&p.trackId===S.id&&L(N,p,A)})}),A}},{}],11:[function(n,i,r){var o=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},c={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};c.localCName=c.generateIdentifier(),c.splitLines=function(a){return a.trim().split(`
9
9
  `).map(function(s){return s.trim()})},c.splitSections=function(a){return a.split(`
10
10
  m=`).map(function(s,l){return(l>0?"m="+s:s).trim()+`\r
11
11
  `})},c.getDescription=function(a){var s=c.splitSections(a);return s&&s[0]},c.getMediaSections=function(a){var s=c.splitSections(a);return s.shift(),s},c.matchPrefix=function(a,s){return c.splitLines(a).filter(function(l){return l.indexOf(s)===0})},c.parseCandidate=function(a){for(var s=void 0,l={foundation:(s=a.indexOf("a=candidate:")===0?a.substring(12).split(" "):a.substring(10).split(" "))[0],component:{1:"rtp",2:"rtcp"}[s[1]]||s[1],protocol:s[2].toLowerCase(),priority:parseInt(s[3],10),ip:s[4],address:s[4],port:parseInt(s[5],10),type:s[7]},u=8;u<s.length;u+=2)switch(s[u]){case"raddr":l.relatedAddress=s[u+1];break;case"rport":l.relatedPort=parseInt(s[u+1],10);break;case"tcptype":l.tcpType=s[u+1];break;case"ufrag":l.ufrag=s[u+1],l.usernameFragment=s[u+1];break;default:l[s[u]]===void 0&&(l[s[u]]=s[u+1])}return l},c.writeCandidate=function(a){var s=[];s.push(a.foundation);var l=a.component;l==="rtp"?s.push(1):l==="rtcp"?s.push(2):s.push(l),s.push(a.protocol.toUpperCase()),s.push(a.priority),s.push(a.address||a.ip),s.push(a.port);var u=a.type;return s.push("typ"),s.push(u),u!=="host"&&a.relatedAddress&&a.relatedPort&&(s.push("raddr"),s.push(a.relatedAddress),s.push("rport"),s.push(a.relatedPort)),a.tcpType&&a.protocol.toLowerCase()==="tcp"&&(s.push("tcptype"),s.push(a.tcpType)),(a.usernameFragment||a.ufrag)&&(s.push("ufrag"),s.push(a.usernameFragment||a.ufrag)),"candidate:"+s.join(" ")},c.parseIceOptions=function(a){return a.substring(14).split(" ")},c.parseRtpMap=function(a){var s=a.substring(9).split(" "),l={payloadType:parseInt(s.shift(),10)};return s=s[0].split("/"),l.name=s[0],l.clockRate=parseInt(s[1],10),l.channels=s.length===3?parseInt(s[2],10):1,l.numChannels=l.channels,l},c.writeRtpMap=function(a){var s=a.payloadType;a.preferredPayloadType!==void 0&&(s=a.preferredPayloadType);var l=a.channels||a.numChannels||1;return"a=rtpmap:"+s+" "+a.name+"/"+a.clockRate+(l!==1?"/"+l:"")+`\r
@@ -18,14 +18,14 @@ m=`).map(function(s,l){return(l>0?"m="+s:s).trim()+`\r
18
18
  `},c.parseCryptoKeyParams=function(a){if(a.indexOf("inline:")!==0)return null;var s=a.substring(7).split("|");return{keyMethod:"inline",keySalt:s[0],lifeTime:s[1],mkiValue:s[2]?s[2].split(":")[0]:void 0,mkiLength:s[2]?s[2].split(":")[1]:void 0}},c.writeCryptoKeyParams=function(a){return a.keyMethod+":"+a.keySalt+(a.lifeTime?"|"+a.lifeTime:"")+(a.mkiValue&&a.mkiLength?"|"+a.mkiValue+":"+a.mkiLength:"")},c.getCryptoParameters=function(a,s){return c.matchPrefix(a+s,"a=crypto:").map(c.parseCryptoLine)},c.getIceParameters=function(a,s){var l=c.matchPrefix(a+s,"a=ice-ufrag:")[0],u=c.matchPrefix(a+s,"a=ice-pwd:")[0];return l&&u?{usernameFragment:l.substring(12),password:u.substring(10)}:null},c.writeIceParameters=function(a){var s="a=ice-ufrag:"+a.usernameFragment+`\r
19
19
  a=ice-pwd:`+a.password+`\r
20
20
  `;return a.iceLite&&(s+=`a=ice-lite\r
21
- `),s},c.parseRtpParameters=function(a){var s={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},l=c.splitLines(a)[0].split(" ");s.profile=l[2];for(var u=3;u<l.length;u++){var h=l[u],S=c.matchPrefix(a,"a=rtpmap:"+h+" ")[0];if(S){var I=c.parseRtpMap(S),E=c.matchPrefix(a,"a=fmtp:"+h+" ");switch(I.parameters=E.length?c.parseFmtp(E[0]):{},I.rtcpFeedback=c.matchPrefix(a,"a=rtcp-fb:"+h+" ").map(c.parseRtcpFb),s.codecs.push(I),I.name.toUpperCase()){case"RED":case"ULPFEC":s.fecMechanisms.push(I.name.toUpperCase())}}}c.matchPrefix(a,"a=extmap:").forEach(function(m){s.headerExtensions.push(c.parseExtmap(m))});var x=c.matchPrefix(a,"a=rtcp-fb:* ").map(c.parseRtcpFb);return s.codecs.forEach(function(m){x.forEach(function(T){m.rtcpFeedback.find(function(v){return v.type===T.type&&v.parameter===T.parameter})||m.rtcpFeedback.push(T)})}),s},c.writeRtpDescription=function(a,s){var l="";l+="m="+a+" ",l+=s.codecs.length>0?"9":"0",l+=" "+(s.profile||"UDP/TLS/RTP/SAVPF")+" ",l+=s.codecs.map(function(h){return h.preferredPayloadType!==void 0?h.preferredPayloadType:h.payloadType}).join(" ")+`\r
21
+ `),s},c.parseRtpParameters=function(a){var s={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},l=c.splitLines(a)[0].split(" ");s.profile=l[2];for(var u=3;u<l.length;u++){var h=l[u],b=c.matchPrefix(a,"a=rtpmap:"+h+" ")[0];if(b){var I=c.parseRtpMap(b),R=c.matchPrefix(a,"a=fmtp:"+h+" ");switch(I.parameters=R.length?c.parseFmtp(R[0]):{},I.rtcpFeedback=c.matchPrefix(a,"a=rtcp-fb:"+h+" ").map(c.parseRtcpFb),s.codecs.push(I),I.name.toUpperCase()){case"RED":case"ULPFEC":s.fecMechanisms.push(I.name.toUpperCase())}}}c.matchPrefix(a,"a=extmap:").forEach(function(m){s.headerExtensions.push(c.parseExtmap(m))});var x=c.matchPrefix(a,"a=rtcp-fb:* ").map(c.parseRtcpFb);return s.codecs.forEach(function(m){x.forEach(function(k){m.rtcpFeedback.find(function(v){return v.type===k.type&&v.parameter===k.parameter})||m.rtcpFeedback.push(k)})}),s},c.writeRtpDescription=function(a,s){var l="";l+="m="+a+" ",l+=s.codecs.length>0?"9":"0",l+=" "+(s.profile||"UDP/TLS/RTP/SAVPF")+" ",l+=s.codecs.map(function(h){return h.preferredPayloadType!==void 0?h.preferredPayloadType:h.payloadType}).join(" ")+`\r
22
22
  `,l+=`c=IN IP4 0.0.0.0\r
23
23
  `,l+=`a=rtcp:9 IN IP4 0.0.0.0\r
24
24
  `,s.codecs.forEach(function(h){l+=c.writeRtpMap(h),l+=c.writeFmtp(h),l+=c.writeRtcpFb(h)});var u=0;return s.codecs.forEach(function(h){h.maxptime>u&&(u=h.maxptime)}),u>0&&(l+="a=maxptime:"+u+`\r
25
- `),s.headerExtensions&&s.headerExtensions.forEach(function(h){l+=c.writeExtmap(h)}),l},c.parseRtpEncodingParameters=function(a){var s=[],l=c.parseRtpParameters(a),u=l.fecMechanisms.indexOf("RED")!==-1,h=l.fecMechanisms.indexOf("ULPFEC")!==-1,S=c.matchPrefix(a,"a=ssrc:").map(function(T){return c.parseSsrcMedia(T)}).filter(function(T){return T.attribute==="cname"}),I=S.length>0&&S[0].ssrc,E=void 0,x=c.matchPrefix(a,"a=ssrc-group:FID").map(function(T){return T.substring(17).split(" ").map(function(v){return parseInt(v,10)})});x.length>0&&x[0].length>1&&x[0][0]===I&&(E=x[0][1]),l.codecs.forEach(function(T){if(T.name.toUpperCase()==="RTX"&&T.parameters.apt){var v={ssrc:I,codecPayloadType:parseInt(T.parameters.apt,10)};I&&E&&(v.rtx={ssrc:E}),s.push(v),u&&((v=JSON.parse(JSON.stringify(v))).fec={ssrc:I,mechanism:h?"red+ulpfec":"red"},s.push(v))}}),s.length===0&&I&&s.push({ssrc:I});var m=c.matchPrefix(a,"b=");return m.length&&(m=m[0].indexOf("b=TIAS:")===0?parseInt(m[0].substring(7),10):m[0].indexOf("b=AS:")===0?1e3*parseInt(m[0].substring(5),10)*.95-16e3:void 0,s.forEach(function(T){T.maxBitrate=m})),s},c.parseRtcpParameters=function(a){var s={},l=c.matchPrefix(a,"a=ssrc:").map(function(S){return c.parseSsrcMedia(S)}).filter(function(S){return S.attribute==="cname"})[0];l&&(s.cname=l.value,s.ssrc=l.ssrc);var u=c.matchPrefix(a,"a=rtcp-rsize");s.reducedSize=u.length>0,s.compound=u.length===0;var h=c.matchPrefix(a,"a=rtcp-mux");return s.mux=h.length>0,s},c.writeRtcpParameters=function(a){var s="";return a.reducedSize&&(s+=`a=rtcp-rsize\r
25
+ `),s.headerExtensions&&s.headerExtensions.forEach(function(h){l+=c.writeExtmap(h)}),l},c.parseRtpEncodingParameters=function(a){var s=[],l=c.parseRtpParameters(a),u=l.fecMechanisms.indexOf("RED")!==-1,h=l.fecMechanisms.indexOf("ULPFEC")!==-1,b=c.matchPrefix(a,"a=ssrc:").map(function(k){return c.parseSsrcMedia(k)}).filter(function(k){return k.attribute==="cname"}),I=b.length>0&&b[0].ssrc,R=void 0,x=c.matchPrefix(a,"a=ssrc-group:FID").map(function(k){return k.substring(17).split(" ").map(function(v){return parseInt(v,10)})});x.length>0&&x[0].length>1&&x[0][0]===I&&(R=x[0][1]),l.codecs.forEach(function(k){if(k.name.toUpperCase()==="RTX"&&k.parameters.apt){var v={ssrc:I,codecPayloadType:parseInt(k.parameters.apt,10)};I&&R&&(v.rtx={ssrc:R}),s.push(v),u&&((v=JSON.parse(JSON.stringify(v))).fec={ssrc:I,mechanism:h?"red+ulpfec":"red"},s.push(v))}}),s.length===0&&I&&s.push({ssrc:I});var m=c.matchPrefix(a,"b=");return m.length&&(m=m[0].indexOf("b=TIAS:")===0?parseInt(m[0].substring(7),10):m[0].indexOf("b=AS:")===0?1e3*parseInt(m[0].substring(5),10)*.95-16e3:void 0,s.forEach(function(k){k.maxBitrate=m})),s},c.parseRtcpParameters=function(a){var s={},l=c.matchPrefix(a,"a=ssrc:").map(function(b){return c.parseSsrcMedia(b)}).filter(function(b){return b.attribute==="cname"})[0];l&&(s.cname=l.value,s.ssrc=l.ssrc);var u=c.matchPrefix(a,"a=rtcp-rsize");s.reducedSize=u.length>0,s.compound=u.length===0;var h=c.matchPrefix(a,"a=rtcp-mux");return s.mux=h.length>0,s},c.writeRtcpParameters=function(a){var s="";return a.reducedSize&&(s+=`a=rtcp-rsize\r
26
26
  `),a.mux&&(s+=`a=rtcp-mux\r
27
27
  `),a.ssrc!==void 0&&a.cname&&(s+="a=ssrc:"+a.ssrc+" cname:"+a.cname+`\r
28
- `),s},c.parseMsid=function(a){var s=void 0,l=c.matchPrefix(a,"a=msid:");if(l.length===1)return{stream:(s=l[0].substring(7).split(" "))[0],track:s[1]};var u=c.matchPrefix(a,"a=ssrc:").map(function(h){return c.parseSsrcMedia(h)}).filter(function(h){return h.attribute==="msid"});return u.length>0?{stream:(s=u[0].value.split(" "))[0],track:s[1]}:void 0},c.parseSctpDescription=function(a){var s=c.parseMLine(a),l=c.matchPrefix(a,"a=max-message-size:"),u=void 0;l.length>0&&(u=parseInt(l[0].substring(19),10)),isNaN(u)&&(u=65536);var h=c.matchPrefix(a,"a=sctp-port:");if(h.length>0)return{port:parseInt(h[0].substring(12),10),protocol:s.fmt,maxMessageSize:u};var S=c.matchPrefix(a,"a=sctpmap:");if(S.length>0){var I=S[0].substring(10).split(" ");return{port:parseInt(I[0],10),protocol:I[1],maxMessageSize:u}}},c.writeSctpDescription=function(a,s){var l=[];return l=a.protocol!=="DTLS/SCTP"?["m="+a.kind+" 9 "+a.protocol+" "+s.protocol+`\r
28
+ `),s},c.parseMsid=function(a){var s=void 0,l=c.matchPrefix(a,"a=msid:");if(l.length===1)return{stream:(s=l[0].substring(7).split(" "))[0],track:s[1]};var u=c.matchPrefix(a,"a=ssrc:").map(function(h){return c.parseSsrcMedia(h)}).filter(function(h){return h.attribute==="msid"});return u.length>0?{stream:(s=u[0].value.split(" "))[0],track:s[1]}:void 0},c.parseSctpDescription=function(a){var s=c.parseMLine(a),l=c.matchPrefix(a,"a=max-message-size:"),u=void 0;l.length>0&&(u=parseInt(l[0].substring(19),10)),isNaN(u)&&(u=65536);var h=c.matchPrefix(a,"a=sctp-port:");if(h.length>0)return{port:parseInt(h[0].substring(12),10),protocol:s.fmt,maxMessageSize:u};var b=c.matchPrefix(a,"a=sctpmap:");if(b.length>0){var I=b[0].substring(10).split(" ");return{port:parseInt(I[0],10),protocol:I[1],maxMessageSize:u}}},c.writeSctpDescription=function(a,s){var l=[];return l=a.protocol!=="DTLS/SCTP"?["m="+a.kind+" 9 "+a.protocol+" "+s.protocol+`\r
29
29
  `,`c=IN IP4 0.0.0.0\r
30
30
  `,"a=sctp-port:"+s.port+`\r
31
31
  `]:["m="+a.kind+" 9 "+a.protocol+" "+s.port+`\r
@@ -36,42 +36,40 @@ a=ice-pwd:`+a.password+`\r
36
36
  o=`+(l||"thisisadapterortc")+" "+(a||c.generateSessionId())+" "+u+` IN IP4 127.0.0.1\r
37
37
  s=-\r
38
38
  t=0 0\r
39
- `},c.getDirection=function(a,s){for(var l=c.splitLines(a),u=0;u<l.length;u++)switch(l[u]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return l[u].substring(2)}return s?c.getDirection(s):"sendrecv"},c.getKind=function(a){return c.splitLines(a)[0].split(" ")[0].substring(2)},c.isRejected=function(a){return a.split(" ",2)[1]==="0"},c.parseMLine=function(a){var s=c.splitLines(a)[0].substring(2).split(" ");return{kind:s[0],port:parseInt(s[1],10),protocol:s[2],fmt:s.slice(3).join(" ")}},c.parseOLine=function(a){var s=c.matchPrefix(a,"o=")[0].substring(2).split(" ");return{username:s[0],sessionId:s[1],sessionVersion:parseInt(s[2],10),netType:s[3],addressType:s[4],address:s[5]}},c.isValidSDP=function(a){if(typeof a!="string"||a.length===0)return!1;for(var s=c.splitLines(a),l=0;l<s.length;l++)if(s[l].length<2||s[l].charAt(1)!=="=")return!1;return!0},(i===void 0?"undefined":o(i))==="object"&&(i.exports=c)},{}]},{},[1])(1)}({exports:{}});var oi="4.15.22-beta.3",bg={},vC=vg,gC=qd,su=Object.keys||function(e){return vC(e,gC)},_C=ye,yC=hs,bC=Pt,SC=Tt,kC=bn,TC=su;bg.f=_C&&!yC?Object.defineProperties:function(e,t){SC(e);for(var n,i=kC(t),r=TC(t),o=r.length,c=0;o>c;)bC.f(e,n=r[c++],i[n]);return e};var cu,Sg=An("document","documentElement"),IC=Tt,xC=bg,kg=qd,wC=ee,CC=Sg,EC=vr,Tg=z("IE_PROTO"),Yd=function(){},Ig=function(e){return"<script>"+e+"<\/script>"},xg=function(e){e.write(Ig("")),e.close();var t=e.parentWindow.Object;return e=null,t},uu=function(){try{cu=new ActiveXObject("htmlfile")}catch(i){}var e,t;uu=typeof document!="undefined"?document.domain&&cu?xg(cu):((t=EC("iframe")).style.display="none",CC.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(Ig("document.F=Object")),e.close(),e.F):xg(cu);for(var n=kg.length;n--;)delete uu.prototype[kg[n]];return uu()};wC[Tg]=!0;var Ba=Object.create||function(e,t){var n;return e!==null?(Yd.prototype=IC(e),n=new Yd,Yd.prototype=null,n[Tg]=e):n=uu(),t===void 0?n:xC.f(n,t)},RC=tt,AC=Ba,PC=Pt.f,$d=RC("unscopables"),Zd=Array.prototype;Zd[$d]==null&&PC(Zd,$d,{configurable:!0,value:AC(null)});var Wi,wg,Cg,lu=function(e){Zd[$d][e]=!0},ks={},Eg=!ue(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),DC=kt,OC=it,LC=Mt,MC=Eg,Rg=z("IE_PROTO"),eh=Object,NC=eh.prototype,Ts=MC?eh.getPrototypeOf:function(e){var t=LC(e);if(DC(t,Rg))return t[Rg];var n=t.constructor;return OC(n)&&t instanceof n?n.prototype:t instanceof eh?NC:null},UC=ue,VC=it,jC=at,Ag=Ts,BC=Qt,th=tt("iterator"),Pg=!1;[].keys&&("next"in(Cg=[].keys())?(wg=Ag(Ag(Cg)))!==Object.prototype&&(Wi=wg):Pg=!0);var FC=!jC(Wi)||UC(function(){var e={};return Wi[th].call(e)!==e});FC&&(Wi={}),VC(Wi[th])||BC(Wi,th,function(){return this});var nh={IteratorPrototype:Wi,BUGGY_SAFARI_ITERATORS:Pg},HC=Pt.f,GC=kt,Dg=tt("toStringTag"),zi=function(e,t,n){e&&!n&&(e=e.prototype),e&&!GC(e,Dg)&&HC(e,Dg,{configurable:!0,value:t})},WC=nh.IteratorPrototype,zC=Ba,JC=Ze,qC=zi,KC=ks,XC=function(){return this},Og=function(e,t,n,i){var r=t+" Iterator";return e.prototype=zC(WC,{next:JC(+!i,n)}),qC(e,r,!1),KC[r]=XC,e},QC=it,YC=String,$C=TypeError,ZC=pe,eE=Tt,tE=function(e){if(typeof e=="object"||QC(e))return e;throw $C("Can't set "+YC(e)+" as a prototype")},Fa=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=ZC(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]),t=n instanceof Array}catch(i){}return function(i,r){return eE(i),tE(r),t?e(i,r):i.__proto__=r,i}}():void 0),nE=Le,rE=Ke,iE=it,aE=Og,Lg=Ts,Mg=Fa,oE=zi,sE=Ln,rh=Qt,cE=ks,uE=Yn.PROPER,lE=Yn.CONFIGURABLE,Ng=nh.IteratorPrototype,du=nh.BUGGY_SAFARI_ITERATORS,Is=tt("iterator"),Ug="keys",xs="values",Vg="entries",dE=function(){return this},ih=function(e,t,n,i,r,o,c){aE(n,t,i);var a,s,l,u=function(T){if(T===r&&x)return x;if(!du&&T in I)return I[T];switch(T){case Ug:case xs:case Vg:return function(){return new n(this,T)}}return function(){return new n(this)}},h=t+" Iterator",S=!1,I=e.prototype,E=I[Is]||I["@@iterator"]||r&&I[r],x=!du&&E||u(r),m=t=="Array"&&I.entries||E;if(m&&(a=Lg(m.call(new e)))!==Object.prototype&&a.next&&(Lg(a)!==Ng&&(Mg?Mg(a,Ng):iE(a[Is])||rh(a,Is,dE)),oE(a,h,!0)),uE&&r==xs&&E&&E.name!==xs&&(lE?sE(I,"name",xs):(S=!0,x=function(){return rE(E,this)})),r)if(s={values:u(xs),keys:o?x:u(Ug),entries:u(Vg)},c)for(l in s)(du||S||!(l in I))&&rh(I,l,s[l]);else nE({target:t,proto:!0,forced:du||S},s);return I[Is]!==x&&rh(I,Is,x,{name:r}),cE[t]=x,s},ah=function(e,t){return{value:e,done:t}},hE=bn,oh=lu,jg=ks,Bg=Xe,fE=Pt.f,pE=ih,Fg=ah,mE=ye,Hg="Array Iterator",vE=Bg.set,gE=Bg.getterFor(Hg),Gg=pE(Array,"Array",function(e,t){vE(this,{type:Hg,target:hE(e),index:0,kind:t})},function(){var e=gE(this),t=e.target,n=e.kind,i=e.index++;return!t||i>=t.length?(e.target=void 0,Fg(void 0,!0)):Fg(n=="keys"?i:n=="values"?t[i]:[i,t[i]],!1)},"values"),Wg=jg.Arguments=jg.Array;if(oh("keys"),oh("values"),oh("entries"),mE&&Wg.name!=="values")try{fE(Wg,"name",{value:"values"})}catch(e){}var zg={};zg[tt("toStringTag")]="z";var sh=String(zg)==="[object z]",_E=sh,yE=it,hu=rt,bE=tt("toStringTag"),SE=Object,kE=hu(function(){return arguments}())=="Arguments",Dr=_E?hu:function(e){var t,n,i;return e===void 0?"Undefined":e===null?"Null":typeof(n=function(r,o){try{return r[o]}catch(c){}}(t=SE(e),bE))=="string"?n:kE?hu(t):(i=hu(t))=="Object"&&yE(t.callee)?"Arguments":i},TE=Dr,IE=sh?{}.toString:function(){return"[object "+TE(this)+"]"};sh||Qt(Object.prototype,"toString",IE,{unsafe:!0});var ws={exports:{}},ch={},xE=Da,wE=Pt,CE=Ze,Cs=function(e,t,n){var i=xE(t);i in e?wE.f(e,i,CE(0,n)):e[i]=n},Jg=ai,EE=nn,RE=Cs,AE=Array,PE=Math.max,fu=function(e,t,n){for(var i=EE(e),r=Jg(t,i),o=Jg(n===void 0?i:n,i),c=AE(PE(o-r,0)),a=0;r<o;r++,a++)RE(c,a,e[r]);return c.length=a,c},DE=rt,OE=bn,qg=ii.f,LE=fu,Kg=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];ch.f=function(e){return Kg&&DE(e)=="Window"?function(t){try{return qg(t)}catch(n){return LE(Kg)}}(e):qg(OE(e))};var ME=ue(function(){if(typeof ArrayBuffer=="function"){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}),NE=ue,UE=at,VE=rt,Xg=ME,pu=Object.isExtensible,Qg=NE(function(){pu(1)})||Xg?function(e){return!!UE(e)&&(!Xg||VE(e)!="ArrayBuffer")&&(!pu||pu(e))}:pu,jE=!ue(function(){return Object.isExtensible(Object.preventExtensions({}))}),BE=Le,FE=pe,HE=ee,GE=at,uh=kt,WE=Pt.f,Yg=ii,zE=ch,lh=Qg,JE=jE,$g=!1,Or=Vi("meta"),qE=0,dh=function(e){WE(e,Or,{value:{objectID:"O"+qE++,weakData:{}}})},KE=ws.exports={enable:function(){KE.enable=function(){},$g=!0;var e=Yg.f,t=FE([].splice),n={};n[Or]=1,e(n).length&&(Yg.f=function(i){for(var r=e(i),o=0,c=r.length;o<c;o++)if(r[o]===Or){t(r,o,1);break}return r},BE({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:zE.f}))},fastKey:function(e,t){if(!GE(e))return typeof e=="symbol"?e:(typeof e=="string"?"S":"P")+e;if(!uh(e,Or)){if(!lh(e))return"F";if(!t)return"E";dh(e)}return e[Or].objectID},getWeakData:function(e,t){if(!uh(e,Or)){if(!lh(e))return!0;if(!t)return!1;dh(e)}return e[Or].weakData},onFreeze:function(e){return JE&&$g&&lh(e)&&!uh(e,Or)&&dh(e),e}};HE[Or]=!0;var XE=Vt,QE=Me,YE=pe(pe.bind),Lr=function(e,t){return XE(e),t===void 0?e:QE?YE(e,t):function(){return e.apply(t,arguments)}},$E=ks,ZE=tt("iterator"),eR=Array.prototype,hh=function(e){return e!==void 0&&($E.Array===e||eR[ZE]===e)},tR=Dr,Zg=Xt,nR=Rt,rR=ks,iR=tt("iterator"),Es=function(e){if(!nR(e))return Zg(e,iR)||Zg(e,"@@iterator")||rR[tR(e)]},aR=Ke,oR=Vt,sR=Tt,cR=Xn,uR=Es,lR=TypeError,mu=function(e,t){var n=arguments.length<2?uR(e):t;if(oR(n))return sR(aR(n,e));throw lR(cR(e)+" is not iterable")},dR=Ke,e_=Tt,hR=Xt,t_=function(e,t,n){var i,r;e_(e);try{if(!(i=hR(e,"return"))){if(t==="throw")throw n;return n}i=dR(i,e)}catch(o){r=!0,i=o}if(t==="throw")throw n;if(r)throw i;return e_(i),n},fR=Lr,pR=Ke,mR=Tt,vR=Xn,gR=hh,_R=nn,n_=Sn,yR=mu,bR=Es,r_=t_,SR=TypeError,vu=function(e,t){this.stopped=e,this.result=t},i_=vu.prototype,Rs=function(e,t,n){var i,r,o,c,a,s,l,u=n&&n.that,h=!(!n||!n.AS_ENTRIES),S=!(!n||!n.IS_RECORD),I=!(!n||!n.IS_ITERATOR),E=!(!n||!n.INTERRUPTED),x=fR(t,u),m=function(v){return i&&r_(i,"normal",v),new vu(!0,v)},T=function(v){return h?(mR(v),E?x(v[0],v[1],m):x(v[0],v[1])):E?x(v,m):x(v)};if(S)i=e.iterator;else if(I)i=e;else{if(!(r=bR(e)))throw SR(vR(e)+" is not iterable");if(gR(r)){for(o=0,c=_R(e);c>o;o++)if((a=T(e[o]))&&n_(i_,a))return a;return new vu(!1)}i=yR(e,r)}for(s=S?e.next:i.next;!(l=pR(s,i)).done;){try{a=T(l.value)}catch(v){r_(i,"throw",v)}if(typeof a=="object"&&a&&n_(i_,a))return a}return new vu(!1)},kR=Sn,TR=TypeError,si=function(e,t){if(kR(t,e))return e;throw TR("Incorrect invocation")},a_=tt("iterator"),o_=!1;try{var IR=0,s_={next:function(){return{done:!!IR++}},return:function(){o_=!0}};s_[a_]=function(){return this},Array.from(s_,function(){throw 2})}catch(e){}var gu=function(e,t){if(!t&&!o_)return!1;var n=!1;try{var i={};i[a_]=function(){return{next:function(){return{done:n=!0}}}},e(i)}catch(r){}return n},xR=it,wR=at,c_=Fa,_u=function(e,t,n){var i,r;return c_&&xR(i=t.constructor)&&i!==n&&wR(r=i.prototype)&&r!==n.prototype&&c_(e,r),e},CR=Le,ER=re,RR=pe,u_=Ss,AR=Qt,PR=ws.exports,DR=Rs,OR=si,LR=it,MR=Rt,fh=at,ph=ue,NR=gu,UR=zi,VR=_u,mh=function(e,t,n){var i=e.indexOf("Map")!==-1,r=e.indexOf("Weak")!==-1,o=i?"set":"add",c=ER[e],a=c&&c.prototype,s=c,l={},u=function(m){var T=RR(a[m]);AR(a,m,m=="add"?function(v){return T(this,v===0?0:v),this}:m=="delete"?function(v){return!(r&&!fh(v))&&T(this,v===0?0:v)}:m=="get"?function(v){return r&&!fh(v)?void 0:T(this,v===0?0:v)}:m=="has"?function(v){return!(r&&!fh(v))&&T(this,v===0?0:v)}:function(v,w){return T(this,v===0?0:v,w),this})};if(u_(e,!LR(c)||!(r||a.forEach&&!ph(function(){new c().entries().next()}))))s=n.getConstructor(t,e,i,o),PR.enable();else if(u_(e,!0)){var h=new s,S=h[o](r?{}:-0,1)!=h,I=ph(function(){h.has(1)}),E=NR(function(m){new c(m)}),x=!r&&ph(function(){for(var m=new c,T=5;T--;)m[o](T,T);return!m.has(-0)});E||((s=t(function(m,T){OR(m,a);var v=VR(new c,m,s);return MR(T)||DR(T,v[o],{that:v,AS_ENTRIES:i}),v})).prototype=a,a.constructor=s),(I||x)&&(u("delete"),u("has"),i&&u("get")),(x||S)&&u(o),r&&a.clear&&delete a.clear}return l[e]=s,CR({global:!0,constructor:!0,forced:s!=c},l),UR(s,e),r||n.setStrong(s,e,i),s},jR=Qt,As=function(e,t,n){for(var i in t)jR(e,i,t[i],n);return e},BR=An,FR=Pt,HR=ye,l_=tt("species"),Ps=function(e){var t=BR(e),n=FR.f;HR&&t&&!t[l_]&&n(t,l_,{configurable:!0,get:function(){return this}})},GR=Pt.f,WR=Ba,d_=As,zR=Lr,JR=si,qR=Rt,KR=Rs,XR=ih,h_=ah,QR=Ps,Ds=ye,f_=ws.exports.fastKey,p_=Xe.set,vh=Xe.getterFor,m_={getConstructor:function(e,t,n,i){var r=e(function(l,u){JR(l,o),p_(l,{type:t,index:WR(null),first:void 0,last:void 0,size:0}),Ds||(l.size=0),qR(u)||KR(u,l[i],{that:l,AS_ENTRIES:n})}),o=r.prototype,c=vh(t),a=function(l,u,h){var S,I,E=c(l),x=s(l,u);return x?x.value=h:(E.last=x={index:I=f_(u,!0),key:u,value:h,previous:S=E.last,next:void 0,removed:!1},E.first||(E.first=x),S&&(S.next=x),Ds?E.size++:l.size++,I!=="F"&&(E.index[I]=x)),l},s=function(l,u){var h,S=c(l),I=f_(u);if(I!=="F")return S.index[I];for(h=S.first;h;h=h.next)if(h.key==u)return h};return d_(o,{clear:function(){for(var l=c(this),u=l.index,h=l.first;h;)h.removed=!0,h.previous&&(h.previous=h.previous.next=void 0),delete u[h.index],h=h.next;l.first=l.last=void 0,Ds?l.size=0:this.size=0},delete:function(l){var u=this,h=c(u),S=s(u,l);if(S){var I=S.next,E=S.previous;delete h.index[S.index],S.removed=!0,E&&(E.next=I),I&&(I.previous=E),h.first==S&&(h.first=I),h.last==S&&(h.last=E),Ds?h.size--:u.size--}return!!S},forEach:function(l){for(var u,h=c(this),S=zR(l,arguments.length>1?arguments[1]:void 0);u=u?u.next:h.first;)for(S(u.value,u.key,this);u&&u.removed;)u=u.previous},has:function(l){return!!s(this,l)}}),d_(o,n?{get:function(l){var u=s(this,l);return u&&u.value},set:function(l,u){return a(this,l===0?0:l,u)}}:{add:function(l){return a(this,l=l===0?0:l,l)}}),Ds&&GR(o,"size",{get:function(){return c(this).size}}),r},setStrong:function(e,t,n){var i=t+" Iterator",r=vh(t),o=vh(i);XR(e,t,function(c,a){p_(this,{type:i,target:c,state:r(c),kind:a,last:void 0})},function(){for(var c=o(this),a=c.kind,s=c.last;s&&s.removed;)s=s.previous;return c.target&&(c.last=s=s?s.next:c.state.first)?h_(a=="keys"?s.key:a=="values"?s.value:[s.key,s.value],!1):(c.target=void 0,h_(void 0,!0))},n?"entries":"values",!n,!0),QR(t)}};mh("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},m_);var YR=Dr,$R=String,Wt=function(e){if(YR(e)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return $R(e)},gh=pe,ZR=$n,eA=Wt,tA=pt,nA=gh("".charAt),v_=gh("".charCodeAt),rA=gh("".slice),g_=function(e){return function(t,n){var i,r,o=eA(tA(t)),c=ZR(n),a=o.length;return c<0||c>=a?e?"":void 0:(i=v_(o,c))<55296||i>56319||c+1===a||(r=v_(o,c+1))<56320||r>57343?e?nA(o,c):i:e?rA(o,c,c+2):r-56320+(i-55296<<10)+65536}},_h={codeAt:g_(!1),charAt:g_(!0)},iA=_h.charAt,aA=Wt,__=Xe,oA=ih,y_=ah,b_="String Iterator",sA=__.set,cA=__.getterFor(b_);oA(String,"String",function(e){sA(this,{type:b_,string:aA(e),index:0})},function(){var e,t=cA(this),n=t.string,i=t.index;return i>=n.length?y_(void 0,!0):(e=iA(n,i),t.index+=e.length,y_(e,!1))});var S_={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},yh=vr("span").classList,k_=yh&&yh.constructor&&yh.constructor.prototype,T_=k_===Object.prototype?void 0:k_,I_=re,x_=S_,uA=T_,Os=Gg,bh=Ln,w_=tt,Sh=w_("iterator"),C_=w_("toStringTag"),kh=Os.values,E_=function(e,t){if(e){if(e[Sh]!==kh)try{bh(e,Sh,kh)}catch(i){e[Sh]=kh}if(e[C_]||bh(e,C_,t),x_[t]){for(var n in Os)if(e[n]!==Os[n])try{bh(e,n,Os[n])}catch(i){e[n]=Os[n]}}}};for(var Th in x_)E_(I_[Th]&&I_[Th].prototype,Th);E_(uA,"DOMTokenList");var lA=Me,R_=Function.prototype,A_=R_.apply,P_=R_.call,Ji=typeof Reflect=="object"&&Reflect.apply||(lA?P_.bind(A_):function(){return P_.apply(A_,arguments)}),Ha=pe([].slice),dA=TypeError,yu=function(e,t){if(e<t)throw dA("Not enough arguments");return e},Ih=re,hA=Ji,fA=it,pA=Ha,mA=yu,vA=/MSIE .\./.test(Kn),gA=Ih.Function,D_=function(e){return vA?function(t,n){var i=mA(arguments.length,1)>2,r=fA(t)?t:gA(t),o=i?pA(arguments,2):void 0;return e(i?function(){hA(r,this,o)}:r,n)}:e},O_={setTimeout:D_(Ih.setTimeout),setInterval:D_(Ih.setInterval)},L_=O_.setInterval;Le({global:!0,bind:!0,forced:re.setInterval!==L_},{setInterval:L_});var M_=O_.setTimeout;Le({global:!0,bind:!0,forced:re.setTimeout!==M_},{setTimeout:M_}),mh("Map",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},m_);var _A=rt,Ga=Array.isArray||function(e){return _A(e)=="Array"},yA=pe,bA=ue,N_=it,SA=Dr,kA=d,U_=function(){},TA=[],V_=An("Reflect","construct"),xh=/^\s*(?:class|function)\b/,IA=yA(xh.exec),xA=!xh.exec(U_),Ls=function(e){if(!N_(e))return!1;try{return V_(U_,TA,e),!0}catch(t){return!1}},j_=function(e){if(!N_(e))return!1;switch(SA(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return xA||!!IA(xh,kA(e))}catch(t){return!0}};j_.sham=!0;var bu=!V_||bA(function(){var e;return Ls(Ls.call)||!Ls(Object)||!Ls(function(){e=!0})||e})?j_:Ls,B_=Ga,wA=bu,CA=at,EA=tt("species"),F_=Array,RA=function(e){var t;return B_(e)&&(t=e.constructor,(wA(t)&&(t===F_||B_(t.prototype))||CA(t)&&(t=t[EA])===null)&&(t=void 0)),t===void 0?F_:t},wh=function(e,t){return new(RA(e))(t===0?0:t)},AA=Lr,PA=yn,DA=Mt,OA=nn,LA=wh,H_=pe([].push),ci=function(e){var t=e==1,n=e==2,i=e==3,r=e==4,o=e==6,c=e==7,a=e==5||o;return function(s,l,u,h){for(var S,I,E=DA(s),x=PA(E),m=AA(l,u),T=OA(x),v=0,w=h||LA,L=t?w(s,T):n||c?w(s,0):void 0;T>v;v++)if((a||v in x)&&(I=m(S=x[v],v,E),e))if(t)L[v]=I;else if(I)switch(e){case 3:return!0;case 5:return S;case 6:return v;case 2:H_(L,S)}else switch(e){case 4:return!1;case 7:H_(L,S)}return o?-1:i||r?r:L}},rn={forEach:ci(0),map:ci(1),filter:ci(2),some:ci(3),every:ci(4),find:ci(5),findIndex:ci(6),filterReject:ci(7)},MA=ue,NA=pr,UA=tt("species"),Ms=function(e){return NA>=51||!MA(function(){var t=[];return(t.constructor={})[UA]=function(){return{foo:1}},t[e](Boolean).foo!==1})},VA=rn.map;Le({target:"Array",proto:!0,forced:!Ms("map")},{map:function(e){return VA(this,e,arguments.length>1?arguments[1]:void 0)}});var jA=ye,BA=Ga,FA=TypeError,HA=Object.getOwnPropertyDescriptor,GA=jA&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),WA=TypeError,G_=function(e){if(e>9007199254740991)throw WA("Maximum allowed index exceeded");return e},W_=Xn,zA=TypeError,z_=function(e,t){if(!delete e[t])throw zA("Cannot delete property "+W_(t)+" of "+W_(e))},JA=Le,qA=Mt,KA=ai,XA=$n,QA=nn,YA=GA?function(e,t){if(BA(e)&&!HA(e,"length").writable)throw FA("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},$A=G_,ZA=wh,e2=Cs,Ch=z_,t2=Ms("splice"),n2=Math.max,r2=Math.min;JA({target:"Array",proto:!0,forced:!t2},{splice:function(e,t){var n,i,r,o,c,a,s=qA(this),l=QA(s),u=KA(e,l),h=arguments.length;for(h===0?n=i=0:h===1?(n=0,i=l-u):(n=h-2,i=r2(n2(XA(t),0),l-u)),$A(l+n-i),r=ZA(s,i),o=0;o<i;o++)(c=u+o)in s&&e2(r,o,s[c]);if(r.length=i,n<i){for(o=u;o<l-i;o++)a=o+n,(c=o+i)in s?s[a]=s[c]:Ch(s,a);for(o=l;o>l-i+n;o--)Ch(s,o-1)}else if(n>i)for(o=l-i;o>u;o--)a=o+n-1,(c=o+i-1)in s?s[a]=s[c]:Ch(s,a);for(o=0;o<n;o++)s[o+u]=arguments[o+2];return YA(s,l-i+n),r}});var i2=ue,Ns=function(e,t){var n=[][e];return!!n&&i2(function(){n.call(null,t||function(){return 1},1)})},a2=rn.forEach,Eh=Ns("forEach")?[].forEach:function(e){return a2(this,e,arguments.length>1?arguments[1]:void 0)};Le({target:"Array",proto:!0,forced:[].forEach!=Eh},{forEach:Eh});var J_=re,q_=S_,o2=T_,Rh=Eh,s2=Ln,K_=function(e){if(e&&e.forEach!==Rh)try{s2(e,"forEach",Rh)}catch(t){e.forEach=Rh}};for(var Ah in q_)q_[Ah]&&K_(J_[Ah]&&J_[Ah].prototype);K_(o2);var c2=Le,u2=ue,l2=Ga,d2=at,h2=Mt,f2=nn,X_=G_,Q_=Cs,p2=wh,m2=Ms,v2=pr,Y_=tt("isConcatSpreadable"),g2=v2>=51||!u2(function(){var e=[];return e[Y_]=!1,e.concat()[0]!==e}),_2=m2("concat"),y2=function(e){if(!d2(e))return!1;var t=e[Y_];return t!==void 0?!!t:l2(e)};c2({target:"Array",proto:!0,arity:1,forced:!g2||!_2},{concat:function(e){var t,n,i,r,o,c=h2(this),a=p2(c,0),s=0;for(t=-1,i=arguments.length;t<i;t++)if(y2(o=t===-1?c:arguments[t]))for(r=f2(o),X_(s+r),n=0;n<r;n++,s++)n in o&&Q_(a,s,o[n]);else X_(s+1),Q_(a,s++,o);return a.length=s,a}});var b2=Le,S2=yn,k2=bn,T2=Ns,I2=pe([].join),x2=S2!=Object,w2=T2("join",",");b2({target:"Array",proto:!0,forced:x2||!w2},{join:function(e){return I2(k2(this),e===void 0?",":e)}});var C2=rn.filter;Le({target:"Array",proto:!0,forced:!Ms("filter")},{filter:function(e){return C2(this,e,arguments.length>1?arguments[1]:void 0)}});var $_=pe,E2=Qt,Ph=Date.prototype,Z_="Invalid Date",R2="toString",A2=$_(Ph.toString),P2=$_(Ph.getTime);String(new Date(NaN))!=Z_&&E2(Ph,R2,function(){var e=P2(this);return e==e?A2(this):Z_});var D2=$n,O2=Wt,L2=pt,M2=RangeError,ey=function(e){var t=O2(L2(this)),n="",i=D2(e);if(i<0||i==1/0)throw M2("Wrong number of repetitions");for(;i>0;(i>>>=1)&&(t+=t))1&i&&(n+=t);return n},ty=pe,N2=yr,ny=Wt,U2=pt,V2=ty(ey),j2=ty("".slice),B2=Math.ceil,ry=function(e){return function(t,n,i){var r,o,c=ny(U2(t)),a=N2(n),s=c.length,l=i===void 0?" ":ny(i);return a<=s||l==""?c:((o=V2(l,B2((r=a-s)/l.length))).length>r&&(o=j2(o,0,r)),e?c+o:o+c)}},F2={start:ry(!1),end:ry(!0)},H2=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(Kn),G2=F2.start;Le({target:"String",proto:!0,forced:H2},{padStart:function(e){return G2(this,e,arguments.length>1?arguments[1]:void 0)}});var W2=Tt,iy=function(){var e=W2(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Dh=ue,Oh=re.RegExp,Lh=Dh(function(){var e=Oh("a","y");return e.lastIndex=2,e.exec("abcd")!=null}),z2=Lh||Dh(function(){return!Oh("a","y").sticky}),ay={BROKEN_CARET:Lh||Dh(function(){var e=Oh("^r","gy");return e.lastIndex=2,e.exec("str")!=null}),MISSED_STICKY:z2,UNSUPPORTED_Y:Lh},J2=ue,q2=re.RegExp,oy=J2(function(){var e=q2(".","s");return!(e.dotAll&&e.exec(`
40
- `)&&e.flags==="s")}),K2=ue,X2=re.RegExp,sy=K2(function(){var e=X2("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),Wa=Ke,Su=pe,Q2=Wt,Y2=iy,$2=ay,Z2=Pr.exports,eP=Ba,tP=Xe.get,nP=oy,rP=sy,iP=Z2("native-string-replace",String.prototype.replace),ku=RegExp.prototype.exec,Mh=ku,aP=Su("".charAt),oP=Su("".indexOf),sP=Su("".replace),Nh=Su("".slice),Uh=function(){var e=/a/,t=/b*/g;return Wa(ku,e,"a"),Wa(ku,t,"a"),e.lastIndex!==0||t.lastIndex!==0}(),cy=$2.BROKEN_CARET,Vh=/()??/.exec("")[1]!==void 0;(Uh||Vh||cy||nP||rP)&&(Mh=function(e){var t,n,i,r,o,c,a,s=this,l=tP(s),u=Q2(e),h=l.raw;if(h)return h.lastIndex=s.lastIndex,t=Wa(Mh,h,u),s.lastIndex=h.lastIndex,t;var S=l.groups,I=cy&&s.sticky,E=Wa(Y2,s),x=s.source,m=0,T=u;if(I&&(E=sP(E,"y",""),oP(E,"g")===-1&&(E+="g"),T=Nh(u,s.lastIndex),s.lastIndex>0&&(!s.multiline||s.multiline&&aP(u,s.lastIndex-1)!==`
41
- `)&&(x="(?: "+x+")",T=" "+T,m++),n=new RegExp("^(?:"+x+")",E)),Vh&&(n=new RegExp("^"+x+"$(?!\\s)",E)),Uh&&(i=s.lastIndex),r=Wa(ku,I?n:s,T),I?r?(r.input=Nh(r.input,m),r[0]=Nh(r[0],m),r.index=s.lastIndex,s.lastIndex+=r[0].length):s.lastIndex=0:Uh&&r&&(s.lastIndex=s.global?r.index+r[0].length:i),Vh&&r&&r.length>1&&Wa(iP,r[0],n,function(){for(o=1;o<arguments.length-2;o++)arguments[o]===void 0&&(r[o]=void 0)}),r&&S)for(r.groups=c=eP(null),o=0;o<S.length;o++)c[(a=S[o])[0]]=r[a[1]];return r});var Tu=Mh;Le({target:"RegExp",proto:!0,forced:/./.exec!==Tu},{exec:Tu});var uy=pe,ly=Qt,cP=Tu,dy=ue,hy=tt,uP=Ln,lP=hy("species"),jh=RegExp.prototype,Bh=function(e,t,n,i){var r=hy(e),o=!dy(function(){var l={};return l[r]=function(){return 7},""[e](l)!=7}),c=o&&!dy(function(){var l=!1,u=/a/;return e==="split"&&((u={}).constructor={},u.constructor[lP]=function(){return u},u.flags="",u[r]=/./[r]),u.exec=function(){return l=!0,null},u[r](""),!l});if(!o||!c||n){var a=uy(/./[r]),s=t(r,""[e],function(l,u,h,S,I){var E=uy(l),x=u.exec;return x===cP||x===jh.exec?o&&!I?{done:!0,value:a(u,h,S)}:{done:!0,value:E(h,u,S)}:{done:!1}});ly(String.prototype,e,s[0]),ly(jh,r,s[1])}i&&uP(jh[r],"sham",!0)},dP=_h.charAt,fy=function(e,t,n){return t+(n?dP(e,t).length:1)},Fh=pe,hP=Mt,fP=Math.floor,Hh=Fh("".charAt),pP=Fh("".replace),Gh=Fh("".slice),mP=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,vP=/\$([$&'`]|\d{1,2})/g,py=Ke,gP=Tt,_P=it,yP=rt,bP=Tu,SP=TypeError,Wh=function(e,t){var n=e.exec;if(_P(n)){var i=py(n,e,t);return i!==null&&gP(i),i}if(yP(e)==="RegExp")return py(bP,e,t);throw SP("RegExp#exec called on incompatible receiver")},kP=Ji,my=Ke,Iu=pe,TP=Bh,IP=ue,xP=Tt,wP=it,CP=Rt,EP=$n,RP=yr,za=Wt,AP=pt,PP=fy,DP=Xt,OP=function(e,t,n,i,r,o){var c=n+e.length,a=i.length,s=vP;return r!==void 0&&(r=hP(r),s=mP),pP(o,s,function(l,u){var h;switch(Hh(u,0)){case"$":return"$";case"&":return e;case"`":return Gh(t,0,n);case"'":return Gh(t,c);case"<":h=r[Gh(u,1,-1)];break;default:var S=+u;if(S===0)return l;if(S>a){var I=fP(S/10);return I===0?l:I<=a?i[I-1]===void 0?Hh(u,1):i[I-1]+Hh(u,1):l}h=i[S-1]}return h===void 0?"":h})},LP=Wh,zh=tt("replace"),MP=Math.max,NP=Math.min,UP=Iu([].concat),Jh=Iu([].push),vy=Iu("".indexOf),gy=Iu("".slice),VP="a".replace(/./,"$0")==="$0",_y=!!/./[zh]&&/./[zh]("a","$0")==="",jP=!IP(function(){var e=/./;return e.exec=function(){var t=[];return t.groups={a:"7"},t},"".replace(e,"$<a>")!=="7"});TP("replace",function(e,t,n){var i=_y?"$":"$0";return[function(r,o){var c=AP(this),a=CP(r)?void 0:DP(r,zh);return a?my(a,r,c,o):my(t,za(c),r,o)},function(r,o){var c=xP(this),a=za(r);if(typeof o=="string"&&vy(o,i)===-1&&vy(o,"$<")===-1){var s=n(t,c,a,o);if(s.done)return s.value}var l=wP(o);l||(o=za(o));var u=c.global;if(u){var h=c.unicode;c.lastIndex=0}for(var S=[];;){var I=LP(c,a);if(I===null||(Jh(S,I),!u))break;za(I[0])===""&&(c.lastIndex=PP(a,RP(c.lastIndex),h))}for(var E,x="",m=0,T=0;T<S.length;T++){for(var v=za((I=S[T])[0]),w=MP(NP(EP(I.index),a.length),0),L=[],N=1;N<I.length;N++)Jh(L,(E=I[N])===void 0?E:String(E));var V=I.groups;if(l){var _=UP([v],L,w,a);V!==void 0&&Jh(_,V);var b=za(kP(o,void 0,_))}else b=OP(v,a,w,L,V,o);w>=m&&(x+=gy(a,m,w)+b,m=w+v.length)}return x+gy(a,m)}]},!jP||!VP||_y);var BP=Ke,FP=kt,HP=Sn,GP=iy,yy=RegExp.prototype,by=function(e){var t=e.flags;return t!==void 0||"flags"in yy||FP(e,"flags")||!HP(yy,e)?t:BP(GP,e)},WP=Yn.PROPER,zP=Qt,JP=Tt,Sy=Wt,qP=ue,KP=by,ky="toString",Ty=RegExp.prototype.toString,XP=qP(function(){return Ty.call({source:"a",flags:"b"})!="/a/b"}),QP=WP&&Ty.name!=ky;(XP||QP)&&zP(RegExp.prototype,ky,function(){var e=JP(this);return"/"+Sy(e.source)+"/"+Sy(KP(e))},{unsafe:!0});var YP=ue,$P=tt("iterator"),Iy=!YP(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(i,r){t.delete("b"),n+=r+i}),!t.sort||e.href!=="http://a/c%20d?a=1&c=3"||t.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!t[$P]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("http://\u0442\u0435\u0441\u0442").host!=="xn--e1aybc"||new URL("http://a#\u0431").hash!=="#%D0%B1"||n!=="a1c3"||new URL("http://x",void 0).host!=="x"}),xy=fu,ZP=Math.floor,qh=function(e,t){var n=e.length,i=ZP(n/2);return n<8?eD(e,t):tD(e,qh(xy(e,0,i),t),qh(xy(e,i),t),t)},eD=function(e,t){for(var n,i,r=e.length,o=1;o<r;){for(i=o,n=e[o];i&&t(e[i-1],n)>0;)e[i]=e[--i];i!==o++&&(e[i]=n)}return e},tD=function(e,t,n,i){for(var r=t.length,o=n.length,c=0,a=0;c<r||a<o;)e[c+a]=c<r&&a<o?i(t[c],n[a])<=0?t[c++]:n[a++]:c<r?t[c++]:n[a++];return e},wy=qh,Kh=Le,Ja=re,xu=Ke,br=pe,nD=ye,Cy=Iy,Ey=Qt,rD=As,iD=zi,aD=Og,Xh=Xe,Ry=si,Qh=it,oD=kt,sD=Lr,cD=Dr,uD=Tt,Ay=at,Tn=Wt,lD=Ba,Py=Ze,Yh=mu,dD=Es,qa=yu,hD=wy,fD=tt("iterator"),wu="URLSearchParams",Dy="URLSearchParamsIterator",Oy=Xh.set,Zn=Xh.getterFor(wu),pD=Xh.getterFor(Dy),mD=Object.getOwnPropertyDescriptor,$h=function(e){if(!nD)return Ja[e];var t=mD(Ja,e);return t&&t.value},Ly=$h("fetch"),Cu=$h("Request"),Us=$h("Headers"),Zh=Cu&&Cu.prototype,My=Us&&Us.prototype,vD=Ja.RegExp,gD=Ja.TypeError,Ny=Ja.decodeURIComponent,_D=Ja.encodeURIComponent,yD=br("".charAt),Uy=br([].join),qi=br([].push),ef=br("".replace),bD=br([].shift),Vy=br([].splice),jy=br("".split),SD=br("".slice),kD=/\+/g,By=Array(4),TD=function(e){return By[e-1]||(By[e-1]=vD("((?:%[\\da-f]{2}){"+e+"})","gi"))},ID=function(e){try{return Ny(e)}catch(t){return e}},Fy=function(e){var t=ef(e,kD," "),n=4;try{return Ny(t)}catch(i){for(;n;)t=ef(t,TD(n--),ID);return t}},xD=/[!'()~]|%20/g,wD={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},CD=function(e){return wD[e]},Hy=function(e){return ef(_D(e),xD,CD)},tf=aD(function(e,t){Oy(this,{type:Dy,iterator:Yh(Zn(e).entries),kind:t})},"Iterator",function(){var e=pD(this),t=e.kind,n=e.iterator.next(),i=n.value;return n.done||(n.value=t==="keys"?i.key:t==="values"?i.value:[i.key,i.value]),n},!0),Gy=function(e){this.entries=[],this.url=null,e!==void 0&&(Ay(e)?this.parseObject(e):this.parseQuery(typeof e=="string"?yD(e,0)==="?"?SD(e,1):e:Tn(e)))};Gy.prototype={type:wu,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,i,r,o,c,a,s=dD(e);if(s)for(n=(t=Yh(e,s)).next;!(i=xu(n,t)).done;){if(o=(r=Yh(uD(i.value))).next,(c=xu(o,r)).done||(a=xu(o,r)).done||!xu(o,r).done)throw gD("Expected sequence with length 2");qi(this.entries,{key:Tn(c.value),value:Tn(a.value)})}else for(var l in e)oD(e,l)&&qi(this.entries,{key:l,value:Tn(e[l])})},parseQuery:function(e){if(e)for(var t,n,i=jy(e,"&"),r=0;r<i.length;)(t=i[r++]).length&&(n=jy(t,"="),qi(this.entries,{key:Fy(bD(n)),value:Fy(Uy(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],i=0;i<t.length;)e=t[i++],qi(n,Hy(e.key)+"="+Hy(e.value));return Uy(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Eu=function(){Ry(this,Vs);var e=arguments.length>0?arguments[0]:void 0;Oy(this,new Gy(e))},Vs=Eu.prototype;if(rD(Vs,{append:function(e,t){qa(arguments.length,2);var n=Zn(this);qi(n.entries,{key:Tn(e),value:Tn(t)}),n.updateURL()},delete:function(e){qa(arguments.length,1);for(var t=Zn(this),n=t.entries,i=Tn(e),r=0;r<n.length;)n[r].key===i?Vy(n,r,1):r++;t.updateURL()},get:function(e){qa(arguments.length,1);for(var t=Zn(this).entries,n=Tn(e),i=0;i<t.length;i++)if(t[i].key===n)return t[i].value;return null},getAll:function(e){qa(arguments.length,1);for(var t=Zn(this).entries,n=Tn(e),i=[],r=0;r<t.length;r++)t[r].key===n&&qi(i,t[r].value);return i},has:function(e){qa(arguments.length,1);for(var t=Zn(this).entries,n=Tn(e),i=0;i<t.length;)if(t[i++].key===n)return!0;return!1},set:function(e,t){qa(arguments.length,1);for(var n,i=Zn(this),r=i.entries,o=!1,c=Tn(e),a=Tn(t),s=0;s<r.length;s++)(n=r[s]).key===c&&(o?Vy(r,s--,1):(o=!0,n.value=a));o||qi(r,{key:c,value:a}),i.updateURL()},sort:function(){var e=Zn(this);hD(e.entries,function(t,n){return t.key>n.key?1:-1}),e.updateURL()},forEach:function(e){for(var t,n=Zn(this).entries,i=sD(e,arguments.length>1?arguments[1]:void 0),r=0;r<n.length;)i((t=n[r++]).value,t.key,this)},keys:function(){return new tf(this,"keys")},values:function(){return new tf(this,"values")},entries:function(){return new tf(this,"entries")}},{enumerable:!0}),Ey(Vs,fD,Vs.entries,{name:"entries"}),Ey(Vs,"toString",function(){return Zn(this).serialize()},{enumerable:!0}),iD(Eu,wu),Kh({global:!0,constructor:!0,forced:!Cy},{URLSearchParams:Eu}),!Cy&&Qh(Us)){var ED=br(My.has),RD=br(My.set),Wy=function(e){if(Ay(e)){var t,n=e.body;if(cD(n)===wu)return t=e.headers?new Us(e.headers):new Us,ED(t,"content-type")||RD(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),lD(e,{body:Py(0,Tn(n)),headers:Py(0,t)})}return e};if(Qh(Ly)&&Kh({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return Ly(e,arguments.length>1?Wy(arguments[1]):{})}}),Qh(Cu)){var nf=function(e){return Ry(this,Zh),new Cu(e,arguments.length>1?Wy(arguments[1]):{})};Zh.constructor=nf,nf.prototype=Zh,Kh({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:nf})}}var AD={URLSearchParams:Eu,getState:Zn},PD=Object.is||function(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t},DD=Ke,OD=Tt,LD=Rt,MD=pt,zy=PD,Jy=Wt,ND=Xt,UD=Wh;Bh("search",function(e,t,n){return[function(i){var r=MD(this),o=LD(i)?void 0:ND(i,e);return o?DD(o,i,r):new RegExp(i)[e](Jy(r))},function(i){var r=OD(this),o=Jy(i),c=n(t,r,o);if(c.done)return c.value;var a=r.lastIndex;zy(a,0)||(r.lastIndex=0);var s=UD(r,o);return zy(r.lastIndex,a)||(r.lastIndex=a),s===null?-1:s.index}]}),new Date().getTime();var rf=0,an=function(){return new Date().getTime()+rf},qy=function(){var e=new Date;return e.setTime(an()),e.toLocaleString()},VD=Ke,jD=Tt,BD=Rt,FD=yr,af=Wt,HD=pt,GD=Xt,WD=fy,Ky=Wh;Bh("match",function(e,t,n){return[function(i){var r=HD(this),o=BD(i)?void 0:GD(i,e);return o?VD(o,i,r):new RegExp(i)[e](af(r))},function(i){var r=jD(this),o=af(i),c=n(t,r,o);if(c.done)return c.value;if(!r.global)return Ky(r,o);var a=r.unicode;r.lastIndex=0;for(var s,l=[],u=0;(s=Ky(r,o))!==null;){var h=af(s[0]);l[u]=h,h===""&&(r.lastIndex=WD(o,FD(r.lastIndex),a)),u++}return u===0?null:l}]});var zD=at,JD=rt,qD=tt("match"),Xy=function(e){var t;return zD(e)&&((t=e[qD])!==void 0?!!t:JD(e)=="RegExp")},KD=Pt.f,XD=ye,of=re,js=pe,QD=Ss,YD=_u,$D=Ln,ZD=ii.f,Qy=Sn,eO=Xy,Yy=Wt,tO=by,$y=ay,nO=function(e,t,n){n in e||KD(e,n,{configurable:!0,get:function(){return t[n]},set:function(i){t[n]=i}})},rO=Qt,iO=ue,aO=kt,oO=Xe.enforce,sO=Ps,Zy=oy,e0=sy,cO=tt("match"),ui=of.RegExp,Ka=ui.prototype,uO=of.SyntaxError,lO=js(Ka.exec),Ru=js("".charAt),t0=js("".replace),n0=js("".indexOf),dO=js("".slice),hO=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Ki=/a/g,sf=/a/g,fO=new ui(Ki)!==Ki,r0=$y.MISSED_STICKY,pO=$y.UNSUPPORTED_Y,mO=XD&&(!fO||r0||Zy||e0||iO(function(){return sf[cO]=!1,ui(Ki)!=Ki||ui(sf)==sf||ui(Ki,"i")!="/a/i"}));if(QD("RegExp",mO)){for(var Xi=function(e,t){var n,i,r,o,c,a,s=Qy(Ka,this),l=eO(e),u=t===void 0,h=[],S=e;if(!s&&l&&u&&e.constructor===Xi)return e;if((l||Qy(Ka,e))&&(e=e.source,u&&(t=tO(S))),e=e===void 0?"":Yy(e),t=t===void 0?"":Yy(t),S=e,Zy&&"dotAll"in Ki&&(i=!!t&&n0(t,"s")>-1)&&(t=t0(t,/s/g,"")),n=t,r0&&"sticky"in Ki&&(r=!!t&&n0(t,"y")>-1)&&pO&&(t=t0(t,/y/g,"")),e0&&(o=function(I){for(var E,x=I.length,m=0,T="",v=[],w={},L=!1,N=!1,V=0,_="";m<=x;m++){if((E=Ru(I,m))==="\\")E+=Ru(I,++m);else if(E==="]")L=!1;else if(!L)switch(!0){case E==="[":L=!0;break;case E==="(":lO(hO,dO(I,m+1))&&(m+=2,N=!0),T+=E,V++;continue;case(E===">"&&N):if(_===""||aO(w,_))throw new uO("Invalid capture group name");w[_]=!0,v[v.length]=[_,V],N=!1,_="";continue}N?_+=E:T+=E}return[T,v]}(e),e=o[0],h=o[1]),c=YD(ui(e,t),s?this:Ka,Xi),(i||r||h.length)&&(a=oO(c),i&&(a.dotAll=!0,a.raw=Xi(function(I){for(var E,x=I.length,m=0,T="",v=!1;m<=x;m++)(E=Ru(I,m))!=="\\"?v||E!=="."?(E==="["?v=!0:E==="]"&&(v=!1),T+=E):T+="[\\s\\S]":T+=E+Ru(I,++m);return T}(e),n)),r&&(a.sticky=!0),h.length&&(a.groups=h)),e!==S)try{$D(c,"source",S===""?"(?:)":S)}catch(I){}return c},i0=ZD(ui),a0=0;i0.length>a0;)nO(Xi,ui,i0[a0++]);Ka.constructor=Xi,Xi.prototype=Ka,rO(of,"RegExp",Xi,{constructor:!0})}sO("RegExp");var o0=pe(1 .valueOf),s0=`
42
- \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF`,vO=pt,gO=Wt,c0=pe("".replace),Au=`[
43
- \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]`,_O=RegExp("^"+Au+Au+"*"),yO=RegExp(Au+Au+"*$"),cf=function(e){return function(t){var n=gO(vO(t));return 1&e&&(n=c0(n,_O,"")),2&e&&(n=c0(n,yO,"")),n}},Pu={start:cf(1),end:cf(2),trim:cf(3)},bO=ye,uf=re,u0=pe,SO=Ss,kO=Qt,l0=kt,TO=_u,IO=Sn,xO=Mi,d0=ji,wO=ue,CO=ii.f,EO=be.f,RO=Pt.f,AO=o0,PO=Pu.trim,h0="Number",li=uf.Number,lf=li.prototype,DO=uf.TypeError,OO=u0("".slice),Du=u0("".charCodeAt),LO=function(e){var t=d0(e,"number");return typeof t=="bigint"?t:MO(t)},MO=function(e){var t,n,i,r,o,c,a,s,l=d0(e,"number");if(xO(l))throw DO("Cannot convert a Symbol value to a number");if(typeof l=="string"&&l.length>2){if(l=PO(l),(t=Du(l,0))===43||t===45){if((n=Du(l,2))===88||n===120)return NaN}else if(t===48){switch(Du(l,1)){case 66:case 98:i=2,r=49;break;case 79:case 111:i=8,r=55;break;default:return+l}for(c=(o=OO(l,2)).length,a=0;a<c;a++)if((s=Du(o,a))<48||s>r)return NaN;return parseInt(o,i)}}return+l};if(SO(h0,!li(" 0o1")||!li("0b1")||li("+0x1"))){for(var Ou,Xa=function(e){var t=arguments.length<1?0:li(LO(e)),n=this;return IO(lf,n)&&wO(function(){AO(n)})?TO(Object(t),n,Xa):t},f0=bO?CO(li):"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(","),df=0;f0.length>df;df++)l0(li,Ou=f0[df])&&!l0(Xa,Ou)&&RO(Xa,Ou,EO(li,Ou));Xa.prototype=lf,lf.constructor=Xa,kO(uf,h0,Xa,{constructor:!0})}var NO=ys.includes,UO=lu;Le({target:"Array",proto:!0,forced:ue(function(){return!Array(1).includes()})},{includes:function(e){return NO(this,e,arguments.length>1?arguments[1]:void 0)}}),UO("includes");var VO=Xy,jO=TypeError,p0=function(e){if(VO(e))throw jO("The method doesn't accept regular expressions");return e},BO=tt("match"),m0=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[BO]=!1,"/./"[e](t)}catch(i){}}return!1},FO=Le,HO=p0,GO=pt,v0=Wt,WO=m0,zO=pe("".indexOf);FO({target:"String",proto:!0,forced:!WO("includes")},{includes:function(e){return!!~zO(v0(GO(this)),v0(HO(e)),arguments.length>1?arguments[1]:void 0)}});var JO=Le,qO=ys.indexOf,KO=Ns,hf=pe([].indexOf),g0=!!hf&&1/hf([1],1,-0)<0,XO=KO("indexOf");JO({target:"Array",proto:!0,forced:g0||!XO},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return g0?hf(this,e,t)||0:qO(this,e,t)}});var QO=Mt,_0=Ts,YO=Eg;Le({target:"Object",stat:!0,forced:ue(function(){_0(1)}),sham:!YO},{getPrototypeOf:function(e){return _0(QO(e))}});var $O=Ji,ZO=Vt,eL=Tt;Le({target:"Reflect",stat:!0,forced:!ue(function(){Reflect.apply(function(){})})},{apply:function(e,t,n){return $O(ZO(e),t,eL(n))}});var tL=ye,nL=Yn.EXISTS,y0=pe,rL=Pt.f,b0=Function.prototype,iL=y0(b0.toString),S0=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,aL=y0(S0.exec);tL&&!nL&&rL(b0,"name",{configurable:!0,get:function(){try{return aL(S0,iL(this))[1]}catch(e){return""}}});var oL=Le,k0=Date,sL=pe(k0.prototype.getTime);oL({target:"Date",stat:!0},{now:function(){return sL(new k0)}});var Bs,Qa,T0,ff,Fs=rt(re.process)=="process",cL=bu,uL=Xn,lL=TypeError,I0=function(e){if(cL(e))return e;throw lL(uL(e)+" is not a constructor")},x0=Tt,dL=I0,hL=Rt,fL=tt("species"),Lu=function(e,t){var n,i=x0(e).constructor;return i===void 0||hL(n=x0(i)[fL])?t:dL(n)},w0=/(?:ipad|iphone|ipod).*applewebkit/i.test(Kn),In=re,pL=Ji,mL=Lr,C0=it,vL=kt,gL=ue,E0=Sg,_L=Ha,R0=vr,yL=yu,bL=w0,SL=Fs,pf=In.setImmediate,mf=In.clearImmediate,kL=In.process,vf=In.Dispatch,TL=In.Function,A0=In.MessageChannel,IL=In.String,gf=0,Hs={},xL="onreadystatechange";try{Bs=In.location}catch(e){}var _f=function(e){if(vL(Hs,e)){var t=Hs[e];delete Hs[e],t()}},yf=function(e){return function(){_f(e)}},P0=function(e){_f(e.data)},D0=function(e){In.postMessage(IL(e),Bs.protocol+"//"+Bs.host)};pf&&mf||(pf=function(e){yL(arguments.length,1);var t=C0(e)?e:TL(e),n=_L(arguments,1);return Hs[++gf]=function(){pL(t,void 0,n)},Qa(gf),gf},mf=function(e){delete Hs[e]},SL?Qa=function(e){kL.nextTick(yf(e))}:vf&&vf.now?Qa=function(e){vf.now(yf(e))}:A0&&!bL?(ff=(T0=new A0).port2,T0.port1.onmessage=P0,Qa=mL(ff.postMessage,ff)):In.addEventListener&&C0(In.postMessage)&&!In.importScripts&&Bs&&Bs.protocol!=="file:"&&!gL(D0)?(Qa=D0,In.addEventListener("message",P0,!1)):Qa=xL in R0("script")?function(e){E0.appendChild(R0("script")).onreadystatechange=function(){E0.removeChild(this),_f(e)}}:function(e){setTimeout(yf(e),0)});var Gs,Qi,Ws,Ya,bf,Sf,kf,O0,L0={set:pf,clear:mf},wL=re,CL=/ipad|iphone|ipod/i.test(Kn)&&wL.Pebble!==void 0,EL=/web0s(?!.*chrome)/i.test(Kn),Yi=re,M0=Lr,RL=be.f,Tf=L0.set,AL=w0,PL=CL,DL=EL,If=Fs,N0=Yi.MutationObserver||Yi.WebKitMutationObserver,U0=Yi.document,V0=Yi.process,Mu=Yi.Promise,j0=RL(Yi,"queueMicrotask"),B0=j0&&j0.value;B0||(Gs=function(){var e,t;for(If&&(e=V0.domain)&&e.exit();Qi;){t=Qi.fn,Qi=Qi.next;try{t()}catch(n){throw Qi?Ya():Ws=void 0,n}}Ws=void 0,e&&e.enter()},AL||If||DL||!N0||!U0?!PL&&Mu&&Mu.resolve?((kf=Mu.resolve(void 0)).constructor=Mu,O0=M0(kf.then,kf),Ya=function(){O0(Gs)}):If?Ya=function(){V0.nextTick(Gs)}:(Tf=M0(Tf,Yi),Ya=function(){Tf(Gs)}):(bf=!0,Sf=U0.createTextNode(""),new N0(Gs).observe(Sf,{characterData:!0}),Ya=function(){Sf.data=bf=!bf}));var OL=B0||function(e){var t={fn:e,next:void 0};Ws&&(Ws.next=t),Qi||(Qi=t,Ya()),Ws=t},LL=re,xf=function(e){try{return{error:!1,value:e()}}catch(t){return{error:!0,value:t}}},F0=function(){this.head=null,this.tail=null};F0.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var ML=F0,zs=re.Promise,H0=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",NL=!H0&&!Fs&&typeof window=="object"&&typeof document=="object",UL=re,Js=zs,VL=it,jL=Ss,BL=d,FL=tt,HL=NL,GL=H0,wf=pr;Js&&Js.prototype;var WL=FL("species"),G0=!1,W0=VL(UL.PromiseRejectionEvent),zL=jL("Promise",function(){var e=BL(Js),t=e!==String(Js);if(!t&&wf===66)return!0;if(!wf||wf<51||!/native code/.test(e)){var n=new Js(function(r){r(1)}),i=function(r){r(function(){},function(){})};if((n.constructor={})[WL]=i,!(G0=n.then(function(){})instanceof i))return!0}return!t&&(HL||GL)&&!W0}),$i={CONSTRUCTOR:zL,REJECTION_EVENT:W0,SUBCLASSING:G0},$a={},z0=Vt,JL=TypeError,qL=function(e){var t,n;this.promise=new e(function(i,r){if(t!==void 0||n!==void 0)throw JL("Bad Promise constructor");t=i,n=r}),this.resolve=z0(t),this.reject=z0(n)};$a.f=function(e){return new qL(e)};var Cf,J0,q0,KL=Le,Nu=Fs,di=re,Za=Ke,K0=Qt,X0=Fa,XL=zi,QL=Ps,YL=Vt,Uu=it,$L=at,ZL=si,eM=Lu,Q0=L0.set,Ef=OL,tM=function(e,t){var n=LL.console;n&&n.error&&(arguments.length==1?n.error(e):n.error(e,t))},nM=xf,rM=ML,Y0=Xe,Vu=zs,$0=$a,ju="Promise",Z0=$i.CONSTRUCTOR,iM=$i.REJECTION_EVENT,aM=$i.SUBCLASSING,Rf=Y0.getterFor(ju),oM=Y0.set,eo=Vu&&Vu.prototype,to=Vu,Bu=eo,eb=di.TypeError,Af=di.document,Pf=di.process,Df=$0.f,sM=Df,cM=!!(Af&&Af.createEvent&&di.dispatchEvent),tb="unhandledrejection",nb=function(e){var t;return!(!$L(e)||!Uu(t=e.then))&&t},rb=function(e,t){var n,i,r,o=t.value,c=t.state==1,a=c?e.ok:e.fail,s=e.resolve,l=e.reject,u=e.domain;try{a?(c||(t.rejection===2&&lM(t),t.rejection=1),a===!0?n=o:(u&&u.enter(),n=a(o),u&&(u.exit(),r=!0)),n===e.promise?l(eb("Promise-chain cycle")):(i=nb(n))?Za(i,n,s,l):s(n)):l(o)}catch(h){u&&!r&&u.exit(),l(h)}},ib=function(e,t){e.notified||(e.notified=!0,Ef(function(){for(var n,i=e.reactions;n=i.get();)rb(n,e);e.notified=!1,t&&!e.rejection&&uM(e)}))},ab=function(e,t,n){var i,r;cM?((i=Af.createEvent("Event")).promise=t,i.reason=n,i.initEvent(e,!1,!0),di.dispatchEvent(i)):i={promise:t,reason:n},!iM&&(r=di["on"+e])?r(i):e===tb&&tM("Unhandled promise rejection",n)},uM=function(e){Za(Q0,di,function(){var t,n=e.facade,i=e.value;if(ob(e)&&(t=nM(function(){Nu?Pf.emit("unhandledRejection",i,n):ab(tb,n,i)}),e.rejection=Nu||ob(e)?2:1,t.error))throw t.value})},ob=function(e){return e.rejection!==1&&!e.parent},lM=function(e){Za(Q0,di,function(){var t=e.facade;Nu?Pf.emit("rejectionHandled",t):ab("rejectionhandled",t,e.value)})},no=function(e,t,n){return function(i){e(t,i,n)}},ro=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,ib(e,!0))},Of=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw eb("Promise can't be resolved itself");var i=nb(t);i?Ef(function(){var r={done:!1};try{Za(i,t,no(Of,r,e),no(ro,r,e))}catch(o){ro(r,o,e)}}):(e.value=t,e.state=1,ib(e,!1))}catch(r){ro({done:!1},r,e)}}};if(Z0&&(Bu=(to=function(e){ZL(this,Bu),YL(e),Za(Cf,this);var t=Rf(this);try{e(no(Of,t),no(ro,t))}catch(n){ro(t,n)}}).prototype,(Cf=function(e){oM(this,{type:ju,done:!1,notified:!1,parent:!1,reactions:new rM,rejection:!1,state:0,value:void 0})}).prototype=K0(Bu,"then",function(e,t){var n=Rf(this),i=Df(eM(this,to));return n.parent=!0,i.ok=!Uu(e)||e,i.fail=Uu(t)&&t,i.domain=Nu?Pf.domain:void 0,n.state==0?n.reactions.add(i):Ef(function(){rb(i,n)}),i.promise}),J0=function(){var e=new Cf,t=Rf(e);this.promise=e,this.resolve=no(Of,t),this.reject=no(ro,t)},$0.f=Df=function(e){return e===to||e===void 0?new J0(e):sM(e)},Uu(Vu)&&eo!==Object.prototype)){q0=eo.then,aM||K0(eo,"then",function(e,t){var n=this;return new to(function(i,r){Za(q0,n,i,r)}).then(e,t)},{unsafe:!0});try{delete eo.constructor}catch(e){}X0&&X0(eo,Bu)}KL({global:!0,constructor:!0,wrap:!0,forced:Z0},{Promise:to}),XL(to,ju,!1),QL(ju);var dM=zs,sb=$i.CONSTRUCTOR||!gu(function(e){dM.all(e).then(void 0,function(){})}),hM=Ke,fM=Vt,pM=$a,mM=xf,vM=Rs;Le({target:"Promise",stat:!0,forced:sb},{all:function(e){var t=this,n=pM.f(t),i=n.resolve,r=n.reject,o=mM(function(){var c=fM(t.resolve),a=[],s=0,l=1;vM(e,function(u){var h=s++,S=!1;l++,hM(c,t,u).then(function(I){S||(S=!0,a[h]=I,--l||i(a))},r)}),--l||i(a)});return o.error&&r(o.value),n.promise}});var gM=Le,_M=$i.CONSTRUCTOR,Lf=zs,yM=An,bM=it,SM=Qt,cb=Lf&&Lf.prototype;if(gM({target:"Promise",proto:!0,forced:_M,real:!0},{catch:function(e){return this.then(void 0,e)}}),bM(Lf)){var ub=yM("Promise").prototype.catch;cb.catch!==ub&&SM(cb,"catch",ub,{unsafe:!0})}var kM=Ke,TM=Vt,IM=$a,xM=xf,wM=Rs;Le({target:"Promise",stat:!0,forced:sb},{race:function(e){var t=this,n=IM.f(t),i=n.reject,r=xM(function(){var o=TM(t.resolve);wM(e,function(c){kM(o,t,c).then(n.resolve,i)})});return r.error&&i(r.value),n.promise}});var CM=Ke,EM=$a;Le({target:"Promise",stat:!0,forced:$i.CONSTRUCTOR},{reject:function(e){var t=EM.f(this);return CM(t.reject,void 0,e),t.promise}});var RM=Tt,AM=at,PM=$a,lb=function(e,t){if(RM(e),AM(t)&&t.constructor===e)return t;var n=PM.f(e);return(0,n.resolve)(t),n.promise},DM=Le,OM=$i.CONSTRUCTOR,LM=lb;An("Promise"),DM({target:"Promise",stat:!0,forced:OM},{resolve:function(e){return LM(this,e)}});var MM=Mt,db=su;Le({target:"Object",stat:!0,forced:ue(function(){db(1)})},{keys:function(e){return db(MM(e))}});var hb="canvas",Ee="audio",Ie="video",Mf="screen",Mr="small",Fu="big",gt="auxiliary",Nn="aux",Hu="smallVideo",fb="user",pb="environment",tn="mute",Sr="unmute",Nt="ended",hi="playing",fi="pause",io="error",Nf="loadeddata",qs="audioinput",Gu="videoinput",mb="detail",NM="text",Qe="main",er="backup",UM="banned",VM="kick",jM="user_time_out",BM="room_disband",vb="sei-message",ao="PLAYING",kr="PAUSED",pi="STOPPED",oo="inactive",mi="sendonly",Uf="recvonly",gb="add",_b="remove",FM="replace",Vf="track",HM="wss://trtc.rtc.qq.com",GM="wss://webrtc.qq.com",Wu="qcloud",WM="trtc",zM="webrtc",Ks="",yb="jssdk_log",JM="jssdk_event",qM="jssdk_new_endreport",jf=function(e){return Ks=e},KM=1,XM=2,zu="live",so=20,Bf=21,Tr="anchor",Zi="audience",Ir="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",Xs="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",QM=2,yt=Qe,Dt=gt,Ju="unknown",on="DISCONNECTED",bb="CONNECTING",Ff="RECONNECTING",sn="CONNECTED",YM="new",qu="connecting",Sb="failed",Hf="closed",$M="disconnected",kb="connected",ZM="completed",Gf=30,Tb="join",eN="delta-join",Ib="rejoin",tN="leave",nN="delta-leave",xb="publish",rN="delta-publish",wb="unpublish",Cb="subscribe",Eb="unsubscribe",Rb="uplink-connection",Ab="uplink-reconnection",Pb="downlink-connection",Db="downlink-reconnection",Ku="setLocalDescription",Ob="setRemoteDescription",Lb="iceConnectionState",Qs="stream-initialize",Wf="websocketConnectionState",Mb="websocketReconnectionState",Nb="update-stream",Ub="recover-subscription",Vb="start-mix-transcode",jb="stop-mix-transcode",Bb="player-error",Fb="schedule",zf="unsubscribe",Jf="subscribe_change",Ys="unified-plan",qf="plan-b",Kf={MANUAL:"manual",PRESET_LAYOUT:"preset-layout"},Hb={REMOTE:"$PLACE_HOLDER_REMOTE$"},Gb={IT_AUDIO_VIDEO:0,IT_PICTURE:2,IT_CANVAS:3,IT_PURE_AUDIO:4,IT_PURE_VIDEO:5},dt="string",wt="number",zt="boolean",Wb="array",xn="object",cn={ADD:gb,REMOVE:_b},Xf={unknown:0,wifi:1,"4g":2,"3g":3,"2g":4,wired:5},zb=-1,$s=0,iN=1,Jb=Fu,qb=Mr,Kb=6048e5,aN="schedule.cloud-rtc.com",oN="schedule.rtc.qcloud.com",sN="schedule.rtc.tencentcloud.com",cN="schedule-ecdn.rtc.tencentcloud.com",Qf="",Xb=function(e){return Qf=e},Zs="TRTC",un="Client",vi="LocalStream",Yf="RemoteStream",uN="Stream",$f="web.sdk.qcloud.com",Qb="web.sdk.tencent.cn",Yb="web.sdk.cloud.tencent.cn",$b="https://console.cloud.tencent.com/trtc",co="https://".concat($f,"/trtc/webrtc/doc"),Zf="".concat(co,"/zh-cn/"),ep="trtc_error_assistance",Xu="default",Zb="communications",Un={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,NONE:5},lN=1,eS=2,dN=1,tS=2,ea=Object.keys(Un),hN=["normal leave","timeout leave","kick","role change"],Qu=2e3,uo="ric",Yu="raf",fN="interval",nS="timeout",rS="Resolution reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386",pN={"TRTC.checkSystemRequirements":40001,"TRTC.isScreenShareSupported":40002,"TRTC.isSmallStreamSupported":40003,"TRTC.createClient.rtc":40004,"TRTC.createClient.live":40005,"TRTC.createClient.intRoomId":40006,"TRTC.createClient.stringRoomId":40007,"TRTC.createClient.autoSubscribe":40008,"TRTC.createClient.manualSubscribe":40009,"TRTC.enableUploadLog":40010,"TRTC.disableUploadLog":40011,"Client.publish":40012,"Client.publish.isAuxiliary":40013,"Client.switchRole":40014,"Client.startPublishCDNStream":40015,"Client.stopPublishCDNStream":40016,"Client.startMixTranscode":40017,"Client.stopMixTranscode":40018,"Client.enableAudioVolumeEvaluation":40019,"Client.enableSmallStream":40020,"Client.disableSmallStream":40021,"Client.setSmallStreamProfile":40022,"Client.setRemoteVideoStreamType":40023,"Client.sendSEIMessage":40024,"Client.setProxyServer":40025,"Client.setTurnServer":40026,"LocalStream.setAudioProfile.standard":40027,"LocalStream.setAudioProfile.high":40028,"LocalStream.setAudioProfile.standard-stereo":40029,"LocalStream.setAudioProfile.high-stereo":40030,"LocalStream.setVideoProfile.120p":40031,"LocalStream.setVideoProfile.120p_2":40032,"LocalStream.setVideoProfile.180p":40033,"LocalStream.setVideoProfile.180p_2":40034,"LocalStream.setVideoProfile.240p":40035,"LocalStream.setVideoProfile.240p_2":40036,"LocalStream.setVideoProfile.360p":40037,"LocalStream.setVideoProfile.360p_2":40038,"LocalStream.setVideoProfile.480p":40039,"LocalStream.setVideoProfile.480p_2":40040,"LocalStream.setVideoProfile.720p":40041,"LocalStream.setVideoProfile.1080p":40042,"LocalStream.setVideoProfile.1440p":40043,"LocalStream.setVideoProfile.4K":40044,"LocalStream.setScreenProfile.480p":40045,"LocalStream.setScreenProfile.480p_2":40046,"LocalStream.setScreenProfile.720p":40047,"LocalStream.setScreenProfile.720p_2":40048,"LocalStream.setScreenProfile.1080p":40049,"LocalStream.setScreenProfile.1080p_2":40050,"LocalStream.setVideoContentHint.motion":40051,"LocalStream.setVideoContentHint.detail":40052,"LocalStream.setVideoContentHint.text":40053,"LocalStream.setAudioCaptureVolume":40054,"LocalStream.getVideoFrame":40055,"RemoteStream.setAudioOutput":40056,"RemoteStream.getVideoFrame":40057,AI_DENOISER:1700,SPATIAL_AUDIO:1701,"2K_4K":1704},tp=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId"],mN=pt,iS=Wt,vN=/"/g,gN=pe("".replace),aS=function(e,t,n,i){var r=iS(mN(e)),o="<"+t;return n!==""&&(o+=" "+n+'="'+gN(iS(i),vN,"&quot;")+'"'),o+">"+r+"</"+t+">"},_N=ue,oS=function(e){return _N(function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3})},yN=aS;Le({target:"String",proto:!0,forced:oS("link")},{link:function(e){return yN(this,"a","href",e)}}),Le({target:"Array",stat:!0},{isArray:Ga});var bN="AVOID_REPEATED_CALL",SN="INVALID_PARAMETER_REQUIRED",sS="INVALID_PARAMETER_TYPE",kN="INVALID_PARAMETER_EMPTY",cS="INVALID_PARAMETER_INSTANCE",TN="INVALID_PARAMETER_RANGE",IN="API_CALL_TIMEOUT",xN="SIGNAL_CHANNEL_RECONNECTION_FAILED",wN="SIGNAL_CHANNEL_SETUP_FAILED",CN="ERROR_MESSAGE",EN="EXCHANGE_SDP_TIMEOUT",RN="DOWNLINK_RECONNECTION_FAILED",AN="EXCHANGE_SDP_FAILED",PN="UPLINK_RECONNECTION_FAILED",DN="INVALID_PURE_AUDIO",ON="INVALID_STREAMID",LN="INVALID_USER_DEFINE_RECORDID",MN="INVALID_USER_DEFINE_PUSH_ARGS",NN="INVALID_PROXY",UN="INVALID_JOIN",VN="INVALID_ROOMID_STRING",jN="INVALID_ROOMID_INTEGER",BN="JOIN_ROOM_TIMEOUT",uS="JOIN_ROOM_FAILED",FN="REJOIN_ROOM_FAILED",HN="INVALID_DESTROY",GN="INVALID_PUBLISH",WN="INVALID_UNPUBLISH",zN="INVALID_AUDIENCE",JN="INVALID_INITIALIZE",qN="INVALID_DUPLICATE_PUBLISHING",np="INVALID_REMOTE_STREAM",KN="SUBSCRIBE_FAILED",XN="INVALID_ROLE",QN="INVALID_OPERATION_SWITCH_ROLE",YN="SWITCH_ROLE_TIMEOUT",$N="SWITCH_ROLE_FAILED",ZN="CLIENT_BANNED",lS="INVALID_OPERATION_START_PUBLISH_CDN",e3="INVALID_OPERATION_STOP_PUBLISH_CDN",t3="INVALID_STREAM_ID",dS="START_PUBLISH_CDN_FAILED",hS="STOP_PUBLISH_CDN_FAILED",n3="START_MIX_TRANSCODE",r3="STOP_MIX_TRANSCODE",i3="INVALID_AUDIO_VOLUME",a3="ENABLE_SMALL_STREAM_PUBLISHED",o3="DISABLE_SMALL_STREAM_PUBLISHED",s3="NOT_SUPPORTED_SMALL_STREAM",c3="INVALID_SMALL_STREAM_PROFILE",u3="INVALID_PARAMETER_REMOTE_STREAM",l3="INVALID_SWITCH_DEVICE",d3="INVALID_SWITCH_DEVICE_PUBLISHING",fS="INVALID_REPLACE_TRACK",h3="INVALID_INITIALIZE_LOCAL_STREAM",f3="INVALID_ADD_TRACK_REPETITIVE",p3="INVALID_ADD_TRACK_REMOVING",m3="INVALID_ADD_TRACK_PUBLISHING",pS="INVALID_STREAM_INITIALIZED",v3="INVALID_ADD_TRACK_NUMBER",g3="INVALID_REMOVE_AUDIO_TRACK",_3="INVALID_REMOVE_AUDIO_ADDING",y3="INVALID_REMOVE_AUDIO_ON",b3="INVALID_REMOVE_TRACK_PUBLISHING",S3="INVALID_REMOVE_TRACK_NOT_PUBLISHING",k3="INVALID_REMOVE_TRACK_NUMBER",T3="INVALID_REPLACE_TRACK_NO_TRACK",I3="REPEAT_JOIN",rp="CLIENT_DESTROYED",x3="START_MIX_TRANSCODE_FAILED",w3="STOP_MIX_TRANSCODE_FAILED",C3="MIX_TRANSCODE_NOT_STARTED",E3="CANNOT_LESS_THAN_ZERO",R3="MIX_PARAMS_VIDEO_FRAMERATE",A3="MIX_PARAMS_VIDEO_GOP",P3="MIX_PARAMS_AUDIO_BITRATE",D3="MIX_PARAMS_USER_Z_ORDER",O3="MIX_PARAMS_NOT_SELF",L3="MIX_PARAMS_USER_STREAM",M3="INVALID_ELEMENT_ID",N3="INVALID_ELEMENT_ID_TYPE",ip="PLAY_FAILED",U3="INVALID_CREATE_STREAM_SOURCE",V3="INVALID_CREATE_STREAM_SCREEN",j3="INVALID_CREATE_STREAM_AUDIO",B3="INVALID_CREATE_STREAM_SCREEN_AUDIO",mS="NOT_SUPPORTED_HTTP",vS="NOT_SUPPORTED_WEBRTC",F3="NOT_SUPPORTED_PROFILE",gS="NOT_SUPPORTED_H264ENCODE",_S="NOT_SUPPORTED_H264DECODE",ap="NOT_SUPPORTED_TRACK",H3="NOT_SUPPORTED_SWITCH_DEVICE",G3="NOT_SUPPORTED_CAPTURE",W3="NOT_SUPPORTED_AUX",z3="MICROPHONE_NOT_FOUND",J3="CAMERA_NOT_FOUND",yS="SIGNAL_RESPONSE_FAILED",q3="CATCH_HANDLER_ERROR",K3="API_NOT_EXIST",X3="CONNECTION_CLOSED",Q3="SUBSCRIBE_ALL_FALSE",bS="SEI_NOT_SUPPORT",Y3="SEI_DISABLED",$3="SEI_EMPTY",Z3="SEI_OVERSIZE",e4="SEI_BEFORE_PUBLISH",t4="SEI_NOT_VIDEO",n4="CALL_FREQUENCY_LIMIT",r4="CONNECTION_ABORTED",op="API_CALL_ABORTED",i4="DUPLICATE_AUX",gi={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,i=e.fnName,r=e.value;return"'".concat(t||n.name,"' is a required param when calling ").concat(i,"(), received: ").concat(r,".")},INVALID_PARAMETER_TYPE:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value,o="".concat(t||n.name),c="";return c=Array.isArray(n.type)?n.type.join("|"):n.type,"'".concat(o,"' must be type of ").concat(c," when calling ").concat(i,"(), received type: ").concat(Si(r),".")},INVALID_PARAMETER_EMPTY:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value;return"'".concat(t||n.name,"' cannot be '").concat(r,"' when calling ").concat(i,"().")},INVALID_PARAMETER_INSTANCE:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value,o="".concat(t||n.name),c="".concat(n.instanceOf.name||n.instanceOf);return"'".concat(o,"' must be instanceof ").concat(c," when calling ").concat(i,"(), received type: ").concat(Si(r),".")},INVALID_PARAMETER_RANGE:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value;return"'".concat(t||n.name,"' must be one of ").concat(n.values.join("|")," when calling ").concat(i,"(), received: ").concat(r,".")},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},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.",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_DESTROY:"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(Zi,', please call switchRole("').concat(Tr,'") firstly before publish().'),INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING:function(e){return"duplicate ".concat(e," stream publishing, please unpublish your prev ").concat(e," stream 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){var t=e.message,n=e.stream;return"failed to subscribe ".concat(n.getUserId()," ").concat(n.getType()," stream, reason: ").concat(t,".")},INVALID_ROLE:"switchRole can only be called in live mode.",INVALID_PARAMETER_SWITCH_ROLE:"role could only be set to a value as ".concat(Tr," or ").concat(Zi,"."),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.code," errMsg: ").concat(e.message,".")},CLIENT_BANNED:function(e){return"client was banned because of "+e.message+"."},INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() before client join the room or after client join the room and successfully publish the local stream.",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 on your browser.",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_REPLACE_TRACK_NO_TRACK:function(e){return"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track")},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,i=e.fnName;return e.value,"'".concat(t||n.name,"' cannot be less than 0 when calling ").concat(i,"().")},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,i=e.type;return"the element corresponding to '".concat(t,"' must be instanceof HTMLDivElement when calling ").concat(n,"(), received: ").concat(i,".")},PLAY_FAILED:function(e){return"".concat(e.media," play failed\uFF0Cbrowser exception: ").concat(e.error.toString())},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:"http protocol does not support the ability to capture and publish streams, please use the https protocol.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment 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_TRACK:function(e){return"".concat(e,"Track is not supported on your browser.")},NOT_SUPPORTED_SWITCH_DEVICE:"switchDevice is not supported on your browser.",NOT_SUPPORTED_CAPTURE:"Your browser or environment does not support screen sharing, please check whether the browser version.",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,".")},CATCH_HANDLER_ERROR:function(e){var t=e.name,n=e.event;return"an error was caught on ".concat(t,".on('").concat(n,"', handler), please check your code on 'handler'.")},API_NOT_EXIST:function(e){var t=e.name;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:function(e){return"[".concat(e,"] is calling client.join api or has already joined room, please avoid repeated join.")},CONNECTION_CLOSED:"remoteStream has been unsubscribed or unpublished by remote user.",SUBSCRIBE_ALL_FALSE:"cannot subscribe when both audio & video are false, use client.unsubscribe() instead",CLIENT_DESTROYED:function(e){var t=e.funName;return"failed to call ".concat(t,"() because client was destroyed.")},SEI_NOT_SUPPORT:function(e){return"not support to sendSEIMessage".concat(e===!1?" without using h264 codec":"")},SEI_DISABLED:"SEI is disabled, to enable SEI: TRTC.createClient({ enableSEI: true })",SEI_EMPTY:"buffer cannot be empty",SEI_OVERSIZE:function(e){return"buffer size(".concat(e,") is over 1000 Bytes")},SEI_BEFORE_PUBLISH:"please call sendSEIMessage() after publish() success",SEI_NOT_VIDEO:"cannot send sei when localStream has not video.",CALL_FREQUENCY_LIMIT:function(e){var t=e.isSize,n=e.name,i=e.timesInSecond,r=e.maxSizeInSecond;return"api ".concat(n," call ").concat(t?"size":"times"," is over ").concat(t?r+" bytes":i," in a second.")},CONNECTION_ABORTED:function(e){return"connection aborted due to: "+e},API_CALL_ABORTED:function(e){return e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.stream.getUserId()," ").concat(e.stream.getType()," stream aborted, reason: remote user ").concat(e.stream.getUserId()," unpublished stream."):"API aborted, reason: ".concat(e.message)},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser."},SS=re,a4=ue,o4=Wt,s4=Pu.trim,c4=pe("".charAt),$u=SS.parseFloat,kS=SS.Symbol,TS=kS&&kS.iterator,IS=1/$u(`
44
- \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF-0`)!=-1/0||TS&&!a4(function(){$u(Object(TS))})?function(e){var t=s4(o4(e)),n=$u(t);return n===0&&c4(t,0)=="-"?-0:n}:$u;Le({global:!0,forced:parseFloat!=IS},{parseFloat:IS});var Ce=window.navigator&&window.navigator.userAgent||"",xS=/AppleWebKit\/([\d.]+)/i.exec(Ce);xS&&parseFloat(xS.pop());var sp=/iPad/i.test(Ce),wS=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/Macintosh/.test(Ce),cp=/iPhone/i.test(Ce)&&!sp,u4=/iPod/i.test(Ce),_i=cp||sp||u4||wS,ta=/Android/i.test(Ce);ta&&function(){var e=Ce.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])}(),ta&&/webkit/i.test(Ce);var Vn=/Firefox/i.test(Ce),CS=Vn&&function(){var e=Ce.match(/Firefox\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),Zu=/Edge\//i.test(Ce),l4=Zu&&function(){var e=Ce.match(/Edge\/(\d+)/i);if(e&&e[1])return e[1]}(),el=/Edg\//i.test(Ce),ES=el&&function(){var e=Ce.match(/Edg\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),up=/SogouMobileBrowser\//i.test(Ce),d4=up&&function(){var e=Ce.match(/SogouMobileBrowser\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),lp=/MetaSr\s/i.test(Ce),h4=lp&&function(){var e=Ce.match(/MetaSr(\s\d+(\.\d+)+)/);return e&&e[1]?parseFloat(e[1]):null}(),Nr=/TBS\/\d+/i.test(Ce),f4=Nr&&function(){var e=Ce.match(/TBS\/(\d+)/i);if(e&&e[1])return e[1]}(),dp=/XWEB\/\d+/i.test(Ce),p4=dp&&function(){var e=Ce.match(/XWEB\/(\d+)/i);if(e&&e[1])return e[1]}();/MSIE\s8\.0/.test(Ce),/MSIE\/\d+/i.test(Ce)&&function(){var e=/MSIE\s(\d+)\.\d/.exec(Ce),t=e&&parseFloat(e[1]);!t&&/Trident\/7.0/i.test(Ce)&&/rv:11.0/.test(Ce)&&(t=11)}();var hp=/(micromessenger|webbrowser)/i.test(Ce),m4=hp&&function(){var e=Ce.match(/MicroMessenger\/(\d+)/i);if(e&&e[1])return e[1]}(),fp=!Nr&&/MQQBrowser\/\d+/i.test(Ce)&&/COVC\/\d+/i.test(Ce),pp=!Nr&&/MQQBrowser\/\d+/i.test(Ce)&&!/COVC\/\d+/i.test(Ce),RS=(pp||fp)&&function(){var e=Ce.match(/ MQQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),mp=!Nr&&/ QQBrowser\/\d+/i.test(Ce),v4=mp&&function(){var e=Ce.match(/ QQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),vp=!Nr&&/QQBrowserLite\/\d+/i.test(Ce),g4=vp&&function(){var e=Ce.match(/QQBrowserLite\/([\d.]+)/);return e&&e[1]?e[1]:null}(),gp=!Nr&&/MQBHD\/\d+/i.test(Ce),_4=gp&&function(){var e=Ce.match(/MQBHD\/([\d.]+)/);return e&&e[1]?e[1]:null}(),AS=/Windows/i.test(Ce),ec=!_i&&/MAC OS X/i.test(Ce),PS=!ta&&/Linux/i.test(Ce);/MicroMessenger/i.test(Ce);var y4=/UCBrowser/i.test(Ce);/Electron/i.test(Ce);var DS,tl,_p=/MiuiBrowser/i.test(Ce),b4=_p&&function(){var e=Ce.match(/MiuiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),yp=/HuaweiBrowser/i.test(Ce),bp=/Huawei/i.test(Ce),S4=yp&&function(){var e=Ce.match(/HuaweiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Sp=/SamsungBrowser/i.test(Ce),k4=Sp&&function(){var e=Ce.match(/SamsungBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),nl=/HeyTapBrowser/i.test(Ce),T4=nl&&function(){var e=Ce.match(/HeyTapBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),rl=/VivoBrowser/i.test(Ce),I4=rl&&function(){var e=Ce.match(/VivoBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),lo=function(){var e=Ce.match(/Chrome\/(\d+)/);return e&&e[1]?Number(e[1]):null},x4=/Chrome/i.test(Ce),il=!Zu&&!lp&&!up&&!Nr&&!dp&&!el&&!mp&&!_p&&!yp&&!Sp&&!nl&&!rl&&/Chrome/i.test(Ce),kp=il&&lo(),w4=il&&function(){var e=Ce.match(/Chrome\/([\d.]+)/);return e&&e[1]?e[1]:null}(),na=!x4&&!pp&&!fp&&!vp&&!gp&&/Safari/i.test(Ce),Tp=function(){if(na){var e=Ce.match(/Version\/([\d.]+)/);if(e&&e[1])return e[1]}return""}(),C4=/Android.*(wv|.0.0.0)/.test(Ce),yi=function(){if(wS)return Tp;if(_i){var e=Ce.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}(),OS=Number(yi.split(".")[0]),al=Tp==="15.1",ol=yi==="15.1",E4=(DS=Number(yi.split(".")[0]))===14||DS===13,ra=location.protocol==="file:"||location.hostname==="localhost"||location.hostname==="127.0.0.1",ia=function(){if(ge(tl))try{tl=window.localStorage}catch(e){_e.warn(e),tl=!1}return tl},Ip=new Map([[Vn,["Firefox",CS]],[el,["Edg",ES]],[il,["Chrome",w4]],[na,["Safari",Tp]],[Nr,["TBS",f4]],[dp,["XWEB",p4]],[hp&&cp,["WeChat",m4]],[mp,["QQ(Win)",v4]],[pp,["QQ(Mobile)",RS]],[fp,["QQ(Mobile X5)",RS]],[vp,["QQ(Mac)",g4]],[gp,["QQ(iPad)",_4]],[_p,["MI",b4]],[yp,["HW",S4]],[Sp,["Samsung",k4]],[nl,["OPPO",T4]],[rl,["VIVO",I4]],[Zu,["EDGE",l4]],[up,["SogouMobile",d4]],[lp,["Sogou",h4]]]);function aa(){var e="unknown",t="unknown";return Ip.get(!0)&&(e=Ip.get(!0)[0],t=Ip.get(!0)[1]),{name:e,version:t}}var LS=function(e,t){return t?co+"/"+e+"/"+t:co+"/"+e+"/index.html"},R4=function(){if(!ia())return!1;var e=localStorage.getItem(ep);e&&!function(t){var n=t.saveTime&&new Date().getTime()-t.saveTime>=Kb,i=!t.saveVersion||t.saveVersion!==oi;return n||i}(JSON.parse(e))||(_e.info("init debug info"),function(){var t=new XMLHttpRequest;if(t.open("GET","https://web.sdk.qcloud.com/trtc/webrtc/download/error-message/0.0.3/script.js",!1),t.send(null),t.readyState===4&&t.status===200){var n=document.createElement("script");n.type="text/javascript",n.text=t.responseText,document.body.appendChild(n),localStorage.setItem(ep,JSON.stringify({message:t.responseText,saveTime:new Date().getTime(),saveVersion:oi})),document.body.removeChild(n)}}())};function ae(e){var t=e.key,n=e.data,i=e.link,r=e.addDocLink,o=r===void 0||r,c="",a="",s="";ln(gi[t])?c=gi[t](n):Bt(gi[t])&&(c=gi[t]);var l=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 I=localStorage.getItem(ep);if(I){I=JSON.parse(I);var E=document.createElement("script");E.type="text/javascript",E.text=I.message,document.body.appendChild(E);var x=window.TRTC_ERROR_INFO,m=window.TRTC_ERROR_LINK;return document.body.removeChild(E),{TRTC_ERROR_INFO:x,TRTC_ERROR_LINK:m}}return{}}(),u=l.TRTC_ERROR_INFO,h=l.TRTC_ERROR_LINK;i?s="".concat(i.className,".html#").concat(i.fnName):h&&h[t]&&(ln(h[t])?s=h[t](n):Bt(h[t])&&(s=h[t]));var S=c;return oa()&&(u&&u[t]&&(ln(u[t])?a=u[t](n):Bt(u[t])&&(a=u[t])),a&&(S=o?a+`
39
+ `},c.getDirection=function(a,s){for(var l=c.splitLines(a),u=0;u<l.length;u++)switch(l[u]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return l[u].substring(2)}return s?c.getDirection(s):"sendrecv"},c.getKind=function(a){return c.splitLines(a)[0].split(" ")[0].substring(2)},c.isRejected=function(a){return a.split(" ",2)[1]==="0"},c.parseMLine=function(a){var s=c.splitLines(a)[0].substring(2).split(" ");return{kind:s[0],port:parseInt(s[1],10),protocol:s[2],fmt:s.slice(3).join(" ")}},c.parseOLine=function(a){var s=c.matchPrefix(a,"o=")[0].substring(2).split(" ");return{username:s[0],sessionId:s[1],sessionVersion:parseInt(s[2],10),netType:s[3],addressType:s[4],address:s[5]}},c.isValidSDP=function(a){if(typeof a!="string"||a.length===0)return!1;for(var s=c.splitLines(a),l=0;l<s.length;l++)if(s[l].length<2||s[l].charAt(1)!=="=")return!1;return!0},(i===void 0?"undefined":o(i))==="object"&&(i.exports=c)},{}]},{},[1])(1)}({exports:{}});var oi="4.15.22-beta.5",bg={},vC=vg,gC=Wd,ou=Object.keys||function(e){return vC(e,gC)},_C=ye,yC=hs,bC=Pt,SC=Tt,kC=bn,TC=ou;bg.f=_C&&!yC?Object.defineProperties:function(e,t){SC(e);for(var n,i=kC(t),r=TC(t),o=r.length,c=0;o>c;)bC.f(e,n=r[c++],i[n]);return e};var su,Sg=An("document","documentElement"),IC=Tt,xC=bg,kg=Wd,wC=ee,CC=Sg,EC=vr,Tg=W("IE_PROTO"),Xd=function(){},Ig=function(e){return"<script>"+e+"<\/script>"},xg=function(e){e.write(Ig("")),e.close();var t=e.parentWindow.Object;return e=null,t},cu=function(){try{su=new ActiveXObject("htmlfile")}catch(i){}var e,t;cu=typeof document!="undefined"?document.domain&&su?xg(su):((t=EC("iframe")).style.display="none",CC.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(Ig("document.F=Object")),e.close(),e.F):xg(su);for(var n=kg.length;n--;)delete cu.prototype[kg[n]];return cu()};wC[Tg]=!0;var Ba=Object.create||function(e,t){var n;return e!==null?(Xd.prototype=IC(e),n=new Xd,Xd.prototype=null,n[Tg]=e):n=cu(),t===void 0?n:xC.f(n,t)},RC=tt,AC=Ba,PC=Pt.f,Qd=RC("unscopables"),Yd=Array.prototype;Yd[Qd]==null&&PC(Yd,Qd,{configurable:!0,value:AC(null)});var zi,wg,Cg,uu=function(e){Yd[Qd][e]=!0},ks={},Eg=!se(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),DC=kt,OC=it,LC=Mt,MC=Eg,Rg=W("IE_PROTO"),$d=Object,NC=$d.prototype,Ts=MC?$d.getPrototypeOf:function(e){var t=LC(e);if(DC(t,Rg))return t[Rg];var n=t.constructor;return OC(n)&&t instanceof n?n.prototype:t instanceof $d?NC:null},UC=se,VC=it,jC=at,Ag=Ts,BC=Qt,Zd=tt("iterator"),Pg=!1;[].keys&&("next"in(Cg=[].keys())?(wg=Ag(Ag(Cg)))!==Object.prototype&&(zi=wg):Pg=!0);var FC=!jC(zi)||UC(function(){var e={};return zi[Zd].call(e)!==e});FC&&(zi={}),VC(zi[Zd])||BC(zi,Zd,function(){return this});var eh={IteratorPrototype:zi,BUGGY_SAFARI_ITERATORS:Pg},HC=Pt.f,GC=kt,Dg=tt("toStringTag"),Wi=function(e,t,n){e&&!n&&(e=e.prototype),e&&!GC(e,Dg)&&HC(e,Dg,{configurable:!0,value:t})},zC=eh.IteratorPrototype,WC=Ba,JC=$e,qC=Wi,KC=ks,XC=function(){return this},Og=function(e,t,n,i){var r=t+" Iterator";return e.prototype=WC(zC,{next:JC(+!i,n)}),qC(e,r,!1),KC[r]=XC,e},QC=it,YC=String,$C=TypeError,ZC=pe,eE=Tt,tE=function(e){if(typeof e=="object"||QC(e))return e;throw $C("Can't set "+YC(e)+" as a prototype")},Fa=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=ZC(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]),t=n instanceof Array}catch(i){}return function(i,r){return eE(i),tE(r),t?e(i,r):i.__proto__=r,i}}():void 0),nE=Le,rE=qe,iE=it,aE=Og,Lg=Ts,Mg=Fa,oE=Wi,sE=Ln,th=Qt,cE=ks,uE=Yn.PROPER,lE=Yn.CONFIGURABLE,Ng=eh.IteratorPrototype,lu=eh.BUGGY_SAFARI_ITERATORS,Is=tt("iterator"),Ug="keys",xs="values",Vg="entries",dE=function(){return this},nh=function(e,t,n,i,r,o,c){aE(n,t,i);var a,s,l,u=function(k){if(k===r&&x)return x;if(!lu&&k in I)return I[k];switch(k){case Ug:case xs:case Vg:return function(){return new n(this,k)}}return function(){return new n(this)}},h=t+" Iterator",b=!1,I=e.prototype,R=I[Is]||I["@@iterator"]||r&&I[r],x=!lu&&R||u(r),m=t=="Array"&&I.entries||R;if(m&&(a=Lg(m.call(new e)))!==Object.prototype&&a.next&&(Lg(a)!==Ng&&(Mg?Mg(a,Ng):iE(a[Is])||th(a,Is,dE)),oE(a,h,!0)),uE&&r==xs&&R&&R.name!==xs&&(lE?sE(I,"name",xs):(b=!0,x=function(){return rE(R,this)})),r)if(s={values:u(xs),keys:o?x:u(Ug),entries:u(Vg)},c)for(l in s)(lu||b||!(l in I))&&th(I,l,s[l]);else nE({target:t,proto:!0,forced:lu||b},s);return I[Is]!==x&&th(I,Is,x,{name:r}),cE[t]=x,s},rh=function(e,t){return{value:e,done:t}},hE=bn,ih=uu,jg=ks,Bg=Ke,fE=Pt.f,pE=nh,Fg=rh,mE=ye,Hg="Array Iterator",vE=Bg.set,gE=Bg.getterFor(Hg),Gg=pE(Array,"Array",function(e,t){vE(this,{type:Hg,target:hE(e),index:0,kind:t})},function(){var e=gE(this),t=e.target,n=e.kind,i=e.index++;return!t||i>=t.length?(e.target=void 0,Fg(void 0,!0)):Fg(n=="keys"?i:n=="values"?t[i]:[i,t[i]],!1)},"values"),zg=jg.Arguments=jg.Array;if(ih("keys"),ih("values"),ih("entries"),mE&&zg.name!=="values")try{fE(zg,"name",{value:"values"})}catch(e){}var Wg={};Wg[tt("toStringTag")]="z";var ah=String(Wg)==="[object z]",_E=ah,yE=it,du=rt,bE=tt("toStringTag"),SE=Object,kE=du(function(){return arguments}())=="Arguments",Dr=_E?du:function(e){var t,n,i;return e===void 0?"Undefined":e===null?"Null":typeof(n=function(r,o){try{return r[o]}catch(c){}}(t=SE(e),bE))=="string"?n:kE?du(t):(i=du(t))=="Object"&&yE(t.callee)?"Arguments":i},TE=Dr,IE=ah?{}.toString:function(){return"[object "+TE(this)+"]"};ah||Qt(Object.prototype,"toString",IE,{unsafe:!0});var ws={exports:{}},oh={},xE=Da,wE=Pt,CE=$e,Cs=function(e,t,n){var i=xE(t);i in e?wE.f(e,i,CE(0,n)):e[i]=n},Jg=ai,EE=nn,RE=Cs,AE=Array,PE=Math.max,hu=function(e,t,n){for(var i=EE(e),r=Jg(t,i),o=Jg(n===void 0?i:n,i),c=AE(PE(o-r,0)),a=0;r<o;r++,a++)RE(c,a,e[r]);return c.length=a,c},DE=rt,OE=bn,qg=ii.f,LE=hu,Kg=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];oh.f=function(e){return Kg&&DE(e)=="Window"?function(t){try{return qg(t)}catch(n){return LE(Kg)}}(e):qg(OE(e))};var ME=se(function(){if(typeof ArrayBuffer=="function"){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}),NE=se,UE=at,VE=rt,Xg=ME,fu=Object.isExtensible,Qg=NE(function(){fu(1)})||Xg?function(e){return!!UE(e)&&(!Xg||VE(e)!="ArrayBuffer")&&(!fu||fu(e))}:fu,jE=!se(function(){return Object.isExtensible(Object.preventExtensions({}))}),BE=Le,FE=pe,HE=ee,GE=at,sh=kt,zE=Pt.f,Yg=ii,WE=oh,ch=Qg,JE=jE,$g=!1,Or=Vi("meta"),qE=0,uh=function(e){zE(e,Or,{value:{objectID:"O"+qE++,weakData:{}}})},KE=ws.exports={enable:function(){KE.enable=function(){},$g=!0;var e=Yg.f,t=FE([].splice),n={};n[Or]=1,e(n).length&&(Yg.f=function(i){for(var r=e(i),o=0,c=r.length;o<c;o++)if(r[o]===Or){t(r,o,1);break}return r},BE({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:WE.f}))},fastKey:function(e,t){if(!GE(e))return typeof e=="symbol"?e:(typeof e=="string"?"S":"P")+e;if(!sh(e,Or)){if(!ch(e))return"F";if(!t)return"E";uh(e)}return e[Or].objectID},getWeakData:function(e,t){if(!sh(e,Or)){if(!ch(e))return!0;if(!t)return!1;uh(e)}return e[Or].weakData},onFreeze:function(e){return JE&&$g&&ch(e)&&!sh(e,Or)&&uh(e),e}};HE[Or]=!0;var XE=Vt,QE=Me,YE=pe(pe.bind),Lr=function(e,t){return XE(e),t===void 0?e:QE?YE(e,t):function(){return e.apply(t,arguments)}},$E=ks,ZE=tt("iterator"),eR=Array.prototype,lh=function(e){return e!==void 0&&($E.Array===e||eR[ZE]===e)},tR=Dr,Zg=Xt,nR=Rt,rR=ks,iR=tt("iterator"),Es=function(e){if(!nR(e))return Zg(e,iR)||Zg(e,"@@iterator")||rR[tR(e)]},aR=qe,oR=Vt,sR=Tt,cR=Xn,uR=Es,lR=TypeError,pu=function(e,t){var n=arguments.length<2?uR(e):t;if(oR(n))return sR(aR(n,e));throw lR(cR(e)+" is not iterable")},dR=qe,e_=Tt,hR=Xt,t_=function(e,t,n){var i,r;e_(e);try{if(!(i=hR(e,"return"))){if(t==="throw")throw n;return n}i=dR(i,e)}catch(o){r=!0,i=o}if(t==="throw")throw n;if(r)throw i;return e_(i),n},fR=Lr,pR=qe,mR=Tt,vR=Xn,gR=lh,_R=nn,n_=Sn,yR=pu,bR=Es,r_=t_,SR=TypeError,mu=function(e,t){this.stopped=e,this.result=t},i_=mu.prototype,Rs=function(e,t,n){var i,r,o,c,a,s,l,u=n&&n.that,h=!(!n||!n.AS_ENTRIES),b=!(!n||!n.IS_RECORD),I=!(!n||!n.IS_ITERATOR),R=!(!n||!n.INTERRUPTED),x=fR(t,u),m=function(v){return i&&r_(i,"normal",v),new mu(!0,v)},k=function(v){return h?(mR(v),R?x(v[0],v[1],m):x(v[0],v[1])):R?x(v,m):x(v)};if(b)i=e.iterator;else if(I)i=e;else{if(!(r=bR(e)))throw SR(vR(e)+" is not iterable");if(gR(r)){for(o=0,c=_R(e);c>o;o++)if((a=k(e[o]))&&n_(i_,a))return a;return new mu(!1)}i=yR(e,r)}for(s=b?e.next:i.next;!(l=pR(s,i)).done;){try{a=k(l.value)}catch(v){r_(i,"throw",v)}if(typeof a=="object"&&a&&n_(i_,a))return a}return new mu(!1)},kR=Sn,TR=TypeError,si=function(e,t){if(kR(t,e))return e;throw TR("Incorrect invocation")},a_=tt("iterator"),o_=!1;try{var IR=0,s_={next:function(){return{done:!!IR++}},return:function(){o_=!0}};s_[a_]=function(){return this},Array.from(s_,function(){throw 2})}catch(e){}var vu=function(e,t){if(!t&&!o_)return!1;var n=!1;try{var i={};i[a_]=function(){return{next:function(){return{done:n=!0}}}},e(i)}catch(r){}return n},xR=it,wR=at,c_=Fa,gu=function(e,t,n){var i,r;return c_&&xR(i=t.constructor)&&i!==n&&wR(r=i.prototype)&&r!==n.prototype&&c_(e,r),e},CR=Le,ER=re,RR=pe,u_=Ss,AR=Qt,PR=ws.exports,DR=Rs,OR=si,LR=it,MR=Rt,dh=at,hh=se,NR=vu,UR=Wi,VR=gu,fh=function(e,t,n){var i=e.indexOf("Map")!==-1,r=e.indexOf("Weak")!==-1,o=i?"set":"add",c=ER[e],a=c&&c.prototype,s=c,l={},u=function(m){var k=RR(a[m]);AR(a,m,m=="add"?function(v){return k(this,v===0?0:v),this}:m=="delete"?function(v){return!(r&&!dh(v))&&k(this,v===0?0:v)}:m=="get"?function(v){return r&&!dh(v)?void 0:k(this,v===0?0:v)}:m=="has"?function(v){return!(r&&!dh(v))&&k(this,v===0?0:v)}:function(v,w){return k(this,v===0?0:v,w),this})};if(u_(e,!LR(c)||!(r||a.forEach&&!hh(function(){new c().entries().next()}))))s=n.getConstructor(t,e,i,o),PR.enable();else if(u_(e,!0)){var h=new s,b=h[o](r?{}:-0,1)!=h,I=hh(function(){h.has(1)}),R=NR(function(m){new c(m)}),x=!r&&hh(function(){for(var m=new c,k=5;k--;)m[o](k,k);return!m.has(-0)});R||((s=t(function(m,k){OR(m,a);var v=VR(new c,m,s);return MR(k)||DR(k,v[o],{that:v,AS_ENTRIES:i}),v})).prototype=a,a.constructor=s),(I||x)&&(u("delete"),u("has"),i&&u("get")),(x||b)&&u(o),r&&a.clear&&delete a.clear}return l[e]=s,CR({global:!0,constructor:!0,forced:s!=c},l),UR(s,e),r||n.setStrong(s,e,i),s},jR=Qt,As=function(e,t,n){for(var i in t)jR(e,i,t[i],n);return e},BR=An,FR=Pt,HR=ye,l_=tt("species"),Ps=function(e){var t=BR(e),n=FR.f;HR&&t&&!t[l_]&&n(t,l_,{configurable:!0,get:function(){return this}})},GR=Pt.f,zR=Ba,d_=As,WR=Lr,JR=si,qR=Rt,KR=Rs,XR=nh,h_=rh,QR=Ps,Ds=ye,f_=ws.exports.fastKey,p_=Ke.set,ph=Ke.getterFor,m_={getConstructor:function(e,t,n,i){var r=e(function(l,u){JR(l,o),p_(l,{type:t,index:zR(null),first:void 0,last:void 0,size:0}),Ds||(l.size=0),qR(u)||KR(u,l[i],{that:l,AS_ENTRIES:n})}),o=r.prototype,c=ph(t),a=function(l,u,h){var b,I,R=c(l),x=s(l,u);return x?x.value=h:(R.last=x={index:I=f_(u,!0),key:u,value:h,previous:b=R.last,next:void 0,removed:!1},R.first||(R.first=x),b&&(b.next=x),Ds?R.size++:l.size++,I!=="F"&&(R.index[I]=x)),l},s=function(l,u){var h,b=c(l),I=f_(u);if(I!=="F")return b.index[I];for(h=b.first;h;h=h.next)if(h.key==u)return h};return d_(o,{clear:function(){for(var l=c(this),u=l.index,h=l.first;h;)h.removed=!0,h.previous&&(h.previous=h.previous.next=void 0),delete u[h.index],h=h.next;l.first=l.last=void 0,Ds?l.size=0:this.size=0},delete:function(l){var u=this,h=c(u),b=s(u,l);if(b){var I=b.next,R=b.previous;delete h.index[b.index],b.removed=!0,R&&(R.next=I),I&&(I.previous=R),h.first==b&&(h.first=I),h.last==b&&(h.last=R),Ds?h.size--:u.size--}return!!b},forEach:function(l){for(var u,h=c(this),b=WR(l,arguments.length>1?arguments[1]:void 0);u=u?u.next:h.first;)for(b(u.value,u.key,this);u&&u.removed;)u=u.previous},has:function(l){return!!s(this,l)}}),d_(o,n?{get:function(l){var u=s(this,l);return u&&u.value},set:function(l,u){return a(this,l===0?0:l,u)}}:{add:function(l){return a(this,l=l===0?0:l,l)}}),Ds&&GR(o,"size",{get:function(){return c(this).size}}),r},setStrong:function(e,t,n){var i=t+" Iterator",r=ph(t),o=ph(i);XR(e,t,function(c,a){p_(this,{type:i,target:c,state:r(c),kind:a,last:void 0})},function(){for(var c=o(this),a=c.kind,s=c.last;s&&s.removed;)s=s.previous;return c.target&&(c.last=s=s?s.next:c.state.first)?h_(a=="keys"?s.key:a=="values"?s.value:[s.key,s.value],!1):(c.target=void 0,h_(void 0,!0))},n?"entries":"values",!n,!0),QR(t)}};fh("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},m_);var YR=Dr,$R=String,zt=function(e){if(YR(e)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return $R(e)},mh=pe,ZR=$n,eA=zt,tA=pt,nA=mh("".charAt),v_=mh("".charCodeAt),rA=mh("".slice),g_=function(e){return function(t,n){var i,r,o=eA(tA(t)),c=ZR(n),a=o.length;return c<0||c>=a?e?"":void 0:(i=v_(o,c))<55296||i>56319||c+1===a||(r=v_(o,c+1))<56320||r>57343?e?nA(o,c):i:e?rA(o,c,c+2):r-56320+(i-55296<<10)+65536}},vh={codeAt:g_(!1),charAt:g_(!0)},iA=vh.charAt,aA=zt,__=Ke,oA=nh,y_=rh,b_="String Iterator",sA=__.set,cA=__.getterFor(b_);oA(String,"String",function(e){sA(this,{type:b_,string:aA(e),index:0})},function(){var e,t=cA(this),n=t.string,i=t.index;return i>=n.length?y_(void 0,!0):(e=iA(n,i),t.index+=e.length,y_(e,!1))});var S_={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},gh=vr("span").classList,k_=gh&&gh.constructor&&gh.constructor.prototype,T_=k_===Object.prototype?void 0:k_,I_=re,x_=S_,uA=T_,Os=Gg,_h=Ln,w_=tt,yh=w_("iterator"),C_=w_("toStringTag"),bh=Os.values,E_=function(e,t){if(e){if(e[yh]!==bh)try{_h(e,yh,bh)}catch(i){e[yh]=bh}if(e[C_]||_h(e,C_,t),x_[t]){for(var n in Os)if(e[n]!==Os[n])try{_h(e,n,Os[n])}catch(i){e[n]=Os[n]}}}};for(var Sh in x_)E_(I_[Sh]&&I_[Sh].prototype,Sh);E_(uA,"DOMTokenList");var lA=Me,R_=Function.prototype,A_=R_.apply,P_=R_.call,Ji=typeof Reflect=="object"&&Reflect.apply||(lA?P_.bind(A_):function(){return P_.apply(A_,arguments)}),Ha=pe([].slice),dA=TypeError,_u=function(e,t){if(e<t)throw dA("Not enough arguments");return e},kh=re,hA=Ji,fA=it,pA=Ha,mA=_u,vA=/MSIE .\./.test(Kn),gA=kh.Function,D_=function(e){return vA?function(t,n){var i=mA(arguments.length,1)>2,r=fA(t)?t:gA(t),o=i?pA(arguments,2):void 0;return e(i?function(){hA(r,this,o)}:r,n)}:e},O_={setTimeout:D_(kh.setTimeout),setInterval:D_(kh.setInterval)},L_=O_.setInterval;Le({global:!0,bind:!0,forced:re.setInterval!==L_},{setInterval:L_});var M_=O_.setTimeout;Le({global:!0,bind:!0,forced:re.setTimeout!==M_},{setTimeout:M_}),fh("Map",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},m_);var _A=rt,Ga=Array.isArray||function(e){return _A(e)=="Array"},yA=pe,bA=se,N_=it,SA=Dr,kA=d,U_=function(){},TA=[],V_=An("Reflect","construct"),Th=/^\s*(?:class|function)\b/,IA=yA(Th.exec),xA=!Th.exec(U_),Ls=function(e){if(!N_(e))return!1;try{return V_(U_,TA,e),!0}catch(t){return!1}},j_=function(e){if(!N_(e))return!1;switch(SA(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return xA||!!IA(Th,kA(e))}catch(t){return!0}};j_.sham=!0;var yu=!V_||bA(function(){var e;return Ls(Ls.call)||!Ls(Object)||!Ls(function(){e=!0})||e})?j_:Ls,B_=Ga,wA=yu,CA=at,EA=tt("species"),F_=Array,RA=function(e){var t;return B_(e)&&(t=e.constructor,(wA(t)&&(t===F_||B_(t.prototype))||CA(t)&&(t=t[EA])===null)&&(t=void 0)),t===void 0?F_:t},Ih=function(e,t){return new(RA(e))(t===0?0:t)},AA=Lr,PA=yn,DA=Mt,OA=nn,LA=Ih,H_=pe([].push),ci=function(e){var t=e==1,n=e==2,i=e==3,r=e==4,o=e==6,c=e==7,a=e==5||o;return function(s,l,u,h){for(var b,I,R=DA(s),x=PA(R),m=AA(l,u),k=OA(x),v=0,w=h||LA,L=t?w(s,k):n||c?w(s,0):void 0;k>v;v++)if((a||v in x)&&(I=m(b=x[v],v,R),e))if(t)L[v]=I;else if(I)switch(e){case 3:return!0;case 5:return b;case 6:return v;case 2:H_(L,b)}else switch(e){case 4:return!1;case 7:H_(L,b)}return o?-1:i||r?r:L}},rn={forEach:ci(0),map:ci(1),filter:ci(2),some:ci(3),every:ci(4),find:ci(5),findIndex:ci(6),filterReject:ci(7)},MA=se,NA=pr,UA=tt("species"),Ms=function(e){return NA>=51||!MA(function(){var t=[];return(t.constructor={})[UA]=function(){return{foo:1}},t[e](Boolean).foo!==1})},VA=rn.map;Le({target:"Array",proto:!0,forced:!Ms("map")},{map:function(e){return VA(this,e,arguments.length>1?arguments[1]:void 0)}});var jA=ye,BA=Ga,FA=TypeError,HA=Object.getOwnPropertyDescriptor,GA=jA&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),zA=TypeError,G_=function(e){if(e>9007199254740991)throw zA("Maximum allowed index exceeded");return e},z_=Xn,WA=TypeError,W_=function(e,t){if(!delete e[t])throw WA("Cannot delete property "+z_(t)+" of "+z_(e))},JA=Le,qA=Mt,KA=ai,XA=$n,QA=nn,YA=GA?function(e,t){if(BA(e)&&!HA(e,"length").writable)throw FA("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},$A=G_,ZA=Ih,e2=Cs,xh=W_,t2=Ms("splice"),n2=Math.max,r2=Math.min;JA({target:"Array",proto:!0,forced:!t2},{splice:function(e,t){var n,i,r,o,c,a,s=qA(this),l=QA(s),u=KA(e,l),h=arguments.length;for(h===0?n=i=0:h===1?(n=0,i=l-u):(n=h-2,i=r2(n2(XA(t),0),l-u)),$A(l+n-i),r=ZA(s,i),o=0;o<i;o++)(c=u+o)in s&&e2(r,o,s[c]);if(r.length=i,n<i){for(o=u;o<l-i;o++)a=o+n,(c=o+i)in s?s[a]=s[c]:xh(s,a);for(o=l;o>l-i+n;o--)xh(s,o-1)}else if(n>i)for(o=l-i;o>u;o--)a=o+n-1,(c=o+i-1)in s?s[a]=s[c]:xh(s,a);for(o=0;o<n;o++)s[o+u]=arguments[o+2];return YA(s,l-i+n),r}});var i2=se,Ns=function(e,t){var n=[][e];return!!n&&i2(function(){n.call(null,t||function(){return 1},1)})},a2=rn.forEach,wh=Ns("forEach")?[].forEach:function(e){return a2(this,e,arguments.length>1?arguments[1]:void 0)};Le({target:"Array",proto:!0,forced:[].forEach!=wh},{forEach:wh});var J_=re,q_=S_,o2=T_,Ch=wh,s2=Ln,K_=function(e){if(e&&e.forEach!==Ch)try{s2(e,"forEach",Ch)}catch(t){e.forEach=Ch}};for(var Eh in q_)q_[Eh]&&K_(J_[Eh]&&J_[Eh].prototype);K_(o2);var c2=Le,u2=se,l2=Ga,d2=at,h2=Mt,f2=nn,X_=G_,Q_=Cs,p2=Ih,m2=Ms,v2=pr,Y_=tt("isConcatSpreadable"),g2=v2>=51||!u2(function(){var e=[];return e[Y_]=!1,e.concat()[0]!==e}),_2=m2("concat"),y2=function(e){if(!d2(e))return!1;var t=e[Y_];return t!==void 0?!!t:l2(e)};c2({target:"Array",proto:!0,arity:1,forced:!g2||!_2},{concat:function(e){var t,n,i,r,o,c=h2(this),a=p2(c,0),s=0;for(t=-1,i=arguments.length;t<i;t++)if(y2(o=t===-1?c:arguments[t]))for(r=f2(o),X_(s+r),n=0;n<r;n++,s++)n in o&&Q_(a,s,o[n]);else X_(s+1),Q_(a,s++,o);return a.length=s,a}});var b2=Le,S2=yn,k2=bn,T2=Ns,I2=pe([].join),x2=S2!=Object,w2=T2("join",",");b2({target:"Array",proto:!0,forced:x2||!w2},{join:function(e){return I2(k2(this),e===void 0?",":e)}});var C2=rn.filter;Le({target:"Array",proto:!0,forced:!Ms("filter")},{filter:function(e){return C2(this,e,arguments.length>1?arguments[1]:void 0)}});var $_=pe,E2=Qt,Rh=Date.prototype,Z_="Invalid Date",R2="toString",A2=$_(Rh.toString),P2=$_(Rh.getTime);String(new Date(NaN))!=Z_&&E2(Rh,R2,function(){var e=P2(this);return e==e?A2(this):Z_});var D2=$n,O2=zt,L2=pt,M2=RangeError,ey=function(e){var t=O2(L2(this)),n="",i=D2(e);if(i<0||i==1/0)throw M2("Wrong number of repetitions");for(;i>0;(i>>>=1)&&(t+=t))1&i&&(n+=t);return n},ty=pe,N2=yr,ny=zt,U2=pt,V2=ty(ey),j2=ty("".slice),B2=Math.ceil,ry=function(e){return function(t,n,i){var r,o,c=ny(U2(t)),a=N2(n),s=c.length,l=i===void 0?" ":ny(i);return a<=s||l==""?c:((o=V2(l,B2((r=a-s)/l.length))).length>r&&(o=j2(o,0,r)),e?c+o:o+c)}},F2={start:ry(!1),end:ry(!0)},H2=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(Kn),G2=F2.start;Le({target:"String",proto:!0,forced:H2},{padStart:function(e){return G2(this,e,arguments.length>1?arguments[1]:void 0)}});var z2=Tt,iy=function(){var e=z2(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Ah=se,Ph=re.RegExp,Dh=Ah(function(){var e=Ph("a","y");return e.lastIndex=2,e.exec("abcd")!=null}),W2=Dh||Ah(function(){return!Ph("a","y").sticky}),ay={BROKEN_CARET:Dh||Ah(function(){var e=Ph("^r","gy");return e.lastIndex=2,e.exec("str")!=null}),MISSED_STICKY:W2,UNSUPPORTED_Y:Dh},J2=se,q2=re.RegExp,oy=J2(function(){var e=q2(".","s");return!(e.dotAll&&e.exec(`
40
+ `)&&e.flags==="s")}),K2=se,X2=re.RegExp,sy=K2(function(){var e=X2("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),za=qe,bu=pe,Q2=zt,Y2=iy,$2=ay,Z2=Pr.exports,eP=Ba,tP=Ke.get,nP=oy,rP=sy,iP=Z2("native-string-replace",String.prototype.replace),Su=RegExp.prototype.exec,Oh=Su,aP=bu("".charAt),oP=bu("".indexOf),sP=bu("".replace),Lh=bu("".slice),Mh=function(){var e=/a/,t=/b*/g;return za(Su,e,"a"),za(Su,t,"a"),e.lastIndex!==0||t.lastIndex!==0}(),cy=$2.BROKEN_CARET,Nh=/()??/.exec("")[1]!==void 0;(Mh||Nh||cy||nP||rP)&&(Oh=function(e){var t,n,i,r,o,c,a,s=this,l=tP(s),u=Q2(e),h=l.raw;if(h)return h.lastIndex=s.lastIndex,t=za(Oh,h,u),s.lastIndex=h.lastIndex,t;var b=l.groups,I=cy&&s.sticky,R=za(Y2,s),x=s.source,m=0,k=u;if(I&&(R=sP(R,"y",""),oP(R,"g")===-1&&(R+="g"),k=Lh(u,s.lastIndex),s.lastIndex>0&&(!s.multiline||s.multiline&&aP(u,s.lastIndex-1)!==`
41
+ `)&&(x="(?: "+x+")",k=" "+k,m++),n=new RegExp("^(?:"+x+")",R)),Nh&&(n=new RegExp("^"+x+"$(?!\\s)",R)),Mh&&(i=s.lastIndex),r=za(Su,I?n:s,k),I?r?(r.input=Lh(r.input,m),r[0]=Lh(r[0],m),r.index=s.lastIndex,s.lastIndex+=r[0].length):s.lastIndex=0:Mh&&r&&(s.lastIndex=s.global?r.index+r[0].length:i),Nh&&r&&r.length>1&&za(iP,r[0],n,function(){for(o=1;o<arguments.length-2;o++)arguments[o]===void 0&&(r[o]=void 0)}),r&&b)for(r.groups=c=eP(null),o=0;o<b.length;o++)c[(a=b[o])[0]]=r[a[1]];return r});var ku=Oh;Le({target:"RegExp",proto:!0,forced:/./.exec!==ku},{exec:ku});var uy=pe,ly=Qt,cP=ku,dy=se,hy=tt,uP=Ln,lP=hy("species"),Uh=RegExp.prototype,Vh=function(e,t,n,i){var r=hy(e),o=!dy(function(){var l={};return l[r]=function(){return 7},""[e](l)!=7}),c=o&&!dy(function(){var l=!1,u=/a/;return e==="split"&&((u={}).constructor={},u.constructor[lP]=function(){return u},u.flags="",u[r]=/./[r]),u.exec=function(){return l=!0,null},u[r](""),!l});if(!o||!c||n){var a=uy(/./[r]),s=t(r,""[e],function(l,u,h,b,I){var R=uy(l),x=u.exec;return x===cP||x===Uh.exec?o&&!I?{done:!0,value:a(u,h,b)}:{done:!0,value:R(h,u,b)}:{done:!1}});ly(String.prototype,e,s[0]),ly(Uh,r,s[1])}i&&uP(Uh[r],"sham",!0)},dP=vh.charAt,fy=function(e,t,n){return t+(n?dP(e,t).length:1)},jh=pe,hP=Mt,fP=Math.floor,Bh=jh("".charAt),pP=jh("".replace),Fh=jh("".slice),mP=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,vP=/\$([$&'`]|\d{1,2})/g,py=qe,gP=Tt,_P=it,yP=rt,bP=ku,SP=TypeError,Hh=function(e,t){var n=e.exec;if(_P(n)){var i=py(n,e,t);return i!==null&&gP(i),i}if(yP(e)==="RegExp")return py(bP,e,t);throw SP("RegExp#exec called on incompatible receiver")},kP=Ji,my=qe,Tu=pe,TP=Vh,IP=se,xP=Tt,wP=it,CP=Rt,EP=$n,RP=yr,Wa=zt,AP=pt,PP=fy,DP=Xt,OP=function(e,t,n,i,r,o){var c=n+e.length,a=i.length,s=vP;return r!==void 0&&(r=hP(r),s=mP),pP(o,s,function(l,u){var h;switch(Bh(u,0)){case"$":return"$";case"&":return e;case"`":return Fh(t,0,n);case"'":return Fh(t,c);case"<":h=r[Fh(u,1,-1)];break;default:var b=+u;if(b===0)return l;if(b>a){var I=fP(b/10);return I===0?l:I<=a?i[I-1]===void 0?Bh(u,1):i[I-1]+Bh(u,1):l}h=i[b-1]}return h===void 0?"":h})},LP=Hh,Gh=tt("replace"),MP=Math.max,NP=Math.min,UP=Tu([].concat),zh=Tu([].push),vy=Tu("".indexOf),gy=Tu("".slice),VP="a".replace(/./,"$0")==="$0",_y=!!/./[Gh]&&/./[Gh]("a","$0")==="",jP=!IP(function(){var e=/./;return e.exec=function(){var t=[];return t.groups={a:"7"},t},"".replace(e,"$<a>")!=="7"});TP("replace",function(e,t,n){var i=_y?"$":"$0";return[function(r,o){var c=AP(this),a=CP(r)?void 0:DP(r,Gh);return a?my(a,r,c,o):my(t,Wa(c),r,o)},function(r,o){var c=xP(this),a=Wa(r);if(typeof o=="string"&&vy(o,i)===-1&&vy(o,"$<")===-1){var s=n(t,c,a,o);if(s.done)return s.value}var l=wP(o);l||(o=Wa(o));var u=c.global;if(u){var h=c.unicode;c.lastIndex=0}for(var b=[];;){var I=LP(c,a);if(I===null||(zh(b,I),!u))break;Wa(I[0])===""&&(c.lastIndex=PP(a,RP(c.lastIndex),h))}for(var R,x="",m=0,k=0;k<b.length;k++){for(var v=Wa((I=b[k])[0]),w=MP(NP(EP(I.index),a.length),0),L=[],E=1;E<I.length;E++)zh(L,(R=I[E])===void 0?R:String(R));var N=I.groups;if(l){var T=UP([v],L,w,a);N!==void 0&&zh(T,N);var y=Wa(kP(o,void 0,T))}else y=OP(v,a,w,L,N,o);w>=m&&(x+=gy(a,m,w)+y,m=w+v.length)}return x+gy(a,m)}]},!jP||!VP||_y);var BP=qe,FP=kt,HP=Sn,GP=iy,yy=RegExp.prototype,by=function(e){var t=e.flags;return t!==void 0||"flags"in yy||FP(e,"flags")||!HP(yy,e)?t:BP(GP,e)},zP=Yn.PROPER,WP=Qt,JP=Tt,Sy=zt,qP=se,KP=by,ky="toString",Ty=RegExp.prototype.toString,XP=qP(function(){return Ty.call({source:"a",flags:"b"})!="/a/b"}),QP=zP&&Ty.name!=ky;(XP||QP)&&WP(RegExp.prototype,ky,function(){var e=JP(this);return"/"+Sy(e.source)+"/"+Sy(KP(e))},{unsafe:!0});var YP=se,$P=tt("iterator"),Iy=!YP(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(i,r){t.delete("b"),n+=r+i}),!t.sort||e.href!=="http://a/c%20d?a=1&c=3"||t.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!t[$P]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("http://\u0442\u0435\u0441\u0442").host!=="xn--e1aybc"||new URL("http://a#\u0431").hash!=="#%D0%B1"||n!=="a1c3"||new URL("http://x",void 0).host!=="x"}),xy=hu,ZP=Math.floor,Wh=function(e,t){var n=e.length,i=ZP(n/2);return n<8?eD(e,t):tD(e,Wh(xy(e,0,i),t),Wh(xy(e,i),t),t)},eD=function(e,t){for(var n,i,r=e.length,o=1;o<r;){for(i=o,n=e[o];i&&t(e[i-1],n)>0;)e[i]=e[--i];i!==o++&&(e[i]=n)}return e},tD=function(e,t,n,i){for(var r=t.length,o=n.length,c=0,a=0;c<r||a<o;)e[c+a]=c<r&&a<o?i(t[c],n[a])<=0?t[c++]:n[a++]:c<r?t[c++]:n[a++];return e},wy=Wh,Jh=Le,Ja=re,Iu=qe,br=pe,nD=ye,Cy=Iy,Ey=Qt,rD=As,iD=Wi,aD=Og,qh=Ke,Ry=si,Kh=it,oD=kt,sD=Lr,cD=Dr,uD=Tt,Ay=at,Tn=zt,lD=Ba,Py=$e,Xh=pu,dD=Es,qa=_u,hD=wy,fD=tt("iterator"),xu="URLSearchParams",Dy="URLSearchParamsIterator",Oy=qh.set,Zn=qh.getterFor(xu),pD=qh.getterFor(Dy),mD=Object.getOwnPropertyDescriptor,Qh=function(e){if(!nD)return Ja[e];var t=mD(Ja,e);return t&&t.value},Ly=Qh("fetch"),wu=Qh("Request"),Us=Qh("Headers"),Yh=wu&&wu.prototype,My=Us&&Us.prototype,vD=Ja.RegExp,gD=Ja.TypeError,Ny=Ja.decodeURIComponent,_D=Ja.encodeURIComponent,yD=br("".charAt),Uy=br([].join),qi=br([].push),$h=br("".replace),bD=br([].shift),Vy=br([].splice),jy=br("".split),SD=br("".slice),kD=/\+/g,By=Array(4),TD=function(e){return By[e-1]||(By[e-1]=vD("((?:%[\\da-f]{2}){"+e+"})","gi"))},ID=function(e){try{return Ny(e)}catch(t){return e}},Fy=function(e){var t=$h(e,kD," "),n=4;try{return Ny(t)}catch(i){for(;n;)t=$h(t,TD(n--),ID);return t}},xD=/[!'()~]|%20/g,wD={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},CD=function(e){return wD[e]},Hy=function(e){return $h(_D(e),xD,CD)},Zh=aD(function(e,t){Oy(this,{type:Dy,iterator:Xh(Zn(e).entries),kind:t})},"Iterator",function(){var e=pD(this),t=e.kind,n=e.iterator.next(),i=n.value;return n.done||(n.value=t==="keys"?i.key:t==="values"?i.value:[i.key,i.value]),n},!0),Gy=function(e){this.entries=[],this.url=null,e!==void 0&&(Ay(e)?this.parseObject(e):this.parseQuery(typeof e=="string"?yD(e,0)==="?"?SD(e,1):e:Tn(e)))};Gy.prototype={type:xu,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,i,r,o,c,a,s=dD(e);if(s)for(n=(t=Xh(e,s)).next;!(i=Iu(n,t)).done;){if(o=(r=Xh(uD(i.value))).next,(c=Iu(o,r)).done||(a=Iu(o,r)).done||!Iu(o,r).done)throw gD("Expected sequence with length 2");qi(this.entries,{key:Tn(c.value),value:Tn(a.value)})}else for(var l in e)oD(e,l)&&qi(this.entries,{key:l,value:Tn(e[l])})},parseQuery:function(e){if(e)for(var t,n,i=jy(e,"&"),r=0;r<i.length;)(t=i[r++]).length&&(n=jy(t,"="),qi(this.entries,{key:Fy(bD(n)),value:Fy(Uy(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],i=0;i<t.length;)e=t[i++],qi(n,Hy(e.key)+"="+Hy(e.value));return Uy(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Cu=function(){Ry(this,Vs);var e=arguments.length>0?arguments[0]:void 0;Oy(this,new Gy(e))},Vs=Cu.prototype;if(rD(Vs,{append:function(e,t){qa(arguments.length,2);var n=Zn(this);qi(n.entries,{key:Tn(e),value:Tn(t)}),n.updateURL()},delete:function(e){qa(arguments.length,1);for(var t=Zn(this),n=t.entries,i=Tn(e),r=0;r<n.length;)n[r].key===i?Vy(n,r,1):r++;t.updateURL()},get:function(e){qa(arguments.length,1);for(var t=Zn(this).entries,n=Tn(e),i=0;i<t.length;i++)if(t[i].key===n)return t[i].value;return null},getAll:function(e){qa(arguments.length,1);for(var t=Zn(this).entries,n=Tn(e),i=[],r=0;r<t.length;r++)t[r].key===n&&qi(i,t[r].value);return i},has:function(e){qa(arguments.length,1);for(var t=Zn(this).entries,n=Tn(e),i=0;i<t.length;)if(t[i++].key===n)return!0;return!1},set:function(e,t){qa(arguments.length,1);for(var n,i=Zn(this),r=i.entries,o=!1,c=Tn(e),a=Tn(t),s=0;s<r.length;s++)(n=r[s]).key===c&&(o?Vy(r,s--,1):(o=!0,n.value=a));o||qi(r,{key:c,value:a}),i.updateURL()},sort:function(){var e=Zn(this);hD(e.entries,function(t,n){return t.key>n.key?1:-1}),e.updateURL()},forEach:function(e){for(var t,n=Zn(this).entries,i=sD(e,arguments.length>1?arguments[1]:void 0),r=0;r<n.length;)i((t=n[r++]).value,t.key,this)},keys:function(){return new Zh(this,"keys")},values:function(){return new Zh(this,"values")},entries:function(){return new Zh(this,"entries")}},{enumerable:!0}),Ey(Vs,fD,Vs.entries,{name:"entries"}),Ey(Vs,"toString",function(){return Zn(this).serialize()},{enumerable:!0}),iD(Cu,xu),Jh({global:!0,constructor:!0,forced:!Cy},{URLSearchParams:Cu}),!Cy&&Kh(Us)){var ED=br(My.has),RD=br(My.set),zy=function(e){if(Ay(e)){var t,n=e.body;if(cD(n)===xu)return t=e.headers?new Us(e.headers):new Us,ED(t,"content-type")||RD(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),lD(e,{body:Py(0,Tn(n)),headers:Py(0,t)})}return e};if(Kh(Ly)&&Jh({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return Ly(e,arguments.length>1?zy(arguments[1]):{})}}),Kh(wu)){var ef=function(e){return Ry(this,Yh),new wu(e,arguments.length>1?zy(arguments[1]):{})};Yh.constructor=ef,ef.prototype=Yh,Jh({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:ef})}}var AD={URLSearchParams:Cu,getState:Zn},PD=Object.is||function(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t},DD=qe,OD=Tt,LD=Rt,MD=pt,Wy=PD,Jy=zt,ND=Xt,UD=Hh;Vh("search",function(e,t,n){return[function(i){var r=MD(this),o=LD(i)?void 0:ND(i,e);return o?DD(o,i,r):new RegExp(i)[e](Jy(r))},function(i){var r=OD(this),o=Jy(i),c=n(t,r,o);if(c.done)return c.value;var a=r.lastIndex;Wy(a,0)||(r.lastIndex=0);var s=UD(r,o);return Wy(r.lastIndex,a)||(r.lastIndex=a),s===null?-1:s.index}]}),new Date().getTime();var tf=0,an=function(){return new Date().getTime()+tf},qy=function(){var e=new Date;return e.setTime(an()),e.toLocaleString()},VD=qe,jD=Tt,BD=Rt,FD=yr,nf=zt,HD=pt,GD=Xt,zD=fy,Ky=Hh;Vh("match",function(e,t,n){return[function(i){var r=HD(this),o=BD(i)?void 0:GD(i,e);return o?VD(o,i,r):new RegExp(i)[e](nf(r))},function(i){var r=jD(this),o=nf(i),c=n(t,r,o);if(c.done)return c.value;if(!r.global)return Ky(r,o);var a=r.unicode;r.lastIndex=0;for(var s,l=[],u=0;(s=Ky(r,o))!==null;){var h=nf(s[0]);l[u]=h,h===""&&(r.lastIndex=zD(o,FD(r.lastIndex),a)),u++}return u===0?null:l}]});var WD=at,JD=rt,qD=tt("match"),Xy=function(e){var t;return WD(e)&&((t=e[qD])!==void 0?!!t:JD(e)=="RegExp")},KD=Pt.f,XD=ye,rf=re,js=pe,QD=Ss,YD=gu,$D=Ln,ZD=ii.f,Qy=Sn,eO=Xy,Yy=zt,tO=by,$y=ay,nO=function(e,t,n){n in e||KD(e,n,{configurable:!0,get:function(){return t[n]},set:function(i){t[n]=i}})},rO=Qt,iO=se,aO=kt,oO=Ke.enforce,sO=Ps,Zy=oy,e0=sy,cO=tt("match"),ui=rf.RegExp,Ka=ui.prototype,uO=rf.SyntaxError,lO=js(Ka.exec),Eu=js("".charAt),t0=js("".replace),n0=js("".indexOf),dO=js("".slice),hO=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Ki=/a/g,af=/a/g,fO=new ui(Ki)!==Ki,r0=$y.MISSED_STICKY,pO=$y.UNSUPPORTED_Y,mO=XD&&(!fO||r0||Zy||e0||iO(function(){return af[cO]=!1,ui(Ki)!=Ki||ui(af)==af||ui(Ki,"i")!="/a/i"}));if(QD("RegExp",mO)){for(var Xi=function(e,t){var n,i,r,o,c,a,s=Qy(Ka,this),l=eO(e),u=t===void 0,h=[],b=e;if(!s&&l&&u&&e.constructor===Xi)return e;if((l||Qy(Ka,e))&&(e=e.source,u&&(t=tO(b))),e=e===void 0?"":Yy(e),t=t===void 0?"":Yy(t),b=e,Zy&&"dotAll"in Ki&&(i=!!t&&n0(t,"s")>-1)&&(t=t0(t,/s/g,"")),n=t,r0&&"sticky"in Ki&&(r=!!t&&n0(t,"y")>-1)&&pO&&(t=t0(t,/y/g,"")),e0&&(o=function(I){for(var R,x=I.length,m=0,k="",v=[],w={},L=!1,E=!1,N=0,T="";m<=x;m++){if((R=Eu(I,m))==="\\")R+=Eu(I,++m);else if(R==="]")L=!1;else if(!L)switch(!0){case R==="[":L=!0;break;case R==="(":lO(hO,dO(I,m+1))&&(m+=2,E=!0),k+=R,N++;continue;case(R===">"&&E):if(T===""||aO(w,T))throw new uO("Invalid capture group name");w[T]=!0,v[v.length]=[T,N],E=!1,T="";continue}E?T+=R:k+=R}return[k,v]}(e),e=o[0],h=o[1]),c=YD(ui(e,t),s?this:Ka,Xi),(i||r||h.length)&&(a=oO(c),i&&(a.dotAll=!0,a.raw=Xi(function(I){for(var R,x=I.length,m=0,k="",v=!1;m<=x;m++)(R=Eu(I,m))!=="\\"?v||R!=="."?(R==="["?v=!0:R==="]"&&(v=!1),k+=R):k+="[\\s\\S]":k+=R+Eu(I,++m);return k}(e),n)),r&&(a.sticky=!0),h.length&&(a.groups=h)),e!==b)try{$D(c,"source",b===""?"(?:)":b)}catch(I){}return c},i0=ZD(ui),a0=0;i0.length>a0;)nO(Xi,ui,i0[a0++]);Ka.constructor=Xi,Xi.prototype=Ka,rO(rf,"RegExp",Xi,{constructor:!0})}sO("RegExp");var o0=pe(1 .valueOf),s0=`
42
+ \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF`,vO=pt,gO=zt,c0=pe("".replace),Ru=`[
43
+ \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]`,_O=RegExp("^"+Ru+Ru+"*"),yO=RegExp(Ru+Ru+"*$"),of=function(e){return function(t){var n=gO(vO(t));return 1&e&&(n=c0(n,_O,"")),2&e&&(n=c0(n,yO,"")),n}},Au={start:of(1),end:of(2),trim:of(3)},bO=ye,sf=re,u0=pe,SO=Ss,kO=Qt,l0=kt,TO=gu,IO=Sn,xO=Mi,d0=ji,wO=se,CO=ii.f,EO=be.f,RO=Pt.f,AO=o0,PO=Au.trim,h0="Number",li=sf.Number,cf=li.prototype,DO=sf.TypeError,OO=u0("".slice),Pu=u0("".charCodeAt),LO=function(e){var t=d0(e,"number");return typeof t=="bigint"?t:MO(t)},MO=function(e){var t,n,i,r,o,c,a,s,l=d0(e,"number");if(xO(l))throw DO("Cannot convert a Symbol value to a number");if(typeof l=="string"&&l.length>2){if(l=PO(l),(t=Pu(l,0))===43||t===45){if((n=Pu(l,2))===88||n===120)return NaN}else if(t===48){switch(Pu(l,1)){case 66:case 98:i=2,r=49;break;case 79:case 111:i=8,r=55;break;default:return+l}for(c=(o=OO(l,2)).length,a=0;a<c;a++)if((s=Pu(o,a))<48||s>r)return NaN;return parseInt(o,i)}}return+l};if(SO(h0,!li(" 0o1")||!li("0b1")||li("+0x1"))){for(var Du,Xa=function(e){var t=arguments.length<1?0:li(LO(e)),n=this;return IO(cf,n)&&wO(function(){AO(n)})?TO(Object(t),n,Xa):t},f0=bO?CO(li):"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(","),uf=0;f0.length>uf;uf++)l0(li,Du=f0[uf])&&!l0(Xa,Du)&&RO(Xa,Du,EO(li,Du));Xa.prototype=cf,cf.constructor=Xa,kO(sf,h0,Xa,{constructor:!0})}var NO=ys.includes,UO=uu;Le({target:"Array",proto:!0,forced:se(function(){return!Array(1).includes()})},{includes:function(e){return NO(this,e,arguments.length>1?arguments[1]:void 0)}}),UO("includes");var VO=Xy,jO=TypeError,p0=function(e){if(VO(e))throw jO("The method doesn't accept regular expressions");return e},BO=tt("match"),m0=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[BO]=!1,"/./"[e](t)}catch(i){}}return!1},FO=Le,HO=p0,GO=pt,v0=zt,zO=m0,WO=pe("".indexOf);FO({target:"String",proto:!0,forced:!zO("includes")},{includes:function(e){return!!~WO(v0(GO(this)),v0(HO(e)),arguments.length>1?arguments[1]:void 0)}});var JO=Le,qO=ys.indexOf,KO=Ns,lf=pe([].indexOf),g0=!!lf&&1/lf([1],1,-0)<0,XO=KO("indexOf");JO({target:"Array",proto:!0,forced:g0||!XO},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return g0?lf(this,e,t)||0:qO(this,e,t)}});var QO=Mt,_0=Ts,YO=Eg;Le({target:"Object",stat:!0,forced:se(function(){_0(1)}),sham:!YO},{getPrototypeOf:function(e){return _0(QO(e))}});var $O=Ji,ZO=Vt,eL=Tt;Le({target:"Reflect",stat:!0,forced:!se(function(){Reflect.apply(function(){})})},{apply:function(e,t,n){return $O(ZO(e),t,eL(n))}});var tL=ye,nL=Yn.EXISTS,y0=pe,rL=Pt.f,b0=Function.prototype,iL=y0(b0.toString),S0=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,aL=y0(S0.exec);tL&&!nL&&rL(b0,"name",{configurable:!0,get:function(){try{return aL(S0,iL(this))[1]}catch(e){return""}}});var oL=Le,k0=Date,sL=pe(k0.prototype.getTime);oL({target:"Date",stat:!0},{now:function(){return sL(new k0)}});var Bs,Qa,T0,df,Fs=rt(re.process)=="process",cL=yu,uL=Xn,lL=TypeError,I0=function(e){if(cL(e))return e;throw lL(uL(e)+" is not a constructor")},x0=Tt,dL=I0,hL=Rt,fL=tt("species"),Ou=function(e,t){var n,i=x0(e).constructor;return i===void 0||hL(n=x0(i)[fL])?t:dL(n)},w0=/(?:ipad|iphone|ipod).*applewebkit/i.test(Kn),In=re,pL=Ji,mL=Lr,C0=it,vL=kt,gL=se,E0=Sg,_L=Ha,R0=vr,yL=_u,bL=w0,SL=Fs,hf=In.setImmediate,ff=In.clearImmediate,kL=In.process,pf=In.Dispatch,TL=In.Function,A0=In.MessageChannel,IL=In.String,mf=0,Hs={},xL="onreadystatechange";try{Bs=In.location}catch(e){}var vf=function(e){if(vL(Hs,e)){var t=Hs[e];delete Hs[e],t()}},gf=function(e){return function(){vf(e)}},P0=function(e){vf(e.data)},D0=function(e){In.postMessage(IL(e),Bs.protocol+"//"+Bs.host)};hf&&ff||(hf=function(e){yL(arguments.length,1);var t=C0(e)?e:TL(e),n=_L(arguments,1);return Hs[++mf]=function(){pL(t,void 0,n)},Qa(mf),mf},ff=function(e){delete Hs[e]},SL?Qa=function(e){kL.nextTick(gf(e))}:pf&&pf.now?Qa=function(e){pf.now(gf(e))}:A0&&!bL?(df=(T0=new A0).port2,T0.port1.onmessage=P0,Qa=mL(df.postMessage,df)):In.addEventListener&&C0(In.postMessage)&&!In.importScripts&&Bs&&Bs.protocol!=="file:"&&!gL(D0)?(Qa=D0,In.addEventListener("message",P0,!1)):Qa=xL in R0("script")?function(e){E0.appendChild(R0("script")).onreadystatechange=function(){E0.removeChild(this),vf(e)}}:function(e){setTimeout(gf(e),0)});var Gs,Qi,zs,Ya,_f,yf,bf,O0,L0={set:hf,clear:ff},wL=re,CL=/ipad|iphone|ipod/i.test(Kn)&&wL.Pebble!==void 0,EL=/web0s(?!.*chrome)/i.test(Kn),Yi=re,M0=Lr,RL=be.f,Sf=L0.set,AL=w0,PL=CL,DL=EL,kf=Fs,N0=Yi.MutationObserver||Yi.WebKitMutationObserver,U0=Yi.document,V0=Yi.process,Lu=Yi.Promise,j0=RL(Yi,"queueMicrotask"),B0=j0&&j0.value;B0||(Gs=function(){var e,t;for(kf&&(e=V0.domain)&&e.exit();Qi;){t=Qi.fn,Qi=Qi.next;try{t()}catch(n){throw Qi?Ya():zs=void 0,n}}zs=void 0,e&&e.enter()},AL||kf||DL||!N0||!U0?!PL&&Lu&&Lu.resolve?((bf=Lu.resolve(void 0)).constructor=Lu,O0=M0(bf.then,bf),Ya=function(){O0(Gs)}):kf?Ya=function(){V0.nextTick(Gs)}:(Sf=M0(Sf,Yi),Ya=function(){Sf(Gs)}):(_f=!0,yf=U0.createTextNode(""),new N0(Gs).observe(yf,{characterData:!0}),Ya=function(){yf.data=_f=!_f}));var OL=B0||function(e){var t={fn:e,next:void 0};zs&&(zs.next=t),Qi||(Qi=t,Ya()),zs=t},LL=re,Tf=function(e){try{return{error:!1,value:e()}}catch(t){return{error:!0,value:t}}},F0=function(){this.head=null,this.tail=null};F0.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var ML=F0,Ws=re.Promise,H0=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",NL=!H0&&!Fs&&typeof window=="object"&&typeof document=="object",UL=re,Js=Ws,VL=it,jL=Ss,BL=d,FL=tt,HL=NL,GL=H0,If=pr;Js&&Js.prototype;var zL=FL("species"),G0=!1,z0=VL(UL.PromiseRejectionEvent),WL=jL("Promise",function(){var e=BL(Js),t=e!==String(Js);if(!t&&If===66)return!0;if(!If||If<51||!/native code/.test(e)){var n=new Js(function(r){r(1)}),i=function(r){r(function(){},function(){})};if((n.constructor={})[zL]=i,!(G0=n.then(function(){})instanceof i))return!0}return!t&&(HL||GL)&&!z0}),$i={CONSTRUCTOR:WL,REJECTION_EVENT:z0,SUBCLASSING:G0},$a={},W0=Vt,JL=TypeError,qL=function(e){var t,n;this.promise=new e(function(i,r){if(t!==void 0||n!==void 0)throw JL("Bad Promise constructor");t=i,n=r}),this.resolve=W0(t),this.reject=W0(n)};$a.f=function(e){return new qL(e)};var xf,J0,q0,KL=Le,Mu=Fs,di=re,Za=qe,K0=Qt,X0=Fa,XL=Wi,QL=Ps,YL=Vt,Nu=it,$L=at,ZL=si,eM=Ou,Q0=L0.set,wf=OL,tM=function(e,t){var n=LL.console;n&&n.error&&(arguments.length==1?n.error(e):n.error(e,t))},nM=Tf,rM=ML,Y0=Ke,Uu=Ws,$0=$a,Vu="Promise",Z0=$i.CONSTRUCTOR,iM=$i.REJECTION_EVENT,aM=$i.SUBCLASSING,Cf=Y0.getterFor(Vu),oM=Y0.set,eo=Uu&&Uu.prototype,to=Uu,ju=eo,eb=di.TypeError,Ef=di.document,Rf=di.process,Af=$0.f,sM=Af,cM=!!(Ef&&Ef.createEvent&&di.dispatchEvent),tb="unhandledrejection",nb=function(e){var t;return!(!$L(e)||!Nu(t=e.then))&&t},rb=function(e,t){var n,i,r,o=t.value,c=t.state==1,a=c?e.ok:e.fail,s=e.resolve,l=e.reject,u=e.domain;try{a?(c||(t.rejection===2&&lM(t),t.rejection=1),a===!0?n=o:(u&&u.enter(),n=a(o),u&&(u.exit(),r=!0)),n===e.promise?l(eb("Promise-chain cycle")):(i=nb(n))?Za(i,n,s,l):s(n)):l(o)}catch(h){u&&!r&&u.exit(),l(h)}},ib=function(e,t){e.notified||(e.notified=!0,wf(function(){for(var n,i=e.reactions;n=i.get();)rb(n,e);e.notified=!1,t&&!e.rejection&&uM(e)}))},ab=function(e,t,n){var i,r;cM?((i=Ef.createEvent("Event")).promise=t,i.reason=n,i.initEvent(e,!1,!0),di.dispatchEvent(i)):i={promise:t,reason:n},!iM&&(r=di["on"+e])?r(i):e===tb&&tM("Unhandled promise rejection",n)},uM=function(e){Za(Q0,di,function(){var t,n=e.facade,i=e.value;if(ob(e)&&(t=nM(function(){Mu?Rf.emit("unhandledRejection",i,n):ab(tb,n,i)}),e.rejection=Mu||ob(e)?2:1,t.error))throw t.value})},ob=function(e){return e.rejection!==1&&!e.parent},lM=function(e){Za(Q0,di,function(){var t=e.facade;Mu?Rf.emit("rejectionHandled",t):ab("rejectionhandled",t,e.value)})},no=function(e,t,n){return function(i){e(t,i,n)}},ro=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,ib(e,!0))},Pf=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw eb("Promise can't be resolved itself");var i=nb(t);i?wf(function(){var r={done:!1};try{Za(i,t,no(Pf,r,e),no(ro,r,e))}catch(o){ro(r,o,e)}}):(e.value=t,e.state=1,ib(e,!1))}catch(r){ro({done:!1},r,e)}}};if(Z0&&(ju=(to=function(e){ZL(this,ju),YL(e),Za(xf,this);var t=Cf(this);try{e(no(Pf,t),no(ro,t))}catch(n){ro(t,n)}}).prototype,(xf=function(e){oM(this,{type:Vu,done:!1,notified:!1,parent:!1,reactions:new rM,rejection:!1,state:0,value:void 0})}).prototype=K0(ju,"then",function(e,t){var n=Cf(this),i=Af(eM(this,to));return n.parent=!0,i.ok=!Nu(e)||e,i.fail=Nu(t)&&t,i.domain=Mu?Rf.domain:void 0,n.state==0?n.reactions.add(i):wf(function(){rb(i,n)}),i.promise}),J0=function(){var e=new xf,t=Cf(e);this.promise=e,this.resolve=no(Pf,t),this.reject=no(ro,t)},$0.f=Af=function(e){return e===to||e===void 0?new J0(e):sM(e)},Nu(Uu)&&eo!==Object.prototype)){q0=eo.then,aM||K0(eo,"then",function(e,t){var n=this;return new to(function(i,r){Za(q0,n,i,r)}).then(e,t)},{unsafe:!0});try{delete eo.constructor}catch(e){}X0&&X0(eo,ju)}KL({global:!0,constructor:!0,wrap:!0,forced:Z0},{Promise:to}),XL(to,Vu,!1),QL(Vu);var dM=Ws,sb=$i.CONSTRUCTOR||!vu(function(e){dM.all(e).then(void 0,function(){})}),hM=qe,fM=Vt,pM=$a,mM=Tf,vM=Rs;Le({target:"Promise",stat:!0,forced:sb},{all:function(e){var t=this,n=pM.f(t),i=n.resolve,r=n.reject,o=mM(function(){var c=fM(t.resolve),a=[],s=0,l=1;vM(e,function(u){var h=s++,b=!1;l++,hM(c,t,u).then(function(I){b||(b=!0,a[h]=I,--l||i(a))},r)}),--l||i(a)});return o.error&&r(o.value),n.promise}});var gM=Le,_M=$i.CONSTRUCTOR,Df=Ws,yM=An,bM=it,SM=Qt,cb=Df&&Df.prototype;if(gM({target:"Promise",proto:!0,forced:_M,real:!0},{catch:function(e){return this.then(void 0,e)}}),bM(Df)){var ub=yM("Promise").prototype.catch;cb.catch!==ub&&SM(cb,"catch",ub,{unsafe:!0})}var kM=qe,TM=Vt,IM=$a,xM=Tf,wM=Rs;Le({target:"Promise",stat:!0,forced:sb},{race:function(e){var t=this,n=IM.f(t),i=n.reject,r=xM(function(){var o=TM(t.resolve);wM(e,function(c){kM(o,t,c).then(n.resolve,i)})});return r.error&&i(r.value),n.promise}});var CM=qe,EM=$a;Le({target:"Promise",stat:!0,forced:$i.CONSTRUCTOR},{reject:function(e){var t=EM.f(this);return CM(t.reject,void 0,e),t.promise}});var RM=Tt,AM=at,PM=$a,lb=function(e,t){if(RM(e),AM(t)&&t.constructor===e)return t;var n=PM.f(e);return(0,n.resolve)(t),n.promise},DM=Le,OM=$i.CONSTRUCTOR,LM=lb;An("Promise"),DM({target:"Promise",stat:!0,forced:OM},{resolve:function(e){return LM(this,e)}});var MM=Mt,db=ou;Le({target:"Object",stat:!0,forced:se(function(){db(1)})},{keys:function(e){return db(MM(e))}});var hb="canvas",Re="audio",Ie="video",Of="screen",Mr="small",Bu="big",gt="auxiliary",Nn="aux",Fu="smallVideo",fb="user",pb="environment",tn="mute",Sr="unmute",Nt="ended",hi="playing",fi="pause",io="error",Lf="loadeddata",qs="audioinput",Hu="videoinput",mb="detail",NM="text",Xe="main",er="backup",UM="banned",VM="kick",jM="user_time_out",BM="room_disband",vb="sei-message",ao="PLAYING",kr="PAUSED",pi="STOPPED",oo="inactive",mi="sendonly",Mf="recvonly",gb="add",_b="remove",FM="replace",Nf="track",HM="wss://trtc.rtc.qq.com",GM="wss://webrtc.qq.com",Gu="qcloud",zM="trtc",WM="webrtc",Ks="",yb="jssdk_log",JM="jssdk_event",qM="jssdk_new_endreport",Uf=function(e){return Ks=e},KM=1,XM=2,zu="live",so=20,Vf=21,Tr="anchor",Zi="audience",Ir="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",Xs="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",QM=2,yt=Xe,Dt=gt,Wu="unknown",on="DISCONNECTED",bb="CONNECTING",jf="RECONNECTING",sn="CONNECTED",YM="new",Ju="connecting",Sb="failed",Bf="closed",$M="disconnected",kb="connected",ZM="completed",Ff=30,Tb="join",eN="delta-join",Ib="rejoin",tN="leave",nN="delta-leave",xb="publish",rN="delta-publish",wb="unpublish",Cb="subscribe",Eb="unsubscribe",Rb="uplink-connection",Ab="uplink-reconnection",Pb="downlink-connection",Db="downlink-reconnection",qu="setLocalDescription",Ob="setRemoteDescription",Lb="iceConnectionState",Qs="stream-initialize",Hf="websocketConnectionState",Mb="websocketReconnectionState",Nb="update-stream",Ub="recover-subscription",Vb="start-mix-transcode",jb="stop-mix-transcode",Bb="player-error",Fb="schedule",Gf="unsubscribe",zf="subscribe_change",Ys="unified-plan",Wf="plan-b",Jf={MANUAL:"manual",PRESET_LAYOUT:"preset-layout"},Hb={REMOTE:"$PLACE_HOLDER_REMOTE$"},Gb={IT_AUDIO_VIDEO:0,IT_PICTURE:2,IT_CANVAS:3,IT_PURE_AUDIO:4,IT_PURE_VIDEO:5},dt="string",wt="number",Wt="boolean",zb="array",xn="object",cn={ADD:gb,REMOVE:_b},qf={unknown:0,wifi:1,"4g":2,"3g":3,"2g":4,wired:5},Wb=-1,$s=0,iN=1,Jb=Bu,qb=Mr,Kb=6048e5,aN="schedule.cloud-rtc.com",oN="schedule.rtc.qcloud.com",sN="schedule.rtc.tencentcloud.com",cN="schedule-ecdn.rtc.tencentcloud.com",Kf="",Xb=function(e){return Kf=e},Zs="TRTC",un="Client",vi="LocalStream",Xf="RemoteStream",uN="Stream",Qf="web.sdk.qcloud.com",Qb="web.sdk.tencent.cn",Yb="web.sdk.cloud.tencent.cn",$b="https://console.cloud.tencent.com/trtc",co="https://".concat(Qf,"/trtc/webrtc/doc"),Yf="".concat(co,"/zh-cn/"),$f="trtc_error_assistance",Ku="default",Zb="communications",Un={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,NONE:5},lN=1,eS=2,dN=1,tS=2,ea=Object.keys(Un),hN=["normal leave","timeout leave","kick","role change"],Xu=2e3,uo="ric",Qu="raf",fN="interval",nS="timeout",rS="Resolution reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386",pN={"TRTC.checkSystemRequirements":40001,"TRTC.isScreenShareSupported":40002,"TRTC.isSmallStreamSupported":40003,"TRTC.createClient.rtc":40004,"TRTC.createClient.live":40005,"TRTC.createClient.intRoomId":40006,"TRTC.createClient.stringRoomId":40007,"TRTC.createClient.autoSubscribe":40008,"TRTC.createClient.manualSubscribe":40009,"TRTC.enableUploadLog":40010,"TRTC.disableUploadLog":40011,"Client.publish":40012,"Client.publish.isAuxiliary":40013,"Client.switchRole":40014,"Client.startPublishCDNStream":40015,"Client.stopPublishCDNStream":40016,"Client.startMixTranscode":40017,"Client.stopMixTranscode":40018,"Client.enableAudioVolumeEvaluation":40019,"Client.enableSmallStream":40020,"Client.disableSmallStream":40021,"Client.setSmallStreamProfile":40022,"Client.setRemoteVideoStreamType":40023,"Client.sendSEIMessage":40024,"Client.setProxyServer":40025,"Client.setTurnServer":40026,"LocalStream.setAudioProfile.standard":40027,"LocalStream.setAudioProfile.high":40028,"LocalStream.setAudioProfile.standard-stereo":40029,"LocalStream.setAudioProfile.high-stereo":40030,"LocalStream.setVideoProfile.120p":40031,"LocalStream.setVideoProfile.120p_2":40032,"LocalStream.setVideoProfile.180p":40033,"LocalStream.setVideoProfile.180p_2":40034,"LocalStream.setVideoProfile.240p":40035,"LocalStream.setVideoProfile.240p_2":40036,"LocalStream.setVideoProfile.360p":40037,"LocalStream.setVideoProfile.360p_2":40038,"LocalStream.setVideoProfile.480p":40039,"LocalStream.setVideoProfile.480p_2":40040,"LocalStream.setVideoProfile.720p":40041,"LocalStream.setVideoProfile.1080p":40042,"LocalStream.setVideoProfile.1440p":40043,"LocalStream.setVideoProfile.4K":40044,"LocalStream.setScreenProfile.480p":40045,"LocalStream.setScreenProfile.480p_2":40046,"LocalStream.setScreenProfile.720p":40047,"LocalStream.setScreenProfile.720p_2":40048,"LocalStream.setScreenProfile.1080p":40049,"LocalStream.setScreenProfile.1080p_2":40050,"LocalStream.setVideoContentHint.motion":40051,"LocalStream.setVideoContentHint.detail":40052,"LocalStream.setVideoContentHint.text":40053,"LocalStream.setAudioCaptureVolume":40054,"LocalStream.getVideoFrame":40055,"RemoteStream.setAudioOutput":40056,"RemoteStream.getVideoFrame":40057,AI_DENOISER:1700,SPATIAL_AUDIO:1701,"2K_4K":1704},Zf=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId"],mN=pt,iS=zt,vN=/"/g,gN=pe("".replace),aS=function(e,t,n,i){var r=iS(mN(e)),o="<"+t;return n!==""&&(o+=" "+n+'="'+gN(iS(i),vN,"&quot;")+'"'),o+">"+r+"</"+t+">"},_N=se,oS=function(e){return _N(function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3})},yN=aS;Le({target:"String",proto:!0,forced:oS("link")},{link:function(e){return yN(this,"a","href",e)}}),Le({target:"Array",stat:!0},{isArray:Ga});var bN="AVOID_REPEATED_CALL",SN="INVALID_PARAMETER_REQUIRED",sS="INVALID_PARAMETER_TYPE",kN="INVALID_PARAMETER_EMPTY",cS="INVALID_PARAMETER_INSTANCE",TN="INVALID_PARAMETER_RANGE",IN="API_CALL_TIMEOUT",xN="SIGNAL_CHANNEL_RECONNECTION_FAILED",wN="SIGNAL_CHANNEL_SETUP_FAILED",CN="ERROR_MESSAGE",EN="EXCHANGE_SDP_TIMEOUT",RN="DOWNLINK_RECONNECTION_FAILED",AN="EXCHANGE_SDP_FAILED",PN="UPLINK_RECONNECTION_FAILED",DN="INVALID_PURE_AUDIO",ON="INVALID_STREAMID",LN="INVALID_USER_DEFINE_RECORDID",MN="INVALID_USER_DEFINE_PUSH_ARGS",NN="INVALID_PROXY",UN="INVALID_JOIN",VN="INVALID_ROOMID_STRING",jN="INVALID_ROOMID_INTEGER",BN="JOIN_ROOM_TIMEOUT",uS="JOIN_ROOM_FAILED",FN="REJOIN_ROOM_FAILED",HN="INVALID_DESTROY",GN="INVALID_PUBLISH",zN="INVALID_UNPUBLISH",WN="INVALID_AUDIENCE",JN="INVALID_INITIALIZE",qN="INVALID_DUPLICATE_PUBLISHING",ep="INVALID_REMOTE_STREAM",KN="SUBSCRIBE_FAILED",XN="INVALID_ROLE",QN="INVALID_OPERATION_SWITCH_ROLE",YN="SWITCH_ROLE_TIMEOUT",$N="SWITCH_ROLE_FAILED",ZN="CLIENT_BANNED",lS="INVALID_OPERATION_START_PUBLISH_CDN",e3="INVALID_OPERATION_STOP_PUBLISH_CDN",t3="INVALID_STREAM_ID",dS="START_PUBLISH_CDN_FAILED",hS="STOP_PUBLISH_CDN_FAILED",n3="START_MIX_TRANSCODE",r3="STOP_MIX_TRANSCODE",i3="INVALID_AUDIO_VOLUME",a3="ENABLE_SMALL_STREAM_PUBLISHED",o3="DISABLE_SMALL_STREAM_PUBLISHED",s3="NOT_SUPPORTED_SMALL_STREAM",c3="INVALID_SMALL_STREAM_PROFILE",u3="INVALID_PARAMETER_REMOTE_STREAM",l3="INVALID_SWITCH_DEVICE",d3="INVALID_SWITCH_DEVICE_PUBLISHING",fS="INVALID_REPLACE_TRACK",h3="INVALID_INITIALIZE_LOCAL_STREAM",f3="INVALID_ADD_TRACK_REPETITIVE",p3="INVALID_ADD_TRACK_REMOVING",m3="INVALID_ADD_TRACK_PUBLISHING",pS="INVALID_STREAM_INITIALIZED",v3="INVALID_ADD_TRACK_NUMBER",g3="INVALID_REMOVE_AUDIO_TRACK",_3="INVALID_REMOVE_AUDIO_ADDING",y3="INVALID_REMOVE_AUDIO_ON",b3="INVALID_REMOVE_TRACK_PUBLISHING",S3="INVALID_REMOVE_TRACK_NOT_PUBLISHING",k3="INVALID_REMOVE_TRACK_NUMBER",T3="INVALID_REPLACE_TRACK_NO_TRACK",I3="REPEAT_JOIN",tp="CLIENT_DESTROYED",x3="START_MIX_TRANSCODE_FAILED",w3="STOP_MIX_TRANSCODE_FAILED",C3="MIX_TRANSCODE_NOT_STARTED",E3="CANNOT_LESS_THAN_ZERO",R3="MIX_PARAMS_VIDEO_FRAMERATE",A3="MIX_PARAMS_VIDEO_GOP",P3="MIX_PARAMS_AUDIO_BITRATE",D3="MIX_PARAMS_USER_Z_ORDER",O3="MIX_PARAMS_NOT_SELF",L3="MIX_PARAMS_USER_STREAM",M3="INVALID_ELEMENT_ID",N3="INVALID_ELEMENT_ID_TYPE",np="PLAY_FAILED",U3="INVALID_CREATE_STREAM_SOURCE",V3="INVALID_CREATE_STREAM_SCREEN",j3="INVALID_CREATE_STREAM_AUDIO",B3="INVALID_CREATE_STREAM_SCREEN_AUDIO",mS="NOT_SUPPORTED_HTTP",vS="NOT_SUPPORTED_WEBRTC",F3="NOT_SUPPORTED_PROFILE",gS="NOT_SUPPORTED_H264ENCODE",_S="NOT_SUPPORTED_H264DECODE",rp="NOT_SUPPORTED_TRACK",H3="NOT_SUPPORTED_SWITCH_DEVICE",G3="NOT_SUPPORTED_CAPTURE",z3="NOT_SUPPORTED_AUX",W3="MICROPHONE_NOT_FOUND",J3="CAMERA_NOT_FOUND",yS="SIGNAL_RESPONSE_FAILED",q3="CATCH_HANDLER_ERROR",K3="API_NOT_EXIST",X3="CONNECTION_CLOSED",Q3="SUBSCRIBE_ALL_FALSE",bS="SEI_NOT_SUPPORT",Y3="SEI_DISABLED",$3="SEI_EMPTY",Z3="SEI_OVERSIZE",e4="SEI_BEFORE_PUBLISH",t4="SEI_NOT_VIDEO",n4="CALL_FREQUENCY_LIMIT",r4="CONNECTION_ABORTED",ip="API_CALL_ABORTED",i4="DUPLICATE_AUX",gi={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,i=e.fnName,r=e.value;return"'".concat(t||n.name,"' is a required param when calling ").concat(i,"(), received: ").concat(r,".")},INVALID_PARAMETER_TYPE:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value,o="".concat(t||n.name),c="";return c=Array.isArray(n.type)?n.type.join("|"):n.type,"'".concat(o,"' must be type of ").concat(c," when calling ").concat(i,"(), received type: ").concat(Si(r),".")},INVALID_PARAMETER_EMPTY:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value;return"'".concat(t||n.name,"' cannot be '").concat(r,"' when calling ").concat(i,"().")},INVALID_PARAMETER_INSTANCE:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value,o="".concat(t||n.name),c="".concat(n.instanceOf.name||n.instanceOf);return"'".concat(o,"' must be instanceof ").concat(c," when calling ").concat(i,"(), received type: ").concat(Si(r),".")},INVALID_PARAMETER_RANGE:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value;return"'".concat(t||n.name,"' must be one of ").concat(n.values.join("|")," when calling ").concat(i,"(), received: ").concat(r,".")},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},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.",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_DESTROY:"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(Zi,', please call switchRole("').concat(Tr,'") firstly before publish().'),INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING:function(e){return"duplicate ".concat(e," stream publishing, please unpublish your prev ").concat(e," stream 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){var t=e.message,n=e.stream;return"failed to subscribe ".concat(n.getUserId()," ").concat(n.getType()," stream, reason: ").concat(t,".")},INVALID_ROLE:"switchRole can only be called in live mode.",INVALID_PARAMETER_SWITCH_ROLE:"role could only be set to a value as ".concat(Tr," or ").concat(Zi,"."),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.code," errMsg: ").concat(e.message,".")},CLIENT_BANNED:function(e){return"client was banned because of "+e.message+"."},INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() before client join the room or after client join the room and successfully publish the local stream.",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 on your browser.",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_REPLACE_TRACK_NO_TRACK:function(e){return"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track")},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,i=e.fnName;return e.value,"'".concat(t||n.name,"' cannot be less than 0 when calling ").concat(i,"().")},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,i=e.type;return"the element corresponding to '".concat(t,"' must be instanceof HTMLDivElement when calling ").concat(n,"(), received: ").concat(i,".")},PLAY_FAILED:function(e){return"".concat(e.media," play failed\uFF0Cbrowser exception: ").concat(e.error.toString())},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:"http protocol does not support the ability to capture and publish streams, please use the https protocol.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment 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_TRACK:function(e){return"".concat(e,"Track is not supported on your browser.")},NOT_SUPPORTED_SWITCH_DEVICE:"switchDevice is not supported on your browser.",NOT_SUPPORTED_CAPTURE:"Your browser or environment does not support screen sharing, please check whether the browser version.",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,".")},CATCH_HANDLER_ERROR:function(e){var t=e.name,n=e.event;return"an error was caught on ".concat(t,".on('").concat(n,"', handler), please check your code on 'handler'.")},API_NOT_EXIST:function(e){var t=e.name;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:function(e){return"[".concat(e,"] is calling client.join api or has already joined room, please avoid repeated join.")},CONNECTION_CLOSED:"remoteStream has been unsubscribed or unpublished by remote user.",SUBSCRIBE_ALL_FALSE:"cannot subscribe when both audio & video are false, use client.unsubscribe() instead",CLIENT_DESTROYED:function(e){var t=e.funName;return"failed to call ".concat(t,"() because client was destroyed.")},SEI_NOT_SUPPORT:function(e){return"not support to sendSEIMessage".concat(e===!1?" without using h264 codec":"")},SEI_DISABLED:"SEI is disabled, to enable SEI: TRTC.createClient({ enableSEI: true })",SEI_EMPTY:"buffer cannot be empty",SEI_OVERSIZE:function(e){return"buffer size(".concat(e,") is over 1000 Bytes")},SEI_BEFORE_PUBLISH:"please call sendSEIMessage() after publish() success",SEI_NOT_VIDEO:"cannot send sei when localStream has not video.",CALL_FREQUENCY_LIMIT:function(e){var t=e.isSize,n=e.name,i=e.timesInSecond,r=e.maxSizeInSecond;return"api ".concat(n," call ").concat(t?"size":"times"," is over ").concat(t?r+" bytes":i," in a second.")},CONNECTION_ABORTED:function(e){return"connection aborted due to: "+e},API_CALL_ABORTED:function(e){return e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.stream.getUserId()," ").concat(e.stream.getType()," stream aborted, reason: remote user ").concat(e.stream.getUserId()," unpublished stream."):"API aborted, reason: ".concat(e.message)},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser."},SS=re,a4=se,o4=zt,s4=Au.trim,c4=pe("".charAt),Yu=SS.parseFloat,kS=SS.Symbol,TS=kS&&kS.iterator,IS=1/Yu(`
44
+ \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF-0`)!=-1/0||TS&&!a4(function(){Yu(Object(TS))})?function(e){var t=s4(o4(e)),n=Yu(t);return n===0&&c4(t,0)=="-"?-0:n}:Yu;Le({global:!0,forced:parseFloat!=IS},{parseFloat:IS});var Ee=window.navigator&&window.navigator.userAgent||"",xS=/AppleWebKit\/([\d.]+)/i.exec(Ee);xS&&parseFloat(xS.pop());var ap=/iPad/i.test(Ee),wS=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/Macintosh/.test(Ee),op=/iPhone/i.test(Ee)&&!ap,u4=/iPod/i.test(Ee),_i=op||ap||u4||wS,ta=/Android/i.test(Ee);ta&&function(){var e=Ee.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])}(),ta&&/webkit/i.test(Ee);var Vn=/Firefox/i.test(Ee),CS=Vn&&function(){var e=Ee.match(/Firefox\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),$u=/Edge\//i.test(Ee),l4=$u&&function(){var e=Ee.match(/Edge\/(\d+)/i);if(e&&e[1])return e[1]}(),Zu=/Edg\//i.test(Ee),ES=Zu&&function(){var e=Ee.match(/Edg\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),sp=/SogouMobileBrowser\//i.test(Ee),d4=sp&&function(){var e=Ee.match(/SogouMobileBrowser\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),cp=/MetaSr\s/i.test(Ee),h4=cp&&function(){var e=Ee.match(/MetaSr(\s\d+(\.\d+)+)/);return e&&e[1]?parseFloat(e[1]):null}(),Nr=/TBS\/\d+/i.test(Ee),f4=Nr&&function(){var e=Ee.match(/TBS\/(\d+)/i);if(e&&e[1])return e[1]}(),up=/XWEB\/\d+/i.test(Ee),p4=up&&function(){var e=Ee.match(/XWEB\/(\d+)/i);if(e&&e[1])return e[1]}();/MSIE\s8\.0/.test(Ee),/MSIE\/\d+/i.test(Ee)&&function(){var e=/MSIE\s(\d+)\.\d/.exec(Ee),t=e&&parseFloat(e[1]);!t&&/Trident\/7.0/i.test(Ee)&&/rv:11.0/.test(Ee)&&(t=11)}();var lp=/(micromessenger|webbrowser)/i.test(Ee),m4=lp&&function(){var e=Ee.match(/MicroMessenger\/(\d+)/i);if(e&&e[1])return e[1]}(),dp=!Nr&&/MQQBrowser\/\d+/i.test(Ee)&&/COVC\/\d+/i.test(Ee),hp=!Nr&&/MQQBrowser\/\d+/i.test(Ee)&&!/COVC\/\d+/i.test(Ee),RS=(hp||dp)&&function(){var e=Ee.match(/ MQQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),fp=!Nr&&/ QQBrowser\/\d+/i.test(Ee),v4=fp&&function(){var e=Ee.match(/ QQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),pp=!Nr&&/QQBrowserLite\/\d+/i.test(Ee),g4=pp&&function(){var e=Ee.match(/QQBrowserLite\/([\d.]+)/);return e&&e[1]?e[1]:null}(),mp=!Nr&&/MQBHD\/\d+/i.test(Ee),_4=mp&&function(){var e=Ee.match(/MQBHD\/([\d.]+)/);return e&&e[1]?e[1]:null}(),AS=/Windows/i.test(Ee),ec=!_i&&/MAC OS X/i.test(Ee),PS=!ta&&/Linux/i.test(Ee);/MicroMessenger/i.test(Ee);var y4=/UCBrowser/i.test(Ee);/Electron/i.test(Ee);var DS,el,vp=/MiuiBrowser/i.test(Ee),b4=vp&&function(){var e=Ee.match(/MiuiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),gp=/HuaweiBrowser/i.test(Ee),_p=/Huawei/i.test(Ee),S4=gp&&function(){var e=Ee.match(/HuaweiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),yp=/SamsungBrowser/i.test(Ee),k4=yp&&function(){var e=Ee.match(/SamsungBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),tl=/HeyTapBrowser/i.test(Ee),T4=tl&&function(){var e=Ee.match(/HeyTapBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),nl=/VivoBrowser/i.test(Ee),I4=nl&&function(){var e=Ee.match(/VivoBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),lo=function(){var e=Ee.match(/Chrome\/(\d+)/);return e&&e[1]?Number(e[1]):null},x4=/Chrome/i.test(Ee),rl=!$u&&!cp&&!sp&&!Nr&&!up&&!Zu&&!fp&&!vp&&!gp&&!yp&&!tl&&!nl&&/Chrome/i.test(Ee),bp=rl&&lo(),w4=rl&&function(){var e=Ee.match(/Chrome\/([\d.]+)/);return e&&e[1]?e[1]:null}(),na=!x4&&!hp&&!dp&&!pp&&!mp&&/Safari/i.test(Ee),Sp=function(){if(na){var e=Ee.match(/Version\/([\d.]+)/);if(e&&e[1])return e[1]}return""}(),C4=/Android.*(wv|.0.0.0)/.test(Ee),yi=function(){if(wS)return Sp;if(_i){var e=Ee.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}(),OS=Number(yi.split(".")[0]),il=Sp==="15.1",al=yi==="15.1",E4=(DS=Number(yi.split(".")[0]))===14||DS===13,ra=location.protocol==="file:"||location.hostname==="localhost"||location.hostname==="127.0.0.1",ia=function(){if(ge(el))try{el=window.localStorage}catch(e){_e.warn(e),el=!1}return el},kp=new Map([[Vn,["Firefox",CS]],[Zu,["Edg",ES]],[rl,["Chrome",w4]],[na,["Safari",Sp]],[Nr,["TBS",f4]],[up,["XWEB",p4]],[lp&&op,["WeChat",m4]],[fp,["QQ(Win)",v4]],[hp,["QQ(Mobile)",RS]],[dp,["QQ(Mobile X5)",RS]],[pp,["QQ(Mac)",g4]],[mp,["QQ(iPad)",_4]],[vp,["MI",b4]],[gp,["HW",S4]],[yp,["Samsung",k4]],[tl,["OPPO",T4]],[nl,["VIVO",I4]],[$u,["EDGE",l4]],[sp,["SogouMobile",d4]],[cp,["Sogou",h4]]]);function aa(){var e="unknown",t="unknown";return kp.get(!0)&&(e=kp.get(!0)[0],t=kp.get(!0)[1]),{name:e,version:t}}var LS=function(e,t){return t?co+"/"+e+"/"+t:co+"/"+e+"/index.html"},R4=function(){if(!ia())return!1;var e=localStorage.getItem($f);e&&!function(t){var n=t.saveTime&&new Date().getTime()-t.saveTime>=Kb,i=!t.saveVersion||t.saveVersion!==oi;return n||i}(JSON.parse(e))||(_e.info("init debug info"),function(){var t=new XMLHttpRequest;if(t.open("GET","https://web.sdk.qcloud.com/trtc/webrtc/download/error-message/0.0.3/script.js",!1),t.send(null),t.readyState===4&&t.status===200){var n=document.createElement("script");n.type="text/javascript",n.text=t.responseText,document.body.appendChild(n),localStorage.setItem($f,JSON.stringify({message:t.responseText,saveTime:new Date().getTime(),saveVersion:oi})),document.body.removeChild(n)}}())};function ie(e){var t=e.key,n=e.data,i=e.link,r=e.addDocLink,o=r===void 0||r,c="",a="",s="";ln(gi[t])?c=gi[t](n):Bt(gi[t])&&(c=gi[t]);var l=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 I=localStorage.getItem($f);if(I){I=JSON.parse(I);var R=document.createElement("script");R.type="text/javascript",R.text=I.message,document.body.appendChild(R);var x=window.TRTC_ERROR_INFO,m=window.TRTC_ERROR_LINK;return document.body.removeChild(R),{TRTC_ERROR_INFO:x,TRTC_ERROR_LINK:m}}return{}}(),u=l.TRTC_ERROR_INFO,h=l.TRTC_ERROR_LINK;i?s="".concat(i.className,".html#").concat(i.fnName):h&&h[t]&&(ln(h[t])?s=h[t](n):Bt(h[t])&&(s=h[t]));var b=c;return oa()&&(u&&u[t]&&(ln(u[t])?a=u[t](n):Bt(u[t])&&(a=u[t])),a&&(b=o?a+`
45
45
  \u8BF7\u67E5\u770B\u6587\u6863: `+LS("zh-cn",s)+`
46
46
 
47
47
  `:a+`
48
48
 
49
- `,S+=c)),o&&(S+=`
49
+ `,b+=c)),o&&(b+=`
50
50
  Refer to: `+LS("en",s)+`
51
- `),S}var MS=function(){return function(e){var t=window.location.search.match(new RegExp("(\\?|&)"+e+"=([^&]*)(&|$)"));return t?decodeURIComponent(t[2]):""}("trtc_env")},NS=function(e){return(e=Number(e))>0&&e<14e8},sl=function(e,t){var n;n=Ks?Ks.includes("http")?Ks:"https://"+Ks:NS(e)?"https://apisgp.my-imcloud.com":"https://yun.tim.qq.com";var i=Math.floor(Math.random()*Math.pow(2,31));return"".concat(n,"/v5/AVQualityReportSvc/C2S?random=").concat(i,"&sdkappid=").concat(e,"&cmdtype=").concat(t)};function xp(){var e=navigator.userAgent,t=navigator.connection,n=e.match(/NetType\/\w+/)?e.match(/NetType\/\w+/)[0]:"";(n=n.toLowerCase().replace("nettype/",""))==="3gnet"&&(n="3g");var i=t&&t.type&&t.type.toLowerCase(),r=t&&t.effectiveType&&t.effectiveType.toLowerCase();r==="slow-2"&&(r="2g");var o=n||"unknown";if(i)switch(i){case"cellular":case"wimax":o=r||"unknown";break;case"wifi":o="wifi";break;case"ethernet":o="wired";break;case"none":case"other":case"unknown":o="unknown"}return o}var bi=function(e){if(!e||G(e)!=="object"||Object.prototype.toString.call(e)!="[object Object]")return!1;var t=Object.getPrototypeOf(e);if(t===null)return!0;var n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object)};function cl(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;return e<=1?n:cl(e-1,n,t+n)}function wp(e){var t=Math.round(e/2)+1;return t>6?13e3:1e3*cl(t)}var ln=function(e){return typeof e=="function"},ge=function(e){return e===void 0},Bt=function(e){return typeof e=="string"},tr=function(e){return typeof e=="number"},nr=function(e){return typeof e=="boolean"},US=function(e){return Si(e)==="object"},ho=function(e){return Si(e)==="array"},VS=function(e){return Si(e)==="MediaStreamTrack".toLowerCase()};function Si(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}function jS(e){var t={};return t.urls="turn:".concat(e.url),ge(e.username)||ge(e.credential)||(t.username=e.username,t.credential=e.credential,t.credentialType="password",ge(e.credentialType)||(t.credentialType=e.credentialType)),t}function Ct(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}function Cp(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"big";if(!Bt(e))return 0;var n=e.split(".");return t==="big"?(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 Ep,Rp,oa=function(){var e=navigator.language||navigator.userLanguage;return(e=e.substr(0,2))==="zh"},BS=(Ep=!1,Rp=document.visibilityState,function(){document.visibilityState!==Rp&&_e.info("visibility change: ".concat(document.visibilityState)),Ep||(document.addEventListener("visibilitychange",function(){_e.info("visibility change: "+document.visibilityState),Rp=document.visibilityState}),Ep=!0)});window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext;var FS=function(){return new window.AudioContext},HS=function(){var e;return function(){return e||(e=new window.AudioContext,e.onstatechange=function(){_e.info("gain context state: ".concat(e.state)),e.state==="suspended"?(e.resume(),document.addEventListener("click",e.resume)):e.state==="interrupted"?e.resume():document.removeEventListener("click",e.resume)},e)}}(),A4=!!window.AudioWorkletNode,GS=function(e,t){var n=e.emit;return e.emit=function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];try{n.apply(e,r)}catch(a){var c=ae({key:q3,data:{name:t,event:r[0]},addDocLink:!1});_e.warn(c+`
51
+ `),b}var MS=function(){return function(e){var t=window.location.search.match(new RegExp("(\\?|&)"+e+"=([^&]*)(&|$)"));return t?decodeURIComponent(t[2]):""}("trtc_env")},NS=function(e){return(e=Number(e))>0&&e<14e8},ol=function(e,t){var n;n=Ks?Ks.includes("http")?Ks:"https://"+Ks:NS(e)?"https://apisgp.my-imcloud.com":"https://yun.tim.qq.com";var i=Math.floor(Math.random()*Math.pow(2,31));return"".concat(n,"/v5/AVQualityReportSvc/C2S?random=").concat(i,"&sdkappid=").concat(e,"&cmdtype=").concat(t)};function Tp(){var e=navigator.userAgent,t=navigator.connection,n=e.match(/NetType\/\w+/)?e.match(/NetType\/\w+/)[0]:"";(n=n.toLowerCase().replace("nettype/",""))==="3gnet"&&(n="3g");var i=t&&t.type&&t.type.toLowerCase(),r=t&&t.effectiveType&&t.effectiveType.toLowerCase();r==="slow-2"&&(r="2g");var o=n||"unknown";if(i)switch(i){case"cellular":case"wimax":o=r||"unknown";break;case"wifi":o="wifi";break;case"ethernet":o="wired";break;case"none":case"other":case"unknown":o="unknown"}return o}var bi=function(e){if(!e||G(e)!=="object"||Object.prototype.toString.call(e)!="[object Object]")return!1;var t=Object.getPrototypeOf(e);if(t===null)return!0;var n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object)};function sl(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;return e<=1?n:sl(e-1,n,t+n)}function Ip(e){var t=Math.round(e/2)+1;return t>6?13e3:1e3*sl(t)}var ln=function(e){return typeof e=="function"},ge=function(e){return e===void 0},Bt=function(e){return typeof e=="string"},tr=function(e){return typeof e=="number"},nr=function(e){return typeof e=="boolean"},US=function(e){return Si(e)==="object"},ho=function(e){return Si(e)==="array"},VS=function(e){return Si(e)==="MediaStreamTrack".toLowerCase()};function Si(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}function jS(e){var t={};return t.urls="turn:".concat(e.url),ge(e.username)||ge(e.credential)||(t.username=e.username,t.credential=e.credential,t.credentialType="password",ge(e.credentialType)||(t.credentialType=e.credentialType)),t}function Ct(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}function xp(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"big";if(!Bt(e))return 0;var n=e.split(".");return t==="big"?(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 wp,Cp,oa=function(){var e=navigator.language||navigator.userLanguage;return(e=e.substr(0,2))==="zh"},BS=(wp=!1,Cp=document.visibilityState,function(){document.visibilityState!==Cp&&_e.info("visibility change: ".concat(document.visibilityState)),wp||(document.addEventListener("visibilitychange",function(){_e.info("visibility change: "+document.visibilityState),Cp=document.visibilityState}),wp=!0)});window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext;var FS=function(){return new window.AudioContext},HS=function(){var e;return function(){return e||(e=new window.AudioContext,e.onstatechange=function(){_e.info("gain context state: ".concat(e.state)),e.state==="suspended"?(e.resume(),document.addEventListener("click",e.resume)):e.state==="interrupted"?e.resume():document.removeEventListener("click",e.resume)},e)}}(),A4=!!window.AudioWorkletNode,GS=function(e,t){var n=e.emit;return e.emit=function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];try{n.apply(e,r)}catch(a){var c=ie({key:q3,data:{name:t,event:r[0]},addDocLink:!1});_e.warn(c+`
52
52
 
53
- `+a.stack)}},e},WS=function(e){return+e<10?"0".concat(e):e},P4=function(e){var t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;var n=t.split("."),i=WS(n[1])+WS(n[2]);return n[1]-15>0&&(n[1]="15"),n[2]-15>0&&(n[2]="15"),n.join(".")+"."+i};function fo(e,t){try{if(ho(e))return"[".concat(e.map(function(r){return fo(r,t)}).join(","),"]");if(!bi(e)||!ho(t))return JSON.stringify(e);var n={},i=new Set(t);return Object.keys(e).forEach(function(r){i.has(r)&&(n[r]=e[r])}),JSON.stringify(n)}catch(r){return"{}"}}function ul(e){var t=e.url,n=e.body,i=e.method,r=e.timeout,o=new XMLHttpRequest;return new Promise(function(c,a){o.onload=function(l){if(o.status>=200&&o.status<300&&o.responseText.length>0)try{var u=JSON.parse(o.response);c({data:u})}catch(h){c({data:o.response})}else o.status>0&&a({code:o.status,message:"request failed, readyState:".concat(o.readyState," status:").concat(o.status," loaded size:").concat(l.loaded)})};var s=function(l){a({code:o.readyState,message:"request ".concat(l.type,", readyState:").concat(o.readyState," status:").concat(o.status," loaded size:").concat(l.loaded)})};o.onerror=s,o.onabort=s,o.ontimeout=s,o.timeout=r||5e3,o.open(i||"POST",t,!0),o.send(n)})}var zS={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,n="~";function i(){}function r(s,l,u){this.fn=s,this.context=l,this.once=u||!1}function o(s,l,u,h,S){if(typeof u!="function")throw new TypeError("The listener must be a function");var I=new r(u,h||s,S),E=n?n+l:l;return s._events[E]?s._events[E].fn?s._events[E]=[s._events[E],I]:s._events[E].push(I):(s._events[E]=I,s._eventsCount++),s}function c(s,l){--s._eventsCount==0?s._events=new i:delete s._events[l]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(n=!1)),a.prototype.eventNames=function(){var s,l,u=[];if(this._eventsCount===0)return u;for(l in s=this._events)t.call(s,l)&&u.push(n?l.slice(1):l);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(s)):u},a.prototype.listeners=function(s){var l=n?n+s:s,u=this._events[l];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,S=u.length,I=new Array(S);h<S;h++)I[h]=u[h].fn;return I},a.prototype.listenerCount=function(s){var l=n?n+s:s,u=this._events[l];return u?u.fn?1:u.length:0},a.prototype.emit=function(s,l,u,h,S,I){var E=n?n+s:s;if(!this._events[E])return!1;var x,m,T=this._events[E],v=arguments.length;if(T.fn){switch(T.once&&this.removeListener(s,T.fn,void 0,!0),v){case 1:return T.fn.call(T.context),!0;case 2:return T.fn.call(T.context,l),!0;case 3:return T.fn.call(T.context,l,u),!0;case 4:return T.fn.call(T.context,l,u,h),!0;case 5:return T.fn.call(T.context,l,u,h,S),!0;case 6:return T.fn.call(T.context,l,u,h,S,I),!0}for(m=1,x=new Array(v-1);m<v;m++)x[m-1]=arguments[m];T.fn.apply(T.context,x)}else{var w,L=T.length;for(m=0;m<L;m++)switch(T[m].once&&this.removeListener(s,T[m].fn,void 0,!0),v){case 1:T[m].fn.call(T[m].context);break;case 2:T[m].fn.call(T[m].context,l);break;case 3:T[m].fn.call(T[m].context,l,u);break;case 4:T[m].fn.call(T[m].context,l,u,h);break;default:if(!x)for(w=1,x=new Array(v-1);w<v;w++)x[w-1]=arguments[w];T[m].fn.apply(T[m].context,x)}}return!0},a.prototype.on=function(s,l,u){return o(this,s,l,u,!1)},a.prototype.once=function(s,l,u){return o(this,s,l,u,!0)},a.prototype.removeListener=function(s,l,u,h){var S=n?n+s:s;if(!this._events[S])return this;if(!l)return c(this,S),this;var I=this._events[S];if(I.fn)I.fn!==l||h&&!I.once||u&&I.context!==u||c(this,S);else{for(var E=0,x=[],m=I.length;E<m;E++)(I[E].fn!==l||h&&!I[E].once||u&&I[E].context!==u)&&x.push(I[E]);x.length?this._events[S]=x.length===1?x[0]:x:c(this,S)}return this},a.prototype.removeAllListeners=function(s){var l;return s?(l=n?n+s:s,this._events[l]&&c(this,l)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a})(zS);var ki=zS.exports,Y=new ki,ll=1,Ap=2,Pp=3,po=4,sa=5,Dp=20,Op=21,mo=22,Lp=23,Mp=24,Np=27,Up=28,dl=29,JS=30,qS=31,Vp=32,jp=33,KS=40,D4=41,O4=52,L4=100,XS=101,tc=102,Bp=103,jn=110,hl=111,Fp=112,Ur=113,Vr=114,M4=115,ca=116,N4=120,Hp=121,Gp=122,Wp=123,nc=130,zp=131,Jp=132,qp=133,Kp=134,Xp=135,Qp=136,Yp=137,fl=200,$p=201,Zp=300,rc=301,em=302,tm=303;function ic(e){var t=e.retryFunction,n=e.settings,i=e.onError,r=e.onRetrying,o=e.onRetryFailed,c=e.onRetrySuccess,a=e.context;return function(){for(var s=this,l=arguments.length,u=new Array(l),h=0;h<l;h++)u[h]=arguments[h];var S=n.retries||5,I=0,E=-1,x=0,m=function(){var T=H(p().mark(function v(w,L){var N,V,_,b;return p().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:return N=a||s,R.prev=1,R.next=4,t.apply(N,u);case 4:V=R.sent,I!==0&&ln(c)&&c.call(N,I),I=0,w(V),R.next=15;break;case 10:R.prev=10,R.t0=R.catch(1),_=function(){clearTimeout(E),I=0,x=2,L(R.t0)},b=function(){x!==2&&I<S?(I++,x=1,ln(r)&&r.call(N,I,_),E=setTimeout(function(){E=-1,m(w,L)},ge(n.timeout)?1e3:n.timeout)):(_(),ln(o)&&o.call(N,R.t0))},ln(i)?i.call(N,R.t0,b,L,u,I):b();case 15:case"end":return R.stop()}},v,null,[[1,10]])}));return function(v,w){return T.apply(this,arguments)}}();return new Promise(m)}}var U4=xe(function e(t){Q(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}),V4=function(){function e(t){Q(this,e),this.id_=t.id,this.userId_=t.userId,this.sdkAppId_=t.sdkAppId,this.type_=t.type,this.isLocal_=!nr(t.isLocal)||t.isLocal}return xe(e,[{key:"setUserId",value:function(t){this.userId_=t}},{key:"setSdkAppId",value:function(t){this.sdkAppId_=t}},{key:"log",value:function(t,n){_e.log({log:"[".concat(this.isLocal_?"\u2191":"\u2193").concat(this.id_,"] ").concat(this.type_?this.type_+" ":"").concat(n),level:t,forAllJoinedClients:ge(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_})}},{key:"info",value:function(t){this.log(Un.INFO,t)}},{key:"debug",value:function(t){this.log(Un.DEBUG,t)}},{key:"warn",value:function(t){this.log(Un.WARN,t)}},{key:"error",value:function(t){this.log(Un.ERROR,t)}}]),e}(),j4=!(_i||ta),B4=function(){function e(){var i=this;Q(this,e),this.clients_=new Set,this.queue_=[],this.timeoutId_=-1,this.logLevel_=Un.DEBUG,this.logLevelToUpload_=Un.INFO,this.enableUploadLog_=!0,this.isAbleToUpload_=!1,this.checkURLParam(),Y.on(JS,function(r){var o=r.client;i.timeoutId_===-1&&i.startUpload(),i.clients_.add(o)}),Y.on(jp,function(r){var o=r.client;return i.clients_.delete(o)}),Y.on(qS,function(r){r&&bi(r.config)&&ea[r.config.logLevelToUpload]&&(i.logLevelToUpload_=r.config.logLevelToUpload)}),Y.on(po,this.setIsAbleToUpload,this),Y.on(sa,this.setIsAbleToUpload,this)}var t,n;return xe(e,[{key:"getIsAbleToUpload",value:function(){return this.isAbleToUpload_}},{key:"setIsAbleToUpload",value:function(){this.isAbleToUpload_=!0,Y.off(po,this.setIsAbleToUpload,this),Y.off(sa,this.setIsAbleToUpload,this)}},{key:"startUpload",value:(n=H(p().mark(function i(){var r=this;return p().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,o.next=3,this.upload();case 3:o.next=7;break;case 5:o.prev=5,o.t0=o.catch(0);case 7:this.timeoutId_=setTimeout(function(){return r.startUpload()},2e3);case 8:case"end":return o.stop()}},i,this,[[0,5]])})),function(){return n.apply(this,arguments)})},{key:"getLogsToUpload",value:function(){var i=this,r={map:new Map,splicedQueue:[]};if(this.queue_[0].forAllJoinedClients&&this.clients_.size===0)return r;for(var o=0,c=function(){if(o===50)return"break";var a=i.queue_[o];if(a.forAllJoinedClients){var s=new Set;i.clients_.forEach(function(l){if(l.getIsJoined()){var u=l.getUserId(),h=l.getSDKAppId();s.has("".concat(u,"-").concat(h))||(s.add("".concat(u,"-").concat(h)),r.map.has(u)?r.map.get(u).logs.push(a):r.map.set(u,{userId:u,sdkAppId:h,logs:[a]}))}})}else r.map.has(a.userId)?r.map.get(a.userId).logs.push(a):r.map.set(a.userId,{userId:a.userId,sdkAppId:a.sdkAppId,logs:[a]})};o<this.queue_.length&&c()!=="break";o++);return r.map.size>0&&(r.splicedQueue=this.queue_.splice(0,o)),r}},{key:"upload",value:(t=H(p().mark(function i(){var r,o,c,a,s,l,u,h,S,I;return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(this.queue_.length!==0&&this.isAbleToUpload_){E.next=2;break}return E.abrupt("return");case 2:if(r=this.getLogsToUpload(),o=r.map,c=r.splicedQueue,o.size!==0){E.next=5;break}return E.abrupt("return");case 5:E.prev=5,a=Se(o.values()),s=0;case 8:if(!(s<a.length)){E.next=16;break}return l=a[s],u=l.userId,h=l.sdkAppId,S=l.logs,E.next=12,this.uploadLogWithRetry(JSON.stringify({timestamp:qy(),sdkAppId:String(h),userId:u,version:oi,log:S.map(function(x){return x.log}).join(`
54
- `)}),h);case 12:S.forEach(function(x){return x.uploaded=!0});case 13:s++,E.next=8;break;case 16:E.next=20;break;case 18:E.prev=18,E.t0=E.catch(5);case 20:I=c.filter(function(x){return!x.uploaded}),I.length>0&&(this.queue_=I.concat(this.queue_));case 22:case"end":return E.stop()}},i,this,[[5,18]])})),function(){return t.apply(this,arguments)})},{key:"uploadLogWithRetry",value:function(i,r){return ic({retryFunction:function(){return ul({url:sl(r,yb),body:i,timeout:5e3})},settings:{retries:3,timeout:1e3},onError:function(o,c){c()}})()}},{key:"getPrefix",value:function(i){var r=new Date;return r.setTime(an()),String.prototype.padStart?"[".concat(r.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(r.getMilliseconds().toString().padStart(3,"0"),"] <").concat(ea[i],">"):"[".concat(r.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(r.getMilliseconds(),"] <").concat(ea[i],">")}},{key:"getLogLevel",value:function(){return this.logLevel_}},{key:"setLogLevel",value:function(i){ge(ea[i])||(this.logLevel_!==i&&this.info("setLogLevel ".concat(i)),this.logLevel_=i)}},{key:"enableUploadLog",value:function(){this.enableUploadLog_=!0}},{key:"disableUploadLog",value:function(){this.enableUploadLog_=!1}},{key:"log",value:function(i){var r=i.log,o=i.level,c=i.forAllJoinedClients,a=c===void 0||c,s=i.userId,l=i.sdkAppId;if(r="".concat(this.getPrefix(o)," ").concat(r),this.enableUploadLog_&&o>=this.logLevelToUpload_&&this.queue_.push(new U4({log:r,level:o,userId:s,sdkAppId:l,forAllJoinedClients:a})),!(o<this.logLevel_)){var u=ea[o]?ea[o].toLowerCase():"info";j4?console[u]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",r):console[u](r)}}},{key:"debug",value:function(i){this.log({log:i,level:Un.DEBUG})}},{key:"info",value:function(i){this.log({log:i,level:Un.INFO})}},{key:"warn",value:function(i){this.log({log:i,level:Un.WARN})}},{key:"error",value:function(i){this.log({log:i,level:Un.ERROR})}},{key:"createLogger",value:function(i){return new V4(i)}},{key:"checkURLParam",value:function(){var i=new URLSearchParams(location.search).get("logLevelToUpload");ea[i]&&(this.logLevelToUpload_=i)}}]),e}(),_e=new B4,QS=!0,F4=at,H4=Math.floor,YS=Number.isInteger||function(e){return!F4(e)&&isFinite(e)&&H4(e)===e};Le({target:"Number",stat:!0},{isInteger:YS});var nm,G4=Le,$S=pe,W4=be.f,z4=yr,ZS=Wt,J4=p0,q4=pt,K4=m0,ek=$S("".startsWith),X4=$S("".slice),Q4=Math.min,tk=K4("startsWith");G4({target:"String",proto:!0,forced:!!(tk||(nm=W4(String.prototype,"startsWith"),!nm||nm.writable))&&!tk},{startsWith:function(e){var t=ZS(q4(this));J4(e);var n=z4(Q4(arguments.length>1?arguments[1]:void 0,t.length)),i=ZS(e);return ek?ek(t,i,n):X4(t,n,n+i.length)===i}});var nk=ye,Y4=pe,$4=Ke,Z4=ue,rm=su,eU=Kd,tU=qt,nU=Mt,rU=yn,vo=Object.assign,rk=Object.defineProperty,iU=Y4([].concat),ik=!vo||Z4(function(){if(nk&&vo({b:1},vo(rk({},"a",{enumerable:!0,get:function(){rk(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var e={},t={},n=Symbol(),i="abcdefghijklmnopqrst";return e[n]=7,i.split("").forEach(function(r){t[r]=r}),vo({},e)[n]!=7||rm(vo({},t)).join("")!=i})?function(e,t){for(var n=nU(e),i=arguments.length,r=1,o=eU.f,c=tU.f;i>r;)for(var a,s=rU(arguments[r++]),l=o?iU(rm(s),o(s)):rm(s),u=l.length,h=0;u>h;)a=l[h++],nk&&!$4(c,s,a)||(n[a]=s[a]);return n}:vo,ak=ik;Le({target:"Object",stat:!0,arity:2,forced:Object.assign!==ak},{assign:ak});var ok=pe,aU=Vt,oU=at,sU=kt,sk=Ha,cU=Me,ck=Function,uU=ok([].concat),lU=ok([].join),im={},dU=function(e,t,n){if(!sU(im,t)){for(var i=[],r=0;r<t;r++)i[r]="a["+r+"]";im[t]=ck("C,a","return new C("+lU(i,",")+")")}return im[t](e,n)},hU=cU?ck.bind:function(e){var t=aU(this),n=t.prototype,i=sk(arguments,1),r=function(){var o=uU(i,sk(arguments));return this instanceof r?dU(t,o.length,o):t.apply(e,o)};return oU(n)&&(r.prototype=n),r},uk=hU;Le({target:"Function",proto:!0,forced:Function.bind!==uk},{bind:uk});var fU=Le,pU=rn.findIndex,mU=lu,lk="findIndex",dk=!0;lk in[]&&Array(1).findIndex(function(){dk=!1}),fU({target:"Array",proto:!0,forced:dk},{findIndex:function(e){return pU(this,e,arguments.length>1?arguments[1]:void 0)}}),mU(lk);var vU=ye,hk=pe,gU=su,_U=bn,yU=hk(qt.f),bU=hk([].push),fk=function(e){return function(t){for(var n,i=_U(t),r=gU(i),o=r.length,c=0,a=[];o>c;)n=r[c++],vU&&!yU(i,n)||bU(a,e?[n,i[n]]:i[n]);return a}},SU={entries:fk(!0),values:fk(!1)}.values;Le({target:"Object",stat:!0},{values:function(e){return SU(e)}});var pk=1,mk=5,am=2,ac=3,om=4,pl="DISCONNECTED",vk="CONNECTING",sm="RECONNECTING",oc="CONNECTED",jr={CLIENT_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,PUBLISH_STATE_CHANGE_RESULT:4112,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,UPDATE_CONSTRAINT_CONFIG_RES:772,CONNECT_OTHER_ROOM_RES:8209,DISCONNECT_OTHER_ROOM_RES:8211,UPDATE_OTHER_ROOM_FORWARD_MODE_RES:8213},kU=[jr.UPDATE_REMOTE_MUTE_STAT,jr.UPLINK_NETWORK_STATS,jr.USER_LIST_RES,jr.MUTE_RESULT],st={CLIENT_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",PUBLISH_STATE_CHANGE_RESULT:"publish-state-change-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",UPDATE_CONSTRAINT_CONFIG_RES:"update-contraint-config-res",CONNECT_OTHER_ROOM_RES:"connect_other_room_res",UPDATE_OTHER_ROOM_FORWARD_MODE_RES:"update_other_room_forward_mode_res",DISCONNECT_OTHER_ROOM_RES:"disconnect_other_room_res"},TU="publish_change",IU="publish_state_change",xU="join",wU="leave",CU="quality_report",EU="mute_uplink",RU="publish",gk="unpublish",AU="subscribe",PU="unsubscribe",DU="subscribe_change",OU="start_publishing",LU="stop_publishing",MU="start_push_user_cdn",NU="stop_push_user_cdn",UU="start_mcu_mix",VU="stop_mcu_mix",jU="get_user_list",BU="change_role",FU="update_constraint_config",HU="connect_other_room",GU="update_other_room_forward_mode",WU="disconnect_other_room",Z={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,API_CALL_ABORTED:16461,UNKNOWN:65535},te=function(e){Et(n,e);var t=Rr(n);function n(i){var r,o=i.name,c=o===void 0?"RtcError":o,a=i.message,s=i.code,l=s===void 0?Z.UNKNOWN:s,u=i.extraCode,h=u===void 0?0:u,S=i.constraint;Q(this,n);var I="<".concat(function(E){for(var x in Z)if(Z[x]===E)return x;return"UNKNOWN"}(l)," 0x").concat(l.toString(16),">");return(r=t.call(this,a+"".concat(S?" constraint: ".concat(S):"")+"".concat(a!=null&&a.includes(I)?"":" "+I))).code_=l,r.extraCode_=h,r.name=c,r.message_=a,S&&(r.constraint=S),r}return xe(n,[{key:"getCode",value:function(){return this.code_}},{key:"getExtraCode",value:function(){return this.extraCode_}}]),n}(zo(Error)),_k=32768,yk=32769,bk=32770,Sk=32771,zU=32772,JU=32773,qU=32774,KU=32775,kk=32777,XU=32778,cm=32779,QU=32780,YU=32781,$U=32782,ZU=32783,eV=32784,tV=32785,nV=32786,rV=32787,iV=32788,aV=32789,oV=32790,sV=32791,cV=32792,uV=32793,lV=32794,dV=32795,hV=32796,fV=32797,pV=32798,mV=32799,vV=32800,gV=32801,_V=32802,yV=32803,bV=32804,sc=new Map,vn=function(e,t){var n=sc.get(e);n||(sc.set(e,[]),n=sc.get(e)),n.push(t)},SV=function(e){var t=sc.get(e),n=[];return t?(sc.delete(e),n=t.map(function(i){return{uint32_event_id:i.eventId,uint64_date:i.timestamp,str_userid:i.remoteUserId,str_event_json:i.eventDesc}})):n=[],n},kV=Object.prototype.hasOwnProperty;function Br(e){if(e==null)return!0;if(typeof e=="boolean")return!1;if(typeof e=="number")return e===0;if(typeof e=="string"||typeof e=="function"||Array.isArray(e))return e.length===0;if(e instanceof Error)return e.message==="";if(bi(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return e.size===0;case"[object Object]":for(var t in e)if(kV.call(e,t))return!1;return!0}return!1}var TV=function(){function e(){Q(this,e);var t=aa(),n=t.name,i=t.version;this.roomIdMap_=new Map,this.configs_={sdkAppId:"",userId:"",version:oi,env:Wu,browserVersion:n+i,ua:navigator.userAgent}}return xe(e,[{key:"setConfig",value:function(t){var n=t.sdkAppId,i=t.env,r=t.userId,o=t.roomId;n!==this.configs_.sdkAppId&&(this.configs_.sdkAppId=String(n)),this.configs_.env=i,this.configs_.userId=r,this.roomIdMap_.set(r,String(o))}},{key:"logEvent",value:function(t){if(!ra){var n=q(q(q({},t),this.configs_),{},{userId:t.userId||this.configs_.userId});ge(n.code)&&(n.code=n.result==="failed"?Z.UNKNOWN:0),this.sendRequest(sl(this.configs_.sdkAppId,JM),n)}}},{key:"logSuccessEvent",value:function(t){ra||(this.logEvent(q(q({},t),{},{result:"success",roomId:this.roomIdMap_.get(t.userId)})),this.configs_.env===Wu&&this.uploadEventToKibana(q(q({},t),{},{result:"success"})))}},{key:"logFailedEvent",value:function(t){if(!ra){var n=t.eventType,i=t.code,r=t.error,o=t.userId,c={roomId:this.roomIdMap_.get(o),userId:o,eventType:n,result:"failed",code:i||(r instanceof te?r.getExtraCode()||r.getCode():Z.UNKNOWN)};this.logEvent(c),this.configs_.env===Wu&&this.uploadEventToKibana(q(q({},c),{},{error:r}))}}},{key:"uploadEventToKibana",value:function(t){var n="stat-".concat(t.eventType,"-").concat(t.result);t.eventType!=="delta-join"&&t.eventType!=="delta-leave"&&t.eventType!=="delta-publish"||(n="".concat(t.eventType,":").concat(t.delta)),this.uploadEvent({log:n,userId:t.userId}),t.result==="failed"&&(n="stat-".concat(t.eventType,"-").concat(t.result,"-").concat(t.code),this.uploadEvent({log:n,userId:t.userId,error:t.error}))}},{key:"uploadEvent",value:function(t){var n=t.log,i=t.userId,r=t.error,o={timestamp:qy(),sdkAppId:this.configs_.sdkAppId,userId:i||this.configs_.userId,version:this.configs_.version,log:n};r&&(o.errorInfo=r.message),this.sendRequest(sl(this.configs_.sdkAppId,yb),o)}},{key:"sendRequest",value:function(t,n){var i=this;_e.getIsAbleToUpload()?ul({url:t,body:JSON.stringify(n)}).catch(function(){}):setTimeout(function(){i.sendRequest(t,n)},1e3)}}]),e}(),ke=new TV,IV=Mt,xV=ji;Le({target:"Date",proto:!0,arity:1,forced:ue(function(){return new Date(NaN).toJSON()!==null||Date.prototype.toJSON.call({toISOString:function(){return 1}})!==1})},{toJSON:function(e){var t=IV(this),n=xV(t,"number");return typeof n!="number"||isFinite(n)?t.toISOString():null}});var wV=Ke;Le({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return wV(URL.prototype.toString,this)}});var CV=Le,um=pe,EV=$n,RV=o0,AV=ey,Tk=ue,PV=RangeError,Ik=String,xk=Math.floor,lm=um(AV),wk=um("".slice),cc=um(1 .toFixed),go=function(e,t,n){return t===0?n:t%2==1?go(e,t-1,n*e):go(e*e,t/2,n)},_o=function(e,t,n){for(var i=-1,r=n;++i<6;)r+=t*e[i],e[i]=r%1e7,r=xk(r/1e7)},dm=function(e,t){for(var n=6,i=0;--n>=0;)i+=e[n],e[n]=xk(i/t),i=i%t*1e7},Ck=function(e){for(var t=6,n="";--t>=0;)if(n!==""||t===0||e[t]!==0){var i=Ik(e[t]);n=n===""?i:n+lm("0",7-i.length)+i}return n};CV({target:"Number",proto:!0,forced:Tk(function(){return cc(8e-5,3)!=="0.000"||cc(.9,0)!=="1"||cc(1.255,2)!=="1.25"||cc(0xde0b6b3a7640080,0)!=="1000000000000000128"})||!Tk(function(){cc({})})},{toFixed:function(e){var t,n,i,r,o=RV(this),c=EV(e),a=[0,0,0,0,0,0],s="",l="0";if(c<0||c>20)throw PV("Incorrect fraction digits");if(o!=o)return"NaN";if(o<=-1e21||o>=1e21)return Ik(o);if(o<0&&(s="-",o=-o),o>1e-21)if(n=(t=function(u){for(var h=0,S=u;S>=4096;)h+=12,S/=4096;for(;S>=2;)h+=1,S/=2;return h}(o*go(2,69,1))-69)<0?o*go(2,-t,1):o/go(2,t,1),n*=4503599627370496,(t=52-t)>0){for(_o(a,0,n),i=c;i>=7;)_o(a,1e7,0),i-=7;for(_o(a,go(10,i,1),0),i=t-1;i>=23;)dm(a,1<<23),i-=23;dm(a,1<<i),_o(a,1,1),dm(a,2),l=Ck(a)}else _o(a,0,n),_o(a,1<<-t,0),l=Ck(a)+lm("0",c);return l=c>0?s+((r=l.length)<=c?"0."+lm("0",c-r)+l:wk(l,0,r-c)+"."+wk(l,r-c)):s+l}});var hm=null,fm=!0;function Ti(e){nr(e)&&e!==fm&&(fm=e,_e.info("setIsNeedToSchedule "+e))}function DV(e,t){try{if(PerformanceObserver){var n=Ct(),i=ml(e,Qe),r=ml(e,er),o=new PerformanceObserver(function(c){c.getEntries().forEach(function(a){if(a.startTime>=n&&(a.name===i||a.name===r)){var s=a.name===i?Qe:er;if(a.code&&a.code!==200)return void _e.warn("".concat(s," schedule with code ").concat(a.code,", ").concat(JSON.stringify(a.toJSON())));var l=a.responseEnd-a.startTime,u=[a.domainLookupStart-a.startTime,a.domainLookupEnd-a.domainLookupStart,a.requestStart-a.secureConnectionStart,a.secureConnectionStart-a.connectStart,a.responseStart-a.requestStart,a.responseEnd-a.responseStart].map(function(h){return h.toFixed(1)});o.disconnect(),ke.uploadEvent({log:"stat-schedule-net:".concat(l.toFixed(1),"(").concat(u.join("->"),") ").concat(s),userId:t})}})});o.observe({type:"resource",buffered:!0})}}catch(c){}}function OV(e){return pm.apply(this,arguments)}function pm(){return pm=H(p().mark(function e(t){var n,i,r,o,c,a,s,l,u,h,S,I,E;return p().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(n=t.userId,i=t.sdkAppId,r=t.useStringRoomId,o=t.roomId,c=t.userSig,fm||!hm){x.next=3;break}return x.abrupt("return",{isCached:!0,result:hm});case 3:return a={delta:0,count:[1,1],msg:[]},x.prev=4,(s=new FormData).append("userId",String(n)),s.append("sdkAppId",String(i)),s.append("isStrGroupId",r),s.append("groupId",String(o)),s.append("sdkVersion",oi),s.append("userSig",String(c)),Qf&&s.append("oversea",!0),DV(i,n),l=Ct(),x.next=17,MV(s,a,i);case 17:return(u=x.sent).config&&(u.config.loggerDomain&&jf(u.config.loggerDomain),nr(u.config.scheduleCache)&&Ti(!u.config.scheduleCache)),a.delta=Ct()-l,Ek({stat:a,userId:n}),hm=u,x.abrupt("return",{isCached:!1,result:u});case 25:throw x.prev=25,x.t0=x.catch(4),h=ho(x.t0)?x.t0[0]:x.t0,S=tr(h.code)?h.code:0,I="schedule failed".concat(h.message?": ".concat(h.message):""),E=new te({code:Z.SCHEDULE_FAILED,extraCode:S,message:ae({key:uS,data:{error:I,code:S}})}),_e.error(E),Ek({stat:a,userId:n,roomId:o,error:E}),E;case 34:case"end":return x.stop()}},e,null,[[4,25]])})),pm.apply(this,arguments)}function Ek(e){var t=e.stat,n=e.userId,i=e.error;i?ke.logFailedEvent({eventType:Fb,error:i,userId:n}):ke.logSuccessEvent({eventType:Fb,delta:t.delta,userId:n}),ke.uploadEvent({log:"stat-schedule:"+JSON.stringify(t),userId:n})}function ml(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qe;return t=Qf||(NS(e)?n===Qe?sN:cN:n===Qe?aN:oN),"https://".concat(t,"/api/v1/config")}function LV(e,t,n){return new Promise(function(i,r){ul({url:e,body:t,timeout:n.timeout}).then(function(o){o.data.code===0?i(o.data.data):r({code:o.data.code,message:o.data.msg})}).catch(r)})}Y.on(sa,function(){return Ti(!0)}),Y.on(D4,function(){return Ti(!0)}),Y.on(O4,function(){return Ti(!0)}),Y.on(KS,function(){return Ti(!0)}),Y.on(fl,function(e){e.state===Ff&&Ti(!0)});var Rk=function(e,t){return ic({retryFunction:LV,settings:{retries:3,timeout:0},onError:t,onRetrying:e})};function MV(e,t,n){return new Promise(function(i,r){var o,c=null;(o=[Rk(function(a){return t.count[0]=a+1},function(a,s){t.msg[0]=a.message,c||s()})(ml(n,Qe),e,{get timeout(){return 1e3*cl(2+t.count[0])}}),Rk(function(a){return t.count[1]=a+1},function(a,s){t.msg[1]=a.message,c||s()})(ml(n,er),e,{get timeout(){return 1e3*cl(2+t.count[1])}})],new Promise(function(a,s){var l=[];o.forEach(function(u){u.then(a).catch(function(h){l.push(h),l.length===o.length&&s(l)})})})).then(function(a){i(c=a)}).catch(r)})}var NV=function(){function e(i){Q(this,e),this.client_=i.client,this.sdkAppId_=i.sdkAppId,this.userId_=i.userId,this.userSig_=i.userSig,this.url_=i.url,this.backupUrl_=i.backupUrl;var r="?sdkAppId=".concat(encodeURIComponent(this.sdkAppId_),"&userId=").concat(encodeURIComponent(this.userId_),"&userSig=").concat(encodeURIComponent(this.userSig_),"&roomId=").concat(encodeURIComponent(i.roomId)),o=this.client_.getSystemResult();if(o&&o.detail){var c=o.detail,a=c.isH264EncodeSupported,s=c.isVp8EncodeSupported,l=c.isH264DecodeSupported,u=c.isVp8DecodeSupported;r+="&enc264=".concat(Number(a),"&dec264=").concat(Number(l),"&encVp8=").concat(Number(s),"&decVp8=").concat(Number(u))}i.signalDomainWhenUnifiedProxy&&(r+="&signalDomain=".concat(encodeURIComponent(i.signalDomainWhenUnifiedProxy))),this.urlParams=r,this.isConnected_=!1,this.isConnecting_=!1,this.socketInUse_=null,this.socket_=null,this.backupSocket_=null,this.backupTimer_=-1,this.signalInfo_={},this.currentState_=pl,this.reconnectionCount_=0,this.reconnectionTimer_=-1,this.lastMessageTime_=-1,this.seq_=0,this.log_=_e.createLogger({id:"ws|"+this.userId_,userId:this.userId_,sdkAppId:this.sdkAppId_}),this.emitter_=new ki}var t,n;return xe(e,[{key:"urlWithParam_",get:function(){return"".concat(this.url_).concat(this.urlParams)}},{key:"backupUrlWithParam_",get:function(){return"".concat(this.backupUrl_).concat(this.urlParams)}},{key:"isOnline",get:function(){return this.currentState_===oc&&Date.now()-this.lastMessageTime_<12e3}},{key:"connect",value:function(){var i=this;return new Promise(function(r,o){i.log_.info("connect to url: ".concat(i.urlWithParam_)),i.emitConnectionStateChanged(vk),i.socket_=new WebSocket(i.urlWithParam_),i.bindSocket(i.socket_),i.backupTimer_=setTimeout(function(){i.isConnected_||(i.log_.info("trying to connect to backupUrl"),i.tryConnectBackup())},5e3);var c=setTimeout(function(){i.close(),o(new te({code:Z.JOIN_ROOM_FAILED,message:"join room timeout"}))},1e4);i.once(ac,function(){clearTimeout(c),r()}),i.once(om,function(a){clearTimeout(c),o(a)})})}},{key:"tryConnectBackup",value:function(){this.backupSocket_||(this.unbindAndCloseSocket(Qe),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(i){i.onopen=this.onopen.bind(this),i.onclose=this.onclose.bind(this),i.onerror=this.onerror.bind(this),i.onmessage=this.onmessage.bind(this)}},{key:"unbindSocket",value:function(i){i.onopen=function(){},i.onclose=function(){},i.onerror=function(){},i.onmessage=function(){}}},{key:"unbindAndCloseSocket",value:function(i){if(i===Qe){if(this.socket_){this.unbindSocket(this.socket_);try{this.socket_.close(1e3)}catch(r){}this.socket_=null}}else if(this.backupSocket_){this.unbindSocket(this.backupSocket_);try{this.backupSocket_.close(1e3)}catch(r){}this.backupSocket_=null}}},{key:"clearBackupTimer",value:function(){this.backupTimer_!==-1&&(clearTimeout(this.backupTimer_),this.backupTimer_=-1)}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"onopen",value:function(i){if(!this.isConnected_){this.isConnected_=!0,this.isConnecting_=!1,this.isReconnecting_&&Br(this.signalInfo_)&&this.stopReconnection(),this.clearBackupTimer(),i.target===this.socket_?(this.unbindAndCloseSocket(er),this.socketInUse_=this.socket_):(this.unbindAndCloseSocket(Qe),this.socketInUse_=this.backupSocket_);var r=i.target.url;this.log_.info("websocket[".concat(r,"] is connected")),this.currentState_===vk?this.addSignalEvent(sV,"signal channel is connected"):this.currentState_===sm&&this.addSignalEvent(dV,"signal channel reconnect success"),this.emitConnectionStateChanged(oc),this.emitter_.emit(ac)}}},{key:"onclose",value:function(i){var r=i.target.url,o=i.target===this.socketInUse_;if(this.log_.info("websocket[".concat(r," InUse: ").concat(o,"] is closed with code: ").concat(i.code)),o&&(this.isConnected_=!1,this.emitConnectionStateChanged(pl),this.addSignalEvent(oV,"signal channel is disconnected"),!i.wasClean||i.code!==1e3)){this.log_.warn("onclose code:".concat(i.code," reason:").concat(i.reason)),this.log_.warn("close current websocket and schedule a reconnect timeout"),this.socketInUse_.onclose=function(){},this.socketInUse_.close(4011);var c=this.socketInUse_===this.socket_;this.socket_=this.backupSocket_=this.socketInUse_=null,this.reconnect(c?er:Qe)}}},{key:"onerror",value:function(i){var r=i.target.url;if(this.log_.error("websocket[".concat(r,"] error observed")),this.isConnected_){if(i.target===this.socketInUse_){this.isConnected_=!1,this.unbindAndCloseSocket(Qe),this.unbindAndCloseSocket(er);var o=this.socketInUse_===this.socket_;this.socketInUse_=null,this.reconnect(o?er:Qe)}}else this.isReconnecting_||ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Wf,code:Z.UNKNOWN}),i.target==this.socket_?(this.unbindAndCloseSocket(Qe),this.reconnect(er)):(this.unbindAndCloseSocket(er),this.reconnect(Qe));this.isConnecting_=!1,this.isConnected_=!1}},{key:"onmessage",value:function(i){if(this.isConnected_){this.lastMessageTime_=Date.now();var r=JSON.parse(i.data),o=r.cmd,c=r.data,a=Object.values(jr),s=Object.keys(jr)[a.indexOf(o)],l=st[s];switch(kU.includes(o)||(this.log_.debug("received msg: ".concat(i.data)),this.log_.info("Received event: [ ".concat(l||"unknown cmd: "+o," ]"))),o){case jr.CHANNEL_SETUP_RESULT:if(r.code===0)this.signalInfo_.clientIp=c.clientIp,this.signalInfo_.signalIp=c.signalInnerIp,this.signalInfo_.tinyId=r.tinyId,c.svrTime&&function(h){rf=h-new Date().getTime();var S=new Date;S.setTime(h),_e.info("baseTime from server: "+S+" offset: "+rf)}(c.svrTime),this.log_.info("ChannelSetup Success"),ke.logSuccessEvent({userId:this.userId_,eventType:Wf}),this.emitter_.emit(pk,{signalInfo:this.signalInfo_});else{var u=new te({code:Z.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:r.code,message:ae({key:wN,data:{errorCode:r.code,errorMsg:r.message}})});this.log_.error("".concat(r.code,", ").concat(r.message)),this.close(),ke.logFailedEvent({userId:this.userId_,eventType:Wf,error:u}),this.emitter_.emit(mk,u)}break;case jr.JOIN_ROOM_RESULT:r.code===0&&(this.signalInfo_.relayIp=c.relayOuterIp,this.signalInfo_.relayInnerIp=c.relayInnerIp,this.signalInfo_.relayPort=c.relayPort,this.log_.info("signalIp:".concat(this.signalInfo_.signalIp," clientIp:").concat(this.signalInfo_.clientIp," relayIp: ").concat(this.signalInfo_.relayIp))),this.emitter_.emit(l,{data:r});break;case jr.CHANNEL_RECONNECT_RESULT:r.code===0?(this.log_.warn("reconnect success"),this.stopReconnection(),ke.logSuccessEvent({userId:this.userId_,eventType:Mb}),this.client_.syncUserList(),this.client_.checkConnectionsToReconnect()):(this.log_.warn("reconnect failed, ".concat(r.code," ").concat(r.message)),this.client_.reJoin());break;default:this.emitter_.emit(l,{data:r})}}}},{key:"addSignalEvent",value:function(i,r){vn(this.userId_,{eventId:i,eventDesc:r,timestamp:an(),userId:this.userId_,tinyId:this.signalInfo_.tinyId})}},{key:"reconnect",value:(n=H(p().mark(function i(){var r,o,c,a,s=this,l=arguments;return p().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(r=l.length>0&&l[0]!==void 0?l[0]:Qe,!this.isConnecting_&&this.reconnectionTimer_===-1){u.next=4;break}return this.log_.info("signal channel is reconnecting, ignoring current reconnection"),u.abrupt("return");case 4:if(Y.emit(KS,this.client_),!(this.reconnectionCount_>=Gf)){u.next=12;break}return this.log_.warn("SDK has tried reconnect signal channel for ".concat(Gf," times, but all failed. please check your network")),o=new te({code:Z.SIGNAL_CHANNEL_RECONNECTION_FAILED,message:ae({key:xN})}),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Mb,error:o}),this.addSignalEvent(hV,"signal channel reconnect fail"),this.emitter_.emit(om,o),u.abrupt("return");case 12:if(this.isConnecting_=!0,this.reconnectionCount_++,this.currentState_!==sm&&(this.emitConnectionStateChanged(sm),this.addSignalEvent(lV,"signal channel is reconnecting")),this.log_.warn("reconnecting to ".concat(r," signal channel [").concat(this.reconnectionCount_,"/").concat(Gf,"]")),!(this.reconnectionCount_>=3&&this.reconnectionCount_%3==0)){u.next=20;break}return this.log_.warn("re-schedule to get new ws url"),u.next=20,this.reGetSignalChannelUrl();case 20:c=this.getReconnectionUrl(r),r===Qe?(this.socket_=new WebSocket(c),this.bindSocket(this.socket_)):(this.backupSocket_=new WebSocket(c),this.bindSocket(this.backupSocket_)),a=wp(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){s.log_.warn("reconnect ".concat(r," signal channel timeout(").concat(a/1e3,"s), close and try again")),s.isConnecting_=!1,s.clearReconnectionTimer(),s.unbindAndCloseSocket(r),s.reconnect(r===Qe?er:Qe)},a);case 24:case"end":return u.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"reGetSignalChannelUrl",value:(t=H(p().mark(function i(){var r,o,c,a;return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(s.prev=0,!this.client_.getWSProxy()&&!this.client_.getUnifiedProxy()){s.next=3;break}return s.abrupt("return");case 3:return Ti(!0),s.next=6,this.client_.schedule(this.client_.getRoomId());case 6:r=this.client_.getSignalChannelUrl(),o=r.mainUrl,c=r.backupUrl,this.url_=o,this.backupUrl_=c,(a=new URLSearchParams(this.urlParams)).has("signalDomain")&&(a.set("signalDomain",o),this.urlParams=a.toString()),s.next=15;break;case 13:s.prev=13,s.t0=s.catch(0);case 15:case"end":return s.stop()}},i,this,[[0,13]])})),function(){return t.apply(this,arguments)})},{key:"isConnected",value:function(){return this.isConnected_}},{key:"isReconnecting_",get:function(){return this.reconnectionTimer_!==-1}},{key:"getReconnectionUrl",value:function(i){var r=i===Qe?this.urlWithParam_:this.backupUrlWithParam_;if(!Br(this.signalInfo_)&&r.indexOf("&rc=1")===-1){var o=this.client_.getRoomId(),c=this.client_.getUseStringRoomId();r+="&rc=1&relayInnerIp=".concat(this.signalInfo_.relayInnerIp,"&relayOuterIp=").concat(this.signalInfo_.relayIp,"&relayPort=").concat(this.signalInfo_.relayPort,"&roomId=").concat(o,"&useStringRoomId=").concat(c)}return r}},{key:"send",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.isConnected_){var o={cmd:i,data:r,userId:this.userId_,tinyId:this.signalInfo_.tinyId,seq:++this.seq_};return this.socketInUse_.send(JSON.stringify(o)),o.seq}}},{key:"sendWaitForResponse",value:function(i){var r=this,o=i.command,c=i.data,a=i.timeout,s=a===void 0?5e3:a,l=i.responseCommand,u=i.commandDesc,h=i.enableLog,S=h===void 0||h;return new Promise(function(I,E){var x=setTimeout(function(){r.off(l,m);var v=new te({code:Z.API_CALL_TIMEOUT,message:ae({key:IN,data:{commandDesc:u,command:o}})});S&&r.log_.warn(v),E(v)},s),m=function v(w){w.data.seq===T&&(clearTimeout(x),r.off(l,v),I(w))};r.on(l,m);var T=r.send(o,c)})}},{key:"sendWaitForResponseWithRetry",value:function(){var i=this,r=arguments.length<=0?void 0:arguments[0],o=r.commandDesc,c=r.command,a=r.retries,s=a===void 0?0:a,l=r.retryTimeout,u=l===void 0?0:l;return ic({retryFunction:this.sendWaitForResponse,onRetrying:function(h){i.log_.warn("".concat(o||c," timeout observed, retrying [").concat(h,"/").concat(s,"]"))},settings:{retries:s,timeout:u},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.signalInfo_={},this.isConnecting_=!1,this.isConnected_=!1,this.socketInUse_=null,this.unbindAndCloseSocket(Qe),this.unbindAndCloseSocket(er),this.emitConnectionStateChanged(pl)}},{key:"on",value:function(i,r,o){this.emitter_.on(i,r,o)}},{key:"removeListener",value:function(i,r,o){this.emitter_.removeListener(i,r,o)}},{key:"once",value:function(i,r,o){this.emitter_.once(i,r,o)}},{key:"off",value:function(i,r,o){this.emitter_.off(i,r,o)}},{key:"emitConnectionStateChanged",value:function(i){i!==this.currentState_&&(this.emitter_.emit(am,{prevState:this.currentState_,state:i}),this.currentState_=i)}}]),e}(),UV=Le,VV=rn.find,jV=lu,Ak="find",Pk=!0;Ak in[]&&Array(1).find(function(){Pk=!1}),UV({target:"Array",proto:!0,forced:Pk},{find:function(e){return VV(this,e,arguments.length>1?arguments[1]:void 0)}}),jV(Ak);var rr={},Dk={},mm={exports:{}},Ok=mm.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return e.address!=null?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return e.subtype!=null?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return e.sessionConfig!=null?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=e.raddr!=null?" raddr %s rport %d":"%v%v",t+=e.tcptype!=null?" tcptype %s":"%v",e.generation!=null&&(t+=" generation %d"),t+=e["network-id"]!=null?" network-id %d":"%v",t+=e["network-cost"]!=null?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return e.attribute!=null&&(t+=" %s",e.value!=null&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return e.maxMessageSize!=null?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(e.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=e.id!=null?"id=%s %s":"%v%s",t+=e.mediaClockValue!=null?"=%s":"",t+=e.rateNumerator!=null?" rate=%s":"",t+=e.rateDenominator!=null?"/%s":""}},{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(Ok).forEach(function(e){Ok[e].forEach(function(t){t.reg||(t.reg=/(.*)/),t.format||(t.format="%s")})}),function(e){var t=function(c){return String(Number(c))===c?Number(c):c},n=function(c,a,s){var l=c.name&&c.names;c.push&&!a[c.push]?a[c.push]=[]:l&&!a[c.name]&&(a[c.name]={});var u=c.push?{}:l?a[c.name]:a;(function(h,S,I,E){if(E&&!I)S[E]=t(h[1]);else for(var x=0;x<I.length;x+=1)h[x+1]!=null&&(S[I[x]]=t(h[x+1]))})(s.match(c.reg),u,c.names,c.name),c.push&&a[c.push].push(u)},i=mm.exports,r=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(c){var a={},s=[],l=a;return c.split(/(\r\n|\r|\n)/).filter(r).forEach(function(u){var h=u[0],S=u.slice(2);h==="m"&&(s.push({rtp:[],fmtp:[]}),l=s[s.length-1]);for(var I=0;I<(i[h]||[]).length;I+=1){var E=i[h][I];if(E.reg.test(S))return n(E,l,S)}}),a.media=s,a};var o=function(c,a){var s=a.split(/=(.+)/,2);return s.length===2?c[s[0]]=t(s[1]):s.length===1&&a.length>1&&(c[s[0]]=void 0),c};e.parseParams=function(c){return c.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(c){return c.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(c){for(var a=[],s=c.split(" ").map(t),l=0;l<s.length;l+=3)a.push({component:s[l],ip:s[l+1],port:s[l+2]});return a},e.parseImageAttributes=function(c){return c.split(" ").map(function(a){return a.substring(1,a.length-1).split(",").reduce(o,{})})},e.parseSimulcastStreamList=function(c){return c.split(";").map(function(a){return a.split(",").map(function(s){var l,u=!1;return s[0]!=="~"?l=t(s):(l=t(s.substring(1,s.length)),u=!0),{scid:l,paused:u}})})}}(Dk);var vm=mm.exports,BV=/%[sdv%]/g,FV=function(e){var t=1,n=arguments,i=n.length;return e.replace(BV,function(r){if(t>=i)return r;var o=n[t];switch(t+=1,r){case"%%":return"%";case"%s":return String(o);case"%d":return Number(o);case"%v":return""}})},uc=function(e,t,n){var i=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var r=0;r<t.names.length;r+=1){var o=t.names[r];t.name?i.push(n[t.name][o]):i.push(n[t.names[r]])}else i.push(n[t.name]);return FV.apply(null,i)},HV=["v","o","s","i","u","e","p","c","b","t","r","z","a"],GV=["i","c","b","a"],ua=Dk,WV=function(e,t){t=t||{},e.version==null&&(e.version=0),e.name==null&&(e.name=" "),e.media.forEach(function(o){o.payloads==null&&(o.payloads="")});var n=t.outerOrder||HV,i=t.innerOrder||GV,r=[];return n.forEach(function(o){vm[o].forEach(function(c){c.name in e&&e[c.name]!=null?r.push(uc(o,c,e)):c.push in e&&e[c.push]!=null&&e[c.push].forEach(function(a){r.push(uc(o,c,a))})})}),e.media.forEach(function(o){r.push(uc("m",vm.m[0],o)),i.forEach(function(c){vm[c].forEach(function(a){a.name in o&&o[a.name]!=null?r.push(uc(c,a,o)):a.push in o&&o[a.push]!=null&&o[a.push].forEach(function(s){r.push(uc(c,a,s))})})})}),r.join(`\r
53
+ `+a.stack)}},e},zS=function(e){return+e<10?"0".concat(e):e},P4=function(e){var t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;var n=t.split("."),i=zS(n[1])+zS(n[2]);return n[1]-15>0&&(n[1]="15"),n[2]-15>0&&(n[2]="15"),n.join(".")+"."+i};function fo(e,t){try{if(ho(e))return"[".concat(e.map(function(r){return fo(r,t)}).join(","),"]");if(!bi(e)||!ho(t))return JSON.stringify(e);var n={},i=new Set(t);return Object.keys(e).forEach(function(r){i.has(r)&&(n[r]=e[r])}),JSON.stringify(n)}catch(r){return"{}"}}function cl(e){var t=e.url,n=e.body,i=e.method,r=e.timeout,o=new XMLHttpRequest;return new Promise(function(c,a){o.onload=function(l){if(o.status>=200&&o.status<300&&o.responseText.length>0)try{var u=JSON.parse(o.response);c({data:u})}catch(h){c({data:o.response})}else o.status>0&&a({code:o.status,message:"request failed, readyState:".concat(o.readyState," status:").concat(o.status," loaded size:").concat(l.loaded)})};var s=function(l){a({code:o.readyState,message:"request ".concat(l.type,", readyState:").concat(o.readyState," status:").concat(o.status," loaded size:").concat(l.loaded)})};o.onerror=s,o.onabort=s,o.ontimeout=s,o.timeout=r||5e3,o.open(i||"POST",t,!0),o.send(n)})}var WS={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,n="~";function i(){}function r(s,l,u){this.fn=s,this.context=l,this.once=u||!1}function o(s,l,u,h,b){if(typeof u!="function")throw new TypeError("The listener must be a function");var I=new r(u,h||s,b),R=n?n+l:l;return s._events[R]?s._events[R].fn?s._events[R]=[s._events[R],I]:s._events[R].push(I):(s._events[R]=I,s._eventsCount++),s}function c(s,l){--s._eventsCount==0?s._events=new i:delete s._events[l]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(n=!1)),a.prototype.eventNames=function(){var s,l,u=[];if(this._eventsCount===0)return u;for(l in s=this._events)t.call(s,l)&&u.push(n?l.slice(1):l);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(s)):u},a.prototype.listeners=function(s){var l=n?n+s:s,u=this._events[l];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,b=u.length,I=new Array(b);h<b;h++)I[h]=u[h].fn;return I},a.prototype.listenerCount=function(s){var l=n?n+s:s,u=this._events[l];return u?u.fn?1:u.length:0},a.prototype.emit=function(s,l,u,h,b,I){var R=n?n+s:s;if(!this._events[R])return!1;var x,m,k=this._events[R],v=arguments.length;if(k.fn){switch(k.once&&this.removeListener(s,k.fn,void 0,!0),v){case 1:return k.fn.call(k.context),!0;case 2:return k.fn.call(k.context,l),!0;case 3:return k.fn.call(k.context,l,u),!0;case 4:return k.fn.call(k.context,l,u,h),!0;case 5:return k.fn.call(k.context,l,u,h,b),!0;case 6:return k.fn.call(k.context,l,u,h,b,I),!0}for(m=1,x=new Array(v-1);m<v;m++)x[m-1]=arguments[m];k.fn.apply(k.context,x)}else{var w,L=k.length;for(m=0;m<L;m++)switch(k[m].once&&this.removeListener(s,k[m].fn,void 0,!0),v){case 1:k[m].fn.call(k[m].context);break;case 2:k[m].fn.call(k[m].context,l);break;case 3:k[m].fn.call(k[m].context,l,u);break;case 4:k[m].fn.call(k[m].context,l,u,h);break;default:if(!x)for(w=1,x=new Array(v-1);w<v;w++)x[w-1]=arguments[w];k[m].fn.apply(k[m].context,x)}}return!0},a.prototype.on=function(s,l,u){return o(this,s,l,u,!1)},a.prototype.once=function(s,l,u){return o(this,s,l,u,!0)},a.prototype.removeListener=function(s,l,u,h){var b=n?n+s:s;if(!this._events[b])return this;if(!l)return c(this,b),this;var I=this._events[b];if(I.fn)I.fn!==l||h&&!I.once||u&&I.context!==u||c(this,b);else{for(var R=0,x=[],m=I.length;R<m;R++)(I[R].fn!==l||h&&!I[R].once||u&&I[R].context!==u)&&x.push(I[R]);x.length?this._events[b]=x.length===1?x[0]:x:c(this,b)}return this},a.prototype.removeAllListeners=function(s){var l;return s?(l=n?n+s:s,this._events[l]&&c(this,l)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a})(WS);var ki=WS.exports,Y=new ki,ul=1,Ep=2,Rp=3,po=4,sa=5,Ap=20,Pp=21,mo=22,Dp=23,Op=24,Lp=27,Mp=28,ll=29,JS=30,qS=31,Np=32,Up=33,KS=40,D4=41,O4=52,L4=100,XS=101,tc=102,Vp=103,jn=110,dl=111,jp=112,Ur=113,Vr=114,M4=115,ca=116,N4=120,Bp=121,Fp=122,Hp=123,nc=130,Gp=131,zp=132,Wp=133,Jp=134,qp=135,Kp=136,Xp=137,hl=200,Qp=201,Yp=300,rc=301,$p=302,Zp=303;function ic(e){var t=e.retryFunction,n=e.settings,i=e.onError,r=e.onRetrying,o=e.onRetryFailed,c=e.onRetrySuccess,a=e.context;return function(){for(var s=this,l=arguments.length,u=new Array(l),h=0;h<l;h++)u[h]=arguments[h];var b=n.retries||5,I=0,R=-1,x=0,m=function(){var k=H(f().mark(function v(w,L){var E,N,T,y;return f().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:return E=a||s,D.prev=1,D.next=4,t.apply(E,u);case 4:N=D.sent,I!==0&&ln(c)&&c.call(E,I),I=0,w(N),D.next=15;break;case 10:D.prev=10,D.t0=D.catch(1),T=function(){clearTimeout(R),I=0,x=2,L(D.t0)},y=function(){x!==2&&I<b?(I++,x=1,ln(r)&&r.call(E,I,T),R=setTimeout(function(){R=-1,m(w,L)},ge(n.timeout)?1e3:n.timeout)):(T(),ln(o)&&o.call(E,D.t0))},ln(i)?i.call(E,D.t0,y,L,u,I):y();case 15:case"end":return D.stop()}},v,null,[[1,10]])}));return function(v,w){return k.apply(this,arguments)}}();return new Promise(m)}}var U4=xe(function e(t){Q(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}),V4=function(){function e(t){Q(this,e),this.id_=t.id,this.userId_=t.userId,this.sdkAppId_=t.sdkAppId,this.type_=t.type,this.isLocal_=!nr(t.isLocal)||t.isLocal}return xe(e,[{key:"setUserId",value:function(t){this.userId_=t}},{key:"setSdkAppId",value:function(t){this.sdkAppId_=t}},{key:"log",value:function(t,n){_e.log({log:"[".concat(this.isLocal_?"\u2191":"\u2193").concat(this.id_,"] ").concat(this.type_?this.type_+" ":"").concat(n),level:t,forAllJoinedClients:ge(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_})}},{key:"info",value:function(t){this.log(Un.INFO,t)}},{key:"debug",value:function(t){this.log(Un.DEBUG,t)}},{key:"warn",value:function(t){this.log(Un.WARN,t)}},{key:"error",value:function(t){this.log(Un.ERROR,t)}}]),e}(),j4=!(_i||ta),B4=function(){function e(){var i=this;Q(this,e),this.clients_=new Set,this.queue_=[],this.timeoutId_=-1,this.logLevel_=Un.DEBUG,this.logLevelToUpload_=Un.INFO,this.enableUploadLog_=!0,this.isAbleToUpload_=!1,this.checkURLParam(),Y.on(JS,function(r){var o=r.client;i.timeoutId_===-1&&i.startUpload(),i.clients_.add(o)}),Y.on(Up,function(r){var o=r.client;return i.clients_.delete(o)}),Y.on(qS,function(r){r&&bi(r.config)&&ea[r.config.logLevelToUpload]&&(i.logLevelToUpload_=r.config.logLevelToUpload)}),Y.on(po,this.setIsAbleToUpload,this),Y.on(sa,this.setIsAbleToUpload,this)}var t,n;return xe(e,[{key:"getIsAbleToUpload",value:function(){return this.isAbleToUpload_}},{key:"setIsAbleToUpload",value:function(){this.isAbleToUpload_=!0,Y.off(po,this.setIsAbleToUpload,this),Y.off(sa,this.setIsAbleToUpload,this)}},{key:"startUpload",value:(n=H(f().mark(function i(){var r=this;return f().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,o.next=3,this.upload();case 3:o.next=7;break;case 5:o.prev=5,o.t0=o.catch(0);case 7:this.timeoutId_=setTimeout(function(){return r.startUpload()},2e3);case 8:case"end":return o.stop()}},i,this,[[0,5]])})),function(){return n.apply(this,arguments)})},{key:"getLogsToUpload",value:function(){var i=this,r={map:new Map,splicedQueue:[]};if(this.queue_[0].forAllJoinedClients&&this.clients_.size===0)return r;for(var o=0,c=function(){if(o===50)return"break";var a=i.queue_[o];if(a.forAllJoinedClients){var s=new Set;i.clients_.forEach(function(l){if(l.getIsJoined()){var u=l.getUserId(),h=l.getSDKAppId();s.has("".concat(u,"-").concat(h))||(s.add("".concat(u,"-").concat(h)),r.map.has(u)?r.map.get(u).logs.push(a):r.map.set(u,{userId:u,sdkAppId:h,logs:[a]}))}})}else r.map.has(a.userId)?r.map.get(a.userId).logs.push(a):r.map.set(a.userId,{userId:a.userId,sdkAppId:a.sdkAppId,logs:[a]})};o<this.queue_.length&&c()!=="break";o++);return r.map.size>0&&(r.splicedQueue=this.queue_.splice(0,o)),r}},{key:"upload",value:(t=H(f().mark(function i(){var r,o,c,a,s,l,u,h,b,I;return f().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:if(this.queue_.length!==0&&this.isAbleToUpload_){R.next=2;break}return R.abrupt("return");case 2:if(r=this.getLogsToUpload(),o=r.map,c=r.splicedQueue,o.size!==0){R.next=5;break}return R.abrupt("return");case 5:R.prev=5,a=Se(o.values()),s=0;case 8:if(!(s<a.length)){R.next=16;break}return l=a[s],u=l.userId,h=l.sdkAppId,b=l.logs,R.next=12,this.uploadLogWithRetry(JSON.stringify({timestamp:qy(),sdkAppId:String(h),userId:u,version:oi,log:b.map(function(x){return x.log}).join(`
54
+ `)}),h);case 12:b.forEach(function(x){return x.uploaded=!0});case 13:s++,R.next=8;break;case 16:R.next=20;break;case 18:R.prev=18,R.t0=R.catch(5);case 20:I=c.filter(function(x){return!x.uploaded}),I.length>0&&(this.queue_=I.concat(this.queue_));case 22:case"end":return R.stop()}},i,this,[[5,18]])})),function(){return t.apply(this,arguments)})},{key:"uploadLogWithRetry",value:function(i,r){return ic({retryFunction:function(){return cl({url:ol(r,yb),body:i,timeout:5e3})},settings:{retries:3,timeout:1e3},onError:function(o,c){c()}})()}},{key:"getPrefix",value:function(i){var r=new Date;return r.setTime(an()),String.prototype.padStart?"[".concat(r.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(r.getMilliseconds().toString().padStart(3,"0"),"] <").concat(ea[i],">"):"[".concat(r.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(r.getMilliseconds(),"] <").concat(ea[i],">")}},{key:"getLogLevel",value:function(){return this.logLevel_}},{key:"setLogLevel",value:function(i){ge(ea[i])||(this.logLevel_!==i&&this.info("setLogLevel ".concat(i)),this.logLevel_=i)}},{key:"enableUploadLog",value:function(){this.enableUploadLog_=!0}},{key:"disableUploadLog",value:function(){this.enableUploadLog_=!1}},{key:"log",value:function(i){var r=i.log,o=i.level,c=i.forAllJoinedClients,a=c===void 0||c,s=i.userId,l=i.sdkAppId;if(r="".concat(this.getPrefix(o)," ").concat(r),this.enableUploadLog_&&o>=this.logLevelToUpload_&&this.queue_.push(new U4({log:r,level:o,userId:s,sdkAppId:l,forAllJoinedClients:a})),!(o<this.logLevel_)){var u=ea[o]?ea[o].toLowerCase():"info";j4?console[u]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",r):console[u](r)}}},{key:"debug",value:function(i){this.log({log:i,level:Un.DEBUG})}},{key:"info",value:function(i){this.log({log:i,level:Un.INFO})}},{key:"warn",value:function(i){this.log({log:i,level:Un.WARN})}},{key:"error",value:function(i){this.log({log:i,level:Un.ERROR})}},{key:"createLogger",value:function(i){return new V4(i)}},{key:"checkURLParam",value:function(){var i=new URLSearchParams(location.search).get("logLevelToUpload");ea[i]&&(this.logLevelToUpload_=i)}}]),e}(),_e=new B4,QS=!0,F4=at,H4=Math.floor,YS=Number.isInteger||function(e){return!F4(e)&&isFinite(e)&&H4(e)===e};Le({target:"Number",stat:!0},{isInteger:YS});var em,G4=Le,$S=pe,z4=be.f,W4=yr,ZS=zt,J4=p0,q4=pt,K4=m0,ek=$S("".startsWith),X4=$S("".slice),Q4=Math.min,tk=K4("startsWith");G4({target:"String",proto:!0,forced:!!(tk||(em=z4(String.prototype,"startsWith"),!em||em.writable))&&!tk},{startsWith:function(e){var t=ZS(q4(this));J4(e);var n=W4(Q4(arguments.length>1?arguments[1]:void 0,t.length)),i=ZS(e);return ek?ek(t,i,n):X4(t,n,n+i.length)===i}});var nk=ye,Y4=pe,$4=qe,Z4=se,tm=ou,eU=Jd,tU=qt,nU=Mt,rU=yn,vo=Object.assign,rk=Object.defineProperty,iU=Y4([].concat),ik=!vo||Z4(function(){if(nk&&vo({b:1},vo(rk({},"a",{enumerable:!0,get:function(){rk(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var e={},t={},n=Symbol(),i="abcdefghijklmnopqrst";return e[n]=7,i.split("").forEach(function(r){t[r]=r}),vo({},e)[n]!=7||tm(vo({},t)).join("")!=i})?function(e,t){for(var n=nU(e),i=arguments.length,r=1,o=eU.f,c=tU.f;i>r;)for(var a,s=rU(arguments[r++]),l=o?iU(tm(s),o(s)):tm(s),u=l.length,h=0;u>h;)a=l[h++],nk&&!$4(c,s,a)||(n[a]=s[a]);return n}:vo,ak=ik;Le({target:"Object",stat:!0,arity:2,forced:Object.assign!==ak},{assign:ak});var ok=pe,aU=Vt,oU=at,sU=kt,sk=Ha,cU=Me,ck=Function,uU=ok([].concat),lU=ok([].join),nm={},dU=function(e,t,n){if(!sU(nm,t)){for(var i=[],r=0;r<t;r++)i[r]="a["+r+"]";nm[t]=ck("C,a","return new C("+lU(i,",")+")")}return nm[t](e,n)},hU=cU?ck.bind:function(e){var t=aU(this),n=t.prototype,i=sk(arguments,1),r=function(){var o=uU(i,sk(arguments));return this instanceof r?dU(t,o.length,o):t.apply(e,o)};return oU(n)&&(r.prototype=n),r},uk=hU;Le({target:"Function",proto:!0,forced:Function.bind!==uk},{bind:uk});var fU=Le,pU=rn.findIndex,mU=uu,lk="findIndex",dk=!0;lk in[]&&Array(1).findIndex(function(){dk=!1}),fU({target:"Array",proto:!0,forced:dk},{findIndex:function(e){return pU(this,e,arguments.length>1?arguments[1]:void 0)}}),mU(lk);var vU=ye,hk=pe,gU=ou,_U=bn,yU=hk(qt.f),bU=hk([].push),fk=function(e){return function(t){for(var n,i=_U(t),r=gU(i),o=r.length,c=0,a=[];o>c;)n=r[c++],vU&&!yU(i,n)||bU(a,e?[n,i[n]]:i[n]);return a}},SU={entries:fk(!0),values:fk(!1)}.values;Le({target:"Object",stat:!0},{values:function(e){return SU(e)}});var pk=1,mk=5,rm=2,ac=3,im=4,fl="DISCONNECTED",vk="CONNECTING",am="RECONNECTING",oc="CONNECTED",jr={CLIENT_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,PUBLISH_STATE_CHANGE_RESULT:4112,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,UPDATE_CONSTRAINT_CONFIG_RES:772,CONNECT_OTHER_ROOM_RES:8209,DISCONNECT_OTHER_ROOM_RES:8211,UPDATE_OTHER_ROOM_FORWARD_MODE_RES:8213},kU=[jr.UPDATE_REMOTE_MUTE_STAT,jr.UPLINK_NETWORK_STATS,jr.USER_LIST_RES,jr.MUTE_RESULT],st={CLIENT_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",PUBLISH_STATE_CHANGE_RESULT:"publish-state-change-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",UPDATE_CONSTRAINT_CONFIG_RES:"update-contraint-config-res",CONNECT_OTHER_ROOM_RES:"connect_other_room_res",UPDATE_OTHER_ROOM_FORWARD_MODE_RES:"update_other_room_forward_mode_res",DISCONNECT_OTHER_ROOM_RES:"disconnect_other_room_res"},TU="publish_change",IU="publish_state_change",xU="join",wU="leave",CU="quality_report",EU="mute_uplink",RU="publish",gk="unpublish",AU="subscribe",PU="unsubscribe",DU="subscribe_change",OU="start_publishing",LU="stop_publishing",MU="start_push_user_cdn",NU="stop_push_user_cdn",UU="start_mcu_mix",VU="stop_mcu_mix",jU="get_user_list",BU="change_role",FU="update_constraint_config",HU="connect_other_room",GU="update_other_room_forward_mode",zU="disconnect_other_room",Z={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,API_CALL_ABORTED:16461,UNKNOWN:65535},te=function(e){Et(n,e);var t=Rr(n);function n(i){var r,o=i.name,c=o===void 0?"RtcError":o,a=i.message,s=i.code,l=s===void 0?Z.UNKNOWN:s,u=i.extraCode,h=u===void 0?0:u,b=i.constraint;Q(this,n);var I="<".concat(function(R){for(var x in Z)if(Z[x]===R)return x;return"UNKNOWN"}(l)," 0x").concat(l.toString(16),">");return(r=t.call(this,a+"".concat(b?" constraint: ".concat(b):"")+"".concat(a!=null&&a.includes(I)?"":" "+I))).code_=l,r.extraCode_=h,r.name=c,r.message_=a,b&&(r.constraint=b),r}return xe(n,[{key:"getCode",value:function(){return this.code_}},{key:"getExtraCode",value:function(){return this.extraCode_}}]),n}(Wo(Error)),_k=32768,yk=32769,bk=32770,Sk=32771,WU=32772,JU=32773,qU=32774,KU=32775,kk=32777,XU=32778,om=32779,QU=32780,YU=32781,$U=32782,ZU=32783,eV=32784,tV=32785,nV=32786,rV=32787,iV=32788,aV=32789,oV=32790,sV=32791,cV=32792,uV=32793,lV=32794,dV=32795,hV=32796,fV=32797,pV=32798,mV=32799,vV=32800,gV=32801,_V=32802,yV=32803,bV=32804,sc=new Map,vn=function(e,t){var n=sc.get(e);n||(sc.set(e,[]),n=sc.get(e)),n.push(t)},SV=function(e){var t=sc.get(e),n=[];return t?(sc.delete(e),n=t.map(function(i){return{uint32_event_id:i.eventId,uint64_date:i.timestamp,str_userid:i.remoteUserId,str_event_json:i.eventDesc}})):n=[],n},kV=Object.prototype.hasOwnProperty;function Br(e){if(e==null)return!0;if(typeof e=="boolean")return!1;if(typeof e=="number")return e===0;if(typeof e=="string"||typeof e=="function"||Array.isArray(e))return e.length===0;if(e instanceof Error)return e.message==="";if(bi(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return e.size===0;case"[object Object]":for(var t in e)if(kV.call(e,t))return!1;return!0}return!1}var TV=function(){function e(){Q(this,e);var t=aa(),n=t.name,i=t.version;this.roomIdMap_=new Map,this.configs_={sdkAppId:"",userId:"",version:oi,env:Gu,browserVersion:n+i,ua:navigator.userAgent}}return xe(e,[{key:"setConfig",value:function(t){var n=t.sdkAppId,i=t.env,r=t.userId,o=t.roomId;n!==this.configs_.sdkAppId&&(this.configs_.sdkAppId=String(n)),this.configs_.env=i,this.configs_.userId=r,this.roomIdMap_.set(r,String(o))}},{key:"logEvent",value:function(t){if(!ra){var n=J(J(J({},t),this.configs_),{},{userId:t.userId||this.configs_.userId});ge(n.code)&&(n.code=n.result==="failed"?Z.UNKNOWN:0),this.sendRequest(ol(this.configs_.sdkAppId,JM),n)}}},{key:"logSuccessEvent",value:function(t){ra||(this.logEvent(J(J({},t),{},{result:"success",roomId:this.roomIdMap_.get(t.userId)})),this.configs_.env===Gu&&this.uploadEventToKibana(J(J({},t),{},{result:"success"})))}},{key:"logFailedEvent",value:function(t){if(!ra){var n=t.eventType,i=t.code,r=t.error,o=t.userId,c={roomId:this.roomIdMap_.get(o),userId:o,eventType:n,result:"failed",code:i||(r instanceof te?r.getExtraCode()||r.getCode():Z.UNKNOWN)};this.logEvent(c),this.configs_.env===Gu&&this.uploadEventToKibana(J(J({},c),{},{error:r}))}}},{key:"uploadEventToKibana",value:function(t){var n="stat-".concat(t.eventType,"-").concat(t.result);t.eventType!=="delta-join"&&t.eventType!=="delta-leave"&&t.eventType!=="delta-publish"||(n="".concat(t.eventType,":").concat(t.delta)),this.uploadEvent({log:n,userId:t.userId}),t.result==="failed"&&(n="stat-".concat(t.eventType,"-").concat(t.result,"-").concat(t.code),this.uploadEvent({log:n,userId:t.userId,error:t.error}))}},{key:"uploadEvent",value:function(t){var n=t.log,i=t.userId,r=t.error,o={timestamp:qy(),sdkAppId:this.configs_.sdkAppId,userId:i||this.configs_.userId,version:this.configs_.version,log:n};r&&(o.errorInfo=r.message),this.sendRequest(ol(this.configs_.sdkAppId,yb),o)}},{key:"sendRequest",value:function(t,n){var i=this;_e.getIsAbleToUpload()?cl({url:t,body:JSON.stringify(n)}).catch(function(){}):setTimeout(function(){i.sendRequest(t,n)},1e3)}}]),e}(),ke=new TV,IV=Mt,xV=ji;Le({target:"Date",proto:!0,arity:1,forced:se(function(){return new Date(NaN).toJSON()!==null||Date.prototype.toJSON.call({toISOString:function(){return 1}})!==1})},{toJSON:function(e){var t=IV(this),n=xV(t,"number");return typeof n!="number"||isFinite(n)?t.toISOString():null}});var wV=qe;Le({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return wV(URL.prototype.toString,this)}});var CV=Le,sm=pe,EV=$n,RV=o0,AV=ey,Tk=se,PV=RangeError,Ik=String,xk=Math.floor,cm=sm(AV),wk=sm("".slice),cc=sm(1 .toFixed),go=function(e,t,n){return t===0?n:t%2==1?go(e,t-1,n*e):go(e*e,t/2,n)},_o=function(e,t,n){for(var i=-1,r=n;++i<6;)r+=t*e[i],e[i]=r%1e7,r=xk(r/1e7)},um=function(e,t){for(var n=6,i=0;--n>=0;)i+=e[n],e[n]=xk(i/t),i=i%t*1e7},Ck=function(e){for(var t=6,n="";--t>=0;)if(n!==""||t===0||e[t]!==0){var i=Ik(e[t]);n=n===""?i:n+cm("0",7-i.length)+i}return n};CV({target:"Number",proto:!0,forced:Tk(function(){return cc(8e-5,3)!=="0.000"||cc(.9,0)!=="1"||cc(1.255,2)!=="1.25"||cc(0xde0b6b3a7640080,0)!=="1000000000000000128"})||!Tk(function(){cc({})})},{toFixed:function(e){var t,n,i,r,o=RV(this),c=EV(e),a=[0,0,0,0,0,0],s="",l="0";if(c<0||c>20)throw PV("Incorrect fraction digits");if(o!=o)return"NaN";if(o<=-1e21||o>=1e21)return Ik(o);if(o<0&&(s="-",o=-o),o>1e-21)if(n=(t=function(u){for(var h=0,b=u;b>=4096;)h+=12,b/=4096;for(;b>=2;)h+=1,b/=2;return h}(o*go(2,69,1))-69)<0?o*go(2,-t,1):o/go(2,t,1),n*=4503599627370496,(t=52-t)>0){for(_o(a,0,n),i=c;i>=7;)_o(a,1e7,0),i-=7;for(_o(a,go(10,i,1),0),i=t-1;i>=23;)um(a,1<<23),i-=23;um(a,1<<i),_o(a,1,1),um(a,2),l=Ck(a)}else _o(a,0,n),_o(a,1<<-t,0),l=Ck(a)+cm("0",c);return l=c>0?s+((r=l.length)<=c?"0."+cm("0",c-r)+l:wk(l,0,r-c)+"."+wk(l,r-c)):s+l}});var lm=null,dm=!0;function Ti(e){nr(e)&&e!==dm&&(dm=e,_e.info("setIsNeedToSchedule "+e))}function DV(e,t){try{if(PerformanceObserver){var n=Ct(),i=pl(e,Xe),r=pl(e,er),o=new PerformanceObserver(function(c){c.getEntries().forEach(function(a){if(a.startTime>=n&&(a.name===i||a.name===r)){var s=a.name===i?Xe:er;if(a.code&&a.code!==200)return void _e.warn("".concat(s," schedule with code ").concat(a.code,", ").concat(JSON.stringify(a.toJSON())));var l=a.responseEnd-a.startTime,u=[a.domainLookupStart-a.startTime,a.domainLookupEnd-a.domainLookupStart,a.requestStart-a.secureConnectionStart,a.secureConnectionStart-a.connectStart,a.responseStart-a.requestStart,a.responseEnd-a.responseStart].map(function(h){return h.toFixed(1)});o.disconnect(),ke.uploadEvent({log:"stat-schedule-net:".concat(l.toFixed(1),"(").concat(u.join("->"),") ").concat(s),userId:t})}})});o.observe({type:"resource",buffered:!0})}}catch(c){}}function OV(e){return hm.apply(this,arguments)}function hm(){return hm=H(f().mark(function e(t){var n,i,r,o,c,a,s,l,u,h,b,I,R;return f().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(n=t.userId,i=t.sdkAppId,r=t.useStringRoomId,o=t.roomId,c=t.userSig,dm||!lm){x.next=3;break}return x.abrupt("return",{isCached:!0,result:lm});case 3:return a={delta:0,count:[1,1],msg:[]},x.prev=4,(s=new FormData).append("userId",String(n)),s.append("sdkAppId",String(i)),s.append("isStrGroupId",r),s.append("groupId",String(o)),s.append("sdkVersion",oi),s.append("userSig",String(c)),Kf&&s.append("oversea",!0),DV(i,n),l=Ct(),x.next=17,MV(s,a,i);case 17:return(u=x.sent).config&&(u.config.loggerDomain&&Uf(u.config.loggerDomain),nr(u.config.scheduleCache)&&Ti(!u.config.scheduleCache)),a.delta=Ct()-l,Ek({stat:a,userId:n}),lm=u,x.abrupt("return",{isCached:!1,result:u});case 25:throw x.prev=25,x.t0=x.catch(4),h=ho(x.t0)?x.t0[0]:x.t0,b=tr(h.code)?h.code:0,I="schedule failed".concat(h.message?": ".concat(h.message):""),R=new te({code:Z.SCHEDULE_FAILED,extraCode:b,message:ie({key:uS,data:{error:I,code:b}})}),_e.error(R),Ek({stat:a,userId:n,roomId:o,error:R}),R;case 34:case"end":return x.stop()}},e,null,[[4,25]])})),hm.apply(this,arguments)}function Ek(e){var t=e.stat,n=e.userId,i=e.error;i?ke.logFailedEvent({eventType:Fb,error:i,userId:n}):ke.logSuccessEvent({eventType:Fb,delta:t.delta,userId:n}),ke.uploadEvent({log:"stat-schedule:"+JSON.stringify(t),userId:n})}function pl(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Xe;return t=Kf||(NS(e)?n===Xe?sN:cN:n===Xe?aN:oN),"https://".concat(t,"/api/v1/config")}function LV(e,t,n){return new Promise(function(i,r){cl({url:e,body:t,timeout:n.timeout}).then(function(o){o.data.code===0?i(o.data.data):r({code:o.data.code,message:o.data.msg})}).catch(r)})}Y.on(sa,function(){return Ti(!0)}),Y.on(D4,function(){return Ti(!0)}),Y.on(O4,function(){return Ti(!0)}),Y.on(KS,function(){return Ti(!0)}),Y.on(hl,function(e){e.state===jf&&Ti(!0)});var Rk=function(e,t){return ic({retryFunction:LV,settings:{retries:3,timeout:0},onError:t,onRetrying:e})};function MV(e,t,n){return new Promise(function(i,r){var o,c=null;(o=[Rk(function(a){return t.count[0]=a+1},function(a,s){t.msg[0]=a.message,c||s()})(pl(n,Xe),e,{get timeout(){return 1e3*sl(2+t.count[0])}}),Rk(function(a){return t.count[1]=a+1},function(a,s){t.msg[1]=a.message,c||s()})(pl(n,er),e,{get timeout(){return 1e3*sl(2+t.count[1])}})],new Promise(function(a,s){var l=[];o.forEach(function(u){u.then(a).catch(function(h){l.push(h),l.length===o.length&&s(l)})})})).then(function(a){i(c=a)}).catch(r)})}var NV=function(){function e(i){Q(this,e),this.client_=i.client,this.sdkAppId_=i.sdkAppId,this.userId_=i.userId,this.userSig_=i.userSig,this.url_=i.url,this.backupUrl_=i.backupUrl;var r="?sdkAppId=".concat(encodeURIComponent(this.sdkAppId_),"&userId=").concat(encodeURIComponent(this.userId_),"&userSig=").concat(encodeURIComponent(this.userSig_),"&roomId=").concat(encodeURIComponent(i.roomId)),o=this.client_.getSystemResult();if(o&&o.detail){var c=o.detail,a=c.isH264EncodeSupported,s=c.isVp8EncodeSupported,l=c.isH264DecodeSupported,u=c.isVp8DecodeSupported;r+="&enc264=".concat(Number(a),"&dec264=").concat(Number(l),"&encVp8=").concat(Number(s),"&decVp8=").concat(Number(u))}i.signalDomainWhenUnifiedProxy&&(r+="&signalDomain=".concat(encodeURIComponent(i.signalDomainWhenUnifiedProxy))),this.urlParams=r,this.isConnected_=!1,this.isConnecting_=!1,this.socketInUse_=null,this.socket_=null,this.backupSocket_=null,this.backupTimer_=-1,this.signalInfo_={},this.currentState_=fl,this.reconnectionCount_=0,this.reconnectionTimer_=-1,this.lastMessageTime_=-1,this.seq_=0,this.log_=_e.createLogger({id:"ws|"+this.userId_,userId:this.userId_,sdkAppId:this.sdkAppId_}),this.emitter_=new ki}var t,n;return xe(e,[{key:"urlWithParam_",get:function(){return"".concat(this.url_).concat(this.urlParams)}},{key:"backupUrlWithParam_",get:function(){return"".concat(this.backupUrl_).concat(this.urlParams)}},{key:"isOnline",get:function(){return this.currentState_===oc&&Date.now()-this.lastMessageTime_<12e3}},{key:"connect",value:function(){var i=this;return new Promise(function(r,o){i.log_.info("connect to url: ".concat(i.urlWithParam_)),i.emitConnectionStateChanged(vk),i.socket_=new WebSocket(i.urlWithParam_),i.bindSocket(i.socket_),i.backupTimer_=setTimeout(function(){i.isConnected_||(i.log_.info("trying to connect to backupUrl"),i.tryConnectBackup())},5e3);var c=setTimeout(function(){i.close(),o(new te({code:Z.JOIN_ROOM_FAILED,message:"join room timeout"}))},1e4);i.once(ac,function(){clearTimeout(c),r()}),i.once(im,function(a){clearTimeout(c),o(a)})})}},{key:"tryConnectBackup",value:function(){this.backupSocket_||(this.unbindAndCloseSocket(Xe),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(i){i.onopen=this.onopen.bind(this),i.onclose=this.onclose.bind(this),i.onerror=this.onerror.bind(this),i.onmessage=this.onmessage.bind(this)}},{key:"unbindSocket",value:function(i){i.onopen=function(){},i.onclose=function(){},i.onerror=function(){},i.onmessage=function(){}}},{key:"unbindAndCloseSocket",value:function(i){if(i===Xe){if(this.socket_){this.unbindSocket(this.socket_);try{this.socket_.close(1e3)}catch(r){}this.socket_=null}}else if(this.backupSocket_){this.unbindSocket(this.backupSocket_);try{this.backupSocket_.close(1e3)}catch(r){}this.backupSocket_=null}}},{key:"clearBackupTimer",value:function(){this.backupTimer_!==-1&&(clearTimeout(this.backupTimer_),this.backupTimer_=-1)}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"onopen",value:function(i){if(!this.isConnected_){this.isConnected_=!0,this.isConnecting_=!1,this.isReconnecting_&&Br(this.signalInfo_)&&this.stopReconnection(),this.clearBackupTimer(),i.target===this.socket_?(this.unbindAndCloseSocket(er),this.socketInUse_=this.socket_):(this.unbindAndCloseSocket(Xe),this.socketInUse_=this.backupSocket_);var r=i.target.url;this.log_.info("websocket[".concat(r,"] is connected")),this.currentState_===vk?this.addSignalEvent(sV,"signal channel is connected"):this.currentState_===am&&this.addSignalEvent(dV,"signal channel reconnect success"),this.emitConnectionStateChanged(oc),this.emitter_.emit(ac)}}},{key:"onclose",value:function(i){var r=i.target.url,o=i.target===this.socketInUse_;if(this.log_.info("websocket[".concat(r," InUse: ").concat(o,"] is closed with code: ").concat(i.code)),o&&(this.isConnected_=!1,this.emitConnectionStateChanged(fl),this.addSignalEvent(oV,"signal channel is disconnected"),!i.wasClean||i.code!==1e3)){this.log_.warn("onclose code:".concat(i.code," reason:").concat(i.reason)),this.log_.warn("close current websocket and schedule a reconnect timeout"),this.socketInUse_.onclose=function(){},this.socketInUse_.close(4011);var c=this.socketInUse_===this.socket_;this.socket_=this.backupSocket_=this.socketInUse_=null,this.reconnect(c?er:Xe)}}},{key:"onerror",value:function(i){var r=i.target.url;if(this.log_.error("websocket[".concat(r,"] error observed")),this.isConnected_){if(i.target===this.socketInUse_){this.isConnected_=!1,this.unbindAndCloseSocket(Xe),this.unbindAndCloseSocket(er);var o=this.socketInUse_===this.socket_;this.socketInUse_=null,this.reconnect(o?er:Xe)}}else this.isReconnecting_||ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Hf,code:Z.UNKNOWN}),i.target==this.socket_?(this.unbindAndCloseSocket(Xe),this.reconnect(er)):(this.unbindAndCloseSocket(er),this.reconnect(Xe));this.isConnecting_=!1,this.isConnected_=!1}},{key:"onmessage",value:function(i){if(this.isConnected_){this.lastMessageTime_=Date.now();var r=JSON.parse(i.data),o=r.cmd,c=r.data,a=Object.values(jr),s=Object.keys(jr)[a.indexOf(o)],l=st[s];switch(kU.includes(o)||(this.log_.debug("received msg: ".concat(i.data)),this.log_.info("Received event: [ ".concat(l||"unknown cmd: "+o," ]"))),o){case jr.CHANNEL_SETUP_RESULT:if(r.code===0)this.signalInfo_.clientIp=c.clientIp,this.signalInfo_.signalIp=c.signalInnerIp,this.signalInfo_.tinyId=r.tinyId,c.svrTime&&function(h){tf=h-new Date().getTime();var b=new Date;b.setTime(h),_e.info("baseTime from server: "+b+" offset: "+tf)}(c.svrTime),this.log_.info("ChannelSetup Success"),ke.logSuccessEvent({userId:this.userId_,eventType:Hf}),this.emitter_.emit(pk,{signalInfo:this.signalInfo_});else{var u=new te({code:Z.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:r.code,message:ie({key:wN,data:{errorCode:r.code,errorMsg:r.message}})});this.log_.error("".concat(r.code,", ").concat(r.message)),this.close(),ke.logFailedEvent({userId:this.userId_,eventType:Hf,error:u}),this.emitter_.emit(mk,u)}break;case jr.JOIN_ROOM_RESULT:r.code===0&&(this.signalInfo_.relayIp=c.relayOuterIp,this.signalInfo_.relayInnerIp=c.relayInnerIp,this.signalInfo_.relayPort=c.relayPort,this.log_.info("signalIp:".concat(this.signalInfo_.signalIp," clientIp:").concat(this.signalInfo_.clientIp," relayIp: ").concat(this.signalInfo_.relayIp))),this.emitter_.emit(l,{data:r});break;case jr.CHANNEL_RECONNECT_RESULT:r.code===0?(this.log_.warn("reconnect success"),this.stopReconnection(),ke.logSuccessEvent({userId:this.userId_,eventType:Mb}),this.client_.syncUserList(),this.client_.checkConnectionsToReconnect()):(this.log_.warn("reconnect failed, ".concat(r.code," ").concat(r.message)),this.client_.reJoin());break;default:this.emitter_.emit(l,{data:r})}}}},{key:"addSignalEvent",value:function(i,r){vn(this.userId_,{eventId:i,eventDesc:r,timestamp:an(),userId:this.userId_,tinyId:this.signalInfo_.tinyId})}},{key:"reconnect",value:(n=H(f().mark(function i(){var r,o,c,a,s=this,l=arguments;return f().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(r=l.length>0&&l[0]!==void 0?l[0]:Xe,!this.isConnecting_&&this.reconnectionTimer_===-1){u.next=4;break}return this.log_.info("signal channel is reconnecting, ignoring current reconnection"),u.abrupt("return");case 4:if(Y.emit(KS,this.client_),!(this.reconnectionCount_>=Ff)){u.next=12;break}return this.log_.warn("SDK has tried reconnect signal channel for ".concat(Ff," times, but all failed. please check your network")),o=new te({code:Z.SIGNAL_CHANNEL_RECONNECTION_FAILED,message:ie({key:xN})}),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Mb,error:o}),this.addSignalEvent(hV,"signal channel reconnect fail"),this.emitter_.emit(im,o),u.abrupt("return");case 12:if(this.isConnecting_=!0,this.reconnectionCount_++,this.currentState_!==am&&(this.emitConnectionStateChanged(am),this.addSignalEvent(lV,"signal channel is reconnecting")),this.log_.warn("reconnecting to ".concat(r," signal channel [").concat(this.reconnectionCount_,"/").concat(Ff,"]")),!(this.reconnectionCount_>=3&&this.reconnectionCount_%3==0)){u.next=20;break}return this.log_.warn("re-schedule to get new ws url"),u.next=20,this.reGetSignalChannelUrl();case 20:c=this.getReconnectionUrl(r),r===Xe?(this.socket_=new WebSocket(c),this.bindSocket(this.socket_)):(this.backupSocket_=new WebSocket(c),this.bindSocket(this.backupSocket_)),a=Ip(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){s.log_.warn("reconnect ".concat(r," signal channel timeout(").concat(a/1e3,"s), close and try again")),s.isConnecting_=!1,s.clearReconnectionTimer(),s.unbindAndCloseSocket(r),s.reconnect(r===Xe?er:Xe)},a);case 24:case"end":return u.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"reGetSignalChannelUrl",value:(t=H(f().mark(function i(){var r,o,c,a;return f().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(s.prev=0,!this.client_.getWSProxy()&&!this.client_.getUnifiedProxy()){s.next=3;break}return s.abrupt("return");case 3:return Ti(!0),s.next=6,this.client_.schedule(this.client_.getRoomId());case 6:r=this.client_.getSignalChannelUrl(),o=r.mainUrl,c=r.backupUrl,this.url_=o,this.backupUrl_=c,(a=new URLSearchParams(this.urlParams)).has("signalDomain")&&(a.set("signalDomain",o),this.urlParams=a.toString()),s.next=15;break;case 13:s.prev=13,s.t0=s.catch(0);case 15:case"end":return s.stop()}},i,this,[[0,13]])})),function(){return t.apply(this,arguments)})},{key:"isConnected",value:function(){return this.isConnected_}},{key:"isReconnecting_",get:function(){return this.reconnectionTimer_!==-1}},{key:"getReconnectionUrl",value:function(i){var r=i===Xe?this.urlWithParam_:this.backupUrlWithParam_;if(!Br(this.signalInfo_)&&r.indexOf("&rc=1")===-1){var o=this.client_.getRoomId(),c=this.client_.getUseStringRoomId();r+="&rc=1&relayInnerIp=".concat(this.signalInfo_.relayInnerIp,"&relayOuterIp=").concat(this.signalInfo_.relayIp,"&relayPort=").concat(this.signalInfo_.relayPort,"&roomId=").concat(o,"&useStringRoomId=").concat(c)}return r}},{key:"send",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.isConnected_){var o={cmd:i,data:r,userId:this.userId_,tinyId:this.signalInfo_.tinyId,seq:++this.seq_};return this.socketInUse_.send(JSON.stringify(o)),o.seq}}},{key:"sendWaitForResponse",value:function(i){var r=this,o=i.command,c=i.data,a=i.timeout,s=a===void 0?5e3:a,l=i.responseCommand,u=i.commandDesc,h=i.enableLog,b=h===void 0||h;return new Promise(function(I,R){var x=setTimeout(function(){r.off(l,m);var v=new te({code:Z.API_CALL_TIMEOUT,message:ie({key:IN,data:{commandDesc:u,command:o}})});b&&r.log_.warn(v),R(v)},s),m=function v(w){w.data.seq===k&&(clearTimeout(x),r.off(l,v),I(w))};r.on(l,m);var k=r.send(o,c)})}},{key:"sendWaitForResponseWithRetry",value:function(){var i=this,r=arguments.length<=0?void 0:arguments[0],o=r.commandDesc,c=r.command,a=r.retries,s=a===void 0?0:a,l=r.retryTimeout,u=l===void 0?0:l;return ic({retryFunction:this.sendWaitForResponse,onRetrying:function(h){i.log_.warn("".concat(o||c," timeout observed, retrying [").concat(h,"/").concat(s,"]"))},settings:{retries:s,timeout:u},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.signalInfo_={},this.isConnecting_=!1,this.isConnected_=!1,this.socketInUse_=null,this.unbindAndCloseSocket(Xe),this.unbindAndCloseSocket(er),this.emitConnectionStateChanged(fl)}},{key:"on",value:function(i,r,o){this.emitter_.on(i,r,o)}},{key:"removeListener",value:function(i,r,o){this.emitter_.removeListener(i,r,o)}},{key:"once",value:function(i,r,o){this.emitter_.once(i,r,o)}},{key:"off",value:function(i,r,o){this.emitter_.off(i,r,o)}},{key:"emitConnectionStateChanged",value:function(i){i!==this.currentState_&&(this.emitter_.emit(rm,{prevState:this.currentState_,state:i}),this.currentState_=i)}}]),e}(),UV=Le,VV=rn.find,jV=uu,Ak="find",Pk=!0;Ak in[]&&Array(1).find(function(){Pk=!1}),UV({target:"Array",proto:!0,forced:Pk},{find:function(e){return VV(this,e,arguments.length>1?arguments[1]:void 0)}}),jV(Ak);var rr={},Dk={},fm={exports:{}},Ok=fm.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return e.address!=null?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return e.subtype!=null?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return e.sessionConfig!=null?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=e.raddr!=null?" raddr %s rport %d":"%v%v",t+=e.tcptype!=null?" tcptype %s":"%v",e.generation!=null&&(t+=" generation %d"),t+=e["network-id"]!=null?" network-id %d":"%v",t+=e["network-cost"]!=null?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return e.attribute!=null&&(t+=" %s",e.value!=null&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return e.maxMessageSize!=null?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(e.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=e.id!=null?"id=%s %s":"%v%s",t+=e.mediaClockValue!=null?"=%s":"",t+=e.rateNumerator!=null?" rate=%s":"",t+=e.rateDenominator!=null?"/%s":""}},{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(Ok).forEach(function(e){Ok[e].forEach(function(t){t.reg||(t.reg=/(.*)/),t.format||(t.format="%s")})}),function(e){var t=function(c){return String(Number(c))===c?Number(c):c},n=function(c,a,s){var l=c.name&&c.names;c.push&&!a[c.push]?a[c.push]=[]:l&&!a[c.name]&&(a[c.name]={});var u=c.push?{}:l?a[c.name]:a;(function(h,b,I,R){if(R&&!I)b[R]=t(h[1]);else for(var x=0;x<I.length;x+=1)h[x+1]!=null&&(b[I[x]]=t(h[x+1]))})(s.match(c.reg),u,c.names,c.name),c.push&&a[c.push].push(u)},i=fm.exports,r=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(c){var a={},s=[],l=a;return c.split(/(\r\n|\r|\n)/).filter(r).forEach(function(u){var h=u[0],b=u.slice(2);h==="m"&&(s.push({rtp:[],fmtp:[]}),l=s[s.length-1]);for(var I=0;I<(i[h]||[]).length;I+=1){var R=i[h][I];if(R.reg.test(b))return n(R,l,b)}}),a.media=s,a};var o=function(c,a){var s=a.split(/=(.+)/,2);return s.length===2?c[s[0]]=t(s[1]):s.length===1&&a.length>1&&(c[s[0]]=void 0),c};e.parseParams=function(c){return c.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(c){return c.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(c){for(var a=[],s=c.split(" ").map(t),l=0;l<s.length;l+=3)a.push({component:s[l],ip:s[l+1],port:s[l+2]});return a},e.parseImageAttributes=function(c){return c.split(" ").map(function(a){return a.substring(1,a.length-1).split(",").reduce(o,{})})},e.parseSimulcastStreamList=function(c){return c.split(";").map(function(a){return a.split(",").map(function(s){var l,u=!1;return s[0]!=="~"?l=t(s):(l=t(s.substring(1,s.length)),u=!0),{scid:l,paused:u}})})}}(Dk);var pm=fm.exports,BV=/%[sdv%]/g,FV=function(e){var t=1,n=arguments,i=n.length;return e.replace(BV,function(r){if(t>=i)return r;var o=n[t];switch(t+=1,r){case"%%":return"%";case"%s":return String(o);case"%d":return Number(o);case"%v":return""}})},uc=function(e,t,n){var i=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var r=0;r<t.names.length;r+=1){var o=t.names[r];t.name?i.push(n[t.name][o]):i.push(n[t.names[r]])}else i.push(n[t.name]);return FV.apply(null,i)},HV=["v","o","s","i","u","e","p","c","b","t","r","z","a"],GV=["i","c","b","a"],ua=Dk,zV=function(e,t){t=t||{},e.version==null&&(e.version=0),e.name==null&&(e.name=" "),e.media.forEach(function(o){o.payloads==null&&(o.payloads="")});var n=t.outerOrder||HV,i=t.innerOrder||GV,r=[];return n.forEach(function(o){pm[o].forEach(function(c){c.name in e&&e[c.name]!=null?r.push(uc(o,c,e)):c.push in e&&e[c.push]!=null&&e[c.push].forEach(function(a){r.push(uc(o,c,a))})})}),e.media.forEach(function(o){r.push(uc("m",pm.m[0],o)),i.forEach(function(c){pm[c].forEach(function(a){a.name in o&&o[a.name]!=null?r.push(uc(c,a,o)):a.push in o&&o[a.push]!=null&&o[a.push].forEach(function(s){r.push(uc(c,a,s))})})})}),r.join(`\r
55
55
  `)+`\r
56
- `};rr.write=WV,rr.parse=ua.parse,rr.parseParams=ua.parseParams,rr.parseFmtpConfig=ua.parseFmtpConfig,rr.parsePayloads=ua.parsePayloads,rr.parseRemoteCandidates=ua.parseRemoteCandidates,rr.parseImageAttributes=ua.parseImageAttributes,rr.parseSimulcastStreamList=ua.parseSimulcastStreamList;var gm,_m,ym,bm,Fr=function(e){return rr.parse(e)},yo=function(e){return rr.write(e)},zV=function(e){var t=Fr(e);return t.media.forEach(function(n){n.type===Ee&&n.fmtp.forEach(function(i){i.config+=";sprop-stereo=1;stereo=1"})}),yo(t)},Lk=((gm=window)===null||gm===void 0?void 0:gm.requestIdleCallback)||function(e){var t=Date.now();return setTimeout(function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},1e3)},JV=((_m=window)===null||_m===void 0?void 0:_m.cancelIdleCallback)||function(e){clearTimeout(e)},qV=((ym=window)===null||ym===void 0?void 0:ym.cancelAnimationFrame)||((bm=window)===null||bm===void 0?void 0:bm.mozCancelAnimationFrame),mt=function(){function e(){Q(this,e)}return xe(e,null,[{key:"generateTaskID",value:function(){return this.currentTaskID++}},{key:"run",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:nS,n=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;i=q(q({},t===fN?{delay:2e3,count:0,backgroundTask:!0}:t===uo?{delay:1e4,count:0}:t===Yu?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0}),i),US(n)&&(i=q(q({},i),n)),ln(t)&&(n=t,t=nS);var r=q({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:t,callback:n},i);return this.taskMap.set(r.taskID,r),this[t](r),r.taskID}},{key:"interval",value:function(t){var n=this;return t.intervalID=setInterval(function(){t.callback(),t.loopCount+=1,n.isBreakLoop(t)},t.delay)}},{key:"timeout",value:function(t){var n=this;return t.timeoutID=setTimeout(function i(){if(t.callback(),t.loopCount+=1,!n.isBreakLoop(t))return t.timeoutID=setTimeout(i,t.delay)},t.delay)}},{key:"ric",value:function(t){var n,i=this,r=Ct();return t.ricID=Lk(function o(){if((n=Ct()-r)>=t.delay&&(r=Ct()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),!i.isBreakLoop(t))return t.ricID=Lk(o,{timeout:t.delay})},{timeout:t.delay})}},{key:"raf",value:function(t){var n=this;t.delay=(1e3/t.fps).toFixed(2);var i,r=Ct(),o=function a(){if(document.hidden&&t.backgroundTask)return i=Ct()-r,r=Ct(),t.callback(),t.loopCount+=1,n.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(a,t.delay-Math.floor(i%t.delay));if((i=Ct()-r)>=t.delay&&(r=Ct()-Math.floor(i%t.delay),t.callback(),t.loopCount+=1),!n.isBreakLoop(t))return t.rafID=requestAnimationFrame(a)};if(t.rafID=requestAnimationFrame(o),t.backgroundTask){var c=function(){if(document.hidden){var a=Ct()-r;a>=t.delay?o():t.timeoutID=setTimeout(o,t.delay-a)}};document.addEventListener("visibilitychange",c),t.onVisibilitychange=c,document.hidden&&c()}return t.taskID}},{key:"hasTask",value:function(t){return this.taskMap.has(t)}},{key:"clearTask",value:function(t){if(!this.taskMap.has(t))return!0;var n=this.taskMap.get(t),i=n.intervalID,r=n.timeoutID,o=n.rafID,c=n.ricID,a=n.onVisibilitychange;return i&&clearInterval(i),r&&clearTimeout(r),o&&qV(o),c&&JV(c),a&&document.removeEventListener("visibilitychange",a),this.taskMap.delete(t),!0}},{key:"isBreakLoop",value:function(t){return!this.taskMap.has(t.taskID)||t.count!==0&&t.loopCount>=t.count&&(this.clearTask(t.taskID),!0)}}]),e}();$e(mt,"taskMap",new Map),$e(mt,"currentTaskID",1);var KV=function(){function e(){Q(this,e),this.prefix_="TRTC",this.queue_=new Map,this.checkStorage()}return xe(e,[{key:"getRealKey",value:function(t){return"".concat(this.prefix_,"_").concat(t)}},{key:"checkStorage",value:function(){var t=this;if(ia()){var n=Object.keys(localStorage).filter(function(i){if(i.startsWith(t.prefix_)){var r=JSON.parse(localStorage.getItem(i));if(r&&r.expiresIn<Date.now())return!0}return!1});n.forEach(function(i){return localStorage.removeItem(i)})}}},{key:"doFlush",value:function(){if(ia())try{var t,n=oe(this.queue_);try{for(n.s();!(t=n.n()).done;){var i=Te(t.value,2),r=i[0],o=i[1];localStorage.setItem(r,JSON.stringify(o))}}catch(c){n.e(c)}finally{n.f()}}catch(c){_e.warn(c)}}},{key:"getItem",value:function(t){if(!ia())return null;try{var n=JSON.parse(localStorage.getItem(this.getRealKey(t)));return n&&n.expiresIn>=Date.now()?n.value:null}catch(i){_e.warn(i)}}},{key:"setItem",value:function(t,n){var i=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(ia())try{var r={expiresIn:Date.now()+Kb,value:n};i?localStorage.setItem(this.getRealKey(t),JSON.stringify(r)):(this.queue_.set(this.getRealKey(t),r),mt.hasTask(this.intervalId_)||(this.intervalId_=mt.run(uo,this.doFlush.bind(this),{count:1})))}catch(o){_e.warn(o)}}},{key:"deleteItem",value:function(t){if(!ia())return!1;try{return t=this.getRealKey(t),this.queue_.delete(t),localStorage.removeItem(t),!0}catch(n){return _e.warn(n),!1}}},{key:"clear",value:function(){if(ia())try{localStorage.clear()}catch(t){_e.warn(t)}}}]),e}(),bo=new KV,_t={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isMediaDevicesSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},Mk="checkResult",Nk=function(){return!y4&&!Zu&&!(el&&ES<80)&&!(Vn&&CS<56)},Sm=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter(function(e){return e in window}).length>0},XV=function(){if(!navigator.mediaDevices)return!1;var e=["getUserMedia","enumerateDevices"];return e.filter(function(t){return t in navigator.mediaDevices}).length===e.length},Uk=function(){var e=H(p().mark(function t(){var n,i,r,o,c,a;return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(!_t.detail.isH264EncodeSupported||!_t.detail.isVp8EncodeSupported){s.next=2;break}return s.abrupt("return",{isH264EncodeSupported:_t.detail.isH264EncodeSupported,isVp8EncodeSupported:_t.detail.isVp8EncodeSupported});case 2:return n="",i=!1,r=!1,s.prev=5,o=new RTCPeerConnection,(c=document.createElement(hb)).getContext("2d"),a=c.captureStream(0),o.addTrack(a.getVideoTracks()[0],a),s.next=13,o.createOffer();case 13:return(n=s.sent).sdp.toLowerCase().indexOf("h264")!==-1&&(i=!0),n.sdp.toLowerCase().indexOf("vp8")!==-1&&(r=!0),o.close(),_t.detail.isH264EncodeSupported=i,_t.detail.isVp8EncodeSupported=r,s.abrupt("return",{isH264EncodeSupported:_t.detail.isH264EncodeSupported,isVp8EncodeSupported:_t.detail.isVp8EncodeSupported});case 22:return s.prev=22,s.t0=s.catch(5),s.abrupt("return",{isH264EncodeSupported:!1,isVp8EncodeSupported:!1});case 25:case"end":return s.stop()}},t,null,[[5,22]])}));return function(){return e.apply(this,arguments)}}();function QV(){return km.apply(this,arguments)}function km(){return km=H(p().mark(function e(){return p().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(){var n=H(p().mark(function i(r){var o,c,a,s,l,u,h,S,I,E,x,m,T,v;return p().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return o={encode:!1,decode:!1},c=null,w.prev=2,a=document.createElement("canvas"),s=a.getContext("2d"),a.width=640,a.height=480,l=setInterval(function(){s.fillText("test",Math.floor(640*Math.random()),Math.floor(480*Math.random()))},33),u=-1,h=-1,c=function(){clearInterval(u),clearInterval(l),clearTimeout(h),I.close(),E.close(),S.getTracks().forEach(function(L){return L.stop()})},h=setTimeout(function(){c(),r(o)},3e3),S=a.captureStream(),I=new RTCPeerConnection({}),E=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),I.addEventListener("icecandidate",function(L){return E.addIceCandidate(L.candidate)}),E.addEventListener("icecandidate",function(L){return I.addIceCandidate(L.candidate)}),I.addTrack(S.getVideoTracks()[0],S),w.next=20,I.createOffer();case 20:return x=w.sent,w.next=23,I.setLocalDescription(x);case 23:return w.next=25,E.setRemoteDescription(x);case 25:return w.next=27,E.createAnswer();case 27:return m=w.sent,T=Fr(m.sdp),v=T.media[0].rtp.findIndex(function(L){return L.codec==="H264"}),T.media[0].rtp=[T.media[0].rtp[v]],T.media[0].fmtp=T.media[0].fmtp.filter(function(L){return L.payload===T.media[0].rtp[0].payload}),T.media[0].rtcpFb=T.media[0].rtcpFb.filter(function(L){return L.payload===T.media[0].rtp[0].payload}),m.sdp=yo(T),w.next=36,E.setLocalDescription(m);case 36:return w.next=38,I.setRemoteDescription(m);case 38:u=setInterval(H(p().mark(function L(){var N,V;return p().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return o.encode&&o.decode&&(c(),r(o)),_.next=3,I.getStats();case 3:return N=_.sent,_.next=6,E.getStats();case 6:V=_.sent,o.encode||N.forEach(function(b){b.type==="outbound-rtp"&&b.mediaType===Ie&&b.framesEncoded>0&&(o.encode=!0)}),o.decode||V.forEach(function(b){b.type==="inbound-rtp"&&b.mediaType===Ie&&b.framesDecoded>0&&(o.decode=!0)});case 9:case"end":return _.stop()}},L)})),500),w.next=46;break;case 41:w.prev=41,w.t0=w.catch(2),c(),_e.warn(w.t0),r(o);case 46:case"end":return w.stop()}},i,null,[[2,41]])}));return function(i){return n.apply(this,arguments)}}()));case 1:case"end":return t.stop()}},e)})),km.apply(this,arguments)}var Vk=function(){var e=H(p().mark(function t(){var n,i,r,o;return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(!_t.detail.isH264DecodeSupported||!_t.detail.isVp8DecodeSupported){c.next=2;break}return c.abrupt("return",{isH264DecodeSupported:_t.detail.isH264DecodeSupported,isVp8DecodeSupported:_t.detail.isVp8DecodeSupported});case 2:return n="",i=!1,r=!1,c.prev=5,o=new RTCPeerConnection,c.next=9,o.createOffer({offerToReceiveAudio:1,offerToReceiveVideo:1});case 9:return(n=c.sent).sdp.toLowerCase().indexOf("h264")!==-1&&(i=!0),n.sdp.toLowerCase().indexOf("vp8")!==-1&&(r=!0),o.close(),c.abrupt("return",{isH264DecodeSupported:i,isVp8DecodeSupported:r});case 16:return c.prev=16,c.t0=c.catch(5),c.abrupt("return",{isH264DecodeSupported:!1,isVp8DecodeSupported:!1});case 19:case"end":return c.stop()}},t,null,[[5,16]])}));return function(){return e.apply(this,arguments)}}(),YV=function(){var e=H(p().mark(function t(){var n,i,r,o,c,a,s,l,u,h,S,I,E;return p().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(jk()){x.next=2;break}return x.abrupt("return",_t);case 2:return n=Nk(),i=Sm(),r=XV(),x.next=7,Uk();case 7:return o=x.sent,c=o.isH264EncodeSupported,a=o.isVp8EncodeSupported,x.next=12,Vk();case 12:if(s=x.sent,l=s.isH264DecodeSupported,u=s.isVp8DecodeSupported,c&&a){x.next=21;break}return x.next=18,Uk();case 18:h=x.sent,c=h.isH264EncodeSupported,a=h.isVp8EncodeSupported;case 21:if(!(c&&l&&(nl||rl||C4)&&!Nr&&lo()<79)){x.next=29;break}return x.next=24,QV();case 24:S=x.sent,I=S.encode,E=S.decode,c=I,l=E;case 29:return _t.result=n&&i&&r&&(c||a)&&(l||u),_t.detail.isBrowserSupported=n,_t.detail.isWebRTCSupported=i,_t.detail.isMediaDevicesSupported=r,_t.detail.isH264EncodeSupported=c,_t.detail.isVp8EncodeSupported=a,_t.detail.isH264DecodeSupported=l,_t.detail.isVp8DecodeSupported=u,$V(),bo.setItem(Mk,{ua:navigator.userAgent,checkResult:_t},!0),x.abrupt("return",_t);case 40:case"end":return x.stop()}},t)}));return function(){return e.apply(this,arguments)}}(),Tm=function(e,t){var n=null;return function(){if(n)return n;for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return(n=e.apply(t||this,r)).then(function(c){return n=null,c}).catch(function(c){throw n=null,c}),n}}(YV);function jk(){return Object.keys(_t.detail).findIndex(function(e){return!_t.detail[e]})>=0}function $V(){jk()&&(_e.warn(ae({key:vS})),_e.info("".concat(navigator.userAgent," ").concat(JSON.stringify(_t.detail))))}function Bk(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)}function Fk(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function vl(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function Ii(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function gl(){return"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype}function Im(){return"RTCRtpSender"in window&&"replaceTrack"in window.RTCRtpSender.prototype}function Hk(){return"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype&&vl()}function _l(){return!!ge(navigator.mediaDevices)&&(_e.error(gi.NOT_SUPPORTED_MEDIA),!0)}function yl(){return location.protocol==="http:"&&!ra&&(_e.warn(ae({key:mS})),!0)}var bl="RTCRtpSender"in window&&"createEncodedStreams"in window.RTCRtpSender.prototype&&lo()>=86;function xm(e){return!(e.type!=="candidate-pair"||!e.nominated||e.state!=="in-progress"&&e.state!=="succeeded")&&!(nr(e.selected)&&!e.selected)}var Gk=new Map([[ta,"Android"],[_i,"iOS"],[AS,"Windows"],[ec,"MacOS"],[PS,"Linux"]]);function wm(){var e="unknown";return Gk.get(!0)&&(e=Gk.get(!0)),e}function ZV(){var e="";return screen.width&&(e+=(screen.width?screen.width*window.devicePixelRatio:"")+" * "+(screen.height?screen.height*window.devicePixelRatio:"")),e}function e6(){var e=!1;return(navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)&&(e=!0),e}function t6(){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 Wk(){return!(hp&&lo()<86)&&!(_i&&tr(yi)&&yi<15)&&!(kp&&kp<63)&&!(!Nk()||!("captureStream"in HTMLCanvasElement.prototype))}var la=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,n6=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,r6=function(){var e,t,n;return((e=window)===null||e===void 0?void 0:e.OffscreenCanvas)&&((t=window)===null||t===void 0?void 0:t.MediaStreamTrackProcessor)&&((n=window)===null||n===void 0?void 0:n.MediaStreamTrackGenerator)};(function(){yl();var e=bo.getItem(Mk);e&&e.ua===navigator.userAgent&&(_t=e.checkResult),Tm()})();var et={STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",STREAM_UPDATED:"stream-updated",STREAM_PUBLISHED:"stream-published",STREAM_SUBSCRIBED:"stream-subscribed",STREAM_UNSUBSCRIBED:"stream-unsubscribed",STATE_CHANGED:"state-changed",ERROR:"error",CONNECTION_STATE_CHANGED:"connection-state-changed",SEI_MESSAGE:vb},ct={STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",STREAM_UPDATED:"stream-updated",STREAM_SUBSCRIBED:"stream-subscribed",CONNECTION_STATE_CHANGED:"connection-state-changed",PEER_JOIN:"peer-join",PEER_LEAVE:"peer-leave",MUTE_AUDIO:"mute-audio",MUTE_VIDEO:"mute-video",UNMUTE_AUDIO:"unmute-audio",UNMUTE_VIDEO:"unmute-video",CLIENT_BANNED:"client-banned",NETWORK_QUALITY:"network-quality",AUDIO_VOLUME:"audio-volume",SEI_MESSAGE:vb,ERROR:"error"},zk="player-state-changed",i6="screen-sharing-stopped",a6="connection-state-changed",o6="device-auto-recovered",Cm="error",gn="player-state-changed",Jk="error",s6=aS;Le({target:"String",proto:!0,forced:oS("small")},{small:function(){return s6(this,"small","","")}});var c6=function(){function e(o){Q(this,e);var c=o.getUserId();this.log_=_e.createLogger({id:c,userId:c,sdkAppId:o.getSDKAppId()}),this.prevReportTime_=0,this.prevReport_={},this.prevEncoderImplementation_="",this.prevQualityLimitationReason_="",this.prevDecoderImplementationMap_=new Map}var t,n,i,r;return xe(e,[{key:"statInterval",get:function(){return this.prevReportTime_===0?2:(Date.now()-this.prevReportTime_)/1e3}},{key:"getSenderStats",value:(r=H(p().mark(function o(c){var a,s,l,u,h=this;return p().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(a={audio:{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0},video:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},small:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},auxiliary:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},rtt:0},s=c.getPeerConnection(),l=c.getSSRC(),!s){S.next=15;break}return S.prev=4,S.next=7,s.getStats();case 7:S.sent.forEach(function(I){var E;if(I.type==="outbound-rtp")if((I.mediaType||I.kind)===Ie){if(!Vn&&I.bytesSent===0)return;I.ssrc!==l.video||ge(I.encoderImplementation)||h.prevEncoderImplementation_===I.encoderImplementation||(h.log_.info("encoderImplementation change to ".concat(I.encoderImplementation)),h.prevEncoderImplementation_=I.encoderImplementation),I.ssrc!==l.video||ge(I.qualityLimitationReason)||h.prevQualityLimitationReason_===I.qualityLimitationReason||(h.log_.info("qualityLimitationReason change to ".concat(I.qualityLimitationReason)),h.prevQualityLimitationReason_=I.qualityLimitationReason);var x=Ie;I.ssrc===l.small?x=Mr:I.ssrc===l.auxiliary&&(x=gt),a[x].bytesSent=I.bytesSent,a[x].packetsSent=I.packetsSent,a[x].framesEncoded=I.framesEncoded}else a.audio.bytesSent=I.bytesSent,a.audio.packetsSent=I.packetsSent;else I.type==="candidate-pair"?xm(I)&&tr(I.currentRoundTripTime)&&(a.rtt=Math.floor(1e3*I.currentRoundTripTime)):I.type==="media-source"&&(I.kind===Ee?(a.audio.audioLevel=I.audioLevel||0,a.audio.totalAudioEnergy=I.totalAudioEnergy||0):I.kind===Ie&&(I.trackIdentifier===c.getVideoTrackId(Ie)?a.video.fpsCapture=I.framesPerSecond:I.trackIdentifier===c.getVideoTrackId(gt)?a.auxiliary.fpsCapture=I.framesPerSecond:a.small.fpsCapture=I.framesPerSecond));ge(I.audioLevel)||(a.audio.audioLevel=I.audioLevel||0,a.audio.totalAudioEnergy=I.totalAudioEnergy||0),ge(I.frameWidth)||(I.trackIdentifier===c.getVideoTrackId(Ie)||I.ssrc===l.video?E=Ie:I.trackIdentifier===c.getVideoTrackId(gt)||I.ssrc===l.auxiliary?E=gt:I.trackIdentifier!==c.getVideoTrackId(Mr)&&I.ssrc!==l.small||(E=Mr),E&&(a[E].frameWidth=I.frameWidth,a[E].frameHeight=I.frameHeight,a[E].framesSent=I.framesSent))}),a.audio.audioLevel===0&&(a.audio.audioLevel=((u=c.getLocalStream())===null||u===void 0?void 0:u.getInternalAudioLevel())||0),S.next=15;break;case 12:S.prev=12,S.t0=S.catch(4),this.log_.warn("failed to getStats on sender connection "+S.t0);case 15:return S.abrupt("return",a);case 16:case"end":return S.stop()}},o,this,[[4,12]])})),function(o){return r.apply(this,arguments)})},{key:"getReceiverStats",value:(i=H(p().mark(function o(c){var a,s,l,u,h,S=this;return p().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(a={tinyId:c.getTinyId(),userId:c.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}},!(s=c.getPeerConnection())){I.next=16;break}return I.prev=3,l=c.getSSRC(),u=c.getTrackState(),I.next=8,s.getStats();case 8:I.sent.forEach(function(E){if(E.type==="inbound-rtp")if((E.mediaType||E.kind)===Ee){if(E.ssrc!==l.audio||!u.audio)return;a.audio.packetsReceived=E.packetsReceived,a.audio.bytesReceived=E.bytesReceived,a.audio.packetsLost=E.packetsLost,a.audio.jitter=E.jitter,a.hasAudio=!0}else{if(Vn&&E.bytesReceived===0)return;E.ssrc===l.video&&u.video&&(a.video.packetsReceived=E.packetsReceived,a.video.bytesReceived=E.bytesReceived,a.video.packetsLost=E.packetsLost,a.video.framesReceived=E.framesReceived,a.video.framesDecoded=E.framesDecoded,a.video.fpsDecoded=E.framesPerSecond,a.hasVideo=!0,!E.decoderImplementation||S.prevDecoderImplementationMap_.has(a.userId)&&S.prevDecoderImplementationMap_.get(a.userId)===E.decoderImplementation||(S.log_.info("".concat(a.userId," decoderImplementation change to ").concat(E.decoderImplementation)),S.prevDecoderImplementationMap_.set(a.userId,E.decoderImplementation))),E.ssrc===l.auxiliary&&u.auxiliary&&(a.auxiliary.packetsReceived=E.packetsReceived,a.auxiliary.bytesReceived=E.bytesReceived,a.auxiliary.packetsLost=E.packetsLost,a.auxiliary.framesReceived=E.framesReceived,a.auxiliary.framesDecoded=E.framesDecoded,a.auxiliary.fpsDecoded=E.framesPerSecond,a.hasAuxiliary=!0)}else E.type==="candidate-pair"&&xm(E)&&tr(E.currentRoundTripTime)&&(a.rtt=Math.floor(1e3*E.currentRoundTripTime));ge(E.frameWidth)||(E.trackIdentifier!==c.getMainStreamVideoTrackId()&&E.ssrc!==l.video||(a.video.frameWidth=E.frameWidth,a.video.frameHeight=E.frameHeight),E.trackIdentifier!==c.getAuxStreamVideoTrackId()&&E.ssrc!==l.auxiliary||(a.auxiliary.frameWidth=E.frameWidth,a.auxiliary.frameHeight=E.frameHeight)),ge(E.audioLevel)||(a.audio.audioLevel=E.audioLevel||0,a.audio.totalAudioEnergy=E.totalAudioEnergy||0)}),a.audio.audioLevel===0&&(a.audio.audioLevel=((h=c.getMainStream())===null||h===void 0?void 0:h.getInternalAudioLevel())||0),I.next=16;break;case 13:I.prev=13,I.t0=I.catch(3),this.log_.warn("failed to getStats on receiver connection "+I.t0);case 16:return I.abrupt("return",a);case 17:case"end":return I.stop()}},o,this,[[3,13]])})),function(o){return i.apply(this,arguments)})},{key:"getStats",value:(n=H(p().mark(function o(c,a){var s,l,u,h,S,I,E;return p().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(s={},!c){x.next=5;break}return x.next=4,this.getSenderStats(c);case 4:s=x.sent;case 5:l=[],u=oe(a),x.prev=7,u.s();case 9:if((h=u.n()).done){x.next=17;break}return(S=Te(h.value,2))[0],I=S[1],x.next=13,this.getReceiverStats(I);case 13:E=x.sent,l.push(E);case 15:x.next=9;break;case 17:x.next=22;break;case 19:x.prev=19,x.t0=x.catch(7),u.e(x.t0);case 22:return x.prev=22,u.f(),x.finish(22);case 25:return x.abrupt("return",{senderStats:s,receiverStats:l});case 26:case"end":return x.stop()}},o,this,[[7,19,22,25]])})),function(o,c){return n.apply(this,arguments)})},{key:"getDifferenceValue",value:function(o,c){if(Br(o))return c;var a=c-o;return a<0?0:a}},{key:"prepareReport",value:function(o){var c=this,a=o.stats,s=o.report,l=o.freezeMap;if(!Br(a.senderStats)){var u;u={uint32_audio_level:1e8*a.senderStats.audio.audioLevel,uint32_audio_energy:1e6*a.senderStats.audio.totalAudioEnergy,uint32_audio_codec_bitrate:a.senderStats.audio.bytesSent,audioLevel:a.senderStats.audio.audioLevel};var h=[],S={uint32_video_stream_type:2,uint32_video_codec_fps:a.senderStats.video.framesSent,uint32_video_capture_fps:a.senderStats.video.fpsCapture,uint32_video_width:a.senderStats.video.frameWidth,uint32_video_height:a.senderStats.video.frameHeight,uint32_video_codec_bitrate:a.senderStats.video.bytesSent,uint32_video_enc_fps:a.senderStats.video.framesEncoded};if(h.push(S),a.senderStats.small.bytesSent){var I={uint32_video_stream_type:3,uint32_video_codec_fps:a.senderStats.small.framesSent||0,uint32_video_capture_fps:a.senderStats.small.fpsCapture||0,uint32_video_width:a.senderStats.small.frameWidth||0,uint32_video_height:a.senderStats.small.frameHeight||0,uint32_video_codec_bitrate:a.senderStats.small.bytesSent,uint32_video_enc_fps:a.senderStats.small.framesEncoded||0};h.push(I)}if(a.senderStats.auxiliary.bytesSent){var E={uint32_video_stream_type:7,uint32_video_codec_fps:a.senderStats.auxiliary.framesSent||0,uint32_video_capture_fps:a.senderStats.auxiliary.fpsCapture||0,uint32_video_width:a.senderStats.auxiliary.frameWidth||0,uint32_video_height:a.senderStats.auxiliary.frameHeight||0,uint32_video_codec_bitrate:a.senderStats.auxiliary.bytesSent,uint32_video_enc_fps:a.senderStats.auxiliary.framesEncoded||0};h.push(E)}var x={uint32_bitrate:0,uint32_rtt:a.senderStats.rtt};s.msg_up_stream_info={msg_audio_status:u,msg_video_status:h,msg_network_status:x}}var m=this.statInterval;s.msg_down_stream_info=[],a.receiverStats.forEach(function(b){var R={};if(R.msg_user_info={str_identifier:b.userId,uint64_tinyid:b.tinyId},R.msg_network_status={uint32_rtt:b.rtt},R.msg_video_status={},b.hasAudio){var P={uint32_audio_codec_bitrate:b.audio.bytesReceived,uint32_audio_total_bitrate:b.audio.bytesReceived,uint32_audio_level:1e8*b.audio.audioLevel,uint32_audio_energy:1e6*b.audio.totalAudioEnergy,uint32_audio_receive:b.audio.packetsReceived,uint32_audio_origin_lost:b.audio.packetsLost,audioLevel:b.audio.audioLevel};R.msg_audio_status=P}if(R.msg_video_status=[],b.hasVideo){var U=l.get(b.userId+"_"+yt),k=U?U.duration:0,f={uint32_video_stream_type:2,uint32_video_receive_fps:b.video.framesReceived,uint32_video_width:b.video.frameWidth,uint32_video_height:b.video.frameHeight,uint32_video_codec_bitrate:b.video.bytesReceived,uint32_video_receive:b.video.packetsReceived,uint32_video_origin_lost:b.video.packetsLost,uint32_video_block_time:k,uint32_video_dec_fps:b.video.framesDecoded};R.msg_video_status.push(f)}if(b.hasAuxiliary){var y=l.get(b.userId+"_"+Dt),A=y?y.duration:0,D={uint32_video_stream_type:7,uint32_video_receive_fps:b.auxiliary.framesReceived,uint32_video_width:b.auxiliary.frameWidth,uint32_video_height:b.auxiliary.frameHeight,uint32_video_codec_bitrate:b.auxiliary.bytesReceived,uint32_video_receive:b.auxiliary.packetsReceived+b.auxiliary.packetsLost,uint32_video_origin_lost:b.auxiliary.packetsLost,uint32_video_block_time:A,uint32_video_dec_fps:b.auxiliary.framesDecoded};R.msg_video_status.push(D)}s.msg_down_stream_info.push(R)});var T=this.prevReport_;if(this.prevReport_=JSON.parse(JSON.stringify(s)),s.msg_up_stream_info.msg_audio_status&&T.msg_up_stream_info.msg_audio_status){var v=T.msg_up_stream_info.msg_audio_status,w=s.msg_up_stream_info.msg_audio_status,L=this.getDifferenceValue(v.uint32_audio_codec_bitrate,w.uint32_audio_codec_bitrate);w.uint32_audio_codec_bitrate=Math.round(8*L/m),s.msg_up_stream_info.msg_network_status.uint32_bitrate+=w.uint32_audio_codec_bitrate}var N=T.msg_up_stream_info.msg_video_status;s.msg_up_stream_info.msg_video_status.forEach(function(b){var R=N.find(function(y){return y.uint32_video_stream_type===b.uint32_video_stream_type});if(!R||R.uint32_video_codec_bitrate===0)return b.uint32_video_codec_bitrate=0,b.uint32_video_enc_fps=0,void(b.uint32_video_codec_fps=0);var P=R.uint32_video_codec_bitrate,U=R.uint32_video_enc_fps,k=R.uint32_video_codec_fps,f=c.getDifferenceValue(P,b.uint32_video_codec_bitrate);b.uint32_video_codec_bitrate=Math.round(8*f/m),s.msg_up_stream_info.msg_network_status.uint32_bitrate+=b.uint32_video_codec_bitrate,b.uint32_video_enc_fps=Math.round(c.getDifferenceValue(U,b.uint32_video_enc_fps)/m),b.uint32_video_codec_fps=Math.round(c.getDifferenceValue(k,b.uint32_video_codec_fps)/m)});var V=s.msg_down_stream_info,_=T.msg_down_stream_info;return V.forEach(function(b){var R=_.find(function(A){return A.msg_user_info.uint64_tinyid===b.msg_user_info.uint64_tinyid});if(R){if(b.msg_audio_status&&R.msg_audio_status){var P=b.msg_audio_status,U=R.msg_audio_status;P.uint32_audio_origin_lost=c.getDifferenceValue(U.uint32_audio_origin_lost,P.uint32_audio_origin_lost),P.uint32_audio_receive=c.getDifferenceValue(U.uint32_audio_receive,P.uint32_audio_receive),P.uint32_audio_receive+=P.uint32_audio_origin_lost;var k=c.getDifferenceValue(U.uint32_audio_codec_bitrate,P.uint32_audio_codec_bitrate);P.uint32_audio_codec_bitrate=Math.round(8*k/m),P.uint32_audio_total_bitrate=Math.round(8*k/m)}if(b.msg_video_status&&R.msg_video_status){var f=b.msg_video_status,y=R.msg_video_status;f.forEach(function(A){var D=y.find(function(Fe){return Fe.uint32_video_stream_type===A.uint32_video_stream_type});if(!D)return A.uint32_video_receive=0,A.uint32_video_origin_lost=0,A.uint32_video_codec_bitrate=0,A.uint32_video_receive_fps=0,void(A.uint32_video_dec_fps=0);var j=D.uint32_video_receive,K=D.uint32_video_origin_lost,J=D.uint32_video_codec_bitrate,se=D.uint32_video_receive_fps,ie=D.uint32_video_dec_fps;A.uint32_video_origin_lost=c.getDifferenceValue(K,A.uint32_video_origin_lost),A.uint32_video_receive=c.getDifferenceValue(j,A.uint32_video_receive)+A.uint32_video_origin_lost;var Je=c.getDifferenceValue(J,A.uint32_video_codec_bitrate);A.uint32_video_codec_bitrate=Math.round(8*Je/m);var Ue=c.getDifferenceValue(se,A.uint32_video_receive_fps);A.uint32_video_receive_fps=Math.round(Ue/m),A.uint32_video_dec_fps=Math.round(c.getDifferenceValue(ie,A.uint32_video_dec_fps)/m)})}}}),s}},{key:"getStatsReport",value:(t=H(p().mark(function o(c){var a,s,l,u,h;return p().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return a=c.uplinkConnection,s=c.downlinkConnections,l=c.freezeMap,u={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_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}}]},S.next=4,this.getStats(a,s);case 4:return h=S.sent,JSON.stringify(this.prevReport_)==="{}"&&(this.prevReport_=JSON.parse(JSON.stringify(u))),this.prepareReport({stats:h,report:u,freezeMap:l,uplinkConnection:a,downlinkConnections:s}),this.prevReportTime_=Date.now(),S.abrupt("return",u);case 9:case"end":return S.stop()}},o,this)})),function(o){return t.apply(this,arguments)})},{key:"reset",value:function(){this.prevReportTime_=0,this.prevReport_={},this.prevEncoderImplementation_="",this.prevQualityLimitationReason_="",this.prevDecoderImplementationMap_=new Map}}]),e}(),u6=function(){function e(i){var r=i.signalChannel,o=i.connections,c=i.client;Q(this,e),this.client_=c,this.signalChannel_=r,this.connections_=o,this.client_=c,this.log_=_e.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 ki,this.initialize()}var t,n;return xe(e,[{key:"uplinkNetworkQuality",get:function(){return this.uplinkNetworkQuality_},set:function(i){i!==this.uplinkNetworkQuality_&&this.log_.info("uplink network quality change ".concat(this.uplinkNetworkQuality," -> ").concat(i,", rtt: ").concat(this.uplinkRTT_,", loss: ").concat(this.uplinkLoss_)),this.uplinkNetworkQuality_=i}},{key:"downlinkNetworkQuality",get:function(){return this.downlinkNetworkQuality_},set:function(i){if(i!==this.downlinkNetworkQuality_){var r=this.getAverageLossAndRTT(Se(this.downlinkLossAndRTTMap_.values())),o=r.rtt,c=r.loss;this.log_.info("downlink network quality change ".concat(this.downlinkNetworkQuality," -> ").concat(i,", rtt: ").concat(o,", loss: ").concat(c))}this.downlinkNetworkQuality_=i}},{key:"initialize",value:function(){var i=this;this.signalChannel_.on(st.UPLINK_NETWORK_STATS,function(r){i.handleUplinkNetworkQuality(r)}),this.signalChannel_.on(am,this.handleSignalConnectionStateChange.bind(this)),this.start()}},{key:"handleUplinkNetworkQuality",value:function(i){if(!this.uplinkConnection_)return this.uplinkNetworkQuality=0,this.uplinkLoss_=0,void(this.uplinkRTT_=0);var r=this.uplinkConnection_.getPeerConnection();if(r&&this.isPeerConnectionDisconnected(r))return this.uplinkNetworkQuality=6,this.uplinkLoss_=0,void(this.uplinkRTT_=0);if(i.data.code===0){var o=i.data.data,c=o.expectAudPkg+o.expectVidPkg,a=o.recvAudPkg+o.recvVidPkg,s=c-a,l=o.delay;if(l&&this.updateDelay(l),c===0&&a===0)return;this.uplinkLoss_=s<=0?0:Math.round(s/c*100),this.uplinkRTT_=o.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this.uplinkLoss_,this.uplinkRTT_)}}},{key:"handleDownlinkNetworkQuality",value:(n=H(p().mark(function i(){var r,o,c,a,s,l,u,h,S,I,E,x,m,T,v,w=this;return p().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(this.connections_&&this.connections_.size!==0){L.next=3;break}return this.downlinkNetworkQuality=0,L.abrupt("return");case 3:if(r=Se(this.connections_.values()),o=r.filter(function(N){return N.getPeerConnection()&&N.getPeerConnection().connectionState===kb}),r.filter(function(N){return N.getPeerConnection()&&w.isPeerConnectionDisconnected(N.getPeerConnection())}).length!==r.length){L.next=9;break}return this.downlinkNetworkQuality=6,L.abrupt("return");case 9:c=0;case 10:if(!(c<o.length)){L.next=31;break}return a=o[c].getPeerConnection(),L.next=14,this.getStat(a);case 14:if(s=L.sent,l=s.rtt,u=s.totalPacketsLost,h=s.totalPacketsReceived,this.downlinkPrevStatMap_.has(a)){L.next=21;break}return this.downlinkPrevStatMap_.set(a,{totalPacketsLost:u,totalPacketsReceived:h}),L.abrupt("continue",28);case 21:S=0,I=this.downlinkPrevStatMap_.get(a),E=u-I.totalPacketsLost,x=h-I.totalPacketsReceived,S=E<=0||x<0?0:Math.round(E/(E+x)*100),this.downlinkPrevStatMap_.set(a,{totalPacketsLost:u,totalPacketsReceived:h}),this.downlinkLossAndRTTMap_.set(a,{rtt:l,loss:S,userId:o[c].getUserId()});case 28:c++,L.next=10;break;case 31:if(Se(this.downlinkPrevStatMap_.keys()).forEach(function(N){w.isPeerConnectionDisconnected(N)&&(w.downlinkPrevStatMap_.delete(N),w.downlinkLossAndRTTMap_.delete(N))}),this.downlinkLossAndRTTMap_.size!==0){L.next=34;break}return L.abrupt("return");case 34:m=this.getAverageLossAndRTT(Se(this.downlinkLossAndRTTMap_.values())),T=m.rtt,v=m.loss,this.downlinkRTT_=T,this.downlinkLoss_=v,this.downlinkNetworkQuality=this.getNetworkQuality(v,T);case 38:case"end":return L.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"getStat",value:(t=H(p().mark(function i(r){var o,c,a,s;return p().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(o={rtt:0,totalPacketsLost:0,totalPacketsReceived:0},r&&Fk()){l.next=3;break}return l.abrupt("return",o);case 3:c=r.getReceivers(),l.prev=4,a=0;case 6:if(!(a<c.length)){l.next=15;break}return s=c[a],l.next=10,s.getStats();case 10:l.sent.forEach(function(u){u.type==="candidate-pair"&&tr(u.currentRoundTripTime)&&(o.rtt=Math.round(1e3*u.currentRoundTripTime)),u.type!=="inbound-rtp"||u.mediaType!==Ee&&u.mediaType!==Ie||(o.totalPacketsLost+=u.packetsLost,o.totalPacketsReceived+=u.packetsReceived)});case 12:a++,l.next=6;break;case 15:return l.abrupt("return",o);case 18:return l.prev=18,l.t0=l.catch(4),l.abrupt("return",o);case 21:case"end":return l.stop()}},i,null,[[4,18]])})),function(i){return t.apply(this,arguments)})},{key:"getAverageLossAndRTT",value:function(i){var r={rtt:0,loss:0};return Array.isArray(i)&&i.length>0&&(i.forEach(function(o){r.rtt+=o.rtt,r.loss+=o.loss}),Object.keys(r).forEach(function(o){r[o]=Math.round(r[o]/i.length)})),r}},{key:"getNetworkQuality",value:function(i,r){return i>50||r>500?5:i>30||r>350?4:i>20||r>200?3:i>10||r>100?2:i>=0||r>=0?1:0}},{key:"handleSignalConnectionStateChange",value:function(i){i.state===pl?(this.uplinkRTT_=0,this.uplinkLoss_=0,this.uplinkNetworkQuality=6):i.state===oc&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"handleUplinkConnectionStateChange",value:function(i){var r=i.state;r===on?(this.uplinkLoss_=0,this.uplinkRTT_=0,this.uplinkNetworkQuality=6):r===sn&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"isPeerConnectionDisconnected",value:function(i){return!(!i||i.connectionState!==$M&&i.connectionState!==Sb&&i.connectionState!==Hf)}},{key:"setUplinkConnection",value:function(i){this.uplinkConnection_=i,this.uplinkConnection_?this.uplinkConnection_.on(et.CONNECTION_STATE_CHANGED,this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this.uplinkRTT_=0,this.uplinkLoss_=0)}},{key:"start",value:function(){var i=this;this.interval_===-1?(this.log_.info("start network quality calculating"),this.interval_=mt.run(uo,function(){i.handleDownlinkNetworkQuality(),Y.emit(Zp,{client:i.client_,uplinkNetworkQuality:i.uplinkNetworkQuality,downlinkNetworkQuality:i.downlinkNetworkQuality,uplinkRTT:i.uplinkRTT_,uplinkLoss:i.uplinkLoss_,downlinkRTT:i.downlinkRTT_,downlinkLoss:i.downlinkLoss_,downlinkLossAndRTTMap:i.downlinkLossAndRTTMap_}),i.emitter_.emit(ct.NETWORK_QUALITY,{uplinkNetworkQuality:i.uplinkNetworkQuality,downlinkNetworkQuality:i.downlinkNetworkQuality,uplinkRTT:i.uplinkRTT_,uplinkLoss:i.uplinkLoss_,downlinkRTT:i.downlinkRTT_,downlinkLoss:i.downlinkLoss_})},{delay:2e3})):this.log_.info("network quality calculating is already started")}},{key:"stop",value:function(){this.log_.info("stop network quality calculating"),this.interval_!==-1&&(mt.clearTask(this.interval_),this.interval_=-1),this.downlinkLossAndRTTMap_.clear(),this.downlinkPrevStatMap_.clear()}},{key:"on",value:function(i,r){this.emitter_.on(i,r)}},{key:"updateDelay",value:function(i){var r=this;i.forEach(function(o){var c=o.srcTinyId,a=o.videoDelay,s=o.audioDelay,l=r.connections_.get(c);l&&l.setDelay({videoDelay:a,audioDelay:s})})}}]),e}(),l6=function(){function e(i){Q(this,e),this.log_=_e.createLogger({id:i.client.getUserId(),userId:i.client.getUserId(),sdkAppId:i.client.getSDKAppId()}),this.localStream_=null,this.prevDevices_=[],this.initialize()}var t,n;return xe(e,[{key:"initialize",value:function(){navigator.mediaDevices&&navigator.mediaDevices.addEventListener&&(this.onDeviceChange=this.onDeviceChange.bind(this),navigator.mediaDevices.addEventListener("devicechange",this.onDeviceChange))}},{key:"destroy",value:function(){navigator.mediaDevices&&navigator.mediaDevices.removeEventListener&&navigator.mediaDevices.removeEventListener("devicechange",this.onDeviceChange)}},{key:"onDeviceChange",value:(n=H(p().mark(function i(){var r,o,c,a=this;return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(this.localStream_&&this.localStream_.getMediaStream()&&!this.localStream_.getScreen()){s.next=2;break}return s.abrupt("return");case 2:return s.next=4,Rm();case 4:r=s.sent,o=r.filter(function(l){return a.prevDevices_.findIndex(function(u){var h=u.deviceId;return l.deviceId===h})<0}),c=this.prevDevices_.filter(function(l){return r.findIndex(function(u){var h=u.deviceId;return l.deviceId===h})<0}),o.length>0&&this.handleDeviceAdded(this.prevDevices_,o),c.length>0&&this.handleDeviceRemoved(r,c),this.prevDevices_=r;case 10:case"end":return s.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"setLocalStream",value:(t=H(p().mark(function i(r){return p().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(!r){o.next=4;break}return o.next=3,Rm();case 3:this.prevDevices_=o.sent;case 4:this.localStream_=r;case 5:case"end":return o.stop()}},i,this)})),function(i){return t.apply(this,arguments)})},{key:"handleDeviceAdded",value:function(i,r){var o,c;if(this.localStream_){this.log_.warn("devicesAdded: ".concat(JSON.stringify(r))),this.localStream_.updateDeviceIdInUse();var a=r.filter(function(I){return I.kind===Gu}),s=r.filter(function(I){return I.kind===qs}),l=i.filter(function(I){return I.kind===Gu}),u=i.filter(function(I){return I.kind===qs}),h=a.length>0&&l.length===0&&((o=this.localStream_.getVideoTrack())===null||o===void 0?void 0:o.readyState)!=="live",S=s.length>0&&u.length===0&&((c=this.localStream_.getAudioTrack())===null||c===void 0?void 0:c.readyState)!=="live";if(S&&h)return this.log_.info("new microphone and camera detected, but there was no device before."),void this.localStream_.recoverCapture({audio:!0,video:!0,cameraId:a[0].deviceId,microphoneId:s[0].deviceId});h&&(this.log_.info("new camera detected, but there was no camera before."),this.localStream_.recoverCapture({audio:!1,video:!0,cameraId:a[0].deviceId})),S&&(this.log_.info("new microphone detected, but there was no microphone before."),this.localStream_.recoverCapture({audio:!0,video:!1,microphoneId:s[0].deviceId}))}}},{key:"handleDeviceRemoved",value:function(i,r){if(this.localStream_){this.log_.warn("devicesRemoved: ".concat(JSON.stringify(r))),this.localStream_.updateDeviceIdInUse();var o=!1,c=!1,a=this.localStream_.getCameraId(),s=this.localStream_.getMicrophoneId();if(s===Xu){var l=this.localStream_.getMicrophoneGroupId(),u=i.filter(function(h){return h.deviceId===Xu&&h.kind===qs})[0];u&&u.groupId!==l&&(c=!0)}if(r.forEach(function(h){var S=h.deviceId;a.length>0&&S===a?o=!0:s.length>0&&S===s&&(c=!0)}),o&&c)return this.log_.warn("current camera and microphone in use is lost, cameraId: ".concat(a,", microphoneId: ").concat(s)),void((this.localStream_.getAudio()||this.localStream_.getVideo())&&this.localStream_.recoverCapture({video:!0,audio:!0}));o&&(this.log_.warn("current camera in use is lost, deviceId: ".concat(a)),this.localStream_.getVideo()&&this.localStream_.recoverCapture({video:!0,audio:!1})),c&&(this.log_.warn("current microphone in use is lost, deviceId: ".concat(s)),this.localStream_.getAudio()&&this.localStream_.recoverCapture({video:!1,audio:!0}))}}}]),e}();function Em(){return Em=H(p().mark(function e(){var t;return p().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!yl()&&!_l()){n.next=2;break}return n.abrupt("return",[]);case 2:return n.next=4,Sl();case 4:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind===Gu}).map(function(i,r){var o=i.label;i.label||(o="camera_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),i.getCapabilities&&(c.getCapabilities=function(){return i.getCapabilities()}),c}));case 6:case"end":return n.stop()}},e)})),Em.apply(this,arguments)}var qk=new Set;function Sl(){return Kk.apply(this,arguments)}function Kk(){return(Kk=H(p().mark(function e(){var t;return p().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!yl()&&!_l()){n.next=2;break}return n.abrupt("return",[]);case 2:return n.next=4,navigator.mediaDevices.enumerateDevices();case 4:return(t=n.sent).forEach(function(i){qk.add("".concat(i.deviceId,"_").concat(i.kind))}),n.abrupt("return",t);case 7:case"end":return n.stop()}},e)}))).apply(this,arguments)}function Rm(){return Am.apply(this,arguments)}function Am(){return Am=H(p().mark(function e(){var t;return p().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Sl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind!==qs||i.deviceId!=Zb}).map(function(i,r){var o=i.label;i.label||(o=i.kind+"_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),i.getCapabilities&&(c.getCapabilities=function(){return i.getCapabilities()}),c}));case 4:case"end":return n.stop()}},e)})),Am.apply(this,arguments)}function Xk(){return Pm.apply(this,arguments)}function Pm(){return Pm=H(p().mark(function e(){var t;return p().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Sl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind===qs&&i.deviceId!==Zb}).map(function(i,r){var o=i.label;i.label||(o="microphone_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),i.getCapabilities&&(c.getCapabilities=function(){return i.getCapabilities()}),c}));case 4:case"end":return n.stop()}},e)})),Pm.apply(this,arguments)}function Qk(){return Dm.apply(this,arguments)}function Dm(){return Dm=H(p().mark(function e(){var t;return p().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Sl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind==="audiooutput"}).map(function(i,r){var o=i.label;i.label||(o="speaker_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),c}));case 4:case"end":return n.stop()}},e)})),Dm.apply(this,arguments)}function d6(e){var t;if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof window.MediaStreamTrack))return!1;var n=e.label.toLocaleLowerCase();if(n.includes("camera")||n.includes("webcam"))return!0;var i="".concat((t=e.getSettings())===null||t===void 0?void 0:t.deviceId,"_").concat(Gu);return!!qk.has(i)}function h6(e,t){return Yk.apply(this,arguments)}function Yk(){return(Yk=H(p().mark(function e(t,n){var i,r;return p().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,Xk();case 2:if(i=o.sent,((r=i.find(function(c){return c.deviceId===Xu}))==null?void 0:r.groupId)!==t||r.label!==n){o.next=6;break}return o.abrupt("return",!0);case 6:return o.abrupt("return",!1);case 7:case"end":return o.stop()}},e)}))).apply(this,arguments)}var Om=typeof ArrayBuffer!="undefined"&&typeof DataView!="undefined",f6=$n,p6=yr,m6=RangeError,$k=function(e){if(e===void 0)return 0;var t=f6(e),n=p6(t);if(t!==n)throw m6("Wrong length or index");return n},v6=Array,g6=Math.abs,Hr=Math.pow,_6=Math.floor,y6=Math.log,b6=Math.LN2,S6={pack:function(e,t,n){var i,r,o,c=v6(n),a=8*n-t-1,s=(1<<a)-1,l=s>>1,u=t===23?Hr(2,-24)-Hr(2,-77):0,h=e<0||e===0&&1/e<0?1:0,S=0;for((e=g6(e))!=e||e===1/0?(r=e!=e?1:0,i=s):(i=_6(y6(e)/b6),e*(o=Hr(2,-i))<1&&(i--,o*=2),(e+=i+l>=1?u/o:u*Hr(2,1-l))*o>=2&&(i++,o/=2),i+l>=s?(r=0,i=s):i+l>=1?(r=(e*o-1)*Hr(2,t),i+=l):(r=e*Hr(2,l-1)*Hr(2,t),i=0));t>=8;)c[S++]=255&r,r/=256,t-=8;for(i=i<<t|r,a+=t;a>0;)c[S++]=255&i,i/=256,a-=8;return c[--S]|=128*h,c},unpack:function(e,t){var n,i=e.length,r=8*i-t-1,o=(1<<r)-1,c=o>>1,a=r-7,s=i-1,l=e[s--],u=127&l;for(l>>=7;a>0;)u=256*u+e[s--],a-=8;for(n=u&(1<<-a)-1,u>>=-a,a+=t;a>0;)n=256*n+e[s--],a-=8;if(u===0)u=1-c;else{if(u===o)return n?NaN:l?-1/0:1/0;n+=Hr(2,t),u-=c}return(l?-1:1)*n*Hr(2,u-t)}},k6=Mt,Zk=ai,T6=nn,eT=function(e){for(var t=k6(this),n=T6(t),i=arguments.length,r=Zk(i>1?arguments[1]:void 0,n),o=i>2?arguments[2]:void 0,c=o===void 0?n:Zk(o,n);c>r;)t[r++]=e;return t},kl=re,Lm=pe,Mm=ye,I6=Om,tT=Yn,nT=Ln,rT=As,Nm=ue,Tl=si,x6=$n,w6=yr,Il=$k,iT=S6,C6=Ts,aT=Fa,E6=ii.f,R6=Pt.f,A6=eT,P6=fu,oT=zi,D6=tT.PROPER,sT=tT.CONFIGURABLE,So=Xe.get,cT=Xe.set,Um="ArrayBuffer",O6="DataView",uT="Wrong index",Bn=kl.ArrayBuffer,ir=Bn,ko=ir&&ir.prototype,xr=kl.DataView,da=xr&&xr.prototype,lT=Object.prototype,L6=kl.Array,xl=kl.RangeError,M6=Lm(A6),N6=Lm([].reverse),dT=iT.pack,hT=iT.unpack,fT=function(e){return[255&e]},pT=function(e){return[255&e,e>>8&255]},mT=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},vT=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},U6=function(e){return dT(e,23,4)},V6=function(e){return dT(e,52,8)},wl=function(e,t){R6(e.prototype,t,{get:function(){return So(this)[t]}})},xi=function(e,t,n,i){var r=Il(n),o=So(e);if(r+t>o.byteLength)throw xl(uT);var c=So(o.buffer).bytes,a=r+o.byteOffset,s=P6(c,a,a+t);return i?s:N6(s)},wi=function(e,t,n,i,r,o){var c=Il(n),a=So(e);if(c+t>a.byteLength)throw xl(uT);for(var s=So(a.buffer).bytes,l=c+a.byteOffset,u=i(+r),h=0;h<t;h++)s[l+h]=u[o?h:t-h-1]};if(I6){var gT=D6&&Bn.name!==Um;if(Nm(function(){Bn(1)})&&Nm(function(){new Bn(-1)})&&!Nm(function(){return new Bn,new Bn(1.5),new Bn(NaN),Bn.length!=1||gT&&!sT}))gT&&sT&&nT(Bn,"name",Um);else{(ir=function(e){return Tl(this,ko),new Bn(Il(e))}).prototype=ko;for(var Vm,_T=E6(Bn),yT=0;_T.length>yT;)(Vm=_T[yT++])in ir||nT(ir,Vm,Bn[Vm]);ko.constructor=ir}aT&&C6(da)!==lT&&aT(da,lT);var Cl=new xr(new ir(2)),bT=Lm(da.setInt8);Cl.setInt8(0,2147483648),Cl.setInt8(1,2147483649),!Cl.getInt8(0)&&Cl.getInt8(1)||rT(da,{setInt8:function(e,t){bT(this,e,t<<24>>24)},setUint8:function(e,t){bT(this,e,t<<24>>24)}},{unsafe:!0})}else ko=(ir=function(e){Tl(this,ko);var t=Il(e);cT(this,{bytes:M6(L6(t),0),byteLength:t}),Mm||(this.byteLength=t)}).prototype,xr=function(e,t,n){Tl(this,da),Tl(e,ko);var i=So(e).byteLength,r=x6(t);if(r<0||r>i)throw xl("Wrong offset");if(r+(n=n===void 0?i-r:w6(n))>i)throw xl("Wrong length");cT(this,{buffer:e,byteLength:n,byteOffset:r}),Mm||(this.buffer=e,this.byteLength=n,this.byteOffset=r)},da=xr.prototype,Mm&&(wl(ir,"byteLength"),wl(xr,"buffer"),wl(xr,"byteLength"),wl(xr,"byteOffset")),rT(da,{getInt8:function(e){return xi(this,1,e)[0]<<24>>24},getUint8:function(e){return xi(this,1,e)[0]},getInt16:function(e){var t=xi(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=xi(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return vT(xi(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return vT(xi(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return hT(xi(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return hT(xi(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){wi(this,1,e,fT,t)},setUint8:function(e,t){wi(this,1,e,fT,t)},setInt16:function(e,t){wi(this,2,e,pT,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){wi(this,2,e,pT,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){wi(this,4,e,mT,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){wi(this,4,e,mT,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){wi(this,4,e,U6,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){wi(this,8,e,V6,t,arguments.length>2?arguments[2]:void 0)}});oT(ir,Um),oT(xr,O6);var lc={ArrayBuffer:ir,DataView:xr},j6=Ps,B6="ArrayBuffer",ST=lc.ArrayBuffer;Le({global:!0,constructor:!0,forced:re.ArrayBuffer!==ST},{ArrayBuffer:ST}),j6(B6);var F6=Le,jm=pe,H6=ue,kT=Tt,TT=ai,G6=yr,W6=Lu,Bm=lc.ArrayBuffer,Fm=lc.DataView,IT=Fm.prototype,xT=jm(Bm.prototype.slice),z6=jm(IT.getUint8),J6=jm(IT.setUint8);F6({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:H6(function(){return!new Bm(2).slice(1,void 0).byteLength})},{slice:function(e,t){if(xT&&t===void 0)return xT(kT(this),e);for(var n=kT(this).byteLength,i=TT(e,n),r=TT(t===void 0?n:t,n),o=new(W6(this,Bm))(G6(r-i)),c=new Fm(this),a=new Fm(o),s=0;i<r;)J6(a,s++,z6(c,i++));return o}});var q6=function(){function e(){Q(this,e),this.set_=new Set,Y.on(ll,this.add,this),Y.on(po,this.add,this),Y.on(sa,this.delete,this),Y.on(mo,this.delete,this)}return xe(e,[{key:"add",value:function(t){var n=t.client,i=t.roomId,r=this.getKey(n.getUserId(),i||n.getRoomId(),n.getSDKAppId(),n.getUseStringRoomId());this.set_.add(r)}},{key:"delete",value:function(t){var n=t.client,i=this.getKey(n.getUserId(),n.getRoomId(),n.getSDKAppId(),n.getUseStringRoomId());this.set_.delete(i)}},{key:"getKey",value:function(t,n,i,r){return"".concat(i,"_").concat(n,"_").concat(t,"_").concat(r)}},{key:"isJoined",value:function(t){var n=t.userId,i=t.roomId,r=t.sdkAppId,o=t.client;return this.set_.has(this.getKey(n,i,r,o.getUseStringRoomId()))}}]),e}(),K6=new q6;function wT(e,t,n,i){if(this.useStringRoomId_){if(!(Bt(e)&&/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e)))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:VN,data:t,link:{className:i,fnName:n}})})}else if(!(tr(e)&&/^[1-9]\d*$/.test(String(e))&&e<4294967295))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:jN,data:t,link:{className:i,fnName:n}})})}function CT(e,t,n,i){if(!/^[A-Za-z\d_-]*$/.test(e))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:t3,data:t,link:{className:i,fnName:n}})})}var X6={createClient:{name:"clientConfig",required:!0,type:xn,properties:{sdkAppId:{required:!0,type:wt,allowEmpty:!1},userId:{required:!0,type:dt,allowEmpty:!1},userSig:{required:!0,type:dt,allowEmpty:!1},mode:{required:!0,type:dt,values:["rtc",zu]},useStringRoomId:{type:zt},autoSubscribe:{type:zt},enableAutoPlayDialog:{type:zt},streamId:{type:dt},userDefineRecordId:{type:dt},pureAudioPushMode:{type:wt,values:[1,2]},enableSEI:{type:zt}}},createStream:{name:"streamConfig",required:!0,type:xn,properties:{userId:{type:dt},audio:{type:zt},video:{type:zt},screen:{type:zt},screenAudio:{type:zt},microphoneId:{type:dt},cameraId:{type:dt},facingMode:{type:[dt,xn]},audioSource:{instanceOf:window.MediaStreamTrack},videoSource:{instanceOf:window.MediaStreamTrack}},validate:function(e){if(!ge(e.screen)&&e.screen&&ge(e.audio)&&(e.audio=!1),!(ge(e.audio)&&ge(e.video)||ge(e.audioSource)&&ge(e.videoSource)))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:U3})});if(!ge(e.screen)&&e.screen===!0&&e.video===!0)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:V3})});if(e.audio&&e.screenAudio)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:j3})});if(e.screen!==!0&&e.screenAudio===!0)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:B3})});if(!ge(e.screen)&&e.screen===!0&&!this.isScreenShareSupported())throw new te({code:Z.INVALID_OPERATION,message:ae({key:G3})})}}},Q6={join:{name:"options",required:!0,type:xn,properties:{roomId:{required:!0,type:[wt,dt],allowEmpty:!1,validate:wT},role:{type:[dt],values:[Tr,Zi]},privateMapKey:{type:[dt]}},validate:function(e){if(this.isJoined_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:UN})});if(this.checkDestroy(),K6.isJoined({userId:this.userId_,roomId:e.roomId,sdkAppId:this.sdkAppId_,client:this}))throw new te({code:Z.INVALID_OPERATION,message:ae({key:I3,data:this.userId_})})}},publish:[{name:"stream",required:!0,instanceOf:vi,validate:function(e){if(!this.isJoined_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:GN})});if(this.mode_===zu&&this.role_===Zi)throw new te({code:Z.INVALID_OPERATION,message:ae({key:zN})});if(!e.getIsReadyToPublish())throw new te({code:Z.INVALID_OPERATION,message:ae({key:JN})});if(this.notPublishWithoutH264Supported_)throw new te({code:Z.NOT_SUPPORTED_H264,message:ae({key:gS})})}},{name:"options",type:xn,defaultValue:{isAuxiliary:!1},properties:{isAuxiliary:{type:zt,defaultValue:!1,validate:function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(e&&!gl())throw new te({code:Z.NOT_SUPPORTED,message:ae({key:W3})});if(this.uplinkConnection_&&(e&&this.uplinkConnection_.isAuxStreamPublished||!e&&this.uplinkConnection_.isMainStreamPublished))throw new te({code:Z.INVALID_OPERATION,message:ae({key:qN,data:e?gt:"local"})});var t=this.localScreenStream_||Se(this.connections_.values()).findIndex(function(n){return n.getTrackState().auxiliary})>=0;if(!this.enableMultiAuxStream_&&e&&t)throw new te({code:Z.INVALID_OPERATION,message:ae({key:i4})})}}}}],unpublish:{name:"stream",required:!0,instanceOf:vi,validate:function(e){if(e!==this.localStream_&&e!==this.localAuxStream_){if(this.localStream_||this.localAuxStream_)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:WN})});this.log_.warn("Client currently has no published stream, please call publish() first.")}}},subscribe:[{name:"stream",required:!0,instanceOf:Yf,validate:function(e){if(!e.getConnection())throw new te({code:Z.INVALID_OPERATION,message:ae({key:np})});if(this.notSubscribeWithoutH264Supported_)throw new te({code:Z.NOT_SUPPORTED_H264,message:ae({key:_S})})}},{name:"options",type:xn,properties:{audio:{type:zt},video:{type:zt},smallVideo:{type:zt}},validate:function(e){var t=e.audio,n=e.video,i=e.smallVideo;if(t===!1&&n===!1&&(ge(i)||i===!1))throw new te({code:Z.INVALID_OPERATION,message:ae({key:Q3})})}}],unsubscribe:{name:"stream",required:!0,instanceOf:Yf,validate:function(e){if(!e.getConnection())throw new te({code:Z.INVALID_OPERATION,message:ae({key:np})})}},switchRole:{name:"role",required:!0,values:[Tr,Zi],validate:function(){if(this.mode_!==zu)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:XN})});if(!this.isJoined_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:QN})})}},startPublishCDNStream:{name:"options",required:!1,properties:{streamId:{type:dt,validate:CT},streamType:{type:dt,values:["main","auxiliary"]},appId:{type:wt,allowEmpty:!1},bizId:{type:wt,allowEmpty:!1},url:{type:dt,allowEmpty:!1}},validate:function(){if(this.isDestroyed_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:rp,data:{funName:"startPublishCDNStream"}})})}},startMixTranscode:{name:"config",required:!0,type:xn,properties:{mode:{type:dt,values:["preset-layout","manual"]},streamId:{type:dt,validate:CT},videoWidth:{type:wt,notLessThanZero:!0},videoHeight:{type:wt,notLessThanZero:!0},videoBitrate:{type:wt,notLessThanZero:!0,allowEmpty:!1},videoFramerate:{type:wt,validate:function(e,t,n,i){if(e<=0||e>30)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:R3,link:{className:i,fnName:n}})})}},videoGOP:{type:wt,validate:function(e,t,n,i){if(e<1||e>8)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:A3,link:{className:i,fnName:n}})})}},audioSampleRate:{type:wt,notLessThanZero:!0},audioBitrate:{type:wt,validate:function(e,t,n,i){if(e<32||e>192)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:P3,link:{className:i,fnName:n}})})}},audioChannels:{type:wt,values:[1,2]},backgroundColor:{type:wt},backgroundImage:{type:dt},mixUsers:{required:!0,type:Wb,arrayItem:{require:!0,type:xn,properties:{userId:{required:!0,type:dt},roomId:{type:[dt,wt],validate:wT},pureAudio:{type:zt},width:{type:wt,notLessThanZero:!0},height:{type:wt,notLessThanZero:!0},locationX:{type:wt,notLessThanZero:!0},locationY:{type:wt,notLessThanZero:!0},zOrder:{type:wt},streamType:{type:dt,values:["main","auxiliary"]},renderMode:{type:wt,values:[0,1,2,4]}}}}},validate:function(e,t,n,i,r){var o=0,c=0,a=e.mixUsers,s=[];if(a.forEach(function(l,u){if(s.push(l.userId),!l.pureAudio){if(!l.zOrder||l.zOrder<1||l.zOrder>15)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:D3,data:"config.mixUsers[".concat(u,"].zOrder"),link:{className:i,fnName:n}})});l.width+l.locationX>o&&(o=l.width+l.locationX),l.height+l.locationY>c&&(c=l.height+l.locationY)}}),s.indexOf(this.getUserId())<0)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:O3,link:{className:i,fnName:n}})});if(e.videoWidth<o||e.videoHeight<c)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:L3,link:{className:i,fnName:n}})})}},sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate:function(e){if(!bl)throw new te({code:Z.NOT_SUPPORTED,message:ae({key:bS})});if(!this.enableSEI_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:Y3})});if(e.byteLength>1e3)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:Z3,data:e.byteLength})});if(e.byteLength===0)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:$3})});if(!this.uplinkConnection_||!this.localStream_)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:e4})});if(!this.localStream_.hasVideo())throw new te({code:Z.INVALID_OPERATION,message:ae({key:t4})});var t=this.uplinkConnection_.isH264;if(!t)throw new te({code:Z.NOT_SUPPORTED,message:ae({key:bS,data:t})})}},{name:"options",type:xn,properties:{seiPayloadType:{type:wt,values:[5,243]}}}]},Y6={switchDevice:[{name:"type",required:!0,type:dt,values:[Ee,Ie]},{name:"deviceId",required:!0,type:dt,validate:function(){if(this.screen_&&!this.audio_||this.audioSource_||this.videoSource_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:l3})});if(this.publishState_===$s)throw new te({code:Z.INVALID_OPERATION,message:ae({key:d3})});if(!Im())throw new te({code:Z.NOT_SUPPORTED,message:ae({key:H3})})}}],setAudioCaptureVolume:{name:"volume",type:wt}},$6={play:[{name:"elementId",required:!0,type:[dt,"HTMLDivElement"],validate:function(e,t,n){if(Bt(e)){var i=document.getElementById(e);if(!i)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:M3,data:{key:t,fnName:n}})});if(!(i instanceof HTMLDivElement))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:N3,data:{key:t,fnName:n,type:Si(i)}})})}}},{name:"options",type:xn,properties:{objectFit:{type:dt,values:["contain","cover","fill"]},muted:{type:zt},mirror:{type:zt}}}],addTrack:{name:Vf,instanceOf:window.MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:f3})});if(this.isRemovingTrack_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:p3})});if(this.publishState_===$s)throw new te({code:Z.INVALID_OPERATION,message:ae({key:m3})});var t=this.getMediaStream();if(!t)throw new te({code:Z.INVALID_OPERATION,message:ae({key:pS})});if(e.kind===Ee&&t.getAudioTracks().length>0||e.kind===Ie&&t.getVideoTracks().length>0)throw new te({code:Z.INVALID_OPERATION,message:ae({key:v3})});if(!Ii()&&!vl())throw new te({code:Z.NOT_SUPPORTED,message:ae({key:ap,data:gb})})}},removeTrack:{name:Vf,instanceOf:window.MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:_3})});if(this.isRemovingTrack_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:y3})});if(this.publishState_===$s)throw new te({code:Z.INVALID_OPERATION,message:ae({key:b3})});var t=this.getMediaStream();if(!t)throw new te({code:Z.INVALID_OPERATION,message:ae({key:pS})});if(t.getTracks().indexOf(e)===-1)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:S3})});if(!Ii()){if(t.getTracks().length===1)throw new te({code:Z.INVALID_OPERATION,message:ae({key:k3})});if(e.kind===Ee)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:g3})});if(!vl())throw new te({code:Z.NOT_SUPPORTED,message:ae({key:ap,data:_b})})}}},replaceTrack:{name:Vf,instanceOf:window.MediaStreamTrack,validate:function(e){var t=this.getMediaStream();if(!t)throw new te({code:Z.INVALID_OPERATION,message:ae({key:h3})});if(this.publishState_===$s)throw new te({code:Z.INVALID_OPERATION,message:ae({key:fS})});if(e.kind===Ee&&t.getAudioTracks().length<=0||e.kind===Ie&&t.getVideoTracks().length<=0)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:T3,data:e})});if(!Im())throw new te({code:Z.NOT_SUPPORTED,message:ae({key:ap,data:FM})})}}},Yt={TRTC:X6,CLIENT:Q6,LOCAL_STREAM:Y6,STREAM:$6},Z6=Yn.PROPER,e5=ue,ET=s0,t5=Pu.trim;Le({target:"String",proto:!0,forced:function(e){return e5(function(){return!!ET[e]()||"\u200B\x85\u180E"[e]()!=="\u200B\x85\u180E"||Z6&&ET[e].name!==e})}("trim")},{trim:function(){return t5(this)}});var Gr="trtc_autoplay",Hm="".concat(Gr,"_mask"),To="".concat(Gr,"_wrapper"),RT="".concat(Gr,"_header"),Gm="".concat(Gr,"_content"),El="".concat(Gr,"_action_wrapper"),Wm="".concat(Gr,"_question"),zm="".concat(Gr,"_collapse"),Rl="".concat(Gr,"_action_confirm"),AT="".concat(Gr,"_detail"),PT="#2473E8",Jm="dialog",n5="".concat(Jm,"-show"),r5="".concat(Jm,"-1"),i5="".concat(Jm,"-2"),DT=!1,OT=function(){return!!document.querySelector(".".concat(To))},LT="".concat(co,"/").concat(oa()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),MT="<br><a href='".concat(LT,"' target='_blank'>").concat(oa()?"\u5176\u4ED6\u65B9\u6848\uFF1F":"Any other solution?","</a>"),a5="".concat(oa()?"\u6D4F\u89C8\u5668\u81EA\u52A8\u64AD\u653E\u7B56\u7565\uFF1A\u5728\u7528\u6237\u4E0E\u9875\u9762\u4EA7\u751F\u4EA4\u4E92\uFF08\u70B9\u51FB\u3001\u89E6\u6478\uFF09\u4E4B\u524D\uFF0C\u6D4F\u89C8\u5668\u7981\u6B62\u64AD\u653E\u6709\u58F0\u5A92\u4F53\u3002\u8BE5\u5F39\u7A97\u7528\u4E8E\u5E2E\u52A9\u7528\u6237\u6062\u590D\u97F3\u89C6\u9891\u64AD\u653E\u3002".concat(MT):"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(MT)),NT=function(){function e(){if(Q(this,e),this.dialogNode_=null,this.bodyPosition_="",this.content="\u97F3\u89C6\u9891\u64AD\u653E\u88AB\u6D4F\u89C8\u5668\u62E6\u622A\uFF0C\u8BF7\u70B9\u51FB\u201C\u6062\u590D\u64AD\u653E\u201D\u3002",oa()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!DT){var t=document.createElement("style");t.innerHTML=".".concat(Hm,"{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(Hm," div:not(.").concat(El,"){display:block !important;}.").concat(To,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(To," a{color:").concat(PT,";}.").concat(RT,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(Gm,"{margin:8px 0;}.").concat(El,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(zm,"{margin-right:auto;cursor:pointer}.").concat(Wm,"{height:100%;line-height:16px;cursor:pointer;}.").concat(Rl,"{margin-left:8px;color:#fff;background:").concat(PT,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(Rl,":hover{opacity:0.9;}.").concat(zm,",.").concat(Rl,",.").concat(Gm,",.").concat(Wm,"{font-size:14px;}@media screen and (max-width:750px){.").concat(To,"{width:80vw;}}"),document.head.appendChild(t),DT=!0}this.showDetail_=!1,this.isCollapseClicked_=!1,this.isQuestionClicked_=!1,this.addDiaLog()}return xe(e,[{key:"createDiaLog",value:function(){var t=document.createElement("template");t.innerHTML='<div class="'.concat(Hm,`"><div class='`).concat(To,"'><div class='").concat(RT,"'>").concat(location.host,"</div><div class='").concat(Gm,"'>").concat(this.content,"</div><div class='").concat(AT,`' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">`).concat(a5,"</div><div class='").concat(El,"'></div></div></div>").trim();var n=document.createElement("button");n.className=Rl,n.innerText=oa()?"\u6062\u590D\u64AD\u653E":"Resume",n.onclick=this.onConfirm.bind(this);var i=document.createElement("div");i.className=Wm,i.innerHTML=`<?xml version="1.0" encoding="UTF-8"?>
56
+ `};rr.write=zV,rr.parse=ua.parse,rr.parseParams=ua.parseParams,rr.parseFmtpConfig=ua.parseFmtpConfig,rr.parsePayloads=ua.parsePayloads,rr.parseRemoteCandidates=ua.parseRemoteCandidates,rr.parseImageAttributes=ua.parseImageAttributes,rr.parseSimulcastStreamList=ua.parseSimulcastStreamList;var mm,vm,gm,_m,Fr=function(e){return rr.parse(e)},yo=function(e){return rr.write(e)},WV=function(e){var t=Fr(e);return t.media.forEach(function(n){n.type===Re&&n.fmtp.forEach(function(i){i.config+=";sprop-stereo=1;stereo=1"})}),yo(t)},Lk=((mm=window)===null||mm===void 0?void 0:mm.requestIdleCallback)||function(e){var t=Date.now();return setTimeout(function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},1e3)},JV=((vm=window)===null||vm===void 0?void 0:vm.cancelIdleCallback)||function(e){clearTimeout(e)},qV=((gm=window)===null||gm===void 0?void 0:gm.cancelAnimationFrame)||((_m=window)===null||_m===void 0?void 0:_m.mozCancelAnimationFrame),mt=function(){function e(){Q(this,e)}return xe(e,null,[{key:"generateTaskID",value:function(){return this.currentTaskID++}},{key:"run",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:nS,n=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;i=J(J({},t===fN?{delay:2e3,count:0,backgroundTask:!0}:t===uo?{delay:1e4,count:0}:t===Qu?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0}),i),US(n)&&(i=J(J({},i),n)),ln(t)&&(n=t,t=nS);var r=J({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:t,callback:n},i);return this.taskMap.set(r.taskID,r),this[t](r),r.taskID}},{key:"interval",value:function(t){var n=this;return t.intervalID=setInterval(function(){t.callback(),t.loopCount+=1,n.isBreakLoop(t)},t.delay)}},{key:"timeout",value:function(t){var n=this;return t.timeoutID=setTimeout(function i(){if(t.callback(),t.loopCount+=1,!n.isBreakLoop(t))return t.timeoutID=setTimeout(i,t.delay)},t.delay)}},{key:"ric",value:function(t){var n,i=this,r=Ct();return t.ricID=Lk(function o(){if((n=Ct()-r)>=t.delay&&(r=Ct()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),!i.isBreakLoop(t))return t.ricID=Lk(o,{timeout:t.delay})},{timeout:t.delay})}},{key:"raf",value:function(t){var n=this;t.delay=(1e3/t.fps).toFixed(2);var i,r=Ct(),o=function a(){if(document.hidden&&t.backgroundTask)return i=Ct()-r,r=Ct(),t.callback(),t.loopCount+=1,n.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(a,t.delay-Math.floor(i%t.delay));if((i=Ct()-r)>=t.delay&&(r=Ct()-Math.floor(i%t.delay),t.callback(),t.loopCount+=1),!n.isBreakLoop(t))return t.rafID=requestAnimationFrame(a)};if(t.rafID=requestAnimationFrame(o),t.backgroundTask){var c=function(){if(document.hidden){var a=Ct()-r;a>=t.delay?o():t.timeoutID=setTimeout(o,t.delay-a)}};document.addEventListener("visibilitychange",c),t.onVisibilitychange=c,document.hidden&&c()}return t.taskID}},{key:"hasTask",value:function(t){return this.taskMap.has(t)}},{key:"clearTask",value:function(t){if(!this.taskMap.has(t))return!0;var n=this.taskMap.get(t),i=n.intervalID,r=n.timeoutID,o=n.rafID,c=n.ricID,a=n.onVisibilitychange;return i&&clearInterval(i),r&&clearTimeout(r),o&&qV(o),c&&JV(c),a&&document.removeEventListener("visibilitychange",a),this.taskMap.delete(t),!0}},{key:"isBreakLoop",value:function(t){return!this.taskMap.has(t.taskID)||t.count!==0&&t.loopCount>=t.count&&(this.clearTask(t.taskID),!0)}}]),e}();Ye(mt,"taskMap",new Map),Ye(mt,"currentTaskID",1);var KV=function(){function e(){Q(this,e),this.prefix_="TRTC",this.queue_=new Map,this.checkStorage()}return xe(e,[{key:"getRealKey",value:function(t){return"".concat(this.prefix_,"_").concat(t)}},{key:"checkStorage",value:function(){var t=this;if(ia()){var n=Object.keys(localStorage).filter(function(i){if(i.startsWith(t.prefix_)){var r=JSON.parse(localStorage.getItem(i));if(r&&r.expiresIn<Date.now())return!0}return!1});n.forEach(function(i){return localStorage.removeItem(i)})}}},{key:"doFlush",value:function(){if(ia())try{var t,n=ae(this.queue_);try{for(n.s();!(t=n.n()).done;){var i=Te(t.value,2),r=i[0],o=i[1];localStorage.setItem(r,JSON.stringify(o))}}catch(c){n.e(c)}finally{n.f()}}catch(c){_e.warn(c)}}},{key:"getItem",value:function(t){if(!ia())return null;try{var n=JSON.parse(localStorage.getItem(this.getRealKey(t)));return n&&n.expiresIn>=Date.now()?n.value:null}catch(i){_e.warn(i)}}},{key:"setItem",value:function(t,n){var i=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(ia())try{var r={expiresIn:Date.now()+Kb,value:n};i?localStorage.setItem(this.getRealKey(t),JSON.stringify(r)):(this.queue_.set(this.getRealKey(t),r),mt.hasTask(this.intervalId_)||(this.intervalId_=mt.run(uo,this.doFlush.bind(this),{count:1})))}catch(o){_e.warn(o)}}},{key:"deleteItem",value:function(t){if(!ia())return!1;try{return t=this.getRealKey(t),this.queue_.delete(t),localStorage.removeItem(t),!0}catch(n){return _e.warn(n),!1}}},{key:"clear",value:function(){if(ia())try{localStorage.clear()}catch(t){_e.warn(t)}}}]),e}(),bo=new KV,_t={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isMediaDevicesSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},Mk="checkResult",Nk=function(){return!y4&&!$u&&!(Zu&&ES<80)&&!(Vn&&CS<56)},ym=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter(function(e){return e in window}).length>0},XV=function(){if(!navigator.mediaDevices)return!1;var e=["getUserMedia","enumerateDevices"];return e.filter(function(t){return t in navigator.mediaDevices}).length===e.length},Uk=function(){var e=H(f().mark(function t(){var n,i,r,o,c,a;return f().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(!_t.detail.isH264EncodeSupported||!_t.detail.isVp8EncodeSupported){s.next=2;break}return s.abrupt("return",{isH264EncodeSupported:_t.detail.isH264EncodeSupported,isVp8EncodeSupported:_t.detail.isVp8EncodeSupported});case 2:return n="",i=!1,r=!1,s.prev=5,o=new RTCPeerConnection,(c=document.createElement(hb)).getContext("2d"),a=c.captureStream(0),o.addTrack(a.getVideoTracks()[0],a),s.next=13,o.createOffer();case 13:return(n=s.sent).sdp.toLowerCase().indexOf("h264")!==-1&&(i=!0),n.sdp.toLowerCase().indexOf("vp8")!==-1&&(r=!0),o.close(),_t.detail.isH264EncodeSupported=i,_t.detail.isVp8EncodeSupported=r,s.abrupt("return",{isH264EncodeSupported:_t.detail.isH264EncodeSupported,isVp8EncodeSupported:_t.detail.isVp8EncodeSupported});case 22:return s.prev=22,s.t0=s.catch(5),s.abrupt("return",{isH264EncodeSupported:!1,isVp8EncodeSupported:!1});case 25:case"end":return s.stop()}},t,null,[[5,22]])}));return function(){return e.apply(this,arguments)}}();function QV(){return bm.apply(this,arguments)}function bm(){return bm=H(f().mark(function e(){return f().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(){var n=H(f().mark(function i(r){var o,c,a,s,l,u,h,b,I,R,x,m,k,v;return f().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return o={encode:!1,decode:!1},c=null,w.prev=2,a=document.createElement("canvas"),s=a.getContext("2d"),a.width=640,a.height=480,l=setInterval(function(){s.fillText("test",Math.floor(640*Math.random()),Math.floor(480*Math.random()))},33),u=-1,h=-1,c=function(){clearInterval(u),clearInterval(l),clearTimeout(h),I.close(),R.close(),b.getTracks().forEach(function(L){return L.stop()})},h=setTimeout(function(){c(),r(o)},3e3),b=a.captureStream(),I=new RTCPeerConnection({}),R=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),I.addEventListener("icecandidate",function(L){return R.addIceCandidate(L.candidate)}),R.addEventListener("icecandidate",function(L){return I.addIceCandidate(L.candidate)}),I.addTrack(b.getVideoTracks()[0],b),w.next=20,I.createOffer();case 20:return x=w.sent,w.next=23,I.setLocalDescription(x);case 23:return w.next=25,R.setRemoteDescription(x);case 25:return w.next=27,R.createAnswer();case 27:return m=w.sent,k=Fr(m.sdp),v=k.media[0].rtp.findIndex(function(L){return L.codec==="H264"}),k.media[0].rtp=[k.media[0].rtp[v]],k.media[0].fmtp=k.media[0].fmtp.filter(function(L){return L.payload===k.media[0].rtp[0].payload}),k.media[0].rtcpFb=k.media[0].rtcpFb.filter(function(L){return L.payload===k.media[0].rtp[0].payload}),m.sdp=yo(k),w.next=36,R.setLocalDescription(m);case 36:return w.next=38,I.setRemoteDescription(m);case 38:u=setInterval(H(f().mark(function L(){var E,N;return f().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return o.encode&&o.decode&&(c(),r(o)),T.next=3,I.getStats();case 3:return E=T.sent,T.next=6,R.getStats();case 6:N=T.sent,o.encode||E.forEach(function(y){y.type==="outbound-rtp"&&y.mediaType===Ie&&y.framesEncoded>0&&(o.encode=!0)}),o.decode||N.forEach(function(y){y.type==="inbound-rtp"&&y.mediaType===Ie&&y.framesDecoded>0&&(o.decode=!0)});case 9:case"end":return T.stop()}},L)})),500),w.next=46;break;case 41:w.prev=41,w.t0=w.catch(2),c(),_e.warn(w.t0),r(o);case 46:case"end":return w.stop()}},i,null,[[2,41]])}));return function(i){return n.apply(this,arguments)}}()));case 1:case"end":return t.stop()}},e)})),bm.apply(this,arguments)}var Vk=function(){var e=H(f().mark(function t(){var n,i,r,o;return f().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(!_t.detail.isH264DecodeSupported||!_t.detail.isVp8DecodeSupported){c.next=2;break}return c.abrupt("return",{isH264DecodeSupported:_t.detail.isH264DecodeSupported,isVp8DecodeSupported:_t.detail.isVp8DecodeSupported});case 2:return n="",i=!1,r=!1,c.prev=5,o=new RTCPeerConnection,c.next=9,o.createOffer({offerToReceiveAudio:1,offerToReceiveVideo:1});case 9:return(n=c.sent).sdp.toLowerCase().indexOf("h264")!==-1&&(i=!0),n.sdp.toLowerCase().indexOf("vp8")!==-1&&(r=!0),o.close(),c.abrupt("return",{isH264DecodeSupported:i,isVp8DecodeSupported:r});case 16:return c.prev=16,c.t0=c.catch(5),c.abrupt("return",{isH264DecodeSupported:!1,isVp8DecodeSupported:!1});case 19:case"end":return c.stop()}},t,null,[[5,16]])}));return function(){return e.apply(this,arguments)}}(),YV=function(){var e=H(f().mark(function t(){var n,i,r,o,c,a,s,l,u,h,b,I,R;return f().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(jk()){x.next=2;break}return x.abrupt("return",_t);case 2:return n=Nk(),i=ym(),r=XV(),x.next=7,Uk();case 7:return o=x.sent,c=o.isH264EncodeSupported,a=o.isVp8EncodeSupported,x.next=12,Vk();case 12:if(s=x.sent,l=s.isH264DecodeSupported,u=s.isVp8DecodeSupported,c&&a){x.next=21;break}return x.next=18,Uk();case 18:h=x.sent,c=h.isH264EncodeSupported,a=h.isVp8EncodeSupported;case 21:if(!(c&&l&&(tl||nl||C4)&&!Nr&&lo()<79)){x.next=29;break}return x.next=24,QV();case 24:b=x.sent,I=b.encode,R=b.decode,c=I,l=R;case 29:return _t.result=n&&i&&r&&(c||a)&&(l||u),_t.detail.isBrowserSupported=n,_t.detail.isWebRTCSupported=i,_t.detail.isMediaDevicesSupported=r,_t.detail.isH264EncodeSupported=c,_t.detail.isVp8EncodeSupported=a,_t.detail.isH264DecodeSupported=l,_t.detail.isVp8DecodeSupported=u,$V(),bo.setItem(Mk,{ua:navigator.userAgent,checkResult:_t},!0),x.abrupt("return",_t);case 40:case"end":return x.stop()}},t)}));return function(){return e.apply(this,arguments)}}(),Sm=function(e,t){var n=null;return function(){if(n)return n;for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return(n=e.apply(t||this,r)).then(function(c){return n=null,c}).catch(function(c){throw n=null,c}),n}}(YV);function jk(){return Object.keys(_t.detail).findIndex(function(e){return!_t.detail[e]})>=0}function $V(){jk()&&(_e.warn(ie({key:vS})),_e.info("".concat(navigator.userAgent," ").concat(JSON.stringify(_t.detail))))}function Bk(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)}function Fk(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function ml(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function Ii(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function vl(){return"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype}function km(){return"RTCRtpSender"in window&&"replaceTrack"in window.RTCRtpSender.prototype}function Hk(){return"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype&&ml()}function gl(){return!!ge(navigator.mediaDevices)&&(_e.error(gi.NOT_SUPPORTED_MEDIA),!0)}function _l(){return location.protocol==="http:"&&!ra&&(_e.warn(ie({key:mS})),!0)}var Tm="RTCRtpSender"in window&&"createEncodedStreams"in window.RTCRtpSender.prototype&&lo()>=86;function Im(e){return!(e.type!=="candidate-pair"||!e.nominated||e.state!=="in-progress"&&e.state!=="succeeded")&&!(nr(e.selected)&&!e.selected)}var Gk=new Map([[ta,"Android"],[_i,"iOS"],[AS,"Windows"],[ec,"MacOS"],[PS,"Linux"]]);function xm(){var e="unknown";return Gk.get(!0)&&(e=Gk.get(!0)),e}function ZV(){var e="";return screen.width&&(e+=(screen.width?screen.width*window.devicePixelRatio:"")+" * "+(screen.height?screen.height*window.devicePixelRatio:"")),e}function e6(){var e=!1;return(navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)&&(e=!0),e}function t6(){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 zk(){return!(lp&&lo()<86)&&!(_i&&tr(yi)&&yi<15)&&!(bp&&bp<63)&&!(!Nk()||!("captureStream"in HTMLCanvasElement.prototype))}var la=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,n6=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,r6=function(){var e,t,n;return((e=window)===null||e===void 0?void 0:e.OffscreenCanvas)&&((t=window)===null||t===void 0?void 0:t.MediaStreamTrackProcessor)&&((n=window)===null||n===void 0?void 0:n.MediaStreamTrackGenerator)};(function(){_l();var e=bo.getItem(Mk);e&&e.ua===navigator.userAgent&&(_t=e.checkResult),Sm()})();var et={STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",STREAM_UPDATED:"stream-updated",STREAM_PUBLISHED:"stream-published",STREAM_SUBSCRIBED:"stream-subscribed",STREAM_UNSUBSCRIBED:"stream-unsubscribed",STATE_CHANGED:"state-changed",ERROR:"error",CONNECTION_STATE_CHANGED:"connection-state-changed",SEI_MESSAGE:vb},ct={STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",STREAM_UPDATED:"stream-updated",STREAM_SUBSCRIBED:"stream-subscribed",CONNECTION_STATE_CHANGED:"connection-state-changed",PEER_JOIN:"peer-join",PEER_LEAVE:"peer-leave",MUTE_AUDIO:"mute-audio",MUTE_VIDEO:"mute-video",UNMUTE_AUDIO:"unmute-audio",UNMUTE_VIDEO:"unmute-video",CLIENT_BANNED:"client-banned",NETWORK_QUALITY:"network-quality",AUDIO_VOLUME:"audio-volume",SEI_MESSAGE:vb,ERROR:"error"},Wk="player-state-changed",i6="screen-sharing-stopped",a6="connection-state-changed",o6="device-auto-recovered",wm="error",gn="player-state-changed",Jk="error",s6=aS;Le({target:"String",proto:!0,forced:oS("small")},{small:function(){return s6(this,"small","","")}});var c6=function(){function e(o){Q(this,e);var c=o.getUserId();this.log_=_e.createLogger({id:c,userId:c,sdkAppId:o.getSDKAppId()}),this.prevReportTime_=0,this.prevReport_={},this.prevEncoderImplementation_="",this.prevQualityLimitationReason_="",this.prevDecoderImplementationMap_=new Map}var t,n,i,r;return xe(e,[{key:"statInterval",get:function(){return this.prevReportTime_===0?2:(Date.now()-this.prevReportTime_)/1e3}},{key:"getSenderStats",value:(r=H(f().mark(function o(c){var a,s,l,u,h=this;return f().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(a={audio:{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0},video:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},small:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},auxiliary:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},rtt:0},s=c.getPeerConnection(),l=c.getSSRC(),!s){b.next=15;break}return b.prev=4,b.next=7,s.getStats();case 7:b.sent.forEach(function(I){var R;if(I.type==="outbound-rtp")if((I.mediaType||I.kind)===Ie){if(!Vn&&I.bytesSent===0)return;I.ssrc!==l.video||ge(I.encoderImplementation)||h.prevEncoderImplementation_===I.encoderImplementation||(h.log_.info("encoderImplementation change to ".concat(I.encoderImplementation)),h.prevEncoderImplementation_=I.encoderImplementation),I.ssrc!==l.video||ge(I.qualityLimitationReason)||h.prevQualityLimitationReason_===I.qualityLimitationReason||(h.log_.info("qualityLimitationReason change to ".concat(I.qualityLimitationReason)),h.prevQualityLimitationReason_=I.qualityLimitationReason);var x=Ie;I.ssrc===l.small?x=Mr:I.ssrc===l.auxiliary&&(x=gt),a[x].bytesSent=I.bytesSent,a[x].packetsSent=I.packetsSent,a[x].framesEncoded=I.framesEncoded}else a.audio.bytesSent=I.bytesSent,a.audio.packetsSent=I.packetsSent;else I.type==="candidate-pair"?Im(I)&&tr(I.currentRoundTripTime)&&(a.rtt=Math.floor(1e3*I.currentRoundTripTime)):I.type==="media-source"&&(I.kind===Re?(a.audio.audioLevel=I.audioLevel||0,a.audio.totalAudioEnergy=I.totalAudioEnergy||0):I.kind===Ie&&(I.trackIdentifier===c.getVideoTrackId(Ie)?a.video.fpsCapture=I.framesPerSecond:I.trackIdentifier===c.getVideoTrackId(gt)?a.auxiliary.fpsCapture=I.framesPerSecond:a.small.fpsCapture=I.framesPerSecond));ge(I.audioLevel)||(a.audio.audioLevel=I.audioLevel||0,a.audio.totalAudioEnergy=I.totalAudioEnergy||0),ge(I.frameWidth)||(I.trackIdentifier===c.getVideoTrackId(Ie)||I.ssrc===l.video?R=Ie:I.trackIdentifier===c.getVideoTrackId(gt)||I.ssrc===l.auxiliary?R=gt:I.trackIdentifier!==c.getVideoTrackId(Mr)&&I.ssrc!==l.small||(R=Mr),R&&(a[R].frameWidth=I.frameWidth,a[R].frameHeight=I.frameHeight,a[R].framesSent=I.framesSent))}),a.audio.audioLevel===0&&(a.audio.audioLevel=((u=c.getLocalStream())===null||u===void 0?void 0:u.getInternalAudioLevel())||0),b.next=15;break;case 12:b.prev=12,b.t0=b.catch(4),this.log_.warn("failed to getStats on sender connection "+b.t0);case 15:return b.abrupt("return",a);case 16:case"end":return b.stop()}},o,this,[[4,12]])})),function(o){return r.apply(this,arguments)})},{key:"getReceiverStats",value:(i=H(f().mark(function o(c){var a,s,l,u,h,b=this;return f().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(a={tinyId:c.getTinyId(),userId:c.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}},!(s=c.getPeerConnection())){I.next=16;break}return I.prev=3,l=c.getSSRC(),u=c.getTrackState(),I.next=8,s.getStats();case 8:I.sent.forEach(function(R){if(R.type==="inbound-rtp")if((R.mediaType||R.kind)===Re){if(R.ssrc!==l.audio||!u.audio)return;a.audio.packetsReceived=R.packetsReceived,a.audio.bytesReceived=R.bytesReceived,a.audio.packetsLost=R.packetsLost,a.audio.jitter=R.jitter,a.hasAudio=!0}else{if(Vn&&R.bytesReceived===0)return;R.ssrc===l.video&&u.video&&(a.video.packetsReceived=R.packetsReceived,a.video.bytesReceived=R.bytesReceived,a.video.packetsLost=R.packetsLost,a.video.framesReceived=R.framesReceived,a.video.framesDecoded=R.framesDecoded,a.video.fpsDecoded=R.framesPerSecond,a.hasVideo=!0,!R.decoderImplementation||b.prevDecoderImplementationMap_.has(a.userId)&&b.prevDecoderImplementationMap_.get(a.userId)===R.decoderImplementation||(b.log_.info("".concat(a.userId," decoderImplementation change to ").concat(R.decoderImplementation)),b.prevDecoderImplementationMap_.set(a.userId,R.decoderImplementation))),R.ssrc===l.auxiliary&&u.auxiliary&&(a.auxiliary.packetsReceived=R.packetsReceived,a.auxiliary.bytesReceived=R.bytesReceived,a.auxiliary.packetsLost=R.packetsLost,a.auxiliary.framesReceived=R.framesReceived,a.auxiliary.framesDecoded=R.framesDecoded,a.auxiliary.fpsDecoded=R.framesPerSecond,a.hasAuxiliary=!0)}else R.type==="candidate-pair"&&Im(R)&&tr(R.currentRoundTripTime)&&(a.rtt=Math.floor(1e3*R.currentRoundTripTime));ge(R.frameWidth)||(R.trackIdentifier!==c.getMainStreamVideoTrackId()&&R.ssrc!==l.video||(a.video.frameWidth=R.frameWidth,a.video.frameHeight=R.frameHeight),R.trackIdentifier!==c.getAuxStreamVideoTrackId()&&R.ssrc!==l.auxiliary||(a.auxiliary.frameWidth=R.frameWidth,a.auxiliary.frameHeight=R.frameHeight)),ge(R.audioLevel)||(a.audio.audioLevel=R.audioLevel||0,a.audio.totalAudioEnergy=R.totalAudioEnergy||0)}),a.audio.audioLevel===0&&(a.audio.audioLevel=((h=c.getMainStream())===null||h===void 0?void 0:h.getInternalAudioLevel())||0),I.next=16;break;case 13:I.prev=13,I.t0=I.catch(3),this.log_.warn("failed to getStats on receiver connection "+I.t0);case 16:return I.abrupt("return",a);case 17:case"end":return I.stop()}},o,this,[[3,13]])})),function(o){return i.apply(this,arguments)})},{key:"getStats",value:(n=H(f().mark(function o(c,a){var s,l,u,h,b,I,R;return f().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(s={},!c){x.next=5;break}return x.next=4,this.getSenderStats(c);case 4:s=x.sent;case 5:l=[],u=ae(a),x.prev=7,u.s();case 9:if((h=u.n()).done){x.next=17;break}return(b=Te(h.value,2))[0],I=b[1],x.next=13,this.getReceiverStats(I);case 13:R=x.sent,l.push(R);case 15:x.next=9;break;case 17:x.next=22;break;case 19:x.prev=19,x.t0=x.catch(7),u.e(x.t0);case 22:return x.prev=22,u.f(),x.finish(22);case 25:return x.abrupt("return",{senderStats:s,receiverStats:l});case 26:case"end":return x.stop()}},o,this,[[7,19,22,25]])})),function(o,c){return n.apply(this,arguments)})},{key:"getDifferenceValue",value:function(o,c){if(Br(o))return c;var a=c-o;return a<0?0:a}},{key:"prepareReport",value:function(o){var c=this,a=o.stats,s=o.report,l=o.freezeMap;if(!Br(a.senderStats)){var u;u={uint32_audio_level:1e8*a.senderStats.audio.audioLevel,uint32_audio_energy:1e6*a.senderStats.audio.totalAudioEnergy,uint32_audio_codec_bitrate:a.senderStats.audio.bytesSent,audioLevel:a.senderStats.audio.audioLevel};var h=[],b={uint32_video_stream_type:2,uint32_video_codec_fps:a.senderStats.video.framesSent,uint32_video_capture_fps:a.senderStats.video.fpsCapture,uint32_video_width:a.senderStats.video.frameWidth,uint32_video_height:a.senderStats.video.frameHeight,uint32_video_codec_bitrate:a.senderStats.video.bytesSent,uint32_video_enc_fps:a.senderStats.video.framesEncoded};if(h.push(b),a.senderStats.small.bytesSent){var I={uint32_video_stream_type:3,uint32_video_codec_fps:a.senderStats.small.framesSent||0,uint32_video_capture_fps:a.senderStats.small.fpsCapture||0,uint32_video_width:a.senderStats.small.frameWidth||0,uint32_video_height:a.senderStats.small.frameHeight||0,uint32_video_codec_bitrate:a.senderStats.small.bytesSent,uint32_video_enc_fps:a.senderStats.small.framesEncoded||0};h.push(I)}if(a.senderStats.auxiliary.bytesSent){var R={uint32_video_stream_type:7,uint32_video_codec_fps:a.senderStats.auxiliary.framesSent||0,uint32_video_capture_fps:a.senderStats.auxiliary.fpsCapture||0,uint32_video_width:a.senderStats.auxiliary.frameWidth||0,uint32_video_height:a.senderStats.auxiliary.frameHeight||0,uint32_video_codec_bitrate:a.senderStats.auxiliary.bytesSent,uint32_video_enc_fps:a.senderStats.auxiliary.framesEncoded||0};h.push(R)}var x={uint32_bitrate:0,uint32_rtt:a.senderStats.rtt};s.msg_up_stream_info={msg_audio_status:u,msg_video_status:h,msg_network_status:x}}var m=this.statInterval;s.msg_down_stream_info=[],a.receiverStats.forEach(function(y){var D={};if(D.msg_user_info={str_identifier:y.userId,uint64_tinyid:y.tinyId},D.msg_network_status={uint32_rtt:y.rtt},D.msg_video_status={},y.hasAudio){var A={uint32_audio_codec_bitrate:y.audio.bytesReceived,uint32_audio_total_bitrate:y.audio.bytesReceived,uint32_audio_level:1e8*y.audio.audioLevel,uint32_audio_energy:1e6*y.audio.totalAudioEnergy,uint32_audio_receive:y.audio.packetsReceived,uint32_audio_origin_lost:y.audio.packetsLost,audioLevel:y.audio.audioLevel};D.msg_audio_status=A}if(D.msg_video_status=[],y.hasVideo){var U=l.get(y.userId+"_"+yt),S=U?U.duration:0,p={uint32_video_stream_type:2,uint32_video_receive_fps:y.video.framesReceived,uint32_video_width:y.video.frameWidth,uint32_video_height:y.video.frameHeight,uint32_video_codec_bitrate:y.video.bytesReceived,uint32_video_receive:y.video.packetsReceived,uint32_video_origin_lost:y.video.packetsLost,uint32_video_block_time:S,uint32_video_dec_fps:y.video.framesDecoded};D.msg_video_status.push(p)}if(y.hasAuxiliary){var _=l.get(y.userId+"_"+Dt),P=_?_.duration:0,M={uint32_video_stream_type:7,uint32_video_receive_fps:y.auxiliary.framesReceived,uint32_video_width:y.auxiliary.frameWidth,uint32_video_height:y.auxiliary.frameHeight,uint32_video_codec_bitrate:y.auxiliary.bytesReceived,uint32_video_receive:y.auxiliary.packetsReceived+y.auxiliary.packetsLost,uint32_video_origin_lost:y.auxiliary.packetsLost,uint32_video_block_time:P,uint32_video_dec_fps:y.auxiliary.framesDecoded};D.msg_video_status.push(M)}s.msg_down_stream_info.push(D)});var k=this.prevReport_;if(this.prevReport_=JSON.parse(JSON.stringify(s)),s.msg_up_stream_info.msg_audio_status&&k.msg_up_stream_info.msg_audio_status){var v=k.msg_up_stream_info.msg_audio_status,w=s.msg_up_stream_info.msg_audio_status,L=this.getDifferenceValue(v.uint32_audio_codec_bitrate,w.uint32_audio_codec_bitrate);w.uint32_audio_codec_bitrate=Math.round(8*L/m),s.msg_up_stream_info.msg_network_status.uint32_bitrate+=w.uint32_audio_codec_bitrate}var E=k.msg_up_stream_info.msg_video_status;s.msg_up_stream_info.msg_video_status.forEach(function(y){var D=E.find(function(_){return _.uint32_video_stream_type===y.uint32_video_stream_type});if(!D||D.uint32_video_codec_bitrate===0)return y.uint32_video_codec_bitrate=0,y.uint32_video_enc_fps=0,void(y.uint32_video_codec_fps=0);var A=D.uint32_video_codec_bitrate,U=D.uint32_video_enc_fps,S=D.uint32_video_codec_fps,p=c.getDifferenceValue(A,y.uint32_video_codec_bitrate);y.uint32_video_codec_bitrate=Math.round(8*p/m),s.msg_up_stream_info.msg_network_status.uint32_bitrate+=y.uint32_video_codec_bitrate,y.uint32_video_enc_fps=Math.round(c.getDifferenceValue(U,y.uint32_video_enc_fps)/m),y.uint32_video_codec_fps=Math.round(c.getDifferenceValue(S,y.uint32_video_codec_fps)/m)});var N=s.msg_down_stream_info,T=k.msg_down_stream_info;return N.forEach(function(y){var D=T.find(function(P){return P.msg_user_info.uint64_tinyid===y.msg_user_info.uint64_tinyid});if(D){if(y.msg_audio_status&&D.msg_audio_status){var A=y.msg_audio_status,U=D.msg_audio_status;A.uint32_audio_origin_lost=c.getDifferenceValue(U.uint32_audio_origin_lost,A.uint32_audio_origin_lost),A.uint32_audio_receive=c.getDifferenceValue(U.uint32_audio_receive,A.uint32_audio_receive),A.uint32_audio_receive+=A.uint32_audio_origin_lost;var S=c.getDifferenceValue(U.uint32_audio_codec_bitrate,A.uint32_audio_codec_bitrate);A.uint32_audio_codec_bitrate=Math.round(8*S/m),A.uint32_audio_total_bitrate=Math.round(8*S/m)}if(y.msg_video_status&&D.msg_video_status){var p=y.msg_video_status,_=D.msg_video_status;p.forEach(function(P){var M=_.find(function(Fe){return Fe.uint32_video_stream_type===P.uint32_video_stream_type});if(!M)return P.uint32_video_receive=0,P.uint32_video_origin_lost=0,P.uint32_video_codec_bitrate=0,P.uint32_video_receive_fps=0,void(P.uint32_video_dec_fps=0);var B=M.uint32_video_receive,X=M.uint32_video_origin_lost,q=M.uint32_video_codec_bitrate,le=M.uint32_video_receive_fps,ce=M.uint32_video_dec_fps;P.uint32_video_origin_lost=c.getDifferenceValue(X,P.uint32_video_origin_lost),P.uint32_video_receive=c.getDifferenceValue(B,P.uint32_video_receive)+P.uint32_video_origin_lost;var Ze=c.getDifferenceValue(q,P.uint32_video_codec_bitrate);P.uint32_video_codec_bitrate=Math.round(8*Ze/m);var Ue=c.getDifferenceValue(le,P.uint32_video_receive_fps);P.uint32_video_receive_fps=Math.round(Ue/m),P.uint32_video_dec_fps=Math.round(c.getDifferenceValue(ce,P.uint32_video_dec_fps)/m)})}}}),s}},{key:"getStatsReport",value:(t=H(f().mark(function o(c){var a,s,l,u,h;return f().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return a=c.uplinkConnection,s=c.downlinkConnections,l=c.freezeMap,u={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_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}}]},b.next=4,this.getStats(a,s);case 4:return h=b.sent,JSON.stringify(this.prevReport_)==="{}"&&(this.prevReport_=JSON.parse(JSON.stringify(u))),this.prepareReport({stats:h,report:u,freezeMap:l,uplinkConnection:a,downlinkConnections:s}),this.prevReportTime_=Date.now(),b.abrupt("return",u);case 9:case"end":return b.stop()}},o,this)})),function(o){return t.apply(this,arguments)})},{key:"reset",value:function(){this.prevReportTime_=0,this.prevReport_={},this.prevEncoderImplementation_="",this.prevQualityLimitationReason_="",this.prevDecoderImplementationMap_=new Map}}]),e}(),u6=function(){function e(i){var r=i.signalChannel,o=i.connections,c=i.client;Q(this,e),this.client_=c,this.signalChannel_=r,this.connections_=o,this.client_=c,this.log_=_e.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 ki,this.initialize()}var t,n;return xe(e,[{key:"uplinkNetworkQuality",get:function(){return this.uplinkNetworkQuality_},set:function(i){i!==this.uplinkNetworkQuality_&&this.log_.info("uplink network quality change ".concat(this.uplinkNetworkQuality," -> ").concat(i,", rtt: ").concat(this.uplinkRTT_,", loss: ").concat(this.uplinkLoss_)),this.uplinkNetworkQuality_=i}},{key:"downlinkNetworkQuality",get:function(){return this.downlinkNetworkQuality_},set:function(i){if(i!==this.downlinkNetworkQuality_){var r=this.getAverageLossAndRTT(Se(this.downlinkLossAndRTTMap_.values())),o=r.rtt,c=r.loss;this.log_.info("downlink network quality change ".concat(this.downlinkNetworkQuality," -> ").concat(i,", rtt: ").concat(o,", loss: ").concat(c))}this.downlinkNetworkQuality_=i}},{key:"initialize",value:function(){var i=this;this.signalChannel_.on(st.UPLINK_NETWORK_STATS,function(r){i.handleUplinkNetworkQuality(r)}),this.signalChannel_.on(rm,this.handleSignalConnectionStateChange.bind(this)),this.start()}},{key:"handleUplinkNetworkQuality",value:function(i){if(!this.uplinkConnection_)return this.uplinkNetworkQuality=0,this.uplinkLoss_=0,void(this.uplinkRTT_=0);var r=this.uplinkConnection_.getPeerConnection();if(r&&this.isPeerConnectionDisconnected(r))return this.uplinkNetworkQuality=6,this.uplinkLoss_=0,void(this.uplinkRTT_=0);if(i.data.code===0){var o=i.data.data,c=o.expectAudPkg+o.expectVidPkg,a=o.recvAudPkg+o.recvVidPkg,s=c-a,l=o.delay;if(l&&this.updateDelay(l),c===0&&a===0)return;this.uplinkLoss_=s<=0?0:Math.round(s/c*100),this.uplinkRTT_=o.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this.uplinkLoss_,this.uplinkRTT_)}}},{key:"handleDownlinkNetworkQuality",value:(n=H(f().mark(function i(){var r,o,c,a,s,l,u,h,b,I,R,x,m,k,v,w=this;return f().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(this.connections_&&this.connections_.size!==0){L.next=3;break}return this.downlinkNetworkQuality=0,L.abrupt("return");case 3:if(r=Se(this.connections_.values()),o=r.filter(function(E){return E.getPeerConnection()&&E.getPeerConnection().connectionState===kb}),r.filter(function(E){return E.getPeerConnection()&&w.isPeerConnectionDisconnected(E.getPeerConnection())}).length!==r.length){L.next=9;break}return this.downlinkNetworkQuality=6,L.abrupt("return");case 9:c=0;case 10:if(!(c<o.length)){L.next=31;break}return a=o[c].getPeerConnection(),L.next=14,this.getStat(a);case 14:if(s=L.sent,l=s.rtt,u=s.totalPacketsLost,h=s.totalPacketsReceived,this.downlinkPrevStatMap_.has(a)){L.next=21;break}return this.downlinkPrevStatMap_.set(a,{totalPacketsLost:u,totalPacketsReceived:h}),L.abrupt("continue",28);case 21:b=0,I=this.downlinkPrevStatMap_.get(a),R=u-I.totalPacketsLost,x=h-I.totalPacketsReceived,b=R<=0||x<0?0:Math.round(R/(R+x)*100),this.downlinkPrevStatMap_.set(a,{totalPacketsLost:u,totalPacketsReceived:h}),this.downlinkLossAndRTTMap_.set(a,{rtt:l,loss:b,userId:o[c].getUserId()});case 28:c++,L.next=10;break;case 31:if(Se(this.downlinkPrevStatMap_.keys()).forEach(function(E){w.isPeerConnectionDisconnected(E)&&(w.downlinkPrevStatMap_.delete(E),w.downlinkLossAndRTTMap_.delete(E))}),this.downlinkLossAndRTTMap_.size!==0){L.next=34;break}return L.abrupt("return");case 34:m=this.getAverageLossAndRTT(Se(this.downlinkLossAndRTTMap_.values())),k=m.rtt,v=m.loss,this.downlinkRTT_=k,this.downlinkLoss_=v,this.downlinkNetworkQuality=this.getNetworkQuality(v,k);case 38:case"end":return L.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"getStat",value:(t=H(f().mark(function i(r){var o,c,a,s;return f().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(o={rtt:0,totalPacketsLost:0,totalPacketsReceived:0},r&&Fk()){l.next=3;break}return l.abrupt("return",o);case 3:c=r.getReceivers(),l.prev=4,a=0;case 6:if(!(a<c.length)){l.next=15;break}return s=c[a],l.next=10,s.getStats();case 10:l.sent.forEach(function(u){u.type==="candidate-pair"&&tr(u.currentRoundTripTime)&&(o.rtt=Math.round(1e3*u.currentRoundTripTime)),u.type!=="inbound-rtp"||u.mediaType!==Re&&u.mediaType!==Ie||(o.totalPacketsLost+=u.packetsLost,o.totalPacketsReceived+=u.packetsReceived)});case 12:a++,l.next=6;break;case 15:return l.abrupt("return",o);case 18:return l.prev=18,l.t0=l.catch(4),l.abrupt("return",o);case 21:case"end":return l.stop()}},i,null,[[4,18]])})),function(i){return t.apply(this,arguments)})},{key:"getAverageLossAndRTT",value:function(i){var r={rtt:0,loss:0};return Array.isArray(i)&&i.length>0&&(i.forEach(function(o){r.rtt+=o.rtt,r.loss+=o.loss}),Object.keys(r).forEach(function(o){r[o]=Math.round(r[o]/i.length)})),r}},{key:"getNetworkQuality",value:function(i,r){return i>50||r>500?5:i>30||r>350?4:i>20||r>200?3:i>10||r>100?2:i>=0||r>=0?1:0}},{key:"handleSignalConnectionStateChange",value:function(i){i.state===fl?(this.uplinkRTT_=0,this.uplinkLoss_=0,this.uplinkNetworkQuality=6):i.state===oc&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"handleUplinkConnectionStateChange",value:function(i){var r=i.state;r===on?(this.uplinkLoss_=0,this.uplinkRTT_=0,this.uplinkNetworkQuality=6):r===sn&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"isPeerConnectionDisconnected",value:function(i){return!(!i||i.connectionState!==$M&&i.connectionState!==Sb&&i.connectionState!==Bf)}},{key:"setUplinkConnection",value:function(i){this.uplinkConnection_=i,this.uplinkConnection_?this.uplinkConnection_.on(et.CONNECTION_STATE_CHANGED,this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this.uplinkRTT_=0,this.uplinkLoss_=0)}},{key:"start",value:function(){var i=this;this.interval_===-1?(this.log_.info("start network quality calculating"),this.interval_=mt.run(uo,function(){i.handleDownlinkNetworkQuality(),Y.emit(Yp,{client:i.client_,uplinkNetworkQuality:i.uplinkNetworkQuality,downlinkNetworkQuality:i.downlinkNetworkQuality,uplinkRTT:i.uplinkRTT_,uplinkLoss:i.uplinkLoss_,downlinkRTT:i.downlinkRTT_,downlinkLoss:i.downlinkLoss_,downlinkLossAndRTTMap:i.downlinkLossAndRTTMap_}),i.emitter_.emit(ct.NETWORK_QUALITY,{uplinkNetworkQuality:i.uplinkNetworkQuality,downlinkNetworkQuality:i.downlinkNetworkQuality,uplinkRTT:i.uplinkRTT_,uplinkLoss:i.uplinkLoss_,downlinkRTT:i.downlinkRTT_,downlinkLoss:i.downlinkLoss_})},{delay:2e3})):this.log_.info("network quality calculating is already started")}},{key:"stop",value:function(){this.log_.info("stop network quality calculating"),this.interval_!==-1&&(mt.clearTask(this.interval_),this.interval_=-1),this.downlinkLossAndRTTMap_.clear(),this.downlinkPrevStatMap_.clear()}},{key:"on",value:function(i,r){this.emitter_.on(i,r)}},{key:"updateDelay",value:function(i){var r=this;i.forEach(function(o){var c=o.srcTinyId,a=o.videoDelay,s=o.audioDelay,l=r.connections_.get(c);l&&l.setDelay({videoDelay:a,audioDelay:s})})}}]),e}(),l6=function(){function e(i){Q(this,e),this.log_=_e.createLogger({id:i.client.getUserId(),userId:i.client.getUserId(),sdkAppId:i.client.getSDKAppId()}),this.localStream_=null,this.prevDevices_=[],this.initialize()}var t,n;return xe(e,[{key:"initialize",value:function(){navigator.mediaDevices&&navigator.mediaDevices.addEventListener&&(this.onDeviceChange=this.onDeviceChange.bind(this),navigator.mediaDevices.addEventListener("devicechange",this.onDeviceChange))}},{key:"destroy",value:function(){navigator.mediaDevices&&navigator.mediaDevices.removeEventListener&&navigator.mediaDevices.removeEventListener("devicechange",this.onDeviceChange)}},{key:"onDeviceChange",value:(n=H(f().mark(function i(){var r,o,c,a=this;return f().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(this.localStream_&&this.localStream_.getMediaStream()&&!this.localStream_.getScreen()){s.next=2;break}return s.abrupt("return");case 2:return s.next=4,Em();case 4:r=s.sent,o=r.filter(function(l){return a.prevDevices_.findIndex(function(u){var h=u.deviceId;return l.deviceId===h})<0}),c=this.prevDevices_.filter(function(l){return r.findIndex(function(u){var h=u.deviceId;return l.deviceId===h})<0}),o.length>0&&this.handleDeviceAdded(this.prevDevices_,o),c.length>0&&this.handleDeviceRemoved(r,c),this.prevDevices_=r;case 10:case"end":return s.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"setLocalStream",value:(t=H(f().mark(function i(r){return f().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(!r){o.next=4;break}return o.next=3,Em();case 3:this.prevDevices_=o.sent;case 4:this.localStream_=r;case 5:case"end":return o.stop()}},i,this)})),function(i){return t.apply(this,arguments)})},{key:"handleDeviceAdded",value:function(i,r){var o,c;if(this.localStream_){this.log_.warn("devicesAdded: ".concat(JSON.stringify(r))),this.localStream_.updateDeviceIdInUse();var a=r.filter(function(I){return I.kind===Hu}),s=r.filter(function(I){return I.kind===qs}),l=i.filter(function(I){return I.kind===Hu}),u=i.filter(function(I){return I.kind===qs}),h=a.length>0&&l.length===0&&((o=this.localStream_.getVideoTrack())===null||o===void 0?void 0:o.readyState)!=="live",b=s.length>0&&u.length===0&&((c=this.localStream_.getAudioTrack())===null||c===void 0?void 0:c.readyState)!=="live";if(b&&h)return this.log_.info("new microphone and camera detected, but there was no device before."),void this.localStream_.recoverCapture({audio:!0,video:!0,cameraId:a[0].deviceId,microphoneId:s[0].deviceId});h&&(this.log_.info("new camera detected, but there was no camera before."),this.localStream_.recoverCapture({audio:!1,video:!0,cameraId:a[0].deviceId})),b&&(this.log_.info("new microphone detected, but there was no microphone before."),this.localStream_.recoverCapture({audio:!0,video:!1,microphoneId:s[0].deviceId}))}}},{key:"handleDeviceRemoved",value:function(i,r){if(this.localStream_){this.log_.warn("devicesRemoved: ".concat(JSON.stringify(r))),this.localStream_.updateDeviceIdInUse();var o=!1,c=!1,a=this.localStream_.getCameraId(),s=this.localStream_.getMicrophoneId();if(s===Ku){var l=this.localStream_.getMicrophoneGroupId(),u=i.filter(function(h){return h.deviceId===Ku&&h.kind===qs})[0];u&&u.groupId!==l&&(c=!0)}if(r.forEach(function(h){var b=h.deviceId;a.length>0&&b===a?o=!0:s.length>0&&b===s&&(c=!0)}),o&&c)return this.log_.warn("current camera and microphone in use is lost, cameraId: ".concat(a,", microphoneId: ").concat(s)),void((this.localStream_.getAudio()||this.localStream_.getVideo())&&this.localStream_.recoverCapture({video:!0,audio:!0}));o&&(this.log_.warn("current camera in use is lost, deviceId: ".concat(a)),this.localStream_.getVideo()&&this.localStream_.recoverCapture({video:!0,audio:!1})),c&&(this.log_.warn("current microphone in use is lost, deviceId: ".concat(s)),this.localStream_.getAudio()&&this.localStream_.recoverCapture({video:!1,audio:!0}))}}}]),e}();function Cm(){return Cm=H(f().mark(function e(){var t;return f().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!_l()&&!gl()){n.next=2;break}return n.abrupt("return",[]);case 2:return n.next=4,yl();case 4:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind===Hu}).map(function(i,r){var o=i.label;i.label||(o="camera_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),i.getCapabilities&&(c.getCapabilities=function(){return i.getCapabilities()}),c}));case 6:case"end":return n.stop()}},e)})),Cm.apply(this,arguments)}var qk=new Set;function yl(){return Kk.apply(this,arguments)}function Kk(){return(Kk=H(f().mark(function e(){var t;return f().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!_l()&&!gl()){n.next=2;break}return n.abrupt("return",[]);case 2:return n.next=4,navigator.mediaDevices.enumerateDevices();case 4:return(t=n.sent).forEach(function(i){qk.add("".concat(i.deviceId,"_").concat(i.kind))}),n.abrupt("return",t);case 7:case"end":return n.stop()}},e)}))).apply(this,arguments)}function Em(){return Rm.apply(this,arguments)}function Rm(){return Rm=H(f().mark(function e(){var t;return f().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,yl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind!==qs||i.deviceId!=Zb}).map(function(i,r){var o=i.label;i.label||(o=i.kind+"_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),i.getCapabilities&&(c.getCapabilities=function(){return i.getCapabilities()}),c}));case 4:case"end":return n.stop()}},e)})),Rm.apply(this,arguments)}function Xk(){return Am.apply(this,arguments)}function Am(){return Am=H(f().mark(function e(){var t;return f().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,yl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind===qs&&i.deviceId!==Zb}).map(function(i,r){var o=i.label;i.label||(o="microphone_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),i.getCapabilities&&(c.getCapabilities=function(){return i.getCapabilities()}),c}));case 4:case"end":return n.stop()}},e)})),Am.apply(this,arguments)}function Qk(){return Pm.apply(this,arguments)}function Pm(){return Pm=H(f().mark(function e(){var t;return f().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,yl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind==="audiooutput"}).map(function(i,r){var o=i.label;i.label||(o="speaker_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),c}));case 4:case"end":return n.stop()}},e)})),Pm.apply(this,arguments)}function d6(e){var t;if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof window.MediaStreamTrack))return!1;var n=e.label.toLocaleLowerCase();if(n.includes("camera")||n.includes("webcam"))return!0;var i="".concat((t=e.getSettings())===null||t===void 0?void 0:t.deviceId,"_").concat(Hu);return!!qk.has(i)}function h6(e,t){return Yk.apply(this,arguments)}function Yk(){return(Yk=H(f().mark(function e(t,n){var i,r;return f().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,Xk();case 2:if(i=o.sent,((r=i.find(function(c){return c.deviceId===Ku}))==null?void 0:r.groupId)!==t||r.label!==n){o.next=6;break}return o.abrupt("return",!0);case 6:return o.abrupt("return",!1);case 7:case"end":return o.stop()}},e)}))).apply(this,arguments)}var Bn,$k=Hi.exports,f6=Pt,p6=Tt,m6=t_,v6=Lr,g6=qe,_6=Mt,y6=function(e,t,n,i){try{return i?t(p6(n)[0],n[1]):t(n)}catch(r){m6(e,"throw",r)}},b6=lh,S6=yu,k6=nn,Zk=Cs,T6=pu,I6=Es,eT=Array,tT=function(e){var t=_6(e),n=S6(this),i=arguments.length,r=i>1?arguments[1]:void 0,o=r!==void 0;o&&(r=v6(r,i>2?arguments[2]:void 0));var c,a,s,l,u,h,b=I6(t),I=0;if(!b||this===eT&&b6(b))for(c=k6(t),a=n?new this(c):eT(c);c>I;I++)h=o?r(t[I],I):t[I],Zk(a,I,h);else for(u=(l=T6(t,b)).next,a=n?new this:[];!(s=g6(u,l)).done;I++)h=o?y6(l,r,[s.value,I],!0):s.value,Zk(a,I,h);return a.length=I,a},da=pe,Dm=2147483647,x6=/[^\0-\u007E]/,nT=/[.\u3002\uFF0E\uFF61]/g,rT="Overflow: input needs wider integers to process",iT=RangeError,w6=da(nT.exec),So=Math.floor,Om=String.fromCharCode,aT=da("".charCodeAt),oT=da([].join),xi=da([].push),C6=da("".replace),E6=da("".split),R6=da("".toLowerCase),sT=function(e){return e+22+75*(e<26)},A6=function(e,t,n){var i=0;for(e=n?So(e/700):e>>1,e+=So(e/t);e>455;)e=So(e/35),i+=36;return So(i+36*e/(e+38))},P6=function(e){var t=[];e=function(k){for(var v=[],w=0,L=k.length;w<L;){var E=aT(k,w++);if(E>=55296&&E<=56319&&w<L){var N=aT(k,w++);(64512&N)==56320?xi(v,((1023&E)<<10)+(1023&N)+65536):(xi(v,E),w--)}else xi(v,E)}return v}(e);var n,i,r=e.length,o=128,c=0,a=72;for(n=0;n<e.length;n++)(i=e[n])<128&&xi(t,Om(i));var s=t.length,l=s;for(s&&xi(t,"-");l<r;){var u=Dm;for(n=0;n<e.length;n++)(i=e[n])>=o&&i<u&&(u=i);var h=l+1;if(u-o>So((Dm-c)/h))throw iT(rT);for(c+=(u-o)*h,o=u,n=0;n<e.length;n++){if((i=e[n])<o&&++c>Dm)throw iT(rT);if(i==o){for(var b=c,I=36;;){var R=I<=a?1:I>=a+26?26:I-a;if(b<R)break;var x=b-R,m=36-R;xi(t,Om(sT(R+x%m))),b=So(x/m),I+=36}xi(t,Om(sT(b))),a=A6(c,h,l==s),c=0,l++}}c++,o++}return oT(t,"")},D6=Le,Lm=ye,O6=Iy,Mm=re,cT=Lr,Fn=pe,bl=Qt,Hn=function(e,t,n){return n.get&&$k(n.get,t,{getter:!0}),n.set&&$k(n.set,t,{setter:!0}),f6.f(e,t,n)},L6=si,Nm=kt,Um=ik,ko=tT,ir=hu,M6=vh.codeAt,N6=function(e){var t,n,i=[],r=E6(C6(R6(e),nT,"."),".");for(t=0;t<r.length;t++)n=r[t],xi(i,w6(x6,n)?"xn--"+P6(n):n);return oT(i,".")},Hr=zt,U6=Wi,V6=_u,uT=AD,lT=Ke,j6=lT.set,Sl=lT.getterFor("URL"),B6=uT.URLSearchParams,F6=uT.getState,lc=Mm.URL,Vm=Mm.TypeError,kl=Mm.parseInt,H6=Math.floor,dT=Math.pow,Gn=Fn("".charAt),ar=Fn(/./.exec),dc=Fn([].join),G6=Fn(1 .toString),z6=Fn([].pop),To=Fn([].push),hT=Fn("".replace),W6=Fn([].shift),J6=Fn("".split),hc=Fn("".slice),Tl=Fn("".toLowerCase),q6=Fn([].unshift),jm="Invalid scheme",ha="Invalid host",fT="Invalid port",pT=/[a-z]/i,K6=/[\d+-.a-z]/i,Bm=/\d/,X6=/^0x/i,Q6=/^[0-7]+$/,Y6=/^\d+$/,mT=/^[\da-f]+$/i,$6=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Z6=/[\0\t\n\r #/:<>?@[\\\]^|]/,e5=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,t5=/[\t\n\r]/g,fc=function(e){var t,n,i,r;if(typeof e=="number"){for(t=[],n=0;n<4;n++)q6(t,e%256),e=H6(e/256);return dc(t,".")}if(typeof e=="object"){for(t="",i=function(o){for(var c=null,a=1,s=null,l=0,u=0;u<8;u++)o[u]!==0?(l>a&&(c=s,a=l),s=null,l=0):(s===null&&(s=u),++l);return l>a&&(c=s,a=l),c}(e),n=0;n<8;n++)r&&e[n]===0||(r&&(r=!1),i===n?(t+=n?":":"::",r=!0):(t+=G6(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},Il={},vT=Um({},Il,{" ":1,'"':1,"<":1,">":1,"`":1}),gT=Um({},vT,{"#":1,"?":1,"{":1,"}":1}),Fm=Um({},gT,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),wi=function(e,t){var n=M6(e,0);return n>32&&n<127&&!Nm(t,e)?e:encodeURIComponent(e)},xl={ftp:21,file:null,http:80,https:443,ws:80,wss:443},pc=function(e,t){var n;return e.length==2&&ar(pT,Gn(e,0))&&((n=Gn(e,1))==":"||!t&&n=="|")},_T=function(e){var t;return e.length>1&&pc(hc(e,0,2))&&(e.length==2||(t=Gn(e,2))==="/"||t==="\\"||t==="?"||t==="#")},n5=function(e){return e==="."||Tl(e)==="%2e"},Hm={},yT={},Gm={},bT={},ST={},zm={},kT={},TT={},wl={},Cl={},Wm={},Jm={},qm={},Km={},IT={},Xm={},Io={},xr={},xT={},fa={},Gr={},Qm=function(e,t,n){var i,r,o,c=Hr(e);if(t){if(r=this.parse(c))throw Vm(r);this.searchParams=null}else{if(n!==void 0&&(i=new Qm(n,!0)),r=this.parse(c,null,i))throw Vm(r);(o=F6(new B6)).bindURL(this),this.searchParams=o}};Qm.prototype={type:"URL",parse:function(e,t,n){var i,r,o,c,a,s=this,l=t||Hm,u=0,h="",b=!1,I=!1,R=!1;for(e=Hr(e),t||(s.scheme="",s.username="",s.password="",s.host=null,s.port=null,s.path=[],s.query=null,s.fragment=null,s.cannotBeABaseURL=!1,e=hT(e,e5,"")),e=hT(e,t5,""),i=ko(e);u<=i.length;){switch(r=i[u],l){case Hm:if(!r||!ar(pT,r)){if(t)return jm;l=Gm;continue}h+=Tl(r),l=yT;break;case yT:if(r&&(ar(K6,r)||r=="+"||r=="-"||r=="."))h+=Tl(r);else{if(r!=":"){if(t)return jm;h="",l=Gm,u=0;continue}if(t&&(s.isSpecial()!=Nm(xl,h)||h=="file"&&(s.includesCredentials()||s.port!==null)||s.scheme=="file"&&!s.host))return;if(s.scheme=h,t)return void(s.isSpecial()&&xl[s.scheme]==s.port&&(s.port=null));h="",s.scheme=="file"?l=Km:s.isSpecial()&&n&&n.scheme==s.scheme?l=bT:s.isSpecial()?l=TT:i[u+1]=="/"?(l=ST,u++):(s.cannotBeABaseURL=!0,To(s.path,""),l=xT)}break;case Gm:if(!n||n.cannotBeABaseURL&&r!="#")return jm;if(n.cannotBeABaseURL&&r=="#"){s.scheme=n.scheme,s.path=ir(n.path),s.query=n.query,s.fragment="",s.cannotBeABaseURL=!0,l=Gr;break}l=n.scheme=="file"?Km:zm;continue;case bT:if(r!="/"||i[u+1]!="/"){l=zm;continue}l=wl,u++;break;case ST:if(r=="/"){l=Cl;break}l=xr;continue;case zm:if(s.scheme=n.scheme,r==Bn)s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=ir(n.path),s.query=n.query;else if(r=="/"||r=="\\"&&s.isSpecial())l=kT;else if(r=="?")s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=ir(n.path),s.query="",l=fa;else{if(r!="#"){s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=ir(n.path),s.path.length--,l=xr;continue}s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=ir(n.path),s.query=n.query,s.fragment="",l=Gr}break;case kT:if(!s.isSpecial()||r!="/"&&r!="\\"){if(r!="/"){s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,l=xr;continue}l=Cl}else l=wl;break;case TT:if(l=wl,r!="/"||Gn(h,u+1)!="/")continue;u++;break;case wl:if(r!="/"&&r!="\\"){l=Cl;continue}break;case Cl:if(r=="@"){b&&(h="%40"+h),b=!0,o=ko(h);for(var x=0;x<o.length;x++){var m=o[x];if(m!=":"||R){var k=wi(m,Fm);R?s.password+=k:s.username+=k}else R=!0}h=""}else if(r==Bn||r=="/"||r=="?"||r=="#"||r=="\\"&&s.isSpecial()){if(b&&h=="")return"Invalid authority";u-=ko(h).length+1,h="",l=Wm}else h+=r;break;case Wm:case Jm:if(t&&s.scheme=="file"){l=Xm;continue}if(r!=":"||I){if(r==Bn||r=="/"||r=="?"||r=="#"||r=="\\"&&s.isSpecial()){if(s.isSpecial()&&h=="")return ha;if(t&&h==""&&(s.includesCredentials()||s.port!==null))return;if(c=s.parseHost(h))return c;if(h="",l=Io,t)return;continue}r=="["?I=!0:r=="]"&&(I=!1),h+=r}else{if(h=="")return ha;if(c=s.parseHost(h))return c;if(h="",l=qm,t==Jm)return}break;case qm:if(!ar(Bm,r)){if(r==Bn||r=="/"||r=="?"||r=="#"||r=="\\"&&s.isSpecial()||t){if(h!=""){var v=kl(h,10);if(v>65535)return fT;s.port=s.isSpecial()&&v===xl[s.scheme]?null:v,h=""}if(t)return;l=Io;continue}return fT}h+=r;break;case Km:if(s.scheme="file",r=="/"||r=="\\")l=IT;else{if(!n||n.scheme!="file"){l=xr;continue}if(r==Bn)s.host=n.host,s.path=ir(n.path),s.query=n.query;else if(r=="?")s.host=n.host,s.path=ir(n.path),s.query="",l=fa;else{if(r!="#"){_T(dc(ir(i,u),""))||(s.host=n.host,s.path=ir(n.path),s.shortenPath()),l=xr;continue}s.host=n.host,s.path=ir(n.path),s.query=n.query,s.fragment="",l=Gr}}break;case IT:if(r=="/"||r=="\\"){l=Xm;break}n&&n.scheme=="file"&&!_T(dc(ir(i,u),""))&&(pc(n.path[0],!0)?To(s.path,n.path[0]):s.host=n.host),l=xr;continue;case Xm:if(r==Bn||r=="/"||r=="\\"||r=="?"||r=="#"){if(!t&&pc(h))l=xr;else if(h==""){if(s.host="",t)return;l=Io}else{if(c=s.parseHost(h))return c;if(s.host=="localhost"&&(s.host=""),t)return;h="",l=Io}continue}h+=r;break;case Io:if(s.isSpecial()){if(l=xr,r!="/"&&r!="\\")continue}else if(t||r!="?")if(t||r!="#"){if(r!=Bn&&(l=xr,r!="/"))continue}else s.fragment="",l=Gr;else s.query="",l=fa;break;case xr:if(r==Bn||r=="/"||r=="\\"&&s.isSpecial()||!t&&(r=="?"||r=="#")){if((a=Tl(a=h))===".."||a==="%2e."||a===".%2e"||a==="%2e%2e"?(s.shortenPath(),r=="/"||r=="\\"&&s.isSpecial()||To(s.path,"")):n5(h)?r=="/"||r=="\\"&&s.isSpecial()||To(s.path,""):(s.scheme=="file"&&!s.path.length&&pc(h)&&(s.host&&(s.host=""),h=Gn(h,0)+":"),To(s.path,h)),h="",s.scheme=="file"&&(r==Bn||r=="?"||r=="#"))for(;s.path.length>1&&s.path[0]==="";)W6(s.path);r=="?"?(s.query="",l=fa):r=="#"&&(s.fragment="",l=Gr)}else h+=wi(r,gT);break;case xT:r=="?"?(s.query="",l=fa):r=="#"?(s.fragment="",l=Gr):r!=Bn&&(s.path[0]+=wi(r,Il));break;case fa:t||r!="#"?r!=Bn&&(r=="'"&&s.isSpecial()?s.query+="%27":s.query+=r=="#"?"%23":wi(r,Il)):(s.fragment="",l=Gr);break;case Gr:r!=Bn&&(s.fragment+=wi(r,vT))}u++}},parseHost:function(e){var t,n,i;if(Gn(e,0)=="["){if(Gn(e,e.length-1)!="]"||(t=function(r){var o,c,a,s,l,u,h,b=[0,0,0,0,0,0,0,0],I=0,R=null,x=0,m=function(){return Gn(r,x)};if(m()==":"){if(Gn(r,1)!=":")return;x+=2,R=++I}for(;m();){if(I==8)return;if(m()!=":"){for(o=c=0;c<4&&ar(mT,m());)o=16*o+kl(m(),16),x++,c++;if(m()=="."){if(c==0||(x-=c,I>6))return;for(a=0;m();){if(s=null,a>0){if(!(m()=="."&&a<4))return;x++}if(!ar(Bm,m()))return;for(;ar(Bm,m());){if(l=kl(m(),10),s===null)s=l;else{if(s==0)return;s=10*s+l}if(s>255)return;x++}b[I]=256*b[I]+s,++a!=2&&a!=4||I++}if(a!=4)return;break}if(m()==":"){if(x++,!m())return}else if(m())return;b[I++]=o}else{if(R!==null)return;x++,R=++I}}if(R!==null)for(u=I-R,I=7;I!=0&&u>0;)h=b[I],b[I--]=b[R+u-1],b[R+--u]=h;else if(I!=8)return;return b}(hc(e,1,-1)),!t))return ha;this.host=t}else if(this.isSpecial()){if(e=N6(e),ar($6,e)||(t=function(r){var o,c,a,s,l,u,h,b=J6(r,".");if(b.length&&b[b.length-1]==""&&b.length--,(o=b.length)>4)return r;for(c=[],a=0;a<o;a++){if((s=b[a])=="")return r;if(l=10,s.length>1&&Gn(s,0)=="0"&&(l=ar(X6,s)?16:8,s=hc(s,l==8?1:2)),s==="")u=0;else{if(!ar(l==10?Y6:l==8?Q6:mT,s))return r;u=kl(s,l)}To(c,u)}for(a=0;a<o;a++)if(u=c[a],a==o-1){if(u>=dT(256,5-o))return null}else if(u>255)return null;for(h=z6(c),a=0;a<c.length;a++)h+=c[a]*dT(256,3-a);return h}(e),t===null))return ha;this.host=t}else{if(ar(Z6,e))return ha;for(t="",n=ko(e),i=0;i<n.length;i++)t+=wi(n[i],Il);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme=="file"},includesCredentials:function(){return this.username!=""||this.password!=""},isSpecial:function(){return Nm(xl,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||this.scheme=="file"&&t==1&&pc(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,n=e.username,i=e.password,r=e.host,o=e.port,c=e.path,a=e.query,s=e.fragment,l=t+":";return r!==null?(l+="//",e.includesCredentials()&&(l+=n+(i?":"+i:"")+"@"),l+=fc(r),o!==null&&(l+=":"+o)):t=="file"&&(l+="//"),l+=e.cannotBeABaseURL?c[0]:c.length?"/"+dc(c,"/"):"",a!==null&&(l+="?"+a),s!==null&&(l+="#"+s),l},setHref:function(e){var t=this.parse(e);if(t)throw Vm(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if(e=="blob")try{return new xo(e.path[0]).origin}catch(n){return"null"}return e!="file"&&this.isSpecial()?e+"://"+fc(this.host)+(t!==null?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Hr(e)+":",Hm)},getUsername:function(){return this.username},setUsername:function(e){var t=ko(Hr(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=wi(t[n],Fm)}},getPassword:function(){return this.password},setPassword:function(e){var t=ko(Hr(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=wi(t[n],Fm)}},getHost:function(){var e=this.host,t=this.port;return e===null?"":t===null?fc(e):fc(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,Wm)},getHostname:function(){var e=this.host;return e===null?"":fc(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Jm)},getPort:function(){var e=this.port;return e===null?"":Hr(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||((e=Hr(e))==""?this.port=null:this.parse(e,qm))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+dc(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Io))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){(e=Hr(e))==""?this.query=null:(Gn(e,0)=="?"&&(e=hc(e,1)),this.query="",this.parse(e,fa)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){(e=Hr(e))!=""?(Gn(e,0)=="#"&&(e=hc(e,1)),this.fragment="",this.parse(e,Gr)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var xo=function(e){var t=L6(this,dn),n=V6(arguments.length,1)>1?arguments[1]:void 0,i=j6(t,new Qm(e,!1,n));Lm||(t.href=i.serialize(),t.origin=i.getOrigin(),t.protocol=i.getProtocol(),t.username=i.getUsername(),t.password=i.getPassword(),t.host=i.getHost(),t.hostname=i.getHostname(),t.port=i.getPort(),t.pathname=i.getPathname(),t.search=i.getSearch(),t.searchParams=i.getSearchParams(),t.hash=i.getHash())},dn=xo.prototype,zn=function(e,t){return{get:function(){return Sl(this)[e]()},set:t&&function(n){return Sl(this)[t](n)},configurable:!0,enumerable:!0}};if(Lm&&(Hn(dn,"href",zn("serialize","setHref")),Hn(dn,"origin",zn("getOrigin")),Hn(dn,"protocol",zn("getProtocol","setProtocol")),Hn(dn,"username",zn("getUsername","setUsername")),Hn(dn,"password",zn("getPassword","setPassword")),Hn(dn,"host",zn("getHost","setHost")),Hn(dn,"hostname",zn("getHostname","setHostname")),Hn(dn,"port",zn("getPort","setPort")),Hn(dn,"pathname",zn("getPathname","setPathname")),Hn(dn,"search",zn("getSearch","setSearch")),Hn(dn,"searchParams",zn("getSearchParams")),Hn(dn,"hash",zn("getHash","setHash"))),bl(dn,"toJSON",function(){return Sl(this).serialize()},{enumerable:!0}),bl(dn,"toString",function(){return Sl(this).serialize()},{enumerable:!0}),lc){var wT=lc.createObjectURL,CT=lc.revokeObjectURL;wT&&bl(xo,"createObjectURL",cT(wT,lc)),CT&&bl(xo,"revokeObjectURL",cT(CT,lc))}U6(xo,"URL"),D6({global:!0,constructor:!0,forced:!O6,sham:!Lm},{URL:xo});var pa,El,r5=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"}),ET=!1,i5=function(){function e(n){Q(this,e),this.context_=n.context,this.addModuleToContext()}var t;return xe(e,[{key:"addModuleToContext",value:(t=H(f().mark(function n(){return f().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,i.next=3,this.context_.audioWorklet.addModule(URL.createObjectURL(r5));case 3:_e.info("worklet addModule success"),Y.emit($p),ET=!0,i.next=12;break;case 8:i.prev=8,i.t0=i.catch(0),_e.info("worklet addModule catch error. ".concat(i.t0.message)),Y.emit(Zp);case 12:case"end":return i.stop()}},n,this,[[0,8]])})),function(){return t.apply(this,arguments)})},{key:"initWorkletSuccess",get:function(){return ET}}]),e}(),mc=0,a5=function(){function e(t){Q(this,e);var n=t.track,i=t.log,r=t.stream;this.volume_=0,this.log_=i,this.track_=n,this.stream_=r,mc+=1,pa||(pa=FS()),this.audioCtx_=pa,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,Y.on(rc,this.resume,this),Y.on(Np,this.handleAudioLevelInterval,this),A4?(Y.on($p,this.initAudioWorklet,this),Y.on(Zp,this.initScriptProcessor,this),this.preload()):this.initScriptProcessor()}return xe(e,[{key:"preload",value:function(){El?El.initWorkletSuccess&&this.initAudioWorklet():El=new i5({context:pa})}},{key:"initAudioWorklet",value:function(){var t=this;if(!this.audioWorkletNode_)try{this.audioWorkletNode_=new AudioWorkletNode(this.audioCtx_,"volume-meter"),this.audioWorkletNode_.port.onmessage=function(n){t.volume_=n.data.volume||0},this.streamSource_.connect(this.audioWorkletNode_).connect(this.destination_),this.handleAudioLevelInterval({interval:this.interval_})}catch(n){this.log_.warn("load volume meter failed, load again. error: "+n),this.initScriptProcessor()}}},{key:"initScriptProcessor",value:function(){var t=this;if(!this.scriptProcessorNode_)try{this.scriptProcessorNode_=this.audioCtx_.createScriptProcessor(2048,1,1),this.scriptProcessorNode_.onaudioprocess=function(n){for(var i=n.inputBuffer.getChannelData(0),r=0,o=0;o<i.length;++o)r+=i[o]*i[o];t.volume_=Math.sqrt(r/i.length)||0},this.streamSource_.connect(this.scriptProcessorNode_),this.scriptProcessorNode_.connect(this.destination_)}catch(n){this.log_.error("volumeMeter init script processor error: "+n),mc-=1}}},{key:"destroy",value:function(){var t;this.streamSource_&&this.streamSource_.disconnect(),this.scriptProcessorNode_&&(this.scriptProcessorNode_.onaudioprocess=null,this.scriptProcessorNode_.disconnect()),this.audioWorkletNode_&&(this.audioWorkletNode_.port.postMessage({name:"stop"}),this.audioWorkletNode_.port.onmessage=null,this.audioWorkletNode_.disconnect()),this.audioWorkletNode_=null,this.scriptProcessorNode_=null,this.audioCtx_=null,Y.off(rc,this.resume,this),Y.off(Np,this.handleAudioLevelInterval,this),Y.off($p,this.initAudioWorklet,this),Y.off(Zp,this.initScriptProcessor,this),mc>0&&(mc-=1),mc===0&&((t=pa)===null||t===void 0||t.close(),pa=null,El=null)}},{key:"resume",value:function(){var t;(t=pa)===null||t===void 0||t.resume()}},{key:"getInternalAudioLevel",value:function(){return this.volume_}},{key:"getCalculatedVolume",value:function(){return this.volume_.toFixed(2)}},{key:"handleAudioLevelInterval",value:function(t){var n,i=t.interval;this.interval_=i,(n=this.audioWorkletNode_)===null||n===void 0||n.port.postMessage({name:"setIntervalTime",intervalTime:i})}}]),e}(),o5=function(){function e(o){Q(this,e),this.stream_=o.stream,this.userId_=o.stream.getUserId(),this.log_=this.stream_.getLogger(),this.track_=o.track,o.gainedTrack&&(this.gainedTrack_=o.gainedTrack),this.div_=o.div,this.muted_=o.muted,this.outputDeviceId_=o.outputDeviceId,this.volume_=o.volume,this.pausedRetryCount_=5,this.emitter_=new ki,this.initializeElement(),this.state_="NONE",this.volumeMeter_=new a5({stream:this.stream_,track:this.gainedTrack_||this.track_,log:this.log_})}var t,n,i,r;return xe(e,[{key:"isPlaying",get:function(){return this.state_===ao}},{key:"initializeElement",value:function(){if(this.isAudioElementInit()){var o=new MediaStream;o.addTrack(this.gainedTrack_||this.track_);var c=document.createElement(Re);c.srcObject=o,c.muted=this.muted_,c.setAttribute("id","audio_".concat(this.stream_.getId())),c.setAttribute("autoplay","autoplay"),c.setAttribute("playsinline","playsinline"),this.div_.appendChild(c),this.element_=c}this.handleEvents()}},{key:"setMuted",value:function(o){this.element_&&(this.element_.muted=o,this.muted_=o)}},{key:"play",value:(r=H(f().mark(function o(){var c;return f().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!this.outputDeviceId_||!this.element_){a.next=3;break}return a.next=3,this.element_.setSinkId(this.outputDeviceId_);case 3:if(this.setVolume(this.volume_),a.prev=4,!this.element_){a.next=8;break}return a.next=8,this.element_.play();case 8:a.next=16;break;case 10:if(a.prev=10,a.t0=a.catch(4),c=ie({key:np,data:{media:"Audio",error:a.t0}}),this.log_.warn(c),!c.includes("NotAllowedError")){a.next=16;break}throw new te({code:Z.PLAY_NOT_ALLOWED,message:c});case 16:case"end":return a.stop()}},o,this,[[4,10]])})),function(){return r.apply(this,arguments)})},{key:"handleEvents",value:function(){this.handleElementEvent=this.handleElementEvent.bind(this),this.handleTrackEvent=this.handleTrackEvent.bind(this),this.element_&&(this.element_.addEventListener(hi,this.handleElementEvent),this.element_.addEventListener(Nt,this.handleElementEvent),this.element_.addEventListener(fi,this.handleElementEvent),this.element_.addEventListener(io,this.handleElementEvent)),this.track_.addEventListener(Nt,this.handleTrackEvent),this.track_.addEventListener(tn,this.handleTrackEvent),this.track_.addEventListener(Sr,this.handleTrackEvent),this.track_.readyState===Nt&&this.handleTrackEvent({type:Nt}),this.track_.muted&&this.handleTrackEvent({type:tn})}},{key:"handleElementEvent",value:(i=H(f().mark(function o(c){var a,s,l,u,h,b,I,R=this;return f().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:a=c.type,x.t0=a,x.next=x.t0===hi?4:x.t0===Nt?9:x.t0===fi?12:x.t0===io?21:33;break;case 4:return this.log_.info("audio player is playing"),this.state_=ao,Y.emit(Vp,{stream:this.stream_}),this.emitter_.emit(gn,{state:this.state_,reason:hi}),x.abrupt("break",33);case 9:return this.log_.info("audio player is ended"),this.state_!==pi&&(this.state_=pi,this.emitter_.emit(gn,{state:this.state_,reason:Nt})),x.abrupt("break",33);case 12:return this.log_.info("audio player is paused"),this.state_=kr,this.emitter_.emit(gn,{state:this.state_,reason:fi}),(s=this.div_&&document.getElementById(this.div_.id))||this.log_.warn("audio player has been remove, element ID: ".concat(this.div_.id)),l=lo(),this.pausedRetryCount_>0&&(tr(l)&&l<=70||!s)&&(this.resume(),this.pausedRetryCount_--),_i&&(this.interval_=mt.run(function(){R.element_&&R.state_===kr&&R.resume()},{delay:3e3})),x.abrupt("break",33);case 21:if(!this.element_||!this.element_.error){x.next=32;break}return u="".concat(xm(),"/").concat(aa().name,"/").concat(aa().version),x.next=25,It.getSpeakers();case 25:h=x.sent,b=h[0].label,(I=h.find(function(m){return m.deviceId===R.outputDeviceId_}))&&(b=I.label),this.log_.error("audio player error observed. code: ".concat(this.element_.error.code," message: ").concat(this.element_.error.message," deviceInfo: ").concat(u," speaker: ").concat(b)),ke.uploadEvent({log:"stat-".concat(this.stream_.getType(),"-audio-").concat(Bb,"-").concat(this.element_.error.code,"-").concat(u,"-").concat(b),userId:this.userId_,error:this.element_.error}),this.emitter_.emit(Jk,this.element_.error);case 32:return x.abrupt("break",33);case 33:case"end":return x.stop()}},o,this)})),function(o){return i.apply(this,arguments)})},{key:"handleTrackEvent",value:function(o){var c=o.type;switch(c){case Nt:this.log_.info("audio track is ended"),this.state_!==pi&&(this.state_=pi,this.emitter_.emit(gn,{state:this.state_,reason:Nt})),Y.emit(Xp,{stream:this.stream_,type:c});break;case tn:this.log_.info("audio track is unable to provide media output"),this.stream_.isRemote()||BS(),this.state_!==kr&&(this.state_=kr,this.emitter_.emit(gn,{state:this.state_,reason:tn})),Y.emit(Kp,{stream:this.stream_,type:c});break;case Sr:this.log_.info("audio track is able to provide media output"),this.state_===kr&&(this.state_=ao,this.emitter_.emit(gn,{state:this.state_,reason:Sr}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(hi,this.handleElementEvent),this.element_.removeEventListener(Nt,this.handleElementEvent),this.element_.removeEventListener(fi,this.handleElementEvent),this.element_.removeEventListener(io,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Nt,this.handleTrackEvent),this.track_.removeEventListener(tn,this.handleTrackEvent),this.track_.removeEventListener(Sr,this.handleTrackEvent))}},{key:"setSinkId",value:(n=H(f().mark(function o(c){return f().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.outputDeviceId_===c){a.next=5;break}if(!this.element_){a.next=4;break}return a.next=4,this.element_.setSinkId(c);case 4:this.outputDeviceId_=c;case 5:case"end":return a.stop()}},o,this)})),function(o){return n.apply(this,arguments)})},{key:"setVolume",value:function(o){this.element_&&(this.log_.info("audioElement setVolume to : ".concat(o)),this.element_.volume=o)}},{key:"getAudioLevel",value:function(){return this.volumeMeter_.getCalculatedVolume()}},{key:"getInternalAudioLevel",value:function(){return this.volumeMeter_.getInternalAudioLevel()}},{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),this.interval_>0&&mt.clearTask(this.interval_)}},{key:"resume",value:(t=H(f().mark(function o(){var c;return f().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(a.prev=0,this.volumeMeter_&&this.volumeMeter_.resume(),!this.element_){a.next=5;break}return a.next=5,this.element_.play();case 5:a.next=13;break;case 7:if(a.prev=7,a.t0=a.catch(0),c=ie({key:np,data:{media:"Audio",error:a.t0}}),this.log_.warn(c),!c.includes("NotAllowedError")){a.next=13;break}throw new te({code:Z.PLAY_NOT_ALLOWED,message:c});case 13:case"end":return a.stop()}},o,this,[[0,7]])})),function(){return t.apply(this,arguments)})},{key:"on",value:function(o,c){this.emitter_.on(o,c)}},{key:"isAudioElementInit",value:function(){return!(yi==="15.2"||yi==="15.3"||yi==="15.4")||this.stream_.getType()!=="local"||!this.muted_||(this.log_.info("audioElement is muted."),!1)}},{key:"getTrack",value:function(){return this.track_}}]),e}(),s5=Yn.PROPER,c5=se,RT=s0,u5=Au.trim;Le({target:"String",proto:!0,forced:function(e){return c5(function(){return!!RT[e]()||"\u200B\x85\u180E"[e]()!=="\u200B\x85\u180E"||s5&&RT[e].name!==e})}("trim")},{trim:function(){return u5(this)}});var zr="trtc_autoplay",Ym="".concat(zr,"_mask"),wo="".concat(zr,"_wrapper"),AT="".concat(zr,"_header"),$m="".concat(zr,"_content"),Rl="".concat(zr,"_action_wrapper"),Zm="".concat(zr,"_question"),ev="".concat(zr,"_collapse"),Al="".concat(zr,"_action_confirm"),PT="".concat(zr,"_detail"),DT="#2473E8",tv="dialog",l5="".concat(tv,"-show"),d5="".concat(tv,"-1"),h5="".concat(tv,"-2"),OT=!1,LT=function(){return!!document.querySelector(".".concat(wo))},MT="".concat(co,"/").concat(oa()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),NT="<br><a href='".concat(MT,"' target='_blank'>").concat(oa()?"\u5176\u4ED6\u65B9\u6848\uFF1F":"Any other solution?","</a>"),f5="".concat(oa()?"\u6D4F\u89C8\u5668\u81EA\u52A8\u64AD\u653E\u7B56\u7565\uFF1A\u5728\u7528\u6237\u4E0E\u9875\u9762\u4EA7\u751F\u4EA4\u4E92\uFF08\u70B9\u51FB\u3001\u89E6\u6478\uFF09\u4E4B\u524D\uFF0C\u6D4F\u89C8\u5668\u7981\u6B62\u64AD\u653E\u6709\u58F0\u5A92\u4F53\u3002\u8BE5\u5F39\u7A97\u7528\u4E8E\u5E2E\u52A9\u7528\u6237\u6062\u590D\u97F3\u89C6\u9891\u64AD\u653E\u3002".concat(NT):"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(NT)),UT=function(){function e(){if(Q(this,e),this.dialogNode_=null,this.bodyPosition_="",this.content="\u97F3\u89C6\u9891\u64AD\u653E\u88AB\u6D4F\u89C8\u5668\u62E6\u622A\uFF0C\u8BF7\u70B9\u51FB\u201C\u6062\u590D\u64AD\u653E\u201D\u3002",oa()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!OT){var t=document.createElement("style");t.innerHTML=".".concat(Ym,"{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(Ym," div:not(.").concat(Rl,"){display:block !important;}.").concat(wo,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(wo," a{color:").concat(DT,";}.").concat(AT,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat($m,"{margin:8px 0;}.").concat(Rl,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(ev,"{margin-right:auto;cursor:pointer}.").concat(Zm,"{height:100%;line-height:16px;cursor:pointer;}.").concat(Al,"{margin-left:8px;color:#fff;background:").concat(DT,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(Al,":hover{opacity:0.9;}.").concat(ev,",.").concat(Al,",.").concat($m,",.").concat(Zm,"{font-size:14px;}@media screen and (max-width:750px){.").concat(wo,"{width:80vw;}}"),document.head.appendChild(t),OT=!0}this.showDetail_=!1,this.isCollapseClicked_=!1,this.isQuestionClicked_=!1,this.addDiaLog()}return xe(e,[{key:"createDiaLog",value:function(){var t=document.createElement("template");t.innerHTML='<div class="'.concat(Ym,`"><div class='`).concat(wo,"'><div class='").concat(AT,"'>").concat(location.host,"</div><div class='").concat($m,"'>").concat(this.content,"</div><div class='").concat(PT,`' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">`).concat(f5,"</div><div class='").concat(Rl,"'></div></div></div>").trim();var n=document.createElement("button");n.className=Al,n.innerText=oa()?"\u6062\u590D\u64AD\u653E":"Resume",n.onclick=this.onConfirm.bind(this);var i=document.createElement("div");i.className=Zm,i.innerHTML=`<?xml version="1.0" encoding="UTF-8"?>
57
57
  <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">
58
58
  <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"/>
59
59
  <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"/>
60
60
  <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"/>
61
61
  </svg>
62
- `,i.onclick=this.onQuestionClick.bind(this);var r=document.createElement("div");r.className=zm,r.innerText="".concat(oa()?"\u8BE6\u60C5 >":"Detail >"),r.onclick=this.onCollapseClick.bind(this);var o=t.content.firstChild,c=o.querySelector(".".concat(El));return c.appendChild(r),c.appendChild(i),c.appendChild(n),o}},{key:"addDiaLog",value:function(){OT()||(this.dialogNode_=this.createDiaLog(),document.body.appendChild(this.dialogNode_),this.dialogNode_.onclick=this.onConfirm.bind(this),this.dialogNode_.querySelector(".".concat(To)).onclick=function(t){return t.stopPropagation()},this.bodyPosition_=document.body.style.position,document.body.style.position="fixed",_e.info("show autoplay dialog"),ke.uploadEvent({log:n5}))}},{key:"deleteDiaLog",value:function(){this.dialogNode_&&(document.body.removeChild(this.dialogNode_),document.body.style.position=this.bodyPosition_,this.dialogNode_=null)}},{key:"onConfirm",value:function(){_e.warn("confirm clicked, try resume stream"),Y.emit(rc),this.deleteDiaLog()}},{key:"onCollapseClick",value:function(){var t=this.dialogNode_.querySelector(".".concat(AT));t.style.visibility="".concat(this.showDetail_?"hidden":"visible"),t.style.height="".concat(this.showDetail_?0:"fit-content"),this.showDetail_=!this.showDetail_,this.isCollapseClicked_||ke.uploadEvent({log:r5}),this.isCollapseClicked_=!0}},{key:"onQuestionClick",value:function(){window.open(LT,"_blank"),this.isQuestionClicked_||ke.uploadEvent({log:i5}),this.isQuestionClicked_=!0}}]),e}();function Al(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(i,r,o){var c=o.value;return o.value=function(){for(var a=arguments.length,s=new Array(a),l=0;l<a;l++)s[l]=arguments[l];return UT.call(this,t,s,r,this.name_),c.apply(this,s)},o}}function dn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(i,r,o){var c=o.value;return o.value=H(p().mark(function a(){var s,l,u,h=arguments;return p().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:for(s=h.length,l=new Array(s),u=0;u<s;u++)l[u]=h[u];return UT.call(this,t,l,r,this.name_),S.abrupt("return",c.apply(this,l));case 3:case"end":return S.stop()}},a,this)})),o}}function UT(e,t,n,i){try{for(var r=0;r<e.length;r++)qm.call(this,{rule:e[r],value:t[r],key:e[r].name,fnName:n,className:i})}catch(o){throw _e.error(o),o}}function qm(e){var t=this,n=e.rule,i=e.value,r=e.key,o=e.fnName,c=e.className;if(ge(i)){if(n.required)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:SN,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(ge(n.defaultValue))return;i=n.defaultValue}if(Array.isArray(n.type)){if(!n.type.map(function(h){return h.toLowerCase()}).includes(Si(i)))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:sS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})})}else if(!ge(n.type)&&Si(i)!==n.type)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:sS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(n.allowEmpty===!1){var a=tr(i)&&(i===0||Number.isNaN(i)),s=Bt(i)&&i.trim()==="";if(a||s)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:kN,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})})}if(n.notLessThanZero&&tr(i)&&i<0)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:E3,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(Bt(n.instanceOf)){if(!i||i.name_!==n.instanceOf)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:cS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})})}else if(ln(n.instanceOf)&&!(i instanceof n.instanceOf))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:cS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(n.values&&!n.values.includes(i))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:TN,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});var l=n.properties;bi(l)&&US(i)&&Object.keys(l).forEach(function(h){qm.call(t,{rule:l[h],value:i&&i[h],key:"".concat(r,".").concat(h),fnName:o,className:c})});var u=n.arrayItem;bi(u)&&ho(i)&&i.forEach(function(h,S){qm.call(t,{rule:u,value:h,key:"".concat(r,"[").concat(S,"]"),fnName:o,className:c})}),ln(n.validate)&&n.validate.call(this,i,r,o,c,this)}Le({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var _n,Io,Pl,Dl={exports:{}},o5=Om,Km=ye,hn=re,VT=it,Ol=at,Ci=kt,Xm=Dr,s5=Xn,c5=Ln,Qm=Qt,u5=Pt.f,l5=Sn,Ll=Ts,xo=Fa,d5=tt,h5=Vi,jT=Xe.enforce,f5=Xe.get,Ml=hn.Int8Array,Ym=Ml&&Ml.prototype,BT=hn.Uint8ClampedArray,FT=BT&&BT.prototype,wr=Ml&&Ll(Ml),ar=Ym&&Ll(Ym),p5=Object.prototype,$m=hn.TypeError,HT=d5("toStringTag"),Zm=h5("TYPED_ARRAY_TAG"),m5="TypedArrayConstructor",Wr=o5&&!!xo&&Xm(hn.opera)!=="Opera",GT=!1,zr={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},ev={BigInt64Array:8,BigUint64Array:8},WT=function(e){var t=Ll(e);if(Ol(t)){var n=f5(t);return n&&Ci(n,m5)?n.TypedArrayConstructor:WT(t)}},zT=function(e){if(!Ol(e))return!1;var t=Xm(e);return Ci(zr,t)||Ci(ev,t)};for(_n in zr)(Pl=(Io=hn[_n])&&Io.prototype)?jT(Pl).TypedArrayConstructor=Io:Wr=!1;for(_n in ev)(Pl=(Io=hn[_n])&&Io.prototype)&&(jT(Pl).TypedArrayConstructor=Io);if((!Wr||!VT(wr)||wr===Function.prototype)&&(wr=function(){throw $m("Incorrect invocation")},Wr))for(_n in zr)hn[_n]&&xo(hn[_n],wr);if((!Wr||!ar||ar===p5)&&(ar=wr.prototype,Wr))for(_n in zr)hn[_n]&&xo(hn[_n].prototype,ar);if(Wr&&Ll(FT)!==ar&&xo(FT,ar),Km&&!Ci(ar,HT))for(_n in GT=!0,u5(ar,HT,{get:function(){return Ol(this)?this[Zm]:void 0}}),zr)hn[_n]&&c5(hn[_n],Zm,_n);var Ge={NATIVE_ARRAY_BUFFER_VIEWS:Wr,TYPED_ARRAY_TAG:GT&&Zm,aTypedArray:function(e){if(zT(e))return e;throw $m("Target is not a typed array")},aTypedArrayConstructor:function(e){if(VT(e)&&(!xo||l5(wr,e)))return e;throw $m(s5(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,i){if(Km){if(n)for(var r in zr){var o=hn[r];if(o&&Ci(o.prototype,e))try{delete o.prototype[e]}catch(c){try{o.prototype[e]=t}catch(a){}}}ar[e]&&!n||Qm(ar,e,n?t:Wr&&Ym[e]||t,i)}},exportTypedArrayStaticMethod:function(e,t,n){var i,r;if(Km){if(xo){if(n){for(i in zr)if((r=hn[i])&&Ci(r,e))try{delete r[e]}catch(o){}}if(wr[e]&&!n)return;try{return Qm(wr,e,n?t:Wr&&wr[e]||t)}catch(o){}}for(i in zr)!(r=hn[i])||r[e]&&!n||Qm(r,e,t)}},getTypedArrayConstructor:WT,isView:function(e){if(!Ol(e))return!1;var t=Xm(e);return t==="DataView"||Ci(zr,t)||Ci(ev,t)},isTypedArray:zT,TypedArray:wr,TypedArrayPrototype:ar},JT=re,tv=ue,v5=gu,g5=Ge.NATIVE_ARRAY_BUFFER_VIEWS,_5=JT.ArrayBuffer,ha=JT.Int8Array,y5=!g5||!tv(function(){ha(1)})||!tv(function(){new ha(-1)})||!v5(function(e){new ha,new ha(null),new ha(1.5),new ha(e)},!0)||tv(function(){return new ha(new _5(2),1,void 0).length!==1}),b5=$n,S5=RangeError,k5=function(e){var t=b5(e);if(t<0)throw S5("The argument can't be less than 0");return t},T5=RangeError,qT=function(e,t){var n=k5(e);if(n%t)throw T5("Wrong offset");return n},I5=Dr,x5=pe("".slice),w5=ji,C5=TypeError,KT=function(e){var t=w5(e,"number");if(typeof t=="number")throw C5("Can't convert number to bigint");return BigInt(t)},E5=Lr,R5=Ke,A5=I0,P5=Mt,D5=nn,O5=mu,L5=Es,M5=hh,N5=function(e){return x5(I5(e),0,3)==="Big"},U5=Ge.aTypedArrayConstructor,V5=KT,XT=Le,QT=re,YT=Ke,j5=ye,B5=y5,wo=Ge,$T=lc,ZT=si,F5=Ze,dc=Ln,H5=YS,G5=yr,e1=$k,nv=qT,t1=Da,hc=kt,W5=Dr,rv=at,z5=Mi,J5=Ba,q5=Sn,Nl=Fa,K5=ii.f,n1=function(e){var t,n,i,r,o,c,a,s,l=A5(this),u=P5(e),h=arguments.length,S=h>1?arguments[1]:void 0,I=S!==void 0,E=L5(u);if(E&&!M5(E))for(s=(a=O5(u,E)).next,u=[];!(c=R5(s,a)).done;)u.push(c.value);for(I&&h>2&&(S=E5(S,arguments[2])),n=D5(u),i=new(U5(l))(n),r=N5(i),t=0;n>t;t++)o=I?S(u[t],t):u[t],i[t]=r?V5(o):+o;return i},X5=rn.forEach,Q5=Ps,r1=Pt,i1=be,Y5=_u,iv=Xe.get,$5=Xe.set,Z5=Xe.enforce,av=r1.f,ej=i1.f,tj=Math.round,ov=QT.RangeError,a1=$T.ArrayBuffer,nj=a1.prototype,rj=$T.DataView,Ul=wo.NATIVE_ARRAY_BUFFER_VIEWS,o1=wo.TYPED_ARRAY_TAG,s1=wo.TypedArray,fc=wo.TypedArrayPrototype,ij=wo.aTypedArrayConstructor,sv=wo.isTypedArray,Vl="BYTES_PER_ELEMENT",cv="Wrong length",c1=function(e,t){ij(e);for(var n=0,i=t.length,r=new e(i);i>n;)r[n]=t[n++];return r},jl=function(e,t){av(e,t,{get:function(){return iv(this)[t]}})},u1=function(e){var t;return q5(nj,e)||(t=W5(e))=="ArrayBuffer"||t=="SharedArrayBuffer"},l1=function(e,t){return sv(e)&&!z5(t)&&t in e&&H5(+t)&&t>=0},d1=function(e,t){return t=t1(t),l1(e,t)?F5(2,e[t]):ej(e,t)},h1=function(e,t,n){return t=t1(t),!(l1(e,t)&&rv(n)&&hc(n,"value"))||hc(n,"get")||hc(n,"set")||n.configurable||hc(n,"writable")&&!n.writable||hc(n,"enumerable")&&!n.enumerable?av(e,t,n):(e[t]=n.value,e)};j5?(Ul||(i1.f=d1,r1.f=h1,jl(fc,"buffer"),jl(fc,"byteOffset"),jl(fc,"byteLength"),jl(fc,"length")),XT({target:"Object",stat:!0,forced:!Ul},{getOwnPropertyDescriptor:d1,defineProperty:h1}),Dl.exports=function(e,t,n){var i=e.match(/\d+$/)[0]/8,r=e+(n?"Clamped":"")+"Array",o="get"+e,c="set"+e,a=QT[r],s=a,l=s&&s.prototype,u={},h=function(I,E){av(I,E,{get:function(){return function(x,m){var T=iv(x);return T.view[o](m*i+T.byteOffset,!0)}(this,E)},set:function(x){return function(m,T,v){var w=iv(m);n&&(v=(v=tj(v))<0?0:v>255?255:255&v),w.view[c](T*i+w.byteOffset,v,!0)}(this,E,x)},enumerable:!0})};Ul?B5&&(s=t(function(I,E,x,m){return ZT(I,l),Y5(rv(E)?u1(E)?m!==void 0?new a(E,nv(x,i),m):x!==void 0?new a(E,nv(x,i)):new a(E):sv(E)?c1(s,E):YT(n1,s,E):new a(e1(E)),I,s)}),Nl&&Nl(s,s1),X5(K5(a),function(I){I in s||dc(s,I,a[I])}),s.prototype=l):(s=t(function(I,E,x,m){ZT(I,l);var T,v,w,L=0,N=0;if(rv(E)){if(!u1(E))return sv(E)?c1(s,E):YT(n1,s,E);T=E,N=nv(x,i);var V=E.byteLength;if(m===void 0){if(V%i||(v=V-N)<0)throw ov(cv)}else if((v=G5(m)*i)+N>V)throw ov(cv);w=v/i}else w=e1(E),T=new a1(v=w*i);for($5(I,{buffer:T,byteOffset:N,byteLength:v,length:w,view:new rj(T)});L<w;)h(I,L++)}),Nl&&Nl(s,s1),l=s.prototype=J5(fc)),l.constructor!==s&&dc(l,"constructor",s),Z5(l).TypedArrayConstructor=s,o1&&dc(l,o1,r);var S=s!=a;u[r]=s,XT({global:!0,constructor:!0,forced:S,sham:!Ul},u),Vl in s||dc(s,Vl,i),Vl in l||dc(l,Vl,i),Q5(r)}):Dl.exports=function(){},(0,Dl.exports)("Float32",function(e){return function(t,n,i){return e(this,t,n,i)}});var aj=Mt,uv=ai,oj=nn,sj=z_,cj=Math.min,uj=[].copyWithin||function(e,t){var n=aj(this),i=oj(n),r=uv(e,i),o=uv(t,i),c=arguments.length>2?arguments[2]:void 0,a=cj((c===void 0?i:uv(c,i))-o,i-r),s=1;for(o<r&&r<o+a&&(s=-1,o+=a-1,r+=a-1);a-- >0;)o in n?n[r]=n[o]:sj(n,r),r+=s,o+=s;return n},f1=Ge,lj=pe(uj),dj=f1.aTypedArray;(0,f1.exportTypedArrayMethod)("copyWithin",function(e,t){return lj(dj(this),e,t,arguments.length>2?arguments[2]:void 0)});var hj=rn.every,fj=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("every",function(e){return hj(fj(this),e,arguments.length>1?arguments[1]:void 0)});var pj=eT,mj=KT,vj=Dr,gj=Ke,_j=ue,yj=Ge.aTypedArray,bj=Ge.exportTypedArrayMethod,Sj=pe("".slice);bj("fill",function(e){var t=arguments.length;yj(this);var n=Sj(vj(this),0,3)==="Big"?mj(e):+e;return gj(pj,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},_j(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),e!==1}));var kj=nn,Tj=Lu,Ij=Ge.aTypedArrayConstructor,xj=Ge.getTypedArrayConstructor,Bl=function(e){return Ij(Tj(e,xj(e)))},wj=function(e,t){for(var n=0,i=kj(t),r=new e(i);i>n;)r[n]=t[n++];return r},Cj=Bl,Ej=rn.filter,Rj=function(e,t){return wj(Cj(e),t)},Aj=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("filter",function(e){var t=Ej(Aj(this),e,arguments.length>1?arguments[1]:void 0);return Rj(this,t)});var Pj=rn.find,Dj=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("find",function(e){return Pj(Dj(this),e,arguments.length>1?arguments[1]:void 0)});var Oj=rn.findIndex,Lj=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("findIndex",function(e){return Oj(Lj(this),e,arguments.length>1?arguments[1]:void 0)});var Mj=rn.forEach,Nj=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("forEach",function(e){Mj(Nj(this),e,arguments.length>1?arguments[1]:void 0)});var Uj=ys.includes,Vj=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("includes",function(e){return Uj(Vj(this),e,arguments.length>1?arguments[1]:void 0)});var jj=ys.indexOf,Bj=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("indexOf",function(e){return jj(Bj(this),e,arguments.length>1?arguments[1]:void 0)});var Fj=re,Hj=ue,lv=pe,p1=Ge,dv=Gg,hv=tt("iterator"),m1=Fj.Uint8Array,Gj=lv(dv.values),Wj=lv(dv.keys),zj=lv(dv.entries),fv=p1.aTypedArray,Fl=p1.exportTypedArrayMethod,Co=m1&&m1.prototype,Hl=!Hj(function(){Co[hv].call([1])}),v1=!!Co&&Co.values&&Co[hv]===Co.values&&Co.values.name==="values",g1=function(){return Gj(fv(this))};Fl("entries",function(){return zj(fv(this))},Hl),Fl("keys",function(){return Wj(fv(this))},Hl),Fl("values",g1,Hl||!v1,{name:"values"}),Fl(hv,g1,Hl||!v1,{name:"values"});var Jj=Ge.aTypedArray,qj=Ge.exportTypedArrayMethod,Kj=pe([].join);qj("join",function(e){return Kj(Jj(this),e)});var Xj=Ji,Qj=bn,Yj=$n,$j=nn,Zj=Ns,e8=Math.min,pv=[].lastIndexOf,_1=!!pv&&1/[1].lastIndexOf(1,-0)<0,t8=Zj("lastIndexOf"),n8=_1||!t8?function(e){if(_1)return Xj(pv,this,arguments)||0;var t=Qj(this),n=$j(t),i=n-1;for(arguments.length>1&&(i=e8(i,Yj(arguments[1]))),i<0&&(i=n+i);i>=0;i--)if(i in t&&t[i]===e)return i||0;return-1}:pv,r8=Ji,i8=n8,a8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("lastIndexOf",function(e){var t=arguments.length;return r8(i8,a8(this),t>1?[e,arguments[1]]:[e])});var o8=rn.map,s8=Bl,c8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("map",function(e){return o8(c8(this),e,arguments.length>1?arguments[1]:void 0,function(t,n){return new(s8(t))(n)})});var u8=Vt,l8=Mt,d8=yn,h8=nn,f8=TypeError,y1=function(e){return function(t,n,i,r){u8(n);var o=l8(t),c=d8(o),a=h8(o),s=e?a-1:0,l=e?-1:1;if(i<2)for(;;){if(s in c){r=c[s],s+=l;break}if(s+=l,e?s<0:a<=s)throw f8("Reduce of empty array with no initial value")}for(;e?s>=0:a>s;s+=l)s in c&&(r=n(r,c[s],s,o));return r}},mv={left:y1(!1),right:y1(!0)},p8=mv.left,m8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("reduce",function(e){var t=arguments.length;return p8(m8(this),e,t,t>1?arguments[1]:void 0)});var v8=mv.right,g8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("reduceRight",function(e){var t=arguments.length;return v8(g8(this),e,t,t>1?arguments[1]:void 0)});var _8=Ge.aTypedArray,y8=Ge.exportTypedArrayMethod,b8=Math.floor;y8("reverse",function(){for(var e,t=this,n=_8(t).length,i=b8(n/2),r=0;r<i;)e=t[r],t[r++]=t[--n],t[n]=e;return t});var b1=re,S1=Ke,vv=Ge,S8=nn,k8=qT,T8=Mt,k1=ue,I8=b1.RangeError,gv=b1.Int8Array,T1=gv&&gv.prototype,I1=T1&&T1.set,x8=vv.aTypedArray,w8=vv.exportTypedArrayMethod,_v=!k1(function(){var e=new Uint8ClampedArray(2);return S1(I1,e,{length:1,0:3},1),e[1]!==3}),C8=_v&&vv.NATIVE_ARRAY_BUFFER_VIEWS&&k1(function(){var e=new gv(2);return e.set(1),e.set("2",1),e[0]!==0||e[1]!==2});w8("set",function(e){x8(this);var t=k8(arguments.length>1?arguments[1]:void 0,1),n=T8(e);if(_v)return S1(I1,this,n,t);var i=this.length,r=S8(n),o=0;if(r+t>i)throw I8("Wrong length");for(;o<r;)this[t+o]=n[o++]},!_v||C8);var E8=Bl,R8=Ha,A8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("slice",function(e,t){for(var n=R8(A8(this),e,t),i=E8(this),r=0,o=n.length,c=new i(o);o>r;)c[r]=n[r++];return c},ue(function(){new Int8Array(1).slice()}));var P8=rn.some,D8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("some",function(e){return P8(D8(this),e,arguments.length>1?arguments[1]:void 0)});var x1=Kn.match(/firefox\/(\d+)/i),O8=!!x1&&+x1[1],L8=/MSIE|Trident/.test(Kn),w1=Kn.match(/AppleWebKit\/(\d+)\./),M8=!!w1&&+w1[1],N8=pe,yv=ue,U8=Vt,V8=wy,C1=O8,j8=L8,E1=pr,R1=M8,B8=Ge.aTypedArray,F8=Ge.exportTypedArrayMethod,pc=re.Uint16Array,Eo=pc&&N8(pc.prototype.sort),H8=!(!Eo||yv(function(){Eo(new pc(2),null)})&&yv(function(){Eo(new pc(2),{})})),A1=!!Eo&&!yv(function(){if(E1)return E1<74;if(C1)return C1<67;if(j8)return!0;if(R1)return R1<602;var e,t,n=new pc(516),i=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,i[e]=e-2*t+3;for(Eo(n,function(r,o){return(r/4|0)-(o/4|0)}),e=0;e<516;e++)if(n[e]!==i[e])return!0});F8("sort",function(e){return e!==void 0&&U8(e),A1?Eo(this,e):V8(B8(this),function(t){return function(n,i){return t!==void 0?+t(n,i)||0:i!=i?-1:n!=n?1:n===0&&i===0?1/n>0&&1/i<0?1:-1:n>i}}(e))},!A1||H8);var G8=yr,P1=ai,W8=Bl,z8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("subarray",function(e,t){var n=z8(this),i=n.length,r=P1(e,i);return new(W8(n))(n.buffer,n.byteOffset+r*n.BYTES_PER_ELEMENT,G8((t===void 0?i:P1(t,i))-r))});var J8=Ji,D1=Ge,bv=ue,O1=Ha,Gl=re.Int8Array,L1=D1.aTypedArray,q8=D1.exportTypedArrayMethod,M1=[].toLocaleString,K8=!!Gl&&bv(function(){M1.call(new Gl(1))});q8("toLocaleString",function(){return J8(M1,K8?O1(L1(this)):L1(this),O1(arguments))},bv(function(){return[1,2].toLocaleString()!=new Gl([1,2]).toLocaleString()})||!bv(function(){Gl.prototype.toLocaleString.call([1,2])}));var X8=Ge.exportTypedArrayMethod,Q8=ue,Y8=pe,N1=re.Uint8Array,$8=N1&&N1.prototype||{},Wl=[].toString,Z8=Y8([].join);Q8(function(){Wl.call({})})&&(Wl=function(){return Z8(this)});var eB=$8.toString!=Wl;X8("toString",Wl,eB);var Fn,U1=Hi.exports,tB=Pt,nB=Tt,rB=t_,iB=Lr,aB=Ke,oB=Mt,sB=function(e,t,n,i){try{return i?t(nB(n)[0],n[1]):t(n)}catch(r){rB(e,"throw",r)}},cB=hh,uB=bu,lB=nn,V1=Cs,dB=mu,hB=Es,j1=Array,B1=function(e){var t=oB(e),n=uB(this),i=arguments.length,r=i>1?arguments[1]:void 0,o=r!==void 0;o&&(r=iB(r,i>2?arguments[2]:void 0));var c,a,s,l,u,h,S=hB(t),I=0;if(!S||this===j1&&cB(S))for(c=lB(t),a=n?new this(c):j1(c);c>I;I++)h=o?r(t[I],I):t[I],V1(a,I,h);else for(u=(l=dB(t,S)).next,a=n?new this:[];!(s=aB(u,l)).done;I++)h=o?sB(l,r,[s.value,I],!0):s.value,V1(a,I,h);return a.length=I,a},fa=pe,Sv=2147483647,fB=/[^\0-\u007E]/,F1=/[.\u3002\uFF0E\uFF61]/g,H1="Overflow: input needs wider integers to process",G1=RangeError,pB=fa(F1.exec),Ro=Math.floor,kv=String.fromCharCode,W1=fa("".charCodeAt),z1=fa([].join),Ei=fa([].push),mB=fa("".replace),vB=fa("".split),gB=fa("".toLowerCase),J1=function(e){return e+22+75*(e<26)},_B=function(e,t,n){var i=0;for(e=n?Ro(e/700):e>>1,e+=Ro(e/t);e>455;)e=Ro(e/35),i+=36;return Ro(i+36*e/(e+38))},yB=function(e){var t=[];e=function(T){for(var v=[],w=0,L=T.length;w<L;){var N=W1(T,w++);if(N>=55296&&N<=56319&&w<L){var V=W1(T,w++);(64512&V)==56320?Ei(v,((1023&N)<<10)+(1023&V)+65536):(Ei(v,N),w--)}else Ei(v,N)}return v}(e);var n,i,r=e.length,o=128,c=0,a=72;for(n=0;n<e.length;n++)(i=e[n])<128&&Ei(t,kv(i));var s=t.length,l=s;for(s&&Ei(t,"-");l<r;){var u=Sv;for(n=0;n<e.length;n++)(i=e[n])>=o&&i<u&&(u=i);var h=l+1;if(u-o>Ro((Sv-c)/h))throw G1(H1);for(c+=(u-o)*h,o=u,n=0;n<e.length;n++){if((i=e[n])<o&&++c>Sv)throw G1(H1);if(i==o){for(var S=c,I=36;;){var E=I<=a?1:I>=a+26?26:I-a;if(S<E)break;var x=S-E,m=36-E;Ei(t,kv(J1(E+x%m))),S=Ro(x/m),I+=36}Ei(t,kv(J1(S))),a=_B(c,h,l==s),c=0,l++}}c++,o++}return z1(t,"")},bB=Le,Tv=ye,SB=Iy,Iv=re,q1=Lr,Hn=pe,zl=Qt,Gn=function(e,t,n){return n.get&&U1(n.get,t,{getter:!0}),n.set&&U1(n.set,t,{setter:!0}),tB.f(e,t,n)},kB=si,xv=kt,wv=ik,Ao=B1,or=fu,TB=_h.codeAt,IB=function(e){var t,n,i=[],r=vB(mB(gB(e),F1,"."),".");for(t=0;t<r.length;t++)n=r[t],Ei(i,pB(fB,n)?"xn--"+yB(n):n);return z1(i,".")},Jr=Wt,xB=zi,wB=yu,K1=AD,X1=Xe,CB=X1.set,Jl=X1.getterFor("URL"),EB=K1.URLSearchParams,RB=K1.getState,mc=Iv.URL,Cv=Iv.TypeError,ql=Iv.parseInt,AB=Math.floor,Q1=Math.pow,Wn=Hn("".charAt),sr=Hn(/./.exec),vc=Hn([].join),PB=Hn(1 .toString),DB=Hn([].pop),Po=Hn([].push),Y1=Hn("".replace),OB=Hn([].shift),LB=Hn("".split),gc=Hn("".slice),Kl=Hn("".toLowerCase),MB=Hn([].unshift),Ev="Invalid scheme",pa="Invalid host",$1="Invalid port",Z1=/[a-z]/i,NB=/[\d+-.a-z]/i,Rv=/\d/,UB=/^0x/i,VB=/^[0-7]+$/,jB=/^\d+$/,eI=/^[\da-f]+$/i,BB=/[\0\t\n\r #%/:<>?@[\\\]^|]/,FB=/[\0\t\n\r #/:<>?@[\\\]^|]/,HB=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,GB=/[\t\n\r]/g,_c=function(e){var t,n,i,r;if(typeof e=="number"){for(t=[],n=0;n<4;n++)MB(t,e%256),e=AB(e/256);return vc(t,".")}if(typeof e=="object"){for(t="",i=function(o){for(var c=null,a=1,s=null,l=0,u=0;u<8;u++)o[u]!==0?(l>a&&(c=s,a=l),s=null,l=0):(s===null&&(s=u),++l);return l>a&&(c=s,a=l),c}(e),n=0;n<8;n++)r&&e[n]===0||(r&&(r=!1),i===n?(t+=n?":":"::",r=!0):(t+=PB(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},Xl={},tI=wv({},Xl,{" ":1,'"':1,"<":1,">":1,"`":1}),nI=wv({},tI,{"#":1,"?":1,"{":1,"}":1}),Av=wv({},nI,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Ri=function(e,t){var n=TB(e,0);return n>32&&n<127&&!xv(t,e)?e:encodeURIComponent(e)},Ql={ftp:21,file:null,http:80,https:443,ws:80,wss:443},yc=function(e,t){var n;return e.length==2&&sr(Z1,Wn(e,0))&&((n=Wn(e,1))==":"||!t&&n=="|")},rI=function(e){var t;return e.length>1&&yc(gc(e,0,2))&&(e.length==2||(t=Wn(e,2))==="/"||t==="\\"||t==="?"||t==="#")},WB=function(e){return e==="."||Kl(e)==="%2e"},Pv={},iI={},Dv={},aI={},oI={},Ov={},sI={},cI={},Yl={},$l={},Lv={},Mv={},Nv={},Uv={},uI={},Vv={},Do={},Cr={},lI={},ma={},qr={},jv=function(e,t,n){var i,r,o,c=Jr(e);if(t){if(r=this.parse(c))throw Cv(r);this.searchParams=null}else{if(n!==void 0&&(i=new jv(n,!0)),r=this.parse(c,null,i))throw Cv(r);(o=RB(new EB)).bindURL(this),this.searchParams=o}};jv.prototype={type:"URL",parse:function(e,t,n){var i,r,o,c,a,s=this,l=t||Pv,u=0,h="",S=!1,I=!1,E=!1;for(e=Jr(e),t||(s.scheme="",s.username="",s.password="",s.host=null,s.port=null,s.path=[],s.query=null,s.fragment=null,s.cannotBeABaseURL=!1,e=Y1(e,HB,"")),e=Y1(e,GB,""),i=Ao(e);u<=i.length;){switch(r=i[u],l){case Pv:if(!r||!sr(Z1,r)){if(t)return Ev;l=Dv;continue}h+=Kl(r),l=iI;break;case iI:if(r&&(sr(NB,r)||r=="+"||r=="-"||r=="."))h+=Kl(r);else{if(r!=":"){if(t)return Ev;h="",l=Dv,u=0;continue}if(t&&(s.isSpecial()!=xv(Ql,h)||h=="file"&&(s.includesCredentials()||s.port!==null)||s.scheme=="file"&&!s.host))return;if(s.scheme=h,t)return void(s.isSpecial()&&Ql[s.scheme]==s.port&&(s.port=null));h="",s.scheme=="file"?l=Uv:s.isSpecial()&&n&&n.scheme==s.scheme?l=aI:s.isSpecial()?l=cI:i[u+1]=="/"?(l=oI,u++):(s.cannotBeABaseURL=!0,Po(s.path,""),l=lI)}break;case Dv:if(!n||n.cannotBeABaseURL&&r!="#")return Ev;if(n.cannotBeABaseURL&&r=="#"){s.scheme=n.scheme,s.path=or(n.path),s.query=n.query,s.fragment="",s.cannotBeABaseURL=!0,l=qr;break}l=n.scheme=="file"?Uv:Ov;continue;case aI:if(r!="/"||i[u+1]!="/"){l=Ov;continue}l=Yl,u++;break;case oI:if(r=="/"){l=$l;break}l=Cr;continue;case Ov:if(s.scheme=n.scheme,r==Fn)s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=or(n.path),s.query=n.query;else if(r=="/"||r=="\\"&&s.isSpecial())l=sI;else if(r=="?")s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=or(n.path),s.query="",l=ma;else{if(r!="#"){s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=or(n.path),s.path.length--,l=Cr;continue}s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=or(n.path),s.query=n.query,s.fragment="",l=qr}break;case sI:if(!s.isSpecial()||r!="/"&&r!="\\"){if(r!="/"){s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,l=Cr;continue}l=$l}else l=Yl;break;case cI:if(l=Yl,r!="/"||Wn(h,u+1)!="/")continue;u++;break;case Yl:if(r!="/"&&r!="\\"){l=$l;continue}break;case $l:if(r=="@"){S&&(h="%40"+h),S=!0,o=Ao(h);for(var x=0;x<o.length;x++){var m=o[x];if(m!=":"||E){var T=Ri(m,Av);E?s.password+=T:s.username+=T}else E=!0}h=""}else if(r==Fn||r=="/"||r=="?"||r=="#"||r=="\\"&&s.isSpecial()){if(S&&h=="")return"Invalid authority";u-=Ao(h).length+1,h="",l=Lv}else h+=r;break;case Lv:case Mv:if(t&&s.scheme=="file"){l=Vv;continue}if(r!=":"||I){if(r==Fn||r=="/"||r=="?"||r=="#"||r=="\\"&&s.isSpecial()){if(s.isSpecial()&&h=="")return pa;if(t&&h==""&&(s.includesCredentials()||s.port!==null))return;if(c=s.parseHost(h))return c;if(h="",l=Do,t)return;continue}r=="["?I=!0:r=="]"&&(I=!1),h+=r}else{if(h=="")return pa;if(c=s.parseHost(h))return c;if(h="",l=Nv,t==Mv)return}break;case Nv:if(!sr(Rv,r)){if(r==Fn||r=="/"||r=="?"||r=="#"||r=="\\"&&s.isSpecial()||t){if(h!=""){var v=ql(h,10);if(v>65535)return $1;s.port=s.isSpecial()&&v===Ql[s.scheme]?null:v,h=""}if(t)return;l=Do;continue}return $1}h+=r;break;case Uv:if(s.scheme="file",r=="/"||r=="\\")l=uI;else{if(!n||n.scheme!="file"){l=Cr;continue}if(r==Fn)s.host=n.host,s.path=or(n.path),s.query=n.query;else if(r=="?")s.host=n.host,s.path=or(n.path),s.query="",l=ma;else{if(r!="#"){rI(vc(or(i,u),""))||(s.host=n.host,s.path=or(n.path),s.shortenPath()),l=Cr;continue}s.host=n.host,s.path=or(n.path),s.query=n.query,s.fragment="",l=qr}}break;case uI:if(r=="/"||r=="\\"){l=Vv;break}n&&n.scheme=="file"&&!rI(vc(or(i,u),""))&&(yc(n.path[0],!0)?Po(s.path,n.path[0]):s.host=n.host),l=Cr;continue;case Vv:if(r==Fn||r=="/"||r=="\\"||r=="?"||r=="#"){if(!t&&yc(h))l=Cr;else if(h==""){if(s.host="",t)return;l=Do}else{if(c=s.parseHost(h))return c;if(s.host=="localhost"&&(s.host=""),t)return;h="",l=Do}continue}h+=r;break;case Do:if(s.isSpecial()){if(l=Cr,r!="/"&&r!="\\")continue}else if(t||r!="?")if(t||r!="#"){if(r!=Fn&&(l=Cr,r!="/"))continue}else s.fragment="",l=qr;else s.query="",l=ma;break;case Cr:if(r==Fn||r=="/"||r=="\\"&&s.isSpecial()||!t&&(r=="?"||r=="#")){if((a=Kl(a=h))===".."||a==="%2e."||a===".%2e"||a==="%2e%2e"?(s.shortenPath(),r=="/"||r=="\\"&&s.isSpecial()||Po(s.path,"")):WB(h)?r=="/"||r=="\\"&&s.isSpecial()||Po(s.path,""):(s.scheme=="file"&&!s.path.length&&yc(h)&&(s.host&&(s.host=""),h=Wn(h,0)+":"),Po(s.path,h)),h="",s.scheme=="file"&&(r==Fn||r=="?"||r=="#"))for(;s.path.length>1&&s.path[0]==="";)OB(s.path);r=="?"?(s.query="",l=ma):r=="#"&&(s.fragment="",l=qr)}else h+=Ri(r,nI);break;case lI:r=="?"?(s.query="",l=ma):r=="#"?(s.fragment="",l=qr):r!=Fn&&(s.path[0]+=Ri(r,Xl));break;case ma:t||r!="#"?r!=Fn&&(r=="'"&&s.isSpecial()?s.query+="%27":s.query+=r=="#"?"%23":Ri(r,Xl)):(s.fragment="",l=qr);break;case qr:r!=Fn&&(s.fragment+=Ri(r,tI))}u++}},parseHost:function(e){var t,n,i;if(Wn(e,0)=="["){if(Wn(e,e.length-1)!="]"||(t=function(r){var o,c,a,s,l,u,h,S=[0,0,0,0,0,0,0,0],I=0,E=null,x=0,m=function(){return Wn(r,x)};if(m()==":"){if(Wn(r,1)!=":")return;x+=2,E=++I}for(;m();){if(I==8)return;if(m()!=":"){for(o=c=0;c<4&&sr(eI,m());)o=16*o+ql(m(),16),x++,c++;if(m()=="."){if(c==0||(x-=c,I>6))return;for(a=0;m();){if(s=null,a>0){if(!(m()=="."&&a<4))return;x++}if(!sr(Rv,m()))return;for(;sr(Rv,m());){if(l=ql(m(),10),s===null)s=l;else{if(s==0)return;s=10*s+l}if(s>255)return;x++}S[I]=256*S[I]+s,++a!=2&&a!=4||I++}if(a!=4)return;break}if(m()==":"){if(x++,!m())return}else if(m())return;S[I++]=o}else{if(E!==null)return;x++,E=++I}}if(E!==null)for(u=I-E,I=7;I!=0&&u>0;)h=S[I],S[I--]=S[E+u-1],S[E+--u]=h;else if(I!=8)return;return S}(gc(e,1,-1)),!t))return pa;this.host=t}else if(this.isSpecial()){if(e=IB(e),sr(BB,e)||(t=function(r){var o,c,a,s,l,u,h,S=LB(r,".");if(S.length&&S[S.length-1]==""&&S.length--,(o=S.length)>4)return r;for(c=[],a=0;a<o;a++){if((s=S[a])=="")return r;if(l=10,s.length>1&&Wn(s,0)=="0"&&(l=sr(UB,s)?16:8,s=gc(s,l==8?1:2)),s==="")u=0;else{if(!sr(l==10?jB:l==8?VB:eI,s))return r;u=ql(s,l)}Po(c,u)}for(a=0;a<o;a++)if(u=c[a],a==o-1){if(u>=Q1(256,5-o))return null}else if(u>255)return null;for(h=DB(c),a=0;a<c.length;a++)h+=c[a]*Q1(256,3-a);return h}(e),t===null))return pa;this.host=t}else{if(sr(FB,e))return pa;for(t="",n=Ao(e),i=0;i<n.length;i++)t+=Ri(n[i],Xl);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme=="file"},includesCredentials:function(){return this.username!=""||this.password!=""},isSpecial:function(){return xv(Ql,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||this.scheme=="file"&&t==1&&yc(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,n=e.username,i=e.password,r=e.host,o=e.port,c=e.path,a=e.query,s=e.fragment,l=t+":";return r!==null?(l+="//",e.includesCredentials()&&(l+=n+(i?":"+i:"")+"@"),l+=_c(r),o!==null&&(l+=":"+o)):t=="file"&&(l+="//"),l+=e.cannotBeABaseURL?c[0]:c.length?"/"+vc(c,"/"):"",a!==null&&(l+="?"+a),s!==null&&(l+="#"+s),l},setHref:function(e){var t=this.parse(e);if(t)throw Cv(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if(e=="blob")try{return new Oo(e.path[0]).origin}catch(n){return"null"}return e!="file"&&this.isSpecial()?e+"://"+_c(this.host)+(t!==null?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Jr(e)+":",Pv)},getUsername:function(){return this.username},setUsername:function(e){var t=Ao(Jr(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=Ri(t[n],Av)}},getPassword:function(){return this.password},setPassword:function(e){var t=Ao(Jr(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=Ri(t[n],Av)}},getHost:function(){var e=this.host,t=this.port;return e===null?"":t===null?_c(e):_c(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,Lv)},getHostname:function(){var e=this.host;return e===null?"":_c(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Mv)},getPort:function(){var e=this.port;return e===null?"":Jr(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||((e=Jr(e))==""?this.port=null:this.parse(e,Nv))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+vc(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Do))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){(e=Jr(e))==""?this.query=null:(Wn(e,0)=="?"&&(e=gc(e,1)),this.query="",this.parse(e,ma)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){(e=Jr(e))!=""?(Wn(e,0)=="#"&&(e=gc(e,1)),this.fragment="",this.parse(e,qr)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Oo=function(e){var t=kB(this,fn),n=wB(arguments.length,1)>1?arguments[1]:void 0,i=CB(t,new jv(e,!1,n));Tv||(t.href=i.serialize(),t.origin=i.getOrigin(),t.protocol=i.getProtocol(),t.username=i.getUsername(),t.password=i.getPassword(),t.host=i.getHost(),t.hostname=i.getHostname(),t.port=i.getPort(),t.pathname=i.getPathname(),t.search=i.getSearch(),t.searchParams=i.getSearchParams(),t.hash=i.getHash())},fn=Oo.prototype,zn=function(e,t){return{get:function(){return Jl(this)[e]()},set:t&&function(n){return Jl(this)[t](n)},configurable:!0,enumerable:!0}};if(Tv&&(Gn(fn,"href",zn("serialize","setHref")),Gn(fn,"origin",zn("getOrigin")),Gn(fn,"protocol",zn("getProtocol","setProtocol")),Gn(fn,"username",zn("getUsername","setUsername")),Gn(fn,"password",zn("getPassword","setPassword")),Gn(fn,"host",zn("getHost","setHost")),Gn(fn,"hostname",zn("getHostname","setHostname")),Gn(fn,"port",zn("getPort","setPort")),Gn(fn,"pathname",zn("getPathname","setPathname")),Gn(fn,"search",zn("getSearch","setSearch")),Gn(fn,"searchParams",zn("getSearchParams")),Gn(fn,"hash",zn("getHash","setHash"))),zl(fn,"toJSON",function(){return Jl(this).serialize()},{enumerable:!0}),zl(fn,"toString",function(){return Jl(this).serialize()},{enumerable:!0}),mc){var dI=mc.createObjectURL,hI=mc.revokeObjectURL;dI&&zl(Oo,"createObjectURL",q1(dI,mc)),hI&&zl(Oo,"revokeObjectURL",q1(hI,mc))}xB(Oo,"URL"),bB({global:!0,constructor:!0,forced:!SB,sham:!Tv},{URL:Oo});var va,bc,zB=new Blob([`
63
- class VolumeMeter extends AudioWorkletProcessor{constructor(){super();this.volume=0;this.intervalTime=200;this.tick=this.intervalTime;this.isStop=false;this.cache=[];this.sentFirstInfo1=false;this.unmute=false;this.port.onmessage=(event)=>{const{data}=event;switch(data.name){case"chunk":this.cache.push.apply(this.cache,data.data);if(!this.sentFirstInfo1){this.port.postMessage({cl:data.data.length});this.sentFirstInfo1=true}break;case"setIntervalTime":this.intervalTime=data.intervalTime;break;case"unmute":this.unmute=true;break;case"stop":this.isStop=true;break}}}process(inputs,outputs){const input=inputs[0];const output=outputs[0];if(!input&&!output){return true}if(this.isStop){return false}const l=output?output[0].length:0;const cl=this.cache.length;if(cl>l){output[0].set(this.cache.slice(0,l));this.cache=this.cache.slice(l)}else if(this.unmute){output[0].set(input[0])}const firstChannel=cl>l?output[0]:input[0];if(!firstChannel){return true}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,cl,l})}return true}}registerProcessor("volume-meter",VolumeMeter);
64
- `],{type:"application/javascript"}),fI=!1,JB=function(){function e(n){Q(this,e),this.context_=n.context,this.ready=this.addModuleToContext()}var t;return xe(e,[{key:"addModuleToContext",value:(t=H(p().mark(function n(){return p().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,i.next=3,this.context_.audioWorklet.addModule(URL.createObjectURL(zB));case 3:_e.info("worklet addModule success"),Y.emit(em),fI=!0,i.next=12;break;case 8:i.prev=8,i.t0=i.catch(0),_e.info("worklet addModule catch error. ".concat(i.t0.message)),Y.emit(tm);case 12:case"end":return i.stop()}},n,this,[[0,8]])})),function(){return t.apply(this,arguments)})},{key:"initWorkletSuccess",get:function(){return fI}}]),e}(),Sc=0,qB=function(){function e(n){Q(this,e);var i=n.track,r=n.log;if(this.volume_=0,this.log_=r,this.track_=i,this.recorddg_=!1,Sc+=1,va||(va=FS()),this.audioCtx_=va,this.destination_=this.audioCtx_.destination,i){var o=new MediaStream;o.addTrack(this.track_),this.streamSource_=this.audioCtx_.createMediaStreamSource(o)}this.audioWorkletNode_=null,this.scriptProcessorNode_=null,this.interval_=200,Y.on(rc,this.resume,this),Y.on(Vp,this.handleAudioLevelInterval,this),A4?(Y.on(em,this.initAudioWorklet,this),Y.on(tm,this.initScriptProcessor,this),this.preload()):this.initScriptProcessor()}var t;return xe(e,[{key:"preload",value:function(){bc?bc.initWorkletSuccess&&this.initAudioWorklet():bc=new JB({context:va})}},{key:"initAudioWorklet",value:(t=H(p().mark(function n(){var i,r=this;return p().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(!this.audioWorkletNode_){o.next=2;break}return o.abrupt("return");case 2:return o.prev=2,o.next=5,bc.ready;case 5:this.audioWorkletNode_=new AudioWorkletNode(this.audioCtx_,"volume-meter"),this.audioWorkletNode_.port.onmessage=function(c){"volume"in c.data?(r.volume_=c.data.volume||0,!r.recorddg_&&c.data.cl&&c.data.l&&(r.log_.warn("worklet play success"),r.recorddg_=!0)):r.log_.info("get first chunk size:"+c.data.cl)},(i=this.streamSource_)===null||i===void 0||i.connect(this.audioWorkletNode_),this.audioWorkletNode_.connect(this.destination_),this.log_.info("initAudioWorklet success"),this.handleAudioLevelInterval({interval:this.interval_}),o.next=17;break;case 13:o.prev=13,o.t0=o.catch(2),this.log_.warn("load volume meter failed, load again. error: "+o.t0),this.initScriptProcessor();case 17:case"end":return o.stop()}},n,this,[[2,13]])})),function(){return t.apply(this,arguments)})},{key:"initScriptProcessor",value:function(){var n=this;if(!this.scriptProcessorNode_)try{this.scriptProcessorNode_=this.audioCtx_.createScriptProcessor(2048,1,1),this.scriptProcessorNode_.onaudioprocess=function(i){for(var r=i.inputBuffer.getChannelData(0),o=0,c=0;c<r.length;++c)o+=r[c]*r[c];n.volume_=Math.sqrt(o/r.length)||0},this.streamSource_.connect(this.scriptProcessorNode_),this.scriptProcessorNode_.connect(this.destination_),console.log("initScriptProcessor success")}catch(i){this.log_.error("volumeMeter init script processor error: "+i),Sc-=1}}},{key:"write",value:function(n){var i=n.allocationSize({planeIndex:0}),r=new Float32Array(i>>2);n.copyTo(r,{planeIndex:0}),this.audioWorkletNode_&&this.audioWorkletNode_.port.postMessage({name:"chunk",data:r},[r.buffer]),n.close()}},{key:"destroy",value:function(){var n;this.streamSource_&&this.streamSource_.disconnect(),this.scriptProcessorNode_&&(this.scriptProcessorNode_.onaudioprocess=null,this.scriptProcessorNode_.disconnect()),this.audioWorkletNode_&&(this.audioWorkletNode_.port.postMessage({name:"stop"}),this.audioWorkletNode_.port.onmessage=null,this.audioWorkletNode_.disconnect()),this.audioWorkletNode_=null,this.scriptProcessorNode_=null,this.audioCtx_=null,Y.off(rc,this.resume,this),Y.off(Vp,this.handleAudioLevelInterval,this),Y.off(em,this.initAudioWorklet,this),Y.off(tm,this.initScriptProcessor,this),Sc>0&&(Sc-=1),this.recorddg_=!1,Sc===0&&((n=va)===null||n===void 0||n.close(),va=null,bc=null)}},{key:"resume",value:function(){var n;(n=va)===null||n===void 0||n.resume()}},{key:"getInternalAudioLevel",value:function(){return this.volume_}},{key:"getCalculatedVolume",value:function(){return this.volume_.toFixed(2)}},{key:"handleAudioLevelInterval",value:function(n){var i,r=n.interval;this.interval_=r,(i=this.audioWorkletNode_)===null||i===void 0||i.port.postMessage({name:"setIntervalTime",intervalTime:r})}}]),e}(),KB=function(){function e(o){Q(this,e),this.useWorklet=o.useWorklet,this.stream_=o.stream,this.userId_=o.stream.getUserId(),this.log_=this.stream_.getLogger(),this.useWorklet||(this.track_=o.track),o.gainedTrack&&(this.gainedTrack_=o.gainedTrack),this.div_=o.div,this.muted_=o.muted,this.outputDeviceId_=o.outputDeviceId,this.volume_=o.volume,this.pausedRetryCount_=5,this.emitter_=new ki,this.initializeElement(),this.state_="NONE",this.volumeMeter_=new qB({track:this.gainedTrack_||this.track_,log:this.log_})}var t,n,i,r;return xe(e,[{key:"isPlaying",get:function(){return this.state_===ao}},{key:"initializeElement",value:function(){if(!this.useWorklet){if(this.isAudioElementInit()){var o=new MediaStream;o.addTrack(this.gainedTrack_||this.track_);var c=document.createElement(Ee);c.srcObject=o,c.muted=this.muted_,c.setAttribute("id","audio_".concat(this.stream_.getId())),c.setAttribute("autoplay","autoplay"),c.setAttribute("playsinline","playsinline"),this.div_.appendChild(c),this.element_=c}this.handleEvents()}}},{key:"setMuted",value:function(o){this.element_&&(this.element_.muted=o,this.muted_=o)}},{key:"write",value:function(o){this.volumeMeter_.write(o)}},{key:"play",value:(r=H(p().mark(function o(){var c;return p().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!this.useWorklet){a.next=2;break}return a.abrupt("return");case 2:if(!this.outputDeviceId_||!this.element_){a.next=5;break}return a.next=5,this.element_.setSinkId(this.outputDeviceId_);case 5:if(this.setVolume(this.volume_),a.prev=6,!this.element_){a.next=10;break}return a.next=10,this.element_.play();case 10:a.next=18;break;case 12:if(a.prev=12,a.t0=a.catch(6),c=ae({key:ip,data:{media:"Audio",error:a.t0}}),this.log_.warn(c),!c.includes("NotAllowedError")){a.next=18;break}throw new te({code:Z.PLAY_NOT_ALLOWED,message:c});case 18:case"end":return a.stop()}},o,this,[[6,12]])})),function(){return r.apply(this,arguments)})},{key:"handleEvents",value:function(){this.handleElementEvent=this.handleElementEvent.bind(this),this.handleTrackEvent=this.handleTrackEvent.bind(this),this.element_&&(this.element_.addEventListener(hi,this.handleElementEvent),this.element_.addEventListener(Nt,this.handleElementEvent),this.element_.addEventListener(fi,this.handleElementEvent),this.element_.addEventListener(io,this.handleElementEvent)),this.track_.addEventListener(Nt,this.handleTrackEvent),this.track_.addEventListener(tn,this.handleTrackEvent),this.track_.addEventListener(Sr,this.handleTrackEvent),this.track_.readyState===Nt&&this.handleTrackEvent({type:Nt}),this.track_.muted&&this.handleTrackEvent({type:tn})}},{key:"handleElementEvent",value:(i=H(p().mark(function o(c){var a,s,l,u,h,S,I,E=this;return p().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:a=c.type,x.t0=a,x.next=x.t0===hi?4:x.t0===Nt?9:x.t0===fi?12:x.t0===io?21:33;break;case 4:return this.log_.info("audio player is playing"),this.state_=ao,Y.emit(Bp,{stream:this.stream_}),this.emitter_.emit(gn,{state:this.state_,reason:hi}),x.abrupt("break",33);case 9:return this.log_.info("audio player is ended"),this.state_!==pi&&(this.state_=pi,this.emitter_.emit(gn,{state:this.state_,reason:Nt})),x.abrupt("break",33);case 12:return this.log_.info("audio player is paused"),this.state_=kr,this.emitter_.emit(gn,{state:this.state_,reason:fi}),(s=this.div_&&document.getElementById(this.div_.id))||this.log_.warn("audio player has been remove, element ID: ".concat(this.div_.id)),l=lo(),this.pausedRetryCount_>0&&(tr(l)&&l<=70||!s)&&(this.resume(),this.pausedRetryCount_--),_i&&(this.interval_=mt.run(function(){E.element_&&E.state_===kr&&E.resume()},{delay:3e3})),x.abrupt("break",33);case 21:if(!this.element_||!this.element_.error){x.next=32;break}return u="".concat(wm(),"/").concat(aa().name,"/").concat(aa().version),x.next=25,It.getSpeakers();case 25:h=x.sent,S=h[0].label,(I=h.find(function(m){return m.deviceId===E.outputDeviceId_}))&&(S=I.label),this.log_.error("audio player error observed. code: ".concat(this.element_.error.code," message: ").concat(this.element_.error.message," deviceInfo: ").concat(u," speaker: ").concat(S)),ke.uploadEvent({log:"stat-".concat(this.stream_.getType(),"-audio-").concat(Bb,"-").concat(this.element_.error.code,"-").concat(u,"-").concat(S),userId:this.userId_,error:this.element_.error}),this.emitter_.emit(Jk,this.element_.error);case 32:return x.abrupt("break",33);case 33:case"end":return x.stop()}},o,this)})),function(o){return i.apply(this,arguments)})},{key:"handleTrackEvent",value:function(o){var c=o.type;switch(c){case Nt:this.log_.info("audio track is ended"),this.state_!==pi&&(this.state_=pi,this.emitter_.emit(gn,{state:this.state_,reason:Nt})),Y.emit(Yp,{stream:this.stream_,type:c});break;case tn:this.log_.info("audio track is unable to provide media output"),this.stream_.isRemote()||BS(),this.state_!==kr&&(this.state_=kr,this.emitter_.emit(gn,{state:this.state_,reason:tn})),Y.emit(Qp,{stream:this.stream_,type:c});break;case Sr:this.log_.info("audio track is able to provide media output"),this.state_===kr&&(this.state_=ao,this.emitter_.emit(gn,{state:this.state_,reason:Sr}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(hi,this.handleElementEvent),this.element_.removeEventListener(Nt,this.handleElementEvent),this.element_.removeEventListener(fi,this.handleElementEvent),this.element_.removeEventListener(io,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Nt,this.handleTrackEvent),this.track_.removeEventListener(tn,this.handleTrackEvent),this.track_.removeEventListener(Sr,this.handleTrackEvent))}},{key:"setSinkId",value:(n=H(p().mark(function o(c){return p().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.outputDeviceId_===c){a.next=5;break}if(!this.element_){a.next=4;break}return a.next=4,this.element_.setSinkId(c);case 4:this.outputDeviceId_=c;case 5:case"end":return a.stop()}},o,this)})),function(o){return n.apply(this,arguments)})},{key:"setVolume",value:function(o){this.element_&&(this.log_.info("audioElement setVolume to : ".concat(o)),this.element_.volume=o)}},{key:"getAudioLevel",value:function(){return this.volumeMeter_.getCalculatedVolume()}},{key:"getInternalAudioLevel",value:function(){return this.volumeMeter_.getInternalAudioLevel()}},{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),this.interval_>0&&mt.clearTask(this.interval_)}},{key:"resume",value:(t=H(p().mark(function o(){var c;return p().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(a.prev=0,this.volumeMeter_&&this.volumeMeter_.resume(),!this.element_){a.next=5;break}return a.next=5,this.element_.play();case 5:a.next=13;break;case 7:if(a.prev=7,a.t0=a.catch(0),c=ae({key:ip,data:{media:"Audio",error:a.t0}}),this.log_.warn(c),!c.includes("NotAllowedError")){a.next=13;break}throw new te({code:Z.PLAY_NOT_ALLOWED,message:c});case 13:case"end":return a.stop()}},o,this,[[0,7]])})),function(){return t.apply(this,arguments)})},{key:"on",value:function(o,c){this.emitter_.on(o,c)}},{key:"isAudioElementInit",value:function(){return!(yi==="15.2"||yi==="15.3"||yi==="15.4")||this.stream_.getType()!=="local"||!this.muted_||(this.log_.info("audioElement is muted."),!1)}},{key:"getTrack",value:function(){return this.track_}}]),e}();Le({global:!0,constructor:!0,forced:!Om},{DataView:lc.DataView});var XB=Le,QB=Ga,YB=pe([].reverse),pI=[1,2];XB({target:"Array",proto:!0,forced:String(pI)===String(pI.reverse())},{reverse:function(){return QB(this)&&(this.length=this.length),YB(this)}});var $B=mv.left,mI=pr,ZB=Fs;Le({target:"Array",proto:!0,forced:!Ns("reduce")||!ZB&&mI>79&&mI<83},{reduce:function(e){var t=arguments.length;return $B(this,e,t,t>1?arguments[1]:void 0)}});var eF=Le,vI=Ga,tF=bu,nF=at,gI=ai,rF=nn,iF=bn,aF=Cs,oF=tt,sF=Ha,cF=Ms("slice"),uF=oF("species"),Bv=Array,lF=Math.max;eF({target:"Array",proto:!0,forced:!cF},{slice:function(e,t){var n,i,r,o=iF(this),c=rF(o),a=gI(e,c),s=gI(t===void 0?c:t,c);if(vI(o)&&(n=o.constructor,(tF(n)&&(n===Bv||vI(n.prototype))||nF(n)&&(n=n[uF])===null)&&(n=void 0),n===Bv||n===void 0))return sF(o,a,s);for(i=new(n===void 0?Bv:n)(lF(s-a,0)),r=0;a<s;a++,r++)a in o&&aF(i,r,o[a]);return i.length=r,i}});var _I=re,dF=ue,hF=pe,fF=Wt,pF=Pu.trim,yI=s0,kc=_I.parseInt,bI=_I.Symbol,SI=bI&&bI.iterator,kI=/^[+-]?0x/i,mF=hF(kI.exec),TI=kc(yI+"08")!==8||kc(yI+"0x16")!==22||SI&&!dF(function(){kc(Object(SI))})?function(e,t){var n=pF(fF(e));return kc(n,t>>>0||(mF(kI,n)?16:10))}:kc;Le({global:!0,forced:parseInt!=TI},{parseInt:TI}),(0,Dl.exports)("Uint8",function(e){return function(t,n,i){return e(this,t,n,i)}});var vF=function(){function e(t,n,i){Q(this,e),this.isUplink_=i,this.connection_=t,this.log_=n,this.seiMessageList_=[],this.smallVideoSeiMessageList_=[],this.seiPayloadType_=243,this.runningAbortMap_=new Map,this.abortMap_=new Map,this.onSEIMessage=null}return xe(e,[{key:"isRunning",get:function(){return!!this.runningAbortMap_.size>0}},{key:"start",value:function(t){var n=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.seiMessageList_,r=t.createEncodedStreams(),o=r.readable,c=r.writable,a=new TransformStream({transform:this.isUplink_?function(l,u){return n.encodeVideoFrame(l,u,i)}:function(l,u){var h,S;return n.decodeVideoFrame(l,u,t===((h=n.connection_)===null||h===void 0||(S=h.getPeerConnection())===null||S===void 0?void 0:S.getReceivers()[tS]))}}),s=new AbortController;o.pipeThrough(a).pipeTo(c,{signal:s.signal}).catch(function(){}),this.runningAbortMap_.set(t,s)}},{key:"restart",value:function(t,n){this.stop(),this.start(t,n)}},{key:"stop",value:function(t){var n;(n=this.runningAbortMap_.get(t))===null||n===void 0||n.abort(),this.runningAbortMap_.delete(t)}},{key:"destroy",value:function(){this.stop(),this.runningAbortMap_.forEach(function(t){return t.abort()}),this.runningAbortMap_.clear(),this.abortMap_.forEach(function(t){return t.abort()}),this.abortMap_.clear(),this.log_=null,this.onSEIMessage=null,this.connection_=null}},{key:"handleEncodedStreams",value:function(){var t=this;try{var n=this.connection_.getPeerConnection();this.clearUnusedSenderOrReceiver(n),this.isUplink_?n.getSenders().forEach(function(i,r){if(!t.runningAbortMap_.has(i)&&!t.abortMap_.has(i))if(r===lN||r===eS){var o=r===eS?t.smallVideoSeiMessageList_:t.seiMessageList_;t.isRunning?t.restart(i,o):t.start(i,o)}else t.pipeSenderOrReceiver(i)}):n.getReceivers().forEach(function(i,r){var o;t.runningAbortMap_.has(i)||t.abortMap_.has(i)||(r!==dN&&r!==tS||((o=i.track)===null||o===void 0?void 0:o.kind)!==Ie?t.pipeSenderOrReceiver(i):t.isRunning?t.restart(i):t.start(i))})}catch(i){this.log_.warn(i)}}},{key:"pipeSenderOrReceiver",value:function(t){var n=t.createEncodedStreams(),i=n.readable,r=n.writable,o=new AbortController;this.abortMap_.set(t,o),i.pipeTo(r,{signal:o.signal}).catch(function(){})}},{key:"clearUnusedSenderOrReceiver",value:function(t){var n=this;this.abortMap_.forEach(function(i,r){(n.isUplink_?t.getSenders():t.getReceivers()).find(function(o){return o===r})||(i.abort(),n.abortMap_.delete(r))})}},{key:"push",value:function(t,n){n&&n.seiPayloadType&&(this.seiPayloadType_=n.seiPayloadType),this.seiMessageList_.push(t),this.smallVideoSeiMessageList_.push(t)}},{key:"hasSEI",value:function(t){var n=new DataView(t);return n.getInt32(0)===1&&n.getInt8(4)===6}},{key:"isEmptyFrame",value:function(t){return t.type==="empty"||t.data.byteLength===0}},{key:"getNaluCount",value:function(t){for(var n=0,i=0,r=new DataView(t),o=0;o<t.byteLength;o++)switch(r.getUint8(o)){case 0:n++;break;case 1:n!==2&&n!==3||i++,n=0;break;default:n=0}return i}},{key:"encodeVideoFrame",value:function(t,n,i){try{if(this.connection_.isH264&&i.length>0&&!this.isEmptyFrame(t)){var r=9-this.getNaluCount(t.data);if(r<=0)return;for(var o=i.splice(0,r).reverse().map(this.encodeSEINalu.bind(this)),c=o.reduce(function(E,x){return E+x.dataView.byteLength},0),a=new ArrayBuffer(c+t.data.byteLength),s=new DataView(a),l=new DataView(t.data),u=0,h=0;h<o.length;h++)for(var S=0;S<o[h].dataView.byteLength;S++)s.setInt8(u++,o[h].dataView.getInt8(S));for(var I=0;I<t.data.byteLength;I++)s.setInt8(u++,l.getInt8(I));t.data=a,this.log_.debug("".concat(o.length," sei sent"))}}catch(E){this.log_.warn(E)}n.enqueue(t)}},{key:"decodeVideoFrame",value:function(t,n){var i=this,r=arguments.length>2&&arguments[2]!==void 0&&arguments[2];try{if(this.connection_.isH264&&!this.isEmptyFrame(t)&&this.hasSEI(t.data)){for(var o=[],c=new DataView(t.data),a=0,s=-1,l=-1,u=0;u<t.data.byteLength;u++){var h=c.getUint8(u);if(h===0)a++;else if(h===1){if(a===2||a===3){var S=u-a;s===-1?s=S:l===-1&&(l=S,o.push(new II(new DataView(c.buffer.slice(s,l)))),s=S,l=-1);var I=c.getUint8(u+1)===6;if(!I){t.data=new DataView(c.buffer.slice(S)).buffer;break}}a=0}else a=0}this.log_.debug("".concat(o.length," sei received")),ln(this.onSEIMessage)&&o.reverse().forEach(function(E){i.onSEIMessage({seiPayloadType:E.seiPayloadType,data:E.seiPayload.buffer,isFromAuxiliary:r})})}}catch(E){this.log_.warn(E)}n.enqueue(t)}},{key:"encodeSEINalu",value:function(t){var n=t.byteLength,i=parseInt(n/255),r=n%255,o=[];o.push(0,0,0,1,6,this.seiPayloadType_);for(var c=0;c<i;c++)o.push(255);o.push(r);var a=new DataView(t);return o.push.apply(o,Se(new Uint8Array(a.buffer))),o.push(128),new II(new DataView(new Uint8Array(o).buffer),!0)}}]),e}(),II=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];Q(this,e),this.dataView=t,this.isSEI&&(n?this.addPreventionByte():this.removePreventionByte())}return xe(e,[{key:"addPreventionByte",value:function(){for(var t=this.seiPayloadStartIndex,n=this.dataView.byteLength-2,i=[],r=0,o=t;o<=n;o++){var c=this.dataView.getInt8(o);switch(c){case 0:case 1:case 2:case 3:r===2&&(i.push(3),r=0),c==0?r++:r=0,i.push(c);break;default:r=0,i.push(c)}}i.push(this.dataView.getInt8(this.dataView.byteLength-1));var a=new DataView(new Uint8Array([].concat(Se(new Uint8Array(this.dataView.buffer).slice(0,t)),i)).buffer);this.dataView=a}},{key:"removePreventionByte",value:function(){for(var t=this.seiPayloadStartIndex,n=this.dataView.byteLength-1,i=[],r=0,o=t;o<=n;o++)switch(this.dataView.getInt8(o)){case 0:r++,i.push(this.dataView.getInt8(o));break;case 3:r!==2&&i.push(this.dataView.getInt8(o)),r=0;break;default:i.push(this.dataView.getInt8(o)),r=0}var c=new DataView(new Uint8Array([].concat(Se(new Uint8Array(this.dataView.buffer).slice(0,t)),i)).buffer);this.dataView=c}},{key:"isSEI",get:function(){return this.dataView.getUint8(4)===6}},{key:"seiPayloadStartIndex",get:function(){for(var t=6,n=6;n<this.dataView.buffer.byteLength&&(t++,this.dataView.getUint8(n)===255);n++);return t}},{key:"seiPayloadType",get:function(){return this.isSEI?this.dataView.getUint8(5):null}},{key:"seiPayload",get:function(){if(!this.isSEI)return null;for(var t=0,n=6,i=6;i<this.dataView.buffer.byteLength;i++){var r=this.dataView.getUint8(i);if(n++,r!==255){t+=r;break}t+=255}for(var o=new ArrayBuffer(t),c=new DataView(o),a=0;a<o.byteLength;a++,n++)c.setInt8(a,this.dataView.getInt8(n));return c}}]),e}(),Fv=function(){function e(n){Q(this,e),this.userId_=n.userId,this.tinyId_=n.tinyId,this.client_=n.client,this.sdpSemantics_=n.client.getSdpSemantics(),this.isUplink_=n.isUplink,this.log_=_e.createLogger({id:"n|"+this.userId_,userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId(),isLocal:this.isUplink_}),this.signalChannel_=n.signalChannel,this.peerConnection_=null,this.isErrorObserved_=!1,this.emitter_=new ki,this.currentState_=on,this.waitForPeerConnectionConnectedPromise_=null,this.isReconnecting_=!1,this.reconnectionCount_=0,this.reconnectionTimer_=-1,this.isFirstConnection_=!0,this.delay_={audioDelay:0,videoDelay:0},this.enableSEI_=n.enableSEI,this.useWebCodecs=!1,this.enableSEI_&&bl&&(this.sei_=new vF(this,this.log_,this.isUplink_))}var t;return xe(e,[{key:"encodedInsertableStreams",get:function(){return(this.enableSEI_||this.useWebCodecs)&&bl}},{key:"initialize",value:function(){var n={encodedInsertableStreams:this.encodedInsertableStreams,iceServers:this.client_.getIceServers(),iceTransportPolicy:this.client_.getIceTransportPolicy(),sdpSemantics:this.sdpSemantics_,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};this.peerConnection_=new RTCPeerConnection(n),this.peerConnection_.onconnectionstatechange=this.onConnectionStateChange.bind(this)}},{key:"close",value:function(){this.log_.info("closing connection"),this.closePeerConnection(),this.sei_&&(this.sei_.destroy(),this.sei_=null)}},{key:"closePeerConnection",value:function(){var n=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.peerConnection_&&(this.peerConnection_.onconnectionstatechange=function(){},this.peerConnection_.close(),this.peerConnection_=null,n&&this.emitConnectionStateChangedEvent(on))}},{key:"getDTLSTransportState",value:function(){if(!this.peerConnection_)return Ju;var n=null;if(this.isUplink_){if(!vl()||this.peerConnection_.getSenders().length===0)return Ju;n=this.peerConnection_.getSenders()[0].transport}else{if(!Fk()||this.peerConnection_.getReceivers().length===0)return Ju;n=this.peerConnection_.getReceivers()[0].transport}return n?n.state:Ju}},{key:"onConnectionStateChange",value:function(n){var i=this.peerConnection_.iceConnectionState,r=this.getDTLSTransportState();if(this.log_.info("onConnectionStateChange() connectionState: "+n.target.connectionState),this.log_.info("ICE Transport state: ".concat(i,", DTLS Transport state: ").concat(r)),n.target.connectionState===qu&&this.emitConnectionStateChangedEvent(bb),n.target.connectionState===Sb||n.target.connectionState===Hf){var o="".concat(this.isUplink_?"uplink":"downlink"," ICE/DTLS Transport connection ").concat(n.target.connectionState,". ICE Transport state: ").concat(i,", DTLS Transport state: ").concat(r),c=new te({message:o,code:Z.ICE_TRANSPORT_ERROR});ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Lb,error:c}),this.emitConnectionStateChangedEvent(on),this.isErrorObserved_||this.emitter_.emit(et.ERROR,c)}n.target.connectionState!==kb&&n.target.connectionState!==ZM||(this.logSelectedCandidate(),ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Lb}),this.emitConnectionStateChangedEvent(sn))}},{key:"emitConnectionStateChangedEvent",value:function(n){n!==this.currentState_&&(this.currentState_===Ff&&n===bb||(Y.emit(fl,{client:this.client_,connection:this,prevState:this.currentState_,state:n}),this.emitter_.emit(et.CONNECTION_STATE_CHANGED,{prevState:this.currentState_,state:n}),this.currentState_=n))}},{key:"hitTest",value:function(n){return(n===0||n==="0")&&this.isUplink_||n===this.tinyId_}},{key:"addEventInternal",value:function(n,i){var r=this.client_.getUserId(),o={eventId:n,eventDesc:i,timestamp:an(),userId:r,tinyId:this.client_.getTinyId()};this.isUplink_||(o.remoteUserId=this.userId_,o.remoteTinyId=this.tinyId_),vn(r,o)}},{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=H(p().mark(function n(){var i,r,o,c,a,s,l;return p().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.peerConnection_){u.next=2;break}return u.abrupt("return");case 2:return u.next=4,this.peerConnection_.getStats();case 4:i=u.sent,r=oe(i),u.prev=6,r.s();case 8:if((o=r.n()).done){u.next=18;break}if((c=Te(o.value,2))[0],!xm(a=c[1])){u.next=16;break}return s=i.get(a.localCandidateId),l=i.get(a.remoteCandidateId),s&&this.log_.info("local candidate: ".concat(s.candidateType," ").concat(s.protocol,":").concat(s.ip||s.address,":").concat(s.port," ").concat(s.networkType||""," ").concat(s.candidateType==="relay"?"relayProtocol:"+s.relayProtocol:"")),l&&this.log_.info("remote candidate: ".concat(l.candidateType," ").concat(l.protocol,":").concat(l.ip||l.address,":").concat(l.port)),u.abrupt("break",18);case 16:u.next=8;break;case 18:u.next=23;break;case 20:u.prev=20,u.t0=u.catch(6),r.e(u.t0);case 23:return u.prev=23,r.f(),u.finish(23);case 26:case"end":return u.stop()}},n,this,[[6,20,23,26]])})),function(){return t.apply(this,arguments)})},{key:"getCurrentState",value:function(){return this.currentState_}},{key:"waitForPeerConnectionConnected",value:function(){var n=this;return this.waitForPeerConnectionConnectedPromise_||(this.waitForPeerConnectionConnectedPromise_=new Promise(function(i,r){if(n.currentState_===sn)return i();var o=-1,c=function(l){l.state===sn&&(clearTimeout(o),s(),i())},a=function(l){l.client===n.client_&&(clearTimeout(o),s(),r(new te({code:Z.API_CALL_ABORTED,message:ae({key:r4,data:"leave room"})})))},s=function(){Y.off(mo,a,n),n.emitter_.off(et.CONNECTION_STATE_CHANGED,c,n)};o=setTimeout(function(){s();var l=new te({code:Z.API_CALL_TIMEOUT,message:"connection timeout"});r(l)},1e4),Y.on(mo,a,n),n.emitter_.on(et.CONNECTION_STATE_CHANGED,c,n)}),this.waitForPeerConnectionConnectedPromise_=this.waitForPeerConnectionConnectedPromise_.then(function(i){return n.waitForPeerConnectionConnectedPromise_=null,i}).catch(function(i){throw n.waitForPeerConnectionConnectedPromise_=null,i})),this.waitForPeerConnectionConnectedPromise_}},{key:"getReconnectionCount",value:function(){return this.reconnectionCount_}},{key:"startReconnection",value:function(){this.isReconnecting_=!0,this.emitConnectionStateChangedEvent(Ff),this.reconnect(),this.addEventInternal(this.isUplink_?fV:vV,"".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(ac,this.reconnect,this)}},{key:"on",value:function(n,i,r){this.emitter_.on(n,i,r)}},{key:"off",value:function(n,i,r){this.emitter_.off(n,i,r)}},{key:"setDelay",value:function(n){var i=n.audioDelay,r=n.videoDelay;this.delay_={audioDelay:i,videoDelay:r}}},{key:"getDelay",value:function(){return this.delay_}},{key:"isH264",get:function(){var n,i;return!((n=this.peerConnection_)===null||n===void 0||(i=n.remoteDescription)===null||i===void 0||!i.sdp.includes("H264"))}}]),e}(),gF=Le,_F=ue,yF=ch.f;gF({target:"Object",stat:!0,forced:_F(function(){return!Object.getOwnPropertyNames(1)})},{getOwnPropertyNames:yF});var xI,Tc,bF=B1;function Lo(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{retries:5,timeout:2e3};return function(t,n,i){var r=ic({retryFunction:i.value,settings:e,onError:e.onError,onRetrying:e.onRetrying,onRetryFailed:e.onRetryFailed});return i.value=function(){for(var o=arguments.length,c=new Array(o),a=0;a<o;a++)c[a]=arguments[a];return r.apply(this,c)},i}}Le({target:"Array",stat:!0,forced:!gu(function(e){Array.from(e)})},{from:bF});var ga=5e3,SF={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},Hv=xe(function e(t){Q(this,e),this.str_identifier=String(t.userId),this.uint64_tinyid=Number(t.tinyId),this.uint32_role=t.role}),kF=(xI=Lo({timeout:500,retries:3}),Tc=function(){function e(r){var o=this;Q(this,e),this.frameWorkType_=r.frameWorkType||30,this.component_=r.component||0,this.client_=r.client,this.keyPrefix_="key_point",this.storageKey_="".concat(this.keyPrefix_,"_").concat(this.client_.getUserId()),this.log_=_e.createLogger({id:"kpm|"+this.client_.getUserId(),userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId()}),Object.getOwnPropertyNames(this.__proto__).forEach(function(c){c.startsWith("handle")&&ln(o[c])&&(o[c]=function(a){var s=a.fn,l=a.context;return H(p().mark(function u(){var h,S,I,E=arguments;return p().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:for(x.prev=0,h=E.length,S=new Array(h),I=0;I<h;I++)S[I]=E[I];return x.next=4,s.apply(l||this,S);case 4:return x.abrupt("return",x.sent);case 7:x.prev=7,x.t0=x.catch(0),_e.error("".concat(s.name,"() error observed ")+x.t0);case 10:case"end":return x.stop()}},u,this,[[0,7]])}))}({fn:o[c],context:o}))}),this.initData(),this.installEvents(),this.intervalId_=mt.run(uo,this.setStorage.bind(this),{delay:2e4})}var t,n,i;return xe(e,[{key:"initData",value:function(){var r;this.firstPublishedUserList_=[],this.networkQuality_={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this.basicInfo={string_sdk_version:oi,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",string_domain:location.host,uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:((r=this.client_)===null||r===void 0?void 0:r.getMode())==="live"?1:0,uint32_joining_duration:0,uint32_networkType:Xf[xp()],uint32_framework:this.frameWorkType_,uint32_component:this.component_},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(){Y.on(ll,this.handleJoinStart,this),Y.on(Up,this.handleWSStart,this),Y.on(dl,this.handleWSEnd,this),Y.on(Ap,this.handleJoinSendCMD,this),Y.on(Pp,this.handleJoinReceivedCMDResponce,this),Y.on(po,this.handleJoinSuccess,this),Y.on(sa,this.handleJoinFailed,this),Y.on(Mp,this.handleReceivedPublishUserList,this),Y.on(fl,this.handleConnectionStateChanged,this),Y.on(Dp,this.handleLeaveStart,this),Y.on(mo,this.handleLeaveSuccess,this),Y.on(Op,this.handleLeaveSendCMD,this),Y.on($p,this.handleSendSubscribeCMD,this),Y.on(tc,this.handleVideoPlaying,this),Y.on(Bp,this.handleAudioPlaying,this),Y.on(Zp,this.handleNetworkQuality,this),Y.on(Lp,this.handleHeartbeatStats,this),Y.on(hl,this.handleRemoteStreamAdded,this),Y.on(Fp,this.handleRemoteStreamSubscribeStart,this),Y.on(Ur,this.handleRemoteStreamSubscribed,this),Y.on(ca,this.handleRemoteStreamRemoved,this),Y.on(qp,this.handleVideoLoadedData,this),Y.on(Jp,this.handlePlayStream,this),Y.on(Np,this.handlePublishStart,this),Y.on(Hp,this.handleLocalStreamInitStart,this),Y.on(Gp,this.handleLocalStreamInitEnd,this),Y.on(Wp,this.handleLocalStreamInitFailed,this)}},{key:"uninstallEvents",value:function(){Y.off(ll,this.handleJoinStart,this),Y.off(Up,this.handleWSStart,this),Y.off(dl,this.handleWSEnd,this),Y.off(Ap,this.handleJoinSendCMD,this),Y.off(Pp,this.handleJoinReceivedCMDResponce,this),Y.off(Mp,this.handleReceivedPublishUserList,this),Y.off(fl,this.handleConnectionStateChanged,this),Y.off(Dp,this.handleLeaveStart,this),Y.off(mo,this.handleLeaveSuccess,this),Y.off(po,this.handleJoinSuccess,this),Y.off(sa,this.handleJoinFailed,this),Y.off(Op,this.handleLeaveSendCMD,this),Y.off($p,this.handleSendSubscribeCMD,this),Y.off(tc,this.handleVideoPlaying,this),Y.off(Bp,this.handleAudioPlaying,this),Y.off(Zp,this.handleNetworkQuality,this),Y.off(Lp,this.handleHeartbeatStats,this),Y.off(hl,this.handleRemoteStreamAdded,this),Y.off(Fp,this.handleRemoteStreamSubscribeStart,this),Y.off(Ur,this.handleRemoteStreamSubscribed,this),Y.off(ca,this.handleRemoteStreamRemoved,this),Y.off(qp,this.handleVideoLoadedData,this),Y.off(Jp,this.handlePlayStream,this),Y.off(Np,this.handlePublishStart,this),Y.off(Hp,this.handleLocalStreamInitStart,this),Y.off(Gp,this.handleLocalStreamInitEnd,this),Y.off(Wp,this.handleLocalStreamInitFailed,this)}},{key:"destroy",value:function(){this.uninstallEvents(),mt.clearTask(this.intervalId_),this.client_=null}},{key:"handleJoinStart",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_start_time===0&&(this.pathJoinRoom_.uint64_start_time=Date.now(),this.checkStorage())}},{key:"handleWSStart",value:function(r){var o=r.client;this.hitTest(o)&&this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_start_time===0&&(this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_start_time=Date.now())}},{key:"handleWSEnd",value:function(r){var o=r.client,c=r.error;this.hitTest(o)&&this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_end_time===0&&(this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_end_time=Date.now(),c&&(this.pathJoinRoom_.int32_send_request_acc_ip_cmd_ret=c instanceof te?Number(c.getExtraCode()||c.getCode()):Z.UNKNOWN,this.pathJoinRoom_.int32_end_ret=2))}},{key:"handleJoinSendCMD",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_send_request_enter_room_cmd_start_time===0&&(this.pathJoinRoom_.uint64_send_request_enter_room_cmd_start_time=Date.now())}},{key:"handleJoinReceivedCMDResponce",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_send_request_enter_room_cmd_end_time===0&&(this.pathJoinRoom_.uint64_send_request_enter_room_cmd_end_time=Date.now(),this.pathJoinRoom_.int32_send_request_enter_room_cmd_ret=r.code,r.code!==0&&(this.pathJoinRoom_.int32_end_ret=3))}},{key:"handleJoinSuccess",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_end_time===0&&(this.pathJoinRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.int32_end_ret=0)}},{key:"handleJoinFailed",value:function(r){var o=r.client;this.hitTest(o)&&(this.pathJoinRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.int32_end_ret===0&&(this.pathJoinRoom_.int32_end_ret=3),this.prepareReport(),this.report())}},{key:"handleReceivedPublishUserList",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_recv_userlist_time===0&&(this.pathJoinRoom_.uint64_recv_userlist_time=Date.now(),this.firstPublishedUserList_=r.data.data&&r.data.data.userList||[])}},{key:"handleConnectionStateChanged",value:function(r){var o=r.client,c=r.state,a=r.connection;if(this.hitTest(o)&&c===sn){this.client_.getUplinkConnection()===a&&this.pathJoinRoom_.uint64_send_first_video_frame_time===0&&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 s=this.pathMainVideoMap_.get("".concat(a.getUserId(),"_").concat(yt));s&&s.statsToReport.uint64_pc_connected_time===0&&(s.statsToReport.uint64_pc_connected_time=Date.now())}}},{key:"handleLeaveStart",value:function(r){this.hitTest(r.client)&&(this.pathLeaveRoom_.uint64_start_time=Date.now())}},{key:"handleLeaveSuccess",value:function(r){this.hitTest(r.client)&&this.pathLeaveRoom_.uint64_end_time===0&&(this.pathLeaveRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.uint64_end_time!==0?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(r){this.hitTest(r.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(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s),u=this.remoteStreamStatsMap_.get(l);if(u)u.stream=c;else{var h={userId:a,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:q({},SF),stream:c};h.statsToReport.msg_user_info=new Hv({userId:a,tinyId:c.getTinyId(),role:so}),h.statsToReport.uint32_stream_type=s===yt?2:7,this.remoteStreamStatsMap_.set(l,h)}}}},{key:"handleRemoteStreamSubscribeStart",value:function(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s),u=this.remoteStreamStatsMap_.get(l);u&&u.subscribeStartTime===0&&(u.subscribeStartTime=Date.now())}}},{key:"handleSendSubscribeCMD",value:function(r){if(this.hitTest(r.client)){var o=new Hv(r),c=Date.now(),a="".concat(r.userId,"_").concat(yt);r.trackState.video&&r.subscribeState.video&&!this.pathMainVideoMap_.has(a)&&this.pathMainVideoMap_.set(a,{statsToReport:{msg_user_info:o,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:r.userId,sendSubscribeCMDTime:c}),r.trackState.audio&&r.subscribeState.audio&&!this.pathMainAudioMap_.has(a)&&this.pathMainAudioMap_.set(a,{statsToReport:{msg_user_info:o,uint64_start_enter_time:this.pathJoinRoom_.uint64_start_time,uint64_play_first_frame_time:0},userId:r.userId,sendSubscribeCMDTime:c});var s="".concat(r.userId,"_").concat(Dt);r.trackState.auxiliary&&r.subscribeState.auxiliary&&!this.pathAuxiliaryMap_.has(s)&&this.pathAuxiliaryMap_.set(s,{sendSubscribeCMDTime:c})}}},{key:"handleRemoteStreamSubscribed",value:function(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s),u=this.remoteStreamStatsMap_.get(l);u&&u.subscribedTime===0&&(u.subscribedTime=Date.now(),u.stream=c)}}},{key:"handleRemoteStreamRemoved",value:function(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l=this.remoteStreamStatsMap_.get("".concat(a,"_").concat(s));l&&(l.stream=null)}}},{key:"handlePlayStream",value:function(r){var o=r.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var c=o.getConnection().getUserId(),a="".concat(c,"_").concat(o.getType());if(this.remoteStreamStatsMap_.has(a)){var s=this.remoteStreamStatsMap_.get(a);s.playStreamTime===0&&(s.playStreamTime=Date.now())}}}},{key:"handleVideoLoadedData",value:function(r){var o=r.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var c=o.getConnection().getUserId(),a="".concat(c,"_").concat(o.getType());if(this.pathMainVideoMap_.has(a)){var s=this.pathMainVideoMap_.get(a);s.statsToReport.uint64_combine_first_frame_time===0&&(s.statsToReport.uint64_combine_first_frame_time=Date.now())}}}},{key:"handleVideoPlaying",value:function(r){var o=r.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var c=o.getConnection().getUserId(),a="".concat(c,"_").concat(o.getType()),s=Date.now();if(this.pathMainVideoMap_.has(a)){var l=this.pathMainVideoMap_.get(a);if(l.statsToReport.uint64_render_first_frame_time===0&&(l.statsToReport.uint64_render_first_frame_time=s),this.remoteStreamStatsMap_.has(a)){var u=this.remoteStreamStatsMap_.get(a),h=u.statsToReport,S=u.playStreamTime,I=u.subscribedTime;h.uint32_video_render_first===0&&S-I<=100&&(h.uint32_video_render_first=s-l.sendSubscribeCMDTime)}}if(o.getType()===Dt&&this.pathAuxiliaryMap_.has(a)&&this.remoteStreamStatsMap_.has(a)){var E=this.remoteStreamStatsMap_.get(a),x=E.statsToReport,m=E.playStreamTime,T=E.subscribedTime;x.uint32_video_render_first===0&&m-T<=100&&(x.uint32_video_render_first=s-this.pathAuxiliaryMap_.get(a).sendSubscribeCMDTime)}}}},{key:"handleAudioPlaying",value:function(r){if(r.stream.isRemote()&&r.stream.getConnection()&&this.hitTest(r.stream.getConnection().getClient())){var o=r.stream.getConnection().getUserId(),c="".concat(o,"_").concat(r.stream.getType());if(this.pathMainAudioMap_.has(c)){var a=this.pathMainAudioMap_.get(c);a.statsToReport.uint64_play_first_frame_time===0&&(a.statsToReport.uint64_play_first_frame_time=Date.now())}}}},{key:"handleNetworkQuality",value:function(r){var o=this;this.hitTest(r.client)&&(this.networkQuality_.totalUplinkLoss+=r.uplinkLoss,this.networkQuality_.totalUplinkRTT+=r.uplinkRTT,this.networkQuality_.count++,r.downlinkLossAndRTTMap.forEach(function(c){var a=c.rtt,s=c.loss,l=c.userId,u=o.networkQuality_.totalDownlinkRTTAndLossMap.get(l);u?(u.totalRTT+=a,u.totalLoss+=s,u.count++):o.networkQuality_.totalDownlinkRTTAndLossMap.set(l,{totalRTT:a,totalLoss:s,count:1})}))}},{key:"handleHeartbeatStats",value:function(r){var o=this;if(this.hitTest(r.client)){var c=r.stats,a=c.msg_up_stream_info,s=c.msg_down_stream_info;if(a.msg_video_status[0]){var l=a.msg_video_status[0],u=l.uint32_video_codec_bitrate,h=l.uint32_video_enc_fps,S=l.uint32_video_width,I=l.uint32_video_height;this.localStreamStats_.totalVideoBitrate+=u,this.localStreamStats_.totalVideoFPS+=h,this.localStreamStats_.totalVideoWidth+=S,this.localStreamStats_.totalVideoHeight+=I,this.localStreamStats_.videoCount++}if(a.msg_audio_status){var E=a.msg_audio_status.audioLevel;Math.floor(100*E)>0&&(this.localStreamStats_.totalAudioLevel+=E,this.localStreamStats_.audioLevelCount++)}s.forEach(function(x){var m=x.msg_user_info,T=x.msg_audio_status,v=x.msg_video_status,w=m.str_identifier;if(v.forEach(function(_){var b=_.uint32_video_stream_type===2,R=_.uint32_video_stream_type===7,P="".concat(w,"_").concat(b?yt:Dt);if(o.remoteStreamStatsMap_.has(P)){var U,k,f=o.remoteStreamStatsMap_.get(P);(b&&(U=f.stream)!==null&&U!==void 0&&U.isMainVideoSubscribed||R&&(k=f.stream)!==null&&k!==void 0&&k.isAuxVideoSubscribed)&&(f.totalVideoFPS+=_.uint32_video_receive_fps,f.totalVideoBitrate+=_.uint32_video_codec_bitrate,f.videoCount++,f.statsToReport.uint32_video_width===0&&(f.statsToReport.uint32_video_width=_.uint32_video_width),f.statsToReport.uint32_video_height===0&&(f.statsToReport.uint32_video_height=_.uint32_video_height))}}),T){var L="".concat(w,"_").concat(yt);if(o.remoteStreamStatsMap_.has(L)){var N,V=o.remoteStreamStatsMap_.get(L);(N=V.stream)!==null&&N!==void 0&&N.isMainAudioSubscribed&&(V.totalAudioBitrate+=T.uint32_audio_codec_bitrate,V.audioCount++,Math.floor(100*T.audioLevel)>0&&(V.totalAudioLevel+=T.audioLevel,V.audioLevelCount++))}}})}}},{key:"handlePublishStart",value:function(r){var o=r.client;this.hitTest(o)&&this.localStreamStats_.publishStartTime===0&&(this.localStreamStats_.publishStartTime=Date.now())}},{key:"handleLocalStreamInitStart",value:function(r){var o=r.audio,c=r.video;o&&this.pathJoinRoom_.uint64_init_audio_start_time===0&&(this.pathJoinRoom_.uint64_init_audio_start_time=Date.now()),c&&this.pathJoinRoom_.uint64_init_camera_start_time===0&&(this.pathJoinRoom_.uint64_init_camera_start_time=Date.now())}},{key:"handleLocalStreamInitEnd",value:function(r){var o=r.audio,c=r.video;o&&this.pathJoinRoom_.uint64_init_audio_end_time===0&&(this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),c&&this.pathJoinRoom_.uint64_init_camera_end_time===0&&(this.pathJoinRoom_.uint64_init_camera_end_time=Date.now())}},{key:"handleLocalStreamInitFailed",value:function(r){var o=r.audio,c=r.video,a=r.error,s=a instanceof te?a.getExtraCode()||a.getCode():{NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5}[a.name]||Z.UNKNOWN;o&&this.pathJoinRoom_.uint64_init_audio_end_time===0&&(this.pathJoinRoom_.int32_init_audio_ret=s,this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),c&&this.pathJoinRoom_.uint64_init_camera_end_time===0&&(this.pathJoinRoom_.int32_init_camera_ret=s,this.pathJoinRoom_.uint64_init_camera_end_time=Date.now())}},{key:"hasVideoFlag",value:function(r){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===r&&1&o.flag})>=0}},{key:"hasAudioFlag",value:function(r){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===r&&8&o.flag})>=0}},{key:"hasAuxFlag",value:function(r){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===r&&4&o.flag})>=0}},{key:"hitTest",value:function(r){return r===this.client_}},{key:"checkStorage",value:(i=H(p().mark(function r(){var o;return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(c.prev=0,!(o=bo.getItem(this.storageKey_))){c.next=6;break}return c.next=5,this.upload(o);case 5:bo.deleteItem(this.storageKey_);case 6:c.next=11;break;case 8:c.prev=8,c.t0=c.catch(0),this.log_.warn(c.t0);case 11:case"end":return c.stop()}},r,this,[[0,8]])})),function(){return i.apply(this,arguments)})},{key:"setStorage",value:function(){this.prepareReport();var r=this.getReportData();r.msg_path_enter_room.uint64_start_time!==0&&bo.setItem(this.storageKey_,r)}},{key:"prepareReport",value:function(){var r=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 o=Math.floor(this.localStreamStats_.totalVideoWidth/this.localStreamStats_.videoCount),c=Math.floor(this.localStreamStats_.totalVideoHeight/this.localStreamStats_.videoCount);this.localStreamStats_.statsToReport.uint32_video_big_resolution=o<<16|c}this.localStreamStats_.audioLevelCount>0&&(this.localStreamStats_.statsToReport.uint32_audio_capture_db=Math.floor(this.localStreamStats_.totalAudioLevel/this.localStreamStats_.audioLevelCount*100)),this.remoteStreamStatsMap_.forEach(function(a,s){var l=a.userId;if(r.networkQuality_.totalDownlinkRTTAndLossMap.has(l)){var u=r.networkQuality_.totalDownlinkRTTAndLossMap.get(l),h=u.totalLoss,S=u.count;a.statsToReport.uint32_avg_down_loss=Math.floor(h/S)}a.videoCount>0&&(a.statsToReport.uint32_video_avg_fps=Math.floor(a.totalVideoFPS/a.videoCount),a.statsToReport.uint32_video_avg_bitrate=Math.floor(a.totalVideoBitrate/a.videoCount)),a.audioCount>0&&(a.statsToReport.uint32_audio_recv_bitrate=a.statsToReport.uint32_audio_bitrate=Math.floor(a.totalAudioBitrate/a.audioCount)),a.audioLevelCount>0&&(a.statsToReport.uint32_audio_play_db=Math.floor(a.totalAudioLevel/a.audioLevelCount*100));var I=r.client_.getCallDurationCalculator();I&&(a.statsToReport.uint32_audio_play_time=I.getDuration(s,Ee),a.statsToReport.uint32_video_play_time=I.getDuration(s,Ie)),a.statsToReport.uint32_video_render_first=Math.min(a.statsToReport.uint32_video_render_first,ga);var E=r.client_.getBadCaseDetector();if(E){var x=E.getDataFreezeDuration(s),m=x.dataFreeze,T=x.count,v=E.getRenderFreezeDuration(s).renderFreeze;a.statsToReport.uint32_video_block_count=T,a.statsToReport.uint32_video_block_time=Math.min(m,a.statsToReport.uint32_video_play_time),a.statsToReport.uint32_video_external_block_time=Math.min(v,a.statsToReport.uint32_video_play_time),E.isBlackStream(s)&&a.statsToReport.uint32_video_avg_fps===0?a.statsToReport.uint32_video_black_screen_subjective=1:a.statsToReport.uint32_video_black_screen_subjective=0}(a.subscribeStartTime===0||a.subscribeStartTime-a.streamAddedTime>100||a.playStreamTime===0)&&(r.pathMainAudioMap_.delete(s),r.pathMainVideoMap_.delete(s),a.statsToReport.uint32_video_render_first=0)}),this.pathMainAudioMap_.forEach(function(a,s){r.hasAudioFlag(a.userId)?a.statsToReport.uint64_play_first_frame_time-a.statsToReport.uint64_start_enter_time>ga&&(a.statsToReport.uint64_play_first_frame_time=a.statsToReport.uint64_start_enter_time+ga):r.pathMainAudioMap_.delete(s)}),this.pathMainVideoMap_.forEach(function(a,s){r.hasVideoFlag(a.userId)?a.statsToReport.uint64_render_first_frame_time-a.statsToReport.uint64_start_enter_time>ga&&(a.statsToReport.uint64_render_first_frame_time=a.statsToReport.uint64_start_enter_time+ga):r.pathMainVideoMap_.delete(s)}),this.pathJoinRoom_.uint64_end_time-this.pathJoinRoom_.uint64_start_time>ga&&(this.pathJoinRoom_.uint64_end_time=this.pathJoinRoom_.uint64_start_time+ga)}},{key:"getReportData",value:function(){var r=this.client_.getSignalInfo();return{uint32_sdk_app_id:Number(this.client_.getSDKAppId()),msg_user_info:new Hv({userId:this.client_.getUserId(),tinyId:this.client_.getTinyId(),role:this.client_.getRole()===Tr?so:Bf}),msg_basic_info:this.basicInfo,uint32_acc_ip:Cp(r.relayIp),uint32_client_ip:Cp(r.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:Se(this.pathMainVideoMap_.values()).map(function(o){return o.statsToReport}),msg_quality_statistics:Se(this.remoteStreamStatsMap_.values()).map(function(o){return o.statsToReport}),str_room_name:String(this.client_.getRoomId()),msg_path_recv_audio:Se(this.pathMainAudioMap_.values()).map(function(o){return o.statsToReport}),uint32_info_client_ip:Cp(r.clientIp,"small"),error_code:[],msg_local_statistics:this.localStreamStats_.statsToReport,msg_function_state:Ai.getStateArray()}}},{key:"report",value:(n=H(p().mark(function r(){var o;return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,o=this.getReportData(),c.next=4,this.upload(o);case 4:bo.deleteItem(this.storageKey_),Ai.clearStateArray(),this.initData(),c.next=12;break;case 9:c.prev=9,c.t0=c.catch(0),this.log_.warn(c.t0);case 12:case"end":return c.stop()}},r,this,[[0,9]])})),function(){return n.apply(this,arguments)})},{key:"upload",value:(t=H(p().mark(function r(o){var c,a,s;return p().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(!(ra||o.msg_path_enter_room.uint64_start_time===0||[$f,Qb,Yb].findIndex(function(u){return u===location.host})>=0)){l.next=2;break}return l.abrupt("return");case 2:return c=Number(this.client_.getSDKAppId()),a=sl(c,qM),l.next=6,ul({url:a,body:JSON.stringify(o)});case 6:if((s=l.sent).data==="ok"){l.next=9;break}throw"key point upload failed: ".concat(s.data);case 9:case"end":return l.stop()}},r,this)})),function(r){return t.apply(this,arguments)})}]),e}(),X(Tc.prototype,"upload",[xI],Object.getOwnPropertyDescriptor(Tc.prototype,"upload"),Tc.prototype),Tc),Ai=function(){function e(){Q(this,e)}return xe(e,null,[{key:"handleFunctionState",value:function(t){var n,i,r,o,c=t.className,a=t.fnName,s=t.params;if(!(ra||[$f,Qb,Yb].findIndex(function(S){return S===location.host})>=0)){var l,u=[];if(c)switch(a){case"createClient":(n=s[0])!==null&&n!==void 0&&n.mode&&u.push("".concat(c,".").concat(a,".").concat(s[0].mode)),(i=s[0])!==null&&i!==void 0&&i.useStringRoomId?u.push("".concat(c,".").concat(a,".stringRoomId")):u.push("".concat(c,".").concat(a,".intRoomId")),(r=s[0])!==null&&r!==void 0&&r.autoSubscribe?u.push("".concat(c,".").concat(a,".autoSubscribe")):u.push("".concat(c,".").concat(a,".manualSubscribe"));break;case"publish":(o=s[1])!==null&&o!==void 0&&o.isAuxiliary?u.push("".concat(c,".").concat(a,".isAuxiliary")):u.push("".concat(c,".").concat(a));break;case"setAudioProfile":case"setVideoProfile":case"setScreenProfile":case"setVideoContentHint":Bt(s[0])&&u.push("".concat(c,".").concat(a,".").concat(s[0]));break;default:u.push("".concat(c,".").concat(a))}else u.push(a);for(var h=0;h<u.length;h++){if(!(l=pN[u[h]]))return;this.stateMap.has(l)?this.stateMap.get(l).int32_call_times+=1:this.stateMap.set(l,{int32_id:l,int32_call_times:1})}}}},{key:"getStateArray",value:function(){return Array.from(this.stateMap.values())}},{key:"clearStateArray",value:function(){this.stateMap.clear()}}]),e}();function St(e){return function(t,n,i){var r=i.value;return i.value=function(){for(var o=arguments.length,c=new Array(o),a=0;a<o;a++)c[a]=arguments[a];try{e||(e=this.name_),Ai.handleFunctionState({className:e,fnName:n,params:c}),e=void 0}catch(s){this.log_.info(s)}return r.apply(this,c)},i}}$e(Ai,"stateMap",new Map);var wI,CI,EI,cr,RI=function(){function e(n){Q(this,e),this.stream_=n.stream,this.userId_=n.stream.getUserId(),this.log_=this.stream_.getLogger(),this.track_=n.track,this.div_=n.div,this.muted_=n.muted,this.objectFit_=n.objectFit,this.mirror_=n.mirror,this.emitter_=new ki,this.initializeElement(),this.state_="NONE",this.pausedRetryCount_=5}var t;return xe(e,[{key:"isPlaying",get:function(){return this.state_===ao}},{key:"initializeElement",value:function(){var n=new MediaStream;n.addTrack(this.track_);var i=document.createElement(Ie);i.srcObject=n,i.muted=!0;var r="width: 100%; height: 100%; object-fit: ".concat(this.objectFit_,";");this.mirror_&&(r+="transform: scaleX(-1);"),i.setAttribute("id","video_".concat(this.stream_.getId())),i.setAttribute("style",r),i.setAttribute("autoplay","autoplay"),i.setAttribute("playsinline","playsinline"),this.element_=i,OS===17&&this.initCanvasElement(r),this.div_&&this.div_.appendChild(this.canvas_||i),this.handleEvents()}},{key:"initCanvasElement",value:function(n){var i=this;if(this.track_&&!this.stream_.isRemote()){var r=document.createElement("canvas"),o=function(){var a,s=(a=i.track_)===null||a===void 0?void 0:a.getSettings();s&&s.width&&s.height&&(r.width=s.width,r.height=s.height)};o(),r.setAttribute("style",n);var c=r.getContext("2d");this.canvasTimerId_=mt.run("raf",function(){i.element_&&c&&(o(),c.drawImage(i.element_,0,0,r.width,r.height))},{backgroundTask:!1}),this.log_.warn("use canvas for playback"),this.canvas_=r}}},{key:"setRect",value:function(n){var i=n.width,r=n.height;this.element_&&(this.element_.style.width=i+"px",this.element_.style.height=r+"px")}},{key:"setMirror",value:function(n){this.element_&&(this.element_.style.transform=n?"scaleX(-1)":"",this.mirror_=n)}},{key:"setObjectFit",value:function(n){this.element_&&(this.element_.style.objectFit="".concat(n),this.objectFit_=n)}},{key:"play",value:(t=H(p().mark(function n(){var i;return p().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,this.element_.play();case 3:r.next=11;break;case 5:if(r.prev=5,r.t0=r.catch(0),i=ae({key:ip,data:{media:"Video",error:r.t0}}),this.log_.warn(i),!i.includes("NotAllowedError")){r.next=11;break}throw new te({code:Z.PLAY_NOT_ALLOWED,message:i});case 11:case"end":return r.stop()}},n,this,[[0,5]])})),function(){return t.apply(this,arguments)})},{key:"handleEvents",value:function(){this.handleElementEvent=this.handleElementEvent.bind(this),this.handleTrackEvent=this.handleTrackEvent.bind(this),this.element_.addEventListener(hi,this.handleElementEvent),this.element_.addEventListener(Nt,this.handleElementEvent),this.element_.addEventListener(fi,this.handleElementEvent),this.element_.addEventListener(io,this.handleElementEvent),this.element_.addEventListener(Nf,this.handleElementEvent),this.track_.addEventListener(Nt,this.handleTrackEvent),this.track_.addEventListener(tn,this.handleTrackEvent),this.track_.addEventListener(Sr,this.handleTrackEvent),this.track_.readyState===Nt&&this.handleTrackEvent({type:Nt}),this.track_.muted&&this.handleTrackEvent({type:tn})}},{key:"handleElementEvent",value:function(n){var i=this;switch(n.type){case hi:this.log_.info("video player is playing"),this.state_=ao,Y.emit(tc,{stream:this.stream_}),this.emitter_.emit(gn,{state:this.state_,reason:hi}),this.interval_&&(mt.clearTask(this.interval_),this.interval_=null);break;case Nt:this.log_.info("video player is ended"),this.state_!==pi&&(this.state_=pi,this.emitter_.emit(gn,{state:this.state_,reason:Nt}));break;case fi:this.log_.info("video player is paused"),this.div_&&!document.getElementById(this.div_.id)&&this.log_.warn("video player has been remove, element ID: ".concat(this.div_.id)),this.state_=kr,this.emitter_.emit(gn,{state:this.state_,reason:fi}),this.pausedRetryCount_>0&&!OT()&&(this.log_.info("video player auto resume when video paused"),this.resume(),this.pausedRetryCount_--),_i&&(this.interval_=mt.run(function(){i.element_&&i.state_===kr&&i.resume()},{delay:3e3}));break;case io:if(this.element_&&this.element_.error){var r="".concat(wm(),"/").concat(aa().name,"/").concat(aa().version);this.log_.error("video player error observed. code: ".concat(this.element_.error.code," message: ").concat(this.element_.error.message," deviceInfo: ").concat(r)),ke.uploadEvent({log:"stat-".concat(this.stream_.getType(),"-video-").concat(Bb,"-").concat(this.element_.error.code,"-").concat(r),userId:this.userId_,error:this.element_.error})}break;case Nf:Y.emit(qp,{stream:this.stream_})}}},{key:"handleTrackEvent",value:function(n){var i=n.type;switch(i){case Nt:this.log_.info("video track is ended"),Y.emit(Xp,{stream:this.stream_,type:i}),this.state_!==pi&&(this.state_=pi,this.emitter_.emit(gn,{state:this.state_,reason:Nt}));break;case tn:this.log_.info("video track is unable to provide media output"),this.stream_.isRemote()||BS(),Y.emit(nc,{stream:this.stream_,type:i}),this.state_!==kr&&(this.state_=kr,this.emitter_.emit(gn,{state:this.state_,reason:tn}));break;case Sr:this.log_.info("video track is able to provide media output"),Y.emit(zp,{stream:this.stream_}),this.state_===kr&&(this.state_=ao,this.emitter_.emit(gn,{state:this.state_,reason:Sr}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(hi,this.handleElementEvent),this.element_.removeEventListener(Nt,this.handleElementEvent),this.element_.removeEventListener(fi,this.handleElementEvent),this.element_.removeEventListener(io,this.handleElementEvent),this.element_.removeEventListener(Nf,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Nt,this.handleTrackEvent),this.track_.removeEventListener(tn,this.handleTrackEvent),this.track_.removeEventListener(Sr,this.handleTrackEvent))}},{key:"stop",value:function(){this.unbindEvents(),this.element_&&(this.element_.remove(),this.element_.srcObject=null,this.element_=null),this.interval_&&mt.clearTask(this.interval_),this.canvasTimerId_&&mt.clearTask(this.canvasTimerId_),this.canvas_&&(this.canvas_.remove(),this.canvas_=null)}},{key:"resume",value:function(){return this.play()}},{key:"getVideoFrame",value:function(){var n=document.createElement("canvas");return n.width=this.element_.videoWidth,n.height=this.element_.videoHeight,n.getContext("2d").drawImage(this.element_,0,0),n.toDataURL("image/png")}},{key:"on",value:function(n,i){this.emitter_.on(n,i)}},{key:"getElement",value:function(){return this.element_?this.element_:null}},{key:"getTrack",value:function(){return this.track_}}]),e}(),AI=(wI=dn.apply(void 0,Se(Yt.STREAM.play)),CI=St(),EI=St(),cr=function(){function e(c){Q(this,e),this.code3reconnect_=0,this.name_=uN,this.userId_=c.userId,this.isRemote_=c.isRemote,this.type_=c.type,this.log_=_e.createLogger({id:"s".concat(c.seq?c.seq:"","|").concat(this.userId_),userId:ge(c.client)?void 0:c.client.getUserId(),sdkAppId:ge(c.client)?void 0:c.client.getSDKAppId(),isLocal:!this.isRemote_,type:this.isRemote_?this.type_:""}),this.client_=null,ge(c.client)||(this.client_=c.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_="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var s=16*Math.random()|0;return(a=="x"?s:3&s|8).toString(16)}),this.audioOutputDeviceId_=0,this.audioVolume_=1,this.emitter_=GS(new ki,this.name_),this.connectionState_=on,this.installEvents(),ge(c.mirror)||this.log_.warn('TRTC.createStream "mirror" option was deprecated since v4.12.1\uFF0Cplease use localStream.play to set up preview mirror. refer to '.concat(co,"/en/LocalStream.html#play. TRTC.createStream \u63A5\u53E3\u7684 mirror \u9009\u9879\u4ECE v4.12.1 \u5F00\u59CB\u88AB\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 localStream.play \u8BBE\u7F6E\u672C\u5730\u6D41\u9884\u89C8\u955C\u50CF\uFF0C\u53C2\u8003\u6587\u6863\uFF1A").concat(co,"/zh-cn/LocalStream.html#play\u3002")),this.audioPlayerRetryCount_=3}var t,n,i,r,o;return xe(e,[{key:"installEvents",value:function(){Y.on(rc,this.restartPlayback,this)}},{key:"uninstallEvents",value:function(){Y.off(rc,this.restartPlayback,this)}},{key:"getType",value:function(){return this.type_}},{key:"getLogger",value:function(){return this.log_}},{key:"isSubscribed",get:function(){return this.type_===yt&&this.connection_.isMainStreamSubscribed||this.type_===Dt&&this.connection_.isAuxStreamSubscribed}},{key:"isMainVideoSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===yt&&c&&c.video}},{key:"isMainAudioSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===yt&&c&&c.audio}},{key:"isAuxVideoSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===Dt&&c&&c.auxiliary}},{key:"isSmallVideoSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===yt&&c&&c.smallVideo}},{key:"emitConnectionStateChanged",value:function(c){c.state!==this.connectionState_&&(c.state!==on&&this.isRemote_&&!this.isSubscribed||(this.emitter_.emit(a6,c),this.connectionState_=c.state))}},{key:"setConnection",value:function(c){this.connection_!==c&&(c instanceof Fv?(this.connection_!==null&&this.connection_.off(et.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),c.on(et.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this)):c===null&&this.connection_.off(et.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),this.connection_=c)}},{key:"getConnection",value:function(){return this.connection_}},{key:"play",value:(o=H(p().mark(function c(a,s){var l,u,h;return p().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(this.log_.info("stream ".concat(this.isPlaying_?"update":"start to"," play with elementId: ").concat(a," and options: ").concat(JSON.stringify(s),".")),!this.isPlaying_){S.next=9;break}return s&&!ge(s.muted)&&(this.muted_=s.muted),s&&!ge(s.objectFit)&&(this.objectFit_=s.objectFit),this.isScreenShare()?this.mirror_=!1:s&&!ge(s.mirror)&&(this.mirror_=s.mirror),this.audioPlayer_&&this.audioPlayer_.setMuted(this.muted_),this.videoPlayer_&&(this.videoPlayer_.setObjectFit(this.objectFit_),this.videoPlayer_.setMirror(this.mirror_)),this.elementId_!==a&&(l=a,Bt(a)&&(l=document.getElementById(a)),l.appendChild(this.div_),this.elementId_=a),S.abrupt("return");case 9:return this.isPlaying_=!0,(u=document.createElement("div")).setAttribute("id","player_".concat(this.id_)),u.setAttribute("style","width: 100%; height: 100%; position: relative; background-color: black; overflow: hidden;"),h=a,Bt(a)&&(h=document.getElementById(a)),h.appendChild(u),this.elementId_=a,this.div_=u,this.isRemote_||(this.muted_=!0),s&&!ge(s.muted)&&(this.muted_=s.muted),this.isScreenShare()&&(this.objectFit_="contain"),s&&!ge(s.objectFit)&&(this.objectFit_=s.objectFit),this.isScreenShare()?this.mirror_=!1:(this.isRemote_||(this.mirror_=!0),s&&!ge(s.mirror)&&(this.mirror_=s.mirror)),Y.emit(Jp,{stream:this}),S.next=26,Promise.all([this.playAudio(),this.playVideo()]);case 26:Y.emit(L4,{stream:this});case 27:case"end":return S.stop()}},c,this)})),function(c,a){return o.apply(this,arguments)})},{key:"playAudio",value:(r=H(p().mark(function c(){var a,s,l,u,h=this;return p().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(this.hasAudio()&&(!this.isRemote_||this.isMainAudioSubscribed)){S.next=2;break}return S.abrupt("return");case 2:if(a=this.getAudioTrack(),this.audioPlayer_||!a){S.next=18;break}return this.log_.info("create AudioPlayer and play"+((s=this.connection_)!==null&&s!==void 0&&s.useWebCodecs?" with WebCodecs":"")),this.audioPlayer_=new KB({useWorklet:(l=this.connection_)===null||l===void 0?void 0:l.useWebCodecs,stream:this,track:a,gainedTrack:(u=this.gain_)===null||u===void 0?void 0:u.audioTrack,div:this.div_,muted:this.muted_,outputDeviceId:this.audioOutputDeviceId_,volume:this.audioVolume_}),this.audioPlayer_.on(gn,function(I){var E={type:Ee,state:I.state,reason:I.reason};Y.emit(XS,q({stream:h},E)),h.emitter_.emit(zk,E)}),this.audioPlayer_.on(Jk,function(I){var E,x,m;if(I.code===3&&bl&&h.isRemote_&&(E=h.client_)!==null&&E!==void 0&&(x=E.schedule_)!==null&&x!==void 0&&(m=x.config)!==null&&m!==void 0&&m.audioCode3)return h.connection_.useWebCodecs?void 0:(h.log_.warn("audio player error code 3, reconnect with WebCodecs decode"),h.stopAudio(),h.connection_.useWebCodecs=!0,void h.connection_.waitForPeerConnectionConnected().then(function(){h.connection_.startReconnection()}));h.audioPlayerRetryCount_>0&&(h.audioPlayerRetryCount_--,h.restartAudio())}),S.prev=8,S.next=11,this.audioPlayer_.play();case 11:S.next=18;break;case 13:throw S.prev=13,S.t0=S.catch(8),this.client_&&this.client_.getEnableAutoPlayDialog()&&new NT,this.emitter_.emit(Cm,S.t0),S.t0;case 18:case"end":return S.stop()}},c,this,[[8,13]])})),function(){return r.apply(this,arguments)})},{key:"playVideo",value:(i=H(p().mark(function c(){var a,s=this;return p().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(this.hasVideo()&&(!this.isRemote_||this.isMainVideoSubscribed||this.isAuxVideoSubscribed||this.isSmallVideoSubscribed)){l.next=2;break}return l.abrupt("return");case 2:if(a=this.getVideoTrack(),this.videoPlayer_||!a){l.next=18;break}return Y.emit(Kp,{stream:this}),this.log_.info("create VideoPlayer and play"),this.videoPlayer_=new RI({stream:this,track:a,div:this.div_,muted:this.muted_,objectFit:this.objectFit_,mirror:this.mirror_}),this.videoPlayer_.on(gn,function(u){var h={type:Ie,state:u.state,reason:u.reason};Y.emit(XS,q({stream:s},h)),s.emitter_.emit(zk,h)}),l.prev=8,l.next=11,this.videoPlayer_.play();case 11:l.next=18;break;case 13:throw l.prev=13,l.t0=l.catch(8),this.client_&&this.client_.getEnableAutoPlayDialog()&&new NT,this.emitter_.emit(Cm,l.t0),l.t0;case 18:case"end":return l.stop()}},c,this,[[8,13]])})),function(){return i.apply(this,arguments)})},{key:"stopAudio",value:function(){this.audioPlayer_&&(this.log_.info("stop AudioPlayer"),this.audioPlayer_.stop(),this.audioPlayer_=null)}},{key:"stopVideo",value:function(){this.videoPlayer_&&(this.log_.info("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(c){}))}},{key:"restartVideo",value:function(){this.isPlaying_&&(this.stopVideo(),this.playVideo().catch(function(c){}))}},{key:"stop",value:function(){this.isPlaying_&&(this.isPlaying_=!1,this.stopAudio(),this.stopVideo(),this.div_.parentNode.removeChild(this.div_))}},{key:"resume",value:(n=H(p().mark(function c(){return p().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.isPlaying_){a.next=2;break}return a.abrupt("return");case 2:if(this.log_.info("resume"),!this.audioPlayer_){a.next=6;break}return a.next=6,this.audioPlayer_.resume();case 6:if(!this.videoPlayer_){a.next=9;break}return a.next=9,this.videoPlayer_.resume();case 9:case"end":return a.stop()}},c,this)})),function(){return n.apply(this,arguments)})},{key:"close",value:function(){this.log_.info("close stream"),this.isPlaying_&&this.stop(),this.isRemote_||(this.mediaStream_&&(this.mediaStream_.preventEvent=1,this.mediaStream_.getTracks().forEach(function(c){c.stop()}),this.mediaStream_=null),this.uninstallEvents())}},{key:"muteAudio",value:function(){return this.addRemoteEvent(!0,Ee),this.doEnableTrack(Ee,!1)}},{key:"muteVideo",value:function(){return this.addRemoteEvent(!0,Ie),this.doEnableTrack(Ie,!1)}},{key:"unmuteAudio",value:function(){return this.addRemoteEvent(!1,Ee),this.doEnableTrack(Ee,!0)}},{key:"unmuteVideo",value:function(){return this.addRemoteEvent(!1,Ie),this.doEnableTrack(Ie,!0)}},{key:"addRemoteEvent",value:function(c,a){if(this.isRemote_&&this.client_){var s=this.client_.getUserId(),l="".concat(c?tn:Sr," remote ").concat(a);vn(s,{eventId:a===Ee?c?tV:rV:c?eV:nV,eventDesc:l,timestamp:new Date().getTime(),userId:s,tinyId:this.client_.getTinyId(),remoteUserId:this.userId_,remoteTinyId:this.connection_.getTinyId()})}}},{key:"doEnableTrack",value:function(c,a){var s=!1;return c===Ee?this.mediaStream_.getAudioTracks().forEach(function(l){s=!0,l.enabled=a}):this.mediaStream_.getVideoTracks().forEach(function(l){s=!0,l.enabled=a}),s}},{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:(t=H(p().mark(function c(a){var s;return p().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(this.log_.info("setAudioOutput ".concat(a)),this.audioOutputDeviceId_=a,!this.audioPlayer_){l.next=5;break}return l.next=5,this.audioPlayer_.setSinkId(a);case 5:return l.next=7,Qk();case 7:s=l.sent,this.log_.info("speakers: ".concat(JSON.stringify(s)));case 9:case"end":return l.stop()}},c,this)})),function(c){return t.apply(this,arguments)})},{key:"setAudioVolume",value:function(c){this.audioVolume_=c,this.log_.info("setAudioVolume to ".concat(c)),this.audioPlayer_&&this.audioPlayer_.setVolume(c)}},{key:"getAudioLevel",value:function(){var c=0;return this.audioPlayer_&&(c=this.audioPlayer_.getAudioLevel()),c}},{key:"getInternalAudioLevel",value:function(){var c=0;return this.audioPlayer_&&(c=this.audioPlayer_.getInternalAudioLevel()),c}},{key:"hasAudio",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var c=this.connection_.getTrackState();return this.type_===yt&&c.audio}return!!this.getAudioTrack()}},{key:"hasVideo",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var c=this.connection_.getTrackState();return this.type_===Dt?c.auxiliary:c.video}return!!this.getVideoTrack()}},{key:"getSubscribedState",value:function(){return this.isRemote_&&this.connection_?this.connection_.getSubscribeState():null}},{key:"getAudioTrack",value:function(){var c=null;if(this.mediaStream_){var a=this.mediaStream_.getAudioTracks();a.length>0&&(c=a[0])}return c}},{key:"getVideoTrack",value:function(){var c=null;if(this.mediaStream_){var a=this.mediaStream_.getVideoTracks();a.length>0&&(c=a[0])}return c}},{key:"getVideoFrame",value:function(){return this.videoPlayer_?this.videoPlayer_.getVideoFrame():null}},{key:"getMediaStream",value:function(){return this.mediaStream_}},{key:"setReceiver",value:function(c){var a=this,s=c.createEncodedStreams(),l=s.readable,u=s.writable;this.log_.info("setReceiver");var h=new AudioDecoder({error:function(E){return a.log_.error(E)},output:function(E){a.audioPlayer_&&a.audioPlayer_.write(E)}});h.configure({codec:"opus",sampleRate:48e3,numberOfChannels:1}),this.log_.info("audioDecoder state:"+h.state);var S,I=new TransformStream({transform:(S=H(p().mark(function E(x,m){return p().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:h.decode(new EncodedAudioChunk({data:x.data,timestamp:x.timestamp,type:"key"})),m.enqueue(x);case 2:case"end":return T.stop()}},E)})),function(E,x){return S.apply(this,arguments)})});l.pipeThrough(I).pipeTo(u).then(function(){return h.close()}).catch(function(E){h.close(),a.log_.error(E)})}},{key:"setMediaStream",value:function(c){c!==this.mediaStream_&&(this.mediaStream_&&this.mediaStream_.getTracks().forEach(function(a){return a.stop()}),this.mediaStream_=c)}},{key:"updateVideoPlayingState",value:function(c){if(this.isPlaying_)if(c){if(this.log_.info("playing state updated, play video"),this.videoPlayer_&&this.videoPlayer_.getTrack()!==this.getVideoTrack())return this.log_.warn("audio track changed, restart playback"),this.restartVideo();this.playVideo().catch(function(a){})}else this.log_.info("playing state updated, stop video"),this.stopVideo()}},{key:"updateAudioPlayingState",value:function(c){if(this.isPlaying_)if(c){if(this.log_.info("playing state updated, play audio"),this.audioPlayer_&&this.audioPlayer_.getTrack()!==this.getAudioTrack())return this.log_.warn("audio track changed, restart playback"),this.restartAudio();this.playAudio().catch(function(a){})}else this.log_.info("playing state updated, stop audio"),this.stopAudio()}},{key:"on",value:function(c,a,s){this.emitter_.on(c,a,s)}},{key:"off",value:function(c,a,s){c==="*"?this.emitter_.removeAllListeners():this.emitter_.off(c,a,s)}},{key:"isRemote",value:function(){return this.isRemote_}},{key:"isScreenShare",value:function(){return!this.isRemote_&&this.screen_||this.isRemote_&&this.getType()===gt}},{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}(),X(cr.prototype,"play",[wI],Object.getOwnPropertyDescriptor(cr.prototype,"play"),cr.prototype),X(cr.prototype,"setAudioOutput",[CI],Object.getOwnPropertyDescriptor(cr.prototype,"setAudioOutput"),cr.prototype),X(cr.prototype,"getVideoFrame",[EI],Object.getOwnPropertyDescriptor(cr.prototype,"getVideoFrame"),cr.prototype),cr),Gv=function(e){Et(n,e);var t=Rr(n);function n(i){var r;Q(this,n);var o={isRemote:!0,type:i.type},c=q(q({},i),o);return(r=t.call(this,c)).name_=Yf,r.isStreamAddedEventEmitted_=!1,r.isAbleToCallSubscription_=!0,r}return xe(n,[{key:"installEvents",value:function(){le(Ye(n.prototype),"installEvents",this).call(this),Y.on(Ur,this.handleStreamSubscribed,this),Y.on(Vr,this.handleStreamUnsubscribed,this)}},{key:"uninstallEvents",value:function(){le(Ye(n.prototype),"uninstallEvents",this).call(this),Y.off(Ur,this.handleStreamSubscribed,this),Y.off(Vr,this.handleStreamUnsubscribed,this)}},{key:"handleStreamSubscribed",value:function(i){i.client===this.client_&&i.stream===this&&this.connection_.getCurrentState()===sn&&this.emitConnectionStateChanged({prevState:on,state:sn})}},{key:"handleStreamUnsubscribed",value:function(i){i.client===this.client_&&i.stream===this&&this.emitConnectionStateChanged({prevState:sn,state:on})}},{key:"getType",value:function(){return le(Ye(n.prototype),"getType",this).call(this)}},{key:"getIsAbleToCallSubscription",value:function(){return this.isAbleToCallSubscription_}},{key:"setIsAbleToCallSubscription",value:function(i){this.isAbleToCallSubscription_=i}},{key:"setIsStreamAddedEventEmitted",value:function(i){this.isStreamAddedEventEmitted_=i}},{key:"getIsStreamAddedEventEmitted",value:function(){return this.isStreamAddedEventEmitted_}},{key:"getAudioTrack",value:function(){return this.connection_&&this.connection_.getTrackState().audio?le(Ye(n.prototype),"getAudioTrack",this).call(this):null}},{key:"getVideoTrack",value:function(){if(!this.connection_)return null;var i=this.connection_.getTrackState();return(this.type_!==yt||i.video)&&(this.type_!==Dt||i.auxiliary)?le(Ye(n.prototype),"getVideoTrack",this).call(this):null}},{key:"close",value:function(){le(Ye(n.prototype),"close",this).call(this)}}]),n}(AI),TF=function(){function e(r){Q(this,e),this.client_=r.client,this.subscribedStreams_=new Map,this.unsubscribedStreams_=new Map,this.subscriptedOptions_=new Map,this.autoRecoveryFlags_=new Map}var t,n,i;return xe(e,[{key:"isEnabled",get:function(){return this.client_.getEnv()!=="webrtc"}},{key:"recover",value:(i=H(p().mark(function r(o){var c,a,s;return p().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(c=o.getUserId(),a=o.getType(),this.hasAutoRecoveryFlag(c,a)){l.next=5;break}return l.abrupt("return");case 5:if(s=this.getUnsubscribedStream(c,a)?"unsubscribe":"subscribe",l.prev=6,_e.warn("recover() try to recover subscription [".concat(s,"][").concat(c,"][").concat(a,"]")),s!=="subscribe"){l.next=13;break}return l.next=11,this.recoverSubscription(c,o);case 11:l.next=15;break;case 13:return l.next=15,this.recoverUnsubscription(c,o);case 15:ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ub}),_e.warn("recover() recover successfully [".concat(s,"][").concat(c,"][").concat(a,"]")),l.next=23;break;case 19:l.prev=19,l.t0=l.catch(6),_e.error("recover() recover failed [".concat(s,"][").concat(c,"][").concat(a,"]"),l.t0),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Ub,error:l.t0});case 23:this.deleteAutoRecoveryFlag(c,a);case 24:case"end":return l.stop()}},r,this,[[6,19]])})),function(r){return i.apply(this,arguments)})},{key:"recoverSubscription",value:(n=H(p().mark(function r(o,c){var a,s,l,u,h;return p().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(a=this.getOptions(o,c.getType()),s=this.getSubscribedStream(o,c.getType()),a&&s){S.next=4;break}return S.abrupt("return");case 4:l=this.getStreamMuteState(s),u=l.isAudioMuted,h=l.isVideoMuted,this.mergeStream(s,c),this.recoverPlayingState(s),u&&s.doEnableTrack(Ee,!1),h&&s.doEnableTrack(Ie,!1);case 9:case"end":return S.stop()}},r,this)})),function(r,o){return n.apply(this,arguments)})},{key:"recoverUnsubscription",value:(t=H(p().mark(function r(o,c){var a;return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(a=this.getUnsubscribedStream(o,c.getType())){s.next=3;break}return s.abrupt("return");case 3:this.mergeStream(a,c);case 4:case"end":return s.stop()}},r,this)})),function(r,o){return t.apply(this,arguments)})},{key:"getStreamMuteState",value:function(r){var o={isAudioMuted:!1,isVideoMuted:!1},c=r.getMediaStream();return c&&(o.isAudioMuted=c.getAudioTracks().map(function(a){return a.enabled}).includes(!1),o.isVideoMuted=c.getVideoTracks().map(function(a){return a.enabled}).includes(!1)),o}},{key:"recoverPlayingState",value:function(r){var o=r.isPlaying(),c=r.getDiv();if(o&&c){var a=c.parentNode;r.stop(),r.play(a,{objectFit:r.getObjectFit(),muted:r.getMuted()})}}},{key:"mergeStream",value:function(r,o){var c=o.getConnection(),a=o.getMediaStream();r.setConnection(c),c.setRemoteStream(a.id,r),r.setMediaStream(a),r.updateAudioPlayingState(o.hasAudio()),r.updateVideoPlayingState(o.hasVideo())}},{key:"addSubscriptionRecord",value:function(r,o,c){var a=o.getType();if(this.subscribedStreams_.has(r))this.subscribedStreams_.get(r).set(a,o);else{var s=new Map;s.set(o.getType(),o),this.subscribedStreams_.set(r,s)}if(this.subscriptedOptions_.has(r))this.subscriptedOptions_.get(r).set(a,c);else{var l=new Map;l.set(o.getType(),c),this.subscriptedOptions_.set(r,l)}this.deleteUnsubscriptionRecord(r,a)}},{key:"addUnsubscriptionRecord",value:function(r,o){if(this.unsubscribedStreams_.has(r))this.unsubscribedStreams_.get(r).set(o.getType(),o);else{var c=new Map;c.set(o.getType(),o),this.unsubscribedStreams_.set(r,c)}this.deleteSubscriptionRecord(r,o.getType())}},{key:"getSubscribedStream",value:function(r,o){return this.subscribedStreams_.has(r)&&this.subscribedStreams_.get(r).has(o)?this.subscribedStreams_.get(r).get(o):null}},{key:"getOptions",value:function(r,o){return this.subscriptedOptions_.has(r)&&this.subscriptedOptions_.get(r).has(o)?this.subscriptedOptions_.get(r).get(o):null}},{key:"getUnsubscribedStream",value:function(r,o){return this.unsubscribedStreams_.has(r)&&this.unsubscribedStreams_.get(r).has(o)?this.unsubscribedStreams_.get(r).get(o):null}},{key:"deleteSubscriptionRecord",value:function(r,o){this.subscribedStreams_.has(r)&&this.subscribedStreams_.get(r).delete(o),this.subscriptedOptions_.has(r)&&this.subscriptedOptions_.get(r).delete(o)}},{key:"deleteUnsubscriptionRecord",value:function(r,o){this.unsubscribedStreams_.has(r)&&this.unsubscribedStreams_.get(r).delete(o)}},{key:"markAllStream",value:function(){for(var r=0,o=Se(this.subscribedStreams_.entries());r<o.length;r++)for(var c=Te(o[r],2),a=c[0],s=0,l=Se(c[1].entries());s<l.length;s++){var u=Te(l[s],1)[0];this.setAutoRecoveryFlag(a,u)}for(var h=0,S=Se(this.unsubscribedStreams_.entries());h<S.length;h++)for(var I=Te(S[h],2),E=I[0],x=0,m=Se(I[1].entries());x<m.length;x++){var T=Te(m[x],1)[0];this.setAutoRecoveryFlag(E,T)}}},{key:"setAutoRecoveryFlag",value:function(r,o){if(_e.info("setAutoRecoveryFlag() mark [".concat(r,"][").concat(o,"]")),this.autoRecoveryFlags_.has(r))this.autoRecoveryFlags_.get(r).set(o);else{var c=new Map;c.set(o),this.autoRecoveryFlags_.set(r,c)}}},{key:"hasAutoRecoveryFlag",value:function(r,o){return!!this.isEnabled&&this.autoRecoveryFlags_.has(r)&&this.autoRecoveryFlags_.get(r).has(o)}},{key:"deleteAutoRecoveryFlag",value:function(r,o){this.autoRecoveryFlags_.has(r)&&this.autoRecoveryFlags_.get(r).delete(o)}},{key:"delete",value:function(r){this.unsubscribedStreams_.delete(r),this.subscribedStreams_.delete(r),this.subscriptedOptions_.delete(r),this.autoRecoveryFlags_.delete(r)}}]),e}(),IF=function(){function e(t){Q(this,e),this.player_=t,this.canvas_=document.createElement(hb),this.canvasCtx_=this.canvas_.getContext("2d")}return xe(e,[{key:"setCanvasRect",value:function(t,n){this.canvas_.width=t,this.canvas_.height=n}},{key:"drawVideoToCanvas",value:function(){var t=this.player_.getElement(),n=t.videoHeight,i=t.videoWidth,r=i*this.canvas_.height/(n*this.canvas_.width);if(r>1.05||r<.95){var o=i*n/(this.canvas_.width*this.canvas_.height);this.setCanvasRect(i/Math.sqrt(o),n/Math.sqrt(o))}this.canvasCtx_.drawImage(t,0,0,this.canvas_.width,this.canvas_.height)}},{key:"generateVideoTrackFromCanvasCapture",value:function(t){return this.canvas_.captureStream(t).getVideoTracks()[0]}},{key:"generateStreamFromTrack",value:function(t){var n=new MediaStream;return n.addTrack(t),n}},{key:"destroy",value:function(){this.player_.stop(),this.canvas_.width=0,this.canvas_.height=0,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 t=this.player_.getElement();if(t)return t.readyState===t.HAVE_ENOUGH_DATA}return!1}}]),e}(),xF=new Blob(['let t,e,a,i;onmessage=function(n){const{action:h,data:s}=n.data;switch(h){case"render":a=s.canvas,t=a.width,e=a.height,i=a.getContext("2d"),function(t,e){const n=new TransformStream({async transform(t,e){const n=t.displayWidth,h=t.displayHeight,s=n*a.height/(h*a.width);if(s>1.05||s<.95){const t=n*h/(a.width*a.height);a.width=n/Math.sqrt(t),a.height=h/Math.sqrt(t)}i.drawImage(t,0,0,a.width,a.height);const o=new VideoFrame(a,{timestamp:t.timestamp});t.close(),e.enqueue(o)}});t.pipeThrough(n).pipeTo(e)}(s.readable,s.writable)}}'],{type:"application/javascript"}),wF=function(){function e(t){Q(this,e);var n=t.videoTrack;this.width=void 0,this.height=void 0,this.canvas=document.createElement("canvas"),this.offscreen=null,this.smallGenerator=new MediaStreamTrackGenerator({kind:"video"}),this.smallWritable=this.smallGenerator.writable,this.bigProcessor=new MediaStreamTrackProcessor({track:n}),this.bigReadable=this.bigProcessor.readable,this.initWorker()}return xe(e,[{key:"initWorker",value:function(){try{this.worker=new Worker(URL.createObjectURL(xF)),_e.info("init worker processor success")}catch(t){_e.warn("init worker processor failed. ".concat(t.error))}}},{key:"setCanvasRect",value:function(t,n){this.width=t,this.height=n,this.canvas.width=t,this.canvas.height=n,this.offscreen=this.canvas.transferControlToOffscreen(),this.worker.postMessage({action:"render",data:{canvas:this.offscreen,readable:this.bigReadable,writable:this.smallWritable}},[this.offscreen,this.bigReadable,this.smallWritable])}},{key:"generatorVideoTrack",value:function(){var t=new MediaStream([this.smallGenerator]);return t==null?void 0:t.getTracks()[0]}},{key:"destroy",value:function(){this.worker.terminate()}}]),e}(),Zl=function(){function e(n){Q(this,e),this.localStream_=n,this.player_=null,this.processor_=null,this.initOffscreenSuccess_=!1}var t;return xe(e,[{key:"initialize",value:(t=H(p().mark(function n(){var i;return p().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(r6()&&((i=navigator)===null||i===void 0?void 0:i.hardwareConcurrency)>=6)){r.next=13;break}return r.prev=1,r.next=4,this.initOffscreen();case 4:this.initOffscreenSuccess_=!0,_e.info("Initialize VideoGenerator successfully!"),r.next=11;break;case 8:r.prev=8,r.t0=r.catch(1),this.initCanvas();case 11:r.next=14;break;case 13:this.initCanvas();case 14:case"end":return r.stop()}},n,this,[[1,8]])})),function(){return t.apply(this,arguments)})},{key:"generateSmallVideoTrack",value:function(n){var i,r=n.height,o=n.width,c=n.frameRate,a=this.getSmallVideoProfile(o,r);return this.initOffscreenSuccess_?(this.processor_.setCanvasRect(a.width,a.height),i=this.processor_.generatorVideoTrack()):(this.processor_.setCanvasRect(a.width,a.height),this.player_.setRect({width:a.width,height:a.height}),i=this.processor_.generateVideoTrackFromCanvasCapture(c),this.interval_=mt.run(Yu,this.render.bind(this),{fps:c})),i}},{key:"render",value:function(){this.processor_.canDrawVideoToCanvas&&this.processor_.drawVideoToCanvas()}},{key:"destroy",value:function(){mt.clearTask(this.interval_),this.processor_&&this.processor_.destroy()}},{key:"initOffscreen",value:function(){this.processor_=new wF({videoTrack:this.localStream_.getVideoTrack()})}},{key:"initCanvas",value:function(){this.player_=new RI({stream:this.localStream_,track:this.localStream_.getVideoTrack(),muted:!0,objectFit:"cover",mirror:!1}),this.player_.play().then(function(){_e.info("VideoGenerator: play local video success")}).catch(function(){_e.error("VideoGenerator: Failed to play local video")}),this.processor_=new IF(this.player_)}},{key:"getSmallVideoProfile",value:function(n,i){var r,o=this.localStream_.getVideoTrack(),c=this.localStream_.getVideoProfile();if(la){var a=o.getSettings();a&&a.width&&a.height&&(c.width=a.width,c.height=a.height)}var s=c.width*c.height,l=n*i;return _e.info("big stream resolution: ".concat(c.width,"*").concat(c.height," small stream resolution: ").concat(n,"*").concat(i," ")),r=s>l?s/l:s/19200,{width:parseInt(c.width/Math.sqrt(r)),height:parseInt(c.height/Math.sqrt(r))}}}]),e}(),ed=new Map,CF=function(){var e=H(p().mark(function t(n){var i,r,o,c,a,s,l;return p().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!_l()){u.next=2;break}return u.abrupt("return");case 2:return u.next=4,EF(n);case 4:if(i=u.sent,_e.info("getUserMedia with constraints: "+JSON.stringify(i)),!i.audio){u.next=11;break}return u.next=9,It.getMicrophones();case 9:r=u.sent,_e.info("microphones: ".concat(fo(r,["deviceId","label"])));case 11:if(!i.video){u.next=16;break}return u.next=14,It.getCameras();case 14:o=u.sent,_e.info("cameras: ".concat(fo(o,["deviceId","label"])));case 16:return u.prev=16,u.next=19,navigator.mediaDevices.getUserMedia(i);case 19:return u.abrupt("return",u.sent);case 22:if(u.prev=22,u.t0=u.catch(16),u.t0.name!=="NotFoundError"){u.next=29;break}if(!o||o.length!==0){u.next=27;break}throw new te({code:Z.DEVICE_NOT_FOUND,message:ae({key:J3})});case 27:if(!r||r.length!==0){u.next=29;break}throw new te({code:Z.DEVICE_NOT_FOUND,message:ae({key:z3})});case 29:throw i.audio&&((c=r)===null||c===void 0?void 0:c.length)>0&&(s=r.find(function(h){return h.deviceId===n.microphoneId}))&&s.getCapabilities&&_e.warn(fo(s.getCapabilities(),tp)),i.video&&((a=o)===null||a===void 0?void 0:a.length)>0&&(l=o.find(function(h){return h.deviceId===n.cameraId}))&&l.getCapabilities&&_e.warn(fo(l.getCapabilities(),tp)),new te({code:Z.INITIALIZE_FAILED,name:u.t0.name,message:u.t0.message,constraint:u.t0.constraint});case 32:case"end":return u.stop()}},t,null,[[16,22]])}));return function(t){return e.apply(this,arguments)}}(),Wv=ic({retryFunction:CF,settings:{retries:3,timeout:500},onError:function(e,t,n,i,r){var o=r+1;_e.warn("getUserMedia error: ".concat(e)),e.name==="NotReadableError"||e.name==="OverconstrainedError"?(o===1&&i[0].video?(i[0].maxResoution=!1,i[0].frameRate=i[0].frameRate>10?10:5):o===2?i[0].useDeviceIdOnly=!0:o!==3||i[0].useExact&&!i[0].retryWhenExactFailed||(i[0].useTrueAsConstraint=!0),e.message.includes("deviceId")&&i[0].retryWhenExactFailed&&(i[0].useExact=!1),t()):n(e)},onRetrying:function(e){_e.warn("getUserMedia retrying [".concat(e,"/3]"))},onRetryFailed:function(){ke.uploadEvent({log:"stat-getUserMedia-retry-failed"})},onRetrySuccess:function(e){ke.uploadEvent({log:"stat-getUserMedia-retry-success-"+e})}});function EF(e){return{audio:RF(e),video:AF(e)}}function RF(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;var t={};return!Br(e.microphoneId)&&(t.deviceId=e.useExact?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(t.echoCancellation=!0,t.noiseSuppression=!0,t.autoGainControl=!0,t.sampleRate=e.sampleRate,tr(e.channelCount)&&e.channelCount>1&&(t.channelCount=e.channelCount),nr(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),nr(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),nr(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!Br(t)||t)}function AF(e){if(!e.video)return!1;if(e.useTrueAsConstraint)return!0;var t=e.maxResoution,n=t===void 0||t,i={};return e.facingMode?i.facingMode=e.facingMode:e.cameraId&&(i.deviceId=e.useExact?{exact:e.cameraId}:e.cameraId),e.useDeviceIdOnly&&!Br(i)?i:(e.width&&(i.width={ideal:e.width},n&&!Vn&&(i.width.max=e.width)),e.height&&(i.height={ideal:e.height},n&&!Vn&&(i.height.max=e.height)),Vn&&ec&&e.width&&e.height&&e.width*e.height<101376&&(i.width=e.width,i.height=e.height),e.frameRate&&(i.frameRate=e.frameRate),!!Br(i)||i)}var PF=function(){var e=H(p().mark(function t(n){var i,r,o,c,a,s,l,u,h;return p().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(!_l()){S.next=2;break}return S.abrupt("return");case 2:if(i=null,!(il&&kp<74||na)){S.next=27;break}return r=zv(n),_e.info("getDisplayMedia with constraints: "+JSON.stringify(r)),S.next=8,navigator.mediaDevices.getDisplayMedia(r);case 8:if(o=S.sent,!n.screenAudio){S.next=14;break}return _e.warn("Your browser not support capture system audio"),S.abrupt("return",o);case 14:if(!n.audio){S.next=24;break}return c=PI(n),_e.info("getUserMedia with constraints: "+JSON.stringify(c)),S.next=19,navigator.mediaDevices.getUserMedia(c);case 19:return i=S.sent,o.addTrack(i.getAudioTracks()[0]),S.abrupt("return",o);case 24:return S.abrupt("return",o);case 25:S.next=53;break;case 27:if(!n.screenAudio){S.next=37;break}return n.audioConstraints={echoCancellation:n.echoCancellation,autoGainControl:n.autoGainControl,noiseSuppression:n.noiseSuppression,sampleRate:44100},a=zv(n),_e.info("getDisplayMedia with constraints: "+JSON.stringify(a)),S.next=33,navigator.mediaDevices.getDisplayMedia(a);case 33:return s=S.sent,S.abrupt("return",s);case 37:return l=zv(n),_e.info("getDisplayMedia with constraints: "+JSON.stringify(l)),S.next=41,navigator.mediaDevices.getDisplayMedia(l);case 41:if(u=S.sent,!n.audio){S.next=52;break}return h=PI(n),_e.info("getUserMedia with constraints: "+JSON.stringify(h)),S.next=47,navigator.mediaDevices.getUserMedia(h);case 47:return i=S.sent,u.addTrack(i.getAudioTracks()[0]),S.abrupt("return",u);case 52:return S.abrupt("return",u);case 53:case"end":return S.stop()}},t)}));return function(t){return e.apply(this,arguments)}}();function PI(e){var t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return ge(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}function zv(e){var t={systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},n={width:na?{max:e.width}:{ideal:e.width,max:e.width},height:na?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:"monitor"};return t.video=n,ge(e.audioConstraints)||(t.audio=e.audioConstraints),t}var DI,OI,LI,MI,NI,UI,VI,jI,BI,FI,HI,nt,GI,Ic,Jv=new Map([["120p",{width:160,height:120,frameRate:15,bitrate:200}],["120p_2",{width:160,height:120,frameRate:15,bitrate:100}],["180p",{width:320,height:180,frameRate:15,bitrate:350}],["180p_2",{width:320,height:180,frameRate:15,bitrate:150}],["240p",{width:320,height:240,frameRate:15,bitrate:400}],["240p_2",{width:320,height:240,frameRate:15,bitrate:200}],["360p",{width:640,height:360,frameRate:15,bitrate:800}],["360p_2",{width:640,height:360,frameRate:15,bitrate:400}],["480p",{width:640,height:480,frameRate:15,bitrate:900}],["480p_2",{width:640,height:480,frameRate:15,bitrate:500}],["720p",{width:1280,height:720,frameRate:15,bitrate:1500}],["1080p",{width:1920,height:1080,frameRate:15,bitrate:2e3}],["1440p",{width:2560,height:1440,frameRate:30,bitrate:4860}],["4K",{width:3840,height:2160,frameRate:30,bitrate:9e3}]]),qv=new Map([["480p",{width:640,height:480,frameRate:5,bitrate:900}],["480p_2",{width:640,height:480,frameRate:30,bitrate:1e3}],["720p",{width:1280,height:720,frameRate:5,bitrate:1200}],["720p_2",{width:1280,height:720,frameRate:30,bitrate:3e3}],["1080p",{width:1920,height:1080,frameRate:5,bitrate:1600}],["1080p_2",{width:1920,height:1080,frameRate:30,bitrate:4e3}]]),WI=new Map([["standard",{sampleRate:48e3,channelCount:1,bitrate:40}],["standard-stereo",{sampleRate:48e3,channelCount:2,bitrate:64}],["high",{sampleRate:48e3,channelCount:1,bitrate:128}],["high-stereo",{sampleRate:48e3,channelCount:2,bitrate:192}]]),_a=new Map,DF=(DI=St(vi),OI=St(vi),LI=St(vi),MI=St(vi),NI=dn.apply(void 0,Se(Yt.LOCAL_STREAM.switchDevice)),UI=dn(Yt.STREAM.addTrack),VI=dn(Yt.STREAM.removeTrack),jI=dn(Yt.STREAM.replaceTrack),BI=Lo({retries:10,timeout:3e3,onRetryFailed:function(e){ke.logFailedEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:Nb,error:e}),this.emitter_.emit(Cm,new te({code:Z.DEVICE_AUTO_RECOVER_FAILED,message:e.message}))}}),FI=Al(Yt.LOCAL_STREAM.setAudioCaptureVolume),HI=St(vi),nt=function(e){Et(x,e);var t,n,i,r,o,c,a,s,l,u,h,S,I,E=Rr(x);function x(m){var T;Q(this,x);var v=q(q({},m),{isRemote:!1,type:"local"});return(T=E.call(this,v)).name_=vi,T.client_=null,T.video_=m.video,T.audio_=m.audio,T.cameraId_=m.cameraId,T.cameraGroupId_="",T.facingMode_=m.facingMode,T.microphoneId_=m.microphoneId,T.microphoneGroupId_="",T.microphoneLabel_="",T.videoSource_=m.videoSource,T.audioSource_=m.audioSource,T.screen_=m.screen,T.screenAudio_=m.screenAudio,T.audioProfile_={echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40},T.screenAudio_&&(T.audioProfile_.echoCancellation=!0,T.audioProfile_.autoGainControl=!1,T.audioProfile_.noiseSuppression=!1),nr(m.echoCancellation)&&(T.audioProfile_.echoCancellation=m.echoCancellation),nr(m.autoGainControl)&&(T.audioProfile_.autoGainControl=m.autoGainControl),nr(m.noiseSuppression)&&(T.audioProfile_.noiseSuppression=m.noiseSuppression),T.videoProfile_=Jv.get("480p_2"),T.screenProfile_=qv.get("1080p"),T.videoSetting_=null,T.muteState_={video:!1,audio:!1,auxVideo:!1},T.beautyStatus_=!1,T.prevAudioRecoverTime_=0,T.prevVideoRecoverTime_=0,T.isAudioRecovering_=!1,T.isVideoRecovering_=!1,T.initState(),T.canvas_=null,T.canvasInterval_=null,T.canvasTrack_=null,T.gain_={audioTrack:null,source:null,gainNode:null},T.captureVolume_=100,T.enableAutoRecoverCapture_=!!ge(m.enableAutoRecoverCapture)||m.enableAutoRecoverCapture,T.enableAutoRecoverOther_=!nr(m.enableAutoRecoverOther)||m.enableAutoRecoverOther,T.log_.info("stream created: ".concat(T.id_," autoRecover: ").concat(T.enableAutoRecoverCapture_)),T.isAIDenoiser=!1,T}return xe(x,[{key:"scaleResolutionDownBy",get:function(){var m=this.getVideoTrack();if(!m||!la||this.isScreenShare())return 1;var T,v,w,L=m.getSettings();return L.width===this.videoProfile_.width&&L.height===this.videoProfile_.height?1:(T=window.screen)!==null&&T!==void 0&&(v=T.orientation)!==null&&v!==void 0&&(w=v.type)!==null&&w!==void 0&&w.includes("portrait")&&this.videoProfile_.width>this.videoProfile_.height&&L.height>L.width?Math.max(L.width/this.videoProfile_.height,L.height/this.videoProfile_.width,1):Math.max(L.width/this.videoProfile_.width,L.height/this.videoProfile_.height,1)}},{key:"initState",value:function(){this.isAddingTrack_=!1,this.isRemovingTrack_=!1,this.setIsReadyToPublish(!1),this.setPublishState(zb)}},{key:"installEvents",value:function(){le(Ye(x.prototype),"installEvents",this).call(this),Y.on(Xp,this.onVideoTrackStopped,this),Y.on(nc,this.onVideoTrackStopped,this),Y.on(Yp,this.onAudioTrackStopped,this),Y.on(Qp,this.onAudioTrackStopped,this)}},{key:"uninstallEvents",value:function(){le(Ye(x.prototype),"uninstallEvents",this).call(this),Y.off(Xp,this.onVideoTrackStopped,this),Y.off(nc,this.onVideoTrackStopped,this),Y.off(Yp,this.onAudioTrackStopped,this),Y.off(Qp,this.onAudioTrackStopped,this)}},{key:"initialize",value:function(){var m=this;return new Promise(function(T,v){if(yl())v(new te({code:Z.INVALID_OPERATION,message:ae({key:mS})}));else{if(ge(m.audio_)){var w=new MediaStream;return ge(m.audioSource_)||(w.addTrack(m.audioSource_),m.updateAudioPlayingState(!0)),ge(m.videoSource_)||(w.addTrack(m.videoSource_),m.updateVideoPlayingState(!0)),m.setMediaStream(w),ke.logSuccessEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Qs,kind:"custom"}),m.setIsReadyToPublish(!0),T()}m.screen_?(m.log_.info("initialize stream audio: "+m.audio_+" screenAudio: "+m.screenAudio_+" screen: "+m.screen_),PF({audio:m.audio_,screenAudio:m.screenAudio_,microphoneId:m.microphoneId_,width:m.screenProfile_.width,height:m.screenProfile_.height,frameRate:m.screenProfile_.frameRate,sampleRate:m.audioProfile_.sampleRate,channelCount:m.audioProfile_.channelCount,autoGainControl:m.audioProfile_.autoGainControl,noiseSuppression:m.audioProfile_.noiseSuppression,echoCancellation:m.audioProfile_.echoCancellation}).then(function(L){m.setMediaStream(L),m.updateAudioPlayingState(m.audio_||m.screenAudio_),m.updateVideoPlayingState(!0);var N=m.getVideoTrack();return N.applyConstraints&&N.applyConstraints({frameRate:{min:m.screenProfile_.frameRate,ideal:m.screenProfile_.frameRate},width:m.screenProfile_.width,height:m.screenProfile_.height}).catch(function(V){m.warn("screen applyConstraints failed: ".concat(V))}),m.listenForScreenSharingStopped(N),m.setVideoContentHint(mb),m.updateDeviceIdInUse(),m.setIsReadyToPublish(!0),m.log_.info(JSON.stringify(N.getSettings())),ke.logSuccessEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Qs,kind:"getDisplayMedia"}),T()}).catch(function(L){ke.logFailedEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Qs,kind:"getDisplayMedia",error:L}),m.log_.error("getDisplayMedia error observed "+L),v(L instanceof te?L:new te({code:Z.INITIALIZE_FAILED,name:L.name,message:L.message}))})):(Y.emit(Hp,{stream:m,audio:m.audio_,video:m.video_}),m.log_.info("initialize stream audio: "+m.audio_+" video: "+m.video_),Wv({audio:m.audio_,video:m.video_,facingMode:m.facingMode_,cameraId:m.cameraId_,microphoneId:m.microphoneId_,width:m.videoProfile_.width,height:m.videoProfile_.height,frameRate:m.videoProfile_.frameRate,sampleRate:m.audioProfile_.sampleRate,channelCount:m.audioProfile_.channelCount,autoGainControl:m.audioProfile_.autoGainControl,noiseSuppression:m.audioProfile_.noiseSuppression,echoCancellation:m.audioProfile_.echoCancellation,useExact:!0,retryWhenExactFailed:!0}).then(function(L){return Y.emit(Gp,{stream:m,audio:m.audio_,video:m.video_}),m.setMediaStream(L),L.getTracks().forEach(function(N){if(la){var V=N.getSettings();m.log_.debug("".concat(N.kind," settings: ").concat(JSON.stringify(V))),N.kind===Ie&&(m.videoSetting_=V)}n6&&m.log_.info("".concat(N.kind," capabilities: ").concat(fo(N.getCapabilities(),tp)))}),m.updateAudioPlayingState(m.audio_),m.updateVideoPlayingState(m.video_),m.updateDeviceIdInUse(),m.log_.info("gotStream hasAudio: "+m.hasAudio()+" hasVideo: "+m.hasVideo()),m.setIsReadyToPublish(!0),ke.logSuccessEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Qs,kind:"getUserMedia"}),T()}).catch(function(L){Y.emit(Wp,{stream:m,audio:m.audio_,video:m.video_,error:L}),ke.logFailedEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Qs,kind:"getUserMedia",error:L}),m.log_.error("getUserMedia error observed "+L),v(L)}))}})}},{key:"listenForScreenSharingStopped",value:function(m){var T=this;m.addEventListener("ended",function(v){T.log_.info("screen sharing was stopped because the video track is ended"),T.emitter_.emit(i6)})}},{key:"muteAudio",value:function(){var m=le(Ye(x.prototype),"muteAudio",this).call(this);return m&&(this.log_.info("localStream mute audio"),this.sendMutedFlag(Ee,!0)),m}},{key:"muteVideo",value:function(){var m=le(Ye(x.prototype),"muteVideo",this).call(this);return m&&(this.log_.info("localStream mute video"),this.sendMutedFlag(Ie,!0)),m}},{key:"unmuteAudio",value:function(){var m=le(Ye(x.prototype),"unmuteAudio",this).call(this);return m&&(this.log_.info("localStream unmute audio"),this.sendMutedFlag(Ee,!1)),m}},{key:"unmuteVideo",value:function(){var m=le(Ye(x.prototype),"unmuteVideo",this).call(this);return m&&(this.log_.info("localStream unmute video"),this.sendMutedFlag(Ie,!1)),m}},{key:"sendMutedFlag",value:function(m,T){this.setMuteState(m,T);var v=this.getConnection();if(v){v.sendMutedFlag(this.muteState_,this);var w=v.getUserId(),L=v.getTinyId(),N="".concat(T?tn:Sr," local ").concat(m," track");vn(w,{eventId:m===Ee?T?zU:qU:T?JU:KU,eventDesc:N,timestamp:an(),userId:w,tinyId:L})}}},{key:"setMuteState",value:function(m,T){this.muteState_[m]=T,this.log_.info("set ".concat(m," muted state: [").concat(T?"mute":"unmute","]"))}},{key:"setAudioProfile",value:(I=H(p().mark(function m(T){var v,w,L;return p().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(G(T)==="object"?v=T:(v=WI.get(T))===void 0&&(v=WI.get("standard")),this.log_.info("setAudioProfile: "+JSON.stringify(v)),!(w=this.getAudioTrack())){N.next=6;break}return N.next=6,w.applyConstraints(v);case 6:if(L=this.audioProfile_.bitrate!==v.bitrate,this.audioProfile_=q(q({},this.audioProfile_),v),!L||!this.connection_){N.next=12;break}return N.next=11,this.connection_.setBandwidth({bandwidth:this.audioProfile_.bitrate,type:Ee});case 11:this.connection_.sendMediaSettings(this);case 12:case"end":return N.stop()}},m,this)})),function(m){return I.apply(this,arguments)})},{key:"setVideoProfile",value:(S=H(p().mark(function m(T){var v,w,L,N;return p().wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(!this.connection_||Hk()){V.next=2;break}throw new te({code:Z.NOT_SUPPORTED,message:ae({key:F3})});case 2:if(bi(T)?w=q(q({},this.videoProfile_),T):Bt(T)&&(w=Jv.get(T),ge(w)&&(w=Jv.get("480p_2"))),(v=this.client_)!==null&&v!==void 0&&v.get2k4kFlag()&&(this.client_.get2k4kFlag()!==1&&!this.screen_&&w.height*w.width>=3686400?(w.width=1920,w.height=1080,this.log_.warn(rS)):Ai.handleFunctionState({fnName:"2K_4K"})),w&&w.width*w.height>921600&&E4&&(w.width=1280,w.height=720,this.log_.warn("reset to 1280 * 720 on iOS 13~14")),this.log_.info("setVideoProfile "+JSON.stringify(w)),!(L=this.getVideoTrack())){V.next=10;break}return V.next=10,L.applyConstraints(w);case 10:if(N=this.videoProfile_.bitrate!==w.bitrate,this.videoProfile_=w,!N||!this.connection_){V.next=16;break}return V.next=15,this.connection_.setBandwidth({bandwidth:w.bitrate,type:Ie,videoType:Fu});case 15:this.connection_.sendMediaSettings(this);case 16:case"end":return V.stop()}},m,this)})),function(m){return S.apply(this,arguments)})},{key:"getVideoBitrate",value:function(){return this.screen_?this.screenProfile_.bitrate:this.videoProfile_.bitrate}},{key:"getAudioBitrate",value:function(){return this.audioProfile_.bitrate}},{key:"setScreenProfile",value:function(m){var T=m;Bt(m)&&(T=qv.get(m)||qv.get("1080p")),this.log_.info("setScreenProfile "+JSON.stringify(m)),this.screenProfile_=T}},{key:"getVideoProfile",value:function(){return this.screen_?this.screenProfile_:this.videoProfile_}},{key:"getAudioProfile",value:function(){return this.audioProfile_}},{key:"setVideoContentHint",value:function(m){var T=this.getVideoTrack();T&&"contentHint"in T&&(this.log_.info("set video track contentHint to: "+m),T.contentHint=m,T.contentHint!==m&&this.log_.warn("Invalid video track contentHint: "+m))}},{key:"switchDevice",value:(h=H(p().mark(function m(T,v){var w,L,N,V,_,b,R,P,U,k,f,y,A,D,j,K,J,se;return p().wrap(function(ie){for(;;)switch(ie.prev=ie.next){case 0:if(this.mediaStream_&&this.cameraId_!==v&&this.facingMode_!==v){ie.next=2;break}return ie.abrupt("return");case 2:if(L=T===Ie,!(w=T===Ee)||v!==this.microphoneId_){ie.next=11;break}if(v===Xu){ie.next=7;break}return ie.abrupt("return");case 7:return ie.next=9,h6(this.microphoneGroupId_,this.microphoneLabel_);case 9:if(!ie.sent){ie.next=11;break}return ie.abrupt("return");case 11:return this.setIsReadyToPublish(!1),this.log_.info("switchDevice "+T+" to: "+v),w&&(N=this.getAudioTrack(),V=this.getMicrophoneTrackMixed(),N&&N.stop(),V&&V.stop()),L&&((_=this.getVideoTrack())&&_.stop(),bp&&(b=this.getAudioTrack())&&(this.log_.info("stop audio track first in huawei env"),b.stop())),ie.prev=15,ie.next=18,Wv({audio:w||bp,video:L,facingMode:v===fb||v===pb?v:void 0,cameraId:L?v:this.cameraId_,microphoneId:w?v:this.microphoneId_,width:this.videoProfile_.width,height:this.videoProfile_.height,frameRate:this.videoProfile_.frameRate,sampleRate:this.audioProfile_.sampleRate,channelCount:this.audioProfile_.channelCount,autoGainControl:this.audioProfile_.autoGainControl,noiseSuppression:this.audioProfile_.noiseSuppression,echoCancellation:this.audioProfile_.echoCancellation,useExact:!0,retryWhenExactFailed:!1});case 18:if(R=ie.sent,P=null,!w){ie.next=34;break}if(!(U=R.getAudioTracks()[0])||!this.isAudioTrackMixed()){ie.next=31;break}return k=this.getAudioTrack(),f=It.AudioMixerPlugin.getAudioTrackMap(),ie.next=27,It.AudioMixerPlugin.mix({targetTrack:U,sourceList:f.get(k.id).sourceList,trackList:f.get(k.id).trackList});case 27:y=ie.sent,P=y,ie.next=32;break;case 31:P=U;case 32:ie.next=43;break;case 34:if(!(P=R.getVideoTracks()[0])||!this.isVideoTrackBeautified()){ie.next=39;break}return ie.next=38,this.generateBeautyTrack(P);case 38:P=ie.sent;case 39:if(!(A=R.getAudioTracks()[0])||!bp){ie.next=43;break}return ie.next=43,this.replaceTrack(A);case 43:return ie.next=45,this.replaceTrack(P);case 45:(D=this.getConnection())&&(j=D.getUserId(),K=D.getTinyId(),J=QU,se="switch camera",w&&(J=YU,se="switch microphone"),vn(j,{eventId:J,eventDesc:se,timestamp:an(),userId:j,tinyId:K})),this.log_.info("switch ".concat(w?"microphone":"camera"," success ")),w&&(this.audio_=!0),L&&(this.video_=!0,this.facingMode_=v===pb||v===fb?v:""),this.updateDeviceIdInUse(),this.setIsReadyToPublish(!0),ie.next=59;break;case 54:throw ie.prev=54,ie.t0=ie.catch(15),this.log_.error(ie.t0),w?this.recoverCapture({audio:!0,video:!1,microphoneId:this.microphoneId_}):this.recoverCapture({audio:!1,video:!0,cameraId:this.cameraId_,facingMode:this.facingMode_}),ie.t0;case 59:case"end":return ie.stop()}},m,this,[[15,54]])})),function(m,T){return h.apply(this,arguments)})},{key:"addTrack",value:(u=H(p().mark(function m(T){var v,w,L;return p().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(N.prev=0,T.kind===Ie&&la&&(v=T.getSettings(),!this.videoSetting_||v.width===this.videoSetting_.width&&v.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(v.width," x ").concat(v.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.isAddingTrack_=!0,this.keepMuteState(T),this.mediaStream_.addTrack(T),!(w=this.getConnection())){N.next=11;break}return L=null,T.kind===Ie&&(ol||al)&&VS(T)&&(L=this.getCanvasTrack()),N.next=11,w.addTrack(L||T,this);case 11:T.kind===Ee?(this.audio_=!0,this.updateAudioPlayingState(!0),this.captureVolume_!==100&&this.setAudioCaptureVolume(this.captureVolume_)):(this.video_=!0,this.updateVideoPlayingState(!0)),this.isAddingTrack_=!1,N.next=20;break;case 15:throw N.prev=15,N.t0=N.catch(0),this.mediaStream_.removeTrack(T),this.isAddingTrack_=!1,N.t0;case 20:case"end":return N.stop()}},m,this,[[0,15]])})),function(m){return u.apply(this,arguments)})},{key:"removeTrack",value:(l=H(p().mark(function m(T){var v;return p().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(w.prev=0,this.isRemovingTrack_=!0,!(v=this.getConnection())){w.next=17;break}if(T.kind!==Ie||!ol&&!al||!this.canvasTrack_){w.next=10;break}return w.next=7,v.removeTrack(this.canvasTrack_,this);case 7:this.clearCanvas(),w.next=17;break;case 10:if(T.kind!==Ee||!this.gain_.audioTrack){w.next=15;break}return w.next=13,v.removeTrack(this.gain_.audioTrack,this);case 13:w.next=17;break;case 15:return w.next=17,v.removeTrack(T,this);case 17:this.mediaStream_.removeTrack(T),T.kind===Ee?(this.audio_=!1,this.updateAudioPlayingState(!1),this.stopGainNode()):(this.video_=!1,this.updateVideoPlayingState(!1)),this.isRemovingTrack_=!1,w.next=26;break;case 22:throw w.prev=22,w.t0=w.catch(0),this.isRemovingTrack_=!1,w.t0;case 26:case"end":return w.stop()}},m,this,[[0,22]])})),function(m){return l.apply(this,arguments)})},{key:"replaceTrack",value:(s=H(p().mark(function m(T){var v,w,L;return p().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(T.kind===Ie&&la&&(v=T.getSettings(),!this.videoSetting_||v.width===this.videoSetting_.width&&v.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(v.width," x ").concat(v.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),w=this.mediaStream_,T.kind!==Ee){N.next=12;break}if(w.removeTrack(w.getAudioTracks()[0]),w.addTrack(T),le(Ye(x.prototype),"restartAudio",this).call(this),!this.gain_.gainNode){N.next=10;break}return this.reconnectGainNode(T),N.abrupt("return");case 10:N.next=15;break;case 12:w.removeTrack(w.getVideoTracks()[0]),w.addTrack(T),le(Ye(x.prototype),"restartVideo",this).call(this);case 15:if(!(L=this.getConnection())){N.next=21;break}if(T.kind!==Ie||!ol&&!al||!this.canvasTrack_){N.next=19;break}return N.abrupt("return");case 19:return N.next=21,L.replaceTrack(T,this);case 21:case"end":return N.stop()}},m,this)})),function(m){return s.apply(this,arguments)})},{key:"recoverCapture",value:(a=H(p().mark(function m(T){var v,w,L,N,V,_,b,R,P,U,k,f,y,A,D,j,K;return p().wrap(function(J){for(;;)switch(J.prev=J.next){case 0:if(!(!this.mediaStream_||!this.enableAutoRecoverCapture_||T.audio&&!T.video&&this.isAudioRecovering_||T.video&&!T.audio&&this.isVideoRecovering_)){J.next=2;break}return J.abrupt("return");case 2:return T.audio&&(this.isAudioRecovering_=!0),T.video&&(this.isVideoRecovering_=!0),this.log_.warn("recoverCapture() trying "+JSON.stringify(T)),v=this.audio_&&T.audio,w=this.video_&&T.video,J.prev=7,J.next=10,It.getCameras();case 10:return L=J.sent,J.next=13,It.getMicrophones();case 13:if(N=J.sent,w&&L.length===0&&(w=!1,this.log_.warn("recoverCapture() video flag is true, but no camera detected, set video to false")),v&&N.length===0&&(v=!1,this.log_.warn("recoverCapture() audio flag is true, but no microphone detected, set audio to false")),v||w){J.next=21;break}return T.audio&&(this.isAudioRecovering_=!1),T.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() both audio and video are false, aborted"),J.abrupt("return");case 21:return V=T&&L.findIndex(function(se){return se.deviceId===T.cameraId})>=0,_=T&&N.findIndex(function(se){return se.deviceId===T.microphoneId})>=0,v&&((b=this.getAudioTrack())===null||b===void 0||b.stop()),w&&((R=this.getVideoTrack())===null||R===void 0||R.stop()),J.next=27,Wv({audio:v,video:w,cameraId:V?T.cameraId:void 0,microphoneId:_?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,autoGainControl:this.audioProfile_.autoGainControl,noiseSuppression:this.audioProfile_.noiseSuppression,echoCancellation:this.audioProfile_.echoCancellation});case 27:P=J.sent,U=P.getTracks(),k=0;case 30:if(!(k<U.length)){J.next=59;break}if((f=U[k]).kind!==Ee||!this.isAudioTrackMixed()){J.next=45;break}if(y=this.getAudioTrack(),A=It.AudioMixerPlugin.getAudioTrackMap(),(D=A.get(y.id)).hasMicrophone){J.next=39;break}return f.stop(),J.abrupt("continue",56);case 39:return J.next=41,It.AudioMixerPlugin.mix({targetTrack:f,sourceList:D.sourceList,trackList:D.trackList});case 41:return j=J.sent,J.next=44,this.replaceTrack(j);case 44:return J.abrupt("continue",56);case 45:if(f.kind!==Ie||!this.isVideoTrackBeautified()){J.next=52;break}return J.next=48,this.generateBeautyTrack(f);case 48:return K=J.sent,J.next=51,this.replaceTrack(K);case 51:return J.abrupt("continue",56);case 52:return J.next=54,this.replaceTrack(f);case 54:if(f.readyState!=="ended"){J.next=56;break}throw new Error("new track is failed, muted ".concat(f.muted," readyState ").concat(f.readyState));case 56:k++,J.next=30;break;case 59:this.updateDeviceIdInUse(),ke.logSuccessEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:Nb}),T.audio&&(this.isAudioRecovering_=!1),T.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() successfully"),this.emitter_.emit(o6,{isCamera:T.video,isMicrophone:T.audio,cameraId:this.cameraId_,microphoneId:this.microphoneId_}),J.next=73;break;case 67:throw J.prev=67,J.t0=J.catch(7),T.audio&&(this.isAudioRecovering_=!1),T.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() failed, "+J.t0),J.t0;case 73:case"end":return J.stop()}},m,this,[[7,67]])})),function(m){return a.apply(this,arguments)})},{key:"updateDeviceIdInUse",value:function(){var m=this;if(!this.mediaStream_)return this.cameraId_="",this.cameraGroupId_="",this.microphoneId_="",void(this.microphoneGroupId_="");la&&this.mediaStream_.getTracks().forEach(function(w){if(w.kind===Ee&&m.isAudioTrackMixed()){var L=m.getMicrophoneTrackMixed();if(L){var N=L.getSettings(),V=N.deviceId,_=N.groupId;V&&(m.microphoneId_=V,m.microphoneGroupId_=_,m.microphoneLabel_=L.label)}}else if(w.kind===Ie&&m.isVideoTrackBeautified()){var b=m.getBeautyOriginTrack();if(b){var R=b.getSettings(),P=R.deviceId,U=R.groupId,k=R.facingMode;P&&(m.cameraId_=P,m.cameraGroupId_=U),k&&(m.facingMode_=k)}}else{var f=w.getSettings(),y=f.deviceId,A=f.groupId,D=f.facingMode;y&&(w.kind===Ee?(m.microphoneId_=y,m.microphoneGroupId_=A,m.microphoneLabel_=w.label):w.kind!==Ie||m.screen_||(m.cameraId_=y,m.cameraGroupId_=A,D&&(m.facingMode_=D)))}});var T=this.mediaStream_.getAudioTracks(),v=this.mediaStream_.getVideoTracks();T&&T.length===0&&(this.microphoneId_="",this.microphoneGroupId_=""),v&&v.length===0&&(this.cameraId_="",this.cameraGroupId_="")}},{key:"isAudioTrackMixed",value:function(){if(It.AudioMixerPlugin){var m=It.AudioMixerPlugin.getAudioTrackMap(),T=this.getAudioTrack();if(m&&T&&m.has(T.id))return!0}return!1}},{key:"getMicrophoneTrackMixed",value:function(){if(It.AudioMixerPlugin){var m=It.AudioMixerPlugin.getAudioTrackMap(),T=this.getAudioTrack();if(m&&T&&m.has(T.id)){var v=m.get(T.id);return v.hasMicrophone?v.microphoneTrack:null}}return null}},{key:"isVideoTrackBeautified",value:function(){if(It.beautyTrackMap){var m=It.beautyTrackMap,T=this.getVideoTrack();if(T&&m.has(T.id))return!0}return!1}},{key:"getBeautyOriginTrack",value:function(){if(It.beautyTrackMap){var m=It.beautyTrackMap,T=this.getVideoTrack();if(T&&m.has(T.id)){var v=m.get(T.id);if(v.originTrack)return v.originTrack}}return null}},{key:"generateBeautyTrack",value:(c=H(p().mark(function m(T){var v,w,L,N;return p().wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(v=null,w=this.getVideoTrack(),L=It.beautyTrackMap.get(w.id),N=L.param,L.type){V.next=8;break}v=L.pluginInstance.generateBeautyTrack(T),V.next=22;break;case 8:V.t0=L.type,V.next=V.t0==="beauty"?11:V.t0==="virtual"?13:V.t0==="mixed"?17:21;break;case 11:return v=L.pluginInstance.generateBeautyTrack(T),V.abrupt("break",22);case 13:return V.next=15,L.pluginInstance.generateVirtualTrack({videoTrack:T,type:N.type,img:N.img});case 15:case 19:return v=V.sent,V.abrupt("break",22);case 17:return V.next=19,L.pluginInstance.generateMixedTrack({videoTrack:T,type:N.type,img:N.img});case 21:return V.abrupt("break",22);case 22:return L.pluginInstance.deleteSource(w.id),this.log_.info("regenerate beauty track, track id = ".concat(T.id)),V.abrupt("return",v);case 25:case"end":return V.stop()}},m,this)})),function(m){return c.apply(this,arguments)})},{key:"getScreen",value:function(){return this.screen_}},{key:"hasScreenTrack",value:function(){if(this.screen_)return!0;var m=this.getVideoTrack();return!!m&&(m.contentHint===mb||m.contentHint===NM)}},{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(m){this.isReadyToPublish_=m}},{key:"setPublishState",value:function(m){this.publishState_=m}},{key:"setBeautyStatus",value:function(m){this.beautyStatus_=!!m}},{key:"getBeautyStatus",value:function(){return this.beautyStatus_}},{key:"syncMuteState",value:function(){var m=this.getAudioTrack(),T=this.getVideoTrack();if(m){var v=!m.enabled;this.setMuteState(Ee,v)}if(T){var w=!T.enabled;this.setMuteState(Ie,w)}this.connection_&&this.connection_.sendMutedFlag(this.muteState_,this)}},{key:"keepMuteState",value:function(m){m instanceof window.MediaStreamTrack&&this.muteState_[m.kind]&&(m.enabled=!1,this.log_.warn("prev ".concat(m.kind," track is muted, keep mute state")))}},{key:"onVideoTrackStopped",value:(o=H(p().mark(function m(T){var v,w,L=this;return p().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(v=T.stream,w=T.type,v===this&&this.video_&&this.cameraId_&&d6(this.getVideoTrack())&&!this.isVideoRecovering_&&(w!==tn||!ec||!na)){N.next=3;break}return N.abrupt("return");case 3:if(!(Date.now()-this.prevVideoRecoverTime_<Qu)){N.next=6;break}return setTimeout(function(){return L.onVideoTrackStopped({stream:v,type:w})},Qu),N.abrupt("return");case 6:w===tn?setTimeout(function(){var V=L.getVideoTrack();V!=null&&V.muted&&document.visibilityState==="visible"&&L.recoverVideoCapture(w)},5e3):this.recoverVideoCapture(w);case 7:case"end":return N.stop()}},m,this)})),function(m){return o.apply(this,arguments)})},{key:"onAudioTrackStopped",value:(r=H(p().mark(function m(T){var v,w,L=this;return p().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(v=T.stream,w=T.type,!(v!==this||!this.audio_||!this.microphoneId_||this.isAudioRecovering_||w===tn&&ec&&na)){N.next=3;break}return N.abrupt("return");case 3:if(!(Date.now()-this.prevAudioRecoverTime_<Qu)){N.next=6;break}return setTimeout(function(){return L.onAudioTrackStopped({stream:v,type:w})},Qu),N.abrupt("return");case 6:w===tn?setTimeout(function(){var V=L.getAudioTrack();V!=null&&V.muted&&document.visibilityState==="visible"&&L.recoverAudioCapture(w)},5e3):this.recoverAudioCapture(w);case 7:case"end":return N.stop()}},m,this)})),function(m){return r.apply(this,arguments)})},{key:"recoverAudioCapture",value:(i=H(p().mark(function m(T){return p().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return this.prevAudioRecoverTime_=Date.now(),ke.uploadEvent({log:"stat-local-audio-".concat(T),userId:this.userId_}),v.t0=this,v.next=5,this.getRecoverCaptureDeviceId(!1);case 5:v.t1=v.sent,v.t2={audio:!0,video:!1,microphoneId:v.t1},v.t0.recoverCapture.call(v.t0,v.t2);case 8:case"end":return v.stop()}},m,this)})),function(m){return i.apply(this,arguments)})},{key:"recoverVideoCapture",value:(n=H(p().mark(function m(T){return p().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return this.prevVideoRecoverTime_=Date.now(),ke.uploadEvent({log:"stat-local-video-".concat(T),userId:this.userId_}),v.t0=this,v.next=5,this.getRecoverCaptureDeviceId(!0);case 5:v.t1=v.sent,v.t2={audio:!1,video:!0,cameraId:v.t1},v.t0.recoverCapture.call(v.t0,v.t2);case 8:case"end":return v.stop()}},m,this)})),function(m){return n.apply(this,arguments)})},{key:"getRecoverCaptureDeviceId",value:(t=H(p().mark(function m(){var T,v,w,L,N=arguments;return p().wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(T=!(N.length>0&&N[0]!==void 0)||N[0],!(v=T?this.cameraId_:this.microphoneId_)||!this.enableAutoRecoverOther_){V.next=17;break}if(_a.has(v)?_a.set(v,_a.get(v)+1):_a.set(v,1),!((w=_a.get(v))>=3)){V.next=17;break}if(!T){V.next=12;break}return V.next=9,It.getCameras();case 9:V.t0=V.sent.find(function(_){return!_a.has(_.deviceId)}),V.next=15;break;case 12:return V.next=14,It.getMicrophones();case 14:V.t0=V.sent.find(function(_){return!_a.has(_.deviceId)});case 15:(L=V.t0)&&(this.log_.warn("".concat(T?"camera":"mic"," ").concat(v," capture fail ").concat(w," times, change new ").concat(L.deviceId)),v=L.deviceId);case 17:return V.abrupt("return",v);case 18:case"end":return V.stop()}},m,this)})),function(){return t.apply(this,arguments)})},{key:"setAudioVolume",value:function(m){le(Ye(x.prototype),"setAudioVolume",this).call(this,m)}},{key:"clearCanvas",value:function(){this.canvasInterval_&&(mt.clearTask(this.canvasInterval_),this.canvasInterval_=null,this.canvas_=null,this.canvasTrack_=null)}},{key:"getCanvasTrack",value:function(){var m=this;if(this.canvasTrack_)return this.canvasTrack_;this.log_.info("gen canvas track");var T=this.getVideoTrack().getSettings(),v=T.width,w=T.height,L=T.frameRate;this.canvas_=document.createElement("canvas");var N=this.canvas_.getContext("2d");this.canvas_.width=v,this.canvas_.height=w,this.canvasInterval_=mt.run(Yu,function(){if(m.hasVideo()){var _=m.getVideoTrack().getSettings();_.width===m.canvas_.width&&_.height===m.canvas_.height||(m.canvas_.width=_.width,m.canvas_.height=_.height)}m.videoPlayer_&&m.videoPlayer_.element_&&N.drawImage(m.videoPlayer_.element_,0,0,m.canvas_.width,m.canvas_.height)},{fps:Math.max(15,L)});var V=this.canvas_.captureStream();return this.canvasTrack_=V.getVideoTracks()[0],this.canvasTrack_}},{key:"setClient",value:function(m,T){m&&(this.log_.setUserId(m.getUserId()),this.log_.setSdkAppId(m.getSDKAppId()),T||this.syncMuteState()),this.client_=m}},{key:"setAudioCaptureVolume",value:function(){var m=this,T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:100;if(!this.hasAudio()||T<0||!Im())return!1;if(this.captureVolume_===T)return!0;this.captureVolume_=T,this.log_.info("setCaptureVolume "+T),T/=100;var v=HS();if(this.gain_.gainNode)this.gain_.gainNode.gain.value=T;else{var w,L=new MediaStream;L.addTrack(this.getAudioTrack());var N=v.createMediaStreamDestination(),V=v.createMediaStreamSource(L),_=v.createGain();_.gain.value=T,V.connect(_),_.connect(N);var b=N.stream.getAudioTracks()[0],R=function(P){return m.log_.info("gained audio track ".concat(P))};b.onmute=function(){return R("muted")},b.onunmute=function(){return R("unmuted")},b.onended=function(){return R("ended")},this.gain_={source:V,audioTrack:b,gainNode:_},(w=this.connection_)===null||w===void 0||w.replaceTrack(b),le(Ye(x.prototype),"restartAudio",this).call(this)}return!0}},{key:"getGainedTrack",value:function(){return this.gain_.audioTrack}},{key:"reconnectGainNode",value:function(m){this.log_.warn("reconnect gain node");var T=new MediaStream;T.addTrack(m);var v=HS().createMediaStreamSource(T);v.connect(this.gain_.gainNode),this.gain_.source.disconnect(),this.gain_.source=v}},{key:"stopGainNode",value:function(){var m=this.gain_,T=m.audioTrack,v=m.source,w=m.gainNode;w&&(v.disconnect(),w.disconnect(),T.onmute=null,T.onunmute=null,T.onended=null,T.stop(),this.gain_={source:null,gainNode:null,audioTrack:null}),this.captureVolume_=100}},{key:"close",value:function(){this.setIsReadyToPublish(!1),this.stopGainNode(),le(Ye(x.prototype),"close",this).call(this)}},{key:"setIsAIDenoiser",value:function(m){this.isAIDenoiser=m}}]),x}(AI),X(nt.prototype,"setAudioProfile",[DI],Object.getOwnPropertyDescriptor(nt.prototype,"setAudioProfile"),nt.prototype),X(nt.prototype,"setVideoProfile",[OI],Object.getOwnPropertyDescriptor(nt.prototype,"setVideoProfile"),nt.prototype),X(nt.prototype,"setScreenProfile",[LI],Object.getOwnPropertyDescriptor(nt.prototype,"setScreenProfile"),nt.prototype),X(nt.prototype,"setVideoContentHint",[MI],Object.getOwnPropertyDescriptor(nt.prototype,"setVideoContentHint"),nt.prototype),X(nt.prototype,"switchDevice",[NI],Object.getOwnPropertyDescriptor(nt.prototype,"switchDevice"),nt.prototype),X(nt.prototype,"addTrack",[UI],Object.getOwnPropertyDescriptor(nt.prototype,"addTrack"),nt.prototype),X(nt.prototype,"removeTrack",[VI],Object.getOwnPropertyDescriptor(nt.prototype,"removeTrack"),nt.prototype),X(nt.prototype,"replaceTrack",[jI],Object.getOwnPropertyDescriptor(nt.prototype,"replaceTrack"),nt.prototype),X(nt.prototype,"recoverCapture",[BI],Object.getOwnPropertyDescriptor(nt.prototype,"recoverCapture"),nt.prototype),X(nt.prototype,"setAudioCaptureVolume",[FI,HI],Object.getOwnPropertyDescriptor(nt.prototype,"setAudioCaptureVolume"),nt.prototype),nt),zI={voiceActivityDetection:!1},OF=(GI=Lo({retries:1,timeout:0,onRetrying:function(e){this.log_.warn("connection timeout, retrying [".concat(e,"]"))},onError:function(e,t,n){e.message.includes("timeout")?(this.reset(),this.initialize(),t()):n(e)}}),Ic=function(e){Et(V,e);var t,n,i,r,o,c,a,s,l,u,h,S,I,E,x,m,T,v,w,L,N=Rr(V);function V(_){var b;return Q(this,V),(b=N.call(this,_)).localStream_=null,b.exchangeSDPTimeout_=-1,b.localAuxStream_=null,b.publishingStream_=null,b.isPublishingAuxStream_=!1,b.smallGenerator_=null,b.isSDPExchanging_=!1,b.ssrc_={audio:0,video:0,small:0,auxiliary:0},b.mediaSettings_={videoCodec:"",videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0,auxVideoWidth:0,auxVideoHeight:0,auxVideoFps:0,auxVideoBps:0},b.mixedAudioTrack_=null,b}return xe(V,[{key:"isMainStreamPublished",get:function(){return!!this.localStream_}},{key:"isAuxStreamPublished",get:function(){return!!this.localAuxStream_}},{key:"publishState",get:function(){var _=this,b={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this.peerConnection_){var R,P,U,k,f=this.peerConnection_.getSenders();f&&(Ii()?(b.audio=!((R=f[0])===null||R===void 0||!R.track),b.bigVideo=!((P=f[1])===null||P===void 0||!P.track),b.smallVideo=!((U=f[2])===null||U===void 0||!U.track),b.auxVideo=!((k=f[3])===null||k===void 0||!k.track)):f.forEach(function(y){y.track&&(y.track.kind===Ee?b.audio=!0:(b.bigVideo=!0,_.smallGenerator_&&(b.smallVideo=!0)))}))}return b}},{key:"initialize",value:function(){le(Ye(V.prototype),"initialize",this).call(this),this.installEvents()}},{key:"reset",value:function(){this.isReconnecting_&&this.stopReconnection(),this.closePeerConnection(),this.uninstallEvents(),this.clearExchangeSDPTimeout(),this.localStream_&&this.localStream_.clearCanvas()}},{key:"close",value:function(){le(Ye(V.prototype),"close",this).call(this),this.reset(),this.emitConnectionStateChangedEvent(on),this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null)}},{key:"installEvents",value:function(){this.emitter_.on(et.ERROR,this.handleError,this),this.emitter_.on(et.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"uninstallEvents",value:function(){this.emitter_.off(et.ERROR,this.handleError,this),this.emitter_.off(et.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"publish",value:(L=H(p().mark(function _(b,R){var P,U,k,f;return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.publishingStream_=b,this.isPublishingAuxStream_=R,U=b.getVideoTrack(),k=null,!U||R||!this.client_.getIsEnableSmallStream()){y.next=9;break}return this.smallGenerator_=new Zl(b),y.next=8,this.smallGenerator_.initialize();case 8:k=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_);case 9:if(f=b.getVideoProfile(),!this.client_.get2k4kFlag()){y.next=18;break}if(this.client_.get2k4kFlag()===1||b.getScreen()||!(f.height*f.width>=3686400)){y.next=18;break}return f.width=1920,f.height=1080,this.log_.warn(rS),y.next=18,b.setVideoProfile(f);case 18:if(!(ta&&lo()===115&&f.width*f.height<=230400)){y.next=22;break}return this.log_.warn("fallback video to 480p"),y.next=22,b.setVideoProfile("480p_2");case 22:if(this.updateMediaSettings(b,R),!gl()){y.next=33;break}if(!_i||OS!==11){y.next=29;break}return y.next=27,this.publishByAddTrack(b,k);case 27:y.next=31;break;case 29:return y.next=31,this.publishByTransceiver(b,k,R);case 31:y.next=35;break;case 33:return y.next=35,this.publishByAddTrack(b,k);case 35:return this.publishingStream_=null,this.isPublishingAuxStream_=!1,R?this.localAuxStream_=b:this.localStream_=b,(P=this.sei_)===null||P===void 0||P.handleEncodedStreams(),y.abrupt("return",b);case 40:case"end":return y.stop()}},_,this)})),function(_,b){return L.apply(this,arguments)})},{key:"publishByTransceiver",value:(w=H(p().mark(function _(b,R,P){var U,k,f,y,A,D,j;return p().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(this.log_.info("publish by transceiver"),U=b.getMediaStream(),k=b.getAudioTrack(),f=b.getVideoTrack(),y=null,(ol||al)&&VS(f)&&(y=b.getCanvasTrack()),(A=this.peerConnection_.getTransceivers()).length!==0){K.next=16;break}return this.peerConnection_.addTransceiver(k||Ee,{direction:mi,streams:[U]}),this.peerConnection_.addTransceiver(P?Ie:y||f||Ie,{direction:mi,streams:[U]}),this.peerConnection_.addTransceiver(R||Ie,{direction:mi,streams:[U]}),this.peerConnection_.addTransceiver(P?y||f:Ie,{direction:mi,streams:[U]}),K.next=14,this.connect();case 14:K.next=46;break;case 16:if(D=[],!k){K.next=29;break}if(!A[0].sender.track){K.next=24;break}return this.mixAudioTrack(A[0].sender.track,k),K.next=22,A[0].sender.replaceTrack(this.mixedAudioTrack_);case 22:K.next=27;break;case 24:return K.next=26,A[0].sender.replaceTrack(k);case 26:D.push(0);case 27:return K.next=29,this.setBandwidth({bandwidth:b.getAudioBitrate(),type:Ee});case 29:if(!f){K.next=42;break}return j=P?3:1,K.next=33,A[j].sender.replaceTrack(y||f);case 33:return K.next=35,this.setBandwidth({bandwidth:b.getVideoBitrate(),type:Ie,videoType:P?gt:Fu,scaleResolutionDownBy:b.scaleResolutionDownBy});case 35:if(D.push(j),!R){K.next=42;break}return K.next=39,A[2].sender.replaceTrack(R);case 39:return K.next=41,this.setBandwidth({bandwidth:this.client_.smallStreamConfig.bitrate,type:Ie,videoType:Mr});case 41:D.push(2);case 42:return K.next=44,this.setTransceiverDirection(mi,D);case 44:return K.next=46,this.doPublishChange();case 46:case"end":return K.stop()}},_,this)})),function(_,b,R){return w.apply(this,arguments)})},{key:"publishByAddTrack",value:(v=H(p().mark(function _(b,R){var P,U,k,f;return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return this.log_.info("publish by addtrack"),P=b.getMediaStream(),U=b.getAudioTrack(),k=b.getVideoTrack(),U&&this.peerConnection_.addTrack(U,P),k&&(this.peerConnection_.addTrack(k,P),R&&((f=new MediaStream).addTrack(R),this.peerConnection_.addTrack(R,f))),y.next=8,this.connect();case 8:case"end":return y.stop()}},_,this)})),function(_,b){return v.apply(this,arguments)})},{key:"unpublish",value:(T=H(p().mark(function _(b){var R,P,U,k;return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(Ii()){f.next=2;break}return f.abrupt("return",this.doUnpublish());case 2:if(R=b.getAudioTrack(),P=b===this.localAuxStream_,U=[],!this.peerConnection_){f.next=33;break}if(k=this.peerConnection_.getSenders(),!R){f.next=18;break}if(!this.mixedAudioTrack_){f.next=15;break}return this.log_.info("has mixed audioTrack, use another audioTrack"),f.next=12,k[0].replaceTrack(P?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 12:this.destroyMixedAudioTrack(),f.next=18;break;case 15:return f.next=17,k[0].replaceTrack(null);case 17:U.push(0);case 18:if(!P){f.next=26;break}return f.next=21,k[3].replaceTrack(null);case 21:this.localAuxStream_=null,this.mediaSettings_=q(q({},this.mediaSettings_),{},{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),U.push(3),f.next=33;break;case 26:return f.next=28,k[1].replaceTrack(null);case 28:return f.next=30,k[2].replaceTrack(null);case 30:this.localStream_=null,this.mediaSettings_=q(q({},this.mediaSettings_),{},{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),U.push(1,2);case 33:if(!this.localStream_&&!this.localAuxStream_){f.next=40;break}return f.next=36,this.setTransceiverDirection(oo,U);case 36:return f.next=38,this.doPublishChange();case 38:f.next=42;break;case 40:return f.next=42,this.doUnpublish();case 42:case"end":return f.stop()}},_,this)})),function(_){return T.apply(this,arguments)})},{key:"doPublishChange",value:(m=H(p().mark(function _(){var b,R;return p().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:return b={state:this.publishState,constraintConfig:this.mediaSettings_},P.next=3,this.signalChannel_.sendWaitForResponse({command:IU,data:b,responseCommand:st.PUBLISH_STATE_CHANGE_RESULT});case 3:R=P.sent,this.checkPublishResultCode(R.data.code,R.data.message);case 5:case"end":return P.stop()}},_,this)})),function(){return m.apply(this,arguments)})},{key:"doUnpublish",value:function(){var _=this;return this.signalChannel_.sendWaitForResponse({command:gk,commandDesc:"unpublish",responseCommand:st.UNPUBLISH_RESULT}).then(function(){_.close()}).catch(function(){_.close()})}},{key:"updateMediaSettings",value:function(_,b){var R=this;this.localAuxStream_&&_===this.localAuxStream_&&(b=!0);var P=this.client_.getSystemResult().detail,U=P.isH264EncodeSupported,k=P.isVp8EncodeSupported;if(U?this.mediaSettings_.videoCodec="H264":k&&(this.mediaSettings_.videoCodec="VP8"),la){var f=_.getMediaStream();f==null||f.getTracks().forEach(function(y){var A=y.getSettings();if(y.kind===Ee){var D=1;A.channelCount&&(D=A.channelCount),R.mediaSettings_.audioChannel=D,R.mediaSettings_.audioBps=1e3*_.getAudioBitrate(),R.mediaSettings_.audioFs=A.sampleRate}else if(y.kind===Ie){if(b)return R.mediaSettings_.auxVideoWidth=A.width,R.mediaSettings_.auxVideoHeight=A.height,R.mediaSettings_.auxVideoFps=A.frameRate,void(R.mediaSettings_.auxVideoBps=1e3*_.getVideoBitrate());R.client_.getIsEnableSmallStream()&&(R.mediaSettings_.smallVideoWidth=R.client_.smallStreamConfig.width,R.mediaSettings_.smallVideoHeight=R.client_.smallStreamConfig.height,R.mediaSettings_.smallVideoFps=R.client_.smallStreamConfig.frameRate,R.mediaSettings_.smallVideoBps=1e3*R.client_.smallStreamConfig.bitrate),R.mediaSettings_.videoWidth=A.width,R.mediaSettings_.videoHeight=A.height,R.mediaSettings_.videoFps=A.frameRate,R.mediaSettings_.videoBps=1e3*_.getVideoBitrate()}})}else this.updateMediaSettingsFromProfile(_);this.log_.info("updateMediaSettings: "+JSON.stringify(this.mediaSettings_))}},{key:"updateMediaSettingsFromProfile",value:function(_){if(_){if(_.hasAudio()){var b=_.getAudioProfile();this.mediaSettings_.audioChannel=b.channelCount,this.mediaSettings_.audioBps=1e3*b.bitrate,this.mediaSettings_.audioFs=b.sampleRate}if(_.hasVideo()){var R=_.getVideoProfile();this.mediaSettings_.videoWidth=R.width,this.mediaSettings_.videoHeight=R.height,this.mediaSettings_.videoFps=R.frameRate,this.mediaSettings_.videoBps=1e3*R.bitrate}}}},{key:"sendMediaSettings",value:function(_){var b=this;this.updateMediaSettings(_),this.signalChannel_.sendWaitForResponse({command:FU,data:this.mediaSettings_,responseCommand:st.UPDATE_CONSTRAINT_CONFIG_RES}).then(function(R){R.data.code!==0&&b.log_.warn(R.data.message)}).catch(this.log_.warn)}},{key:"addTrack",value:(x=H(p().mark(function _(b,R){var P,U;return p().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(this.peerConnection_){k.next=2;break}return k.abrupt("return");case 2:if(U=R===this.localAuxStream_,this.log_.info("is adding ".concat(b.kind," track to current published local ").concat(U?gt:Qe," stream")),(P=this.sei_)===null||P===void 0||P.handleEncodedStreams(),!Ii()){k.next=10;break}return k.next=8,this.addTrackByTransceiver(b,R);case 8:k.next=12;break;case 10:return k.next=12,this.addTrackBySender(b);case 12:vn(this.userId_,{eventId:b.kind===Ee?yk:_k,eventDesc:"add ".concat(b.kind," track to current published stream"),timestamp:an(),userId:this.userId_,tinyId:this.tinyId_});case 13:case"end":return k.stop()}},_,this)})),function(_,b){return x.apply(this,arguments)})},{key:"addTrackByTransceiver",value:(E=H(p().mark(function _(b,R){var P,U,k,f;return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(P=R===this.localAuxStream_,U=this.peerConnection_.getTransceivers(),b.kind!==Ee){y.next=13;break}if(!U[0].sender.track){y.next=9;break}return this.mixAudioTrack(U[0].sender.track,b),y.next=7,U[0].sender.replaceTrack(this.mixedAudioTrack_);case 7:y.next=11;break;case 9:return y.next=11,U[0].sender.replaceTrack(b);case 11:y.next=26;break;case 13:return k=P?3:1,y.next=16,U[k].sender.replaceTrack(b);case 16:if(k!==1||!this.client_.getIsEnableSmallStream()){y.next=23;break}return this.smallGenerator_=new Zl(this.localStream_),y.next=20,this.smallGenerator_.initialize();case 20:return f=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),y.next=23,U[2].sender.replaceTrack(f);case 23:if(U[k].direction!==oo){y.next=26;break}return y.next=26,this.setTransceiverDirection(mi,[k]);case 26:return this.updateMediaSettings(R,P),y.next=29,this.doPublishChange();case 29:case"end":return y.stop()}},_,this)})),function(_,b){return E.apply(this,arguments)})},{key:"addTrackBySender",value:(I=H(p().mark(function _(b){var R,P,U,k,f;return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!(Ii()&&this.peerConnection_.getTransceivers().findIndex(function(A){return A.direction==="stopped"})>=0)){y.next=4;break}return this.log_.warn("transceiver is stopping, negotiate sdp first"),y.next=4,this.updateOffer(cn.REMOVE,b);case 4:if(!(R=this.peerConnection_.getSenders().find(function(A){return A.track&&A.track.kind===b.kind}))){y.next=11;break}return this.log_.warn("sender already exists, remove sender first"),P=R.track,this.removeSender(R),y.next=11,this.updateOffer(cn.REMOVE,P);case 11:if(U=this.localStream_.getMediaStream(),this.peerConnection_.addTrack(b,U),b.kind!==Ie||!this.client_.getIsEnableSmallStream()){y.next=21;break}return this.smallGenerator_=new Zl(this.localStream_),y.next=17,this.smallGenerator_.initialize();case 17:k=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),(f=new MediaStream).addTrack(k),this.peerConnection_.addTrack(k,f);case 21:return y.next=23,this.updateOffer(cn.ADD,b);case 23:case"end":return y.stop()}},_,this)})),function(_){return I.apply(this,arguments)})},{key:"isNeedToResetOfferOrder",value:function(){if(this.sdpSemantics_===qf||!this.peerConnection_||!this.peerConnection_.localDescription)return!1;for(var _=this.peerConnection_.localDescription.sdp,b=Fr(_),R=0;R<b.media.length;R++)if(b.media[R].mid===0&&b.media[R].type===Ie)return!0;return!1}},{key:"removeSender",value:function(_){var b=null;Ii()&&(b=this.peerConnection_.getTransceivers().find(function(R){return R.sender&&R.sender.track===_.track})),this.peerConnection_.removeTrack(_),b&&ln(b.stop)&&(this.log_.info("stop transceiver"),b.stop())}},{key:"removeTrack",value:(S=H(p().mark(function _(b,R){return p().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(this.peerConnection_){P.next=2;break}return P.abrupt("return");case 2:if(this.log_.info("is removing ".concat(b.kind," track from current published local ").concat(R===this.localAuxStream_?gt:Qe," stream")),!Ii()){P.next=8;break}return P.next=6,this.removeTrackByTransceiver(b,R);case 6:P.next=10;break;case 8:return P.next=10,this.removeTrackBySender(b);case 10:vn(this.userId_,{eventId:b.kind===Ee?Sk:bk,eventDesc:"remove ".concat(b.kind," track from current published stream"),timestamp:an(),userId:this.userId_,tinyId:this.tinyId_});case 11:case"end":return P.stop()}},_,this)})),function(_,b){return S.apply(this,arguments)})},{key:"removeTrackByTransceiver",value:(h=H(p().mark(function _(b,R){var P,U,k;return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(P=R===this.localAuxStream_,U=this.peerConnection_.getTransceivers(),b.kind!==Ee){f.next=13;break}if(!this.mixedAudioTrack_){f.next=9;break}return f.next=6,U[0].sender.replaceTrack(P?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 6:this.destroyMixedAudioTrack(),f.next=11;break;case 9:return f.next=11,U[0].sender.replaceTrack(null);case 11:f.next=23;break;case 13:return k=P?3:1,f.next=16,U[k].sender.replaceTrack(null);case 16:if(k!==1||!this.smallGenerator_){f.next=21;break}return this.smallGenerator_.destroy(),this.smallGenerator_=null,f.next=21,U[2].sender.replaceTrack(null);case 21:return f.next=23,this.setTransceiverDirection(oo,[k]);case 23:return this.updateMediaSettings(R,P),f.next=26,this.doPublishChange();case 26:case"end":return f.stop()}},_,this)})),function(_,b){return h.apply(this,arguments)})},{key:"setTransceiverDirection",value:(u=H(p().mark(function _(b,R){var P,U,k,f,y,A;return p().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:if(Vn){D.next=2;break}return D.abrupt("return");case 2:if(P=!1,U=!1,this.log_.info("setting transceiver ".concat(R.join(",")," direction to ").concat(b)),k=this.peerConnection_.getTransceivers(),R.forEach(function(j){k[j].direction!==b&&(k[j].direction=b,P=!0)}),!P){D.next=14;break}return this.log_.info("updating offer"),D.next=11,this.peerConnection_.createOffer();case 11:return f=D.sent,D.next=14,this.peerConnection_.setLocalDescription(f);case 14:if(y=-1,A=this.peerConnection_.remoteDescription.sdp.split(`\r
65
- `).map(function(j){if(j.match(new RegExp("a=(".concat(oo,"|").concat(Uf,"|").concat(mi,")")))&&y++,R.includes(y)){if(b===oo&&j.includes("a=".concat(Uf)))return U=!0,"a=".concat(b);if(b===mi&&j.includes("a=".concat(oo)))return U=!0,"a=".concat(Uf)}return j}).join(`\r
66
- `),!U){D.next=20;break}return this.log_.info("updating answer"),D.next=20,this.peerConnection_.setRemoteDescription({type:"answer",sdp:A});case 20:case"end":return D.stop()}},_,this)})),function(_,b){return u.apply(this,arguments)})},{key:"removeTrackBySender",value:(l=H(p().mark(function _(b){var R,P,U=this;return p().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(b.kind!==Ie||!this.isNeedToResetOfferOrder()){k.next=7;break}return this.reset(),this.initialize(),(R=this.localStream_.getMediaStream())===null||R===void 0||R.removeTrack(b),k.next=6,this.publish(this.localStream_);case 6:return k.abrupt("return");case 7:return(P=this.peerConnection_.getSenders().find(function(f){return f.track===b}))&&(this.removeSender(P),b.kind===Ie&&this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null,this.peerConnection_.getSenders().forEach(function(f){f.track&&f.track.kind===Ie&&U.removeSender(f)}))),k.next=11,this.updateOffer(cn.REMOVE,b);case 11:case"end":return k.stop()}},_,this)})),function(_){return l.apply(this,arguments)})},{key:"replaceTrack",value:(s=H(p().mark(function _(b,R){var P,U,k,f,y,A,D;return p().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:if((U=(P=this.peerConnection_)===null||P===void 0?void 0:P.getSenders())&&U.length!==0){j.next=3;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:fS})});case 3:if(k=R===this.localAuxStream_,this.log_.info("is replacing ".concat(b.kind," track to current published local ").concat(k?gt:Qe," stream")),b.kind!==Ee||!U[0]){j.next=16;break}if(!(this.mixedAudioTrack_&&(f=this.localStream_)!==null&&f!==void 0&&f.hasAudio()&&(y=this.localAuxStream_)!==null&&y!==void 0&&y.hasAudio())){j.next=14;break}return this.destroyMixedAudioTrack(),A=k?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack(),this.mixAudioTrack(b,A),j.next=12,U[0].replaceTrack(this.mixedAudioTrack_);case 12:j.next=16;break;case 14:return j.next=16,U[0].replaceTrack(b);case 16:if(b.kind!==Ie){j.next=32;break}if(R!==this.localStream_||!U[1]){j.next=29;break}return j.next=20,U[1].replaceTrack(b);case 20:if(!this.smallGenerator_||!U[2]){j.next=29;break}return this.log_.info("replacing smallVideo"),this.smallGenerator_.destroy(),this.smallGenerator_=new Zl(this.localStream_),j.next=26,this.smallGenerator_.initialize();case 26:return D=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),j.next=29,U[2].replaceTrack(D);case 29:if(R!==this.localAuxStream_||!U[3]){j.next=32;break}return j.next=32,U[3].replaceTrack(b);case 32:vn(this.userId_,{eventId:b.kind===Ee?ZU:$U,eventDesc:"replace ".concat(b.kind," track from current published stream"),timestamp:an(),userId:this.userId_,tinyId:this.tinyId_});case 33:case"end":return j.stop()}},_,this)})),function(_,b){return s.apply(this,arguments)})},{key:"updateOffer",value:(a=H(p().mark(function _(b,R){var P,U,k,f,y,A,D;return p().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return j.prev=0,j.next=3,this.peerConnection_.createOffer(zI);case 3:return P=j.sent,Vn&&(P.sdp=this.setSDPDirection(P.sdp,"sendrecv")),j.next=7,this.peerConnection_.setLocalDescription(P);case 7:return U=this.updateMediaSettings(this.localStream_||this.localAuxStream_),k={action:b,trackId:R.id,kind:R.kind===Ie?"bigVideo":R.kind,type:"offer",sdp:this.peerConnection_.localDescription.sdp,constraintConfig:U,state:this.publishState},this.log_.info("createOffer success, sending updated offer to remote server"),this.log_.debug("updatedOffer: "+k.sdp),j.next=13,this.signalChannel_.sendWaitForResponse({command:TU,data:k,responseCommand:st.UPDATE_OFFER_RESULT,timeout:1e4,commandDesc:"update offer"});case 13:return f=j.sent,y=f.data,A=y.code,D=y.message,A!==0&&this.checkPublishResultCode(A,D),j.next=18,this.acceptAnswer(f.data.data);case 18:this.updateSSRC(P.sdp),ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ku,kind:"offer"}),j.next=27;break;case 22:throw j.prev=22,j.t0=j.catch(0),this.log_.error(j.t0),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Ku,kind:"offer",error:j.t0}),j.t0;case 27:case"end":return j.stop()}},_,this,[[0,22]])})),function(_,b){return a.apply(this,arguments)})},{key:"setBandwidth",value:(c=H(p().mark(function _(b){var R,P,U,k,f,y,A,D,j,K;return p().wrap(function(J){for(;;)switch(J.prev=J.next){case 0:if(R=b.bandwidth,P=b.type,U=b.videoType,k=U===void 0?"":U,f=b.sdp,y=b.scaleResolutionDownBy,A=y===void 0?1:y,Hk()||!f){J.next=3;break}return J.abrupt("return",P===Ie?this.updateVideoBandwidthRestriction(f,R,k):this.updateAudioBandwidthRestriction(f,R));case 3:if(D=null,gl()?(j=0,P===Ie&&(j=k===Mr?2:k===gt?3:1),D=this.peerConnection_.getSenders()[j]):D=this.peerConnection_.getSenders().find(function(se){return se.track&&se.track.kind===P}),!D){J.next=22;break}return(K=D.getParameters()).encodings&&K.encodings.length!==0||(K.encodings=[{}]),R==="unlimited"?delete K.encodings[0].maxBitrate:K.encodings[0].maxBitrate=1e3*R,A>1&&(this.log_.warn("".concat(k," scaleResolutionDownBy ").concat(A)),K.encodings[0].scaleResolutionDownBy=A),J.prev=10,J.next=13,D.setParameters(K);case 13:return this.log_.info(k+P+" bandwidth was set to "+R+" kbps"),J.abrupt("return",f);case 17:if(J.prev=17,J.t0=J.catch(10),this.log_.info("failed to set bandwidth by setting maxBitrate: "+J.t0),!f){J.next=22;break}return J.abrupt("return",P===Ie?this.updateVideoBandwidthRestriction(f,R,k):this.updateAudioBandwidthRestriction(f,R));case 22:return J.abrupt("return",f);case 23:case"end":return J.stop()}},_,this,[[10,17]])})),function(_){return c.apply(this,arguments)})},{key:"updateVideoBandwidthRestriction",value:function(_,b,R){var P="AS";Vn&&(P="TIAS",b*=1e3);var U=0,k=-1;return R===Mr?U=1:R===gt&&(U=2),_=_.replace(/m=video (.*)\r\nc=IN (.*)\r\n/g,function(f){return++k===U?"".concat(f,"b=").concat(P,":").concat(b,`\r
67
- `):f}),_}},{key:"updateAudioBandwidthRestriction",value:function(_,b){var R="AS";return Vn&&(R="TIAS",b*=1e3),_=_.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,`m=audio $1\r
62
+ `,i.onclick=this.onQuestionClick.bind(this);var r=document.createElement("div");r.className=ev,r.innerText="".concat(oa()?"\u8BE6\u60C5 >":"Detail >"),r.onclick=this.onCollapseClick.bind(this);var o=t.content.firstChild,c=o.querySelector(".".concat(Rl));return c.appendChild(r),c.appendChild(i),c.appendChild(n),o}},{key:"addDiaLog",value:function(){LT()||(this.dialogNode_=this.createDiaLog(),document.body.appendChild(this.dialogNode_),this.dialogNode_.onclick=this.onConfirm.bind(this),this.dialogNode_.querySelector(".".concat(wo)).onclick=function(t){return t.stopPropagation()},this.bodyPosition_=document.body.style.position,document.body.style.position="fixed",_e.info("show autoplay dialog"),ke.uploadEvent({log:l5}))}},{key:"deleteDiaLog",value:function(){this.dialogNode_&&(document.body.removeChild(this.dialogNode_),document.body.style.position=this.bodyPosition_,this.dialogNode_=null)}},{key:"onConfirm",value:function(){_e.warn("confirm clicked, try resume stream"),Y.emit(rc),this.deleteDiaLog()}},{key:"onCollapseClick",value:function(){var t=this.dialogNode_.querySelector(".".concat(PT));t.style.visibility="".concat(this.showDetail_?"hidden":"visible"),t.style.height="".concat(this.showDetail_?0:"fit-content"),this.showDetail_=!this.showDetail_,this.isCollapseClicked_||ke.uploadEvent({log:d5}),this.isCollapseClicked_=!0}},{key:"onQuestionClick",value:function(){window.open(MT,"_blank"),this.isQuestionClicked_||ke.uploadEvent({log:h5}),this.isQuestionClicked_=!0}}]),e}(),VT=function(){function e(n){Q(this,e),this.stream_=n.stream,this.userId_=n.stream.getUserId(),this.log_=this.stream_.getLogger(),this.track_=n.track,this.div_=n.div,this.muted_=n.muted,this.objectFit_=n.objectFit,this.mirror_=n.mirror,this.emitter_=new ki,this.initializeElement(),this.state_="NONE",this.pausedRetryCount_=5}var t;return xe(e,[{key:"isPlaying",get:function(){return this.state_===ao}},{key:"initializeElement",value:function(){var n=new MediaStream;n.addTrack(this.track_);var i=document.createElement(Ie);i.srcObject=n,i.muted=!0;var r="width: 100%; height: 100%; object-fit: ".concat(this.objectFit_,";");this.mirror_&&(r+="transform: scaleX(-1);"),i.setAttribute("id","video_".concat(this.stream_.getId())),i.setAttribute("style",r),i.setAttribute("autoplay","autoplay"),i.setAttribute("playsinline","playsinline"),this.element_=i,OS===17&&this.initCanvasElement(r),this.div_&&this.div_.appendChild(this.canvas_||i),this.handleEvents()}},{key:"initCanvasElement",value:function(n){var i=this;if(this.track_&&!this.stream_.isRemote()){var r=document.createElement("canvas"),o=function(){var a,s=(a=i.track_)===null||a===void 0?void 0:a.getSettings();s&&s.width&&s.height&&(r.width=s.width,r.height=s.height)};o(),r.setAttribute("style",n);var c=r.getContext("2d");this.canvasTimerId_=mt.run("raf",function(){i.element_&&c&&(o(),c.drawImage(i.element_,0,0,r.width,r.height))},{backgroundTask:!1}),this.log_.warn("use canvas for playback"),this.canvas_=r}}},{key:"setRect",value:function(n){var i=n.width,r=n.height;this.element_&&(this.element_.style.width=i+"px",this.element_.style.height=r+"px")}},{key:"setMirror",value:function(n){this.element_&&(this.element_.style.transform=n?"scaleX(-1)":"",this.mirror_=n)}},{key:"setObjectFit",value:function(n){this.element_&&(this.element_.style.objectFit="".concat(n),this.objectFit_=n)}},{key:"play",value:(t=H(f().mark(function n(){var i;return f().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,this.element_.play();case 3:r.next=11;break;case 5:if(r.prev=5,r.t0=r.catch(0),i=ie({key:np,data:{media:"Video",error:r.t0}}),this.log_.warn(i),!i.includes("NotAllowedError")){r.next=11;break}throw new te({code:Z.PLAY_NOT_ALLOWED,message:i});case 11:case"end":return r.stop()}},n,this,[[0,5]])})),function(){return t.apply(this,arguments)})},{key:"handleEvents",value:function(){this.handleElementEvent=this.handleElementEvent.bind(this),this.handleTrackEvent=this.handleTrackEvent.bind(this),this.element_.addEventListener(hi,this.handleElementEvent),this.element_.addEventListener(Nt,this.handleElementEvent),this.element_.addEventListener(fi,this.handleElementEvent),this.element_.addEventListener(io,this.handleElementEvent),this.element_.addEventListener(Lf,this.handleElementEvent),this.track_.addEventListener(Nt,this.handleTrackEvent),this.track_.addEventListener(tn,this.handleTrackEvent),this.track_.addEventListener(Sr,this.handleTrackEvent),this.track_.readyState===Nt&&this.handleTrackEvent({type:Nt}),this.track_.muted&&this.handleTrackEvent({type:tn})}},{key:"handleElementEvent",value:function(n){var i=this;switch(n.type){case hi:this.log_.info("video player is playing"),this.state_=ao,Y.emit(tc,{stream:this.stream_}),this.emitter_.emit(gn,{state:this.state_,reason:hi}),this.interval_&&(mt.clearTask(this.interval_),this.interval_=null);break;case Nt:this.log_.info("video player is ended"),this.state_!==pi&&(this.state_=pi,this.emitter_.emit(gn,{state:this.state_,reason:Nt}));break;case fi:this.log_.info("video player is paused"),this.div_&&!document.getElementById(this.div_.id)&&this.log_.warn("video player has been remove, element ID: ".concat(this.div_.id)),this.state_=kr,this.emitter_.emit(gn,{state:this.state_,reason:fi}),this.pausedRetryCount_>0&&!LT()&&(this.log_.info("video player auto resume when video paused"),this.resume(),this.pausedRetryCount_--),_i&&(this.interval_=mt.run(function(){i.element_&&i.state_===kr&&i.resume()},{delay:3e3}));break;case io:if(this.element_&&this.element_.error){var r="".concat(xm(),"/").concat(aa().name,"/").concat(aa().version);this.log_.error("video player error observed. code: ".concat(this.element_.error.code," message: ").concat(this.element_.error.message," deviceInfo: ").concat(r)),ke.uploadEvent({log:"stat-".concat(this.stream_.getType(),"-video-").concat(Bb,"-").concat(this.element_.error.code,"-").concat(r),userId:this.userId_,error:this.element_.error})}break;case Lf:Y.emit(Wp,{stream:this.stream_})}}},{key:"handleTrackEvent",value:function(n){var i=n.type;switch(i){case Nt:this.log_.info("video track is ended"),Y.emit(qp,{stream:this.stream_,type:i}),this.state_!==pi&&(this.state_=pi,this.emitter_.emit(gn,{state:this.state_,reason:Nt}));break;case tn:this.log_.info("video track is unable to provide media output"),this.stream_.isRemote()||BS(),Y.emit(nc,{stream:this.stream_,type:i}),this.state_!==kr&&(this.state_=kr,this.emitter_.emit(gn,{state:this.state_,reason:tn}));break;case Sr:this.log_.info("video track is able to provide media output"),Y.emit(Gp,{stream:this.stream_}),this.state_===kr&&(this.state_=ao,this.emitter_.emit(gn,{state:this.state_,reason:Sr}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(hi,this.handleElementEvent),this.element_.removeEventListener(Nt,this.handleElementEvent),this.element_.removeEventListener(fi,this.handleElementEvent),this.element_.removeEventListener(io,this.handleElementEvent),this.element_.removeEventListener(Lf,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Nt,this.handleTrackEvent),this.track_.removeEventListener(tn,this.handleTrackEvent),this.track_.removeEventListener(Sr,this.handleTrackEvent))}},{key:"stop",value:function(){this.unbindEvents(),this.element_&&(this.element_.remove(),this.element_.srcObject=null,this.element_=null),this.interval_&&mt.clearTask(this.interval_),this.canvasTimerId_&&mt.clearTask(this.canvasTimerId_),this.canvas_&&(this.canvas_.remove(),this.canvas_=null)}},{key:"resume",value:function(){return this.play()}},{key:"getVideoFrame",value:function(){var n=document.createElement("canvas");return n.width=this.element_.videoWidth,n.height=this.element_.videoHeight,n.getContext("2d").drawImage(this.element_,0,0),n.toDataURL("image/png")}},{key:"on",value:function(n,i){this.emitter_.on(n,i)}},{key:"getElement",value:function(){return this.element_?this.element_:null}},{key:"getTrack",value:function(){return this.track_}}]),e}(),nv=typeof ArrayBuffer!="undefined"&&typeof DataView!="undefined",p5=$n,m5=yr,v5=RangeError,jT=function(e){if(e===void 0)return 0;var t=p5(e),n=m5(t);if(t!==n)throw v5("Wrong length or index");return n},g5=Array,_5=Math.abs,Wr=Math.pow,y5=Math.floor,b5=Math.log,S5=Math.LN2,k5={pack:function(e,t,n){var i,r,o,c=g5(n),a=8*n-t-1,s=(1<<a)-1,l=s>>1,u=t===23?Wr(2,-24)-Wr(2,-77):0,h=e<0||e===0&&1/e<0?1:0,b=0;for((e=_5(e))!=e||e===1/0?(r=e!=e?1:0,i=s):(i=y5(b5(e)/S5),e*(o=Wr(2,-i))<1&&(i--,o*=2),(e+=i+l>=1?u/o:u*Wr(2,1-l))*o>=2&&(i++,o/=2),i+l>=s?(r=0,i=s):i+l>=1?(r=(e*o-1)*Wr(2,t),i+=l):(r=e*Wr(2,l-1)*Wr(2,t),i=0));t>=8;)c[b++]=255&r,r/=256,t-=8;for(i=i<<t|r,a+=t;a>0;)c[b++]=255&i,i/=256,a-=8;return c[--b]|=128*h,c},unpack:function(e,t){var n,i=e.length,r=8*i-t-1,o=(1<<r)-1,c=o>>1,a=r-7,s=i-1,l=e[s--],u=127&l;for(l>>=7;a>0;)u=256*u+e[s--],a-=8;for(n=u&(1<<-a)-1,u>>=-a,a+=t;a>0;)n=256*n+e[s--],a-=8;if(u===0)u=1-c;else{if(u===o)return n?NaN:l?-1/0:1/0;n+=Wr(2,t),u-=c}return(l?-1:1)*n*Wr(2,u-t)}},T5=Mt,BT=ai,I5=nn,FT=function(e){for(var t=T5(this),n=I5(t),i=arguments.length,r=BT(i>1?arguments[1]:void 0,n),o=i>2?arguments[2]:void 0,c=o===void 0?n:BT(o,n);c>r;)t[r++]=e;return t},Pl=re,rv=pe,iv=ye,x5=nv,HT=Yn,GT=Ln,zT=As,av=se,Dl=si,w5=$n,C5=yr,Ol=jT,WT=k5,E5=Ts,JT=Fa,R5=ii.f,A5=Pt.f,P5=FT,D5=hu,qT=Wi,O5=HT.PROPER,KT=HT.CONFIGURABLE,Co=Ke.get,XT=Ke.set,ov="ArrayBuffer",L5="DataView",QT="Wrong index",Wn=Pl.ArrayBuffer,or=Wn,Eo=or&&or.prototype,wr=Pl.DataView,ma=wr&&wr.prototype,YT=Object.prototype,M5=Pl.Array,Ll=Pl.RangeError,N5=rv(P5),U5=rv([].reverse),$T=WT.pack,ZT=WT.unpack,e1=function(e){return[255&e]},t1=function(e){return[255&e,e>>8&255]},n1=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},r1=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},V5=function(e){return $T(e,23,4)},j5=function(e){return $T(e,52,8)},Ml=function(e,t){A5(e.prototype,t,{get:function(){return Co(this)[t]}})},Ci=function(e,t,n,i){var r=Ol(n),o=Co(e);if(r+t>o.byteLength)throw Ll(QT);var c=Co(o.buffer).bytes,a=r+o.byteOffset,s=D5(c,a,a+t);return i?s:U5(s)},Ei=function(e,t,n,i,r,o){var c=Ol(n),a=Co(e);if(c+t>a.byteLength)throw Ll(QT);for(var s=Co(a.buffer).bytes,l=c+a.byteOffset,u=i(+r),h=0;h<t;h++)s[l+h]=u[o?h:t-h-1]};if(x5){var i1=O5&&Wn.name!==ov;if(av(function(){Wn(1)})&&av(function(){new Wn(-1)})&&!av(function(){return new Wn,new Wn(1.5),new Wn(NaN),Wn.length!=1||i1&&!KT}))i1&&KT&&GT(Wn,"name",ov);else{(or=function(e){return Dl(this,Eo),new Wn(Ol(e))}).prototype=Eo;for(var sv,a1=R5(Wn),o1=0;a1.length>o1;)(sv=a1[o1++])in or||GT(or,sv,Wn[sv]);Eo.constructor=or}JT&&E5(ma)!==YT&&JT(ma,YT);var Nl=new wr(new or(2)),s1=rv(ma.setInt8);Nl.setInt8(0,2147483648),Nl.setInt8(1,2147483649),!Nl.getInt8(0)&&Nl.getInt8(1)||zT(ma,{setInt8:function(e,t){s1(this,e,t<<24>>24)},setUint8:function(e,t){s1(this,e,t<<24>>24)}},{unsafe:!0})}else Eo=(or=function(e){Dl(this,Eo);var t=Ol(e);XT(this,{bytes:N5(M5(t),0),byteLength:t}),iv||(this.byteLength=t)}).prototype,wr=function(e,t,n){Dl(this,ma),Dl(e,Eo);var i=Co(e).byteLength,r=w5(t);if(r<0||r>i)throw Ll("Wrong offset");if(r+(n=n===void 0?i-r:C5(n))>i)throw Ll("Wrong length");XT(this,{buffer:e,byteLength:n,byteOffset:r}),iv||(this.buffer=e,this.byteLength=n,this.byteOffset=r)},ma=wr.prototype,iv&&(Ml(or,"byteLength"),Ml(wr,"buffer"),Ml(wr,"byteLength"),Ml(wr,"byteOffset")),zT(ma,{getInt8:function(e){return Ci(this,1,e)[0]<<24>>24},getUint8:function(e){return Ci(this,1,e)[0]},getInt16:function(e){var t=Ci(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=Ci(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return r1(Ci(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return r1(Ci(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return ZT(Ci(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return ZT(Ci(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){Ei(this,1,e,e1,t)},setUint8:function(e,t){Ei(this,1,e,e1,t)},setInt16:function(e,t){Ei(this,2,e,t1,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){Ei(this,2,e,t1,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){Ei(this,4,e,n1,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){Ei(this,4,e,n1,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){Ei(this,4,e,V5,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){Ei(this,8,e,j5,t,arguments.length>2?arguments[2]:void 0)}});qT(or,ov),qT(wr,L5);var vc={ArrayBuffer:or,DataView:wr},B5=Le,cv=pe,F5=se,c1=Tt,u1=ai,H5=yr,G5=Ou,uv=vc.ArrayBuffer,lv=vc.DataView,l1=lv.prototype,d1=cv(uv.prototype.slice),z5=cv(l1.getUint8),W5=cv(l1.setUint8);B5({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:F5(function(){return!new uv(2).slice(1,void 0).byteLength})},{slice:function(e,t){if(d1&&t===void 0)return d1(c1(this),e);for(var n=c1(this).byteLength,i=u1(e,n),r=u1(t===void 0?n:t,n),o=new(G5(this,uv))(H5(r-i)),c=new lv(this),a=new lv(o),s=0;i<r;)W5(a,s++,z5(c,i++));return o}}),Le({global:!0,constructor:!0,forced:!nv},{DataView:vc.DataView});var J5=Le,q5=Ga,K5=pe([].reverse),h1=[1,2];J5({target:"Array",proto:!0,forced:String(h1)===String(h1.reverse())},{reverse:function(){return q5(this)&&(this.length=this.length),K5(this)}});var X5=Vt,Q5=Mt,Y5=yn,$5=nn,Z5=TypeError,f1=function(e){return function(t,n,i,r){X5(n);var o=Q5(t),c=Y5(o),a=$5(o),s=e?a-1:0,l=e?-1:1;if(i<2)for(;;){if(s in c){r=c[s],s+=l;break}if(s+=l,e?s<0:a<=s)throw Z5("Reduce of empty array with no initial value")}for(;e?s>=0:a>s;s+=l)s in c&&(r=n(r,c[s],s,o));return r}},dv={left:f1(!1),right:f1(!0)},ej=dv.left,p1=pr,tj=Fs;Le({target:"Array",proto:!0,forced:!Ns("reduce")||!tj&&p1>79&&p1<83},{reduce:function(e){var t=arguments.length;return ej(this,e,t,t>1?arguments[1]:void 0)}});var nj=Ps,rj="ArrayBuffer",m1=vc.ArrayBuffer;Le({global:!0,constructor:!0,forced:re.ArrayBuffer!==m1},{ArrayBuffer:m1}),nj(rj);var ij=Le,v1=Ga,aj=yu,oj=at,g1=ai,sj=nn,cj=bn,uj=Cs,lj=tt,dj=Ha,hj=Ms("slice"),fj=lj("species"),hv=Array,pj=Math.max;ij({target:"Array",proto:!0,forced:!hj},{slice:function(e,t){var n,i,r,o=cj(this),c=sj(o),a=g1(e,c),s=g1(t===void 0?c:t,c);if(v1(o)&&(n=o.constructor,(aj(n)&&(n===hv||v1(n.prototype))||oj(n)&&(n=n[fj])===null)&&(n=void 0),n===hv||n===void 0))return dj(o,a,s);for(i=new(n===void 0?hv:n)(pj(s-a,0)),r=0;a<s;a++,r++)a in o&&uj(i,r,o[a]);return i.length=r,i}});var _1=re,mj=se,vj=pe,gj=zt,_j=Au.trim,y1=s0,gc=_1.parseInt,b1=_1.Symbol,S1=b1&&b1.iterator,k1=/^[+-]?0x/i,yj=vj(k1.exec),T1=gc(y1+"08")!==8||gc(y1+"0x16")!==22||S1&&!mj(function(){gc(Object(S1))})?function(e,t){var n=_j(gj(e));return gc(n,t>>>0||(yj(k1,n)?16:10))}:gc;Le({global:!0,forced:parseInt!=T1},{parseInt:T1});var _n,Ro,Ul,fv={exports:{}},bj=nv,pv=ye,hn=re,I1=it,Vl=at,Ri=kt,mv=Dr,Sj=Xn,kj=Ln,vv=Qt,Tj=Pt.f,Ij=Sn,jl=Ts,Ao=Fa,xj=tt,wj=Vi,x1=Ke.enforce,Cj=Ke.get,Bl=hn.Int8Array,gv=Bl&&Bl.prototype,w1=hn.Uint8ClampedArray,C1=w1&&w1.prototype,Cr=Bl&&jl(Bl),sr=gv&&jl(gv),Ej=Object.prototype,_v=hn.TypeError,E1=xj("toStringTag"),yv=wj("TYPED_ARRAY_TAG"),Rj="TypedArrayConstructor",Jr=bj&&!!Ao&&mv(hn.opera)!=="Opera",R1=!1,qr={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},bv={BigInt64Array:8,BigUint64Array:8},A1=function(e){var t=jl(e);if(Vl(t)){var n=Cj(t);return n&&Ri(n,Rj)?n.TypedArrayConstructor:A1(t)}},P1=function(e){if(!Vl(e))return!1;var t=mv(e);return Ri(qr,t)||Ri(bv,t)};for(_n in qr)(Ul=(Ro=hn[_n])&&Ro.prototype)?x1(Ul).TypedArrayConstructor=Ro:Jr=!1;for(_n in bv)(Ul=(Ro=hn[_n])&&Ro.prototype)&&(x1(Ul).TypedArrayConstructor=Ro);if((!Jr||!I1(Cr)||Cr===Function.prototype)&&(Cr=function(){throw _v("Incorrect invocation")},Jr))for(_n in qr)hn[_n]&&Ao(hn[_n],Cr);if((!Jr||!sr||sr===Ej)&&(sr=Cr.prototype,Jr))for(_n in qr)hn[_n]&&Ao(hn[_n].prototype,sr);if(Jr&&jl(C1)!==sr&&Ao(C1,sr),pv&&!Ri(sr,E1))for(_n in R1=!0,Tj(sr,E1,{get:function(){return Vl(this)?this[yv]:void 0}}),qr)hn[_n]&&kj(hn[_n],yv,_n);var Ge={NATIVE_ARRAY_BUFFER_VIEWS:Jr,TYPED_ARRAY_TAG:R1&&yv,aTypedArray:function(e){if(P1(e))return e;throw _v("Target is not a typed array")},aTypedArrayConstructor:function(e){if(I1(e)&&(!Ao||Ij(Cr,e)))return e;throw _v(Sj(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,i){if(pv){if(n)for(var r in qr){var o=hn[r];if(o&&Ri(o.prototype,e))try{delete o.prototype[e]}catch(c){try{o.prototype[e]=t}catch(a){}}}sr[e]&&!n||vv(sr,e,n?t:Jr&&gv[e]||t,i)}},exportTypedArrayStaticMethod:function(e,t,n){var i,r;if(pv){if(Ao){if(n){for(i in qr)if((r=hn[i])&&Ri(r,e))try{delete r[e]}catch(o){}}if(Cr[e]&&!n)return;try{return vv(Cr,e,n?t:Jr&&Cr[e]||t)}catch(o){}}for(i in qr)!(r=hn[i])||r[e]&&!n||vv(r,e,t)}},getTypedArrayConstructor:A1,isView:function(e){if(!Vl(e))return!1;var t=mv(e);return t==="DataView"||Ri(qr,t)||Ri(bv,t)},isTypedArray:P1,TypedArray:Cr,TypedArrayPrototype:sr},D1=re,Sv=se,Aj=vu,Pj=Ge.NATIVE_ARRAY_BUFFER_VIEWS,Dj=D1.ArrayBuffer,va=D1.Int8Array,Oj=!Pj||!Sv(function(){va(1)})||!Sv(function(){new va(-1)})||!Aj(function(e){new va,new va(null),new va(1.5),new va(e)},!0)||Sv(function(){return new va(new Dj(2),1,void 0).length!==1}),Lj=$n,Mj=RangeError,Nj=function(e){var t=Lj(e);if(t<0)throw Mj("The argument can't be less than 0");return t},Uj=RangeError,O1=function(e,t){var n=Nj(e);if(n%t)throw Uj("Wrong offset");return n},Vj=Dr,jj=pe("".slice),Bj=ji,Fj=TypeError,L1=function(e){var t=Bj(e,"number");if(typeof t=="number")throw Fj("Can't convert number to bigint");return BigInt(t)},Hj=Lr,Gj=qe,zj=I0,Wj=Mt,Jj=nn,qj=pu,Kj=Es,Xj=lh,Qj=function(e){return jj(Vj(e),0,3)==="Big"},Yj=Ge.aTypedArrayConstructor,$j=L1,M1=Le,N1=re,U1=qe,Zj=ye,e8=Oj,Po=Ge,V1=vc,j1=si,t8=$e,_c=Ln,n8=YS,r8=yr,B1=jT,kv=O1,F1=Da,yc=kt,i8=Dr,Tv=at,a8=Mi,o8=Ba,s8=Sn,Fl=Fa,c8=ii.f,H1=function(e){var t,n,i,r,o,c,a,s,l=zj(this),u=Wj(e),h=arguments.length,b=h>1?arguments[1]:void 0,I=b!==void 0,R=Kj(u);if(R&&!Xj(R))for(s=(a=qj(u,R)).next,u=[];!(c=Gj(s,a)).done;)u.push(c.value);for(I&&h>2&&(b=Hj(b,arguments[2])),n=Jj(u),i=new(Yj(l))(n),r=Qj(i),t=0;n>t;t++)o=I?b(u[t],t):u[t],i[t]=r?$j(o):+o;return i},u8=rn.forEach,l8=Ps,G1=Pt,z1=be,d8=gu,Iv=Ke.get,h8=Ke.set,f8=Ke.enforce,xv=G1.f,p8=z1.f,m8=Math.round,wv=N1.RangeError,W1=V1.ArrayBuffer,v8=W1.prototype,g8=V1.DataView,Hl=Po.NATIVE_ARRAY_BUFFER_VIEWS,J1=Po.TYPED_ARRAY_TAG,q1=Po.TypedArray,bc=Po.TypedArrayPrototype,_8=Po.aTypedArrayConstructor,Cv=Po.isTypedArray,Gl="BYTES_PER_ELEMENT",Ev="Wrong length",K1=function(e,t){_8(e);for(var n=0,i=t.length,r=new e(i);i>n;)r[n]=t[n++];return r},zl=function(e,t){xv(e,t,{get:function(){return Iv(this)[t]}})},X1=function(e){var t;return s8(v8,e)||(t=i8(e))=="ArrayBuffer"||t=="SharedArrayBuffer"},Q1=function(e,t){return Cv(e)&&!a8(t)&&t in e&&n8(+t)&&t>=0},Y1=function(e,t){return t=F1(t),Q1(e,t)?t8(2,e[t]):p8(e,t)},$1=function(e,t,n){return t=F1(t),!(Q1(e,t)&&Tv(n)&&yc(n,"value"))||yc(n,"get")||yc(n,"set")||n.configurable||yc(n,"writable")&&!n.writable||yc(n,"enumerable")&&!n.enumerable?xv(e,t,n):(e[t]=n.value,e)};Zj?(Hl||(z1.f=Y1,G1.f=$1,zl(bc,"buffer"),zl(bc,"byteOffset"),zl(bc,"byteLength"),zl(bc,"length")),M1({target:"Object",stat:!0,forced:!Hl},{getOwnPropertyDescriptor:Y1,defineProperty:$1}),fv.exports=function(e,t,n){var i=e.match(/\d+$/)[0]/8,r=e+(n?"Clamped":"")+"Array",o="get"+e,c="set"+e,a=N1[r],s=a,l=s&&s.prototype,u={},h=function(I,R){xv(I,R,{get:function(){return function(x,m){var k=Iv(x);return k.view[o](m*i+k.byteOffset,!0)}(this,R)},set:function(x){return function(m,k,v){var w=Iv(m);n&&(v=(v=m8(v))<0?0:v>255?255:255&v),w.view[c](k*i+w.byteOffset,v,!0)}(this,R,x)},enumerable:!0})};Hl?e8&&(s=t(function(I,R,x,m){return j1(I,l),d8(Tv(R)?X1(R)?m!==void 0?new a(R,kv(x,i),m):x!==void 0?new a(R,kv(x,i)):new a(R):Cv(R)?K1(s,R):U1(H1,s,R):new a(B1(R)),I,s)}),Fl&&Fl(s,q1),u8(c8(a),function(I){I in s||_c(s,I,a[I])}),s.prototype=l):(s=t(function(I,R,x,m){j1(I,l);var k,v,w,L=0,E=0;if(Tv(R)){if(!X1(R))return Cv(R)?K1(s,R):U1(H1,s,R);k=R,E=kv(x,i);var N=R.byteLength;if(m===void 0){if(N%i||(v=N-E)<0)throw wv(Ev)}else if((v=r8(m)*i)+E>N)throw wv(Ev);w=v/i}else w=B1(R),k=new W1(v=w*i);for(h8(I,{buffer:k,byteOffset:E,byteLength:v,length:w,view:new g8(k)});L<w;)h(I,L++)}),Fl&&Fl(s,q1),l=s.prototype=o8(bc)),l.constructor!==s&&_c(l,"constructor",s),f8(l).TypedArrayConstructor=s,J1&&_c(l,J1,r);var b=s!=a;u[r]=s,M1({global:!0,constructor:!0,forced:b,sham:!Hl},u),Gl in s||_c(s,Gl,i),Gl in l||_c(l,Gl,i),l8(r)}):fv.exports=function(){},(0,fv.exports)("Uint8",function(e){return function(t,n,i){return e(this,t,n,i)}});var y8=Mt,Rv=ai,b8=nn,S8=W_,k8=Math.min,T8=[].copyWithin||function(e,t){var n=y8(this),i=b8(n),r=Rv(e,i),o=Rv(t,i),c=arguments.length>2?arguments[2]:void 0,a=k8((c===void 0?i:Rv(c,i))-o,i-r),s=1;for(o<r&&r<o+a&&(s=-1,o+=a-1,r+=a-1);a-- >0;)o in n?n[r]=n[o]:S8(n,r),r+=s,o+=s;return n},Z1=Ge,I8=pe(T8),x8=Z1.aTypedArray;(0,Z1.exportTypedArrayMethod)("copyWithin",function(e,t){return I8(x8(this),e,t,arguments.length>2?arguments[2]:void 0)});var w8=rn.every,C8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("every",function(e){return w8(C8(this),e,arguments.length>1?arguments[1]:void 0)});var E8=FT,R8=L1,A8=Dr,P8=qe,D8=se,O8=Ge.aTypedArray,L8=Ge.exportTypedArrayMethod,M8=pe("".slice);L8("fill",function(e){var t=arguments.length;O8(this);var n=M8(A8(this),0,3)==="Big"?R8(e):+e;return P8(E8,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},D8(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),e!==1}));var N8=nn,U8=Ou,V8=Ge.aTypedArrayConstructor,j8=Ge.getTypedArrayConstructor,Wl=function(e){return V8(U8(e,j8(e)))},B8=function(e,t){for(var n=0,i=N8(t),r=new e(i);i>n;)r[n]=t[n++];return r},F8=Wl,H8=rn.filter,G8=function(e,t){return B8(F8(e),t)},z8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("filter",function(e){var t=H8(z8(this),e,arguments.length>1?arguments[1]:void 0);return G8(this,t)});var W8=rn.find,J8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("find",function(e){return W8(J8(this),e,arguments.length>1?arguments[1]:void 0)});var q8=rn.findIndex,K8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("findIndex",function(e){return q8(K8(this),e,arguments.length>1?arguments[1]:void 0)});var X8=rn.forEach,Q8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("forEach",function(e){X8(Q8(this),e,arguments.length>1?arguments[1]:void 0)});var Y8=ys.includes,$8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("includes",function(e){return Y8($8(this),e,arguments.length>1?arguments[1]:void 0)});var Z8=ys.indexOf,eB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("indexOf",function(e){return Z8(eB(this),e,arguments.length>1?arguments[1]:void 0)});var tB=re,nB=se,Av=pe,eI=Ge,Pv=Gg,Dv=tt("iterator"),tI=tB.Uint8Array,rB=Av(Pv.values),iB=Av(Pv.keys),aB=Av(Pv.entries),Ov=eI.aTypedArray,Jl=eI.exportTypedArrayMethod,Do=tI&&tI.prototype,ql=!nB(function(){Do[Dv].call([1])}),nI=!!Do&&Do.values&&Do[Dv]===Do.values&&Do.values.name==="values",rI=function(){return rB(Ov(this))};Jl("entries",function(){return aB(Ov(this))},ql),Jl("keys",function(){return iB(Ov(this))},ql),Jl("values",rI,ql||!nI,{name:"values"}),Jl(Dv,rI,ql||!nI,{name:"values"});var oB=Ge.aTypedArray,sB=Ge.exportTypedArrayMethod,cB=pe([].join);sB("join",function(e){return cB(oB(this),e)});var uB=Ji,lB=bn,dB=$n,hB=nn,fB=Ns,pB=Math.min,Lv=[].lastIndexOf,iI=!!Lv&&1/[1].lastIndexOf(1,-0)<0,mB=fB("lastIndexOf"),vB=iI||!mB?function(e){if(iI)return uB(Lv,this,arguments)||0;var t=lB(this),n=hB(t),i=n-1;for(arguments.length>1&&(i=pB(i,dB(arguments[1]))),i<0&&(i=n+i);i>=0;i--)if(i in t&&t[i]===e)return i||0;return-1}:Lv,gB=Ji,_B=vB,yB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("lastIndexOf",function(e){var t=arguments.length;return gB(_B,yB(this),t>1?[e,arguments[1]]:[e])});var bB=rn.map,SB=Wl,kB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("map",function(e){return bB(kB(this),e,arguments.length>1?arguments[1]:void 0,function(t,n){return new(SB(t))(n)})});var TB=dv.left,IB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("reduce",function(e){var t=arguments.length;return TB(IB(this),e,t,t>1?arguments[1]:void 0)});var xB=dv.right,wB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("reduceRight",function(e){var t=arguments.length;return xB(wB(this),e,t,t>1?arguments[1]:void 0)});var CB=Ge.aTypedArray,EB=Ge.exportTypedArrayMethod,RB=Math.floor;EB("reverse",function(){for(var e,t=this,n=CB(t).length,i=RB(n/2),r=0;r<i;)e=t[r],t[r++]=t[--n],t[n]=e;return t});var aI=re,oI=qe,Mv=Ge,AB=nn,PB=O1,DB=Mt,sI=se,OB=aI.RangeError,Nv=aI.Int8Array,cI=Nv&&Nv.prototype,uI=cI&&cI.set,LB=Mv.aTypedArray,MB=Mv.exportTypedArrayMethod,Uv=!sI(function(){var e=new Uint8ClampedArray(2);return oI(uI,e,{length:1,0:3},1),e[1]!==3}),NB=Uv&&Mv.NATIVE_ARRAY_BUFFER_VIEWS&&sI(function(){var e=new Nv(2);return e.set(1),e.set("2",1),e[0]!==0||e[1]!==2});MB("set",function(e){LB(this);var t=PB(arguments.length>1?arguments[1]:void 0,1),n=DB(e);if(Uv)return oI(uI,this,n,t);var i=this.length,r=AB(n),o=0;if(r+t>i)throw OB("Wrong length");for(;o<r;)this[t+o]=n[o++]},!Uv||NB);var UB=Wl,VB=Ha,jB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("slice",function(e,t){for(var n=VB(jB(this),e,t),i=UB(this),r=0,o=n.length,c=new i(o);o>r;)c[r]=n[r++];return c},se(function(){new Int8Array(1).slice()}));var BB=rn.some,FB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("some",function(e){return BB(FB(this),e,arguments.length>1?arguments[1]:void 0)});var lI=Kn.match(/firefox\/(\d+)/i),HB=!!lI&&+lI[1],GB=/MSIE|Trident/.test(Kn),dI=Kn.match(/AppleWebKit\/(\d+)\./),zB=!!dI&&+dI[1],WB=pe,Vv=se,JB=Vt,qB=wy,hI=HB,KB=GB,fI=pr,pI=zB,XB=Ge.aTypedArray,QB=Ge.exportTypedArrayMethod,Sc=re.Uint16Array,Oo=Sc&&WB(Sc.prototype.sort),YB=!(!Oo||Vv(function(){Oo(new Sc(2),null)})&&Vv(function(){Oo(new Sc(2),{})})),mI=!!Oo&&!Vv(function(){if(fI)return fI<74;if(hI)return hI<67;if(KB)return!0;if(pI)return pI<602;var e,t,n=new Sc(516),i=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,i[e]=e-2*t+3;for(Oo(n,function(r,o){return(r/4|0)-(o/4|0)}),e=0;e<516;e++)if(n[e]!==i[e])return!0});QB("sort",function(e){return e!==void 0&&JB(e),mI?Oo(this,e):qB(XB(this),function(t){return function(n,i){return t!==void 0?+t(n,i)||0:i!=i?-1:n!=n?1:n===0&&i===0?1/n>0&&1/i<0?1:-1:n>i}}(e))},!mI||YB);var $B=yr,vI=ai,ZB=Wl,eF=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("subarray",function(e,t){var n=eF(this),i=n.length,r=vI(e,i);return new(ZB(n))(n.buffer,n.byteOffset+r*n.BYTES_PER_ELEMENT,$B((t===void 0?i:vI(t,i))-r))});var tF=Ji,gI=Ge,jv=se,_I=Ha,Kl=re.Int8Array,yI=gI.aTypedArray,nF=gI.exportTypedArrayMethod,bI=[].toLocaleString,rF=!!Kl&&jv(function(){bI.call(new Kl(1))});nF("toLocaleString",function(){return tF(bI,rF?_I(yI(this)):yI(this),_I(arguments))},jv(function(){return[1,2].toLocaleString()!=new Kl([1,2]).toLocaleString()})||!jv(function(){Kl.prototype.toLocaleString.call([1,2])}));var iF=Ge.exportTypedArrayMethod,aF=se,oF=pe,SI=re.Uint8Array,sF=SI&&SI.prototype||{},Xl=[].toString,cF=oF([].join);aF(function(){Xl.call({})})&&(Xl=function(){return cF(this)});var uF=sF.toString!=Xl;iF("toString",Xl,uF);var lF=function(){function e(t,n,i){Q(this,e),this.isUplink_=i,this.connection_=t,this.log_=n,this.seiMessageList_=[],this.smallVideoSeiMessageList_=[],this.seiPayloadType_=243,this.runningAbortMap_=new Map,this.abortMap_=new Map,this.onSEIMessage=null}return xe(e,[{key:"isRunning",get:function(){return!!this.runningAbortMap_.size>0}},{key:"start",value:function(t){var n=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.seiMessageList_,r=t.createEncodedStreams(),o=r.readable,c=r.writable,a=new TransformStream({transform:this.isUplink_?function(l,u){return n.encodeVideoFrame(l,u,i)}:function(l,u){var h,b;return n.decodeVideoFrame(l,u,t===((h=n.connection_)===null||h===void 0||(b=h.getPeerConnection())===null||b===void 0?void 0:b.getReceivers()[tS]))}}),s=new AbortController;o.pipeThrough(a).pipeTo(c,{signal:s.signal}).catch(function(){}),this.runningAbortMap_.set(t,s)}},{key:"restart",value:function(t,n){this.stop(),this.start(t,n)}},{key:"stop",value:function(t){var n;(n=this.runningAbortMap_.get(t))===null||n===void 0||n.abort(),this.runningAbortMap_.delete(t)}},{key:"destroy",value:function(){this.stop(),this.runningAbortMap_.forEach(function(t){return t.abort()}),this.runningAbortMap_.clear(),this.abortMap_.forEach(function(t){return t.abort()}),this.abortMap_.clear(),this.log_=null,this.onSEIMessage=null,this.connection_=null}},{key:"handleEncodedStreams",value:function(){var t=this;try{var n=this.connection_.getPeerConnection();this.clearUnusedSenderOrReceiver(n),this.isUplink_?n.getSenders().forEach(function(i,r){if(!t.runningAbortMap_.has(i)&&!t.abortMap_.has(i))if(r===lN||r===eS){var o=r===eS?t.smallVideoSeiMessageList_:t.seiMessageList_;t.isRunning?t.restart(i,o):t.start(i,o)}else t.pipeSenderOrReceiver(i)}):n.getReceivers().forEach(function(i,r){var o;t.runningAbortMap_.has(i)||t.abortMap_.has(i)||(r!==dN&&r!==tS||((o=i.track)===null||o===void 0?void 0:o.kind)!==Ie?t.pipeSenderOrReceiver(i):t.isRunning?t.restart(i):t.start(i))})}catch(i){this.log_.warn(i)}}},{key:"pipeSenderOrReceiver",value:function(t){var n=t.createEncodedStreams(),i=n.readable,r=n.writable,o=new AbortController;this.abortMap_.set(t,o),i.pipeTo(r,{signal:o.signal}).catch(function(){})}},{key:"clearUnusedSenderOrReceiver",value:function(t){var n=this;this.abortMap_.forEach(function(i,r){(n.isUplink_?t.getSenders():t.getReceivers()).find(function(o){return o===r})||(i.abort(),n.abortMap_.delete(r))})}},{key:"push",value:function(t,n){n&&n.seiPayloadType&&(this.seiPayloadType_=n.seiPayloadType),this.seiMessageList_.push(t),this.smallVideoSeiMessageList_.push(t)}},{key:"hasSEI",value:function(t){var n=new DataView(t);return n.getInt32(0)===1&&n.getInt8(4)===6}},{key:"isEmptyFrame",value:function(t){return t.type==="empty"||t.data.byteLength===0}},{key:"getNaluCount",value:function(t){for(var n=0,i=0,r=new DataView(t),o=0;o<t.byteLength;o++)switch(r.getUint8(o)){case 0:n++;break;case 1:n!==2&&n!==3||i++,n=0;break;default:n=0}return i}},{key:"encodeVideoFrame",value:function(t,n,i){try{if(this.connection_.isH264&&i.length>0&&!this.isEmptyFrame(t)){var r=9-this.getNaluCount(t.data);if(r<=0)return;for(var o=i.splice(0,r).reverse().map(this.encodeSEINalu.bind(this)),c=o.reduce(function(R,x){return R+x.dataView.byteLength},0),a=new ArrayBuffer(c+t.data.byteLength),s=new DataView(a),l=new DataView(t.data),u=0,h=0;h<o.length;h++)for(var b=0;b<o[h].dataView.byteLength;b++)s.setInt8(u++,o[h].dataView.getInt8(b));for(var I=0;I<t.data.byteLength;I++)s.setInt8(u++,l.getInt8(I));t.data=a,this.log_.debug("".concat(o.length," sei sent"))}}catch(R){this.log_.warn(R)}n.enqueue(t)}},{key:"decodeVideoFrame",value:function(t,n){var i=this,r=arguments.length>2&&arguments[2]!==void 0&&arguments[2];try{if(this.connection_.isH264&&!this.isEmptyFrame(t)&&this.hasSEI(t.data)){for(var o=[],c=new DataView(t.data),a=0,s=-1,l=-1,u=0;u<t.data.byteLength;u++){var h=c.getUint8(u);if(h===0)a++;else if(h===1){if(a===2||a===3){var b=u-a;s===-1?s=b:l===-1&&(l=b,o.push(new kI(new DataView(c.buffer.slice(s,l)))),s=b,l=-1);var I=c.getUint8(u+1)===6;if(!I){t.data=new DataView(c.buffer.slice(b)).buffer;break}}a=0}else a=0}this.log_.debug("".concat(o.length," sei received")),ln(this.onSEIMessage)&&o.reverse().forEach(function(R){i.onSEIMessage({seiPayloadType:R.seiPayloadType,data:R.seiPayload.buffer,isFromAuxiliary:r})})}}catch(R){this.log_.warn(R)}n.enqueue(t)}},{key:"encodeSEINalu",value:function(t){var n=t.byteLength,i=parseInt(n/255),r=n%255,o=[];o.push(0,0,0,1,6,this.seiPayloadType_);for(var c=0;c<i;c++)o.push(255);o.push(r);var a=new DataView(t);return o.push.apply(o,Se(new Uint8Array(a.buffer))),o.push(128),new kI(new DataView(new Uint8Array(o).buffer),!0)}}]),e}(),kI=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];Q(this,e),this.dataView=t,this.isSEI&&(n?this.addPreventionByte():this.removePreventionByte())}return xe(e,[{key:"addPreventionByte",value:function(){for(var t=this.seiPayloadStartIndex,n=this.dataView.byteLength-2,i=[],r=0,o=t;o<=n;o++){var c=this.dataView.getInt8(o);switch(c){case 0:case 1:case 2:case 3:r===2&&(i.push(3),r=0),c==0?r++:r=0,i.push(c);break;default:r=0,i.push(c)}}i.push(this.dataView.getInt8(this.dataView.byteLength-1));var a=new DataView(new Uint8Array([].concat(Se(new Uint8Array(this.dataView.buffer).slice(0,t)),i)).buffer);this.dataView=a}},{key:"removePreventionByte",value:function(){for(var t=this.seiPayloadStartIndex,n=this.dataView.byteLength-1,i=[],r=0,o=t;o<=n;o++)switch(this.dataView.getInt8(o)){case 0:r++,i.push(this.dataView.getInt8(o));break;case 3:r!==2&&i.push(this.dataView.getInt8(o)),r=0;break;default:i.push(this.dataView.getInt8(o)),r=0}var c=new DataView(new Uint8Array([].concat(Se(new Uint8Array(this.dataView.buffer).slice(0,t)),i)).buffer);this.dataView=c}},{key:"isSEI",get:function(){return this.dataView.getUint8(4)===6}},{key:"seiPayloadStartIndex",get:function(){for(var t=6,n=6;n<this.dataView.buffer.byteLength&&(t++,this.dataView.getUint8(n)===255);n++);return t}},{key:"seiPayloadType",get:function(){return this.isSEI?this.dataView.getUint8(5):null}},{key:"seiPayload",get:function(){if(!this.isSEI)return null;for(var t=0,n=6,i=6;i<this.dataView.buffer.byteLength;i++){var r=this.dataView.getUint8(i);if(n++,r!==255){t+=r;break}t+=255}for(var o=new ArrayBuffer(t),c=new DataView(o),a=0;a<o.byteLength;a++,n++)c.setInt8(a,this.dataView.getInt8(n));return c}}]),e}(),Bv=function(){function e(n){Q(this,e),this.userId_=n.userId,this.tinyId_=n.tinyId,this.client_=n.client,this.sdpSemantics_=n.client.getSdpSemantics(),this.isUplink_=n.isUplink,this.log_=_e.createLogger({id:"n|"+this.userId_,userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId(),isLocal:this.isUplink_}),this.signalChannel_=n.signalChannel,this.peerConnection_=null,this.isErrorObserved_=!1,this.emitter_=new ki,this.currentState_=on,this.waitForPeerConnectionConnectedPromise_=null,this.isReconnecting_=!1,this.reconnectionCount_=0,this.reconnectionTimer_=-1,this.isFirstConnection_=!0,this.delay_={audioDelay:0,videoDelay:0},this.enableSEI_=n.enableSEI,this.enableSEI_&&Tm&&(this.sei_=new lF(this,this.log_,this.isUplink_))}var t;return xe(e,[{key:"initialize",value:function(){var n={encodedInsertableStreams:this.enableSEI_&&Tm,iceServers:this.client_.getIceServers(),iceTransportPolicy:this.client_.getIceTransportPolicy(),sdpSemantics:this.sdpSemantics_,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};this.peerConnection_=new RTCPeerConnection(n),this.peerConnection_.onconnectionstatechange=this.onConnectionStateChange.bind(this)}},{key:"close",value:function(){this.log_.info("closing connection"),this.closePeerConnection(),this.sei_&&(this.sei_.destroy(),this.sei_=null)}},{key:"closePeerConnection",value:function(){var n=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.peerConnection_&&(this.peerConnection_.onconnectionstatechange=function(){},this.peerConnection_.close(),this.peerConnection_=null,n&&this.emitConnectionStateChangedEvent(on))}},{key:"getDTLSTransportState",value:function(){if(!this.peerConnection_)return Wu;var n=null;if(this.isUplink_){if(!ml()||this.peerConnection_.getSenders().length===0)return Wu;n=this.peerConnection_.getSenders()[0].transport}else{if(!Fk()||this.peerConnection_.getReceivers().length===0)return Wu;n=this.peerConnection_.getReceivers()[0].transport}return n?n.state:Wu}},{key:"onConnectionStateChange",value:function(n){var i=this.peerConnection_.iceConnectionState,r=this.getDTLSTransportState();if(this.log_.info("onConnectionStateChange() connectionState: "+n.target.connectionState),this.log_.info("ICE Transport state: ".concat(i,", DTLS Transport state: ").concat(r)),n.target.connectionState===Ju&&this.emitConnectionStateChangedEvent(bb),n.target.connectionState===Sb||n.target.connectionState===Bf){var o="".concat(this.isUplink_?"uplink":"downlink"," ICE/DTLS Transport connection ").concat(n.target.connectionState,". ICE Transport state: ").concat(i,", DTLS Transport state: ").concat(r),c=new te({message:o,code:Z.ICE_TRANSPORT_ERROR});ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Lb,error:c}),this.emitConnectionStateChangedEvent(on),this.isErrorObserved_||this.emitter_.emit(et.ERROR,c)}n.target.connectionState!==kb&&n.target.connectionState!==ZM||(this.logSelectedCandidate(),ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Lb}),this.emitConnectionStateChangedEvent(sn))}},{key:"emitConnectionStateChangedEvent",value:function(n){n!==this.currentState_&&(this.currentState_===jf&&n===bb||(Y.emit(hl,{client:this.client_,connection:this,prevState:this.currentState_,state:n}),this.emitter_.emit(et.CONNECTION_STATE_CHANGED,{prevState:this.currentState_,state:n}),this.currentState_=n))}},{key:"hitTest",value:function(n){return(n===0||n==="0")&&this.isUplink_||n===this.tinyId_}},{key:"addEventInternal",value:function(n,i){var r=this.client_.getUserId(),o={eventId:n,eventDesc:i,timestamp:an(),userId:r,tinyId:this.client_.getTinyId()};this.isUplink_||(o.remoteUserId=this.userId_,o.remoteTinyId=this.tinyId_),vn(r,o)}},{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=H(f().mark(function n(){var i,r,o,c,a,s,l;return f().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.peerConnection_){u.next=2;break}return u.abrupt("return");case 2:return u.next=4,this.peerConnection_.getStats();case 4:i=u.sent,r=ae(i),u.prev=6,r.s();case 8:if((o=r.n()).done){u.next=18;break}if((c=Te(o.value,2))[0],!Im(a=c[1])){u.next=16;break}return s=i.get(a.localCandidateId),l=i.get(a.remoteCandidateId),s&&this.log_.info("local candidate: ".concat(s.candidateType," ").concat(s.protocol,":").concat(s.ip||s.address,":").concat(s.port," ").concat(s.networkType||""," ").concat(s.candidateType==="relay"?"relayProtocol:"+s.relayProtocol:"")),l&&this.log_.info("remote candidate: ".concat(l.candidateType," ").concat(l.protocol,":").concat(l.ip||l.address,":").concat(l.port)),u.abrupt("break",18);case 16:u.next=8;break;case 18:u.next=23;break;case 20:u.prev=20,u.t0=u.catch(6),r.e(u.t0);case 23:return u.prev=23,r.f(),u.finish(23);case 26:case"end":return u.stop()}},n,this,[[6,20,23,26]])})),function(){return t.apply(this,arguments)})},{key:"getCurrentState",value:function(){return this.currentState_}},{key:"waitForPeerConnectionConnected",value:function(){var n=this;return this.waitForPeerConnectionConnectedPromise_||(this.waitForPeerConnectionConnectedPromise_=new Promise(function(i,r){if(n.currentState_===sn)return i();var o=-1,c=function(l){l.state===sn&&(clearTimeout(o),s(),i())},a=function(l){l.client===n.client_&&(clearTimeout(o),s(),r(new te({code:Z.API_CALL_ABORTED,message:ie({key:r4,data:"leave room"})})))},s=function(){Y.off(mo,a,n),n.emitter_.off(et.CONNECTION_STATE_CHANGED,c,n)};o=setTimeout(function(){s();var l=new te({code:Z.API_CALL_TIMEOUT,message:"connection timeout"});r(l)},1e4),Y.on(mo,a,n),n.emitter_.on(et.CONNECTION_STATE_CHANGED,c,n)}),this.waitForPeerConnectionConnectedPromise_=this.waitForPeerConnectionConnectedPromise_.then(function(i){return n.waitForPeerConnectionConnectedPromise_=null,i}).catch(function(i){throw n.waitForPeerConnectionConnectedPromise_=null,i})),this.waitForPeerConnectionConnectedPromise_}},{key:"getReconnectionCount",value:function(){return this.reconnectionCount_}},{key:"startReconnection",value:function(){this.isReconnecting_=!0,this.emitConnectionStateChangedEvent(jf),this.reconnect(),this.addEventInternal(this.isUplink_?fV:vV,"".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(ac,this.reconnect,this)}},{key:"on",value:function(n,i,r){this.emitter_.on(n,i,r)}},{key:"off",value:function(n,i,r){this.emitter_.off(n,i,r)}},{key:"setDelay",value:function(n){var i=n.audioDelay,r=n.videoDelay;this.delay_={audioDelay:i,videoDelay:r}}},{key:"getDelay",value:function(){return this.delay_}},{key:"isH264",get:function(){var n,i;if((n=this.peerConnection_)!==null&&n!==void 0&&(i=n.remoteDescription)!==null&&i!==void 0&&i.sdp)return!!this.peerConnection_.remoteDescription.sdp.includes("H264");var r=this.client_.getSystemResult().detail,o=r.isH264EncodeSupported,c=r.isH264DecodeSupported;return this.isUplink_?o:c}}]),e}(),dF=function(){function e(){Q(this,e),this.set_=new Set,Y.on(ul,this.add,this),Y.on(po,this.add,this),Y.on(sa,this.delete,this),Y.on(mo,this.delete,this)}return xe(e,[{key:"add",value:function(t){var n=t.client,i=t.roomId,r=this.getKey(n.getUserId(),i||n.getRoomId(),n.getSDKAppId(),n.getUseStringRoomId());this.set_.add(r)}},{key:"delete",value:function(t){var n=t.client,i=this.getKey(n.getUserId(),n.getRoomId(),n.getSDKAppId(),n.getUseStringRoomId());this.set_.delete(i)}},{key:"getKey",value:function(t,n,i,r){return"".concat(i,"_").concat(n,"_").concat(t,"_").concat(r)}},{key:"isJoined",value:function(t){var n=t.userId,i=t.roomId,r=t.sdkAppId,o=t.client;return this.set_.has(this.getKey(n,i,r,o.getUseStringRoomId()))}}]),e}(),hF=new dF;function TI(e,t,n,i){if(this.useStringRoomId_){if(!(Bt(e)&&/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e)))throw new te({code:Z.INVALID_PARAMETER,message:ie({key:VN,data:t,link:{className:i,fnName:n}})})}else if(!(tr(e)&&/^[1-9]\d*$/.test(String(e))&&e<4294967295))throw new te({code:Z.INVALID_PARAMETER,message:ie({key:jN,data:t,link:{className:i,fnName:n}})})}function II(e,t,n,i){if(!/^[A-Za-z\d_-]*$/.test(e))throw new te({code:Z.INVALID_PARAMETER,message:ie({key:t3,data:t,link:{className:i,fnName:n}})})}var fF={createClient:{name:"clientConfig",required:!0,type:xn,properties:{sdkAppId:{required:!0,type:wt,allowEmpty:!1},userId:{required:!0,type:dt,allowEmpty:!1},userSig:{required:!0,type:dt,allowEmpty:!1},mode:{required:!0,type:dt,values:["rtc",zu]},useStringRoomId:{type:Wt},autoSubscribe:{type:Wt},enableAutoPlayDialog:{type:Wt},streamId:{type:dt},userDefineRecordId:{type:dt},pureAudioPushMode:{type:wt,values:[1,2]},enableSEI:{type:Wt}}},createStream:{name:"streamConfig",required:!0,type:xn,properties:{userId:{type:dt},audio:{type:Wt},video:{type:Wt},screen:{type:Wt},screenAudio:{type:Wt},microphoneId:{type:dt},cameraId:{type:dt},facingMode:{type:[dt,xn]},audioSource:{instanceOf:window.MediaStreamTrack},videoSource:{instanceOf:window.MediaStreamTrack}},validate:function(e){if(!ge(e.screen)&&e.screen&&ge(e.audio)&&(e.audio=!1),!(ge(e.audio)&&ge(e.video)||ge(e.audioSource)&&ge(e.videoSource)))throw new te({code:Z.INVALID_PARAMETER,message:ie({key:U3})});if(!ge(e.screen)&&e.screen===!0&&e.video===!0)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:V3})});if(e.audio&&e.screenAudio)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:j3})});if(e.screen!==!0&&e.screenAudio===!0)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:B3})});if(!ge(e.screen)&&e.screen===!0&&!this.isScreenShareSupported())throw new te({code:Z.INVALID_OPERATION,message:ie({key:G3})})}}},pF={join:{name:"options",required:!0,type:xn,properties:{roomId:{required:!0,type:[wt,dt],allowEmpty:!1,validate:TI},role:{type:[dt],values:[Tr,Zi]},privateMapKey:{type:[dt]}},validate:function(e){if(this.isJoined_)throw new te({code:Z.INVALID_OPERATION,message:ie({key:UN})});if(this.checkDestroy(),hF.isJoined({userId:this.userId_,roomId:e.roomId,sdkAppId:this.sdkAppId_,client:this}))throw new te({code:Z.INVALID_OPERATION,message:ie({key:I3,data:this.userId_})})}},publish:[{name:"stream",required:!0,instanceOf:vi,validate:function(e){if(!this.isJoined_)throw new te({code:Z.INVALID_OPERATION,message:ie({key:GN})});if(this.mode_===zu&&this.role_===Zi)throw new te({code:Z.INVALID_OPERATION,message:ie({key:WN})});if(!e.getIsReadyToPublish())throw new te({code:Z.INVALID_OPERATION,message:ie({key:JN})});if(this.notPublishWithoutH264Supported_)throw new te({code:Z.NOT_SUPPORTED_H264,message:ie({key:gS})})}},{name:"options",type:xn,defaultValue:{isAuxiliary:!1},properties:{isAuxiliary:{type:Wt,defaultValue:!1,validate:function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(e&&!vl())throw new te({code:Z.NOT_SUPPORTED,message:ie({key:z3})});if(this.uplinkConnection_&&(e&&this.uplinkConnection_.isAuxStreamPublished||!e&&this.uplinkConnection_.isMainStreamPublished))throw new te({code:Z.INVALID_OPERATION,message:ie({key:qN,data:e?gt:"local"})});var t=this.localScreenStream_||Se(this.connections_.values()).findIndex(function(n){return n.getTrackState().auxiliary})>=0;if(!this.enableMultiAuxStream_&&e&&t)throw new te({code:Z.INVALID_OPERATION,message:ie({key:i4})})}}}}],unpublish:{name:"stream",required:!0,instanceOf:vi,validate:function(e){if(e!==this.localStream_&&e!==this.localAuxStream_){if(this.localStream_||this.localAuxStream_)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:zN})});this.log_.warn("Client currently has no published stream, please call publish() first.")}}},subscribe:[{name:"stream",required:!0,instanceOf:Xf,validate:function(e){if(!e.getConnection())throw new te({code:Z.INVALID_OPERATION,message:ie({key:ep})});if(this.notSubscribeWithoutH264Supported_)throw new te({code:Z.NOT_SUPPORTED_H264,message:ie({key:_S})})}},{name:"options",type:xn,properties:{audio:{type:Wt},video:{type:Wt},smallVideo:{type:Wt}},validate:function(e){var t=e.audio,n=e.video,i=e.smallVideo;if(t===!1&&n===!1&&(ge(i)||i===!1))throw new te({code:Z.INVALID_OPERATION,message:ie({key:Q3})})}}],unsubscribe:{name:"stream",required:!0,instanceOf:Xf,validate:function(e){if(!e.getConnection())throw new te({code:Z.INVALID_OPERATION,message:ie({key:ep})})}},switchRole:{name:"role",required:!0,values:[Tr,Zi],validate:function(){if(this.mode_!==zu)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:XN})});if(!this.isJoined_)throw new te({code:Z.INVALID_OPERATION,message:ie({key:QN})})}},startPublishCDNStream:{name:"options",required:!1,properties:{streamId:{type:dt,validate:II},streamType:{type:dt,values:["main","auxiliary"]},appId:{type:wt,allowEmpty:!1},bizId:{type:wt,allowEmpty:!1},url:{type:dt,allowEmpty:!1}},validate:function(){if(this.isDestroyed_)throw new te({code:Z.INVALID_OPERATION,message:ie({key:tp,data:{funName:"startPublishCDNStream"}})})}},startMixTranscode:{name:"config",required:!0,type:xn,properties:{mode:{type:dt,values:["preset-layout","manual"]},streamId:{type:dt,validate:II},videoWidth:{type:wt,notLessThanZero:!0},videoHeight:{type:wt,notLessThanZero:!0},videoBitrate:{type:wt,notLessThanZero:!0,allowEmpty:!1},videoFramerate:{type:wt,validate:function(e,t,n,i){if(e<=0||e>30)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:R3,link:{className:i,fnName:n}})})}},videoGOP:{type:wt,validate:function(e,t,n,i){if(e<1||e>8)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:A3,link:{className:i,fnName:n}})})}},audioSampleRate:{type:wt,notLessThanZero:!0},audioBitrate:{type:wt,validate:function(e,t,n,i){if(e<32||e>192)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:P3,link:{className:i,fnName:n}})})}},audioChannels:{type:wt,values:[1,2]},backgroundColor:{type:wt},backgroundImage:{type:dt},mixUsers:{required:!0,type:zb,arrayItem:{require:!0,type:xn,properties:{userId:{required:!0,type:dt},roomId:{type:[dt,wt],validate:TI},pureAudio:{type:Wt},width:{type:wt,notLessThanZero:!0},height:{type:wt,notLessThanZero:!0},locationX:{type:wt,notLessThanZero:!0},locationY:{type:wt,notLessThanZero:!0},zOrder:{type:wt},streamType:{type:dt,values:["main","auxiliary"]},renderMode:{type:wt,values:[0,1,2,4]}}}}},validate:function(e,t,n,i,r){var o=0,c=0,a=e.mixUsers,s=[];if(a.forEach(function(l,u){if(s.push(l.userId),!l.pureAudio){if(!l.zOrder||l.zOrder<1||l.zOrder>15)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:D3,data:"config.mixUsers[".concat(u,"].zOrder"),link:{className:i,fnName:n}})});l.width+l.locationX>o&&(o=l.width+l.locationX),l.height+l.locationY>c&&(c=l.height+l.locationY)}}),s.indexOf(this.getUserId())<0)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:O3,link:{className:i,fnName:n}})});if(e.videoWidth<o||e.videoHeight<c)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:L3,link:{className:i,fnName:n}})})}},sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate:function(e){if(!Tm)throw new te({code:Z.NOT_SUPPORTED,message:ie({key:bS})});if(!this.enableSEI_)throw new te({code:Z.INVALID_OPERATION,message:ie({key:Y3})});if(e.byteLength>1e3)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:Z3,data:e.byteLength})});if(e.byteLength===0)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:$3})});if(!this.uplinkConnection_||!this.localStream_)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:e4})});if(!this.localStream_.hasVideo())throw new te({code:Z.INVALID_OPERATION,message:ie({key:t4})});var t=this.uplinkConnection_.isH264;if(!t)throw new te({code:Z.NOT_SUPPORTED,message:ie({key:bS,data:t})})}},{name:"options",type:xn,properties:{seiPayloadType:{type:wt,values:[5,243]}}}]},mF={switchDevice:[{name:"type",required:!0,type:dt,values:[Re,Ie]},{name:"deviceId",required:!0,type:dt,validate:function(){if(this.screen_&&!this.audio_||this.audioSource_||this.videoSource_)throw new te({code:Z.INVALID_OPERATION,message:ie({key:l3})});if(this.publishState_===$s)throw new te({code:Z.INVALID_OPERATION,message:ie({key:d3})});if(!km())throw new te({code:Z.NOT_SUPPORTED,message:ie({key:H3})})}}],setAudioCaptureVolume:{name:"volume",type:wt}},vF={play:[{name:"elementId",required:!0,type:[dt,"HTMLDivElement"],validate:function(e,t,n){if(Bt(e)){var i=document.getElementById(e);if(!i)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:M3,data:{key:t,fnName:n}})});if(!(i instanceof HTMLDivElement))throw new te({code:Z.INVALID_PARAMETER,message:ie({key:N3,data:{key:t,fnName:n,type:Si(i)}})})}}},{name:"options",type:xn,properties:{objectFit:{type:dt,values:["contain","cover","fill"]},muted:{type:Wt},mirror:{type:Wt}}}],addTrack:{name:Nf,instanceOf:window.MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new te({code:Z.INVALID_OPERATION,message:ie({key:f3})});if(this.isRemovingTrack_)throw new te({code:Z.INVALID_OPERATION,message:ie({key:p3})});if(this.publishState_===$s)throw new te({code:Z.INVALID_OPERATION,message:ie({key:m3})});var t=this.getMediaStream();if(!t)throw new te({code:Z.INVALID_OPERATION,message:ie({key:pS})});if(e.kind===Re&&t.getAudioTracks().length>0||e.kind===Ie&&t.getVideoTracks().length>0)throw new te({code:Z.INVALID_OPERATION,message:ie({key:v3})});if(!Ii()&&!ml())throw new te({code:Z.NOT_SUPPORTED,message:ie({key:rp,data:gb})})}},removeTrack:{name:Nf,instanceOf:window.MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new te({code:Z.INVALID_OPERATION,message:ie({key:_3})});if(this.isRemovingTrack_)throw new te({code:Z.INVALID_OPERATION,message:ie({key:y3})});if(this.publishState_===$s)throw new te({code:Z.INVALID_OPERATION,message:ie({key:b3})});var t=this.getMediaStream();if(!t)throw new te({code:Z.INVALID_OPERATION,message:ie({key:pS})});if(t.getTracks().indexOf(e)===-1)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:S3})});if(!Ii()){if(t.getTracks().length===1)throw new te({code:Z.INVALID_OPERATION,message:ie({key:k3})});if(e.kind===Re)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:g3})});if(!ml())throw new te({code:Z.NOT_SUPPORTED,message:ie({key:rp,data:_b})})}}},replaceTrack:{name:Nf,instanceOf:window.MediaStreamTrack,validate:function(e){var t=this.getMediaStream();if(!t)throw new te({code:Z.INVALID_OPERATION,message:ie({key:h3})});if(this.publishState_===$s)throw new te({code:Z.INVALID_OPERATION,message:ie({key:fS})});if(e.kind===Re&&t.getAudioTracks().length<=0||e.kind===Ie&&t.getVideoTracks().length<=0)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:T3,data:e})});if(!km())throw new te({code:Z.NOT_SUPPORTED,message:ie({key:rp,data:FM})})}}},Yt={TRTC:fF,CLIENT:pF,LOCAL_STREAM:mF,STREAM:vF};function Ql(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(i,r,o){var c=o.value;return o.value=function(){for(var a=arguments.length,s=new Array(a),l=0;l<a;l++)s[l]=arguments[l];return xI.call(this,t,s,r,this.name_),c.apply(this,s)},o}}function fn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(i,r,o){var c=o.value;return o.value=H(f().mark(function a(){var s,l,u,h=arguments;return f().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:for(s=h.length,l=new Array(s),u=0;u<s;u++)l[u]=h[u];return xI.call(this,t,l,r,this.name_),b.abrupt("return",c.apply(this,l));case 3:case"end":return b.stop()}},a,this)})),o}}function xI(e,t,n,i){try{for(var r=0;r<e.length;r++)Fv.call(this,{rule:e[r],value:t[r],key:e[r].name,fnName:n,className:i})}catch(o){throw _e.error(o),o}}function Fv(e){var t=this,n=e.rule,i=e.value,r=e.key,o=e.fnName,c=e.className;if(ge(i)){if(n.required)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:SN,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(ge(n.defaultValue))return;i=n.defaultValue}if(Array.isArray(n.type)){if(!n.type.map(function(h){return h.toLowerCase()}).includes(Si(i)))throw new te({code:Z.INVALID_PARAMETER,message:ie({key:sS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})})}else if(!ge(n.type)&&Si(i)!==n.type)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:sS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(n.allowEmpty===!1){var a=tr(i)&&(i===0||Number.isNaN(i)),s=Bt(i)&&i.trim()==="";if(a||s)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:kN,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})})}if(n.notLessThanZero&&tr(i)&&i<0)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:E3,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(Bt(n.instanceOf)){if(!i||i.name_!==n.instanceOf)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:cS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})})}else if(ln(n.instanceOf)&&!(i instanceof n.instanceOf))throw new te({code:Z.INVALID_PARAMETER,message:ie({key:cS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(n.values&&!n.values.includes(i))throw new te({code:Z.INVALID_PARAMETER,message:ie({key:TN,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});var l=n.properties;bi(l)&&US(i)&&Object.keys(l).forEach(function(h){Fv.call(t,{rule:l[h],value:i&&i[h],key:"".concat(r,".").concat(h),fnName:o,className:c})});var u=n.arrayItem;bi(u)&&ho(i)&&i.forEach(function(h,b){Fv.call(t,{rule:u,value:h,key:"".concat(r,"[").concat(b,"]"),fnName:o,className:c})}),ln(n.validate)&&n.validate.call(this,i,r,o,c,this)}Le({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var gF=Le,_F=se,yF=oh.f;gF({target:"Object",stat:!0,forced:_F(function(){return!Object.getOwnPropertyNames(1)})},{getOwnPropertyNames:yF});var wI,kc,bF=tT;function Lo(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{retries:5,timeout:2e3};return function(t,n,i){var r=ic({retryFunction:i.value,settings:e,onError:e.onError,onRetrying:e.onRetrying,onRetryFailed:e.onRetryFailed});return i.value=function(){for(var o=arguments.length,c=new Array(o),a=0;a<o;a++)c[a]=arguments[a];return r.apply(this,c)},i}}Le({target:"Array",stat:!0,forced:!vu(function(e){Array.from(e)})},{from:bF});var CI,EI,RI,cr,ga=5e3,SF={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},Hv=xe(function e(t){Q(this,e),this.str_identifier=String(t.userId),this.uint64_tinyid=Number(t.tinyId),this.uint32_role=t.role}),kF=(wI=Lo({timeout:500,retries:3}),kc=function(){function e(r){var o=this;Q(this,e),this.frameWorkType_=r.frameWorkType||30,this.component_=r.component||0,this.client_=r.client,this.keyPrefix_="key_point",this.storageKey_="".concat(this.keyPrefix_,"_").concat(this.client_.getUserId()),this.log_=_e.createLogger({id:"kpm|"+this.client_.getUserId(),userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId()}),Object.getOwnPropertyNames(this.__proto__).forEach(function(c){c.startsWith("handle")&&ln(o[c])&&(o[c]=function(a){var s=a.fn,l=a.context;return H(f().mark(function u(){var h,b,I,R=arguments;return f().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:for(x.prev=0,h=R.length,b=new Array(h),I=0;I<h;I++)b[I]=R[I];return x.next=4,s.apply(l||this,b);case 4:return x.abrupt("return",x.sent);case 7:x.prev=7,x.t0=x.catch(0),_e.error("".concat(s.name,"() error observed ")+x.t0);case 10:case"end":return x.stop()}},u,this,[[0,7]])}))}({fn:o[c],context:o}))}),this.initData(),this.installEvents(),this.intervalId_=mt.run(uo,this.setStorage.bind(this),{delay:2e4})}var t,n,i;return xe(e,[{key:"initData",value:function(){var r;this.firstPublishedUserList_=[],this.networkQuality_={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this.basicInfo={string_sdk_version:oi,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",string_domain:location.host,uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:((r=this.client_)===null||r===void 0?void 0:r.getMode())==="live"?1:0,uint32_joining_duration:0,uint32_networkType:qf[Tp()],uint32_framework:this.frameWorkType_,uint32_component:this.component_},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(){Y.on(ul,this.handleJoinStart,this),Y.on(Mp,this.handleWSStart,this),Y.on(ll,this.handleWSEnd,this),Y.on(Ep,this.handleJoinSendCMD,this),Y.on(Rp,this.handleJoinReceivedCMDResponce,this),Y.on(po,this.handleJoinSuccess,this),Y.on(sa,this.handleJoinFailed,this),Y.on(Op,this.handleReceivedPublishUserList,this),Y.on(hl,this.handleConnectionStateChanged,this),Y.on(Ap,this.handleLeaveStart,this),Y.on(mo,this.handleLeaveSuccess,this),Y.on(Pp,this.handleLeaveSendCMD,this),Y.on(Qp,this.handleSendSubscribeCMD,this),Y.on(tc,this.handleVideoPlaying,this),Y.on(Vp,this.handleAudioPlaying,this),Y.on(Yp,this.handleNetworkQuality,this),Y.on(Dp,this.handleHeartbeatStats,this),Y.on(dl,this.handleRemoteStreamAdded,this),Y.on(jp,this.handleRemoteStreamSubscribeStart,this),Y.on(Ur,this.handleRemoteStreamSubscribed,this),Y.on(ca,this.handleRemoteStreamRemoved,this),Y.on(Wp,this.handleVideoLoadedData,this),Y.on(zp,this.handlePlayStream,this),Y.on(Lp,this.handlePublishStart,this),Y.on(Bp,this.handleLocalStreamInitStart,this),Y.on(Fp,this.handleLocalStreamInitEnd,this),Y.on(Hp,this.handleLocalStreamInitFailed,this)}},{key:"uninstallEvents",value:function(){Y.off(ul,this.handleJoinStart,this),Y.off(Mp,this.handleWSStart,this),Y.off(ll,this.handleWSEnd,this),Y.off(Ep,this.handleJoinSendCMD,this),Y.off(Rp,this.handleJoinReceivedCMDResponce,this),Y.off(Op,this.handleReceivedPublishUserList,this),Y.off(hl,this.handleConnectionStateChanged,this),Y.off(Ap,this.handleLeaveStart,this),Y.off(mo,this.handleLeaveSuccess,this),Y.off(po,this.handleJoinSuccess,this),Y.off(sa,this.handleJoinFailed,this),Y.off(Pp,this.handleLeaveSendCMD,this),Y.off(Qp,this.handleSendSubscribeCMD,this),Y.off(tc,this.handleVideoPlaying,this),Y.off(Vp,this.handleAudioPlaying,this),Y.off(Yp,this.handleNetworkQuality,this),Y.off(Dp,this.handleHeartbeatStats,this),Y.off(dl,this.handleRemoteStreamAdded,this),Y.off(jp,this.handleRemoteStreamSubscribeStart,this),Y.off(Ur,this.handleRemoteStreamSubscribed,this),Y.off(ca,this.handleRemoteStreamRemoved,this),Y.off(Wp,this.handleVideoLoadedData,this),Y.off(zp,this.handlePlayStream,this),Y.off(Lp,this.handlePublishStart,this),Y.off(Bp,this.handleLocalStreamInitStart,this),Y.off(Fp,this.handleLocalStreamInitEnd,this),Y.off(Hp,this.handleLocalStreamInitFailed,this)}},{key:"destroy",value:function(){this.uninstallEvents(),mt.clearTask(this.intervalId_),this.client_=null}},{key:"handleJoinStart",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_start_time===0&&(this.pathJoinRoom_.uint64_start_time=Date.now(),this.checkStorage())}},{key:"handleWSStart",value:function(r){var o=r.client;this.hitTest(o)&&this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_start_time===0&&(this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_start_time=Date.now())}},{key:"handleWSEnd",value:function(r){var o=r.client,c=r.error;this.hitTest(o)&&this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_end_time===0&&(this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_end_time=Date.now(),c&&(this.pathJoinRoom_.int32_send_request_acc_ip_cmd_ret=c instanceof te?Number(c.getExtraCode()||c.getCode()):Z.UNKNOWN,this.pathJoinRoom_.int32_end_ret=2))}},{key:"handleJoinSendCMD",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_send_request_enter_room_cmd_start_time===0&&(this.pathJoinRoom_.uint64_send_request_enter_room_cmd_start_time=Date.now())}},{key:"handleJoinReceivedCMDResponce",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_send_request_enter_room_cmd_end_time===0&&(this.pathJoinRoom_.uint64_send_request_enter_room_cmd_end_time=Date.now(),this.pathJoinRoom_.int32_send_request_enter_room_cmd_ret=r.code,r.code!==0&&(this.pathJoinRoom_.int32_end_ret=3))}},{key:"handleJoinSuccess",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_end_time===0&&(this.pathJoinRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.int32_end_ret=0)}},{key:"handleJoinFailed",value:function(r){var o=r.client;this.hitTest(o)&&(this.pathJoinRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.int32_end_ret===0&&(this.pathJoinRoom_.int32_end_ret=3),this.prepareReport(),this.report())}},{key:"handleReceivedPublishUserList",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_recv_userlist_time===0&&(this.pathJoinRoom_.uint64_recv_userlist_time=Date.now(),this.firstPublishedUserList_=r.data.data&&r.data.data.userList||[])}},{key:"handleConnectionStateChanged",value:function(r){var o=r.client,c=r.state,a=r.connection;if(this.hitTest(o)&&c===sn){this.client_.getUplinkConnection()===a&&this.pathJoinRoom_.uint64_send_first_video_frame_time===0&&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 s=this.pathMainVideoMap_.get("".concat(a.getUserId(),"_").concat(yt));s&&s.statsToReport.uint64_pc_connected_time===0&&(s.statsToReport.uint64_pc_connected_time=Date.now())}}},{key:"handleLeaveStart",value:function(r){this.hitTest(r.client)&&(this.pathLeaveRoom_.uint64_start_time=Date.now())}},{key:"handleLeaveSuccess",value:function(r){this.hitTest(r.client)&&this.pathLeaveRoom_.uint64_end_time===0&&(this.pathLeaveRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.uint64_end_time!==0?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(r){this.hitTest(r.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(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s),u=this.remoteStreamStatsMap_.get(l);if(u)u.stream=c;else{var h={userId:a,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:J({},SF),stream:c};h.statsToReport.msg_user_info=new Hv({userId:a,tinyId:c.getTinyId(),role:so}),h.statsToReport.uint32_stream_type=s===yt?2:7,this.remoteStreamStatsMap_.set(l,h)}}}},{key:"handleRemoteStreamSubscribeStart",value:function(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s),u=this.remoteStreamStatsMap_.get(l);u&&u.subscribeStartTime===0&&(u.subscribeStartTime=Date.now())}}},{key:"handleSendSubscribeCMD",value:function(r){if(this.hitTest(r.client)){var o=new Hv(r),c=Date.now(),a="".concat(r.userId,"_").concat(yt);r.trackState.video&&r.subscribeState.video&&!this.pathMainVideoMap_.has(a)&&this.pathMainVideoMap_.set(a,{statsToReport:{msg_user_info:o,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:r.userId,sendSubscribeCMDTime:c}),r.trackState.audio&&r.subscribeState.audio&&!this.pathMainAudioMap_.has(a)&&this.pathMainAudioMap_.set(a,{statsToReport:{msg_user_info:o,uint64_start_enter_time:this.pathJoinRoom_.uint64_start_time,uint64_play_first_frame_time:0},userId:r.userId,sendSubscribeCMDTime:c});var s="".concat(r.userId,"_").concat(Dt);r.trackState.auxiliary&&r.subscribeState.auxiliary&&!this.pathAuxiliaryMap_.has(s)&&this.pathAuxiliaryMap_.set(s,{sendSubscribeCMDTime:c})}}},{key:"handleRemoteStreamSubscribed",value:function(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s),u=this.remoteStreamStatsMap_.get(l);u&&u.subscribedTime===0&&(u.subscribedTime=Date.now(),u.stream=c)}}},{key:"handleRemoteStreamRemoved",value:function(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l=this.remoteStreamStatsMap_.get("".concat(a,"_").concat(s));l&&(l.stream=null)}}},{key:"handlePlayStream",value:function(r){var o=r.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var c=o.getConnection().getUserId(),a="".concat(c,"_").concat(o.getType());if(this.remoteStreamStatsMap_.has(a)){var s=this.remoteStreamStatsMap_.get(a);s.playStreamTime===0&&(s.playStreamTime=Date.now())}}}},{key:"handleVideoLoadedData",value:function(r){var o=r.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var c=o.getConnection().getUserId(),a="".concat(c,"_").concat(o.getType());if(this.pathMainVideoMap_.has(a)){var s=this.pathMainVideoMap_.get(a);s.statsToReport.uint64_combine_first_frame_time===0&&(s.statsToReport.uint64_combine_first_frame_time=Date.now())}}}},{key:"handleVideoPlaying",value:function(r){var o=r.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var c=o.getConnection().getUserId(),a="".concat(c,"_").concat(o.getType()),s=Date.now();if(this.pathMainVideoMap_.has(a)){var l=this.pathMainVideoMap_.get(a);if(l.statsToReport.uint64_render_first_frame_time===0&&(l.statsToReport.uint64_render_first_frame_time=s),this.remoteStreamStatsMap_.has(a)){var u=this.remoteStreamStatsMap_.get(a),h=u.statsToReport,b=u.playStreamTime,I=u.subscribedTime;h.uint32_video_render_first===0&&b-I<=100&&(h.uint32_video_render_first=s-l.sendSubscribeCMDTime)}}if(o.getType()===Dt&&this.pathAuxiliaryMap_.has(a)&&this.remoteStreamStatsMap_.has(a)){var R=this.remoteStreamStatsMap_.get(a),x=R.statsToReport,m=R.playStreamTime,k=R.subscribedTime;x.uint32_video_render_first===0&&m-k<=100&&(x.uint32_video_render_first=s-this.pathAuxiliaryMap_.get(a).sendSubscribeCMDTime)}}}},{key:"handleAudioPlaying",value:function(r){if(r.stream.isRemote()&&r.stream.getConnection()&&this.hitTest(r.stream.getConnection().getClient())){var o=r.stream.getConnection().getUserId(),c="".concat(o,"_").concat(r.stream.getType());if(this.pathMainAudioMap_.has(c)){var a=this.pathMainAudioMap_.get(c);a.statsToReport.uint64_play_first_frame_time===0&&(a.statsToReport.uint64_play_first_frame_time=Date.now())}}}},{key:"handleNetworkQuality",value:function(r){var o=this;this.hitTest(r.client)&&(this.networkQuality_.totalUplinkLoss+=r.uplinkLoss,this.networkQuality_.totalUplinkRTT+=r.uplinkRTT,this.networkQuality_.count++,r.downlinkLossAndRTTMap.forEach(function(c){var a=c.rtt,s=c.loss,l=c.userId,u=o.networkQuality_.totalDownlinkRTTAndLossMap.get(l);u?(u.totalRTT+=a,u.totalLoss+=s,u.count++):o.networkQuality_.totalDownlinkRTTAndLossMap.set(l,{totalRTT:a,totalLoss:s,count:1})}))}},{key:"handleHeartbeatStats",value:function(r){var o=this;if(this.hitTest(r.client)){var c=r.stats,a=c.msg_up_stream_info,s=c.msg_down_stream_info;if(a.msg_video_status[0]){var l=a.msg_video_status[0],u=l.uint32_video_codec_bitrate,h=l.uint32_video_enc_fps,b=l.uint32_video_width,I=l.uint32_video_height;this.localStreamStats_.totalVideoBitrate+=u,this.localStreamStats_.totalVideoFPS+=h,this.localStreamStats_.totalVideoWidth+=b,this.localStreamStats_.totalVideoHeight+=I,this.localStreamStats_.videoCount++}if(a.msg_audio_status){var R=a.msg_audio_status.audioLevel;Math.floor(100*R)>0&&(this.localStreamStats_.totalAudioLevel+=R,this.localStreamStats_.audioLevelCount++)}s.forEach(function(x){var m=x.msg_user_info,k=x.msg_audio_status,v=x.msg_video_status,w=m.str_identifier;if(v.forEach(function(T){var y=T.uint32_video_stream_type===2,D=T.uint32_video_stream_type===7,A="".concat(w,"_").concat(y?yt:Dt);if(o.remoteStreamStatsMap_.has(A)){var U,S,p=o.remoteStreamStatsMap_.get(A);(y&&(U=p.stream)!==null&&U!==void 0&&U.isMainVideoSubscribed||D&&(S=p.stream)!==null&&S!==void 0&&S.isAuxVideoSubscribed)&&(p.totalVideoFPS+=T.uint32_video_receive_fps,p.totalVideoBitrate+=T.uint32_video_codec_bitrate,p.videoCount++,p.statsToReport.uint32_video_width===0&&(p.statsToReport.uint32_video_width=T.uint32_video_width),p.statsToReport.uint32_video_height===0&&(p.statsToReport.uint32_video_height=T.uint32_video_height))}}),k){var L="".concat(w,"_").concat(yt);if(o.remoteStreamStatsMap_.has(L)){var E,N=o.remoteStreamStatsMap_.get(L);(E=N.stream)!==null&&E!==void 0&&E.isMainAudioSubscribed&&(N.totalAudioBitrate+=k.uint32_audio_codec_bitrate,N.audioCount++,Math.floor(100*k.audioLevel)>0&&(N.totalAudioLevel+=k.audioLevel,N.audioLevelCount++))}}})}}},{key:"handlePublishStart",value:function(r){var o=r.client;this.hitTest(o)&&this.localStreamStats_.publishStartTime===0&&(this.localStreamStats_.publishStartTime=Date.now())}},{key:"handleLocalStreamInitStart",value:function(r){var o=r.audio,c=r.video;o&&this.pathJoinRoom_.uint64_init_audio_start_time===0&&(this.pathJoinRoom_.uint64_init_audio_start_time=Date.now()),c&&this.pathJoinRoom_.uint64_init_camera_start_time===0&&(this.pathJoinRoom_.uint64_init_camera_start_time=Date.now())}},{key:"handleLocalStreamInitEnd",value:function(r){var o=r.audio,c=r.video;o&&this.pathJoinRoom_.uint64_init_audio_end_time===0&&(this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),c&&this.pathJoinRoom_.uint64_init_camera_end_time===0&&(this.pathJoinRoom_.uint64_init_camera_end_time=Date.now())}},{key:"handleLocalStreamInitFailed",value:function(r){var o=r.audio,c=r.video,a=r.error,s=a instanceof te?a.getExtraCode()||a.getCode():{NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5}[a.name]||Z.UNKNOWN;o&&this.pathJoinRoom_.uint64_init_audio_end_time===0&&(this.pathJoinRoom_.int32_init_audio_ret=s,this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),c&&this.pathJoinRoom_.uint64_init_camera_end_time===0&&(this.pathJoinRoom_.int32_init_camera_ret=s,this.pathJoinRoom_.uint64_init_camera_end_time=Date.now())}},{key:"hasVideoFlag",value:function(r){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===r&&1&o.flag})>=0}},{key:"hasAudioFlag",value:function(r){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===r&&8&o.flag})>=0}},{key:"hasAuxFlag",value:function(r){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===r&&4&o.flag})>=0}},{key:"hitTest",value:function(r){return r===this.client_}},{key:"checkStorage",value:(i=H(f().mark(function r(){var o;return f().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(c.prev=0,!(o=bo.getItem(this.storageKey_))){c.next=6;break}return c.next=5,this.upload(o);case 5:bo.deleteItem(this.storageKey_);case 6:c.next=11;break;case 8:c.prev=8,c.t0=c.catch(0),this.log_.warn(c.t0);case 11:case"end":return c.stop()}},r,this,[[0,8]])})),function(){return i.apply(this,arguments)})},{key:"setStorage",value:function(){this.prepareReport();var r=this.getReportData();r.msg_path_enter_room.uint64_start_time!==0&&bo.setItem(this.storageKey_,r)}},{key:"prepareReport",value:function(){var r=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 o=Math.floor(this.localStreamStats_.totalVideoWidth/this.localStreamStats_.videoCount),c=Math.floor(this.localStreamStats_.totalVideoHeight/this.localStreamStats_.videoCount);this.localStreamStats_.statsToReport.uint32_video_big_resolution=o<<16|c}this.localStreamStats_.audioLevelCount>0&&(this.localStreamStats_.statsToReport.uint32_audio_capture_db=Math.floor(this.localStreamStats_.totalAudioLevel/this.localStreamStats_.audioLevelCount*100)),this.remoteStreamStatsMap_.forEach(function(a,s){var l=a.userId;if(r.networkQuality_.totalDownlinkRTTAndLossMap.has(l)){var u=r.networkQuality_.totalDownlinkRTTAndLossMap.get(l),h=u.totalLoss,b=u.count;a.statsToReport.uint32_avg_down_loss=Math.floor(h/b)}a.videoCount>0&&(a.statsToReport.uint32_video_avg_fps=Math.floor(a.totalVideoFPS/a.videoCount),a.statsToReport.uint32_video_avg_bitrate=Math.floor(a.totalVideoBitrate/a.videoCount)),a.audioCount>0&&(a.statsToReport.uint32_audio_recv_bitrate=a.statsToReport.uint32_audio_bitrate=Math.floor(a.totalAudioBitrate/a.audioCount)),a.audioLevelCount>0&&(a.statsToReport.uint32_audio_play_db=Math.floor(a.totalAudioLevel/a.audioLevelCount*100));var I=r.client_.getCallDurationCalculator();I&&(a.statsToReport.uint32_audio_play_time=I.getDuration(s,Re),a.statsToReport.uint32_video_play_time=I.getDuration(s,Ie)),a.statsToReport.uint32_video_render_first=Math.min(a.statsToReport.uint32_video_render_first,ga);var R=r.client_.getBadCaseDetector();if(R){var x=R.getDataFreezeDuration(s),m=x.dataFreeze,k=x.count,v=R.getRenderFreezeDuration(s).renderFreeze;a.statsToReport.uint32_video_block_count=k,a.statsToReport.uint32_video_block_time=Math.min(m,a.statsToReport.uint32_video_play_time),a.statsToReport.uint32_video_external_block_time=Math.min(v,a.statsToReport.uint32_video_play_time),R.isBlackStream(s)&&a.statsToReport.uint32_video_avg_fps===0?a.statsToReport.uint32_video_black_screen_subjective=1:a.statsToReport.uint32_video_black_screen_subjective=0}(a.subscribeStartTime===0||a.subscribeStartTime-a.streamAddedTime>100||a.playStreamTime===0)&&(r.pathMainAudioMap_.delete(s),r.pathMainVideoMap_.delete(s),a.statsToReport.uint32_video_render_first=0)}),this.pathMainAudioMap_.forEach(function(a,s){r.hasAudioFlag(a.userId)?a.statsToReport.uint64_play_first_frame_time-a.statsToReport.uint64_start_enter_time>ga&&(a.statsToReport.uint64_play_first_frame_time=a.statsToReport.uint64_start_enter_time+ga):r.pathMainAudioMap_.delete(s)}),this.pathMainVideoMap_.forEach(function(a,s){r.hasVideoFlag(a.userId)?a.statsToReport.uint64_render_first_frame_time-a.statsToReport.uint64_start_enter_time>ga&&(a.statsToReport.uint64_render_first_frame_time=a.statsToReport.uint64_start_enter_time+ga):r.pathMainVideoMap_.delete(s)}),this.pathJoinRoom_.uint64_end_time-this.pathJoinRoom_.uint64_start_time>ga&&(this.pathJoinRoom_.uint64_end_time=this.pathJoinRoom_.uint64_start_time+ga)}},{key:"getReportData",value:function(){var r=this.client_.getSignalInfo();return{uint32_sdk_app_id:Number(this.client_.getSDKAppId()),msg_user_info:new Hv({userId:this.client_.getUserId(),tinyId:this.client_.getTinyId(),role:this.client_.getRole()===Tr?so:Vf}),msg_basic_info:this.basicInfo,uint32_acc_ip:xp(r.relayIp),uint32_client_ip:xp(r.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:Se(this.pathMainVideoMap_.values()).map(function(o){return o.statsToReport}),msg_quality_statistics:Se(this.remoteStreamStatsMap_.values()).map(function(o){return o.statsToReport}),str_room_name:String(this.client_.getRoomId()),msg_path_recv_audio:Se(this.pathMainAudioMap_.values()).map(function(o){return o.statsToReport}),uint32_info_client_ip:xp(r.clientIp,"small"),error_code:[],msg_local_statistics:this.localStreamStats_.statsToReport,msg_function_state:Ai.getStateArray()}}},{key:"report",value:(n=H(f().mark(function r(){var o;return f().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,o=this.getReportData(),c.next=4,this.upload(o);case 4:bo.deleteItem(this.storageKey_),Ai.clearStateArray(),this.initData(),c.next=12;break;case 9:c.prev=9,c.t0=c.catch(0),this.log_.warn(c.t0);case 12:case"end":return c.stop()}},r,this,[[0,9]])})),function(){return n.apply(this,arguments)})},{key:"upload",value:(t=H(f().mark(function r(o){var c,a,s;return f().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(!(ra||o.msg_path_enter_room.uint64_start_time===0||[Qf,Qb,Yb].findIndex(function(u){return u===location.host})>=0)){l.next=2;break}return l.abrupt("return");case 2:return c=Number(this.client_.getSDKAppId()),a=ol(c,qM),l.next=6,cl({url:a,body:JSON.stringify(o)});case 6:if((s=l.sent).data==="ok"){l.next=9;break}throw"key point upload failed: ".concat(s.data);case 9:case"end":return l.stop()}},r,this)})),function(r){return t.apply(this,arguments)})}]),e}(),K(kc.prototype,"upload",[wI],Object.getOwnPropertyDescriptor(kc.prototype,"upload"),kc.prototype),kc),Ai=function(){function e(){Q(this,e)}return xe(e,null,[{key:"handleFunctionState",value:function(t){var n,i,r,o,c=t.className,a=t.fnName,s=t.params;if(!(ra||[Qf,Qb,Yb].findIndex(function(b){return b===location.host})>=0)){var l,u=[];if(c)switch(a){case"createClient":(n=s[0])!==null&&n!==void 0&&n.mode&&u.push("".concat(c,".").concat(a,".").concat(s[0].mode)),(i=s[0])!==null&&i!==void 0&&i.useStringRoomId?u.push("".concat(c,".").concat(a,".stringRoomId")):u.push("".concat(c,".").concat(a,".intRoomId")),(r=s[0])!==null&&r!==void 0&&r.autoSubscribe?u.push("".concat(c,".").concat(a,".autoSubscribe")):u.push("".concat(c,".").concat(a,".manualSubscribe"));break;case"publish":(o=s[1])!==null&&o!==void 0&&o.isAuxiliary?u.push("".concat(c,".").concat(a,".isAuxiliary")):u.push("".concat(c,".").concat(a));break;case"setAudioProfile":case"setVideoProfile":case"setScreenProfile":case"setVideoContentHint":Bt(s[0])&&u.push("".concat(c,".").concat(a,".").concat(s[0]));break;default:u.push("".concat(c,".").concat(a))}else u.push(a);for(var h=0;h<u.length;h++){if(!(l=pN[u[h]]))return;this.stateMap.has(l)?this.stateMap.get(l).int32_call_times+=1:this.stateMap.set(l,{int32_id:l,int32_call_times:1})}}}},{key:"getStateArray",value:function(){return Array.from(this.stateMap.values())}},{key:"clearStateArray",value:function(){this.stateMap.clear()}}]),e}();function St(e){return function(t,n,i){var r=i.value;return i.value=function(){for(var o=arguments.length,c=new Array(o),a=0;a<o;a++)c[a]=arguments[a];try{e||(e=this.name_),Ai.handleFunctionState({className:e,fnName:n,params:c}),e=void 0}catch(s){this.log_.info(s)}return r.apply(this,c)},i}}Ye(Ai,"stateMap",new Map);var AI=(CI=fn.apply(void 0,Se(Yt.STREAM.play)),EI=St(),RI=St(),cr=function(){function e(c){Q(this,e),this.name_=uN,this.userId_=c.userId,this.isRemote_=c.isRemote,this.type_=c.type,this.log_=_e.createLogger({id:"s".concat(c.seq?c.seq:"","|").concat(this.userId_),userId:ge(c.client)?void 0:c.client.getUserId(),sdkAppId:ge(c.client)?void 0:c.client.getSDKAppId(),isLocal:!this.isRemote_,type:this.isRemote_?this.type_:""}),this.client_=null,ge(c.client)||(this.client_=c.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_="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var s=16*Math.random()|0;return(a=="x"?s:3&s|8).toString(16)}),this.audioOutputDeviceId_=0,this.audioVolume_=1,this.emitter_=GS(new ki,this.name_),this.connectionState_=on,this.installEvents(),ge(c.mirror)||this.log_.warn('TRTC.createStream "mirror" option was deprecated since v4.12.1\uFF0Cplease use localStream.play to set up preview mirror. refer to '.concat(co,"/en/LocalStream.html#play. TRTC.createStream \u63A5\u53E3\u7684 mirror \u9009\u9879\u4ECE v4.12.1 \u5F00\u59CB\u88AB\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 localStream.play \u8BBE\u7F6E\u672C\u5730\u6D41\u9884\u89C8\u955C\u50CF\uFF0C\u53C2\u8003\u6587\u6863\uFF1A").concat(co,"/zh-cn/LocalStream.html#play\u3002")),this.audioPlayerRetryCount_=3}var t,n,i,r,o;return xe(e,[{key:"installEvents",value:function(){Y.on(rc,this.restartPlayback,this)}},{key:"uninstallEvents",value:function(){Y.off(rc,this.restartPlayback,this)}},{key:"getType",value:function(){return this.type_}},{key:"getLogger",value:function(){return this.log_}},{key:"isSubscribed",get:function(){return this.type_===yt&&this.connection_.isMainStreamSubscribed||this.type_===Dt&&this.connection_.isAuxStreamSubscribed}},{key:"isMainVideoSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===yt&&c&&c.video}},{key:"isMainAudioSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===yt&&c&&c.audio}},{key:"isAuxVideoSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===Dt&&c&&c.auxiliary}},{key:"isSmallVideoSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===yt&&c&&c.smallVideo}},{key:"emitConnectionStateChanged",value:function(c){c.state!==this.connectionState_&&(c.state!==on&&this.isRemote_&&!this.isSubscribed||(this.emitter_.emit(a6,c),this.connectionState_=c.state))}},{key:"setConnection",value:function(c){this.connection_!==c&&(c instanceof Bv?(this.connection_!==null&&this.connection_.off(et.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),c.on(et.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this)):c===null&&this.connection_.off(et.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),this.connection_=c)}},{key:"getConnection",value:function(){return this.connection_}},{key:"play",value:(o=H(f().mark(function c(a,s){var l,u,h;return f().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(this.log_.info("stream ".concat(this.isPlaying_?"update":"start to"," play with elementId: ").concat(a," and options: ").concat(JSON.stringify(s),".")),!this.isPlaying_){b.next=9;break}return s&&!ge(s.muted)&&(this.muted_=s.muted),s&&!ge(s.objectFit)&&(this.objectFit_=s.objectFit),this.isScreenShare()?this.mirror_=!1:s&&!ge(s.mirror)&&(this.mirror_=s.mirror),this.audioPlayer_&&this.audioPlayer_.setMuted(this.muted_),this.videoPlayer_&&(this.videoPlayer_.setObjectFit(this.objectFit_),this.videoPlayer_.setMirror(this.mirror_)),this.elementId_!==a&&(l=a,Bt(a)&&(l=document.getElementById(a)),l.appendChild(this.div_),this.elementId_=a),b.abrupt("return");case 9:return this.isPlaying_=!0,(u=document.createElement("div")).setAttribute("id","player_".concat(this.id_)),u.setAttribute("style","width: 100%; height: 100%; position: relative; background-color: black; overflow: hidden;"),h=a,Bt(a)&&(h=document.getElementById(a)),h.appendChild(u),this.elementId_=a,this.div_=u,this.isRemote_||(this.muted_=!0),s&&!ge(s.muted)&&(this.muted_=s.muted),this.isScreenShare()&&(this.objectFit_="contain"),s&&!ge(s.objectFit)&&(this.objectFit_=s.objectFit),this.isScreenShare()?this.mirror_=!1:(this.isRemote_||(this.mirror_=!0),s&&!ge(s.mirror)&&(this.mirror_=s.mirror)),Y.emit(zp,{stream:this}),b.next=26,Promise.all([this.playAudio(),this.playVideo()]);case 26:Y.emit(L4,{stream:this});case 27:case"end":return b.stop()}},c,this)})),function(c,a){return o.apply(this,arguments)})},{key:"playAudio",value:(r=H(f().mark(function c(){var a,s,l=this;return f().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.hasAudio()&&(!this.isRemote_||this.isMainAudioSubscribed)){u.next=2;break}return u.abrupt("return");case 2:if(a=this.getAudioTrack(),this.audioPlayer_||!a){u.next=18;break}return this.log_.info("create AudioPlayer and play"),this.audioPlayer_=new o5({stream:this,track:a,gainedTrack:(s=this.gain_)===null||s===void 0?void 0:s.audioTrack,div:this.div_,muted:this.muted_,outputDeviceId:this.audioOutputDeviceId_,volume:this.audioVolume_}),this.audioPlayer_.on(gn,function(h){var b={type:Re,state:h.state,reason:h.reason};Y.emit(XS,J({stream:l},b)),l.emitter_.emit(Wk,b)}),this.audioPlayer_.on(Jk,function(h){l.audioPlayerRetryCount_>0&&(l.audioPlayerRetryCount_--,l.restartAudio())}),u.prev=8,u.next=11,this.audioPlayer_.play();case 11:u.next=18;break;case 13:throw u.prev=13,u.t0=u.catch(8),this.client_&&this.client_.getEnableAutoPlayDialog()&&new UT,this.emitter_.emit(wm,u.t0),u.t0;case 18:case"end":return u.stop()}},c,this,[[8,13]])})),function(){return r.apply(this,arguments)})},{key:"playVideo",value:(i=H(f().mark(function c(){var a,s=this;return f().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(this.hasVideo()&&(!this.isRemote_||this.isMainVideoSubscribed||this.isAuxVideoSubscribed||this.isSmallVideoSubscribed)){l.next=2;break}return l.abrupt("return");case 2:if(a=this.getVideoTrack(),this.videoPlayer_||!a){l.next=18;break}return Y.emit(Jp,{stream:this}),this.log_.info("create VideoPlayer and play"),this.videoPlayer_=new VT({stream:this,track:a,div:this.div_,muted:this.muted_,objectFit:this.objectFit_,mirror:this.mirror_}),this.videoPlayer_.on(gn,function(u){var h={type:Ie,state:u.state,reason:u.reason};Y.emit(XS,J({stream:s},h)),s.emitter_.emit(Wk,h)}),l.prev=8,l.next=11,this.videoPlayer_.play();case 11:l.next=18;break;case 13:throw l.prev=13,l.t0=l.catch(8),this.client_&&this.client_.getEnableAutoPlayDialog()&&new UT,this.emitter_.emit(wm,l.t0),l.t0;case 18:case"end":return l.stop()}},c,this,[[8,13]])})),function(){return i.apply(this,arguments)})},{key:"stopAudio",value:function(){this.audioPlayer_&&(this.log_.info("stop AudioPlayer"),this.audioPlayer_.stop(),this.audioPlayer_=null)}},{key:"stopVideo",value:function(){this.videoPlayer_&&(this.log_.info("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(c){}))}},{key:"restartVideo",value:function(){this.isPlaying_&&(this.stopVideo(),this.playVideo().catch(function(c){}))}},{key:"stop",value:function(){this.isPlaying_&&(this.isPlaying_=!1,this.stopAudio(),this.stopVideo(),this.div_.parentNode.removeChild(this.div_))}},{key:"resume",value:(n=H(f().mark(function c(){return f().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.isPlaying_){a.next=2;break}return a.abrupt("return");case 2:if(this.log_.info("resume"),!this.audioPlayer_){a.next=6;break}return a.next=6,this.audioPlayer_.resume();case 6:if(!this.videoPlayer_){a.next=9;break}return a.next=9,this.videoPlayer_.resume();case 9:case"end":return a.stop()}},c,this)})),function(){return n.apply(this,arguments)})},{key:"close",value:function(){this.log_.info("close stream"),this.isPlaying_&&this.stop(),this.isRemote_||(this.mediaStream_&&(this.mediaStream_.preventEvent=1,this.mediaStream_.getTracks().forEach(function(c){c.stop()}),this.mediaStream_=null),this.uninstallEvents())}},{key:"muteAudio",value:function(){return this.addRemoteEvent(!0,Re),this.doEnableTrack(Re,!1)}},{key:"muteVideo",value:function(){return this.addRemoteEvent(!0,Ie),this.doEnableTrack(Ie,!1)}},{key:"unmuteAudio",value:function(){return this.addRemoteEvent(!1,Re),this.doEnableTrack(Re,!0)}},{key:"unmuteVideo",value:function(){return this.addRemoteEvent(!1,Ie),this.doEnableTrack(Ie,!0)}},{key:"addRemoteEvent",value:function(c,a){if(this.isRemote_&&this.client_){var s=this.client_.getUserId(),l="".concat(c?tn:Sr," remote ").concat(a);vn(s,{eventId:a===Re?c?tV:rV:c?eV:nV,eventDesc:l,timestamp:new Date().getTime(),userId:s,tinyId:this.client_.getTinyId(),remoteUserId:this.userId_,remoteTinyId:this.connection_.getTinyId()})}}},{key:"doEnableTrack",value:function(c,a){var s=!1;return c===Re?this.mediaStream_.getAudioTracks().forEach(function(l){s=!0,l.enabled=a}):this.mediaStream_.getVideoTracks().forEach(function(l){s=!0,l.enabled=a}),s}},{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:(t=H(f().mark(function c(a){var s;return f().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(this.log_.info("setAudioOutput ".concat(a)),this.audioOutputDeviceId_=a,!this.audioPlayer_){l.next=5;break}return l.next=5,this.audioPlayer_.setSinkId(a);case 5:return l.next=7,Qk();case 7:s=l.sent,this.log_.info("speakers: ".concat(JSON.stringify(s)));case 9:case"end":return l.stop()}},c,this)})),function(c){return t.apply(this,arguments)})},{key:"setAudioVolume",value:function(c){this.audioVolume_=c,this.log_.info("setAudioVolume to ".concat(c)),this.audioPlayer_&&this.audioPlayer_.setVolume(c)}},{key:"getAudioLevel",value:function(){var c=0;return this.audioPlayer_&&(c=this.audioPlayer_.getAudioLevel()),c}},{key:"getInternalAudioLevel",value:function(){var c=0;return this.audioPlayer_&&(c=this.audioPlayer_.getInternalAudioLevel()),c}},{key:"hasAudio",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var c=this.connection_.getTrackState();return this.type_===yt&&c.audio}return!!this.getAudioTrack()}},{key:"hasVideo",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var c=this.connection_.getTrackState();return this.type_===Dt?c.auxiliary:c.video}return!!this.getVideoTrack()}},{key:"getSubscribedState",value:function(){return this.isRemote_&&this.connection_?this.connection_.getSubscribeState():null}},{key:"getAudioTrack",value:function(){var c=null;if(this.mediaStream_){var a=this.mediaStream_.getAudioTracks();a.length>0&&(c=a[0])}return c}},{key:"getVideoTrack",value:function(){var c=null;if(this.mediaStream_){var a=this.mediaStream_.getVideoTracks();a.length>0&&(c=a[0])}return c}},{key:"getVideoFrame",value:function(){return this.videoPlayer_?this.videoPlayer_.getVideoFrame():null}},{key:"getMediaStream",value:function(){return this.mediaStream_}},{key:"setMediaStream",value:function(c){c!==this.mediaStream_&&(this.mediaStream_&&this.mediaStream_.getTracks().forEach(function(a){return a.stop()}),this.mediaStream_=c)}},{key:"updateVideoPlayingState",value:function(c){if(this.isPlaying_)if(c){if(this.log_.info("playing state updated, play video"),this.videoPlayer_&&this.videoPlayer_.getTrack()!==this.getVideoTrack())return this.log_.warn("audio track changed, restart playback"),this.restartVideo();this.playVideo().catch(function(a){})}else this.log_.info("playing state updated, stop video"),this.stopVideo()}},{key:"updateAudioPlayingState",value:function(c){if(this.isPlaying_)if(c){if(this.log_.info("playing state updated, play audio"),this.audioPlayer_&&this.audioPlayer_.getTrack()!==this.getAudioTrack())return this.log_.warn("audio track changed, restart playback"),this.restartAudio();this.playAudio().catch(function(a){})}else this.log_.info("playing state updated, stop audio"),this.stopAudio()}},{key:"on",value:function(c,a,s){this.emitter_.on(c,a,s)}},{key:"off",value:function(c,a,s){c==="*"?this.emitter_.removeAllListeners():this.emitter_.off(c,a,s)}},{key:"isRemote",value:function(){return this.isRemote_}},{key:"isScreenShare",value:function(){return!this.isRemote_&&this.screen_||this.isRemote_&&this.getType()===gt}},{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}(),K(cr.prototype,"play",[CI],Object.getOwnPropertyDescriptor(cr.prototype,"play"),cr.prototype),K(cr.prototype,"setAudioOutput",[EI],Object.getOwnPropertyDescriptor(cr.prototype,"setAudioOutput"),cr.prototype),K(cr.prototype,"getVideoFrame",[RI],Object.getOwnPropertyDescriptor(cr.prototype,"getVideoFrame"),cr.prototype),cr),Gv=function(e){Et(n,e);var t=Rr(n);function n(i){var r;Q(this,n);var o={isRemote:!0,type:i.type},c=J(J({},i),o);return(r=t.call(this,c)).name_=Xf,r.isStreamAddedEventEmitted_=!1,r.isAbleToCallSubscription_=!0,r}return xe(n,[{key:"installEvents",value:function(){ue(Qe(n.prototype),"installEvents",this).call(this),Y.on(Ur,this.handleStreamSubscribed,this),Y.on(Vr,this.handleStreamUnsubscribed,this)}},{key:"uninstallEvents",value:function(){ue(Qe(n.prototype),"uninstallEvents",this).call(this),Y.off(Ur,this.handleStreamSubscribed,this),Y.off(Vr,this.handleStreamUnsubscribed,this)}},{key:"handleStreamSubscribed",value:function(i){i.client===this.client_&&i.stream===this&&this.connection_.getCurrentState()===sn&&this.emitConnectionStateChanged({prevState:on,state:sn})}},{key:"handleStreamUnsubscribed",value:function(i){i.client===this.client_&&i.stream===this&&this.emitConnectionStateChanged({prevState:sn,state:on})}},{key:"getType",value:function(){return ue(Qe(n.prototype),"getType",this).call(this)}},{key:"getIsAbleToCallSubscription",value:function(){return this.isAbleToCallSubscription_}},{key:"setIsAbleToCallSubscription",value:function(i){this.isAbleToCallSubscription_=i}},{key:"setIsStreamAddedEventEmitted",value:function(i){this.isStreamAddedEventEmitted_=i}},{key:"getIsStreamAddedEventEmitted",value:function(){return this.isStreamAddedEventEmitted_}},{key:"getAudioTrack",value:function(){return this.connection_&&this.connection_.getTrackState().audio?ue(Qe(n.prototype),"getAudioTrack",this).call(this):null}},{key:"getVideoTrack",value:function(){if(!this.connection_)return null;var i=this.connection_.getTrackState();return(this.type_!==yt||i.video)&&(this.type_!==Dt||i.auxiliary)?ue(Qe(n.prototype),"getVideoTrack",this).call(this):null}},{key:"close",value:function(){ue(Qe(n.prototype),"close",this).call(this)}}]),n}(AI),TF=function(){function e(r){Q(this,e),this.client_=r.client,this.subscribedStreams_=new Map,this.unsubscribedStreams_=new Map,this.subscriptedOptions_=new Map,this.autoRecoveryFlags_=new Map}var t,n,i;return xe(e,[{key:"isEnabled",get:function(){return this.client_.getEnv()!=="webrtc"}},{key:"recover",value:(i=H(f().mark(function r(o){var c,a,s;return f().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(c=o.getUserId(),a=o.getType(),this.hasAutoRecoveryFlag(c,a)){l.next=5;break}return l.abrupt("return");case 5:if(s=this.getUnsubscribedStream(c,a)?"unsubscribe":"subscribe",l.prev=6,_e.warn("recover() try to recover subscription [".concat(s,"][").concat(c,"][").concat(a,"]")),s!=="subscribe"){l.next=13;break}return l.next=11,this.recoverSubscription(c,o);case 11:l.next=15;break;case 13:return l.next=15,this.recoverUnsubscription(c,o);case 15:ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ub}),_e.warn("recover() recover successfully [".concat(s,"][").concat(c,"][").concat(a,"]")),l.next=23;break;case 19:l.prev=19,l.t0=l.catch(6),_e.error("recover() recover failed [".concat(s,"][").concat(c,"][").concat(a,"]"),l.t0),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Ub,error:l.t0});case 23:this.deleteAutoRecoveryFlag(c,a);case 24:case"end":return l.stop()}},r,this,[[6,19]])})),function(r){return i.apply(this,arguments)})},{key:"recoverSubscription",value:(n=H(f().mark(function r(o,c){var a,s,l,u,h;return f().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(a=this.getOptions(o,c.getType()),s=this.getSubscribedStream(o,c.getType()),a&&s){b.next=4;break}return b.abrupt("return");case 4:l=this.getStreamMuteState(s),u=l.isAudioMuted,h=l.isVideoMuted,this.mergeStream(s,c),this.recoverPlayingState(s),u&&s.doEnableTrack(Re,!1),h&&s.doEnableTrack(Ie,!1);case 9:case"end":return b.stop()}},r,this)})),function(r,o){return n.apply(this,arguments)})},{key:"recoverUnsubscription",value:(t=H(f().mark(function r(o,c){var a;return f().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(a=this.getUnsubscribedStream(o,c.getType())){s.next=3;break}return s.abrupt("return");case 3:this.mergeStream(a,c);case 4:case"end":return s.stop()}},r,this)})),function(r,o){return t.apply(this,arguments)})},{key:"getStreamMuteState",value:function(r){var o={isAudioMuted:!1,isVideoMuted:!1},c=r.getMediaStream();return c&&(o.isAudioMuted=c.getAudioTracks().map(function(a){return a.enabled}).includes(!1),o.isVideoMuted=c.getVideoTracks().map(function(a){return a.enabled}).includes(!1)),o}},{key:"recoverPlayingState",value:function(r){var o=r.isPlaying(),c=r.getDiv();if(o&&c){var a=c.parentNode;r.stop(),r.play(a,{objectFit:r.getObjectFit(),muted:r.getMuted()})}}},{key:"mergeStream",value:function(r,o){var c=o.getConnection(),a=o.getMediaStream();r.setConnection(c),c.setRemoteStream(a.id,r),r.setMediaStream(a),r.updateAudioPlayingState(o.hasAudio()),r.updateVideoPlayingState(o.hasVideo())}},{key:"addSubscriptionRecord",value:function(r,o,c){var a=o.getType();if(this.subscribedStreams_.has(r))this.subscribedStreams_.get(r).set(a,o);else{var s=new Map;s.set(o.getType(),o),this.subscribedStreams_.set(r,s)}if(this.subscriptedOptions_.has(r))this.subscriptedOptions_.get(r).set(a,c);else{var l=new Map;l.set(o.getType(),c),this.subscriptedOptions_.set(r,l)}this.deleteUnsubscriptionRecord(r,a)}},{key:"addUnsubscriptionRecord",value:function(r,o){if(this.unsubscribedStreams_.has(r))this.unsubscribedStreams_.get(r).set(o.getType(),o);else{var c=new Map;c.set(o.getType(),o),this.unsubscribedStreams_.set(r,c)}this.deleteSubscriptionRecord(r,o.getType())}},{key:"getSubscribedStream",value:function(r,o){return this.subscribedStreams_.has(r)&&this.subscribedStreams_.get(r).has(o)?this.subscribedStreams_.get(r).get(o):null}},{key:"getOptions",value:function(r,o){return this.subscriptedOptions_.has(r)&&this.subscriptedOptions_.get(r).has(o)?this.subscriptedOptions_.get(r).get(o):null}},{key:"getUnsubscribedStream",value:function(r,o){return this.unsubscribedStreams_.has(r)&&this.unsubscribedStreams_.get(r).has(o)?this.unsubscribedStreams_.get(r).get(o):null}},{key:"deleteSubscriptionRecord",value:function(r,o){this.subscribedStreams_.has(r)&&this.subscribedStreams_.get(r).delete(o),this.subscriptedOptions_.has(r)&&this.subscriptedOptions_.get(r).delete(o)}},{key:"deleteUnsubscriptionRecord",value:function(r,o){this.unsubscribedStreams_.has(r)&&this.unsubscribedStreams_.get(r).delete(o)}},{key:"markAllStream",value:function(){for(var r=0,o=Se(this.subscribedStreams_.entries());r<o.length;r++)for(var c=Te(o[r],2),a=c[0],s=0,l=Se(c[1].entries());s<l.length;s++){var u=Te(l[s],1)[0];this.setAutoRecoveryFlag(a,u)}for(var h=0,b=Se(this.unsubscribedStreams_.entries());h<b.length;h++)for(var I=Te(b[h],2),R=I[0],x=0,m=Se(I[1].entries());x<m.length;x++){var k=Te(m[x],1)[0];this.setAutoRecoveryFlag(R,k)}}},{key:"setAutoRecoveryFlag",value:function(r,o){if(_e.info("setAutoRecoveryFlag() mark [".concat(r,"][").concat(o,"]")),this.autoRecoveryFlags_.has(r))this.autoRecoveryFlags_.get(r).set(o);else{var c=new Map;c.set(o),this.autoRecoveryFlags_.set(r,c)}}},{key:"hasAutoRecoveryFlag",value:function(r,o){return!!this.isEnabled&&this.autoRecoveryFlags_.has(r)&&this.autoRecoveryFlags_.get(r).has(o)}},{key:"deleteAutoRecoveryFlag",value:function(r,o){this.autoRecoveryFlags_.has(r)&&this.autoRecoveryFlags_.get(r).delete(o)}},{key:"delete",value:function(r){this.unsubscribedStreams_.delete(r),this.subscribedStreams_.delete(r),this.subscriptedOptions_.delete(r),this.autoRecoveryFlags_.delete(r)}}]),e}(),IF=function(){function e(t){Q(this,e),this.player_=t,this.canvas_=document.createElement(hb),this.canvasCtx_=this.canvas_.getContext("2d")}return xe(e,[{key:"setCanvasRect",value:function(t,n){this.canvas_.width=t,this.canvas_.height=n}},{key:"drawVideoToCanvas",value:function(){var t=this.player_.getElement(),n=t.videoHeight,i=t.videoWidth,r=i*this.canvas_.height/(n*this.canvas_.width);if(r>1.05||r<.95){var o=i*n/(this.canvas_.width*this.canvas_.height);this.setCanvasRect(i/Math.sqrt(o),n/Math.sqrt(o))}this.canvasCtx_.drawImage(t,0,0,this.canvas_.width,this.canvas_.height)}},{key:"generateVideoTrackFromCanvasCapture",value:function(t){return this.canvas_.captureStream(t).getVideoTracks()[0]}},{key:"generateStreamFromTrack",value:function(t){var n=new MediaStream;return n.addTrack(t),n}},{key:"destroy",value:function(){this.player_.stop(),this.canvas_.width=0,this.canvas_.height=0,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 t=this.player_.getElement();if(t)return t.readyState===t.HAVE_ENOUGH_DATA}return!1}}]),e}(),xF=new Blob(['let t,e,a,i;onmessage=function(n){const{action:h,data:s}=n.data;switch(h){case"render":a=s.canvas,t=a.width,e=a.height,i=a.getContext("2d"),function(t,e){const n=new TransformStream({async transform(t,e){const n=t.displayWidth,h=t.displayHeight,s=n*a.height/(h*a.width);if(s>1.05||s<.95){const t=n*h/(a.width*a.height);a.width=n/Math.sqrt(t),a.height=h/Math.sqrt(t)}i.drawImage(t,0,0,a.width,a.height);const o=new VideoFrame(a,{timestamp:t.timestamp});t.close(),e.enqueue(o)}});t.pipeThrough(n).pipeTo(e)}(s.readable,s.writable)}}'],{type:"application/javascript"}),wF=function(){function e(t){Q(this,e);var n=t.videoTrack;this.width=void 0,this.height=void 0,this.canvas=document.createElement("canvas"),this.offscreen=null,this.smallGenerator=new MediaStreamTrackGenerator({kind:"video"}),this.smallWritable=this.smallGenerator.writable,this.bigProcessor=new MediaStreamTrackProcessor({track:n}),this.bigReadable=this.bigProcessor.readable,this.initWorker()}return xe(e,[{key:"initWorker",value:function(){try{this.worker=new Worker(URL.createObjectURL(xF)),_e.info("init worker processor success")}catch(t){_e.warn("init worker processor failed. ".concat(t.error))}}},{key:"setCanvasRect",value:function(t,n){this.width=t,this.height=n,this.canvas.width=t,this.canvas.height=n,this.offscreen=this.canvas.transferControlToOffscreen(),this.worker.postMessage({action:"render",data:{canvas:this.offscreen,readable:this.bigReadable,writable:this.smallWritable}},[this.offscreen,this.bigReadable,this.smallWritable])}},{key:"generatorVideoTrack",value:function(){var t=new MediaStream([this.smallGenerator]);return t==null?void 0:t.getTracks()[0]}},{key:"destroy",value:function(){this.worker.terminate()}}]),e}(),Yl=function(){function e(n){Q(this,e),this.localStream_=n,this.player_=null,this.processor_=null,this.initOffscreenSuccess_=!1}var t;return xe(e,[{key:"initialize",value:(t=H(f().mark(function n(){var i;return f().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(r6()&&((i=navigator)===null||i===void 0?void 0:i.hardwareConcurrency)>=6)){r.next=13;break}return r.prev=1,r.next=4,this.initOffscreen();case 4:this.initOffscreenSuccess_=!0,_e.info("Initialize VideoGenerator successfully!"),r.next=11;break;case 8:r.prev=8,r.t0=r.catch(1),this.initCanvas();case 11:r.next=14;break;case 13:this.initCanvas();case 14:case"end":return r.stop()}},n,this,[[1,8]])})),function(){return t.apply(this,arguments)})},{key:"generateSmallVideoTrack",value:function(n){var i,r=n.height,o=n.width,c=n.frameRate,a=this.getSmallVideoProfile(o,r);return this.initOffscreenSuccess_?(this.processor_.setCanvasRect(a.width,a.height),i=this.processor_.generatorVideoTrack()):(this.processor_.setCanvasRect(a.width,a.height),this.player_.setRect({width:a.width,height:a.height}),i=this.processor_.generateVideoTrackFromCanvasCapture(c),this.interval_=mt.run(Qu,this.render.bind(this),{fps:c})),i}},{key:"render",value:function(){this.processor_.canDrawVideoToCanvas&&this.processor_.drawVideoToCanvas()}},{key:"destroy",value:function(){mt.clearTask(this.interval_),this.processor_&&this.processor_.destroy()}},{key:"initOffscreen",value:function(){this.processor_=new wF({videoTrack:this.localStream_.getVideoTrack()})}},{key:"initCanvas",value:function(){this.player_=new VT({stream:this.localStream_,track:this.localStream_.getVideoTrack(),muted:!0,objectFit:"cover",mirror:!1}),this.player_.play().then(function(){_e.info("VideoGenerator: play local video success")}).catch(function(){_e.error("VideoGenerator: Failed to play local video")}),this.processor_=new IF(this.player_)}},{key:"getSmallVideoProfile",value:function(n,i){var r,o=this.localStream_.getVideoTrack(),c=J({},this.localStream_.getVideoProfile());if(la){var a=o.getSettings();a&&a.width&&a.height&&(c.width=a.width,c.height=a.height)}var s=c.width*c.height,l=n*i;return _e.info("big stream resolution: ".concat(c.width,"*").concat(c.height," small stream resolution: ").concat(n,"*").concat(i," ")),r=s>l?s/l:s/19200,{width:parseInt(c.width/Math.sqrt(r)),height:parseInt(c.height/Math.sqrt(r))}}}]),e}(),$l=new Map,CF=function(){var e=H(f().mark(function t(n){var i,r,o,c,a,s,l;return f().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!gl()){u.next=2;break}return u.abrupt("return");case 2:return u.next=4,EF(n);case 4:if(i=u.sent,_e.info("getUserMedia with constraints: "+JSON.stringify(i)),!i.audio){u.next=11;break}return u.next=9,It.getMicrophones();case 9:r=u.sent,_e.info("microphones: ".concat(fo(r,["deviceId","label"])));case 11:if(!i.video){u.next=16;break}return u.next=14,It.getCameras();case 14:o=u.sent,_e.info("cameras: ".concat(fo(o,["deviceId","label"])));case 16:return u.prev=16,u.next=19,navigator.mediaDevices.getUserMedia(i);case 19:return u.abrupt("return",u.sent);case 22:if(u.prev=22,u.t0=u.catch(16),u.t0.name!=="NotFoundError"){u.next=29;break}if(!o||o.length!==0){u.next=27;break}throw new te({code:Z.DEVICE_NOT_FOUND,message:ie({key:J3})});case 27:if(!r||r.length!==0){u.next=29;break}throw new te({code:Z.DEVICE_NOT_FOUND,message:ie({key:W3})});case 29:throw i.audio&&((c=r)===null||c===void 0?void 0:c.length)>0&&(s=r.find(function(h){return h.deviceId===n.microphoneId}))&&s.getCapabilities&&_e.warn(fo(s.getCapabilities(),Zf)),i.video&&((a=o)===null||a===void 0?void 0:a.length)>0&&(l=o.find(function(h){return h.deviceId===n.cameraId}))&&l.getCapabilities&&_e.warn(fo(l.getCapabilities(),Zf)),new te({code:Z.INITIALIZE_FAILED,name:u.t0.name,message:u.t0.message,constraint:u.t0.constraint});case 32:case"end":return u.stop()}},t,null,[[16,22]])}));return function(t){return e.apply(this,arguments)}}(),zv=ic({retryFunction:CF,settings:{retries:3,timeout:500},onError:function(e,t,n,i,r){var o=r+1;_e.warn("getUserMedia error: ".concat(e)),e.name==="NotReadableError"||e.name==="OverconstrainedError"||e.name.includes("TypeError")?(o===1&&i[0].video?(i[0].maxResoution=!1,i[0].frameRate=i[0].frameRate>10?10:5):o===2?i[0].useDeviceIdOnly=!0:o!==3||i[0].useExact&&!i[0].retryWhenExactFailed||(i[0].useTrueAsConstraint=!0),e.message.includes("deviceId")&&i[0].retryWhenExactFailed&&(i[0].useExact=!1),t()):n(e)},onRetrying:function(e){_e.warn("getUserMedia retrying [".concat(e,"/3]"))},onRetryFailed:function(){ke.uploadEvent({log:"stat-getUserMedia-retry-failed"})},onRetrySuccess:function(e){ke.uploadEvent({log:"stat-getUserMedia-retry-success-"+e})}});function EF(e){return{audio:RF(e),video:AF(e)}}function RF(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;var t={};return!Br(e.microphoneId)&&(t.deviceId=e.useExact?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(t.echoCancellation=!0,t.noiseSuppression=!0,t.autoGainControl=!0,t.sampleRate=e.sampleRate,tr(e.channelCount)&&e.channelCount>1&&(t.channelCount=e.channelCount),nr(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),nr(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),nr(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!Br(t)||t)}function AF(e){if(!e.video)return!1;if(e.useTrueAsConstraint)return!0;var t=e.maxResoution,n=t===void 0||t,i={};return e.facingMode?i.facingMode=e.facingMode:e.cameraId&&(i.deviceId=e.useExact?{exact:e.cameraId}:e.cameraId),e.useDeviceIdOnly&&!Br(i)?i:(e.width&&(i.width={ideal:e.width},n&&!Vn&&(i.width.max=e.width)),e.height&&(i.height={ideal:e.height},n&&!Vn&&(i.height.max=e.height)),Vn&&ec&&e.width&&e.height&&e.width*e.height<101376&&(i.width=e.width,i.height=e.height),e.frameRate&&(i.frameRate=e.frameRate),!!Br(i)||i)}var PF=function(){var e=H(f().mark(function t(n){var i,r,o,c,a,s,l,u,h;return f().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(!gl()){b.next=2;break}return b.abrupt("return");case 2:if(i=null,!(rl&&bp<74||na)){b.next=27;break}return r=Wv(n),_e.info("getDisplayMedia with constraints: "+JSON.stringify(r)),b.next=8,navigator.mediaDevices.getDisplayMedia(r);case 8:if(o=b.sent,!n.screenAudio){b.next=14;break}return _e.warn("Your browser not support capture system audio"),b.abrupt("return",o);case 14:if(!n.audio){b.next=24;break}return c=PI(n),_e.info("getUserMedia with constraints: "+JSON.stringify(c)),b.next=19,navigator.mediaDevices.getUserMedia(c);case 19:return i=b.sent,o.addTrack(i.getAudioTracks()[0]),b.abrupt("return",o);case 24:return b.abrupt("return",o);case 25:b.next=53;break;case 27:if(!n.screenAudio){b.next=37;break}return n.audioConstraints={echoCancellation:n.echoCancellation,autoGainControl:n.autoGainControl,noiseSuppression:n.noiseSuppression,sampleRate:44100},a=Wv(n),_e.info("getDisplayMedia with constraints: "+JSON.stringify(a)),b.next=33,navigator.mediaDevices.getDisplayMedia(a);case 33:return s=b.sent,b.abrupt("return",s);case 37:return l=Wv(n),_e.info("getDisplayMedia with constraints: "+JSON.stringify(l)),b.next=41,navigator.mediaDevices.getDisplayMedia(l);case 41:if(u=b.sent,!n.audio){b.next=52;break}return h=PI(n),_e.info("getUserMedia with constraints: "+JSON.stringify(h)),b.next=47,navigator.mediaDevices.getUserMedia(h);case 47:return i=b.sent,u.addTrack(i.getAudioTracks()[0]),b.abrupt("return",u);case 52:return b.abrupt("return",u);case 53:case"end":return b.stop()}},t)}));return function(t){return e.apply(this,arguments)}}();function PI(e){var t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return ge(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}function Wv(e){var t={systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},n={width:na?{max:e.width}:{ideal:e.width,max:e.width},height:na?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:"monitor"};return t.video=n,ge(e.audioConstraints)||(t.audio=e.audioConstraints),t}var DI,OI,LI,MI,NI,UI,VI,jI,BI,FI,HI,nt,GI,Tc,Jv=new Map([["120p",{width:160,height:120,frameRate:15,bitrate:200}],["120p_2",{width:160,height:120,frameRate:15,bitrate:100}],["180p",{width:320,height:180,frameRate:15,bitrate:350}],["180p_2",{width:320,height:180,frameRate:15,bitrate:150}],["240p",{width:320,height:240,frameRate:15,bitrate:400}],["240p_2",{width:320,height:240,frameRate:15,bitrate:200}],["360p",{width:640,height:360,frameRate:15,bitrate:800}],["360p_2",{width:640,height:360,frameRate:15,bitrate:400}],["480p",{width:640,height:480,frameRate:15,bitrate:900}],["480p_2",{width:640,height:480,frameRate:15,bitrate:500}],["720p",{width:1280,height:720,frameRate:15,bitrate:1500}],["1080p",{width:1920,height:1080,frameRate:15,bitrate:2e3}],["1440p",{width:2560,height:1440,frameRate:30,bitrate:4860}],["4K",{width:3840,height:2160,frameRate:30,bitrate:9e3}]]),qv=new Map([["480p",{width:640,height:480,frameRate:5,bitrate:900}],["480p_2",{width:640,height:480,frameRate:30,bitrate:1e3}],["720p",{width:1280,height:720,frameRate:5,bitrate:1200}],["720p_2",{width:1280,height:720,frameRate:30,bitrate:3e3}],["1080p",{width:1920,height:1080,frameRate:5,bitrate:1600}],["1080p_2",{width:1920,height:1080,frameRate:30,bitrate:4e3}]]),zI=new Map([["standard",{sampleRate:48e3,channelCount:1,bitrate:40}],["standard-stereo",{sampleRate:48e3,channelCount:2,bitrate:64}],["high",{sampleRate:48e3,channelCount:1,bitrate:128}],["high-stereo",{sampleRate:48e3,channelCount:2,bitrate:192}]]),_a=new Map,DF=(DI=St(vi),OI=St(vi),LI=St(vi),MI=St(vi),NI=fn.apply(void 0,Se(Yt.LOCAL_STREAM.switchDevice)),UI=fn(Yt.STREAM.addTrack),VI=fn(Yt.STREAM.removeTrack),jI=fn(Yt.STREAM.replaceTrack),BI=Lo({retries:10,timeout:3e3,onRetryFailed:function(e){ke.logFailedEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:Nb,error:e}),this.emitter_.emit(wm,new te({code:Z.DEVICE_AUTO_RECOVER_FAILED,message:e.message}))}}),FI=Ql(Yt.LOCAL_STREAM.setAudioCaptureVolume),HI=St(vi),nt=function(e){Et(x,e);var t,n,i,r,o,c,a,s,l,u,h,b,I,R=Rr(x);function x(m){var k;Q(this,x);var v=J(J({},m),{isRemote:!1,type:"local"});return(k=R.call(this,v)).name_=vi,k.client_=null,k.video_=m.video,k.audio_=m.audio,k.cameraId_=m.cameraId,k.cameraGroupId_="",k.facingMode_=m.facingMode,k.microphoneId_=m.microphoneId,k.microphoneGroupId_="",k.microphoneLabel_="",k.videoSource_=m.videoSource,k.audioSource_=m.audioSource,k.screen_=m.screen,k.screenAudio_=m.screenAudio,k.audioProfile_={echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40},k.screenAudio_&&(k.audioProfile_.echoCancellation=!0,k.audioProfile_.autoGainControl=!1,k.audioProfile_.noiseSuppression=!1),nr(m.echoCancellation)&&(k.audioProfile_.echoCancellation=m.echoCancellation),nr(m.autoGainControl)&&(k.audioProfile_.autoGainControl=m.autoGainControl),nr(m.noiseSuppression)&&(k.audioProfile_.noiseSuppression=m.noiseSuppression),k.videoProfile_=Jv.get("480p_2"),k.screenProfile_=qv.get("1080p"),k.videoSetting_=null,k.muteState_={video:!1,audio:!1,auxVideo:!1},k.beautyStatus_=!1,k.prevAudioRecoverTime_=0,k.prevVideoRecoverTime_=0,k.isAudioRecovering_=!1,k.isVideoRecovering_=!1,k.initState(),k.canvas_=null,k.canvasInterval_=null,k.canvasTrack_=null,k.gain_={audioTrack:null,source:null,gainNode:null},k.captureVolume_=100,k.enableAutoRecoverCapture_=!!ge(m.enableAutoRecoverCapture)||m.enableAutoRecoverCapture,k.enableAutoRecoverOther_=!nr(m.enableAutoRecoverOther)||m.enableAutoRecoverOther,k.log_.info("stream created: ".concat(k.id_," autoRecover: ").concat(k.enableAutoRecoverCapture_)),k.isAIDenoiser=!1,k}return xe(x,[{key:"scaleResolutionDownBy",get:function(){var m=this.getVideoTrack();if(!m||!la||this.isScreenShare())return 1;var k,v,w,L=m.getSettings();return L.width===this.videoProfile_.width&&L.height===this.videoProfile_.height?1:(k=window.screen)!==null&&k!==void 0&&(v=k.orientation)!==null&&v!==void 0&&(w=v.type)!==null&&w!==void 0&&w.includes("portrait")&&this.videoProfile_.width>this.videoProfile_.height&&L.height>L.width?Math.max(L.width/this.videoProfile_.height,L.height/this.videoProfile_.width,1):Math.max(L.width/this.videoProfile_.width,L.height/this.videoProfile_.height,1)}},{key:"initState",value:function(){this.isAddingTrack_=!1,this.isRemovingTrack_=!1,this.setIsReadyToPublish(!1),this.setPublishState(Wb)}},{key:"installEvents",value:function(){ue(Qe(x.prototype),"installEvents",this).call(this),Y.on(qp,this.onVideoTrackStopped,this),Y.on(nc,this.onVideoTrackStopped,this),Y.on(Xp,this.onAudioTrackStopped,this),Y.on(Kp,this.onAudioTrackStopped,this)}},{key:"uninstallEvents",value:function(){ue(Qe(x.prototype),"uninstallEvents",this).call(this),Y.off(qp,this.onVideoTrackStopped,this),Y.off(nc,this.onVideoTrackStopped,this),Y.off(Xp,this.onAudioTrackStopped,this),Y.off(Kp,this.onAudioTrackStopped,this)}},{key:"initialize",value:function(){var m=this;return new Promise(function(k,v){if(_l())v(new te({code:Z.INVALID_OPERATION,message:ie({key:mS})}));else{if(ge(m.audio_)){var w=new MediaStream;return ge(m.audioSource_)||(w.addTrack(m.audioSource_),m.updateAudioPlayingState(!0)),ge(m.videoSource_)||(w.addTrack(m.videoSource_),m.updateVideoPlayingState(!0)),m.setMediaStream(w),ke.logSuccessEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Qs,kind:"custom"}),m.setIsReadyToPublish(!0),k()}m.screen_?(m.log_.info("initialize stream audio: "+m.audio_+" screenAudio: "+m.screenAudio_+" screen: "+m.screen_),PF({audio:m.audio_,screenAudio:m.screenAudio_,microphoneId:m.microphoneId_,width:m.screenProfile_.width,height:m.screenProfile_.height,frameRate:m.screenProfile_.frameRate,sampleRate:m.audioProfile_.sampleRate,channelCount:m.audioProfile_.channelCount,autoGainControl:m.audioProfile_.autoGainControl,noiseSuppression:m.audioProfile_.noiseSuppression,echoCancellation:m.audioProfile_.echoCancellation}).then(function(L){m.setMediaStream(L),m.updateAudioPlayingState(m.audio_||m.screenAudio_),m.updateVideoPlayingState(!0);var E=m.getVideoTrack();return E.applyConstraints&&E.applyConstraints({frameRate:{min:m.screenProfile_.frameRate,ideal:m.screenProfile_.frameRate},width:m.screenProfile_.width,height:m.screenProfile_.height}).catch(function(N){m.warn("screen applyConstraints failed: ".concat(N))}),m.listenForScreenSharingStopped(E),m.setVideoContentHint(mb),m.updateDeviceIdInUse(),m.setIsReadyToPublish(!0),m.log_.info(JSON.stringify(E.getSettings())),ke.logSuccessEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Qs,kind:"getDisplayMedia"}),k()}).catch(function(L){ke.logFailedEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Qs,kind:"getDisplayMedia",error:L}),m.log_.error("getDisplayMedia error observed "+L),v(L instanceof te?L:new te({code:Z.INITIALIZE_FAILED,name:L.name,message:L.message}))})):(Y.emit(Bp,{stream:m,audio:m.audio_,video:m.video_}),m.log_.info("initialize stream audio: "+m.audio_+" video: "+m.video_),zv({audio:m.audio_,video:m.video_,facingMode:m.facingMode_,cameraId:m.cameraId_,microphoneId:m.microphoneId_,width:m.videoProfile_.width,height:m.videoProfile_.height,frameRate:m.videoProfile_.frameRate,sampleRate:m.audioProfile_.sampleRate,channelCount:m.audioProfile_.channelCount,autoGainControl:m.audioProfile_.autoGainControl,noiseSuppression:m.audioProfile_.noiseSuppression,echoCancellation:m.audioProfile_.echoCancellation,useExact:!0,retryWhenExactFailed:!0}).then(function(L){return Y.emit(Fp,{stream:m,audio:m.audio_,video:m.video_}),m.setMediaStream(L),L.getTracks().forEach(function(E){if(la){var N=E.getSettings();m.log_.debug("".concat(E.kind," settings: ").concat(JSON.stringify(N))),E.kind===Ie&&(m.videoSetting_=N)}n6&&m.log_.info("".concat(E.kind," capabilities: ").concat(fo(E.getCapabilities(),Zf)))}),m.updateAudioPlayingState(m.audio_),m.updateVideoPlayingState(m.video_),m.updateDeviceIdInUse(),m.log_.info("gotStream hasAudio: "+m.hasAudio()+" hasVideo: "+m.hasVideo()),m.setIsReadyToPublish(!0),ke.logSuccessEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Qs,kind:"getUserMedia"}),k()}).catch(function(L){Y.emit(Hp,{stream:m,audio:m.audio_,video:m.video_,error:L}),ke.logFailedEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Qs,kind:"getUserMedia",error:L}),m.log_.error("getUserMedia error observed "+L),v(L)}))}})}},{key:"listenForScreenSharingStopped",value:function(m){var k=this;m.addEventListener("ended",function(v){k.log_.info("screen sharing was stopped because the video track is ended"),k.emitter_.emit(i6)})}},{key:"muteAudio",value:function(){var m=ue(Qe(x.prototype),"muteAudio",this).call(this);return m&&(this.log_.info("localStream mute audio"),this.sendMutedFlag(Re,!0)),m}},{key:"muteVideo",value:function(){var m=ue(Qe(x.prototype),"muteVideo",this).call(this);return m&&(this.log_.info("localStream mute video"),this.sendMutedFlag(Ie,!0)),m}},{key:"unmuteAudio",value:function(){var m=ue(Qe(x.prototype),"unmuteAudio",this).call(this);return m&&(this.log_.info("localStream unmute audio"),this.sendMutedFlag(Re,!1)),m}},{key:"unmuteVideo",value:function(){var m=ue(Qe(x.prototype),"unmuteVideo",this).call(this);return m&&(this.log_.info("localStream unmute video"),this.sendMutedFlag(Ie,!1)),m}},{key:"sendMutedFlag",value:function(m,k){this.setMuteState(m,k);var v=this.getConnection();if(v){v.sendMutedFlag(this.muteState_,this);var w=v.getUserId(),L=v.getTinyId(),E="".concat(k?tn:Sr," local ").concat(m," track");vn(w,{eventId:m===Re?k?WU:qU:k?JU:KU,eventDesc:E,timestamp:an(),userId:w,tinyId:L})}}},{key:"setMuteState",value:function(m,k){this.muteState_[m]=k,this.log_.info("set ".concat(m," muted state: [").concat(k?"mute":"unmute","]"))}},{key:"setAudioProfile",value:(I=H(f().mark(function m(k){var v,w,L;return f().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(G(k)==="object"?v=k:(v=zI.get(k))===void 0&&(v=zI.get("standard")),this.log_.info("setAudioProfile: "+JSON.stringify(v)),!(w=this.getAudioTrack())){E.next=6;break}return E.next=6,w.applyConstraints(v);case 6:if(L=this.audioProfile_.bitrate!==v.bitrate,this.audioProfile_=J(J({},this.audioProfile_),v),!L||!this.connection_){E.next=12;break}return E.next=11,this.connection_.setBandwidth({bandwidth:this.audioProfile_.bitrate,type:Re});case 11:this.connection_.sendMediaSettings(this);case 12:case"end":return E.stop()}},m,this)})),function(m){return I.apply(this,arguments)})},{key:"setVideoProfile",value:(b=H(f().mark(function m(k){var v,w,L,E;return f().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(!this.connection_||Hk()){N.next=2;break}throw new te({code:Z.NOT_SUPPORTED,message:ie({key:F3})});case 2:if(bi(k)?w=J(J({},this.videoProfile_),k):Bt(k)&&(w=Jv.get(k),ge(w)&&(w=Jv.get("480p_2"))),(v=this.client_)!==null&&v!==void 0&&v.get2k4kFlag()&&(this.client_.get2k4kFlag()!==1&&!this.screen_&&w.height*w.width>=3686400?(w.width=1920,w.height=1080,this.log_.warn(rS)):Ai.handleFunctionState({fnName:"2K_4K"})),w&&w.width*w.height>921600&&E4&&(w.width=1280,w.height=720,this.log_.warn("reset to 1280 * 720 on iOS 13~14")),this.log_.info("setVideoProfile "+JSON.stringify(w)),!(L=this.getVideoTrack())){N.next=10;break}return N.next=10,L.applyConstraints(w);case 10:if(E=this.videoProfile_.bitrate!==w.bitrate,this.videoProfile_=w,!E||!this.connection_){N.next=16;break}return N.next=15,this.connection_.setBandwidth({bandwidth:w.bitrate,type:Ie,videoType:Bu});case 15:this.connection_.sendMediaSettings(this);case 16:case"end":return N.stop()}},m,this)})),function(m){return b.apply(this,arguments)})},{key:"getVideoBitrate",value:function(){return this.screen_?this.screenProfile_.bitrate:this.videoProfile_.bitrate}},{key:"getAudioBitrate",value:function(){return this.audioProfile_.bitrate}},{key:"setScreenProfile",value:function(m){var k=m;Bt(m)&&(k=qv.get(m)||qv.get("1080p")),this.log_.info("setScreenProfile "+JSON.stringify(m)),this.screenProfile_=k}},{key:"getVideoProfile",value:function(){return this.screen_?this.screenProfile_:this.videoProfile_}},{key:"getAudioProfile",value:function(){return this.audioProfile_}},{key:"setVideoContentHint",value:function(m){var k=this.getVideoTrack();k&&"contentHint"in k&&(this.log_.info("set video track contentHint to: "+m),k.contentHint=m,k.contentHint!==m&&this.log_.warn("Invalid video track contentHint: "+m))}},{key:"switchDevice",value:(h=H(f().mark(function m(k,v){var w,L,E,N,T,y,D,A,U,S,p,_,P,M,B,X,q,le;return f().wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:if(this.mediaStream_&&this.cameraId_!==v&&this.facingMode_!==v){ce.next=2;break}return ce.abrupt("return");case 2:if(L=k===Ie,!(w=k===Re)||v!==this.microphoneId_){ce.next=11;break}if(v===Ku){ce.next=7;break}return ce.abrupt("return");case 7:return ce.next=9,h6(this.microphoneGroupId_,this.microphoneLabel_);case 9:if(!ce.sent){ce.next=11;break}return ce.abrupt("return");case 11:return this.setIsReadyToPublish(!1),this.log_.info("switchDevice "+k+" to: "+v),w&&(E=this.getAudioTrack(),N=this.getMicrophoneTrackMixed(),E&&E.stop(),N&&N.stop()),L&&((T=this.getVideoTrack())&&T.stop(),_p&&(y=this.getAudioTrack())&&(this.log_.info("stop audio track first in huawei env"),y.stop())),ce.prev=15,ce.next=18,zv({audio:w||_p,video:L,facingMode:v===fb||v===pb?v:void 0,cameraId:L?v:this.cameraId_,microphoneId:w?v:this.microphoneId_,width:this.videoProfile_.width,height:this.videoProfile_.height,frameRate:this.videoProfile_.frameRate,sampleRate:this.audioProfile_.sampleRate,channelCount:this.audioProfile_.channelCount,autoGainControl:this.audioProfile_.autoGainControl,noiseSuppression:this.audioProfile_.noiseSuppression,echoCancellation:this.audioProfile_.echoCancellation,useExact:!0,retryWhenExactFailed:!1});case 18:if(D=ce.sent,A=null,!w){ce.next=34;break}if(!(U=D.getAudioTracks()[0])||!this.isAudioTrackMixed()){ce.next=31;break}return S=this.getAudioTrack(),p=It.AudioMixerPlugin.getAudioTrackMap(),ce.next=27,It.AudioMixerPlugin.mix({targetTrack:U,sourceList:p.get(S.id).sourceList,trackList:p.get(S.id).trackList});case 27:_=ce.sent,A=_,ce.next=32;break;case 31:A=U;case 32:ce.next=43;break;case 34:if(!(A=D.getVideoTracks()[0])||!this.isVideoTrackBeautified()){ce.next=39;break}return ce.next=38,this.generateBeautyTrack(A);case 38:A=ce.sent;case 39:if(!(P=D.getAudioTracks()[0])||!_p){ce.next=43;break}return ce.next=43,this.replaceTrack(P);case 43:return ce.next=45,this.replaceTrack(A);case 45:(M=this.getConnection())&&(B=M.getUserId(),X=M.getTinyId(),q=QU,le="switch camera",w&&(q=YU,le="switch microphone"),vn(B,{eventId:q,eventDesc:le,timestamp:an(),userId:B,tinyId:X})),this.log_.info("switch ".concat(w?"microphone":"camera"," success ")),w&&(this.audio_=!0),L&&(this.video_=!0,this.facingMode_=v===pb||v===fb?v:""),this.updateDeviceIdInUse(),this.setIsReadyToPublish(!0),ce.next=59;break;case 54:throw ce.prev=54,ce.t0=ce.catch(15),this.log_.error(ce.t0),w?this.recoverCapture({audio:!0,video:!1,microphoneId:this.microphoneId_}):this.recoverCapture({audio:!1,video:!0,cameraId:this.cameraId_,facingMode:this.facingMode_}),ce.t0;case 59:case"end":return ce.stop()}},m,this,[[15,54]])})),function(m,k){return h.apply(this,arguments)})},{key:"addTrack",value:(u=H(f().mark(function m(k){var v,w,L;return f().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(E.prev=0,k.kind===Ie&&la&&(v=k.getSettings(),!this.videoSetting_||v.width===this.videoSetting_.width&&v.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(v.width," x ").concat(v.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.isAddingTrack_=!0,this.keepMuteState(k),this.mediaStream_.addTrack(k),!(w=this.getConnection())){E.next=11;break}return L=null,k.kind===Ie&&(al||il)&&VS(k)&&(L=this.getCanvasTrack()),E.next=11,w.addTrack(L||k,this);case 11:k.kind===Re?(this.audio_=!0,this.updateAudioPlayingState(!0),this.captureVolume_!==100&&this.setAudioCaptureVolume(this.captureVolume_)):(this.video_=!0,this.updateVideoPlayingState(!0)),this.isAddingTrack_=!1,E.next=20;break;case 15:throw E.prev=15,E.t0=E.catch(0),this.mediaStream_.removeTrack(k),this.isAddingTrack_=!1,E.t0;case 20:case"end":return E.stop()}},m,this,[[0,15]])})),function(m){return u.apply(this,arguments)})},{key:"removeTrack",value:(l=H(f().mark(function m(k){var v;return f().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(w.prev=0,this.isRemovingTrack_=!0,!(v=this.getConnection())){w.next=17;break}if(k.kind!==Ie||!al&&!il||!this.canvasTrack_){w.next=10;break}return w.next=7,v.removeTrack(this.canvasTrack_,this);case 7:this.clearCanvas(),w.next=17;break;case 10:if(k.kind!==Re||!this.gain_.audioTrack){w.next=15;break}return w.next=13,v.removeTrack(this.gain_.audioTrack,this);case 13:w.next=17;break;case 15:return w.next=17,v.removeTrack(k,this);case 17:this.mediaStream_.removeTrack(k),k.kind===Re?(this.audio_=!1,this.updateAudioPlayingState(!1),this.stopGainNode()):(this.video_=!1,this.updateVideoPlayingState(!1)),this.isRemovingTrack_=!1,w.next=26;break;case 22:throw w.prev=22,w.t0=w.catch(0),this.isRemovingTrack_=!1,w.t0;case 26:case"end":return w.stop()}},m,this,[[0,22]])})),function(m){return l.apply(this,arguments)})},{key:"replaceTrack",value:(s=H(f().mark(function m(k){var v,w,L;return f().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(k.kind===Ie&&la&&(v=k.getSettings(),!this.videoSetting_||v.width===this.videoSetting_.width&&v.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(v.width," x ").concat(v.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(k),w=this.mediaStream_,k.kind!==Re){E.next=12;break}if(w.removeTrack(w.getAudioTracks()[0]),w.addTrack(k),ue(Qe(x.prototype),"restartAudio",this).call(this),!this.gain_.gainNode){E.next=10;break}return this.reconnectGainNode(k),E.abrupt("return");case 10:E.next=15;break;case 12:w.removeTrack(w.getVideoTracks()[0]),w.addTrack(k),ue(Qe(x.prototype),"restartVideo",this).call(this);case 15:if(!(L=this.getConnection())){E.next=21;break}if(k.kind!==Ie||!al&&!il||!this.canvasTrack_){E.next=19;break}return E.abrupt("return");case 19:return E.next=21,L.replaceTrack(k,this);case 21:case"end":return E.stop()}},m,this)})),function(m){return s.apply(this,arguments)})},{key:"recoverCapture",value:(a=H(f().mark(function m(k){var v,w,L,E,N,T,y,D,A,U,S,p,_,P,M,B,X;return f().wrap(function(q){for(;;)switch(q.prev=q.next){case 0:if(!(!this.mediaStream_||!this.enableAutoRecoverCapture_||k.audio&&!k.video&&this.isAudioRecovering_||k.video&&!k.audio&&this.isVideoRecovering_)){q.next=2;break}return q.abrupt("return");case 2:return k.audio&&(this.isAudioRecovering_=!0),k.video&&(this.isVideoRecovering_=!0),this.log_.warn("recoverCapture() trying "+JSON.stringify(k)),v=this.audio_&&k.audio,w=this.video_&&k.video,q.prev=7,q.next=10,It.getCameras();case 10:return L=q.sent,q.next=13,It.getMicrophones();case 13:if(E=q.sent,w&&L.length===0&&(w=!1,this.log_.warn("recoverCapture() video flag is true, but no camera detected, set video to false")),v&&E.length===0&&(v=!1,this.log_.warn("recoverCapture() audio flag is true, but no microphone detected, set audio to false")),v||w){q.next=21;break}return k.audio&&(this.isAudioRecovering_=!1),k.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() both audio and video are false, aborted"),q.abrupt("return");case 21:return N=k&&L.findIndex(function(le){return le.deviceId===k.cameraId})>=0,T=k&&E.findIndex(function(le){return le.deviceId===k.microphoneId})>=0,v&&((y=this.getAudioTrack())===null||y===void 0||y.stop()),w&&((D=this.getVideoTrack())===null||D===void 0||D.stop()),q.next=27,zv({audio:v,video:w,cameraId:N?k.cameraId:void 0,microphoneId:T?k.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,autoGainControl:this.audioProfile_.autoGainControl,noiseSuppression:this.audioProfile_.noiseSuppression,echoCancellation:this.audioProfile_.echoCancellation});case 27:A=q.sent,U=A.getTracks(),S=0;case 30:if(!(S<U.length)){q.next=59;break}if((p=U[S]).kind!==Re||!this.isAudioTrackMixed()){q.next=45;break}if(_=this.getAudioTrack(),P=It.AudioMixerPlugin.getAudioTrackMap(),(M=P.get(_.id)).hasMicrophone){q.next=39;break}return p.stop(),q.abrupt("continue",56);case 39:return q.next=41,It.AudioMixerPlugin.mix({targetTrack:p,sourceList:M.sourceList,trackList:M.trackList});case 41:return B=q.sent,q.next=44,this.replaceTrack(B);case 44:return q.abrupt("continue",56);case 45:if(p.kind!==Ie||!this.isVideoTrackBeautified()){q.next=52;break}return q.next=48,this.generateBeautyTrack(p);case 48:return X=q.sent,q.next=51,this.replaceTrack(X);case 51:return q.abrupt("continue",56);case 52:return q.next=54,this.replaceTrack(p);case 54:if(p.readyState!=="ended"){q.next=56;break}throw new Error("new track is failed, muted ".concat(p.muted," readyState ").concat(p.readyState));case 56:S++,q.next=30;break;case 59:this.updateDeviceIdInUse(),ke.logSuccessEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:Nb}),k.audio&&(this.isAudioRecovering_=!1),k.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() successfully"),this.emitter_.emit(o6,{isCamera:k.video,isMicrophone:k.audio,cameraId:this.cameraId_,microphoneId:this.microphoneId_}),q.next=73;break;case 67:throw q.prev=67,q.t0=q.catch(7),k.audio&&(this.isAudioRecovering_=!1),k.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() failed, "+q.t0),q.t0;case 73:case"end":return q.stop()}},m,this,[[7,67]])})),function(m){return a.apply(this,arguments)})},{key:"updateDeviceIdInUse",value:function(){var m=this;if(!this.mediaStream_)return this.cameraId_="",this.cameraGroupId_="",this.microphoneId_="",void(this.microphoneGroupId_="");la&&this.mediaStream_.getTracks().forEach(function(w){if(w.kind===Re&&m.isAudioTrackMixed()){var L=m.getMicrophoneTrackMixed();if(L){var E=L.getSettings(),N=E.deviceId,T=E.groupId;N&&(m.microphoneId_=N,m.microphoneGroupId_=T,m.microphoneLabel_=L.label)}}else if(w.kind===Ie&&m.isVideoTrackBeautified()){var y=m.getBeautyOriginTrack();if(y){var D=y.getSettings(),A=D.deviceId,U=D.groupId,S=D.facingMode;A&&(m.cameraId_=A,m.cameraGroupId_=U),S&&(m.facingMode_=S)}}else{var p=w.getSettings(),_=p.deviceId,P=p.groupId,M=p.facingMode;_&&(w.kind===Re?(m.microphoneId_=_,m.microphoneGroupId_=P,m.microphoneLabel_=w.label):w.kind!==Ie||m.screen_||(m.cameraId_=_,m.cameraGroupId_=P,M&&(m.facingMode_=M)))}});var k=this.mediaStream_.getAudioTracks(),v=this.mediaStream_.getVideoTracks();k&&k.length===0&&(this.microphoneId_="",this.microphoneGroupId_=""),v&&v.length===0&&(this.cameraId_="",this.cameraGroupId_="")}},{key:"isAudioTrackMixed",value:function(){if(It.AudioMixerPlugin){var m=It.AudioMixerPlugin.getAudioTrackMap(),k=this.getAudioTrack();if(m&&k&&m.has(k.id))return!0}return!1}},{key:"getMicrophoneTrackMixed",value:function(){if(It.AudioMixerPlugin){var m=It.AudioMixerPlugin.getAudioTrackMap(),k=this.getAudioTrack();if(m&&k&&m.has(k.id)){var v=m.get(k.id);return v.hasMicrophone?v.microphoneTrack:null}}return null}},{key:"isVideoTrackBeautified",value:function(){if(It.beautyTrackMap){var m=It.beautyTrackMap,k=this.getVideoTrack();if(k&&m.has(k.id))return!0}return!1}},{key:"getBeautyOriginTrack",value:function(){if(It.beautyTrackMap){var m=It.beautyTrackMap,k=this.getVideoTrack();if(k&&m.has(k.id)){var v=m.get(k.id);if(v.originTrack)return v.originTrack}}return null}},{key:"generateBeautyTrack",value:(c=H(f().mark(function m(k){var v,w,L,E;return f().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(v=null,w=this.getVideoTrack(),L=It.beautyTrackMap.get(w.id),E=L.param,L.type){N.next=8;break}v=L.pluginInstance.generateBeautyTrack(k),N.next=22;break;case 8:N.t0=L.type,N.next=N.t0==="beauty"?11:N.t0==="virtual"?13:N.t0==="mixed"?17:21;break;case 11:return v=L.pluginInstance.generateBeautyTrack(k),N.abrupt("break",22);case 13:return N.next=15,L.pluginInstance.generateVirtualTrack({videoTrack:k,type:E.type,img:E.img});case 15:case 19:return v=N.sent,N.abrupt("break",22);case 17:return N.next=19,L.pluginInstance.generateMixedTrack({videoTrack:k,type:E.type,img:E.img});case 21:return N.abrupt("break",22);case 22:return L.pluginInstance.deleteSource(w.id),this.log_.info("regenerate beauty track, track id = ".concat(k.id)),N.abrupt("return",v);case 25:case"end":return N.stop()}},m,this)})),function(m){return c.apply(this,arguments)})},{key:"getScreen",value:function(){return this.screen_}},{key:"hasScreenTrack",value:function(){if(this.screen_)return!0;var m=this.getVideoTrack();return!!m&&(m.contentHint===mb||m.contentHint===NM)}},{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(m){this.isReadyToPublish_=m}},{key:"setPublishState",value:function(m){this.publishState_=m}},{key:"setBeautyStatus",value:function(m){this.beautyStatus_=!!m}},{key:"getBeautyStatus",value:function(){return this.beautyStatus_}},{key:"syncMuteState",value:function(){var m=this.getAudioTrack(),k=this.getVideoTrack();if(m){var v=!m.enabled;this.setMuteState(Re,v)}if(k){var w=!k.enabled;this.setMuteState(Ie,w)}this.connection_&&this.connection_.sendMutedFlag(this.muteState_,this)}},{key:"keepMuteState",value:function(m){m instanceof window.MediaStreamTrack&&this.muteState_[m.kind]&&(m.enabled=!1,this.log_.warn("prev ".concat(m.kind," track is muted, keep mute state")))}},{key:"onVideoTrackStopped",value:(o=H(f().mark(function m(k){var v,w,L=this;return f().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(v=k.stream,w=k.type,v===this&&this.video_&&this.cameraId_&&d6(this.getVideoTrack())&&!this.isVideoRecovering_&&(w!==tn||!ec||!na)){E.next=3;break}return E.abrupt("return");case 3:if(!(Date.now()-this.prevVideoRecoverTime_<Xu)){E.next=6;break}return setTimeout(function(){return L.onVideoTrackStopped({stream:v,type:w})},Xu),E.abrupt("return");case 6:w===tn?setTimeout(function(){var N=L.getVideoTrack();N!=null&&N.muted&&document.visibilityState==="visible"&&L.recoverVideoCapture(w)},5e3):this.recoverVideoCapture(w);case 7:case"end":return E.stop()}},m,this)})),function(m){return o.apply(this,arguments)})},{key:"onAudioTrackStopped",value:(r=H(f().mark(function m(k){var v,w,L=this;return f().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(v=k.stream,w=k.type,!(v!==this||!this.audio_||!this.microphoneId_||this.isAudioRecovering_||w===tn&&ec&&na)){E.next=3;break}return E.abrupt("return");case 3:if(!(Date.now()-this.prevAudioRecoverTime_<Xu)){E.next=6;break}return setTimeout(function(){return L.onAudioTrackStopped({stream:v,type:w})},Xu),E.abrupt("return");case 6:w===tn?setTimeout(function(){var N=L.getAudioTrack();N!=null&&N.muted&&document.visibilityState==="visible"&&L.recoverAudioCapture(w)},5e3):this.recoverAudioCapture(w);case 7:case"end":return E.stop()}},m,this)})),function(m){return r.apply(this,arguments)})},{key:"recoverAudioCapture",value:(i=H(f().mark(function m(k){return f().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return this.prevAudioRecoverTime_=Date.now(),ke.uploadEvent({log:"stat-local-audio-".concat(k),userId:this.userId_}),v.t0=this,v.next=5,this.getRecoverCaptureDeviceId(!1);case 5:v.t1=v.sent,v.t2={audio:!0,video:!1,microphoneId:v.t1},v.t0.recoverCapture.call(v.t0,v.t2);case 8:case"end":return v.stop()}},m,this)})),function(m){return i.apply(this,arguments)})},{key:"recoverVideoCapture",value:(n=H(f().mark(function m(k){return f().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return this.prevVideoRecoverTime_=Date.now(),ke.uploadEvent({log:"stat-local-video-".concat(k),userId:this.userId_}),v.t0=this,v.next=5,this.getRecoverCaptureDeviceId(!0);case 5:v.t1=v.sent,v.t2={audio:!1,video:!0,cameraId:v.t1},v.t0.recoverCapture.call(v.t0,v.t2);case 8:case"end":return v.stop()}},m,this)})),function(m){return n.apply(this,arguments)})},{key:"getRecoverCaptureDeviceId",value:(t=H(f().mark(function m(){var k,v,w,L,E=arguments;return f().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(k=!(E.length>0&&E[0]!==void 0)||E[0],!(v=k?this.cameraId_:this.microphoneId_)||!this.enableAutoRecoverOther_){N.next=17;break}if(_a.has(v)?_a.set(v,_a.get(v)+1):_a.set(v,1),!((w=_a.get(v))>=3)){N.next=17;break}if(!k){N.next=12;break}return N.next=9,It.getCameras();case 9:N.t0=N.sent.find(function(T){return!_a.has(T.deviceId)}),N.next=15;break;case 12:return N.next=14,It.getMicrophones();case 14:N.t0=N.sent.find(function(T){return!_a.has(T.deviceId)});case 15:(L=N.t0)&&(this.log_.warn("".concat(k?"camera":"mic"," ").concat(v," capture fail ").concat(w," times, change new ").concat(L.deviceId)),v=L.deviceId);case 17:return N.abrupt("return",v);case 18:case"end":return N.stop()}},m,this)})),function(){return t.apply(this,arguments)})},{key:"setAudioVolume",value:function(m){ue(Qe(x.prototype),"setAudioVolume",this).call(this,m)}},{key:"clearCanvas",value:function(){this.canvasInterval_&&(mt.clearTask(this.canvasInterval_),this.canvasInterval_=null,this.canvas_=null,this.canvasTrack_=null)}},{key:"getCanvasTrack",value:function(){var m=this;if(this.canvasTrack_)return this.canvasTrack_;this.log_.info("gen canvas track");var k=this.getVideoTrack().getSettings(),v=k.width,w=k.height,L=k.frameRate;this.canvas_=document.createElement("canvas");var E=this.canvas_.getContext("2d");this.canvas_.width=v,this.canvas_.height=w,this.canvasInterval_=mt.run(Qu,function(){if(m.hasVideo()){var T=m.getVideoTrack().getSettings();T.width===m.canvas_.width&&T.height===m.canvas_.height||(m.canvas_.width=T.width,m.canvas_.height=T.height)}m.videoPlayer_&&m.videoPlayer_.element_&&E.drawImage(m.videoPlayer_.element_,0,0,m.canvas_.width,m.canvas_.height)},{fps:Math.max(15,L)});var N=this.canvas_.captureStream();return this.canvasTrack_=N.getVideoTracks()[0],this.canvasTrack_}},{key:"setClient",value:function(m,k){m&&(this.log_.setUserId(m.getUserId()),this.log_.setSdkAppId(m.getSDKAppId()),k||this.syncMuteState()),this.client_=m}},{key:"setAudioCaptureVolume",value:function(){var m=this,k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:100;if(!this.hasAudio()||k<0||!km())return!1;if(this.captureVolume_===k)return!0;this.captureVolume_=k,this.log_.info("setCaptureVolume "+k),k/=100;var v=HS();if(this.gain_.gainNode)this.gain_.gainNode.gain.value=k;else{var w,L=new MediaStream;L.addTrack(this.getAudioTrack());var E=v.createMediaStreamDestination(),N=v.createMediaStreamSource(L),T=v.createGain();T.gain.value=k,N.connect(T),T.connect(E);var y=E.stream.getAudioTracks()[0],D=function(A){return m.log_.info("gained audio track ".concat(A))};y.onmute=function(){return D("muted")},y.onunmute=function(){return D("unmuted")},y.onended=function(){return D("ended")},this.gain_={source:N,audioTrack:y,gainNode:T},(w=this.connection_)===null||w===void 0||w.replaceTrack(y),ue(Qe(x.prototype),"restartAudio",this).call(this)}return!0}},{key:"getGainedTrack",value:function(){return this.gain_.audioTrack}},{key:"reconnectGainNode",value:function(m){this.log_.warn("reconnect gain node");var k=new MediaStream;k.addTrack(m);var v=HS().createMediaStreamSource(k);v.connect(this.gain_.gainNode),this.gain_.source.disconnect(),this.gain_.source=v}},{key:"stopGainNode",value:function(){var m=this.gain_,k=m.audioTrack,v=m.source,w=m.gainNode;w&&(v.disconnect(),w.disconnect(),k.onmute=null,k.onunmute=null,k.onended=null,k.stop(),this.gain_={source:null,gainNode:null,audioTrack:null}),this.captureVolume_=100}},{key:"close",value:function(){this.setIsReadyToPublish(!1),this.stopGainNode(),ue(Qe(x.prototype),"close",this).call(this)}},{key:"setIsAIDenoiser",value:function(m){this.isAIDenoiser=m}}]),x}(AI),K(nt.prototype,"setAudioProfile",[DI],Object.getOwnPropertyDescriptor(nt.prototype,"setAudioProfile"),nt.prototype),K(nt.prototype,"setVideoProfile",[OI],Object.getOwnPropertyDescriptor(nt.prototype,"setVideoProfile"),nt.prototype),K(nt.prototype,"setScreenProfile",[LI],Object.getOwnPropertyDescriptor(nt.prototype,"setScreenProfile"),nt.prototype),K(nt.prototype,"setVideoContentHint",[MI],Object.getOwnPropertyDescriptor(nt.prototype,"setVideoContentHint"),nt.prototype),K(nt.prototype,"switchDevice",[NI],Object.getOwnPropertyDescriptor(nt.prototype,"switchDevice"),nt.prototype),K(nt.prototype,"addTrack",[UI],Object.getOwnPropertyDescriptor(nt.prototype,"addTrack"),nt.prototype),K(nt.prototype,"removeTrack",[VI],Object.getOwnPropertyDescriptor(nt.prototype,"removeTrack"),nt.prototype),K(nt.prototype,"replaceTrack",[jI],Object.getOwnPropertyDescriptor(nt.prototype,"replaceTrack"),nt.prototype),K(nt.prototype,"recoverCapture",[BI],Object.getOwnPropertyDescriptor(nt.prototype,"recoverCapture"),nt.prototype),K(nt.prototype,"setAudioCaptureVolume",[FI,HI],Object.getOwnPropertyDescriptor(nt.prototype,"setAudioCaptureVolume"),nt.prototype),nt),WI={voiceActivityDetection:!1},OF=(GI=Lo({retries:1,timeout:0,onRetrying:function(e){this.log_.warn("connection timeout, retrying [".concat(e,"]"))},onError:function(e,t,n){e.message.includes("timeout")?(this.reset(),this.initialize(),t()):n(e)}}),Tc=function(e){Et(N,e);var t,n,i,r,o,c,a,s,l,u,h,b,I,R,x,m,k,v,w,L,E=Rr(N);function N(T){var y;return Q(this,N),(y=E.call(this,T)).localStream_=null,y.exchangeSDPTimeout_=-1,y.localAuxStream_=null,y.publishingStream_=null,y.isPublishingAuxStream_=!1,y.smallGenerator_=null,y.isSDPExchanging_=!1,y.ssrc_={audio:0,video:0,small:0,auxiliary:0},y.mediaSettings_={videoCodec:"",videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0,auxVideoWidth:0,auxVideoHeight:0,auxVideoFps:0,auxVideoBps:0},y.mixedAudioTrack_=null,y}return xe(N,[{key:"isMainStreamPublished",get:function(){return!!this.localStream_}},{key:"isAuxStreamPublished",get:function(){return!!this.localAuxStream_}},{key:"publishState",get:function(){var T=this,y={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this.peerConnection_){var D,A,U,S,p=this.peerConnection_.getSenders();p&&(Ii()?(y.audio=!((D=p[0])===null||D===void 0||!D.track),y.bigVideo=!((A=p[1])===null||A===void 0||!A.track),y.smallVideo=!((U=p[2])===null||U===void 0||!U.track),y.auxVideo=!((S=p[3])===null||S===void 0||!S.track)):p.forEach(function(_){_.track&&(_.track.kind===Re?y.audio=!0:(y.bigVideo=!0,T.smallGenerator_&&(y.smallVideo=!0)))}))}return y}},{key:"initialize",value:function(){ue(Qe(N.prototype),"initialize",this).call(this),this.installEvents()}},{key:"reset",value:function(){this.isReconnecting_&&this.stopReconnection(),this.closePeerConnection(),this.uninstallEvents(),this.clearExchangeSDPTimeout(),this.localStream_&&this.localStream_.clearCanvas()}},{key:"close",value:function(){ue(Qe(N.prototype),"close",this).call(this),this.reset(),this.emitConnectionStateChangedEvent(on),this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null)}},{key:"installEvents",value:function(){this.emitter_.on(et.ERROR,this.handleError,this),this.emitter_.on(et.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"uninstallEvents",value:function(){this.emitter_.off(et.ERROR,this.handleError,this),this.emitter_.off(et.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"publish",value:(L=H(f().mark(function T(y,D){var A,U,S,p;return f().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(this.publishingStream_=y,this.isPublishingAuxStream_=D,U=y.getVideoTrack(),S=null,!U||D||!this.client_.getIsEnableSmallStream()){_.next=9;break}return this.smallGenerator_=new Yl(y),_.next=8,this.smallGenerator_.initialize();case 8:S=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_);case 9:if(p=y.getVideoProfile(),!this.client_.get2k4kFlag()){_.next=18;break}if(this.client_.get2k4kFlag()===1||y.getScreen()||!(p.height*p.width>=3686400)){_.next=18;break}return p.width=1920,p.height=1080,this.log_.warn(rS),_.next=18,y.setVideoProfile(p);case 18:if(!(ta&&lo()===115&&p.width*p.height<=230400)){_.next=22;break}return this.log_.warn("fallback video to 480p"),_.next=22,y.setVideoProfile("480p_2");case 22:if(this.updateMediaSettings(y,D),!vl()){_.next=33;break}if(!_i||OS!==11){_.next=29;break}return _.next=27,this.publishByAddTrack(y,S);case 27:_.next=31;break;case 29:return _.next=31,this.publishByTransceiver(y,S,D);case 31:_.next=35;break;case 33:return _.next=35,this.publishByAddTrack(y,S);case 35:return this.publishingStream_=null,this.isPublishingAuxStream_=!1,D?this.localAuxStream_=y:this.localStream_=y,(A=this.sei_)===null||A===void 0||A.handleEncodedStreams(),_.abrupt("return",y);case 40:case"end":return _.stop()}},T,this)})),function(T,y){return L.apply(this,arguments)})},{key:"publishByTransceiver",value:(w=H(f().mark(function T(y,D,A){var U,S,p,_,P,M,B;return f().wrap(function(X){for(;;)switch(X.prev=X.next){case 0:if(this.log_.info("publish by transceiver"),U=y.getMediaStream(),S=y.getAudioTrack(),p=y.getVideoTrack(),_=null,(al||il)&&VS(p)&&(_=y.getCanvasTrack()),(P=this.peerConnection_.getTransceivers()).length!==0){X.next=16;break}return this.peerConnection_.addTransceiver(S||Re,{direction:mi,streams:[U]}),this.peerConnection_.addTransceiver(A?Ie:_||p||Ie,{direction:mi,streams:[U]}),this.peerConnection_.addTransceiver(D||Ie,{direction:mi,streams:[U]}),this.peerConnection_.addTransceiver(A?_||p:Ie,{direction:mi,streams:[U]}),X.next=14,this.connect();case 14:X.next=46;break;case 16:if(M=[],!S){X.next=29;break}if(!P[0].sender.track){X.next=24;break}return this.mixAudioTrack(P[0].sender.track,S),X.next=22,P[0].sender.replaceTrack(this.mixedAudioTrack_);case 22:X.next=27;break;case 24:return X.next=26,P[0].sender.replaceTrack(S);case 26:M.push(0);case 27:return X.next=29,this.setBandwidth({bandwidth:y.getAudioBitrate(),type:Re});case 29:if(!p){X.next=42;break}return B=A?3:1,X.next=33,P[B].sender.replaceTrack(_||p);case 33:return X.next=35,this.setBandwidth({bandwidth:y.getVideoBitrate(),type:Ie,videoType:A?gt:Bu,scaleResolutionDownBy:y.scaleResolutionDownBy});case 35:if(M.push(B),!D){X.next=42;break}return X.next=39,P[2].sender.replaceTrack(D);case 39:return X.next=41,this.setBandwidth({bandwidth:this.client_.smallStreamConfig.bitrate,type:Ie,videoType:Mr});case 41:M.push(2);case 42:return X.next=44,this.setTransceiverDirection(mi,M);case 44:return X.next=46,this.doPublishChange();case 46:case"end":return X.stop()}},T,this)})),function(T,y,D){return w.apply(this,arguments)})},{key:"publishByAddTrack",value:(v=H(f().mark(function T(y,D){var A,U,S,p;return f().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return this.log_.info("publish by addtrack"),A=y.getMediaStream(),U=y.getAudioTrack(),S=y.getVideoTrack(),U&&this.peerConnection_.addTrack(U,A),S&&(this.peerConnection_.addTrack(S,A),D&&((p=new MediaStream).addTrack(D),this.peerConnection_.addTrack(D,p))),_.next=8,this.connect();case 8:case"end":return _.stop()}},T,this)})),function(T,y){return v.apply(this,arguments)})},{key:"unpublish",value:(k=H(f().mark(function T(y){var D,A,U,S;return f().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(Ii()){p.next=2;break}return p.abrupt("return",this.doUnpublish());case 2:if(D=y.getAudioTrack(),A=y===this.localAuxStream_,U=[],!this.peerConnection_){p.next=33;break}if(S=this.peerConnection_.getSenders(),!D){p.next=18;break}if(!this.mixedAudioTrack_){p.next=15;break}return this.log_.info("has mixed audioTrack, use another audioTrack"),p.next=12,S[0].replaceTrack(A?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 12:this.destroyMixedAudioTrack(),p.next=18;break;case 15:return p.next=17,S[0].replaceTrack(null);case 17:U.push(0);case 18:if(!A){p.next=26;break}return p.next=21,S[3].replaceTrack(null);case 21:this.localAuxStream_=null,this.mediaSettings_=J(J({},this.mediaSettings_),{},{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),U.push(3),p.next=33;break;case 26:return p.next=28,S[1].replaceTrack(null);case 28:return p.next=30,S[2].replaceTrack(null);case 30:this.localStream_=null,this.mediaSettings_=J(J({},this.mediaSettings_),{},{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),U.push(1,2);case 33:if(!this.localStream_&&!this.localAuxStream_){p.next=40;break}return p.next=36,this.setTransceiverDirection(oo,U);case 36:return p.next=38,this.doPublishChange();case 38:p.next=42;break;case 40:return p.next=42,this.doUnpublish();case 42:case"end":return p.stop()}},T,this)})),function(T){return k.apply(this,arguments)})},{key:"doPublishChange",value:(m=H(f().mark(function T(){var y,D;return f().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:return y={state:this.publishState,constraintConfig:this.mediaSettings_},A.next=3,this.signalChannel_.sendWaitForResponse({command:IU,data:y,responseCommand:st.PUBLISH_STATE_CHANGE_RESULT});case 3:D=A.sent,this.checkPublishResultCode(D.data.code,D.data.message);case 5:case"end":return A.stop()}},T,this)})),function(){return m.apply(this,arguments)})},{key:"doUnpublish",value:function(){var T=this;return this.signalChannel_.sendWaitForResponse({command:gk,commandDesc:"unpublish",responseCommand:st.UNPUBLISH_RESULT}).then(function(){T.close()}).catch(function(){T.close()})}},{key:"updateMediaSettings",value:function(T,y){var D=this;this.localAuxStream_&&T===this.localAuxStream_&&(y=!0);var A=this.client_.getSystemResult().detail,U=A.isH264EncodeSupported,S=A.isVp8EncodeSupported;if(U?this.mediaSettings_.videoCodec="H264":S&&(this.mediaSettings_.videoCodec="VP8"),la){var p=T.getMediaStream();p==null||p.getTracks().forEach(function(_){var P=_.getSettings();if(_.kind===Re){var M=1;P.channelCount&&(M=P.channelCount),D.mediaSettings_.audioChannel=M,D.mediaSettings_.audioBps=1e3*T.getAudioBitrate(),D.mediaSettings_.audioFs=P.sampleRate}else if(_.kind===Ie){if(y)return D.mediaSettings_.auxVideoWidth=P.width,D.mediaSettings_.auxVideoHeight=P.height,D.mediaSettings_.auxVideoFps=P.frameRate,void(D.mediaSettings_.auxVideoBps=1e3*T.getVideoBitrate());D.client_.getIsEnableSmallStream()&&(D.mediaSettings_.smallVideoWidth=D.client_.smallStreamConfig.width,D.mediaSettings_.smallVideoHeight=D.client_.smallStreamConfig.height,D.mediaSettings_.smallVideoFps=D.client_.smallStreamConfig.frameRate,D.mediaSettings_.smallVideoBps=1e3*D.client_.smallStreamConfig.bitrate),D.mediaSettings_.videoWidth=P.width,D.mediaSettings_.videoHeight=P.height,D.mediaSettings_.videoFps=P.frameRate,D.mediaSettings_.videoBps=1e3*T.getVideoBitrate()}})}else this.updateMediaSettingsFromProfile(T);this.log_.info("updateMediaSettings: "+JSON.stringify(this.mediaSettings_))}},{key:"updateMediaSettingsFromProfile",value:function(T){if(T){if(T.hasAudio()){var y=T.getAudioProfile();this.mediaSettings_.audioChannel=y.channelCount,this.mediaSettings_.audioBps=1e3*y.bitrate,this.mediaSettings_.audioFs=y.sampleRate}if(T.hasVideo()){var D=T.getVideoProfile();this.mediaSettings_.videoWidth=D.width,this.mediaSettings_.videoHeight=D.height,this.mediaSettings_.videoFps=D.frameRate,this.mediaSettings_.videoBps=1e3*D.bitrate}}}},{key:"sendMediaSettings",value:function(T){var y=this;this.updateMediaSettings(T),this.signalChannel_.sendWaitForResponse({command:FU,data:this.mediaSettings_,responseCommand:st.UPDATE_CONSTRAINT_CONFIG_RES}).then(function(D){D.data.code!==0&&y.log_.warn(D.data.message)}).catch(this.log_.warn)}},{key:"addTrack",value:(x=H(f().mark(function T(y,D){var A,U;return f().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(this.peerConnection_){S.next=2;break}return S.abrupt("return");case 2:if(U=D===this.localAuxStream_,this.log_.info("is adding ".concat(y.kind," track to current published local ").concat(U?gt:Xe," stream")),(A=this.sei_)===null||A===void 0||A.handleEncodedStreams(),!Ii()){S.next=10;break}return S.next=8,this.addTrackByTransceiver(y,D);case 8:S.next=12;break;case 10:return S.next=12,this.addTrackBySender(y);case 12:vn(this.userId_,{eventId:y.kind===Re?yk:_k,eventDesc:"add ".concat(y.kind," track to current published stream"),timestamp:an(),userId:this.userId_,tinyId:this.tinyId_});case 13:case"end":return S.stop()}},T,this)})),function(T,y){return x.apply(this,arguments)})},{key:"addTrackByTransceiver",value:(R=H(f().mark(function T(y,D){var A,U,S,p;return f().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(A=D===this.localAuxStream_,U=this.peerConnection_.getTransceivers(),y.kind!==Re){_.next=13;break}if(!U[0].sender.track){_.next=9;break}return this.mixAudioTrack(U[0].sender.track,y),_.next=7,U[0].sender.replaceTrack(this.mixedAudioTrack_);case 7:_.next=11;break;case 9:return _.next=11,U[0].sender.replaceTrack(y);case 11:_.next=26;break;case 13:return S=A?3:1,_.next=16,U[S].sender.replaceTrack(y);case 16:if(S!==1||!this.client_.getIsEnableSmallStream()){_.next=23;break}return this.smallGenerator_=new Yl(this.localStream_),_.next=20,this.smallGenerator_.initialize();case 20:return p=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),_.next=23,U[2].sender.replaceTrack(p);case 23:if(U[S].direction!==oo){_.next=26;break}return _.next=26,this.setTransceiverDirection(mi,[S]);case 26:return this.updateMediaSettings(D,A),_.next=29,this.doPublishChange();case 29:case"end":return _.stop()}},T,this)})),function(T,y){return R.apply(this,arguments)})},{key:"addTrackBySender",value:(I=H(f().mark(function T(y){var D,A,U,S,p;return f().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(!(Ii()&&this.peerConnection_.getTransceivers().findIndex(function(P){return P.direction==="stopped"})>=0)){_.next=4;break}return this.log_.warn("transceiver is stopping, negotiate sdp first"),_.next=4,this.updateOffer(cn.REMOVE,y);case 4:if(!(D=this.peerConnection_.getSenders().find(function(P){return P.track&&P.track.kind===y.kind}))){_.next=11;break}return this.log_.warn("sender already exists, remove sender first"),A=D.track,this.removeSender(D),_.next=11,this.updateOffer(cn.REMOVE,A);case 11:if(U=this.localStream_.getMediaStream(),this.peerConnection_.addTrack(y,U),y.kind!==Ie||!this.client_.getIsEnableSmallStream()){_.next=21;break}return this.smallGenerator_=new Yl(this.localStream_),_.next=17,this.smallGenerator_.initialize();case 17:S=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),(p=new MediaStream).addTrack(S),this.peerConnection_.addTrack(S,p);case 21:return _.next=23,this.updateOffer(cn.ADD,y);case 23:case"end":return _.stop()}},T,this)})),function(T){return I.apply(this,arguments)})},{key:"isNeedToResetOfferOrder",value:function(){if(this.sdpSemantics_===Wf||!this.peerConnection_||!this.peerConnection_.localDescription)return!1;for(var T=this.peerConnection_.localDescription.sdp,y=Fr(T),D=0;D<y.media.length;D++)if(y.media[D].mid===0&&y.media[D].type===Ie)return!0;return!1}},{key:"removeSender",value:function(T){var y=null;Ii()&&(y=this.peerConnection_.getTransceivers().find(function(D){return D.sender&&D.sender.track===T.track})),this.peerConnection_.removeTrack(T),y&&ln(y.stop)&&(this.log_.info("stop transceiver"),y.stop())}},{key:"removeTrack",value:(b=H(f().mark(function T(y,D){return f().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(this.peerConnection_){A.next=2;break}return A.abrupt("return");case 2:if(this.log_.info("is removing ".concat(y.kind," track from current published local ").concat(D===this.localAuxStream_?gt:Xe," stream")),!Ii()){A.next=8;break}return A.next=6,this.removeTrackByTransceiver(y,D);case 6:A.next=10;break;case 8:return A.next=10,this.removeTrackBySender(y);case 10:vn(this.userId_,{eventId:y.kind===Re?Sk:bk,eventDesc:"remove ".concat(y.kind," track from current published stream"),timestamp:an(),userId:this.userId_,tinyId:this.tinyId_});case 11:case"end":return A.stop()}},T,this)})),function(T,y){return b.apply(this,arguments)})},{key:"removeTrackByTransceiver",value:(h=H(f().mark(function T(y,D){var A,U,S;return f().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(A=D===this.localAuxStream_,U=this.peerConnection_.getTransceivers(),y.kind!==Re){p.next=13;break}if(!this.mixedAudioTrack_){p.next=9;break}return p.next=6,U[0].sender.replaceTrack(A?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 6:this.destroyMixedAudioTrack(),p.next=11;break;case 9:return p.next=11,U[0].sender.replaceTrack(null);case 11:p.next=23;break;case 13:return S=A?3:1,p.next=16,U[S].sender.replaceTrack(null);case 16:if(S!==1||!this.smallGenerator_){p.next=21;break}return this.smallGenerator_.destroy(),this.smallGenerator_=null,p.next=21,U[2].sender.replaceTrack(null);case 21:return p.next=23,this.setTransceiverDirection(oo,[S]);case 23:return this.updateMediaSettings(D,A),p.next=26,this.doPublishChange();case 26:case"end":return p.stop()}},T,this)})),function(T,y){return h.apply(this,arguments)})},{key:"setTransceiverDirection",value:(u=H(f().mark(function T(y,D){var A,U,S,p,_,P;return f().wrap(function(M){for(;;)switch(M.prev=M.next){case 0:if(Vn){M.next=2;break}return M.abrupt("return");case 2:if(A=!1,U=!1,this.log_.info("setting transceiver ".concat(D.join(",")," direction to ").concat(y)),S=this.peerConnection_.getTransceivers(),D.forEach(function(B){S[B].direction!==y&&(S[B].direction=y,A=!0)}),!A){M.next=14;break}return this.log_.info("updating offer"),M.next=11,this.peerConnection_.createOffer();case 11:return p=M.sent,M.next=14,this.peerConnection_.setLocalDescription(p);case 14:if(_=-1,P=this.peerConnection_.remoteDescription.sdp.split(`\r
63
+ `).map(function(B){if(B.match(new RegExp("a=(".concat(oo,"|").concat(Mf,"|").concat(mi,")")))&&_++,D.includes(_)){if(y===oo&&B.includes("a=".concat(Mf)))return U=!0,"a=".concat(y);if(y===mi&&B.includes("a=".concat(oo)))return U=!0,"a=".concat(Mf)}return B}).join(`\r
64
+ `),!U){M.next=20;break}return this.log_.info("updating answer"),M.next=20,this.peerConnection_.setRemoteDescription({type:"answer",sdp:P});case 20:case"end":return M.stop()}},T,this)})),function(T,y){return u.apply(this,arguments)})},{key:"removeTrackBySender",value:(l=H(f().mark(function T(y){var D,A,U=this;return f().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(y.kind!==Ie||!this.isNeedToResetOfferOrder()){S.next=7;break}return this.reset(),this.initialize(),(D=this.localStream_.getMediaStream())===null||D===void 0||D.removeTrack(y),S.next=6,this.publish(this.localStream_);case 6:return S.abrupt("return");case 7:return(A=this.peerConnection_.getSenders().find(function(p){return p.track===y}))&&(this.removeSender(A),y.kind===Ie&&this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null,this.peerConnection_.getSenders().forEach(function(p){p.track&&p.track.kind===Ie&&U.removeSender(p)}))),S.next=11,this.updateOffer(cn.REMOVE,y);case 11:case"end":return S.stop()}},T,this)})),function(T){return l.apply(this,arguments)})},{key:"replaceTrack",value:(s=H(f().mark(function T(y,D){var A,U,S,p,_,P,M;return f().wrap(function(B){for(;;)switch(B.prev=B.next){case 0:if((U=(A=this.peerConnection_)===null||A===void 0?void 0:A.getSenders())&&U.length!==0){B.next=3;break}throw new te({code:Z.INVALID_OPERATION,message:ie({key:fS})});case 3:if(S=D===this.localAuxStream_,this.log_.info("is replacing ".concat(y.kind," track to current published local ").concat(S?gt:Xe," stream")),y.kind!==Re||!U[0]){B.next=16;break}if(!(this.mixedAudioTrack_&&(p=this.localStream_)!==null&&p!==void 0&&p.hasAudio()&&(_=this.localAuxStream_)!==null&&_!==void 0&&_.hasAudio())){B.next=14;break}return this.destroyMixedAudioTrack(),P=S?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack(),this.mixAudioTrack(y,P),B.next=12,U[0].replaceTrack(this.mixedAudioTrack_);case 12:B.next=16;break;case 14:return B.next=16,U[0].replaceTrack(y);case 16:if(y.kind!==Ie){B.next=32;break}if(D!==this.localStream_||!U[1]){B.next=29;break}return B.next=20,U[1].replaceTrack(y);case 20:if(!this.smallGenerator_||!U[2]){B.next=29;break}return this.log_.info("replacing smallVideo"),this.smallGenerator_.destroy(),this.smallGenerator_=new Yl(this.localStream_),B.next=26,this.smallGenerator_.initialize();case 26:return M=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),B.next=29,U[2].replaceTrack(M);case 29:if(D!==this.localAuxStream_||!U[3]){B.next=32;break}return B.next=32,U[3].replaceTrack(y);case 32:vn(this.userId_,{eventId:y.kind===Re?ZU:$U,eventDesc:"replace ".concat(y.kind," track from current published stream"),timestamp:an(),userId:this.userId_,tinyId:this.tinyId_});case 33:case"end":return B.stop()}},T,this)})),function(T,y){return s.apply(this,arguments)})},{key:"updateOffer",value:(a=H(f().mark(function T(y,D){var A,U,S,p,_,P,M;return f().wrap(function(B){for(;;)switch(B.prev=B.next){case 0:return B.prev=0,B.next=3,this.peerConnection_.createOffer(WI);case 3:return A=B.sent,Vn&&(A.sdp=this.setSDPDirection(A.sdp,"sendrecv")),B.next=7,this.peerConnection_.setLocalDescription(A);case 7:return U=this.updateMediaSettings(this.localStream_||this.localAuxStream_),S={action:y,trackId:D.id,kind:D.kind===Ie?"bigVideo":D.kind,type:"offer",sdp:this.peerConnection_.localDescription.sdp,constraintConfig:U,state:this.publishState},this.log_.info("createOffer success, sending updated offer to remote server"),this.log_.debug("updatedOffer: "+S.sdp),B.next=13,this.signalChannel_.sendWaitForResponse({command:TU,data:S,responseCommand:st.UPDATE_OFFER_RESULT,timeout:1e4,commandDesc:"update offer"});case 13:return p=B.sent,_=p.data,P=_.code,M=_.message,P!==0&&this.checkPublishResultCode(P,M),B.next=18,this.acceptAnswer(p.data.data);case 18:this.updateSSRC(A.sdp),ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:qu,kind:"offer"}),B.next=27;break;case 22:throw B.prev=22,B.t0=B.catch(0),this.log_.error(B.t0),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:qu,kind:"offer",error:B.t0}),B.t0;case 27:case"end":return B.stop()}},T,this,[[0,22]])})),function(T,y){return a.apply(this,arguments)})},{key:"setBandwidth",value:(c=H(f().mark(function T(y){var D,A,U,S,p,_,P,M,B,X;return f().wrap(function(q){for(;;)switch(q.prev=q.next){case 0:if(D=y.bandwidth,A=y.type,U=y.videoType,S=U===void 0?"":U,p=y.sdp,_=y.scaleResolutionDownBy,P=_===void 0?1:_,Hk()||!p){q.next=3;break}return q.abrupt("return",A===Ie?this.updateVideoBandwidthRestriction(p,D,S):this.updateAudioBandwidthRestriction(p,D));case 3:if(M=null,vl()?(B=0,A===Ie&&(B=S===Mr?2:S===gt?3:1),M=this.peerConnection_.getSenders()[B]):M=this.peerConnection_.getSenders().find(function(le){return le.track&&le.track.kind===A}),!M){q.next=23;break}return(X=M.getParameters()).encodings&&X.encodings.length!==0||(X.encodings=[{}]),D==="unlimited"?delete X.encodings[0].maxBitrate:X.encodings[0].maxBitrate=1e3*D,delete X.encodings[0].scaleResolutionDownBy,P>1&&(this.log_.warn("".concat(S," scaleResolutionDownBy ").concat(P)),X.encodings[0].scaleResolutionDownBy=P),q.prev=11,q.next=14,M.setParameters(X);case 14:return this.log_.info(S+A+" bandwidth was set to "+D+" kbps"),q.abrupt("return",p);case 18:if(q.prev=18,q.t0=q.catch(11),this.log_.info("failed to set bandwidth by setting maxBitrate: "+q.t0),!p){q.next=23;break}return q.abrupt("return",A===Ie?this.updateVideoBandwidthRestriction(p,D,S):this.updateAudioBandwidthRestriction(p,D));case 23:return q.abrupt("return",p);case 24:case"end":return q.stop()}},T,this,[[11,18]])})),function(T){return c.apply(this,arguments)})},{key:"updateVideoBandwidthRestriction",value:function(T,y,D){var A="AS";Vn&&(A="TIAS",y*=1e3);var U=0,S=-1;return D===Mr?U=1:D===gt&&(U=2),T=T.replace(/m=video (.*)\r\nc=IN (.*)\r\n/g,function(p){return++S===U?"".concat(p,"b=").concat(A,":").concat(y,`\r
65
+ `):p}),T}},{key:"updateAudioBandwidthRestriction",value:function(T,y){var D="AS";return Vn&&(D="TIAS",y*=1e3),T=T.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,`m=audio $1\r
68
66
  c=IN $2\r
69
- b=`+R+":"+b+`\r
70
- `)}},{key:"removeBandwidthRestriction",value:function(_){return _.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}},{key:"removeVideoOrientation",value:function(_){return _.replace(/urn:3gpp:video-orientation/,"")}},{key:"connect",value:(o=H(p().mark(function _(){return p().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.prev=0,b.next=3,this.exchangeSDP();case 3:return b.next=5,this.waitForPeerConnectionConnected();case 5:b.next=11;break;case 7:throw b.prev=7,b.t0=b.catch(0),this.closePeerConnection(!0),b.t0;case 11:case"end":return b.stop()}},_,this,[[0,7]])})),function(){return o.apply(this,arguments)})},{key:"exchangeSDP",value:(r=H(p().mark(function _(){return p().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.prev=0,this.isSDPExchanging_=!0,b.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),b.next=7,this.doExchangeSDP();case 7:this.isSDPExchanging_=!1,b.next=14;break;case 10:throw b.prev=10,b.t0=b.catch(0),this.isSDPExchanging_=!1,b.t0;case 14:case"end":return b.stop()}},_,this,[[0,10]])})),function(){return r.apply(this,arguments)})},{key:"createOffer",value:(i=H(p().mark(function _(){var b;return p().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:return R.prev=0,R.next=3,this.peerConnection_.createOffer(zI);case 3:return b=R.sent,R.next=6,this.peerConnection_.setLocalDescription(b);case 6:this.updateSSRC(b.sdp),ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ku,kind:"offer"}),R.next=14;break;case 10:throw R.prev=10,R.t0=R.catch(0),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Ku,kind:"offer",error:R.t0}),R.t0;case 14:case"end":return R.stop()}},_,this,[[0,10]])})),function(){return i.apply(this,arguments)})},{key:"doExchangeSDP",value:function(){var _=this;return new Promise(function(b,R){_.exchangeSDPTimeout_=setTimeout(function(){_.signalChannel_.off(st.PUBLISH_RESULT,P),_.clearExchangeSDPTimeout();var k=new te({code:Z.API_CALL_TIMEOUT,message:ae({key:EN})});R(k)},1e4);var P=function(){var k=H(p().mark(function f(y){var A,D,j;return p().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(K.prev=0,_.clearExchangeSDPTimeout(),A=y.data,D=A.code,j=A.message,D!==0){K.next=9;break}return K.next=6,_.acceptAnswer(y.data.data);case 6:b(),K.next=10;break;case 9:_.checkPublishResultCode(D,j);case 10:K.next=15;break;case 12:K.prev=12,K.t0=K.catch(0),R(K.t0);case 15:case"end":return K.stop()}},f,null,[[0,12]])}));return function(f){return k.apply(this,arguments)}}(),U={type:_.peerConnection_.localDescription.type,sdp:_.removeVideoOrientation(_.peerConnection_.localDescription.sdp),screen:(_.publishingStream_||_.localStream_).hasScreenTrack(),state:_.publishState,constraintConfig:_.mediaSettings_};_.signalChannel_.once(st.PUBLISH_RESULT,P),_.log_.debug("sending sdp offer: "+U.sdp),_.signalChannel_.send(RU,U)})}},{key:"setSDPDirection",value:function(_,b){var R=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"all",P=Fr(_);return P.media.forEach(function(U){R!=="all"&&U.type!==R||(U.direction=b)}),yo(P)}},{key:"acceptAnswer",value:(n=H(p().mark(function _(b){var R,P,U,k,f,y,A;return p().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:if(D.prev=0,R=this.removeVideoOrientation(b.sdp),!(P=this.publishingStream_||this.localStream_)){D.next=15;break}if(U=P.getVideoBitrate(),k=P.getAudioBitrate(),!U){D.next=11;break}return f=this.isPublishingAuxStream_?gt:Fu,D.next=10,this.setBandwidth({sdp:R,videoType:f,type:Ie,bandwidth:U,scaleResolutionDownBy:P.scaleResolutionDownBy});case 10:R=D.sent;case 11:if(!k){D.next=15;break}return D.next=14,this.setBandwidth({bandwidth:k,type:Ee,sdp:R});case 14:R=D.sent;case 15:if(!this.client_.getIsEnableSmallStream()){D.next=20;break}return y=this.client_.smallStreamConfig,D.next=19,this.setBandwidth({bandwidth:y.bitrate,type:Ie,videoType:Mr,sdp:R});case 19:R=D.sent;case 20:return A={type:b.type,sdp:R},D.next=23,this.peerConnection_.setRemoteDescription(A);case 23:this.log_.debug("accepted answer: "+R),ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ob,kind:"answer"}),D.next=32;break;case 27:throw D.prev=27,D.t0=D.catch(0),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Ob,kind:"answer",error:D.t0}),this.log_.error("failed to accept remote answer "+D.t0),D.t0;case 32:case"end":return D.stop()}},_,this,[[0,27]])})),function(_){return n.apply(this,arguments)})},{key:"sendMutedFlag",value:function(_,b){if(b!==this.localAuxStream_){var R={audio:_.audio,bigVideo:_.video,auxVideo:_.auxVideo};this.log_.info("send muted state: ".concat(JSON.stringify(R))),this.signalChannel_.send(EU,R)}}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"reconnect",value:(t=H(p().mark(function _(){var b,R,P=this;return p().wrap(function(U){for(;;)switch(U.prev=U.next){case 0:if(this.reconnectionTimer_===-1){U.next=3;break}return this.log_.warn("reconnect() uplink is reconnecting, ignore current reconnection"),U.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){U.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(),b=new te({code:Z.UPLINK_RECONNECTION_FAILED,message:ae({key:PN})}),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Ab,error:b}),this.addEventInternal(mV,"uplink-connection reconnect fail"),this.emitConnectionStateChangedEvent(on),this.emitter_.emit(et.ERROR,b),U.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===oc){U.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(ac,this.reconnect,this),U.abrupt("return");case 16:if(this.reconnectionCount_++,U.prev=17,this.log_.warn("reconnect() try to reconnect uplink [".concat(this.reconnectionCount_,"/").concat(30,"]")),R=wp(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){P.log_.warn("reconnect() uplink reconnect timeout(".concat(R/1e3,"s), try again")),P.clearReconnectionTimer(),P.reconnect()},R),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===qu)){U.next=23;break}return U.abrupt("return");case 23:return U.next=25,this.signalChannel_.sendWaitForResponse({command:gk,responseCommand:st.UNPUBLISH_RESULT,enableLog:!1});case 25:if(this.reset(),this.initialize(),!this.localStream_){U.next=30;break}return U.next=30,this.publish(this.localStream_);case 30:if(!this.localAuxStream_){U.next=33;break}return U.next=33,this.publish(this.localAuxStream_,!0);case 33:ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ab}),this.log_.warn("reconnect() uplink reconnect successfully"),this.addEventInternal(pV,"uplink-connection reconnect success"),this.stopReconnection(),this.localStream_.syncMuteState(),U.next=42;break;case 40:U.prev=40,U.t0=U.catch(17);case 42:case"end":return U.stop()}},_,this,[[17,40]])})),function(){return t.apply(this,arguments)})},{key:"clearExchangeSDPTimeout",value:function(){this.exchangeSDPTimeout_!==-1&&(clearTimeout(this.exchangeSDPTimeout_),this.exchangeSDPTimeout_=-1)}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"handleError",value:function(_){_.getCode()===Z.ICE_TRANSPORT_ERROR&&(this.isFirstConnection_&&(this.isFirstConnection_=!1,ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Rb,error:_})),this.isReconnecting_||this.startReconnection())}},{key:"handleConnectionStateChange",value:function(_){_.state===sn&&this.isFirstConnection_&&(this.isFirstConnection_=!1,ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Rb}),this.addEventInternal(cV,"uplink-connection is connected"))}},{key:"updateSSRC",value:function(_){var b=this;try{Fr(_).media.forEach(function(R,P){if(R.type===Ee){var U=R.ssrcs[0];U&&(b.ssrc_.audio=U.id)}else{if(b.sdpSemantics_===qf)return void R.ssrcGroups.forEach(function(f,y){var A=Number(f.ssrcs.split(" ")[0]);y===0?b.ssrc_.video=A:y===1&&(b.ssrc_.small=A)});var k=R.ssrcs[0];if(!k)return;switch(P){case 1:b.ssrc_.video=k.id;break;case 2:b.ssrc_.small=k.id;break;case 3:b.ssrc_.auxiliary=k.id}}})}catch(R){}}},{key:"getVideoTrackId",value:function(){var _=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ie;if(this.peerConnection_){var b=this.peerConnection_.getSenders();if(_===Ie&&b[1]&&b[1].track)return b[1].track.id;if(_===Mr&&b[2]&&b[2].track)return b[2].track.id;if(_===gt&&b[3]&&b[3].track)return b[3].track.id}if(this.localStream_&&_===Ie){var R=this.localStream_.getVideoTrack();if(R)return R.id}if(this.localAuxStream_&&_===gt){var P=this.localAuxStream_.getVideoTrack();if(P)return P.id}return""}},{key:"getSSRC",value:function(){return this.ssrc_}},{key:"checkPublishResultCode",value:function(_,b){if(_!==0)throw _===1028?(this.log_.error(gi.NOT_SUPPORTED_H264ENCODE),new te({code:Z.NOT_SUPPORTED_H264,message:ae({key:gS})})):new te({code:Z.UNKNOWN,message:ae({key:yS,data:{signalResponse:st.PUBLISH_RESULT,code:_,message:b}})})}},{key:"getLocalStream",value:function(){return this.localStream_}},{key:"sendSEI",value:function(_,b){this.sei_.push(_,b)}},{key:"mixAudioTrack",value:function(_,b){this.log_.info("mix audio track"),this.mixedAudioTrack_=function(R){var P=FS(),U=P.createMediaStreamDestination(),k=[];R.forEach(function(y){var A=new MediaStream;A.addTrack(y);var D=P.createMediaStreamSource(A);D.connect(U),k.push(D)});var f=U.stream.getAudioTracks()[0];return ed.set(f,{destination:U,track:f,mediaStreamSourceList:k}),f}([_,b])}},{key:"destroyMixedAudioTrack",value:function(){this.mixedAudioTrack_&&(this.log_.info("destroy audio track"),function(_){if(ed.has(_)){var b=ed.get(_),R=b.destination,P=b.track,U=b.mediaStreamSourceList;P.stop(),R.disconnect(),U.forEach(function(k){k.disconnect()}),ed.delete(_)}}(this.mixedAudioTrack_),this.mixedAudioTrack_=null)}}]),V}(Fv),X(Ic.prototype,"publish",[GI],Object.getOwnPropertyDescriptor(Ic.prototype,"publish"),Ic.prototype),Ic),LF=pe,JI=As,td=ws.exports.getWeakData,MF=si,NF=Tt,UF=Rt,Kv=at,VF=Rs,qI=kt,jF=Xe.set,BF=Xe.getterFor,FF=rn.find,HF=rn.findIndex,GF=LF([].splice),WF=0,nd=function(e){return e.frozen||(e.frozen=new KI)},KI=function(){this.entries=[]},Xv=function(e,t){return FF(e.entries,function(n){return n[0]===t})};KI.prototype={get:function(e){var t=Xv(this,e);if(t)return t[1]},has:function(e){return!!Xv(this,e)},set:function(e,t){var n=Xv(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=HF(this.entries,function(n){return n[0]===e});return~t&&GF(this.entries,t,1),!!~t}};var xc,zF={getConstructor:function(e,t,n,i){var r=e(function(s,l){MF(s,o),jF(s,{type:t,id:WF++,frozen:void 0}),UF(l)||VF(l,s[i],{that:s,AS_ENTRIES:n})}),o=r.prototype,c=BF(t),a=function(s,l,u){var h=c(s),S=td(NF(l),!0);return S===!0?nd(h).set(l,u):S[h.id]=u,s};return JI(o,{delete:function(s){var l=c(this);if(!Kv(s))return!1;var u=td(s);return u===!0?nd(l).delete(s):u&&qI(u,l.id)&&delete u[l.id]},has:function(s){var l=c(this);if(!Kv(s))return!1;var u=td(s);return u===!0?nd(l).has(s):u&&qI(u,l.id)}}),JI(o,n?{get:function(s){var l=c(this);if(Kv(s)){var u=td(s);return u===!0?nd(l).get(s):u?u[l.id]:void 0}},set:function(s,l){return a(this,s,l)}}:{add:function(s){return a(this,s,!0)}}),r}},XI=re,rd=pe,JF=As,qF=ws.exports,KF=mh,QI=zF,id=at,ad=Qg,od=Xe.enforce,XF=O,QF=!XI.ActiveXObject&&"ActiveXObject"in XI,YI=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},YF=KF("WeakMap",YI,QI);if(XF&&QF){xc=QI.getConstructor(YI,"WeakMap",!0),qF.enable();var wc=YF.prototype,$I=rd(wc.delete),sd=rd(wc.has),ZI=rd(wc.get),ex=rd(wc.set);JF(wc,{delete:function(e){if(id(e)&&!ad(e)){var t=od(this);return t.frozen||(t.frozen=new xc),$I(this,e)||t.frozen.delete(e)}return $I(this,e)},has:function(e){if(id(e)&&!ad(e)){var t=od(this);return t.frozen||(t.frozen=new xc),sd(this,e)||t.frozen.has(e)}return sd(this,e)},get:function(e){if(id(e)&&!ad(e)){var t=od(this);return t.frozen||(t.frozen=new xc),sd(this,e)?ZI(this,e):t.frozen.get(e)}return ZI(this,e)},set:function(e,t){if(id(e)&&!ad(e)){var n=od(this);n.frozen||(n.frozen=new xc),sd(this,e)?ex(this,e,t):n.frozen.set(e,t)}else ex(this,e,t);return this}})}var $F=Le,cd=zs,ZF=ue,tx=An,nx=it,e7=Lu,rx=lb,t7=Qt,Qv=cd&&cd.prototype;if($F({target:"Promise",proto:!0,real:!0,forced:!!cd&&ZF(function(){Qv.finally.call({then:function(){}},function(){})})},{finally:function(e){var t=e7(this,tx("Promise")),n=nx(e);return this.then(n?function(i){return rx(t,e()).then(function(){return i})}:e,n?function(i){return rx(t,e()).then(function(){throw i})}:e)}}),nx(cd)){var ix=tx("Promise").prototype.finally;Qv.finally!==ix&&t7(Qv,"finally",ix,{unsafe:!0})}var ax,ox,sx,cx,ur,Mo=new WeakMap;function ux(){return function(e,t,n){var i=n.value,r=function o(c){var a=c.fn,s=c.args,l=c.context,u=c.resolve,h=c.reject;a.apply(l,s).then(u,h).finally(function(){var S=Mo.get(l);S&&(S.shift(),S[0]&&o(q({},S[0])))})};return n.value=function(){for(var o=this,c=arguments.length,a=new Array(c),s=0;s<c;s++)a[s]=arguments[s];return new Promise(function(l,u){if(Mo.has(o)){var h=Mo.get(o),S=h.length;h.push({fn:i,args:a,context:o,resolve:l,reject:u,name:t}),S===0&&r({fn:i,args:a,context:o,resolve:l,reject:u})}else Mo.set(o,[{fn:i,args:a,context:o,resolve:l,reject:u,name:t}]),r({fn:i,args:a,context:o,resolve:l,reject:u})})},n}}var n7=(ax=ux(),ox=Lo({retries:1,timeout:0,onRetrying:function(e){this.log_.warn("connection timeout, retrying [".concat(e,"]"))},onError:function(e,t,n){e.message.includes("timeout")?t():n(e)}}),sx=ux(),cx=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1e4;return function(t,n,i){var r=i.value;return i.value=function(){for(var o=this,c=arguments.length,a=new Array(c),s=0;s<c;s++)a[s]=arguments[s];return new Promise(function(l,u){var h=setTimeout(function(){return u(new Error("".concat(n," timeout")))},e);r.apply(o,a).then(l,u).finally(function(){clearTimeout(h)})})},i}}(),ur=function(e){Et(l,e);var t,n,i,r,o,c,a,s=Rr(l);function l(u){var h;return Q(this,l),(h=s.call(this,u)).remoteStreams_=new Map,h.autoSubscribe=u.autoSubscribe,h.trackState_={audio:u.trackState.audio,video:u.trackState.video,auxiliary:u.trackState.auxiliary,smallVideo:u.trackState.smallVideo},h.ssrc_={audio:0,video:0,auxiliary:0},h.subscribeState_={audio:u.autoSubscribe,video:u.autoSubscribe,auxiliary:u.autoSubscribe,smallVideo:!1},h.isSDPExchanging_=!1,h.installEvents(),h}return xe(l,[{key:"getMixUserList",value:function(){return this.mixUserList_?this.mixUserList_.map(function(u){var h=u.userId,S=u.flag;return{userId:h,hasAudio:!!(8&S),hasVideo:!!(1&S),hasAuxiliary:!!(4&S)}}):void 0}},{key:"setMixUserList",value:function(u){(!this.mixUserList_||ho(this.mixUserList_)&&!function(h,S){if(S.length===h.length){var I,E=oe(S);try{var x=function(){var T=I.value,v=h.find(function(w){return w.userId===T.userId});if(!v||v.flag!==T.flag)return{v:!1}};for(E.s();!(I=E.n()).done;){var m=x();if(G(m)==="object")return m.v}}catch(T){E.e(T)}finally{E.f()}return!0}return!1}(this.mixUserList_,u))&&(this.mixUserList_=u,this.emitter_.emit(et.STREAM_UPDATED,{stream:this.getMainStream()}))}},{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:"isSmallStreamSubscribed",get:function(){return this.subscribeState_.smallVideo&&this.trackState_.smallVideo}},{key:"isBigStreamSubscribed",get:function(){return this.subscribeState_.video&&this.trackState_.video}},{key:"isStreamUnpublished",value:function(u){return u.getType()===Qe?!this.trackState_.audio&&!this.trackState_.video:!this.trackState_.auxiliary}},{key:"initialize",value:function(){le(Ye(l.prototype),"initialize",this).call(this),this.peerConnection_.ontrack=this.onTrack.bind(this)}},{key:"close",value:function(){var u,h,S,I=this;le(Ye(l.prototype),"close",this).call(this),this.trackState_.audio=!1,this.trackState_.video=!1,this.trackState_.smallVideo=!1,this.trackState_.auxiliary=!1,this.emitConnectionStateChangedEvent(on),u=this,h=function(E){E.fn;var x=E.args,m=E.resolve,T=E.reject,v=E.name;if(v==="subscribe"){if(!I.client_.getIsJoined())return T(new te({code:Z.API_CALL_ABORTED,message:ae({key:op,data:{message:"leave room",stream:x[0]}})}));if(I.isStreamUnpublished(x[0]))return T(new te({code:Z.API_CALL_ABORTED,message:ae({key:op,data:{message:"remote user ".concat(I.userId_," unpublished stream"),stream:x[0]}})}))}else if(v==="unsubscribe")return m();m()},(S=Mo.get(u))===null||S===void 0||S.forEach(h),Mo.delete(u),this.remoteStreams_.forEach(function(E){var x=E;x.setConnection(null),x.uninstallEvents(),x.getIsStreamAddedEventEmitted()&&I.emitter_.emit(et.STREAM_REMOVED,{stream:x})}),this.remoteStreams_.clear(),this.uninstallEvents()}},{key:"installEvents",value:function(){var u=this;Y.on(jn,this.onRemoteStreamUpdate,this),this.emitter_.on(et.ERROR,function(h){h.getCode()===Z.ICE_TRANSPORT_ERROR&&(u.isFirstConnection_&&(u.isFirstConnection_=!1,ke.logFailedEvent({userId:u.client_.getUserId(),eventType:Pb,error:h})),u.isReconnecting_||u.startReconnection())}),this.emitter_.on(et.CONNECTION_STATE_CHANGED,function(h){h.state===sn&&u.isFirstConnection_&&(u.isFirstConnection_=!1,ke.logSuccessEvent({userId:u.client_.getUserId(),eventType:Pb}),u.addEventInternal(uV,"downlink-connection is connected"))})}},{key:"uninstallEvents",value:function(){Y.removeListener(jn,this.onRemoteStreamUpdate,this)}},{key:"onRemoteStreamUpdate",value:function(u){if(this.hitTest(u.tinyId)&&u.client===this.client_){this.updateTrackState(u.action,u.kind);var h=u.kind===gt?Xs:Ir,S=this.remoteStreams_.get(h);if(!S)return;u.action===cn.ADD?this.handleRemoteAddTrack(u.kind,S):this.handleRemoteRemoveTrack(u.kind,S)}}},{key:"handleRemoteAddTrack",value:function(u,h){this.log_.info("remote add ".concat(u," track")),u===Ee?h.updateAudioPlayingState(this.subscribeState_.audio):h.updateVideoPlayingState(u===gt?this.subscribeState_.auxiliary:this.subscribeState_.video||this.subscribeState_.smallVideo),h.getIsStreamAddedEventEmitted()?this.emitter_.emit(et.STREAM_UPDATED,{stream:h}):(this.emitter_.emit(et.STREAM_ADDED,{stream:h}),this.currentState_===sn&&h.emitConnectionStateChanged({prevState:on,state:sn}))}},{key:"handleRemoteRemoveTrack",value:function(u,h){h.getIsStreamAddedEventEmitted()&&(this.log_.info("remote remove ".concat(u," track")),u===gt||!this.trackState_.audio&&!this.trackState_.video?(this.log_.info("remote stream ".concat(h.getType()," removed")),this.currentState_===sn&&h.emitConnectionStateChanged({prevState:sn,state:on}),this.emitter_.emit(et.STREAM_REMOVED,{stream:h})):(u===Ee?h.updateAudioPlayingState(!1):(u!==Hu||this.isSmallStreamSubscribed)&&h.updateVideoPlayingState(!1),this.emitter_.emit(et.STREAM_UPDATED,{stream:h})))}},{key:"updateTrackState",value:function(u,h){var S=u===cn.ADD;switch(h){case Ee:this.trackState_.audio=S;break;case Ie:this.trackState_.video=S;break;case gt:this.trackState_.auxiliary=S;break;case Hu:this.trackState_.smallVideo=S}this.log_.info("trackState updated: ".concat(JSON.stringify(this.trackState_)))}},{key:"onTrack",value:function(u){var h=this,S=u.streams[0],I=u.track,E=u.receiver;if(this.log_.info("ontrack() kind: ".concat(I.kind," id: ").concat(I.id," streamId: ").concat(S.id)),this.sdpSemantics_===Ys){var x=function(_){var b=rr.parse(_),R={audio:[],video:[]};return b.media.forEach(function(P){if(P.ssrcs){var U=P.ssrcs[0].id>>16&255;if(P.type===Ee)R.audio.push(Ir);else if(P.type==Ie){var k=U===QM?Ir:Xs;R.video.push(k)}}}),R}(this.peerConnection_.remoteDescription.sdp);if(I.kind===Ee){if(x.audio.length===0||S.id!==Ir)return void this.log_.debug("skip this invalid audio track")}else if(x.video.indexOf(S.id)===-1)return void this.log_.debug("skip this invalid video track: ".concat(I.id," msid: ").concat(S.id))}ke.logEvent({eventType:"ontrack",kind:I.kind});var m=!1,T=this.remoteStreams_.get(S.id),v=S.id===Ir?yt:Dt;if(ge(T)&&((T=new Gv({type:v,userId:this.userId_,client:this.client_})).setConnection(this),this.remoteStreams_.set(S.id,T),m=!0),this.encodedInsertableStreams&&this.useWebCodecs){if(I.kind=="audio")T.setReceiver(E);else if(!this.enableSEI_){var w=E.createEncodedStreams(),L=w.readable,N=w.writable;L.pipeTo(N).catch(function(_){return h.log_.error(_)})}}if(T.setMediaStream(S),I.kind===Ee?T.updateAudioPlayingState(this.subscribeState_.audio):v===yt?T.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo):T.updateVideoPlayingState(this.subscribeState_.auxiliary),(v!==Dt||this.trackState_.auxiliary)&&(v!==yt||this.trackState_.audio||this.trackState_.video)){var V=this.client_.getSubscriptionManager();V&&V.hasAutoRecoveryFlag(this.userId_,v)||(m?this.emitter_.emit(et.STREAM_ADDED,{stream:T}):this.emitter_.emit(et.STREAM_UPDATED,{stream:T}))}}},{key:"addRRTRLine",value:function(u){var h=u.split(`\r
71
- `),S=new Map;h.forEach(function(v,w){/^a=rtcp-fb:/.test(v)&&h[w+1]&&!/^a=rtcp-fb:/.test(h[w+1])&&v.match(/^a=rtcp-fb:\d+/)&&S.set(w+1,v.match(/^a=rtcp-fb:\d+/)[0]+" rrtr")});for(var I=Se(S),E=0;E<I.length;E++){var x=Te(I[E],2),m=x[0],T=x[1];h.splice(m+E,0,T)}return h.join(`\r
72
- `)}},{key:"addSPSDescription",value:function(u){var h=Fr(u);return h.media.forEach(function(S){S.type===Ie&&S.fmtp.forEach(function(I){I.config+=";sps-pps-idr-in-keyframe=1"})}),yo(h)}},{key:"removeSDESDescription",value:function(u){var h=["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"],S=Fr(u);return S.media.forEach(function(I){I.ext=I.ext.filter(function(E){return!h.includes(E.uri)})}),yo(S)}},{key:"isSubscriptionStateNotChanged",value:function(u,h){return u.getType()===yt?(h==null?void 0:h.audio)===this.subscribeState_.audio&&(h==null?void 0:h.video)===this.subscribeState_.video&&this.isSubscribeSmall(h):u.getType()===Dt?!ge(h.video)&&this.subscribeState_.auxiliary===h.video:void 0}},{key:"isSubscribeSmall",value:function(u){return ge(u.smallVideo)&&!this.subscribeState_.smallVideo}},{key:"subscribe",value:(a=H(p().mark(function u(h,S){var I,E,x,m,T,v;return p().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(w.prev=0,x=S.emitEvent,m=x===void 0||x,T=h.getType(),((I=this.peerConnection_)===null||I===void 0?void 0:I.connectionState)!==YM&&((E=this.peerConnection_)===null||E===void 0?void 0:E.connectionState)!==qu){w.next=6;break}return w.next=6,this.waitForPeerConnectionConnected();case 6:if(!this.isSubscriptionStateNotChanged(h,S)){w.next=13;break}if(this.peerConnection_){w.next=11;break}return this.initialize(),w.next=11,this.connect();case 11:return m&&ge(S.smallVideo)&&this.emitter_.emit(et.STREAM_SUBSCRIBED,{stream:h,result:!0}),w.abrupt("return",h);case 13:if(T===Qe?(ge(S.audio)||(this.subscribeState_.audio=S.audio),ge(S.video)||(this.subscribeState_.video=S.video),this.subscribeState_.smallVideo=(S==null?void 0:S.smallVideo)||!1,this.addEventInternal(this.subscribeState_.audio?kk:cm,this.subscribeState_.audio?"subscribe audio":"unsubscribe audio"),this.addEventInternal(this.subscribeState_.video?kk:cm,this.subscribeState_.video?"subscribe video":"unsubscribe video"),this.addEventInternal(this.subscribeState_.smallVideo?yV:bV,this.subscribeState_.smallVideo?"subscribe smallVideo":"unsubscribe smallVideo")):ge(S.video)||(this.subscribeState_.auxiliary=S.video),this.log_.info("subscribe ".concat(T," stream with options ").concat(JSON.stringify(S)," current state: ").concat(JSON.stringify(this.subscribeState_))),!this.peerConnection_&&!this.isSDPExchanging_){w.next=23;break}return v=Jf,this.isMainStreamSubscribed||this.isAuxStreamSubscribed||(v=zf),w.next=20,this.sendSubscription(v);case 20:T===Qe?(h.updateAudioPlayingState(this.subscribeState_.audio),h.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo)):h.updateVideoPlayingState(this.subscribeState_.auxiliary),w.next=26;break;case 23:return this.initialize(),w.next=26,this.connect();case 26:return m&&this.emitter_.emit(et.STREAM_SUBSCRIBED,{stream:h,result:!0}),w.abrupt("return",h);case 30:if(w.prev=30,w.t0=w.catch(0),!this.client_.getIsJoined()||!this.isStreamUnpublished(h)){w.next=35;break}throw this.log_.warn("".concat(w.t0.message," ").concat(JSON.stringify(this.trackState_))),new te({code:Z.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId_," unpublished stream")});case 35:throw w.t0;case 36:case"end":return w.stop()}},u,this,[[0,30]])})),function(u,h){return a.apply(this,arguments)})},{key:"checkTrackEnded",value:function(){try{var u=this.peerConnection_.getReceivers().map(function(h){return h.track}).find(function(h){return h.readyState==="ended"});u&&this.currentState_===sn&&!this.isReconnecting_&&(this.log_.warn("".concat(u.kind," track ended, start reconnect")),this.startReconnection())}catch(h){}}},{key:"unsubscribe",value:(c=H(p().mark(function u(h){var S,I,E;return p().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if((S=h.getType())!==Qe){x.next=10;break}if(this.isMainStreamSubscribed){x.next=5;break}return this.log_.info("main stream already unsubscribed"),x.abrupt("return",h);case 5:this.subscribeState_.audio=!1,this.subscribeState_.video=!1,this.subscribeState_.smallVideo=!1,x.next=14;break;case 10:if(this.isAuxStreamSubscribed){x.next=13;break}return this.log_.info("auxiliary stream already unsubscribed"),x.abrupt("return",h);case 13:this.subscribeState_.auxiliary=!1;case 14:return I=zf,(S===yt&&this.isAuxStreamSubscribed||S===Dt&&this.isMainStreamSubscribed)&&(I=Jf),this.log_.info("unsubscribe ".concat(S," stream with ").concat(JSON.stringify(this.subscribeState_))),x.next=19,this.sendSubscription(I);case 19:return h.updateVideoPlayingState(!1),h.updateAudioPlayingState(!1),I===zf&&((E=h.getMediaStream())&&E.getTracks().forEach(function(m){return E.removeTrack(m)}),this.closePeerConnection(),this.emitConnectionStateChangedEvent(on)),this.addEventInternal(cm,"unsubscribe audio"),this.addEventInternal(XU,"unsubscribe video"),x.abrupt("return",h);case 25:case"end":return x.stop()}},u,this)})),function(u){return c.apply(this,arguments)})},{key:"sendSubscription",value:function(u){var h=this,S={srcTinyId:this.tinyId_,srcUserId:this.userId_},I=PU,E=st.UNSUBSCRIBE_RESULT;return u===Jf&&(S={audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo,srcTinyId:this.tinyId_},I=DU,E=st.SUBSCRIBE_CHANGE_RESULT),this.signalChannel_.sendWaitForResponse({command:I,data:S,responseCommand:E,timeout:1e4}).then(function(x){var m=x.data;if(m.code!==0){var T=new te({code:m.code,message:ae({key:CN,data:{type:u,message:m.message}})});throw h.log_.error(T),T}})}},{key:"connect",value:(o=H(p().mark(function u(){return p().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.prev=0,h.next=3,this.exchangeSDP();case 3:return h.next=5,this.waitForPeerConnectionConnected();case 5:h.next=11;break;case 7:throw h.prev=7,h.t0=h.catch(0),this.closePeerConnection(!0),h.t0;case 11:case"end":return h.stop()}},u,this,[[0,7]])})),function(){return o.apply(this,arguments)})},{key:"exchangeSDP",value:(r=H(p().mark(function u(){var h,S,I,E,x,m;return p().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.prev=0,this.isSDPExchanging_=!0,T.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),h=this.peerConnection_.localDescription,S=h.type,I=h.sdp,E={type:S,sdp:I,srcUserId:this.userId_,srcTinyId:this.tinyId_,audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo},Y.emit($p,{client:this.client_,connection:this,userId:this.userId_,tinyId:this.tinyId_,role:so,subscribeState:this.subscribeState_,trackState:this.trackState_}),T.next=10,this.signalChannel_.sendWaitForResponse({command:AU,commandDesc:"exchange sdp",data:E,responseCommand:st.SUBSCRIBE_RESULT,timeout:1e4});case 10:if(x=T.sent,this.peerConnection_){T.next=15;break}throw m=new te({code:Z.INVALID_OPERATION,message:ae({key:X3})}),this.log_.warn(m),m;case 15:return T.next=17,this.onSubscribeResult(x);case 17:this.isSDPExchanging_=!1,T.next=24;break;case 20:throw T.prev=20,T.t0=T.catch(0),this.isSDPExchanging_=!1,T.t0;case 24:case"end":return T.stop()}},u,this,[[0,20]])})),function(){return r.apply(this,arguments)})},{key:"createOffer",value:(i=H(p().mark(function u(){var h,S;return p().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:return h={voiceActivityDetection:!1},gl()&&this.sdpSemantics_===Ys?(this.peerConnection_.addTransceiver(Ee,{direction:"recvonly"}),this.peerConnection_.addTransceiver(Ie,{direction:"recvonly"}),this.peerConnection_.addTransceiver(Ie,{direction:"recvonly"})):(h.offerToReceiveAudio=!0,h.offerToReceiveVideo=!0),I.next=4,this.peerConnection_.createOffer(h);case 4:return S=I.sent,I.next=7,Vk();case 7:return I.sent.isH264DecodeSupported||(this.log_.warn("remove h264 desc from sdp"),S.sdp=(E=S.sdp,x=void 0,(x=Fr(E)).media.forEach(function(m){if(m.type===Ie){var T=new Set;m.rtp.forEach(function(w){var L=w.payload;return w.codec==="H264"&&T.add(L)}),m.fmtp.forEach(function(w){var L=w.payload,N=w.config.match(/apt=(\d+)/);N&&N[1]&&T.has(Number(N[1]))&&T.add(L)});var v=function(w){var L=w.payload;return!T.has(L)};m.rtp=m.rtp.filter(v),m.rtcpFb=m.rtcpFb.filter(v),m.fmtp=m.fmtp.filter(v),m.payloads=m.payloads.split(" ").filter(function(w){return!T.has(Number(w))}).join(" ")}}),yo(x))),S.sdp=this.addRRTRLine(S.sdp),S.sdp=this.addSPSDescription(S.sdp),S.sdp=zV(S.sdp),this.sdpSemantics_===Ys&&(S.sdp=this.removeSDESDescription(S.sdp)),I.next=16,this.peerConnection_.setLocalDescription(S);case 16:case"end":return I.stop()}var E,x},u,this)})),function(){return i.apply(this,arguments)})},{key:"onSubscribeResult",value:(n=H(p().mark(function u(h){var S,I,E,x,m,T,v,w=this;return p().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(S=h&&h.data||{},I=S.code,E=S.message,x=E===void 0?"":E,m=h&&h.data&&h.data.data||{},T=m.type,v=m.sdp,I!==77393){L.next=5;break}throw this.log_.error(gi.NOT_SUPPORTED_H264DECODE),new te({code:Z.NOT_SUPPORTED_H264,message:ae({key:_S})});case 5:if(L.prev=5,I===0){L.next=8;break}throw new te({code:I,message:ae({key:AN,data:{errMsg:x}})});case 8:return this.log_.debug("accept remote answer: "+v),L.next=11,this.peerConnection_.setRemoteDescription({type:T,sdp:v});case 11:this.sei_&&(this.sei_.handleEncodedStreams(),this.sei_.onSEIMessage=function(N){w.emitter_.emit(et.SEI_MESSAGE,q(q({},N),{},{userId:w.userId_}))}),this.updateSSRC(v),L.next=19;break;case 15:throw L.prev=15,L.t0=L.catch(5),this.log_.error(L.t0),L.t0;case 19:case"end":return L.stop()}},u,this,[[5,15]])})),function(u){return n.apply(this,arguments)})},{key:"updateSSRC",value:function(u){var h=this;try{Fr(u).media.forEach(function(S){if(S.type===Ee){var I=S.ssrcs.find(function(m){return m.value.includes(Ir)});I&&(h.ssrc_.audio=I.id)}else{var E=S.ssrcs.find(function(m){return m.value.includes(Ir)}),x=S.ssrcs.find(function(m){return m.value.includes(Xs)});E&&(h.ssrc_.video=E.id),x&&(h.ssrc_.auxiliary=x.id)}})}catch(S){}}},{key:"setRemoteStream",value:function(u,h){this.remoteStreams_.set(u,h)}},{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(Ir)}},{key:"getAuxStream",value:function(){return this.remoteStreams_.get(Xs)}},{key:"getMainStreamVideoTrackId",value:function(){var u=this.getMainStream();if(u){var h=u.getVideoTrack();if(h)return h.id}return""}},{key:"getAuxStreamVideoTrackId",value:function(){var u=this.getAuxStream();if(u){var h=u.getVideoTrack();if(h)return h.id}return""}},{key:"reconnect",value:(t=H(p().mark(function u(){var h,S,I=this;return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(this.reconnectionTimer_===-1){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(),h=new te({code:Z.DOWNLINK_RECONNECTION_FAILED,message:ae({key:RN})}),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Db,error:h}),this.addEventInternal(_V,"downlink-connection reconnect fail"),this.emitConnectionStateChangedEvent(on),this.emitter_.emit(et.ERROR,h),E.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===oc){E.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(ac,this.reconnect,this),E.abrupt("return");case 16:if(this.reconnectionCount_++,this.log_.warn("reconnect() try to reconnect downlink [".concat(this.reconnectionCount_,"/").concat(30,"]")),S=wp(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){I.log_.warn("reconnect() downlink [".concat(I.userId_,"] reconnect timeout(").concat(S/1e3,"s), try again")),I.clearReconnectionTimer(),I.reconnect()},S),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===qu)){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"),ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Db}),this.addEventInternal(gV,"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()}},u,this,[[22,34]])})),function(){return t.apply(this,arguments)})},{key:"recoverSubscription",value:function(){var u=this,h=this.client_.getSubscriptionManager();h&&Se(this.remoteStreams_.values()).forEach(function(S){h.hasAutoRecoveryFlag(u.userId_,S.getType())&&h.recover(S)})}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"getSubscribedMainStream",value:function(){var u=null;return this.isMainStreamSubscribed&&(u=this.remoteStreams_.get(Ir)),u}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"startReconnection",value:function(){var u=this.client_.getSubscriptionManager();if(u){var h,S=oe(this.remoteStreams_.values());try{for(S.s();!(h=S.n()).done;){var I=h.value,E=I.getType();(E===yt&&(this.trackState_.audio||this.trackState_.video)||E===Dt&&this.trackState_.auxiliary)&&u.setAutoRecoveryFlag(this.userId_,I.getType())}}catch(x){S.e(x)}finally{S.f()}}le(Ye(l.prototype),"startReconnection",this).call(this)}},{key:"getCurrentState",value:function(){return this.currentState_}},{key:"hasMainStream",value:function(){return this.trackState_.video||this.trackState_.audio||this.trackState_.smallVideo}},{key:"hasAuxStream",value:function(){return this.trackState_.auxiliary}}]),l}(Fv),X(ur.prototype,"subscribe",[ax,ox],Object.getOwnPropertyDescriptor(ur.prototype,"subscribe"),ur.prototype),X(ur.prototype,"unsubscribe",[sx],Object.getOwnPropertyDescriptor(ur.prototype,"unsubscribe"),ur.prototype),X(ur.prototype,"exchangeSDP",[cx],Object.getOwnPropertyDescriptor(ur.prototype,"exchangeSDP"),ur.prototype),ur),ud=function(){function e(){Q(this,e),this.startTime=0,this.endTime=0,this.start()}return xe(e,[{key:"start",value:function(){this.startTime===0&&(this.startTime=Ct())}},{key:"stop",value:function(){this.endTime===0&&(this.endTime=Ct())}},{key:"getDuration",value:function(){return this.endTime===0?Ct()-this.startTime:this.endTime-this.startTime}}]),e}(),r7=function(){function e(r){Q(this,e),this.client_=r.client,this.intervalId_=-1,this.statsCalculator_=r.stats,this.prevStats_=null,this.renderFreezeMap_=new Map,this.remoteStreamMap_=new Map,this.dataFreezeMap_=new Map,this.monitorFreezeData_=new Map}var t,n,i;return xe(e,[{key:"installEvents",value:function(){Y.on(Kp,this.handlePlayVideoStart,this),Y.on(nc,this.onVideoTrackMuted,this),Y.on(zp,this.onVideoTrackUnmuted,this),Y.on(ca,this.handleStreamStopped,this),Y.on(Vr,this.handleStreamStopped,this),Y.on(tc,this.handleVideoPlaying,this)}},{key:"uninstallEvents",value:function(){Y.off(Kp,this.handlePlayVideoStart,this),Y.off(nc,this.onVideoTrackMuted,this),Y.off(zp,this.onVideoTrackUnmuted,this),Y.off(ca,this.handleStreamStopped,this),Y.off(Vr,this.handleStreamStopped,this),Y.off(tc,this.handleVideoPlaying,this)}},{key:"start",value:function(){var r=this;this.intervalId_===-1&&(this.installEvents(),this.intervalId_=mt.run(H(p().mark(function o(){return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,c.next=3,r.detectFPS();case 3:c.next=7;break;case 5:c.prev=5,c.t0=c.catch(0);case 7:case"end":return c.stop()}},o,null,[[0,5]])})),{delay:1e3}))}},{key:"stop",value:function(){this.intervalId_!==-1&&(this.uninstallEvents(),mt.clearTask(this.intervalId_),this.intervalId_=-1,this.renderFreezeMap_.clear(),this.dataFreezeMap_.clear(),this.remoteStreamMap_.clear())}},{key:"onVideoTrackMuted",value:function(r){var o=r.stream;if(o.getClient()===this.client_&&o.isRemote()){var c=o.userId_,a=o.type_,s="".concat(c,"_").concat(a),l=this.dataFreezeMap_.get(s),u=new ud;l?l.durationItemList.push(u):this.dataFreezeMap_.set(s,{userId:c,type:a,durationItemList:[u],isFreezing:function(){var h=this.durationItemList[this.durationItemList.length-1];return h&&h.endTime===0}})}}},{key:"onVideoTrackUnmuted",value:function(r){var o=r.stream;if(o.getClient()===this.client_&&o.isRemote()){var c=o.userId_,a=o.type_,s="".concat(c,"_").concat(a);this.stopDataFreeze({key:s,userId:c,type:a})}}},{key:"handleStreamStopped",value:function(r){var o=r.client,c=r.stream;if(o===this.client_){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s);this.stopDataFreeze({key:l,userId:a,type:s})}}},{key:"stopDataFreeze",value:function(r){var o=r.key,c=r.userId,a=r.type,s=this.dataFreezeMap_.get(o);if(s&&s.isFreezing()){var l=s.durationItemList[s.durationItemList.length-1];l.stop();var u=l.getDuration();u>500?(ke.logEvent({eventType:"videoFrozenCount",delta:u}),this.monitorFreezeData_.set(o,{userId:c,type:a,duration:u})):s.durationItemList.pop()}}},{key:"getTotalDuration",value:function(r){return r.reduce(function(o,c){var a=c.getDuration();return o+Math.min(a,5e3)},0)}},{key:"getStats",value:(i=H(p().mark(function r(){var o,c,a,s,l,u,h,S,I,E,x;return p().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:o=this.client_.getConnections(),c={},a=oe(o),m.prev=3,a.s();case 5:if((s=a.n()).done){m.next=20;break}if(l=Te(s.value,2),u=l[0],(h=l[1]).getPeerConnection()){m.next=9;break}return m.abrupt("continue",18);case 9:return S=h.getSubscribeState(),I=h.getTrackState(),m.next=13,this.statsCalculator_.getReceiverStats(h);case 13:E=m.sent,(x={userId:E.userId,tinyId:u,hasVideo:I.video&&S.video,hasAuxiliary:I.auxiliary&&S.auxiliary,video:{framesDecoded:0},auxiliary:{framesDecoded:0}}).hasVideo&&(x.video.framesDecoded=E.video.framesDecoded),x.hasAuxiliary&&(x.auxiliary.framesDecoded=E.auxiliary.framesDecoded),c[E.userId]=x;case 18:m.next=5;break;case 20:m.next=25;break;case 22:m.prev=22,m.t0=m.catch(3),a.e(m.t0);case 25:return m.prev=25,a.f(),m.finish(25);case 28:return m.abrupt("return",c);case 29:case"end":return m.stop()}},r,this,[[3,22,25,28]])})),function(){return i.apply(this,arguments)})},{key:"detectFPS",value:(n=H(p().mark(function r(){var o,c,a,s,l,u;return p().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,this.getStats();case 2:if(o=h.sent,this.prevStats_){h.next=6;break}return this.prevStats_=o,h.abrupt("return");case 6:h.t0=p().keys(o);case 7:if((h.t1=h.t0()).done){h.next=17;break}if(c=h.t1.value,this.prevStats_[c]){h.next=11;break}return h.abrupt("continue",7);case 11:a=o[c].tinyId,s=this.client_.getMutedStates(),o[c].hasVideo&&this.prevStats_[c].hasVideo&&s.has(a)&&!s.get(a).videoMuted&&(l=o[c].video.framesDecoded-this.prevStats_[c].video.framesDecoded,this.handleRenderFreeze({userId:c,type:yt,fps:l})),o[c].hasAuxiliary&&this.prevStats_[c].hasAuxiliary&&(u=o[c].auxiliary.framesDecoded-this.prevStats_[c].auxiliary.framesDecoded,this.handleRenderFreeze({userId:c,type:Dt,fps:u})),h.next=7;break;case 17:this.prevStats_=o;case 18:case"end":return h.stop()}},r,this)})),function(){return n.apply(this,arguments)})},{key:"handleRenderFreeze",value:(t=H(p().mark(function r(o){var c,a,s,l,u,h,S,I;return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:c=o.userId,a=o.fps,s=o.type,l="".concat(c,"_").concat(s),u=this.renderFreezeMap_.get(l),a<=2?(h=Ct(),u&&!u.isFreeze&&(u.freezeTimeline.push({startTime:h,endTime:void 0}),u.isFreeze=!0),u||this.renderFreezeMap_.set(l,{userId:c,type:s,isFreeze:!0,freezeTimeline:[{startTime:h,endTime:void 0}],renderFreezeTotal:0})):u&&u.isFreeze&&(u.isFreeze=!1,(S=u.freezeTimeline.pop()).endTime=Ct(),I=S.endTime-S.startTime,u.freezeTimeline.push(S),u.renderFreezeTotal+=Math.min(5e3,I));case 4:case"end":return E.stop()}},r,this)})),function(r){return t.apply(this,arguments)})},{key:"handlePlayVideoStart",value:function(r){var o=r.stream;if(o.getClient()===this.client_&&o.isRemote()&&o.hasVideo()){var c="".concat(o.getUserId(),"_").concat(o.getType());this.remoteStreamMap_.has(c)||this.remoteStreamMap_.set(c,{isPlayingFired:!1})}}},{key:"handleVideoPlaying",value:function(r){var o=r.stream;if(o.isRemote()&&o.getClient()===this.client_){var c="".concat(o.getUserId(),"_").concat(o.getType());this.remoteStreamMap_.has(c)&&(this.remoteStreamMap_.get(c).isPlayingFired=!0)}}},{key:"getDataFreezeDuration",value:function(r){var o={dataFreeze:0,count:0},c=this.dataFreezeMap_.get(r);if(c){if(c.isFreezing()){var a=c.durationItemList[c.durationItemList.length-1];a.stop(),a.getDuration()<500&&c.durationItemList.pop()}o.dataFreeze=this.getTotalDuration(c.durationItemList),o.count=c.durationItemList.length}return o}},{key:"getRenderFreezeDuration",value:function(r){var o=this.renderFreezeMap_.get(r),c=0,a=0;if(o)if(o.isFreeze){var s=Ct()-o.freezeTimeline[o.freezeTimeline.length-1].startTime;c=o.renderFreezeTotal+Math.min(s,5e3),a=o.freezeTimeline.length}else c=o.renderFreezeTotal;return{renderFreeze:c,count:a}}},{key:"getMonitorFreeze",value:function(){return this.monitorFreezeData_}},{key:"isBlackStream",value:function(r){return!!this.remoteStreamMap_.has(r)&&!this.remoteStreamMap_.get(r).isPlayingFired}},{key:"resetMonitor",value:function(){this.monitorFreezeData_.clear()}}]),e}(),Yv=xe(function e(t){Q(this,e),this.userId=t.userId,this.tinyId=t.tinyId,this.role=t.role===so?Tr:Zi}),lx={exports:{}};(function(e){(function(t){function n(m,T){var v=(65535&m)+(65535&T);return(m>>16)+(T>>16)+(v>>16)<<16|65535&v}function i(m,T,v,w,L,N){return n((V=n(n(T,m),n(w,N)))<<(_=L)|V>>>32-_,v);var V,_}function r(m,T,v,w,L,N,V){return i(T&v|~T&w,m,T,L,N,V)}function o(m,T,v,w,L,N,V){return i(T&w|v&~w,m,T,L,N,V)}function c(m,T,v,w,L,N,V){return i(T^v^w,m,T,L,N,V)}function a(m,T,v,w,L,N,V){return i(v^(T|~w),m,T,L,N,V)}function s(m,T){var v,w,L,N,V;m[T>>5]|=128<<T%32,m[14+(T+64>>>9<<4)]=T;var _=1732584193,b=-271733879,R=-1732584194,P=271733878;for(v=0;v<m.length;v+=16)w=_,L=b,N=R,V=P,_=r(_,b,R,P,m[v],7,-680876936),P=r(P,_,b,R,m[v+1],12,-389564586),R=r(R,P,_,b,m[v+2],17,606105819),b=r(b,R,P,_,m[v+3],22,-1044525330),_=r(_,b,R,P,m[v+4],7,-176418897),P=r(P,_,b,R,m[v+5],12,1200080426),R=r(R,P,_,b,m[v+6],17,-1473231341),b=r(b,R,P,_,m[v+7],22,-45705983),_=r(_,b,R,P,m[v+8],7,1770035416),P=r(P,_,b,R,m[v+9],12,-1958414417),R=r(R,P,_,b,m[v+10],17,-42063),b=r(b,R,P,_,m[v+11],22,-1990404162),_=r(_,b,R,P,m[v+12],7,1804603682),P=r(P,_,b,R,m[v+13],12,-40341101),R=r(R,P,_,b,m[v+14],17,-1502002290),_=o(_,b=r(b,R,P,_,m[v+15],22,1236535329),R,P,m[v+1],5,-165796510),P=o(P,_,b,R,m[v+6],9,-1069501632),R=o(R,P,_,b,m[v+11],14,643717713),b=o(b,R,P,_,m[v],20,-373897302),_=o(_,b,R,P,m[v+5],5,-701558691),P=o(P,_,b,R,m[v+10],9,38016083),R=o(R,P,_,b,m[v+15],14,-660478335),b=o(b,R,P,_,m[v+4],20,-405537848),_=o(_,b,R,P,m[v+9],5,568446438),P=o(P,_,b,R,m[v+14],9,-1019803690),R=o(R,P,_,b,m[v+3],14,-187363961),b=o(b,R,P,_,m[v+8],20,1163531501),_=o(_,b,R,P,m[v+13],5,-1444681467),P=o(P,_,b,R,m[v+2],9,-51403784),R=o(R,P,_,b,m[v+7],14,1735328473),_=c(_,b=o(b,R,P,_,m[v+12],20,-1926607734),R,P,m[v+5],4,-378558),P=c(P,_,b,R,m[v+8],11,-2022574463),R=c(R,P,_,b,m[v+11],16,1839030562),b=c(b,R,P,_,m[v+14],23,-35309556),_=c(_,b,R,P,m[v+1],4,-1530992060),P=c(P,_,b,R,m[v+4],11,1272893353),R=c(R,P,_,b,m[v+7],16,-155497632),b=c(b,R,P,_,m[v+10],23,-1094730640),_=c(_,b,R,P,m[v+13],4,681279174),P=c(P,_,b,R,m[v],11,-358537222),R=c(R,P,_,b,m[v+3],16,-722521979),b=c(b,R,P,_,m[v+6],23,76029189),_=c(_,b,R,P,m[v+9],4,-640364487),P=c(P,_,b,R,m[v+12],11,-421815835),R=c(R,P,_,b,m[v+15],16,530742520),_=a(_,b=c(b,R,P,_,m[v+2],23,-995338651),R,P,m[v],6,-198630844),P=a(P,_,b,R,m[v+7],10,1126891415),R=a(R,P,_,b,m[v+14],15,-1416354905),b=a(b,R,P,_,m[v+5],21,-57434055),_=a(_,b,R,P,m[v+12],6,1700485571),P=a(P,_,b,R,m[v+3],10,-1894986606),R=a(R,P,_,b,m[v+10],15,-1051523),b=a(b,R,P,_,m[v+1],21,-2054922799),_=a(_,b,R,P,m[v+8],6,1873313359),P=a(P,_,b,R,m[v+15],10,-30611744),R=a(R,P,_,b,m[v+6],15,-1560198380),b=a(b,R,P,_,m[v+13],21,1309151649),_=a(_,b,R,P,m[v+4],6,-145523070),P=a(P,_,b,R,m[v+11],10,-1120210379),R=a(R,P,_,b,m[v+2],15,718787259),b=a(b,R,P,_,m[v+9],21,-343485551),_=n(_,w),b=n(b,L),R=n(R,N),P=n(P,V);return[_,b,R,P]}function l(m){var T,v="",w=32*m.length;for(T=0;T<w;T+=8)v+=String.fromCharCode(m[T>>5]>>>T%32&255);return v}function u(m){var T,v=[];for(v[(m.length>>2)-1]=void 0,T=0;T<v.length;T+=1)v[T]=0;var w=8*m.length;for(T=0;T<w;T+=8)v[T>>5]|=(255&m.charCodeAt(T/8))<<T%32;return v}function h(m){var T,v,w="0123456789abcdef",L="";for(v=0;v<m.length;v+=1)T=m.charCodeAt(v),L+=w.charAt(T>>>4&15)+w.charAt(15&T);return L}function S(m){return unescape(encodeURIComponent(m))}function I(m){return function(T){return l(s(u(T),8*T.length))}(S(m))}function E(m,T){return function(v,w){var L,N,V=u(v),_=[],b=[];for(_[15]=b[15]=void 0,V.length>16&&(V=s(V,8*v.length)),L=0;L<16;L+=1)_[L]=909522486^V[L],b[L]=1549556828^V[L];return N=s(_.concat(u(w)),512+8*w.length),l(s(b.concat(N),640))}(S(m),S(T))}function x(m,T,v){return T?v?E(T,m):h(E(T,m)):v?I(m):h(I(m))}e.exports?e.exports=x:t.md5=x})(ce)})(lx);var dx,hx,Pi,ld=lx.exports,i7=function(){function e(o){Q(this,e),this.client_=o.client,this.signalChannel_=o.signalChannel,this.log_=_e.createLogger({id:"mix|"+this.client_.getUserId(),userId:o.client.getUserId(),sdkAppId:o.client.getSDKAppId()}),this.isMixing_=!1,this.config_=null,this.data_=null,this.remoteStreamMap_=new Map,this.installEvents()}var t,n,i,r;return xe(e,[{key:"isPresetLayoutMode",get:function(){return this.config_&&this.config_.mode===Kf.PRESET_LAYOUT}},{key:"installEvents",value:function(){Y.on(Ur,this.onStreamSubscribed,this),Y.on(Vr,this.onStreamUnsubscribed,this),this.client_.on("stream-removed",this.onStreamRemoved,this)}},{key:"uninstallEvents",value:function(){Y.off(Ur,this.onStreamSubscribed,this),Y.off(Vr,this.onStreamUnsubscribed,this),this.client_.off("stream-removed",this.onStreamRemoved,this)}},{key:"reset",value:function(){this.uninstallEvents(),this.isMixing_=!1,this.config_=null}},{key:"onStreamSubscribed",value:function(o){var c=o.client,a=o.stream;c===this.client_&&(this.remoteStreamMap_.set(a.getId(),{remoteStream:a,isUsed:!1}),this.isMixing_&&this.hasAvailablePlaceHolder()&&this.startMixTranscode(this.config_))}},{key:"onStreamUnsubscribed",value:function(o){var c=o.client,a=o.stream;c===this.client_&&this.onStreamRemoved({stream:a})}},{key:"onStreamRemoved",value:function(o){var c=o.stream;if(this.remoteStreamMap_.has(c.getId())){var a=this.remoteStreamMap_.get(c.getId()).isUsed;this.remoteStreamMap_.delete(c.getId()),this.isMixing_&&this.isPresetLayoutMode&&a&&this.startMixTranscode(this.config_)}}},{key:"startMixTranscode",value:(r=H(p().mark(function o(c){var a,s,l;return p().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(u.prev=0,this.resetIsUsedFlag(),this.config_=c,a=this.getInputParam(c,this.remoteStreamMap_),s=this.getOutputParam(c),l=this.getOutputSessionId({config:c,roomId:this.client_.getRoomId(),userId:this.client_.getUserId()}),!this.isMixing_||!this.data_||l===this.data_.outputSessionId){u.next=10;break}return this.log_.info("startMixTranscode() streamId changed, stop mixing before start"),u.next=10,this.doStopMixTranscode();case 10:return u.next=12,this.doStartMixTranscode({outputSessionId:l,inputParam:a,outputParam:s});case 12:u.next=18;break;case 14:throw u.prev=14,u.t0=u.catch(0),this.resetIsUsedFlag(),u.t0;case 18:case"end":return u.stop()}},o,this,[[0,14]])})),function(o){return r.apply(this,arguments)})},{key:"doStartMixTranscode",value:(i=H(p().mark(function o(c){var a,s,l,u,h,S,I,E;return p().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:return a=c.outputSessionId,s=c.inputParam,l=c.outputParam,u={roomId:String(this.client_.getRoomId()),mcuRequestTime:Date.now(),outputSessionId:a,inputParam:s,outputParam:l},this.data_=u,this.log_.info("startMixTranscode: ".concat(JSON.stringify(u))),this.isMixing_=!0,x.prev=5,x.next=8,this.signalChannel_.sendWaitForResponse({command:UU,data:u,timeout:5e3,responseCommand:st.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"});case 8:if(h=x.sent,S=h.data,I=S.code,E=S.message,I===0){x.next=15;break}throw I===-102083&&(E="Please enable relayed-push in ".concat($b," and try later, refer to ").concat(Zf,"tutorial-26-advanced-publish-cdn-stream.html")),this.log_.error("startMixTranscode failed, errCode: ".concat(I," errMsg: ").concat(E)),this.isMixing_=!1,new te({code:Z.START_MIX_TRANSCODE_FAILED,message:ae({key:x3,data:{message:E},link:{className:"Client",fnName:"startMixTranscode"}})});case 15:x.next=21;break;case 17:throw x.prev=17,x.t0=x.catch(5),this.isMixing_=!1,x.t0;case 21:case"end":return x.stop()}},o,this,[[5,17]])})),function(o){return i.apply(this,arguments)})},{key:"reStartMixTranscode",value:function(){this.isMixing_&&this.startMixTranscode(this.config_)}},{key:"stopMixTranscode",value:(n=H(p().mark(function o(){return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.isMixing_){c.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:C3})});case 2:return c.next=4,this.doStopMixTranscode();case 4:this.resetIsUsedFlag();case 5:case"end":return c.stop()}},o,this)})),function(){return n.apply(this,arguments)})},{key:"doStopMixTranscode",value:(t=H(p().mark(function o(){var c,a,s,l,u;return p().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return c={mcuRequestTime:Date.now(),outputSessionId:this.data_.outputSessionId,streamType:this.data_.outputParam.streamType},this.log_.info("stopMixTranscode: ".concat(JSON.stringify(c))),h.next=4,this.signalChannel_.sendWaitForResponse({command:VU,data:c,timeout:5e3,responseCommand:st.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"});case 4:if(a=h.sent,s=a.data,l=s.code,u=s.message,l!==0){h.next=10;break}this.isMixing_=!1,h.next=12;break;case 10:throw this.log_.error("stopMixTranscode failed, errCode: ".concat(l," errMsg: ").concat(u)),new te({code:Z.STOP_MIX_TRANSCODE_FAILED,message:ae({key:w3,data:{message:u},link:{className:"Client",fnName:"stopMixTranscode"}})});case 12:case"end":return h.stop()}},o,this)})),function(){return t.apply(this,arguments)})},{key:"getOutputSessionId",value:function(o){var c=o.config,a=o.userId,s=o.roomId;return Bt(c.streamId)&&c.streamId.length>0?c.streamId:ld("".concat(s,"_").concat(a,"_main"))}},{key:"getInputParam",value:function(o,c){var a=this,s=o.mixUsers.map(function(l){return{userId:l.userId,roomId:String(l.roomId||a.client_.getRoomId()),width:l.width||0,height:l.height||0,locationX:l.locationX||0,locationY:l.locationY||0,zOrder:l.zOrder,streamType:ge(l.streamType)||l.streamType!==Dt?0:1,inputType:l.pureAudio?Gb.IT_PURE_AUDIO:Gb.IT_AUDIO_VIDEO,renderMode:l.renderMode||0}});return o.mode===Kf.PRESET_LAYOUT&&(s.forEach(function(l){if(l.userId===Hb.REMOTE){var u=Se(c.values()).find(function(h){return!h.isUsed});u&&(l.userId=u.remoteStream.getUserId(),l.streamType=u.remoteStream.getType()===Dt?1:0,u.isUsed=!0)}}),s=s.filter(function(l){return l.userId!==Hb.REMOTE})),s}},{key:"getOutputParam",value:function(o){var c=o.streamId||"";return{streamId:c,streamType:c.length>0?1:0,width:ge(o.videoWidth)?640:o.videoWidth,height:ge(o.videoHeight)?480:o.videoHeight,videoBps:o.videoBitrate||0,fps:o.videoFramerate||15,gop:o.videoGOP||2,audioSampleRate:o.audioSampleRate||48e3,audioBps:o.audioBitrate||64,audioChannels:o.audioChannels||1,backgroundColor:o.backgroundColor||0,backgroundImg:o.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(o){return o.isUsed=!1})}}]),e}(),a7=function(){function e(a){Q(this,e),this.client_=a.client,this.signalChannel_=a.signalChannel,this.publishTencentMainStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1},this.publishTencentAuxStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1},this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1}var t,n,i,r,o,c;return xe(e,[{key:"setSignalChannel",value:function(a){this.signalChannel_=a.signalChannel}},{key:"getIsPublishingTencentCDN",value:function(){return this.publishTencentMainStreamObj_.isPublishing_||this.publishTencentAuxStreamObj_.isPublishing_}},{key:"getIsPublishingGivenCDN",value:function(){return this.isPublishingGivenCDN_}},{key:"generatePublishCDNStreamId",value:function(a,s){if(!a){var l="".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(s);return/^[A-Za-z\d_-]*$/.test(l)||(l=ld(l)),"".concat(this.client_.getSDKAppId(),"_").concat(l)}return a}},{key:"generatePublishCDNSessionId",value:function(a){return ld("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(a))}},{key:"startPublishTencentCDN",value:(c=H(p().mark(function a(s){var l,u,h,S;return p().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(s.streamType===Nn?(this.publishTencentAuxStreamObj_.params_=s,this.publishTencentAuxStreamObj_.isPublishing_=!0):(this.publishTencentMainStreamObj_.params_=s,this.publishTencentMainStreamObj_.isPublishing_=!0),this.client_.isJoined_){I.next=3;break}return I.abrupt("return");case 3:return l=this.generatePublishCDNStreamId(s.streamId,s.streamType),u=this.generatePublishCDNSessionId(s.streamType),h=s.streamType===Nn?1:0,S={requestTime:Date.now(),sessionId:u,streamId:l,streamType:h},I.next=9,this.doStartPublishTencentCDN(S,s.streamType);case 9:case"end":return I.stop()}},a,this)})),function(a){return c.apply(this,arguments)})},{key:"doStartPublishTencentCDN",value:(o=H(p().mark(function a(s,l){var u,h,S,I;return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return E.prev=0,_e.info("startPublishTencentCDN: "+JSON.stringify(s)),E.next=4,this.signalChannel_.sendWaitForResponseWithRetry({command:OU,data:s,timeout:2e3,responseCommand:st.START_PUBLISH_TENCENT_CDN_RES,commandDesc:"startPublishCDNStream",retries:2});case 4:if(u=E.sent,h=u.data,S=h.code,I=h.message,S!==0){E.next=10;break}l===Nn?this.publishTencentAuxStreamObj_.streamId_=s.streamId:this.publishTencentMainStreamObj_.streamId_=s.streamId,E.next=14;break;case 10:throw l===Nn?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,S===-102083&&(I="Please enable relayed-push in ".concat($b," and try later, refer to ").concat(Zf,"tutorial-26-advanced-publish-cdn-stream.html")),_e.error("startPublishTencentCDN failed, errCode: ".concat(S,", errMsg: ").concat(I)),new te({code:Z.START_PUBLISH_CDN_FAILED,message:ae({key:dS,data:{message:I},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 14:E.next=20;break;case 16:throw E.prev=16,E.t0=E.catch(0),l===Nn?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,E.t0;case 20:case"end":return E.stop()}},a,this,[[0,16]])})),function(a,s){return o.apply(this,arguments)})},{key:"resetPublishTencentParam",value:function(a){a===Qe&&(this.publishTencentMainStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1}),a===Nn&&(this.publishTencentAuxStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1})}},{key:"stopPublishTencentCDN",value:(r=H(p().mark(function a(){return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(this.client_.isJoined_){s.next=4;break}return this.resetPublishTencentParam(Qe),this.resetPublishTencentParam(Nn),s.abrupt("return");case 4:if(!this.publishTencentMainStreamObj_.isPublishing_){s.next=7;break}return s.next=7,this.doStopPublishTencentCDN(Qe);case 7:if(!this.publishTencentAuxStreamObj_.isPublishing_){s.next=10;break}return s.next=10,this.doStopPublishTencentCDN(Nn);case 10:case"end":return s.stop()}},a,this)})),function(){return r.apply(this,arguments)})},{key:"doStopPublishTencentCDN",value:(i=H(p().mark(function a(s){var l,u,h,S,I;return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return l={requestTime:Date.now(),sessionId:ld("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(s))},_e.info("stopPublishTencentCDN: "+JSON.stringify(l)),E.next=4,this.signalChannel_.sendWaitForResponse({command:LU,data:l,timeout:5e3,responseCommand:st.STOP_PUBLISH_TENCENT_CDN_RES,commandDesc:"stopPublishCDNStream"});case 4:if(u=E.sent,h=u.data,S=h.code,I=h.message,S!==0){E.next=10;break}this.resetPublishTencentParam(s),E.next=17;break;case 10:if(S!==-102069){E.next=15;break}_e.warn("stopPublishTencentCDN failed, can not stopPublishTencentCDN in auto relayed-push mode"),this.resetPublishTencentParam(s),E.next=17;break;case 15:throw _e.error("stopPublishTencentCDN failed, errCode: ".concat(S," errMsg: ").concat(I)),new te({code:Z.STOP_PUBLISH_CDN_FAILED,message:ae({key:hS,data:{message:I},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 17:case"end":return E.stop()}},a,this)})),function(a){return i.apply(this,arguments)})},{key:"startPublishGivenCDN",value:(n=H(p().mark(function a(s){var l,u,h,S,I,E;return p().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(l=s.streamType===Qe?this.publishTencentMainStreamObj_.streamId_:this.publishTencentAuxStreamObj_.streamId_,u={pushRequestTime:Date.now(),pushAppId:s.appId,pushBizId:s.bizId,pushCdnUrl:s.url,pushStreamType:s.streamType,pushStreamId:l},_e.info("startPublishGivenCDN: "+JSON.stringify(u)),this.publishGivenCDNData_=u,this.isPublishingGivenCDN_=!0,this.client_.isJoined_){x.next=7;break}return x.abrupt("return");case 7:return x.prev=7,x.next=10,this.signalChannel_.sendWaitForResponse({command:MU,data:u,timeout:5e3,responseCommand:st.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDNStream"});case 10:if(h=x.sent,S=h.data,I=S.code,E=S.message,I===0){x.next=17;break}throw _e.error("startPublishGivenCDN failed, errCode: ".concat(I,", errMsg: ").concat(E)),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,new te({code:Z.START_PUBLISH_CDN_FAILED,message:ae({key:dS,data:{message:E},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 17:x.next=24;break;case 19:throw x.prev=19,x.t0=x.catch(7),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,x.t0;case 24:case"end":return x.stop()}},a,this,[[7,19]])})),function(a){return n.apply(this,arguments)})},{key:"stopPublishGivenCDN",value:(t=H(p().mark(function a(){var s,l,u,h,S,I,E,x,m,T;return p().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(this.client_.isJoined_){v.next=4;break}return this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,v.abrupt("return");case 4:return s=this.publishGivenCDNData_,l=s.pushAppId,u=s.pushBizId,h=s.pushCdnUrl,S=s.pushStreamType,I={pushRequestTime:Date.now(),pushAppId:l,pushBizId:u,pushCdnUrl:h,pushStreamType:S},_e.info("stopPublishGivenCDN: "+JSON.stringify(I)),v.next=9,this.signalChannel_.sendWaitForResponse({command:NU,data:I,timeout:5e3,responseCommand:st.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDNStream"});case 9:if(E=v.sent,x=E.data,m=x.code,T=x.message,m!==0){v.next=16;break}this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,v.next=18;break;case 16:throw _e.error("stopPublishGivenCDN failed, errCode: ".concat(m," errMsg: ").concat(T)),new te({code:Z.STOP_PUBLISH_CDN_FAILED,message:ae({key:hS,data:{message:T},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 18:case"end":return v.stop()}},a,this)})),function(){return t.apply(this,arguments)})},{key:"handleCDNConfigForJoinData",value:function(a){var s,l=a;if(this.publishTencentMainStreamObj_.isPublishing_||this.publishTencentAuxStreamObj_.isPublishing_){var u={};Bt(l)&&(u=JSON.parse(l)),u.Str_uc_params||(u.Str_uc_params={}),this.publishTencentMainStreamObj_.isPublishing_&&(this.publishTencentMainStreamObj_.streamId_?u.Str_uc_params.userdefine_streamid_main=this.publishTencentMainStreamObj_.streamId_:this.publishTencentMainStreamObj_.params_&&(u.Str_uc_params.userdefine_streamid_main=this.generatePublishCDNStreamId(this.publishTencentMainStreamObj_.params_.streamId,Qe))),this.publishTencentAuxStreamObj_.isPublishing_&&(this.publishTencentAuxStreamObj_.streamId_?u.Str_uc_params.userdefine_streamid_aux=this.publishTencentAuxStreamObj_.streamId_:this.publishTencentAuxStreamObj_.params_&&(u.Str_uc_params.userdefine_streamid_aux=this.generatePublishCDNStreamId(this.publishTencentAuxStreamObj_.params_.streamId,Nn))),l=JSON.stringify(u)}if(this.isPublishingGivenCDN_){var h=this.publishGivenCDNData_,S=h.pushAppId,I=h.pushBizId,E=h.pushCdnUrl,x=h.pushStreamType,m=h.pushStreamId;s={pushRequestTime:Date.now(),pushAppId:S,pushBizId:I,pushCdnUrl:E,pushStreamType:x,pushStreamId:m}}return{bussinessInfo:l,pushUserCdnInfo:s}}},{key:"reset",value:function(){this.resetPublishTencentParam(Qe),this.resetPublishTencentParam(Nn),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1}}]),e}(),o7=function(){function e(t){Q(this,e),this.client_=t.client,this.durationMap_=new Map,this.installEvents()}return xe(e,[{key:"installEvents",value:function(){Y.on(Ur,this.handleSubscribed,this),Y.on(jn,this.handleStreamTrackUpdated,this),Y.on(Vr,this.handleStreamStopped,this),Y.on(ca,this.handleStreamStopped,this)}},{key:"uninstallEvents",value:function(){Y.off(Ur,this.handleSubscribed,this),Y.off(jn,this.handleStreamTrackUpdated,this),Y.off(Vr,this.handleStreamStopped,this),Y.off(ca,this.handleStreamStopped,this)}},{key:"handleSubscribed",value:function(t){var n=t.client,i=t.stream;if(n===this.client_){var r=i.getUserId(),o=i.getType(),c="".concat(r,"_").concat(o);if(i.hasAudio())if(i.isMainAudioSubscribed){var a=new ud,s=this.durationMap_.get(c);s?this.isRecording(s.audio)||s.audio.push(a):this.durationMap_.set(c,{userId:r,type:o,audio:[a],video:[]})}else this.stopDurationItem(c,Ee);if(i.hasVideo())if(o===yt&&i.isMainVideoSubscribed||o===Dt&&i.isAuxVideoSubscribed){var l=new ud,u=this.durationMap_.get(c);u?this.isRecording(u.video)||u.video.push(l):this.durationMap_.set(c,{userId:r,type:o,audio:[],video:[l]})}else this.stopDurationItem(c,Ie)}}},{key:"handleStreamStopped",value:function(t){var n=t.client,i=t.stream;if(this.clientHitTest(n)){var r=i.getUserId(),o=i.getType(),c="".concat(r,"_").concat(o);this.stopDurationItem(c,Ee),this.stopDurationItem(c,Ie)}}},{key:"handleStreamTrackUpdated",value:function(t){var n=t.client,i=t.userId,r=t.tinyId,o=t.kind,c=t.action;if(this.clientHitTest(n)&&this.client_.getConnections().has(r)){var a=o===gt?o:yt,s="".concat(i,"_").concat(a);if(c===cn.ADD){var l=this.client_.getConnections().get(r).getSubscribeState();if(o===Ee&&!l.audio||o===Ie&&!l.video||o===gt&&!l.auxiliary)return;var u=new ud,h=this.durationMap_.get(s);h?(o!==Ee||this.isRecording(h.audio)||h.audio.push(u),o===Ee||this.isRecording(h.video)||h.video.push(u)):this.durationMap_.set(s,{userId:i,type:a,audio:o===Ee?[u]:[],video:o===Ee?[]:[u]})}else this.stopDurationItem(s,o===Ee?Ee:Ie)}}},{key:"isRecording",value:function(t){return t.findIndex(function(n){return n.endTime===0})>=0}},{key:"stopDurationItem",value:function(t,n){if(this.durationMap_.has(t)){var i=this.durationMap_.get(t)[n].find(function(r){return r.endTime===0});i&&i.stop()}}},{key:"clientHitTest",value:function(t){return this.client_===t}},{key:"getDuration",value:function(t,n){return this.durationMap_.has(t)?this.durationMap_.get(t)[n].reduce(function(i,r){return i+r.getDuration()},0):0}},{key:"getDurationMap",value:function(){return this.durationMap_}},{key:"reset",value:function(){this.durationMap_.clear()}},{key:"destroy",value:function(){this.client_=null,this.uninstallEvents()}}]),e}();function Cc(){return function(e,t,n){var i=n.value,r=new Set;return n.value=H(p().mark(function o(){var c,a,s,l,u=arguments;return p().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(!r.has(this)){h.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:bN,data:{name:t}})});case 2:for(h.prev=2,r.add(this),c=u.length,a=new Array(c),s=0;s<c;s++)a[s]=u[s];return h.next=7,i.apply(this,a);case 7:return l=h.sent,r.delete(this),h.abrupt("return",l);case 12:throw h.prev=12,h.t0=h.catch(2),r.delete(this),h.t0;case 16:case"end":return h.stop()}},o,this,[[2,12]])})),n}}var fx,px,mx,vx,gx,_x,yx,bx,Sx,kx,Tx,Ix,xx,wx,Cx,Ex,Rx,Ax,Px,Dx,Ox,Lx,Mx,Nx,Ux,Vx,jx,Bx,Fx,Hx,Gx,Pe,s7=(dx=dn({name:"options",type:xn,required:!0,properties:{roomId:{type:dt,required:!0},userId:{type:dt,required:!1}}}),hx=dn({name:"options",type:xn,required:!0,properties:{updateList:{type:Wb,required:!0,arrayItem:{require:!0,type:xn,properties:{roomId:{required:!0,type:dt},userId:{required:!1,type:dt},muteAudio:{type:zt},muteVideo:{type:zt},muteAuxiliary:{type:zt}}},validate:function(e){if(e.find(function(t){return t.userId})&&e.find(function(t){return!t.userId}))throw new te({code:Z.INVALID_PARAMETER,message:"you can not update both userId and all"})}}}}),Pi=function(){function e(){Q(this,e),this.crossRoomSeq=0}var t,n,i;return xe(e,[{key:"call",value:function(r,o){return ln(this[r])?this[r](o):Promise.reject(new te({code:Z.INVALID_PARAMETER,message:ae({key:K3,data:{name:r}})}))}},{key:"updatePrivateMapKey",value:function(r){var o=r.privateMapKey;return r.client.setProperty("privateMapKey",o),Promise.resolve()}},{key:"connectOtherRoom",value:(i=H(p().mark(function r(o){var c,a,s,l;return p().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(c=o.client,a=o.roomId,s=o.userId,c.signalChannel_){u.next=3;break}return u.abrupt("return",Promise.reject(new te({code:Z.INVALID_OPERATION,message:"you did not joined room"})));case 3:return u.next=5,c.signalChannel_.sendWaitForResponseWithRetry({command:HU,responseCommand:st.CONNECT_OTHER_ROOM_RES,data:{roomId:a,userId:s,localRoomId:s?void 0:c.getRoomId()},retries:3});case 5:if((l=u.sent).data.code===0){u.next=8;break}throw new te({code:l.data.code,message:l.data.message});case 8:case"end":return u.stop()}},r)})),function(r){return i.apply(this,arguments)})},{key:"updateOtherRoomForwardMode",value:(n=H(p().mark(function r(o){var c,a,s,l,u;return p().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(a=o.client,s=o.updateList,a.signalChannel_){h.next=3;break}return h.abrupt("return",Promise.reject(new te({code:Z.INVALID_OPERATION,message:"you did not joined room"})));case 3:return l=s.find(function(S){return S.userId})?0:1,h.next=6,a.signalChannel_.sendWaitForResponseWithRetry({command:GU,responseCommand:st.UPDATE_OTHER_ROOM_FORWARD_MODE_RES,data:{seq:++this.crossRoomSeq,operationType:l,updateList:s.map(function(S){return{roomId:S.roomId,userId:S.userId,muteAudio:S.muteAudio,muteVideo:S.muteVideo,muteSubStream:S.muteAuxiliary}})},retries:3});case 6:if(!(u=h.sent).data.data.expectSeq){h.next=10;break}return this.crossRoomSeq=u.data.data.expectSeq,h.abrupt("return",this.updateOtherRoomForwardMode({client:a,updateList:s}));case 10:if(u.data.code===0){h.next=14;break}throw new te({code:u.data.code,message:u.data.message});case 14:if(!(((c=u.data.errorList)===null||c===void 0?void 0:c.length)>0)){h.next=16;break}throw new te({code:Z.UNKNOWN,message:u.data.errorList[0].message});case 16:case"end":return h.stop()}},r,this)})),function(r){return n.apply(this,arguments)})},{key:"disconnectOtherRoom",value:(t=H(p().mark(function r(o){var c,a,s;return p().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(c=o.client,a=o.roomId,c.signalChannel_){l.next=3;break}return l.abrupt("return",Promise.resolve());case 3:return l.next=5,c.signalChannel_.sendWaitForResponseWithRetry({command:WU,responseCommand:st.DISCONNECT_OTHER_ROOM_RES,data:{roomId:a,localRoomId:a?c.getRoomId():void 0},retries:3});case 5:if((s=l.sent).data.code===0){l.next=8;break}throw new te({code:s.data.code,message:s.data.message});case 8:case"end":return l.stop()}},r)})),function(r){return t.apply(this,arguments)})}]),e}(),X(Pi.prototype,"connectOtherRoom",[dx],Object.getOwnPropertyDescriptor(Pi.prototype,"connectOtherRoom"),Pi.prototype),X(Pi.prototype,"updateOtherRoomForwardMode",[hx],Object.getOwnPropertyDescriptor(Pi.prototype,"updateOtherRoomForwardMode"),Pi.prototype),Pi),c7=new s7,dd,hd,fd,$v,Wx,zx,Jx,qx,Kx,Xx,$t,u7=(fx=Cc(),px=dn(Yt.CLIENT.join),mx=Lo({retries:1,timeout:0,onError:function(e,t,n){this.isUsingCachedSchedule_?(this.log_.warn("is using cached schedule, retry join"),Ti(!0),this.reset(),t()):(Y.emit(sa,{client:this,error:e}),ke.logFailedEvent({userId:this.userId_,eventType:Tb,error:e}),this.reset(),this.log_.error(e),n(e))}}),vx=Cc(),gx=Lo({retries:3}),_x=Cc(),yx=dn.apply(void 0,Se(Yt.CLIENT.publish)),bx=St(un),Sx=Cc(),kx=dn(Yt.CLIENT.unpublish),Tx=dn.apply(void 0,Se(Yt.CLIENT.subscribe)),Ix=dn(Yt.CLIENT.unsubscribe),xx=Cc(),wx=dn(Yt.CLIENT.switchRole),Cx=St(un),Ex=dn(Yt.CLIENT.startPublishCDNStream),Rx=St(un),Ax=St(un),Px=dn(Yt.CLIENT.startMixTranscode),Dx=St(un),Ox=St(un),Lx=St(un),Mx=St(un),Nx=St(un),Ux=St(un),Vx=St(un),jx=Al.apply(void 0,Se(Yt.CLIENT.sendSEIMessage)),Bx=St(un),dd={timesInSecond:30,maxSizeInSecond:8e3,getSize:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[0].byteLength}},hd=dd.timesInSecond,fd=dd.maxSizeInSecond,$v=dd.getSize,Fx=function(e,t,n){var i=n.value,r=new Map;return Y.on(jp,function(o){var c=o.client;return r.delete(c)}),n.value=function(){var o=r.get(this);o||(o={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},r.set(this,o)),o.timestamp===0?o.timestamp=Date.now():Date.now()-o.timestamp>1e3&&(o.timestamp=Date.now(),o.callCountInSecond=0,o.totalSizeInSecond=0);for(var c=arguments.length,a=new Array(c),s=0;s<c;s++)a[s]=arguments[s];if($v&&(o.totalSizeInSecond+=$v.apply(void 0,a)),o.timestamp!==0&&Date.now()-o.timestamp<1e3&&(o.callCountInSecond>=hd||o.totalSizeInSecond>fd))throw new te({code:Z.INVALID_OPERATION,message:ae({key:n4,data:{isTimes:o.callCountInSecond>=hd,isSize:o.totalSizeInSecond>fd,name:t,timesInSecond:hd,maxSizeInSecond:fd}})});return o.callCountInSecond++,i.apply(this,a)},n},Hx=St(un),Gx=St(un),Pe=function(){function e(k){var f,y;Q(this,e),this.name_=un,this.mode_=k.mode,this.sdpSemantics_=qf,ge(k.sdpSemantics)?function(){var A;if(ge(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var D=null,j=!1;try{(D=new RTCPeerConnection({sdpSemantics:Ys})).addTransceiver(Ee),j=!0}catch(K){}return(A=D)===null||A===void 0||A.close(),j}()&&(this.sdpSemantics_=Ys):this.sdpSemantics_=k.sdpSemantics,this.sdkAppId_=k.sdkAppId,this.userId_=k.userId,this.log_=_e.createLogger({id:"c".concat(k.seq,"|").concat(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_}),this.userSig_=k.userSig,this.roomId_=0,this.useStringRoomId_=k.useStringRoomId||!1,this.pureAudioPushMode_=null,this.version_=k.version,this.log_.info("using sdpSemantics: "+this.sdpSemantics_),this.signalChannel_=null,this.role_=Tr,this.privateMapKey_="",this.tinyId_=0,this.env_="",this.proxy_=null,this.unifiedProxy_=null,this.connections_=new Map,this.mutedStates_=new Map,this.userMap_=new Map,this.syncUserListInterval_=-1,this.localStream_=null,this.localAuxStream_=null,this.uplinkConnection_=null,this.emitter_=GS(new ki,this.name_),this.isJoined_=!1,this.heartbeat_=-1,this.lastHeartBeatTime_=-1,this.stats_=new c6(this),this.joinTimeout_=-1,this.changeBigSmallRecords_=new Map,this.networkQuality_=null,this.badCaseDetector_=null,this.networkType_=xp(),this.autoSubscribe_=!!ge(k.autoSubscribe)||k.autoSubscribe,this.joinedTimestamp_=0,this.joinOptions_={},this.basis_=(y={browser:aa().name+"/"+aa().version,os:wm(),displayResolution:ZV(),isScreenShareSupported:Bk(),isWebRTCSupported:Sm(),isGetUserMediaSupported:e6(),isWebAudioSupported:t6(),isWebSocketsSupported:"WebSocket"in window&&window.WebSocket.CLOSING===2,isWebCodecSupported:(f={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1},ge(window.AudioDecoder)||(f.AudioDecoder=!0),ge(window.AudioEncoder)||(f.AudioEncoder=!0),ge(window.VideoDecoder)||(f.VideoDecoder=!0),ge(window.VideoEncoder)||(f.VideoEncoder=!0),ge(window.ImageDecoder)||(f.ImageDecoder=!0),f),isMediaSessionSupported:"mediaSession"in navigator&&!ge(navigator.mediaSession.setActionHandler),isWebTransportSupported:!ge(window.WebTransport)},navigator.userAgent.includes("miniProgram")&&(y.browser="mini/".concat(y.browser)),y),this.initBussinessInfo_(k),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_=new a7({client:this}),this.keyPointManager_=new kF({client:this,frameWorkType:k.frameWorkType,component:k.component}),this.isPublishing_=!1,this.isEnableSmallStream_=!1,this.smallStreamConfig_={bitrate:100,frameRate:15,height:120,width:160},this.turnServers_=[],this.iceTransportPolicy_=k.iceTransportPolicy,this.schedule_={domains:null,iceServers:null,iceTransportPolicy:null,trtcCapability:null},this.isUsingCachedSchedule_=!1,this.enableAutoPlayDialog_=!!ge(k.enableAutoPlayDialog)||k.enableAutoPlayDialog,this.enableMultiAuxStream_=!ge(k.enableMultiAuxStream)&&k.enableMultiAuxStream,this.signalInfo_={},this.enableSEI_=!ge(k.enableSEI)&&k.enableSEI,this.isDestroyed_=!1}var t,n,i,r,o,c,a,s,l,u,h,S,I,E,x,m,T,v,w,L,N,V,_,b,R,P,U;return xe(e,[{key:"initBussinessInfo_",value:function(k){this.bussinessInfo_=k.bussinessInfo;var f={};if(Bt(k.bussinessInfo)&&(f=JSON.parse(k.bussinessInfo)),!ge(k.pureAudioPushMode)){if(!Number.isInteger(Number(k.pureAudioPushMode)))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:DN})});this.pureAudioPushMode_=k.pureAudioPushMode,f.Str_uc_params||(f.Str_uc_params={}),f.Str_uc_params.pure_audio_push_mod=this.pureAudioPushMode_}if(!ge(k.streamId)){if(!(Bt(k.streamId)&&String(k.streamId)&&String(k.streamId).length<=64))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:ON})});f.Str_uc_params||(f.Str_uc_params={}),f.Str_uc_params.userdefine_streamid_main=k.streamId}if(!ge(k.userDefineRecordId)){if(k.userDefineRecordId.match(/^[A-Za-z0-9_-]{1,64}$/gi)===null)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:LN})});f.Str_uc_params||(f.Str_uc_params={}),f.Str_uc_params.userdefine_record_id=k.userDefineRecordId}if(!ge(k.userDefinePushArgs)){if(!(Bt(k.userDefinePushArgs)&&String(k.userDefinePushArgs)&&String(k.userDefinePushArgs).length<=256))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:MN})});f.Str_uc_params||(f.Str_uc_params={}),f.Str_uc_params.userdefine_push_args=k.userDefinePushArgs}k.enableServerAudioMix&&(f.Str_uc_params||(f.Str_uc_params={}),f.Str_uc_params.enable_server_audio_mix=1,f.Str_uc_params.uc_biz_type=1e3),Br(f)||(this.bussinessInfo_=JSON.stringify(f))}},{key:"schedule",value:(U=H(p().mark(function k(f){var y,A,D;return p().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return j.next=2,OV({userId:this.userId_,sdkAppId:this.sdkAppId_,roomId:f,useStringRoomId:this.useStringRoomId_,version:this.version_,userSig:this.userSig_});case 2:y=j.sent,A=y.result,D=y.isCached,this.isUsingCachedSchedule_=D,A&&(this.log_.info("schedule with cache:".concat(D," : ").concat(JSON.stringify(A))),A.trtcCapability=A==null?void 0:A.trtcAutoConf,this.schedule_=q(q({},this.schedule_),A),Y.emit(qS,this.schedule_));case 7:case"end":return j.stop()}},k,this)})),function(k){return U.apply(this,arguments)})},{key:"getSignalChannelUrl",value:function(){var k={mainUrl:"",backupUrl:""},f=MS();return f?k.mainUrl=k.backupUrl="wss://".concat(f,".rtc.qq.com"):this.proxy_?k.mainUrl=k.backupUrl=this.proxy_:this.unifiedProxy_?k.mainUrl=k.backupUrl="wss://".concat(this.unifiedProxy_):Array.isArray(this.schedule_.domains)&&this.schedule_.domains.length>0&&(k.mainUrl=k.backupUrl="wss://".concat(this.schedule_.domains[0]),this.schedule_.domains[1]&&(k.backupUrl="wss://".concat(this.schedule_.domains[1]))),k}},{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:"getIceTransportPolicy",value:function(){return this.iceTransportPolicy_||this.schedule_.iceTransportPolicy||"all"}},{key:"initialize",value:function(k){var f=this;this.log_.info("setup signal channel");var y=this.getSignalChannelUrl(),A=y.mainUrl,D=y.backupUrl;return this.signalChannel_=new NV({sdkAppId:this.sdkAppId_,userId:this.userId_,userSig:this.userSig_,roomId:k.roomId,url:A,backupUrl:D,signalDomainWhenUnifiedProxy:this.unifiedProxy_?this.schedule_.domains[0]:void 0,client:this}),this.networkQuality_||(this.networkQuality_=new u6({connections:this.connections_,signalChannel:this.signalChannel_,userId:this.userId_,client:this}),this.networkQuality_.on(ct.NETWORK_QUALITY,function(j){f.emitter_.emit(ct.NETWORK_QUALITY,j)})),this.deviceDetector_||(this.deviceDetector_=new l6({client:this})),this.subscriptionManager_||(this.subscriptionManager_=new TF({client:this})),this.badCaseDetector_||(this.badCaseDetector_=new r7({client:this,stats:this.stats_})),this.callDurationCalculator_||(this.callDurationCalculator_=new o7({client:this})),this.mixTranscodeManager_||(this.mixTranscodeManager_=new i7({client:this,signalChannel:this.signalChannel_})),this.publishCDNManager_&&this.publishCDNManager_.setSignalChannel({signalChannel:this.signalChannel_}),this.signalChannel_.on(am,function(j){f.log_.info("SignalChannel state changed from ".concat(j.prevState," to ").concat(j.state)),f.emitter_.emit(ct.CONNECTION_STATE_CHANGED,j)}),this.signalChannel_.on(om,function(j){f.reset(),f.emitter_.emit(ct.ERROR,j)}),this.signalChannel_.once(pk,function(j){f.tinyId_=j.signalInfo.tinyId,Y.emit(dl,{client:f})}),this.signalChannel_.on(st.PEER_JOIN,this.onPeerJoin,this),this.signalChannel_.on(st.PEER_LEAVE,this.onPeerLeave,this),this.signalChannel_.on(st.UPDATE_REMOTE_MUTE_STAT,function(j){Date.now()-f.lastHeartBeatTime_>=1e4&&f.doHeartbeat(),Y.emit(Mp,{client:f,data:j.data}),f.onPublishedUserList(j.data),f.onUpdateRemoteMuteStat(j.data)}),this.signalChannel_.on(st.CLIENT_BANNED,function(j){var K,J=j.data.data.reason;if(ke.uploadEvent({log:"stat-banned:".concat(J),userId:f.userId_}),J===UM)K="you got banned by the admin";else if(J===VM)K="duplicated userId joining the room";else if(J===BM)K="the room has been disbanded by the admin",J=J.replace("_","-");else if(J===jM)return f.log_.warn("".concat(J," last heart beat time: ").concat(f.lastHeartBeatTime_," interval: ").concat(Date.now()-f.lastHeartBeatTime_,", visibility: ").concat(document.visibilityState)),void f.reJoin();f.log_[J==="kick"?"error":"info"]("user was banned because of [".concat(J,"]")),f.reset(),f.emitter_.emit(ct.CLIENT_BANNED,{reason:J,message:ae({key:ZN,data:{message:K,reason:J}})||J})}),Y.emit(Up,{client:this}),this.signalChannel_.connect()}},{key:"preJoin",value:(P=H(p().mark(function k(f){var y,A,D,j;return p().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return this.joinOptions_=f,K.next=3,Tm();case 3:if(this.checkSystemResult_=K.sent,this.checkDestroy(),(y=MS())||(y=Wu,this.proxy_&&(this.proxy_.startsWith(HM)?y=WM:this.proxy_.startsWith(GM)&&(y=zM))),this.env_=y,ke.setConfig({env:y,sdkAppId:this.sdkAppId_,userId:this.userId_,roomId:f.roomId}),this.uploadTrtcStats(),A=this.checkSystemResult_.detail,D=A.isH264EncodeSupported,j=A.isVp8EncodeSupported,Sm()&&(D||j)){K.next=13;break}throw new te({code:Z.NOT_SUPPORTED,message:ae({key:vS})});case 13:case"end":return K.stop()}},k,this)})),function(k){return P.apply(this,arguments)})},{key:"join",value:(R=H(p().mark(function k(f){var y,A=this;return p().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:return this.roomId_=f.roomId,ge(f.role)||(this.role_=f.role),ge(f.privateMapKey)||(this.privateMapKey_=f.privateMapKey),y=Ct(),Y.emit(ll,{client:this}),vn(this.userId_,{eventId:iV,eventDesc:"joining room",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),D.next=8,this.preJoin(f);case 8:return D.abrupt("return",new Promise(function(){var j=H(p().mark(function K(J,se){return p().wrap(function(ie){for(;;)switch(ie.prev=ie.next){case 0:if(A.joinReject_=se,ie.prev=1,A.proxy_||A.schedule_.domains){ie.next=5;break}return ie.next=5,A.schedule(f.roomId);case 5:return A.checkDestroy(),ie.next=8,A.initialize(f);case 8:return ie.next=10,A.doJoin(f);case 10:A.signalInfo_=A.signalChannel_.getSignalInfo(),Y.emit(po,{client:A}),A.joinedTimestamp_=Ct(),ke.logSuccessEvent({userId:A.userId_,eventType:eN,delta:A.joinedTimestamp_-y}),ke.logSuccessEvent({userId:A.userId_,eventType:Tb}),ke.uploadEvent({log:"stat-autoplay-dialog:".concat(A.enableAutoPlayDialog_),userId:A.userId_}),ke.uploadEvent({log:"stat-conv-".concat(ra,"-").concat(location.hostname),userId:A.userId_}),J(),ie.next=23;break;case 20:ie.prev=20,ie.t0=ie.catch(1),se(ie.t0);case 23:A.joinReject_=null;case 24:case"end":return ie.stop()}},K,null,[[1,20]])}));return function(K,J){return j.apply(this,arguments)}}()));case 9:case"end":return D.stop()}},k,this)})),function(k){return R.apply(this,arguments)})},{key:"checkDestroy",value:function(){if(this.isDestroyed_)throw new te({code:Z.INVALID_OPERATION,message:ae({key:rp,data:{funName:"join"}})})}},{key:"uploadTrtcStats",value:(b=H(p().mark(function k(){var f,y,A,D,j,K,J,se,ie,Je,Ue,Fe,ht;return p().wrap(function(We){for(;;)switch(We.prev=We.next){case 0:return We.prev=0,We.next=3,It.getMicrophones();case 3:A=We.sent,f=A&&A.length,We.next=9;break;case 7:We.prev=7,We.t0=We.catch(0);case 9:return We.prev=9,We.next=12,It.getCameras();case 12:D=We.sent,y=D&&D.length,We.next=18;break;case 16:We.prev=16,We.t1=We.catch(9);case 18:j={microphone:f,camera:y},K=this.checkSystemResult_.detail,J=K.isH264EncodeSupported,se=K.isVp8EncodeSupported,ie=K.isH264DecodeSupported,Je=K.isVp8DecodeSupported,Ue={webRTC:this.basis_.isWebRTCSupported,getUserMedia:this.basis_.isGetUserMediaSupported,webSocket:this.basis_.isWebSocketsSupported,screenShare:this.basis_.isScreenShareSupported,webAudio:this.basis_.isWebAudioSupported,h264Encode:J,h264Decode:ie,vp8Encode:se,vp8Decode:Je},Fe={browser:this.basis_.browser,os:this.basis_.os,trtc:Ue,devices:j},ht={isWebCodecSupported:this.basis_.isWebCodecSupported,isMediaSessionSupported:this.basis_.isMediaSessionSupported,isWebTransportSupported:this.basis_.isWebTransportSupported},ke.uploadEvent({log:"trtcstats-"+JSON.stringify(Fe),userId:this.userId_}),this.log_.info("TrtcStats-"+JSON.stringify(Fe)),ke.uploadEvent({log:"trtcadvancedstats-"+JSON.stringify(ht),userId:this.userId_});case 26:case"end":return We.stop()}},k,this,[[0,7],[9,16]])})),function(){return b.apply(this,arguments)})},{key:"doJoin",value:function(k){var f=this;return new Promise(function(y,A){f.log_.info("Join() => joining room: ".concat(f.roomId_," useStringRoomId: ").concat(f.useStringRoomId_," mode: ").concat(f.mode_," role: ").concat(f.role_));var D={roomId:String(f.roomId_),useStringRoomId:f.useStringRoomId_,privateMapKey:f.privateMapKey_,trtcRole:f.role_===Tr?so:Bf,trtcScene:f.mode_===zu?XM:KM,sdpSemantics:f.sdpSemantics_,version:P4(f.version_),ua:navigator&&navigator.userAgent||"",autoSubscribe:f.autoSubscribe_,terminalType:ta?4:cp?2:sp?3:ec?12:AS?5:PS?13:1,netType:Xf[xp()],bussinessInfo:f.bussinessInfo_,receiveMix:!0};if(f.publishCDNManager_){var j=f.publishCDNManager_.handleCDNConfigForJoinData(f.bussinessInfo_),K=j.bussinessInfo,J=j.pushUserCdnInfo;Object.assign(D,{bussinessInfo:K,pushUserCdnInfo:J})}f.log_.debug("join room signal data: ".concat(JSON.stringify(D))),f.joinTimeout_=setTimeout(function(){A(new te({code:Z.JOIN_ROOM_FAILED,message:ae({key:BN})}))},5e3),Y.emit(Ap,{client:f}),f.signalChannel_.once(mk,function(se){f.clearJoinTimeout(),Y.emit(dl,{client:f,error:se}),A(se)}),f.signalChannel_.send(xU,D),f.signalChannel_.once(st.JOIN_ROOM_RESULT,function(se){f.clearJoinTimeout();var ie=se.data,Je=ie.code,Ue=ie.message,Fe=ie.data;f.onPublishedUserList({data:{userList:Fe.publishers}}),Y.emit(Pp,{client:f,code:Je}),Je===0?(f.isJoined_=!0,f.log_.info("Join room success, start heartbeat"),f.startHeartbeat(),f.badCaseDetector_&&f.badCaseDetector_.start(),f.syncUserList(),f.startSyncUserListInterval(),y()):(f.log_.error("Join room failed result: "+Je+" error: "+Ue),A(new te({code:Z.JOIN_ROOM_FAILED,extraCode:Je,message:ae({key:uS,data:{error:Ue,code:Je}})})))})})}},{key:"reJoin",value:(_=H(p().mark(function k(){return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(this.isJoined_){f.next=3;break}return this.log_.warn("reJoin abort"),f.abrupt("return");case 3:return this.isJoined_=!1,f.prev=4,this.log_.warn("reJoin pending: ".concat(this.joinOptions_.roomId)),this.subscriptionManager_&&this.subscriptionManager_.markAllStream(),this.signalChannel_.close(),f.next=10,this.signalChannel_.connect();case 10:return f.next=12,this.doJoin(q(q({},this.joinOptions_),{},{role:this.role_,privateMapKey:this.privateMapKey_}));case 12:this.log_.warn("reJoin success"),ke.logSuccessEvent({userId:this.userId_,eventType:Ib}),this.checkConnectionsToReconnect(),this.uplinkConnection_&&!this.uplinkConnection_.getIsReconnecting()&&this.uplinkConnection_.startReconnection(),this.mixTranscodeManager_&&this.mixTranscodeManager_.reStartMixTranscode(),f.next=25;break;case 19:f.prev=19,f.t0=f.catch(4),this.log_.warn("reJoin fail "+f.t0),this.reset(),ke.logFailedEvent({userId:this.userId_,eventType:Ib,error:f.t0}),this.emitter_.emit(ct.ERROR,new te({code:Z.JOIN_ROOM_FAILED,message:ae({key:FN,data:{roomId:this.joinOptions_.roomId}})}));case 25:case"end":return f.stop()}},k,this,[[4,19]])})),function(){return _.apply(this,arguments)})},{key:"leave",value:(V=H(p().mark(function k(){var f;return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return Y.emit(Dp,{client:this}),vn(this.userId_,{eventId:aV,eventDesc:"leaving room",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),y.prev=2,y.next=5,this.doHeartbeat();case 5:y.next=9;break;case 7:y.prev=7,y.t0=y.catch(2);case 9:this.doLeave(),Y.emit(mo,{client:this}),ke.logSuccessEvent({userId:this.userId_,eventType:tN}),f=Math.floor((Ct()-this.joinedTimestamp_)/1e3),ke.logSuccessEvent({userId:this.userId_,eventType:nN,delta:f});case 14:case"end":return y.stop()}},k,this,[[2,7]])})),function(){return V.apply(this,arguments)})},{key:"doLeave",value:function(){this.isJoined_&&(Y.emit(Op,{client:this}),this.log_.info("leave() => leaving room"),this.signalChannel_.send(wU),this.reset())}},{key:"clearNetworkQuality",value:function(){this.networkQuality_&&(this.networkQuality_.stop(),this.networkQuality_=null)}},{key:"closeConnections",value:function(){var k=this;this.connections_.forEach(function(f){k.closeDownLink(f.getTinyId())})}},{key:"clearJoinTimeout",value:function(){clearTimeout(this.joinTimeout_),this.joinTimeout_=-1}},{key:"destroy",value:function(){var k,f,y;if(this.isJoined_)throw this.log_.warn(gi.INVALID_DESTROY),new te({code:Z.INVALID_OPERATION,message:ae({key:HN})});this.isDestroyed_||(this.log_.info("destroy client"),this.joinReject_&&(this.joinReject_(new te({code:Z.INVALID_OPERATION,message:ae({key:rp,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.off("*"),(k=this.callDurationCalculator_)===null||k===void 0||k.destroy(),(f=this.keyPointManager_)===null||f===void 0||f.destroy(),(y=this.deviceDetector_)===null||y===void 0||y.destroy(),this.callDurationCalculator_=null,this.keyPointManager_=null,this.deviceDetector_=null,this.badCaseDetector_=null,this.publishCDNManager_=null,this.isDestroyed_=!0,Y.emit(jp,{client:this}))}},{key:"reset",value:function(){this.isJoined_=!1,this.schedule_={domains:null,iceServers:null,iceTransportPolicy:null,trtcCapability:null},this.keyPointManager_&&this.keyPointManager_.prepareReport(),this.mixTranscodeManager_&&(this.mixTranscodeManager_.reset(),this.mixTranscodeManager_=null),this.publishCDNManager_&&this.publishCDNManager_.reset(),this.userMap_.clear(),this.stopSyncUserListInterval(),this.stopHeartbeat(),this.closeConnections(),this.mutedStates_.clear(),this.clearNetworkQuality(),this.badCaseDetector_&&this.callDurationCalculator_&&this.uploadAllCallStats(),this.closeUplink(),this.signalChannel_&&(this.log_.info("destroying SignalChannel"),this.signalChannel_.close(),this.signalChannel_=null),this.stats_.reset()}},{key:"startSyncUserListInterval",value:function(){this.syncUserListInterval_===-1&&(this.syncUserListInterval_=mt.run(uo,this.syncUserList.bind(this)))}},{key:"stopSyncUserListInterval",value:function(){mt.clearTask(this.syncUserListInterval_),this.syncUserListInterval_=-1}},{key:"syncUserList",value:(N=H(p().mark(function k(){var f,y=this;return p().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:return A.prev=0,A.next=3,this.getUserList();case 3:f=A.sent,this.userMap_.size!==0&&this.userMap_.forEach(function(D){f.findIndex(function(j){return j.userId===D.userId})<0&&(y.log_.info("peer leave detected: ".concat(D.userId)),y.cleanUser({userId:D.userId,tinyId:D.tinyId}))}),f.forEach(function(D){var j=D.userId;y.userMap_.has(j)||j===y.userId_||(y.userMap_.set(j,D),y.emitter_.emit(ct.PEER_JOIN,{userId:j}))}),A.next=11;break;case 8:A.prev=8,A.t0=A.catch(0),this.log_.warn("sync user list failed: "+A.t0);case 11:case"end":return A.stop()}},k,this,[[0,8]])})),function(){return N.apply(this,arguments)})},{key:"getUserList",value:function(){return this.signalChannel_?this.signalChannel_.sendWaitForResponse({command:jU,responseCommand:st.USER_LIST_RES,enableLog:!1,timeout:2e3}).then(function(k){var f=k.data,y=f.code,A=f.message;if(y===0)return(f.data&&f.data.userList||[]).map(function(D){var j=D.userId,K=D.srcTinyId,J=D.role;return new Yv({userId:j,tinyId:K,role:J})});throw ae({key:yS,data:{signalResponse:st.USER_LIST_RES,code:y,message:A}})}):[]}},{key:"publish",value:(L=H(p().mark(function k(f){var y,A,D,j,K,J,se,ie,Je=this,Ue=arguments;return p().wrap(function(Fe){for(;;)switch(Fe.prev=Fe.next){case 0:return y=Ue.length>1&&Ue[1]!==void 0?Ue[1]:{isAuxiliary:!1},f.setPublishState($s),this.isPublishing_=!0,A=Ct(),Y.emit(Np,{client:this,stream:f}),D=y.isAuxiliary,j=D?gt:Qe,K=f.getScreen(),this.log_.info("publish() => publishing ".concat(K?Mf+" ":"").concat(j," stream ").concat(f.getId())),J=this.uplinkConnection_,Fe.prev=10,J||((J=new OF({userId:this.userId_,tinyId:this.tinyId_,client:this,isUplink:!0,signalChannel:this.signalChannel_,enableSEI:this.enableSEI_})).initialize(),J.on(et.ERROR,function(ht){var We=ht.getCode();We!==Z.ICE_TRANSPORT_ERROR&&(We===Z.UPLINK_RECONNECTION_FAILED&&Je.closeUplink(),Je.emitter_.emit(ct.ERROR,ht))})),f.setConnection(J),Fe.next=15,J.publish(f,D);case 15:this.log_.info("local ".concat(K?Mf+" ":"").concat(j," stream is published")),this.isPublishing_=!1,D?this.localAuxStream_=f:(this.localStream_=f,this.deviceDetector_&&this.deviceDetector_.setLocalStream(this.localStream_),this.localStream_.getBeautyStatus()&&this.log_.info("beauty stream is published successfully")),f.setPublishState(iN),f.setClient(this,D),this.uplinkConnection_=J,se=Ct(),ie=se-A,ke.logSuccessEvent({userId:this.userId_,eventType:xb}),ke.logSuccessEvent({userId:this.userId_,eventType:rN,delta:ie}),f.hasAudio()&&vn(this.userId_,{eventId:yk,eventDesc:"publish audio track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),f.hasVideo()&&vn(this.userId_,{eventId:_k,eventDesc:"publish video track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),this.networkQuality_&&this.networkQuality_.setUplinkConnection(this.uplinkConnection_),Y.emit(N4,{localStream:f,isAuxiliary:D,client:this}),this.notPublishWithoutH264Supported_=!1,f.isAIDenoiser&&Ai.handleFunctionState({fnName:"AI_DENOISER"}),Fe.next=42;break;case 33:throw Fe.prev=33,Fe.t0=Fe.catch(10),Fe.t0 instanceof te&&Fe.t0.getCode()===Z.NOT_SUPPORTED_H264&&(this.notPublishWithoutH264Supported_=!0),f.setPublishState(zb),J.close(),this.log_.error("failed to publish stream "+Fe.t0),this.isPublishing_=!1,ke.logFailedEvent({userId:this.userId_,eventType:xb,error:Fe.t0}),Fe.t0;case 42:case"end":return Fe.stop()}},k,this,[[10,33]])})),function(k){return L.apply(this,arguments)})},{key:"unpublish",value:(w=H(p().mark(function k(f){var y,A;return p().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:if(this.uplinkConnection_){D.next=2;break}return D.abrupt("return");case 2:return y=f===this.localAuxStream_,A=f.getScreen(),this.log_.info("unpublish() => unpublishing local ".concat(A?Mf+" ":"").concat(y?gt:Qe," stream")),D.prev=5,D.next=8,this.uplinkConnection_.unpublish(f);case 8:ke.logSuccessEvent({userId:this.userId_,eventType:wb}),D.next=15;break;case 11:D.prev=11,D.t0=D.catch(5),this.log_.warn("unpublish error ".concat(D.t0)),ke.logFailedEvent({userId:this.userId_,eventType:wb,error:D.t0});case 15:f.setClient(null),f.setConnection(null),y?this.localAuxStream_=null:(this.localStream_=null,f.hasAudio()&&vn(this.userId_,{eventId:Sk,eventDesc:"unpublish audio track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),f.hasVideo()&&vn(this.userId_,{eventId:bk,eventDesc:"unpublish video track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_})),this.localStream_||this.localAuxStream_||this.closeUplink();case 19:case"end":return D.stop()}},k,this,[[5,11]])})),function(k){return w.apply(this,arguments)})},{key:"closeUplink",value:function(){this.uplinkConnection_&&(this.uplinkConnection_.close(),this.uplinkConnection_=null,this.networkQuality_&&this.networkQuality_.setUplinkConnection(null),this.localStream_&&(this.localStream_.setClient(null),this.localStream_.setConnection(null),this.localStream_=null),this.localAuxStream_&&(this.localAuxStream_.setClient(null),this.localAuxStream_.setConnection(null),this.localAuxStream_=null),this.deviceDetector_&&this.deviceDetector_.setLocalStream(null))}},{key:"closeDownLink",value:function(k){var f=this.connections_.get(k);f&&(f.getIsReconnecting()&&f.stopReconnection(),this.subscriptionManager_&&this.subscriptionManager_.delete(f.getUserId()),f.close(),this.connections_.delete(k),this.mutedStates_.delete(k))}},{key:"subscribe",value:(v=H(p().mark(function k(f,y){var A,D,j;return p().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return this.log_.info("subscribe() => subscribe to [".concat(f.getUserId(),"] ").concat(f.getType()," stream with options: ").concat(JSON.stringify(y))),ge(y)&&(y={audio:!0,video:!0}),ge(y.audio)&&(y.audio=!0),ge(y.smallVideo)?ge(y.video)&&(y.video=!0):y.smallVideo?ge(y.video)?(y.video=!1,y.smallVideo=!0):y.video&&(y.video=!0,delete y.smallVideo,this.log_.warn("options.video and options.smallVideo can't be both true")):ge(y.video)&&(y.video=!0,delete y.smallVideo),y.video&&this.changeBigSmallRecords_.delete(f.getUserId()),A=f.getConnection(),y.smallVideo&&(A.getTrackState().smallVideo||(this.setRemoteVideoStreamType(f,"small"),y.video=!0,delete y.smallVideo)),K.prev=7,Y.emit(Fp,{client:this,stream:f}),K.next=11,A.subscribe(f,y);case 11:this.subscriptionManager_&&this.subscriptionManager_.addSubscriptionRecord(f.getUserId(),f,y),this.notSubscribeWithoutH264Supported_=!1,ke.logSuccessEvent({userId:this.userId_,eventType:Cb}),A.checkTrackEnded(),K.next=25;break;case 17:throw K.prev=17,K.t0=K.catch(7),(D=K.t0 instanceof te?K.t0.getCode():Z.UNKNOWN)===Z.NOT_SUPPORTED_H264&&(this.notSubscribeWithoutH264Supported_=!0),(j=new te(D===Z.REMOTE_STREAM_NOT_EXIST?{code:Z.API_CALL_ABORTED,message:ae({key:op,data:{message:K.t0.message,stream:f}})}:{code:D,message:ae({key:KN,data:{message:K.t0.message,stream:f}})})).getCode()===Z.API_CALL_ABORTED?this.log_.warn(j):this.log_.error(j),ke.logFailedEvent({userId:this.userId_,eventType:Cb,error:j}),j;case 25:case"end":return K.stop()}},k,this,[[7,17]])})),function(k,f){return v.apply(this,arguments)})},{key:"unsubscribe",value:(T=H(p().mark(function k(f){var y;return p().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:return this.log_.info("unsubscribe() => unsubscribe to [".concat(f.getUserId(),"] ").concat(f.getType()," stream")),A.prev=1,y=f.getConnection(),A.next=5,y.unsubscribe(f);case 5:this.subscriptionManager_&&this.subscriptionManager_.addUnsubscriptionRecord(f.getUserId(),f),Y.emit(Vr,{client:this,stream:f}),ke.logSuccessEvent({userId:this.userId_,eventType:Eb}),A.next=14;break;case 10:throw A.prev=10,A.t0=A.catch(1),ke.logFailedEvent({userId:this.userId_,eventType:Eb,error:A.t0}),A.t0;case 14:case"end":return A.stop()}},k,this,[[1,10]])})),function(k){return T.apply(this,arguments)})},{key:"switchRole",value:(m=H(p().mark(function k(f){return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.role_!==f){y.next=2;break}return y.abrupt("return");case 2:return f===Zi&&this.uplinkConnection_&&this.closeUplink(),this.log_.info("switchRole() => switch role to: "+f),y.next=6,this.doSwitchRole(f);case 6:case"end":return y.stop()}},k,this)})),function(k){return m.apply(this,arguments)})},{key:"doSwitchRole",value:function(k){var f,y,A=this,D={command:BU,data:{role:k===Tr?so:Bf,privateMapKey:this.privateMapKey_},responseCommand:st.SWITCH_ROLE_RES,retries:((f=this.schedule_.config)===null||f===void 0||(y=f.retries)===null||y===void 0?void 0:y.switchRole)||1};return this.log_.info("switchRole signal data: "+JSON.stringify(D.data)),this.signalChannel_.sendWaitForResponseWithRetry(D).then(function(j){var K=j.data,J=K.code,se=K.message;if(J!==0)throw new te({code:Z.SWITCH_ROLE_FAILED,message:ae({key:$N,data:{errMsg:se,errCode:J}})});A.role_=k}).catch(function(j){throw j instanceof te&&j.getCode()===Z.API_CALL_TIMEOUT&&(j=new te({code:Z.SWITCH_ROLE_FAILED,message:ae({key:YN})})),A.log_.error(j),j})}},{key:"on",value:function(k,f,y){this.emitter_.on(k,f,y)}},{key:"off",value:function(k,f,y){k==="*"?this.emitter_.removeAllListeners():this.emitter_.off(k,f,y)}},{key:"getRemoteMutedState",value:function(){var k=this,f=[];return this.mutedStates_.forEach(function(y,A,D){var j=k.connections_.get(A);j&&f.push(q({userId:j.getUserId()},y))}),f}},{key:"getTransportStats",value:(x=H(p().mark(function k(){var f,y,A,D,j,K,J;return p().wrap(function(se){for(;;)switch(se.prev=se.next){case 0:if(f={rtt:0,downlinksRTT:{}},!this.uplinkConnection_){se.next=6;break}return se.next=4,this.stats_.getSenderStats(this.uplinkConnection_);case 4:y=se.sent,f.rtt=y.rtt;case 6:A=oe(this.connections_),se.prev=7,A.s();case 9:if((D=A.n()).done){se.next=17;break}return(j=Te(D.value,2))[0],K=j[1],se.next=13,this.stats_.getReceiverStats(K);case 13:J=se.sent,f.downlinksRTT[J.userId]=J.rtt;case 15:se.next=9;break;case 17:se.next=22;break;case 19:se.prev=19,se.t0=se.catch(7),A.e(se.t0);case 22:return se.prev=22,A.f(),se.finish(22);case 25:return se.abrupt("return",f);case 26:case"end":return se.stop()}},k,this,[[7,19,22,25]])})),function(){return x.apply(this,arguments)})},{key:"getLocalAudioStats",value:(E=H(p().mark(function k(){var f,y;return p().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if((f={})[this.userId_]={bytesSent:0,packetsSent:0},!this.uplinkConnection_){A.next=7;break}return A.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:y=A.sent,f[this.userId_]={bytesSent:y.audio.bytesSent,packetsSent:y.audio.packetsSent};case 7:return A.abrupt("return",f);case 8:case"end":return A.stop()}},k,this)})),function(){return E.apply(this,arguments)})},{key:"getLocalVideoStats",value:(I=H(p().mark(function k(){var f,y;return p().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if((f={})[this.userId_]={bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0},!this.uplinkConnection_){A.next=7;break}return A.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:y=A.sent,f[this.userId_]={bytesSent:y.video.bytesSent,packetsSent:y.video.packetsSent,framesEncoded:y.video.framesEncoded,framesSent:y.video.framesSent,frameWidth:y.video.frameWidth,frameHeight:y.video.frameHeight};case 7:return A.abrupt("return",f);case 8:case"end":return A.stop()}},k,this)})),function(){return I.apply(this,arguments)})},{key:"getRemoteAudioStats",value:(S=H(p().mark(function k(){var f,y,A,D,j,K,J,se;return p().wrap(function(ie){for(;;)switch(ie.prev=ie.next){case 0:f={},y=oe(this.connections_),ie.prev=2,y.s();case 4:if((A=y.n()).done){ie.next=13;break}return(D=Te(A.value,2))[0],j=D[1],K=j.getDelay(),J=K.audioDelay,ie.next=9,this.stats_.getReceiverStats(j);case 9:(se=ie.sent).hasAudio&&(f[se.userId]={bytesReceived:se.audio.bytesReceived,packetsReceived:se.audio.packetsReceived,packetsLost:se.audio.packetsLost,end2EndDelay:J});case 11:ie.next=4;break;case 13:ie.next=18;break;case 15:ie.prev=15,ie.t0=ie.catch(2),y.e(ie.t0);case 18:return ie.prev=18,y.f(),ie.finish(18);case 21:return ie.abrupt("return",f);case 22:case"end":return ie.stop()}},k,this,[[2,15,18,21]])})),function(){return S.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(h=H(p().mark(function k(){var f,y,A,D,j,K,J,se,ie,Je=arguments;return p().wrap(function(Ue){for(;;)switch(Ue.prev=Ue.next){case 0:f=Je.length>0&&Je[0]!==void 0?Je[0]:yt,y={},A=oe(this.connections_),Ue.prev=3,A.s();case 5:if((D=A.n()).done){Ue.next=15;break}return(j=Te(D.value,2))[0],K=j[1],Ue.next=9,this.stats_.getReceiverStats(K);case 9:J=Ue.sent,se=K.getDelay(),ie=se.videoDelay,f===yt&&J.hasVideo&&(y[J.userId]={bytesReceived:J.video.bytesReceived,packetsReceived:J.video.packetsReceived,packetsLost:J.video.packetsLost,framesDecoded:J.video.framesDecoded,frameWidth:J.video.frameWidth,frameHeight:J.video.frameHeight,end2EndDelay:ie}),f===Dt&&J.hasAuxiliary&&(y[J.userId]={bytesReceived:J.auxiliary.bytesReceived,packetsReceived:J.auxiliary.packetsReceived,packetsLost:J.auxiliary.packetsLost,framesDecoded:J.auxiliary.framesDecoded,frameWidth:J.auxiliary.frameWidth,frameHeight:J.auxiliary.frameHeight,end2EndDelay:ie});case 13:Ue.next=5;break;case 15:Ue.next=20;break;case 17:Ue.prev=17,Ue.t0=Ue.catch(3),A.e(Ue.t0);case 20:return Ue.prev=20,A.f(),Ue.finish(20);case 23:return Ue.abrupt("return",y);case 24:case"end":return Ue.stop()}},k,this,[[3,17,20,23]])})),function(){return h.apply(this,arguments)})},{key:"getSdpSemantics",value:function(){return this.sdpSemantics_}},{key:"getIceServers",value:function(){return this.turnServers_.length===0&&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(){this.heartbeat_===-1&&(this.log_.info("startHeartbeat..."),this.heartbeat_=mt.run(uo,this.doHeartbeat.bind(this),{delay:2e3}))}},{key:"stopHeartbeat",value:function(){this.heartbeat_!==-1&&(this.log_.info("stopHeartbeat"),mt.clearTask(this.heartbeat_),this.heartbeat_=-1,this.lastHeartBeatTime_=-1)}},{key:"doHeartbeat",value:(u=H(p().mark(function k(){var f,y,A,D,j,K;return p().wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return y=this.badCaseDetector_.getMonitorFreeze(),J.next=3,this.stats_.getStatsReport({uplinkConnection:this.uplinkConnection_,downlinkConnections:this.connections_,freezeMap:y});case 3:if(A=J.sent,Y.emit(Lp,{client:this,stats:A}),(f=this.badCaseDetector_)===null||f===void 0||f.resetMonitor(),this.signalChannel_){J.next=8;break}return J.abrupt("return");case 8:D=this.signalChannel_.isConnected()?SV(this.userId_):[],j=q(q({str_sdk_version:this.version_,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:Xf[this.networkType_]}},A),{},{msg_event_msg:D}),this.signalChannel_.send(CU,j),K=Date.now(),this.lastHeartBeatTime_>0&&K-this.lastHeartBeatTime_>1e4&&this.log_.warn("heartbeat took ".concat(K-this.lastHeartBeatTime_)),this.lastHeartBeatTime_=K,!this.isRelayChanged_&&this.isRelayMaybeFailed()&&(this.reJoin(),this.isRelayChanged_=!0);case 15:case"end":return J.stop()}},k,this)})),function(){return u.apply(this,arguments)})},{key:"onRemoteStreamAdded",value:function(k){var f=k.content,y=f.userId,A=f.tinyId,D=f.audio,j=f.bigVideo,K=f.auxVideo,J=f.smallVideo;if(y!==null){this.userMap_.has(y)||(this.userMap_.set(y,new Yv({userId:y,tinyId:A,role:Tr})),this.emitter_.emit(ct.PEER_JOIN,{userId:y}));var se=this.connections_.get(A);if(se){if(se.getIsReconnecting())return;this.log_.warn("duplicated stream-added observed, rebuild the connection"),se.close(),this.connections_.delete(A)}var ie={audio:D,video:j,auxiliary:K,smallVideo:J};this.log_.info("remote peer [".concat(y,"] published stream. trackState: ").concat(JSON.stringify(ie))),this.createDownlinkConnection({userId:y,tinyId:A,trackState:ie})}else this.log_.warn("received null userId on stream added")}},{key:"createDownlinkConnection",value:function(k){var f=this,y=k.userId,A=k.tinyId,D=k.trackState,j=new n7({userId:y,tinyId:A,client:this,isUplink:!1,signalChannel:this.signalChannel_,autoSubscribe:this.autoSubscribe_,trackState:D,enableSEI:this.enableSEI_});this.connections_.set(A,j),this.installDownlinkEvents(j,y,A),this.autoSubscribe_?(j.initialize(),j.connect().catch(function(){!j.getMainStream()&&j.hasMainStream()&&f.initRemoteStream({type:yt,userId:y,downlinkConnection:j}),!j.getAuxStream()&&j.hasAuxStream()&&f.initRemoteStream({type:Dt,userId:y,downlinkConnection:j})})):(j.hasMainStream()&&this.initRemoteStream({type:yt,userId:y,downlinkConnection:j}),j.hasAuxStream()&&this.initRemoteStream({type:Dt,userId:y,downlinkConnection:j}))}},{key:"initRemoteStream",value:function(k){var f=k.type,y=k.userId,A=k.downlinkConnection,D=new Gv({type:f,userId:y,client:this});D.setConnection(A),A.setRemoteStream(f===yt?Ir:Xs,D),D.setIsStreamAddedEventEmitted(!0),Y.emit(hl,{client:this,stream:D}),this.emitter_.emit(ct.STREAM_ADDED,{stream:D})}},{key:"installDownlinkEvents",value:function(k,f,y){var A=this;k.on(et.SEI_MESSAGE,function(D){A.emitter_.emit(ct.SEI_MESSAGE,D)}),k.on(et.STREAM_ADDED,function(D){D.stream.setIsStreamAddedEventEmitted(!0),Y.emit(hl,{client:A,stream:D.stream}),A.emitter_.emit(ct.STREAM_ADDED,{stream:D.stream})}),k.on(et.STREAM_REMOVED,function(D){A.changeBigSmallRecords_.delete(D.stream.getUserId()),D.stream.stop(),D.stream.setIsStreamAddedEventEmitted(!1),A.subscriptionManager_&&A.subscriptionManager_.deleteAutoRecoveryFlag(D.stream.getUserId(),D.stream.getType()),Y.emit(ca,{client:A,stream:D.stream}),A.emitter_.emit(ct.STREAM_REMOVED,{stream:D.stream})}),k.on(et.STREAM_UPDATED,function(D){Y.emit(M4,{client:A,stream:D.stream});var j=k.getMixUserList();j&&(D.mixUserList=j),A.emitter_.emit(ct.STREAM_UPDATED,D)}),k.on(et.STREAM_SUBSCRIBED,function(D){Y.emit(Ur,{client:A,stream:D.stream}),A.emitter_.emit(ct.STREAM_SUBSCRIBED,{stream:D.stream})}),k.on(et.ERROR,function(D){var j=D.getCode();j!==Z.ICE_TRANSPORT_ERROR&&(j===Z.DOWNLINK_RECONNECTION_FAILED&&A.closeDownLink(y),A.emitter_.emit(ct.ERROR,D))})}},{key:"onPeerJoin",value:function(k){var f=k.data.data,y=f.srcTinyId,A=f.userId,D=f.role;this.userMap_.has(A)||(this.userMap_.set(A,new Yv({userId:A,tinyId:y,role:D})),this.emitter_.emit(ct.PEER_JOIN,{userId:A}))}},{key:"onPeerLeave",value:function(k){var f=k.data.data,y=f.srcTinyId,A=f.userId,D=f.reason,j=D===void 0?0:D;this.log_.info("peer leave [".concat(A,"]: ").concat(hN[j])),this.cleanUser({userId:A,tinyId:y})}},{key:"cleanUser",value:function(k){var f=k.userId,y=k.tinyId;this.userMap_.delete(f),this.closeDownLink(y),this.emitter_.emit(ct.PEER_LEAVE,{userId:f})}},{key:"onPublishedUserList",value:function(k){var f=this;try{var y=Se(k.data.userList);k.data.mixRobotList&&y.push.apply(y,Se(k.data.mixRobotList)),k.data.fakeMixUser&&y.push(k.data.fakeMixUser);var A=y.map(function(D){return D.userId});this.connections_.forEach(function(D){var j=D.getUserId(),K=D.getTinyId();A.findIndex(function(J){return J===j})<0&&(f.log_.info("peer unpublished detected [".concat(j,"]")),f.closeDownLink(K))}),y.forEach(function(D){var j=D.userId,K=D.srcTinyId,J=D.flag,se=D.mixUserList;if(j!==f.userId_){var ie=!!(1&J),Je=!!(8&J),Ue=!!(4&J),Fe=!!(2&J),ht=f.connections_.get(K);if((Fe||ie)&&f.checkSubscribeBigSmallVideo(ht,Fe),ht){var We=ht.getTrackState(),Ec=We.audio,pd=We.video,Rc=We.auxiliary,Qx=We.smallVideo;ho(se)&&ht.setMixUserList(se),!pd&&ie&&Y.emit(jn,{client:f,tinyId:K,userId:j,action:cn.ADD,kind:Ie}),!Ec&&Je&&Y.emit(jn,{client:f,tinyId:K,userId:j,action:cn.ADD,kind:Ee}),!Rc&&Ue&&Y.emit(jn,{client:f,tinyId:K,userId:j,action:cn.ADD,kind:gt}),!Qx&&Fe&&Y.emit(jn,{client:f,tinyId:K,userId:j,action:cn.ADD,kind:Hu}),pd&&!ie&&Y.emit(jn,{client:f,tinyId:K,userId:j,action:cn.REMOVE,kind:Ie}),Ec&&!Je&&Y.emit(jn,{client:f,tinyId:K,userId:j,action:cn.REMOVE,kind:Ee}),Rc&&!Ue&&Y.emit(jn,{client:f,tinyId:K,userId:j,action:cn.REMOVE,kind:gt}),Qx&&!Fe&&Y.emit(jn,{client:f,tinyId:K,userId:j,action:cn.REMOVE,kind:Hu})}else f.log_.info("peer published detected [".concat(j,"]")),f.onRemoteStreamAdded({content:{audio:Je,bigVideo:ie,auxVideo:Ue,smallVideo:Fe,userId:j,tinyId:K}})}})}catch(D){}}},{key:"onUpdateRemoteMuteStat",value:function(k){var f=this,y=k.data;(y&&y.userList||[]).forEach(function(A){var D=A.srcTinyId,j=A.userId;if(D!==0&&D!==f.tinyId_){var K=f.connections_.get(D);if(K){var J=K.getMainStream();if(J&&J.getIsStreamAddedEventEmitted()){var se=!!(1&A.flag),ie=!!(8&A.flag),Je=!!(2&A.flag),Ue=!!(64&A.flag),Fe=!!(16&A.flag),ht=f.mutedStates_.get(D);if(ht===void 0)return f.mutedStates_.set(D,{hasAudio:ie,hasVideo:se,hasSmall:Je,audioMuted:Ue,videoMuted:Fe}),se?Fe?f.emitter_.emit(ct.MUTE_VIDEO,{userId:j}):f.emitter_.emit(ct.UNMUTE_VIDEO,{userId:j}):f.emitter_.emit(ct.MUTE_VIDEO,{userId:j}),void(ie?Ue?f.emitter_.emit(ct.MUTE_AUDIO,{userId:j}):f.emitter_.emit(ct.UNMUTE_AUDIO,{userId:j}):f.emitter_.emit(ct.MUTE_AUDIO,{userId:j}));var We=!ht.audioMuted&&ht.hasAudio,Ec=!Ue&&ie,pd=!ht.videoMuted&&ht.hasVideo,Rc=!Fe&&se;f.mutedStates_.set(D,{hasAudio:ie,hasVideo:se,hasSmall:Je,audioMuted:Ue,videoMuted:Fe}),We!==Ec&&(Ec?f.emitter_.emit(ct.UNMUTE_AUDIO,{userId:j}):f.emitter_.emit(ct.MUTE_AUDIO,{userId:j})),pd!==Rc&&(Rc?f.emitter_.emit(ct.UNMUTE_VIDEO,{userId:j}):f.emitter_.emit(ct.MUTE_VIDEO,{userId:j}))}}else f.mutedStates_.delete(D)}})}},{key:"getEnv",value:function(){return this.env_}},{key:"getSubscriptionManager",value:function(){return this.subscriptionManager_}},{key:"startPublishCDNStream",value:(l=H(p().mark(function k(){var f,y=arguments;return p().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(f=y.length>0&&y[0]!==void 0?y[0]:{},this.log_.info("startPublishCDNStream with params: ".concat(JSON.stringify(f),"; isJoined: ").concat(this.isJoined_,"; hasMainStream: ").concat(!!this.localStream_,"; hasAuxStream: ").concat(!!this.localAuxStream_,";")),f.streamType=f.streamType||Qe,f.streamType===gt&&(f.streamType=Nn),f.streamId=f.streamId||"",!this.isJoined_){A.next=10;break}if(f.streamType!==Qe||this.localStream_){A.next=8;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:lS})});case 8:if(f.streamType!==Nn||this.localAuxStream_){A.next=10;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:lS})});case 10:return A.next=12,this.publishCDNManager_.startPublishTencentCDN(f);case 12:if(!(f.appId&&f.bizId&&f.url)){A.next=15;break}return A.next=15,this.publishCDNManager_.startPublishGivenCDN(f);case 15:case"end":return A.stop()}},k,this)})),function(){return l.apply(this,arguments)})},{key:"stopPublishCDNStream",value:(s=H(p().mark(function k(){return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(this.publishCDNManager_.getIsPublishingTencentCDN()){f.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:e3})});case 2:return this.log_.info("stopPublishCDNStream"),f.next=5,this.publishCDNManager_.stopPublishTencentCDN();case 5:if(!this.publishCDNManager_.getIsPublishingGivenCDN()){f.next=8;break}return f.next=8,this.publishCDNManager_.stopPublishGivenCDN();case 8:case"end":return f.stop()}},k,this)})),function(){return s.apply(this,arguments)})},{key:"startMixTranscode",value:(a=H(p().mark(function k(f){return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){y.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:n3})});case 2:return ge(f.mode)&&(f.mode=Kf.MANUAL),y.prev=3,this.log_.info("startMixTranscode with config ".concat(JSON.stringify(f))),ke.uploadEvent({log:"mix-transcode-mode:".concat(f.mode),userId:this.userId_}),y.next=8,this.mixTranscodeManager_.startMixTranscode(f);case 8:ke.logSuccessEvent({userId:this.userId_,eventType:Vb}),y.next=15;break;case 11:throw y.prev=11,y.t0=y.catch(3),ke.logFailedEvent({userId:this.userId_,eventType:Vb,error:y.t0}),y.t0;case 15:case"end":return y.stop()}},k,this,[[3,11]])})),function(k){return a.apply(this,arguments)})},{key:"stopMixTranscode",value:(c=H(p().mark(function k(){return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){f.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:r3})});case 2:return f.prev=2,f.next=5,this.mixTranscodeManager_.stopMixTranscode();case 5:ke.logSuccessEvent({userId:this.userId_,eventType:jb}),f.next=12;break;case 8:throw f.prev=8,f.t0=f.catch(2),ke.logFailedEvent({userId:this.userId_,eventType:jb,error:f.t0}),f.t0;case 12:case"end":return f.stop()}},k,this,[[2,8]])})),function(){return c.apply(this,arguments)})},{key:"getSystemResult",value:function(){return this.checkSystemResult_}},{key:"enableAudioVolumeEvaluation",value:function(){var k=this,f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:2e3,y=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!tr(f))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:i3})});if(this.log_.info("enableAudioVolumeEvaluation with interval: "+f),f<=0)return this.enableAudioVolumeEvaluation_=!1,mt.clearTask(this.audioVolumeIntervalId_),void(this.audioVolumeIntervalId_=null);f=Math.floor(Math.max(f,16)),Y.emit(Vp,{interval:f}),this.audioVolumeIntervalId_&&(mt.clearTask(this.audioVolumeIntervalId_),this.audioVolumeIntervalId_=null),this.enableAudioVolumeEvaluation_=!0,this.audioVolumeIntervalId_=mt.run(Yu,function(){var A=[];if(k.localStream_){var D=Math.floor(100*k.localStream_.getAudioLevel());A.push({userId:k.userId_,audioVolume:D,stream:k.localStream_})}k.connections_.forEach(function(j){var K=j.getSubscribedMainStream();if(K){var J=Math.floor(100*K.getAudioLevel());A.push({userId:j.getUserId(),audioVolume:J,stream:K})}}),k.emitter_.emit(ct.AUDIO_VOLUME,{result:A})},{fps:1e3/f,backgroundTask:y})}},{key:"callExperimentalAPI",value:function(k,f){return this.log_.info("callExperimentalAPI(".concat(k,", ").concat(JSON.stringify(f),")")),c7.call(k,q({client:this},f))}},{key:"setProperty",value:function(k,f){var y="".concat(k,"_");ge(this[y])||(this[y]=f)}},{key:"uploadAllCallStats",value:function(){var k=this;this.callDurationCalculator_.getDurationMap().forEach(function(f,y){var A={userId:f.userId,type:f.type,duration:k.callDurationCalculator_.getDuration(y,Ie),dataFreeze:k.badCaseDetector_.getDataFreezeDuration(y).dataFreeze,renderFreeze:k.badCaseDetector_.getRenderFreezeDuration(y).renderFreeze};ke.uploadEvent({log:"callStats-"+JSON.stringify(A),userId:k.userId_})}),this.badCaseDetector_.stop(),this.callDurationCalculator_.reset()}},{key:"enableSmallStream",value:(o=H(p().mark(function k(){return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(!this.isPublished()&&!this.isPublishing_){f.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:a3})});case 2:if(!Wk()){f.next=7;break}this.setIsEnableSmallStream(!0),this.log_.info("SmallStream successfully enabled"),f.next=8;break;case 7:throw new te({code:Z.INVALID_OPERATION,message:ae({key:s3})});case 8:case"end":return f.stop()}},k,this)})),function(){return o.apply(this,arguments)})},{key:"disableSmallStream",value:(r=H(p().mark(function k(){return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(!this.isPublished()&&!this.isPublishing_){f.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:o3})});case 2:this.setIsEnableSmallStream(!1),this.log_.info("SmallStream successfully disabled");case 4:case"end":return f.stop()}},k,this)})),function(){return r.apply(this,arguments)})},{key:"setSmallStreamProfile",value:function(k){var f=this;k&&k.framerate&&(k.frameRate=k.framerate),k.width*k.height>307200&&(k.width=320,k.height=240,this.log_.info("Small stream resolution is beyond limitation, which is invalid. Reset to 320 * 240")),Object.keys(this.smallStreamConfig_).forEach(function(J){k[J]&&(f.smallStreamConfig_[J]=k[J])});var y=this.smallStreamConfig_,A=y.width,D=y.height,j=y.bitrate,K=y.frameRate;if(this.log_.info("setSmallStreamProfile: bitrate=".concat(j,", frameRate=").concat(K,", height=").concat(D,", width=").concat(A)),A<0||D<0||j<0||K<0)throw new te({code:Z.INVALID_PARAMETER,message:ae({key:c3})})}},{key:"setRemoteVideoStreamType",value:(i=H(p().mark(function k(f,y){return p().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(f instanceof Gv){A.next=2;break}throw new te({code:Z.INVALID_PARAMETER,message:ae({key:u3})});case 2:if(f.getConnection()){A.next=4;break}throw new te({code:Z.INVALID_OPERATION,message:ae({key:np})});case 4:if(f.getType()!==Dt){A.next=6;break}return A.abrupt("return");case 6:A.t0=y,A.next=A.t0===Jb||A.t0===qb?9:12;break;case 9:return A.next=11,this.changeVideoType(f,y);case 11:case 12:return A.abrupt("break",13);case 13:case"end":return A.stop()}},k,this)})),function(k,f){return i.apply(this,arguments)})},{key:"changeVideoType",value:(n=H(p().mark(function k(f,y){var A,D;return p().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:A=f.getUserId(),D={stream:f,options:{video:y===Jb,smallVideo:y===qb},isSubscribing:!1,reSubscribeCount:10},this.changeBigSmallRecords_.set(A,D),this.log_.info("set [".concat(A,"] ").concat(f.getType()," stream video prefer type: ").concat(y));case 5:case"end":return j.stop()}},k,this)})),function(k,f){return n.apply(this,arguments)})},{key:"checkSubscribeBigSmallVideo",value:(t=H(p().mark(function k(f,y){var A,D,j,K,J,se,ie,Je,Ue,Fe,ht;return p().wrap(function(We){for(;;)switch(We.prev=We.next){case 0:if(f!=null&&f.isBigStreamSubscribed||f!=null&&f.isSmallStreamSubscribed){We.next=2;break}return We.abrupt("return");case 2:if(A=f.getUserId(),this.changeBigSmallRecords_.has(A)){We.next=5;break}return We.abrupt("return");case 5:if(D=this.changeBigSmallRecords_.get(A),j=f.getSubscribeState(),K=j.video,J=j.smallVideo,se=D.stream,ie=D.options,Je=D.isSubscribing,Ue=D.reSubscribeCount,!(ie.video&&K||ie.smallVideo&&J&&y)){We.next=10;break}return We.abrupt("return");case 10:if(Fe={video:ie.video,smallVideo:ie.smallVideo},!(y&&f.isBigStreamSubscribed||f.isSmallStreamSubscribed)){We.next=31;break}if(We.prev=12,!(ie&&se&&!Je&&Ue>=1)){We.next=24;break}return D.isSubscribing=!0,D.reSubscribeCount=Ue-1,ht=se.getConnection(),!y&&ht.isSmallStreamSubscribed&&(Fe={video:!0,smallVideo:!1}),Fe.emitEvent=!1,We.next=21,ht==null?void 0:ht.subscribe(se,Fe);case 21:this.log_.info("change [".concat(A,"] to ").concat(Fe.smallVideo?"small":"big"," video successfully. count ").concat(10-D.reSubscribeCount,".")),D.isSubscribing=!1,D.reSubscribeCount=10;case 24:We.next=31;break;case 26:We.prev=26,We.t0=We.catch(12),this.log_.info("change [".concat(A,"] to ").concat(Fe.smallVideo?"small":"big"," video failed. count ").concat(10-D.reSubscribeCount,".")),D.isSubscribing=!1,Ue===0&&this.changeBigSmallRecords_.delete(A);case 31:case"end":return We.stop()}},k,this,[[12,26]])})),function(k,f){return t.apply(this,arguments)})},{key:"setIsEnableSmallStream",value:function(k){this.isEnableSmallStream_=k}},{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 k=Se(this.connections_.values());return this.uplinkConnection_&&k.push(this.uplinkConnection_),k}},{key:"isRelayMaybeFailed",value:function(){if(!this.signalChannel_.isOnline)return!1;var k=this.getAllConnections();if(k.length===0)return!1;for(var f=0;f<k.length;f++)if(k[f].getReconnectionCount()<6)return!1;return!0}},{key:"getUseStringRoomId",value:function(){return this.useStringRoomId_}},{key:"checkConnectionsToReconnect",value:function(){var k=this;this.getAllConnections().forEach(function(f){if(!f.getIsReconnecting()){var y=f.getPeerConnection();y&&y.connectionState===Hf&&(k.log_.warn("[".concat(f.getUserId(),"] pc is closed but not reconnect")),f.startReconnection())}})}},{key:"getEnableAutoPlayDialog",value:function(){return this.enableAutoPlayDialog_}},{key:"sendSEIMessage",value:function(k,f){this.uplinkConnection_.sendSEI(k,f)}},{key:"setProxyServer",value:function(k){if(this.log_.info("set proxy server: ".concat(JSON.stringify(k))),Bt(k)){if(!k.startsWith("wss://"))throw new te({code:Z.INVALID_PARAMETER,message:ae({key:NN})});this.proxy_=k}else if(bi(k)){var f=k.websocketProxy,y=k.loggerProxy,A=k.scheduleProxy,D=k.unifiedProxy;f&&(this.proxy_=f),y&&jf(y),A&&Xb(A),D&&(this.unifiedProxy_=D,jf("https://".concat(D)),Xb(D))}}},{key:"setTurnServer",value:function(k){this.log_.info("set turn server: "+JSON.stringify(k));var f=[];Array.isArray(k)?k.forEach(function(y){return f.push(jS(y))}):bi(k)&&f.push(jS(k)),this.turnServers_=f}},{key:"get2k4kFlag",value:function(){var k,f;return((k=this.schedule_)===null||k===void 0||(f=k.trtcCapability)===null||f===void 0?void 0:f["2k4k"])||2}},{key:"getWSProxy",value:function(){return this.proxy_}},{key:"getUnifiedProxy",value:function(){return this.unifiedProxy_}}]),e}(),X(Pe.prototype,"join",[fx,px,mx],Object.getOwnPropertyDescriptor(Pe.prototype,"join"),Pe.prototype),X(Pe.prototype,"leave",[vx],Object.getOwnPropertyDescriptor(Pe.prototype,"leave"),Pe.prototype),X(Pe.prototype,"getUserList",[gx],Object.getOwnPropertyDescriptor(Pe.prototype,"getUserList"),Pe.prototype),X(Pe.prototype,"publish",[_x,yx,bx],Object.getOwnPropertyDescriptor(Pe.prototype,"publish"),Pe.prototype),X(Pe.prototype,"unpublish",[Sx,kx],Object.getOwnPropertyDescriptor(Pe.prototype,"unpublish"),Pe.prototype),X(Pe.prototype,"subscribe",[Tx],Object.getOwnPropertyDescriptor(Pe.prototype,"subscribe"),Pe.prototype),X(Pe.prototype,"unsubscribe",[Ix],Object.getOwnPropertyDescriptor(Pe.prototype,"unsubscribe"),Pe.prototype),X(Pe.prototype,"switchRole",[xx,wx,Cx],Object.getOwnPropertyDescriptor(Pe.prototype,"switchRole"),Pe.prototype),X(Pe.prototype,"startPublishCDNStream",[Ex,Rx],Object.getOwnPropertyDescriptor(Pe.prototype,"startPublishCDNStream"),Pe.prototype),X(Pe.prototype,"stopPublishCDNStream",[Ax],Object.getOwnPropertyDescriptor(Pe.prototype,"stopPublishCDNStream"),Pe.prototype),X(Pe.prototype,"startMixTranscode",[Px,Dx],Object.getOwnPropertyDescriptor(Pe.prototype,"startMixTranscode"),Pe.prototype),X(Pe.prototype,"stopMixTranscode",[Ox],Object.getOwnPropertyDescriptor(Pe.prototype,"stopMixTranscode"),Pe.prototype),X(Pe.prototype,"enableAudioVolumeEvaluation",[Lx],Object.getOwnPropertyDescriptor(Pe.prototype,"enableAudioVolumeEvaluation"),Pe.prototype),X(Pe.prototype,"enableSmallStream",[Mx],Object.getOwnPropertyDescriptor(Pe.prototype,"enableSmallStream"),Pe.prototype),X(Pe.prototype,"disableSmallStream",[Nx],Object.getOwnPropertyDescriptor(Pe.prototype,"disableSmallStream"),Pe.prototype),X(Pe.prototype,"setSmallStreamProfile",[Ux],Object.getOwnPropertyDescriptor(Pe.prototype,"setSmallStreamProfile"),Pe.prototype),X(Pe.prototype,"setRemoteVideoStreamType",[Vx],Object.getOwnPropertyDescriptor(Pe.prototype,"setRemoteVideoStreamType"),Pe.prototype),X(Pe.prototype,"sendSEIMessage",[jx,Bx,Fx],Object.getOwnPropertyDescriptor(Pe.prototype,"sendSEIMessage"),Pe.prototype),X(Pe.prototype,"setProxyServer",[Hx],Object.getOwnPropertyDescriptor(Pe.prototype,"setProxyServer"),Pe.prototype),X(Pe.prototype,"setTurnServer",[Gx],Object.getOwnPropertyDescriptor(Pe.prototype,"setTurnServer"),Pe.prototype),Pe),l7=0,d7=0,h7=(Wx=St(Zs),zx=St(Zs),Jx=St(Zs),qx=Al(Yt.TRTC.createClient),Kx=St(Zs),Xx=Al(Yt.TRTC.createStream),$t=function(){function e(){Q(this,e),this.name_=Zs,this.VERSION=oi,this.Logger={loggerManager:_e,LogLevel:Un,setLogLevel:function(n){_e.setLogLevel(n),n<=1&&R4()},enableUploadLog:function(){Ai.handleFunctionState({fnName:"TRTC.enableUploadLog"}),_e.enableUploadLog()},disableUploadLog:function(){_e.warn("disableUploadLog"),Ai.handleFunctionState({fnName:"TRTC.disableUploadLog"}),_e.disableUploadLog()}}}var t;return xe(e,[{key:"checkSystemRequirements",value:(t=H(p().mark(function n(){return p().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,Tm();case 2:return i.abrupt("return",i.sent);case 3:case"end":return i.stop()}},n)})),function(){return t.apply(this,arguments)})},{key:"isScreenShareSupported",value:function(){return Bk()}},{key:"isSmallStreamSupported",value:function(){return Wk()}},{key:"getDevices",value:function(){return Rm()}},{key:"getCameras",value:function(){return function(){return Em.apply(this,arguments)}()}},{key:"getMicrophones",value:function(){return Xk()}},{key:"getSpeakers",value:function(){return Qk()}},{key:"createClient",value:function(n){(function(){if(QS&&(QS=!1,_e.getLogLevel()!=It.Logger.LogLevel.NONE&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: "+"".concat(Zf,"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("******************************************************************************")),_e.info("TRTC Web SDK Version: "+oi),_e.info("UserAgent: "+navigator.userAgent),_e.info("URL of current page: "+location.href),navigator.userAgentData&&ln(navigator.userAgentData.getHighEntropyValues)))try{navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"]).then(function(o){var c="UAData: ".concat(o.platform,"/").concat(o.platformVersion);o.architecture&&o.bitness&&(c+=" ".concat(o.architecture,"/").concat(o.bitness)),o.mobile&&(c+=" mobile"),o.model&&(c+=" model: ".concat(o.model)),o.fullVersionList&&(c+=" ".concat(o.fullVersionList.filter(function(a){return a.brand!=="Not/A)Brand"}).map(function(a){return"".concat(a.brand,"/").concat(a.version)}).join(","))),_e.info(c)}).catch(function(){})}catch(o){}})();var i={version:this.VERSION},r=new u7(q(q(q({},i),n),{},{seq:++l7}));return Y.emit(JS,{client:r}),r}},{key:"createStream",value:function(n){return new DF(q(q({},n),{},{seq:++d7}))}}]),e}(),X($t.prototype,"checkSystemRequirements",[Wx],Object.getOwnPropertyDescriptor($t.prototype,"checkSystemRequirements"),$t.prototype),X($t.prototype,"isScreenShareSupported",[zx],Object.getOwnPropertyDescriptor($t.prototype,"isScreenShareSupported"),$t.prototype),X($t.prototype,"isSmallStreamSupported",[Jx],Object.getOwnPropertyDescriptor($t.prototype,"isSmallStreamSupported"),$t.prototype),X($t.prototype,"createClient",[qx,Kx],Object.getOwnPropertyDescriptor($t.prototype,"createClient"),$t.prototype),X($t.prototype,"createStream",[Xx],Object.getOwnPropertyDescriptor($t.prototype,"createStream"),$t.prototype),$t),It=new h7;return It})});var ig=eg((L7,rg)=>{"use strict";var No=typeof Reflect=="object"?Reflect:null,tw=No&&typeof No.apply=="function"?No.apply:function(q,p,G){return Function.prototype.apply.call(q,p,G)},gd;No&&typeof No.ownKeys=="function"?gd=No.ownKeys:Object.getOwnPropertySymbols?gd=function(q){return Object.getOwnPropertyNames(q).concat(Object.getOwnPropertySymbols(q))}:gd=function(q){return Object.getOwnPropertyNames(q)};function S7(ne){console&&console.warn&&console.warn(ne)}var rw=Number.isNaN||function(q){return q!==q};function vt(){vt.init.call(this)}rg.exports=vt;rg.exports.once=x7;vt.EventEmitter=vt;vt.prototype._events=void 0;vt.prototype._eventsCount=0;vt.prototype._maxListeners=void 0;var nw=10;function _d(ne){if(typeof ne!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof ne)}Object.defineProperty(vt,"defaultMaxListeners",{enumerable:!0,get:function(){return nw},set:function(ne){if(typeof ne!="number"||ne<0||rw(ne))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+ne+".");nw=ne}});vt.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};vt.prototype.setMaxListeners=function(q){if(typeof q!="number"||q<0||rw(q))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+q+".");return this._maxListeners=q,this};function iw(ne){return ne._maxListeners===void 0?vt.defaultMaxListeners:ne._maxListeners}vt.prototype.getMaxListeners=function(){return iw(this)};vt.prototype.emit=function(q){for(var p=[],G=1;G<arguments.length;G++)p.push(arguments[G]);var $=q==="error",H=this._events;if(H!==void 0)$=$&&H.error===void 0;else if(!$)return!1;if($){var Q;if(p.length>0&&(Q=p[0]),Q instanceof Error)throw Q;var Re=new Error("Unhandled error."+(Q?" ("+Q.message+")":""));throw Re.context=Q,Re}var xe=H[q];if(xe===void 0)return!1;if(typeof xe=="function")tw(xe,this,p);else for(var $e=xe.length,Et=uw(xe,$e),G=0;G<$e;++G)tw(Et[G],this,p);return!0};function aw(ne,q,p,G){var $,H,Q;if(_d(p),H=ne._events,H===void 0?(H=ne._events=Object.create(null),ne._eventsCount=0):(H.newListener!==void 0&&(ne.emit("newListener",q,p.listener?p.listener:p),H=ne._events),Q=H[q]),Q===void 0)Q=H[q]=p,++ne._eventsCount;else if(typeof Q=="function"?Q=H[q]=G?[p,Q]:[Q,p]:G?Q.unshift(p):Q.push(p),$=iw(ne),$>0&&Q.length>$&&!Q.warned){Q.warned=!0;var Re=new Error("Possible EventEmitter memory leak detected. "+Q.length+" "+String(q)+" listeners added. Use emitter.setMaxListeners() to increase limit");Re.name="MaxListenersExceededWarning",Re.emitter=ne,Re.type=q,Re.count=Q.length,S7(Re)}return ne}vt.prototype.addListener=function(q,p){return aw(this,q,p,!1)};vt.prototype.on=vt.prototype.addListener;vt.prototype.prependListener=function(q,p){return aw(this,q,p,!0)};function k7(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ow(ne,q,p){var G={fired:!1,wrapFn:void 0,target:ne,type:q,listener:p},$=k7.bind(G);return $.listener=p,G.wrapFn=$,$}vt.prototype.once=function(q,p){return _d(p),this.on(q,ow(this,q,p)),this};vt.prototype.prependOnceListener=function(q,p){return _d(p),this.prependListener(q,ow(this,q,p)),this};vt.prototype.removeListener=function(q,p){var G,$,H,Q,Re;if(_d(p),$=this._events,$===void 0)return this;if(G=$[q],G===void 0)return this;if(G===p||G.listener===p)--this._eventsCount===0?this._events=Object.create(null):(delete $[q],$.removeListener&&this.emit("removeListener",q,G.listener||p));else if(typeof G!="function"){for(H=-1,Q=G.length-1;Q>=0;Q--)if(G[Q]===p||G[Q].listener===p){Re=G[Q].listener,H=Q;break}if(H<0)return this;H===0?G.shift():T7(G,H),G.length===1&&($[q]=G[0]),$.removeListener!==void 0&&this.emit("removeListener",q,Re||p)}return this};vt.prototype.off=vt.prototype.removeListener;vt.prototype.removeAllListeners=function(q){var p,G,$;if(G=this._events,G===void 0)return this;if(G.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):G[q]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete G[q]),this;if(arguments.length===0){var H=Object.keys(G),Q;for($=0;$<H.length;++$)Q=H[$],Q!=="removeListener"&&this.removeAllListeners(Q);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(p=G[q],typeof p=="function")this.removeListener(q,p);else if(p!==void 0)for($=p.length-1;$>=0;$--)this.removeListener(q,p[$]);return this};function sw(ne,q,p){var G=ne._events;if(G===void 0)return[];var $=G[q];return $===void 0?[]:typeof $=="function"?p?[$.listener||$]:[$]:p?I7($):uw($,$.length)}vt.prototype.listeners=function(q){return sw(this,q,!0)};vt.prototype.rawListeners=function(q){return sw(this,q,!1)};vt.listenerCount=function(ne,q){return typeof ne.listenerCount=="function"?ne.listenerCount(q):cw.call(ne,q)};vt.prototype.listenerCount=cw;function cw(ne){var q=this._events;if(q!==void 0){var p=q[ne];if(typeof p=="function")return 1;if(p!==void 0)return p.length}return 0}vt.prototype.eventNames=function(){return this._eventsCount>0?gd(this._events):[]};function uw(ne,q){for(var p=new Array(q),G=0;G<q;++G)p[G]=ne[G];return p}function T7(ne,q){for(;q+1<ne.length;q++)ne[q]=ne[q+1];ne.pop()}function I7(ne){for(var q=new Array(ne.length),p=0;p<q.length;++p)q[p]=ne[p].listener||ne[p];return q}function x7(ne,q){return new Promise(function(p,G){function $(Q){ne.removeListener(q,H),G(Q)}function H(){typeof ne.removeListener=="function"&&ne.removeListener("error",$),p([].slice.call(arguments))}lw(ne,q,H,{once:!0}),q!=="error"&&w7(ne,$,{once:!0})})}function w7(ne,q,p){typeof ne.on=="function"&&lw(ne,"error",q,p)}function lw(ne,q,p,G){if(typeof ne.on=="function")G.once?ne.once(q,p):ne.on(q,p);else if(typeof ne.addEventListener=="function")ne.addEventListener(q,function $(H){G.once&&ne.removeEventListener(q,$),p(H)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof ne)}});var hw=eg((ag,og)=>{(function(ne,q){typeof ag=="object"&&typeof og!="undefined"?og.exports=q(Er()):typeof define=="function"&&define.amd?define(["trtc-js-sdk"],q):(ne=typeof globalThis!="undefined"?globalThis:ne||self).RTCBeautyPlugin=q(ne.TRTC)})(ag,function(ne){function q(le){return le&&typeof le=="object"&&"default"in le?le:{default:le}}var p=q(ne);function G(){G=function(){return le};var le={},Te=Object.prototype,Se=Te.hasOwnProperty,je=typeof Symbol=="function"?Symbol:{},He=je.iterator||"@@iterator",oe=je.asyncIterator||"@@asyncIterator",X=je.toStringTag||"@@toStringTag";function ce(he,de,Ne){return Object.defineProperty(he,de,{value:Ne,enumerable:!0,configurable:!0,writable:!0}),he[de]}try{ce({},"")}catch(he){ce=function(de,Ne,ze){return de[Ne]=ze}}function W(he,de,Ne,ze){var De=de&&de.prototype instanceof ue?de:ue,ut=Object.create(De.prototype),rt=new Ze(ze||[]);return ut._invoke=function(Ut,en,pe){var Ot="suspendedStart";return function(Kt,fr){if(Ot==="executing")throw new Error("Generator is already running");if(Ot==="completed"){if(Kt==="throw")throw fr;return qn()}for(pe.method=Kt,pe.arg=fr;;){var Di=pe.delegate;if(Di){var yn=hr(Di,pe);if(yn){if(yn===be)continue;return yn}}if(pe.method==="next")pe.sent=pe._sent=pe.arg;else if(pe.method==="throw"){if(Ot==="suspendedStart")throw Ot="completed",pe.arg;pe.dispatchException(pe.arg)}else pe.method==="return"&&pe.abrupt("return",pe.arg);Ot="executing";var Rt=re(Ut,en,pe);if(Rt.type==="normal"){if(Ot=pe.done?"completed":"suspendedYield",Rt.arg===be)continue;return{value:Rt.arg,done:pe.done}}Rt.type==="throw"&&(Ot="completed",pe.method="throw",pe.arg=Rt.arg)}}}(he,Ne,rt),ut}function re(he,de,Ne){try{return{type:"normal",arg:he.call(de,Ne)}}catch(ze){return{type:"throw",arg:ze}}}le.wrap=W;var be={};function ue(){}function ye(){}function Me(){}var Jt={};ce(Jt,He,function(){return this});var Zt=Object.getPrototypeOf,Ke=Zt&&Zt(Zt(Gt([])));Ke&&Ke!==Te&&Se.call(Ke,He)&&(Jt=Ke);var qt=Me.prototype=ue.prototype=Object.create(Jt);function ft(he){["next","throw","return"].forEach(function(de){ce(he,de,function(Ne){return this._invoke(de,Ne)})})}function Jn(he,de){function Ne(De,ut,rt,Ut){var en=re(he[De],he,ut);if(en.type!=="throw"){var pe=en.arg,Ot=pe.value;return Ot&&typeof Ot=="object"&&Se.call(Ot,"__await")?de.resolve(Ot.__await).then(function(Kt){Ne("next",Kt,rt,Ut)},function(Kt){Ne("throw",Kt,rt,Ut)}):de.resolve(Ot).then(function(Kt){pe.value=Kt,rt(pe)},function(Kt){return Ne("throw",Kt,rt,Ut)})}Ut(en.arg)}var ze;this._invoke=function(De,ut){function rt(){return new de(function(Ut,en){Ne(De,ut,Ut,en)})}return ze=ze?ze.then(rt,rt):rt()}}function hr(he,de){var Ne=he.iterator[de.method];if(Ne===void 0){if(de.delegate=null,de.method==="throw"){if(he.iterator.return&&(de.method="return",de.arg=void 0,hr(he,de),de.method==="throw"))return be;de.method="throw",de.arg=new TypeError("The iterator does not provide a 'throw' method")}return be}var ze=re(Ne,he.iterator,de.arg);if(ze.type==="throw")return de.method="throw",de.arg=ze.arg,de.delegate=null,be;var De=ze.arg;return De?De.done?(de[he.resultName]=De.value,de.next=he.nextLoc,de.method!=="return"&&(de.method="next",de.arg=void 0),de.delegate=null,be):De:(de.method="throw",de.arg=new TypeError("iterator result is not an object"),de.delegate=null,be)}function Ht(he){var de={tryLoc:he[0]};1 in he&&(de.catchLoc=he[1]),2 in he&&(de.finallyLoc=he[2],de.afterLoc=he[3]),this.tryEntries.push(de)}function Rn(he){var de=he.completion||{};de.type="normal",delete de.arg,he.completion=de}function Ze(he){this.tryEntries=[{tryLoc:"root"}],he.forEach(Ht,this),this.reset(!0)}function Gt(he){if(he){var de=he[He];if(de)return de.call(he);if(typeof he.next=="function")return he;if(!isNaN(he.length)){var Ne=-1,ze=function De(){for(;++Ne<he.length;)if(Se.call(he,Ne))return De.value=he[Ne],De.done=!1,De;return De.value=void 0,De.done=!0,De};return ze.next=ze}}return{next:qn}}function qn(){return{value:void 0,done:!0}}return ye.prototype=Me,ce(qt,"constructor",Me),ce(Me,"constructor",ye),ye.displayName=ce(Me,X,"GeneratorFunction"),le.isGeneratorFunction=function(he){var de=typeof he=="function"&&he.constructor;return!!de&&(de===ye||(de.displayName||de.name)==="GeneratorFunction")},le.mark=function(he){return Object.setPrototypeOf?Object.setPrototypeOf(he,Me):(he.__proto__=Me,ce(he,X,"GeneratorFunction")),he.prototype=Object.create(qt),he},le.awrap=function(he){return{__await:he}},ft(Jn.prototype),ce(Jn.prototype,oe,function(){return this}),le.AsyncIterator=Jn,le.async=function(he,de,Ne,ze,De){De===void 0&&(De=Promise);var ut=new Jn(W(he,de,Ne,ze),De);return le.isGeneratorFunction(de)?ut:ut.next().then(function(rt){return rt.done?rt.value:ut.next()})},ft(qt),ce(qt,X,"Generator"),ce(qt,He,function(){return this}),ce(qt,"toString",function(){return"[object Generator]"}),le.keys=function(he){var de=[];for(var Ne in he)de.push(Ne);return de.reverse(),function ze(){for(;de.length;){var De=de.pop();if(De in he)return ze.value=De,ze.done=!1,ze}return ze.done=!0,ze}},le.values=Gt,Ze.prototype={constructor:Ze,reset:function(he){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(Rn),!he)for(var de in this)de.charAt(0)==="t"&&Se.call(this,de)&&!isNaN(+de.slice(1))&&(this[de]=void 0)},stop:function(){this.done=!0;var he=this.tryEntries[0].completion;if(he.type==="throw")throw he.arg;return this.rval},dispatchException:function(he){if(this.done)throw he;var de=this;function Ne(en,pe){return ut.type="throw",ut.arg=he,de.next=en,pe&&(de.method="next",de.arg=void 0),!!pe}for(var ze=this.tryEntries.length-1;ze>=0;--ze){var De=this.tryEntries[ze],ut=De.completion;if(De.tryLoc==="root")return Ne("end");if(De.tryLoc<=this.prev){var rt=Se.call(De,"catchLoc"),Ut=Se.call(De,"finallyLoc");if(rt&&Ut){if(this.prev<De.catchLoc)return Ne(De.catchLoc,!0);if(this.prev<De.finallyLoc)return Ne(De.finallyLoc)}else if(rt){if(this.prev<De.catchLoc)return Ne(De.catchLoc,!0)}else{if(!Ut)throw new Error("try statement without catch or finally");if(this.prev<De.finallyLoc)return Ne(De.finallyLoc)}}}},abrupt:function(he,de){for(var Ne=this.tryEntries.length-1;Ne>=0;--Ne){var ze=this.tryEntries[Ne];if(ze.tryLoc<=this.prev&&Se.call(ze,"finallyLoc")&&this.prev<ze.finallyLoc){var De=ze;break}}De&&(he==="break"||he==="continue")&&De.tryLoc<=de&&de<=De.finallyLoc&&(De=null);var ut=De?De.completion:{};return ut.type=he,ut.arg=de,De?(this.method="next",this.next=De.finallyLoc,be):this.complete(ut)},complete:function(he,de){if(he.type==="throw")throw he.arg;return he.type==="break"||he.type==="continue"?this.next=he.arg:he.type==="return"?(this.rval=this.arg=he.arg,this.method="return",this.next="end"):he.type==="normal"&&de&&(this.next=de),be},finish:function(he){for(var de=this.tryEntries.length-1;de>=0;--de){var Ne=this.tryEntries[de];if(Ne.finallyLoc===he)return this.complete(Ne.completion,Ne.afterLoc),Rn(Ne),be}},catch:function(he){for(var de=this.tryEntries.length-1;de>=0;--de){var Ne=this.tryEntries[de];if(Ne.tryLoc===he){var ze=Ne.completion;if(ze.type==="throw"){var De=ze.arg;Rn(Ne)}return De}}throw new Error("illegal catch attempt")},delegateYield:function(he,de,Ne){return this.delegate={iterator:Gt(he),resultName:de,nextLoc:Ne},this.method==="next"&&(this.arg=void 0),be}},le}function $(le){return $=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Te){return typeof Te}:function(Te){return Te&&typeof Symbol=="function"&&Te.constructor===Symbol&&Te!==Symbol.prototype?"symbol":typeof Te},$(le)}function H(le,Te,Se,je,He,oe,X){try{var ce=le[oe](X),W=ce.value}catch(re){return void Se(re)}ce.done?Te(W):Promise.resolve(W).then(je,He)}function Q(le){return function(){var Te=this,Se=arguments;return new Promise(function(je,He){var oe=le.apply(Te,Se);function X(W){H(oe,je,He,X,ce,"next",W)}function ce(W){H(oe,je,He,X,ce,"throw",W)}X(void 0)})}}function Re(le,Te){if(!(le instanceof Te))throw new TypeError("Cannot call a class as a function")}function xe(le,Te){for(var Se=0;Se<Te.length;Se++){var je=Te[Se];je.enumerable=je.enumerable||!1,je.configurable=!0,"value"in je&&(je.writable=!0),Object.defineProperty(le,je.key,je)}}function $e(le,Te,Se){return Te&&xe(le.prototype,Te),Se&&xe(le,Se),Object.defineProperty(le,"prototype",{writable:!1}),le}function Et(le,Te,Se){var je=function(re,be,ue){var ye=new RegExp("\\b".concat(be," \\w+ (\\w+)"),"ig");re.replace(ye,function(Me,Jt){return ue[Jt]=0,Me})},He=function(re,be,ue){var ye=re.createShader(ue);return re.shaderSource(ye,be),re.compileShader(ye),re.getShaderParameter(ye,re.COMPILE_STATUS)?ye:(console.log(re.getShaderInfoLog(ye)),null)};this.uniform={},this.attribute={};var oe=He(le,Te,le.VERTEX_SHADER),X=He(le,Se,le.FRAGMENT_SHADER);for(var ce in this.id=le.createProgram(),le.attachShader(this.id,oe),le.attachShader(this.id,X),le.linkProgram(this.id),le.getProgramParameter(this.id,le.LINK_STATUS)||console.log(le.getProgramInfoLog(this.id)),le.useProgram(this.id),je(Te,"attribute",this.attribute),this.attribute)this.attribute[ce]=le.getAttribLocation(this.id,ce);for(var W in je(Te,"uniform",this.uniform),je(Se,"uniform",this.uniform),this.uniform)this.uniform[W]=le.getUniformLocation(this.id,W)}function Ye(le,Te,Se,je){for(var He=[],oe=0;oe<Te.length;++oe)He.push(Pc(le,Te[oe],le[dr[oe]]));return function(X,ce,W,re){var be=X.createProgram();return ce.forEach(function(ue){X.attachShader(be,ue)}),W&&W.forEach(function(ue,ye){X.bindAttribLocation(be,re?re[ye]:ye,ue)}),X.linkProgram(be),X.getProgramParameter(be,X.LINK_STATUS)?be:(X.deleteProgram(be),null)}(le,He,Se,je)}var dr=["VERTEX_SHADER","FRAGMENT_SHADER"];function Pc(le,Te,Se){var je=le.createShader(Se);return le.shaderSource(je,Te),le.compileShader(je),le.getShaderParameter(je,le.COMPILE_STATUS)?je:(le.deleteShader(je),null)}var Wo=function(){function le(Te){Re(this,le),this.canvas=Te.canvas,this.video=Te.video,this.width=Te.width||640,this.height=Te.height||480,this.vertexBuffer=null,this.currentProgram=null,this.applied=!1,this.beautyParams={beauty:.5,brightness:.5,ruddy:.5},this.gl=this.createGL(Te.canvas),this.sourceTexture=this.gl.createTexture()}return $e(le,[{key:"setRect",value:function(Te,Se){this.width=Te,this.height=Se}},{key:"apply",value:function(Te){if(!this.vertexBuffer){var Se=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);this.vertexBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,Se,this.gl.STATIC_DRAW),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}this.gl.viewport(0,0,this.width,this.height),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.applied?this.gl.texSubImage2D(this.gl.TEXTURE_2D,0,0,0,this.gl.RGB,this.gl.UNSIGNED_BYTE,Te):(this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGB,this.gl.RGB,this.gl.UNSIGNED_BYTE,Te),this.applied=!0);var je=this.beautyParams,He=je.beauty,oe=je.brightness,X=je.ruddy,ce=2/this.width,W=2/this.height,re=this.compileBeautyShader();this.gl.uniform2f(re.uniform.singleStepOffset,ce,W);var be=new Float32Array([1-.8*He,1-.6*He,.1+.45*X,.1+.45*X]);this.gl.uniform4fv(re.uniform.params,be),this.gl.uniform1f(re.uniform.brightness,.12*oe),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null),this.gl.uniform1f(this.currentProgram.uniform.flipY,1),this.gl.drawArrays(this.gl.TRIANGLES,0,6)}},{key:"compileBeautyShader",value:function(){if(this.currentProgram)return this.currentProgram;this.currentProgram=new Et(this.gl,["precision highp float;","attribute vec2 pos;","attribute vec2 uv;","varying vec2 vUv;","uniform float flipY;","void main(void) {","vUv = uv;","gl_Position = vec4(pos.x, pos.y*flipY, 0.0, 1.);","}"].join(`
67
+ b=`+D+":"+y+`\r
68
+ `)}},{key:"removeBandwidthRestriction",value:function(T){return T.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}},{key:"removeVideoOrientation",value:function(T){return T.replace(/urn:3gpp:video-orientation/,"")}},{key:"connect",value:(o=H(f().mark(function T(){return f().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.prev=0,y.next=3,this.exchangeSDP();case 3:return y.next=5,this.waitForPeerConnectionConnected();case 5:y.next=11;break;case 7:throw y.prev=7,y.t0=y.catch(0),this.closePeerConnection(!0),y.t0;case 11:case"end":return y.stop()}},T,this,[[0,7]])})),function(){return o.apply(this,arguments)})},{key:"exchangeSDP",value:(r=H(f().mark(function T(){return f().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.prev=0,this.isSDPExchanging_=!0,y.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),y.next=7,this.doExchangeSDP();case 7:this.isSDPExchanging_=!1,y.next=14;break;case 10:throw y.prev=10,y.t0=y.catch(0),this.isSDPExchanging_=!1,y.t0;case 14:case"end":return y.stop()}},T,this,[[0,10]])})),function(){return r.apply(this,arguments)})},{key:"createOffer",value:(i=H(f().mark(function T(){var y;return f().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:return D.prev=0,D.next=3,this.peerConnection_.createOffer(WI);case 3:return y=D.sent,D.next=6,this.peerConnection_.setLocalDescription(y);case 6:this.updateSSRC(y.sdp),ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:qu,kind:"offer"}),D.next=14;break;case 10:throw D.prev=10,D.t0=D.catch(0),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:qu,kind:"offer",error:D.t0}),D.t0;case 14:case"end":return D.stop()}},T,this,[[0,10]])})),function(){return i.apply(this,arguments)})},{key:"doExchangeSDP",value:function(){var T=this;return new Promise(function(y,D){T.exchangeSDPTimeout_=setTimeout(function(){T.signalChannel_.off(st.PUBLISH_RESULT,A),T.clearExchangeSDPTimeout();var S=new te({code:Z.API_CALL_TIMEOUT,message:ie({key:EN})});D(S)},1e4);var A=function(){var S=H(f().mark(function p(_){var P,M,B;return f().wrap(function(X){for(;;)switch(X.prev=X.next){case 0:if(X.prev=0,T.clearExchangeSDPTimeout(),P=_.data,M=P.code,B=P.message,M!==0){X.next=9;break}return X.next=6,T.acceptAnswer(_.data.data);case 6:y(),X.next=10;break;case 9:T.checkPublishResultCode(M,B);case 10:X.next=15;break;case 12:X.prev=12,X.t0=X.catch(0),D(X.t0);case 15:case"end":return X.stop()}},p,null,[[0,12]])}));return function(p){return S.apply(this,arguments)}}(),U={type:T.peerConnection_.localDescription.type,sdp:T.removeVideoOrientation(T.peerConnection_.localDescription.sdp),screen:(T.publishingStream_||T.localStream_).hasScreenTrack(),state:T.publishState,constraintConfig:T.mediaSettings_};T.signalChannel_.once(st.PUBLISH_RESULT,A),T.log_.debug("sending sdp offer: "+U.sdp),T.signalChannel_.send(RU,U)})}},{key:"setSDPDirection",value:function(T,y){var D=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"all",A=Fr(T);return A.media.forEach(function(U){D!=="all"&&U.type!==D||(U.direction=y)}),yo(A)}},{key:"acceptAnswer",value:(n=H(f().mark(function T(y){var D,A,U,S,p,_,P;return f().wrap(function(M){for(;;)switch(M.prev=M.next){case 0:if(M.prev=0,D=this.removeVideoOrientation(y.sdp),!(A=this.publishingStream_||this.localStream_)){M.next=15;break}if(U=A.getVideoBitrate(),S=A.getAudioBitrate(),!U){M.next=11;break}return p=this.isPublishingAuxStream_?gt:Bu,M.next=10,this.setBandwidth({sdp:D,videoType:p,type:Ie,bandwidth:U,scaleResolutionDownBy:A.scaleResolutionDownBy});case 10:D=M.sent;case 11:if(!S){M.next=15;break}return M.next=14,this.setBandwidth({bandwidth:S,type:Re,sdp:D});case 14:D=M.sent;case 15:if(!this.client_.getIsEnableSmallStream()){M.next=20;break}return _=this.client_.smallStreamConfig,M.next=19,this.setBandwidth({bandwidth:_.bitrate,type:Ie,videoType:Mr,sdp:D});case 19:D=M.sent;case 20:return P={type:y.type,sdp:D},M.next=23,this.peerConnection_.setRemoteDescription(P);case 23:this.log_.debug("accepted answer: "+D),ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ob,kind:"answer"}),M.next=32;break;case 27:throw M.prev=27,M.t0=M.catch(0),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Ob,kind:"answer",error:M.t0}),this.log_.error("failed to accept remote answer "+M.t0),M.t0;case 32:case"end":return M.stop()}},T,this,[[0,27]])})),function(T){return n.apply(this,arguments)})},{key:"sendMutedFlag",value:function(T,y){if(y!==this.localAuxStream_){var D={audio:T.audio,bigVideo:T.video,auxVideo:T.auxVideo};this.log_.info("send muted state: ".concat(JSON.stringify(D))),this.signalChannel_.send(EU,D)}}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"reconnect",value:(t=H(f().mark(function T(){var y,D,A=this;return f().wrap(function(U){for(;;)switch(U.prev=U.next){case 0:if(this.reconnectionTimer_===-1){U.next=3;break}return this.log_.warn("reconnect() uplink is reconnecting, ignore current reconnection"),U.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){U.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(),y=new te({code:Z.UPLINK_RECONNECTION_FAILED,message:ie({key:PN})}),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Ab,error:y}),this.addEventInternal(mV,"uplink-connection reconnect fail"),this.emitConnectionStateChangedEvent(on),this.emitter_.emit(et.ERROR,y),U.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===oc){U.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(ac,this.reconnect,this),U.abrupt("return");case 16:if(this.reconnectionCount_++,U.prev=17,this.log_.warn("reconnect() try to reconnect uplink [".concat(this.reconnectionCount_,"/").concat(30,"]")),D=Ip(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){A.log_.warn("reconnect() uplink reconnect timeout(".concat(D/1e3,"s), try again")),A.clearReconnectionTimer(),A.reconnect()},D),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Ju)){U.next=23;break}return U.abrupt("return");case 23:return U.next=25,this.signalChannel_.sendWaitForResponse({command:gk,responseCommand:st.UNPUBLISH_RESULT,enableLog:!1});case 25:if(this.reset(),this.initialize(),!this.localStream_){U.next=30;break}return U.next=30,this.publish(this.localStream_);case 30:if(!this.localAuxStream_){U.next=33;break}return U.next=33,this.publish(this.localAuxStream_,!0);case 33:ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ab}),this.log_.warn("reconnect() uplink reconnect successfully"),this.addEventInternal(pV,"uplink-connection reconnect success"),this.stopReconnection(),this.localStream_.syncMuteState(),U.next=42;break;case 40:U.prev=40,U.t0=U.catch(17);case 42:case"end":return U.stop()}},T,this,[[17,40]])})),function(){return t.apply(this,arguments)})},{key:"clearExchangeSDPTimeout",value:function(){this.exchangeSDPTimeout_!==-1&&(clearTimeout(this.exchangeSDPTimeout_),this.exchangeSDPTimeout_=-1)}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"handleError",value:function(T){T.getCode()===Z.ICE_TRANSPORT_ERROR&&(this.isFirstConnection_&&(this.isFirstConnection_=!1,ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Rb,error:T})),this.isReconnecting_||this.startReconnection())}},{key:"handleConnectionStateChange",value:function(T){T.state===sn&&this.isFirstConnection_&&(this.isFirstConnection_=!1,ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Rb}),this.addEventInternal(cV,"uplink-connection is connected"))}},{key:"updateSSRC",value:function(T){var y=this;try{Fr(T).media.forEach(function(D,A){if(D.type===Re){var U=D.ssrcs[0];U&&(y.ssrc_.audio=U.id)}else{if(y.sdpSemantics_===Wf)return void D.ssrcGroups.forEach(function(p,_){var P=Number(p.ssrcs.split(" ")[0]);_===0?y.ssrc_.video=P:_===1&&(y.ssrc_.small=P)});var S=D.ssrcs[0];if(!S)return;switch(A){case 1:y.ssrc_.video=S.id;break;case 2:y.ssrc_.small=S.id;break;case 3:y.ssrc_.auxiliary=S.id}}})}catch(D){}}},{key:"getVideoTrackId",value:function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ie;if(this.peerConnection_){var y=this.peerConnection_.getSenders();if(T===Ie&&y[1]&&y[1].track)return y[1].track.id;if(T===Mr&&y[2]&&y[2].track)return y[2].track.id;if(T===gt&&y[3]&&y[3].track)return y[3].track.id}if(this.localStream_&&T===Ie){var D=this.localStream_.getVideoTrack();if(D)return D.id}if(this.localAuxStream_&&T===gt){var A=this.localAuxStream_.getVideoTrack();if(A)return A.id}return""}},{key:"getSSRC",value:function(){return this.ssrc_}},{key:"checkPublishResultCode",value:function(T,y){if(T!==0)throw T===1028?(this.log_.error(gi.NOT_SUPPORTED_H264ENCODE),new te({code:Z.NOT_SUPPORTED_H264,message:ie({key:gS})})):new te({code:Z.UNKNOWN,message:ie({key:yS,data:{signalResponse:st.PUBLISH_RESULT,code:T,message:y}})})}},{key:"getLocalStream",value:function(){return this.localStream_}},{key:"sendSEI",value:function(T,y){this.sei_.push(T,y)}},{key:"mixAudioTrack",value:function(T,y){this.log_.info("mix audio track"),this.mixedAudioTrack_=function(D){var A=FS(),U=A.createMediaStreamDestination(),S=[];D.forEach(function(_){var P=new MediaStream;P.addTrack(_);var M=A.createMediaStreamSource(P);M.connect(U),S.push(M)});var p=U.stream.getAudioTracks()[0];return $l.set(p,{destination:U,track:p,mediaStreamSourceList:S}),p}([T,y])}},{key:"destroyMixedAudioTrack",value:function(){this.mixedAudioTrack_&&(this.log_.info("destroy audio track"),function(T){if($l.has(T)){var y=$l.get(T),D=y.destination,A=y.track,U=y.mediaStreamSourceList;A.stop(),D.disconnect(),U.forEach(function(S){S.disconnect()}),$l.delete(T)}}(this.mixedAudioTrack_),this.mixedAudioTrack_=null)}}]),N}(Bv),K(Tc.prototype,"publish",[GI],Object.getOwnPropertyDescriptor(Tc.prototype,"publish"),Tc.prototype),Tc),LF=pe,JI=As,Zl=ws.exports.getWeakData,MF=si,NF=Tt,UF=Rt,Kv=at,VF=Rs,qI=kt,jF=Ke.set,BF=Ke.getterFor,FF=rn.find,HF=rn.findIndex,GF=LF([].splice),zF=0,ed=function(e){return e.frozen||(e.frozen=new KI)},KI=function(){this.entries=[]},Xv=function(e,t){return FF(e.entries,function(n){return n[0]===t})};KI.prototype={get:function(e){var t=Xv(this,e);if(t)return t[1]},has:function(e){return!!Xv(this,e)},set:function(e,t){var n=Xv(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=HF(this.entries,function(n){return n[0]===e});return~t&&GF(this.entries,t,1),!!~t}};var Ic,WF={getConstructor:function(e,t,n,i){var r=e(function(s,l){MF(s,o),jF(s,{type:t,id:zF++,frozen:void 0}),UF(l)||VF(l,s[i],{that:s,AS_ENTRIES:n})}),o=r.prototype,c=BF(t),a=function(s,l,u){var h=c(s),b=Zl(NF(l),!0);return b===!0?ed(h).set(l,u):b[h.id]=u,s};return JI(o,{delete:function(s){var l=c(this);if(!Kv(s))return!1;var u=Zl(s);return u===!0?ed(l).delete(s):u&&qI(u,l.id)&&delete u[l.id]},has:function(s){var l=c(this);if(!Kv(s))return!1;var u=Zl(s);return u===!0?ed(l).has(s):u&&qI(u,l.id)}}),JI(o,n?{get:function(s){var l=c(this);if(Kv(s)){var u=Zl(s);return u===!0?ed(l).get(s):u?u[l.id]:void 0}},set:function(s,l){return a(this,s,l)}}:{add:function(s){return a(this,s,!0)}}),r}},XI=re,td=pe,JF=As,qF=ws.exports,KF=fh,QI=WF,nd=at,rd=Qg,id=Ke.enforce,XF=O,QF=!XI.ActiveXObject&&"ActiveXObject"in XI,YI=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},YF=KF("WeakMap",YI,QI);if(XF&&QF){Ic=QI.getConstructor(YI,"WeakMap",!0),qF.enable();var xc=YF.prototype,$I=td(xc.delete),ad=td(xc.has),ZI=td(xc.get),ex=td(xc.set);JF(xc,{delete:function(e){if(nd(e)&&!rd(e)){var t=id(this);return t.frozen||(t.frozen=new Ic),$I(this,e)||t.frozen.delete(e)}return $I(this,e)},has:function(e){if(nd(e)&&!rd(e)){var t=id(this);return t.frozen||(t.frozen=new Ic),ad(this,e)||t.frozen.has(e)}return ad(this,e)},get:function(e){if(nd(e)&&!rd(e)){var t=id(this);return t.frozen||(t.frozen=new Ic),ad(this,e)?ZI(this,e):t.frozen.get(e)}return ZI(this,e)},set:function(e,t){if(nd(e)&&!rd(e)){var n=id(this);n.frozen||(n.frozen=new Ic),ad(this,e)?ex(this,e,t):n.frozen.set(e,t)}else ex(this,e,t);return this}})}var $F=Le,od=Ws,ZF=se,tx=An,nx=it,e7=Ou,rx=lb,t7=Qt,Qv=od&&od.prototype;if($F({target:"Promise",proto:!0,real:!0,forced:!!od&&ZF(function(){Qv.finally.call({then:function(){}},function(){})})},{finally:function(e){var t=e7(this,tx("Promise")),n=nx(e);return this.then(n?function(i){return rx(t,e()).then(function(){return i})}:e,n?function(i){return rx(t,e()).then(function(){throw i})}:e)}}),nx(od)){var ix=tx("Promise").prototype.finally;Qv.finally!==ix&&t7(Qv,"finally",ix,{unsafe:!0})}var ax,ox,sx,cx,ur,Mo=new WeakMap;function ux(){return function(e,t,n){var i=n.value,r=function o(c){var a=c.fn,s=c.args,l=c.context,u=c.resolve,h=c.reject;a.apply(l,s).then(u,h).finally(function(){var b=Mo.get(l);b&&(b.shift(),b[0]&&o(J({},b[0])))})};return n.value=function(){for(var o=this,c=arguments.length,a=new Array(c),s=0;s<c;s++)a[s]=arguments[s];return new Promise(function(l,u){if(Mo.has(o)){var h=Mo.get(o),b=h.length;h.push({fn:i,args:a,context:o,resolve:l,reject:u,name:t}),b===0&&r({fn:i,args:a,context:o,resolve:l,reject:u})}else Mo.set(o,[{fn:i,args:a,context:o,resolve:l,reject:u,name:t}]),r({fn:i,args:a,context:o,resolve:l,reject:u})})},n}}var n7=(ax=ux(),ox=Lo({retries:1,timeout:0,onRetrying:function(e){this.log_.warn("connection timeout, retrying [".concat(e,"]"))},onError:function(e,t,n){e.message.includes("timeout")?t():n(e)}}),sx=ux(),cx=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1e4;return function(t,n,i){var r=i.value;return i.value=function(){for(var o=this,c=arguments.length,a=new Array(c),s=0;s<c;s++)a[s]=arguments[s];return new Promise(function(l,u){var h=setTimeout(function(){return u(new Error("".concat(n," timeout")))},e);r.apply(o,a).then(l,u).finally(function(){clearTimeout(h)})})},i}}(),ur=function(e){Et(l,e);var t,n,i,r,o,c,a,s=Rr(l);function l(u){var h;return Q(this,l),(h=s.call(this,u)).remoteStreams_=new Map,h.autoSubscribe=u.autoSubscribe,h.trackState_={audio:u.trackState.audio,video:u.trackState.video,auxiliary:u.trackState.auxiliary,smallVideo:u.trackState.smallVideo},h.ssrc_={audio:0,video:0,auxiliary:0},h.subscribeState_={audio:u.autoSubscribe,video:u.autoSubscribe,auxiliary:u.autoSubscribe,smallVideo:!1},h.isSDPExchanging_=!1,h.installEvents(),h}return xe(l,[{key:"getMixUserList",value:function(){return this.mixUserList_?this.mixUserList_.map(function(u){var h=u.userId,b=u.flag;return{userId:h,hasAudio:!!(8&b),hasVideo:!!(1&b),hasAuxiliary:!!(4&b)}}):void 0}},{key:"setMixUserList",value:function(u){(!this.mixUserList_||ho(this.mixUserList_)&&!function(h,b){if(b.length===h.length){var I,R=ae(b);try{var x=function(){var k=I.value,v=h.find(function(w){return w.userId===k.userId});if(!v||v.flag!==k.flag)return{v:!1}};for(R.s();!(I=R.n()).done;){var m=x();if(G(m)==="object")return m.v}}catch(k){R.e(k)}finally{R.f()}return!0}return!1}(this.mixUserList_,u))&&(this.mixUserList_=u,this.emitter_.emit(et.STREAM_UPDATED,{stream:this.getMainStream()}))}},{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:"isSmallStreamSubscribed",get:function(){return this.subscribeState_.smallVideo&&this.trackState_.smallVideo}},{key:"isBigStreamSubscribed",get:function(){return this.subscribeState_.video&&this.trackState_.video}},{key:"isStreamUnpublished",value:function(u){return u.getType()===Xe?!this.trackState_.audio&&!this.trackState_.video:!this.trackState_.auxiliary}},{key:"initialize",value:function(){ue(Qe(l.prototype),"initialize",this).call(this),this.peerConnection_.ontrack=this.onTrack.bind(this)}},{key:"close",value:function(){var u,h,b,I=this;ue(Qe(l.prototype),"close",this).call(this),this.trackState_.audio=!1,this.trackState_.video=!1,this.trackState_.smallVideo=!1,this.trackState_.auxiliary=!1,this.emitConnectionStateChangedEvent(on),u=this,h=function(R){R.fn;var x=R.args,m=R.resolve,k=R.reject,v=R.name;if(v==="subscribe"){if(!I.client_.getIsJoined())return k(new te({code:Z.API_CALL_ABORTED,message:ie({key:ip,data:{message:"leave room",stream:x[0]}})}));if(I.isStreamUnpublished(x[0]))return k(new te({code:Z.API_CALL_ABORTED,message:ie({key:ip,data:{message:"remote user ".concat(I.userId_," unpublished stream"),stream:x[0]}})}))}else if(v==="unsubscribe")return m();m()},(b=Mo.get(u))===null||b===void 0||b.forEach(h),Mo.delete(u),this.remoteStreams_.forEach(function(R){var x=R;x.setConnection(null),x.uninstallEvents(),x.getIsStreamAddedEventEmitted()&&I.emitter_.emit(et.STREAM_REMOVED,{stream:x})}),this.remoteStreams_.clear(),this.uninstallEvents()}},{key:"installEvents",value:function(){var u=this;Y.on(jn,this.onRemoteStreamUpdate,this),this.emitter_.on(et.ERROR,function(h){h.getCode()===Z.ICE_TRANSPORT_ERROR&&(u.isFirstConnection_&&(u.isFirstConnection_=!1,ke.logFailedEvent({userId:u.client_.getUserId(),eventType:Pb,error:h})),u.isReconnecting_||u.startReconnection())}),this.emitter_.on(et.CONNECTION_STATE_CHANGED,function(h){h.state===sn&&u.isFirstConnection_&&(u.isFirstConnection_=!1,ke.logSuccessEvent({userId:u.client_.getUserId(),eventType:Pb}),u.addEventInternal(uV,"downlink-connection is connected"))})}},{key:"uninstallEvents",value:function(){Y.removeListener(jn,this.onRemoteStreamUpdate,this)}},{key:"onRemoteStreamUpdate",value:function(u){if(this.hitTest(u.tinyId)&&u.client===this.client_){this.updateTrackState(u.action,u.kind);var h=u.kind===gt?Xs:Ir,b=this.remoteStreams_.get(h);if(!b)return;u.action===cn.ADD?this.handleRemoteAddTrack(u.kind,b):this.handleRemoteRemoveTrack(u.kind,b)}}},{key:"handleRemoteAddTrack",value:function(u,h){this.log_.info("remote add ".concat(u," track")),u===Re?h.updateAudioPlayingState(this.subscribeState_.audio):h.updateVideoPlayingState(u===gt?this.subscribeState_.auxiliary:this.subscribeState_.video||this.subscribeState_.smallVideo),h.getIsStreamAddedEventEmitted()?this.emitter_.emit(et.STREAM_UPDATED,{stream:h}):(this.emitter_.emit(et.STREAM_ADDED,{stream:h}),this.currentState_===sn&&h.emitConnectionStateChanged({prevState:on,state:sn}))}},{key:"handleRemoteRemoveTrack",value:function(u,h){h.getIsStreamAddedEventEmitted()&&(this.log_.info("remote remove ".concat(u," track")),u===gt||!this.trackState_.audio&&!this.trackState_.video?(this.log_.info("remote stream ".concat(h.getType()," removed")),this.currentState_===sn&&h.emitConnectionStateChanged({prevState:sn,state:on}),this.emitter_.emit(et.STREAM_REMOVED,{stream:h})):(u===Re?h.updateAudioPlayingState(!1):(u!==Fu||this.isSmallStreamSubscribed)&&h.updateVideoPlayingState(!1),this.emitter_.emit(et.STREAM_UPDATED,{stream:h})))}},{key:"updateTrackState",value:function(u,h){var b=u===cn.ADD;switch(h){case Re:this.trackState_.audio=b;break;case Ie:this.trackState_.video=b;break;case gt:this.trackState_.auxiliary=b;break;case Fu:this.trackState_.smallVideo=b}this.log_.info("trackState updated: ".concat(JSON.stringify(this.trackState_)))}},{key:"onTrack",value:function(u){var h=u.streams[0],b=u.track;if(this.log_.info("ontrack() kind: ".concat(b.kind," id: ").concat(b.id," streamId: ").concat(h.id)),this.sdpSemantics_===Ys){var I=function(v){var w=rr.parse(v),L={audio:[],video:[]};return w.media.forEach(function(E){if(E.ssrcs){var N=E.ssrcs[0].id>>16&255;if(E.type===Re)L.audio.push(Ir);else if(E.type==Ie){var T=N===QM?Ir:Xs;L.video.push(T)}}}),L}(this.peerConnection_.remoteDescription.sdp);if(b.kind===Re){if(I.audio.length===0||h.id!==Ir)return void this.log_.debug("skip this invalid audio track")}else if(I.video.indexOf(h.id)===-1)return void this.log_.debug("skip this invalid video track: ".concat(b.id," msid: ").concat(h.id))}ke.logEvent({eventType:"ontrack",kind:b.kind});var R=!1,x=this.remoteStreams_.get(h.id),m=h.id===Ir?yt:Dt;if(ge(x)&&((x=new Gv({type:m,userId:this.userId_,client:this.client_})).setConnection(this),this.remoteStreams_.set(h.id,x),R=!0),x.setMediaStream(h),b.kind===Re?x.updateAudioPlayingState(this.subscribeState_.audio):m===yt?x.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo):x.updateVideoPlayingState(this.subscribeState_.auxiliary),(m!==Dt||this.trackState_.auxiliary)&&(m!==yt||this.trackState_.audio||this.trackState_.video)){var k=this.client_.getSubscriptionManager();k&&k.hasAutoRecoveryFlag(this.userId_,m)||(R?this.emitter_.emit(et.STREAM_ADDED,{stream:x}):this.emitter_.emit(et.STREAM_UPDATED,{stream:x}))}}},{key:"addRRTRLine",value:function(u){var h=u.split(`\r
69
+ `),b=new Map;h.forEach(function(v,w){/^a=rtcp-fb:/.test(v)&&h[w+1]&&!/^a=rtcp-fb:/.test(h[w+1])&&v.match(/^a=rtcp-fb:\d+/)&&b.set(w+1,v.match(/^a=rtcp-fb:\d+/)[0]+" rrtr")});for(var I=Se(b),R=0;R<I.length;R++){var x=Te(I[R],2),m=x[0],k=x[1];h.splice(m+R,0,k)}return h.join(`\r
70
+ `)}},{key:"addSPSDescription",value:function(u){var h=Fr(u);return h.media.forEach(function(b){b.type===Ie&&b.fmtp.forEach(function(I){I.config+=";sps-pps-idr-in-keyframe=1"})}),yo(h)}},{key:"removeSDESDescription",value:function(u){var h=["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"],b=Fr(u);return b.media.forEach(function(I){I.ext=I.ext.filter(function(R){return!h.includes(R.uri)})}),yo(b)}},{key:"isSubscriptionStateNotChanged",value:function(u,h){return u.getType()===yt?(h==null?void 0:h.audio)===this.subscribeState_.audio&&(h==null?void 0:h.video)===this.subscribeState_.video&&this.isSubscribeSmall(h):u.getType()===Dt?!ge(h.video)&&this.subscribeState_.auxiliary===h.video:void 0}},{key:"isSubscribeSmall",value:function(u){return ge(u.smallVideo)&&!this.subscribeState_.smallVideo}},{key:"subscribe",value:(a=H(f().mark(function u(h,b){var I,R,x,m,k,v;return f().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(w.prev=0,x=b.emitEvent,m=x===void 0||x,k=h.getType(),((I=this.peerConnection_)===null||I===void 0?void 0:I.connectionState)!==YM&&((R=this.peerConnection_)===null||R===void 0?void 0:R.connectionState)!==Ju){w.next=6;break}return w.next=6,this.waitForPeerConnectionConnected();case 6:if(!this.isSubscriptionStateNotChanged(h,b)){w.next=13;break}if(this.peerConnection_){w.next=11;break}return this.initialize(),w.next=11,this.connect();case 11:return m&&ge(b.smallVideo)&&this.emitter_.emit(et.STREAM_SUBSCRIBED,{stream:h,result:!0}),w.abrupt("return",h);case 13:if(k===Xe?(ge(b.audio)||(this.subscribeState_.audio=b.audio),ge(b.video)||(this.subscribeState_.video=b.video),this.subscribeState_.smallVideo=(b==null?void 0:b.smallVideo)||!1,this.addEventInternal(this.subscribeState_.audio?kk:om,this.subscribeState_.audio?"subscribe audio":"unsubscribe audio"),this.addEventInternal(this.subscribeState_.video?kk:om,this.subscribeState_.video?"subscribe video":"unsubscribe video"),this.addEventInternal(this.subscribeState_.smallVideo?yV:bV,this.subscribeState_.smallVideo?"subscribe smallVideo":"unsubscribe smallVideo")):ge(b.video)||(this.subscribeState_.auxiliary=b.video),this.log_.info("subscribe ".concat(k," stream with options ").concat(JSON.stringify(b)," current state: ").concat(JSON.stringify(this.subscribeState_))),!this.peerConnection_&&!this.isSDPExchanging_){w.next=23;break}return v=zf,this.isMainStreamSubscribed||this.isAuxStreamSubscribed||(v=Gf),w.next=20,this.sendSubscription(v);case 20:k===Xe?(h.updateAudioPlayingState(this.subscribeState_.audio),h.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo)):h.updateVideoPlayingState(this.subscribeState_.auxiliary),w.next=26;break;case 23:return this.initialize(),w.next=26,this.connect();case 26:return m&&this.emitter_.emit(et.STREAM_SUBSCRIBED,{stream:h,result:!0}),w.abrupt("return",h);case 30:if(w.prev=30,w.t0=w.catch(0),!this.client_.getIsJoined()||!this.isStreamUnpublished(h)){w.next=35;break}throw this.log_.warn("".concat(w.t0.message," ").concat(JSON.stringify(this.trackState_))),new te({code:Z.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId_," unpublished stream")});case 35:throw w.t0;case 36:case"end":return w.stop()}},u,this,[[0,30]])})),function(u,h){return a.apply(this,arguments)})},{key:"checkTrackEnded",value:function(){try{var u=this.peerConnection_.getReceivers().map(function(h){return h.track}).find(function(h){return h.readyState==="ended"});u&&this.currentState_===sn&&!this.isReconnecting_&&(this.log_.warn("".concat(u.kind," track ended, start reconnect")),this.startReconnection())}catch(h){}}},{key:"unsubscribe",value:(c=H(f().mark(function u(h){var b,I,R;return f().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if((b=h.getType())!==Xe){x.next=10;break}if(this.isMainStreamSubscribed){x.next=5;break}return this.log_.info("main stream already unsubscribed"),x.abrupt("return",h);case 5:this.subscribeState_.audio=!1,this.subscribeState_.video=!1,this.subscribeState_.smallVideo=!1,x.next=14;break;case 10:if(this.isAuxStreamSubscribed){x.next=13;break}return this.log_.info("auxiliary stream already unsubscribed"),x.abrupt("return",h);case 13:this.subscribeState_.auxiliary=!1;case 14:return I=Gf,(b===yt&&this.isAuxStreamSubscribed||b===Dt&&this.isMainStreamSubscribed)&&(I=zf),this.log_.info("unsubscribe ".concat(b," stream with ").concat(JSON.stringify(this.subscribeState_))),x.next=19,this.sendSubscription(I);case 19:return h.updateVideoPlayingState(!1),h.updateAudioPlayingState(!1),I===Gf&&((R=h.getMediaStream())&&R.getTracks().forEach(function(m){return R.removeTrack(m)}),this.closePeerConnection(),this.emitConnectionStateChangedEvent(on)),this.addEventInternal(om,"unsubscribe audio"),this.addEventInternal(XU,"unsubscribe video"),x.abrupt("return",h);case 25:case"end":return x.stop()}},u,this)})),function(u){return c.apply(this,arguments)})},{key:"sendSubscription",value:function(u){var h=this,b={srcTinyId:this.tinyId_,srcUserId:this.userId_},I=PU,R=st.UNSUBSCRIBE_RESULT;return u===zf&&(b={audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo,srcTinyId:this.tinyId_},I=DU,R=st.SUBSCRIBE_CHANGE_RESULT),this.signalChannel_.sendWaitForResponse({command:I,data:b,responseCommand:R,timeout:1e4}).then(function(x){var m=x.data;if(m.code!==0){var k=new te({code:m.code,message:ie({key:CN,data:{type:u,message:m.message}})});throw h.log_.error(k),k}})}},{key:"connect",value:(o=H(f().mark(function u(){return f().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.prev=0,h.next=3,this.exchangeSDP();case 3:return h.next=5,this.waitForPeerConnectionConnected();case 5:h.next=11;break;case 7:throw h.prev=7,h.t0=h.catch(0),this.closePeerConnection(!0),h.t0;case 11:case"end":return h.stop()}},u,this,[[0,7]])})),function(){return o.apply(this,arguments)})},{key:"exchangeSDP",value:(r=H(f().mark(function u(){var h,b,I,R,x,m;return f().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.prev=0,this.isSDPExchanging_=!0,k.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),h=this.peerConnection_.localDescription,b=h.type,I=h.sdp,R={type:b,sdp:I,srcUserId:this.userId_,srcTinyId:this.tinyId_,audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo},Y.emit(Qp,{client:this.client_,connection:this,userId:this.userId_,tinyId:this.tinyId_,role:so,subscribeState:this.subscribeState_,trackState:this.trackState_}),k.next=10,this.signalChannel_.sendWaitForResponse({command:AU,commandDesc:"exchange sdp",data:R,responseCommand:st.SUBSCRIBE_RESULT,timeout:1e4});case 10:if(x=k.sent,this.peerConnection_){k.next=15;break}throw m=new te({code:Z.INVALID_OPERATION,message:ie({key:X3})}),this.log_.warn(m),m;case 15:return k.next=17,this.onSubscribeResult(x);case 17:this.isSDPExchanging_=!1,k.next=24;break;case 20:throw k.prev=20,k.t0=k.catch(0),this.isSDPExchanging_=!1,k.t0;case 24:case"end":return k.stop()}},u,this,[[0,20]])})),function(){return r.apply(this,arguments)})},{key:"createOffer",value:(i=H(f().mark(function u(){var h,b;return f().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:return h={voiceActivityDetection:!1},vl()&&this.sdpSemantics_===Ys?(this.peerConnection_.addTransceiver(Re,{direction:"recvonly"}),this.peerConnection_.addTransceiver(Ie,{direction:"recvonly"}),this.peerConnection_.addTransceiver(Ie,{direction:"recvonly"})):(h.offerToReceiveAudio=!0,h.offerToReceiveVideo=!0),I.next=4,this.peerConnection_.createOffer(h);case 4:return b=I.sent,I.next=7,Vk();case 7:return I.sent.isH264DecodeSupported||(this.log_.warn("remove h264 desc from sdp"),b.sdp=(R=b.sdp,x=void 0,(x=Fr(R)).media.forEach(function(m){if(m.type===Ie){var k=new Set;m.rtp.forEach(function(w){var L=w.payload;return w.codec==="H264"&&k.add(L)}),m.fmtp.forEach(function(w){var L=w.payload,E=w.config.match(/apt=(\d+)/);E&&E[1]&&k.has(Number(E[1]))&&k.add(L)});var v=function(w){var L=w.payload;return!k.has(L)};m.rtp=m.rtp.filter(v),m.rtcpFb=m.rtcpFb.filter(v),m.fmtp=m.fmtp.filter(v),m.payloads=m.payloads.split(" ").filter(function(w){return!k.has(Number(w))}).join(" ")}}),yo(x))),b.sdp=this.addRRTRLine(b.sdp),b.sdp=this.addSPSDescription(b.sdp),b.sdp=WV(b.sdp),this.sdpSemantics_===Ys&&(b.sdp=this.removeSDESDescription(b.sdp)),I.next=16,this.peerConnection_.setLocalDescription(b);case 16:case"end":return I.stop()}var R,x},u,this)})),function(){return i.apply(this,arguments)})},{key:"onSubscribeResult",value:(n=H(f().mark(function u(h){var b,I,R,x,m,k,v,w=this;return f().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(b=h&&h.data||{},I=b.code,R=b.message,x=R===void 0?"":R,m=h&&h.data&&h.data.data||{},k=m.type,v=m.sdp,I!==77393){L.next=5;break}throw this.log_.error(gi.NOT_SUPPORTED_H264DECODE),new te({code:Z.NOT_SUPPORTED_H264,message:ie({key:_S})});case 5:if(L.prev=5,I===0){L.next=8;break}throw new te({code:I,message:ie({key:AN,data:{errMsg:x}})});case 8:return this.log_.debug("accept remote answer: "+v),L.next=11,this.peerConnection_.setRemoteDescription({type:k,sdp:v});case 11:this.sei_&&(this.sei_.handleEncodedStreams(),this.sei_.onSEIMessage=function(E){w.emitter_.emit(et.SEI_MESSAGE,J(J({},E),{},{userId:w.userId_}))}),this.updateSSRC(v),L.next=19;break;case 15:throw L.prev=15,L.t0=L.catch(5),this.log_.error(L.t0),L.t0;case 19:case"end":return L.stop()}},u,this,[[5,15]])})),function(u){return n.apply(this,arguments)})},{key:"updateSSRC",value:function(u){var h=this;try{Fr(u).media.forEach(function(b){if(b.type===Re){var I=b.ssrcs.find(function(m){return m.value.includes(Ir)});I&&(h.ssrc_.audio=I.id)}else{var R=b.ssrcs.find(function(m){return m.value.includes(Ir)}),x=b.ssrcs.find(function(m){return m.value.includes(Xs)});R&&(h.ssrc_.video=R.id),x&&(h.ssrc_.auxiliary=x.id)}})}catch(b){}}},{key:"setRemoteStream",value:function(u,h){this.remoteStreams_.set(u,h)}},{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(Ir)}},{key:"getAuxStream",value:function(){return this.remoteStreams_.get(Xs)}},{key:"getMainStreamVideoTrackId",value:function(){var u=this.getMainStream();if(u){var h=u.getVideoTrack();if(h)return h.id}return""}},{key:"getAuxStreamVideoTrackId",value:function(){var u=this.getAuxStream();if(u){var h=u.getVideoTrack();if(h)return h.id}return""}},{key:"reconnect",value:(t=H(f().mark(function u(){var h,b,I=this;return f().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:if(this.reconnectionTimer_===-1){R.next=3;break}return this.log_.warn("reconnect() downlink is reconnecting, ignore current reconnection"),R.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){R.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(),h=new te({code:Z.DOWNLINK_RECONNECTION_FAILED,message:ie({key:RN})}),ke.logFailedEvent({userId:this.client_.getUserId(),eventType:Db,error:h}),this.addEventInternal(_V,"downlink-connection reconnect fail"),this.emitConnectionStateChangedEvent(on),this.emitter_.emit(et.ERROR,h),R.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===oc){R.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(ac,this.reconnect,this),R.abrupt("return");case 16:if(this.reconnectionCount_++,this.log_.warn("reconnect() try to reconnect downlink [".concat(this.reconnectionCount_,"/").concat(30,"]")),b=Ip(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){I.log_.warn("reconnect() downlink [".concat(I.userId_,"] reconnect timeout(").concat(b/1e3,"s), try again")),I.clearReconnectionTimer(),I.reconnect()},b),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Ju)){R.next=22;break}return R.abrupt("return");case 22:return R.prev=22,this.closePeerConnection(),this.initialize(),R.next=27,this.connect();case 27:this.stopReconnection(),this.log_.warn("reconnect() downlink reconnect successfully"),ke.logSuccessEvent({userId:this.client_.getUserId(),eventType:Db}),this.addEventInternal(gV,"downlink-connection reconnect success"),this.recoverSubscription(),R.next=36;break;case 34:R.prev=34,R.t0=R.catch(22);case 36:case"end":return R.stop()}},u,this,[[22,34]])})),function(){return t.apply(this,arguments)})},{key:"recoverSubscription",value:function(){var u=this,h=this.client_.getSubscriptionManager();h&&Se(this.remoteStreams_.values()).forEach(function(b){h.hasAutoRecoveryFlag(u.userId_,b.getType())&&h.recover(b)})}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"getSubscribedMainStream",value:function(){var u=null;return this.isMainStreamSubscribed&&(u=this.remoteStreams_.get(Ir)),u}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"startReconnection",value:function(){var u=this.client_.getSubscriptionManager();if(u){var h,b=ae(this.remoteStreams_.values());try{for(b.s();!(h=b.n()).done;){var I=h.value,R=I.getType();(R===yt&&(this.trackState_.audio||this.trackState_.video)||R===Dt&&this.trackState_.auxiliary)&&u.setAutoRecoveryFlag(this.userId_,I.getType())}}catch(x){b.e(x)}finally{b.f()}}ue(Qe(l.prototype),"startReconnection",this).call(this)}},{key:"getCurrentState",value:function(){return this.currentState_}},{key:"hasMainStream",value:function(){return this.trackState_.video||this.trackState_.audio||this.trackState_.smallVideo}},{key:"hasAuxStream",value:function(){return this.trackState_.auxiliary}}]),l}(Bv),K(ur.prototype,"subscribe",[ax,ox],Object.getOwnPropertyDescriptor(ur.prototype,"subscribe"),ur.prototype),K(ur.prototype,"unsubscribe",[sx],Object.getOwnPropertyDescriptor(ur.prototype,"unsubscribe"),ur.prototype),K(ur.prototype,"exchangeSDP",[cx],Object.getOwnPropertyDescriptor(ur.prototype,"exchangeSDP"),ur.prototype),ur),sd=function(){function e(){Q(this,e),this.startTime=0,this.endTime=0,this.start()}return xe(e,[{key:"start",value:function(){this.startTime===0&&(this.startTime=Ct())}},{key:"stop",value:function(){this.endTime===0&&(this.endTime=Ct())}},{key:"getDuration",value:function(){return this.endTime===0?Ct()-this.startTime:this.endTime-this.startTime}}]),e}(),r7=function(){function e(r){Q(this,e),this.client_=r.client,this.intervalId_=-1,this.statsCalculator_=r.stats,this.prevStats_=null,this.renderFreezeMap_=new Map,this.remoteStreamMap_=new Map,this.dataFreezeMap_=new Map,this.monitorFreezeData_=new Map}var t,n,i;return xe(e,[{key:"installEvents",value:function(){Y.on(Jp,this.handlePlayVideoStart,this),Y.on(nc,this.onVideoTrackMuted,this),Y.on(Gp,this.onVideoTrackUnmuted,this),Y.on(ca,this.handleStreamStopped,this),Y.on(Vr,this.handleStreamStopped,this),Y.on(tc,this.handleVideoPlaying,this)}},{key:"uninstallEvents",value:function(){Y.off(Jp,this.handlePlayVideoStart,this),Y.off(nc,this.onVideoTrackMuted,this),Y.off(Gp,this.onVideoTrackUnmuted,this),Y.off(ca,this.handleStreamStopped,this),Y.off(Vr,this.handleStreamStopped,this),Y.off(tc,this.handleVideoPlaying,this)}},{key:"start",value:function(){var r=this;this.intervalId_===-1&&(this.installEvents(),this.intervalId_=mt.run(H(f().mark(function o(){return f().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,c.next=3,r.detectFPS();case 3:c.next=7;break;case 5:c.prev=5,c.t0=c.catch(0);case 7:case"end":return c.stop()}},o,null,[[0,5]])})),{delay:1e3}))}},{key:"stop",value:function(){this.intervalId_!==-1&&(this.uninstallEvents(),mt.clearTask(this.intervalId_),this.intervalId_=-1,this.renderFreezeMap_.clear(),this.dataFreezeMap_.clear(),this.remoteStreamMap_.clear())}},{key:"onVideoTrackMuted",value:function(r){var o=r.stream;if(o.getClient()===this.client_&&o.isRemote()){var c=o.userId_,a=o.type_,s="".concat(c,"_").concat(a),l=this.dataFreezeMap_.get(s),u=new sd;l?l.durationItemList.push(u):this.dataFreezeMap_.set(s,{userId:c,type:a,durationItemList:[u],isFreezing:function(){var h=this.durationItemList[this.durationItemList.length-1];return h&&h.endTime===0}})}}},{key:"onVideoTrackUnmuted",value:function(r){var o=r.stream;if(o.getClient()===this.client_&&o.isRemote()){var c=o.userId_,a=o.type_,s="".concat(c,"_").concat(a);this.stopDataFreeze({key:s,userId:c,type:a})}}},{key:"handleStreamStopped",value:function(r){var o=r.client,c=r.stream;if(o===this.client_){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s);this.stopDataFreeze({key:l,userId:a,type:s})}}},{key:"stopDataFreeze",value:function(r){var o=r.key,c=r.userId,a=r.type,s=this.dataFreezeMap_.get(o);if(s&&s.isFreezing()){var l=s.durationItemList[s.durationItemList.length-1];l.stop();var u=l.getDuration();u>500?(ke.logEvent({eventType:"videoFrozenCount",delta:u}),this.monitorFreezeData_.set(o,{userId:c,type:a,duration:u})):s.durationItemList.pop()}}},{key:"getTotalDuration",value:function(r){return r.reduce(function(o,c){var a=c.getDuration();return o+Math.min(a,5e3)},0)}},{key:"getStats",value:(i=H(f().mark(function r(){var o,c,a,s,l,u,h,b,I,R,x;return f().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:o=this.client_.getConnections(),c={},a=ae(o),m.prev=3,a.s();case 5:if((s=a.n()).done){m.next=20;break}if(l=Te(s.value,2),u=l[0],(h=l[1]).getPeerConnection()){m.next=9;break}return m.abrupt("continue",18);case 9:return b=h.getSubscribeState(),I=h.getTrackState(),m.next=13,this.statsCalculator_.getReceiverStats(h);case 13:R=m.sent,(x={userId:R.userId,tinyId:u,hasVideo:I.video&&b.video,hasAuxiliary:I.auxiliary&&b.auxiliary,video:{framesDecoded:0},auxiliary:{framesDecoded:0}}).hasVideo&&(x.video.framesDecoded=R.video.framesDecoded),x.hasAuxiliary&&(x.auxiliary.framesDecoded=R.auxiliary.framesDecoded),c[R.userId]=x;case 18:m.next=5;break;case 20:m.next=25;break;case 22:m.prev=22,m.t0=m.catch(3),a.e(m.t0);case 25:return m.prev=25,a.f(),m.finish(25);case 28:return m.abrupt("return",c);case 29:case"end":return m.stop()}},r,this,[[3,22,25,28]])})),function(){return i.apply(this,arguments)})},{key:"detectFPS",value:(n=H(f().mark(function r(){var o,c,a,s,l,u;return f().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,this.getStats();case 2:if(o=h.sent,this.prevStats_){h.next=6;break}return this.prevStats_=o,h.abrupt("return");case 6:h.t0=f().keys(o);case 7:if((h.t1=h.t0()).done){h.next=17;break}if(c=h.t1.value,this.prevStats_[c]){h.next=11;break}return h.abrupt("continue",7);case 11:a=o[c].tinyId,s=this.client_.getMutedStates(),o[c].hasVideo&&this.prevStats_[c].hasVideo&&s.has(a)&&!s.get(a).videoMuted&&(l=o[c].video.framesDecoded-this.prevStats_[c].video.framesDecoded,this.handleRenderFreeze({userId:c,type:yt,fps:l})),o[c].hasAuxiliary&&this.prevStats_[c].hasAuxiliary&&(u=o[c].auxiliary.framesDecoded-this.prevStats_[c].auxiliary.framesDecoded,this.handleRenderFreeze({userId:c,type:Dt,fps:u})),h.next=7;break;case 17:this.prevStats_=o;case 18:case"end":return h.stop()}},r,this)})),function(){return n.apply(this,arguments)})},{key:"handleRenderFreeze",value:(t=H(f().mark(function r(o){var c,a,s,l,u,h,b,I;return f().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:c=o.userId,a=o.fps,s=o.type,l="".concat(c,"_").concat(s),u=this.renderFreezeMap_.get(l),a<=2?(h=Ct(),u&&!u.isFreeze&&(u.freezeTimeline.push({startTime:h,endTime:void 0}),u.isFreeze=!0),u||this.renderFreezeMap_.set(l,{userId:c,type:s,isFreeze:!0,freezeTimeline:[{startTime:h,endTime:void 0}],renderFreezeTotal:0})):u&&u.isFreeze&&(u.isFreeze=!1,(b=u.freezeTimeline.pop()).endTime=Ct(),I=b.endTime-b.startTime,u.freezeTimeline.push(b),u.renderFreezeTotal+=Math.min(5e3,I));case 4:case"end":return R.stop()}},r,this)})),function(r){return t.apply(this,arguments)})},{key:"handlePlayVideoStart",value:function(r){var o=r.stream;if(o.getClient()===this.client_&&o.isRemote()&&o.hasVideo()){var c="".concat(o.getUserId(),"_").concat(o.getType());this.remoteStreamMap_.has(c)||this.remoteStreamMap_.set(c,{isPlayingFired:!1})}}},{key:"handleVideoPlaying",value:function(r){var o=r.stream;if(o.isRemote()&&o.getClient()===this.client_){var c="".concat(o.getUserId(),"_").concat(o.getType());this.remoteStreamMap_.has(c)&&(this.remoteStreamMap_.get(c).isPlayingFired=!0)}}},{key:"getDataFreezeDuration",value:function(r){var o={dataFreeze:0,count:0},c=this.dataFreezeMap_.get(r);if(c){if(c.isFreezing()){var a=c.durationItemList[c.durationItemList.length-1];a.stop(),a.getDuration()<500&&c.durationItemList.pop()}o.dataFreeze=this.getTotalDuration(c.durationItemList),o.count=c.durationItemList.length}return o}},{key:"getRenderFreezeDuration",value:function(r){var o=this.renderFreezeMap_.get(r),c=0,a=0;if(o)if(o.isFreeze){var s=Ct()-o.freezeTimeline[o.freezeTimeline.length-1].startTime;c=o.renderFreezeTotal+Math.min(s,5e3),a=o.freezeTimeline.length}else c=o.renderFreezeTotal;return{renderFreeze:c,count:a}}},{key:"getMonitorFreeze",value:function(){return this.monitorFreezeData_}},{key:"isBlackStream",value:function(r){return!!this.remoteStreamMap_.has(r)&&!this.remoteStreamMap_.get(r).isPlayingFired}},{key:"resetMonitor",value:function(){this.monitorFreezeData_.clear()}}]),e}(),Yv=xe(function e(t){Q(this,e),this.userId=t.userId,this.tinyId=t.tinyId,this.role=t.role===so?Tr:Zi}),lx={exports:{}};(function(e){(function(t){function n(m,k){var v=(65535&m)+(65535&k);return(m>>16)+(k>>16)+(v>>16)<<16|65535&v}function i(m,k,v,w,L,E){return n((N=n(n(k,m),n(w,E)))<<(T=L)|N>>>32-T,v);var N,T}function r(m,k,v,w,L,E,N){return i(k&v|~k&w,m,k,L,E,N)}function o(m,k,v,w,L,E,N){return i(k&w|v&~w,m,k,L,E,N)}function c(m,k,v,w,L,E,N){return i(k^v^w,m,k,L,E,N)}function a(m,k,v,w,L,E,N){return i(v^(k|~w),m,k,L,E,N)}function s(m,k){var v,w,L,E,N;m[k>>5]|=128<<k%32,m[14+(k+64>>>9<<4)]=k;var T=1732584193,y=-271733879,D=-1732584194,A=271733878;for(v=0;v<m.length;v+=16)w=T,L=y,E=D,N=A,T=r(T,y,D,A,m[v],7,-680876936),A=r(A,T,y,D,m[v+1],12,-389564586),D=r(D,A,T,y,m[v+2],17,606105819),y=r(y,D,A,T,m[v+3],22,-1044525330),T=r(T,y,D,A,m[v+4],7,-176418897),A=r(A,T,y,D,m[v+5],12,1200080426),D=r(D,A,T,y,m[v+6],17,-1473231341),y=r(y,D,A,T,m[v+7],22,-45705983),T=r(T,y,D,A,m[v+8],7,1770035416),A=r(A,T,y,D,m[v+9],12,-1958414417),D=r(D,A,T,y,m[v+10],17,-42063),y=r(y,D,A,T,m[v+11],22,-1990404162),T=r(T,y,D,A,m[v+12],7,1804603682),A=r(A,T,y,D,m[v+13],12,-40341101),D=r(D,A,T,y,m[v+14],17,-1502002290),T=o(T,y=r(y,D,A,T,m[v+15],22,1236535329),D,A,m[v+1],5,-165796510),A=o(A,T,y,D,m[v+6],9,-1069501632),D=o(D,A,T,y,m[v+11],14,643717713),y=o(y,D,A,T,m[v],20,-373897302),T=o(T,y,D,A,m[v+5],5,-701558691),A=o(A,T,y,D,m[v+10],9,38016083),D=o(D,A,T,y,m[v+15],14,-660478335),y=o(y,D,A,T,m[v+4],20,-405537848),T=o(T,y,D,A,m[v+9],5,568446438),A=o(A,T,y,D,m[v+14],9,-1019803690),D=o(D,A,T,y,m[v+3],14,-187363961),y=o(y,D,A,T,m[v+8],20,1163531501),T=o(T,y,D,A,m[v+13],5,-1444681467),A=o(A,T,y,D,m[v+2],9,-51403784),D=o(D,A,T,y,m[v+7],14,1735328473),T=c(T,y=o(y,D,A,T,m[v+12],20,-1926607734),D,A,m[v+5],4,-378558),A=c(A,T,y,D,m[v+8],11,-2022574463),D=c(D,A,T,y,m[v+11],16,1839030562),y=c(y,D,A,T,m[v+14],23,-35309556),T=c(T,y,D,A,m[v+1],4,-1530992060),A=c(A,T,y,D,m[v+4],11,1272893353),D=c(D,A,T,y,m[v+7],16,-155497632),y=c(y,D,A,T,m[v+10],23,-1094730640),T=c(T,y,D,A,m[v+13],4,681279174),A=c(A,T,y,D,m[v],11,-358537222),D=c(D,A,T,y,m[v+3],16,-722521979),y=c(y,D,A,T,m[v+6],23,76029189),T=c(T,y,D,A,m[v+9],4,-640364487),A=c(A,T,y,D,m[v+12],11,-421815835),D=c(D,A,T,y,m[v+15],16,530742520),T=a(T,y=c(y,D,A,T,m[v+2],23,-995338651),D,A,m[v],6,-198630844),A=a(A,T,y,D,m[v+7],10,1126891415),D=a(D,A,T,y,m[v+14],15,-1416354905),y=a(y,D,A,T,m[v+5],21,-57434055),T=a(T,y,D,A,m[v+12],6,1700485571),A=a(A,T,y,D,m[v+3],10,-1894986606),D=a(D,A,T,y,m[v+10],15,-1051523),y=a(y,D,A,T,m[v+1],21,-2054922799),T=a(T,y,D,A,m[v+8],6,1873313359),A=a(A,T,y,D,m[v+15],10,-30611744),D=a(D,A,T,y,m[v+6],15,-1560198380),y=a(y,D,A,T,m[v+13],21,1309151649),T=a(T,y,D,A,m[v+4],6,-145523070),A=a(A,T,y,D,m[v+11],10,-1120210379),D=a(D,A,T,y,m[v+2],15,718787259),y=a(y,D,A,T,m[v+9],21,-343485551),T=n(T,w),y=n(y,L),D=n(D,E),A=n(A,N);return[T,y,D,A]}function l(m){var k,v="",w=32*m.length;for(k=0;k<w;k+=8)v+=String.fromCharCode(m[k>>5]>>>k%32&255);return v}function u(m){var k,v=[];for(v[(m.length>>2)-1]=void 0,k=0;k<v.length;k+=1)v[k]=0;var w=8*m.length;for(k=0;k<w;k+=8)v[k>>5]|=(255&m.charCodeAt(k/8))<<k%32;return v}function h(m){var k,v,w="0123456789abcdef",L="";for(v=0;v<m.length;v+=1)k=m.charCodeAt(v),L+=w.charAt(k>>>4&15)+w.charAt(15&k);return L}function b(m){return unescape(encodeURIComponent(m))}function I(m){return function(k){return l(s(u(k),8*k.length))}(b(m))}function R(m,k){return function(v,w){var L,E,N=u(v),T=[],y=[];for(T[15]=y[15]=void 0,N.length>16&&(N=s(N,8*v.length)),L=0;L<16;L+=1)T[L]=909522486^N[L],y[L]=1549556828^N[L];return E=s(T.concat(u(w)),512+8*w.length),l(s(y.concat(E),640))}(b(m),b(k))}function x(m,k,v){return k?v?R(k,m):h(R(k,m)):v?I(m):h(I(m))}e.exports?e.exports=x:t.md5=x})(oe)})(lx);var dx,hx,Pi,cd=lx.exports,i7=function(){function e(o){Q(this,e),this.client_=o.client,this.signalChannel_=o.signalChannel,this.log_=_e.createLogger({id:"mix|"+this.client_.getUserId(),userId:o.client.getUserId(),sdkAppId:o.client.getSDKAppId()}),this.isMixing_=!1,this.config_=null,this.data_=null,this.remoteStreamMap_=new Map,this.installEvents()}var t,n,i,r;return xe(e,[{key:"isPresetLayoutMode",get:function(){return this.config_&&this.config_.mode===Jf.PRESET_LAYOUT}},{key:"installEvents",value:function(){Y.on(Ur,this.onStreamSubscribed,this),Y.on(Vr,this.onStreamUnsubscribed,this),this.client_.on("stream-removed",this.onStreamRemoved,this)}},{key:"uninstallEvents",value:function(){Y.off(Ur,this.onStreamSubscribed,this),Y.off(Vr,this.onStreamUnsubscribed,this),this.client_.off("stream-removed",this.onStreamRemoved,this)}},{key:"reset",value:function(){this.uninstallEvents(),this.isMixing_=!1,this.config_=null}},{key:"onStreamSubscribed",value:function(o){var c=o.client,a=o.stream;c===this.client_&&(this.remoteStreamMap_.set(a.getId(),{remoteStream:a,isUsed:!1}),this.isMixing_&&this.hasAvailablePlaceHolder()&&this.startMixTranscode(this.config_))}},{key:"onStreamUnsubscribed",value:function(o){var c=o.client,a=o.stream;c===this.client_&&this.onStreamRemoved({stream:a})}},{key:"onStreamRemoved",value:function(o){var c=o.stream;if(this.remoteStreamMap_.has(c.getId())){var a=this.remoteStreamMap_.get(c.getId()).isUsed;this.remoteStreamMap_.delete(c.getId()),this.isMixing_&&this.isPresetLayoutMode&&a&&this.startMixTranscode(this.config_)}}},{key:"startMixTranscode",value:(r=H(f().mark(function o(c){var a,s,l;return f().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(u.prev=0,this.resetIsUsedFlag(),this.config_=c,a=this.getInputParam(c,this.remoteStreamMap_),s=this.getOutputParam(c),l=this.getOutputSessionId({config:c,roomId:this.client_.getRoomId(),userId:this.client_.getUserId()}),!this.isMixing_||!this.data_||l===this.data_.outputSessionId){u.next=10;break}return this.log_.info("startMixTranscode() streamId changed, stop mixing before start"),u.next=10,this.doStopMixTranscode();case 10:return u.next=12,this.doStartMixTranscode({outputSessionId:l,inputParam:a,outputParam:s});case 12:u.next=18;break;case 14:throw u.prev=14,u.t0=u.catch(0),this.resetIsUsedFlag(),u.t0;case 18:case"end":return u.stop()}},o,this,[[0,14]])})),function(o){return r.apply(this,arguments)})},{key:"doStartMixTranscode",value:(i=H(f().mark(function o(c){var a,s,l,u,h,b,I,R;return f().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:return a=c.outputSessionId,s=c.inputParam,l=c.outputParam,u={roomId:String(this.client_.getRoomId()),mcuRequestTime:Date.now(),outputSessionId:a,inputParam:s,outputParam:l},this.data_=u,this.log_.info("startMixTranscode: ".concat(JSON.stringify(u))),this.isMixing_=!0,x.prev=5,x.next=8,this.signalChannel_.sendWaitForResponse({command:UU,data:u,timeout:5e3,responseCommand:st.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"});case 8:if(h=x.sent,b=h.data,I=b.code,R=b.message,I===0){x.next=15;break}throw I===-102083&&(R="Please enable relayed-push in ".concat($b," and try later, refer to ").concat(Yf,"tutorial-26-advanced-publish-cdn-stream.html")),this.log_.error("startMixTranscode failed, errCode: ".concat(I," errMsg: ").concat(R)),this.isMixing_=!1,new te({code:Z.START_MIX_TRANSCODE_FAILED,message:ie({key:x3,data:{message:R},link:{className:"Client",fnName:"startMixTranscode"}})});case 15:x.next=21;break;case 17:throw x.prev=17,x.t0=x.catch(5),this.isMixing_=!1,x.t0;case 21:case"end":return x.stop()}},o,this,[[5,17]])})),function(o){return i.apply(this,arguments)})},{key:"reStartMixTranscode",value:function(){this.isMixing_&&this.startMixTranscode(this.config_)}},{key:"stopMixTranscode",value:(n=H(f().mark(function o(){return f().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.isMixing_){c.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ie({key:C3})});case 2:return c.next=4,this.doStopMixTranscode();case 4:this.resetIsUsedFlag();case 5:case"end":return c.stop()}},o,this)})),function(){return n.apply(this,arguments)})},{key:"doStopMixTranscode",value:(t=H(f().mark(function o(){var c,a,s,l,u;return f().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return c={mcuRequestTime:Date.now(),outputSessionId:this.data_.outputSessionId,streamType:this.data_.outputParam.streamType},this.log_.info("stopMixTranscode: ".concat(JSON.stringify(c))),h.next=4,this.signalChannel_.sendWaitForResponse({command:VU,data:c,timeout:5e3,responseCommand:st.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"});case 4:if(a=h.sent,s=a.data,l=s.code,u=s.message,l!==0){h.next=10;break}this.isMixing_=!1,h.next=12;break;case 10:throw this.log_.error("stopMixTranscode failed, errCode: ".concat(l," errMsg: ").concat(u)),new te({code:Z.STOP_MIX_TRANSCODE_FAILED,message:ie({key:w3,data:{message:u},link:{className:"Client",fnName:"stopMixTranscode"}})});case 12:case"end":return h.stop()}},o,this)})),function(){return t.apply(this,arguments)})},{key:"getOutputSessionId",value:function(o){var c=o.config,a=o.userId,s=o.roomId;return Bt(c.streamId)&&c.streamId.length>0?c.streamId:cd("".concat(s,"_").concat(a,"_main"))}},{key:"getInputParam",value:function(o,c){var a=this,s=o.mixUsers.map(function(l){return{userId:l.userId,roomId:String(l.roomId||a.client_.getRoomId()),width:l.width||0,height:l.height||0,locationX:l.locationX||0,locationY:l.locationY||0,zOrder:l.zOrder,streamType:ge(l.streamType)||l.streamType!==Dt?0:1,inputType:l.pureAudio?Gb.IT_PURE_AUDIO:Gb.IT_AUDIO_VIDEO,renderMode:l.renderMode||0}});return o.mode===Jf.PRESET_LAYOUT&&(s.forEach(function(l){if(l.userId===Hb.REMOTE){var u=Se(c.values()).find(function(h){return!h.isUsed});u&&(l.userId=u.remoteStream.getUserId(),l.streamType=u.remoteStream.getType()===Dt?1:0,u.isUsed=!0)}}),s=s.filter(function(l){return l.userId!==Hb.REMOTE})),s}},{key:"getOutputParam",value:function(o){var c=o.streamId||"";return{streamId:c,streamType:c.length>0?1:0,width:ge(o.videoWidth)?640:o.videoWidth,height:ge(o.videoHeight)?480:o.videoHeight,videoBps:o.videoBitrate||0,fps:o.videoFramerate||15,gop:o.videoGOP||2,audioSampleRate:o.audioSampleRate||48e3,audioBps:o.audioBitrate||64,audioChannels:o.audioChannels||1,backgroundColor:o.backgroundColor||0,backgroundImg:o.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(o){return o.isUsed=!1})}}]),e}(),a7=function(){function e(a){Q(this,e),this.client_=a.client,this.signalChannel_=a.signalChannel,this.publishTencentMainStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1},this.publishTencentAuxStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1},this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1}var t,n,i,r,o,c;return xe(e,[{key:"setSignalChannel",value:function(a){this.signalChannel_=a.signalChannel}},{key:"getIsPublishingTencentCDN",value:function(){return this.publishTencentMainStreamObj_.isPublishing_||this.publishTencentAuxStreamObj_.isPublishing_}},{key:"getIsPublishingGivenCDN",value:function(){return this.isPublishingGivenCDN_}},{key:"generatePublishCDNStreamId",value:function(a,s){if(!a){var l="".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(s);return/^[A-Za-z\d_-]*$/.test(l)||(l=cd(l)),"".concat(this.client_.getSDKAppId(),"_").concat(l)}return a}},{key:"generatePublishCDNSessionId",value:function(a){return cd("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(a))}},{key:"startPublishTencentCDN",value:(c=H(f().mark(function a(s){var l,u,h,b;return f().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(s.streamType===Nn?(this.publishTencentAuxStreamObj_.params_=s,this.publishTencentAuxStreamObj_.isPublishing_=!0):(this.publishTencentMainStreamObj_.params_=s,this.publishTencentMainStreamObj_.isPublishing_=!0),this.client_.isJoined_){I.next=3;break}return I.abrupt("return");case 3:return l=this.generatePublishCDNStreamId(s.streamId,s.streamType),u=this.generatePublishCDNSessionId(s.streamType),h=s.streamType===Nn?1:0,b={requestTime:Date.now(),sessionId:u,streamId:l,streamType:h},I.next=9,this.doStartPublishTencentCDN(b,s.streamType);case 9:case"end":return I.stop()}},a,this)})),function(a){return c.apply(this,arguments)})},{key:"doStartPublishTencentCDN",value:(o=H(f().mark(function a(s,l){var u,h,b,I;return f().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:return R.prev=0,_e.info("startPublishTencentCDN: "+JSON.stringify(s)),R.next=4,this.signalChannel_.sendWaitForResponseWithRetry({command:OU,data:s,timeout:2e3,responseCommand:st.START_PUBLISH_TENCENT_CDN_RES,commandDesc:"startPublishCDNStream",retries:2});case 4:if(u=R.sent,h=u.data,b=h.code,I=h.message,b!==0){R.next=10;break}l===Nn?this.publishTencentAuxStreamObj_.streamId_=s.streamId:this.publishTencentMainStreamObj_.streamId_=s.streamId,R.next=14;break;case 10:throw l===Nn?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,b===-102083&&(I="Please enable relayed-push in ".concat($b," and try later, refer to ").concat(Yf,"tutorial-26-advanced-publish-cdn-stream.html")),_e.error("startPublishTencentCDN failed, errCode: ".concat(b,", errMsg: ").concat(I)),new te({code:Z.START_PUBLISH_CDN_FAILED,message:ie({key:dS,data:{message:I},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 14:R.next=20;break;case 16:throw R.prev=16,R.t0=R.catch(0),l===Nn?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,R.t0;case 20:case"end":return R.stop()}},a,this,[[0,16]])})),function(a,s){return o.apply(this,arguments)})},{key:"resetPublishTencentParam",value:function(a){a===Xe&&(this.publishTencentMainStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1}),a===Nn&&(this.publishTencentAuxStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1})}},{key:"stopPublishTencentCDN",value:(r=H(f().mark(function a(){return f().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(this.client_.isJoined_){s.next=4;break}return this.resetPublishTencentParam(Xe),this.resetPublishTencentParam(Nn),s.abrupt("return");case 4:if(!this.publishTencentMainStreamObj_.isPublishing_){s.next=7;break}return s.next=7,this.doStopPublishTencentCDN(Xe);case 7:if(!this.publishTencentAuxStreamObj_.isPublishing_){s.next=10;break}return s.next=10,this.doStopPublishTencentCDN(Nn);case 10:case"end":return s.stop()}},a,this)})),function(){return r.apply(this,arguments)})},{key:"doStopPublishTencentCDN",value:(i=H(f().mark(function a(s){var l,u,h,b,I;return f().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:return l={requestTime:Date.now(),sessionId:cd("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(s))},_e.info("stopPublishTencentCDN: "+JSON.stringify(l)),R.next=4,this.signalChannel_.sendWaitForResponse({command:LU,data:l,timeout:5e3,responseCommand:st.STOP_PUBLISH_TENCENT_CDN_RES,commandDesc:"stopPublishCDNStream"});case 4:if(u=R.sent,h=u.data,b=h.code,I=h.message,b!==0){R.next=10;break}this.resetPublishTencentParam(s),R.next=17;break;case 10:if(b!==-102069){R.next=15;break}_e.warn("stopPublishTencentCDN failed, can not stopPublishTencentCDN in auto relayed-push mode"),this.resetPublishTencentParam(s),R.next=17;break;case 15:throw _e.error("stopPublishTencentCDN failed, errCode: ".concat(b," errMsg: ").concat(I)),new te({code:Z.STOP_PUBLISH_CDN_FAILED,message:ie({key:hS,data:{message:I},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 17:case"end":return R.stop()}},a,this)})),function(a){return i.apply(this,arguments)})},{key:"startPublishGivenCDN",value:(n=H(f().mark(function a(s){var l,u,h,b,I,R;return f().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(l=s.streamType===Xe?this.publishTencentMainStreamObj_.streamId_:this.publishTencentAuxStreamObj_.streamId_,u={pushRequestTime:Date.now(),pushAppId:s.appId,pushBizId:s.bizId,pushCdnUrl:s.url,pushStreamType:s.streamType,pushStreamId:l},_e.info("startPublishGivenCDN: "+JSON.stringify(u)),this.publishGivenCDNData_=u,this.isPublishingGivenCDN_=!0,this.client_.isJoined_){x.next=7;break}return x.abrupt("return");case 7:return x.prev=7,x.next=10,this.signalChannel_.sendWaitForResponse({command:MU,data:u,timeout:5e3,responseCommand:st.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDNStream"});case 10:if(h=x.sent,b=h.data,I=b.code,R=b.message,I===0){x.next=17;break}throw _e.error("startPublishGivenCDN failed, errCode: ".concat(I,", errMsg: ").concat(R)),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,new te({code:Z.START_PUBLISH_CDN_FAILED,message:ie({key:dS,data:{message:R},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 17:x.next=24;break;case 19:throw x.prev=19,x.t0=x.catch(7),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,x.t0;case 24:case"end":return x.stop()}},a,this,[[7,19]])})),function(a){return n.apply(this,arguments)})},{key:"stopPublishGivenCDN",value:(t=H(f().mark(function a(){var s,l,u,h,b,I,R,x,m,k;return f().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(this.client_.isJoined_){v.next=4;break}return this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,v.abrupt("return");case 4:return s=this.publishGivenCDNData_,l=s.pushAppId,u=s.pushBizId,h=s.pushCdnUrl,b=s.pushStreamType,I={pushRequestTime:Date.now(),pushAppId:l,pushBizId:u,pushCdnUrl:h,pushStreamType:b},_e.info("stopPublishGivenCDN: "+JSON.stringify(I)),v.next=9,this.signalChannel_.sendWaitForResponse({command:NU,data:I,timeout:5e3,responseCommand:st.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDNStream"});case 9:if(R=v.sent,x=R.data,m=x.code,k=x.message,m!==0){v.next=16;break}this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,v.next=18;break;case 16:throw _e.error("stopPublishGivenCDN failed, errCode: ".concat(m," errMsg: ").concat(k)),new te({code:Z.STOP_PUBLISH_CDN_FAILED,message:ie({key:hS,data:{message:k},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 18:case"end":return v.stop()}},a,this)})),function(){return t.apply(this,arguments)})},{key:"handleCDNConfigForJoinData",value:function(a){var s,l=a;if(this.publishTencentMainStreamObj_.isPublishing_||this.publishTencentAuxStreamObj_.isPublishing_){var u={};Bt(l)&&(u=JSON.parse(l)),u.Str_uc_params||(u.Str_uc_params={}),this.publishTencentMainStreamObj_.isPublishing_&&(this.publishTencentMainStreamObj_.streamId_?u.Str_uc_params.userdefine_streamid_main=this.publishTencentMainStreamObj_.streamId_:this.publishTencentMainStreamObj_.params_&&(u.Str_uc_params.userdefine_streamid_main=this.generatePublishCDNStreamId(this.publishTencentMainStreamObj_.params_.streamId,Xe))),this.publishTencentAuxStreamObj_.isPublishing_&&(this.publishTencentAuxStreamObj_.streamId_?u.Str_uc_params.userdefine_streamid_aux=this.publishTencentAuxStreamObj_.streamId_:this.publishTencentAuxStreamObj_.params_&&(u.Str_uc_params.userdefine_streamid_aux=this.generatePublishCDNStreamId(this.publishTencentAuxStreamObj_.params_.streamId,Nn))),l=JSON.stringify(u)}if(this.isPublishingGivenCDN_){var h=this.publishGivenCDNData_,b=h.pushAppId,I=h.pushBizId,R=h.pushCdnUrl,x=h.pushStreamType,m=h.pushStreamId;s={pushRequestTime:Date.now(),pushAppId:b,pushBizId:I,pushCdnUrl:R,pushStreamType:x,pushStreamId:m}}return{bussinessInfo:l,pushUserCdnInfo:s}}},{key:"reset",value:function(){this.resetPublishTencentParam(Xe),this.resetPublishTencentParam(Nn),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1}}]),e}(),o7=function(){function e(t){Q(this,e),this.client_=t.client,this.durationMap_=new Map,this.installEvents()}return xe(e,[{key:"installEvents",value:function(){Y.on(Ur,this.handleSubscribed,this),Y.on(jn,this.handleStreamTrackUpdated,this),Y.on(Vr,this.handleStreamStopped,this),Y.on(ca,this.handleStreamStopped,this)}},{key:"uninstallEvents",value:function(){Y.off(Ur,this.handleSubscribed,this),Y.off(jn,this.handleStreamTrackUpdated,this),Y.off(Vr,this.handleStreamStopped,this),Y.off(ca,this.handleStreamStopped,this)}},{key:"handleSubscribed",value:function(t){var n=t.client,i=t.stream;if(n===this.client_){var r=i.getUserId(),o=i.getType(),c="".concat(r,"_").concat(o);if(i.hasAudio())if(i.isMainAudioSubscribed){var a=new sd,s=this.durationMap_.get(c);s?this.isRecording(s.audio)||s.audio.push(a):this.durationMap_.set(c,{userId:r,type:o,audio:[a],video:[]})}else this.stopDurationItem(c,Re);if(i.hasVideo())if(o===yt&&i.isMainVideoSubscribed||o===Dt&&i.isAuxVideoSubscribed){var l=new sd,u=this.durationMap_.get(c);u?this.isRecording(u.video)||u.video.push(l):this.durationMap_.set(c,{userId:r,type:o,audio:[],video:[l]})}else this.stopDurationItem(c,Ie)}}},{key:"handleStreamStopped",value:function(t){var n=t.client,i=t.stream;if(this.clientHitTest(n)){var r=i.getUserId(),o=i.getType(),c="".concat(r,"_").concat(o);this.stopDurationItem(c,Re),this.stopDurationItem(c,Ie)}}},{key:"handleStreamTrackUpdated",value:function(t){var n=t.client,i=t.userId,r=t.tinyId,o=t.kind,c=t.action;if(this.clientHitTest(n)&&this.client_.getConnections().has(r)){var a=o===gt?o:yt,s="".concat(i,"_").concat(a);if(c===cn.ADD){var l=this.client_.getConnections().get(r).getSubscribeState();if(o===Re&&!l.audio||o===Ie&&!l.video||o===gt&&!l.auxiliary)return;var u=new sd,h=this.durationMap_.get(s);h?(o!==Re||this.isRecording(h.audio)||h.audio.push(u),o===Re||this.isRecording(h.video)||h.video.push(u)):this.durationMap_.set(s,{userId:i,type:a,audio:o===Re?[u]:[],video:o===Re?[]:[u]})}else this.stopDurationItem(s,o===Re?Re:Ie)}}},{key:"isRecording",value:function(t){return t.findIndex(function(n){return n.endTime===0})>=0}},{key:"stopDurationItem",value:function(t,n){if(this.durationMap_.has(t)){var i=this.durationMap_.get(t)[n].find(function(r){return r.endTime===0});i&&i.stop()}}},{key:"clientHitTest",value:function(t){return this.client_===t}},{key:"getDuration",value:function(t,n){return this.durationMap_.has(t)?this.durationMap_.get(t)[n].reduce(function(i,r){return i+r.getDuration()},0):0}},{key:"getDurationMap",value:function(){return this.durationMap_}},{key:"reset",value:function(){this.durationMap_.clear()}},{key:"destroy",value:function(){this.client_=null,this.uninstallEvents()}}]),e}();function wc(){return function(e,t,n){var i=n.value,r=new Set;return n.value=H(f().mark(function o(){var c,a,s,l,u=arguments;return f().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(!r.has(this)){h.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ie({key:bN,data:{name:t}})});case 2:for(h.prev=2,r.add(this),c=u.length,a=new Array(c),s=0;s<c;s++)a[s]=u[s];return h.next=7,i.apply(this,a);case 7:return l=h.sent,r.delete(this),h.abrupt("return",l);case 12:throw h.prev=12,h.t0=h.catch(2),r.delete(this),h.t0;case 16:case"end":return h.stop()}},o,this,[[2,12]])})),n}}var fx,px,mx,vx,gx,_x,yx,bx,Sx,kx,Tx,Ix,xx,wx,Cx,Ex,Rx,Ax,Px,Dx,Ox,Lx,Mx,Nx,Ux,Vx,jx,Bx,Fx,Hx,Gx,Pe,s7=(dx=fn({name:"options",type:xn,required:!0,properties:{roomId:{type:dt,required:!0},userId:{type:dt,required:!1}}}),hx=fn({name:"options",type:xn,required:!0,properties:{updateList:{type:zb,required:!0,arrayItem:{require:!0,type:xn,properties:{roomId:{required:!0,type:dt},userId:{required:!1,type:dt},muteAudio:{type:Wt},muteVideo:{type:Wt},muteAuxiliary:{type:Wt}}},validate:function(e){if(e.find(function(t){return t.userId})&&e.find(function(t){return!t.userId}))throw new te({code:Z.INVALID_PARAMETER,message:"you can not update both userId and all"})}}}}),Pi=function(){function e(){Q(this,e),this.crossRoomSeq=0}var t,n,i;return xe(e,[{key:"call",value:function(r,o){return ln(this[r])?this[r](o):Promise.reject(new te({code:Z.INVALID_PARAMETER,message:ie({key:K3,data:{name:r}})}))}},{key:"updatePrivateMapKey",value:function(r){var o=r.privateMapKey;return r.client.setProperty("privateMapKey",o),Promise.resolve()}},{key:"connectOtherRoom",value:(i=H(f().mark(function r(o){var c,a,s,l;return f().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(c=o.client,a=o.roomId,s=o.userId,c.signalChannel_){u.next=3;break}return u.abrupt("return",Promise.reject(new te({code:Z.INVALID_OPERATION,message:"you did not joined room"})));case 3:return u.next=5,c.signalChannel_.sendWaitForResponseWithRetry({command:HU,responseCommand:st.CONNECT_OTHER_ROOM_RES,data:{roomId:a,userId:s,localRoomId:s?void 0:c.getRoomId()},retries:3});case 5:if((l=u.sent).data.code===0){u.next=8;break}throw new te({code:l.data.code,message:l.data.message});case 8:case"end":return u.stop()}},r)})),function(r){return i.apply(this,arguments)})},{key:"updateOtherRoomForwardMode",value:(n=H(f().mark(function r(o){var c,a,s,l,u;return f().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(a=o.client,s=o.updateList,a.signalChannel_){h.next=3;break}return h.abrupt("return",Promise.reject(new te({code:Z.INVALID_OPERATION,message:"you did not joined room"})));case 3:return l=s.find(function(b){return b.userId})?0:1,h.next=6,a.signalChannel_.sendWaitForResponseWithRetry({command:GU,responseCommand:st.UPDATE_OTHER_ROOM_FORWARD_MODE_RES,data:{seq:++this.crossRoomSeq,operationType:l,updateList:s.map(function(b){return{roomId:b.roomId,userId:b.userId,muteAudio:b.muteAudio,muteVideo:b.muteVideo,muteSubStream:b.muteAuxiliary}})},retries:3});case 6:if(!(u=h.sent).data.data.expectSeq){h.next=10;break}return this.crossRoomSeq=u.data.data.expectSeq,h.abrupt("return",this.updateOtherRoomForwardMode({client:a,updateList:s}));case 10:if(u.data.code===0){h.next=14;break}throw new te({code:u.data.code,message:u.data.message});case 14:if(!(((c=u.data.errorList)===null||c===void 0?void 0:c.length)>0)){h.next=16;break}throw new te({code:Z.UNKNOWN,message:u.data.errorList[0].message});case 16:case"end":return h.stop()}},r,this)})),function(r){return n.apply(this,arguments)})},{key:"disconnectOtherRoom",value:(t=H(f().mark(function r(o){var c,a,s;return f().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(c=o.client,a=o.roomId,c.signalChannel_){l.next=3;break}return l.abrupt("return",Promise.resolve());case 3:return l.next=5,c.signalChannel_.sendWaitForResponseWithRetry({command:zU,responseCommand:st.DISCONNECT_OTHER_ROOM_RES,data:{roomId:a,localRoomId:a?c.getRoomId():void 0},retries:3});case 5:if((s=l.sent).data.code===0){l.next=8;break}throw new te({code:s.data.code,message:s.data.message});case 8:case"end":return l.stop()}},r)})),function(r){return t.apply(this,arguments)})}]),e}(),K(Pi.prototype,"connectOtherRoom",[dx],Object.getOwnPropertyDescriptor(Pi.prototype,"connectOtherRoom"),Pi.prototype),K(Pi.prototype,"updateOtherRoomForwardMode",[hx],Object.getOwnPropertyDescriptor(Pi.prototype,"updateOtherRoomForwardMode"),Pi.prototype),Pi),c7=new s7,ud,ld,dd,$v,zx,Wx,Jx,qx,Kx,Xx,$t,u7=(fx=wc(),px=fn(Yt.CLIENT.join),mx=Lo({retries:1,timeout:0,onError:function(e,t,n){this.isUsingCachedSchedule_?(this.log_.warn("is using cached schedule, retry join"),Ti(!0),this.reset(),t()):(Y.emit(sa,{client:this,error:e}),ke.logFailedEvent({userId:this.userId_,eventType:Tb,error:e}),this.reset(),this.log_.error(e),n(e))}}),vx=wc(),gx=Lo({retries:3}),_x=wc(),yx=fn.apply(void 0,Se(Yt.CLIENT.publish)),bx=St(un),Sx=wc(),kx=fn(Yt.CLIENT.unpublish),Tx=fn.apply(void 0,Se(Yt.CLIENT.subscribe)),Ix=fn(Yt.CLIENT.unsubscribe),xx=wc(),wx=fn(Yt.CLIENT.switchRole),Cx=St(un),Ex=fn(Yt.CLIENT.startPublishCDNStream),Rx=St(un),Ax=St(un),Px=fn(Yt.CLIENT.startMixTranscode),Dx=St(un),Ox=St(un),Lx=St(un),Mx=St(un),Nx=St(un),Ux=St(un),Vx=St(un),jx=Ql.apply(void 0,Se(Yt.CLIENT.sendSEIMessage)),Bx=St(un),ud={timesInSecond:30,maxSizeInSecond:8e3,getSize:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[0].byteLength}},ld=ud.timesInSecond,dd=ud.maxSizeInSecond,$v=ud.getSize,Fx=function(e,t,n){var i=n.value,r=new Map;return Y.on(Up,function(o){var c=o.client;return r.delete(c)}),n.value=function(){var o=r.get(this);o||(o={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},r.set(this,o)),o.timestamp===0?o.timestamp=Date.now():Date.now()-o.timestamp>1e3&&(o.timestamp=Date.now(),o.callCountInSecond=0,o.totalSizeInSecond=0);for(var c=arguments.length,a=new Array(c),s=0;s<c;s++)a[s]=arguments[s];if($v&&(o.totalSizeInSecond+=$v.apply(void 0,a)),o.timestamp!==0&&Date.now()-o.timestamp<1e3&&(o.callCountInSecond>=ld||o.totalSizeInSecond>dd))throw new te({code:Z.INVALID_OPERATION,message:ie({key:n4,data:{isTimes:o.callCountInSecond>=ld,isSize:o.totalSizeInSecond>dd,name:t,timesInSecond:ld,maxSizeInSecond:dd}})});return o.callCountInSecond++,i.apply(this,a)},n},Hx=St(un),Gx=St(un),Pe=function(){function e(S){var p,_;Q(this,e),this.name_=un,this.mode_=S.mode,this.sdpSemantics_=Wf,ge(S.sdpSemantics)?function(){var P;if(ge(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var M=null,B=!1;try{(M=new RTCPeerConnection({sdpSemantics:Ys})).addTransceiver(Re),B=!0}catch(X){}return(P=M)===null||P===void 0||P.close(),B}()&&(this.sdpSemantics_=Ys):this.sdpSemantics_=S.sdpSemantics,this.sdkAppId_=S.sdkAppId,this.userId_=S.userId,this.log_=_e.createLogger({id:"c".concat(S.seq,"|").concat(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_}),this.userSig_=S.userSig,this.roomId_=0,this.useStringRoomId_=S.useStringRoomId||!1,this.pureAudioPushMode_=null,this.version_=S.version,this.log_.info("using sdpSemantics: "+this.sdpSemantics_),this.signalChannel_=null,this.role_=Tr,this.privateMapKey_="",this.tinyId_=0,this.env_="",this.proxy_=null,this.unifiedProxy_=null,this.connections_=new Map,this.mutedStates_=new Map,this.userMap_=new Map,this.syncUserListInterval_=-1,this.localStream_=null,this.localAuxStream_=null,this.uplinkConnection_=null,this.emitter_=GS(new ki,this.name_),this.isJoined_=!1,this.heartbeat_=-1,this.lastHeartBeatTime_=-1,this.stats_=new c6(this),this.joinTimeout_=-1,this.changeBigSmallRecords_=new Map,this.networkQuality_=null,this.badCaseDetector_=null,this.networkType_=Tp(),this.autoSubscribe_=!!ge(S.autoSubscribe)||S.autoSubscribe,this.joinedTimestamp_=0,this.joinOptions_={},this.basis_=(_={browser:aa().name+"/"+aa().version,os:xm(),displayResolution:ZV(),isScreenShareSupported:Bk(),isWebRTCSupported:ym(),isGetUserMediaSupported:e6(),isWebAudioSupported:t6(),isWebSocketsSupported:"WebSocket"in window&&window.WebSocket.CLOSING===2,isWebCodecSupported:(p={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1},ge(window.AudioDecoder)||(p.AudioDecoder=!0),ge(window.AudioEncoder)||(p.AudioEncoder=!0),ge(window.VideoDecoder)||(p.VideoDecoder=!0),ge(window.VideoEncoder)||(p.VideoEncoder=!0),ge(window.ImageDecoder)||(p.ImageDecoder=!0),p),isMediaSessionSupported:"mediaSession"in navigator&&!ge(navigator.mediaSession.setActionHandler),isWebTransportSupported:!ge(window.WebTransport)},navigator.userAgent.includes("miniProgram")&&(_.browser="mini/".concat(_.browser)),_),this.initBussinessInfo_(S),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_=new a7({client:this}),this.keyPointManager_=new kF({client:this,frameWorkType:S.frameWorkType,component:S.component}),this.isPublishing_=!1,this.isEnableSmallStream_=!1,this.smallStreamConfig_={bitrate:100,frameRate:15,height:120,width:160},this.turnServers_=[],this.iceTransportPolicy_=S.iceTransportPolicy,this.schedule_={domains:null,iceServers:null,iceTransportPolicy:null,trtcCapability:null},this.isUsingCachedSchedule_=!1,this.enableAutoPlayDialog_=!!ge(S.enableAutoPlayDialog)||S.enableAutoPlayDialog,this.enableMultiAuxStream_=!ge(S.enableMultiAuxStream)&&S.enableMultiAuxStream,this.signalInfo_={},this.enableSEI_=!ge(S.enableSEI)&&S.enableSEI,this.isDestroyed_=!1}var t,n,i,r,o,c,a,s,l,u,h,b,I,R,x,m,k,v,w,L,E,N,T,y,D,A,U;return xe(e,[{key:"initBussinessInfo_",value:function(S){this.bussinessInfo_=S.bussinessInfo;var p={};if(Bt(S.bussinessInfo)&&(p=JSON.parse(S.bussinessInfo)),!ge(S.pureAudioPushMode)){if(!Number.isInteger(Number(S.pureAudioPushMode)))throw new te({code:Z.INVALID_PARAMETER,message:ie({key:DN})});this.pureAudioPushMode_=S.pureAudioPushMode,p.Str_uc_params||(p.Str_uc_params={}),p.Str_uc_params.pure_audio_push_mod=this.pureAudioPushMode_}if(!ge(S.streamId)){if(!(Bt(S.streamId)&&String(S.streamId)&&String(S.streamId).length<=64))throw new te({code:Z.INVALID_PARAMETER,message:ie({key:ON})});p.Str_uc_params||(p.Str_uc_params={}),p.Str_uc_params.userdefine_streamid_main=S.streamId}if(!ge(S.userDefineRecordId)){if(S.userDefineRecordId.match(/^[A-Za-z0-9_-]{1,64}$/gi)===null)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:LN})});p.Str_uc_params||(p.Str_uc_params={}),p.Str_uc_params.userdefine_record_id=S.userDefineRecordId}if(!ge(S.userDefinePushArgs)){if(!(Bt(S.userDefinePushArgs)&&String(S.userDefinePushArgs)&&String(S.userDefinePushArgs).length<=256))throw new te({code:Z.INVALID_PARAMETER,message:ie({key:MN})});p.Str_uc_params||(p.Str_uc_params={}),p.Str_uc_params.userdefine_push_args=S.userDefinePushArgs}S.enableServerAudioMix&&(p.Str_uc_params||(p.Str_uc_params={}),p.Str_uc_params.enable_server_audio_mix=1,p.Str_uc_params.uc_biz_type=1e3),Br(p)||(this.bussinessInfo_=JSON.stringify(p))}},{key:"schedule",value:(U=H(f().mark(function S(p){var _,P,M;return f().wrap(function(B){for(;;)switch(B.prev=B.next){case 0:return B.next=2,OV({userId:this.userId_,sdkAppId:this.sdkAppId_,roomId:p,useStringRoomId:this.useStringRoomId_,version:this.version_,userSig:this.userSig_});case 2:_=B.sent,P=_.result,M=_.isCached,this.isUsingCachedSchedule_=M,P&&(this.log_.info("schedule with cache:".concat(M," : ").concat(JSON.stringify(P))),P.trtcCapability=P==null?void 0:P.trtcAutoConf,this.schedule_=J(J({},this.schedule_),P),Y.emit(qS,this.schedule_));case 7:case"end":return B.stop()}},S,this)})),function(S){return U.apply(this,arguments)})},{key:"getSignalChannelUrl",value:function(){var S={mainUrl:"",backupUrl:""},p=MS();return p?S.mainUrl=S.backupUrl="wss://".concat(p,".rtc.qq.com"):this.proxy_?S.mainUrl=S.backupUrl=this.proxy_:this.unifiedProxy_?S.mainUrl=S.backupUrl="wss://".concat(this.unifiedProxy_):Array.isArray(this.schedule_.domains)&&this.schedule_.domains.length>0&&(S.mainUrl=S.backupUrl="wss://".concat(this.schedule_.domains[0]),this.schedule_.domains[1]&&(S.backupUrl="wss://".concat(this.schedule_.domains[1]))),S}},{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:"getIceTransportPolicy",value:function(){return this.iceTransportPolicy_||this.schedule_.iceTransportPolicy||"all"}},{key:"initialize",value:function(S){var p=this;this.log_.info("setup signal channel");var _=this.getSignalChannelUrl(),P=_.mainUrl,M=_.backupUrl;return this.signalChannel_=new NV({sdkAppId:this.sdkAppId_,userId:this.userId_,userSig:this.userSig_,roomId:S.roomId,url:P,backupUrl:M,signalDomainWhenUnifiedProxy:this.unifiedProxy_?this.schedule_.domains[0]:void 0,client:this}),this.networkQuality_||(this.networkQuality_=new u6({connections:this.connections_,signalChannel:this.signalChannel_,userId:this.userId_,client:this}),this.networkQuality_.on(ct.NETWORK_QUALITY,function(B){p.emitter_.emit(ct.NETWORK_QUALITY,B)})),this.deviceDetector_||(this.deviceDetector_=new l6({client:this})),this.subscriptionManager_||(this.subscriptionManager_=new TF({client:this})),this.badCaseDetector_||(this.badCaseDetector_=new r7({client:this,stats:this.stats_})),this.callDurationCalculator_||(this.callDurationCalculator_=new o7({client:this})),this.mixTranscodeManager_||(this.mixTranscodeManager_=new i7({client:this,signalChannel:this.signalChannel_})),this.publishCDNManager_&&this.publishCDNManager_.setSignalChannel({signalChannel:this.signalChannel_}),this.signalChannel_.on(rm,function(B){p.log_.info("SignalChannel state changed from ".concat(B.prevState," to ").concat(B.state)),p.emitter_.emit(ct.CONNECTION_STATE_CHANGED,B)}),this.signalChannel_.on(im,function(B){p.reset(),p.emitter_.emit(ct.ERROR,B)}),this.signalChannel_.once(pk,function(B){p.tinyId_=B.signalInfo.tinyId,Y.emit(ll,{client:p})}),this.signalChannel_.on(st.PEER_JOIN,this.onPeerJoin,this),this.signalChannel_.on(st.PEER_LEAVE,this.onPeerLeave,this),this.signalChannel_.on(st.UPDATE_REMOTE_MUTE_STAT,function(B){Date.now()-p.lastHeartBeatTime_>=1e4&&p.doHeartbeat(),Y.emit(Op,{client:p,data:B.data}),p.onPublishedUserList(B.data),p.onUpdateRemoteMuteStat(B.data)}),this.signalChannel_.on(st.CLIENT_BANNED,function(B){var X,q=B.data.data.reason;if(ke.uploadEvent({log:"stat-banned:".concat(q),userId:p.userId_}),q===UM)X="you got banned by the admin";else if(q===VM)X="duplicated userId joining the room";else if(q===BM)X="the room has been disbanded by the admin",q=q.replace("_","-");else if(q===jM)return p.log_.warn("".concat(q," last heart beat time: ").concat(p.lastHeartBeatTime_," interval: ").concat(Date.now()-p.lastHeartBeatTime_,", visibility: ").concat(document.visibilityState)),void p.reJoin();p.log_[q==="kick"?"error":"info"]("user was banned because of [".concat(q,"]")),p.reset(),p.emitter_.emit(ct.CLIENT_BANNED,{reason:q,message:ie({key:ZN,data:{message:X,reason:q}})||q})}),Y.emit(Mp,{client:this}),this.signalChannel_.connect()}},{key:"preJoin",value:(A=H(f().mark(function S(p){var _,P,M,B;return f().wrap(function(X){for(;;)switch(X.prev=X.next){case 0:return this.joinOptions_=p,X.next=3,Sm();case 3:if(this.checkSystemResult_=X.sent,this.checkDestroy(),(_=MS())||(_=Gu,this.proxy_&&(this.proxy_.startsWith(HM)?_=zM:this.proxy_.startsWith(GM)&&(_=WM))),this.env_=_,ke.setConfig({env:_,sdkAppId:this.sdkAppId_,userId:this.userId_,roomId:p.roomId}),this.uploadTrtcStats(),P=this.checkSystemResult_.detail,M=P.isH264EncodeSupported,B=P.isVp8EncodeSupported,ym()&&(M||B)){X.next=13;break}throw new te({code:Z.NOT_SUPPORTED,message:ie({key:vS})});case 13:case"end":return X.stop()}},S,this)})),function(S){return A.apply(this,arguments)})},{key:"join",value:(D=H(f().mark(function S(p){var _,P=this;return f().wrap(function(M){for(;;)switch(M.prev=M.next){case 0:return this.roomId_=p.roomId,ge(p.role)||(this.role_=p.role),ge(p.privateMapKey)||(this.privateMapKey_=p.privateMapKey),_=Ct(),Y.emit(ul,{client:this}),vn(this.userId_,{eventId:iV,eventDesc:"joining room",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),M.next=8,this.preJoin(p);case 8:return M.abrupt("return",new Promise(function(){var B=H(f().mark(function X(q,le){return f().wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:if(P.joinReject_=le,ce.prev=1,P.proxy_||P.schedule_.domains){ce.next=5;break}return ce.next=5,P.schedule(p.roomId);case 5:return P.checkDestroy(),ce.next=8,P.initialize(p);case 8:return ce.next=10,P.doJoin(p);case 10:P.signalInfo_=P.signalChannel_.getSignalInfo(),Y.emit(po,{client:P}),P.joinedTimestamp_=Ct(),ke.logSuccessEvent({userId:P.userId_,eventType:eN,delta:P.joinedTimestamp_-_}),ke.logSuccessEvent({userId:P.userId_,eventType:Tb}),ke.uploadEvent({log:"stat-autoplay-dialog:".concat(P.enableAutoPlayDialog_),userId:P.userId_}),ke.uploadEvent({log:"stat-conv-".concat(ra,"-").concat(location.hostname),userId:P.userId_}),q(),ce.next=23;break;case 20:ce.prev=20,ce.t0=ce.catch(1),le(ce.t0);case 23:P.joinReject_=null;case 24:case"end":return ce.stop()}},X,null,[[1,20]])}));return function(X,q){return B.apply(this,arguments)}}()));case 9:case"end":return M.stop()}},S,this)})),function(S){return D.apply(this,arguments)})},{key:"checkDestroy",value:function(){if(this.isDestroyed_)throw new te({code:Z.INVALID_OPERATION,message:ie({key:tp,data:{funName:"join"}})})}},{key:"uploadTrtcStats",value:(y=H(f().mark(function S(){var p,_,P,M,B,X,q,le,ce,Ze,Ue,Fe,ht;return f().wrap(function(ze){for(;;)switch(ze.prev=ze.next){case 0:return ze.prev=0,ze.next=3,It.getMicrophones();case 3:P=ze.sent,p=P&&P.length,ze.next=9;break;case 7:ze.prev=7,ze.t0=ze.catch(0);case 9:return ze.prev=9,ze.next=12,It.getCameras();case 12:M=ze.sent,_=M&&M.length,ze.next=18;break;case 16:ze.prev=16,ze.t1=ze.catch(9);case 18:B={microphone:p,camera:_},X=this.checkSystemResult_.detail,q=X.isH264EncodeSupported,le=X.isVp8EncodeSupported,ce=X.isH264DecodeSupported,Ze=X.isVp8DecodeSupported,Ue={webRTC:this.basis_.isWebRTCSupported,getUserMedia:this.basis_.isGetUserMediaSupported,webSocket:this.basis_.isWebSocketsSupported,screenShare:this.basis_.isScreenShareSupported,webAudio:this.basis_.isWebAudioSupported,h264Encode:q,h264Decode:ce,vp8Encode:le,vp8Decode:Ze},Fe={browser:this.basis_.browser,os:this.basis_.os,trtc:Ue,devices:B},ht={isWebCodecSupported:this.basis_.isWebCodecSupported,isMediaSessionSupported:this.basis_.isMediaSessionSupported,isWebTransportSupported:this.basis_.isWebTransportSupported},ke.uploadEvent({log:"trtcstats-"+JSON.stringify(Fe),userId:this.userId_}),this.log_.info("TrtcStats-"+JSON.stringify(Fe)),ke.uploadEvent({log:"trtcadvancedstats-"+JSON.stringify(ht),userId:this.userId_});case 26:case"end":return ze.stop()}},S,this,[[0,7],[9,16]])})),function(){return y.apply(this,arguments)})},{key:"doJoin",value:function(S){var p=this;return new Promise(function(_,P){p.log_.info("Join() => joining room: ".concat(p.roomId_," useStringRoomId: ").concat(p.useStringRoomId_," mode: ").concat(p.mode_," role: ").concat(p.role_));var M={roomId:String(p.roomId_),useStringRoomId:p.useStringRoomId_,privateMapKey:p.privateMapKey_,trtcRole:p.role_===Tr?so:Vf,trtcScene:p.mode_===zu?XM:KM,sdpSemantics:p.sdpSemantics_,version:P4(p.version_),ua:navigator&&navigator.userAgent||"",autoSubscribe:p.autoSubscribe_,terminalType:ta?4:op?2:ap?3:ec?12:AS?5:PS?13:1,netType:qf[Tp()],bussinessInfo:p.bussinessInfo_,receiveMix:!0};if(p.publishCDNManager_){var B=p.publishCDNManager_.handleCDNConfigForJoinData(p.bussinessInfo_),X=B.bussinessInfo,q=B.pushUserCdnInfo;Object.assign(M,{bussinessInfo:X,pushUserCdnInfo:q})}p.log_.debug("join room signal data: ".concat(JSON.stringify(M))),p.joinTimeout_=setTimeout(function(){P(new te({code:Z.JOIN_ROOM_FAILED,message:ie({key:BN})}))},5e3),Y.emit(Ep,{client:p}),p.signalChannel_.once(mk,function(le){p.clearJoinTimeout(),Y.emit(ll,{client:p,error:le}),P(le)}),p.signalChannel_.send(xU,M),p.signalChannel_.once(st.JOIN_ROOM_RESULT,function(le){p.clearJoinTimeout();var ce=le.data,Ze=ce.code,Ue=ce.message,Fe=ce.data;p.onPublishedUserList({data:{userList:Fe.publishers}}),Y.emit(Rp,{client:p,code:Ze}),Ze===0?(p.isJoined_=!0,p.log_.info("Join room success, start heartbeat"),p.startHeartbeat(),p.badCaseDetector_&&p.badCaseDetector_.start(),p.syncUserList(),p.startSyncUserListInterval(),_()):(p.log_.error("Join room failed result: "+Ze+" error: "+Ue),P(new te({code:Z.JOIN_ROOM_FAILED,extraCode:Ze,message:ie({key:uS,data:{error:Ue,code:Ze}})})))})})}},{key:"reJoin",value:(T=H(f().mark(function S(){return f().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(this.isJoined_){p.next=3;break}return this.log_.warn("reJoin abort"),p.abrupt("return");case 3:return this.isJoined_=!1,p.prev=4,this.log_.warn("reJoin pending: ".concat(this.joinOptions_.roomId)),this.subscriptionManager_&&this.subscriptionManager_.markAllStream(),this.signalChannel_.close(),p.next=10,this.signalChannel_.connect();case 10:return p.next=12,this.doJoin(J(J({},this.joinOptions_),{},{role:this.role_,privateMapKey:this.privateMapKey_}));case 12:this.log_.warn("reJoin success"),ke.logSuccessEvent({userId:this.userId_,eventType:Ib}),this.checkConnectionsToReconnect(),this.uplinkConnection_&&!this.uplinkConnection_.getIsReconnecting()&&this.uplinkConnection_.startReconnection(),this.mixTranscodeManager_&&this.mixTranscodeManager_.reStartMixTranscode(),p.next=25;break;case 19:p.prev=19,p.t0=p.catch(4),this.log_.warn("reJoin fail "+p.t0),this.reset(),ke.logFailedEvent({userId:this.userId_,eventType:Ib,error:p.t0}),this.emitter_.emit(ct.ERROR,new te({code:Z.JOIN_ROOM_FAILED,message:ie({key:FN,data:{roomId:this.joinOptions_.roomId}})}));case 25:case"end":return p.stop()}},S,this,[[4,19]])})),function(){return T.apply(this,arguments)})},{key:"leave",value:(N=H(f().mark(function S(){var p;return f().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return Y.emit(Ap,{client:this}),vn(this.userId_,{eventId:aV,eventDesc:"leaving room",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),_.prev=2,_.next=5,this.doHeartbeat();case 5:_.next=9;break;case 7:_.prev=7,_.t0=_.catch(2);case 9:this.doLeave(),Y.emit(mo,{client:this}),ke.logSuccessEvent({userId:this.userId_,eventType:tN}),p=Math.floor((Ct()-this.joinedTimestamp_)/1e3),ke.logSuccessEvent({userId:this.userId_,eventType:nN,delta:p});case 14:case"end":return _.stop()}},S,this,[[2,7]])})),function(){return N.apply(this,arguments)})},{key:"doLeave",value:function(){this.isJoined_&&(Y.emit(Pp,{client:this}),this.log_.info("leave() => leaving room"),this.signalChannel_.send(wU),this.reset())}},{key:"clearNetworkQuality",value:function(){this.networkQuality_&&(this.networkQuality_.stop(),this.networkQuality_=null)}},{key:"closeConnections",value:function(){var S=this;this.connections_.forEach(function(p){S.closeDownLink(p.getTinyId())})}},{key:"clearJoinTimeout",value:function(){clearTimeout(this.joinTimeout_),this.joinTimeout_=-1}},{key:"destroy",value:function(){var S,p,_;if(this.isJoined_)throw this.log_.warn(gi.INVALID_DESTROY),new te({code:Z.INVALID_OPERATION,message:ie({key:HN})});this.isDestroyed_||(this.log_.info("destroy client"),this.joinReject_&&(this.joinReject_(new te({code:Z.INVALID_OPERATION,message:ie({key:tp,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.off("*"),(S=this.callDurationCalculator_)===null||S===void 0||S.destroy(),(p=this.keyPointManager_)===null||p===void 0||p.destroy(),(_=this.deviceDetector_)===null||_===void 0||_.destroy(),this.callDurationCalculator_=null,this.keyPointManager_=null,this.deviceDetector_=null,this.badCaseDetector_=null,this.publishCDNManager_=null,this.isDestroyed_=!0,Y.emit(Up,{client:this}))}},{key:"reset",value:function(){this.isJoined_=!1,this.schedule_={domains:null,iceServers:null,iceTransportPolicy:null,trtcCapability:null},this.keyPointManager_&&this.keyPointManager_.prepareReport(),this.mixTranscodeManager_&&(this.mixTranscodeManager_.reset(),this.mixTranscodeManager_=null),this.publishCDNManager_&&this.publishCDNManager_.reset(),this.userMap_.clear(),this.stopSyncUserListInterval(),this.stopHeartbeat(),this.closeConnections(),this.mutedStates_.clear(),this.clearNetworkQuality(),this.badCaseDetector_&&this.callDurationCalculator_&&this.uploadAllCallStats(),this.closeUplink(),this.signalChannel_&&(this.log_.info("destroying SignalChannel"),this.signalChannel_.close(),this.signalChannel_=null),this.stats_.reset()}},{key:"startSyncUserListInterval",value:function(){this.syncUserListInterval_===-1&&(this.syncUserListInterval_=mt.run(uo,this.syncUserList.bind(this)))}},{key:"stopSyncUserListInterval",value:function(){mt.clearTask(this.syncUserListInterval_),this.syncUserListInterval_=-1}},{key:"syncUserList",value:(E=H(f().mark(function S(){var p,_=this;return f().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:return P.prev=0,P.next=3,this.getUserList();case 3:p=P.sent,this.userMap_.size!==0&&this.userMap_.forEach(function(M){p.findIndex(function(B){return B.userId===M.userId})<0&&(_.log_.info("peer leave detected: ".concat(M.userId)),_.cleanUser({userId:M.userId,tinyId:M.tinyId}))}),p.forEach(function(M){var B=M.userId;_.userMap_.has(B)||B===_.userId_||(_.userMap_.set(B,M),_.emitter_.emit(ct.PEER_JOIN,{userId:B}))}),P.next=11;break;case 8:P.prev=8,P.t0=P.catch(0),this.log_.warn("sync user list failed: "+P.t0);case 11:case"end":return P.stop()}},S,this,[[0,8]])})),function(){return E.apply(this,arguments)})},{key:"getUserList",value:function(){return this.signalChannel_?this.signalChannel_.sendWaitForResponse({command:jU,responseCommand:st.USER_LIST_RES,enableLog:!1,timeout:2e3}).then(function(S){var p=S.data,_=p.code,P=p.message;if(_===0)return(p.data&&p.data.userList||[]).map(function(M){var B=M.userId,X=M.srcTinyId,q=M.role;return new Yv({userId:B,tinyId:X,role:q})});throw ie({key:yS,data:{signalResponse:st.USER_LIST_RES,code:_,message:P}})}):[]}},{key:"publish",value:(L=H(f().mark(function S(p){var _,P,M,B,X,q,le,ce,Ze=this,Ue=arguments;return f().wrap(function(Fe){for(;;)switch(Fe.prev=Fe.next){case 0:return _=Ue.length>1&&Ue[1]!==void 0?Ue[1]:{isAuxiliary:!1},p.setPublishState($s),this.isPublishing_=!0,P=Ct(),Y.emit(Lp,{client:this,stream:p}),M=_.isAuxiliary,B=M?gt:Xe,X=p.getScreen(),this.log_.info("publish() => publishing ".concat(X?Of+" ":"").concat(B," stream ").concat(p.getId())),q=this.uplinkConnection_,Fe.prev=10,q||((q=new OF({userId:this.userId_,tinyId:this.tinyId_,client:this,isUplink:!0,signalChannel:this.signalChannel_,enableSEI:this.enableSEI_})).initialize(),q.on(et.ERROR,function(ht){var ze=ht.getCode();ze!==Z.ICE_TRANSPORT_ERROR&&(ze===Z.UPLINK_RECONNECTION_FAILED&&Ze.closeUplink(),Ze.emitter_.emit(ct.ERROR,ht))})),p.setConnection(q),Fe.next=15,q.publish(p,M);case 15:this.log_.info("local ".concat(X?Of+" ":"").concat(B," stream is published")),this.isPublishing_=!1,M?this.localAuxStream_=p:(this.localStream_=p,this.deviceDetector_&&this.deviceDetector_.setLocalStream(this.localStream_),this.localStream_.getBeautyStatus()&&this.log_.info("beauty stream is published successfully")),p.setPublishState(iN),p.setClient(this,M),this.uplinkConnection_=q,le=Ct(),ce=le-P,ke.logSuccessEvent({userId:this.userId_,eventType:xb}),ke.logSuccessEvent({userId:this.userId_,eventType:rN,delta:ce}),p.hasAudio()&&vn(this.userId_,{eventId:yk,eventDesc:"publish audio track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),p.hasVideo()&&vn(this.userId_,{eventId:_k,eventDesc:"publish video track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),this.networkQuality_&&this.networkQuality_.setUplinkConnection(this.uplinkConnection_),Y.emit(N4,{localStream:p,isAuxiliary:M,client:this}),this.notPublishWithoutH264Supported_=!1,p.isAIDenoiser&&Ai.handleFunctionState({fnName:"AI_DENOISER"}),Fe.next=42;break;case 33:throw Fe.prev=33,Fe.t0=Fe.catch(10),Fe.t0 instanceof te&&Fe.t0.getCode()===Z.NOT_SUPPORTED_H264&&(this.notPublishWithoutH264Supported_=!0),p.setPublishState(Wb),q.close(),this.log_.error("failed to publish stream "+Fe.t0),this.isPublishing_=!1,ke.logFailedEvent({userId:this.userId_,eventType:xb,error:Fe.t0}),Fe.t0;case 42:case"end":return Fe.stop()}},S,this,[[10,33]])})),function(S){return L.apply(this,arguments)})},{key:"unpublish",value:(w=H(f().mark(function S(p){var _,P;return f().wrap(function(M){for(;;)switch(M.prev=M.next){case 0:if(this.uplinkConnection_){M.next=2;break}return M.abrupt("return");case 2:return _=p===this.localAuxStream_,P=p.getScreen(),this.log_.info("unpublish() => unpublishing local ".concat(P?Of+" ":"").concat(_?gt:Xe," stream")),M.prev=5,M.next=8,this.uplinkConnection_.unpublish(p);case 8:ke.logSuccessEvent({userId:this.userId_,eventType:wb}),M.next=15;break;case 11:M.prev=11,M.t0=M.catch(5),this.log_.warn("unpublish error ".concat(M.t0)),ke.logFailedEvent({userId:this.userId_,eventType:wb,error:M.t0});case 15:p.setClient(null),p.setConnection(null),_?this.localAuxStream_=null:(this.localStream_=null,p.hasAudio()&&vn(this.userId_,{eventId:Sk,eventDesc:"unpublish audio track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_}),p.hasVideo()&&vn(this.userId_,{eventId:bk,eventDesc:"unpublish video track",timestamp:an(),userId:this.userId_,tinyId:this.tinyId_})),this.localStream_||this.localAuxStream_||this.closeUplink();case 19:case"end":return M.stop()}},S,this,[[5,11]])})),function(S){return w.apply(this,arguments)})},{key:"closeUplink",value:function(){this.uplinkConnection_&&(this.uplinkConnection_.close(),this.uplinkConnection_=null,this.networkQuality_&&this.networkQuality_.setUplinkConnection(null),this.localStream_&&(this.localStream_.setClient(null),this.localStream_.setConnection(null),this.localStream_=null),this.localAuxStream_&&(this.localAuxStream_.setClient(null),this.localAuxStream_.setConnection(null),this.localAuxStream_=null),this.deviceDetector_&&this.deviceDetector_.setLocalStream(null))}},{key:"closeDownLink",value:function(S){var p=this.connections_.get(S);p&&(p.getIsReconnecting()&&p.stopReconnection(),this.subscriptionManager_&&this.subscriptionManager_.delete(p.getUserId()),p.close(),this.connections_.delete(S),this.mutedStates_.delete(S))}},{key:"subscribe",value:(v=H(f().mark(function S(p,_){var P,M,B;return f().wrap(function(X){for(;;)switch(X.prev=X.next){case 0:return this.log_.info("subscribe() => subscribe to [".concat(p.getUserId(),"] ").concat(p.getType()," stream with options: ").concat(JSON.stringify(_))),ge(_)&&(_={audio:!0,video:!0}),ge(_.audio)&&(_.audio=!0),ge(_.smallVideo)?ge(_.video)&&(_.video=!0):_.smallVideo?ge(_.video)?(_.video=!1,_.smallVideo=!0):_.video&&(_.video=!0,delete _.smallVideo,this.log_.warn("options.video and options.smallVideo can't be both true")):ge(_.video)&&(_.video=!0,delete _.smallVideo),_.video&&this.changeBigSmallRecords_.delete(p.getUserId()),P=p.getConnection(),_.smallVideo&&(P.getTrackState().smallVideo||(this.setRemoteVideoStreamType(p,"small"),_.video=!0,delete _.smallVideo)),X.prev=7,Y.emit(jp,{client:this,stream:p}),X.next=11,P.subscribe(p,_);case 11:this.subscriptionManager_&&this.subscriptionManager_.addSubscriptionRecord(p.getUserId(),p,_),this.notSubscribeWithoutH264Supported_=!1,ke.logSuccessEvent({userId:this.userId_,eventType:Cb}),P.checkTrackEnded(),X.next=25;break;case 17:throw X.prev=17,X.t0=X.catch(7),(M=X.t0 instanceof te?X.t0.getCode():Z.UNKNOWN)===Z.NOT_SUPPORTED_H264&&(this.notSubscribeWithoutH264Supported_=!0),(B=new te(M===Z.REMOTE_STREAM_NOT_EXIST?{code:Z.API_CALL_ABORTED,message:ie({key:ip,data:{message:X.t0.message,stream:p}})}:{code:M,message:ie({key:KN,data:{message:X.t0.message,stream:p}})})).getCode()===Z.API_CALL_ABORTED?this.log_.warn(B):this.log_.error(B),ke.logFailedEvent({userId:this.userId_,eventType:Cb,error:B}),B;case 25:case"end":return X.stop()}},S,this,[[7,17]])})),function(S,p){return v.apply(this,arguments)})},{key:"unsubscribe",value:(k=H(f().mark(function S(p){var _;return f().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:return this.log_.info("unsubscribe() => unsubscribe to [".concat(p.getUserId(),"] ").concat(p.getType()," stream")),P.prev=1,_=p.getConnection(),P.next=5,_.unsubscribe(p);case 5:this.subscriptionManager_&&this.subscriptionManager_.addUnsubscriptionRecord(p.getUserId(),p),Y.emit(Vr,{client:this,stream:p}),ke.logSuccessEvent({userId:this.userId_,eventType:Eb}),P.next=14;break;case 10:throw P.prev=10,P.t0=P.catch(1),ke.logFailedEvent({userId:this.userId_,eventType:Eb,error:P.t0}),P.t0;case 14:case"end":return P.stop()}},S,this,[[1,10]])})),function(S){return k.apply(this,arguments)})},{key:"switchRole",value:(m=H(f().mark(function S(p){return f().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(this.role_!==p){_.next=2;break}return _.abrupt("return");case 2:return p===Zi&&this.uplinkConnection_&&this.closeUplink(),this.log_.info("switchRole() => switch role to: "+p),_.next=6,this.doSwitchRole(p);case 6:case"end":return _.stop()}},S,this)})),function(S){return m.apply(this,arguments)})},{key:"doSwitchRole",value:function(S){var p,_,P=this,M={command:BU,data:{role:S===Tr?so:Vf,privateMapKey:this.privateMapKey_},responseCommand:st.SWITCH_ROLE_RES,retries:((p=this.schedule_.config)===null||p===void 0||(_=p.retries)===null||_===void 0?void 0:_.switchRole)||1};return this.log_.info("switchRole signal data: "+JSON.stringify(M.data)),this.signalChannel_.sendWaitForResponseWithRetry(M).then(function(B){var X=B.data,q=X.code,le=X.message;if(q!==0)throw new te({code:Z.SWITCH_ROLE_FAILED,message:ie({key:$N,data:{errMsg:le,errCode:q}})});P.role_=S}).catch(function(B){throw B instanceof te&&B.getCode()===Z.API_CALL_TIMEOUT&&(B=new te({code:Z.SWITCH_ROLE_FAILED,message:ie({key:YN})})),P.log_.error(B),B})}},{key:"on",value:function(S,p,_){this.emitter_.on(S,p,_)}},{key:"off",value:function(S,p,_){S==="*"?this.emitter_.removeAllListeners():this.emitter_.off(S,p,_)}},{key:"getRemoteMutedState",value:function(){var S=this,p=[];return this.mutedStates_.forEach(function(_,P,M){var B=S.connections_.get(P);B&&p.push(J({userId:B.getUserId()},_))}),p}},{key:"getTransportStats",value:(x=H(f().mark(function S(){var p,_,P,M,B,X,q;return f().wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(p={rtt:0,downlinksRTT:{}},!this.uplinkConnection_){le.next=6;break}return le.next=4,this.stats_.getSenderStats(this.uplinkConnection_);case 4:_=le.sent,p.rtt=_.rtt;case 6:P=ae(this.connections_),le.prev=7,P.s();case 9:if((M=P.n()).done){le.next=17;break}return(B=Te(M.value,2))[0],X=B[1],le.next=13,this.stats_.getReceiverStats(X);case 13:q=le.sent,p.downlinksRTT[q.userId]=q.rtt;case 15:le.next=9;break;case 17:le.next=22;break;case 19:le.prev=19,le.t0=le.catch(7),P.e(le.t0);case 22:return le.prev=22,P.f(),le.finish(22);case 25:return le.abrupt("return",p);case 26:case"end":return le.stop()}},S,this,[[7,19,22,25]])})),function(){return x.apply(this,arguments)})},{key:"getLocalAudioStats",value:(R=H(f().mark(function S(){var p,_;return f().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if((p={})[this.userId_]={bytesSent:0,packetsSent:0},!this.uplinkConnection_){P.next=7;break}return P.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:_=P.sent,p[this.userId_]={bytesSent:_.audio.bytesSent,packetsSent:_.audio.packetsSent};case 7:return P.abrupt("return",p);case 8:case"end":return P.stop()}},S,this)})),function(){return R.apply(this,arguments)})},{key:"getLocalVideoStats",value:(I=H(f().mark(function S(){var p,_;return f().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if((p={})[this.userId_]={bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0},!this.uplinkConnection_){P.next=7;break}return P.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:_=P.sent,p[this.userId_]={bytesSent:_.video.bytesSent,packetsSent:_.video.packetsSent,framesEncoded:_.video.framesEncoded,framesSent:_.video.framesSent,frameWidth:_.video.frameWidth,frameHeight:_.video.frameHeight};case 7:return P.abrupt("return",p);case 8:case"end":return P.stop()}},S,this)})),function(){return I.apply(this,arguments)})},{key:"getRemoteAudioStats",value:(b=H(f().mark(function S(){var p,_,P,M,B,X,q,le;return f().wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:p={},_=ae(this.connections_),ce.prev=2,_.s();case 4:if((P=_.n()).done){ce.next=13;break}return(M=Te(P.value,2))[0],B=M[1],X=B.getDelay(),q=X.audioDelay,ce.next=9,this.stats_.getReceiverStats(B);case 9:(le=ce.sent).hasAudio&&(p[le.userId]={bytesReceived:le.audio.bytesReceived,packetsReceived:le.audio.packetsReceived,packetsLost:le.audio.packetsLost,end2EndDelay:q});case 11:ce.next=4;break;case 13:ce.next=18;break;case 15:ce.prev=15,ce.t0=ce.catch(2),_.e(ce.t0);case 18:return ce.prev=18,_.f(),ce.finish(18);case 21:return ce.abrupt("return",p);case 22:case"end":return ce.stop()}},S,this,[[2,15,18,21]])})),function(){return b.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(h=H(f().mark(function S(){var p,_,P,M,B,X,q,le,ce,Ze=arguments;return f().wrap(function(Ue){for(;;)switch(Ue.prev=Ue.next){case 0:p=Ze.length>0&&Ze[0]!==void 0?Ze[0]:yt,_={},P=ae(this.connections_),Ue.prev=3,P.s();case 5:if((M=P.n()).done){Ue.next=15;break}return(B=Te(M.value,2))[0],X=B[1],Ue.next=9,this.stats_.getReceiverStats(X);case 9:q=Ue.sent,le=X.getDelay(),ce=le.videoDelay,p===yt&&q.hasVideo&&(_[q.userId]={bytesReceived:q.video.bytesReceived,packetsReceived:q.video.packetsReceived,packetsLost:q.video.packetsLost,framesDecoded:q.video.framesDecoded,frameWidth:q.video.frameWidth,frameHeight:q.video.frameHeight,end2EndDelay:ce}),p===Dt&&q.hasAuxiliary&&(_[q.userId]={bytesReceived:q.auxiliary.bytesReceived,packetsReceived:q.auxiliary.packetsReceived,packetsLost:q.auxiliary.packetsLost,framesDecoded:q.auxiliary.framesDecoded,frameWidth:q.auxiliary.frameWidth,frameHeight:q.auxiliary.frameHeight,end2EndDelay:ce});case 13:Ue.next=5;break;case 15:Ue.next=20;break;case 17:Ue.prev=17,Ue.t0=Ue.catch(3),P.e(Ue.t0);case 20:return Ue.prev=20,P.f(),Ue.finish(20);case 23:return Ue.abrupt("return",_);case 24:case"end":return Ue.stop()}},S,this,[[3,17,20,23]])})),function(){return h.apply(this,arguments)})},{key:"getSdpSemantics",value:function(){return this.sdpSemantics_}},{key:"getIceServers",value:function(){return this.turnServers_.length===0&&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(){this.heartbeat_===-1&&(this.log_.info("startHeartbeat..."),this.heartbeat_=mt.run(uo,this.doHeartbeat.bind(this),{delay:2e3}))}},{key:"stopHeartbeat",value:function(){this.heartbeat_!==-1&&(this.log_.info("stopHeartbeat"),mt.clearTask(this.heartbeat_),this.heartbeat_=-1,this.lastHeartBeatTime_=-1)}},{key:"doHeartbeat",value:(u=H(f().mark(function S(){var p,_,P,M,B,X;return f().wrap(function(q){for(;;)switch(q.prev=q.next){case 0:return _=this.badCaseDetector_.getMonitorFreeze(),q.next=3,this.stats_.getStatsReport({uplinkConnection:this.uplinkConnection_,downlinkConnections:this.connections_,freezeMap:_});case 3:if(P=q.sent,Y.emit(Dp,{client:this,stats:P}),(p=this.badCaseDetector_)===null||p===void 0||p.resetMonitor(),this.signalChannel_){q.next=8;break}return q.abrupt("return");case 8:M=this.signalChannel_.isConnected()?SV(this.userId_):[],B=J(J({str_sdk_version:this.version_,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:qf[this.networkType_]}},P),{},{msg_event_msg:M}),this.signalChannel_.send(CU,B),X=Date.now(),this.lastHeartBeatTime_>0&&X-this.lastHeartBeatTime_>1e4&&this.log_.warn("heartbeat took ".concat(X-this.lastHeartBeatTime_)),this.lastHeartBeatTime_=X,!this.isRelayChanged_&&this.isRelayMaybeFailed()&&(this.reJoin(),this.isRelayChanged_=!0);case 15:case"end":return q.stop()}},S,this)})),function(){return u.apply(this,arguments)})},{key:"onRemoteStreamAdded",value:function(S){var p=S.content,_=p.userId,P=p.tinyId,M=p.audio,B=p.bigVideo,X=p.auxVideo,q=p.smallVideo;if(_!==null){this.userMap_.has(_)||(this.userMap_.set(_,new Yv({userId:_,tinyId:P,role:Tr})),this.emitter_.emit(ct.PEER_JOIN,{userId:_}));var le=this.connections_.get(P);if(le){if(le.getIsReconnecting())return;this.log_.warn("duplicated stream-added observed, rebuild the connection"),le.close(),this.connections_.delete(P)}var ce={audio:M,video:B,auxiliary:X,smallVideo:q};this.log_.info("remote peer [".concat(_,"] published stream. trackState: ").concat(JSON.stringify(ce))),this.createDownlinkConnection({userId:_,tinyId:P,trackState:ce})}else this.log_.warn("received null userId on stream added")}},{key:"createDownlinkConnection",value:function(S){var p=this,_=S.userId,P=S.tinyId,M=S.trackState,B=new n7({userId:_,tinyId:P,client:this,isUplink:!1,signalChannel:this.signalChannel_,autoSubscribe:this.autoSubscribe_,trackState:M,enableSEI:this.enableSEI_});this.connections_.set(P,B),this.installDownlinkEvents(B,_,P),this.autoSubscribe_?(B.initialize(),B.connect().catch(function(){!B.getMainStream()&&B.hasMainStream()&&p.initRemoteStream({type:yt,userId:_,downlinkConnection:B}),!B.getAuxStream()&&B.hasAuxStream()&&p.initRemoteStream({type:Dt,userId:_,downlinkConnection:B})})):(B.hasMainStream()&&this.initRemoteStream({type:yt,userId:_,downlinkConnection:B}),B.hasAuxStream()&&this.initRemoteStream({type:Dt,userId:_,downlinkConnection:B}))}},{key:"initRemoteStream",value:function(S){var p=S.type,_=S.userId,P=S.downlinkConnection,M=new Gv({type:p,userId:_,client:this});M.setConnection(P),P.setRemoteStream(p===yt?Ir:Xs,M),M.setIsStreamAddedEventEmitted(!0),Y.emit(dl,{client:this,stream:M}),this.emitter_.emit(ct.STREAM_ADDED,{stream:M})}},{key:"installDownlinkEvents",value:function(S,p,_){var P=this;S.on(et.SEI_MESSAGE,function(M){P.emitter_.emit(ct.SEI_MESSAGE,M)}),S.on(et.STREAM_ADDED,function(M){M.stream.setIsStreamAddedEventEmitted(!0),Y.emit(dl,{client:P,stream:M.stream}),P.emitter_.emit(ct.STREAM_ADDED,{stream:M.stream})}),S.on(et.STREAM_REMOVED,function(M){P.changeBigSmallRecords_.delete(M.stream.getUserId()),M.stream.stop(),M.stream.setIsStreamAddedEventEmitted(!1),P.subscriptionManager_&&P.subscriptionManager_.deleteAutoRecoveryFlag(M.stream.getUserId(),M.stream.getType()),Y.emit(ca,{client:P,stream:M.stream}),P.emitter_.emit(ct.STREAM_REMOVED,{stream:M.stream})}),S.on(et.STREAM_UPDATED,function(M){Y.emit(M4,{client:P,stream:M.stream});var B=S.getMixUserList();B&&(M.mixUserList=B),P.emitter_.emit(ct.STREAM_UPDATED,M)}),S.on(et.STREAM_SUBSCRIBED,function(M){Y.emit(Ur,{client:P,stream:M.stream}),P.emitter_.emit(ct.STREAM_SUBSCRIBED,{stream:M.stream})}),S.on(et.ERROR,function(M){var B=M.getCode();B!==Z.ICE_TRANSPORT_ERROR&&(B===Z.DOWNLINK_RECONNECTION_FAILED&&P.closeDownLink(_),P.emitter_.emit(ct.ERROR,M))})}},{key:"onPeerJoin",value:function(S){var p=S.data.data,_=p.srcTinyId,P=p.userId,M=p.role;this.userMap_.has(P)||(this.userMap_.set(P,new Yv({userId:P,tinyId:_,role:M})),this.emitter_.emit(ct.PEER_JOIN,{userId:P}))}},{key:"onPeerLeave",value:function(S){var p=S.data.data,_=p.srcTinyId,P=p.userId,M=p.reason,B=M===void 0?0:M;this.log_.info("peer leave [".concat(P,"]: ").concat(hN[B])),this.cleanUser({userId:P,tinyId:_})}},{key:"cleanUser",value:function(S){var p=S.userId,_=S.tinyId;this.userMap_.delete(p),this.closeDownLink(_),this.emitter_.emit(ct.PEER_LEAVE,{userId:p})}},{key:"onPublishedUserList",value:function(S){var p=this;try{var _=Se(S.data.userList);S.data.mixRobotList&&_.push.apply(_,Se(S.data.mixRobotList)),S.data.fakeMixUser&&_.push(S.data.fakeMixUser);var P=_.map(function(M){return M.userId});this.connections_.forEach(function(M){var B=M.getUserId(),X=M.getTinyId();P.findIndex(function(q){return q===B})<0&&(p.log_.info("peer unpublished detected [".concat(B,"]")),p.closeDownLink(X))}),_.forEach(function(M){var B=M.userId,X=M.srcTinyId,q=M.flag,le=M.mixUserList;if(B!==p.userId_){var ce=!!(1&q),Ze=!!(8&q),Ue=!!(4&q),Fe=!!(2&q),ht=p.connections_.get(X);if((Fe||ce)&&p.checkSubscribeBigSmallVideo(ht,Fe),ht){var ze=ht.getTrackState(),Cc=ze.audio,hd=ze.video,Ec=ze.auxiliary,Qx=ze.smallVideo;ho(le)&&ht.setMixUserList(le),!hd&&ce&&Y.emit(jn,{client:p,tinyId:X,userId:B,action:cn.ADD,kind:Ie}),!Cc&&Ze&&Y.emit(jn,{client:p,tinyId:X,userId:B,action:cn.ADD,kind:Re}),!Ec&&Ue&&Y.emit(jn,{client:p,tinyId:X,userId:B,action:cn.ADD,kind:gt}),!Qx&&Fe&&Y.emit(jn,{client:p,tinyId:X,userId:B,action:cn.ADD,kind:Fu}),hd&&!ce&&Y.emit(jn,{client:p,tinyId:X,userId:B,action:cn.REMOVE,kind:Ie}),Cc&&!Ze&&Y.emit(jn,{client:p,tinyId:X,userId:B,action:cn.REMOVE,kind:Re}),Ec&&!Ue&&Y.emit(jn,{client:p,tinyId:X,userId:B,action:cn.REMOVE,kind:gt}),Qx&&!Fe&&Y.emit(jn,{client:p,tinyId:X,userId:B,action:cn.REMOVE,kind:Fu})}else p.log_.info("peer published detected [".concat(B,"]")),p.onRemoteStreamAdded({content:{audio:Ze,bigVideo:ce,auxVideo:Ue,smallVideo:Fe,userId:B,tinyId:X}})}})}catch(M){}}},{key:"onUpdateRemoteMuteStat",value:function(S){var p=this,_=S.data;(_&&_.userList||[]).forEach(function(P){var M=P.srcTinyId,B=P.userId;if(M!==0&&M!==p.tinyId_){var X=p.connections_.get(M);if(X){var q=X.getMainStream();if(q&&q.getIsStreamAddedEventEmitted()){var le=!!(1&P.flag),ce=!!(8&P.flag),Ze=!!(2&P.flag),Ue=!!(64&P.flag),Fe=!!(16&P.flag),ht=p.mutedStates_.get(M);if(ht===void 0)return p.mutedStates_.set(M,{hasAudio:ce,hasVideo:le,hasSmall:Ze,audioMuted:Ue,videoMuted:Fe}),le?Fe?p.emitter_.emit(ct.MUTE_VIDEO,{userId:B}):p.emitter_.emit(ct.UNMUTE_VIDEO,{userId:B}):p.emitter_.emit(ct.MUTE_VIDEO,{userId:B}),void(ce?Ue?p.emitter_.emit(ct.MUTE_AUDIO,{userId:B}):p.emitter_.emit(ct.UNMUTE_AUDIO,{userId:B}):p.emitter_.emit(ct.MUTE_AUDIO,{userId:B}));var ze=!ht.audioMuted&&ht.hasAudio,Cc=!Ue&&ce,hd=!ht.videoMuted&&ht.hasVideo,Ec=!Fe&&le;p.mutedStates_.set(M,{hasAudio:ce,hasVideo:le,hasSmall:Ze,audioMuted:Ue,videoMuted:Fe}),ze!==Cc&&(Cc?p.emitter_.emit(ct.UNMUTE_AUDIO,{userId:B}):p.emitter_.emit(ct.MUTE_AUDIO,{userId:B})),hd!==Ec&&(Ec?p.emitter_.emit(ct.UNMUTE_VIDEO,{userId:B}):p.emitter_.emit(ct.MUTE_VIDEO,{userId:B}))}}else p.mutedStates_.delete(M)}})}},{key:"getEnv",value:function(){return this.env_}},{key:"getSubscriptionManager",value:function(){return this.subscriptionManager_}},{key:"startPublishCDNStream",value:(l=H(f().mark(function S(){var p,_=arguments;return f().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(p=_.length>0&&_[0]!==void 0?_[0]:{},this.log_.info("startPublishCDNStream with params: ".concat(JSON.stringify(p),"; isJoined: ").concat(this.isJoined_,"; hasMainStream: ").concat(!!this.localStream_,"; hasAuxStream: ").concat(!!this.localAuxStream_,";")),p.streamType=p.streamType||Xe,p.streamType===gt&&(p.streamType=Nn),p.streamId=p.streamId||"",!this.isJoined_){P.next=10;break}if(p.streamType!==Xe||this.localStream_){P.next=8;break}throw new te({code:Z.INVALID_OPERATION,message:ie({key:lS})});case 8:if(p.streamType!==Nn||this.localAuxStream_){P.next=10;break}throw new te({code:Z.INVALID_OPERATION,message:ie({key:lS})});case 10:return P.next=12,this.publishCDNManager_.startPublishTencentCDN(p);case 12:if(!(p.appId&&p.bizId&&p.url)){P.next=15;break}return P.next=15,this.publishCDNManager_.startPublishGivenCDN(p);case 15:case"end":return P.stop()}},S,this)})),function(){return l.apply(this,arguments)})},{key:"stopPublishCDNStream",value:(s=H(f().mark(function S(){return f().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(this.publishCDNManager_.getIsPublishingTencentCDN()){p.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ie({key:e3})});case 2:return this.log_.info("stopPublishCDNStream"),p.next=5,this.publishCDNManager_.stopPublishTencentCDN();case 5:if(!this.publishCDNManager_.getIsPublishingGivenCDN()){p.next=8;break}return p.next=8,this.publishCDNManager_.stopPublishGivenCDN();case 8:case"end":return p.stop()}},S,this)})),function(){return s.apply(this,arguments)})},{key:"startMixTranscode",value:(a=H(f().mark(function S(p){return f().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){_.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ie({key:n3})});case 2:return ge(p.mode)&&(p.mode=Jf.MANUAL),_.prev=3,this.log_.info("startMixTranscode with config ".concat(JSON.stringify(p))),ke.uploadEvent({log:"mix-transcode-mode:".concat(p.mode),userId:this.userId_}),_.next=8,this.mixTranscodeManager_.startMixTranscode(p);case 8:ke.logSuccessEvent({userId:this.userId_,eventType:Vb}),_.next=15;break;case 11:throw _.prev=11,_.t0=_.catch(3),ke.logFailedEvent({userId:this.userId_,eventType:Vb,error:_.t0}),_.t0;case 15:case"end":return _.stop()}},S,this,[[3,11]])})),function(S){return a.apply(this,arguments)})},{key:"stopMixTranscode",value:(c=H(f().mark(function S(){return f().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){p.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ie({key:r3})});case 2:return p.prev=2,p.next=5,this.mixTranscodeManager_.stopMixTranscode();case 5:ke.logSuccessEvent({userId:this.userId_,eventType:jb}),p.next=12;break;case 8:throw p.prev=8,p.t0=p.catch(2),ke.logFailedEvent({userId:this.userId_,eventType:jb,error:p.t0}),p.t0;case 12:case"end":return p.stop()}},S,this,[[2,8]])})),function(){return c.apply(this,arguments)})},{key:"getSystemResult",value:function(){return this.checkSystemResult_}},{key:"enableAudioVolumeEvaluation",value:function(){var S=this,p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:2e3,_=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!tr(p))throw new te({code:Z.INVALID_PARAMETER,message:ie({key:i3})});if(this.log_.info("enableAudioVolumeEvaluation with interval: "+p),p<=0)return this.enableAudioVolumeEvaluation_=!1,mt.clearTask(this.audioVolumeIntervalId_),void(this.audioVolumeIntervalId_=null);p=Math.floor(Math.max(p,16)),Y.emit(Np,{interval:p}),this.audioVolumeIntervalId_&&(mt.clearTask(this.audioVolumeIntervalId_),this.audioVolumeIntervalId_=null),this.enableAudioVolumeEvaluation_=!0,this.audioVolumeIntervalId_=mt.run(Qu,function(){var P=[];if(S.localStream_){var M=Math.floor(100*S.localStream_.getAudioLevel());P.push({userId:S.userId_,audioVolume:M,stream:S.localStream_})}S.connections_.forEach(function(B){var X=B.getSubscribedMainStream();if(X){var q=Math.floor(100*X.getAudioLevel());P.push({userId:B.getUserId(),audioVolume:q,stream:X})}}),S.emitter_.emit(ct.AUDIO_VOLUME,{result:P})},{fps:1e3/p,backgroundTask:_})}},{key:"callExperimentalAPI",value:function(S,p){return this.log_.info("callExperimentalAPI(".concat(S,", ").concat(JSON.stringify(p),")")),c7.call(S,J({client:this},p))}},{key:"setProperty",value:function(S,p){var _="".concat(S,"_");ge(this[_])||(this[_]=p)}},{key:"uploadAllCallStats",value:function(){var S=this;this.callDurationCalculator_.getDurationMap().forEach(function(p,_){var P={userId:p.userId,type:p.type,duration:S.callDurationCalculator_.getDuration(_,Ie),dataFreeze:S.badCaseDetector_.getDataFreezeDuration(_).dataFreeze,renderFreeze:S.badCaseDetector_.getRenderFreezeDuration(_).renderFreeze};ke.uploadEvent({log:"callStats-"+JSON.stringify(P),userId:S.userId_})}),this.badCaseDetector_.stop(),this.callDurationCalculator_.reset()}},{key:"enableSmallStream",value:(o=H(f().mark(function S(){return f().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(!this.isPublished()&&!this.isPublishing_){p.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ie({key:a3})});case 2:if(!zk()){p.next=7;break}this.setIsEnableSmallStream(!0),this.log_.info("SmallStream successfully enabled"),p.next=8;break;case 7:throw new te({code:Z.INVALID_OPERATION,message:ie({key:s3})});case 8:case"end":return p.stop()}},S,this)})),function(){return o.apply(this,arguments)})},{key:"disableSmallStream",value:(r=H(f().mark(function S(){return f().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(!this.isPublished()&&!this.isPublishing_){p.next=2;break}throw new te({code:Z.INVALID_OPERATION,message:ie({key:o3})});case 2:this.setIsEnableSmallStream(!1),this.log_.info("SmallStream successfully disabled");case 4:case"end":return p.stop()}},S,this)})),function(){return r.apply(this,arguments)})},{key:"setSmallStreamProfile",value:function(S){var p=this;S&&S.framerate&&(S.frameRate=S.framerate),S.width*S.height>307200&&(S.width=320,S.height=240,this.log_.info("Small stream resolution is beyond limitation, which is invalid. Reset to 320 * 240")),Object.keys(this.smallStreamConfig_).forEach(function(q){S[q]&&(p.smallStreamConfig_[q]=S[q])});var _=this.smallStreamConfig_,P=_.width,M=_.height,B=_.bitrate,X=_.frameRate;if(this.log_.info("setSmallStreamProfile: bitrate=".concat(B,", frameRate=").concat(X,", height=").concat(M,", width=").concat(P)),P<0||M<0||B<0||X<0)throw new te({code:Z.INVALID_PARAMETER,message:ie({key:c3})})}},{key:"setRemoteVideoStreamType",value:(i=H(f().mark(function S(p,_){return f().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(p instanceof Gv){P.next=2;break}throw new te({code:Z.INVALID_PARAMETER,message:ie({key:u3})});case 2:if(p.getConnection()){P.next=4;break}throw new te({code:Z.INVALID_OPERATION,message:ie({key:ep})});case 4:if(p.getType()!==Dt){P.next=6;break}return P.abrupt("return");case 6:P.t0=_,P.next=P.t0===Jb||P.t0===qb?9:12;break;case 9:return P.next=11,this.changeVideoType(p,_);case 11:case 12:return P.abrupt("break",13);case 13:case"end":return P.stop()}},S,this)})),function(S,p){return i.apply(this,arguments)})},{key:"changeVideoType",value:(n=H(f().mark(function S(p,_){var P,M;return f().wrap(function(B){for(;;)switch(B.prev=B.next){case 0:P=p.getUserId(),M={stream:p,options:{video:_===Jb,smallVideo:_===qb},isSubscribing:!1,reSubscribeCount:10},this.changeBigSmallRecords_.set(P,M),this.log_.info("set [".concat(P,"] ").concat(p.getType()," stream video prefer type: ").concat(_));case 5:case"end":return B.stop()}},S,this)})),function(S,p){return n.apply(this,arguments)})},{key:"checkSubscribeBigSmallVideo",value:(t=H(f().mark(function S(p,_){var P,M,B,X,q,le,ce,Ze,Ue,Fe,ht;return f().wrap(function(ze){for(;;)switch(ze.prev=ze.next){case 0:if(p!=null&&p.isBigStreamSubscribed||p!=null&&p.isSmallStreamSubscribed){ze.next=2;break}return ze.abrupt("return");case 2:if(P=p.getUserId(),this.changeBigSmallRecords_.has(P)){ze.next=5;break}return ze.abrupt("return");case 5:if(M=this.changeBigSmallRecords_.get(P),B=p.getSubscribeState(),X=B.video,q=B.smallVideo,le=M.stream,ce=M.options,Ze=M.isSubscribing,Ue=M.reSubscribeCount,!(ce.video&&X||ce.smallVideo&&q&&_)){ze.next=10;break}return ze.abrupt("return");case 10:if(Fe={video:ce.video,smallVideo:ce.smallVideo},!(_&&p.isBigStreamSubscribed||p.isSmallStreamSubscribed)){ze.next=31;break}if(ze.prev=12,!(ce&&le&&!Ze&&Ue>=1)){ze.next=24;break}return M.isSubscribing=!0,M.reSubscribeCount=Ue-1,ht=le.getConnection(),!_&&ht.isSmallStreamSubscribed&&(Fe={video:!0,smallVideo:!1}),Fe.emitEvent=!1,ze.next=21,ht==null?void 0:ht.subscribe(le,Fe);case 21:this.log_.info("change [".concat(P,"] to ").concat(Fe.smallVideo?"small":"big"," video successfully. count ").concat(10-M.reSubscribeCount,".")),M.isSubscribing=!1,M.reSubscribeCount=10;case 24:ze.next=31;break;case 26:ze.prev=26,ze.t0=ze.catch(12),this.log_.info("change [".concat(P,"] to ").concat(Fe.smallVideo?"small":"big"," video failed. count ").concat(10-M.reSubscribeCount,".")),M.isSubscribing=!1,Ue===0&&this.changeBigSmallRecords_.delete(P);case 31:case"end":return ze.stop()}},S,this,[[12,26]])})),function(S,p){return t.apply(this,arguments)})},{key:"setIsEnableSmallStream",value:function(S){this.isEnableSmallStream_=S}},{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 S=Se(this.connections_.values());return this.uplinkConnection_&&S.push(this.uplinkConnection_),S}},{key:"isRelayMaybeFailed",value:function(){if(!this.signalChannel_.isOnline)return!1;var S=this.getAllConnections();if(S.length===0)return!1;for(var p=0;p<S.length;p++)if(S[p].getReconnectionCount()<6)return!1;return!0}},{key:"getUseStringRoomId",value:function(){return this.useStringRoomId_}},{key:"checkConnectionsToReconnect",value:function(){var S=this;this.getAllConnections().forEach(function(p){if(!p.getIsReconnecting()){var _=p.getPeerConnection();_&&_.connectionState===Bf&&(S.log_.warn("[".concat(p.getUserId(),"] pc is closed but not reconnect")),p.startReconnection())}})}},{key:"getEnableAutoPlayDialog",value:function(){return this.enableAutoPlayDialog_}},{key:"sendSEIMessage",value:function(S,p){this.uplinkConnection_.sendSEI(S,p)}},{key:"setProxyServer",value:function(S){if(this.log_.info("set proxy server: ".concat(JSON.stringify(S))),Bt(S)){if(!S.startsWith("wss://"))throw new te({code:Z.INVALID_PARAMETER,message:ie({key:NN})});this.proxy_=S}else if(bi(S)){var p=S.websocketProxy,_=S.loggerProxy,P=S.scheduleProxy,M=S.unifiedProxy;p&&(this.proxy_=p),_&&Uf(_),P&&Xb(P),M&&(this.unifiedProxy_=M,Uf("https://".concat(M)),Xb(M))}}},{key:"setTurnServer",value:function(S){this.log_.info("set turn server: "+JSON.stringify(S));var p=[];Array.isArray(S)?S.forEach(function(_){return p.push(jS(_))}):bi(S)&&p.push(jS(S)),this.turnServers_=p}},{key:"get2k4kFlag",value:function(){var S,p;return((S=this.schedule_)===null||S===void 0||(p=S.trtcCapability)===null||p===void 0?void 0:p["2k4k"])||2}},{key:"getWSProxy",value:function(){return this.proxy_}},{key:"getUnifiedProxy",value:function(){return this.unifiedProxy_}}]),e}(),K(Pe.prototype,"join",[fx,px,mx],Object.getOwnPropertyDescriptor(Pe.prototype,"join"),Pe.prototype),K(Pe.prototype,"leave",[vx],Object.getOwnPropertyDescriptor(Pe.prototype,"leave"),Pe.prototype),K(Pe.prototype,"getUserList",[gx],Object.getOwnPropertyDescriptor(Pe.prototype,"getUserList"),Pe.prototype),K(Pe.prototype,"publish",[_x,yx,bx],Object.getOwnPropertyDescriptor(Pe.prototype,"publish"),Pe.prototype),K(Pe.prototype,"unpublish",[Sx,kx],Object.getOwnPropertyDescriptor(Pe.prototype,"unpublish"),Pe.prototype),K(Pe.prototype,"subscribe",[Tx],Object.getOwnPropertyDescriptor(Pe.prototype,"subscribe"),Pe.prototype),K(Pe.prototype,"unsubscribe",[Ix],Object.getOwnPropertyDescriptor(Pe.prototype,"unsubscribe"),Pe.prototype),K(Pe.prototype,"switchRole",[xx,wx,Cx],Object.getOwnPropertyDescriptor(Pe.prototype,"switchRole"),Pe.prototype),K(Pe.prototype,"startPublishCDNStream",[Ex,Rx],Object.getOwnPropertyDescriptor(Pe.prototype,"startPublishCDNStream"),Pe.prototype),K(Pe.prototype,"stopPublishCDNStream",[Ax],Object.getOwnPropertyDescriptor(Pe.prototype,"stopPublishCDNStream"),Pe.prototype),K(Pe.prototype,"startMixTranscode",[Px,Dx],Object.getOwnPropertyDescriptor(Pe.prototype,"startMixTranscode"),Pe.prototype),K(Pe.prototype,"stopMixTranscode",[Ox],Object.getOwnPropertyDescriptor(Pe.prototype,"stopMixTranscode"),Pe.prototype),K(Pe.prototype,"enableAudioVolumeEvaluation",[Lx],Object.getOwnPropertyDescriptor(Pe.prototype,"enableAudioVolumeEvaluation"),Pe.prototype),K(Pe.prototype,"enableSmallStream",[Mx],Object.getOwnPropertyDescriptor(Pe.prototype,"enableSmallStream"),Pe.prototype),K(Pe.prototype,"disableSmallStream",[Nx],Object.getOwnPropertyDescriptor(Pe.prototype,"disableSmallStream"),Pe.prototype),K(Pe.prototype,"setSmallStreamProfile",[Ux],Object.getOwnPropertyDescriptor(Pe.prototype,"setSmallStreamProfile"),Pe.prototype),K(Pe.prototype,"setRemoteVideoStreamType",[Vx],Object.getOwnPropertyDescriptor(Pe.prototype,"setRemoteVideoStreamType"),Pe.prototype),K(Pe.prototype,"sendSEIMessage",[jx,Bx,Fx],Object.getOwnPropertyDescriptor(Pe.prototype,"sendSEIMessage"),Pe.prototype),K(Pe.prototype,"setProxyServer",[Hx],Object.getOwnPropertyDescriptor(Pe.prototype,"setProxyServer"),Pe.prototype),K(Pe.prototype,"setTurnServer",[Gx],Object.getOwnPropertyDescriptor(Pe.prototype,"setTurnServer"),Pe.prototype),Pe),l7=0,d7=0,h7=(zx=St(Zs),Wx=St(Zs),Jx=St(Zs),qx=Ql(Yt.TRTC.createClient),Kx=St(Zs),Xx=Ql(Yt.TRTC.createStream),$t=function(){function e(){Q(this,e),this.name_=Zs,this.VERSION=oi,this.Logger={loggerManager:_e,LogLevel:Un,setLogLevel:function(n){_e.setLogLevel(n),n<=1&&R4()},enableUploadLog:function(){Ai.handleFunctionState({fnName:"TRTC.enableUploadLog"}),_e.enableUploadLog()},disableUploadLog:function(){_e.warn("disableUploadLog"),Ai.handleFunctionState({fnName:"TRTC.disableUploadLog"}),_e.disableUploadLog()}}}var t;return xe(e,[{key:"checkSystemRequirements",value:(t=H(f().mark(function n(){return f().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,Sm();case 2:return i.abrupt("return",i.sent);case 3:case"end":return i.stop()}},n)})),function(){return t.apply(this,arguments)})},{key:"isScreenShareSupported",value:function(){return Bk()}},{key:"isSmallStreamSupported",value:function(){return zk()}},{key:"getDevices",value:function(){return Em()}},{key:"getCameras",value:function(){return function(){return Cm.apply(this,arguments)}()}},{key:"getMicrophones",value:function(){return Xk()}},{key:"getSpeakers",value:function(){return Qk()}},{key:"createClient",value:function(n){(function(){if(QS&&(QS=!1,_e.getLogLevel()!=It.Logger.LogLevel.NONE&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: "+"".concat(Yf,"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("******************************************************************************")),_e.info("TRTC Web SDK Version: "+oi),_e.info("UserAgent: "+navigator.userAgent),_e.info("URL of current page: "+location.href),navigator.userAgentData&&ln(navigator.userAgentData.getHighEntropyValues)))try{navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"]).then(function(o){var c="UAData: ".concat(o.platform,"/").concat(o.platformVersion);o.architecture&&o.bitness&&(c+=" ".concat(o.architecture,"/").concat(o.bitness)),o.mobile&&(c+=" mobile"),o.model&&(c+=" model: ".concat(o.model)),o.fullVersionList&&(c+=" ".concat(o.fullVersionList.filter(function(a){return a.brand!=="Not/A)Brand"}).map(function(a){return"".concat(a.brand,"/").concat(a.version)}).join(","))),_e.info(c)}).catch(function(){})}catch(o){}})();var i={version:this.VERSION},r=new u7(J(J(J({},i),n),{},{seq:++l7}));return Y.emit(JS,{client:r}),r}},{key:"createStream",value:function(n){return new DF(J(J({},n),{},{seq:++d7}))}}]),e}(),K($t.prototype,"checkSystemRequirements",[zx],Object.getOwnPropertyDescriptor($t.prototype,"checkSystemRequirements"),$t.prototype),K($t.prototype,"isScreenShareSupported",[Wx],Object.getOwnPropertyDescriptor($t.prototype,"isScreenShareSupported"),$t.prototype),K($t.prototype,"isSmallStreamSupported",[Jx],Object.getOwnPropertyDescriptor($t.prototype,"isSmallStreamSupported"),$t.prototype),K($t.prototype,"createClient",[qx,Kx],Object.getOwnPropertyDescriptor($t.prototype,"createClient"),$t.prototype),K($t.prototype,"createStream",[Xx],Object.getOwnPropertyDescriptor($t.prototype,"createStream"),$t.prototype),$t),It=new h7;return It})});var ig=eg((L7,rg)=>{"use strict";var No=typeof Reflect=="object"?Reflect:null,tw=No&&typeof No.apply=="function"?No.apply:function(J,f,G){return Function.prototype.apply.call(J,f,G)},md;No&&typeof No.ownKeys=="function"?md=No.ownKeys:Object.getOwnPropertySymbols?md=function(J){return Object.getOwnPropertyNames(J).concat(Object.getOwnPropertySymbols(J))}:md=function(J){return Object.getOwnPropertyNames(J)};function S7(ne){console&&console.warn&&console.warn(ne)}var rw=Number.isNaN||function(J){return J!==J};function vt(){vt.init.call(this)}rg.exports=vt;rg.exports.once=x7;vt.EventEmitter=vt;vt.prototype._events=void 0;vt.prototype._eventsCount=0;vt.prototype._maxListeners=void 0;var nw=10;function vd(ne){if(typeof ne!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof ne)}Object.defineProperty(vt,"defaultMaxListeners",{enumerable:!0,get:function(){return nw},set:function(ne){if(typeof ne!="number"||ne<0||rw(ne))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+ne+".");nw=ne}});vt.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};vt.prototype.setMaxListeners=function(J){if(typeof J!="number"||J<0||rw(J))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+J+".");return this._maxListeners=J,this};function iw(ne){return ne._maxListeners===void 0?vt.defaultMaxListeners:ne._maxListeners}vt.prototype.getMaxListeners=function(){return iw(this)};vt.prototype.emit=function(J){for(var f=[],G=1;G<arguments.length;G++)f.push(arguments[G]);var $=J==="error",H=this._events;if(H!==void 0)$=$&&H.error===void 0;else if(!$)return!1;if($){var Q;if(f.length>0&&(Q=f[0]),Q instanceof Error)throw Q;var we=new Error("Unhandled error."+(Q?" ("+Q.message+")":""));throw we.context=Q,we}var xe=H[J];if(xe===void 0)return!1;if(typeof xe=="function")tw(xe,this,f);else for(var Ye=xe.length,Et=uw(xe,Ye),G=0;G<Ye;++G)tw(Et[G],this,f);return!0};function aw(ne,J,f,G){var $,H,Q;if(vd(f),H=ne._events,H===void 0?(H=ne._events=Object.create(null),ne._eventsCount=0):(H.newListener!==void 0&&(ne.emit("newListener",J,f.listener?f.listener:f),H=ne._events),Q=H[J]),Q===void 0)Q=H[J]=f,++ne._eventsCount;else if(typeof Q=="function"?Q=H[J]=G?[f,Q]:[Q,f]:G?Q.unshift(f):Q.push(f),$=iw(ne),$>0&&Q.length>$&&!Q.warned){Q.warned=!0;var we=new Error("Possible EventEmitter memory leak detected. "+Q.length+" "+String(J)+" listeners added. Use emitter.setMaxListeners() to increase limit");we.name="MaxListenersExceededWarning",we.emitter=ne,we.type=J,we.count=Q.length,S7(we)}return ne}vt.prototype.addListener=function(J,f){return aw(this,J,f,!1)};vt.prototype.on=vt.prototype.addListener;vt.prototype.prependListener=function(J,f){return aw(this,J,f,!0)};function k7(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ow(ne,J,f){var G={fired:!1,wrapFn:void 0,target:ne,type:J,listener:f},$=k7.bind(G);return $.listener=f,G.wrapFn=$,$}vt.prototype.once=function(J,f){return vd(f),this.on(J,ow(this,J,f)),this};vt.prototype.prependOnceListener=function(J,f){return vd(f),this.prependListener(J,ow(this,J,f)),this};vt.prototype.removeListener=function(J,f){var G,$,H,Q,we;if(vd(f),$=this._events,$===void 0)return this;if(G=$[J],G===void 0)return this;if(G===f||G.listener===f)--this._eventsCount===0?this._events=Object.create(null):(delete $[J],$.removeListener&&this.emit("removeListener",J,G.listener||f));else if(typeof G!="function"){for(H=-1,Q=G.length-1;Q>=0;Q--)if(G[Q]===f||G[Q].listener===f){we=G[Q].listener,H=Q;break}if(H<0)return this;H===0?G.shift():T7(G,H),G.length===1&&($[J]=G[0]),$.removeListener!==void 0&&this.emit("removeListener",J,we||f)}return this};vt.prototype.off=vt.prototype.removeListener;vt.prototype.removeAllListeners=function(J){var f,G,$;if(G=this._events,G===void 0)return this;if(G.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):G[J]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete G[J]),this;if(arguments.length===0){var H=Object.keys(G),Q;for($=0;$<H.length;++$)Q=H[$],Q!=="removeListener"&&this.removeAllListeners(Q);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(f=G[J],typeof f=="function")this.removeListener(J,f);else if(f!==void 0)for($=f.length-1;$>=0;$--)this.removeListener(J,f[$]);return this};function sw(ne,J,f){var G=ne._events;if(G===void 0)return[];var $=G[J];return $===void 0?[]:typeof $=="function"?f?[$.listener||$]:[$]:f?I7($):uw($,$.length)}vt.prototype.listeners=function(J){return sw(this,J,!0)};vt.prototype.rawListeners=function(J){return sw(this,J,!1)};vt.listenerCount=function(ne,J){return typeof ne.listenerCount=="function"?ne.listenerCount(J):cw.call(ne,J)};vt.prototype.listenerCount=cw;function cw(ne){var J=this._events;if(J!==void 0){var f=J[ne];if(typeof f=="function")return 1;if(f!==void 0)return f.length}return 0}vt.prototype.eventNames=function(){return this._eventsCount>0?md(this._events):[]};function uw(ne,J){for(var f=new Array(J),G=0;G<J;++G)f[G]=ne[G];return f}function T7(ne,J){for(;J+1<ne.length;J++)ne[J]=ne[J+1];ne.pop()}function I7(ne){for(var J=new Array(ne.length),f=0;f<J.length;++f)J[f]=ne[f].listener||ne[f];return J}function x7(ne,J){return new Promise(function(f,G){function $(Q){ne.removeListener(J,H),G(Q)}function H(){typeof ne.removeListener=="function"&&ne.removeListener("error",$),f([].slice.call(arguments))}lw(ne,J,H,{once:!0}),J!=="error"&&w7(ne,$,{once:!0})})}function w7(ne,J,f){typeof ne.on=="function"&&lw(ne,"error",J,f)}function lw(ne,J,f,G){if(typeof ne.on=="function")G.once?ne.once(J,f):ne.on(J,f);else if(typeof ne.addEventListener=="function")ne.addEventListener(J,function $(H){G.once&&ne.removeEventListener(J,$),f(H)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof ne)}});var hw=eg((ag,og)=>{(function(ne,J){typeof ag=="object"&&typeof og!="undefined"?og.exports=J(Er()):typeof define=="function"&&define.amd?define(["trtc-js-sdk"],J):(ne=typeof globalThis!="undefined"?globalThis:ne||self).RTCBeautyPlugin=J(ne.TRTC)})(ag,function(ne){function J(ue){return ue&&typeof ue=="object"&&"default"in ue?ue:{default:ue}}var f=J(ne);function G(){G=function(){return ue};var ue={},Te=Object.prototype,Se=Te.hasOwnProperty,je=typeof Symbol=="function"?Symbol:{},He=je.iterator||"@@iterator",ae=je.asyncIterator||"@@asyncIterator",K=je.toStringTag||"@@toStringTag";function oe(he,de,Ne){return Object.defineProperty(he,de,{value:Ne,enumerable:!0,configurable:!0,writable:!0}),he[de]}try{oe({},"")}catch(he){oe=function(de,Ne,We){return de[Ne]=We}}function z(he,de,Ne,We){var De=de&&de.prototype instanceof se?de:se,ut=Object.create(De.prototype),rt=new $e(We||[]);return ut._invoke=function(Ut,en,pe){var Ot="suspendedStart";return function(Kt,fr){if(Ot==="executing")throw new Error("Generator is already running");if(Ot==="completed"){if(Kt==="throw")throw fr;return qn()}for(pe.method=Kt,pe.arg=fr;;){var Di=pe.delegate;if(Di){var yn=hr(Di,pe);if(yn){if(yn===be)continue;return yn}}if(pe.method==="next")pe.sent=pe._sent=pe.arg;else if(pe.method==="throw"){if(Ot==="suspendedStart")throw Ot="completed",pe.arg;pe.dispatchException(pe.arg)}else pe.method==="return"&&pe.abrupt("return",pe.arg);Ot="executing";var Rt=re(Ut,en,pe);if(Rt.type==="normal"){if(Ot=pe.done?"completed":"suspendedYield",Rt.arg===be)continue;return{value:Rt.arg,done:pe.done}}Rt.type==="throw"&&(Ot="completed",pe.method="throw",pe.arg=Rt.arg)}}}(he,Ne,rt),ut}function re(he,de,Ne){try{return{type:"normal",arg:he.call(de,Ne)}}catch(We){return{type:"throw",arg:We}}}ue.wrap=z;var be={};function se(){}function ye(){}function Me(){}var Jt={};oe(Jt,He,function(){return this});var Zt=Object.getPrototypeOf,qe=Zt&&Zt(Zt(Gt([])));qe&&qe!==Te&&Se.call(qe,He)&&(Jt=qe);var qt=Me.prototype=se.prototype=Object.create(Jt);function ft(he){["next","throw","return"].forEach(function(de){oe(he,de,function(Ne){return this._invoke(de,Ne)})})}function Jn(he,de){function Ne(De,ut,rt,Ut){var en=re(he[De],he,ut);if(en.type!=="throw"){var pe=en.arg,Ot=pe.value;return Ot&&typeof Ot=="object"&&Se.call(Ot,"__await")?de.resolve(Ot.__await).then(function(Kt){Ne("next",Kt,rt,Ut)},function(Kt){Ne("throw",Kt,rt,Ut)}):de.resolve(Ot).then(function(Kt){pe.value=Kt,rt(pe)},function(Kt){return Ne("throw",Kt,rt,Ut)})}Ut(en.arg)}var We;this._invoke=function(De,ut){function rt(){return new de(function(Ut,en){Ne(De,ut,Ut,en)})}return We=We?We.then(rt,rt):rt()}}function hr(he,de){var Ne=he.iterator[de.method];if(Ne===void 0){if(de.delegate=null,de.method==="throw"){if(he.iterator.return&&(de.method="return",de.arg=void 0,hr(he,de),de.method==="throw"))return be;de.method="throw",de.arg=new TypeError("The iterator does not provide a 'throw' method")}return be}var We=re(Ne,he.iterator,de.arg);if(We.type==="throw")return de.method="throw",de.arg=We.arg,de.delegate=null,be;var De=We.arg;return De?De.done?(de[he.resultName]=De.value,de.next=he.nextLoc,de.method!=="return"&&(de.method="next",de.arg=void 0),de.delegate=null,be):De:(de.method="throw",de.arg=new TypeError("iterator result is not an object"),de.delegate=null,be)}function Ht(he){var de={tryLoc:he[0]};1 in he&&(de.catchLoc=he[1]),2 in he&&(de.finallyLoc=he[2],de.afterLoc=he[3]),this.tryEntries.push(de)}function Rn(he){var de=he.completion||{};de.type="normal",delete de.arg,he.completion=de}function $e(he){this.tryEntries=[{tryLoc:"root"}],he.forEach(Ht,this),this.reset(!0)}function Gt(he){if(he){var de=he[He];if(de)return de.call(he);if(typeof he.next=="function")return he;if(!isNaN(he.length)){var Ne=-1,We=function De(){for(;++Ne<he.length;)if(Se.call(he,Ne))return De.value=he[Ne],De.done=!1,De;return De.value=void 0,De.done=!0,De};return We.next=We}}return{next:qn}}function qn(){return{value:void 0,done:!0}}return ye.prototype=Me,oe(qt,"constructor",Me),oe(Me,"constructor",ye),ye.displayName=oe(Me,K,"GeneratorFunction"),ue.isGeneratorFunction=function(he){var de=typeof he=="function"&&he.constructor;return!!de&&(de===ye||(de.displayName||de.name)==="GeneratorFunction")},ue.mark=function(he){return Object.setPrototypeOf?Object.setPrototypeOf(he,Me):(he.__proto__=Me,oe(he,K,"GeneratorFunction")),he.prototype=Object.create(qt),he},ue.awrap=function(he){return{__await:he}},ft(Jn.prototype),oe(Jn.prototype,ae,function(){return this}),ue.AsyncIterator=Jn,ue.async=function(he,de,Ne,We,De){De===void 0&&(De=Promise);var ut=new Jn(z(he,de,Ne,We),De);return ue.isGeneratorFunction(de)?ut:ut.next().then(function(rt){return rt.done?rt.value:ut.next()})},ft(qt),oe(qt,K,"Generator"),oe(qt,He,function(){return this}),oe(qt,"toString",function(){return"[object Generator]"}),ue.keys=function(he){var de=[];for(var Ne in he)de.push(Ne);return de.reverse(),function We(){for(;de.length;){var De=de.pop();if(De in he)return We.value=De,We.done=!1,We}return We.done=!0,We}},ue.values=Gt,$e.prototype={constructor:$e,reset:function(he){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(Rn),!he)for(var de in this)de.charAt(0)==="t"&&Se.call(this,de)&&!isNaN(+de.slice(1))&&(this[de]=void 0)},stop:function(){this.done=!0;var he=this.tryEntries[0].completion;if(he.type==="throw")throw he.arg;return this.rval},dispatchException:function(he){if(this.done)throw he;var de=this;function Ne(en,pe){return ut.type="throw",ut.arg=he,de.next=en,pe&&(de.method="next",de.arg=void 0),!!pe}for(var We=this.tryEntries.length-1;We>=0;--We){var De=this.tryEntries[We],ut=De.completion;if(De.tryLoc==="root")return Ne("end");if(De.tryLoc<=this.prev){var rt=Se.call(De,"catchLoc"),Ut=Se.call(De,"finallyLoc");if(rt&&Ut){if(this.prev<De.catchLoc)return Ne(De.catchLoc,!0);if(this.prev<De.finallyLoc)return Ne(De.finallyLoc)}else if(rt){if(this.prev<De.catchLoc)return Ne(De.catchLoc,!0)}else{if(!Ut)throw new Error("try statement without catch or finally");if(this.prev<De.finallyLoc)return Ne(De.finallyLoc)}}}},abrupt:function(he,de){for(var Ne=this.tryEntries.length-1;Ne>=0;--Ne){var We=this.tryEntries[Ne];if(We.tryLoc<=this.prev&&Se.call(We,"finallyLoc")&&this.prev<We.finallyLoc){var De=We;break}}De&&(he==="break"||he==="continue")&&De.tryLoc<=de&&de<=De.finallyLoc&&(De=null);var ut=De?De.completion:{};return ut.type=he,ut.arg=de,De?(this.method="next",this.next=De.finallyLoc,be):this.complete(ut)},complete:function(he,de){if(he.type==="throw")throw he.arg;return he.type==="break"||he.type==="continue"?this.next=he.arg:he.type==="return"?(this.rval=this.arg=he.arg,this.method="return",this.next="end"):he.type==="normal"&&de&&(this.next=de),be},finish:function(he){for(var de=this.tryEntries.length-1;de>=0;--de){var Ne=this.tryEntries[de];if(Ne.finallyLoc===he)return this.complete(Ne.completion,Ne.afterLoc),Rn(Ne),be}},catch:function(he){for(var de=this.tryEntries.length-1;de>=0;--de){var Ne=this.tryEntries[de];if(Ne.tryLoc===he){var We=Ne.completion;if(We.type==="throw"){var De=We.arg;Rn(Ne)}return De}}throw new Error("illegal catch attempt")},delegateYield:function(he,de,Ne){return this.delegate={iterator:Gt(he),resultName:de,nextLoc:Ne},this.method==="next"&&(this.arg=void 0),be}},ue}function $(ue){return $=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Te){return typeof Te}:function(Te){return Te&&typeof Symbol=="function"&&Te.constructor===Symbol&&Te!==Symbol.prototype?"symbol":typeof Te},$(ue)}function H(ue,Te,Se,je,He,ae,K){try{var oe=ue[ae](K),z=oe.value}catch(re){return void Se(re)}oe.done?Te(z):Promise.resolve(z).then(je,He)}function Q(ue){return function(){var Te=this,Se=arguments;return new Promise(function(je,He){var ae=ue.apply(Te,Se);function K(z){H(ae,je,He,K,oe,"next",z)}function oe(z){H(ae,je,He,K,oe,"throw",z)}K(void 0)})}}function we(ue,Te){if(!(ue instanceof Te))throw new TypeError("Cannot call a class as a function")}function xe(ue,Te){for(var Se=0;Se<Te.length;Se++){var je=Te[Se];je.enumerable=je.enumerable||!1,je.configurable=!0,"value"in je&&(je.writable=!0),Object.defineProperty(ue,je.key,je)}}function Ye(ue,Te,Se){return Te&&xe(ue.prototype,Te),Se&&xe(ue,Se),Object.defineProperty(ue,"prototype",{writable:!1}),ue}function Et(ue,Te,Se){var je=function(re,be,se){var ye=new RegExp("\\b".concat(be," \\w+ (\\w+)"),"ig");re.replace(ye,function(Me,Jt){return se[Jt]=0,Me})},He=function(re,be,se){var ye=re.createShader(se);return re.shaderSource(ye,be),re.compileShader(ye),re.getShaderParameter(ye,re.COMPILE_STATUS)?ye:(console.log(re.getShaderInfoLog(ye)),null)};this.uniform={},this.attribute={};var ae=He(ue,Te,ue.VERTEX_SHADER),K=He(ue,Se,ue.FRAGMENT_SHADER);for(var oe in this.id=ue.createProgram(),ue.attachShader(this.id,ae),ue.attachShader(this.id,K),ue.linkProgram(this.id),ue.getProgramParameter(this.id,ue.LINK_STATUS)||console.log(ue.getProgramInfoLog(this.id)),ue.useProgram(this.id),je(Te,"attribute",this.attribute),this.attribute)this.attribute[oe]=ue.getAttribLocation(this.id,oe);for(var z in je(Te,"uniform",this.uniform),je(Se,"uniform",this.uniform),this.uniform)this.uniform[z]=ue.getUniformLocation(this.id,z)}function Qe(ue,Te,Se,je){for(var He=[],ae=0;ae<Te.length;++ae)He.push(Ac(ue,Te[ae],ue[dr[ae]]));return function(K,oe,z,re){var be=K.createProgram();return oe.forEach(function(se){K.attachShader(be,se)}),z&&z.forEach(function(se,ye){K.bindAttribLocation(be,re?re[ye]:ye,se)}),K.linkProgram(be),K.getProgramParameter(be,K.LINK_STATUS)?be:(K.deleteProgram(be),null)}(ue,He,Se,je)}var dr=["VERTEX_SHADER","FRAGMENT_SHADER"];function Ac(ue,Te,Se){var je=ue.createShader(Se);return ue.shaderSource(je,Te),ue.compileShader(je),ue.getShaderParameter(je,ue.COMPILE_STATUS)?je:(ue.deleteShader(je),null)}var zo=function(){function ue(Te){we(this,ue),this.canvas=Te.canvas,this.video=Te.video,this.width=Te.width||640,this.height=Te.height||480,this.vertexBuffer=null,this.currentProgram=null,this.applied=!1,this.beautyParams={beauty:.5,brightness:.5,ruddy:.5},this.gl=this.createGL(Te.canvas),this.sourceTexture=this.gl.createTexture()}return Ye(ue,[{key:"setRect",value:function(Te,Se){this.width=Te,this.height=Se}},{key:"apply",value:function(Te){if(!this.vertexBuffer){var Se=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);this.vertexBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,Se,this.gl.STATIC_DRAW),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}this.gl.viewport(0,0,this.width,this.height),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.applied?this.gl.texSubImage2D(this.gl.TEXTURE_2D,0,0,0,this.gl.RGB,this.gl.UNSIGNED_BYTE,Te):(this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGB,this.gl.RGB,this.gl.UNSIGNED_BYTE,Te),this.applied=!0);var je=this.beautyParams,He=je.beauty,ae=je.brightness,K=je.ruddy,oe=2/this.width,z=2/this.height,re=this.compileBeautyShader();this.gl.uniform2f(re.uniform.singleStepOffset,oe,z);var be=new Float32Array([1-.8*He,1-.6*He,.1+.45*K,.1+.45*K]);this.gl.uniform4fv(re.uniform.params,be),this.gl.uniform1f(re.uniform.brightness,.12*ae),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null),this.gl.uniform1f(this.currentProgram.uniform.flipY,1),this.gl.drawArrays(this.gl.TRIANGLES,0,6)}},{key:"compileBeautyShader",value:function(){if(this.currentProgram)return this.currentProgram;this.currentProgram=new Et(this.gl,["precision highp float;","attribute vec2 pos;","attribute vec2 uv;","varying vec2 vUv;","uniform float flipY;","void main(void) {","vUv = uv;","gl_Position = vec4(pos.x, pos.y*flipY, 0.0, 1.);","}"].join(`
73
71
  `),["precision highp float;","uniform vec2 singleStepOffset;","uniform sampler2D texture;","uniform vec4 params;","uniform float brightness;","varying vec2 vUv;","const highp vec3 W = vec3(0.299,0.587,0.114);","const mat3 saturateMatrix = mat3(1.1102,-0.0598,-0.061,-0.0774,1.0826,-0.1186,-0.0228,-0.0228,1.1772);","vec2 blurCoordinates[24];","float hardLight(float color){","if(color <= 0.5){","color = color * color * 2.0;","} else {","color = 1.0 - ((1.0 - color)*(1.0 - color) * 2.0);","}","return color;","}","void main(){","vec3 centralColor = texture2D(texture, vUv).rgb;","blurCoordinates[0] = vUv.xy + singleStepOffset * vec2(0.0, -10.0);","blurCoordinates[1] = vUv.xy + singleStepOffset * vec2(0.0, 10.0);","blurCoordinates[2] = vUv.xy + singleStepOffset * vec2(-10.0, 0.0);","blurCoordinates[3] = vUv.xy + singleStepOffset * vec2(10.0, 0.0);","blurCoordinates[4] = vUv.xy + singleStepOffset * vec2(5.0, -8.0);","blurCoordinates[5] = vUv.xy + singleStepOffset * vec2(5.0, 8.0);","blurCoordinates[6] = vUv.xy + singleStepOffset * vec2(-5.0, 8.0);","blurCoordinates[7] = vUv.xy + singleStepOffset * vec2(-5.0, -8.0);","blurCoordinates[8] = vUv.xy + singleStepOffset * vec2(8.0, -5.0);","blurCoordinates[9] = vUv.xy + singleStepOffset * vec2(8.0, 5.0);","blurCoordinates[10] = vUv.xy + singleStepOffset * vec2(-8.0, 5.0);","blurCoordinates[11] = vUv.xy + singleStepOffset * vec2(-8.0, -5.0);","blurCoordinates[12] = vUv.xy + singleStepOffset * vec2(0.0, -6.0);","blurCoordinates[13] = vUv.xy + singleStepOffset * vec2(0.0, 6.0);","blurCoordinates[14] = vUv.xy + singleStepOffset * vec2(6.0, 0.0);","blurCoordinates[15] = vUv.xy + singleStepOffset * vec2(-6.0, 0.0);","blurCoordinates[16] = vUv.xy + singleStepOffset * vec2(-4.0, -4.0);","blurCoordinates[17] = vUv.xy + singleStepOffset * vec2(-4.0, 4.0);","blurCoordinates[18] = vUv.xy + singleStepOffset * vec2(4.0, -4.0);","blurCoordinates[19] = vUv.xy + singleStepOffset * vec2(4.0, 4.0);","blurCoordinates[20] = vUv.xy + singleStepOffset * vec2(-2.0, -2.0);","blurCoordinates[21] = vUv.xy + singleStepOffset * vec2(-2.0, 2.0);","blurCoordinates[22] = vUv.xy + singleStepOffset * vec2(2.0, -2.0);","blurCoordinates[23] = vUv.xy + singleStepOffset * vec2(2.0, 2.0);","float sampleColor = centralColor.g * 22.0;","sampleColor += texture2D(texture, blurCoordinates[0]).g;","sampleColor += texture2D(texture, blurCoordinates[1]).g;","sampleColor += texture2D(texture, blurCoordinates[2]).g;","sampleColor += texture2D(texture, blurCoordinates[3]).g;","sampleColor += texture2D(texture, blurCoordinates[4]).g;","sampleColor += texture2D(texture, blurCoordinates[5]).g;","sampleColor += texture2D(texture, blurCoordinates[6]).g;","sampleColor += texture2D(texture, blurCoordinates[7]).g;","sampleColor += texture2D(texture, blurCoordinates[8]).g;","sampleColor += texture2D(texture, blurCoordinates[9]).g;","sampleColor += texture2D(texture, blurCoordinates[10]).g;","sampleColor += texture2D(texture, blurCoordinates[11]).g;","sampleColor += texture2D(texture, blurCoordinates[12]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[13]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[14]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[15]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[16]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[17]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[18]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[19]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[20]).g * 3.0;","sampleColor += texture2D(texture, blurCoordinates[21]).g * 3.0;","sampleColor += texture2D(texture, blurCoordinates[22]).g * 3.0;","sampleColor += texture2D(texture, blurCoordinates[23]).g * 3.0;","sampleColor = sampleColor / 62.0;","float highPass = centralColor.g - sampleColor + 0.5;","for(int i = 0; i < 5;i++){","highPass = hardLight(highPass);","}","float luminance = dot(centralColor, W);","float alpha = pow(luminance, params.r);","vec3 smoothColor = centralColor + (centralColor-vec3(highPass))*alpha*0.1;","smoothColor.r = clamp(pow(smoothColor.r, params.g),0.0,1.0);","smoothColor.g = clamp(pow(smoothColor.g, params.g),0.0,1.0);","smoothColor.b = clamp(pow(smoothColor.b, params.g),0.0,1.0);","vec3 screen = vec3(1.0) - (vec3(1.0)-smoothColor) * (vec3(1.0)-centralColor);","vec3 lighten = max(smoothColor, centralColor);","vec3 softLight = 2.0 * centralColor*smoothColor + centralColor*centralColor - 2.0 * centralColor*centralColor * smoothColor;","gl_FragColor = vec4(mix(centralColor, screen, alpha), 1.0);","gl_FragColor.rgb = mix(gl_FragColor.rgb, lighten, alpha);","gl_FragColor.rgb = mix(gl_FragColor.rgb, softLight, params.b);","vec3 satColor = gl_FragColor.rgb * saturateMatrix;","gl_FragColor.rgb = mix(gl_FragColor.rgb, satColor, params.a);","gl_FragColor.rgb = vec3(gl_FragColor.rgb + vec3(brightness));","}"].join(`
74
- `));var Te=Float32Array.BYTES_PER_ELEMENT,Se=4*Te;return this.gl.enableVertexAttribArray(this.currentProgram.attribute.pos),this.gl.vertexAttribPointer(this.currentProgram.attribute.pos,2,this.gl.FLOAT,!1,Se,0),this.gl.enableVertexAttribArray(this.currentProgram.attribute.uv),this.gl.vertexAttribPointer(this.currentProgram.attribute.uv,2,this.gl.FLOAT,!1,Se,2*Te),this.currentProgram}},{key:"createGL",value:function(Te){var Se=Te.getContext("webgl2");if(Se||Te.getContext("experimental-webgl",{preserveDrawingBuffer:!0}),!Se)throw"Couldn't get WebGL context";return Se}},{key:"setBeautyParams",value:function(Te){this.beautyParams=Te}},{key:"reset",value:function(){this.applied=!1}}]),le}(),zo=function(){function le(oe){Re(this,le),this.canvas=oe.canvas,this.video=oe.video,this.width=oe.width||640,this.height=oe.height||480,this.onoverload=oe.onoverload,this.gl=this.createGL(oe.canvas),this.vao=this.gl.createVertexArray(),this.positionBuffer=this.gl.createBuffer(),this.sourceTexture=this.gl.createTexture(),this.program=null,this.blurParams={resolutionLocation:null,imageLocation0:null,imageLocation1:null},this.virtualParams={resolutionLocation:null,imageLocation0:null,imageLocation1:null,imageLocation2:null,imageOldLocation0:null,imageOldLocation1:null,imageOldLocation2:null,imageOldLocation3:null,imageOldLocation4:null,imageOldLocation5:null},this.virtualLocation={postProcessTypeLocation:null,sigmaLocation:null,bSigmaLocation:null,mSizeLocation:null,overlayTypeLocation:null,hardThresholdLocation:null,sigmoidClipLocation:null},this.maskBuffer=[],this.frameBuffer=[],this.virtualOption={postProcess:2,sigma:100,bSigma:10,kSize:19,overlayType:0,hardThreshold:.5,sigmoidClip:1},this.type=0,this.frameRate=0,this.rafId=null,this.timeoutId=null,this.img=new Image,this.imgCropCanvas=document.createElement("canvas"),this.imgCropCanvasCtx=this.imgCropCanvas.getContext("2d"),this.imgMap=new Map,this.tempImg=new Image,this.tempImg.crossOrigin="anonymous",this.isRender=!1,this.enable=!1,this.processingTimes=[],this.frameCount=0}var Te,Se,je,He;return $e(le,[{key:"loadResources",value:(He=Q(G().mark(function oe(){return G().wrap(function(X){for(;;)switch(X.prev=X.next){case 0:return X.next=2,new window.SelfieSegmentation({locateFile:function(ce){return"https://web.sdk.qcloud.com/trtc/webrtc/download/segmentation/".concat(ce)}});case 2:return this.selfieSegmentation=X.sent,X.next=5,this.selfieSegmentation.initialize();case 5:case"end":return X.stop()}},oe,this)})),function(){return He.apply(this,arguments)})},{key:"setEnable",value:function(oe){this.enable=oe}},{key:"initVirtualParams",value:(je=Q(G().mark(function oe(X){var ce,W;return G().wrap(function(re){for(;;)switch(re.prev=re.next){case 0:if(ce=X.img,W=X.type,this.type=W==="blur"?0:1,!ce){re.next=5;break}return re.next=5,this.setBackground(ce);case 5:this.type===0?this.initBackgroundBlurProgram():this.type===1&&this.initVirtualBackgroundProgram();case 6:case"end":return re.stop()}},oe,this)})),function(oe){return je.apply(this,arguments)})},{key:"setBackground",value:(Se=Q(G().mark(function oe(X){var ce=this;return G().wrap(function(W){for(;;)switch(W.prev=W.next){case 0:return W.abrupt("return",new Promise(function(re,be){try{X instanceof HTMLImageElement?(ce.img=X,re()):(ce.tempImg.onload=function(){ce.imgCropCanvasCtx.drawImage(ce.tempImg,0,0,ce.width,ce.height);var ue=ce.imgCropCanvas.toDataURL("image/jpeg",.5);ce.img.src=ue,ce.imgMap.set(X,ue),re()},ce.imgMap.has(X)?(ce.img.src=ce.imgMap.get(X),re()):ce.tempImg.src=X)}catch(ue){be("please check the img parameter!")}}));case 1:case"end":return W.stop()}},oe)})),function(oe){return Se.apply(this,arguments)})},{key:"setRect",value:function(oe,X){this.width=oe,this.height=X,this.imgCropCanvas.width=this.width,this.imgCropCanvas.height=this.height,this.imgCropCanvasCtx.fillStyle="#000",this.imgCropCanvasCtx.fillRect(0,0,this.width,this.height),this.img.width=oe,this.img.height=X,this.img.src=this.imgCropCanvas.toDataURL("image/jpeg",.5),this.tempImg.width=oe,this.tempImg.height=X}},{key:"createGL",value:function(oe){var X=oe.getContext("webgl2");if(X||oe.getContext("experimental-webgl",{preserveDrawingBuffer:!0}),!X)throw"Couldn't get WebGL context";return X}},{key:"setRectangle",value:function(oe,X,ce,W,re){var be=X,ue=X+W,ye=ce,Me=ce+re;oe.bufferData(oe.ARRAY_BUFFER,new Float32Array([be,ye,ue,ye,be,Me,be,Me,ue,ye,ue,Me]),oe.STATIC_DRAW)}},{key:"startVirtual",value:function(oe){this.frameRate=oe,this.selfieSegmentation.setOptions({selfieMode:!1,modelSelection:0,effect:"background"}),this.type===0?this.selfieSegmentation.onResults(this.onBlurResult.bind(this)):this.selfieSegmentation.onResults(this.onVirtualResults.bind(this)),this.startTime=new Date().getTime(),this.isRender=!0,this.enable=!0,this.installEvents()}},{key:"render",value:(Te=Q(G().mark(function oe(){var X,ce,W=this;return G().wrap(function(re){for(;;)switch(re.prev=re.next){case 0:if(this.isRender){re.next=2;break}return re.abrupt("return");case 2:if(!((X=new Date().getTime())-this.startTime>1e3/this.frameRate)){re.next=12;break}if(!this.enable||this.video.readyState!==this.video.HAVE_ENOUGH_DATA){re.next=7;break}return re.next=7,this.selfieSegmentation.send({image:this.video});case 7:ce=X-this.startTime,this.processingTimes.push(ce),this.processingTimes.length>100&&this.processingTimes.shift(),this.frameCount>=100?this.processingTimes.reduce(function(be,ue){return be+ue},0)/this.processingTimes.length>100&&(console.log("frameRate is too low, trigger overload."),this.onoverload&&typeof this.onoverload=="function"&&this.onoverload(),this.frameCount=0,this.processingTimes=[]):this.frameCount+=1,this.startTime=X;case 12:document.hidden?(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.timeoutId=setTimeout(function(){W.render()},1e3/this.frameRate)):(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(this.render.bind(this)));case 13:case"end":return re.stop()}},oe,this)})),function(){return Te.apply(this,arguments)})},{key:"installEvents",value:function(){window.addEventListener("visibilitychange",this.render.bind(this))}},{key:"uninstallEvents",value:function(){window.addEventListener("visibilitychange",this.render.bind(this))}},{key:"reset",value:function(){this.isRender=!1,cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT),this.gl.deleteProgram(this.program),this.gl.deleteTexture(this.sourceTexture),this.uninstallEvents()}},{key:"destroy",value:function(){this.reset(),this.gl.deleteBuffer(this.positionBuffer)}},{key:"initBackgroundBlurProgram",value:function(){var oe=this.gl,X={vertexShaderSource:`#version 300 es
72
+ `));var Te=Float32Array.BYTES_PER_ELEMENT,Se=4*Te;return this.gl.enableVertexAttribArray(this.currentProgram.attribute.pos),this.gl.vertexAttribPointer(this.currentProgram.attribute.pos,2,this.gl.FLOAT,!1,Se,0),this.gl.enableVertexAttribArray(this.currentProgram.attribute.uv),this.gl.vertexAttribPointer(this.currentProgram.attribute.uv,2,this.gl.FLOAT,!1,Se,2*Te),this.currentProgram}},{key:"createGL",value:function(Te){var Se=Te.getContext("webgl2");if(Se||Te.getContext("experimental-webgl",{preserveDrawingBuffer:!0}),!Se)throw"Couldn't get WebGL context";return Se}},{key:"setBeautyParams",value:function(Te){this.beautyParams=Te}},{key:"reset",value:function(){this.applied=!1}}]),ue}(),Wo=function(){function ue(ae){we(this,ue),this.canvas=ae.canvas,this.video=ae.video,this.width=ae.width||640,this.height=ae.height||480,this.onoverload=ae.onoverload,this.gl=this.createGL(ae.canvas),this.vao=this.gl.createVertexArray(),this.positionBuffer=this.gl.createBuffer(),this.sourceTexture=this.gl.createTexture(),this.program=null,this.blurParams={resolutionLocation:null,imageLocation0:null,imageLocation1:null},this.virtualParams={resolutionLocation:null,imageLocation0:null,imageLocation1:null,imageLocation2:null,imageOldLocation0:null,imageOldLocation1:null,imageOldLocation2:null,imageOldLocation3:null,imageOldLocation4:null,imageOldLocation5:null},this.virtualLocation={postProcessTypeLocation:null,sigmaLocation:null,bSigmaLocation:null,mSizeLocation:null,overlayTypeLocation:null,hardThresholdLocation:null,sigmoidClipLocation:null},this.maskBuffer=[],this.frameBuffer=[],this.virtualOption={postProcess:2,sigma:100,bSigma:10,kSize:19,overlayType:0,hardThreshold:.5,sigmoidClip:1},this.type=0,this.frameRate=0,this.rafId=null,this.timeoutId=null,this.img=new Image,this.imgCropCanvas=document.createElement("canvas"),this.imgCropCanvasCtx=this.imgCropCanvas.getContext("2d"),this.imgMap=new Map,this.tempImg=new Image,this.tempImg.crossOrigin="anonymous",this.isRender=!1,this.enable=!1,this.processingTimes=[],this.frameCount=0}var Te,Se,je,He;return Ye(ue,[{key:"loadResources",value:(He=Q(G().mark(function ae(){return G().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return K.next=2,new window.SelfieSegmentation({locateFile:function(oe){return"https://web.sdk.qcloud.com/trtc/webrtc/download/segmentation/".concat(oe)}});case 2:return this.selfieSegmentation=K.sent,K.next=5,this.selfieSegmentation.initialize();case 5:case"end":return K.stop()}},ae,this)})),function(){return He.apply(this,arguments)})},{key:"setEnable",value:function(ae){this.enable=ae}},{key:"initVirtualParams",value:(je=Q(G().mark(function ae(K){var oe,z;return G().wrap(function(re){for(;;)switch(re.prev=re.next){case 0:if(oe=K.img,z=K.type,this.type=z==="blur"?0:1,!oe){re.next=5;break}return re.next=5,this.setBackground(oe);case 5:this.type===0?this.initBackgroundBlurProgram():this.type===1&&this.initVirtualBackgroundProgram();case 6:case"end":return re.stop()}},ae,this)})),function(ae){return je.apply(this,arguments)})},{key:"setBackground",value:(Se=Q(G().mark(function ae(K){var oe=this;return G().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:return z.abrupt("return",new Promise(function(re,be){try{K instanceof HTMLImageElement?(oe.img=K,re()):(oe.tempImg.onload=function(){oe.imgCropCanvasCtx.drawImage(oe.tempImg,0,0,oe.width,oe.height);var se=oe.imgCropCanvas.toDataURL("image/jpeg",.5);oe.img.src=se,oe.imgMap.set(K,se),re()},oe.imgMap.has(K)?(oe.img.src=oe.imgMap.get(K),re()):oe.tempImg.src=K)}catch(se){be("please check the img parameter!")}}));case 1:case"end":return z.stop()}},ae)})),function(ae){return Se.apply(this,arguments)})},{key:"setRect",value:function(ae,K){this.width=ae,this.height=K,this.imgCropCanvas.width=this.width,this.imgCropCanvas.height=this.height,this.imgCropCanvasCtx.fillStyle="#000",this.imgCropCanvasCtx.fillRect(0,0,this.width,this.height),this.img.width=ae,this.img.height=K,this.img.src=this.imgCropCanvas.toDataURL("image/jpeg",.5),this.tempImg.width=ae,this.tempImg.height=K}},{key:"createGL",value:function(ae){var K=ae.getContext("webgl2");if(K||ae.getContext("experimental-webgl",{preserveDrawingBuffer:!0}),!K)throw"Couldn't get WebGL context";return K}},{key:"setRectangle",value:function(ae,K,oe,z,re){var be=K,se=K+z,ye=oe,Me=oe+re;ae.bufferData(ae.ARRAY_BUFFER,new Float32Array([be,ye,se,ye,be,Me,be,Me,se,ye,se,Me]),ae.STATIC_DRAW)}},{key:"startVirtual",value:function(ae){this.frameRate=ae,this.selfieSegmentation.setOptions({selfieMode:!1,modelSelection:0,effect:"background"}),this.type===0?this.selfieSegmentation.onResults(this.onBlurResult.bind(this)):this.selfieSegmentation.onResults(this.onVirtualResults.bind(this)),this.startTime=new Date().getTime(),this.isRender=!0,this.enable=!0,this.installEvents()}},{key:"render",value:(Te=Q(G().mark(function ae(){var K,oe,z=this;return G().wrap(function(re){for(;;)switch(re.prev=re.next){case 0:if(this.isRender){re.next=2;break}return re.abrupt("return");case 2:if(!((K=new Date().getTime())-this.startTime>1e3/this.frameRate)){re.next=12;break}if(!this.enable||this.video.readyState!==this.video.HAVE_ENOUGH_DATA){re.next=7;break}return re.next=7,this.selfieSegmentation.send({image:this.video});case 7:oe=K-this.startTime,this.processingTimes.push(oe),this.processingTimes.length>100&&this.processingTimes.shift(),this.frameCount>=100?this.processingTimes.reduce(function(be,se){return be+se},0)/this.processingTimes.length>100&&(console.log("frameRate is too low, trigger overload."),this.onoverload&&typeof this.onoverload=="function"&&this.onoverload(),this.frameCount=0,this.processingTimes=[]):this.frameCount+=1,this.startTime=K;case 12:document.hidden?(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.timeoutId=setTimeout(function(){z.render()},1e3/this.frameRate)):(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(this.render.bind(this)));case 13:case"end":return re.stop()}},ae,this)})),function(){return Te.apply(this,arguments)})},{key:"installEvents",value:function(){window.addEventListener("visibilitychange",this.render.bind(this))}},{key:"uninstallEvents",value:function(){window.addEventListener("visibilitychange",this.render.bind(this))}},{key:"reset",value:function(){this.isRender=!1,cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT),this.gl.deleteProgram(this.program),this.gl.deleteTexture(this.sourceTexture),this.uninstallEvents()}},{key:"destroy",value:function(){this.reset(),this.gl.deleteBuffer(this.positionBuffer)}},{key:"initBackgroundBlurProgram",value:function(){var ae=this.gl,K={vertexShaderSource:`#version 300 es
75
73
 
76
74
  // an attribute is an input (in) to a vertex shader.
77
75
  // It will receive data from a buffer
@@ -250,7 +248,7 @@ b=`+R+":"+b+`\r
250
248
 
251
249
  outColor = (1.0 - color0.r) * gaussianBlur + color0.r * color1;
252
250
  }
253
- `},ce=X.vertexShaderSource,W=X.fragmentShaderSource;this.program=Ye(oe,[ce,W]);var re=oe.getAttribLocation(this.program,"position"),be=oe.getAttribLocation(this.program,"texCoord");this.blurParams.resolutionLocation=oe.getUniformLocation(this.program,"resolution"),this.blurParams.imageLocation0=oe.getUniformLocation(this.program,"u_image0"),this.blurParams.imageLocation1=oe.getUniformLocation(this.program,"u_image1"),oe.bindVertexArray(this.vao),oe.bindBuffer(oe.ARRAY_BUFFER,this.positionBuffer),oe.enableVertexAttribArray(re),oe.vertexAttribPointer(re,2,oe.FLOAT,!1,0,0),oe.bindBuffer(oe.ARRAY_BUFFER,oe.createBuffer()),oe.bufferData(oe.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),oe.STATIC_DRAW),oe.enableVertexAttribArray(be),oe.vertexAttribPointer(be,2,oe.FLOAT,!1,0,0)}},{key:"onBlurResult",value:function(oe){for(var X=oe.segmentationMask,ce=oe.image,W=this.gl,re=[],be=[X,ce],ue=0;ue<2;++ue){var ye=W.createTexture();W.bindTexture(W.TEXTURE_2D,ye),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_WRAP_S,W.CLAMP_TO_EDGE),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_WRAP_T,W.CLAMP_TO_EDGE),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_MIN_FILTER,W.NEAREST),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_MAG_FILTER,W.NEAREST),W.texImage2D(W.TEXTURE_2D,0,W.RGBA,W.RGBA,W.UNSIGNED_BYTE,be[ue]),re.push(ye)}W.bindBuffer(W.ARRAY_BUFFER,this.positionBuffer),this.setRectangle(W,0,0,this.width,this.height),W.viewport(0,0,this.width,this.height),W.clearColor(0,0,0,0),W.clear(W.COLOR_BUFFER_BIT|W.DEPTH_BUFFER_BIT),W.useProgram(this.program),W.bindVertexArray(this.vao);var Me=this.blurParams,Jt=Me.resolutionLocation,Zt=Me.imageLocation0,Ke=Me.imageLocation1;W.uniform2f(Jt,this.width,this.height),W.uniform1i(Zt,0),W.uniform1i(Ke,1),W.activeTexture(W.TEXTURE0),W.bindTexture(W.TEXTURE_2D,re[0]),W.activeTexture(W.TEXTURE1),W.bindTexture(W.TEXTURE_2D,re[1]),W.drawArrays(W.TRIANGLES,0,6)}},{key:"initVirtualBackgroundProgram",value:function(){var oe=this.gl,X={vertexShaderSource:`#version 300 es
251
+ `},oe=K.vertexShaderSource,z=K.fragmentShaderSource;this.program=Qe(ae,[oe,z]);var re=ae.getAttribLocation(this.program,"position"),be=ae.getAttribLocation(this.program,"texCoord");this.blurParams.resolutionLocation=ae.getUniformLocation(this.program,"resolution"),this.blurParams.imageLocation0=ae.getUniformLocation(this.program,"u_image0"),this.blurParams.imageLocation1=ae.getUniformLocation(this.program,"u_image1"),ae.bindVertexArray(this.vao),ae.bindBuffer(ae.ARRAY_BUFFER,this.positionBuffer),ae.enableVertexAttribArray(re),ae.vertexAttribPointer(re,2,ae.FLOAT,!1,0,0),ae.bindBuffer(ae.ARRAY_BUFFER,ae.createBuffer()),ae.bufferData(ae.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),ae.STATIC_DRAW),ae.enableVertexAttribArray(be),ae.vertexAttribPointer(be,2,ae.FLOAT,!1,0,0)}},{key:"onBlurResult",value:function(ae){for(var K=ae.segmentationMask,oe=ae.image,z=this.gl,re=[],be=[K,oe],se=0;se<2;++se){var ye=z.createTexture();z.bindTexture(z.TEXTURE_2D,ye),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_S,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_T,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MIN_FILTER,z.NEAREST),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MAG_FILTER,z.NEAREST),z.texImage2D(z.TEXTURE_2D,0,z.RGBA,z.RGBA,z.UNSIGNED_BYTE,be[se]),re.push(ye)}z.bindBuffer(z.ARRAY_BUFFER,this.positionBuffer),this.setRectangle(z,0,0,this.width,this.height),z.viewport(0,0,this.width,this.height),z.clearColor(0,0,0,0),z.clear(z.COLOR_BUFFER_BIT|z.DEPTH_BUFFER_BIT),z.useProgram(this.program),z.bindVertexArray(this.vao);var Me=this.blurParams,Jt=Me.resolutionLocation,Zt=Me.imageLocation0,qe=Me.imageLocation1;z.uniform2f(Jt,this.width,this.height),z.uniform1i(Zt,0),z.uniform1i(qe,1),z.activeTexture(z.TEXTURE0),z.bindTexture(z.TEXTURE_2D,re[0]),z.activeTexture(z.TEXTURE1),z.bindTexture(z.TEXTURE_2D,re[1]),z.drawArrays(z.TRIANGLES,0,6)}},{key:"initVirtualBackgroundProgram",value:function(){var ae=this.gl,K={vertexShaderSource:`#version 300 es
254
252
 
255
253
  // an attribute is an input (in) to a vertex shader.
256
254
  // It will receive data from a buffer
@@ -530,23 +528,23 @@ b=`+R+":"+b+`\r
530
528
  outColor.rgb = (maskValue * color1 + (1.0 - maskValue) * color2).rgb;
531
529
  outColor.a = 1.0;
532
530
  }
533
- `},ce=X.vertexShaderSource,W=X.fragmentShaderSource;this.program=Ye(oe,[ce,W]);var re=oe.getAttribLocation(this.program,"position"),be=oe.getAttribLocation(this.program,"texCoord"),ue=this.program;this.virtualParams={resolutionLocation:oe.getUniformLocation(ue,"resolution"),imageLocation0:oe.getUniformLocation(ue,"u_image0"),imageLocation1:oe.getUniformLocation(ue,"u_image1"),imageLocation2:oe.getUniformLocation(ue,"u_image2"),imageOldLocation0:oe.getUniformLocation(ue,"u_image_old0"),imageOldLocation1:oe.getUniformLocation(ue,"u_image_old1"),imageOldLocation2:oe.getUniformLocation(ue,"u_image_old2"),imageOldLocation3:oe.getUniformLocation(ue,"u_image_old3"),imageOldLocation4:oe.getUniformLocation(ue,"u_image_old4"),imageOldLocation5:oe.getUniformLocation(ue,"u_image_old5")},this.virtualLocation={postProcessTypeLocation:oe.getUniformLocation(ue,"PostProcessType"),sigmaLocation:oe.getUniformLocation(ue,"SIGMA"),bSigmaLocation:oe.getUniformLocation(ue,"BSIGMA"),mSizeLocation:oe.getUniformLocation(ue,"MSIZE"),overlayTypeLocation:oe.getUniformLocation(ue,"overlayType"),hardThresholdLocation:oe.getUniformLocation(ue,"hardThreshold"),sigmoidClipLocation:oe.getUniformLocation(ue,"sigmoidClip")},oe.bindVertexArray(this.vao),oe.bindBuffer(oe.ARRAY_BUFFER,this.positionBuffer),oe.enableVertexAttribArray(re),oe.vertexAttribPointer(re,2,oe.FLOAT,!1,0,0),oe.bindBuffer(oe.ARRAY_BUFFER,oe.createBuffer()),oe.bufferData(oe.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),oe.STATIC_DRAW),oe.enableVertexAttribArray(be),oe.vertexAttribPointer(be,2,oe.FLOAT,!1,0,0)}},{key:"onVirtualResults",value:function(oe){var X=oe.segmentationMask,ce=oe.image,W=this.gl;this.maskBuffer.length<3&&this.maskBuffer.push(X,X,X),this.frameBuffer.length<3&&this.frameBuffer.push(ce,ce,ce);for(var re=[],be=[X,ce,this.img,this.maskBuffer[0],this.maskBuffer[1],this.maskBuffer[2],this.frameBuffer[0],this.frameBuffer[1],this.frameBuffer[2]],ue=0;ue<be.length;++ue)this.sourceTexture=W.createTexture(),W.bindTexture(W.TEXTURE_2D,this.sourceTexture),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_WRAP_S,W.CLAMP_TO_EDGE),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_WRAP_T,W.CLAMP_TO_EDGE),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_MIN_FILTER,W.NEAREST),W.texParameteri(W.TEXTURE_2D,W.TEXTURE_MAG_FILTER,W.NEAREST),W.texImage2D(W.TEXTURE_2D,0,W.RGBA,W.RGBA,W.UNSIGNED_BYTE,be[ue]),re.push(this.sourceTexture);W.bindBuffer(W.ARRAY_BUFFER,this.positionBuffer),this.setRectangle(W,0,0,this.width,this.height),W.viewport(0,0,this.width,this.height),W.clearColor(0,0,0,0),W.clear(W.COLOR_BUFFER_BIT|W.DEPTH_BUFFER_BIT),W.useProgram(this.program),W.bindVertexArray(this.vao);var ye=this.virtualParams,Me=ye.resolutionLocation,Jt=ye.imageLocation0,Zt=ye.imageLocation1,Ke=ye.imageLocation2,qt=ye.imageOldLocation0,ft=ye.imageOldLocation1,Jn=ye.imageOldLocation2,hr=ye.imageOldLocation3,Ht=ye.imageOldLocation4,Rn=ye.imageOldLocation5;W.uniform2f(Me,this.width,this.height);var Ze=this.virtualOption,Gt=Ze.postProcess,qn=Ze.kSize,he=Ze.sigma,de=Ze.bSigma,Ne=Ze.overlayType,ze=Ze.hardThreshold,De=Ze.sigmoidClip,ut=this.virtualLocation,rt=ut.postProcessTypeLocation,Ut=ut.mSizeLocation,en=ut.sigmaLocation,pe=ut.bSigmaLocation,Ot=ut.overlayTypeLocation,Kt=ut.hardThresholdLocation,fr=ut.sigmoidClipLocation;W.uniform1i(rt,Gt),W.uniform1i(Ut,qn),W.uniform1f(en,he),W.uniform1f(pe,de),W.uniform1i(Ot,Ne),W.uniform1f(Kt,ze),W.uniform1i(fr,De),W.uniform1i(Jt,0),W.uniform1i(Zt,1),W.uniform1i(Ke,2),W.uniform1i(qt,3),W.uniform1i(ft,4),W.uniform1i(Jn,5),W.uniform1i(hr,6),W.uniform1i(Ht,7),W.uniform1i(Rn,8),W.activeTexture(W.TEXTURE0),W.bindTexture(W.TEXTURE_2D,re[0]),W.activeTexture(W.TEXTURE1),W.bindTexture(W.TEXTURE_2D,re[1]),W.activeTexture(W.TEXTURE2),W.bindTexture(W.TEXTURE_2D,re[2]),W.activeTexture(W.TEXTURE3),W.bindTexture(W.TEXTURE_2D,re[3]),W.activeTexture(W.TEXTURE4),W.bindTexture(W.TEXTURE_2D,re[4]),W.activeTexture(W.TEXTURE5),W.bindTexture(W.TEXTURE_2D,re[5]),W.activeTexture(W.TEXTURE6),W.bindTexture(W.TEXTURE_2D,re[6]),W.activeTexture(W.TEXTURE7),W.bindTexture(W.TEXTURE_2D,re[7]),W.activeTexture(W.TEXTURE8),W.bindTexture(W.TEXTURE_2D,re[8]),W.drawArrays(W.TRIANGLES,0,6),this.maskBuffer[0]=this.maskBuffer[1],this.maskBuffer[1]=this.maskBuffer[2],this.maskBuffer[2]=X,this.frameBuffer[0]=this.frameBuffer[1],this.frameBuffer[1]=this.frameBuffer[2],this.frameBuffer[2]=ce}}]),le}(),Jo=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};(function(){var le;function Te(d){var g=0;return function(){return g<d.length?{done:!1,value:d[g++]}:{done:!0}}}var Se=typeof Object.defineProperties=="function"?Object.defineProperty:function(d,g,C){return d==Array.prototype||d==Object.prototype||(d[g]=C.value),d},je=function(d){d=[(typeof globalThis=="undefined"?"undefined":$(globalThis))=="object"&&globalThis,d,(typeof window=="undefined"?"undefined":$(window))=="object"&&window,(typeof self=="undefined"?"undefined":$(self))=="object"&&self,$(Jo)=="object"&&Jo];for(var g=0;g<d.length;++g){var C=d[g];if(C&&C.Math==Math)return C}throw Error("Cannot find global object")}(this);function He(d,g){if(g)e:{var C=je;d=d.split(".");for(var O=0;O<d.length-1;O++){var B=d[O];if(!(B in C))break e;C=C[B]}(g=g(O=C[d=d[d.length-1]]))!=O&&g!=null&&Se(C,d,{configurable:!0,writable:!0,value:g})}}function oe(d){return(d={next:d})[Symbol.iterator]=function(){return this},d}function X(d){var g=typeof Symbol!="undefined"&&Symbol.iterator&&d[Symbol.iterator];return g?g.call(d):{next:Te(d)}}function ce(d){if(!(d instanceof Array)){d=X(d);for(var g,C=[];!(g=d.next()).done;)C.push(g.value);d=C}return d}He("Symbol",function(d){function g(B,M){this.h=B,Se(this,"description",{configurable:!0,writable:!0,value:M})}if(d)return d;g.prototype.toString=function(){return this.h};var C="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",O=0;return function B(M){if(this instanceof B)throw new TypeError("Symbol is not a constructor");return new g(C+(M||"")+"_"+O++,M)}}),He("Symbol.iterator",function(d){if(d)return d;d=Symbol("Symbol.iterator");for(var g="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),C=0;C<g.length;C++){var O=je[g[C]];typeof O=="function"&&typeof O.prototype[d]!="function"&&Se(O.prototype,d,{configurable:!0,writable:!0,value:function(){return oe(Te(this))}})}return d});var W=typeof Object.assign=="function"?Object.assign:function(d,g){for(var C=1;C<arguments.length;C++){var O=arguments[C];if(O)for(var B in O)Object.prototype.hasOwnProperty.call(O,B)&&(d[B]=O[B])}return d};He("Object.assign",function(d){return d||W});var re,be=typeof Object.create=="function"?Object.create:function(d){function g(){}return g.prototype=d,new g};if(typeof Object.setPrototypeOf=="function")re=Object.setPrototypeOf;else{var ue;e:{var ye={};try{ye.__proto__={a:!0},ue=ye.a;break e}catch(d){}ue=!1}re=ue?function(d,g){if(d.__proto__=g,d.__proto__!==g)throw new TypeError(d+" is not extensible");return d}:null}var Me=re;function Jt(d,g){if(d.prototype=be(g.prototype),d.prototype.constructor=d,Me)Me(d,g);else for(var C in g)if(C!="prototype")if(Object.defineProperties){var O=Object.getOwnPropertyDescriptor(g,C);O&&Object.defineProperty(d,C,O)}else d[C]=g[C];d.za=g.prototype}function Zt(){this.m=!1,this.j=null,this.i=void 0,this.h=1,this.v=this.s=0,this.l=null}function Ke(d){if(d.m)throw new TypeError("Generator is already running");d.m=!0}function qt(d,g){d.l={ma:g,na:!0},d.h=d.s||d.v}function ft(d,g,C){return d.h=C,{value:g}}function Jn(d){this.h=new Zt,this.i=d}function hr(d,g,C,O){try{var B=g.call(d.h.j,C);if(!(B instanceof Object))throw new TypeError("Iterator result "+B+" is not an object");if(!B.done)return d.h.m=!1,B;var M=B.value}catch(F){return d.h.j=null,qt(d.h,F),Ht(d)}return d.h.j=null,O.call(d.h,M),Ht(d)}function Ht(d){for(;d.h.h;)try{var g=d.i(d.h);if(g)return d.h.m=!1,{value:g.value,done:!1}}catch(C){d.h.i=void 0,qt(d.h,C)}if(d.h.m=!1,d.h.l){if(g=d.h.l,d.h.l=null,g.na)throw g.ma;return{value:g.return,done:!0}}return{value:void 0,done:!0}}function Rn(d){this.next=function(g){return Ke(d.h),d.h.j?g=hr(d,d.h.j.next,g,d.h.u):(d.h.u(g),g=Ht(d)),g},this.throw=function(g){return Ke(d.h),d.h.j?g=hr(d,d.h.j.throw,g,d.h.u):(qt(d.h,g),g=Ht(d)),g},this.return=function(g){return function(C,O){Ke(C.h);var B=C.h.j;return B?hr(C,"return"in B?B.return:function(M){return{value:M,done:!0}},O,C.h.return):(C.h.return(O),Ht(C))}(d,g)},this[Symbol.iterator]=function(){return this}}function Ze(d){return function(g){function C(B){return g.next(B)}function O(B){return g.throw(B)}return new Promise(function(B,M){(function F(z){z.done?B(z.value):Promise.resolve(z.value).then(C,O).then(F,M)})(g.next())})}(new Rn(new Jn(d)))}function Gt(d){return d||Array.prototype.fill}Zt.prototype.u=function(d){this.i=d},Zt.prototype.return=function(d){this.l={return:d},this.h=this.v},He("Promise",function(d){function g(F){this.i=0,this.j=void 0,this.h=[],this.u=!1;var z=this.l();try{F(z.resolve,z.reject)}catch(ee){z.reject(ee)}}function C(){this.h=null}function O(F){return F instanceof g?F:new g(function(z){z(F)})}if(d)return d;C.prototype.i=function(F){if(this.h==null){this.h=[];var z=this;this.j(function(){z.m()})}this.h.push(F)};var B=je.setTimeout;C.prototype.j=function(F){B(F,0)},C.prototype.m=function(){for(;this.h&&this.h.length;){var F=this.h;this.h=[];for(var z=0;z<F.length;++z){var ee=F[z];F[z]=null;try{ee()}catch(fe){this.l(fe)}}}this.h=null},C.prototype.l=function(F){this.j(function(){throw F})},g.prototype.l=function(){function F(fe){return function(me){ee||(ee=!0,fe.call(z,me))}}var z=this,ee=!1;return{resolve:F(this.I),reject:F(this.m)}},g.prototype.I=function(F){if(F===this)this.m(new TypeError("A Promise cannot resolve to itself"));else if(F instanceof g)this.L(F);else{e:switch($(F)){case"object":var z=F!=null;break e;case"function":z=!0;break e;default:z=!1}z?this.F(F):this.s(F)}},g.prototype.F=function(F){var z=void 0;try{z=F.then}catch(ee){return void this.m(ee)}typeof z=="function"?this.M(z,F):this.s(F)},g.prototype.m=function(F){this.v(2,F)},g.prototype.s=function(F){this.v(1,F)},g.prototype.v=function(F,z){if(this.i!=0)throw Error("Cannot settle("+F+", "+z+"): Promise already settled in state"+this.i);this.i=F,this.j=z,this.i===2&&this.K(),this.H()},g.prototype.K=function(){var F=this;B(function(){if(F.D()){var z=je.console;z!==void 0&&z.error(F.j)}},1)},g.prototype.D=function(){if(this.u)return!1;var F=je.CustomEvent,z=je.Event,ee=je.dispatchEvent;return ee===void 0||(typeof F=="function"?F=new F("unhandledrejection",{cancelable:!0}):typeof z=="function"?F=new z("unhandledrejection",{cancelable:!0}):(F=je.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,F),F.promise=this,F.reason=this.j,ee(F))},g.prototype.H=function(){if(this.h!=null){for(var F=0;F<this.h.length;++F)M.i(this.h[F]);this.h=null}};var M=new C;return g.prototype.L=function(F){var z=this.l();F.T(z.resolve,z.reject)},g.prototype.M=function(F,z){var ee=this.l();try{F.call(z,ee.resolve,ee.reject)}catch(fe){ee.reject(fe)}},g.prototype.then=function(F,z){function ee(Ae,ve){return typeof Ae=="function"?function(Oe){try{fe(Ae(Oe))}catch(Be){me(Be)}}:ve}var fe,me,we=new g(function(Ae,ve){fe=Ae,me=ve});return this.T(ee(F,fe),ee(z,me)),we},g.prototype.catch=function(F){return this.then(void 0,F)},g.prototype.T=function(F,z){function ee(){switch(fe.i){case 1:F(fe.j);break;case 2:z(fe.j);break;default:throw Error("Unexpected state: "+fe.i)}}var fe=this;this.h==null?M.i(ee):this.h.push(ee),this.u=!0},g.resolve=O,g.reject=function(F){return new g(function(z,ee){ee(F)})},g.race=function(F){return new g(function(z,ee){for(var fe=X(F),me=fe.next();!me.done;me=fe.next())O(me.value).T(z,ee)})},g.all=function(F){var z=X(F),ee=z.next();return ee.done?O([]):new g(function(fe,me){function we(Oe){return function(Be){Ae[Oe]=Be,--ve==0&&fe(Ae)}}var Ae=[],ve=0;do Ae.push(void 0),ve++,O(ee.value).T(we(Ae.length-1),me),ee=z.next();while(!ee.done)})},g}),He("Array.prototype.keys",function(d){return d||function(){return function(g,C){g instanceof String&&(g+="");var O=0,B=!1,M={next:function(){if(!B&&O<g.length){var F=O++;return{value:C(F,g[F]),done:!1}}return B=!0,{done:!0,value:void 0}}};return M[Symbol.iterator]=function(){return M},M}(this,function(g){return g})}}),He("Array.prototype.fill",function(d){return d||function(g,C,O){var B=this.length||0;for(0>C&&(C=Math.max(0,B+C)),(O==null||O>B)&&(O=B),0>(O=Number(O))&&(O=Math.max(0,B+O)),C=Number(C||0);C<O;C++)this[C]=g;return this}}),He("Int8Array.prototype.fill",Gt),He("Uint8Array.prototype.fill",Gt),He("Uint8ClampedArray.prototype.fill",Gt),He("Int16Array.prototype.fill",Gt),He("Uint16Array.prototype.fill",Gt),He("Int32Array.prototype.fill",Gt),He("Uint32Array.prototype.fill",Gt),He("Float32Array.prototype.fill",Gt),He("Float64Array.prototype.fill",Gt),He("Object.is",function(d){return d||function(g,C){return g===C?g!==0||1/g==1/C:g!=g&&C!=C}}),He("Array.prototype.includes",function(d){return d||function(g,C){var O=this;O instanceof String&&(O=String(O));var B=O.length;for(0>(C=C||0)&&(C=Math.max(C+B,0));C<B;C++){var M=O[C];if(M===g||Object.is(M,g))return!0}return!1}}),He("String.prototype.includes",function(d){return d||function(g,C){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(g instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(g,C||0)!==-1}});var qn=this||self;function he(d,g){d=d.split(".");var C,O=qn;for((d[0]in O)||O.execScript===void 0||O.execScript("var "+d[0]);d.length&&(C=d.shift());)d.length||g===void 0?O=O[C]&&O[C]!==Object.prototype[C]?O[C]:O[C]={}:O[C]=g}function de(d){var g;return(g=qn.navigator)&&(g=g.userAgent)||(g=""),g.indexOf(d)!=-1}var Ne=Array.prototype.map?function(d,g){return Array.prototype.map.call(d,g,void 0)}:function(d,g){for(var C=d.length,O=Array(C),B=typeof d=="string"?d.split(""):d,M=0;M<C;M++)M in B&&(O[M]=g.call(void 0,B[M],M,d));return O},ze={},De=null;function ut(d){var g=d.length,C=3*g/4;C%3?C=Math.floor(C):"=.".indexOf(d[g-1])!=-1&&(C="=.".indexOf(d[g-2])!=-1?C-2:C-1);var O=new Uint8Array(C),B=0;return function(M,F){function z(ve){for(;ee<M.length;){var Oe=M.charAt(ee++),Be=De[Oe];if(Be!=null)return Be;if(!/^[\s\xa0]*$/.test(Oe))throw Error("Unknown base64 encoding at char: "+Oe)}return ve}rt();for(var ee=0;;){var fe=z(-1),me=z(0),we=z(64),Ae=z(64);if(Ae===64&&fe===-1)break;F(fe<<2|me>>4),we!=64&&(F(me<<4&240|we>>2),Ae!=64&&F(we<<6&192|Ae))}}(d,function(M){O[B++]=M}),B!==C?O.subarray(0,B):O}function rt(){if(!De){De={};for(var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),g=["+/=","+/","-_=","-_.","-_"],C=0;5>C;C++){var O=d.concat(g[C].split(""));ze[C]=O;for(var B=0;B<O.length;B++){var M=O[B];De[M]===void 0&&(De[M]=B)}}}}var Ut=typeof Uint8Array!="undefined",en=!(de("Trident")||de("MSIE"))&&typeof qn.btoa=="function";function pe(d){if(!en){var g;g===void 0&&(g=0),rt(),g=ze[g];for(var C=Array(Math.floor(d.length/3)),O=g[64]||"",B=0,M=0;B<d.length-2;B+=3){var F=d[B],z=d[B+1],ee=d[B+2],fe=g[F>>2];F=g[(3&F)<<4|z>>4],z=g[(15&z)<<2|ee>>6],ee=g[63&ee],C[M++]=fe+F+z+ee}switch(fe=0,ee=O,d.length-B){case 2:ee=g[(15&(fe=d[B+1]))<<2]||O;case 1:d=d[B],C[M]=g[d>>2]+g[(3&d)<<4|fe>>4]+ee+O}return C.join("")}for(g="";10240<d.length;)g+=String.fromCharCode.apply(null,d.subarray(0,10240)),d=d.subarray(10240);return g+=String.fromCharCode.apply(null,d),btoa(g)}var Ot,Kt=RegExp("[-_.]","g");function fr(d){switch(d){case"-":return"+";case"_":return"/";case".":return"=";default:return""}}function Di(d){if(!en)return ut(d);Kt.test(d)&&(d=d.replace(Kt,fr)),d=atob(d);for(var g=new Uint8Array(d.length),C=0;C<d.length;C++)g[C]=d.charCodeAt(C);return g}function yn(){return Ot||(Ot=new Uint8Array(0))}var Rt={},Rd=typeof Uint8Array.prototype.slice=="function",Lt=0,pt=0;function Oc(d){var g=0>d,C=(d=Math.abs(d))>>>0;d=Math.floor((d-C)/4294967296),g&&(g=(C=X(ba(C,d))).next().value,d=C.next().value,C=g),Lt=C>>>0,pt=d>>>0}var Lc,bn=typeof BigInt=="function";function ba(d,g){return g=~g,d?d=1+~d:g+=1,[d,g]}function Oi(d,g){this.i=d>>>0,this.h=g>>>0}function Mc(d){if(!d)return Lc||(Lc=new Oi(0,0));if(!/^-?\d+$/.test(d))return null;if(16>d.length)Oc(Number(d));else if(bn)d=BigInt(d),Lt=Number(d&BigInt(4294967295))>>>0,pt=Number(d>>BigInt(32)&BigInt(4294967295));else{var g=+(d[0]==="-");pt=Lt=0;for(var C=d.length,O=g,B=(C-g)%6+g;B<=C;O=B,B+=6)O=Number(d.slice(O,B)),pt*=1e6,4294967296<=(Lt=1e6*Lt+O)&&(pt+=Lt/4294967296|0,Lt%=4294967296);g&&(d=(g=X(ba(Lt,pt))).next().value,g=g.next().value,Lt=d,pt=g)}return new Oi(Lt,pt)}function it(d,g){return Error("Invalid wire type: "+d+" (at position "+g+")")}function Sa(){return Error("Failed to read varint, encoding is invalid.")}function Nc(d,g){return Error("Tried to read past the end of the data "+g+" > "+d)}function at(){throw Error("Invalid UTF8")}function ka(d,g){return g=String.fromCharCode.apply(null,g),d==null?g:d+g}var qo,Uc,An,Sn=void 0,Kn=typeof TextDecoder!="undefined",Vc=typeof TextEncoder!="undefined";function Ta(d){if(d!==Rt)throw Error("illegal external caller")}function Xr(d,g){if(Ta(g),this.V=d,d!=null&&d.length===0)throw Error("ByteString should be constructed with non-empty values")}function Ia(){return An||(An=new Xr(null,Rt))}function Ko(d){Ta(Rt);var g=d.V;return(g=g==null||Ut&&g!=null&&g instanceof Uint8Array?g:typeof g=="string"?Di(g):null)==null?g:d.V=g}function Xo(d,g){this.i=null,this.m=!1,this.h=this.j=this.l=0,pr(this,d,g)}function pr(d,g,C){C=C===void 0?{}:C,d.S=C.S!==void 0&&C.S,g&&(g=function(O){if(typeof O=="string")return{buffer:Di(O),C:!1};if(Array.isArray(O))return{buffer:new Uint8Array(O),C:!1};if(O.constructor===Uint8Array)return{buffer:O,C:!1};if(O.constructor===ArrayBuffer)return{buffer:new Uint8Array(O),C:!1};if(O.constructor===Xr)return{buffer:Ko(O)||yn(),C:!0};if(O instanceof Uint8Array)return{buffer:new Uint8Array(O.buffer,O.byteOffset,O.byteLength),C:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}(g),d.i=g.buffer,d.m=g.C,d.l=0,d.j=d.i.length,d.h=d.l)}function mr(d,g){if(d.h=g,g>d.j)throw Nc(d.j,g)}function Li(d){var g=d.i,C=d.h,O=g[C++],B=127&O;if(128&O&&(B|=(127&(O=g[C++]))<<7,128&O&&(B|=(127&(O=g[C++]))<<14,128&O&&(B|=(127&(O=g[C++]))<<21,128&O&&(B|=(O=g[C++])<<28,128&O&&128&g[C++]&&128&g[C++]&&128&g[C++]&&128&g[C++]&&128&g[C++])))))throw Sa();return mr(d,C),B}function Qo(d,g){if(0>g)throw Error("Tried to read a negative byte length: "+g);var C=d.h,O=C+g;if(O>d.j)throw Nc(g,d.j-C);return d.h=O,C}Xo.prototype.reset=function(){this.h=this.l};var Yo=[];function $o(){this.h=[]}function jc(d,g,C){for(;0<C||127<g;)d.h.push(127&g|128),g=(g>>>7|C<<25)>>>0,C>>>=7;d.h.push(g)}function Ar(d,g){for(;127<g;)d.h.push(127&g|128),g>>>=7;d.h.push(g)}function Zo(d,g){if(Yo.length){var C=Yo.pop();pr(C,d,g),d=C}else d=new Xo(d,g);this.h=d,this.j=this.h.h,this.i=this.l=-1,this.setOptions(g)}function Mi(d){var g=d.h;if(g.h==g.j)return!1;d.j=d.h.h;var C=Li(d.h)>>>0;if(g=C>>>3,!(0<=(C&=7)&&5>=C))throw it(C,d.j);if(1>g)throw Error("Invalid field number: "+g+" (at position "+d.j+")");return d.l=g,d.i=C,!0}function xa(d){switch(d.i){case 0:if(d.i!=0)xa(d);else e:{for(var g=(d=d.h).h,C=g+10,O=d.i;g<C;)if((128&O[g++])==0){mr(d,g);break e}throw Sa()}break;case 1:mr(d=d.h,d.h+8);break;case 2:d.i!=2?xa(d):(g=Li(d.h)>>>0,mr(d=d.h,d.h+g));break;case 5:mr(d=d.h,d.h+4);break;case 3:for(g=d.l;;){if(!Mi(d))throw Error("Unmatched start-group tag: stream EOF");if(d.i==4){if(d.l!=g)throw Error("Unmatched end-group tag");break}xa(d)}break;default:throw it(d.i,d.j)}}$o.prototype.length=function(){return this.h.length},$o.prototype.end=function(){var d=this.h;return this.h=[],d},Zo.prototype.setOptions=function(d){d=d===void 0?{}:d,this.ca=d.ca!==void 0&&d.ca},Zo.prototype.reset=function(){this.h.reset(),this.j=this.h.h,this.i=this.l=-1};var Xn=[];function Ad(){this.j=[],this.i=0,this.h=new $o}function Qr(d,g){g.length!==0&&(d.j.push(g),d.i+=g.length)}var Qn=typeof Symbol=="function"&&$(Symbol())==="symbol"?Symbol():void 0;function Vt(d,g){return Qn?d[Qn]|=g:d.A!==void 0?d.A|=g:(Object.defineProperties(d,{A:{value:g,configurable:!0,writable:!0,enumerable:!1}}),g)}function Bc(d,g){Qn?d[Qn]&&(d[Qn]&=~g):d.A!==void 0&&(d.A&=~g)}function xt(d){var g;return(g=Qn?d[Qn]:d.A)==null?0:g}function Xt(d,g){Qn?d[Qn]=g:d.A!==void 0?d.A=g:Object.defineProperties(d,{A:{value:g,configurable:!0,writable:!0,enumerable:!1}})}function Ni(d){return Vt(d,1),d}function es(d,g){Xt(g,-51&(0|d))}function Yr(d,g){Xt(g,-41&(18|d))}var ts={};function Pr(d){return d!==null&&$(d)==="object"&&!Array.isArray(d)&&d.constructor===Object}var $r,wa,Ca=[];function ns(d){if(2&xt(d.o))throw Error("Cannot mutate an immutable Message")}function Ea(d){var g=d.length;(g=g?d[g-1]:void 0)&&Pr(g)?g.g=1:(g={},d.push((g.g=1,g)))}function Ra(d){var g=d.i+d.G;return d.B||(d.B=d.o[g]={})}function pn(d,g){return g===-1?null:g>=d.i?d.B?d.B[g]:void 0:d.o[g+d.G]}function Pn(d,g,C,O){ns(d),Ui(d,g,C,O)}function Ui(d,g,C,O){d.j&&(d.j=void 0),g>=d.i||O?Ra(d)[g]=C:(d.o[g+d.G]=C,(d=d.B)&&g in d&&delete d[g])}function Mt(d,g,C,O){var B=pn(d,g);Array.isArray(B)||(B=$r);var M=xt(B);if(1&M||Ni(B),O)2&M||Vt(B,2),1&C||Object.freeze(B);else{O=!(2&C);var F=2&M;1&C||!F?O&&16&M&&!F&&Bc(B,16):Ui(d,g,B=Ni(Array.prototype.slice.call(B)))}return B}function rs(d,g){var C=pn(d,g),O=C==null?C:typeof C=="number"||C==="NaN"||C==="Infinity"||C==="-Infinity"?Number(C):void 0;return O!=null&&O!==C&&Ui(d,g,O),O}function Fc(d,g,C,O,B){d.h||(d.h={});var M=d.h[C],F=Mt(d,C,3,B);if(!M){var z=F;M=[];var ee=!!(16&xt(d.o));F=!!(2&xt(z));var fe=z;!B&&F&&(z=Array.prototype.slice.call(z));for(var me=F,we=0;we<z.length;we++){var Ae=z[we],ve=g,Oe=!1;if(Oe=Oe!==void 0&&Oe,(Ae=Array.isArray(Ae)?new ve(Ae):Oe?new ve:void 0)!==void 0){var Be=Oe=xt(ve=Ae.o);F&&(Be|=2),ee&&(Be|=16),Be!=Oe&&Xt(ve,Be),ve=Be,me=me||!!(2&ve),M.push(Ae)}}return d.h[C]=M,g=33|(ee=xt(z)),ee!=(g=me?-9&g:8|g)&&(me=z,Object.isFrozen(me)&&(me=Array.prototype.slice.call(me)),Xt(me,g),z=me),fe!==z&&Ui(d,C,z),(B||O&&F)&&Vt(M,2),O&&Object.freeze(M),M}return B||(B=Object.isFrozen(M),O&&!B?Object.freeze(M):!O&&B&&(M=Array.prototype.slice.call(M),d.h[C]=M)),M}function kt(d,g,C){var O=!!(2&xt(d.o));if(g=Fc(d,g,C,O,O),d=Mt(d,C,3,O),!(O||8&xt(d))){for(O=0;O<g.length;O++){if(2&xt((C=g[O]).o)){var B=Zr(C,!1);B.j=C}else B=C;C!==B&&(g[O]=B,d[O]=B.o)}Vt(d,8)}return g}function Dn(d,g,C){if(C!=null&&typeof C!="number")throw Error("Value of float/double field must be a number|null|undefined, found "+$(C)+": "+C);Pn(d,g,C)}function Hc(d,g,C,O,B){ns(d);var M=Fc(d,C,g,!1,!1);return C=O!=null?O:new C,d=Mt(d,g,2,!1),B!=null?(M.splice(B,0,C),d.splice(B,0,C.o)):(M.push(C),d.push(C.o)),C.C()&&Bc(d,8),C}function Aa(d,g){return d==null?g:d}function On(d,g,C){return C=C===void 0?0:C,Aa(rs(d,g),C)}function Vi(d,g,C,O){if(d!=null){if(Array.isArray(d))d=is(d,g,C,O!==void 0);else if(Pr(d)){var B,M={};for(B in d)M[B]=Vi(d[B],g,C,O);d=M}else d=g(d,O);return d}}function is(d,g,C,O){var B=xt(d);O=O?!!(16&B):void 0,d=Array.prototype.slice.call(d);for(var M=0;M<d.length;M++)d[M]=Vi(d[M],g,C,O);return C(B,d),d}function Pd(d){return d.ja===ts?d.toJSON():function(g){switch($(g)){case"number":return isFinite(g)?g:String(g);case"object":if(g)if(Array.isArray(g)){if((128&xt(g))!=0)return Ea(g=Array.prototype.slice.call(g)),g}else{if(Ut&&g!=null&&g instanceof Uint8Array)return pe(g);if(g instanceof Xr){var C=g.V;return C==null?"":typeof C=="string"?C:g.V=pe(C)}}}return g}(d)}function Gc(d,g){128&d&&Ea(g)}function Wc(d,g,C){if(C=C===void 0?Yr:C,d!=null){if(Ut&&d instanceof Uint8Array)return d.length?new Xr(new Uint8Array(d),Rt):Ia();if(Array.isArray(d)){var O=xt(d);return 2&O?d:!g||32&O||!(16&O||O===0)?(4&(g=xt(d=is(d,Wc,4&O?Yr:C,!0)))&&2&g&&Object.freeze(d),d):(Xt(d,2|O),d)}return d.ja===ts?os(d):d}}function as(d,g,C,O,B,M,F){if(d=d.h&&d.h[C]){if(2&(O=xt(d))?O=d:(Yr(O,M=Ne(d,os)),Object.freeze(M),O=M),ns(g),F=O==null?$r:Ni([]),O!=null){for(M=!!O.length,d=0;d<O.length;d++){var z=O[d];M=M&&!(2&xt(z.o)),F[d]=z.o}M=1|(M?8:0),((d=xt(F))&M)!==M&&(Object.isFrozen(F)&&(F=Array.prototype.slice.call(F)),Xt(F,d|M)),g.h||(g.h={}),g.h[C]=O}else g.h&&(g.h[C]=void 0);Ui(g,C,F,B)}else Pn(g,C,Wc(O,M,F),B)}function os(d){return 2&xt(d.o)||Vt((d=Zr(d,!0)).o,2),d}function Zr(d,g){var C=d.o,O=[];Vt(O,16);var B=d.constructor.h;if(B&&O.push(B),B=d.B){O.length=C.length,O.fill(void 0,O.length,C.length);var M={};O[O.length-1]=M}(128&xt(C))!=0&&Ea(O),g=g||d.C()?Yr:es,M=d.constructor,wa=O,O=new M(O),wa=void 0,d.R&&(O.R=d.R.slice()),M=!!(16&xt(C));for(var F=B?C.length-1:C.length,z=0;z<F;z++)as(d,O,z-d.G,C[z],!1,M,g);if(B)for(var ee in B)as(d,O,+ee,B[ee],!0,M,g);return O}function At(d,g,C){d==null&&(d=wa),wa=void 0;var O,B=this.constructor.i||0,M=0<B,F=this.constructor.h,z=!1;if(d==null){var ee=48,fe=!0;M&&(B=0,ee|=128),Xt(d=F?[F]:[],ee)}else{if(!Array.isArray(d)||F&&F!==d[0])throw Error();var me=ee=Vt(d,0);if((fe=(16&me)!=0)&&((z=(32&me)!=0)||(me|=32)),M){if(128&me)B=0;else if(0<d.length){var we=d[d.length-1];if(Pr(we)&&"g"in we){B=0,me|=128,delete we.g;var Ae,ve=!0;for(Ae in we){ve=!1;break}ve&&d.pop()}}}else if(128&me)throw Error();ee!==me&&Xt(d,me)}if(this.G=(F?0:-1)-B,this.h=void 0,this.o=d,B=(F=this.o.length)-1,F&&Pr(F=this.o[B])?(this.B=F,this.i=B-this.G):g!==void 0&&-1<g?(this.i=Math.max(g,B+1-this.G),this.B=void 0):this.i=Number.MAX_VALUE,!M&&this.B&&"g"in this.B)throw Error('Unexpected "g" flag in sparse object of message that is not a group type.');if(C)for(g=fe&&!z&&!0,M=this.i,fe=0;fe<C.length;fe++)(z=C[fe])<M?(B=d[z+=this.G])?ss(B,g):d[z]=$r:(O||(O=Ra(this)),(B=O[z])?ss(B,g):O[z]=$r)}function ss(d,g){if(Array.isArray(d)){var C=xt(d),O=1;!g||2&C||(O|=16),(C&O)!==O&&Xt(d,C|O)}}function zc(d,g,C){if(C){var O,B={};for(O in C){var M=C[O],F=M.ra;F||(B.J=M.xa||M.oa.W,M.ia?(B.aa=Qc(M.ia),F=function(z){return function(ee,fe,me){return z.J(ee,fe,me,z.aa)}}(B)):M.ka?(B.Z=ji(M.da.P,M.ka),F=function(z){return function(ee,fe,me){return z.J(ee,fe,me,z.Z)}}(B)):F=B.J,M.ra=F),F(g,d,M.da),B={J:B.J,aa:B.aa,Z:B.Z}}}(function(z,ee){if(ee=ee.R){Qr(z,z.h.end());for(var fe=0;fe<ee.length;fe++)Qr(z,Ko(ee[fe])||yn())}})(g,d)}Xt(Ca,23),$r=Object.freeze(Ca),At.prototype.toJSON=function(){return is(this.o,Pd,Gc)},At.prototype.C=function(){return!!(2&xt(this.o))},At.prototype.ja=ts,At.prototype.toString=function(){return this.o.toString()};var tt=Symbol();function Jc(d,g,C){return d[tt]||(d[tt]=function(O,B){return g(O,B,C)})}function cs(d){var g=d[tt];if(!g){var C=ds(d);g=function(O,B){return Zc(O,B,C)},d[tt]=g}return g}function qc(d){var g=function(B){var M=B.ia;return M?cs(M):(M=B.wa)?Jc(B.da.P,M,B.ka):void 0}(d),C=d.da,O=d.oa.U;return g?function(B,M){return O(B,M,C,g)}:function(B,M){return O(B,M,C)}}function Kc(d,g){var C=d[g];return typeof C=="function"&&C.length===0&&(C=C(),d[g]=C),Array.isArray(C)&&(vr in C||Bi in C||0<C.length&&typeof C[0]=="function")?C:void 0}function Xc(d,g,C,O,B,M){g.P=d[0];var F=1;if(d.length>F&&typeof d[F]!="number"){var z=d[F++];C(g,z)}for(;F<d.length;){C=d[F++];for(var ee=F+1;ee<d.length&&typeof d[ee]!="number";)ee++;switch(z=d[F++],ee-=F){case 0:O(g,C,z);break;case 1:(ee=Kc(d,F))?(F++,B(g,C,z,ee)):O(g,C,z,d[F++]);break;case 2:B(g,C,z,ee=Kc(d,ee=F++),d[F++]);break;case 3:M(g,C,z,d[F++],d[F++],d[F++]);break;case 4:M(g,C,z,d[F++],d[F++],d[F++],d[F++]);break;default:throw Error("unexpected number of binary field arguments: "+ee)}}return g}var Pa=Symbol();function Qc(d){var g=d[Pa];if(!g){var C=ls(d);g=function(O,B){return eu(O,B,C)},d[Pa]=g}return g}function ji(d,g){var C=d[Pa];return C||(C=function(O,B){return zc(O,B,g)},d[Pa]=C),C}var Bi=Symbol();function Dd(d,g){d.push(g)}function Da(d,g,C){d.push(g,C.W)}function Yc(d,g,C,O){var B=Qc(O),M=ls(O).P,F=C.W;d.push(g,function(z,ee,fe){return F(z,ee,fe,M,B)})}function us(d,g,C,O,B,M){var F=ji(O,M),z=C.W;d.push(g,function(ee,fe,me){return z(ee,fe,me,O,F)})}function ls(d){var g=d[Bi];return g||(g=Xc(d,d[Bi]=[],Dd,Da,Yc,us),vr in d&&Bi in d&&(d.length=0),g)}var vr=Symbol();function Od(d,g){d[0]=g}function $c(d,g,C,O){var B=C.U;d[g]=O?function(M,F,z){return B(M,F,z,O)}:B}function Ld(d,g,C,O,B){var M=C.U,F=cs(O),z=ds(O).P;d[g]=function(ee,fe,me){return M(ee,fe,me,z,F,B)}}function Md(d,g,C,O,B,M,F){var z=C.U,ee=Jc(O,B,M);d[g]=function(fe,me,we){return z(fe,me,we,O,ee,F)}}function ds(d){var g=d[vr];return g||(g=Xc(d,d[vr]={},Od,$c,Ld,Md),vr in d&&Bi in d&&(d.length=0),g)}function Zc(d,g,C){for(;Mi(g)&&g.i!=4;){var O=g.l,B=C[O];if(!B){var M=C[0];M&&(M=M[O])&&(B=C[O]=qc(M))}if(!B||!B(g,d,O)){O=d,M=(B=g).j,xa(B);var F=B;if(!F.ca){if(B=F.h.h-M,F.h.h=M,F=F.h,B==0)B=Ia();else{if(M=Qo(F,B),F.S&&F.m)B=F.i.subarray(M,M+B);else{F=F.i;var z=M;B=z===(B=M+B)?yn():Rd?F.slice(z,B):new Uint8Array(F.subarray(z,B))}B=B.length==0?Ia():new Xr(B,Rt)}(M=O.R)?M.push(B):O.R=[B]}}}return d}function eu(d,g,C){for(var O=C.length,B=O%2==1,M=B?1:0;M<O;M+=2)(0,C[M+1])(g,d,C[M]);zc(d,g,B?C[0]:void 0)}function Fi(d,g){return{U:d,W:g}}var kn=Fi(function(d,g,C){if(d.i!==5)return!1;var O=(d=d.h).i,B=d.h,M=O[B],F=O[B+1],z=O[B+2];return O=O[B+3],mr(d,d.h+4),d=2*((F=(M<<0|F<<8|z<<16|O<<24)>>>0)>>31)+1,M=F>>>23&255,F&=8388607,Pn(g,C,M==255?F?NaN:1/0*d:M==0?d*Math.pow(2,-149)*F:d*Math.pow(2,M-150)*(F+Math.pow(2,23))),!0},function(d,g,C){if((g=rs(g,C))!=null){Ar(d.h,8*C+5),d=d.h;var O=+g;O===0?0<1/O?Lt=pt=0:(pt=0,Lt=2147483648):isNaN(O)?(pt=0,Lt=2147483647):34028234663852886e22<(O=(C=0>O?-2147483648:0)?-O:O)?(pt=0,Lt=(2139095040|C)>>>0):11754943508222875e-54>O?(O=Math.round(O/Math.pow(2,-149)),pt=0,Lt=(C|O)>>>0):(g=Math.floor(Math.log(O)/Math.LN2),O*=Math.pow(2,-g),16777216<=(O=Math.round(8388608*O))&&++g,pt=0,Lt=(C|g+127<<23|8388607&O)>>>0),C=Lt,d.h.push(C>>>0&255),d.h.push(C>>>8&255),d.h.push(C>>>16&255),d.h.push(C>>>24&255)}}),Nd=Fi(function(d,g,C){if(d.i!==0)return!1;var O=d.h,B=0,M=d=0,F=O.i,z=O.h;do{var ee=F[z++];B|=(127&ee)<<M,M+=7}while(32>M&&128&ee);for(32<M&&(d|=(127&ee)>>4),M=3;32>M&&128&ee;M+=7)d|=(127&(ee=F[z++]))<<M;if(mr(O,z),!(128>ee))throw Sa();return O=B>>>0,(d=2147483648&(ee=d>>>0))&&(ee=~ee>>>0,(O=1+~O>>>0)==0&&(ee=ee+1>>>0)),O=4294967296*ee+(O>>>0),Pn(g,C,d?-O:O),!0},function(d,g,C){(g=pn(g,C))!=null&&(typeof g=="string"&&Mc(g),g!=null&&(Ar(d.h,8*C),typeof g=="number"?(d=d.h,Oc(g),jc(d,Lt,pt)):(C=Mc(g),jc(d.h,C.i,C.h))))}),tu=Fi(function(d,g,C){return d.i===0&&(Pn(g,C,Li(d.h)),!0)},function(d,g,C){if((g=pn(g,C))!=null&&g!=null)if(Ar(d.h,8*C),d=d.h,0<=(C=g))Ar(d,C);else{for(g=0;9>g;g++)d.h.push(127&C|128),C>>=7;d.h.push(1)}}),Pt=Fi(function(d,g,C){if(d.i!==2)return!1;var O=Li(d.h)>>>0,B=Qo(d=d.h,O);if(d=d.i,Kn){var M,F=d;(M=qo)||(M=qo=new TextDecoder("utf-8",{fatal:!0})),d=B+O,F=B===0&&d===F.length?F:F.subarray(B,d);try{var z=M.decode(F)}catch(we){if(Sn===void 0){try{M.decode(new Uint8Array([128]))}catch(Ae){}try{M.decode(new Uint8Array([97])),Sn=!0}catch(Ae){Sn=!1}}throw!Sn&&(qo=void 0),we}}else{O=(z=B)+O,B=[];for(var ee,fe,me=null;z<O;)128>(ee=d[z++])?B.push(ee):224>ee?z>=O?at():(fe=d[z++],194>ee||(192&fe)!=128?(z--,at()):B.push((31&ee)<<6|63&fe)):240>ee?z>=O-1?at():(192&(fe=d[z++]))!=128||ee===224&&160>fe||ee===237&&160<=fe||(192&(F=d[z++]))!=128?(z--,at()):B.push((15&ee)<<12|(63&fe)<<6|63&F):244>=ee?z>=O-2?at():(192&(fe=d[z++]))!=128||fe-144+(ee<<28)>>30!=0||(192&(F=d[z++]))!=128||(192&(M=d[z++]))!=128?(z--,at()):(ee=(7&ee)<<18|(63&fe)<<12|(63&F)<<6|63&M,ee-=65536,B.push(55296+(ee>>10&1023),56320+(1023&ee))):at(),8192<=B.length&&(me=ka(me,B),B.length=0);z=ka(me,B)}return Pn(g,C,z),!0},function(d,g,C){if((g=pn(g,C))!=null){var O=!1;if(O=O!==void 0&&O,Vc){if(O&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(g))throw Error("Found an unpaired surrogate");g=(Uc||(Uc=new TextEncoder)).encode(g)}else{for(var B=0,M=new Uint8Array(3*g.length),F=0;F<g.length;F++){var z=g.charCodeAt(F);if(128>z)M[B++]=z;else{if(2048>z)M[B++]=z>>6|192;else{if(55296<=z&&57343>=z){if(56319>=z&&F<g.length){var ee=g.charCodeAt(++F);if(56320<=ee&&57343>=ee){z=1024*(z-55296)+ee-56320+65536,M[B++]=z>>18|240,M[B++]=z>>12&63|128,M[B++]=z>>6&63|128,M[B++]=63&z|128;continue}F--}if(O)throw Error("Found an unpaired surrogate");z=65533}M[B++]=z>>12|224,M[B++]=z>>6&63|128}M[B++]=63&z|128}}g=B===M.length?M:M.subarray(0,B)}Ar(d.h,8*C+2),Ar(d.h,g.length),Qr(d,d.h.end()),Qr(d,g)}}),hs=Fi(function(d,g,C,O,B){if(d.i!==2)return!1;g=Hc(g,C,O),C=d.h.j,O=Li(d.h)>>>0;var M=d.h.h+O,F=M-C;if(0>=F&&(d.h.j=M,B(g,d,void 0,void 0,void 0),F=M-d.h.h),F)throw Error("Message parsing ended unexpectedly. Expected to read "+O+" bytes, instead read "+(O-F)+" bytes, either the data ended unexpectedly or the message misreported its own length");return d.h.h=M,d.h.j=C,!0},function(d,g,C,O,B){if((g=kt(g,O,C))!=null)for(O=0;O<g.length;O++){var M=d;Ar(M.h,8*C+2);var F=M.h.end();Qr(M,F),F.push(M.i),M=F,B(g[O],d),F=d;var z=M.pop();for(z=F.i+F.h.length()-z;127<z;)M.push(127&z|128),z>>>=7,F.i++;M.push(z),F.i++}});function fs(d){return function(g,C){e:{if(Xn.length){var O=Xn.pop();O.setOptions(C),pr(O.h,g,C),g=O}else g=new Zo(g,C);try{var B=ds(d),M=Zc(new B.P,g,B);break e}finally{(B=g.h).i=null,B.m=!1,B.l=0,B.j=0,B.h=0,B.S=!1,g.l=-1,g.i=-1,100>Xn.length&&Xn.push(g)}M=void 0}return M}}function ps(d){return function(){var g=new Ad;eu(this,g,ls(d)),Qr(g,g.h.end());for(var C=new Uint8Array(g.i),O=g.j,B=O.length,M=0,F=0;F<B;F++){var z=O[F];C.set(z,M),M+=z.length}return g.j=[C],C}}function ei(d){At.call(this,d)}Jt(ei,At);var Tt=[ei,1,tu,2,kn,3,Pt,4,Pt];function ms(d){At.call(this,d,-1,Ud)}ei.prototype.l=ps(Tt),Jt(ms,At),ms.prototype.addClassification=function(d,g){return Hc(this,1,ei,d,g),this};var Ud=[1],Vd=fs([ms,1,hs,Tt]);function gr(d){At.call(this,d)}Jt(gr,At);var vs=[gr,1,kn,2,kn,3,kn,4,kn,5,kn];function nu(d){At.call(this,d,-1,gs)}gr.prototype.l=ps(vs),Jt(nu,At);var gs=[1],jd=fs([nu,1,hs,vs]);function Oa(d){At.call(this,d)}Jt(Oa,At);var ru=[Oa,1,kn,2,kn,3,kn,4,kn,5,kn,6,Nd],Bd=fs(ru);function iu(d,g,C){if(C=d.createShader(C===0?d.VERTEX_SHADER:d.FRAGMENT_SHADER),d.shaderSource(C,g),d.compileShader(C),!d.getShaderParameter(C,d.COMPILE_STATUS))throw Error(`Could not compile WebGL shader.
531
+ `},oe=K.vertexShaderSource,z=K.fragmentShaderSource;this.program=Qe(ae,[oe,z]);var re=ae.getAttribLocation(this.program,"position"),be=ae.getAttribLocation(this.program,"texCoord"),se=this.program;this.virtualParams={resolutionLocation:ae.getUniformLocation(se,"resolution"),imageLocation0:ae.getUniformLocation(se,"u_image0"),imageLocation1:ae.getUniformLocation(se,"u_image1"),imageLocation2:ae.getUniformLocation(se,"u_image2"),imageOldLocation0:ae.getUniformLocation(se,"u_image_old0"),imageOldLocation1:ae.getUniformLocation(se,"u_image_old1"),imageOldLocation2:ae.getUniformLocation(se,"u_image_old2"),imageOldLocation3:ae.getUniformLocation(se,"u_image_old3"),imageOldLocation4:ae.getUniformLocation(se,"u_image_old4"),imageOldLocation5:ae.getUniformLocation(se,"u_image_old5")},this.virtualLocation={postProcessTypeLocation:ae.getUniformLocation(se,"PostProcessType"),sigmaLocation:ae.getUniformLocation(se,"SIGMA"),bSigmaLocation:ae.getUniformLocation(se,"BSIGMA"),mSizeLocation:ae.getUniformLocation(se,"MSIZE"),overlayTypeLocation:ae.getUniformLocation(se,"overlayType"),hardThresholdLocation:ae.getUniformLocation(se,"hardThreshold"),sigmoidClipLocation:ae.getUniformLocation(se,"sigmoidClip")},ae.bindVertexArray(this.vao),ae.bindBuffer(ae.ARRAY_BUFFER,this.positionBuffer),ae.enableVertexAttribArray(re),ae.vertexAttribPointer(re,2,ae.FLOAT,!1,0,0),ae.bindBuffer(ae.ARRAY_BUFFER,ae.createBuffer()),ae.bufferData(ae.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),ae.STATIC_DRAW),ae.enableVertexAttribArray(be),ae.vertexAttribPointer(be,2,ae.FLOAT,!1,0,0)}},{key:"onVirtualResults",value:function(ae){var K=ae.segmentationMask,oe=ae.image,z=this.gl;this.maskBuffer.length<3&&this.maskBuffer.push(K,K,K),this.frameBuffer.length<3&&this.frameBuffer.push(oe,oe,oe);for(var re=[],be=[K,oe,this.img,this.maskBuffer[0],this.maskBuffer[1],this.maskBuffer[2],this.frameBuffer[0],this.frameBuffer[1],this.frameBuffer[2]],se=0;se<be.length;++se)this.sourceTexture=z.createTexture(),z.bindTexture(z.TEXTURE_2D,this.sourceTexture),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_S,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_T,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MIN_FILTER,z.NEAREST),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MAG_FILTER,z.NEAREST),z.texImage2D(z.TEXTURE_2D,0,z.RGBA,z.RGBA,z.UNSIGNED_BYTE,be[se]),re.push(this.sourceTexture);z.bindBuffer(z.ARRAY_BUFFER,this.positionBuffer),this.setRectangle(z,0,0,this.width,this.height),z.viewport(0,0,this.width,this.height),z.clearColor(0,0,0,0),z.clear(z.COLOR_BUFFER_BIT|z.DEPTH_BUFFER_BIT),z.useProgram(this.program),z.bindVertexArray(this.vao);var ye=this.virtualParams,Me=ye.resolutionLocation,Jt=ye.imageLocation0,Zt=ye.imageLocation1,qe=ye.imageLocation2,qt=ye.imageOldLocation0,ft=ye.imageOldLocation1,Jn=ye.imageOldLocation2,hr=ye.imageOldLocation3,Ht=ye.imageOldLocation4,Rn=ye.imageOldLocation5;z.uniform2f(Me,this.width,this.height);var $e=this.virtualOption,Gt=$e.postProcess,qn=$e.kSize,he=$e.sigma,de=$e.bSigma,Ne=$e.overlayType,We=$e.hardThreshold,De=$e.sigmoidClip,ut=this.virtualLocation,rt=ut.postProcessTypeLocation,Ut=ut.mSizeLocation,en=ut.sigmaLocation,pe=ut.bSigmaLocation,Ot=ut.overlayTypeLocation,Kt=ut.hardThresholdLocation,fr=ut.sigmoidClipLocation;z.uniform1i(rt,Gt),z.uniform1i(Ut,qn),z.uniform1f(en,he),z.uniform1f(pe,de),z.uniform1i(Ot,Ne),z.uniform1f(Kt,We),z.uniform1i(fr,De),z.uniform1i(Jt,0),z.uniform1i(Zt,1),z.uniform1i(qe,2),z.uniform1i(qt,3),z.uniform1i(ft,4),z.uniform1i(Jn,5),z.uniform1i(hr,6),z.uniform1i(Ht,7),z.uniform1i(Rn,8),z.activeTexture(z.TEXTURE0),z.bindTexture(z.TEXTURE_2D,re[0]),z.activeTexture(z.TEXTURE1),z.bindTexture(z.TEXTURE_2D,re[1]),z.activeTexture(z.TEXTURE2),z.bindTexture(z.TEXTURE_2D,re[2]),z.activeTexture(z.TEXTURE3),z.bindTexture(z.TEXTURE_2D,re[3]),z.activeTexture(z.TEXTURE4),z.bindTexture(z.TEXTURE_2D,re[4]),z.activeTexture(z.TEXTURE5),z.bindTexture(z.TEXTURE_2D,re[5]),z.activeTexture(z.TEXTURE6),z.bindTexture(z.TEXTURE_2D,re[6]),z.activeTexture(z.TEXTURE7),z.bindTexture(z.TEXTURE_2D,re[7]),z.activeTexture(z.TEXTURE8),z.bindTexture(z.TEXTURE_2D,re[8]),z.drawArrays(z.TRIANGLES,0,6),this.maskBuffer[0]=this.maskBuffer[1],this.maskBuffer[1]=this.maskBuffer[2],this.maskBuffer[2]=K,this.frameBuffer[0]=this.frameBuffer[1],this.frameBuffer[1]=this.frameBuffer[2],this.frameBuffer[2]=oe}}]),ue}(),Jo=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};(function(){var ue;function Te(d){var g=0;return function(){return g<d.length?{done:!1,value:d[g++]}:{done:!0}}}var Se=typeof Object.defineProperties=="function"?Object.defineProperty:function(d,g,C){return d==Array.prototype||d==Object.prototype||(d[g]=C.value),d},je=function(d){d=[(typeof globalThis=="undefined"?"undefined":$(globalThis))=="object"&&globalThis,d,(typeof window=="undefined"?"undefined":$(window))=="object"&&window,(typeof self=="undefined"?"undefined":$(self))=="object"&&self,$(Jo)=="object"&&Jo];for(var g=0;g<d.length;++g){var C=d[g];if(C&&C.Math==Math)return C}throw Error("Cannot find global object")}(this);function He(d,g){if(g)e:{var C=je;d=d.split(".");for(var O=0;O<d.length-1;O++){var j=d[O];if(!(j in C))break e;C=C[j]}(g=g(O=C[d=d[d.length-1]]))!=O&&g!=null&&Se(C,d,{configurable:!0,writable:!0,value:g})}}function ae(d){return(d={next:d})[Symbol.iterator]=function(){return this},d}function K(d){var g=typeof Symbol!="undefined"&&Symbol.iterator&&d[Symbol.iterator];return g?g.call(d):{next:Te(d)}}function oe(d){if(!(d instanceof Array)){d=K(d);for(var g,C=[];!(g=d.next()).done;)C.push(g.value);d=C}return d}He("Symbol",function(d){function g(j,V){this.h=j,Se(this,"description",{configurable:!0,writable:!0,value:V})}if(d)return d;g.prototype.toString=function(){return this.h};var C="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",O=0;return function j(V){if(this instanceof j)throw new TypeError("Symbol is not a constructor");return new g(C+(V||"")+"_"+O++,V)}}),He("Symbol.iterator",function(d){if(d)return d;d=Symbol("Symbol.iterator");for(var g="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),C=0;C<g.length;C++){var O=je[g[C]];typeof O=="function"&&typeof O.prototype[d]!="function"&&Se(O.prototype,d,{configurable:!0,writable:!0,value:function(){return ae(Te(this))}})}return d});var z=typeof Object.assign=="function"?Object.assign:function(d,g){for(var C=1;C<arguments.length;C++){var O=arguments[C];if(O)for(var j in O)Object.prototype.hasOwnProperty.call(O,j)&&(d[j]=O[j])}return d};He("Object.assign",function(d){return d||z});var re,be=typeof Object.create=="function"?Object.create:function(d){function g(){}return g.prototype=d,new g};if(typeof Object.setPrototypeOf=="function")re=Object.setPrototypeOf;else{var se;e:{var ye={};try{ye.__proto__={a:!0},se=ye.a;break e}catch(d){}se=!1}re=se?function(d,g){if(d.__proto__=g,d.__proto__!==g)throw new TypeError(d+" is not extensible");return d}:null}var Me=re;function Jt(d,g){if(d.prototype=be(g.prototype),d.prototype.constructor=d,Me)Me(d,g);else for(var C in g)if(C!="prototype")if(Object.defineProperties){var O=Object.getOwnPropertyDescriptor(g,C);O&&Object.defineProperty(d,C,O)}else d[C]=g[C];d.za=g.prototype}function Zt(){this.m=!1,this.j=null,this.i=void 0,this.h=1,this.v=this.s=0,this.l=null}function qe(d){if(d.m)throw new TypeError("Generator is already running");d.m=!0}function qt(d,g){d.l={ma:g,na:!0},d.h=d.s||d.v}function ft(d,g,C){return d.h=C,{value:g}}function Jn(d){this.h=new Zt,this.i=d}function hr(d,g,C,O){try{var j=g.call(d.h.j,C);if(!(j instanceof Object))throw new TypeError("Iterator result "+j+" is not an object");if(!j.done)return d.h.m=!1,j;var V=j.value}catch(F){return d.h.j=null,qt(d.h,F),Ht(d)}return d.h.j=null,O.call(d.h,V),Ht(d)}function Ht(d){for(;d.h.h;)try{var g=d.i(d.h);if(g)return d.h.m=!1,{value:g.value,done:!1}}catch(C){d.h.i=void 0,qt(d.h,C)}if(d.h.m=!1,d.h.l){if(g=d.h.l,d.h.l=null,g.na)throw g.ma;return{value:g.return,done:!0}}return{value:void 0,done:!0}}function Rn(d){this.next=function(g){return qe(d.h),d.h.j?g=hr(d,d.h.j.next,g,d.h.u):(d.h.u(g),g=Ht(d)),g},this.throw=function(g){return qe(d.h),d.h.j?g=hr(d,d.h.j.throw,g,d.h.u):(qt(d.h,g),g=Ht(d)),g},this.return=function(g){return function(C,O){qe(C.h);var j=C.h.j;return j?hr(C,"return"in j?j.return:function(V){return{value:V,done:!0}},O,C.h.return):(C.h.return(O),Ht(C))}(d,g)},this[Symbol.iterator]=function(){return this}}function $e(d){return function(g){function C(j){return g.next(j)}function O(j){return g.throw(j)}return new Promise(function(j,V){(function F(W){W.done?j(W.value):Promise.resolve(W.value).then(C,O).then(F,V)})(g.next())})}(new Rn(new Jn(d)))}function Gt(d){return d||Array.prototype.fill}Zt.prototype.u=function(d){this.i=d},Zt.prototype.return=function(d){this.l={return:d},this.h=this.v},He("Promise",function(d){function g(F){this.i=0,this.j=void 0,this.h=[],this.u=!1;var W=this.l();try{F(W.resolve,W.reject)}catch(ee){W.reject(ee)}}function C(){this.h=null}function O(F){return F instanceof g?F:new g(function(W){W(F)})}if(d)return d;C.prototype.i=function(F){if(this.h==null){this.h=[];var W=this;this.j(function(){W.m()})}this.h.push(F)};var j=je.setTimeout;C.prototype.j=function(F){j(F,0)},C.prototype.m=function(){for(;this.h&&this.h.length;){var F=this.h;this.h=[];for(var W=0;W<F.length;++W){var ee=F[W];F[W]=null;try{ee()}catch(fe){this.l(fe)}}}this.h=null},C.prototype.l=function(F){this.j(function(){throw F})},g.prototype.l=function(){function F(fe){return function(me){ee||(ee=!0,fe.call(W,me))}}var W=this,ee=!1;return{resolve:F(this.I),reject:F(this.m)}},g.prototype.I=function(F){if(F===this)this.m(new TypeError("A Promise cannot resolve to itself"));else if(F instanceof g)this.L(F);else{e:switch($(F)){case"object":var W=F!=null;break e;case"function":W=!0;break e;default:W=!1}W?this.F(F):this.s(F)}},g.prototype.F=function(F){var W=void 0;try{W=F.then}catch(ee){return void this.m(ee)}typeof W=="function"?this.M(W,F):this.s(F)},g.prototype.m=function(F){this.v(2,F)},g.prototype.s=function(F){this.v(1,F)},g.prototype.v=function(F,W){if(this.i!=0)throw Error("Cannot settle("+F+", "+W+"): Promise already settled in state"+this.i);this.i=F,this.j=W,this.i===2&&this.K(),this.H()},g.prototype.K=function(){var F=this;j(function(){if(F.D()){var W=je.console;W!==void 0&&W.error(F.j)}},1)},g.prototype.D=function(){if(this.u)return!1;var F=je.CustomEvent,W=je.Event,ee=je.dispatchEvent;return ee===void 0||(typeof F=="function"?F=new F("unhandledrejection",{cancelable:!0}):typeof W=="function"?F=new W("unhandledrejection",{cancelable:!0}):(F=je.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,F),F.promise=this,F.reason=this.j,ee(F))},g.prototype.H=function(){if(this.h!=null){for(var F=0;F<this.h.length;++F)V.i(this.h[F]);this.h=null}};var V=new C;return g.prototype.L=function(F){var W=this.l();F.T(W.resolve,W.reject)},g.prototype.M=function(F,W){var ee=this.l();try{F.call(W,ee.resolve,ee.reject)}catch(fe){ee.reject(fe)}},g.prototype.then=function(F,W){function ee(Ae,ve){return typeof Ae=="function"?function(Oe){try{fe(Ae(Oe))}catch(Be){me(Be)}}:ve}var fe,me,Ce=new g(function(Ae,ve){fe=Ae,me=ve});return this.T(ee(F,fe),ee(W,me)),Ce},g.prototype.catch=function(F){return this.then(void 0,F)},g.prototype.T=function(F,W){function ee(){switch(fe.i){case 1:F(fe.j);break;case 2:W(fe.j);break;default:throw Error("Unexpected state: "+fe.i)}}var fe=this;this.h==null?V.i(ee):this.h.push(ee),this.u=!0},g.resolve=O,g.reject=function(F){return new g(function(W,ee){ee(F)})},g.race=function(F){return new g(function(W,ee){for(var fe=K(F),me=fe.next();!me.done;me=fe.next())O(me.value).T(W,ee)})},g.all=function(F){var W=K(F),ee=W.next();return ee.done?O([]):new g(function(fe,me){function Ce(Oe){return function(Be){Ae[Oe]=Be,--ve==0&&fe(Ae)}}var Ae=[],ve=0;do Ae.push(void 0),ve++,O(ee.value).T(Ce(Ae.length-1),me),ee=W.next();while(!ee.done)})},g}),He("Array.prototype.keys",function(d){return d||function(){return function(g,C){g instanceof String&&(g+="");var O=0,j=!1,V={next:function(){if(!j&&O<g.length){var F=O++;return{value:C(F,g[F]),done:!1}}return j=!0,{done:!0,value:void 0}}};return V[Symbol.iterator]=function(){return V},V}(this,function(g){return g})}}),He("Array.prototype.fill",function(d){return d||function(g,C,O){var j=this.length||0;for(0>C&&(C=Math.max(0,j+C)),(O==null||O>j)&&(O=j),0>(O=Number(O))&&(O=Math.max(0,j+O)),C=Number(C||0);C<O;C++)this[C]=g;return this}}),He("Int8Array.prototype.fill",Gt),He("Uint8Array.prototype.fill",Gt),He("Uint8ClampedArray.prototype.fill",Gt),He("Int16Array.prototype.fill",Gt),He("Uint16Array.prototype.fill",Gt),He("Int32Array.prototype.fill",Gt),He("Uint32Array.prototype.fill",Gt),He("Float32Array.prototype.fill",Gt),He("Float64Array.prototype.fill",Gt),He("Object.is",function(d){return d||function(g,C){return g===C?g!==0||1/g==1/C:g!=g&&C!=C}}),He("Array.prototype.includes",function(d){return d||function(g,C){var O=this;O instanceof String&&(O=String(O));var j=O.length;for(0>(C=C||0)&&(C=Math.max(C+j,0));C<j;C++){var V=O[C];if(V===g||Object.is(V,g))return!0}return!1}}),He("String.prototype.includes",function(d){return d||function(g,C){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(g instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(g,C||0)!==-1}});var qn=this||self;function he(d,g){d=d.split(".");var C,O=qn;for((d[0]in O)||O.execScript===void 0||O.execScript("var "+d[0]);d.length&&(C=d.shift());)d.length||g===void 0?O=O[C]&&O[C]!==Object.prototype[C]?O[C]:O[C]={}:O[C]=g}function de(d){var g;return(g=qn.navigator)&&(g=g.userAgent)||(g=""),g.indexOf(d)!=-1}var Ne=Array.prototype.map?function(d,g){return Array.prototype.map.call(d,g,void 0)}:function(d,g){for(var C=d.length,O=Array(C),j=typeof d=="string"?d.split(""):d,V=0;V<C;V++)V in j&&(O[V]=g.call(void 0,j[V],V,d));return O},We={},De=null;function ut(d){var g=d.length,C=3*g/4;C%3?C=Math.floor(C):"=.".indexOf(d[g-1])!=-1&&(C="=.".indexOf(d[g-2])!=-1?C-2:C-1);var O=new Uint8Array(C),j=0;return function(V,F){function W(ve){for(;ee<V.length;){var Oe=V.charAt(ee++),Be=De[Oe];if(Be!=null)return Be;if(!/^[\s\xa0]*$/.test(Oe))throw Error("Unknown base64 encoding at char: "+Oe)}return ve}rt();for(var ee=0;;){var fe=W(-1),me=W(0),Ce=W(64),Ae=W(64);if(Ae===64&&fe===-1)break;F(fe<<2|me>>4),Ce!=64&&(F(me<<4&240|Ce>>2),Ae!=64&&F(Ce<<6&192|Ae))}}(d,function(V){O[j++]=V}),j!==C?O.subarray(0,j):O}function rt(){if(!De){De={};for(var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),g=["+/=","+/","-_=","-_.","-_"],C=0;5>C;C++){var O=d.concat(g[C].split(""));We[C]=O;for(var j=0;j<O.length;j++){var V=O[j];De[V]===void 0&&(De[V]=j)}}}}var Ut=typeof Uint8Array!="undefined",en=!(de("Trident")||de("MSIE"))&&typeof qn.btoa=="function";function pe(d){if(!en){var g;g===void 0&&(g=0),rt(),g=We[g];for(var C=Array(Math.floor(d.length/3)),O=g[64]||"",j=0,V=0;j<d.length-2;j+=3){var F=d[j],W=d[j+1],ee=d[j+2],fe=g[F>>2];F=g[(3&F)<<4|W>>4],W=g[(15&W)<<2|ee>>6],ee=g[63&ee],C[V++]=fe+F+W+ee}switch(fe=0,ee=O,d.length-j){case 2:ee=g[(15&(fe=d[j+1]))<<2]||O;case 1:d=d[j],C[V]=g[d>>2]+g[(3&d)<<4|fe>>4]+ee+O}return C.join("")}for(g="";10240<d.length;)g+=String.fromCharCode.apply(null,d.subarray(0,10240)),d=d.subarray(10240);return g+=String.fromCharCode.apply(null,d),btoa(g)}var Ot,Kt=RegExp("[-_.]","g");function fr(d){switch(d){case"-":return"+";case"_":return"/";case".":return"=";default:return""}}function Di(d){if(!en)return ut(d);Kt.test(d)&&(d=d.replace(Kt,fr)),d=atob(d);for(var g=new Uint8Array(d.length),C=0;C<d.length;C++)g[C]=d.charCodeAt(C);return g}function yn(){return Ot||(Ot=new Uint8Array(0))}var Rt={},Cd=typeof Uint8Array.prototype.slice=="function",Lt=0,pt=0;function Dc(d){var g=0>d,C=(d=Math.abs(d))>>>0;d=Math.floor((d-C)/4294967296),g&&(g=(C=K(ba(C,d))).next().value,d=C.next().value,C=g),Lt=C>>>0,pt=d>>>0}var Oc,bn=typeof BigInt=="function";function ba(d,g){return g=~g,d?d=1+~d:g+=1,[d,g]}function Oi(d,g){this.i=d>>>0,this.h=g>>>0}function Lc(d){if(!d)return Oc||(Oc=new Oi(0,0));if(!/^-?\d+$/.test(d))return null;if(16>d.length)Dc(Number(d));else if(bn)d=BigInt(d),Lt=Number(d&BigInt(4294967295))>>>0,pt=Number(d>>BigInt(32)&BigInt(4294967295));else{var g=+(d[0]==="-");pt=Lt=0;for(var C=d.length,O=g,j=(C-g)%6+g;j<=C;O=j,j+=6)O=Number(d.slice(O,j)),pt*=1e6,4294967296<=(Lt=1e6*Lt+O)&&(pt+=Lt/4294967296|0,Lt%=4294967296);g&&(d=(g=K(ba(Lt,pt))).next().value,g=g.next().value,Lt=d,pt=g)}return new Oi(Lt,pt)}function it(d,g){return Error("Invalid wire type: "+d+" (at position "+g+")")}function Sa(){return Error("Failed to read varint, encoding is invalid.")}function Mc(d,g){return Error("Tried to read past the end of the data "+g+" > "+d)}function at(){throw Error("Invalid UTF8")}function ka(d,g){return g=String.fromCharCode.apply(null,g),d==null?g:d+g}var qo,Nc,An,Sn=void 0,Kn=typeof TextDecoder!="undefined",Uc=typeof TextEncoder!="undefined";function Ta(d){if(d!==Rt)throw Error("illegal external caller")}function Xr(d,g){if(Ta(g),this.V=d,d!=null&&d.length===0)throw Error("ByteString should be constructed with non-empty values")}function Ia(){return An||(An=new Xr(null,Rt))}function Ko(d){Ta(Rt);var g=d.V;return(g=g==null||Ut&&g!=null&&g instanceof Uint8Array?g:typeof g=="string"?Di(g):null)==null?g:d.V=g}function Xo(d,g){this.i=null,this.m=!1,this.h=this.j=this.l=0,pr(this,d,g)}function pr(d,g,C){C=C===void 0?{}:C,d.S=C.S!==void 0&&C.S,g&&(g=function(O){if(typeof O=="string")return{buffer:Di(O),C:!1};if(Array.isArray(O))return{buffer:new Uint8Array(O),C:!1};if(O.constructor===Uint8Array)return{buffer:O,C:!1};if(O.constructor===ArrayBuffer)return{buffer:new Uint8Array(O),C:!1};if(O.constructor===Xr)return{buffer:Ko(O)||yn(),C:!0};if(O instanceof Uint8Array)return{buffer:new Uint8Array(O.buffer,O.byteOffset,O.byteLength),C:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}(g),d.i=g.buffer,d.m=g.C,d.l=0,d.j=d.i.length,d.h=d.l)}function mr(d,g){if(d.h=g,g>d.j)throw Mc(d.j,g)}function Li(d){var g=d.i,C=d.h,O=g[C++],j=127&O;if(128&O&&(j|=(127&(O=g[C++]))<<7,128&O&&(j|=(127&(O=g[C++]))<<14,128&O&&(j|=(127&(O=g[C++]))<<21,128&O&&(j|=(O=g[C++])<<28,128&O&&128&g[C++]&&128&g[C++]&&128&g[C++]&&128&g[C++]&&128&g[C++])))))throw Sa();return mr(d,C),j}function Qo(d,g){if(0>g)throw Error("Tried to read a negative byte length: "+g);var C=d.h,O=C+g;if(O>d.j)throw Mc(g,d.j-C);return d.h=O,C}Xo.prototype.reset=function(){this.h=this.l};var Yo=[];function $o(){this.h=[]}function Vc(d,g,C){for(;0<C||127<g;)d.h.push(127&g|128),g=(g>>>7|C<<25)>>>0,C>>>=7;d.h.push(g)}function Ar(d,g){for(;127<g;)d.h.push(127&g|128),g>>>=7;d.h.push(g)}function Zo(d,g){if(Yo.length){var C=Yo.pop();pr(C,d,g),d=C}else d=new Xo(d,g);this.h=d,this.j=this.h.h,this.i=this.l=-1,this.setOptions(g)}function Mi(d){var g=d.h;if(g.h==g.j)return!1;d.j=d.h.h;var C=Li(d.h)>>>0;if(g=C>>>3,!(0<=(C&=7)&&5>=C))throw it(C,d.j);if(1>g)throw Error("Invalid field number: "+g+" (at position "+d.j+")");return d.l=g,d.i=C,!0}function xa(d){switch(d.i){case 0:if(d.i!=0)xa(d);else e:{for(var g=(d=d.h).h,C=g+10,O=d.i;g<C;)if((128&O[g++])==0){mr(d,g);break e}throw Sa()}break;case 1:mr(d=d.h,d.h+8);break;case 2:d.i!=2?xa(d):(g=Li(d.h)>>>0,mr(d=d.h,d.h+g));break;case 5:mr(d=d.h,d.h+4);break;case 3:for(g=d.l;;){if(!Mi(d))throw Error("Unmatched start-group tag: stream EOF");if(d.i==4){if(d.l!=g)throw Error("Unmatched end-group tag");break}xa(d)}break;default:throw it(d.i,d.j)}}$o.prototype.length=function(){return this.h.length},$o.prototype.end=function(){var d=this.h;return this.h=[],d},Zo.prototype.setOptions=function(d){d=d===void 0?{}:d,this.ca=d.ca!==void 0&&d.ca},Zo.prototype.reset=function(){this.h.reset(),this.j=this.h.h,this.i=this.l=-1};var Xn=[];function Ed(){this.j=[],this.i=0,this.h=new $o}function Qr(d,g){g.length!==0&&(d.j.push(g),d.i+=g.length)}var Qn=typeof Symbol=="function"&&$(Symbol())==="symbol"?Symbol():void 0;function Vt(d,g){return Qn?d[Qn]|=g:d.A!==void 0?d.A|=g:(Object.defineProperties(d,{A:{value:g,configurable:!0,writable:!0,enumerable:!1}}),g)}function jc(d,g){Qn?d[Qn]&&(d[Qn]&=~g):d.A!==void 0&&(d.A&=~g)}function xt(d){var g;return(g=Qn?d[Qn]:d.A)==null?0:g}function Xt(d,g){Qn?d[Qn]=g:d.A!==void 0?d.A=g:Object.defineProperties(d,{A:{value:g,configurable:!0,writable:!0,enumerable:!1}})}function Ni(d){return Vt(d,1),d}function es(d,g){Xt(g,-51&(0|d))}function Yr(d,g){Xt(g,-41&(18|d))}var ts={};function Pr(d){return d!==null&&$(d)==="object"&&!Array.isArray(d)&&d.constructor===Object}var $r,wa,Ca=[];function ns(d){if(2&xt(d.o))throw Error("Cannot mutate an immutable Message")}function Ea(d){var g=d.length;(g=g?d[g-1]:void 0)&&Pr(g)?g.g=1:(g={},d.push((g.g=1,g)))}function Ra(d){var g=d.i+d.G;return d.B||(d.B=d.o[g]={})}function pn(d,g){return g===-1?null:g>=d.i?d.B?d.B[g]:void 0:d.o[g+d.G]}function Pn(d,g,C,O){ns(d),Ui(d,g,C,O)}function Ui(d,g,C,O){d.j&&(d.j=void 0),g>=d.i||O?Ra(d)[g]=C:(d.o[g+d.G]=C,(d=d.B)&&g in d&&delete d[g])}function Mt(d,g,C,O){var j=pn(d,g);Array.isArray(j)||(j=$r);var V=xt(j);if(1&V||Ni(j),O)2&V||Vt(j,2),1&C||Object.freeze(j);else{O=!(2&C);var F=2&V;1&C||!F?O&&16&V&&!F&&jc(j,16):Ui(d,g,j=Ni(Array.prototype.slice.call(j)))}return j}function rs(d,g){var C=pn(d,g),O=C==null?C:typeof C=="number"||C==="NaN"||C==="Infinity"||C==="-Infinity"?Number(C):void 0;return O!=null&&O!==C&&Ui(d,g,O),O}function Bc(d,g,C,O,j){d.h||(d.h={});var V=d.h[C],F=Mt(d,C,3,j);if(!V){var W=F;V=[];var ee=!!(16&xt(d.o));F=!!(2&xt(W));var fe=W;!j&&F&&(W=Array.prototype.slice.call(W));for(var me=F,Ce=0;Ce<W.length;Ce++){var Ae=W[Ce],ve=g,Oe=!1;if(Oe=Oe!==void 0&&Oe,(Ae=Array.isArray(Ae)?new ve(Ae):Oe?new ve:void 0)!==void 0){var Be=Oe=xt(ve=Ae.o);F&&(Be|=2),ee&&(Be|=16),Be!=Oe&&Xt(ve,Be),ve=Be,me=me||!!(2&ve),V.push(Ae)}}return d.h[C]=V,g=33|(ee=xt(W)),ee!=(g=me?-9&g:8|g)&&(me=W,Object.isFrozen(me)&&(me=Array.prototype.slice.call(me)),Xt(me,g),W=me),fe!==W&&Ui(d,C,W),(j||O&&F)&&Vt(V,2),O&&Object.freeze(V),V}return j||(j=Object.isFrozen(V),O&&!j?Object.freeze(V):!O&&j&&(V=Array.prototype.slice.call(V),d.h[C]=V)),V}function kt(d,g,C){var O=!!(2&xt(d.o));if(g=Bc(d,g,C,O,O),d=Mt(d,C,3,O),!(O||8&xt(d))){for(O=0;O<g.length;O++){if(2&xt((C=g[O]).o)){var j=Zr(C,!1);j.j=C}else j=C;C!==j&&(g[O]=j,d[O]=j.o)}Vt(d,8)}return g}function Dn(d,g,C){if(C!=null&&typeof C!="number")throw Error("Value of float/double field must be a number|null|undefined, found "+$(C)+": "+C);Pn(d,g,C)}function Fc(d,g,C,O,j){ns(d);var V=Bc(d,C,g,!1,!1);return C=O!=null?O:new C,d=Mt(d,g,2,!1),j!=null?(V.splice(j,0,C),d.splice(j,0,C.o)):(V.push(C),d.push(C.o)),C.C()&&jc(d,8),C}function Aa(d,g){return d==null?g:d}function On(d,g,C){return C=C===void 0?0:C,Aa(rs(d,g),C)}function Vi(d,g,C,O){if(d!=null){if(Array.isArray(d))d=is(d,g,C,O!==void 0);else if(Pr(d)){var j,V={};for(j in d)V[j]=Vi(d[j],g,C,O);d=V}else d=g(d,O);return d}}function is(d,g,C,O){var j=xt(d);O=O?!!(16&j):void 0,d=Array.prototype.slice.call(d);for(var V=0;V<d.length;V++)d[V]=Vi(d[V],g,C,O);return C(j,d),d}function Rd(d){return d.ja===ts?d.toJSON():function(g){switch($(g)){case"number":return isFinite(g)?g:String(g);case"object":if(g)if(Array.isArray(g)){if((128&xt(g))!=0)return Ea(g=Array.prototype.slice.call(g)),g}else{if(Ut&&g!=null&&g instanceof Uint8Array)return pe(g);if(g instanceof Xr){var C=g.V;return C==null?"":typeof C=="string"?C:g.V=pe(C)}}}return g}(d)}function Hc(d,g){128&d&&Ea(g)}function Gc(d,g,C){if(C=C===void 0?Yr:C,d!=null){if(Ut&&d instanceof Uint8Array)return d.length?new Xr(new Uint8Array(d),Rt):Ia();if(Array.isArray(d)){var O=xt(d);return 2&O?d:!g||32&O||!(16&O||O===0)?(4&(g=xt(d=is(d,Gc,4&O?Yr:C,!0)))&&2&g&&Object.freeze(d),d):(Xt(d,2|O),d)}return d.ja===ts?os(d):d}}function as(d,g,C,O,j,V,F){if(d=d.h&&d.h[C]){if(2&(O=xt(d))?O=d:(Yr(O,V=Ne(d,os)),Object.freeze(V),O=V),ns(g),F=O==null?$r:Ni([]),O!=null){for(V=!!O.length,d=0;d<O.length;d++){var W=O[d];V=V&&!(2&xt(W.o)),F[d]=W.o}V=1|(V?8:0),((d=xt(F))&V)!==V&&(Object.isFrozen(F)&&(F=Array.prototype.slice.call(F)),Xt(F,d|V)),g.h||(g.h={}),g.h[C]=O}else g.h&&(g.h[C]=void 0);Ui(g,C,F,j)}else Pn(g,C,Gc(O,V,F),j)}function os(d){return 2&xt(d.o)||Vt((d=Zr(d,!0)).o,2),d}function Zr(d,g){var C=d.o,O=[];Vt(O,16);var j=d.constructor.h;if(j&&O.push(j),j=d.B){O.length=C.length,O.fill(void 0,O.length,C.length);var V={};O[O.length-1]=V}(128&xt(C))!=0&&Ea(O),g=g||d.C()?Yr:es,V=d.constructor,wa=O,O=new V(O),wa=void 0,d.R&&(O.R=d.R.slice()),V=!!(16&xt(C));for(var F=j?C.length-1:C.length,W=0;W<F;W++)as(d,O,W-d.G,C[W],!1,V,g);if(j)for(var ee in j)as(d,O,+ee,j[ee],!0,V,g);return O}function At(d,g,C){d==null&&(d=wa),wa=void 0;var O,j=this.constructor.i||0,V=0<j,F=this.constructor.h,W=!1;if(d==null){var ee=48,fe=!0;V&&(j=0,ee|=128),Xt(d=F?[F]:[],ee)}else{if(!Array.isArray(d)||F&&F!==d[0])throw Error();var me=ee=Vt(d,0);if((fe=(16&me)!=0)&&((W=(32&me)!=0)||(me|=32)),V){if(128&me)j=0;else if(0<d.length){var Ce=d[d.length-1];if(Pr(Ce)&&"g"in Ce){j=0,me|=128,delete Ce.g;var Ae,ve=!0;for(Ae in Ce){ve=!1;break}ve&&d.pop()}}}else if(128&me)throw Error();ee!==me&&Xt(d,me)}if(this.G=(F?0:-1)-j,this.h=void 0,this.o=d,j=(F=this.o.length)-1,F&&Pr(F=this.o[j])?(this.B=F,this.i=j-this.G):g!==void 0&&-1<g?(this.i=Math.max(g,j+1-this.G),this.B=void 0):this.i=Number.MAX_VALUE,!V&&this.B&&"g"in this.B)throw Error('Unexpected "g" flag in sparse object of message that is not a group type.');if(C)for(g=fe&&!W&&!0,V=this.i,fe=0;fe<C.length;fe++)(W=C[fe])<V?(j=d[W+=this.G])?ss(j,g):d[W]=$r:(O||(O=Ra(this)),(j=O[W])?ss(j,g):O[W]=$r)}function ss(d,g){if(Array.isArray(d)){var C=xt(d),O=1;!g||2&C||(O|=16),(C&O)!==O&&Xt(d,C|O)}}function zc(d,g,C){if(C){var O,j={};for(O in C){var V=C[O],F=V.ra;F||(j.J=V.xa||V.oa.W,V.ia?(j.aa=Xc(V.ia),F=function(W){return function(ee,fe,me){return W.J(ee,fe,me,W.aa)}}(j)):V.ka?(j.Z=ji(V.da.P,V.ka),F=function(W){return function(ee,fe,me){return W.J(ee,fe,me,W.Z)}}(j)):F=j.J,V.ra=F),F(g,d,V.da),j={J:j.J,aa:j.aa,Z:j.Z}}}(function(W,ee){if(ee=ee.R){Qr(W,W.h.end());for(var fe=0;fe<ee.length;fe++)Qr(W,Ko(ee[fe])||yn())}})(g,d)}Xt(Ca,23),$r=Object.freeze(Ca),At.prototype.toJSON=function(){return is(this.o,Rd,Hc)},At.prototype.C=function(){return!!(2&xt(this.o))},At.prototype.ja=ts,At.prototype.toString=function(){return this.o.toString()};var tt=Symbol();function Wc(d,g,C){return d[tt]||(d[tt]=function(O,j){return g(O,j,C)})}function cs(d){var g=d[tt];if(!g){var C=ds(d);g=function(O,j){return $c(O,j,C)},d[tt]=g}return g}function Jc(d){var g=function(j){var V=j.ia;return V?cs(V):(V=j.wa)?Wc(j.da.P,V,j.ka):void 0}(d),C=d.da,O=d.oa.U;return g?function(j,V){return O(j,V,C,g)}:function(j,V){return O(j,V,C)}}function qc(d,g){var C=d[g];return typeof C=="function"&&C.length===0&&(C=C(),d[g]=C),Array.isArray(C)&&(vr in C||Bi in C||0<C.length&&typeof C[0]=="function")?C:void 0}function Kc(d,g,C,O,j,V){g.P=d[0];var F=1;if(d.length>F&&typeof d[F]!="number"){var W=d[F++];C(g,W)}for(;F<d.length;){C=d[F++];for(var ee=F+1;ee<d.length&&typeof d[ee]!="number";)ee++;switch(W=d[F++],ee-=F){case 0:O(g,C,W);break;case 1:(ee=qc(d,F))?(F++,j(g,C,W,ee)):O(g,C,W,d[F++]);break;case 2:j(g,C,W,ee=qc(d,ee=F++),d[F++]);break;case 3:V(g,C,W,d[F++],d[F++],d[F++]);break;case 4:V(g,C,W,d[F++],d[F++],d[F++],d[F++]);break;default:throw Error("unexpected number of binary field arguments: "+ee)}}return g}var Pa=Symbol();function Xc(d){var g=d[Pa];if(!g){var C=ls(d);g=function(O,j){return Zc(O,j,C)},d[Pa]=g}return g}function ji(d,g){var C=d[Pa];return C||(C=function(O,j){return zc(O,j,g)},d[Pa]=C),C}var Bi=Symbol();function Ad(d,g){d.push(g)}function Da(d,g,C){d.push(g,C.W)}function Qc(d,g,C,O){var j=Xc(O),V=ls(O).P,F=C.W;d.push(g,function(W,ee,fe){return F(W,ee,fe,V,j)})}function us(d,g,C,O,j,V){var F=ji(O,V),W=C.W;d.push(g,function(ee,fe,me){return W(ee,fe,me,O,F)})}function ls(d){var g=d[Bi];return g||(g=Kc(d,d[Bi]=[],Ad,Da,Qc,us),vr in d&&Bi in d&&(d.length=0),g)}var vr=Symbol();function Pd(d,g){d[0]=g}function Yc(d,g,C,O){var j=C.U;d[g]=O?function(V,F,W){return j(V,F,W,O)}:j}function Dd(d,g,C,O,j){var V=C.U,F=cs(O),W=ds(O).P;d[g]=function(ee,fe,me){return V(ee,fe,me,W,F,j)}}function Od(d,g,C,O,j,V,F){var W=C.U,ee=Wc(O,j,V);d[g]=function(fe,me,Ce){return W(fe,me,Ce,O,ee,F)}}function ds(d){var g=d[vr];return g||(g=Kc(d,d[vr]={},Pd,Yc,Dd,Od),vr in d&&Bi in d&&(d.length=0),g)}function $c(d,g,C){for(;Mi(g)&&g.i!=4;){var O=g.l,j=C[O];if(!j){var V=C[0];V&&(V=V[O])&&(j=C[O]=Jc(V))}if(!j||!j(g,d,O)){O=d,V=(j=g).j,xa(j);var F=j;if(!F.ca){if(j=F.h.h-V,F.h.h=V,F=F.h,j==0)j=Ia();else{if(V=Qo(F,j),F.S&&F.m)j=F.i.subarray(V,V+j);else{F=F.i;var W=V;j=W===(j=V+j)?yn():Cd?F.slice(W,j):new Uint8Array(F.subarray(W,j))}j=j.length==0?Ia():new Xr(j,Rt)}(V=O.R)?V.push(j):O.R=[j]}}}return d}function Zc(d,g,C){for(var O=C.length,j=O%2==1,V=j?1:0;V<O;V+=2)(0,C[V+1])(g,d,C[V]);zc(d,g,j?C[0]:void 0)}function Fi(d,g){return{U:d,W:g}}var kn=Fi(function(d,g,C){if(d.i!==5)return!1;var O=(d=d.h).i,j=d.h,V=O[j],F=O[j+1],W=O[j+2];return O=O[j+3],mr(d,d.h+4),d=2*((F=(V<<0|F<<8|W<<16|O<<24)>>>0)>>31)+1,V=F>>>23&255,F&=8388607,Pn(g,C,V==255?F?NaN:1/0*d:V==0?d*Math.pow(2,-149)*F:d*Math.pow(2,V-150)*(F+Math.pow(2,23))),!0},function(d,g,C){if((g=rs(g,C))!=null){Ar(d.h,8*C+5),d=d.h;var O=+g;O===0?0<1/O?Lt=pt=0:(pt=0,Lt=2147483648):isNaN(O)?(pt=0,Lt=2147483647):34028234663852886e22<(O=(C=0>O?-2147483648:0)?-O:O)?(pt=0,Lt=(2139095040|C)>>>0):11754943508222875e-54>O?(O=Math.round(O/Math.pow(2,-149)),pt=0,Lt=(C|O)>>>0):(g=Math.floor(Math.log(O)/Math.LN2),O*=Math.pow(2,-g),16777216<=(O=Math.round(8388608*O))&&++g,pt=0,Lt=(C|g+127<<23|8388607&O)>>>0),C=Lt,d.h.push(C>>>0&255),d.h.push(C>>>8&255),d.h.push(C>>>16&255),d.h.push(C>>>24&255)}}),Ld=Fi(function(d,g,C){if(d.i!==0)return!1;var O=d.h,j=0,V=d=0,F=O.i,W=O.h;do{var ee=F[W++];j|=(127&ee)<<V,V+=7}while(32>V&&128&ee);for(32<V&&(d|=(127&ee)>>4),V=3;32>V&&128&ee;V+=7)d|=(127&(ee=F[W++]))<<V;if(mr(O,W),!(128>ee))throw Sa();return O=j>>>0,(d=2147483648&(ee=d>>>0))&&(ee=~ee>>>0,(O=1+~O>>>0)==0&&(ee=ee+1>>>0)),O=4294967296*ee+(O>>>0),Pn(g,C,d?-O:O),!0},function(d,g,C){(g=pn(g,C))!=null&&(typeof g=="string"&&Lc(g),g!=null&&(Ar(d.h,8*C),typeof g=="number"?(d=d.h,Dc(g),Vc(d,Lt,pt)):(C=Lc(g),Vc(d.h,C.i,C.h))))}),eu=Fi(function(d,g,C){return d.i===0&&(Pn(g,C,Li(d.h)),!0)},function(d,g,C){if((g=pn(g,C))!=null&&g!=null)if(Ar(d.h,8*C),d=d.h,0<=(C=g))Ar(d,C);else{for(g=0;9>g;g++)d.h.push(127&C|128),C>>=7;d.h.push(1)}}),Pt=Fi(function(d,g,C){if(d.i!==2)return!1;var O=Li(d.h)>>>0,j=Qo(d=d.h,O);if(d=d.i,Kn){var V,F=d;(V=qo)||(V=qo=new TextDecoder("utf-8",{fatal:!0})),d=j+O,F=j===0&&d===F.length?F:F.subarray(j,d);try{var W=V.decode(F)}catch(Ce){if(Sn===void 0){try{V.decode(new Uint8Array([128]))}catch(Ae){}try{V.decode(new Uint8Array([97])),Sn=!0}catch(Ae){Sn=!1}}throw!Sn&&(qo=void 0),Ce}}else{O=(W=j)+O,j=[];for(var ee,fe,me=null;W<O;)128>(ee=d[W++])?j.push(ee):224>ee?W>=O?at():(fe=d[W++],194>ee||(192&fe)!=128?(W--,at()):j.push((31&ee)<<6|63&fe)):240>ee?W>=O-1?at():(192&(fe=d[W++]))!=128||ee===224&&160>fe||ee===237&&160<=fe||(192&(F=d[W++]))!=128?(W--,at()):j.push((15&ee)<<12|(63&fe)<<6|63&F):244>=ee?W>=O-2?at():(192&(fe=d[W++]))!=128||fe-144+(ee<<28)>>30!=0||(192&(F=d[W++]))!=128||(192&(V=d[W++]))!=128?(W--,at()):(ee=(7&ee)<<18|(63&fe)<<12|(63&F)<<6|63&V,ee-=65536,j.push(55296+(ee>>10&1023),56320+(1023&ee))):at(),8192<=j.length&&(me=ka(me,j),j.length=0);W=ka(me,j)}return Pn(g,C,W),!0},function(d,g,C){if((g=pn(g,C))!=null){var O=!1;if(O=O!==void 0&&O,Uc){if(O&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(g))throw Error("Found an unpaired surrogate");g=(Nc||(Nc=new TextEncoder)).encode(g)}else{for(var j=0,V=new Uint8Array(3*g.length),F=0;F<g.length;F++){var W=g.charCodeAt(F);if(128>W)V[j++]=W;else{if(2048>W)V[j++]=W>>6|192;else{if(55296<=W&&57343>=W){if(56319>=W&&F<g.length){var ee=g.charCodeAt(++F);if(56320<=ee&&57343>=ee){W=1024*(W-55296)+ee-56320+65536,V[j++]=W>>18|240,V[j++]=W>>12&63|128,V[j++]=W>>6&63|128,V[j++]=63&W|128;continue}F--}if(O)throw Error("Found an unpaired surrogate");W=65533}V[j++]=W>>12|224,V[j++]=W>>6&63|128}V[j++]=63&W|128}}g=j===V.length?V:V.subarray(0,j)}Ar(d.h,8*C+2),Ar(d.h,g.length),Qr(d,d.h.end()),Qr(d,g)}}),hs=Fi(function(d,g,C,O,j){if(d.i!==2)return!1;g=Fc(g,C,O),C=d.h.j,O=Li(d.h)>>>0;var V=d.h.h+O,F=V-C;if(0>=F&&(d.h.j=V,j(g,d,void 0,void 0,void 0),F=V-d.h.h),F)throw Error("Message parsing ended unexpectedly. Expected to read "+O+" bytes, instead read "+(O-F)+" bytes, either the data ended unexpectedly or the message misreported its own length");return d.h.h=V,d.h.j=C,!0},function(d,g,C,O,j){if((g=kt(g,O,C))!=null)for(O=0;O<g.length;O++){var V=d;Ar(V.h,8*C+2);var F=V.h.end();Qr(V,F),F.push(V.i),V=F,j(g[O],d),F=d;var W=V.pop();for(W=F.i+F.h.length()-W;127<W;)V.push(127&W|128),W>>>=7,F.i++;V.push(W),F.i++}});function fs(d){return function(g,C){e:{if(Xn.length){var O=Xn.pop();O.setOptions(C),pr(O.h,g,C),g=O}else g=new Zo(g,C);try{var j=ds(d),V=$c(new j.P,g,j);break e}finally{(j=g.h).i=null,j.m=!1,j.l=0,j.j=0,j.h=0,j.S=!1,g.l=-1,g.i=-1,100>Xn.length&&Xn.push(g)}V=void 0}return V}}function ps(d){return function(){var g=new Ed;Zc(this,g,ls(d)),Qr(g,g.h.end());for(var C=new Uint8Array(g.i),O=g.j,j=O.length,V=0,F=0;F<j;F++){var W=O[F];C.set(W,V),V+=W.length}return g.j=[C],C}}function ei(d){At.call(this,d)}Jt(ei,At);var Tt=[ei,1,eu,2,kn,3,Pt,4,Pt];function ms(d){At.call(this,d,-1,Md)}ei.prototype.l=ps(Tt),Jt(ms,At),ms.prototype.addClassification=function(d,g){return Fc(this,1,ei,d,g),this};var Md=[1],Nd=fs([ms,1,hs,Tt]);function gr(d){At.call(this,d)}Jt(gr,At);var vs=[gr,1,kn,2,kn,3,kn,4,kn,5,kn];function tu(d){At.call(this,d,-1,gs)}gr.prototype.l=ps(vs),Jt(tu,At);var gs=[1],Ud=fs([tu,1,hs,vs]);function Oa(d){At.call(this,d)}Jt(Oa,At);var nu=[Oa,1,kn,2,kn,3,kn,4,kn,5,kn,6,Ld],Vd=fs(nu);function ru(d,g,C){if(C=d.createShader(C===0?d.VERTEX_SHADER:d.FRAGMENT_SHADER),d.shaderSource(C,g),d.compileShader(C),!d.getShaderParameter(C,d.COMPILE_STATUS))throw Error(`Could not compile WebGL shader.
534
532
 
535
- `+d.getShaderInfoLog(C));return C}function Fd(d){return kt(d,ei,1).map(function(g){var C=pn(g,1);return{index:C==null?0:C,qa:On(g,2),label:pn(g,3)!=null?Aa(pn(g,3),""):void 0,displayName:pn(g,4)!=null?Aa(pn(g,4),""):void 0}})}function Ln(d){return{x:On(d,1),y:On(d,2),z:On(d,3),visibility:rs(d,4)!=null?On(d,4):void 0}}function Hi(d,g){this.i=d,this.h=g,this.m=0}function La(d,g,C){return function(O,B){var M=O.h;if(O.s===void 0){var F=iu(M,`
533
+ `+d.getShaderInfoLog(C));return C}function jd(d){return kt(d,ei,1).map(function(g){var C=pn(g,1);return{index:C==null?0:C,qa:On(g,2),label:pn(g,3)!=null?Aa(pn(g,3),""):void 0,displayName:pn(g,4)!=null?Aa(pn(g,4),""):void 0}})}function Ln(d){return{x:On(d,1),y:On(d,2),z:On(d,3),visibility:rs(d,4)!=null?On(d,4):void 0}}function Hi(d,g){this.i=d,this.h=g,this.m=0}function La(d,g,C){return function(O,j){var V=O.h;if(O.s===void 0){var F=ru(V,`
536
534
  attribute vec2 aVertex;
537
535
  attribute vec2 aTex;
538
536
  varying vec2 vTex;
539
537
  void main(void) {
540
538
  gl_Position = vec4(aVertex, 0.0, 1.0);
541
539
  vTex = aTex;
542
- }`,0),z=iu(M,`
540
+ }`,0),W=ru(V,`
543
541
  precision mediump float;
544
542
  varying vec2 vTex;
545
543
  uniform sampler2D sampler0;
546
544
  void main(){
547
545
  gl_FragColor = texture2D(sampler0, vTex);
548
- }`,1),ee=M.createProgram();if(M.attachShader(ee,F),M.attachShader(ee,z),M.linkProgram(ee),!M.getProgramParameter(ee,M.LINK_STATUS))throw Error(`Could not compile WebGL program.
546
+ }`,1),ee=V.createProgram();if(V.attachShader(ee,F),V.attachShader(ee,W),V.linkProgram(ee),!V.getProgramParameter(ee,V.LINK_STATUS))throw Error(`Could not compile WebGL program.
549
547
 
550
- `+M.getProgramInfoLog(ee));F=O.s=ee,M.useProgram(F),z=M.getUniformLocation(F,"sampler0"),O.l={O:M.getAttribLocation(F,"aVertex"),N:M.getAttribLocation(F,"aTex"),ya:z},O.v=M.createBuffer(),M.bindBuffer(M.ARRAY_BUFFER,O.v),M.enableVertexAttribArray(O.l.O),M.vertexAttribPointer(O.l.O,2,M.FLOAT,!1,0,0),M.bufferData(M.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),M.STATIC_DRAW),M.bindBuffer(M.ARRAY_BUFFER,null),O.u=M.createBuffer(),M.bindBuffer(M.ARRAY_BUFFER,O.u),M.enableVertexAttribArray(O.l.N),M.vertexAttribPointer(O.l.N,2,M.FLOAT,!1,0,0),M.bufferData(M.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),M.STATIC_DRAW),M.bindBuffer(M.ARRAY_BUFFER,null),M.uniform1i(z,0)}F=O.l,M.useProgram(O.s),M.canvas.width=B.width,M.canvas.height=B.height,M.viewport(0,0,B.width,B.height),M.activeTexture(M.TEXTURE0),O.i.bindTexture2d(B.glName),M.enableVertexAttribArray(F.O),M.bindBuffer(M.ARRAY_BUFFER,O.v),M.vertexAttribPointer(F.O,2,M.FLOAT,!1,0,0),M.enableVertexAttribArray(F.N),M.bindBuffer(M.ARRAY_BUFFER,O.u),M.vertexAttribPointer(F.N,2,M.FLOAT,!1,0,0),M.bindFramebuffer(M.DRAW_FRAMEBUFFER?M.DRAW_FRAMEBUFFER:M.FRAMEBUFFER,null),M.clearColor(0,0,0,0),M.clear(M.COLOR_BUFFER_BIT),M.colorMask(!0,!0,!0,!0),M.drawArrays(M.TRIANGLE_FAN,0,4),M.disableVertexAttribArray(F.O),M.disableVertexAttribArray(F.N),M.bindBuffer(M.ARRAY_BUFFER,null),O.i.bindTexture2d(0)}(d,g),typeof d.h.canvas.transferToImageBitmap=="function"?Promise.resolve(d.h.canvas.transferToImageBitmap()):C?Promise.resolve(d.h.canvas):typeof createImageBitmap=="function"?createImageBitmap(d.h.canvas):(d.j===void 0&&(d.j=document.createElement("canvas")),new Promise(function(O){d.j.height=d.h.canvas.height,d.j.width=d.h.canvas.width,d.j.getContext("2d",{}).drawImage(d.h.canvas,0,0,d.h.canvas.width,d.h.canvas.height),O(d.j)}))}function Hd(d){this.h=d}Oa.prototype.l=ps(ru);var au=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function Gd(d,g){return g+d}function Ma(d,g){window[d]=g}function Yn(d){if(this.h=d,this.listeners={},this.l={},this.L={},this.s={},this.v={},this.M=this.u=this.ga=!0,this.I=Promise.resolve(),this.fa="",this.D={},this.locateFile=d&&d.locateFile||Gd,(typeof window=="undefined"?"undefined":$(window))==="object")var g=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if(typeof location=="undefined")throw Error("solutions can only be loaded on a web page or in a web worker");g=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.ha=g,d.options)for(var C=(g=X(Object.keys(d.options))).next();!C.done;C=g.next()){C=C.value;var O=d.options[C].default;O!==void 0&&(this.l[C]=typeof O=="function"?O():O)}}function Wd(d){var g,C,O,B,M,F,z,ee,fe,me,we;return Ze(function(Ae){switch(Ae.h){case 1:return d.ga?(g=d.h.files===void 0?[]:typeof d.h.files=="function"?d.h.files(d.l):d.h.files,ft(Ae,Ze(function(ve){switch(ve.h){case 1:return ve.s=2,ft(ve,WebAssembly.instantiate(au),4);case 4:ve.h=3,ve.s=0;break;case 2:return ve.s=0,ve.l=null,ve.return(!1);case 3:return ve.return(!0)}}),2)):Ae.return();case 2:if(C=Ae.i,(typeof window=="undefined"?"undefined":$(window))==="object")return Ma("createMediapipeSolutionsWasm",{locateFile:d.locateFile}),Ma("createMediapipeSolutionsPackedAssets",{locateFile:d.locateFile}),F=g.filter(function(ve){return ve.data!==void 0}),z=g.filter(function(ve){return ve.data===void 0}),ee=Promise.all(F.map(function(ve){var Oe=ti(d,ve.url);if(ve.path!==void 0){var Be=ve.path;Oe=Oe.then(function(ot){return d.overrideFile(Be,ot),Promise.resolve(ot)})}return Oe})),fe=Promise.all(z.map(function(ve){return ve.simd===void 0||ve.simd&&C||!ve.simd&&!C?function(Oe){var Be=document.createElement("script");return Be.setAttribute("src",Oe),Be.setAttribute("crossorigin","anonymous"),new Promise(function(ot){Be.addEventListener("load",function(){ot()},!1),Be.addEventListener("error",function(){ot()},!1),document.body.appendChild(Be)})}(d.locateFile(ve.url,d.ha)):Promise.resolve()})).then(function(){var ve,Oe,Be;return Ze(function(ot){if(ot.h==1)return ve=window.createMediapipeSolutionsWasm,Oe=window.createMediapipeSolutionsPackedAssets,Be=d,ft(ot,ve(Oe),2);Be.i=ot.i,ot.h=0})}),me=Ze(function(ve){return d.h.graph&&d.h.graph.url?ve=ft(ve,ti(d,d.h.graph.url),0):(ve.h=0,ve=void 0),ve}),ft(Ae,Promise.all([fe,ee,me]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return O=g.filter(function(ve){return ve.simd===void 0||ve.simd&&C||!ve.simd&&!C}).map(function(ve){return d.locateFile(ve.url,d.ha)}),importScripts.apply(null,ce(O)),B=d,ft(Ae,createMediapipeSolutionsWasm(Module),6);case 6:B.i=Ae.i,d.m=new OffscreenCanvas(1,1),d.i.canvas=d.m,M=d.i.GL.createContext(d.m,{antialias:!1,alpha:!1,va:typeof WebGL2RenderingContext!="undefined"?2:1}),d.i.GL.makeContextCurrent(M),Ae.h=4;break;case 7:if(d.m=document.createElement("canvas"),!(we=d.m.getContext("webgl2",{}))&&!(we=d.m.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),Ae.return();d.K=we,d.i.canvas=d.m,d.i.createContext(d.m,!0,!0,{});case 4:d.j=new d.i.SolutionWasm,d.ga=!1,Ae.h=0}})}function ti(d,g){var C,O;return Ze(function(B){return g in d.L?B.return(d.L[g]):(C=d.locateFile(g,""),O=fetch(C).then(function(M){return M.arrayBuffer()}),d.L[g]=O,B.return(O))})}function zd(d,g,C){var O,B,M,F,z,ee,fe,me,we,Ae,ve,Oe,Be,ot;return Ze(function(lt){switch(lt.h){case 1:if(!C)return lt.return(g);for(O={},B=0,M=X(Object.keys(C)),F=M.next();!F.done;F=M.next())z=F.value,typeof(ee=C[z])!="string"&&ee.type==="texture"&&g[ee.stream]!==void 0&&++B;1<B&&(d.M=!1),fe=X(Object.keys(C)),F=fe.next();case 2:if(F.done){lt.h=4;break}if(me=F.value,typeof(we=C[me])=="string")return Be=O,ot=me,ft(lt,function(Mn,Va,ri){var ja;return Ze(function(_s){return typeof ri=="number"||ri instanceof Uint8Array||ri instanceof Mn.i.Uint8BlobList?_s.return(ri):ri instanceof Mn.i.Texture2dDataOut?((ja=Mn.v[Va])||(ja=new Hi(Mn.i,Mn.K),Mn.v[Va]=ja),_s.return(La(ja,ri,Mn.M))):_s.return(void 0)})}(d,me,g[we]),14);if(Ae=g[we.stream],we.type==="detection_list"){if(Ae){for(var jt=Ae.getRectList(),mn=Ae.getLandmarksList(),bt=Ae.getClassificationsList(),qe=[],Xe=0;Xe<jt.size();++Xe){var _r=Bd(jt.get(Xe)),Ua=void 0;Ua=Ua===void 0?0:Ua,_r={la:{sa:On(_r,1),ta:On(_r,2),height:On(_r,3),width:On(_r,4),rotation:On(_r,5,0),pa:Aa(pn(_r,6),Ua)},ea:kt(jd(mn.get(Xe)),gr,1).map(Ln),ba:Fd(Vd(bt.get(Xe)))},qe.push(_r)}jt=qe}else jt=[];O[me]=jt,lt.h=7;break}if(we.type==="proto_list"){if(Ae){for(jt=Array(Ae.size()),mn=0;mn<Ae.size();mn++)jt[mn]=Ae.get(mn);Ae.delete()}else jt=[];O[me]=jt,lt.h=7;break}if(Ae===void 0){lt.h=3;break}if(we.type==="float_list"){O[me]=Ae,lt.h=7;break}if(we.type==="proto"){O[me]=Ae,lt.h=7;break}if(we.type!=="texture")throw Error("Unknown output config type: '"+we.type+"'");return(ve=d.v[me])||(ve=new Hi(d.i,d.K),d.v[me]=ve),ft(lt,La(ve,Ae,d.M),13);case 13:Oe=lt.i,O[me]=Oe;case 7:we.transform&&O[me]&&(O[me]=we.transform(O[me])),lt.h=3;break;case 14:Be[ot]=lt.i;case 3:F=fe.next(),lt.h=2;break;case 4:return lt.return(O)}})}function Na(d,g){for(var C=g.name||"$",O=[].concat(ce(g.wants)),B=new d.i.StringList,M=X(g.wants),F=M.next();!F.done;F=M.next())B.push_back(F.value);M=d.i.PacketListener.implement({onResults:function(z){for(var ee={},fe=0;fe<g.wants.length;++fe)ee[O[fe]]=z.get(fe);var me=d.listeners[C];me&&(d.I=zd(d,ee,g.outs).then(function(we){we=me(we);for(var Ae=0;Ae<g.wants.length;++Ae){var ve=ee[O[Ae]];$(ve)==="object"&&ve.hasOwnProperty&&ve.hasOwnProperty("delete")&&ve.delete()}we&&(d.I=we)}))}}),d.j.attachMultiListener(B,M),B.delete()}function ni(d){return d===void 0&&(d=0),d===1?"selfie_segmentation_landscape.tflite":"selfie_segmentation.tflite"}function Gi(d){var g=this;d=d||{},this.h=new Yn({locateFile:d.locateFile,files:function(C){return[{simd:!0,url:"selfie_segmentation_solution_simd_wasm_bin.js"},{simd:!1,url:"selfie_segmentation_solution_wasm_bin.js"},{data:!0,url:ni(C.modelSelection)}]},graph:{url:"selfie_segmentation.binarypb"},listeners:[{wants:["segmentation_mask","image_transformed"],outs:{image:{type:"texture",stream:"image_transformed"},segmentationMask:{type:"texture",stream:"segmentation_mask"}}}],inputs:{image:{type:"video",stream:"input_frames_gpu"}},options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:(typeof window=="undefined"?"undefined":$(window))==="object"&&window.navigator!==void 0&&("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document)},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},modelSelection:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorModelSelection",fieldName:"int_value"},onChange:function(C){var O,B,M;return Ze(function(F){return F.h==1?(O=ni(C),B="third_party/mediapipe/modules/selfie_segmentation/"+O,ft(F,ti(g.h,O),2)):(M=F.i,g.h.overrideFile(B,M),F.return(!0))})}}}})}(le=Yn.prototype).close=function(){return this.j&&this.j.delete(),Promise.resolve()},le.reset=function(){var d=this;return Ze(function(g){d.j&&(d.j.reset(),d.s={},d.v={}),g.h=0})},le.setOptions=function(d,g){var C=this;if(g=g||this.h.options){for(var O=[],B=[],M={},F=X(Object.keys(d)),z=F.next();!z.done;M={X:M.X,Y:M.Y},z=F.next())if(!((z=z.value)in this.l)||this.l[z]!==d[z]){this.l[z]=d[z];var ee=g[z];ee!==void 0&&(ee.onChange&&(M.X=ee.onChange,M.Y=d[z],O.push(function(fe){return function(){return Ze(function(me){if(me.h==1)return ft(me,fe.X(fe.Y),2);me.i===!0&&(C.u=!0),me.h=0})}}(M))),ee.graphOptionXref&&(z=Object.assign({},{calculatorName:"",calculatorIndex:0},ee.graphOptionXref,{valueNumber:ee.type===1?d[z]:0,valueBoolean:ee.type===0&&d[z],valueString:ee.type===2?d[z]:""}),B.push(z)))}O.length===0&&B.length===0||(this.u=!0,this.H=(this.H===void 0?[]:this.H).concat(B),this.F=(this.F===void 0?[]:this.F).concat(O))}},le.initialize=function(){var d=this;return Ze(function(g){return g.h==1?ft(g,Wd(d),2):g.h!=3?ft(g,function(C){var O,B,M,F,z,ee,fe,me;return Ze(function(we){if(we.h==1)return C.h.graph&&C.h.graph.url&&C.fa===C.h.graph.url?we.return():(C.u=!0,C.h.graph&&C.h.graph.url?(C.fa=C.h.graph.url,ft(we,ti(C,C.h.graph.url),3)):void(we.h=2));for(we.h!=2&&(O=we.i,C.j.loadGraph(O)),B=X(Object.keys(C.D)),M=B.next();!M.done;M=B.next())F=M.value,C.j.overrideFile(F,C.D[F]);if(C.D={},C.h.listeners)for(z=X(C.h.listeners),ee=z.next();!ee.done;ee=z.next())fe=ee.value,Na(C,fe);me=C.l,C.l={},C.setOptions(me),we.h=0})}(d),3):ft(g,function(C){var O,B,M,F,z,ee;return Ze(function(fe){switch(fe.h){case 1:if(!C.u)return fe.return();if(!C.F){fe.h=2;break}O=X(C.F),B=O.next();case 3:if(B.done){fe.h=5;break}return ft(fe,(0,B.value)(),4);case 4:B=O.next(),fe.h=3;break;case 5:C.F=void 0;case 2:if(C.H){for(M=new C.i.GraphOptionChangeRequestList,F=X(C.H),z=F.next();!z.done;z=F.next())ee=z.value,M.push_back(ee);C.j.changeOptions(M),M.delete(),C.H=void 0}C.u=!1,fe.h=0}})}(d),0)})},le.overrideFile=function(d,g){this.j?this.j.overrideFile(d,g):this.D[d]=g},le.clearOverriddenFiles=function(){this.D={},this.j&&this.j.clearOverriddenFiles()},le.send=function(d,g){var C,O,B,M,F,z,ee,fe,me,we=this;return Ze(function(Ae){switch(Ae.h){case 1:return we.h.inputs?(C=1e3*(g==null?performance.now():g),ft(Ae,we.I,2)):Ae.return();case 2:return ft(Ae,we.initialize(),3);case 3:for(O=new we.i.PacketDataList,B=X(Object.keys(d)),M=B.next();!M.done;M=B.next())if(F=M.value,z=we.h.inputs[F]){e:{var ve=d[F];switch(z.type){case"video":var Oe=we.s[z.stream];if(Oe||(Oe=new Hi(we.i,we.K),we.s[z.stream]=Oe),Oe.m===0&&(Oe.m=Oe.i.createTexture()),typeof HTMLVideoElement!="undefined"&&ve instanceof HTMLVideoElement)var Be=ve.videoWidth,ot=ve.videoHeight;else typeof HTMLImageElement!="undefined"&&ve instanceof HTMLImageElement?(Be=ve.naturalWidth,ot=ve.naturalHeight):(Be=ve.width,ot=ve.height);ot={glName:Oe.m,width:Be,height:ot},(Be=Oe.h).canvas.width=ot.width,Be.canvas.height=ot.height,Be.activeTexture(Be.TEXTURE0),Oe.i.bindTexture2d(Oe.m),Be.texImage2D(Be.TEXTURE_2D,0,Be.RGBA,Be.RGBA,Be.UNSIGNED_BYTE,ve),Oe.i.bindTexture2d(0),Oe=ot;break e;case"detections":for((Oe=we.s[z.stream])||(Oe=new Hd(we.i),we.s[z.stream]=Oe),Oe.data||(Oe.data=new Oe.h.DetectionListData),Oe.data.reset(ve.length),ot=0;ot<ve.length;++ot){Be=ve[ot];var lt=Oe.data,jt=lt.setBoundingBox,mn=ot,bt=Be.la,qe=new Oa;if(Dn(qe,1,bt.sa),Dn(qe,2,bt.ta),Dn(qe,3,bt.height),Dn(qe,4,bt.width),Dn(qe,5,bt.rotation),Pn(qe,6,bt.pa),bt=qe.l(),jt.call(lt,mn,bt),Be.ea)for(lt=0;lt<Be.ea.length;++lt){qe=Be.ea[lt],mn=(jt=Oe.data).addNormalizedLandmark,bt=ot,qe=Object.assign({},qe,{visibility:qe.visibility?qe.visibility:0});var Xe=new gr;Dn(Xe,1,qe.x),Dn(Xe,2,qe.y),Dn(Xe,3,qe.z),qe.visibility&&Dn(Xe,4,qe.visibility),qe=Xe.l(),mn.call(jt,bt,qe)}if(Be.ba)for(lt=0;lt<Be.ba.length;++lt)mn=(jt=Oe.data).addClassification,bt=ot,qe=Be.ba[lt],Dn(Xe=new ei,2,qe.qa),qe.index&&Pn(Xe,1,qe.index),qe.label&&Pn(Xe,3,qe.label),qe.displayName&&Pn(Xe,4,qe.displayName),qe=Xe.l(),mn.call(jt,bt,qe)}Oe=Oe.data;break e;default:Oe={}}}switch(ee=Oe,fe=z.stream,z.type){case"video":O.pushTexture2d(Object.assign({},ee,{stream:fe,timestamp:C}));break;case"detections":(me=ee).stream=fe,me.timestamp=C,O.pushDetectionList(me);break;default:throw Error("Unknown input config type: '"+z.type+"'")}}return we.j.send(O),ft(Ae,we.I,4);case 4:O.delete(),Ae.h=0}})},le.onResults=function(d,g){this.listeners[g||"$"]=d},he("Solution",Yn),he("OptionType",{BOOL:0,NUMBER:1,ua:2,0:"BOOL",1:"NUMBER",2:"STRING"}),(le=Gi.prototype).close=function(){return this.h.close(),Promise.resolve()},le.onResults=function(d){this.h.onResults(d)},le.initialize=function(){var d=this;return Ze(function(g){return ft(g,d.h.initialize(),0)})},le.reset=function(){this.h.reset()},le.send=function(d){var g=this;return Ze(function(C){return ft(C,g.h.send(d),0)})},le.setOptions=function(d){this.h.setOptions(d)},he("SelfieSegmentation",Gi),he("VERSION","0.1.1675465747")}).call(Jo);var Rr=function(le){return typeof le=="number"},Dc=function(){function le(){Re(this,le),this.userId="",this.videoBeauty=document.createElement("video"),this.videoBeauty.loop=!0,this.videoBeauty.autoplay=!0,this.videoVirtual=document.createElement("video"),this.videoVirtual.loop=!0,this.videoVirtual.autoplay=!0,this.onoverload=null,this.canvasBeauty=document.createElement("canvas"),this.filter=new Wo({canvas:this.canvasBeauty,video:this.videoBeauty}),this.canvasVirtual=document.createElement("canvas"),this.virtual=new zo({canvas:this.canvasVirtual,video:this.videoVirtual,onoverload:this.onoverload}),this.beautyParams={beauty:.5,brightness:.5,ruddy:.5},this.timeoutId=null,this.rafId=null,this.startTime=null,this.originTrack=null,this.beautyTrack=null,this.resultTrack=null,this.localStream=null,this.frameRate=null,this.disableStatus=!1,this.isVirualEnable=!1}var Te,Se,je,He,oe;return $e(le,[{key:"generateBeautyStream",value:function(X){this.userId=X==null?void 0:X.getUserId();var ce=X.getVideoTrack();if(!ce)throw new Error("Your localStream does not contain video track.");var W=this.generateBeautyTrack(ce);return X.replaceTrack(W),this.localStream=X,X.setBeautyStatus&&X.setBeautyStatus(!0),console.log("RTCBeautyPlugin: generateBeautyStream ".concat(this.userId?"userId: ".concat(this.userId):"")),X}},{key:"generateBeautyTrack",value:function(X){var ce=this;this.reset();var W=X.getSettings();this.frameRate=W.frameRate,this.filter.setRect(W.width,W.height),this.setRect(W.width,W.height);var re=new MediaStream;re.addTrack(X),this.videoBeauty.srcObject=re,this.videoBeauty.play();var be=this.canvasBeauty.captureStream(this.frameRate||15).getVideoTracks()[0];return this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(function(){ce.startTime=new Date().getTime(),ce.render()}),this.installEvents(),this.originTrack=X,this.beautyTrack=be,this.setTrackParam({type:"beauty",originTrack:X,resultTrack:be,param:this.beautyParams}),be}},{key:"setBackground",value:(oe=Q(G().mark(function X(ce){return G().wrap(function(W){for(;;)switch(W.prev=W.next){case 0:return W.next=2,this.virtual.setBackground(ce);case 2:console.log("RTCBeautyPlugin: setBackground img:".concat(ce));case 3:case"end":return W.stop()}},X,this)})),function(X){return oe.apply(this,arguments)})},{key:"generateStream",value:(He=Q(G().mark(function X(ce){var W,re,be,ue,ye;return G().wrap(function(Me){for(;;)switch(Me.prev=Me.next){case 0:if(W=ce.localStream,re=ce.type,be=ce.img,ue=W.getVideoTrack()){Me.next=4;break}throw new Error("Your localStream does not contain video track.");case 4:return this.localStream=W,Me.next=7,this.generateMixedTrack({videoTrack:ue,type:re,img:be});case 7:return ye=Me.sent,W.replaceTrack(ye),W.setBeautyStatus&&W.setBeautyStatus(!0),Me.abrupt("return",W);case 11:case"end":return Me.stop()}},X,this)})),function(X){return He.apply(this,arguments)})},{key:"generateMixedTrack",value:(je=Q(G().mark(function X(ce){var W,re,be,ue,ye;return G().wrap(function(Me){for(;;)switch(Me.prev=Me.next){case 0:if(W=ce.videoTrack,re=ce.type,be=ce.img,this.virtual.selfieSegmentation){Me.next=3;break}throw new Error("you should call loadResources() first");case 3:return this.virtual.initVirtualParams({type:re,img:be}),Me.next=6,this.generateBeautyTrack(W);case 6:return ue=Me.sent,Me.next=9,this.generateVirtualTrack({videoTrack:ue,type:re,img:be});case 9:return ye=Me.sent,this.beautyTrack=ue,this.resultTrack=ye,this.setTrackParam({type:"mixed",originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:re,img:be}}),Me.abrupt("return",this.resultTrack);case 14:case"end":return Me.stop()}},X,this)})),function(X){return je.apply(this,arguments)})},{key:"generateVirtualStream",value:(Se=Q(G().mark(function X(ce){var W,re,be,ue,ye;return G().wrap(function(Me){for(;;)switch(Me.prev=Me.next){case 0:if(W=ce.localStream,re=ce.type,be=ce.img,ue=W.getVideoTrack()){Me.next=4;break}throw new Error("Your localStream does not contain video track.");case 4:return this.localStream=W,Me.next=7,this.generateVirtualTrack({videoTrack:ue,type:re,img:be});case 7:return ye=Me.sent,Me.next=10,W.replaceTrack(ye);case 10:return W.setBeautyStatus&&W.setBeautyStatus(!0),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin generate ").concat(re," Stream.")),Me.abrupt("return",W);case 13:case"end":return Me.stop()}},X,this)})),function(X){return Se.apply(this,arguments)})},{key:"generateVirtualTrack",value:(Te=Q(G().mark(function X(ce){var W,re,be,ue;return G().wrap(function(ye){for(;;)switch(ye.prev=ye.next){case 0:if(W=ce.videoTrack,re=ce.type,be=ce.img,this.virtual.selfieSegmentation){ye.next=3;break}throw new Error("you should call loadResources() first");case 3:return ue=W.getSettings(),this.frameRate=ue.frameRate,this.virtual.setRect(ue.width,ue.height),ye.next=8,this.virtual.initVirtualParams({type:re,img:be});case 8:return this.setRect(ue.width,ue.height),this.mediaStream=new MediaStream,this.mediaStream.addTrack(W),this.videoVirtual.srcObject=this.mediaStream,ye.next=14,this.videoVirtual.play();case 14:return this.virtual.startVirtual(this.frameRate),ye.next=17,this.virtual.render();case 17:return this.originTrack=W,this.resultTrack=this.canvasVirtual.captureStream(this.frameRate||15).getVideoTracks()[0],this.setTrackParam({type:"virtual",originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:re,img:be}}),this.isVirualEnable=!0,ye.abrupt("return",this.resultTrack);case 22:case"end":return ye.stop()}},X,this)})),function(X){return Te.apply(this,arguments)})},{key:"replaceVirtualTrack",value:function(X){this.isVirualEnable&&(this.mediaStream.removeTrack(this.mediaStream.getVideoTracks()[0]),this.mediaStream.addTrack(X),this.originTrack=X)}},{key:"deleteSource",value:function(X){if(p.default){var ce=p.default.beautyTrackMap.get(X);ce&&(ce.type==="mixed"&&this.deleteSource(ce.originTrack.id),ce.originTrack&&(ce.originTrack.stop(),ce.originTrack=null),ce.beautyTrack&&(ce.beautyTrack.stop(),ce.beautyTrack=null),ce.resultTrack&&(ce.resultTrack.stop(),ce.resultTrack=null),p.default.beautyTrackMap.delete(X))}}},{key:"draw",value:function(){this.videoBeauty&&this.videoBeauty.readyState===this.videoBeauty.HAVE_ENOUGH_DATA&&this.filter.apply(this.videoBeauty)}},{key:"enableVirtualBg",value:function(){var X;if(this.virtual&&!this.isVirualEnable)return this.virtual.setEnable(!0),this.virtual.render(),this.isVirualEnable=!0,(X=this.localStream)===null||X===void 0||X.replaceTrack(this.resultTrack),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin enable.")),this.resultTrack}},{key:"disableVirtualBg",value:function(){var X;if(this.virtual&&this.isVirualEnable)return this.virtual.setEnable(!1),this.isVirualEnable=!1,(X=this.localStream)===null||X===void 0||X.replaceTrack(this.originTrack),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin disable.")),this.originTrack}},{key:"changeType",value:function(X){var ce=X.type,W=X.img;console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin changeType\uFF1A").concat(ce,". img: ").concat(W,".")),ce==="blur"&&(this.virtual.reset(),this.virtual.initVirtualParams({type:"blur"}),this.virtual.startVirtual(this.frameRate),this.virtual.render()),ce==="virtual"&&(this.virtual.reset(),this.virtual.initVirtualParams({type:"virtual",img:W}),this.virtual.startVirtual(this.frameRate),this.virtual.render()),this.setTrackParam({type:ce,originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:ce,img:W}})}},{key:"render",value:function(){var X=this,ce=new Date().getTime();ce-this.startTime>1e3/this.frameRate&&(this.draw(),this.startTime=ce),document.hidden?(clearTimeout(this.timeoutId),this.timeoutId=setTimeout(function(){X.render()},1e3/this.frameRate)):(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(this.render.bind(this)))}},{key:"setBeautyParam",value:function(X){var ce=X.beauty,W=X.brightness,re=X.ruddy;Rr(ce)&&(this.beautyParams.beauty=ce),Rr(W)&&(this.beautyParams.brightness=W),Rr(re)&&(this.beautyParams.ruddy=re),this.filter.setBeautyParams(this.beautyParams),this.getClose()&&!this.disableStatus&&this.disable(),!this.getClose()&&this.disableStatus&&this.enable()}},{key:"setRect",value:function(X,ce){var W=X||640,re=ce||480;this.videoBeauty.height=re,this.videoBeauty.width=W,this.canvasBeauty.height=re,this.canvasBeauty.width=W,this.videoVirtual.height=re,this.videoVirtual.width=W,this.canvasVirtual.height=re,this.canvasVirtual.width=W}},{key:"reset",value:function(){cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.videoBeauty.pause(),this.filter.reset(),this.beautyTrack&&this.beautyTrack.stop(),this.videoVirtual.pause(),this.resultTrack&&this.resultTrack.stop(),this.originTrack&&this.originTrack.stop()}},{key:"destroy",value:function(){cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.canvasBeauty&&(this.canvasBeauty.width=0,this.canvasBeauty.height=0,this.canvasBeauty.remove(),this.canvasBeauty=null),this.videoBeauty&&(this.videoBeauty.pause(),this.videoBeauty.removeAttribute("srcObject"),this.videoBeauty.removeAttribute("src"),this.videoBeauty.load(),this.videoBeauty.width=0,this.videoBeauty.height=0,this.videoBeauty.remove(),this.videoBeauty=null),this.beautyTrack&&(this.deleteSource(this.beautyTrack.id),this.beautyTrack.stop(),this.beautyTrack=null),this.originTrack&&(this.originTrack.stop(),this.originTrack=null),this.resultTrack&&(this.deleteSource(this.resultTrack.id),this.resultTrack.stop(),this.resultTrack=null),this.canvasVirtual&&(this.canvasVirtual.width=0,this.canvasVirtual.height=0,this.canvasVirtual.remove(),this.canvasVirtual=null),this.videoVirtual&&(this.videoVirtual.pause(),this.videoVirtual.removeAttribute("srcObject"),this.videoVirtual.removeAttribute("src"),this.videoVirtual.load(),this.videoVirtual.width=0,this.videoVirtual.height=0,this.videoVirtual.remove(),this.videoVirtual=null),this.virtual.destroy(),this.uninstallEvents()}},{key:"generateVideoTrackFromCanvasCapture",value:function(X){return this.canvasVirtual.captureStream(X).getVideoTracks()[0]}},{key:"setTrackParam",value:function(X){var ce=X.type,W=X.originTrack,re=X.resultTrack,be=X.param;p.default&&(p.default.beautyTrackMap||(p.default.beautyTrackMap=new Map),p.default.beautyTrackMap.set(re.id,{type:ce,originTrack:W,resultTrack:re,param:be,pluginInstance:this}))}},{key:"disable",value:function(){this.localStream&&this.originTrack&&(this.localStream.replaceTrack(this.originTrack),cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.disableStatus=!0)}},{key:"enable",value:function(){this.localStream&&this.beautyTrack&&(this.localStream.replaceTrack(this.beautyTrack),this.render(),this.disableStatus=!1)}},{key:"installEvents",value:function(){document.addEventListener("visibilitychange",this.render.bind(this))}},{key:"uninstallEvents",value:function(){document.removeEventListener("visibilitychange",this.render.bind(this))}},{key:"overload",value:function(){this.onoverload&&this.onoverload()}},{key:"getClose",value:function(){return this.beautyParams.beauty===0&&this.beautyParams.brightness===0&&this.beautyParams.ruddy===0}}]),le}();return p.default&&(p.default.getRTCBeautyPlugin=function(){return new Dc}),Dc})});var ew="0.0.18";var bd=lr(Er());var yd=lr(Er());var dw=lr(ig());var Uo=class extends dw.default{constructor({mediaType:p}){super();Ve(this,"trackMediaType");Ve(this,"_stream");Ve(this,"_playerState");this.trackMediaType=p}get isPlaying(){return this._playerState==="PLAYING"}async stop(){this._playerState="STOPPED",await this._stream.stop()}};var C7=1,Vo=class extends Uo{constructor(p){super(p);Ve(this,"TRTC",yd.default);Ve(this,"muted");Ve(this,"_publishedStream",null);Ve(this,"_log");this._log=Ft.createLogger({id:p.id+C7++})}get closed(){let p=this.getMediaStreamTrack();return p?p.readyState==="ended":!0}async init(){this._stream.on("device-auto-recovered",async({isMicrophone:p,isCamera:G,microphoneId:$,cameraId:H})=>{if(this._publishedStream&&this._stream!==this._publishedStream){let Q=this.getMediaStreamTrack(),Re=this.trackMediaType==="audio"?this._publishedStream.getAudioTrack():this._publishedStream.getVideoTrack();Q&&Re&&Q!==Re&&this._publishedStream.replaceTrack(Q)}if(p){let Q=(await yd.default.getMicrophones()).find(Re=>Re.deviceId===$);Q&&this.emit("device-switched",Q)}if(G){let Q=(await yd.default.getCameras()).find(Re=>Re.deviceId===H);Q&&this.emit("device-switched",Q)}}),this._stream.on("player-state-changed",({state:p})=>{this._playerState=p}),this._stream.on("error",p=>{p.getCode()===16452&&this.emit("track-ended",this.trackMediaType)}),await this._stream.initialize()}setPublishedStream(p){this._publishedStream=p}on(p,G){return super.on(p,G),this}async setMuted(p){let G=this._publishedStream||this._stream;this.trackMediaType==="audio"?p?G.muteAudio():G.unmuteAudio():p?G.muteVideo():G.unmuteVideo()}getMediaStreamTrack(){return this.trackMediaType==="audio"?this._stream.getAudioTrack():this._stream.getVideoTrack()}close(){this._stream.close()}getTrackLabel(){var p;return((p=this.getMediaStreamTrack())==null?void 0:p.label)||""}getDeviceId(){var p,G;return((G=(p=this.getMediaStreamTrack())==null?void 0:p.getSettings())==null?void 0:G.deviceId)||""}};var fw=lr(hw()),pw=lr(Er());var jo=class extends Vo{constructor(p){super(p);Ve(this,"mirrored",!1);Ve(this,"lastPlayContainer");Ve(this,"_beautyPlugin");Ve(this,"_virtualTrack");Ve(this,"_isVirtualEnable",!1);Ve(this,"_imageUrl",null);this.onOriginTrackEnded=this.onOriginTrackEnded.bind(this)}get _originTrack(){var p;return((p=this._beautyPlugin)==null?void 0:p.originTrack)||null}get videoElement(){var p;return((p=this.lastPlayContainer)==null?void 0:p.querySelector(`#video_${this._stream.getId()}`))||null}mirrorVideo(p){this.lastPlayContainer&&this._stream.play(this.lastPlayContainer,{mirror:p}),this.mirrored=p}async applyVirtualBackground(p){var G;if(this._log.info(`applyVirtualBackground ${p} ${this._imageUrl}`),!p)return this.stopVirtualBackground(),!0;if(p===this._imageUrl)return!0;if(this._beautyPlugin||(this._beautyPlugin=new fw.default,await this._beautyPlugin.virtual.loadResources(),this._beautyPlugin.virtual.onoverload=()=>{this._log.info("virtualBackground is onoverload"),this.emit("VirtualBackgroundOverload")}),this._imageUrl)p==="blur"&&this._imageUrl!=="blur"&&this._beautyPlugin.changeType({type:"blur"}),p!=="blur"&&this._imageUrl==="blur"&&this._beautyPlugin.changeType({type:"virtual",img:p}),p!=="blur"&&this._imageUrl!=="blur"&&this._imageUrl!==p&&await this._beautyPlugin.setBackground(p);else{let $=await this._beautyPlugin.generateVirtualStream({localStream:this._stream,type:p==="blur"?"blur":"virtual",img:p==="blur"?void 0:p});this._virtualTrack=$.getVideoTrack(),this._publishedStream&&this._publishedStream.replaceTrack(this._virtualTrack),this._isVirtualEnable=!0}return(G=this._originTrack)==null||G.addEventListener("ended",this.onOriginTrackEnded),this._imageUrl=p,!this._isVirtualEnable&&this._beautyPlugin&&(this._isVirtualEnable=!0,this._beautyPlugin.enableVirtualBg()),!0}async onOriginTrackEnded(){let p=(await pw.default.getCameras())[0];p?this.setDevice(p.deviceId):this.emit("track-ended",this.trackMediaType)}async stopVirtualBackground(){var p;return this._log.info("stopVirtualBackground is called"),this._beautyPlugin&&this._isVirtualEnable&&(this._log.info("RTCBeautyPlugin: call disableVirtualBackground"),this._beautyPlugin.disableVirtualBg(),this._isVirtualEnable=!1,(p=this._originTrack)==null||p.removeEventListener("ended",this.onOriginTrackEnded)),!0}getDeviceId(){var p,G;return this._isVirtualEnable||this._beautyPlugin?((G=(p=this._beautyPlugin.originTrack)==null?void 0:p.getSettings())==null?void 0:G.deviceId)||"":super.getDeviceId()}getMediaStreamTrack(){return this._originTrack&&(this._isVirtualEnable||this._beautyPlugin)?this._originTrack:super.getMediaStreamTrack()}close(){var p;(p=this._beautyPlugin)==null||p.destroy()}};var ya=class extends jo{constructor(p){var Re;super(vd(Kr({},p),{mediaType:"video"}));Ve(this,"_videoProfile",{width:320,height:240,frameRate:15,bitrate:300});let{width:G,height:$,frameRate:H,bitrate:Q}=p;Ft.info("new LingoCameraVideoTrack"),this._stream=bd.default.createStream({audio:!1,video:!0,cameraId:p.cameraId}),G&&(this._videoProfile.width=G),$&&(this._videoProfile.height=$),H&&(this._videoProfile.frameRate=H),Q&&(this._videoProfile.bitrate=Q),this._stream.setVideoProfile(this._videoProfile),(Re=this._publishedStream)==null||Re.setVideoProfile(this._videoProfile)}getVideoProfile(){return this._videoProfile}async play(p){await this._stream.play(p.container,{mirror:this.mirrored}),this.lastPlayContainer=p.container}async stop(){await super.stop(),this.lastPlayContainer=null}async setDevice(p){var H,Q,Re,xe;let G=this._beautyPlugin&&this._isVirtualEnable;if(this._log.info(`setDevice ${p} visual: ${G}`),G){let $e=bd.default.createStream({audio:!1,video:!0,cameraId:p});$e.setVideoProfile(this._videoProfile),(H=this._publishedStream)==null||H.setVideoProfile(this._videoProfile),await $e.initialize();let Et=$e.getVideoTrack();Et&&((Q=this._originTrack)==null||Q.removeEventListener("ended",this.onOriginTrackEnded),await((Re=this._beautyPlugin)==null?void 0:Re.replaceVirtualTrack(Et)),(xe=this._originTrack)==null||xe.addEventListener("ended",this.onOriginTrackEnded))}else if(await this._stream.switchDevice(this.trackMediaType,p),this._publishedStream&&this._publishedStream!==this._stream){let $e=this.getMediaStreamTrack();$e&&await this._publishedStream.replaceTrack($e)}let $=(await bd.default.getCameras()).find($e=>$e.deviceId===p);$&&this.emit("device-switched",$),!this._isVirtualEnable&&this._beautyPlugin&&(this._beautyPlugin.destroy(),this._beautyPlugin=null,this._isVirtualEnable=!1,this._imageUrl=null)}close(){var p;(p=this.getMediaStreamTrack())==null||p.stop(),this._stream.hasAudio()||this._stream.close(),super.close()}};var mw=lr(Er());var E7=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(ne){let q=Math.random()*16|0;return(ne=="x"?q:q&3|8).toString(16)})};function Sd(){return!performance||!performance.now?Date.now():Math.floor(performance.now())}var sg=class{constructor(){this.intervalMap_=new Map}setInterval(q,p,G=!0){if(!window||!window.requestAnimationFrame)return setInterval(q,p);let $=E7(),H=Sd(),Q=H;this.intervalMap_.set($,{rafId:null,timeoutId:null,onVisibilityChange:null});let Re=()=>{if(G&&document.hidden){if(q(),!this.intervalMap_.has($))return;let $e=setTimeout(Re,p);this.setTimeoutId($,$e),H=Sd(),Q=H}else{if(Q=Sd(),Q-H>=p&&(H=Q,q(),!this.intervalMap_.has($)))return;let $e=requestAnimationFrame(Re);this.setRafId($,$e)}},xe=requestAnimationFrame(Re);if(this.setRafId($,xe),G){let $e=()=>{if(document.hidden){let Et=Sd()-H;if(Et>=p)Re();else{let Ye=setTimeout(Re,p-Et);this.setTimeoutId($,Ye)}}};document.addEventListener("visibilitychange",$e),this.setOnVisibilityChange($,$e),document.hidden&&$e()}return $}clearInterval(q){if(this.intervalMap_.has(q)){let{rafId:p,timeoutId:G,onVisibilityChange:$}=this.intervalMap_.get(q);cancelAnimationFrame(p),clearTimeout(G),document.removeEventListener("visibilitychange",$),this.intervalMap_.delete(q)}}setTimeoutId(q,p){if(this.intervalMap_.has(q)){let G=this.intervalMap_.get(q);G.timeoutId&&clearTimeout(G.timeoutId),G.timeoutId=p}}setRafId(q,p){if(this.intervalMap_.has(q)){let G=this.intervalMap_.get(q);G.rafId&&cancelAnimationFrame(G.rafId),G.rafId=p}}setOnVisibilityChange(q,p){if(this.intervalMap_.has(q)){let G=this.intervalMap_.get(q);G.onVisibilityChange=p}}},R7=new sg,cg=R7;var kd=class extends jo{constructor(p){super({mediaType:"video",id:"cus"});Ve(this,"frameRate",0);Ve(this,"canvas",document.createElement("canvas"));Ve(this,"canvasCtx");Ve(this,"onDraw",null);Ve(this,"_cameraVideoTrack",null);Ve(this,"_timerId");this._cameraVideoTrack=p}timerStop(){cg.clearInterval(this._timerId)}async init(){var $;if(this.canvasCtx)return;this.canvasCtx=this.canvas.getContext("2d");let p=($=this._cameraVideoTrack)==null?void 0:$.getMediaStreamTrack();if(p){let{width:H,height:Q,frameRate:Re}=p.getSettings();H&&(this.canvas.width=H),Q&&(this.canvas.height=Q),Re&&(this.frameRate=Re)}this._timerId=cg.setInterval(()=>{var Re,xe,$e;let H=(Re=this._cameraVideoTrack)==null?void 0:Re.getMediaStreamTrack();if(H){let{width:Et,height:Ye,frameRate:dr}=H.getSettings();Et&&(this.canvas.width=Et),Ye&&(this.canvas.height=Ye),dr&&(this.frameRate=dr)}let Q=(xe=this._cameraVideoTrack)==null?void 0:xe.videoElement;Q&&(($e=this.canvasCtx)==null||$e.drawImage(Q,0,0,this.canvas.width,this.canvas.height),this.onDraw&&this.onDraw(this.canvas,this.mirrored))},1e3/this.frameRate,!0);let G=this.canvas.captureStream(this.frameRate).getVideoTracks()[0];this._stream=mw.default.createStream({videoSource:G}),await super.init()}async play(p){var G,$,H,Q;if(p.container){this.lastPlayContainer=p.container,(G=this._cameraVideoTrack)!=null&&G.isPlaying||await(($=this._cameraVideoTrack)==null?void 0:$.play({container:p.container}));let Re=(H=this._cameraVideoTrack)==null?void 0:H.videoElement;Re&&Re.parentElement&&(Re.parentElement.style.display="none"),await this._stream.play(p.container),this.mirrorVideo(this.mirrored)}(Q=p.custom)!=null&&Q.onDraw&&(this.onDraw=p.custom.onDraw)}async stop(){var G;this.onDraw=null;let p=(G=this._cameraVideoTrack)==null?void 0:G.videoElement;p&&p.parentElement&&(p.parentElement.style.display="block"),await this._stream.stop(),this.lastPlayContainer=null}setDevice(p){return Promise.resolve()}};var ug=lr(Er());function Td(ne){return ne*1.5>100?100:ne*1.5}var Id=class extends Vo{constructor({microphoneId:p}){super({mediaType:"audio"});Ve(this,"_captureVolume",100);Ve(this,"_div",document.createElement("div"));Ve(this,"_isPlayCalled",!1);Ft.info("new LingoMicrophoneAudioTrack"),this._stream=ug.default.createStream({audio:!0,video:!1,microphoneId:p})}async play(){return this._isPlayCalled=!0,await this._stream.play(this._div,{muted:!1})}stop(){return this._isPlayCalled=!1,super.stop()}setPublishedStream(p){var G;p===null?(G=this._publishedStream)==null||G.setAudioCaptureVolume(100):p.setAudioCaptureVolume(this._captureVolume),super.setPublishedStream(p)}async setDevice(p){if(Ft.warn(`switch mic ${p}`),p==="default"&&this._stream.isAudioRecovering_)return;if(await this._stream.switchDevice(this.trackMediaType,p),this._publishedStream&&this._publishedStream!==this._stream){let $=this.getMediaStreamTrack();$&&await this._publishedStream.replaceTrack($)}let G=(await ug.default.getMicrophones()).find($=>$.deviceId===p);G&&this.emit("device-switched",G)}setVolume(p){var G;(G=this._publishedStream)==null||G.setAudioCaptureVolume(p),this._captureVolume=p}getVolume(){return this._isPlayCalled||(this._isPlayCalled=!0,this._stream.play(this._div)),Td(this._stream.getAudioLevel()*100)}setSpeakerDevice(p){return this._stream.setAudioOutput(p)}close(){var p;(p=this.getMediaStreamTrack())==null||p.stop(),this._stream.hasAudio()||this._stream.close()}};var Bo=class extends Uo{constructor({uid:p,mediaType:G,stream:$}){super({mediaType:G});Ve(this,"uid");Ve(this,"isSubscribed",!1);this.uid=p,this._stream=$,this._stream.on("player-state-changed",({state:H})=>{this._playerState=H})}subscribe(){this.isSubscribed=!0}unsubscribe(){this.isSubscribed=!1}};var xd=class extends Bo{constructor({uid:q,stream:p}){super({uid:q,mediaType:"audio",stream:p})}setVolume(q){this._stream.setAudioVolume(q/100)}getVolume(){return Td(this._stream.getAudioLevel()*100)}setSpeakerDevice(q){return this._stream.setAudioOutput(q)}async play(){return this._stream.isPlaying()?Promise.resolve():this._stream.play(document.createElement("div"))}};var wd=class extends Bo{constructor({uid:p,stream:G}){super({uid:p,mediaType:"video",stream:G});Ve(this,"mirrored",!1);Ve(this,"lastPlayContainer")}async play(p){await this._stream.play(p.container),this.lastPlayContainer=p.container}async stop(){await super.stop(),this.lastPlayContainer=null}mirrorVideo(p){this.lastPlayContainer&&(this._stream.play(this.lastPlayContainer,{mirror:p}),this.mirrored=p)}};import{LingoBaseRTC as P7,LingoRTCError as fg}from"@lingoace/lingo-base-rtc";var lg=lr(Er());import{LingoBaseRTCClient as A7,LingoRTCError as Fo,config as Ac}from"@lingoace/lingo-base-rtc";var Cd=new WeakMap;function Ed(){return function(ne,q,p){let G=p.value,$=({fn:H,args:Q,context:Re,resolve:xe,reject:$e})=>{H.apply(Re,Q).then(xe,$e).finally(()=>{let Et=Cd.get(Re);Et.shift(),Et[0]&&$(Kr({},Et[0]))})};return p.value=function(...H){return new Promise((Q,Re)=>{if(Cd.has(this)){let xe=Cd.get(this),{length:$e}=xe;xe.push({fn:G,args:H,context:this,resolve:Q,reject:Re}),$e===0&&$({fn:G,args:H,context:this,resolve:Q,reject:Re})}else Cd.set(this,[{fn:G,args:H,context:this,resolve:Q,reject:Re}]),$({fn:G,args:H,context:this,resolve:Q,reject:Re})})},p}}import{LingoRTCError as vw}from"@lingoace/lingo-base-rtc";function Cn(ne){return function(q,p,G){let $=G.value;return G.value=async function(...H){try{return await $.apply(this,H)}catch(Q){throw ne?ne(Q):Q instanceof vw?Q:vw.createOtherError(Q.message)}},G}}var En=class extends A7{constructor(){super(...arguments);Ve(this,"_client",null);Ve(this,"_localStream",null);Ve(this,"_screenStream",null);Ve(this,"_remoteAuxiliaryStream",null);Ve(this,"_remoteMainStreamMap",new Map);Ve(this,"_remoteUserIdSet",new Set);Ve(this,"_quality",{res:"0x0",vfps:0,vra:0,ara:0,rtt:0,pktLostRate:0,upQuality:0,downQuality:0});Ve(this,"_prevLocalVideoStat",null);Ve(this,"_prevLocalAudioStat",null)}getRemoteUsers(){let p=new Map;return this._remoteUserIdSet.forEach(G=>{p.set(G,{uid:G,hasAudio:!1,hasVideo:!1})}),this.remoteAudioTrackMap.forEach(G=>{if(p.has(G.uid)){let $=p.get(G.uid);$.hasAudio=!0,$.audioTrack=G.isSubscribed?G:void 0}else p.set(G.uid,{uid:G.uid,hasAudio:!0,hasVideo:!1,audioTrack:G.isSubscribed?G:void 0,videoTrack:void 0})}),this.remoteVideoTrackMap.forEach(G=>{let{uid:$}=G;if(p.has(G.uid)){let H=p.get(G.uid);H.hasVideo=!0,H.videoTrack=G.isSubscribed?G:void 0}else p.set($,{uid:$,hasAudio:!1,hasVideo:!0,audioTrack:void 0,videoTrack:G.isSubscribed?G:void 0})}),[...p.values()]}async join(p){return this._client=lg.default.createClient({sdkAppId:Number(p.appId),userId:p.uid,userSig:p.token,mode:"rtc",useStringRoomId:!0,autoSubscribe:!1,enableAutoPlayDialog:!1}),this.handleEvents(),await this._client.join({roomId:p.roomId}),this.joinParam=p,this.uid=p.uid,p.uid}async leave(){!this._client||(await this._client.leave(),this.joinParam=void 0,this._client=null)}start(){return Promise.resolve()}async publish(p){return this._localStream?(p instanceof ya&&await this._localStream.setVideoProfile(p.getVideoProfile()),await this._localStream.addTrack(p.getMediaStreamTrack())):(await this._client.publish(p._stream),this._localStream=p._stream),p.setPublishedStream(this._localStream),this.localTracks.push(p),!0}async unpublish(p){var $;let G=p.getMediaStreamTrack();return!G||!this._localStream||this.localTracks.length===0||(this.localTracks.length===1?(await(($=this._client)==null?void 0:$.unpublish(this._localStream)),p.setPublishedStream(null),this._localStream=null,this.localTracks=[]):this.localTracks.find(H=>H===p)&&(await this._localStream.removeTrack(G),p.setPublishedStream(null),this.localTracks=this.localTracks.filter(H=>H!==p))),!0}async subscribe(p,G){var $,H;if(!this._client)throw Fo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u8BA2\u9605");if(G==="audio"&&!this.remoteAudioTrackMap.has(p))throw Fo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${p} \u672A\u63A8\u97F3\u9891\uFF0C\u65E0\u6CD5\u8BA2\u9605`);if(G==="video"&&p!==Ac.screenSharingUid&&!this.remoteVideoTrackMap.has(p))throw Fo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${p} \u672A\u63A8\u89C6\u9891\uFF0C\u65E0\u6CD5\u8BA2\u9605`);if(Ft.info(`subscribe ${p} ${G}`),p===Ac.screenSharingUid&&this._remoteAuxiliaryStream&&this._client)return await this._client.subscribe(this._remoteAuxiliaryStream),!0;if(G==="audio"){let Q=this.remoteAudioTrackMap.get(p);Q.subscribe();try{await this._client.subscribe(Q._stream,{audio:!0,video:!!(($=this.remoteVideoTrackMap.get(p))!=null&&$.isSubscribed)})}catch(Re){throw Q.unsubscribe(),Re}}else{let Q=this.remoteVideoTrackMap.get(p);Q.subscribe();try{await this._client.subscribe(Q._stream,{video:!0,audio:!!((H=this.remoteAudioTrackMap.get(p))!=null&&H.isSubscribed)})}catch(Re){throw Q.unsubscribe(),Re}}return!0}async unsubscribe(p,G){var H,Q;if(!this._client)throw Fo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u8BA2\u9605");Ft.info(`unsubscribe ${p} ${G}`);let $=null;if(G==="audio"&&this.remoteAudioTrackMap.has(p)?$=this.remoteAudioTrackMap.get(p):G==="video"&&this.remoteVideoTrackMap.has(p)&&($=this.remoteVideoTrackMap.get(p)),!$)throw Fo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${p} \u672A\u63A8 ${G}\uFF0C\u65E0\u6CD5\u8BA2\u9605`);return p===Ac.screenSharingUid&&this._remoteAuxiliaryStream?(await this._client.unsubscribe(this._remoteAuxiliaryStream),!0):(G==="audio"?(H=this.remoteVideoTrackMap.get(p))!=null&&H.isSubscribed?await this._client.subscribe($._stream,{video:!0,audio:!1}):await this._client.unsubscribe($._stream):(Q=this.remoteAudioTrackMap.get(p))!=null&&Q.isSubscribed?await this._client.subscribe($._stream,{video:!1,audio:!0}):await this._client.unsubscribe($._stream),$.unsubscribe(),!0)}getQOEStats(){return this._quality}async startScreenShare(p){if(!this.joinParam||!this._client)throw Fo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u5F00\u542F\u5C4F\u5E55\u5206\u4EAB");this._screenStream=lg.default.createStream({screen:!0,screenAudio:!0});let G={width:1280,height:720,frameRate:15,bitrate:2e3};this._screenStream.setScreenProfile(Kr(Kr({},G),p)),this._screenStream.on("screen-sharing-stopped",async()=>{await this.stopScreenShare(),this.emit("ScreenSharingEnded")}),await this._screenStream.initialize(),await this._client.publish(this._screenStream,{isAuxiliary:!0})}async stopScreenShare(){!this._client||!this._screenStream||(await this._client.unpublish(this._screenStream),this._screenStream.stop(),this._screenStream.close(),this._screenStream=null)}async playScreenShareView(p){var G;this._remoteAuxiliaryStream&&this._client?(await this._client.subscribe(this._remoteAuxiliaryStream),await this._remoteAuxiliaryStream.play(p)):await((G=this._screenStream)==null?void 0:G.play(p))}async stopScreenShareView(){var p;this._remoteAuxiliaryStream&&this._client?(await this._client.unsubscribe(this._remoteAuxiliaryStream),await this._remoteAuxiliaryStream.stop()):await((p=this._screenStream)==null?void 0:p.stop())}handleEvents(){!this._client||(this._client.on("connection-state-changed",({prevState:p,state:G})=>{this.connectionState=G,this.emit("ConnectionStateChange",G,p,"")}),this._client.on("peer-join",p=>{this._remoteUserIdSet.add(p.userId),this.emit("UserJoined",p.userId)}),this._client.on("peer-leave",p=>{this._remoteUserIdSet.delete(p.userId),this.emit("UserLeft",p.userId)}),this._client.on("stream-added",p=>{let G=p.stream,$=G.getUserId();if(G.getType()==="auxiliary"){this._remoteAuxiliaryStream=G,this.emit("RemoteScreenSharing",Ac.screenSharingUid,!0,"video");return}this._remoteMainStreamMap.set($,G),G.on("error",H=>{if(H.getCode()===16451){let Q=()=>{G.resume().then(()=>{document.body.removeEventListener("click",Q),document.body.removeEventListener("touchstart",Q)})};document.body.addEventListener("click",Q,!0),document.body.addEventListener("touchstart",Q,!0),this.emit("AutoplayFailed")}}),G.hasAudio()&&this.handleUserPublished($,"audio"),G.hasVideo()&&this.handleUserPublished($,"video")}),this._client.on("stream-updated",p=>{let G=p.stream,$=G.getUserId();!this.remoteAudioTrackMap.has($)&&G.hasAudio()&&this.handleUserPublished($,"audio"),this.remoteAudioTrackMap.has($)&&!G.hasAudio()&&this.handleUserUnpublished($,"audio"),!this.remoteVideoTrackMap.has($)&&G.hasVideo()&&this.handleUserPublished($,"video"),this.remoteVideoTrackMap.has($)&&!G.hasVideo()&&this.handleUserUnpublished($,"video")}),this._client.on("stream-removed",p=>{let G=p.stream.getUserId();if(p.stream.getType()==="auxiliary"){this._remoteAuxiliaryStream=null,this.emit("RemoteScreenSharing",Ac.screenSharingUid,!1,"video");return}this._remoteMainStreamMap.delete(G),this.handleUserUnpublished(G,"audio"),this.handleUserUnpublished(G,"video")}),this._client.on("network-quality",p=>{var G,$;this._quality.upQuality=p.uplinkNetworkQuality,this._quality.downQuality=p.downlinkNetworkQuality,this._quality.rtt=p.uplinkRTT,this._quality.pktLostRate=p.uplinkLoss,(G=this._client)==null||G.getLocalVideoStats().then(H=>{let Q=H[this.uid];Q&&(this._quality.res=`${Q.frameWidth}x${Q.frameHeight}`,this._prevLocalVideoStat&&(this._quality.vfps=Math.floor((Q.framesSent-this._prevLocalVideoStat.framesSent)/2)||0,this._quality.vra=Math.floor((Q.bytesSent-this._prevLocalVideoStat.bytesSent)*8/2)||0),this._prevLocalVideoStat=Q)}),($=this._client)==null||$.getLocalAudioStats().then(H=>{let Q=H[this.uid];Q&&(this._prevLocalAudioStat&&(this._quality.ara=Math.floor((Q.bytesSent-this._prevLocalAudioStat.bytesSent)*8/2)||0),this._prevLocalAudioStat=Q)}),this.emit("NetworkQuality",p)}),this._client.on("mute-audio",p=>{this.handleUserUnpublished(p.userId,"audio")}),this._client.on("unmute-audio",p=>{this.handleUserPublished(p.userId,"audio",!0)}))}handleUserUnpublished(p,G){Ft.info(`UserUnpublished ${p} ${G}`),G==="audio"?this.remoteAudioTrackMap.has(p)&&(this.remoteAudioTrackMap.delete(p),this.emit("UserUnpublished",p,G)):this.remoteVideoTrackMap.has(p)&&(this.remoteVideoTrackMap.delete(p),this.emit("UserUnpublished",p,G))}handleUserPublished(p,G,$=!1){var Re;Ft.info(`UserPublished ${p} ${G} firedByUnmute: ${$}`);let H=this._remoteMainStreamMap.get(p),Q=(Re=this._client)==null?void 0:Re.getRemoteMutedState().find(xe=>xe.userId===p);if(H){if(G==="audio"&&!this.remoteAudioTrackMap.has(p)&&H.hasAudio()){if(!$&&Q&&Q.audioMuted)return;let xe=new xd({uid:p,stream:H});this.remoteAudioTrackMap.set(p,xe)}else if(G==="video"&&!this.remoteVideoTrackMap.has(p)&&H.hasVideo()){let xe=new wd({uid:p,stream:H});this.remoteVideoTrackMap.set(p,xe)}this.emit("UserPublished",p,G)}}};wn([Cn(),Ed()],En.prototype,"publish",1),wn([Cn()],En.prototype,"unpublish",1),wn([Cn()],En.prototype,"subscribe",1),wn([Cn()],En.prototype,"unsubscribe",1),wn([Cn()],En.prototype,"startScreenShare",1),wn([Cn()],En.prototype,"stopScreenShare",1),wn([Cn()],En.prototype,"playScreenShareView",1),wn([Cn()],En.prototype,"stopScreenShareView",1);var Go=lr(Er());var gw=lr(ig()),dg=lr(Er());var hg=class extends gw.default{constructor(){super();Ve(this,"prevDevices_",[]);navigator.mediaDevices&&(this.onDeviceChange=this.onDeviceChange.bind(this),navigator.mediaDevices.addEventListener("devicechange",this.onDeviceChange))}async init(){this.prevDevices_=await dg.default.getDevices()}async onDeviceChange(){let p=await dg.default.getDevices(),G=p.filter(H=>this.prevDevices_.findIndex(({deviceId:Q})=>H.deviceId===Q)<0),$=this.prevDevices_.filter(H=>p.findIndex(({deviceId:Q})=>H.deviceId===Q)<0);G.length>0&&G.forEach(H=>{this.emit("device-added",H)}),$.length>0&&$.forEach(H=>{this.emit("device-removed",H)}),this.prevDevices_=p}destroy(){navigator.mediaDevices.removeEventListener("devicechange",this.onDeviceChange)}},_w=hg;var Ft=Go.default.Logger.loggerManager,Ho=class extends P7{constructor(){super(...arguments);Ve(this,"version",ew);Ve(this,"_deviceDetector",new _w);Ve(this,"_virtualOverloadCount",0);Ve(this,"_isVirtualOverloadStart",0)}init(p){return Ft.info(`lingo-trtc version: ${this.version}`),Promise.resolve()}release(){this._deviceDetector.destroy(),super.release()}async checkSystemRequirements(){let{result:p}=await Go.default.checkSystemRequirements();return p&&Go.default.isScreenShareSupported()}async createClient(){return this.client=new En,await this._deviceDetector.init(),this._deviceDetector.on("device-added",p=>{p.kind==="videoinput"?this.client.emit("CameraChanged",!0,p):p.kind==="audioinput"?this.client.emit("MicrophoneChanged",!0,p):p.kind==="audiooutput"&&this.client.emit("SpeakerDeviceChanged",!0,p)}),this._deviceDetector.on("device-removed",async p=>{var G,$;if(p.kind==="videoinput"){let H=this.cameraVideoTrack||this.previewVideoTrack;if(p.deviceId===(H==null?void 0:H.getDeviceId())){if((await Go.default.getCameras()).length===0){this.client.emit("CameraChanged",!1,p);return}H.once("device-switched",()=>{this.client.emit("CameraChanged",!1,p)}),H.once("track-ended",()=>{this.client.emit("CameraChanged",!1,p)})}else this.client.emit("CameraChanged",!1,p)}else if(p.kind==="audioinput")if(p.deviceId===((G=this.microphoneAudioTrack)==null?void 0:G.getDeviceId())){if((await Go.default.getMicrophones()).length===0){this.client.emit("CameraChanged",!1,p);return}this.microphoneAudioTrack.once("device-switched",()=>{this.client.emit("CameraChanged",!1,p)}),($=this.microphoneAudioTrack)==null||$.once("track-ended",()=>{this.client.emit("CameraChanged",!1,p)})}else this.client.emit("MicrophoneChanged",!1,p);else p.kind==="audiooutput"&&this.client.emit("SpeakerDeviceChanged",!1,p)}),this.client}async createCustomVideoTrack(p){if(this.customVideoTrack&&!this.customVideoTrack.closed)return this.customVideoTrack;Ft.info("createCustomVideoTrack");let G=new kd(p);return await G.init(),this.customVideoTrack=G,G}async detectCamera(p){var G,$;if(this.previewVideoTrack&&!this.previewVideoTrack.closed)return{checkIsActive:()=>{var H,Q;return Promise.resolve(((Q=(H=this.previewVideoTrack)==null?void 0:H.getMediaStreamTrack())==null?void 0:Q.readyState)==="live")},cleanup:()=>{var H,Q;(H=this.previewVideoTrack)==null||H.stop(),(Q=this.previewVideoTrack)==null||Q.close(),this.previewVideoTrack=void 0}};Ft.info("detectCamera");try{let H=new ya({cameraId:p.cameraId,id:"pv"});return H.on("device-switched",Q=>this.client.emit("DeviceSwitched",Q)),this.previewVideoTrack=H,await H.init(),p.mirror&&H.mirrorVideo(p.mirror),p.container&&await H.play({container:p.container}),{checkIsActive:()=>{var Q;return Promise.resolve(((Q=H.getMediaStreamTrack())==null?void 0:Q.readyState)==="live")},cleanup:()=>{H.stop(),H.close(),this.previewVideoTrack=void 0}}}catch(H){throw(G=this.previewVideoTrack)==null||G.stop(),($=this.previewVideoTrack)==null||$.close(),this.previewVideoTrack=void 0,H}}processExternalMediaAEC(p){}async createMicrophoneAudioTrack(p){if(this.microphoneAudioTrack&&!this.microphoneAudioTrack.closed)return this.microphoneAudioTrack;Ft.info("createMicrophoneAudioTrack");let G=new Id({microphoneId:p});return G.on("device-switched",$=>this.client.emit("DeviceSwitched",$)),await G.init(),this.microphoneAudioTrack=G,this.client.emit("LocalTrackCreated",G),G}async createCameraVideoTrack(p){if(this.cameraVideoTrack&&!this.cameraVideoTrack.closed)return this.cameraVideoTrack;Ft.info(`createCameraVideoTrack ${JSON.stringify(p)}`);let G=new ya(vd(Kr({},p),{id:"ct"}));return G.on("device-switched",$=>this.client.emit("DeviceSwitched",$)),await G.init(),this.cameraVideoTrack=G,this.client.emit("LocalTrackCreated",G),this.cameraVideoTrack.on("VirtualBackgroundOverload",()=>{this._virtualOverloadCount++,Ft.warn(`VirtualBackground overload count is: ${this._virtualOverloadCount}`),new Date().getTime()-this._isVirtualOverloadStart>5e3&&(this._virtualOverloadCount>10&&(Ft.warn("VirtualBackgroundOverload"),this.client.emit("VirtualBackgroundOverload")),this._virtualOverloadCount=0,this._isVirtualOverloadStart=new Date().getTime())}),G}async getDevicesCore(p,G){return(await super.getDevicesCore(p,G)).filter(H=>!(H.label&&H.label.toLowerCase().includes("virtual")))}};wn([Ed(),Cn(ne=>fg.createRTCError(ne))],Ho.prototype,"detectCamera",1),wn([Cn(ne=>fg.createRTCError(ne))],Ho.prototype,"createMicrophoneAudioTrack",1),wn([Cn(ne=>fg.createRTCError(ne))],Ho.prototype,"createCameraVideoTrack",1);if(document){let ne={MAIN:"schedule.rtc.qq.com",BACKUP:"schedule.rtc.qcloud.com",MAIN_OVERSEA:"schedule.rtc.tencentcloud.com",BACKUP_OVERSEA:"schedule-ecdn.rtc.tencentcloud.com"};document.head.innerHTML+=Object.values(ne).map(q=>`<link rel="dns-prefetch" href="https://${q}">`).join(`\r
548
+ `+V.getProgramInfoLog(ee));F=O.s=ee,V.useProgram(F),W=V.getUniformLocation(F,"sampler0"),O.l={O:V.getAttribLocation(F,"aVertex"),N:V.getAttribLocation(F,"aTex"),ya:W},O.v=V.createBuffer(),V.bindBuffer(V.ARRAY_BUFFER,O.v),V.enableVertexAttribArray(O.l.O),V.vertexAttribPointer(O.l.O,2,V.FLOAT,!1,0,0),V.bufferData(V.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),V.STATIC_DRAW),V.bindBuffer(V.ARRAY_BUFFER,null),O.u=V.createBuffer(),V.bindBuffer(V.ARRAY_BUFFER,O.u),V.enableVertexAttribArray(O.l.N),V.vertexAttribPointer(O.l.N,2,V.FLOAT,!1,0,0),V.bufferData(V.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),V.STATIC_DRAW),V.bindBuffer(V.ARRAY_BUFFER,null),V.uniform1i(W,0)}F=O.l,V.useProgram(O.s),V.canvas.width=j.width,V.canvas.height=j.height,V.viewport(0,0,j.width,j.height),V.activeTexture(V.TEXTURE0),O.i.bindTexture2d(j.glName),V.enableVertexAttribArray(F.O),V.bindBuffer(V.ARRAY_BUFFER,O.v),V.vertexAttribPointer(F.O,2,V.FLOAT,!1,0,0),V.enableVertexAttribArray(F.N),V.bindBuffer(V.ARRAY_BUFFER,O.u),V.vertexAttribPointer(F.N,2,V.FLOAT,!1,0,0),V.bindFramebuffer(V.DRAW_FRAMEBUFFER?V.DRAW_FRAMEBUFFER:V.FRAMEBUFFER,null),V.clearColor(0,0,0,0),V.clear(V.COLOR_BUFFER_BIT),V.colorMask(!0,!0,!0,!0),V.drawArrays(V.TRIANGLE_FAN,0,4),V.disableVertexAttribArray(F.O),V.disableVertexAttribArray(F.N),V.bindBuffer(V.ARRAY_BUFFER,null),O.i.bindTexture2d(0)}(d,g),typeof d.h.canvas.transferToImageBitmap=="function"?Promise.resolve(d.h.canvas.transferToImageBitmap()):C?Promise.resolve(d.h.canvas):typeof createImageBitmap=="function"?createImageBitmap(d.h.canvas):(d.j===void 0&&(d.j=document.createElement("canvas")),new Promise(function(O){d.j.height=d.h.canvas.height,d.j.width=d.h.canvas.width,d.j.getContext("2d",{}).drawImage(d.h.canvas,0,0,d.h.canvas.width,d.h.canvas.height),O(d.j)}))}function Bd(d){this.h=d}Oa.prototype.l=ps(nu);var iu=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function Fd(d,g){return g+d}function Ma(d,g){window[d]=g}function Yn(d){if(this.h=d,this.listeners={},this.l={},this.L={},this.s={},this.v={},this.M=this.u=this.ga=!0,this.I=Promise.resolve(),this.fa="",this.D={},this.locateFile=d&&d.locateFile||Fd,(typeof window=="undefined"?"undefined":$(window))==="object")var g=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if(typeof location=="undefined")throw Error("solutions can only be loaded on a web page or in a web worker");g=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.ha=g,d.options)for(var C=(g=K(Object.keys(d.options))).next();!C.done;C=g.next()){C=C.value;var O=d.options[C].default;O!==void 0&&(this.l[C]=typeof O=="function"?O():O)}}function Hd(d){var g,C,O,j,V,F,W,ee,fe,me,Ce;return $e(function(Ae){switch(Ae.h){case 1:return d.ga?(g=d.h.files===void 0?[]:typeof d.h.files=="function"?d.h.files(d.l):d.h.files,ft(Ae,$e(function(ve){switch(ve.h){case 1:return ve.s=2,ft(ve,WebAssembly.instantiate(iu),4);case 4:ve.h=3,ve.s=0;break;case 2:return ve.s=0,ve.l=null,ve.return(!1);case 3:return ve.return(!0)}}),2)):Ae.return();case 2:if(C=Ae.i,(typeof window=="undefined"?"undefined":$(window))==="object")return Ma("createMediapipeSolutionsWasm",{locateFile:d.locateFile}),Ma("createMediapipeSolutionsPackedAssets",{locateFile:d.locateFile}),F=g.filter(function(ve){return ve.data!==void 0}),W=g.filter(function(ve){return ve.data===void 0}),ee=Promise.all(F.map(function(ve){var Oe=ti(d,ve.url);if(ve.path!==void 0){var Be=ve.path;Oe=Oe.then(function(ot){return d.overrideFile(Be,ot),Promise.resolve(ot)})}return Oe})),fe=Promise.all(W.map(function(ve){return ve.simd===void 0||ve.simd&&C||!ve.simd&&!C?function(Oe){var Be=document.createElement("script");return Be.setAttribute("src",Oe),Be.setAttribute("crossorigin","anonymous"),new Promise(function(ot){Be.addEventListener("load",function(){ot()},!1),Be.addEventListener("error",function(){ot()},!1),document.body.appendChild(Be)})}(d.locateFile(ve.url,d.ha)):Promise.resolve()})).then(function(){var ve,Oe,Be;return $e(function(ot){if(ot.h==1)return ve=window.createMediapipeSolutionsWasm,Oe=window.createMediapipeSolutionsPackedAssets,Be=d,ft(ot,ve(Oe),2);Be.i=ot.i,ot.h=0})}),me=$e(function(ve){return d.h.graph&&d.h.graph.url?ve=ft(ve,ti(d,d.h.graph.url),0):(ve.h=0,ve=void 0),ve}),ft(Ae,Promise.all([fe,ee,me]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return O=g.filter(function(ve){return ve.simd===void 0||ve.simd&&C||!ve.simd&&!C}).map(function(ve){return d.locateFile(ve.url,d.ha)}),importScripts.apply(null,oe(O)),j=d,ft(Ae,createMediapipeSolutionsWasm(Module),6);case 6:j.i=Ae.i,d.m=new OffscreenCanvas(1,1),d.i.canvas=d.m,V=d.i.GL.createContext(d.m,{antialias:!1,alpha:!1,va:typeof WebGL2RenderingContext!="undefined"?2:1}),d.i.GL.makeContextCurrent(V),Ae.h=4;break;case 7:if(d.m=document.createElement("canvas"),!(Ce=d.m.getContext("webgl2",{}))&&!(Ce=d.m.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),Ae.return();d.K=Ce,d.i.canvas=d.m,d.i.createContext(d.m,!0,!0,{});case 4:d.j=new d.i.SolutionWasm,d.ga=!1,Ae.h=0}})}function ti(d,g){var C,O;return $e(function(j){return g in d.L?j.return(d.L[g]):(C=d.locateFile(g,""),O=fetch(C).then(function(V){return V.arrayBuffer()}),d.L[g]=O,j.return(O))})}function Gd(d,g,C){var O,j,V,F,W,ee,fe,me,Ce,Ae,ve,Oe,Be,ot;return $e(function(lt){switch(lt.h){case 1:if(!C)return lt.return(g);for(O={},j=0,V=K(Object.keys(C)),F=V.next();!F.done;F=V.next())W=F.value,typeof(ee=C[W])!="string"&&ee.type==="texture"&&g[ee.stream]!==void 0&&++j;1<j&&(d.M=!1),fe=K(Object.keys(C)),F=fe.next();case 2:if(F.done){lt.h=4;break}if(me=F.value,typeof(Ce=C[me])=="string")return Be=O,ot=me,ft(lt,function(Mn,Va,ri){var ja;return $e(function(_s){return typeof ri=="number"||ri instanceof Uint8Array||ri instanceof Mn.i.Uint8BlobList?_s.return(ri):ri instanceof Mn.i.Texture2dDataOut?((ja=Mn.v[Va])||(ja=new Hi(Mn.i,Mn.K),Mn.v[Va]=ja),_s.return(La(ja,ri,Mn.M))):_s.return(void 0)})}(d,me,g[Ce]),14);if(Ae=g[Ce.stream],Ce.type==="detection_list"){if(Ae){for(var jt=Ae.getRectList(),mn=Ae.getLandmarksList(),bt=Ae.getClassificationsList(),Je=[],Ke=0;Ke<jt.size();++Ke){var _r=Vd(jt.get(Ke)),Ua=void 0;Ua=Ua===void 0?0:Ua,_r={la:{sa:On(_r,1),ta:On(_r,2),height:On(_r,3),width:On(_r,4),rotation:On(_r,5,0),pa:Aa(pn(_r,6),Ua)},ea:kt(Ud(mn.get(Ke)),gr,1).map(Ln),ba:jd(Nd(bt.get(Ke)))},Je.push(_r)}jt=Je}else jt=[];O[me]=jt,lt.h=7;break}if(Ce.type==="proto_list"){if(Ae){for(jt=Array(Ae.size()),mn=0;mn<Ae.size();mn++)jt[mn]=Ae.get(mn);Ae.delete()}else jt=[];O[me]=jt,lt.h=7;break}if(Ae===void 0){lt.h=3;break}if(Ce.type==="float_list"){O[me]=Ae,lt.h=7;break}if(Ce.type==="proto"){O[me]=Ae,lt.h=7;break}if(Ce.type!=="texture")throw Error("Unknown output config type: '"+Ce.type+"'");return(ve=d.v[me])||(ve=new Hi(d.i,d.K),d.v[me]=ve),ft(lt,La(ve,Ae,d.M),13);case 13:Oe=lt.i,O[me]=Oe;case 7:Ce.transform&&O[me]&&(O[me]=Ce.transform(O[me])),lt.h=3;break;case 14:Be[ot]=lt.i;case 3:F=fe.next(),lt.h=2;break;case 4:return lt.return(O)}})}function Na(d,g){for(var C=g.name||"$",O=[].concat(oe(g.wants)),j=new d.i.StringList,V=K(g.wants),F=V.next();!F.done;F=V.next())j.push_back(F.value);V=d.i.PacketListener.implement({onResults:function(W){for(var ee={},fe=0;fe<g.wants.length;++fe)ee[O[fe]]=W.get(fe);var me=d.listeners[C];me&&(d.I=Gd(d,ee,g.outs).then(function(Ce){Ce=me(Ce);for(var Ae=0;Ae<g.wants.length;++Ae){var ve=ee[O[Ae]];$(ve)==="object"&&ve.hasOwnProperty&&ve.hasOwnProperty("delete")&&ve.delete()}Ce&&(d.I=Ce)}))}}),d.j.attachMultiListener(j,V),j.delete()}function ni(d){return d===void 0&&(d=0),d===1?"selfie_segmentation_landscape.tflite":"selfie_segmentation.tflite"}function Gi(d){var g=this;d=d||{},this.h=new Yn({locateFile:d.locateFile,files:function(C){return[{simd:!0,url:"selfie_segmentation_solution_simd_wasm_bin.js"},{simd:!1,url:"selfie_segmentation_solution_wasm_bin.js"},{data:!0,url:ni(C.modelSelection)}]},graph:{url:"selfie_segmentation.binarypb"},listeners:[{wants:["segmentation_mask","image_transformed"],outs:{image:{type:"texture",stream:"image_transformed"},segmentationMask:{type:"texture",stream:"segmentation_mask"}}}],inputs:{image:{type:"video",stream:"input_frames_gpu"}},options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:(typeof window=="undefined"?"undefined":$(window))==="object"&&window.navigator!==void 0&&("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document)},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},modelSelection:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorModelSelection",fieldName:"int_value"},onChange:function(C){var O,j,V;return $e(function(F){return F.h==1?(O=ni(C),j="third_party/mediapipe/modules/selfie_segmentation/"+O,ft(F,ti(g.h,O),2)):(V=F.i,g.h.overrideFile(j,V),F.return(!0))})}}}})}(ue=Yn.prototype).close=function(){return this.j&&this.j.delete(),Promise.resolve()},ue.reset=function(){var d=this;return $e(function(g){d.j&&(d.j.reset(),d.s={},d.v={}),g.h=0})},ue.setOptions=function(d,g){var C=this;if(g=g||this.h.options){for(var O=[],j=[],V={},F=K(Object.keys(d)),W=F.next();!W.done;V={X:V.X,Y:V.Y},W=F.next())if(!((W=W.value)in this.l)||this.l[W]!==d[W]){this.l[W]=d[W];var ee=g[W];ee!==void 0&&(ee.onChange&&(V.X=ee.onChange,V.Y=d[W],O.push(function(fe){return function(){return $e(function(me){if(me.h==1)return ft(me,fe.X(fe.Y),2);me.i===!0&&(C.u=!0),me.h=0})}}(V))),ee.graphOptionXref&&(W=Object.assign({},{calculatorName:"",calculatorIndex:0},ee.graphOptionXref,{valueNumber:ee.type===1?d[W]:0,valueBoolean:ee.type===0&&d[W],valueString:ee.type===2?d[W]:""}),j.push(W)))}O.length===0&&j.length===0||(this.u=!0,this.H=(this.H===void 0?[]:this.H).concat(j),this.F=(this.F===void 0?[]:this.F).concat(O))}},ue.initialize=function(){var d=this;return $e(function(g){return g.h==1?ft(g,Hd(d),2):g.h!=3?ft(g,function(C){var O,j,V,F,W,ee,fe,me;return $e(function(Ce){if(Ce.h==1)return C.h.graph&&C.h.graph.url&&C.fa===C.h.graph.url?Ce.return():(C.u=!0,C.h.graph&&C.h.graph.url?(C.fa=C.h.graph.url,ft(Ce,ti(C,C.h.graph.url),3)):void(Ce.h=2));for(Ce.h!=2&&(O=Ce.i,C.j.loadGraph(O)),j=K(Object.keys(C.D)),V=j.next();!V.done;V=j.next())F=V.value,C.j.overrideFile(F,C.D[F]);if(C.D={},C.h.listeners)for(W=K(C.h.listeners),ee=W.next();!ee.done;ee=W.next())fe=ee.value,Na(C,fe);me=C.l,C.l={},C.setOptions(me),Ce.h=0})}(d),3):ft(g,function(C){var O,j,V,F,W,ee;return $e(function(fe){switch(fe.h){case 1:if(!C.u)return fe.return();if(!C.F){fe.h=2;break}O=K(C.F),j=O.next();case 3:if(j.done){fe.h=5;break}return ft(fe,(0,j.value)(),4);case 4:j=O.next(),fe.h=3;break;case 5:C.F=void 0;case 2:if(C.H){for(V=new C.i.GraphOptionChangeRequestList,F=K(C.H),W=F.next();!W.done;W=F.next())ee=W.value,V.push_back(ee);C.j.changeOptions(V),V.delete(),C.H=void 0}C.u=!1,fe.h=0}})}(d),0)})},ue.overrideFile=function(d,g){this.j?this.j.overrideFile(d,g):this.D[d]=g},ue.clearOverriddenFiles=function(){this.D={},this.j&&this.j.clearOverriddenFiles()},ue.send=function(d,g){var C,O,j,V,F,W,ee,fe,me,Ce=this;return $e(function(Ae){switch(Ae.h){case 1:return Ce.h.inputs?(C=1e3*(g==null?performance.now():g),ft(Ae,Ce.I,2)):Ae.return();case 2:return ft(Ae,Ce.initialize(),3);case 3:for(O=new Ce.i.PacketDataList,j=K(Object.keys(d)),V=j.next();!V.done;V=j.next())if(F=V.value,W=Ce.h.inputs[F]){e:{var ve=d[F];switch(W.type){case"video":var Oe=Ce.s[W.stream];if(Oe||(Oe=new Hi(Ce.i,Ce.K),Ce.s[W.stream]=Oe),Oe.m===0&&(Oe.m=Oe.i.createTexture()),typeof HTMLVideoElement!="undefined"&&ve instanceof HTMLVideoElement)var Be=ve.videoWidth,ot=ve.videoHeight;else typeof HTMLImageElement!="undefined"&&ve instanceof HTMLImageElement?(Be=ve.naturalWidth,ot=ve.naturalHeight):(Be=ve.width,ot=ve.height);ot={glName:Oe.m,width:Be,height:ot},(Be=Oe.h).canvas.width=ot.width,Be.canvas.height=ot.height,Be.activeTexture(Be.TEXTURE0),Oe.i.bindTexture2d(Oe.m),Be.texImage2D(Be.TEXTURE_2D,0,Be.RGBA,Be.RGBA,Be.UNSIGNED_BYTE,ve),Oe.i.bindTexture2d(0),Oe=ot;break e;case"detections":for((Oe=Ce.s[W.stream])||(Oe=new Bd(Ce.i),Ce.s[W.stream]=Oe),Oe.data||(Oe.data=new Oe.h.DetectionListData),Oe.data.reset(ve.length),ot=0;ot<ve.length;++ot){Be=ve[ot];var lt=Oe.data,jt=lt.setBoundingBox,mn=ot,bt=Be.la,Je=new Oa;if(Dn(Je,1,bt.sa),Dn(Je,2,bt.ta),Dn(Je,3,bt.height),Dn(Je,4,bt.width),Dn(Je,5,bt.rotation),Pn(Je,6,bt.pa),bt=Je.l(),jt.call(lt,mn,bt),Be.ea)for(lt=0;lt<Be.ea.length;++lt){Je=Be.ea[lt],mn=(jt=Oe.data).addNormalizedLandmark,bt=ot,Je=Object.assign({},Je,{visibility:Je.visibility?Je.visibility:0});var Ke=new gr;Dn(Ke,1,Je.x),Dn(Ke,2,Je.y),Dn(Ke,3,Je.z),Je.visibility&&Dn(Ke,4,Je.visibility),Je=Ke.l(),mn.call(jt,bt,Je)}if(Be.ba)for(lt=0;lt<Be.ba.length;++lt)mn=(jt=Oe.data).addClassification,bt=ot,Je=Be.ba[lt],Dn(Ke=new ei,2,Je.qa),Je.index&&Pn(Ke,1,Je.index),Je.label&&Pn(Ke,3,Je.label),Je.displayName&&Pn(Ke,4,Je.displayName),Je=Ke.l(),mn.call(jt,bt,Je)}Oe=Oe.data;break e;default:Oe={}}}switch(ee=Oe,fe=W.stream,W.type){case"video":O.pushTexture2d(Object.assign({},ee,{stream:fe,timestamp:C}));break;case"detections":(me=ee).stream=fe,me.timestamp=C,O.pushDetectionList(me);break;default:throw Error("Unknown input config type: '"+W.type+"'")}}return Ce.j.send(O),ft(Ae,Ce.I,4);case 4:O.delete(),Ae.h=0}})},ue.onResults=function(d,g){this.listeners[g||"$"]=d},he("Solution",Yn),he("OptionType",{BOOL:0,NUMBER:1,ua:2,0:"BOOL",1:"NUMBER",2:"STRING"}),(ue=Gi.prototype).close=function(){return this.h.close(),Promise.resolve()},ue.onResults=function(d){this.h.onResults(d)},ue.initialize=function(){var d=this;return $e(function(g){return ft(g,d.h.initialize(),0)})},ue.reset=function(){this.h.reset()},ue.send=function(d){var g=this;return $e(function(C){return ft(C,g.h.send(d),0)})},ue.setOptions=function(d){this.h.setOptions(d)},he("SelfieSegmentation",Gi),he("VERSION","0.1.1675465747")}).call(Jo);var Rr=function(ue){return typeof ue=="number"},Pc=function(){function ue(){we(this,ue),this.userId="",this.videoBeauty=document.createElement("video"),this.videoBeauty.loop=!0,this.videoBeauty.autoplay=!0,this.videoVirtual=document.createElement("video"),this.videoVirtual.loop=!0,this.videoVirtual.autoplay=!0,this.onoverload=null,this.canvasBeauty=document.createElement("canvas"),this.filter=new zo({canvas:this.canvasBeauty,video:this.videoBeauty}),this.canvasVirtual=document.createElement("canvas"),this.virtual=new Wo({canvas:this.canvasVirtual,video:this.videoVirtual,onoverload:this.onoverload}),this.beautyParams={beauty:.5,brightness:.5,ruddy:.5},this.timeoutId=null,this.rafId=null,this.startTime=null,this.originTrack=null,this.beautyTrack=null,this.resultTrack=null,this.localStream=null,this.frameRate=null,this.disableStatus=!1,this.isVirualEnable=!1}var Te,Se,je,He,ae;return Ye(ue,[{key:"generateBeautyStream",value:function(K){this.userId=K==null?void 0:K.getUserId();var oe=K.getVideoTrack();if(!oe)throw new Error("Your localStream does not contain video track.");var z=this.generateBeautyTrack(oe);return K.replaceTrack(z),this.localStream=K,K.setBeautyStatus&&K.setBeautyStatus(!0),console.log("RTCBeautyPlugin: generateBeautyStream ".concat(this.userId?"userId: ".concat(this.userId):"")),K}},{key:"generateBeautyTrack",value:function(K){var oe=this;this.reset();var z=K.getSettings();this.frameRate=z.frameRate,this.filter.setRect(z.width,z.height),this.setRect(z.width,z.height);var re=new MediaStream;re.addTrack(K),this.videoBeauty.srcObject=re,this.videoBeauty.play();var be=this.canvasBeauty.captureStream(this.frameRate||15).getVideoTracks()[0];return this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(function(){oe.startTime=new Date().getTime(),oe.render()}),this.installEvents(),this.originTrack=K,this.beautyTrack=be,this.setTrackParam({type:"beauty",originTrack:K,resultTrack:be,param:this.beautyParams}),be}},{key:"setBackground",value:(ae=Q(G().mark(function K(oe){return G().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:return z.next=2,this.virtual.setBackground(oe);case 2:console.log("RTCBeautyPlugin: setBackground img:".concat(oe));case 3:case"end":return z.stop()}},K,this)})),function(K){return ae.apply(this,arguments)})},{key:"generateStream",value:(He=Q(G().mark(function K(oe){var z,re,be,se,ye;return G().wrap(function(Me){for(;;)switch(Me.prev=Me.next){case 0:if(z=oe.localStream,re=oe.type,be=oe.img,se=z.getVideoTrack()){Me.next=4;break}throw new Error("Your localStream does not contain video track.");case 4:return this.localStream=z,Me.next=7,this.generateMixedTrack({videoTrack:se,type:re,img:be});case 7:return ye=Me.sent,z.replaceTrack(ye),z.setBeautyStatus&&z.setBeautyStatus(!0),Me.abrupt("return",z);case 11:case"end":return Me.stop()}},K,this)})),function(K){return He.apply(this,arguments)})},{key:"generateMixedTrack",value:(je=Q(G().mark(function K(oe){var z,re,be,se,ye;return G().wrap(function(Me){for(;;)switch(Me.prev=Me.next){case 0:if(z=oe.videoTrack,re=oe.type,be=oe.img,this.virtual.selfieSegmentation){Me.next=3;break}throw new Error("you should call loadResources() first");case 3:return this.virtual.initVirtualParams({type:re,img:be}),Me.next=6,this.generateBeautyTrack(z);case 6:return se=Me.sent,Me.next=9,this.generateVirtualTrack({videoTrack:se,type:re,img:be});case 9:return ye=Me.sent,this.beautyTrack=se,this.resultTrack=ye,this.setTrackParam({type:"mixed",originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:re,img:be}}),Me.abrupt("return",this.resultTrack);case 14:case"end":return Me.stop()}},K,this)})),function(K){return je.apply(this,arguments)})},{key:"generateVirtualStream",value:(Se=Q(G().mark(function K(oe){var z,re,be,se,ye;return G().wrap(function(Me){for(;;)switch(Me.prev=Me.next){case 0:if(z=oe.localStream,re=oe.type,be=oe.img,se=z.getVideoTrack()){Me.next=4;break}throw new Error("Your localStream does not contain video track.");case 4:return this.localStream=z,Me.next=7,this.generateVirtualTrack({videoTrack:se,type:re,img:be});case 7:return ye=Me.sent,Me.next=10,z.replaceTrack(ye);case 10:return z.setBeautyStatus&&z.setBeautyStatus(!0),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin generate ").concat(re," Stream.")),Me.abrupt("return",z);case 13:case"end":return Me.stop()}},K,this)})),function(K){return Se.apply(this,arguments)})},{key:"generateVirtualTrack",value:(Te=Q(G().mark(function K(oe){var z,re,be,se;return G().wrap(function(ye){for(;;)switch(ye.prev=ye.next){case 0:if(z=oe.videoTrack,re=oe.type,be=oe.img,this.virtual.selfieSegmentation){ye.next=3;break}throw new Error("you should call loadResources() first");case 3:return se=z.getSettings(),this.frameRate=se.frameRate,this.virtual.setRect(se.width,se.height),ye.next=8,this.virtual.initVirtualParams({type:re,img:be});case 8:return this.setRect(se.width,se.height),this.mediaStream=new MediaStream,this.mediaStream.addTrack(z),this.videoVirtual.srcObject=this.mediaStream,ye.next=14,this.videoVirtual.play();case 14:return this.virtual.startVirtual(this.frameRate),ye.next=17,this.virtual.render();case 17:return this.originTrack=z,this.resultTrack=this.canvasVirtual.captureStream(this.frameRate||15).getVideoTracks()[0],this.setTrackParam({type:"virtual",originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:re,img:be}}),this.isVirualEnable=!0,ye.abrupt("return",this.resultTrack);case 22:case"end":return ye.stop()}},K,this)})),function(K){return Te.apply(this,arguments)})},{key:"replaceVirtualTrack",value:function(K){this.isVirualEnable&&(this.mediaStream.removeTrack(this.mediaStream.getVideoTracks()[0]),this.mediaStream.addTrack(K),this.originTrack=K)}},{key:"deleteSource",value:function(K){if(f.default){var oe=f.default.beautyTrackMap.get(K);oe&&(oe.type==="mixed"&&this.deleteSource(oe.originTrack.id),oe.originTrack&&(oe.originTrack.stop(),oe.originTrack=null),oe.beautyTrack&&(oe.beautyTrack.stop(),oe.beautyTrack=null),oe.resultTrack&&(oe.resultTrack.stop(),oe.resultTrack=null),f.default.beautyTrackMap.delete(K))}}},{key:"draw",value:function(){this.videoBeauty&&this.videoBeauty.readyState===this.videoBeauty.HAVE_ENOUGH_DATA&&this.filter.apply(this.videoBeauty)}},{key:"enableVirtualBg",value:function(){var K;if(this.virtual&&!this.isVirualEnable)return this.virtual.setEnable(!0),this.virtual.render(),this.isVirualEnable=!0,(K=this.localStream)===null||K===void 0||K.replaceTrack(this.resultTrack),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin enable.")),this.resultTrack}},{key:"disableVirtualBg",value:function(){var K;if(this.virtual&&this.isVirualEnable)return this.virtual.setEnable(!1),this.isVirualEnable=!1,(K=this.localStream)===null||K===void 0||K.replaceTrack(this.originTrack),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin disable.")),this.originTrack}},{key:"changeType",value:function(K){var oe=K.type,z=K.img;console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin changeType\uFF1A").concat(oe,". img: ").concat(z,".")),oe==="blur"&&(this.virtual.reset(),this.virtual.initVirtualParams({type:"blur"}),this.virtual.startVirtual(this.frameRate),this.virtual.render()),oe==="virtual"&&(this.virtual.reset(),this.virtual.initVirtualParams({type:"virtual",img:z}),this.virtual.startVirtual(this.frameRate),this.virtual.render()),this.setTrackParam({type:oe,originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:oe,img:z}})}},{key:"render",value:function(){var K=this,oe=new Date().getTime();oe-this.startTime>1e3/this.frameRate&&(this.draw(),this.startTime=oe),document.hidden?(clearTimeout(this.timeoutId),this.timeoutId=setTimeout(function(){K.render()},1e3/this.frameRate)):(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(this.render.bind(this)))}},{key:"setBeautyParam",value:function(K){var oe=K.beauty,z=K.brightness,re=K.ruddy;Rr(oe)&&(this.beautyParams.beauty=oe),Rr(z)&&(this.beautyParams.brightness=z),Rr(re)&&(this.beautyParams.ruddy=re),this.filter.setBeautyParams(this.beautyParams),this.getClose()&&!this.disableStatus&&this.disable(),!this.getClose()&&this.disableStatus&&this.enable()}},{key:"setRect",value:function(K,oe){var z=K||640,re=oe||480;this.videoBeauty.height=re,this.videoBeauty.width=z,this.canvasBeauty.height=re,this.canvasBeauty.width=z,this.videoVirtual.height=re,this.videoVirtual.width=z,this.canvasVirtual.height=re,this.canvasVirtual.width=z}},{key:"reset",value:function(){cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.videoBeauty.pause(),this.filter.reset(),this.beautyTrack&&this.beautyTrack.stop(),this.videoVirtual.pause(),this.resultTrack&&this.resultTrack.stop(),this.originTrack&&this.originTrack.stop()}},{key:"destroy",value:function(){cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.canvasBeauty&&(this.canvasBeauty.width=0,this.canvasBeauty.height=0,this.canvasBeauty.remove(),this.canvasBeauty=null),this.videoBeauty&&(this.videoBeauty.pause(),this.videoBeauty.removeAttribute("srcObject"),this.videoBeauty.removeAttribute("src"),this.videoBeauty.load(),this.videoBeauty.width=0,this.videoBeauty.height=0,this.videoBeauty.remove(),this.videoBeauty=null),this.beautyTrack&&(this.deleteSource(this.beautyTrack.id),this.beautyTrack.stop(),this.beautyTrack=null),this.originTrack&&(this.originTrack.stop(),this.originTrack=null),this.resultTrack&&(this.deleteSource(this.resultTrack.id),this.resultTrack.stop(),this.resultTrack=null),this.canvasVirtual&&(this.canvasVirtual.width=0,this.canvasVirtual.height=0,this.canvasVirtual.remove(),this.canvasVirtual=null),this.videoVirtual&&(this.videoVirtual.pause(),this.videoVirtual.removeAttribute("srcObject"),this.videoVirtual.removeAttribute("src"),this.videoVirtual.load(),this.videoVirtual.width=0,this.videoVirtual.height=0,this.videoVirtual.remove(),this.videoVirtual=null),this.virtual.destroy(),this.uninstallEvents()}},{key:"generateVideoTrackFromCanvasCapture",value:function(K){return this.canvasVirtual.captureStream(K).getVideoTracks()[0]}},{key:"setTrackParam",value:function(K){var oe=K.type,z=K.originTrack,re=K.resultTrack,be=K.param;f.default&&(f.default.beautyTrackMap||(f.default.beautyTrackMap=new Map),f.default.beautyTrackMap.set(re.id,{type:oe,originTrack:z,resultTrack:re,param:be,pluginInstance:this}))}},{key:"disable",value:function(){this.localStream&&this.originTrack&&(this.localStream.replaceTrack(this.originTrack),cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.disableStatus=!0)}},{key:"enable",value:function(){this.localStream&&this.beautyTrack&&(this.localStream.replaceTrack(this.beautyTrack),this.render(),this.disableStatus=!1)}},{key:"installEvents",value:function(){document.addEventListener("visibilitychange",this.render.bind(this))}},{key:"uninstallEvents",value:function(){document.removeEventListener("visibilitychange",this.render.bind(this))}},{key:"overload",value:function(){this.onoverload&&this.onoverload()}},{key:"getClose",value:function(){return this.beautyParams.beauty===0&&this.beautyParams.brightness===0&&this.beautyParams.ruddy===0}}]),ue}();return f.default&&(f.default.getRTCBeautyPlugin=function(){return new Pc}),Pc})});var ew="0.0.20";var _d=lr(Er());var gd=lr(Er());var dw=lr(ig());var Uo=class extends dw.default{constructor({mediaType:f}){super();Ve(this,"trackMediaType");Ve(this,"_stream");Ve(this,"_playerState");this.trackMediaType=f}get isPlaying(){return this._playerState==="PLAYING"}async stop(){this._playerState="STOPPED",await this._stream.stop()}};var C7=1,Vo=class extends Uo{constructor(f){super(f);Ve(this,"TRTC",gd.default);Ve(this,"muted");Ve(this,"_publishedStream",null);Ve(this,"_log");this._log=Ft.createLogger({id:f.id+C7++})}get closed(){let f=this.getMediaStreamTrack();return f?f.readyState==="ended":!0}async init(){this._stream.on("device-auto-recovered",async({isMicrophone:f,isCamera:G,microphoneId:$,cameraId:H})=>{if(this._publishedStream&&this._stream!==this._publishedStream){let Q=this.getMediaStreamTrack(),we=this.trackMediaType==="audio"?this._publishedStream.getAudioTrack():this._publishedStream.getVideoTrack();Q&&we&&Q!==we&&this._publishedStream.replaceTrack(Q)}if(f){let Q=(await gd.default.getMicrophones()).find(we=>we.deviceId===$);Q&&this.emit("device-switched",Q)}if(G){let Q=(await gd.default.getCameras()).find(we=>we.deviceId===H);Q&&this.emit("device-switched",Q)}}),this._stream.on("player-state-changed",({state:f})=>{this._playerState=f}),this._stream.on("error",f=>{f.getCode()===16452&&this.emit("track-ended",this.trackMediaType)}),await this._stream.initialize()}setPublishedStream(f){this._publishedStream=f}on(f,G){return super.on(f,G),this}async setMuted(f){let G=this._publishedStream||this._stream;this.trackMediaType==="audio"?f?G.muteAudio():G.unmuteAudio():f?G.muteVideo():G.unmuteVideo()}getMediaStreamTrack(){return this.trackMediaType==="audio"?this._stream.getAudioTrack():this._stream.getVideoTrack()}close(){this._stream.close()}getTrackLabel(){var f;return((f=this.getMediaStreamTrack())==null?void 0:f.label)||""}getDeviceId(){var f,G;return((G=(f=this.getMediaStreamTrack())==null?void 0:f.getSettings())==null?void 0:G.deviceId)||""}};var fw=lr(hw()),pw=lr(Er());var jo=class extends Vo{constructor(f){super(f);Ve(this,"mirrored",!1);Ve(this,"lastPlayContainer");Ve(this,"_beautyPlugin");Ve(this,"_virtualTrack");Ve(this,"_isVirtualEnable",!1);Ve(this,"_imageUrl",null);this.onOriginTrackEnded=this.onOriginTrackEnded.bind(this)}get _originTrack(){var f;return((f=this._beautyPlugin)==null?void 0:f.originTrack)||null}get videoElement(){var f;return((f=this.lastPlayContainer)==null?void 0:f.querySelector(`#video_${this._stream.getId()}`))||null}mirrorVideo(f){this.lastPlayContainer&&this._stream.play(this.lastPlayContainer,{mirror:f}),this.mirrored=f}async applyVirtualBackground(f){var G;if(this._log.info(`applyVirtualBackground ${f} ${this._imageUrl}`),!f)return this.stopVirtualBackground(),!0;if(f===this._imageUrl)return!0;if(this._beautyPlugin||(this._beautyPlugin=new fw.default,await this._beautyPlugin.virtual.loadResources(),this._beautyPlugin.virtual.onoverload=()=>{this._log.info("virtualBackground is onoverload"),this.emit("VirtualBackgroundOverload")}),this._imageUrl)f==="blur"&&this._imageUrl!=="blur"&&this._beautyPlugin.changeType({type:"blur"}),f!=="blur"&&this._imageUrl==="blur"&&this._beautyPlugin.changeType({type:"virtual",img:f}),f!=="blur"&&this._imageUrl!=="blur"&&this._imageUrl!==f&&await this._beautyPlugin.setBackground(f);else{let $=await this._beautyPlugin.generateVirtualStream({localStream:this._stream,type:f==="blur"?"blur":"virtual",img:f==="blur"?void 0:f});this._virtualTrack=$.getVideoTrack(),this._publishedStream&&this._publishedStream.replaceTrack(this._virtualTrack),this._isVirtualEnable=!0}return(G=this._originTrack)==null||G.addEventListener("ended",this.onOriginTrackEnded),this._imageUrl=f,!this._isVirtualEnable&&this._beautyPlugin&&(this._isVirtualEnable=!0,this._beautyPlugin.enableVirtualBg()),!0}async onOriginTrackEnded(){let f=(await pw.default.getCameras())[0];f?this.setDevice(f.deviceId):this.emit("track-ended",this.trackMediaType)}async stopVirtualBackground(){var f;return this._log.info("stopVirtualBackground is called"),this._beautyPlugin&&this._isVirtualEnable&&(this._log.info("RTCBeautyPlugin: call disableVirtualBackground"),this._beautyPlugin.disableVirtualBg(),this._isVirtualEnable=!1,(f=this._originTrack)==null||f.removeEventListener("ended",this.onOriginTrackEnded)),!0}getDeviceId(){var f,G;return this._isVirtualEnable||this._beautyPlugin?((G=(f=this._beautyPlugin.originTrack)==null?void 0:f.getSettings())==null?void 0:G.deviceId)||"":super.getDeviceId()}getMediaStreamTrack(){return this._originTrack&&(this._isVirtualEnable||this._beautyPlugin)?this._originTrack:super.getMediaStreamTrack()}close(){var f;(f=this._beautyPlugin)==null||f.destroy()}};var ya=class extends jo{constructor(f){var we;super(pd(Kr({},f),{mediaType:"video"}));Ve(this,"_videoProfile",{width:320,height:240,frameRate:15,bitrate:300});let{width:G,height:$,frameRate:H,bitrate:Q}=f;Ft.info("new LingoCameraVideoTrack"),this._stream=_d.default.createStream({audio:!1,video:!0,cameraId:f.cameraId}),G&&(this._videoProfile.width=G),$&&(this._videoProfile.height=$),H&&(this._videoProfile.frameRate=H),Q&&(this._videoProfile.bitrate=Q),this._stream.setVideoProfile(this._videoProfile),(we=this._publishedStream)==null||we.setVideoProfile(this._videoProfile)}getVideoProfile(){return this._videoProfile}async play(f){await this._stream.play(f.container,{mirror:this.mirrored}),this.lastPlayContainer=f.container}async stop(){await super.stop(),this.lastPlayContainer=null}async setDevice(f){var H,Q,we,xe;let G=this._beautyPlugin&&this._isVirtualEnable;if(this._log.info(`setDevice ${f} visual: ${G}`),G){let Ye=_d.default.createStream({audio:!1,video:!0,cameraId:f});Ye.setVideoProfile(this._videoProfile),(H=this._publishedStream)==null||H.setVideoProfile(this._videoProfile),await Ye.initialize();let Et=Ye.getVideoTrack();Et&&((Q=this._originTrack)==null||Q.removeEventListener("ended",this.onOriginTrackEnded),await((we=this._beautyPlugin)==null?void 0:we.replaceVirtualTrack(Et)),(xe=this._originTrack)==null||xe.addEventListener("ended",this.onOriginTrackEnded))}else if(await this._stream.switchDevice(this.trackMediaType,f),this._publishedStream&&this._publishedStream!==this._stream){let Ye=this.getMediaStreamTrack();Ye&&await this._publishedStream.replaceTrack(Ye)}let $=(await _d.default.getCameras()).find(Ye=>Ye.deviceId===f);$&&this.emit("device-switched",$),!this._isVirtualEnable&&this._beautyPlugin&&(this._beautyPlugin.destroy(),this._beautyPlugin=null,this._isVirtualEnable=!1,this._imageUrl=null)}close(){var f;(f=this.getMediaStreamTrack())==null||f.stop(),this._stream.hasAudio()||this._stream.close(),super.close()}};var mw=lr(Er());var E7=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(ne){let J=Math.random()*16|0;return(ne=="x"?J:J&3|8).toString(16)})};function yd(){return!performance||!performance.now?Date.now():Math.floor(performance.now())}var sg=class{constructor(){this.intervalMap_=new Map}setInterval(J,f,G=!0){if(!window||!window.requestAnimationFrame)return setInterval(J,f);let $=E7(),H=yd(),Q=H;this.intervalMap_.set($,{rafId:null,timeoutId:null,onVisibilityChange:null});let we=()=>{if(G&&document.hidden){if(J(),!this.intervalMap_.has($))return;let Ye=setTimeout(we,f);this.setTimeoutId($,Ye),H=yd(),Q=H}else{if(Q=yd(),Q-H>=f&&(H=Q,J(),!this.intervalMap_.has($)))return;let Ye=requestAnimationFrame(we);this.setRafId($,Ye)}},xe=requestAnimationFrame(we);if(this.setRafId($,xe),G){let Ye=()=>{if(document.hidden){let Et=yd()-H;if(Et>=f)we();else{let Qe=setTimeout(we,f-Et);this.setTimeoutId($,Qe)}}};document.addEventListener("visibilitychange",Ye),this.setOnVisibilityChange($,Ye),document.hidden&&Ye()}return $}clearInterval(J){if(this.intervalMap_.has(J)){let{rafId:f,timeoutId:G,onVisibilityChange:$}=this.intervalMap_.get(J);cancelAnimationFrame(f),clearTimeout(G),document.removeEventListener("visibilitychange",$),this.intervalMap_.delete(J)}}setTimeoutId(J,f){if(this.intervalMap_.has(J)){let G=this.intervalMap_.get(J);G.timeoutId&&clearTimeout(G.timeoutId),G.timeoutId=f}}setRafId(J,f){if(this.intervalMap_.has(J)){let G=this.intervalMap_.get(J);G.rafId&&cancelAnimationFrame(G.rafId),G.rafId=f}}setOnVisibilityChange(J,f){if(this.intervalMap_.has(J)){let G=this.intervalMap_.get(J);G.onVisibilityChange=f}}},R7=new sg,cg=R7;var bd=class extends jo{constructor(f){super({mediaType:"video",id:"cus"});Ve(this,"frameRate",0);Ve(this,"canvas",document.createElement("canvas"));Ve(this,"canvasCtx");Ve(this,"onDraw",null);Ve(this,"_cameraVideoTrack",null);Ve(this,"_timerId");this._cameraVideoTrack=f}timerStop(){cg.clearInterval(this._timerId)}async init(){var $;if(this.canvasCtx)return;this.canvasCtx=this.canvas.getContext("2d");let f=($=this._cameraVideoTrack)==null?void 0:$.getMediaStreamTrack();if(f){let{width:H,height:Q,frameRate:we}=f.getSettings();H&&(this.canvas.width=H),Q&&(this.canvas.height=Q),we&&(this.frameRate=we)}this._timerId=cg.setInterval(()=>{var we,xe,Ye;let H=(we=this._cameraVideoTrack)==null?void 0:we.getMediaStreamTrack();if(H){let{width:Et,height:Qe,frameRate:dr}=H.getSettings();Et&&(this.canvas.width=Et),Qe&&(this.canvas.height=Qe),dr&&(this.frameRate=dr)}let Q=(xe=this._cameraVideoTrack)==null?void 0:xe.videoElement;Q&&((Ye=this.canvasCtx)==null||Ye.drawImage(Q,0,0,this.canvas.width,this.canvas.height),this.onDraw&&this.onDraw(this.canvas,this.mirrored))},1e3/this.frameRate,!0);let G=this.canvas.captureStream(this.frameRate).getVideoTracks()[0];this._stream=mw.default.createStream({videoSource:G}),await super.init()}async play(f){var G,$,H,Q;if(f.container){this.lastPlayContainer=f.container,(G=this._cameraVideoTrack)!=null&&G.isPlaying||await(($=this._cameraVideoTrack)==null?void 0:$.play({container:f.container}));let we=(H=this._cameraVideoTrack)==null?void 0:H.videoElement;we&&we.parentElement&&(we.parentElement.style.display="none"),await this._stream.play(f.container),this.mirrorVideo(this.mirrored)}(Q=f.custom)!=null&&Q.onDraw&&(this.onDraw=f.custom.onDraw)}async stop(){var G;this.onDraw=null;let f=(G=this._cameraVideoTrack)==null?void 0:G.videoElement;f&&f.parentElement&&(f.parentElement.style.display="block"),await this._stream.stop(),this.lastPlayContainer=null}setDevice(f){return Promise.resolve()}};var ug=lr(Er());function Sd(ne){return ne*1.5>100?100:ne*1.5}var kd=class extends Vo{constructor({microphoneId:f}){super({mediaType:"audio"});Ve(this,"_captureVolume",100);Ve(this,"_div",document.createElement("div"));Ve(this,"_isPlayCalled",!1);Ft.info("new LingoMicrophoneAudioTrack"),this._stream=ug.default.createStream({audio:!0,video:!1,microphoneId:f})}async play(){return this._isPlayCalled=!0,await this._stream.play(this._div,{muted:!1})}stop(){return this._isPlayCalled=!1,super.stop()}setPublishedStream(f){var G;f===null?(G=this._publishedStream)==null||G.setAudioCaptureVolume(100):f.setAudioCaptureVolume(this._captureVolume),super.setPublishedStream(f)}async setDevice(f){if(Ft.warn(`switch mic ${f}`),f==="default"&&this._stream.isAudioRecovering_)return;if(await this._stream.switchDevice(this.trackMediaType,f),this._publishedStream&&this._publishedStream!==this._stream){let $=this.getMediaStreamTrack();$&&await this._publishedStream.replaceTrack($)}let G=(await ug.default.getMicrophones()).find($=>$.deviceId===f);G&&this.emit("device-switched",G)}setVolume(f){var G;(G=this._publishedStream)==null||G.setAudioCaptureVolume(f),this._captureVolume=f}getVolume(){return this._isPlayCalled||(this._isPlayCalled=!0,this._stream.play(this._div)),Sd(this._stream.getAudioLevel()*100)}setSpeakerDevice(f){return this._stream.setAudioOutput(f)}close(){var f;(f=this.getMediaStreamTrack())==null||f.stop(),this._stream.hasAudio()||this._stream.close()}};var Bo=class extends Uo{constructor({uid:f,mediaType:G,stream:$}){super({mediaType:G});Ve(this,"uid");Ve(this,"isSubscribed",!1);this.uid=f,this._stream=$,this._stream.on("player-state-changed",({state:H})=>{this._playerState=H})}subscribe(){this.isSubscribed=!0}unsubscribe(){this.isSubscribed=!1}};var Td=class extends Bo{constructor({uid:J,stream:f}){super({uid:J,mediaType:"audio",stream:f})}setVolume(J){this._stream.setAudioVolume(J/100)}getVolume(){return Sd(this._stream.getAudioLevel()*100)}setSpeakerDevice(J){return this._stream.setAudioOutput(J)}async play(){return this._stream.isPlaying()?Promise.resolve():this._stream.play(document.createElement("div"))}};var Id=class extends Bo{constructor({uid:f,stream:G}){super({uid:f,mediaType:"video",stream:G});Ve(this,"mirrored",!1);Ve(this,"lastPlayContainer")}async play(f){await this._stream.play(f.container),this.lastPlayContainer=f.container}async stop(){await super.stop(),this.lastPlayContainer=null}mirrorVideo(f){this.lastPlayContainer&&(this._stream.play(this.lastPlayContainer,{mirror:f}),this.mirrored=f)}};import{LingoBaseRTC as P7,LingoRTCError as fg}from"@lingoace/lingo-base-rtc";var lg=lr(Er());import{LingoBaseRTCClient as A7,LingoRTCError as Fo,config as Rc}from"@lingoace/lingo-base-rtc";var xd=new WeakMap;function wd(){return function(ne,J,f){let G=f.value,$=({fn:H,args:Q,context:we,resolve:xe,reject:Ye})=>{H.apply(we,Q).then(xe,Ye).finally(()=>{let Et=xd.get(we);Et.shift(),Et[0]&&$(Kr({},Et[0]))})};return f.value=function(...H){return new Promise((Q,we)=>{if(xd.has(this)){let xe=xd.get(this),{length:Ye}=xe;xe.push({fn:G,args:H,context:this,resolve:Q,reject:we}),Ye===0&&$({fn:G,args:H,context:this,resolve:Q,reject:we})}else xd.set(this,[{fn:G,args:H,context:this,resolve:Q,reject:we}]),$({fn:G,args:H,context:this,resolve:Q,reject:we})})},f}}import{LingoRTCError as vw}from"@lingoace/lingo-base-rtc";function Cn(ne){return function(J,f,G){let $=G.value;return G.value=async function(...H){try{return await $.apply(this,H)}catch(Q){throw ne?ne(Q):Q instanceof vw?Q:vw.createOtherError(Q.message)}},G}}var En=class extends A7{constructor(){super(...arguments);Ve(this,"_client",null);Ve(this,"_localStream",null);Ve(this,"_screenStream",null);Ve(this,"_remoteAuxiliaryStream",null);Ve(this,"_remoteMainStreamMap",new Map);Ve(this,"_remoteUserIdSet",new Set);Ve(this,"_quality",{res:"0x0",vfps:0,vra:0,ara:0,rtt:0,pktLostRate:0,upQuality:0,downQuality:0});Ve(this,"_prevLocalVideoStat",null);Ve(this,"_prevLocalAudioStat",null)}getRemoteUsers(){let f=new Map;return this._remoteUserIdSet.forEach(G=>{f.set(G,{uid:G,hasAudio:!1,hasVideo:!1})}),this.remoteAudioTrackMap.forEach(G=>{if(f.has(G.uid)){let $=f.get(G.uid);$.hasAudio=!0,$.audioTrack=G.isSubscribed?G:void 0}else f.set(G.uid,{uid:G.uid,hasAudio:!0,hasVideo:!1,audioTrack:G.isSubscribed?G:void 0,videoTrack:void 0})}),this.remoteVideoTrackMap.forEach(G=>{let{uid:$}=G;if(f.has(G.uid)){let H=f.get(G.uid);H.hasVideo=!0,H.videoTrack=G.isSubscribed?G:void 0}else f.set($,{uid:$,hasAudio:!1,hasVideo:!0,audioTrack:void 0,videoTrack:G.isSubscribed?G:void 0})}),[...f.values()]}async join(f){return this._client=lg.default.createClient({sdkAppId:Number(f.appId),userId:f.uid,userSig:f.token,mode:"rtc",useStringRoomId:!0,autoSubscribe:!1,enableAutoPlayDialog:!1}),this.handleEvents(),await this._client.join({roomId:f.roomId}),this.joinParam=f,this.uid=f.uid,f.uid}async leave(){!this._client||(await this._client.leave(),this.joinParam=void 0,this._client=null)}start(){return Promise.resolve()}async publish(f){return this._localStream?(f instanceof ya&&await this._localStream.setVideoProfile(f.getVideoProfile()),await this._localStream.addTrack(f.getMediaStreamTrack())):(await this._client.publish(f._stream),this._localStream=f._stream),f.setPublishedStream(this._localStream),this.localTracks.push(f),!0}async unpublish(f){var $;let G=f.getMediaStreamTrack();return!G||!this._localStream||this.localTracks.length===0||(this.localTracks.length===1?(await(($=this._client)==null?void 0:$.unpublish(this._localStream)),f.setPublishedStream(null),this._localStream=null,this.localTracks=[]):this.localTracks.find(H=>H===f)&&(await this._localStream.removeTrack(G),f.setPublishedStream(null),this.localTracks=this.localTracks.filter(H=>H!==f))),!0}async subscribe(f,G){var $,H;if(!this._client)throw Fo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u8BA2\u9605");if(G==="audio"&&!this.remoteAudioTrackMap.has(f))throw Fo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${f} \u672A\u63A8\u97F3\u9891\uFF0C\u65E0\u6CD5\u8BA2\u9605`);if(G==="video"&&f!==Rc.screenSharingUid&&!this.remoteVideoTrackMap.has(f))throw Fo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${f} \u672A\u63A8\u89C6\u9891\uFF0C\u65E0\u6CD5\u8BA2\u9605`);if(Ft.info(`subscribe ${f} ${G}`),f===Rc.screenSharingUid&&this._remoteAuxiliaryStream&&this._client)return await this._client.subscribe(this._remoteAuxiliaryStream),!0;if(G==="audio"){let Q=this.remoteAudioTrackMap.get(f);Q.subscribe();try{await this._client.subscribe(Q._stream,{audio:!0,video:!!(($=this.remoteVideoTrackMap.get(f))!=null&&$.isSubscribed)})}catch(we){throw Q.unsubscribe(),we}}else{let Q=this.remoteVideoTrackMap.get(f);Q.subscribe();try{await this._client.subscribe(Q._stream,{video:!0,audio:!!((H=this.remoteAudioTrackMap.get(f))!=null&&H.isSubscribed)})}catch(we){throw Q.unsubscribe(),we}}return!0}async unsubscribe(f,G){var H,Q;if(!this._client)throw Fo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u8BA2\u9605");Ft.info(`unsubscribe ${f} ${G}`);let $=null;if(G==="audio"&&this.remoteAudioTrackMap.has(f)?$=this.remoteAudioTrackMap.get(f):G==="video"&&this.remoteVideoTrackMap.has(f)&&($=this.remoteVideoTrackMap.get(f)),!$)throw Fo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${f} \u672A\u63A8 ${G}\uFF0C\u65E0\u6CD5\u8BA2\u9605`);return f===Rc.screenSharingUid&&this._remoteAuxiliaryStream?(await this._client.unsubscribe(this._remoteAuxiliaryStream),!0):(G==="audio"?(H=this.remoteVideoTrackMap.get(f))!=null&&H.isSubscribed?await this._client.subscribe($._stream,{video:!0,audio:!1}):await this._client.unsubscribe($._stream):(Q=this.remoteAudioTrackMap.get(f))!=null&&Q.isSubscribed?await this._client.subscribe($._stream,{video:!1,audio:!0}):await this._client.unsubscribe($._stream),$.unsubscribe(),!0)}getQOEStats(){return this._quality}async startScreenShare(f){if(!this.joinParam||!this._client)throw Fo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u5F00\u542F\u5C4F\u5E55\u5206\u4EAB");this._screenStream=lg.default.createStream({screen:!0,screenAudio:!0});let G={width:1280,height:720,frameRate:15,bitrate:2e3};this._screenStream.setScreenProfile(Kr(Kr({},G),f)),this._screenStream.on("screen-sharing-stopped",async()=>{await this.stopScreenShare(),this.emit("ScreenSharingEnded")}),await this._screenStream.initialize(),await this._client.publish(this._screenStream,{isAuxiliary:!0})}async stopScreenShare(){!this._client||!this._screenStream||(await this._client.unpublish(this._screenStream),this._screenStream.stop(),this._screenStream.close(),this._screenStream=null)}async playScreenShareView(f){var G;this._remoteAuxiliaryStream&&this._client?(await this._client.subscribe(this._remoteAuxiliaryStream),await this._remoteAuxiliaryStream.play(f)):await((G=this._screenStream)==null?void 0:G.play(f))}async stopScreenShareView(){var f;this._remoteAuxiliaryStream&&this._client?(await this._client.unsubscribe(this._remoteAuxiliaryStream),await this._remoteAuxiliaryStream.stop()):await((f=this._screenStream)==null?void 0:f.stop())}handleEvents(){!this._client||(this._client.on("connection-state-changed",({prevState:f,state:G})=>{this.connectionState=G,this.emit("ConnectionStateChange",G,f,"")}),this._client.on("peer-join",f=>{this._remoteUserIdSet.add(f.userId),this.emit("UserJoined",f.userId)}),this._client.on("peer-leave",f=>{this._remoteUserIdSet.delete(f.userId),this.emit("UserLeft",f.userId)}),this._client.on("stream-added",f=>{let G=f.stream,$=G.getUserId();if(G.getType()==="auxiliary"){this._remoteAuxiliaryStream=G,this.emit("RemoteScreenSharing",Rc.screenSharingUid,!0,"video");return}this._remoteMainStreamMap.set($,G),G.on("error",H=>{if(H.getCode()===16451){let Q=()=>{G.resume().then(()=>{document.body.removeEventListener("click",Q),document.body.removeEventListener("touchstart",Q)})};document.body.addEventListener("click",Q,!0),document.body.addEventListener("touchstart",Q,!0),this.emit("AutoplayFailed")}}),G.hasAudio()&&this.handleUserPublished($,"audio"),G.hasVideo()&&this.handleUserPublished($,"video")}),this._client.on("stream-updated",f=>{let G=f.stream,$=G.getUserId();!this.remoteAudioTrackMap.has($)&&G.hasAudio()&&this.handleUserPublished($,"audio"),this.remoteAudioTrackMap.has($)&&!G.hasAudio()&&this.handleUserUnpublished($,"audio"),!this.remoteVideoTrackMap.has($)&&G.hasVideo()&&this.handleUserPublished($,"video"),this.remoteVideoTrackMap.has($)&&!G.hasVideo()&&this.handleUserUnpublished($,"video")}),this._client.on("stream-removed",f=>{let G=f.stream.getUserId();if(f.stream.getType()==="auxiliary"){this._remoteAuxiliaryStream=null,this.emit("RemoteScreenSharing",Rc.screenSharingUid,!1,"video");return}this._remoteMainStreamMap.delete(G),this.handleUserUnpublished(G,"audio"),this.handleUserUnpublished(G,"video")}),this._client.on("network-quality",f=>{var G,$;this._quality.upQuality=f.uplinkNetworkQuality,this._quality.downQuality=f.downlinkNetworkQuality,this._quality.rtt=f.uplinkRTT,this._quality.pktLostRate=f.uplinkLoss,(G=this._client)==null||G.getLocalVideoStats().then(H=>{let Q=H[this.uid];Q&&(this._quality.res=`${Q.frameWidth}x${Q.frameHeight}`,this._prevLocalVideoStat&&(this._quality.vfps=Math.floor((Q.framesSent-this._prevLocalVideoStat.framesSent)/2)||0,this._quality.vra=Math.floor((Q.bytesSent-this._prevLocalVideoStat.bytesSent)*8/2)||0),this._prevLocalVideoStat=Q)}),($=this._client)==null||$.getLocalAudioStats().then(H=>{let Q=H[this.uid];Q&&(this._prevLocalAudioStat&&(this._quality.ara=Math.floor((Q.bytesSent-this._prevLocalAudioStat.bytesSent)*8/2)||0),this._prevLocalAudioStat=Q)}),this.emit("NetworkQuality",f)}),this._client.on("mute-audio",f=>{this.handleUserUnpublished(f.userId,"audio")}),this._client.on("unmute-audio",f=>{this.handleUserPublished(f.userId,"audio",!0)}))}handleUserUnpublished(f,G){Ft.info(`UserUnpublished ${f} ${G}`),G==="audio"?this.remoteAudioTrackMap.has(f)&&(this.remoteAudioTrackMap.delete(f),this.emit("UserUnpublished",f,G)):this.remoteVideoTrackMap.has(f)&&(this.remoteVideoTrackMap.delete(f),this.emit("UserUnpublished",f,G))}handleUserPublished(f,G,$=!1){var we;Ft.info(`UserPublished ${f} ${G} firedByUnmute: ${$}`);let H=this._remoteMainStreamMap.get(f),Q=(we=this._client)==null?void 0:we.getRemoteMutedState().find(xe=>xe.userId===f);if(H){if(G==="audio"&&!this.remoteAudioTrackMap.has(f)&&H.hasAudio()){if(!$&&Q&&Q.audioMuted)return;let xe=new Td({uid:f,stream:H});this.remoteAudioTrackMap.set(f,xe)}else if(G==="video"&&!this.remoteVideoTrackMap.has(f)&&H.hasVideo()){let xe=new Id({uid:f,stream:H});this.remoteVideoTrackMap.set(f,xe)}this.emit("UserPublished",f,G)}}};wn([Cn(),wd()],En.prototype,"publish",1),wn([Cn()],En.prototype,"unpublish",1),wn([Cn()],En.prototype,"subscribe",1),wn([Cn()],En.prototype,"unsubscribe",1),wn([Cn()],En.prototype,"startScreenShare",1),wn([Cn()],En.prototype,"stopScreenShare",1),wn([Cn()],En.prototype,"playScreenShareView",1),wn([Cn()],En.prototype,"stopScreenShareView",1);var Go=lr(Er());var gw=lr(ig()),dg=lr(Er());var hg=class extends gw.default{constructor(){super();Ve(this,"prevDevices_",[]);navigator.mediaDevices&&(this.onDeviceChange=this.onDeviceChange.bind(this),navigator.mediaDevices.addEventListener("devicechange",this.onDeviceChange))}async init(){this.prevDevices_=await dg.default.getDevices()}async onDeviceChange(){let f=await dg.default.getDevices(),G=f.filter(H=>this.prevDevices_.findIndex(({deviceId:Q})=>H.deviceId===Q)<0),$=this.prevDevices_.filter(H=>f.findIndex(({deviceId:Q})=>H.deviceId===Q)<0);G.length>0&&G.forEach(H=>{this.emit("device-added",H)}),$.length>0&&$.forEach(H=>{this.emit("device-removed",H)}),this.prevDevices_=f}destroy(){navigator.mediaDevices.removeEventListener("devicechange",this.onDeviceChange)}},_w=hg;var Ft=Go.default.Logger.loggerManager,Ho=class extends P7{constructor(){super(...arguments);Ve(this,"version",ew);Ve(this,"_deviceDetector",new _w);Ve(this,"_virtualOverloadCount",0);Ve(this,"_isVirtualOverloadStart",0)}init(f){return Ft.info(`lingo-trtc version: ${this.version}`),Promise.resolve()}release(){this._deviceDetector.destroy(),super.release()}async checkSystemRequirements(){let{result:f}=await Go.default.checkSystemRequirements();return f&&Go.default.isScreenShareSupported()}async createClient(){return this.client=new En,await this._deviceDetector.init(),this._deviceDetector.on("device-added",f=>{f.kind==="videoinput"?this.client.emit("CameraChanged",!0,f):f.kind==="audioinput"?this.client.emit("MicrophoneChanged",!0,f):f.kind==="audiooutput"&&this.client.emit("SpeakerDeviceChanged",!0,f)}),this._deviceDetector.on("device-removed",async f=>{var G,$;if(f.kind==="videoinput"){let H=this.cameraVideoTrack||this.previewVideoTrack;if(f.deviceId===(H==null?void 0:H.getDeviceId())){if((await Go.default.getCameras()).length===0){this.client.emit("CameraChanged",!1,f);return}H.once("device-switched",()=>{this.client.emit("CameraChanged",!1,f)}),H.once("track-ended",()=>{this.client.emit("CameraChanged",!1,f)})}else this.client.emit("CameraChanged",!1,f)}else if(f.kind==="audioinput")if(f.deviceId===((G=this.microphoneAudioTrack)==null?void 0:G.getDeviceId())){if((await Go.default.getMicrophones()).length===0){this.client.emit("CameraChanged",!1,f);return}this.microphoneAudioTrack.once("device-switched",()=>{this.client.emit("CameraChanged",!1,f)}),($=this.microphoneAudioTrack)==null||$.once("track-ended",()=>{this.client.emit("CameraChanged",!1,f)})}else this.client.emit("MicrophoneChanged",!1,f);else f.kind==="audiooutput"&&this.client.emit("SpeakerDeviceChanged",!1,f)}),this.client}async createCustomVideoTrack(f){if(this.customVideoTrack&&!this.customVideoTrack.closed)return this.customVideoTrack;Ft.info("createCustomVideoTrack");let G=new bd(f);return await G.init(),this.customVideoTrack=G,G}async detectCamera(f){var G,$;if(this.previewVideoTrack&&!this.previewVideoTrack.closed)return{checkIsActive:()=>{var H,Q;return Promise.resolve(((Q=(H=this.previewVideoTrack)==null?void 0:H.getMediaStreamTrack())==null?void 0:Q.readyState)==="live")},cleanup:()=>{var H,Q;(H=this.previewVideoTrack)==null||H.stop(),(Q=this.previewVideoTrack)==null||Q.close(),this.previewVideoTrack=void 0}};Ft.info("detectCamera");try{let H=new ya({cameraId:f.cameraId,id:"pv"});return H.on("device-switched",Q=>this.client.emit("DeviceSwitched",Q)),this.previewVideoTrack=H,await H.init(),f.mirror&&H.mirrorVideo(f.mirror),f.container&&await H.play({container:f.container}),{checkIsActive:()=>{var Q;return Promise.resolve(((Q=H.getMediaStreamTrack())==null?void 0:Q.readyState)==="live")},cleanup:()=>{H.stop(),H.close(),this.previewVideoTrack=void 0}}}catch(H){throw(G=this.previewVideoTrack)==null||G.stop(),($=this.previewVideoTrack)==null||$.close(),this.previewVideoTrack=void 0,H}}processExternalMediaAEC(f){}async createMicrophoneAudioTrack(f){if(this.microphoneAudioTrack&&!this.microphoneAudioTrack.closed)return this.microphoneAudioTrack;Ft.info("createMicrophoneAudioTrack");let G=new kd({microphoneId:f});return G.on("device-switched",$=>this.client.emit("DeviceSwitched",$)),await G.init(),this.microphoneAudioTrack=G,this.client.emit("LocalTrackCreated",G),G}async createCameraVideoTrack(f){if(this.cameraVideoTrack&&!this.cameraVideoTrack.closed)return this.cameraVideoTrack;Ft.info(`createCameraVideoTrack ${JSON.stringify(f)}`);let G=new ya(pd(Kr({},f),{id:"ct"}));return G.on("device-switched",$=>this.client.emit("DeviceSwitched",$)),await G.init(),this.cameraVideoTrack=G,this.client.emit("LocalTrackCreated",G),this.cameraVideoTrack.on("VirtualBackgroundOverload",()=>{this._virtualOverloadCount++,Ft.warn(`VirtualBackground overload count is: ${this._virtualOverloadCount}`),new Date().getTime()-this._isVirtualOverloadStart>5e3&&(this._virtualOverloadCount>10&&(Ft.warn("VirtualBackgroundOverload"),this.client.emit("VirtualBackgroundOverload")),this._virtualOverloadCount=0,this._isVirtualOverloadStart=new Date().getTime())}),G}async getDevicesCore(f,G){let $=await super.getDevicesCore(f,G),H=[],Q=[];return $.forEach(we=>{we.label&&we.label.toLowerCase().includes("virtual")?H.push(we):Q.push(we)}),Q.concat(H)}};wn([wd(),Cn(ne=>fg.createRTCError(ne))],Ho.prototype,"detectCamera",1),wn([Cn(ne=>fg.createRTCError(ne))],Ho.prototype,"createMicrophoneAudioTrack",1),wn([Cn(ne=>fg.createRTCError(ne))],Ho.prototype,"createCameraVideoTrack",1);if(document){let ne={MAIN:"schedule.rtc.qq.com",BACKUP:"schedule.rtc.qcloud.com",MAIN_OVERSEA:"schedule.rtc.tencentcloud.com",BACKUP_OVERSEA:"schedule-ecdn.rtc.tencentcloud.com"};document.head.innerHTML+=Object.values(ne).map(J=>`<link rel="dns-prefetch" href="https://${J}">`).join(`\r
551
549
  `)}var eH=Ho;export{eH as default,Ft as loggerManager};
552
550
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */