aliyun-rtc-sdk 7.0.1 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@
3
3
  `+g)}},Qi.exports}(),i=s.win,r=i.document,n=/^(error|api|speed|sum|avg|percent|custom|msg|setPage|setConfig|behavior|performance)$/,c=function(o){var d=this;return a.call(d,o),d._initialPage=o.page&&s.safetyCall(o.page,[],o.page+"")||null,d._isRobot=s.isRobot(),d._health={errcount:0,apisucc:0,apifail:0},d.beforeSend=function(h,l){h==="error"?d._health.errcount++:h==="api"&&d._health[l.success?"apisucc":"apifail"]++},o.enableInstanceAutoSend!==!1&&(d.initHandler(),d.initHook(),d.initFmpObserver(1e4),d._conf&&d._conf.behavior&&typeof d.initBehavior=="function"&&d.initBehavior(),d._conf&&d._conf.enableResource&&typeof d.initResource=="function"&&d.initResource()),Object.defineProperty&&i.addEventListener&&Object.defineProperty(d,"pipe",{set:d.sendPipe}),d};return c.prototype=s.createObject(a.prototype),s.ext(a._root.dftCon,{uid:null,setUsername:null,ignoreUrlPath:null,ignoreApiPath:null,urlHelper:[{rule:/\/([a-z\-_]+)?\d{2,20}/g,target:"/$1**"},/\/$/],resourceHelper:[],apiHelper:{rule:/\/([a-z\-_]+)?\d{2,20}/g,target:"/$1**"},ignoreUrlCase:!0,imgUrl:"https://arms-retcode.aliyuncs.com/r.png?",cdnHostList:[],resourceTypes:["css","script","img","font"],resourceSlow:2e3,disableHook:!1,autoSendPv:!0,autoSendPerf:!0,enableSPA:!1,enableLinkTrace:!1,linkType:"arms",enableApiCors:!1,sendResource:!0,behavior:!0,enableConsole:!1,parseHash:function(o){return(o?s.cutUrlSearch(o.replace(/^#\/?/,"")):"")||"[index]"},parseResponse:function(o){if(!o||typeof o!="object")return{};var d=o.code,h=o.msg||o.message||o.subMsg||o.errorMsg||o.ret||o.errorResponse||"";return typeof h=="object"&&(d=d||h.code,h=h.msg||h.message||h.info||h.ret||JSON.stringify(h)),{msg:h,code:d,success:!0}}}),s.ext(c.prototype,{constructor:c,_super:a,onReady:function(o){var d=this;if(d.hasReady)return o();r.readyState==="complete"?(d.hasReady=!0,o()):s.on(i,"load",function(){d.hasReady=!0,o()},!0)},getPage:function(o){var d=this._conf,h=d.page,l=location,p=l.host+l.pathname;return h&&!o?s.safetyCall(h,[],h+""):this._initialPage||s.filterByRule(d.ignoreUrlCase?p.toLowerCase():p,l.href,d.ignoreUrlPath?d.ignoreUrlPath:d.urlHelper)},setPage:function(o,d){var h=this,l=h.prevPage;if(d!==!1){if(!o||o===l)return h;h.prevPage=o,clearTimeout(h.sendPVTimmer),h.handleUnload(1),h.resetPageview(),h.sendPVTimmer=setTimeout(function(){h.sendPV()},10)}else h.prevPage=o;return h._conf.page=o,h},setConfig:function(o,d){if(o&&typeof o=="object"){s.verifyConfig(o),o=this.setImgUrl(o);var h=this._conf;if(this._conf=s.ext({},h,o),!d){var l="disableHook";l in o&&h[l]!==o[l]&&(o[l]?this.removeHook():this.addHook()),(l="enableSPA")in o&&h[l]!==o[l]&&this.bindHashChange(o[l])}}},sendRequest:function(o){e(o,this.getConfig("imgUrl"))},postData:function(o,d){var h={};h[d]=o[d],delete o[d];var l="";typeof o=="object"&&(l=s.serialize(o)),t(h,this.getConfig("imgUrl")+l+"&post_res=")},sendPipe:function(o){var d=this;if(!o||!o.length)return d;try{if(s.T(o[0])==="Array")return s.each(o,function(l){return d.sendPipe(l)});if(s.T(o)!=="Array")return d;var h=o.shift();if(!n.test(h))return d;d[h].apply(d,o)}catch(l){return s.warn("[retcode] error in sendPipe",l),d}},sendHealth:function(){var o=s.ext({},this._health);o.healthy=o.errcount>0?0:1,o.begin=Date.now();var d=o.begin-this.sBegin;o.stay=d,this._lg("health",o,1),this._health={errcount:0,apisucc:0,apifail:0}},createInstance:function(o){o=s.ext({pid:this._conf.pid},o);var d=this.__proto__.constructor(o);return o.page&&d.sendPV(),d}}),Pn()(c,i),Dn()(c,i,r),Mn()(c,i,r),(cs||(cs=1,os=function(o,d){var h=He(),l=null,p=h.getCurDomain(),u=function(v,_,w,y,R,A,E,I,k,P,B,G,Y){var J=h.J(R)||null,z=h.safetyCall(_,[J,y],null);if(!z)return!1;var Q=z.code||A,ee=!("success"in z)||z.success;v.api(w,ee,E,Q,z.msg,I,k,P,ee?{}:B,p,G,Y)},g="fetch",m="__oFetch_",b="__oXMLHttpRequest_",S="XMLHttpRequest";return h.ext(o.prototype,{removeHook:function(v,_){return l&&(_||this===l)?(d[m]&&(d[g]=d[m],delete d[m]),d[b]&&(d[S]=d[b],delete d[b]),l=null,this):this},addHook:function(v){return!v&&l||(l||(function(){if(typeof d[g]=="function"){var _=d[g];d[m]=_,d[g]=function(w,y){var R=arguments.length===1?[arguments[0]]:Array.apply(null,arguments),A=l;if(!A||!A.api||y&&(y.method==="HEAD"||y.mode==="no-cors"))return _.apply(d,R);y||(y={});var E=Date.now(),I=A._conf,k=h.duration(),P=(w&&typeof w!="string"?w.url:w)||"",B=P;P=h.cutUrlSearch(P);var G=(I.ignore||{}).ignoreApis,Y=I.parseTraceId;if(!h.checkAPI(P,!0)||h.ignoreByRule(P,G))return _.apply(d,R);P=h.filterByRule(P,B,I.ignoreApiPath?I.ignoreApiPath:I.apiHelper);var J=I.enableLinkTrace,z="",Q="",ee=A.getConfig("pid"),pe=null,D=A.getConfig("sample"),L=A.getConfig("linkType"),N=1;if(D&&!A.sampling(D)&&(N=0),J){var x="";try{x=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(de){x=""}var ce=h.checkSameOrigin(B,x);if(A.getConfig("enableApiCors")||ce)if(w&&typeof w!="string")try{if(R[0].headers&&typeof R[0].headers.get=="function"&&typeof R[0].headers.append=="function")switch(L){case"arms":var ke=R[0].headers.get("EagleEye-TraceID"),$=R[0].headers.get("EagleEye-SessionID"),ge=R[0].headers.get("EagleEye-pAppName");ke?z=ke:(z=A.getTraceId()["EagleEye-TraceID"],R[0].headers.append("EagleEye-TraceID",z)),$?Q=$:(Q=A.getPageviewId()["EagleEye-SessionID"],R[0].headers.append("EagleEye-SessionID",Q)),ge||R[0].headers.append("EagleEye-pAppName",ee);break;case"b3":var De=R[0].headers.get("X-B3-TraceId");if(De)z=De;else{var Ae=A.getB3TraceId(N);R[0].headers.append("X-B3-TraceId",Ae["X-B3-TraceId"]),R[0].headers.append("X-B3-ParentSpanId",Ae["X-B3-ParentSpanId"]),R[0].headers.append("X-B3-SpanId",Ae["X-B3-SpanId"]),R[0].headers.append("X-B3-Sampled",Ae["X-B3-Sampled"]),R[0].headers.append("X-Request-ID",h.guid()),z=Ae["X-B3-TraceId"]}Q=A.pageview;break;default:var Te=R[0].headers.get("uber-trace-id");Te?z=Te.split(":")[0]:(Te=A.getUberTraceId(N),R[0].headers.append("uber-trace-id",Te["uber-trace-id"]),z=Te.traceId),Q=A.pageview}}catch(de){h.warn(`[retcode] fetch failed to set header, exception is :
4
4
  `+de)}else switch(y.headers=y.headers?y.headers:{},L){case"arms":y.headers["EagleEye-TraceID"]?z=y.headers["EagleEye-TraceID"]:(z=A.getTraceId()["EagleEye-TraceID"],y.headers["EagleEye-TraceID"]=z),y.headers["EagleEye-SessionID"]?Q=y.headers["EagleEye-SessionID"]:(Q=A.getPageviewId()["EagleEye-SessionID"],y.headers["EagleEye-SessionID"]=Q),y.headers["EagleEye-pAppName"]||(y.headers["EagleEye-pAppName"]=ee);break;case"b3":if(y.headers["X-B3-TraceId"])z=y.headers["X-B3-TraceId"];else{var fe=A.getB3TraceId(N);y.headers["X-B3-TraceId"]=fe["X-B3-TraceId"],y.headers["X-B3-ParentSpanId"]=fe["X-B3-ParentSpanId"],y.headers["X-B3-SpanId"]=fe["X-B3-SpanId"],y.headers["X-B3-Sampled"]=fe["X-B3-Sampled"],y.headers["X-Request-ID"]=h.guid(),z=fe["X-B3-TraceId"]}Q=A.getPageviewId()["EagleEye-SessionID"];break;default:if(y.headers["uber-trace-id"])z=y.headers["uber-trace-id"].split(":")[0];else{var _e=A.getUberTraceId(N);y.headers["uber-trace-id"]=_e["uber-trace-id"],z=_e.traceId}Q=A.getPageviewId()["EagleEye-SessionID"]}}return _.apply(d,R).then(function(de){if(!A||!A.api)return de;try{if(!de||typeof de.clone!="function")return de;var Pe=de.clone(),ye=Pe.headers;if(ye&&typeof ye.get=="function"){var Ge=ye.get("content-type");if(Ge&&!/(text)|(json)/.test(Ge))return de;if(!z){var st=h.parseFetchHeaders(ye);typeof st=="object"&&st["eagleeye-traceid"]&&(z=st["eagleeye-traceid"],pe="response")}}var ae=k();return Pe.text().then(function(re){if(!z&&h.isFunction(Y)){var te=Y(Pe,re);te&&h.isString(te)&&(z=te)}var be=h.getFetchSnapshot(R,re,ye);Pe.ok?u(A,I.parseResponse,P,B,re,Pe.status||200,ae,E,z,Q,be,pe,N):(A.api(P,!1,ae,Pe.status||404,Pe.statusText,E,z,Q,be,p,pe,N),I.enableResource&&l.fixResourceStatus&&l.fixResourceStatus({src:Pe.url,res_type:"api"}))}),de}catch(re){return h.warn("[ARMS] fetch response error :",re),de}}).catch(function(de){if(!A||!A.api)throw de;var Pe=k();throw A.api(P,!1,Pe,de.name||"Error",de.message,E,z,Q,{},p),I.enableResource&&l.fixResourceStatus&&l.fixResourceStatus({src:B,res_type:"api"}),de})},d[g].toString=h.createFakeToString(g)}}(),function(){if(typeof d[S]=="function"){var _,w=d[S];d[b]=w;var y=function(R){var A=new w(R),E=l;if(!E||!E.api||!A.addEventListener)return A;var I,k,P,B,G=A.send,Y=A.open,J=A.setRequestHeader,z=E._conf,Q=(z.ignore||{}).ignoreApis,ee=z.parseTraceId,pe=E.getConfig("enableLinkTrace"),D="",L="",N="",x=null,ce=E.getConfig("sample"),ke=E.getConfig("linkType"),$=1;return ce&&!E.sampling(ce)&&($=0),A.open=function(ge,De){_=ge;var Ae=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);Y.apply(A,Ae),B=De||"",P=h.cutUrlSearch(B);var Te=!h.checkAPI(P,!0)||h.ignoreByRule(P,Q);if(P=P?h.filterByRule(P,B,z.ignoreApiPath?z.ignoreApiPath:z.apiHelper):"",!Te&&pe){var fe="";try{fe=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(ye){fe=""}var _e=h.checkSameOrigin(B,fe);if((E.getConfig("enableApiCors")||_e)&&J&&typeof J=="function")switch(ke){case"arms":D=E.getTraceId()["EagleEye-TraceID"],J.apply(A,["EagleEye-TraceID",D]),L=E.getPageviewId()["EagleEye-SessionID"],J.apply(A,["EagleEye-SessionID",L]),N=E.getConfig("pid"),J.apply(A,["EagleEye-pAppName",N]);break;case"b3":var de=E.getB3TraceId($);J.apply(A,["X-B3-TraceId",de["X-B3-TraceId"]]),J.apply(A,["X-B3-ParentSpanId",de["X-B3-ParentSpanId"]]),J.apply(A,["X-B3-SpanId",de["X-B3-SpanId"]]),J.apply(A,["X-B3-Sampled",de["X-B3-Sampled"]]),J.apply(A,["X-Request-ID",h.guid()]),D=de["X-B3-TraceId"],L=E.getPageviewId()["EagleEye-SessionID"];break;default:var Pe=E.getUberTraceId($);J.apply(A,["uber-trace-id",Pe["uber-trace-id"]]),D=Pe.traceId,L=E.getPageviewId()["EagleEye-SessionID"]}}},A.send=function(){I=Date.now(),k=h.duration();var ge=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);G.apply(A,ge)},h.on(A,"readystatechange",function(){if(P&&A.readyState===4){var ge=k(),De=h.getXhrSnapshot(B,_,A);if(!D){var Ae=h.parseXhrHeaders(typeof A.getAllResponseHeaders=="function"&&A.getAllResponseHeaders()||"");typeof Ae=="object"&&Ae["eagleeye-traceid"]&&(D=Ae["eagleeye-traceid"],x="response")}if(!D&&h.isFunction(ee)){var Te=ee(A);Te&&h.isString(Te)&&(D=Te)}if(A.status>=200&&A.status<=299){var fe=A.status||200;if(typeof A.getResponseHeader=="function"){var _e=A.getResponseHeader("Content-Type");if(_e&&!/(text)|(json)/.test(_e))return}A.responseType&&A.responseType!=="text"?E.api(P,!0,ge,fe,"",I,D,L,{},p,x,$):u(E,z.parseResponse,P,B,A.responseText,fe,ge,I,D,L,De,x,$)}else E.api(P,!1,ge,A.status||"FAILED",A.statusText,I,D,L,De,p,x,$),z.enableResource&&l.fixResourceStatus&&l.fixResourceStatus({src:A.responseURL||B,res_type:"api"})}}),A};y.prototype=w.prototype,h.each(Object.keys(w),function(R){y[R]=w[R]}),d[S]=y,d[S].toString=h.createFakeToString(S)}}()),l=this),this},initHook:function(){return this.hasInitHook||(this.getConfig("disableHook")||this.addHook(),this.hasInitHook=!0),this}}),o}),os)(c,i),(hs||(hs=1,ds=function(o,d){var h=He(),l=d.history||{},p=d.document,u=function(m,b){var S;d.CustomEvent?S=new CustomEvent(m,{detail:b}):((S=p.createEvent("HTMLEvents")).initEvent(m,!1,!0),S.detail=b),d.dispatchEvent(S)},g=function(m){var b=l[m];typeof b=="function"&&(l[m]=function(S,v,_){var w=arguments.length===1?[arguments[0]]:Array.apply(null,arguments),y=location.href,R=b.apply(l,w);if(!_||typeof _!="string"||_===y)return R;try{var A=y.split("#"),E=_.split("#"),I=h.cutUrlSearch(A[0]),k=h.cutUrlSearch(E[0]),P=A[1]&&A[1].replace(/^\/?(.*)/,"$1"),B=E[1]&&E[1].replace(/^\/?(.*)/,"$1");P!==B?u("historystatechange",B):I!==k&&u("historystatechange",k)}catch(G){h.warn("[retcode] error in "+m+": "+G)}return R},l[m].toString=h.createFakeToString(m))};h.ext(o.prototype,{hackHistoryState:function(){return this.hasHackedHistoryState||(g("pushState"),g("replaceState"),this.hasHackedHistoryState=!0),this}})}),ds)(c,i),function(){if(ls)return rr;ls=1;var o=He(),d=sr().TIMING_KEYS;return rr=function(h,l){function p(m,b,S){if(m instanceof l.PerformanceResourceTiming&&m.initiatorType){var v=o.getResType(m.initiatorType,m.name),_=b.resourceTypes||[],w=(b.ignore||{}).ignoreResources;if(v&&_.includes(v)&&!o.ignoreByRule(m.name,w)&&!o.ignoreByRule(o.decode(m.name),w)){var y=m[d[0]],R=m[d[1]],A=m[d[2]],E=m[d[3]],I=m[d[4]],k=m[d[5]],P=m[d[6]],B=m[d[7]],G=m[d[8]],Y=m[d[18]],J=m[d[19]];if(!S.has(m)&&(!o.areInOrder(y,R,A,E,I,k,P,B,G)||y>B))return;if(Y<y&&(Y=y),J<y&&(J=R),o.areInOrder(y,Y,J,R))return{domain:o.getURL(m.name).domain,res_type:v,src_type:o.getSrcType(m.name,b.cdnHostList),success:1,size:Math.round(m.decodedBodySize),duration:Math.round(m.duration),timeStamp:m.responseEnd,timing:m}}}}var u="_resource-"+Date.now(),g="_resource_error-"+Date.now();o.ext(h.prototype,{initResource:function(){var m=this,b=l.performance,S=l.PerformanceObserver;if(m[g]||(m[g]=new WeakMap),!b||!S||typeof b!="object"||typeof b.getEntriesByType!="function")return null;var v=b.getEntriesByType("resource")||[];return setTimeout(function(){m.setResource(v)},10),new S(function(_){setTimeout(function(){m.setResource(_.getEntries())},10)}).observe({entryTypes:["resource"]}),this.onReady(function(){setTimeout(m.resourceComboReport.bind(m),5e3)}),m},setResource:function(m){var b=this._conf,S=this[g];if(o.isArray(m)&&m.length){this[u]||(this[u]={});for(var v=this[u],_=0,w=m.length;_<w;_+=1){var y=m[_];if(o.checkAPI(y.name,!1)){var R=p(y,b,S);if(R){var A=R.res_type+"-"+R.domain;A in v||(v[A]=[]),v[A].push(R)}}}return this}},fixResourceStatus:function(m){var b=l.performance;if(!b||typeof b.getEntriesByName!="function")return null;var S=this[g];if(!m.src||!o.checkAPI(m.src,!1))return this;var v=m.timeStamp||b.now(),_=b.getEntriesByName(m.src,"resource");return o.each(_,function(w){S.has(w)||v-w.responseEnd<100&&S.set(w,{success:0})}),this},resourceComboReport:function(){var m=this[u]||{},b=this._conf.resourceSlow||2e3,S=this[g];this[u]={};var v=Object.keys(m);if(v.length!==0){var _=[];o.each(v,function(A){var E=m[A],I={domain:"",res_type:"",src_type:"",size:0,duration:0,count:0,err_count:0,err_duration:0,slow_count:0,slow_duration:0,timings:[]};o.each(E,function(k){var P=k.timing||{},B=S.get(k.timing),G=B?B.success:1,Y=k.duration>b?1:0;I.domain=k.domain,I.res_type=k.res_type,I.src_type=k.src_type,I.count+=1,I.duration+=k.duration,I.size+=k.size,G||(I.err_count+=1,I.err_duration+=k.duration),Y&&(I.slow_count+=1,I.slow_duration+=k.duration);try{var J=JSON.parse(JSON.stringify(P));J.success=G,J.resourceSlow=b,J.isSlow=Y,I.timings.push(J)}catch(z){}}),I.count&&(I.size=Math.round(I.size/I.count),I.duration=Math.round(I.duration/I.count)),I.slow_count&&(I.slow_duration=Math.round(I.slow_duration/I.slow_count)),I.err_count&&(I.err_duration=Math.round(I.err_duration/I.err_count)),I.timings.length>20&&(I.timings.sort(function(k,P){return P.duration-k.duration}),I.timings.length=20),I.timings=encodeURIComponent(JSON.stringify(I.timings)),_.push(I)});var w={_combo:1,resource:JSON.stringify(_)},y=l.navigator.connection;w.ct=y?y.effectiveType||y.type:"";var R=y&&(y.downlink||y.downlinkMax||y.bandwidth)||null;(R=R>999?999:R)&&(w.bandwidth=R),this._lg("resource",w,this.getConfig("sample"))}}})},rr}()(c,i),c._super=a,c._root=a._root,a.Browser=c,mt.exports=c,mt.exports}var Ln={getArmsLogger:function(){return function(){if(ps)return jt.exports;function s(r,n){var c=a[t]=new e(r);c.sendPipe(n);var o=c._conf;return o.autoSendPv!==!1&&c.sendPV(),o&&o.useFmp||c.sendPerformance(),o&&o.sendResource&&c.sendResources(),a[i]=!0,c}ps=1;var a=window,e=a.BrowserLogger=Nn(),t=He().key,i="__hasInitBlSdk";return e.singleton=function(r,n){return a[i]?a[t]:s(r,n)},e.createExtraInstance=function(r){r&&typeof r=="object"&&r.enableInstanceAutoSend!==!0&&(r.enableInstanceAutoSend=!1);var n=new e(r),c=n._conf;return c.enableInstanceAutoSend&&(c.autoSendPv!==!1&&n.sendPV(),c&&c.useFmp||n.sendPerformance(),c&&c.sendResource&&n.sendResources()),n},typeof window=="object"&&window.navigator&&a[t]&&(e.bl=function(){if(a[i])return a[t];var r={},n=[];return t in a&&(r=a[t].config||{},n=a[t].pipe||[]),s(r,n)}()),jt.exports=e,jt.exports}()}};const gs="https://arms-retcode.aliyuncs.com/r.png?",fs="https://arms-retcode-sg.aliyuncs.com/r.png?",Ss="https://retcode-us-west-1.arms.aliyuncs.com/r.png?",bs="e1iftji1w7@7ec1cef2cc88733",vs="e1iftji1w7@10a06d1ec260adc",ys="e1iftji1w7@10a06d1ec260adc",ar={cn:{reportUrl:gs,pid:bs},"cn-hangzhou":{reportUrl:gs,pid:bs},sg:{reportUrl:fs,pid:vs},"ap-southeast-1":{reportUrl:fs,pid:vs},usw:{reportUrl:Ss,pid:ys},"us-west-1":{reportUrl:Ss,pid:ys}},xn=s=>!!Object.isExtensible(s)&&(a=>Object.prototype.toString.call(a).slice(8,-1))(s)==="Object";function Rs(s,a){if(typeof s!="string")return!1;const e=s.indexOf(a);if(e<0)return!1;const t=s.indexOf(`
5
5
  `);return t<0||e<t}function Et(s,a,e){return typeof s=="function"?function(t,i,r){const n={MediaboxWrapperFunctionApply(c,o,d){let h;try{h=Reflect.apply(c,o,d)}catch(l){throw r(l),l}return Et(h,i,r)},MediaboxWrapperFunctionGet(c,o){const d=Object.getOwnPropertyDescriptor(c,o);return!d||d.writable||d.configurable?Et(c[o],i,r):c[o]},MediaboxWrapperClassConstructor(c,o){let d;try{d=new c(...o)}catch(h){throw r(h),h}return Et(d,i,r)}};return new Proxy(t,{apply:n.MediaboxWrapperFunctionApply,get:n.MediaboxWrapperFunctionGet,construct:n.MediaboxWrapperClassConstructor})}(s,a+1,e):s instanceof Promise?s.then(t=>Et(t,a+1,e)).catch(t=>(e(t),Promise.reject(t))):Array.isArray(s)?(s.forEach((t,i)=>{s[i]=Et(t,a+1,e)}),s):(t=>t!==null&&typeof t=="object")(s)&&xn(s)?function(t,i,r){var d;if(Reflect.get(t,"__v_skip")===!0)return t;const n=[],c=typeof Object.getOwnPropertyDescriptors=="function"?Object.getOwnPropertyDescriptors((d=Object.getPrototypeOf(t))!=null?d:{}):{};for(const h of Object.keys(c))c[h].get&&n.push(h);const o={MediaboxWrapperObjectGetter(h,l){if(typeof l=="string"&&n.indexOf(l)>-1){let p;try{p=h[l]}catch(u){throw r(u),u}return Et(p,i,r)}return i>10?h[l]:Et(h[l],i,r)},MediaboxWrapperObjectSetter:(h,l,p)=>(h[l]=Et(p,i,r),!0)};return Object.defineProperty(t,"__v_skip",{configurable:!0,enumerable:!1,writable:!1,value:!0}),new Proxy(t,{get:o.MediaboxWrapperObjectGetter,set:o.MediaboxWrapperObjectSetter})}(s,a+1,e):s}function As(s){return typeof s=="string"&&(s.indexOf("g.alicdn.com/apsara-media-")>-1||s.indexOf("g.alicdn.com/thor-server")>-1||s.indexOf("MediaboxWrapper")>-1)}class _s extends Error{constructor(a){super(a),this.name="MQTError"}}let Vn=1;class nr{constructor(a){var e,t;wt(this,"armsLogger"),wt(this,"isReady",!1),wt(this,"isDestroyed",!1),wt(this,"options"),wt(this,"queue",[]),wt(this,"marker"),wt(this,"helper",{MediaboxWrapperQueue:i=>new _s(i),MediaboxWrapperInitiative:i=>new _s(i)}),this.options=kt(X({},a),{region:a.deferRegionSet?void 0:(e=a.region)!=null?e:"cn",env:(t=a.env)!=null?t:"prod"}),this.marker=`-${Vn++}-`,this.initArmsLogger()}static get version(){return"0.23.0"}initArmsLogger(a){const{region:e,env:t,disabled:i}=this.options;if(i||this.armsLogger)return;if(a&&!e)throw new Error("region is required");if(!e)return;if(!ar[e])throw new Error(`region ${e} is not supported`);const r=Ln.getArmsLogger();this.armsLogger=r.createExtraInstance({enableInstanceAutoSend:!0,pid:ar[e].pid,tag:this.options.businessName,release:`${this.options.businessName}_${this.options.version}`,imgUrl:ar[e].reportUrl,behavior:!0,sample:1,disableHook:!0,environment:t,beforeReport:n=>{var c;if(this.isDestroyed||Rs(n.stack,this.marker)||n.t!=="pv"&&n.t!=="error")return!1;if(n.c1=(c=this.options.cid)!=null?c:window.location.host,n.c2=nr.version,this.options.customData&&(n.c3=new URLSearchParams(this.options.customData).toString()),n.t==="error"){if(function(o){return typeof o=="string"&&(o.indexOf("g.alicdn.com/apsara-media-")>-1||o.indexOf("g.alicdn.com/thor-server")>-1)}(n.file)||As(n.stack)){let o=n;return this.options.beforeSend&&(o=this.options.beforeSend(n)),this.isReady?o:(o&&this.queue.push(o),!1)}return!1}return n}})}wrap(a){return this.options.disabled||typeof Proxy>"u"?a:Et(a,0,e=>{var t;e instanceof Error&&typeof e.stack=="string"&&As(e.stack)&&((t=this.armsLogger)==null||t.error(e),e.stack=function(i,r){if(typeof i!="string")return r;if(Rs(i,r))return i;const n=i.indexOf(`
6
- `);return n<0?`${i}${r}`:`${i.slice(0,n)}${r}${i.slice(n)}`}(e.stack,this.marker))})}updateOptions(a){this.options=X(X({},this.options),a)}setReady(){this.initArmsLogger(!0),this.isReady=!0,this.queue.length&&this.queue.forEach(a=>{var e;(e=this.armsLogger)==null||e.error(this.helper.MediaboxWrapperQueue(a.msg),{filename:a.file,lineno:a.line,colno:a.col})})}report(a,e){var t;(t=this.armsLogger)==null||t.error(this.helper.MediaboxWrapperInitiative(a),e)}destroy(){this.isDestroyed=!0}}for(var or,$e=[],cr=0;cr<256;++cr)$e.push((cr+256).toString(16).slice(1));var On=new Uint8Array(16);function Un(){if(!or&&!(or=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return or(On)}const ws={randomUUID:typeof crypto!="undefined"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function dt(s,a,e){if(ws.randomUUID&&!a&&!s)return ws.randomUUID();var t=(s=s||{}).random||(s.rng||Un)();if(t[6]=15&t[6]|64,t[8]=63&t[8]|128,a){e=e||0;for(var i=0;i<16;++i)a[e+i]=t[i];return a}return function(r,n=0){return($e[r[n+0]]+$e[r[n+1]]+$e[r[n+2]]+$e[r[n+3]]+"-"+$e[r[n+4]]+$e[r[n+5]]+"-"+$e[r[n+6]]+$e[r[n+7]]+"-"+$e[r[n+8]]+$e[r[n+9]]+"-"+$e[r[n+10]]+$e[r[n+11]]+$e[r[n+12]]+$e[r[n+13]]+$e[r[n+14]]+$e[r[n+15]]).toLowerCase()}(t)}var we=(s=>(s.PullStreamStats="remoteStat",s.RtsSubscribeExceeds="rtsSubscribeExceeds",s.UserJoined="userJoined",s.UserLeft="userLeft",s.Bye="bye",s.MuteAudio="muteAudio",s.UnmuteAudio="unmuteAudio",s.MuteVideo="muteVideo",s.UnmuteVideo="unmuteVideo",s.MuteScreen="muteScreen",s.UnmuteScreen="unmuteScreen",s.Error="error",s))(we||{}),Xe=(s=>(s.Local="local-device-status-change",s.Remote="remote-device-status-change",s))(Xe||{}),M=(s=>(s.Audio="sophon_audio",s.VideoLarge="sophon_video_camera_large",s.VideoSmall="sophon_video_camera_small",s.Screen="sophon_video_screen_share",s.Data="sophon_data",s))(M||{}),dr=(s=>(s.Audio="rts audio",s.VideoLarge="rts video",s))(dr||{}),Pt=(s=>(s.Add="add",s.Delete="delete",s.Replace="replace",s.Stop="stop",s.UnPublish="unpublish",s))(Pt||{}),ei=(s=>(s[s.Camera=0]="Camera",s[s.Screen=1]="Screen",s[s.Image=2]="Image",s))(ei||{}),Ei=(s=>(s[s.Microphone=0]="Microphone",s[s.Screen=1]="Screen",s[s.Mixed=2]="Mixed",s))(Ei||{}),Se=(s=>(s.InRoom="inRoom",s.Join="join",s.Publish="publish",s.User="user",s.Resume="resume",s.Retry="retry",s.Reconnect="reconnect",s))(Se||{}),bt=(s=>(s[s.MANUAL=0]="MANUAL",s[s.JOIN_CHANNEL=1]="JOIN_CHANNEL",s[s.ROLE_CHANGE=2]="ROLE_CHANGE",s[s.RECONNECT=3]="RECONNECT",s))(bt||{}),Ii=(s=>(s.prod="rs.rtn.aliyuncs.com",s.pre="prs.rtn.aliyuncs.com",s))(Ii||{});const Ti="7.0.1";class et{static getVersionNumber(){let a=Ti.split("."),e="";return a.forEach(t=>{t.length===1?e+="0"+t:e+=t}),parseInt(e)}static queryingParam(a){let e=[];if(a)for(let t in a)e.push(t+"="+a[t]);return e.join("&")}static getQueryParams(a){const e=window.location.search.substring(1).split("&");for(let t=0;t<e.length;t++){const i=e[t].split("=");if(decodeURIComponent(i[0])===a)return decodeURIComponent(i[1])}}static createCallid(a=""){const e=dt();return a&&e&&e.length>a.length?`${a}${e.substring(a.length)}`:e}static checkSubOptionsValid(a){if(a){const{audio:e,video:t,screen:i}=a;if(e===!1&&t===!1&&i===!1)return!1}return!0}static isNetworkAvailable(){return T(this,null,function*(){const a=Ii.prod,{onLine:e}=navigator;if(!e)return!1;try{return yield fetch(`https://${a}/roomserver/v1/ws/version`),!0}catch(t){return!1}})}static toString(a){let e;if(a instanceof Error)e=a.message;else if(typeof a=="string")e=a;else try{e=JSON.stringify(a)}catch(t){e="undefined"}return e}static paramArrayToString(a){let e="";for(let t=0;t<a.length;t++)e!==""&&(e+=" "),e+=et.toString(a[t]);return e}}function Es(s,a,e){Object.defineProperty(s,a,{writable:!0,enumerable:!0,configurable:!0,value:e})}function Is(s,a,e,t){t?t(()=>{Es(s,a,e)}):Es(s,a,e)}Array(32);class Bn{constructor(a){var e,t;this.timer=null,this.time=10,this.count=10,this.arr=[],this.time=(e=a.time)!=null?e:10,this.count=(t=a.count)!=null?t:10,a.host.startsWith("http://")||a.host.startsWith("https://")?this.url=a.host+"/logstores/"+a.logstore+"/track":this.url="https://"+a.project+"."+a.host+"/logstores/"+a.logstore+"/track",this.opt=a,a.installUnloadHook&&typeof a.installUnloadHook=="function"&&a.installUnloadHook(()=>{this.sendImmediateInner()})}assemblePayload(a){const e={__logs__:a};return this.opt.tags&&(e.__tags__=this.opt.tags),this.opt.topic&&(e.__topic__=this.opt.topic),this.opt.source&&(e.__source__=this.opt.source),JSON.stringify(e)}platformSend(){if(this.opt.sendPayload&&typeof this.opt.sendPayload=="function"){const a=this.assemblePayload(this.arr);this.opt.sendPayload(this.url,a)}}transString(a){let e={};for(let t in a)typeof a[t]=="object"?e[t]=JSON.stringify(a[t]):e[t]=String(a[t]);return e}sendImmediateInner(){this.arr&&this.arr.length>0&&(this.platformSend(),this.timer!=null&&(clearTimeout(this.timer),this.timer=null),this.arr=[])}sendInner(){if(this.timer)this.arr.length>=this.count&&(clearTimeout(this.timer),this.timer=null,this.sendImmediateInner());else{const a=this;this.arr.length>=this.count||this.time<=0?this.sendImmediateInner():this.timer=setTimeout(function(){a.sendImmediateInner()},1e3*this.time)}}send(a){const e=this.transString(a);this.arr.push(e),this.sendInner()}sendImmediate(a){const e=this.transString(a);this.arr.push(e),this.sendImmediateInner()}sendBatchLogs(a){const e=a.map(t=>this.transString(t));this.arr.push(...e),this.sendInner()}sendBatchLogsImmediate(a){const e=a.map(t=>this.transString(t));this.arr.push(...e),this.sendImmediateInner()}overwriteTransString(a){this.transString=a.transString}getOpt(){return this.opt}}function Ts(s,a){const e=new window.XMLHttpRequest;e.open("POST",`${s}?APIVersion=0.6.0`,!0),e.send(a)}function Hn(s,a){try{if(a.length>=32768)return void Ts(s,a);(function(e,t){return!(!navigator||!navigator.sendBeacon)&&navigator.sendBeacon(`${e}?APIVersion=0.6.0`,t)})(s,a)||Ts(s,a)}catch(e){window&&window.console&&typeof window.console.error=="function"&&(console.error(`Failed to log to ali log service because of this exception:
6
+ `);return n<0?`${i}${r}`:`${i.slice(0,n)}${r}${i.slice(n)}`}(e.stack,this.marker))})}updateOptions(a){this.options=X(X({},this.options),a)}setReady(){this.initArmsLogger(!0),this.isReady=!0,this.queue.length&&this.queue.forEach(a=>{var e;(e=this.armsLogger)==null||e.error(this.helper.MediaboxWrapperQueue(a.msg),{filename:a.file,lineno:a.line,colno:a.col})})}report(a,e){var t;(t=this.armsLogger)==null||t.error(this.helper.MediaboxWrapperInitiative(a),e)}destroy(){this.isDestroyed=!0}}for(var or,$e=[],cr=0;cr<256;++cr)$e.push((cr+256).toString(16).slice(1));var On=new Uint8Array(16);function Un(){if(!or&&!(or=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return or(On)}const ws={randomUUID:typeof crypto!="undefined"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function dt(s,a,e){if(ws.randomUUID&&!a&&!s)return ws.randomUUID();var t=(s=s||{}).random||(s.rng||Un)();if(t[6]=15&t[6]|64,t[8]=63&t[8]|128,a){e=e||0;for(var i=0;i<16;++i)a[e+i]=t[i];return a}return function(r,n=0){return($e[r[n+0]]+$e[r[n+1]]+$e[r[n+2]]+$e[r[n+3]]+"-"+$e[r[n+4]]+$e[r[n+5]]+"-"+$e[r[n+6]]+$e[r[n+7]]+"-"+$e[r[n+8]]+$e[r[n+9]]+"-"+$e[r[n+10]]+$e[r[n+11]]+$e[r[n+12]]+$e[r[n+13]]+$e[r[n+14]]+$e[r[n+15]]).toLowerCase()}(t)}var we=(s=>(s.PullStreamStats="remoteStat",s.RtsSubscribeExceeds="rtsSubscribeExceeds",s.UserJoined="userJoined",s.UserLeft="userLeft",s.Bye="bye",s.MuteAudio="muteAudio",s.UnmuteAudio="unmuteAudio",s.MuteVideo="muteVideo",s.UnmuteVideo="unmuteVideo",s.MuteScreen="muteScreen",s.UnmuteScreen="unmuteScreen",s.Error="error",s))(we||{}),Xe=(s=>(s.Local="local-device-status-change",s.Remote="remote-device-status-change",s))(Xe||{}),M=(s=>(s.Audio="sophon_audio",s.VideoLarge="sophon_video_camera_large",s.VideoSmall="sophon_video_camera_small",s.Screen="sophon_video_screen_share",s.Data="sophon_data",s))(M||{}),dr=(s=>(s.Audio="rts audio",s.VideoLarge="rts video",s))(dr||{}),Pt=(s=>(s.Add="add",s.Delete="delete",s.Replace="replace",s.Stop="stop",s.UnPublish="unpublish",s))(Pt||{}),ei=(s=>(s[s.Camera=0]="Camera",s[s.Screen=1]="Screen",s[s.Image=2]="Image",s))(ei||{}),Ei=(s=>(s[s.Microphone=0]="Microphone",s[s.Screen=1]="Screen",s[s.Mixed=2]="Mixed",s))(Ei||{}),Se=(s=>(s.InRoom="inRoom",s.Join="join",s.Publish="publish",s.User="user",s.Resume="resume",s.Retry="retry",s.Reconnect="reconnect",s))(Se||{}),bt=(s=>(s[s.MANUAL=0]="MANUAL",s[s.JOIN_CHANNEL=1]="JOIN_CHANNEL",s[s.ROLE_CHANGE=2]="ROLE_CHANGE",s[s.RECONNECT=3]="RECONNECT",s))(bt||{}),Ii=(s=>(s.prod="rs.rtn.aliyuncs.com",s.pre="prs.rtn.aliyuncs.com",s))(Ii||{});const Ti="7.0.2";class et{static getVersionNumber(){let a=Ti.split("."),e="";return a.forEach(t=>{t.length===1?e+="0"+t:e+=t}),parseInt(e)}static queryingParam(a){let e=[];if(a)for(let t in a)e.push(t+"="+a[t]);return e.join("&")}static getQueryParams(a){const e=window.location.search.substring(1).split("&");for(let t=0;t<e.length;t++){const i=e[t].split("=");if(decodeURIComponent(i[0])===a)return decodeURIComponent(i[1])}}static createCallid(a=""){const e=dt();return a&&e&&e.length>a.length?`${a}${e.substring(a.length)}`:e}static checkSubOptionsValid(a){if(a){const{audio:e,video:t,screen:i}=a;if(e===!1&&t===!1&&i===!1)return!1}return!0}static isNetworkAvailable(){return T(this,null,function*(){const a=Ii.prod,{onLine:e}=navigator;if(!e)return!1;try{return yield fetch(`https://${a}/roomserver/v1/ws/version`),!0}catch(t){return!1}})}static toString(a){let e;if(a instanceof Error)e=a.message;else if(typeof a=="string")e=a;else try{e=JSON.stringify(a)}catch(t){e="undefined"}return e}static paramArrayToString(a){let e="";for(let t=0;t<a.length;t++)e!==""&&(e+=" "),e+=et.toString(a[t]);return e}}function Es(s,a,e){Object.defineProperty(s,a,{writable:!0,enumerable:!0,configurable:!0,value:e})}function Is(s,a,e,t){t?t(()=>{Es(s,a,e)}):Es(s,a,e)}Array(32);class Bn{constructor(a){var e,t;this.timer=null,this.time=10,this.count=10,this.arr=[],this.time=(e=a.time)!=null?e:10,this.count=(t=a.count)!=null?t:10,a.host.startsWith("http://")||a.host.startsWith("https://")?this.url=a.host+"/logstores/"+a.logstore+"/track":this.url="https://"+a.project+"."+a.host+"/logstores/"+a.logstore+"/track",this.opt=a,a.installUnloadHook&&typeof a.installUnloadHook=="function"&&a.installUnloadHook(()=>{this.sendImmediateInner()})}assemblePayload(a){const e={__logs__:a};return this.opt.tags&&(e.__tags__=this.opt.tags),this.opt.topic&&(e.__topic__=this.opt.topic),this.opt.source&&(e.__source__=this.opt.source),JSON.stringify(e)}platformSend(){if(this.opt.sendPayload&&typeof this.opt.sendPayload=="function"){const a=this.assemblePayload(this.arr);this.opt.sendPayload(this.url,a)}}transString(a){let e={};for(let t in a)typeof a[t]=="object"?e[t]=JSON.stringify(a[t]):e[t]=String(a[t]);return e}sendImmediateInner(){this.arr&&this.arr.length>0&&(this.platformSend(),this.timer!=null&&(clearTimeout(this.timer),this.timer=null),this.arr=[])}sendInner(){if(this.timer)this.arr.length>=this.count&&(clearTimeout(this.timer),this.timer=null,this.sendImmediateInner());else{const a=this;this.arr.length>=this.count||this.time<=0?this.sendImmediateInner():this.timer=setTimeout(function(){a.sendImmediateInner()},1e3*this.time)}}send(a){const e=this.transString(a);this.arr.push(e),this.sendInner()}sendImmediate(a){const e=this.transString(a);this.arr.push(e),this.sendImmediateInner()}sendBatchLogs(a){const e=a.map(t=>this.transString(t));this.arr.push(...e),this.sendInner()}sendBatchLogsImmediate(a){const e=a.map(t=>this.transString(t));this.arr.push(...e),this.sendImmediateInner()}overwriteTransString(a){this.transString=a.transString}getOpt(){return this.opt}}function Ts(s,a){const e=new window.XMLHttpRequest;e.open("POST",`${s}?APIVersion=0.6.0`,!0),e.send(a)}function Hn(s,a){try{if(a.length>=32768)return void Ts(s,a);(function(e,t){return!(!navigator||!navigator.sendBeacon)&&navigator.sendBeacon(`${e}?APIVersion=0.6.0`,t)})(s,a)||Ts(s,a)}catch(e){window&&window.console&&typeof window.console.error=="function"&&(console.error(`Failed to log to ali log service because of this exception:
7
7
  `+e),console.error("Failed log data:",s))}}function Fn(s,a,e){return t=this,i=null,r=function*(){try{s=s.slice(0,-6);const{data:n,header:c}=yield e.process(s,a),o=new window.XMLHttpRequest;o.open("POST",s,!0);for(let d in c)o.setRequestHeader(d,c[d]);o.send(n)}catch(n){window&&window.console&&typeof window.console.error=="function"&&(console.error(`Failed to log to ali log service because of this exception:
8
8
  `+n),console.error("Failed log data:",s))}},new Promise((n,c)=>{var o=l=>{try{h(r.next(l))}catch(p){c(p)}},d=l=>{try{h(r.throw(l))}catch(p){c(p)}},h=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,d);h((r=r.apply(t,i)).next())});var t,i,r}class hr extends Bn{constructor(a){super(Object.assign({},a,{installUnloadHook:e=>{window.addEventListener("beforeunload",()=>{e()})},sendPayload:(e,t)=>{Hn(e,t)}}))}useStsPlugin(a){this.getOpt().sendPayload=(e,t)=>{Fn(e,t,a)},this.overwriteTransString(a)}}Is(window,"SLS_Tracker",hr);var Ci=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function jn(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function zn(s){if(s.__esModule)return s;var a=s.default;if(typeof a=="function"){var e=function t(){return this instanceof t?Reflect.construct(a,arguments,this.constructor):a.apply(this,arguments)};e.prototype=a.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(s).forEach(function(t){var i=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:function(){return s[t]}})}),e}var Cs={exports:{}},ks={exports:{}};const Wn=zn(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Ps;function le(){return Ps||(Ps=1,function(s){s.exports=function(){var a=a||function(e,t){var i;if(typeof window!="undefined"&&window.crypto&&(i=window.crypto),typeof self!="undefined"&&self.crypto&&(i=self.crypto),typeof globalThis!="undefined"&&globalThis.crypto&&(i=globalThis.crypto),!i&&typeof window!="undefined"&&window.msCrypto&&(i=window.msCrypto),!i&&Ci!==void 0&&Ci.crypto&&(i=Ci.crypto),!i)try{i=Wn}catch(S){}var r=function(){if(i){if(typeof i.getRandomValues=="function")try{return i.getRandomValues(new Uint32Array(1))[0]}catch(S){}if(typeof i.randomBytes=="function")try{return i.randomBytes(4).readInt32LE()}catch(S){}}throw new Error("Native crypto module could not be used to get secure random number.")},n=Object.create||function(){function S(){}return function(v){var _;return S.prototype=v,_=new S,S.prototype=null,_}}(),c={},o=c.lib={},d=o.Base={extend:function(S){var v=n(this);return S&&v.mixIn(S),v.hasOwnProperty("init")&&this.init!==v.init||(v.init=function(){v.$super.init.apply(this,arguments)}),v.init.prototype=v,v.$super=this,v},create:function(){var S=this.extend();return S.init.apply(S,arguments),S},init:function(){},mixIn:function(S){for(var v in S)S.hasOwnProperty(v)&&(this[v]=S[v]);S.hasOwnProperty("toString")&&(this.toString=S.toString)},clone:function(){return this.init.prototype.extend(this)}},h=o.WordArray=d.extend({init:function(S,v){S=this.words=S||[],this.sigBytes=v!=t?v:4*S.length},toString:function(S){return(S||p).stringify(this)},concat:function(S){var v=this.words,_=S.words,w=this.sigBytes,y=S.sigBytes;if(this.clamp(),w%4)for(var R=0;R<y;R++){var A=_[R>>>2]>>>24-R%4*8&255;v[w+R>>>2]|=A<<24-(w+R)%4*8}else for(var E=0;E<y;E+=4)v[w+E>>>2]=_[E>>>2];return this.sigBytes+=y,this},clamp:function(){var S=this.words,v=this.sigBytes;S[v>>>2]&=4294967295<<32-v%4*8,S.length=e.ceil(v/4)},clone:function(){var S=d.clone.call(this);return S.words=this.words.slice(0),S},random:function(S){for(var v=[],_=0;_<S;_+=4)v.push(r());return new h.init(v,S)}}),l=c.enc={},p=l.Hex={stringify:function(S){for(var v=S.words,_=S.sigBytes,w=[],y=0;y<_;y++){var R=v[y>>>2]>>>24-y%4*8&255;w.push((R>>>4).toString(16)),w.push((15&R).toString(16))}return w.join("")},parse:function(S){for(var v=S.length,_=[],w=0;w<v;w+=2)_[w>>>3]|=parseInt(S.substr(w,2),16)<<24-w%8*4;return new h.init(_,v/2)}},u=l.Latin1={stringify:function(S){for(var v=S.words,_=S.sigBytes,w=[],y=0;y<_;y++){var R=v[y>>>2]>>>24-y%4*8&255;w.push(String.fromCharCode(R))}return w.join("")},parse:function(S){for(var v=S.length,_=[],w=0;w<v;w++)_[w>>>2]|=(255&S.charCodeAt(w))<<24-w%4*8;return new h.init(_,v)}},g=l.Utf8={stringify:function(S){try{return decodeURIComponent(escape(u.stringify(S)))}catch(v){throw new Error("Malformed UTF-8 data")}},parse:function(S){return u.parse(unescape(encodeURIComponent(S)))}},m=o.BufferedBlockAlgorithm=d.extend({reset:function(){this._data=new h.init,this._nDataBytes=0},_append:function(S){typeof S=="string"&&(S=g.parse(S)),this._data.concat(S),this._nDataBytes+=S.sigBytes},_process:function(S){var v,_=this._data,w=_.words,y=_.sigBytes,R=this.blockSize,A=y/(4*R),E=(A=S?e.ceil(A):e.max((0|A)-this._minBufferSize,0))*R,I=e.min(4*E,y);if(E){for(var k=0;k<E;k+=R)this._doProcessBlock(w,k);v=w.splice(0,E),_.sigBytes-=I}return new h.init(v,I)},clone:function(){var S=d.clone.call(this);return S._data=this._data.clone(),S},_minBufferSize:0});o.Hasher=m.extend({cfg:d.extend(),init:function(S){this.cfg=this.cfg.extend(S),this.reset()},reset:function(){m.reset.call(this),this._doReset()},update:function(S){return this._append(S),this._process(),this},finalize:function(S){return S&&this._append(S),this._doFinalize()},blockSize:16,_createHelper:function(S){return function(v,_){return new S.init(_).finalize(v)}},_createHmacHelper:function(S){return function(v,_){return new b.HMAC.init(S,_).finalize(v)}}});var b=c.algo={};return c}(Math);return a}()}(ks)),ks.exports}var Ds,Ms={exports:{}};function ki(){return Ds||(Ds=1,function(s){s.exports=function(a){return i=(t=a).lib,r=i.Base,n=i.WordArray,(c=t.x64={}).Word=r.extend({init:function(o,d){this.high=o,this.low=d}}),c.WordArray=r.extend({init:function(o,d){o=this.words=o||[],this.sigBytes=d!=e?d:8*o.length},toX32:function(){for(var o=this.words,d=o.length,h=[],l=0;l<d;l++){var p=o[l];h.push(p.high),h.push(p.low)}return n.create(h,this.sigBytes)},clone:function(){for(var o=r.clone.call(this),d=o.words=this.words.slice(0),h=d.length,l=0;l<h;l++)d[l]=d[l].clone();return o}}),a;var e,t,i,r,n,c}(le())}(Ms)),Ms.exports}var Ns,Ls={exports:{}};function Kn(){return Ns||(Ns=1,function(s){s.exports=function(a){return function(){if(typeof ArrayBuffer=="function"){var e=a.lib.WordArray,t=e.init,i=e.init=function(r){if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),(r instanceof Int8Array||typeof Uint8ClampedArray!="undefined"&&r instanceof Uint8ClampedArray||r instanceof Int16Array||r instanceof Uint16Array||r instanceof Int32Array||r instanceof Uint32Array||r instanceof Float32Array||r instanceof Float64Array)&&(r=new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),r instanceof Uint8Array){for(var n=r.byteLength,c=[],o=0;o<n;o++)c[o>>>2]|=r[o]<<24-o%4*8;t.call(this,c,n)}else t.apply(this,arguments)};i.prototype=e}}(),a.lib.WordArray}(le())}(Ls)),Ls.exports}var xs,Vs={exports:{}};function $n(){return xs||(xs=1,function(s){s.exports=function(a){return function(){var e=a,t=e.lib.WordArray,i=e.enc;function r(n){return n<<8&4278255360|n>>>8&16711935}i.Utf16=i.Utf16BE={stringify:function(n){for(var c=n.words,o=n.sigBytes,d=[],h=0;h<o;h+=2){var l=c[h>>>2]>>>16-h%4*8&65535;d.push(String.fromCharCode(l))}return d.join("")},parse:function(n){for(var c=n.length,o=[],d=0;d<c;d++)o[d>>>1]|=n.charCodeAt(d)<<16-d%2*16;return t.create(o,2*c)}},i.Utf16LE={stringify:function(n){for(var c=n.words,o=n.sigBytes,d=[],h=0;h<o;h+=2){var l=r(c[h>>>2]>>>16-h%4*8&65535);d.push(String.fromCharCode(l))}return d.join("")},parse:function(n){for(var c=n.length,o=[],d=0;d<c;d++)o[d>>>1]|=r(n.charCodeAt(d)<<16-d%2*16);return t.create(o,2*c)}}}(),a.enc.Utf16}(le())}(Vs)),Vs.exports}var Os,Us={exports:{}};function zt(){return Os||(Os=1,function(s){s.exports=function(a){return function(){var e=a,t=e.lib.WordArray;function i(r,n,c){for(var o=[],d=0,h=0;h<n;h++)if(h%4){var l=c[r.charCodeAt(h-1)]<<h%4*2|c[r.charCodeAt(h)]>>>6-h%4*2;o[d>>>2]|=l<<24-d%4*8,d++}return t.create(o,d)}e.enc.Base64={stringify:function(r){var n=r.words,c=r.sigBytes,o=this._map;r.clamp();for(var d=[],h=0;h<c;h+=3)for(var l=(n[h>>>2]>>>24-h%4*8&255)<<16|(n[h+1>>>2]>>>24-(h+1)%4*8&255)<<8|n[h+2>>>2]>>>24-(h+2)%4*8&255,p=0;p<4&&h+.75*p<c;p++)d.push(o.charAt(l>>>6*(3-p)&63));var u=o.charAt(64);if(u)for(;d.length%4;)d.push(u);return d.join("")},parse:function(r){var n=r.length,c=this._map,o=this._reverseMap;if(!o){o=this._reverseMap=[];for(var d=0;d<c.length;d++)o[c.charCodeAt(d)]=d}var h=c.charAt(64);if(h){var l=r.indexOf(h);l!==-1&&(n=l)}return i(r,n,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),a.enc.Base64}(le())}(Us)),Us.exports}var Bs,Hs={exports:{}};function Jn(){return Bs||(Bs=1,function(s){s.exports=function(a){return function(){var e=a,t=e.lib.WordArray;function i(r,n,c){for(var o=[],d=0,h=0;h<n;h++)if(h%4){var l=c[r.charCodeAt(h-1)]<<h%4*2|c[r.charCodeAt(h)]>>>6-h%4*2;o[d>>>2]|=l<<24-d%4*8,d++}return t.create(o,d)}e.enc.Base64url={stringify:function(r,n){n===void 0&&(n=!0);var c=r.words,o=r.sigBytes,d=n?this._safe_map:this._map;r.clamp();for(var h=[],l=0;l<o;l+=3)for(var p=(c[l>>>2]>>>24-l%4*8&255)<<16|(c[l+1>>>2]>>>24-(l+1)%4*8&255)<<8|c[l+2>>>2]>>>24-(l+2)%4*8&255,u=0;u<4&&l+.75*u<o;u++)h.push(d.charAt(p>>>6*(3-u)&63));var g=d.charAt(64);if(g)for(;h.length%4;)h.push(g);return h.join("")},parse:function(r,n){n===void 0&&(n=!0);var c=r.length,o=n?this._safe_map:this._map,d=this._reverseMap;if(!d){d=this._reverseMap=[];for(var h=0;h<o.length;h++)d[o.charCodeAt(h)]=h}var l=o.charAt(64);if(l){var p=r.indexOf(l);p!==-1&&(c=p)}return i(r,c,d)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"}}(),a.enc.Base64url}(le())}(Hs)),Hs.exports}var Fs,js={exports:{}};function Wt(){return Fs||(Fs=1,function(s){s.exports=function(a){return function(e){var t=a,i=t.lib,r=i.WordArray,n=i.Hasher,c=t.algo,o=[];(function(){for(var g=0;g<64;g++)o[g]=4294967296*e.abs(e.sin(g+1))|0})();var d=c.MD5=n.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(g,m){for(var b=0;b<16;b++){var S=m+b,v=g[S];g[S]=16711935&(v<<8|v>>>24)|4278255360&(v<<24|v>>>8)}var _=this._hash.words,w=g[m+0],y=g[m+1],R=g[m+2],A=g[m+3],E=g[m+4],I=g[m+5],k=g[m+6],P=g[m+7],B=g[m+8],G=g[m+9],Y=g[m+10],J=g[m+11],z=g[m+12],Q=g[m+13],ee=g[m+14],pe=g[m+15],D=_[0],L=_[1],N=_[2],x=_[3];D=h(D,L,N,x,w,7,o[0]),x=h(x,D,L,N,y,12,o[1]),N=h(N,x,D,L,R,17,o[2]),L=h(L,N,x,D,A,22,o[3]),D=h(D,L,N,x,E,7,o[4]),x=h(x,D,L,N,I,12,o[5]),N=h(N,x,D,L,k,17,o[6]),L=h(L,N,x,D,P,22,o[7]),D=h(D,L,N,x,B,7,o[8]),x=h(x,D,L,N,G,12,o[9]),N=h(N,x,D,L,Y,17,o[10]),L=h(L,N,x,D,J,22,o[11]),D=h(D,L,N,x,z,7,o[12]),x=h(x,D,L,N,Q,12,o[13]),N=h(N,x,D,L,ee,17,o[14]),D=l(D,L=h(L,N,x,D,pe,22,o[15]),N,x,y,5,o[16]),x=l(x,D,L,N,k,9,o[17]),N=l(N,x,D,L,J,14,o[18]),L=l(L,N,x,D,w,20,o[19]),D=l(D,L,N,x,I,5,o[20]),x=l(x,D,L,N,Y,9,o[21]),N=l(N,x,D,L,pe,14,o[22]),L=l(L,N,x,D,E,20,o[23]),D=l(D,L,N,x,G,5,o[24]),x=l(x,D,L,N,ee,9,o[25]),N=l(N,x,D,L,A,14,o[26]),L=l(L,N,x,D,B,20,o[27]),D=l(D,L,N,x,Q,5,o[28]),x=l(x,D,L,N,R,9,o[29]),N=l(N,x,D,L,P,14,o[30]),D=p(D,L=l(L,N,x,D,z,20,o[31]),N,x,I,4,o[32]),x=p(x,D,L,N,B,11,o[33]),N=p(N,x,D,L,J,16,o[34]),L=p(L,N,x,D,ee,23,o[35]),D=p(D,L,N,x,y,4,o[36]),x=p(x,D,L,N,E,11,o[37]),N=p(N,x,D,L,P,16,o[38]),L=p(L,N,x,D,Y,23,o[39]),D=p(D,L,N,x,Q,4,o[40]),x=p(x,D,L,N,w,11,o[41]),N=p(N,x,D,L,A,16,o[42]),L=p(L,N,x,D,k,23,o[43]),D=p(D,L,N,x,G,4,o[44]),x=p(x,D,L,N,z,11,o[45]),N=p(N,x,D,L,pe,16,o[46]),D=u(D,L=p(L,N,x,D,R,23,o[47]),N,x,w,6,o[48]),x=u(x,D,L,N,P,10,o[49]),N=u(N,x,D,L,ee,15,o[50]),L=u(L,N,x,D,I,21,o[51]),D=u(D,L,N,x,z,6,o[52]),x=u(x,D,L,N,A,10,o[53]),N=u(N,x,D,L,Y,15,o[54]),L=u(L,N,x,D,y,21,o[55]),D=u(D,L,N,x,B,6,o[56]),x=u(x,D,L,N,pe,10,o[57]),N=u(N,x,D,L,k,15,o[58]),L=u(L,N,x,D,Q,21,o[59]),D=u(D,L,N,x,E,6,o[60]),x=u(x,D,L,N,J,10,o[61]),N=u(N,x,D,L,R,15,o[62]),L=u(L,N,x,D,G,21,o[63]),_[0]=_[0]+D|0,_[1]=_[1]+L|0,_[2]=_[2]+N|0,_[3]=_[3]+x|0},_doFinalize:function(){var g=this._data,m=g.words,b=8*this._nDataBytes,S=8*g.sigBytes;m[S>>>5]|=128<<24-S%32;var v=e.floor(b/4294967296),_=b;m[15+(S+64>>>9<<4)]=16711935&(v<<8|v>>>24)|4278255360&(v<<24|v>>>8),m[14+(S+64>>>9<<4)]=16711935&(_<<8|_>>>24)|4278255360&(_<<24|_>>>8),g.sigBytes=4*(m.length+1),this._process();for(var w=this._hash,y=w.words,R=0;R<4;R++){var A=y[R];y[R]=16711935&(A<<8|A>>>24)|4278255360&(A<<24|A>>>8)}return w},clone:function(){var g=n.clone.call(this);return g._hash=this._hash.clone(),g}});function h(g,m,b,S,v,_,w){var y=g+(m&b|~m&S)+v+w;return(y<<_|y>>>32-_)+m}function l(g,m,b,S,v,_,w){var y=g+(m&S|b&~S)+v+w;return(y<<_|y>>>32-_)+m}function p(g,m,b,S,v,_,w){var y=g+(m^b^S)+v+w;return(y<<_|y>>>32-_)+m}function u(g,m,b,S,v,_,w){var y=g+(b^(m|~S))+v+w;return(y<<_|y>>>32-_)+m}t.MD5=n._createHelper(d),t.HmacMD5=n._createHmacHelper(d)}(Math),a.MD5}(le())}(js)),js.exports}var zs,Ws={exports:{}};function Ks(){return zs||(zs=1,function(s){s.exports=function(a){return t=(e=a).lib,i=t.WordArray,r=t.Hasher,n=e.algo,c=[],o=n.SHA1=r.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(d,h){for(var l=this._hash.words,p=l[0],u=l[1],g=l[2],m=l[3],b=l[4],S=0;S<80;S++){if(S<16)c[S]=0|d[h+S];else{var v=c[S-3]^c[S-8]^c[S-14]^c[S-16];c[S]=v<<1|v>>>31}var _=(p<<5|p>>>27)+b+c[S];_+=S<20?1518500249+(u&g|~u&m):S<40?1859775393+(u^g^m):S<60?(u&g|u&m|g&m)-1894007588:(u^g^m)-899497514,b=m,m=g,g=u<<30|u>>>2,u=p,p=_}l[0]=l[0]+p|0,l[1]=l[1]+u|0,l[2]=l[2]+g|0,l[3]=l[3]+m|0,l[4]=l[4]+b|0},_doFinalize:function(){var d=this._data,h=d.words,l=8*this._nDataBytes,p=8*d.sigBytes;return h[p>>>5]|=128<<24-p%32,h[14+(p+64>>>9<<4)]=Math.floor(l/4294967296),h[15+(p+64>>>9<<4)]=l,d.sigBytes=4*h.length,this._process(),this._hash},clone:function(){var d=r.clone.call(this);return d._hash=this._hash.clone(),d}}),e.SHA1=r._createHelper(o),e.HmacSHA1=r._createHmacHelper(o),a.SHA1;var e,t,i,r,n,c,o}(le())}(Ws)),Ws.exports}var $s,Js={exports:{}};function lr(){return $s||($s=1,function(s){s.exports=function(a){return function(e){var t=a,i=t.lib,r=i.WordArray,n=i.Hasher,c=t.algo,o=[],d=[];(function(){function p(b){for(var S=e.sqrt(b),v=2;v<=S;v++)if(!(b%v))return!1;return!0}function u(b){return 4294967296*(b-(0|b))|0}for(var g=2,m=0;m<64;)p(g)&&(m<8&&(o[m]=u(e.pow(g,.5))),d[m]=u(e.pow(g,1/3)),m++),g++})();var h=[],l=c.SHA256=n.extend({_doReset:function(){this._hash=new r.init(o.slice(0))},_doProcessBlock:function(p,u){for(var g=this._hash.words,m=g[0],b=g[1],S=g[2],v=g[3],_=g[4],w=g[5],y=g[6],R=g[7],A=0;A<64;A++){if(A<16)h[A]=0|p[u+A];else{var E=h[A-15],I=(E<<25|E>>>7)^(E<<14|E>>>18)^E>>>3,k=h[A-2],P=(k<<15|k>>>17)^(k<<13|k>>>19)^k>>>10;h[A]=I+h[A-7]+P+h[A-16]}var B=m&b^m&S^b&S,G=(m<<30|m>>>2)^(m<<19|m>>>13)^(m<<10|m>>>22),Y=R+((_<<26|_>>>6)^(_<<21|_>>>11)^(_<<7|_>>>25))+(_&w^~_&y)+d[A]+h[A];R=y,y=w,w=_,_=v+Y|0,v=S,S=b,b=m,m=Y+(G+B)|0}g[0]=g[0]+m|0,g[1]=g[1]+b|0,g[2]=g[2]+S|0,g[3]=g[3]+v|0,g[4]=g[4]+_|0,g[5]=g[5]+w|0,g[6]=g[6]+y|0,g[7]=g[7]+R|0},_doFinalize:function(){var p=this._data,u=p.words,g=8*this._nDataBytes,m=8*p.sigBytes;return u[m>>>5]|=128<<24-m%32,u[14+(m+64>>>9<<4)]=e.floor(g/4294967296),u[15+(m+64>>>9<<4)]=g,p.sigBytes=4*u.length,this._process(),this._hash},clone:function(){var p=n.clone.call(this);return p._hash=this._hash.clone(),p}});t.SHA256=n._createHelper(l),t.HmacSHA256=n._createHmacHelper(l)}(Math),a.SHA256}(le())}(Js)),Js.exports}var Gs,Gn={exports:{}},qs,Xs={exports:{}};function Ys(){return qs||(qs=1,function(s){s.exports=function(a){return function(){var e=a,t=e.lib.Hasher,i=e.x64,r=i.Word,n=i.WordArray,c=e.algo;function o(){return r.create.apply(r,arguments)}var d=[o(1116352408,3609767458),o(1899447441,602891725),o(3049323471,3964484399),o(3921009573,2173295548),o(961987163,4081628472),o(1508970993,3053834265),o(2453635748,2937671579),o(2870763221,3664609560),o(3624381080,2734883394),o(310598401,1164996542),o(607225278,1323610764),o(1426881987,3590304994),o(1925078388,4068182383),o(2162078206,991336113),o(2614888103,633803317),o(3248222580,3479774868),o(3835390401,2666613458),o(4022224774,944711139),o(264347078,2341262773),o(604807628,2007800933),o(770255983,1495990901),o(1249150122,1856431235),o(1555081692,3175218132),o(1996064986,2198950837),o(2554220882,3999719339),o(2821834349,766784016),o(2952996808,2566594879),o(3210313671,3203337956),o(3336571891,1034457026),o(3584528711,2466948901),o(113926993,3758326383),o(338241895,168717936),o(666307205,1188179964),o(773529912,1546045734),o(1294757372,1522805485),o(1396182291,2643833823),o(1695183700,2343527390),o(1986661051,1014477480),o(2177026350,1206759142),o(2456956037,344077627),o(2730485921,1290863460),o(2820302411,3158454273),o(3259730800,3505952657),o(3345764771,106217008),o(3516065817,3606008344),o(3600352804,1432725776),o(4094571909,1467031594),o(275423344,851169720),o(430227734,3100823752),o(506948616,1363258195),o(659060556,3750685593),o(883997877,3785050280),o(958139571,3318307427),o(1322822218,3812723403),o(1537002063,2003034995),o(1747873779,3602036899),o(1955562222,1575990012),o(2024104815,1125592928),o(2227730452,2716904306),o(2361852424,442776044),o(2428436474,593698344),o(2756734187,3733110249),o(3204031479,2999351573),o(3329325298,3815920427),o(3391569614,3928383900),o(3515267271,566280711),o(3940187606,3454069534),o(4118630271,4000239992),o(116418474,1914138554),o(174292421,2731055270),o(289380356,3203993006),o(460393269,320620315),o(685471733,587496836),o(852142971,1086792851),o(1017036298,365543100),o(1126000580,2618297676),o(1288033470,3409855158),o(1501505948,4234509866),o(1607167915,987167468),o(1816402316,1246189591)],h=[];(function(){for(var p=0;p<80;p++)h[p]=o()})();var l=c.SHA512=t.extend({_doReset:function(){this._hash=new n.init([new r.init(1779033703,4089235720),new r.init(3144134277,2227873595),new r.init(1013904242,4271175723),new r.init(2773480762,1595750129),new r.init(1359893119,2917565137),new r.init(2600822924,725511199),new r.init(528734635,4215389547),new r.init(1541459225,327033209)])},_doProcessBlock:function(p,u){for(var g=this._hash.words,m=g[0],b=g[1],S=g[2],v=g[3],_=g[4],w=g[5],y=g[6],R=g[7],A=m.high,E=m.low,I=b.high,k=b.low,P=S.high,B=S.low,G=v.high,Y=v.low,J=_.high,z=_.low,Q=w.high,ee=w.low,pe=y.high,D=y.low,L=R.high,N=R.low,x=A,ce=E,ke=I,$=k,ge=P,De=B,Ae=G,Te=Y,fe=J,_e=z,de=Q,Pe=ee,ye=pe,Ge=D,st=L,ae=N,re=0;re<80;re++){var te,be,Ve=h[re];if(re<16)be=Ve.high=0|p[u+2*re],te=Ve.low=0|p[u+2*re+1];else{var he=h[re-15],je=he.high,Z=he.low,Me=(je>>>1|Z<<31)^(je>>>8|Z<<24)^je>>>7,at=(Z>>>1|je<<31)^(Z>>>8|je<<24)^(Z>>>7|je<<25),Le=h[re-2],ft=Le.high,_t=Le.low,St=(ft>>>19|_t<<13)^(ft<<3|_t>>>29)^ft>>>6,Ft=(_t>>>19|ft<<13)^(_t<<3|ft>>>29)^(_t>>>6|ft<<26),_i=h[re-7],Ki=_i.high,Cc=_i.low,yn=h[re-16],kc=yn.high,Rn=yn.low;be=(be=(be=Me+Ki+((te=at+Cc)>>>0<at>>>0?1:0))+St+((te+=Ft)>>>0<Ft>>>0?1:0))+kc+((te+=Rn)>>>0<Rn>>>0?1:0),Ve.high=be,Ve.low=te}var Zt,Pc=fe&de^~fe&ye,An=_e&Pe^~_e&Ge,Dc=x&ke^x&ge^ke&ge,Mc=ce&$^ce&De^$&De,Nc=(x>>>28|ce<<4)^(x<<30|ce>>>2)^(x<<25|ce>>>7),_n=(ce>>>28|x<<4)^(ce<<30|x>>>2)^(ce<<25|x>>>7),Lc=(fe>>>14|_e<<18)^(fe>>>18|_e<<14)^(fe<<23|_e>>>9),xc=(_e>>>14|fe<<18)^(_e>>>18|fe<<14)^(_e<<23|fe>>>9),wn=d[re],Vc=wn.high,En=wn.low,wi=st+Lc+((Zt=ae+xc)>>>0<ae>>>0?1:0),In=_n+Mc;st=ye,ae=Ge,ye=de,Ge=Pe,de=fe,Pe=_e,fe=Ae+(wi=(wi=(wi=wi+Pc+((Zt+=An)>>>0<An>>>0?1:0))+Vc+((Zt+=En)>>>0<En>>>0?1:0))+be+((Zt+=te)>>>0<te>>>0?1:0))+((_e=Te+Zt|0)>>>0<Te>>>0?1:0)|0,Ae=ge,Te=De,ge=ke,De=$,ke=x,$=ce,x=wi+(Nc+Dc+(In>>>0<_n>>>0?1:0))+((ce=Zt+In|0)>>>0<Zt>>>0?1:0)|0}E=m.low=E+ce,m.high=A+x+(E>>>0<ce>>>0?1:0),k=b.low=k+$,b.high=I+ke+(k>>>0<$>>>0?1:0),B=S.low=B+De,S.high=P+ge+(B>>>0<De>>>0?1:0),Y=v.low=Y+Te,v.high=G+Ae+(Y>>>0<Te>>>0?1:0),z=_.low=z+_e,_.high=J+fe+(z>>>0<_e>>>0?1:0),ee=w.low=ee+Pe,w.high=Q+de+(ee>>>0<Pe>>>0?1:0),D=y.low=D+Ge,y.high=pe+ye+(D>>>0<Ge>>>0?1:0),N=R.low=N+ae,R.high=L+st+(N>>>0<ae>>>0?1:0)},_doFinalize:function(){var p=this._data,u=p.words,g=8*this._nDataBytes,m=8*p.sigBytes;return u[m>>>5]|=128<<24-m%32,u[30+(m+128>>>10<<5)]=Math.floor(g/4294967296),u[31+(m+128>>>10<<5)]=g,p.sigBytes=4*u.length,this._process(),this._hash.toX32()},clone:function(){var p=t.clone.call(this);return p._hash=this._hash.clone(),p},blockSize:32});e.SHA512=t._createHelper(l),e.HmacSHA512=t._createHmacHelper(l)}(),a.SHA512}(le(),ki())}(Xs)),Xs.exports}var Zs,qn={exports:{}},Qs,ea={exports:{}};function Xn(){return Qs||(Qs=1,function(s){s.exports=function(a){return function(e){var t=a,i=t.lib,r=i.WordArray,n=i.Hasher,c=t.x64.Word,o=t.algo,d=[],h=[],l=[];(function(){for(var g=1,m=0,b=0;b<24;b++){d[g+5*m]=(b+1)*(b+2)/2%64;var S=(2*g+3*m)%5;g=m%5,m=S}for(g=0;g<5;g++)for(m=0;m<5;m++)h[g+5*m]=m+(2*g+3*m)%5*5;for(var v=1,_=0;_<24;_++){for(var w=0,y=0,R=0;R<7;R++){if(1&v){var A=(1<<R)-1;A<32?y^=1<<A:w^=1<<A-32}128&v?v=v<<1^113:v<<=1}l[_]=c.create(w,y)}})();var p=[];(function(){for(var g=0;g<25;g++)p[g]=c.create()})();var u=o.SHA3=n.extend({cfg:n.cfg.extend({outputLength:512}),_doReset:function(){for(var g=this._state=[],m=0;m<25;m++)g[m]=new c.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(g,m){for(var b=this._state,S=this.blockSize/2,v=0;v<S;v++){var _=g[m+2*v],w=g[m+2*v+1];_=16711935&(_<<8|_>>>24)|4278255360&(_<<24|_>>>8),w=16711935&(w<<8|w>>>24)|4278255360&(w<<24|w>>>8),(N=b[v]).high^=w,N.low^=_}for(var y=0;y<24;y++){for(var R=0;R<5;R++){for(var A=0,E=0,I=0;I<5;I++)A^=(N=b[R+5*I]).high,E^=N.low;var k=p[R];k.high=A,k.low=E}for(R=0;R<5;R++){var P=p[(R+4)%5],B=p[(R+1)%5],G=B.high,Y=B.low;for(A=P.high^(G<<1|Y>>>31),E=P.low^(Y<<1|G>>>31),I=0;I<5;I++)(N=b[R+5*I]).high^=A,N.low^=E}for(var J=1;J<25;J++){var z=(N=b[J]).high,Q=N.low,ee=d[J];ee<32?(A=z<<ee|Q>>>32-ee,E=Q<<ee|z>>>32-ee):(A=Q<<ee-32|z>>>64-ee,E=z<<ee-32|Q>>>64-ee);var pe=p[h[J]];pe.high=A,pe.low=E}var D=p[0],L=b[0];for(D.high=L.high,D.low=L.low,R=0;R<5;R++)for(I=0;I<5;I++){var N=b[J=R+5*I],x=p[J],ce=p[(R+1)%5+5*I],ke=p[(R+2)%5+5*I];N.high=x.high^~ce.high&ke.high,N.low=x.low^~ce.low&ke.low}N=b[0];var $=l[y];N.high^=$.high,N.low^=$.low}},_doFinalize:function(){var g=this._data,m=g.words;this._nDataBytes;var b=8*g.sigBytes,S=32*this.blockSize;m[b>>>5]|=1<<24-b%32,m[(e.ceil((b+1)/S)*S>>>5)-1]|=128,g.sigBytes=4*m.length,this._process();for(var v=this._state,_=this.cfg.outputLength/8,w=_/8,y=[],R=0;R<w;R++){var A=v[R],E=A.high,I=A.low;E=16711935&(E<<8|E>>>24)|4278255360&(E<<24|E>>>8),I=16711935&(I<<8|I>>>24)|4278255360&(I<<24|I>>>8),y.push(I),y.push(E)}return new r.init(y,_)},clone:function(){for(var g=n.clone.call(this),m=g._state=this._state.slice(0),b=0;b<25;b++)m[b]=m[b].clone();return g}});t.SHA3=n._createHelper(u),t.HmacSHA3=n._createHmacHelper(u)}(Math),a.SHA3}(le(),ki())}(ea)),ea.exports}var ta,Yn={exports:{}},ia,ra={exports:{}};function ur(){return ia||(ia=1,function(s){s.exports=function(a){var e,t,i;t=(e=a).lib.Base,i=e.enc.Utf8,e.algo.HMAC=t.extend({init:function(r,n){r=this._hasher=new r.init,typeof n=="string"&&(n=i.parse(n));var c=r.blockSize,o=4*c;n.sigBytes>o&&(n=r.finalize(n)),n.clamp();for(var d=this._oKey=n.clone(),h=this._iKey=n.clone(),l=d.words,p=h.words,u=0;u<c;u++)l[u]^=1549556828,p[u]^=909522486;d.sigBytes=h.sigBytes=o,this.reset()},reset:function(){var r=this._hasher;r.reset(),r.update(this._iKey)},update:function(r){return this._hasher.update(r),this},finalize:function(r){var n=this._hasher,c=n.finalize(r);return n.reset(),n.finalize(this._oKey.clone().concat(c))}})}(le())}(ra)),ra.exports}var sa,Zn={exports:{}},aa,na={exports:{}};function Dt(){return aa||(aa=1,function(s){s.exports=function(a){return t=(e=a).lib,i=t.Base,r=t.WordArray,n=e.algo,c=n.MD5,o=n.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:c,iterations:1}),init:function(d){this.cfg=this.cfg.extend(d)},compute:function(d,h){for(var l,p=this.cfg,u=p.hasher.create(),g=r.create(),m=g.words,b=p.keySize,S=p.iterations;m.length<b;){l&&u.update(l),l=u.update(d).finalize(h),u.reset();for(var v=1;v<S;v++)l=u.finalize(l),u.reset();g.concat(l)}return g.sigBytes=4*b,g}}),e.EvpKDF=function(d,h,l){return o.create(l).compute(d,h)},a.EvpKDF;var e,t,i,r,n,c,o}(le(),Ks(),ur())}(na)),na.exports}var oa,ca={exports:{}};function ze(){return oa||(oa=1,function(s){s.exports=function(a){a.lib.Cipher||function(e){var t=a,i=t.lib,r=i.Base,n=i.WordArray,c=i.BufferedBlockAlgorithm,o=t.enc;o.Utf8;var d=o.Base64,h=t.algo.EvpKDF,l=i.Cipher=c.extend({cfg:r.extend(),createEncryptor:function(y,R){return this.create(this._ENC_XFORM_MODE,y,R)},createDecryptor:function(y,R){return this.create(this._DEC_XFORM_MODE,y,R)},init:function(y,R,A){this.cfg=this.cfg.extend(A),this._xformMode=y,this._key=R,this.reset()},reset:function(){c.reset.call(this),this._doReset()},process:function(y){return this._append(y),this._process()},finalize:function(y){return y&&this._append(y),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function y(R){return typeof R=="string"?w:v}return function(R){return{encrypt:function(A,E,I){return y(E).encrypt(R,A,E,I)},decrypt:function(A,E,I){return y(E).decrypt(R,A,E,I)}}}}()});i.StreamCipher=l.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var p=t.mode={},u=i.BlockCipherMode=r.extend({createEncryptor:function(y,R){return this.Encryptor.create(y,R)},createDecryptor:function(y,R){return this.Decryptor.create(y,R)},init:function(y,R){this._cipher=y,this._iv=R}}),g=p.CBC=function(){var y=u.extend();function R(A,E,I){var k,P=this._iv;P?(k=P,this._iv=e):k=this._prevBlock;for(var B=0;B<I;B++)A[E+B]^=k[B]}return y.Encryptor=y.extend({processBlock:function(A,E){var I=this._cipher,k=I.blockSize;R.call(this,A,E,k),I.encryptBlock(A,E),this._prevBlock=A.slice(E,E+k)}}),y.Decryptor=y.extend({processBlock:function(A,E){var I=this._cipher,k=I.blockSize,P=A.slice(E,E+k);I.decryptBlock(A,E),R.call(this,A,E,k),this._prevBlock=P}}),y}(),m=(t.pad={}).Pkcs7={pad:function(y,R){for(var A=4*R,E=A-y.sigBytes%A,I=E<<24|E<<16|E<<8|E,k=[],P=0;P<E;P+=4)k.push(I);var B=n.create(k,E);y.concat(B)},unpad:function(y){var R=255&y.words[y.sigBytes-1>>>2];y.sigBytes-=R}};i.BlockCipher=l.extend({cfg:l.cfg.extend({mode:g,padding:m}),reset:function(){var y;l.reset.call(this);var R=this.cfg,A=R.iv,E=R.mode;this._xformMode==this._ENC_XFORM_MODE?y=E.createEncryptor:(y=E.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==y?this._mode.init(this,A&&A.words):(this._mode=y.call(E,this,A&&A.words),this._mode.__creator=y)},_doProcessBlock:function(y,R){this._mode.processBlock(y,R)},_doFinalize:function(){var y,R=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(R.pad(this._data,this.blockSize),y=this._process(!0)):(y=this._process(!0),R.unpad(y)),y},blockSize:4});var b=i.CipherParams=r.extend({init:function(y){this.mixIn(y)},toString:function(y){return(y||this.formatter).stringify(this)}}),S=(t.format={}).OpenSSL={stringify:function(y){var R=y.ciphertext,A=y.salt;return(A?n.create([1398893684,1701076831]).concat(A).concat(R):R).toString(d)},parse:function(y){var R,A=d.parse(y),E=A.words;return E[0]==1398893684&&E[1]==1701076831&&(R=n.create(E.slice(2,4)),E.splice(0,4),A.sigBytes-=16),b.create({ciphertext:A,salt:R})}},v=i.SerializableCipher=r.extend({cfg:r.extend({format:S}),encrypt:function(y,R,A,E){E=this.cfg.extend(E);var I=y.createEncryptor(A,E),k=I.finalize(R),P=I.cfg;return b.create({ciphertext:k,key:A,iv:P.iv,algorithm:y,mode:P.mode,padding:P.padding,blockSize:y.blockSize,formatter:E.format})},decrypt:function(y,R,A,E){return E=this.cfg.extend(E),R=this._parse(R,E.format),y.createDecryptor(A,E).finalize(R.ciphertext)},_parse:function(y,R){return typeof y=="string"?R.parse(y,this):y}}),_=(t.kdf={}).OpenSSL={execute:function(y,R,A,E,I){if(E||(E=n.random(8)),I)k=h.create({keySize:R+A,hasher:I}).compute(y,E);else var k=h.create({keySize:R+A}).compute(y,E);var P=n.create(k.words.slice(R),4*A);return k.sigBytes=4*R,b.create({key:k,iv:P,salt:E})}},w=i.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:_}),encrypt:function(y,R,A,E){var I=(E=this.cfg.extend(E)).kdf.execute(A,y.keySize,y.ivSize,E.salt,E.hasher);E.iv=I.iv;var k=v.encrypt.call(this,y,R,I.key,E);return k.mixIn(I),k},decrypt:function(y,R,A,E){E=this.cfg.extend(E),R=this._parse(R,E.format);var I=E.kdf.execute(A,y.keySize,y.ivSize,R.salt,E.hasher);return E.iv=I.iv,v.decrypt.call(this,y,R,I.key,E)}})}()}(le(),Dt())}(ca)),ca.exports}var da,ha={exports:{}};function Qn(){return da||(da=1,function(s){s.exports=function(a){return a.mode.CFB=function(){var e=a.lib.BlockCipherMode.extend();function t(i,r,n,c){var o,d=this._iv;d?(o=d.slice(0),this._iv=void 0):o=this._prevBlock,c.encryptBlock(o,0);for(var h=0;h<n;h++)i[r+h]^=o[h]}return e.Encryptor=e.extend({processBlock:function(i,r){var n=this._cipher,c=n.blockSize;t.call(this,i,r,c,n),this._prevBlock=i.slice(r,r+c)}}),e.Decryptor=e.extend({processBlock:function(i,r){var n=this._cipher,c=n.blockSize,o=i.slice(r,r+c);t.call(this,i,r,c,n),this._prevBlock=o}}),e}(),a.mode.CFB}(le(),ze())}(ha)),ha.exports}var la,ua={exports:{}};function eo(){return la||(la=1,function(s){s.exports=function(a){return a.mode.CTR=(e=a.lib.BlockCipherMode.extend(),t=e.Encryptor=e.extend({processBlock:function(i,r){var n=this._cipher,c=n.blockSize,o=this._iv,d=this._counter;o&&(d=this._counter=o.slice(0),this._iv=void 0);var h=d.slice(0);n.encryptBlock(h,0),d[c-1]=d[c-1]+1|0;for(var l=0;l<c;l++)i[r+l]^=h[l]}}),e.Decryptor=t,e),a.mode.CTR;var e,t}(le(),ze())}(ua)),ua.exports}var pa,ma={exports:{}};function to(){return pa||(pa=1,function(s){s.exports=function(a){return a.mode.CTRGladman=function(){var e=a.lib.BlockCipherMode.extend();function t(n){if(255&~(n>>24))n+=1<<24;else{var c=n>>16&255,o=n>>8&255,d=255&n;c===255?(c=0,o===255?(o=0,d===255?d=0:++d):++o):++c,n=0,n+=c<<16,n+=o<<8,n+=d}return n}function i(n){return(n[0]=t(n[0]))===0&&(n[1]=t(n[1])),n}var r=e.Encryptor=e.extend({processBlock:function(n,c){var o=this._cipher,d=o.blockSize,h=this._iv,l=this._counter;h&&(l=this._counter=h.slice(0),this._iv=void 0),i(l);var p=l.slice(0);o.encryptBlock(p,0);for(var u=0;u<d;u++)n[c+u]^=p[u]}});return e.Decryptor=r,e}(),a.mode.CTRGladman}(le(),ze())}(ma)),ma.exports}var ga,fa={exports:{}};function io(){return ga||(ga=1,function(s){s.exports=function(a){return a.mode.OFB=(e=a.lib.BlockCipherMode.extend(),t=e.Encryptor=e.extend({processBlock:function(i,r){var n=this._cipher,c=n.blockSize,o=this._iv,d=this._keystream;o&&(d=this._keystream=o.slice(0),this._iv=void 0),n.encryptBlock(d,0);for(var h=0;h<c;h++)i[r+h]^=d[h]}}),e.Decryptor=t,e),a.mode.OFB;var e,t}(le(),ze())}(fa)),fa.exports}var Sa,ro={exports:{}},ba,so={exports:{}},va,ao={exports:{}},ya,no={exports:{}},Ra,oo={exports:{}},Aa,co={exports:{}},_a,ho={exports:{}},wa,lo={exports:{}},Ea,Ia={exports:{}};function uo(){return Ea||(Ea=1,function(s){s.exports=function(a){return function(){var e=a,t=e.lib,i=t.WordArray,r=t.BlockCipher,n=e.algo,c=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],o=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],d=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],h=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],l=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],p=n.DES=r.extend({_doReset:function(){for(var b=this._key.words,S=[],v=0;v<56;v++){var _=c[v]-1;S[v]=b[_>>>5]>>>31-_%32&1}for(var w=this._subKeys=[],y=0;y<16;y++){var R=w[y]=[],A=d[y];for(v=0;v<24;v++)R[v/6|0]|=S[(o[v]-1+A)%28]<<31-v%6,R[4+(v/6|0)]|=S[28+(o[v+24]-1+A)%28]<<31-v%6;for(R[0]=R[0]<<1|R[0]>>>31,v=1;v<7;v++)R[v]=R[v]>>>4*(v-1)+3;R[7]=R[7]<<5|R[7]>>>27}var E=this._invSubKeys=[];for(v=0;v<16;v++)E[v]=w[15-v]},encryptBlock:function(b,S){this._doCryptBlock(b,S,this._subKeys)},decryptBlock:function(b,S){this._doCryptBlock(b,S,this._invSubKeys)},_doCryptBlock:function(b,S,v){this._lBlock=b[S],this._rBlock=b[S+1],u.call(this,4,252645135),u.call(this,16,65535),g.call(this,2,858993459),g.call(this,8,16711935),u.call(this,1,1431655765);for(var _=0;_<16;_++){for(var w=v[_],y=this._lBlock,R=this._rBlock,A=0,E=0;E<8;E++)A|=h[E][((R^w[E])&l[E])>>>0];this._lBlock=R,this._rBlock=y^A}var I=this._lBlock;this._lBlock=this._rBlock,this._rBlock=I,u.call(this,1,1431655765),g.call(this,8,16711935),g.call(this,2,858993459),u.call(this,16,65535),u.call(this,4,252645135),b[S]=this._lBlock,b[S+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function u(b,S){var v=(this._lBlock>>>b^this._rBlock)&S;this._rBlock^=v,this._lBlock^=v<<b}function g(b,S){var v=(this._rBlock>>>b^this._lBlock)&S;this._lBlock^=v,this._rBlock^=v<<b}e.DES=r._createHelper(p);var m=n.TripleDES=r.extend({_doReset:function(){var b=this._key.words;if(b.length!==2&&b.length!==4&&b.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var S=b.slice(0,2),v=b.length<4?b.slice(0,2):b.slice(2,4),_=b.length<6?b.slice(0,2):b.slice(4,6);this._des1=p.createEncryptor(i.create(S)),this._des2=p.createEncryptor(i.create(v)),this._des3=p.createEncryptor(i.create(_))},encryptBlock:function(b,S){this._des1.encryptBlock(b,S),this._des2.decryptBlock(b,S),this._des3.encryptBlock(b,S)},decryptBlock:function(b,S){this._des3.decryptBlock(b,S),this._des2.encryptBlock(b,S),this._des1.decryptBlock(b,S)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=r._createHelper(m)}(),a.TripleDES}(le(),zt(),Wt(),Dt(),ze())}(Ia)),Ia.exports}var Ta,po={exports:{}},Ca,mo={exports:{}},ka,go={exports:{}},Pa,Da={exports:{}};function fo(){return Pa||(Pa=1,function(s){s.exports=function(a){return function(){var e=a,t=e.lib.BlockCipher,i=e.algo;const r=16,n=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],c=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]];var o={pbox:[],sbox:[]};function d(g,m){let b=m>>24&255,S=m>>16&255,v=m>>8&255,_=255&m,w=g.sbox[0][b]+g.sbox[1][S];return w^=g.sbox[2][v],w+=g.sbox[3][_],w}function h(g,m,b){let S,v=m,_=b;for(let w=0;w<r;++w)v^=g.pbox[w],_=d(g,v)^_,S=v,v=_,_=S;return S=v,v=_,_=S,_^=g.pbox[r],v^=g.pbox[r+1],{left:v,right:_}}function l(g,m,b){let S,v=m,_=b;for(let w=r+1;w>1;--w)v^=g.pbox[w],_=d(g,v)^_,S=v,v=_,_=S;return S=v,v=_,_=S,_^=g.pbox[1],v^=g.pbox[0],{left:v,right:_}}function p(g,m,b){for(let y=0;y<4;y++){g.sbox[y]=[];for(let R=0;R<256;R++)g.sbox[y][R]=c[y][R]}let S=0;for(let y=0;y<r+2;y++)g.pbox[y]=n[y]^m[S],S++,S>=b&&(S=0);let v=0,_=0,w=0;for(let y=0;y<r+2;y+=2)w=h(g,v,_),v=w.left,_=w.right,g.pbox[y]=v,g.pbox[y+1]=_;for(let y=0;y<4;y++)for(let R=0;R<256;R+=2)w=h(g,v,_),v=w.left,_=w.right,g.sbox[y][R]=v,g.sbox[y][R+1]=_;return!0}var u=i.Blowfish=t.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var g=this._keyPriorReset=this._key,m=g.words,b=g.sigBytes/4;p(o,m,b)}},encryptBlock:function(g,m){var b=h(o,g[m],g[m+1]);g[m]=b.left,g[m+1]=b.right},decryptBlock:function(g,m){var b=l(o,g[m],g[m+1]);g[m]=b.left,g[m+1]=b.right},blockSize:2,keySize:4,ivSize:2});e.Blowfish=t._createHelper(u)}(),a.Blowfish}(le(),zt(),Wt(),Dt(),ze())}(Da)),Da.exports}(function(s){s.exports=function(a){return a}(le(),ki(),Kn(),$n(),zt(),Jn(),Wt(),Ks(),lr(),Gs||(Gs=1,function(a){a.exports=function(e){return i=(t=e).lib.WordArray,r=t.algo,n=r.SHA256,c=r.SHA224=n.extend({_doReset:function(){this._hash=new i.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var o=n._doFinalize.call(this);return o.sigBytes-=4,o}}),t.SHA224=n._createHelper(c),t.HmacSHA224=n._createHmacHelper(c),e.SHA224;var t,i,r,n,c}(le(),lr())}(Gn)),Ys(),Zs||(Zs=1,function(a){a.exports=function(e){return i=(t=e).x64,r=i.Word,n=i.WordArray,c=t.algo,o=c.SHA512,d=c.SHA384=o.extend({_doReset:function(){this._hash=new n.init([new r.init(3418070365,3238371032),new r.init(1654270250,914150663),new r.init(2438529370,812702999),new r.init(355462360,4144912697),new r.init(1731405415,4290775857),new r.init(2394180231,1750603025),new r.init(3675008525,1694076839),new r.init(1203062813,3204075428)])},_doFinalize:function(){var h=o._doFinalize.call(this);return h.sigBytes-=16,h}}),t.SHA384=o._createHelper(d),t.HmacSHA384=o._createHmacHelper(d),e.SHA384;var t,i,r,n,c,o,d}(le(),ki(),Ys())}(qn)),Xn(),ta||(ta=1,function(a){a.exports=function(e){return function(){var t=e,i=t.lib,r=i.WordArray,n=i.Hasher,c=t.algo,o=r.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),d=r.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),h=r.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),l=r.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),p=r.create([0,1518500249,1859775393,2400959708,2840853838]),u=r.create([1352829926,1548603684,1836072691,2053994217,0]),g=c.RIPEMD160=n.extend({_doReset:function(){this._hash=r.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(y,R){for(var A=0;A<16;A++){var E=R+A,I=y[E];y[E]=16711935&(I<<8|I>>>24)|4278255360&(I<<24|I>>>8)}var k,P,B,G,Y,J,z,Q,ee,pe,D,L=this._hash.words,N=p.words,x=u.words,ce=o.words,ke=d.words,$=h.words,ge=l.words;for(J=k=L[0],z=P=L[1],Q=B=L[2],ee=G=L[3],pe=Y=L[4],A=0;A<80;A+=1)D=k+y[R+ce[A]]|0,D+=A<16?m(P,B,G)+N[0]:A<32?b(P,B,G)+N[1]:A<48?S(P,B,G)+N[2]:A<64?v(P,B,G)+N[3]:_(P,B,G)+N[4],D=(D=w(D|=0,$[A]))+Y|0,k=Y,Y=G,G=w(B,10),B=P,P=D,D=J+y[R+ke[A]]|0,D+=A<16?_(z,Q,ee)+x[0]:A<32?v(z,Q,ee)+x[1]:A<48?S(z,Q,ee)+x[2]:A<64?b(z,Q,ee)+x[3]:m(z,Q,ee)+x[4],D=(D=w(D|=0,ge[A]))+pe|0,J=pe,pe=ee,ee=w(Q,10),Q=z,z=D;D=L[1]+B+ee|0,L[1]=L[2]+G+pe|0,L[2]=L[3]+Y+J|0,L[3]=L[4]+k+z|0,L[4]=L[0]+P+Q|0,L[0]=D},_doFinalize:function(){var y=this._data,R=y.words,A=8*this._nDataBytes,E=8*y.sigBytes;R[E>>>5]|=128<<24-E%32,R[14+(E+64>>>9<<4)]=16711935&(A<<8|A>>>24)|4278255360&(A<<24|A>>>8),y.sigBytes=4*(R.length+1),this._process();for(var I=this._hash,k=I.words,P=0;P<5;P++){var B=k[P];k[P]=16711935&(B<<8|B>>>24)|4278255360&(B<<24|B>>>8)}return I},clone:function(){var y=n.clone.call(this);return y._hash=this._hash.clone(),y}});function m(y,R,A){return y^R^A}function b(y,R,A){return y&R|~y&A}function S(y,R,A){return(y|~R)^A}function v(y,R,A){return y&A|R&~A}function _(y,R,A){return y^(R|~A)}function w(y,R){return y<<R|y>>>32-R}t.RIPEMD160=n._createHelper(g),t.HmacRIPEMD160=n._createHmacHelper(g)}(),e.RIPEMD160}(le())}(Yn)),ur(),sa||(sa=1,function(a){a.exports=function(e){return r=(i=(t=e).lib).Base,n=i.WordArray,o=(c=t.algo).SHA256,d=c.HMAC,h=c.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:o,iterations:25e4}),init:function(l){this.cfg=this.cfg.extend(l)},compute:function(l,p){for(var u=this.cfg,g=d.create(u.hasher,l),m=n.create(),b=n.create([1]),S=m.words,v=b.words,_=u.keySize,w=u.iterations;S.length<_;){var y=g.update(p).finalize(b);g.reset();for(var R=y.words,A=R.length,E=y,I=1;I<w;I++){E=g.finalize(E),g.reset();for(var k=E.words,P=0;P<A;P++)R[P]^=k[P]}m.concat(y),v[0]++}return m.sigBytes=4*_,m}}),t.PBKDF2=function(l,p,u){return h.create(u).compute(l,p)},e.PBKDF2;var t,i,r,n,c,o,d,h}(le(),lr(),ur())}(Zn)),Dt(),ze(),Qn(),eo(),to(),io(),Sa||(Sa=1,function(a){a.exports=function(e){return e.mode.ECB=((t=e.lib.BlockCipherMode.extend()).Encryptor=t.extend({processBlock:function(i,r){this._cipher.encryptBlock(i,r)}}),t.Decryptor=t.extend({processBlock:function(i,r){this._cipher.decryptBlock(i,r)}}),t),e.mode.ECB;var t}(le(),ze())}(ro)),ba||(ba=1,function(a){a.exports=function(e){return e.pad.AnsiX923={pad:function(t,i){var r=t.sigBytes,n=4*i,c=n-r%n,o=r+c-1;t.clamp(),t.words[o>>>2]|=c<<24-o%4*8,t.sigBytes+=c},unpad:function(t){var i=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=i}},e.pad.Ansix923}(le(),ze())}(so)),va||(va=1,function(a){a.exports=function(e){return e.pad.Iso10126={pad:function(t,i){var r=4*i,n=r-t.sigBytes%r;t.concat(e.lib.WordArray.random(n-1)).concat(e.lib.WordArray.create([n<<24],1))},unpad:function(t){var i=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=i}},e.pad.Iso10126}(le(),ze())}(ao)),ya||(ya=1,function(a){a.exports=function(e){return e.pad.Iso97971={pad:function(t,i){t.concat(e.lib.WordArray.create([2147483648],1)),e.pad.ZeroPadding.pad(t,i)},unpad:function(t){e.pad.ZeroPadding.unpad(t),t.sigBytes--}},e.pad.Iso97971}(le(),ze())}(no)),Ra||(Ra=1,function(a){a.exports=function(e){return e.pad.ZeroPadding={pad:function(t,i){var r=4*i;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){var i=t.words,r=t.sigBytes-1;for(r=t.sigBytes-1;r>=0;r--)if(i[r>>>2]>>>24-r%4*8&255){t.sigBytes=r+1;break}}},e.pad.ZeroPadding}(le(),ze())}(oo)),Aa||(Aa=1,function(a){a.exports=function(e){return e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding}(le(),ze())}(co)),_a||(_a=1,function(a){a.exports=function(e){return i=(t=e).lib.CipherParams,r=t.enc.Hex,t.format.Hex={stringify:function(n){return n.ciphertext.toString(r)},parse:function(n){var c=r.parse(n);return i.create({ciphertext:c})}},e.format.Hex;var t,i,r}(le(),ze())}(ho)),wa||(wa=1,function(a){a.exports=function(e){return function(){var t=e,i=t.lib.BlockCipher,r=t.algo,n=[],c=[],o=[],d=[],h=[],l=[],p=[],u=[],g=[],m=[];(function(){for(var v=[],_=0;_<256;_++)v[_]=_<128?_<<1:_<<1^283;var w=0,y=0;for(_=0;_<256;_++){var R=y^y<<1^y<<2^y<<3^y<<4;R=R>>>8^255&R^99,n[w]=R,c[R]=w;var A=v[w],E=v[A],I=v[E],k=257*v[R]^16843008*R;o[w]=k<<24|k>>>8,d[w]=k<<16|k>>>16,h[w]=k<<8|k>>>24,l[w]=k,k=16843009*I^65537*E^257*A^16843008*w,p[R]=k<<24|k>>>8,u[R]=k<<16|k>>>16,g[R]=k<<8|k>>>24,m[R]=k,w?(w=A^v[v[v[I^A]]],y^=v[v[y]]):w=y=1}})();var b=[0,1,2,4,8,16,32,64,128,27,54],S=r.AES=i.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var v=this._keyPriorReset=this._key,_=v.words,w=v.sigBytes/4,y=4*((this._nRounds=w+6)+1),R=this._keySchedule=[],A=0;A<y;A++)A<w?R[A]=_[A]:(k=R[A-1],A%w?w>6&&A%w==4&&(k=n[k>>>24]<<24|n[k>>>16&255]<<16|n[k>>>8&255]<<8|n[255&k]):(k=n[(k=k<<8|k>>>24)>>>24]<<24|n[k>>>16&255]<<16|n[k>>>8&255]<<8|n[255&k],k^=b[A/w|0]<<24),R[A]=R[A-w]^k);for(var E=this._invKeySchedule=[],I=0;I<y;I++){if(A=y-I,I%4)var k=R[A];else k=R[A-4];E[I]=I<4||A<=4?k:p[n[k>>>24]]^u[n[k>>>16&255]]^g[n[k>>>8&255]]^m[n[255&k]]}}},encryptBlock:function(v,_){this._doCryptBlock(v,_,this._keySchedule,o,d,h,l,n)},decryptBlock:function(v,_){var w=v[_+1];v[_+1]=v[_+3],v[_+3]=w,this._doCryptBlock(v,_,this._invKeySchedule,p,u,g,m,c),w=v[_+1],v[_+1]=v[_+3],v[_+3]=w},_doCryptBlock:function(v,_,w,y,R,A,E,I){for(var k=this._nRounds,P=v[_]^w[0],B=v[_+1]^w[1],G=v[_+2]^w[2],Y=v[_+3]^w[3],J=4,z=1;z<k;z++){var Q=y[P>>>24]^R[B>>>16&255]^A[G>>>8&255]^E[255&Y]^w[J++],ee=y[B>>>24]^R[G>>>16&255]^A[Y>>>8&255]^E[255&P]^w[J++],pe=y[G>>>24]^R[Y>>>16&255]^A[P>>>8&255]^E[255&B]^w[J++],D=y[Y>>>24]^R[P>>>16&255]^A[B>>>8&255]^E[255&G]^w[J++];P=Q,B=ee,G=pe,Y=D}Q=(I[P>>>24]<<24|I[B>>>16&255]<<16|I[G>>>8&255]<<8|I[255&Y])^w[J++],ee=(I[B>>>24]<<24|I[G>>>16&255]<<16|I[Y>>>8&255]<<8|I[255&P])^w[J++],pe=(I[G>>>24]<<24|I[Y>>>16&255]<<16|I[P>>>8&255]<<8|I[255&B])^w[J++],D=(I[Y>>>24]<<24|I[P>>>16&255]<<16|I[B>>>8&255]<<8|I[255&G])^w[J++],v[_]=Q,v[_+1]=ee,v[_+2]=pe,v[_+3]=D},keySize:8});t.AES=i._createHelper(S)}(),e.AES}(le(),zt(),Wt(),Dt(),ze())}(lo)),uo(),Ta||(Ta=1,function(a){a.exports=function(e){return function(){var t=e,i=t.lib.StreamCipher,r=t.algo,n=r.RC4=i.extend({_doReset:function(){for(var d=this._key,h=d.words,l=d.sigBytes,p=this._S=[],u=0;u<256;u++)p[u]=u;u=0;for(var g=0;u<256;u++){var m=u%l,b=h[m>>>2]>>>24-m%4*8&255;g=(g+p[u]+b)%256;var S=p[u];p[u]=p[g],p[g]=S}this._i=this._j=0},_doProcessBlock:function(d,h){d[h]^=c.call(this)},keySize:8,ivSize:0});function c(){for(var d=this._S,h=this._i,l=this._j,p=0,u=0;u<4;u++){l=(l+d[h=(h+1)%256])%256;var g=d[h];d[h]=d[l],d[l]=g,p|=d[(d[h]+d[l])%256]<<24-8*u}return this._i=h,this._j=l,p}t.RC4=i._createHelper(n);var o=r.RC4Drop=n.extend({cfg:n.cfg.extend({drop:192}),_doReset:function(){n._doReset.call(this);for(var d=this.cfg.drop;d>0;d--)c.call(this)}});t.RC4Drop=i._createHelper(o)}(),e.RC4}(le(),zt(),Wt(),Dt(),ze())}(po)),Ca||(Ca=1,function(a){a.exports=function(e){return function(){var t=e,i=t.lib.StreamCipher,r=t.algo,n=[],c=[],o=[],d=r.Rabbit=i.extend({_doReset:function(){for(var l=this._key.words,p=this.cfg.iv,u=0;u<4;u++)l[u]=16711935&(l[u]<<8|l[u]>>>24)|4278255360&(l[u]<<24|l[u]>>>8);var g=this._X=[l[0],l[3]<<16|l[2]>>>16,l[1],l[0]<<16|l[3]>>>16,l[2],l[1]<<16|l[0]>>>16,l[3],l[2]<<16|l[1]>>>16],m=this._C=[l[2]<<16|l[2]>>>16,4294901760&l[0]|65535&l[1],l[3]<<16|l[3]>>>16,4294901760&l[1]|65535&l[2],l[0]<<16|l[0]>>>16,4294901760&l[2]|65535&l[3],l[1]<<16|l[1]>>>16,4294901760&l[3]|65535&l[0]];for(this._b=0,u=0;u<4;u++)h.call(this);for(u=0;u<8;u++)m[u]^=g[u+4&7];if(p){var b=p.words,S=b[0],v=b[1],_=16711935&(S<<8|S>>>24)|4278255360&(S<<24|S>>>8),w=16711935&(v<<8|v>>>24)|4278255360&(v<<24|v>>>8),y=_>>>16|4294901760&w,R=w<<16|65535&_;for(m[0]^=_,m[1]^=y,m[2]^=w,m[3]^=R,m[4]^=_,m[5]^=y,m[6]^=w,m[7]^=R,u=0;u<4;u++)h.call(this)}},_doProcessBlock:function(l,p){var u=this._X;h.call(this),n[0]=u[0]^u[5]>>>16^u[3]<<16,n[1]=u[2]^u[7]>>>16^u[5]<<16,n[2]=u[4]^u[1]>>>16^u[7]<<16,n[3]=u[6]^u[3]>>>16^u[1]<<16;for(var g=0;g<4;g++)n[g]=16711935&(n[g]<<8|n[g]>>>24)|4278255360&(n[g]<<24|n[g]>>>8),l[p+g]^=n[g]},blockSize:4,ivSize:2});function h(){for(var l=this._X,p=this._C,u=0;u<8;u++)c[u]=p[u];for(p[0]=p[0]+1295307597+this._b|0,p[1]=p[1]+3545052371+(p[0]>>>0<c[0]>>>0?1:0)|0,p[2]=p[2]+886263092+(p[1]>>>0<c[1]>>>0?1:0)|0,p[3]=p[3]+1295307597+(p[2]>>>0<c[2]>>>0?1:0)|0,p[4]=p[4]+3545052371+(p[3]>>>0<c[3]>>>0?1:0)|0,p[5]=p[5]+886263092+(p[4]>>>0<c[4]>>>0?1:0)|0,p[6]=p[6]+1295307597+(p[5]>>>0<c[5]>>>0?1:0)|0,p[7]=p[7]+3545052371+(p[6]>>>0<c[6]>>>0?1:0)|0,this._b=p[7]>>>0<c[7]>>>0?1:0,u=0;u<8;u++){var g=l[u]+p[u],m=65535&g,b=g>>>16,S=((m*m>>>17)+m*b>>>15)+b*b,v=((4294901760&g)*g|0)+((65535&g)*g|0);o[u]=S^v}l[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,l[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,l[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,l[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,l[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,l[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,l[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,l[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}t.Rabbit=i._createHelper(d)}(),e.Rabbit}(le(),zt(),Wt(),Dt(),ze())}(mo)),ka||(ka=1,function(a){a.exports=function(e){return function(){var t=e,i=t.lib.StreamCipher,r=t.algo,n=[],c=[],o=[],d=r.RabbitLegacy=i.extend({_doReset:function(){var l=this._key.words,p=this.cfg.iv,u=this._X=[l[0],l[3]<<16|l[2]>>>16,l[1],l[0]<<16|l[3]>>>16,l[2],l[1]<<16|l[0]>>>16,l[3],l[2]<<16|l[1]>>>16],g=this._C=[l[2]<<16|l[2]>>>16,4294901760&l[0]|65535&l[1],l[3]<<16|l[3]>>>16,4294901760&l[1]|65535&l[2],l[0]<<16|l[0]>>>16,4294901760&l[2]|65535&l[3],l[1]<<16|l[1]>>>16,4294901760&l[3]|65535&l[0]];this._b=0;for(var m=0;m<4;m++)h.call(this);for(m=0;m<8;m++)g[m]^=u[m+4&7];if(p){var b=p.words,S=b[0],v=b[1],_=16711935&(S<<8|S>>>24)|4278255360&(S<<24|S>>>8),w=16711935&(v<<8|v>>>24)|4278255360&(v<<24|v>>>8),y=_>>>16|4294901760&w,R=w<<16|65535&_;for(g[0]^=_,g[1]^=y,g[2]^=w,g[3]^=R,g[4]^=_,g[5]^=y,g[6]^=w,g[7]^=R,m=0;m<4;m++)h.call(this)}},_doProcessBlock:function(l,p){var u=this._X;h.call(this),n[0]=u[0]^u[5]>>>16^u[3]<<16,n[1]=u[2]^u[7]>>>16^u[5]<<16,n[2]=u[4]^u[1]>>>16^u[7]<<16,n[3]=u[6]^u[3]>>>16^u[1]<<16;for(var g=0;g<4;g++)n[g]=16711935&(n[g]<<8|n[g]>>>24)|4278255360&(n[g]<<24|n[g]>>>8),l[p+g]^=n[g]},blockSize:4,ivSize:2});function h(){for(var l=this._X,p=this._C,u=0;u<8;u++)c[u]=p[u];for(p[0]=p[0]+1295307597+this._b|0,p[1]=p[1]+3545052371+(p[0]>>>0<c[0]>>>0?1:0)|0,p[2]=p[2]+886263092+(p[1]>>>0<c[1]>>>0?1:0)|0,p[3]=p[3]+1295307597+(p[2]>>>0<c[2]>>>0?1:0)|0,p[4]=p[4]+3545052371+(p[3]>>>0<c[3]>>>0?1:0)|0,p[5]=p[5]+886263092+(p[4]>>>0<c[4]>>>0?1:0)|0,p[6]=p[6]+1295307597+(p[5]>>>0<c[5]>>>0?1:0)|0,p[7]=p[7]+3545052371+(p[6]>>>0<c[6]>>>0?1:0)|0,this._b=p[7]>>>0<c[7]>>>0?1:0,u=0;u<8;u++){var g=l[u]+p[u],m=65535&g,b=g>>>16,S=((m*m>>>17)+m*b>>>15)+b*b,v=((4294901760&g)*g|0)+((65535&g)*g|0);o[u]=S^v}l[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,l[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,l[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,l[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,l[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,l[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,l[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,l[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}t.RabbitLegacy=i._createHelper(d)}(),e.RabbitLegacy}(le(),zt(),Wt(),Dt(),ze())}(go)),fo())})(Cs);const di=jn(Cs.exports);function So(s){return a=this,e=null,t=function*(){const i=new Date;if(s.refreshSTSTokenInterval||(s.refreshSTSTokenInterval=3e5),!s.stsTokenFreshTime||+i-s.stsTokenFreshTime>=s.refreshSTSTokenInterval){s.stsTokenFreshTime=i;try{yield s.refreshSTSToken()}catch(r){typeof console.error=="function"&&console.error(`Some error occured during excuting refreshSTSToken, see:
9
9
  `+r)}}return null},new Promise((i,r)=>{var n=d=>{try{o(t.next(d))}catch(h){r(h)}},c=d=>{try{o(t.throw(d))}catch(h){r(h)}},o=d=>d.done?i(d.value):Promise.resolve(d.value).then(n,c);o((t=t.apply(a,e)).next())});var a,e,t}function pr(s){return{transString:function(a){let e={},t=0,i=!1;for(let r in a)r!=="time"&&r!=="__time__"||typeof a[r]!="number"?typeof a[r]=="object"?e[r]=JSON.stringify(a[r]):e[r]=String(a[r]):(t=a[r],i=!0);return e.__time__=i?t:Math.floor(new Date().getTime()/1e3),e},process:function(a,e){return t=this,i=null,r=function*(){yield So(s);let n=a.slice(a.indexOf("/logstores")),c=e.length,o=(d=e,di.MD5(d).toString().toUpperCase());var d;let h=new Date().toUTCString(),l=new Map,p=new Map([["Content-Type","application/json"],["Content-MD5",o],["x-log-bodyrawsize",c.toString()]]);s.securityToken&&p.set("x-acs-security-token",s.securityToken),function(g,m,b,S,v,_,w,y){var R;let A="";_.set("x-log-apiversion","0.6.0"),_.set("x-log-signaturemethod","hmac-sha1"),A+=g+`
@@ -11,7 +11,7 @@
11
11
  `+((R=_.get("Content-Type"))!=null?R:"")+`
12
12
  `+y+`
13
13
  `;const E=(P,B)=>P[0].localeCompare(B[0]),I=P=>P[0].startsWith("x-log-")||P[0].startsWith("x-acs-");try{const P=[..._.entries()].filter(I).sort(E).map(B=>B[0]+":"+B[1]+`
14
- `).join("");A+=P}catch(P){}A+=m,v.size>0&&(A+="?");try{A+=[...v.entries()].sort(E).map(P=>P[0]+"="+P[1]).join("&")}catch(P){}const k="LOG "+b+":"+di.HmacSHA1(A,S).toString(di.enc.Base64);_.set("Authorization",k),_.set("x-log-date",y)}("POST",n,s.accessKeyId,s.accessKeySecret,l,p,o,h);let u=Object.fromEntries(p);return{data:e,header:u}},new Promise((n,c)=>{var o=l=>{try{h(r.next(l))}catch(p){c(p)}},d=l=>{try{h(r.throw(l))}catch(p){c(p)}},h=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,d);h((r=r.apply(t,i)).next())});var t,i,r}}}typeof window!="undefined"&&Is(window,"stsPlugin",pr);var bo=/d{1,4}|D{3,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|W{1,2}|[LlopSZN]|"[^"]*"|'[^']*'/g,vo=/\b(?:[A-Z]{1,3}[A-Z][TC])(?:[-+]\d{4})?|((?:Australian )?(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time)\b/g,yo=/[^-+\dA-Z]/g;function mr(s,a,e,t){if(arguments.length!==1||typeof s!="string"||/\d/.test(s)||(a=s,s=void 0),(s=s||s===0?s:new Date)instanceof Date||(s=new Date(s)),isNaN(s))throw TypeError("Invalid date");var i=(a=String(Ma[a]||a||Ma.default)).slice(0,4);i!=="UTC:"&&i!=="GMT:"||(a=a.slice(4),e=!0,i==="GMT:"&&(t=!0));var r=function(){return e?"getUTC":"get"},n=function(){return s[r()+"Date"]()},c=function(){return s[r()+"Day"]()},o=function(){return s[r()+"Month"]()},d=function(){return s[r()+"FullYear"]()},h=function(){return s[r()+"Hours"]()},l=function(){return s[r()+"Minutes"]()},p=function(){return s[r()+"Seconds"]()},u=function(){return s[r()+"Milliseconds"]()},g=function(){return e?0:s.getTimezoneOffset()},m=function(){return Ro(s)},b={d:function(){return n()},dd:function(){return nt(n())},ddd:function(){return tt.dayNames[c()]},DDD:function(){return Na({y:d(),m:o(),d:n(),_:r(),dayName:tt.dayNames[c()],short:!0})},dddd:function(){return tt.dayNames[c()+7]},DDDD:function(){return Na({y:d(),m:o(),d:n(),_:r(),dayName:tt.dayNames[c()+7]})},m:function(){return o()+1},mm:function(){return nt(o()+1)},mmm:function(){return tt.monthNames[o()]},mmmm:function(){return tt.monthNames[o()+12]},yy:function(){return String(d()).slice(2)},yyyy:function(){return nt(d(),4)},h:function(){return h()%12||12},hh:function(){return nt(h()%12||12)},H:function(){return h()},HH:function(){return nt(h())},M:function(){return l()},MM:function(){return nt(l())},s:function(){return p()},ss:function(){return nt(p())},l:function(){return nt(u(),3)},L:function(){return nt(Math.floor(u()/10))},t:function(){return h()<12?tt.timeNames[0]:tt.timeNames[1]},tt:function(){return h()<12?tt.timeNames[2]:tt.timeNames[3]},T:function(){return h()<12?tt.timeNames[4]:tt.timeNames[5]},TT:function(){return h()<12?tt.timeNames[6]:tt.timeNames[7]},Z:function(){return t?"GMT":e?"UTC":_o(s)},o:function(){return(g()>0?"-":"+")+nt(100*Math.floor(Math.abs(g())/60)+Math.abs(g())%60,4)},p:function(){return(g()>0?"-":"+")+nt(Math.floor(Math.abs(g())/60),2)+":"+nt(Math.floor(Math.abs(g())%60),2)},S:function(){return["th","st","nd","rd"][n()%10>3?0:(n()%100-n()%10!=10)*n()%10]},W:function(){return m()},WW:function(){return nt(m())},N:function(){return Ao(s)}};return a.replace(bo,function(S){return S in b?b[S]():S.slice(1,S.length-1)})}var Ma={default:"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",paddedShortDate:"mm/dd/yyyy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:sso",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'",expiresHeaderFormat:"ddd, dd mmm yyyy HH:MM:ss Z"},tt={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"],timeNames:["a","p","am","pm","A","P","AM","PM"]},nt=function(s){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;return String(s).padStart(a,"0")},Na=function(s){var a=s.y,e=s.m,t=s.d,i=s._,r=s.dayName,n=s.short,c=n!==void 0&&n,o=new Date,d=new Date;d.setDate(d[i+"Date"]()-1);var h=new Date;return h.setDate(h[i+"Date"]()+1),o[i+"FullYear"]()===a&&o[i+"Month"]()===e&&o[i+"Date"]()===t?c?"Tdy":"Today":d[i+"FullYear"]()===a&&d[i+"Month"]()===e&&d[i+"Date"]()===t?c?"Ysd":"Yesterday":h[i+"FullYear"]()===a&&h[i+"Month"]()===e&&h[i+"Date"]()===t?c?"Tmw":"Tomorrow":r},Ro=function(s){var a=new Date(s.getFullYear(),s.getMonth(),s.getDate());a.setDate(a.getDate()-(a.getDay()+6)%7+3);var e=new Date(a.getFullYear(),0,4);e.setDate(e.getDate()-(e.getDay()+6)%7+3);var t=a.getTimezoneOffset()-e.getTimezoneOffset();a.setHours(a.getHours()-t);var i=(a-e)/6048e5;return 1+Math.floor(i)},Ao=function(s){var a=s.getDay();return a===0&&(a=7),a},_o=function(s){return(String(s).match(vo)||[""]).pop().replace(yo,"").replace(/GMT\+0000/g,"UTC")};const{BrowserUtil:wo}=q.AliRTS,Eo="EdgeHTML",La="Blink",Io="Trident",To="Gecko",Co="WebKit",Pi=(s,a)=>{const e=a.match(s);return e&&e.length>0&&e[1]||""},ko=[{test:[/\sedg\//i,[/edg([ea]|ios)/i]],describe(s){if(/\sedg\//i.test(s))return{name:La};const a=Pi(/edge\/(\d+(\.?_?\d+)+)/i,s);return{name:Eo,version:a}}},{test:[/trident/i],describe(s){const a={name:Io},e=Pi(/trident\/(\d+(\.?_?\d+)+)/i,s);return e&&(a.version=e),a}},{test(s){const a=/gecko/i.test(s),e=/like gecko/i.test(s);return a&&!e},describe(s){const a={name:To},e=Pi(/gecko\/(\d+(\.?_?\d+)+)/i,s);return e&&(a.version=e),a}},{test:[/(apple)?webkit\/537\.36/i],describe:()=>({name:La})},{test:[/(apple)?webkit/i],describe(s){const a={name:Co},e=Pi(/webkit\/(\d+(\.?_?\d+)+)/i,s);return e&&(a.version=e),a}}],gr=(s,a)=>s.find(e=>typeof e.test=="function"?e.test(a):Array.isArray(e.test)?e.test.some(t=>typeof t=="string"?a.indexOf(t)>-1:t instanceof RegExp&&t.test(a)):void 0),Po=()=>{try{const s=navigator.userAgent||"",a=gr(ko,s);if(a){const e=a.describe(s);return`${e.name}/${e.version||wo.browserVersion}`}}catch(s){}return navigator.userAgent},Do=[{test:["wow64","win64","x64"],describe:()=>"amd64"},{test:["i686","x86"],describe:()=>"x86"},{test:["aarch64","arm64"],describe:()=>"arm64"},{test:["arm"],describe:()=>"arm"}],xa=()=>{let s="unknown";try{const a=navigator.userAgent||"",e=gr(Do,a);if(!e)return s;s=e.describe(a)}catch(a){}return s},Mo=[{test:[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],describe:()=>"Samsung"},{test:[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i,/\((ipad);[-\w\),; ]+apple/i,/(macintosh);/i],describe:()=>"Apple"},{test:[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],describe:()=>"Huawei"},{test:[/(?:honor)([-\w ]+)[;\)]/i],describe:()=>"Honor"},{test:[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],describe:()=>"Xiaomi"},{test:[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],describe:()=>"Oppo"},{test:[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],describe:()=>"Vivo"},{test:[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],describe:()=>"Realme"},{test:[/(pixel c)\b/i,/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],describe:()=>"Google"},{test:[/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],describe:()=>"ZTE"},{test:[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],describe:()=>"Meizu"}],No=()=>{let s="Unknown";try{const a=navigator.userAgent||"",e=gr(Mo,a);if(!e)return s;s=e.describe(a)}catch(a){}return s},{BrowserUtil:Va,SystenUtil:Oa}=q.AliRTS,Lo=xa(),Di=6e5,Mi={host:"cn-hangzhou.log.aliyuncs.com",project:"alivc-aio",logstore:"logger",time:10,count:10};function fr(){return mr(new Date,"HH:MM:ss.l")}function Ua(){return mr(new Date,"isoDate")}var Sr=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.API=2]="API",s[s.WARNING=3]="WARNING",s[s.ERROR=4]="ERROR",s[s.NONE=5]="NONE",s))(Sr||{});class xo{constructor(){f(this,"tracker");f(this,"slsPlugin");f(this,"stsData");f(this,"stsExpiration",Date.now());f(this,"clientId",dt());f(this,"bSesid",dt());f(this,"logLevel",3);f(this,"appId","");f(this,"sessionId","");f(this,"logCache",[]);f(this,"updateTaskTimer");f(this,"endReported",!0);f(this,"logSequence",0);f(this,"sendLogBeforeUnload",a=>T(this,null,function*(){if(!this.slsPlugin)return;this.logSequence+=1,a.unshift(this.getLogParams(710203,{log:`[${Ua()} ${fr()}] [INF] beforeunload`,stat_log_seq:this.logSequence}));const e=`https://${Mi.project}.${Mi.host}/logstores/${Mi.logstore}`,t={__logs__:a.map(n=>this.slsPlugin.transString(n))},{data:i,header:r}=yield this.slsPlugin.process(e,JSON.stringify(t));fetch(e,{keepalive:!0,method:"POST",headers:r,body:i})}));f(this,"logMethod",(a,e=console.log)=>(...t)=>{let i=fr();this.logLevel<=a&&e(i,...t);let r=et.paramArrayToString(t);a>0&&this.addLog(r)});f(this,"d",this.logMethod(0,console.debug));f(this,"i",this.logMethod(1));f(this,"w",this.logMethod(3,console.warn));f(this,"e",this.logMethod(4,(...a)=>{const[e,...t]=a;console.error(e,"<error>",t)}));f(this,"ev",this.logMethod(2));f(this,"a",this.logMethod(2,(...a)=>{const[e,...t]=a;if(t.length>2){const i=`${t[1]}`;i.startsWith("__g__")&&console.group(`${i.substring(5)}_${t[2]}`)}console.log(e,...t)}));f(this,"ar",this.logMethod(2,(...a)=>{const[e,...t]=a;console.log(e,...t),t.length>2&&`${t[1]}`.startsWith("__g__")&&console.groupEnd()}));f(this,"ae",this.logMethod(2,(...a)=>{const[e,...t]=a;console.error(e,"<error>",...t),t.length>2&&`${t[1]}`.startsWith("__g__")&&console.groupEnd()}));window.addEventListener("beforeunload",()=>{this.reportEnd(!0)})}init(){this.reset(),this.startSTSUpdateTask()}destroy(){this.updateTaskTimer&&clearTimeout(this.updateTaskTimer)}reset(){this.bSesid=dt(),this.endReported=!0,this.logSequence=0,this.appId="",this.sessionId=""}startSTSUpdateTask(){return T(this,null,function*(){this.updateTaskTimer&&clearTimeout(this.updateTaskTimer);try{const a=yield this.refreshSTSToken();this.createTracker(a)}catch(a){}this.updateTaskTimer=setTimeout(()=>{this.startSTSUpdateTask()},Di)})}refreshSTSToken(){return T(this,null,function*(){if(!this.stsData||this.stsExpiration<=Date.now()-Di){const a=yield this.requestSTSToken(),e=new Date(a==null?void 0:a.Expiration).getTime()||0,t=Date.now()+Di;this.stsExpiration=Math.max(e,t),this.stsData=a}return this.stsData})}requestSTSToken(){const a=Date.now(),e=`${this.clientId}|woMMssV6jmyol9fr|${a}`,t={Action:"AssumeSlsRoleV2",AuthInfo:di.MD5(e).toString(di.enc.Hex),ClientId:this.clientId,BusinessType:"logger",AppVersion:"1.0",Version:"2017-03-14",AuthTimestamp:`${a}`,TerminalType:"web",DeviceModel:"",Format:"JSON",SignatureMethod:"HMAC-SHA1",SignatureVersion:"1.0",Timestamp:mr(a,"isoUtcDateTime")},i=new URLSearchParams(t).toString();return fetch(`https://slsrole.alicdn.com/?${i}`).then(r=>r.json()).then(r=>JSON.parse(window.atob(r.SlsAuthResult)))}createTracker(a){if(!this.tracker){const e={accessKeyId:a.AccessKeyId,accessKeySecret:a.AccessKeySecret,securityToken:a.SecurityToken,refreshSTSTokenInterval:Di,stsTokenFreshTime:void 0,refreshSTSToken:()=>{this.refreshSTSToken().then(r=>{e.accessKeyId=r.AccessKeyId,e.accessKeySecret=r.AccessKeySecret,e.securityToken=r.SecurityToken}).catch(()=>{})}},t=new hr(Mi),i=pr(e);t.useStsPlugin(i),this.slsPlugin=i,this.tracker=t,this.reportStartAndCache()}}changeConfig(a){a.logLevel!==void 0&&a.logLevel>=0&&a.logLevel<=5&&(this.logLevel=a.logLevel)}setSessionID(a,e){a&&e&&(this.appId=a,this.sessionId=e,this.reportStartAndCache())}reportStartAndCache(){if(!this.tracker||!this.sessionId)return;this.endReported=!1;const a={task_btm_sec:0,task_duration:0,task_etm_sec:0,task_type:"session"},e=[this.getLogParams(710201,a),this.getLogParams(710202,a)];this.tracker.sendBatchLogsImmediate(e),this.logCache.forEach(t=>{this.sendLog(t)})}reportEnd(a=!1){if(!this.tracker||!this.sessionId||this.endReported)return void this.reset();const e={task_btm_sec:0,task_duration:0,task_etm_sec:0,task_type:"session"},t=[this.getLogParams(710204,e),this.getLogParams(710205,e)];a?this.sendLogBeforeUnload(t):(this.tracker.sendBatchLogsImmediate(t),this.endReported=!0),this.reset()}getLogParams(a,e){return X({appid:`${window.location.host}`,appid_list:this.appId,appver:"",b_sesid:this.bSesid,biz_type:"rtc",cpu_info:Lo,db:Va.browserName,dm:Va.browserVersion,install_uuid:this.clientId,logger_v:"0.0.1",os:Oa.systemName,osv:Oa.systemVersion,p_sesid:this.bSesid,sdk_version:Ti,sdkname:"AliRTCSdk",stm:Date.now(),tar_pf:"web",traceid:this.sessionId,event_id:a},e||{})}sendLog(a){if(!this.tracker||!this.sessionId)return;this.logSequence+=1;const e=this.getLogParams(710203,{log:a,stat_log_seq:this.logSequence});this.tracker.send(e)}addLog(a){const e=fr(),t=`[${Ua()} ${e}] ${a}`;this.sessionId&&this.tracker?this.sendLog(t):(this.logCache.push(t),this.logCache.length>=200&&this.logCache.shift())}}class V{static getLogger(){return this.logger||(this.logger=new xo),this.logger}static init(){this.getLogger().init()}static destroy(){this.getLogger().destroy()}static setLogLevel(a){this.getLogger().changeConfig({logLevel:a})}static setSessionID(a,e){this.getLogger().setSessionID(a,e)}static reportEnd(){this.getLogger().reportEnd()}static interface(...a){this.getLogger().a("[API]",...a)}static interfaceResult(a,e,t,...i){t?this.getLogger().ar("[ARE]",a,e,...i):this.getLogger().ae("[ARE]",a,e,...i)}static event(...a){this.getLogger().ev("[EVT]",...a)}static debug(...a){this.getLogger().d("[DBG]",...a)}static info(...a){this.getLogger().i("[INF]",...a)}static warn(...a){this.getLogger().w("[WARN]",...a)}static error(...a){this.getLogger().e("[ERR]",...a)}}f(V,"logger");const Vo=s=>T(this,null,function*(){const a=new q.AliRTS.SupportUtil;let e={support:!1,detail:{isWebRTCSupported:a.checkMediaDevices()&&a.checkWebRtcSupport(),isH264DecodeSupported:!1,isH264EncodeSupported:!1,isScreenShareSupported:!1,isSendMediaExtensionMsgSupported:!1,isBrowserSupported:!0}},t=!1;try{yield a.isSupport({isReceiveVideo:!0}),t=!0}catch(i){t=!1,e.detail.isBrowserSupported=a.checkBrowser({errorCode:0,message:""})}if(e.support=t,a.checkWebRtcSupport()&&s!=="sendonly"){const i=yield a.checkH264Decode();e.detail.isH264DecodeSupported=i,e.support=e.support&&i}if(a.checkWebRtcSupport()&&s!=="recvonly"){const i=yield a.checkH264Encode();e.detail.isH264EncodeSupported=i,e.support=e.support&&i}return e.detail.isScreenShareSupported=a.checkWebRtcSupport()&&a.checkScreenCapture()&&!q.AliRTS.SystenUtil.isAndroid&&!q.AliRTS.SystenUtil.isIos,e.detail.isSendMediaExtensionMsgSupported=a.checkWebRtcSupport()&&a.checkEncodedTransformSupport(),e});var Ne=(s=>(s[s.AliRtcSdkStreamTypeCapture=0]="AliRtcSdkStreamTypeCapture",s[s.AliRtcSdkStreamTypeScreen=1]="AliRtcSdkStreamTypeScreen",s))(Ne||{}),Ba=(s=>(s[s.PRE_PROCESSOR=0]="PRE_PROCESSOR",s[s.POST_PROCESSOR=1]="POST_PROCESSOR",s))(Ba||{}),ti=(s=>(s[s.AUDIO=0]="AUDIO",s[s.VIDEO=1]="VIDEO",s[s.BOTH=2]="BOTH",s))(ti||{});class Mt extends se{constructor(e,t=Ne.AliRtcSdkStreamTypeCapture,i=1){super();f(this,"name");f(this,"options");f(this,"type",0);f(this,"streamType");f(this,"trackType");f(this,"zIndex",1);f(this,"_isEnable",!0);f(this,"lastInputAudioTrack");f(this,"lastOutputAudioTrack");f(this,"lastInputVideoTrack");f(this,"lastOutputVideoTrack");f(this,"_hasCleared",!0);this.name=e,this.streamType=t,this.trackType=i,this.options=this.initOptions}get initOptions(){return{}}getOptions(){return this.options}init(){return T(this,null,function*(){})}enable(){this._isEnable||(this._isEnable=!0,this.init(),this.emit("enabled"))}disable(){this._isEnable&&(this._isEnable=!1,this.clear(),this.emit("disabled"))}get isEnable(){return this._isEnable}audioUpdated(e){var t,i;return((t=this.lastInputAudioTrack)==null?void 0:t.id)!==((i=e.currentAudioTrack)==null?void 0:i.id)}videoUpdated(e){var t,i;return((t=this.lastInputVideoTrack)==null?void 0:t.id)!==((i=e.currentVideoTrack)==null?void 0:i.id)}execute(e,t){return T(this,null,function*(){const i=this.shouldUpdate(e,t);this.lastInputAudioTrack=e.currentAudioTrack,this.lastInputVideoTrack=e.currentVideoTrack,this._hasCleared||i?(yield this.process(e,t),this._hasCleared=!1):(!this.lastOutputAudioTrack||this.trackType!==2&&this.trackType!==0||this.lastOutputAudioTrack&&e.updateAudioTrack(this.lastOutputAudioTrack),!this.lastOutputVideoTrack||this.trackType!==2&&this.trackType!==1||this.lastOutputVideoTrack&&e.updateVideoTrack(this.lastOutputVideoTrack)),this.lastOutputAudioTrack=e.currentAudioTrack,this.lastOutputVideoTrack=e.currentVideoTrack})}clear(e){this._hasCleared=!0,this.lastInputAudioTrack=void 0,this.lastInputVideoTrack=void 0,this.lastOutputAudioTrack=void 0,this.lastOutputVideoTrack=void 0}}var hi=(s=>(s[s.LiveTranscodingSingle=0]="LiveTranscodingSingle",s[s.LiveTranscodingMix=1]="LiveTranscodingMix",s))(hi||{}),br=(s=>(s[s.LiveTranscodingOrigin=0]="LiveTranscodingOrigin",s[s.LiveTranscodingAudio=1]="LiveTranscodingAudio",s[s.LiveTranscodingVideo=2]="LiveTranscodingVideo",s))(br||{}),ii=(s=>(s[s.LiveTranscodingCamera=0]="LiveTranscodingCamera",s[s.LiveTranscodingShareScreen=1]="LiveTranscodingShareScreen",s))(ii||{});const li={0:"camera",1:"shareScreen"};var vr=(s=>(s[s.LiveTranscoding_Profile_1IN_1080P=0]="LiveTranscoding_Profile_1IN_1080P",s[s.LiveTranscoding_Profile_1IN_720P=1]="LiveTranscoding_Profile_1IN_720P",s[s.LiveTranscoding_Profile_1IN_360P=2]="LiveTranscoding_Profile_1IN_360P",s[s.LiveTranscoding_Profile_2IN_1080P=3]="LiveTranscoding_Profile_2IN_1080P",s[s.LiveTranscoding_Profile_2IN_720P=4]="LiveTranscoding_Profile_2IN_720P",s[s.LiveTranscoding_Profile_2IN_360P=5]="LiveTranscoding_Profile_2IN_360P",s[s.LiveTranscoding_Profile_4IN_1080P=6]="LiveTranscoding_Profile_4IN_1080P",s[s.LiveTranscoding_Profile_4IN_720P=7]="LiveTranscoding_Profile_4IN_720P",s[s.LiveTranscoding_Profile_4IN_360P=8]="LiveTranscoding_Profile_4IN_360P",s[s.LiveTranscoding_Profile_9IN_1080P=9]="LiveTranscoding_Profile_9IN_1080P",s[s.LiveTranscoding_Profile_9IN_720P=10]="LiveTranscoding_Profile_9IN_720P",s[s.LiveTranscoding_Profile_9IN_360P=11]="LiveTranscoding_Profile_9IN_360P",s[s.LiveTranscoding_Profile_12IN_1080P=12]="LiveTranscoding_Profile_12IN_1080P",s[s.LiveTranscoding_Profile_12IN_720P=13]="LiveTranscoding_Profile_12IN_720P",s[s.LiveTranscoding_Profile_12IN_360P=14]="LiveTranscoding_Profile_12IN_360P",s[s.LiveTranscoding_Profile_16IN_1080P=15]="LiveTranscoding_Profile_16IN_1080P",s[s.LiveTranscoding_Profile_16IN_720P=16]="LiveTranscoding_Profile_16IN_720P",s[s.LiveTranscoding_Profile_16IN_360P=17]="LiveTranscoding_Profile_16IN_360P",s[s.LiveTranscoding_Profile_Mixed=9999]="LiveTranscoding_Profile_Mixed",s))(vr||{});const Oo={0:"1IN_1080P",1:"1IN_720P",2:"1IN_360P",3:"2IN_1080P",4:"2IN_720P",5:"2IN_360P",6:"4IN_1080P",7:"4IN_720P",8:"4IN_360P",9:"9IN_1080P",10:"9IN_720P",11:"9IN_360P",12:"12IN_1080P",13:"12IN_720P",14:"12IN_360P",15:"16IN_1080P",16:"16IN_720P",17:"16IN_360P",9999:"Mixed_Audio"};var Ni=(s=>(s[s.LiveTranscoding_HZ_48000=48e3]="LiveTranscoding_HZ_48000",s[s.LiveTranscoding_HZ_44100=44100]="LiveTranscoding_HZ_44100",s[s.LiveTranscoding_HZ_32000=32e3]="LiveTranscoding_HZ_32000",s[s.LiveTranscoding_HZ_16000=16e3]="LiveTranscoding_HZ_16000",s[s.LiveTranscoding_HZ_8000=8e3]="LiveTranscoding_HZ_8000",s))(Ni||{}),ui=(s=>(s[s.LiveTranscodingNoBody=0]="LiveTranscodingNoBody",s[s.LiveTranscodingBody=1]="LiveTranscodingBody",s))(ui||{}),pi=(s=>(s[s.NOTO_SERIF_CJKSC_REGULAR=0]="NOTO_SERIF_CJKSC_REGULAR",s[s.ALIBABA_PUHUITI_REGULAR=1]="ALIBABA_PUHUITI_REGULAR",s[s.ALIBABA_PUHUITI_BOLD=2]="ALIBABA_PUHUITI_BOLD",s[s.ALIBABA_PUHUITI_Heavy=3]="ALIBABA_PUHUITI_Heavy",s[s.ALIBABA_PUHUITI_LIGHT=4]="ALIBABA_PUHUITI_LIGHT",s[s.ALIBABA_PUHUITI_MEDIUM=5]="ALIBABA_PUHUITI_MEDIUM",s))(pi||{}),yr=(s=>(s[s.LiveTranscodingOrigin=0]="LiveTranscodingOrigin",s[s.LiveTranscodingCrop=1]="LiveTranscodingCrop",s[s.LiveTranscodingFill=2]="LiveTranscodingFill",s))(yr||{}),Li=(s=>(s[s.LiveTranscodingNormal=0]="LiveTranscodingNormal",s[s.LiveTranscodingVirtualBackground=1]="LiveTranscodingVirtualBackground",s))(Li||{}),Rr=(s=>(s[s.LiveTranscodingState_IDLE=0]="LiveTranscodingState_IDLE",s[s.LiveTranscodingState_CONNNECT=1]="LiveTranscodingState_CONNNECT",s[s.LiveTranscodingState_RUNNING=2]="LiveTranscodingState_RUNNING",s[s.LiveTranscodingState_RECOVERING=3]="LiveTranscodingState_RECOVERING",s[s.LiveTranscodingState_FAILURE=4]="LiveTranscodingState_FAILURE",s[s.LiveTranscodingState_END=5]="LiveTranscodingState_END",s))(Rr||{}),vt=(s=>(s[s.LiveTranscodingErrorPublishOk=0]="LiveTranscodingErrorPublishOk",s[s.LiveTranscodingErrorStreamNotFound=17825793]="LiveTranscodingErrorStreamNotFound",s[s.LiveTranscodingErrorStreamAlreadyExist=17825794]="LiveTranscodingErrorStreamAlreadyExist",s[s.LiveTranscodingErrorInvalidParam=17825795]="LiveTranscodingErrorInvalidParam",s[s.LiveTranscodingErrorInternalError=17825796]="LiveTranscodingErrorInternalError",s[s.LiveTranscodingErrorRtmpServerError=17825797]="LiveTranscodingErrorRtmpServerError",s[s.LiveTranscodingErrorRtmpStreamUrlError=17825798]="LiveTranscodingErrorRtmpStreamUrlError",s[s.LiveTranscodingErrorPublishTimeout=17825799]="LiveTranscodingErrorPublishTimeout",s[s.LiveTranscodingErrorNotAuthorized=17825800]="LiveTranscodingErrorNotAuthorized",s))(vt||{}),Ar=(s=>(s[s.TrascodingPublishTaskStatusStart=0]="TrascodingPublishTaskStatusStart",s[s.TrascodingPublishTaskStatusUpdate=1]="TrascodingPublishTaskStatusUpdate",s[s.TrascodingPublishTaskStatusStop=2]="TrascodingPublishTaskStatusStop",s))(Ar||{}),it=(s=>(s[s.MPU_TASK_TRANSACTION_START=0]="MPU_TASK_TRANSACTION_START",s[s.MPU_TASK_TRANSACTION_UPDATE=1]="MPU_TASK_TRANSACTION_UPDATE",s[s.MPU_TASK_TRANSACTION_STOP=2]="MPU_TASK_TRANSACTION_STOP",s[s.MPU_TASK_TRANSACTION_LIST=3]="MPU_TASK_TRANSACTION_LIST",s[s.MPU_TASK_TRANSACTION_POLLING=4]="MPU_TASK_TRANSACTION_POLLING",s[s.MPU_TASK_TRANSACTION_ACKNOWLEDGE=5]="MPU_TASK_TRANSACTION_ACKNOWLEDGE",s[s.MPU_TASK_TRANSACTION_END=6]="MPU_TASK_TRANSACTION_END",s))(it||{});const Uo={0:"/libra/v1/sdk/start-task",1:"/libra/v1/sdk/update-task",2:"/libra/v1/sdk/stop-task",3:"/libra/v1/sdk/list-task",4:"/libra/v1/sdk/polling",5:"/libra/v1/sdk/acknowledge",6:"/"};class _r{constructor(a,e,t,i,r,n,c,o){f(this,"videoWidth");f(this,"videoHeight");f(this,"videoFramerate",20);f(this,"videoBitrate",2e3);f(this,"videoGop",30);f(this,"audioSamplerate",Ni.LiveTranscoding_HZ_44100);f(this,"audioBitrate",500);f(this,"audioChannels",1);this.videoWidth=a,this.videoHeight=e,t&&(this.videoFramerate=t),i&&(this.videoBitrate=i),r&&(this.videoGop=r),n&&(this.audioSamplerate=n),c&&(this.audioBitrate=c),o&&(this.audioChannels=o)}}const wr=s=>((16711680&s)>>16)+(65280&s)+((255&s)<<16),ht=(s=0,a)=>{if(a==0)return 0;let e=s/a;return e<0&&(e=0),e>1&&(e=1),e};class xi{constructor(a,e,t){f(this,"mixMode",hi.LiveTranscodingSingle);f(this,"singleParam");f(this,"mixParam");a&&(this.mixMode=a),e&&(this.singleParam=e),t&&(this.mixParam=t)}toJson(a,e,t,i,r){const n={appid:e.appId,channelid:e.channelId};if(a===it.MPU_TASK_TRANSACTION_POLLING||a===it.MPU_TASK_TRANSACTION_LIST||a===it.MPU_TASK_TRANSACTION_ACKNOWLEDGE)return a===it.MPU_TASK_TRANSACTION_ACKNOWLEDGE&&(n.messageid=r),n;if(n.taskid=t,a!==it.MPU_TASK_TRANSACTION_STOP){if(n.mixmode=this.mixMode,i&&(n.streamurl=i),this.mixMode===hi.LiveTranscodingSingle){const c=this.singleParam;if(c){n.streamtype=c.streamType,c.sourceType===ii.LiveTranscodingShareScreen?n.sourcetype=li[c.sourceType]:n.sourcetype=li[ii.LiveTranscodingCamera];const o=[];c.userId&&o.push(c.userId),n.subspecusers=o}}else if(a===it.MPU_TASK_TRANSACTION_START||a===it.MPU_TASK_TRANSACTION_UPDATE){const c=this.mixParam;if(c){c.taskProfile&&(n.taskprofile=Oo[c.taskProfile]);const o=c.encodeParam||new _r(1280,720);let d=o.videoWidth,h=o.videoHeight;const l={};Object.keys(o).forEach(u=>{const g=o[u];g>0&&(l[u.toLowerCase()]=g)}),l.lowbitratehighquality=0,n.encodeparam=l,n.backgrounds=c.backgrounds.map(u=>u.toJson(d,h)),n.watermarks=c.watermarks.map(u=>u.toJson(d,h)),n.clockwidgets=c.clockWidgets.map(u=>u.toJson(d,h));const p=c.users.map(u=>u.userId);n.subspecusers=[...new Set(p)],n.layouts=[{audiomixcount:c.users.length,panes:c.users.map((u,g)=>u.toJson(g,d,h,c.mediaProcessMode))}],n.layoutids=["0"],n.cropmode=c.cropMode,n.backgroundcolor=wr(c.backgroundColor),n.taskmode=c.mediaProcessMode}}}return n}}var It=(s=>(s.pre="pre",s.prod="prod",s))(It||{}),Tt=(s=>(s.AliRtcSdkCommunication="communication",s.AliRtcSdkInteractiveLive="interactive_live",s.AliRtcSdkInteractiveWithLowLatencyLive="cdn_live",s))(Tt||{}),Nt=(s=>(s.AliRtcSdkInteractive="interactive",s.AliRtcSdkLive="live",s))(Nt||{}),yt=(s=>(s[s.AliEngineLocalDeviceTypeUnknown=0]="AliEngineLocalDeviceTypeUnknown",s[s.AliEngineLocalDeviceTypeMic=1]="AliEngineLocalDeviceTypeMic",s[s.AliEngineLocalDeviceTypeSpeaker=2]="AliEngineLocalDeviceTypeSpeaker",s[s.AliEngineLocalDeviceTypeAudioDevice=3]="AliEngineLocalDeviceTypeAudioDevice",s[s.AliEngineLocalDeviceTypeCamera=4]="AliEngineLocalDeviceTypeCamera",s[s.AliEngineLocalDeviceTypeDisplay=5]="AliEngineLocalDeviceTypeDisplay",s[s.AliEngineLocalDeviceTypeVideoDevice=6]="AliEngineLocalDeviceTypeVideoDevice",s))(yt||{}),Oe=(s=>(s[s.AliEngineLocalDeviceExceptionTypeUnknown=0]="AliEngineLocalDeviceExceptionTypeUnknown",s[s.AliEngineLocalDeviceExceptionTypeMicOpenFail=1]="AliEngineLocalDeviceExceptionTypeMicOpenFail",s[s.AliEngineLocalDeviceExceptionTypeMicInterrupt=2]="AliEngineLocalDeviceExceptionTypeMicInterrupt",s[s.AliEngineLocalDeviceExceptionTypeMicAuthFail=3]="AliEngineLocalDeviceExceptionTypeMicAuthFail",s[s.AliEngineLocalDeviceExceptionTypeMicNotAvailable=4]="AliEngineLocalDeviceExceptionTypeMicNotAvailable",s[s.AliEngineLocalDeviceExceptionTypeSpeakerOpenFail=5]="AliEngineLocalDeviceExceptionTypeSpeakerOpenFail",s[s.AliEngineLocalDeviceExceptionTypeSpeakerInterrupt=6]="AliEngineLocalDeviceExceptionTypeSpeakerInterrupt",s[s.AliEngineLocalDeviceExceptionTypeSpeakerNotAvailable=7]="AliEngineLocalDeviceExceptionTypeSpeakerNotAvailable",s[s.AliEngineLocalDeviceExceptionTypeAudioDeviceException=8]="AliEngineLocalDeviceExceptionTypeAudioDeviceException",s[s.AliEngineLocalDeviceExceptionTypeCameraOpenFail=9]="AliEngineLocalDeviceExceptionTypeCameraOpenFail",s[s.AliEngineLocalDeviceExceptionTypeCameraInterrupt=10]="AliEngineLocalDeviceExceptionTypeCameraInterrupt",s[s.AliEngineLocalDeviceExceptionTypeCameraAuthFail=11]="AliEngineLocalDeviceExceptionTypeCameraAuthFail",s[s.AliEngineLocalDeviceExceptionTypeDisplayException=12]="AliEngineLocalDeviceExceptionTypeDisplayException",s[s.AliEngineLocalDeviceExceptionTypeVideoDeviceException=13]="AliEngineLocalDeviceExceptionTypeVideoDeviceException",s))(Oe||{}),ue=(s=>(s[s.AliRtcConnectionStatusInit=0]="AliRtcConnectionStatusInit",s[s.AliRtcConnectionStatusDisconnected=1]="AliRtcConnectionStatusDisconnected",s[s.AliRtcConnectionStatusConnecting=2]="AliRtcConnectionStatusConnecting",s[s.AliRtcConnectionStatusConnected=3]="AliRtcConnectionStatusConnected",s[s.AliRtcConnectionStatusReconnecting=4]="AliRtcConnectionStatusReconnecting",s[s.AliRtcConnectionStatusFailed=5]="AliRtcConnectionStatusFailed",s))(ue||{}),Kt=(s=>(s[s.AliRtcConnectionChangedDummyReason=0]="AliRtcConnectionChangedDummyReason",s[s.AliRtcConnectionMediaPathChanged=1]="AliRtcConnectionMediaPathChanged",s[s.AliRtcConnectionSignalingHeartbeatTimeout=2]="AliRtcConnectionSignalingHeartbeatTimeout",s[s.AliRtcConnectionSignalingHeartbeatAlive=3]="AliRtcConnectionSignalingHeartbeatAlive",s[s.AliRtcConnectionSignalingHttpDnsResolved=4]="AliRtcConnectionSignalingHttpDnsResolved",s[s.AliRtcConnectionSignalingHttpDnsFailure=5]="AliRtcConnectionSignalingHttpDnsFailure",s[s.AliRtcConnectionSignalingGslbFailure=6]="AliRtcConnectionSignalingGslbFailure",s[s.AliRtcConnectionSignalingGslbSuccess=7]="AliRtcConnectionSignalingGslbSuccess",s[s.AliRtcConnectionSignalingJoinRoomFailure=8]="AliRtcConnectionSignalingJoinRoomFailure",s[s.AliRtcConnectionSignalingJoinRoomSuccess=9]="AliRtcConnectionSignalingJoinRoomSuccess",s[s.AliRtcConnectionSignalingLeaveRoom=10]="AliRtcConnectionSignalingLeaveRoom",s[s.AliRtcConnectionSignalingConnecting=11]="AliRtcConnectionSignalingConnecting",s[s.AliRtcConnectionChangedNetworkInterrupted=12]="AliRtcConnectionChangedNetworkInterrupted",s))(Kt||{}),Er=(s=>(s[s.AliRtcUserOfflineQuit=0]="AliRtcUserOfflineQuit",s[s.AliRtcUserOfflineDropped=1]="AliRtcUserOfflineDropped",s[s.AliRtcUserOfflineBecomeAudience=2]="AliRtcUserOfflineBecomeAudience",s))(Er||{}),ri=(s=>(s[s.AliRtcAudioTrackNo=0]="AliRtcAudioTrackNo",s[s.AliRtcAudioTrackMic=1]="AliRtcAudioTrackMic",s[s.AliRtcAudioTrackDual=2]="AliRtcAudioTrackDual",s))(ri||{}),ne=(s=>(s[s.AliRtcVideoTrackNo=0]="AliRtcVideoTrackNo",s[s.AliRtcVideoTrackCamera=1]="AliRtcVideoTrackCamera",s[s.AliRtcVideoTrackScreen=2]="AliRtcVideoTrackScreen",s[s.AliRtcVideoTrackBoth=3]="AliRtcVideoTrackBoth",s))(ne||{}),ie=(s=>(s[s.AliRtcStatePublishIdle=0]="AliRtcStatePublishIdle",s[s.AliRtcStateNoPublish=1]="AliRtcStateNoPublish",s[s.AliRtcStatePublishing=2]="AliRtcStatePublishing",s[s.AliRtcStatePublished=3]="AliRtcStatePublished",s))(ie||{}),me=(s=>(s[s.AliRtcStateSubscribeIdle=0]="AliRtcStateSubscribeIdle",s[s.AliRtcStateNoSubscribe=1]="AliRtcStateNoSubscribe",s[s.AliRtcStateSubscribing=2]="AliRtcStateSubscribing",s[s.AliRtcStateSubscribed=3]="AliRtcStateSubscribed",s))(me||{}),We=(s=>(s[s.AliRtcVideoStreamTypeNone=0]="AliRtcVideoStreamTypeNone",s[s.AliRtcVideoStreamTypeHigh=1]="AliRtcVideoStreamTypeHigh",s[s.AliRtcVideoStreamTypeLow=2]="AliRtcVideoStreamTypeLow",s))(We||{}),mi=(s=>(s[s.CAMERA_INVALID=-1]="CAMERA_INVALID",s[s.CAMERA_REAR=0]="CAMERA_REAR",s[s.CAMERA_FRONT=1]="CAMERA_FRONT",s))(mi||{});const oi=class oi extends se{constructor(e){super();f(this,"ws");f(this,"socketStatus",0);f(this,"wsUrl","");f(this,"lastConnectStartTime",0);f(this,"maxConnectRetryCount",12);f(this,"connectRetryCount",0);f(this,"gotErr",!1);f(this,"closedByInvoke",!0);f(this,"isReconnecting",!1);f(this,"networkAvailableChecked",!0);f(this,"reconnectTimeoutId",0);this.maxConnectRetryCount=e!=null?e:12,this.onOpen=this.onOpen.bind(this),this.onMessage=this.onMessage.bind(this),this.onError=this.onError.bind(this),this.onClose=this.onClose.bind(this)}get connectUrl(){return this.wsUrl}get connectStatus(){return this.socketStatus}start(e){this.wsUrl=e,this.initWebSocket()}send(e){return!(!this.ws||this.socketStatus!==2)&&(this.ws.send(JSON.stringify(e)),!0)}close(){this.closedByInvoke=!0,this.uninitWebsocket()}reconnect(){this.reconnectTimeoutId&&(clearTimeout(this.reconnectTimeoutId),this.reconnectTimeoutId=0),this.emit("onReconnectStart"),this.isReconnecting=!0,this.initWebSocket()}onOpen(e){V.info(`[${oi.logName}]`,"onOpen"),this.socketStatus=2,this.connectRetryCount=0,this.networkAvailableChecked=!1,this.closedByInvoke=!1,this.gotErr=!1,this.isReconnecting=!1,this.emit("onOpen",e)}onMessage(e){this.emit("onMessage",e)}onError(e){this.isReconnecting&&this.emit("onReconnectFail",e),this.emit("onError",e),this.isReconnecting=!1,this.socketStatus!==2&&et.isNetworkAvailable().then(t=>{t&&console.error(oi.logName,"onError, Network is available, token may be invalid")})}onClose(e){return T(this,null,function*(){if(this.closedByInvoke)this.socketStatus=0;else{if(V.info(`[${oi.logName}]`,`onClose, code: ${e.code}, reason: ${e.reason}, status: ${status}, retryCount: ${this.connectRetryCount}`),(yield et.isNetworkAvailable())&&!this.networkAvailableChecked)return this.reconnect(),void(this.networkAvailableChecked=!0);this.connectRetryCount||this.emit("onNetworkError"),!this.reconnectTimeoutId&&(this.connectRetryCount+=1,this.connectRetryCount>this.maxConnectRetryCount?this.emit("onConnectFail"):Date.now()-this.lastConnectStartTime>=5e3?this.reconnect():this.reconnectTimeoutId=window.setTimeout(()=>{this.reconnect()},5e3)),this.socketStatus=0,this.emit("onClose",e)}})}initWebSocket(){this.uninitWebsocket(),this.socketStatus=1,this.lastConnectStartTime=Date.now(),this.ws=new WebSocket(this.wsUrl),this.ws.addEventListener("open",this.onOpen),this.ws.addEventListener("message",this.onMessage),this.ws.addEventListener("error",this.onError),this.ws.addEventListener("close",this.onClose)}uninitWebsocket(){this.ws&&(this.ws.removeEventListener("open",this.onOpen),this.ws.removeEventListener("message",this.onMessage),this.ws.removeEventListener("error",this.onError),this.ws.removeEventListener("close",this.onClose),this.ws.readyState!==WebSocket.CLOSED&&this.ws.close(),this.ws=void 0,this.socketStatus=0)}};f(oi,"logName","Socket");let Ir=oi;var Tr={exports:{}};(function(s,a){(function(e,t){var i="function",r="undefined",n="object",c="string",o="major",d="model",h="name",l="type",p="vendor",u="version",g="architecture",m="console",b="mobile",S="tablet",v="smarttv",_="wearable",w="embedded",y="Amazon",R="Apple",A="ASUS",E="BlackBerry",I="Browser",k="Chrome",P="Firefox",B="Google",G="Huawei",Y="LG",J="Microsoft",z="Motorola",Q="Opera",ee="Samsung",pe="Sharp",D="Sony",L="Xiaomi",N="Zebra",x="Facebook",ce="Chromium OS",ke="Mac OS",$=" Browser",ge=function(ae){for(var re={},te=0;te<ae.length;te++)re[ae[te].toUpperCase()]=ae[te];return re},De=function(ae,re){return typeof ae===c&&Ae(re).indexOf(Ae(ae))!==-1},Ae=function(ae){return ae.toLowerCase()},Te=function(ae,re){if(typeof ae===c)return ae=ae.replace(/^\s\s*/,""),typeof re===r?ae:ae.substring(0,500)},fe=function(ae,re){for(var te,be,Ve,he,je,Z,Me=0;Me<re.length&&!je;){var at=re[Me],Le=re[Me+1];for(te=be=0;te<at.length&&!je&&at[te];)if(je=at[te++].exec(ae))for(Ve=0;Ve<Le.length;Ve++)Z=je[++be],typeof(he=Le[Ve])===n&&he.length>0?he.length===2?typeof he[1]==i?this[he[0]]=he[1].call(this,Z):this[he[0]]=he[1]:he.length===3?typeof he[1]!==i||he[1].exec&&he[1].test?this[he[0]]=Z?Z.replace(he[1],he[2]):t:this[he[0]]=Z?he[1].call(this,Z,he[2]):t:he.length===4&&(this[he[0]]=Z?he[3].call(this,Z.replace(he[1],he[2])):t):this[he]=Z||t;Me+=2}},_e=function(ae,re){for(var te in re)if(typeof re[te]===n&&re[te].length>0){for(var be=0;be<re[te].length;be++)if(De(re[te][be],ae))return te==="?"?t:te}else if(De(re[te],ae))return te==="?"?t:te;return re.hasOwnProperty("*")?re["*"]:ae},de={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},Pe={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[u,[h,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[u,[h,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[h,u],[/opios[\/ ]+([\w\.]+)/i],[u,[h,Q+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[u,[h,Q+" GX"]],[/\bopr\/([\w\.]+)/i],[u,[h,Q]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[u,[h,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[u,[h,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[h,u],[/quark(?:pc)?\/([-\w\.]+)/i],[u,[h,"Quark"]],[/\bddg\/([\w\.]+)/i],[u,[h,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[u,[h,"UC"+I]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[u,[h,"WeChat"]],[/konqueror\/([\w\.]+)/i],[u,[h,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[u,[h,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[u,[h,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[u,[h,"Smart Lenovo "+I]],[/(avast|avg)\/([\w\.]+)/i],[[h,/(.+)/,"$1 Secure "+I],u],[/\bfocus\/([\w\.]+)/i],[u,[h,P+" Focus"]],[/\bopt\/([\w\.]+)/i],[u,[h,Q+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[u,[h,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[u,[h,"Dolphin"]],[/coast\/([\w\.]+)/i],[u,[h,Q+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[u,[h,"MIUI"+$]],[/fxios\/([\w\.-]+)/i],[u,[h,P]],[/\bqihoobrowser\/?([\w\.]*)/i],[u,[h,"360"]],[/\b(qq)\/([\w\.]+)/i],[[h,/(.+)/,"$1Browser"],u],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[h,/(.+)/,"$1"+$],u],[/samsungbrowser\/([\w\.]+)/i],[u,[h,ee+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[u,[h,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[h,"Sogou Mobile"],u],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[h,u],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[h],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[u,h],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[h,x],u],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[h,u],[/\bgsa\/([\w\.]+) .*safari\//i],[u,[h,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[u,[h,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[u,[h,k+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[h,k+" WebView"],u],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[u,[h,"Android "+I]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[h,u],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[u,[h,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[u,h],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[h,[u,_e,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[h,u],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[h,"Netscape"],u],[/(wolvic|librewolf)\/([\w\.]+)/i],[h,u],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[u,[h,P+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i],[h,[u,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[h,[u,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[g,"amd64"]],[/(ia32(?=;))/i],[[g,Ae]],[/((?:i[346]|x)86)[;\)]/i],[[g,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[g,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[g,"armhf"]],[/windows (ce|mobile); ppc;/i],[[g,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[g,/ower/,"",Ae]],[/(sun4\w)[;\)]/i],[[g,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[g,Ae]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[d,[p,ee],[l,S]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[d,[p,ee],[l,b]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[d,[p,R],[l,b]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[d,[p,R],[l,S]],[/(macintosh);/i],[d,[p,R]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[d,[p,pe],[l,b]],[/(?:honor)([-\w ]+)[;\)]/i],[d,[p,"Honor"],[l,b]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[d,[p,G],[l,S]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[d,[p,G],[l,b]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i],[[d,/_/g," "],[p,L],[l,b]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[d,/_/g," "],[p,L],[l,S]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[d,[p,"OPPO"],[l,b]],[/\b(opd2\d{3}a?) bui/i],[d,[p,"OPPO"],[l,S]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[d,[p,"Vivo"],[l,b]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[d,[p,"Realme"],[l,b]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[d,[p,z],[l,b]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[d,[p,z],[l,S]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[p,Y],[l,S]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[d,[p,Y],[l,b]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[d,[p,"Lenovo"],[l,S]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[d,/_/g," "],[p,"Nokia"],[l,b]],[/(pixel c)\b/i],[d,[p,B],[l,S]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[d,[p,B],[l,b]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[d,[p,D],[l,b]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[d,"Xperia Tablet"],[p,D],[l,S]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[d,[p,"OnePlus"],[l,b]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[d,[p,y],[l,S]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[d,/(.+)/g,"Fire Phone $1"],[p,y],[l,b]],[/(playbook);[-\w\),; ]+(rim)/i],[d,p,[l,S]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[d,[p,E],[l,b]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[d,[p,A],[l,S]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[d,[p,A],[l,b]],[/(nexus 9)/i],[d,[p,"HTC"],[l,S]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[p,[d,/_/g," "],[l,b]],[/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])\w*(\)| bui)/i],[d,[p,"TCL"],[l,S]],[/(itel) ((\w+))/i],[[p,Ae],d,[l,_e,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[d,[p,"Acer"],[l,S]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[d,[p,"Meizu"],[l,b]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[d,[p,"Ulefone"],[l,b]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[d,[p,"Energizer"],[l,b]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[d,[p,"Cat"],[l,b]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[d,[p,"Smartfren"],[l,b]],[/droid.+; (a(?:015|06[35]|142p?))/i],[d,[p,"Nothing"],[l,b]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (imo) ((?!tab)[\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[p,d,[l,b]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[p,d,[l,S]],[/(surface duo)/i],[d,[p,J],[l,S]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[d,[p,"Fairphone"],[l,b]],[/(u304aa)/i],[d,[p,"AT&T"],[l,b]],[/\bsie-(\w*)/i],[d,[p,"Siemens"],[l,b]],[/\b(rct\w+) b/i],[d,[p,"RCA"],[l,S]],[/\b(venue[\d ]{2,7}) b/i],[d,[p,"Dell"],[l,S]],[/\b(q(?:mv|ta)\w+) b/i],[d,[p,"Verizon"],[l,S]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[d,[p,"Barnes & Noble"],[l,S]],[/\b(tm\d{3}\w+) b/i],[d,[p,"NuVision"],[l,S]],[/\b(k88) b/i],[d,[p,"ZTE"],[l,S]],[/\b(nx\d{3}j) b/i],[d,[p,"ZTE"],[l,b]],[/\b(gen\d{3}) b.+49h/i],[d,[p,"Swiss"],[l,b]],[/\b(zur\d{3}) b/i],[d,[p,"Swiss"],[l,S]],[/\b((zeki)?tb.*\b) b/i],[d,[p,"Zeki"],[l,S]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[p,"Dragon Touch"],d,[l,S]],[/\b(ns-?\w{0,9}) b/i],[d,[p,"Insignia"],[l,S]],[/\b((nxa|next)-?\w{0,9}) b/i],[d,[p,"NextBook"],[l,S]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[p,"Voice"],d,[l,b]],[/\b(lvtel\-)?(v1[12]) b/i],[[p,"LvTel"],d,[l,b]],[/\b(ph-1) /i],[d,[p,"Essential"],[l,b]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[d,[p,"Envizen"],[l,S]],[/\b(trio[-\w\. ]+) b/i],[d,[p,"MachSpeed"],[l,S]],[/\btu_(1491) b/i],[d,[p,"Rotor"],[l,S]],[/(shield[\w ]+) b/i],[d,[p,"Nvidia"],[l,S]],[/(sprint) (\w+)/i],[p,d,[l,b]],[/(kin\.[onetw]{3})/i],[[d,/\./g," "],[p,J],[l,b]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[d,[p,N],[l,S]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[d,[p,N],[l,b]],[/smart-tv.+(samsung)/i],[p,[l,v]],[/hbbtv.+maple;(\d+)/i],[[d,/^/,"SmartTV"],[p,ee],[l,v]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[p,Y],[l,v]],[/(apple) ?tv/i],[p,[d,R+" TV"],[l,v]],[/crkey/i],[[d,k+"cast"],[p,B],[l,v]],[/droid.+aft(\w+)( bui|\))/i],[d,[p,y],[l,v]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[d,[p,pe],[l,v]],[/(bravia[\w ]+)( bui|\))/i],[d,[p,D],[l,v]],[/(mitv-\w{5}) bui/i],[d,[p,L],[l,v]],[/Hbbtv.*(technisat) (.*);/i],[p,d,[l,v]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[p,Te],[d,Te],[l,v]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[l,v]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[p,d,[l,m]],[/droid.+; (shield) bui/i],[d,[p,"Nvidia"],[l,m]],[/(playstation [345portablevi]+)/i],[d,[p,D],[l,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[d,[p,J],[l,m]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[d,[p,ee],[l,_]],[/((pebble))app/i],[p,d,[l,_]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[d,[p,R],[l,_]],[/droid.+; (glass) \d/i],[d,[p,B],[l,_]],[/droid.+; (wt63?0{2,3})\)/i],[d,[p,N],[l,_]],[/droid.+; (glass) \d/i],[d,[p,B],[l,_]],[/(pico) (4|neo3(?: link|pro)?)/i],[p,d,[l,_]],[/; (quest( \d| pro)?)/i],[d,[p,x],[l,_]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[p,[l,w]],[/(aeobc)\b/i],[d,[p,y],[l,w]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[d,[l,b]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[d,[l,S]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[l,S]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[l,b]],[/(android[-\w\. ]{0,9});.+buil/i],[d,[p,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[u,[h,"EdgeHTML"]],[/(arkweb)\/([\w\.]+)/i],[h,u],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[u,[h,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[h,u],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[u,h]],os:[[/microsoft (windows) (vista|xp)/i],[h,u],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[h,[u,_e,de]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[u,_e,de],[h,"Windows"]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[u,/_/g,"."],[h,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[h,ke],[u,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[u,h],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[h,u],[/\(bb(10);/i],[u,[h,E]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[u,[h,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[u,[h,P+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[u,[h,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[u,[h,"watchOS"]],[/crkey\/([\d\.]+)/i],[u,[h,k+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[h,ce],u],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[h,u],[/(sunos) ?([\w\.\d]*)/i],[[h,"Solaris"],u],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[h,u]]},ye=function(ae,re){if(typeof ae===n&&(re=ae,ae=t),!(this instanceof ye))return new ye(ae,re).getResult();var te=typeof e!==r&&e.navigator?e.navigator:t,be=ae||(te&&te.userAgent?te.userAgent:""),Ve=te&&te.userAgentData?te.userAgentData:t,he=re?function(Z,Me){var at={};for(var Le in Z)Me[Le]&&Me[Le].length%2==0?at[Le]=Me[Le].concat(Z[Le]):at[Le]=Z[Le];return at}(Pe,re):Pe,je=te&&te.userAgent==be;return this.getBrowser=function(){var Z,Me={};return Me[h]=t,Me[u]=t,fe.call(Me,be,he.browser),Me[o]=typeof(Z=Me[u])===c?Z.replace(/[^\d\.]/g,"").split(".")[0]:t,je&&te&&te.brave&&typeof te.brave.isBrave==i&&(Me[h]="Brave"),Me},this.getCPU=function(){var Z={};return Z[g]=t,fe.call(Z,be,he.cpu),Z},this.getDevice=function(){var Z={};return Z[p]=t,Z[d]=t,Z[l]=t,fe.call(Z,be,he.device),je&&!Z[l]&&Ve&&Ve.mobile&&(Z[l]=b),je&&Z[d]=="Macintosh"&&te&&typeof te.standalone!==r&&te.maxTouchPoints&&te.maxTouchPoints>2&&(Z[d]="iPad",Z[l]=S),Z},this.getEngine=function(){var Z={};return Z[h]=t,Z[u]=t,fe.call(Z,be,he.engine),Z},this.getOS=function(){var Z={};return Z[h]=t,Z[u]=t,fe.call(Z,be,he.os),je&&!Z[h]&&Ve&&Ve.platform&&Ve.platform!="Unknown"&&(Z[h]=Ve.platform.replace(/chrome os/i,ce).replace(/macos/i,ke)),Z},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return be},this.setUA=function(Z){return be=typeof Z===c&&Z.length>500?Te(Z,500):Z,this},this.setUA(be),this};ye.VERSION="1.0.40",ye.BROWSER=ge([h,u,o]),ye.CPU=ge([g]),ye.DEVICE=ge([d,p,l,m,b,v,S,_,w]),ye.ENGINE=ye.OS=ge([h,u]),s.exports&&(a=s.exports=ye),a.UAParser=ye;var Ge=typeof e!==r&&(e.jQuery||e.Zepto);if(Ge&&!Ge.ua){var st=new ye;Ge.ua=st.getResult(),Ge.ua.get=function(){return st.getUA()},Ge.ua.set=function(ae){st.setUA(ae);var re=st.getResult();for(var te in re)Ge.ua[te]=re[te]}}})(typeof window=="object"?window:Ci)})(Tr,Tr.exports);var Bo=Tr.exports,Ue=(s=>(s.KEEPALIVE="keepalive",s.JOINCHANNEL="joinchannel",s.NOTIFYJOIN="notifyjoin",s.NOTIFYSTATUS="notifystatus",s.STATUSREPORT="statusreport",s.LEAVECHANNEL="leavechannel",s.NOTIFYLEAVE="notifyleave",s.NOTIFYPUBLISH="notifypublish",s.BYE="bye",s.RECONNECT="reconnect",s.PUBLISH="publish",s.REFRESHURL="refreshurl",s.UNSUBSCRIBE="unsubscribe",s.ROLEUPDATE="roleupdate",s))(Ue||{});class Ho{constructor(a,e){f(this,"authInfo");f(this,"userName");f(this,"seqIndex",0);this.authInfo=a,this.userName=e}get roleAuth(){if(this.authInfo.role){const{timestamp:a,nonce:e,token:t,role:i}=this.authInfo;return{timestamp:a,nonce:e,token:t,tokenrole:i}}}get adaptInfo(){var e,t,i,r;let a=new Bo.UAParser().getResult();return{os_name:((e=a.os.name)==null?void 0:e.replace(" ",""))+"_"+((t=a.browser.name)==null?void 0:t.replace(" ","")),device_name:((i=a.device.model)==null?void 0:i.replace(" ",""))||"",brand_name:((r=a.device.vendor)==null?void 0:r.replace(" ",""))||"",device_key:window.navigator.userAgent,os_version:a.browser.version||"",sdk_version:"7.0.1",version:"v1"}}refreshAuthInfo(a){this.authInfo=a}getSeqIndex(){return this.seqIndex}createKeepAlivePackage(){return this.createBaseSendPackage("keepalive")}createJoinPackage(a){let e=this.createBaseSendPackage("joinchannel");return e.header.displayName=this.userName,e.header.clientversion=et.getVersionNumber().toString(),e.header.platform="web",this.roleAuth&&(e.data.auth=this.roleAuth),this.adaptInfo&&(e.data.adapt=this.adaptInfo),a&&(e.data=X(X({},e.data),a)),e}crateLeavePackage(){return this.createBaseSendPackage("leavechannel")}createStatusPackage(a){let e=this.createBaseSendPackage("statusreport");return e.header.displayName=this.userName,e.data.status=a,e}createPublishPackage(){let a=this.createBaseSendPackage("publish");return a.data.users=[{}],this.roleAuth&&(a.data.auth=this.roleAuth),a}createRoleUpdatePackage(){let a=this.createBaseSendPackage("roleupdate");return a.header.displayName=this.userName,a}createReconnectPackage(a){let e=this.createBaseSendPackage("reconnect");return e.header.displayName=this.userName,e.header.clientversion=et.getVersionNumber().toString(),e.header.platform="web",e.data=X(X({},e.data),a!=null?a:{}),this.roleAuth&&(e.data.auth=this.roleAuth),e}createRefreshUrlPackage(){let a=this.createBaseSendPackage("refreshurl");return a.header.displayName=this.userName,a}createResponsePackage(a,e){return{version:1,code:200,tid:a,msgtype:e}}createBaseSendPackage(a){var e;return++this.seqIndex,{version:1,msgtype:a,tid:dt(),header:{appid:this.authInfo.appId,channelid:this.authInfo.channelId,sessionid:(e=this.authInfo.sessionId)!=null?e:"",userid:this.authInfo.userId},data:{seq:this.seqIndex}}}}var H=(s=>(s[s.ERR_JOIN_ALREADY_JOINED=16843521]="ERR_JOIN_ALREADY_JOINED",s[s.ERR_JOIN_BAD_APPID=33620481]="ERR_JOIN_BAD_APPID",s[s.ERR_JOIN_INVALID_APPID=33620482]="ERR_JOIN_INVALID_APPID",s[s.ERR_JOIN_BAD_CHANNEL=33620484]="ERR_JOIN_BAD_CHANNEL",s[s.ERR_JOIN_INVALID_CHANNEL=33620483]="ERR_JOIN_INVALID_CHANNEL",s[s.ERR_JOIN_BAD_TOKEN=33620485]="ERR_JOIN_BAD_TOKEN",s[s.ERR_JOIN_TIMEOUT=16908804]="ERR_JOIN_TIMEOUT",s[s.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD=16974081]="ERR_JOIN_ERR_JOIN_BAD_PARAMBAD",s[s.ERR_JOIN_CHANNEL_FAILED=16974338]="ERR_JOIN_CHANNEL_FAILED",s[s.ERR_LOG_ALREADY_INIT=16974085]="ERR_LOG_ALREADY_INIT",s[s.ERR_LOG_ROOT_PATH_ERROR=16974086]="ERR_LOG_ROOT_PATH_ERROR",s[s.ERR_MIC_OPEN_FAIL=17040388]="ERR_MIC_OPEN_FAIL",s[s.ERR_SPEAKER_OPEN_FAIL=17040389]="ERR_SPEAKER_OPEN_FAIL",s[s.ERR_MIC_INTERRUPT=17040390]="ERR_MIC_INTERRUPT",s[s.ERR_SPEAKER_INTERRUPT=17040391]="ERR_SPEAKER_INTERRUPT",s[s.ERR_MIC_AUTH_FAIL=17040392]="ERR_MIC_AUTH_FAIL",s[s.ERR_MIC_NOT_AVAILABLE=17040393]="ERR_MIC_NOT_AVAILABLE",s[s.ERR_SPEAKER_NOT_AVAILABLE=17040400]="ERR_SPEAKER_NOT_AVAILABLE",s[s.ERR_CAMERA_OPEN_FAIL=17039620]="ERR_CAMERA_OPEN_FAIL",s[s.ERR_CAMERA_AUTH_FAIL=17039621]="ERR_CAMERA_AUTH_FAIL",s[s.ERR_CAMERA_INTERRUPT=17039622]="ERR_CAMERA_INTERRUPT",s[s.ERR_CAMERA_NOT_AVAILABLE=17039623]="ERR_CAMERA_NOT_AVAILABLE",s[s.ERR_VIDEO_DISPLAY_OPEN_FAIL=17039873]="ERR_VIDEO_DISPLAY_OPEN_FAIL",s[s.ERR_VIDEO_DISPLAY_INTERRUPT=1064992]="ERR_VIDEO_DISPLAY_INTERRUPT",s[s.ERR_ICE_CONNECTION_CONNECT_FAIL=17105409]="ERR_ICE_CONNECTION_CONNECT_FAIL",s[s.ERR_ICE_CONNECTION_RECONNECT_FAI=17105410]="ERR_ICE_CONNECTION_RECONNECT_FAI",s[s.ERR_ICE_CONNECTION_MOBILITY_FAIL=17105411]="ERR_ICE_CONNECTION_MOBILITY_FAIL",s[s.ERR_ICE_CONNECTION_HEARTBEAT_TIMEOUT=16908812]="ERR_ICE_CONNECTION_HEARTBEAT_TIMEOUT",s[s.ERR_LATENCY_LIVE_COMMUNICATION_FAILED=17235971]="ERR_LATENCY_LIVE_COMMUNICATION_FAILED",s[s.ERR_LATENCY_LIVE_MEIDASETTING_FAILED=17235972]="ERR_LATENCY_LIVE_MEIDASETTING_FAILED",s[s.ERR_LATENCY_LIVE_NONE_BROADCASTER=17235973]="ERR_LATENCY_LIVE_NONE_BROADCASTER",s[s.ERR_LATENCY_LIVE_NEED_RESTART=17235974]="ERR_LATENCY_LIVE_NEED_RESTART",s[s.ERR_LATENCY_LIVE_NEED_RESTART_AGAIN_LATER=17235975]="ERR_LATENCY_LIVE_NEED_RESTART_AGAIN_LATER",s[s.ERR_LATENCY_LIVE_SERVICE_UNAVAILABLE=17235976]="ERR_LATENCY_LIVE_SERVICE_UNAVAILABLE",s[s.ERR_LATENCY_LIVE_MEDIACONNECTION_INTERRUPTION=17235977]="ERR_LATENCY_LIVE_MEDIACONNECTION_INTERRUPTION",s[s.ERR_SDK_PUBLISH_INVAILD=16974597]="ERR_SDK_PUBLISH_INVAILD",s[s.ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL=16843782]="ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL",s[s.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED=16843856]="ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED",s[s.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED=16843857]="ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED",s[s.ERR_SDK_PUBLISH_DUAL_STREAM_FAILED=16843858]="ERR_SDK_PUBLISH_DUAL_STREAM_FAILED",s[s.ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED=16843859]="ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED",s[s.ERR_SDK_PUBLISH_SCREEN_SHARE_CONFIG_ERROR=16843860]="ERR_SDK_PUBLISH_SCREEN_SHARE_CONFIG_ERROR",s[s.ERR_SDK_SUBSCRIBE_INVAILD=16974852]="ERR_SDK_SUBSCRIBE_INVAILD",s[s.ERR_SDK_SUBSCRIBE_NOT_JOIN_CHANNEL=16844112]="ERR_SDK_SUBSCRIBE_NOT_JOIN_CHANNEL",s[s.ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED=16844113]="ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED",s[s.ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED=16844114]="ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED",s[s.ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED=16844115]="ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED",s[s.ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED=16844116]="ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED",s[s.ERR_SDK_SUBSCRIBE_DATA_FAILED=16844117]="ERR_SDK_SUBSCRIBE_DATA_FAILED",s[s.ERR_SDK_SUBSCRIBE_DATA_ERROR=16844118]="ERR_SDK_SUBSCRIBE_DATA_ERROR",s[s.ERR_SDK_INVALID_STATE=16974340]="ERR_SDK_INVALID_STATE",s[s.ERR_INVALID_ARGUMENTS=16974083]="ERR_INVALID_ARGUMENTS",s[s.ERR_SESSION_REMOVED=33620229]="ERR_SESSION_REMOVED",s[s.ERR_SDK_UPDATE_ROLE_CHANNEL=16908801]="ERR_SDK_UPDATE_ROLE_CHANNEL",s[s.ERR_INNER=-1]="ERR_INNER",s[s.ERR_SDK_MPU_TASK_PUBLISH_OK=0]="ERR_SDK_MPU_TASK_PUBLISH_OK",s[s.ERR_SDK_MPU_TASK_STREAM_NOT_FOUND=17825793]="ERR_SDK_MPU_TASK_STREAM_NOT_FOUND",s[s.ERR_SDK_MPU_TASK_STREAM_ALREADY_EXIST=17825794]="ERR_SDK_MPU_TASK_STREAM_ALREADY_EXIST",s[s.ERR_SDK_MPU_TASK_INVALID_PARAM=17825795]="ERR_SDK_MPU_TASK_INVALID_PARAM",s[s.ERR_SDK_MPU_TASK_INTERNAL_ERROR=17825796]="ERR_SDK_MPU_TASK_INTERNAL_ERROR",s[s.ERR_SDK_MPU_TASK_RTMP_SERVER_ERROR=17825797]="ERR_SDK_MPU_TASK_RTMP_SERVER_ERROR",s[s.ERR_SDK_MPU_TASK_RTMP_STREAM_URL_ERROR=17825798]="ERR_SDK_MPU_TASK_RTMP_STREAM_URL_ERROR",s[s.ERR_SDK_MPU_TASK_PUBLISH_TIMEOUT=17825799]="ERR_SDK_MPU_TASK_PUBLISH_TIMEOUT",s[s.ERR_SDK_MPU_TASK_NOT_AUTHORIZED=17825800]="ERR_SDK_MPU_TASK_NOT_AUTHORIZED",s[s.ERR_SDK_CHANNEL_RELAY_STATE_ERROR=18874369]="ERR_SDK_CHANNEL_RELAY_STATE_ERROR",s[s.ERR_SDK_CHANNEL_RELAY_SRC_NOT_ALLOW=18874370]="ERR_SDK_CHANNEL_RELAY_SRC_NOT_ALLOW",s[s.ERR_SDK_CHANNEL_RELAY_JOIN_DEST_FAILED=18874371]="ERR_SDK_CHANNEL_RELAY_JOIN_DEST_FAILED",s[s.ERR_SDK_CHANNEL_RELAY_TOKEN_INVALID=18874372]="ERR_SDK_CHANNEL_RELAY_TOKEN_INVALID",s[s.ERR_SDK_CHANNEL_RELAY_ROLE_ERROR=18874373]="ERR_SDK_CHANNEL_RELAY_ROLE_ERROR",s[s.ERR_SDK_CHANNEL_RELAY_INVALID_PARAM=18874374]="ERR_SDK_CHANNEL_RELAY_INVALID_PARAM",s[s.ERR_SDK_CHANNEL_RELAY_TO_SELF_ERROR=18874375]="ERR_SDK_CHANNEL_RELAY_TO_SELF_ERROR",s))(H||{});class O extends Error{constructor(e,t,i){super(t);f(this,"_code");f(this,"_extra");this._code=e,this._extra=i}static fromRtsError(e){return e instanceof O?e:new O((e==null?void 0:e.errorCode)||-1,(e==null?void 0:e.message)||(e==null?void 0:e.errorCodeName)||"rts error",e)}static fromError(e,t=-1,i=""){return new O(t,(e==null?void 0:e.message)||(e==null?void 0:e.reason)||i||"error",e)}get code(){return this._code}set code(e){this._code=e}get reason(){return this.message}get extra(){return this._extra}}const ct=class ct extends se{constructor(e,t,i,r,n,c){super();f(this,"authInfo");f(this,"userName");f(this,"channelProfile");f(this,"clientRole");f(this,"slsReporter");f(this,"wsClient");f(this,"packageCreater");f(this,"keepAliveTimer",0);f(this,"packageCache",new Map);f(this,"isFirstConnect",!0);f(this,"aliveChecker",0);f(this,"reconnectData");f(this,"joinChannelExtraData");this.authInfo=e,this.userName=t,this.packageCreater=new Ho(e,t),this.channelProfile=i,this.clientRole=r,this.slsReporter=n,this.wsClient=new Ir(c),this.wsClient.on("onOpen",this.onOpen.bind(this)),this.wsClient.on("onMessage",this.onMessage.bind(this)),this.wsClient.on("onError",this.onError.bind(this)),this.wsClient.on("onClose",this.onClose.bind(this)),this.wsClient.on("onConnectFail",this.onConnectFail.bind(this)),this.wsClient.on("onAuthInvalid",this.onAuthInvalid.bind(this)),this.wsClient.on("onNetworkError",this.onNetworkError.bind(this)),this.wsClient.on("onReconnectStart",this.onReconnectStart.bind(this)),this.wsClient.on("onReconnectFail",this.onReconnectFail.bind(this))}get retryCount(){return this.wsClient.connectRetryCount}start(e,t){this.joinChannelExtraData=t,this.wsClient.start(e)}startKeepAlive(){this.keepAliveTimer===0&&(this.keepAliveTimer=window.setInterval(()=>{let e=this.packageCreater.createKeepAlivePackage();this.sendPackage(e)},5e3)),this.checkAlive()}stopKeepAlive(){this.keepAliveTimer!==0&&(clearInterval(this.keepAliveTimer),this.keepAliveTimer=0),this.aliveChecker&&(window.clearTimeout(this.aliveChecker),this.aliveChecker=0)}sendPkgCache(){this.packageCache.forEach(e=>{this.wsClient.send(e)})}leave(){let e=this.packageCreater.crateLeavePackage();this.sendPackage(e)}reportStatus(e){let t=this.packageCreater.createStatusPackage(e);this.sendPackage(t)}publish(e){const d=e,{l1ip:t}=d,i=Qt(d,["l1ip"]);let r=this.packageCreater.createPublishPackage();r.data.users=[],r.data.l1ip=t,i.subscribe.signal=this.wsClient.connectUrl;const{tracks:n,resume:c}=i;let o="7.0.1";o&&(o=o.split("-")[0]),n.forEach(h=>{const{codec:l,ssrc:p}=h;h.userdata=JSON.stringify({sdk_version:o,codec:l}),h.ssrc=`${p}`,c&&(h.attr={reason:"reconnect"})}),r.data.users.push(i),this.sendPackage(r)}roleUpdate(e){let t=this.packageCreater.createRoleUpdatePackage();t.data.clientrole=e,this.sendPackage(t)}refreshUrl(e){const t=this.packageCreater.createRefreshUrlPackage();t.data=X(kt(X({},t.data),{sessionid:t.header.sessionid}),e),this.sendPackage(t)}refreshAuthInfo(e){this.authInfo=e,this.packageCreater.refreshAuthInfo(e)}close(){V.info(`[${ct.logName}] close`),this.stopKeepAlive(),this.wsClient.off("onOpen",this.onOpen.bind(this)),this.wsClient.off("onMessage",this.onMessage.bind(this)),this.wsClient.off("onError",this.onError.bind(this)),this.wsClient.off("onClose",this.onClose.bind(this)),this.wsClient.off("onConnectFail",this.onConnectFail.bind(this)),this.wsClient.off("onAuthInvalid",this.onAuthInvalid.bind(this)),this.wsClient.off("onReconnectStart"),this.wsClient.off("onReconnectFail"),this.wsClient.close()}sendPackage(e){[Ue.KEEPALIVE,Ue.RECONNECT,Ue.JOINCHANNEL].includes(e.msgtype)||this.packageCache.set(e.tid,e),this.wsClient.send(e),e.msgtype!==Ue.KEEPALIVE&&this.slsReporter.reportRoomServerEvent(!0,e.msgtype,e.tid,e)}updateReconnectData(e){this.reconnectData=e}onOpen(){if(V.info(`[${ct.logName}] onOpen`),this.isFirstConnect){let e=this.packageCreater.createJoinPackage(this.joinChannelExtraData);e.data.configure={channelprofile:this.channelProfile},this.channelProfile!==Tt.AliRtcSdkInteractiveLive&&this.channelProfile!==Tt.AliRtcSdkInteractiveWithLowLatencyLive||(e.data.configure.clientrole=this.clientRole),this.sendPackage(e)}else{this.stopKeepAlive();const e=this.packageCreater.createReconnectPackage(this.reconnectData);this.sendPackage(e)}}onMessage(e){try{let t=JSON.parse(e.data);this.packageCache.delete(t.tid),this.onRecvMessage(t),t!=null&&t.msgtype&&(t==null?void 0:t.msgtype)!==Ue.KEEPALIVE&&this.slsReporter.reportRoomServerEvent(!1,t.msgtype,t.tid,t)}catch(t){V.warn(`[${ct.logName}] onMessage err`,t,e)}}onError(e){V.warn(`[${ct.logName}] onError`,e),this.isFirstConnect&&this.onConnectFail()}onConnectFail(){V.warn(`[${ct.logName}] onConnectFail`);const e=new O(H.ERR_INNER,"Signaling connect failed.");this.isFirstConnect?this.emit("onJoinChannelResult",e):this.emit("onConnectFail",e)}onAuthInvalid(){V.warn(`[${ct.logName}] onAuthInvalid`),this.isFirstConnect&&this.emit("onAuthInvalid")}onNetworkError(){V.warn(`[${ct.logName}] onNetworkError`);const e=new O(H.ERR_INNER,"Network error, signaling connect failed.");this.emit("onNetworkError",e)}onClose(e){V.info(`[${ct.logName}] onClose`,e),this.stopKeepAlive()}onKeepAliveRsp(){this.emit("onKeepAliveRsp"),this.checkAlive()}onReconnectStart(){this.emit("onReconnectStart")}onReconnectFail(){this.emit("onReconnectFail",new O(H.ERR_INNER,"signaling reconnect failed."))}checkAlive(){window.clearTimeout(this.aliveChecker),this.aliveChecker=window.setTimeout(()=>{V.info(`[${ct.logName}] not alive, reconnect`),this.stopKeepAlive(),this.emit("onReconnectStart"),this.wsClient.reconnect()},3e4)}onRecvMessage(e){switch(e.msgtype!==Ue.KEEPALIVE&&V.info(`[${ct.logName}] recv msg: ${e.msgtype}`),e.msgtype){case Ue.JOINCHANNEL:this.onJoinResult(e);break;case Ue.KEEPALIVE:this.onKeepAliveRsp();break;case Ue.PUBLISH:this.onPublishResult(e);break;case Ue.NOTIFYJOIN:this.onNotifyJoin(e);break;case Ue.NOTIFYSTATUS:this.onNotifyStatus(e);break;case Ue.LEAVECHANNEL:this.onLeaveResult(e);break;case Ue.NOTIFYLEAVE:this.onNotifyLeave(e);break;case Ue.NOTIFYPUBLISH:this.onNotifyPublish(e);break;case Ue.STATUSREPORT:this.onStatusReport(e);break;case Ue.BYE:this.onBye(e);break;case Ue.ROLEUPDATE:this.onRoleUpdateResult(e);break;case Ue.REFRESHURL:this.onRefreshUrlResult(e);break;case Ue.RECONNECT:this.onReconnectResult(e);break;default:this.onUnknownMessage(e)}}onJoinResult(e){this.isFirstConnect=!1,this.emit("onJoinChannelResult",e)}onLeaveResult(e){this.emit("onLeaveResult",e.code,e.tid)}onPublishResult(e){this.emit("onPublishResult",e.code,e.tid,e.description)}onRoleUpdateResult(e){this.emit("onRoleUpdateResult",e.code,e.tid,e.description)}onRefreshUrlResult(e){this.emit("onRefreshUrlResult",e)}onReconnectResult(e){if(e.code===200)this.sendPkgCache(),this.startKeepAlive(),this.emit("onReconnectSuccess",e.data.users);else{const t=new O(H.ERR_INNER,`reconnect failed, code: ${e.code};description: ${e.description}`);e.code===403&&(t.code=403),this.emit("onReconnectFail",t),this.close()}}onNotifyJoin(e){let t=this.packageCreater.createResponsePackage(e.tid,e.msgtype);this.wsClient.send(t),e&&e.data&&e.data.users&&this.emit("onNotifyJoin",e.data.users)}onNotifyStatus(e){let t=this.packageCreater.createResponsePackage(e.tid,e.msgtype);this.wsClient.send(t),e.data&&e.data.status&&e.data.status.length&&this.emit("onNotifyStatus",e.data.status)}onNotifyLeave(e){let t=this.packageCreater.createResponsePackage(e.tid,e.msgtype);this.wsClient.send(t),e.data&&e.data.users&&e.data.users.length&&this.emit("onNotifyLeave",e.data.users)}onNotifyPublish(e){let t=this.packageCreater.createResponsePackage(e.tid,e.msgtype);this.wsClient.send(t),e.data&&e.data.users&&e.data.users.length&&this.emit("onNotifyPublish",e.data.users)}onStatusReport(e){this.emit("onStatusReport",e.code,e.tid,e.description)}onBye(e){this.stopKeepAlive(),this.emit("onBye",e.reason,e.description)}onUnknownMessage(e){this.emit("onUnknownMessage",e)}};f(ct,"logName","RSMessageCenter");let Cr=ct;const C=(s,a)=>(e,t,i)=>{const r=i.value;return i.value=function(...n){var l;const c=`[${((l=e.constructor)==null?void 0:l.logName)||""}]`,o=Date.now();let d=[];if(s)try{d=s(n)}catch(p){}V.interface(c,t,...d);const h=r.apply(this,n);return Promise.resolve(h).then(p=>p).catch(p=>p).then(p=>{var b;let u="";const g=p instanceof Error,m=g&&((b=e.constructor)==null?void 0:b.logError);if(a||g){if(m)u=p;else if(g)u=p.message||"";else{if(!a)return;if(p===void 0)u="";else try{u=a(p)}catch(S){}}V.interfaceResult(c,t,!(g&&m),Date.now()-o+"ms",u)}}),h},i},U=s=>s;var Fo=Object.defineProperty,jo=Object.getOwnPropertyDescriptor,kr=(s,a,e,t)=>{for(var i,r=t>1?void 0:t?jo(a,e):a,n=s.length-1;n>=0;n--)(i=s[n])&&(r=(t?i(a,e,r):i(r))||r);return t&&r&&Fo(a,e,r),r};const Vi=(Ye=class extends se{constructor(e,t,i,r=It.prod){super();f(this,"messageCenter");f(this,"authInfo");f(this,"userName");f(this,"channelProfile");f(this,"clientRole");f(this,"slsReporter");f(this,"reconnectData");f(this,"roomServerUri","");this.channelProfile=e,this.clientRole=t,this.slsReporter=i,this.reconnectData={role:{channelprofile:e,clientrole:t}};const n=r===It.pre?Ii.pre:Ii.prod;this.roomServerUri=`wss://${n}/roomserver/v1/ws`}updateReconnectData(e){var t;this.reconnectData=e,(t=this.messageCenter)==null||t.updateReconnectData(this.reconnectData)}reset(){V.info("[roomsig] reset"),this.messageCenter&&(this.messageCenter.close(),this.messageCenter=void 0),this.authInfo=void 0}join(e,t,i,r){return T(this,null,function*(){return new Promise((n,c)=>{const o={};this.authInfo=e,this.userName=t,this.messageCenter=new Cr(e,t,this.channelProfile,this.clientRole,this.slsReporter,i),this.initMessageCenter(),this.messageCenter.once("onJoinChannelResult",h=>{var l,p,u;if(V.info(`[${Ye.logName}]`,"join result: ",h),o.taskretrynum=((l=this.messageCenter)==null?void 0:l.retryCount)||0,h.code==200){(p=this.messageCenter)==null||p.sendPkgCache(),(u=this.messageCenter)==null||u.startKeepAlive();let g=h.data;g.tid=h.tid,g.users=h.data.users,g.timestamp=h.timestamp,o.est&&(o.joinconnecttc=Date.now()-o.est),this.slsReporter.reportJoinConnection(o),n(g)}else this.reset(),c(this.handleSignalError(h.code,h.reason,H.ERR_JOIN_CHANNEL_FAILED))}),this.messageCenter.once("onAuthInvalid",()=>{this.reset(),c(new O(H.ERR_JOIN_BAD_TOKEN,"join failed because authentication failed"))}),V.info(`[${Ye.logName}]`,"start ws connecting roomserver and auto join when connected");const d={appid:this.authInfo.appId,callid:this.authInfo.sessionId,channelid:this.authInfo.channelId,userid:this.authInfo.userId,nonce:this.authInfo.nonce||"",timestamp:this.authInfo.timestamp,token:this.authInfo.token,authtype:"app",tid:dt()};e.role&&(d.tokenrole=e.role),o.est=Date.now(),this.messageCenter.start(this.roomServerUri+"?"+et.queryingParam(d),r)})})}leave(){return V.info("[roomsig] leave .."),new Promise((e,t)=>{this.messageCenter?(this.messageCenter.on("onLeaveResult",(i,r)=>{V.info(`[${Ye.logName}]`,"recv leave response "+i),i===200?(this.updateReconnectData(),this.reset(),e({tid:r})):t(this.handleSignalError(i,"leave error"))}),V.info(`[${Ye.logName}]`,"send leave request"),this.messageCenter.leave()):(V.info(`[${Ye.logName}]`,"no message center, ok to leave"),e({tid:""}))})}publish(e){return new Promise((t,i)=>{var r;this.messageCenter?(this.messageCenter.once("onPublishResult",(n,c,o)=>{V.info(`[${Ye.logName}]`,"recv pubish response "+n),n===200?(this.updateReconnectData(kt(X({},this.reconnectData),{publish:{users:[e]}})),t({tid:c})):i(this.handleSignalError(n,`publish error, ${o}`))}),this.authInfo&&(e.sessionid=(r=this.authInfo.sessionId)!=null?r:""),e.callid||(e.callid=dt()),V.info(`[${Ye.logName}]`,"assign callid "+e.callid+" and send publish request"),this.messageCenter.publish(e)):i(this.handleSignalError(-1,"publish error, no message center"))})}roleUpdate(e){return new Promise((t,i)=>{this.messageCenter?(this.messageCenter.on("onRoleUpdateResult",(r,n,c)=>{var o,d;V.info(`[${Ye.logName}]`,"recv role update response "+r),r===200?((d=(o=this.reconnectData)==null?void 0:o.role)!=null&&d.clientrole&&(this.reconnectData.role.clientrole=e,this.updateReconnectData(this.reconnectData)),t({tid:n})):i(this.handleSignalError(r,`role update error, ${c}`))}),this.messageCenter.roleUpdate(e)):i(this.handleSignalError(-1,"role update error, no message center"))})}setChannelProfile(e){this.channelProfile=e}refreshUrl(e){return V.info(`[${Ye.logName}]`,"refreshUrl .."),new Promise((t,i)=>{this.messageCenter?(this.messageCenter.on("onRefreshUrlResult",r=>{const{code:n,description:c,data:o={}}=r||{};V.info("recv refresh url response "+n),n===200?t(o):i(this.handleSignalError(n,`refresh url error, ${c}`))}),V.info("send refresh url request"),this.messageCenter.refreshUrl(e)):i(this.handleSignalError(-1,"refresh url error, no message center"))})}reportStatus(e){return V.info(`[${Ye.logName}]`,"reportStatus "+e),new Promise((t,i)=>{this.messageCenter?(this.messageCenter.once("onStatusReport",(r,n)=>{r===200?t():i(new O(r,n))}),this.messageCenter.reportStatus(e)):i(new O(-1,"No messageCenter"))})}handleSignalError(e,t,i=H.ERR_INNER){return new O(i,`signal error: code - ${e}; description - ${t}`)}refreshAuthInfo(e){return T(this,null,function*(){var t;this.authInfo&&(this.authInfo=e,(t=this.messageCenter)==null||t.refreshAuthInfo(this.authInfo))})}initMessageCenter(){var e,t,i,r,n,c,o,d,h,l,p,u,g;(e=this.messageCenter)==null||e.on("onKeepAliveRsp",()=>{this.emit("onKeepAliveRsp")}),(t=this.messageCenter)==null||t.on("onNotifyJoin",m=>{this.emit("onNotifyJoin",m)}),(i=this.messageCenter)==null||i.on("onNotifyStatus",m=>{this.emit("onNotifyStatus",m)}),(r=this.messageCenter)==null||r.on("onNotifyLeave",m=>{this.emit("onNotifyLeave",m)}),(n=this.messageCenter)==null||n.on("onNotifyPublish",m=>{this.emit("onNotifyPublish",m)}),(c=this.messageCenter)==null||c.on("onBye",(m,b)=>{this.emit("onBye",m,b)}),(o=this.messageCenter)==null||o.on("onReconnectStart",()=>{this.emit("onReconnectStart")}),(d=this.messageCenter)==null||d.on("onReconnectSuccess",m=>{this.emit("onReconnectSuccess",m)}),(h=this.messageCenter)==null||h.on("onReconnectFail",m=>{this.emit("onReconnectFail",m)}),(l=this.messageCenter)==null||l.on("onConnectFail",m=>{this.emit("onConnectFail",m),this.reset()}),(p=this.messageCenter)==null||p.on("onNetworkError",m=>{this.emit("onNetworkError",m)}),(u=this.messageCenter)==null||u.on("onAuthInvalid",()=>{this.emit("onAuthInvalid")}),(g=this.messageCenter)==null||g.on("onUnknownMessage",m=>{this.emit("onUnknownMessage",m)})}},f(Ye,"logName","RoomServerSignaling"),Ye);kr([C()],Vi.prototype,"join",1),kr([C()],Vi.prototype,"publish",1),kr([C()],Vi.prototype,"roleUpdate",1);let zo=Vi;const Wo=6e5,Ri=class Ri extends se{constructor(e,t){super();f(this,"env");f(this,"authInfo");f(this,"timer");f(this,"slsReporter");f(this,"expiration",0);f(this,"skipTime",0);f(this,"requestToken",()=>T(this,null,function*(){if(this.skipTime=0,!this.authInfo)return;const{appId:e,channelId:t,userId:i,nonce:r="",token:n,timestamp:c,sessionId:o,role:d}=this.authInfo;let h="https://gw.rtn.aliyuncs.com";this.env===It.pre&&(h="https://pgw.rtn.aliyuncs.com");const l=`${h}/gslb/v1/stsupdate?appid=${e}&channelid=${t}&userid=${i}&nonce=${r}&token=${n}&timestamp=${c}&session=${o}${d?`&tokenrole=${d}`:""}&slstoken=true&osstoken=true&tokensid=false`,p=Date.now();fetch(l).then(u=>u.json()).then(u=>{var g,m;if(u.code!==0)throw new Error;{const b=(g=u.data)==null?void 0:g.oss,S=(m=u.data)==null?void 0:m.sls;this.expiration=b.expiration||S.expiration,this.emit("onTokenUpdate",b,S),V.event(`[${Ri.logName}]`,"getToken",b,S)}this.slsReporter.reportSTSResult(200,p)}).catch(u=>{this.slsReporter.reportSTSResult(-1,p),V.error(`[${Ri.logName}]`,"getToken",u.message)})}));this.slsReporter=e,this.env=t}refreshAuthInfo(e){this.authInfo=e}startSTSUpdate(e){this.authInfo=e,this.requestToken(),this.timer&&clearInterval(this.timer),this.timer=window.setInterval(()=>{this.expiration&&Math.floor((Date.now()+9e5)/1e3)<this.expiration&&this.skipTime<12?this.skipTime+=1:this.requestToken()},Wo)}clear(){this.timer&&clearInterval(this.timer)}};f(Ri,"logName","StsManager");let Pr=Ri;var Ko=Object.defineProperty,$o=Object.getOwnPropertyDescriptor;class Dr extends se{constructor(e,t,i,r=It.prod){super();f(this,"signaling");f(this,"authInfo");f(this,"userName");f(this,"channelProfile");f(this,"clientRole");f(this,"env",It.prod);f(this,"maxConnectRetryCount");f(this,"stsManager");f(this,"slsReporter");this.channelProfile=e,this.clientRole=t,this.env=r,this.slsReporter=i,this.stsManager=new Pr(i,r)}reset(){var e;V.info("[signalingmanager] reset"),(e=this.signaling)==null||e.reset(),this.stsManager.clear(),this.signaling=void 0,this.authInfo=void 0}join(e,t=e.userId,i,r,n){return this.maxConnectRetryCount=i,this.userName=t,new Promise((c,o)=>{this.signaling?o(new O(H.ERR_JOIN_ALREADY_JOINED,"already joined")):(V.info("[signalingmanager] create signaling"),this.signaling=new zo(this.channelProfile,this.clientRole,this.slsReporter,this.env),this.initSignaling(),r&&(r.rs=Date.now()),this.signaling.join(e,t,i,n).then(d=>{this.authInfo=e,r&&(r.re=Date.now()),c(d)}).catch(d=>{this.reset(),o(d)}),this.stsManager.startSTSUpdate(e))})}retryJoin(){const e=this.authInfo;this.reset(),e&&this.join(e,this.userName,this.maxConnectRetryCount)}leave(){return new Promise((e,t)=>{this.signaling?this.signaling.leave().then(i=>{this.reset(),e(i)}).catch(i=>{t(i)}):e({tid:""})})}publish(e){return new Promise((t,i)=>{var r;this.signaling&&this.authInfo?(e.userid=this.authInfo.userId,e.displayname=(r=this.userName)!=null?r:this.authInfo.userId,this.signaling.publish(e).then(n=>{t(n)}).catch(n=>{i(n)})):i(new O(H.ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL,"no signaling"))})}reportStatus(e){return new Promise((t,i)=>{this.signaling?this.signaling.reportStatus(e).then(()=>{t()}).catch(r=>{i(r)}):i(new O(-1,"no signaling"))})}setClientRole(e){return T(this,null,function*(){const t=this.clientRole;if(!this.signaling)return void(this.clientRole=e);const i=Date.now();try{const r=yield this.signaling.roleUpdate(e);return this.slsReporter.reportRoleUpdateResult(t,e,Date.now()-i,0),r}catch(r){this.slsReporter.reportRoleUpdateResult(t,e,Date.now()-i,r.code||-1)}})}setChannelProfile(e){this.signaling?this.signaling.setChannelProfile(e):this.channelProfile=e}refreshUrl(e){return this.signaling?this.signaling.refreshUrl(e):Promise.reject(new O(H.ERR_SDK_INVALID_STATE,"should join first"))}refreshAuthInfo(e){return T(this,null,function*(){var t;try{this.authInfo&&(this.authInfo=X(X({},this.authInfo),e),(t=this.signaling)==null||t.refreshAuthInfo(this.authInfo),this.stsManager.refreshAuthInfo(this.authInfo))}catch(i){throw i}})}initSignaling(){var e,t,i,r,n,c,o,d,h,l,p,u,g,m;(e=this.signaling)==null||e.on("onKeepAliveRsp",this.onKeepAliveRsp.bind(this)),(t=this.signaling)==null||t.on("onNotifyJoin",this.onNotifyJoin.bind(this)),(i=this.signaling)==null||i.on("onNotifyStatus",this.onNotifyStatus.bind(this)),(r=this.signaling)==null||r.on("onNotifyLeave",this.onNotifyLeave.bind(this)),(n=this.signaling)==null||n.on("onNotifyPublish",this.onNotifyPublish.bind(this)),(c=this.signaling)==null||c.on("onBye",this.onBye.bind(this)),(o=this.signaling)==null||o.on("onReconnectStart",this.onReconnectStart.bind(this)),(d=this.signaling)==null||d.on("onReconnectSuccess",this.onReconnectSuccess.bind(this)),(h=this.signaling)==null||h.on("onReconnectFail",this.onReconnectFail.bind(this)),(l=this.signaling)==null||l.on("onConnectFail",this.onConnectFail.bind(this)),(p=this.signaling)==null||p.on("onNetworkError",this.onNetworkError.bind(this)),(u=this.signaling)==null||u.on("onAuthInvalid",this.onAuthInvalid.bind(this)),(g=this.signaling)==null||g.on("onError",this.onError.bind(this)),(m=this.signaling)==null||m.on("onUnknownMessage",this.onUnknownMessage.bind(this))}onKeepAliveRsp(){this.emit("onKeepAliveRsp")}onNotifyJoin(e){this.emit("onNotifyJoin",e)}onNotifyStatus(e){this.emit("onNotifyStatus",e)}onNotifyLeave(e){this.emit("onNotifyLeave",e)}onNotifyPublish(e){this.emit("onNotifyPublish",e)}onBye(e,t){this.emit("onBye",e,t)}onConnectFail(e){this.reset(),this.emit("onConnectFail",e)}onNetworkError(e){this.emit("onNetworkError",e)}onAuthInvalid(){}onReconnectStart(){this.emit("onReconnectStart")}onReconnectSuccess(e){this.emit("onReconnectSuccess",e)}onReconnectFail(e){this.emit("onReconnectFail",e)}onError(e){this.emit("onError",e)}onUnknownMessage(e){this.emit("onUnknownMessage",e)}}f(Dr,"logName","SignalingManager");function si(){}((s,a,e,t)=>{for(var i,r=t>1?void 0:t?$o(a,e):a,n=s.length-1;n>=0;n--)(i=s[n])&&(r=(t?i(a,e,r):i(r))||r);t&&r&&Ko(a,e,r)})([C(U)],Dr.prototype,"publish",1);const Xt=class Xt{static getInstance(){var a;return Xt.instance||(Xt.instance=new AudioContext),(a=Xt.instance.resume())==null||a.then(si,si).catch(si),Xt.instance}};f(Xt,"instance");let $t=Xt;const Oi=()=>{var a;const s=$t.getInstance();s.state!=="running"&&s.state!=="closed"&&((a=s.resume())==null||a.then(si,si).catch(si)),window.removeEventListener("mousedown",Oi),window.removeEventListener("touchstart",Oi)};window.addEventListener("mousedown",Oi),window.addEventListener("touchstart",Oi);class Jo extends se{constructor(){super();f(this,"audioContext");f(this,"stream");f(this,"sourceNode");f(this,"analyser");this.audioContext=$t.getInstance(),this.stream=new MediaStream}getLevel(){return this.analyser?this.analyser.getLevel():0}start(e,t=1e3){this.sourceNode&&this.stop(),this.stream.addTrack(e),this.sourceNode=this.audioContext.createMediaStreamSource(this.stream);const i=this.audioContext.createMediaStreamDestination();this.analyser=function(r,n,c,o,d){let h,l=o,p=0;const u=r.createAnalyser();u.fftSize=256;const g=new Uint8Array(u.frequencyBinCount);n.connect(u),u.connect(c);const m=()=>{h&&window.clearInterval(h)},b=()=>{r.state==="suspended"&&r.resume(),h=window.setInterval(()=>{u.getByteFrequencyData(g);let S=Math.round(g.reduce((v,_)=>v+_)/g.length);S=Math.min(100,S),p=S,d&&d(S)},l)};return b(),{updateInterval:S=>{m(),l=S,b()},getLevel:()=>p,dispose:()=>{m(),n.disconnect(),u.disconnect()}}}(this.audioContext,this.sourceNode,i,t,r=>{this.emit("audioLevel",r)})}stop(){this.analyser&&this.analyser.dispose(),this.analyser=void 0,this.sourceNode=void 0,this.stream.getAudioTracks().forEach(e=>{this.stream.removeTrack(e)})}dispose(){this.stop()}}class Ha extends se{constructor(e,t,i,r){super();f(this,"uid");f(this,"name");f(this,"rtsManager");f(this,"callId","");f(this,"audioLevelMonitor");f(this,"audioVolumeIndicationInterval",0);this.uid=e,this.name=t,this.rtsManager=i,this.audioVolumeIndicationInterval=r,this.audioLevelMonitor=new Jo}get userId(){return this.uid}get displayname(){return this.name}createCallId(){this.callId||(this.callId=et.createCallid())}setUserInfo(e,t){this.uid=e,this.name=t}refreshUserInfo(e){this.uid=e}getAudioLevel(){return this.audioLevelMonitor.getLevel()}enableAudioVolumeIndication(e){this.audioVolumeIndicationInterval=e}clear(){this.audioLevelMonitor.dispose()}}class Fa{static getCurrentStatus(a){let e=0;a.micOpen&&(e+=1),a.micInterrupted&&(e+=2),a.cameraOpen&&(e+=4),a.screenShare&&(e+=128),a.audioDisable&&(e+=8),a.videoDisable&&(e+=16),a.screenDisable&&(e+=256);let t=e.toString(16);for(;t.length<16;)t="0"+t;return t}static parseStatus(a){let e=parseInt(a,16);return{micOpen:!!(1&e),micInterrupted:!!(2&e),cameraOpen:!!(4&e),screenShare:!!(128&e),audioDisable:!!(8&e),videoDisable:!!(16&e),screenDisable:!!(256&e),backgroundMode:!!(32&e),accompanyPlaying:!!(64&e)}}}const ja="customVideoProfile",za="customScreenProfile",Mr={width:1280,height:720,frameRate:30,maxBitrate:2e3},Wa={width:1920,height:1080,frameRate:30,maxBitrate:2600};var gi=(s=>(s[s.ERROR_DEVICE_UNKNOWNERROR=1e4]="ERROR_DEVICE_UNKNOWNERROR",s[s.ERROR_DEVICE_AUDIODEVICE_NOTFOUND=10001]="ERROR_DEVICE_AUDIODEVICE_NOTFOUND",s[s.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED=10002]="ERROR_DEVICE_AUDIODEVICE_NOTALLOWED",s[s.ERROR_DEVICE_AUDIODEVICE_NOTREADABLE=10003]="ERROR_DEVICE_AUDIODEVICE_NOTREADABLE",s[s.ERROR_DEVICE_VIDEODEVICE_NOTFOUND=10004]="ERROR_DEVICE_VIDEODEVICE_NOTFOUND",s[s.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED=10005]="ERROR_DEVICE_VIDEODEVICE_NOTALLOWED",s[s.ERROR_DEVICE_VIDEODEVICE_NOTREADABLE=10006]="ERROR_DEVICE_VIDEODEVICE_NOTREADABLE",s[s.ERROR_SCREENSHARE_NOTSUPPORT=10010]="ERROR_SCREENSHARE_NOTSUPPORT",s[s.ERROR_SCREENSHARE_NOTALLOWED=10011]="ERROR_SCREENSHARE_NOTALLOWED",s[s.ERROR_SCREENSHARE_ENDED=10012]="ERROR_SCREENSHARE_ENDED",s[s.ERROR_SCREENSHARE_NOPERMISSION=10013]="ERROR_SCREENSHARE_NOPERMISSION",s[s.ERROR_SCREENSHARE_SAFARI_INVALIDACCESS=10014]="ERROR_SCREENSHARE_SAFARI_INVALIDACCESS",s[s.ERROR_SCREENSHARE_UNKNOWNERRO=10019]="ERROR_SCREENSHARE_UNKNOWNERRO",s[s.ERROR_DEVICE_NOTSUPPORT=2e4]="ERROR_DEVICE_NOTSUPPORT",s))(gi||{});const Go={1e4:Oe.AliEngineLocalDeviceExceptionTypeUnknown,2e4:Oe.AliEngineLocalDeviceExceptionTypeUnknown,10001:Oe.AliEngineLocalDeviceExceptionTypeMicNotAvailable,10002:Oe.AliEngineLocalDeviceExceptionTypeMicAuthFail,10003:Oe.AliEngineLocalDeviceExceptionTypeMicOpenFail,10005:Oe.AliEngineLocalDeviceExceptionTypeCameraAuthFail,10004:Oe.AliEngineLocalDeviceExceptionTypeVideoDeviceException,10006:Oe.AliEngineLocalDeviceExceptionTypeCameraOpenFail,10010:Oe.AliEngineLocalDeviceExceptionTypeDisplayException,10011:Oe.AliEngineLocalDeviceExceptionTypeDisplayException,10012:Oe.AliEngineLocalDeviceExceptionTypeDisplayException,10013:Oe.AliEngineLocalDeviceExceptionTypeDisplayException,10014:Oe.AliEngineLocalDeviceExceptionTypeDisplayException,10019:Oe.AliEngineLocalDeviceExceptionTypeDisplayException};var ot=(s=>(s.CREATE_ENGINE="create_engine",s.JOIN="join",s.WANT_INSERT_PUB_TASK="wantInsertPubTask",s.INSERT_PUB_TASK="InsertPubTask",s.HANDLE_PUB_TASK="HandlePubTask",s.RECV_NOTIFY_PUBLISH="RecvNotifyPublish",s.INSERT_SUB_TASK="InsertSubTask",s.HANDLE_SUB_TASK="HandleSubTask",s.FIRST_REMOTE="first_remote",s))(ot||{}),lt=(s=>(s.START="start",s.SEND_SIG="send_sig",s.RECV_RST="recv_rst",s.END="end",s.RECEIVED="received",s.DECODED="decoded",s.PLAYED="played",s))(lt||{});function Ka(s){var a;if(((a=s==null?void 0:s.nodeName)==null?void 0:a.toLowerCase())==="video")return s.setAttribute("playsinline",""),s;if(typeof s=="string"){let e=document.getElementById(s);if(e){if(e.nodeName.toLocaleLowerCase()==="video")return e.setAttribute("playsinline",""),e;throw new O(H.ERR_INVALID_ARGUMENTS,"element should be HtmlVideoElement")}throw new O(H.ERR_INVALID_ARGUMENTS,"element not founded")}throw new O(H.ERR_INVALID_ARGUMENTS,"element id should be string")}function Nr(s){var e;const a=[];if(Array.isArray(s))s.forEach(t=>{try{a.push(Ka(t))}catch(i){}});else if(typeof s=="string"||((e=s==null?void 0:s.nodeName)==null?void 0:e.toLowerCase())==="video")try{a.push(Ka(s))}catch(t){}return a}function Lt(s){return new Promise(a=>setTimeout(a,s))}function $a(s,a,e=1e3,t=i=>!0){return T(this,null,function*(){let i=0;for(;i<a;)try{return yield s(i)}catch(r){if(i++,i>=a||!t(r))throw r||void 0;yield new Promise(n=>setTimeout(n,e))}})}function Ja(s,a){let e=a;return typeof window.__ali_prefer_media_server=="string"&&window.__ali_prefer_media_server!==""&&(e=window.__ali_prefer_media_server),e?`${s}&ali_prefer_media_server=${e}`:s}function fi(s,a){var e;try{const{archCfgs:t}=s;if(!t||!Array.isArray(t))return;const i=t.find(r=>r.arch==="grtn");return i?(e=i.user_specified)==null?void 0:e[a]:void 0}catch(t){return}}function Si(s,a){try{const{config:e}=s;return e?e==null?void 0:e[a]:void 0}catch(e){return}}const Ga=(s,a,e=!1)=>{const t=()=>(s.muted=!0,Promise.race([Lt(500),s._playPromise||Promise.resolve()]).catch(()=>{}).then(()=>{let i;return e&&s.srcObject===a?i=Promise.resolve():(s.load(),s.srcObject=a,i=s.play(),s._playPromise=i),i}));return new Promise(i=>{if(q.AliRTS.BrowserUtil.isMicroMessenger){const r=window.top!==window.self,n=window.WeixinJSBridge||window.top.WeixinJSBridge;n?n.invoke("getNetworkType",{},()=>{i(t())}):(r?window.top.document:document).addEventListener("WeixinJSBridgeReady",()=>{n.invoke("getNetworkType",{},()=>{i(t())})}),setTimeout(()=>{i(t())},1e3)}else setTimeout(()=>{i(t())},0)})},Rt=s=>{Promise.race([Lt(100),s._playPromise||Promise.resolve()]).catch(()=>{}).then(()=>{s.srcObject=null,s._playPromise=void 0})};var Lr=(s=>(s[s.AliEngineDataMsgNone=0]="AliEngineDataMsgNone",s[s.AliEngineDataMsgMusicProgress=1]="AliEngineDataMsgMusicProgress",s[s.AliEngineDataMsgCustom=2]="AliEngineDataMsgCustom",s))(Lr||{});class Ui{constructor(a,e,t,i=0){f(this,"msgType");f(this,"msgId");f(this,"protocolVersion");f(this,"tlvVersion");this.msgType=a,this.msgId=e,this.protocolVersion=t,this.tlvVersion=i}build(){const a=new Uint8Array(4);return a.set(Uint8Array.from([this.protocolVersion,this.tlvVersion<<4|15&this.msgType]),0),a.set(Uint16Array.from([this.msgId]),2),a}static parse(a){const e=new DataView(a),t=e.getUint8(0),i=e.getUint8(1)>>4,r=15&e.getUint8(1),n=e.getUint16(2);return new Ui(r,n,t,i)}}class Bi{constructor(a,e,t){f(this,"_byteArray");if(this._byteArray=new Uint8Array(0),a!==void 0&&e!==void 0&&t!==void 0){const i=new Ui(a,e,t).build();this._byteArray=new Uint8Array(i.byteLength+this._byteArray.byteLength),this._byteArray.set(i,0)}}write(a,e){const t=this._byteArray,i=new ArrayBuffer(5),r=new DataView(i);r.setUint8(0,a),r.setUint32(1,e.byteLength);const n=new Uint8Array(t.byteLength+5+e.byteLength);n.set(t,0),n.set(new Uint8Array(i),t.byteLength),n.set(new Uint8Array(e),t.byteLength+5),this._byteArray=n}static parse(a){const e={},t=new DataView(a);let i=0;for(;i<a.byteLength;){const r=t.getUint8(i),n=t.getUint32(i+1);if(!(i+5+n<=a.byteLength))break;{const c=a.slice(i+5,i+5+n);e[r]=c,i+=5+n}}return e}get buffer(){return this._byteArray.buffer}}class bi{constructor(a=0,e=!0,t=1,i=!1,r=0,n=!1,c=!1,o=3){f(this,"_fin",!0);f(this,"_hasExtension",!1);f(this,"_version",0);f(this,"_frameType",1);f(this,"_isEncrypted",!1);f(this,"_isCompressed",!1);f(this,"_signalType",3);f(this,"_payloadLength",0);this._fin=e,this._hasExtension=i,this._version=r,this._frameType=t,this._isEncrypted=n,this._isCompressed=c,this._signalType=o,this._payloadLength=a}get fin(){return this._fin}get hasExtension(){return this._hasExtension}get version(){return this._version}get frameType(){return this._frameType}get isEncrypted(){return this._isEncrypted}get isCompressed(){return this._isCompressed}get signalType(){return this._signalType}get payloadLength(){return this._payloadLength}toBuffer(){const a=new ArrayBuffer(4),e=new DataView(a);return e.setUint8(0,(this._fin?1:0)<<7|(this._hasExtension?1:0)<<6|this._version<<4|15&this._frameType),e.setUint8(1,(this._isEncrypted?1:0)<<7|(this._isCompressed?1:0)<<6|15&this._signalType),e.setUint16(2,this._payloadLength),a}static parse(a){const e=new DataView(a),t=e.getUint8(0)>>7==1,i=(64&e.getUint8(0))>>6==1,r=(48&e.getUint8(0))>>4,n=15&e.getUint8(0),c=e.getUint8(1)>>7==1,o=(64&e.getUint8(1))>>6==1,d=15&e.getUint8(1),h=e.getUint16(2);return new bi(h,t,n,i,r,c,o,d)}}class Hi{constructor(a,e){f(this,"_body");f(this,"_header",new bi);this._header=a,this._body=e}get header(){return this._header}get isFin(){return this._header.fin}get body(){return this._body}toGRTNBuffer(){const a=this._header.toBuffer(),e=this._body,t=new ArrayBuffer(4);new DataView(t).setUint8(0,1*Math.pow(2,4));const i=new Uint8Array(t.byteLength+a.byteLength+e.byteLength);return i.set(new Uint8Array(t),0),i.set(new Uint8Array(a),t.byteLength),i.set(new Uint8Array(e),t.byteLength+a.byteLength),i.buffer}static parse(a){const e=a.slice(0,4),t=bi.parse(e);let i=new ArrayBuffer(0);return a.byteLength-4>=t.payloadLength&&(i=a.slice(4,4+t.payloadLength)),new Hi(t,i)}}const xr=s=>{const a=s.byteLength,e=new DataView(s);let t=0;for(let i=0;i<a;i++)t=256*t+e.getUint8(i);return t};let qa=0;class xt{constructor(a,e=0,t=0,i=0){f(this,"data");f(this,"networkTime");f(this,"futureOrProgress");f(this,"type");this.data=a,this.type=e,this.networkTime=t,this.futureOrProgress=i}toBuffer(){const a=new Bi(0,0,0);a.write(1,Uint8Array.from([0]).buffer),a.write(2,Uint16Array.from([0]).buffer),qa++,a.write(3,Uint32Array.from([qa]).buffer);const e=new Bi;return e.write(1,Uint8Array.from([0]).buffer),e.write(2,Uint8Array.from([this.type]).buffer),e.write(3,Uint32Array.from([this.futureOrProgress]).buffer),e.write(4,Uint32Array.from([Number(this.networkTime>>32&4294967295),Number(4294967295&this.networkTime)]).buffer),e.write(5,this.data),a.write(30,e.buffer),a.buffer}static parse(a){if(!a||a.byteLength<4)return;Ui.parse(a.slice(0,4));const e=Bi.parse(a.slice(4))[30];if(!e)return;const t=Bi.parse(e),i=t[2],r=t[3],n=t[4],c=t[5];return c.byteLength!==0?new xt(c,xr(i),xr(n),xr(r)):void 0}}var qo=Object.defineProperty,Xo=Object.getOwnPropertyDescriptor,Ce=(s,a,e,t)=>{for(var i,r=t>1?void 0:t?Xo(a,e):a,n=s.length-1;n>=0;n--)(i=s[n])&&(r=(t?i(a,e,r):i(r))||r);return t&&r&&qo(a,e,r),r};class vi extends se{constructor(){super();f(this,"_state");f(this,"time");this._state=ie.AliRtcStatePublishIdle,this.time=Date.now()}get state(){return this._state}setState(e){const t=this._state,i=this.time;this._state=e,this.time=Date.now(),this.emit("change",t,e,Math.floor((this.time-i)/1e3))}}const Ie=(Ct=class extends Ha{constructor(e){const{rtsManager:t,localStreamManager:i,slsReporter:r,signalingManager:n,audioVolumeIndicationInterval:c,parameter:o}=e;super("","",t,c);f(this,"_url","");f(this,"joinTime",0);f(this,"publishPromise",Promise.resolve({traceId:"",l1ip:void 0}));f(this,"previewElements",[]);f(this,"screenPreviewElements",[]);f(this,"streamManager");f(this,"dc");f(this,"streamTracks");f(this,"publishId",dt());f(this,"signalingManager");f(this,"traceId","");f(this,"monitorTimerId");f(this,"monitorDataCache",{});f(this,"trackTraceIdMap",{});f(this,"candidateDataCache",[]);f(this,"pcMediaStatsMap",{});f(this,"slsReporter");f(this,"audioPubState");f(this,"videoPubState");f(this,"videoSmallPubState");f(this,"screenPubState");f(this,"dataPubState");f(this,"parameter",{});f(this,"onTrackEnd",e=>{this.emit(e)});this.streamManager=i,this.signalingManager=n,this.slsReporter=r,this.parameter=o,this.streamManager.on("trackended",d=>{this.onTrackEnd(d)}),this.streamManager.on("publishupdate",()=>{this.publishUpdate()}),this.audioPubState=new vi,this.audioPubState.on("change",(d,h,l)=>{this.emit("audioPublishStateChanged",d,h,l)}),this.videoPubState=new vi,this.videoPubState.on("change",(d,h,l)=>{this.emit("videoPublishStateChanged",d,h,l)}),this.videoSmallPubState=new vi,this.videoSmallPubState.on("change",(d,h,l)=>{this.emit("dualStreamPublishStateChanged",d,h,l)}),this.screenPubState=new vi,this.screenPubState.on("change",(d,h,l)=>{this.emit("screenPublishStateChanged",d,h,l)}),this.dataPubState=new vi,this.dataPubState.on("change",(d,h,l)=>{this.emit("dataPublishStateChanged",d,h,l)}),this.startStreamMonitor()}get url(){return this._url}set url(e){this._url=e,this.rtsManager.updateAuth(e)}get joined(){return!!this.uid}get isPublishing(){return this.rtsManager.publishingTracks.length>0}get publishStreams(){return this.streamManager.publishStreams}get cameraTrack(){return this.streamManager.cameraStreamInfo.originVideoTrack}get screenTrack(){return this.streamManager.screenStreamInfo.originVideoTrack}get audioTrack(){return this.streamManager.cameraStreamInfo.originAudioTrack}get hasCamera(){return!!this.streamManager.cameraStreamInfo.originVideoTrack}get hasMicrophone(){return!!this.streamManager.cameraStreamInfo.originAudioTrack}get hasScreenShare(){return!!this.streamManager.screenStreamInfo.originVideoTrack}get hasCameraTrackInMS(){var e;return!!((e=this.streamTracks)!=null&&e.find(({ssrc:t,type:i,msid:r})=>i==="video"&&t&&r===M.VideoLarge))}get hasCameraDualTrackInMS(){var e;return!!((e=this.streamTracks)!=null&&e.find(({ssrc:t,type:i,msid:r})=>i==="video"&&t&&r===M.VideoSmall))}get hasScreenTrackInMS(){var e;return!!((e=this.streamTracks)!=null&&e.find(({ssrc:t,type:i,msid:r})=>i==="video"&&t&&r===M.Screen))}get hasAudioTrackInMS(){var e;return!!((e=this.streamTracks)!=null&&e.find(({ssrc:t,type:i,msid:r})=>i==="audio"&&t&&r===M.Audio))}get cameraDirection(){var e,t;return(t=(e=this.streamManager.cameraStreamInfo)==null?void 0:e.cameraVideoConstraints)==null?void 0:t.facingMode}get audioCaptureDisabled(){return this.streamManager.audioCaptureDisabled}get cameraCaptureDisabled(){return this.streamManager.cameraCaptureDisabled}get publishLocalVideoStreamEnabled(){return this.streamManager.publishLocalVideoStreamEnabled}get publishLocalAudioStreamEnabled(){return this.streamManager.publishLocalAudioStreamEnabled}get publishLocalScreenStreamEnabled(){return this.streamManager.publishLocalScreenStreamEnabled}setPublishLocalAudioStreamEnabled(e){this.streamManager.publishLocalAudioStreamEnabled=e}setPublishLocalVideoStreamEnabled(e){this.streamManager.publishLocalVideoStreamEnabled=e}setPublishLocalScreenStreamEnabled(e){this.streamManager.publishLocalScreenStreamEnabled=e}initInfo(e,t){this.joinTime=Date.now(),this.rtsManager.localJoinTime=this.joinTime,this.setUserInfo(e.userId,e.userId),this.url=t,this.callId=e.sessionId||et.createCallid(),this.updatePubId()}setVideoProfile(e){return T(this,null,function*(){yield this.streamManager.setVideoProfile(ja,e)})}setVideoContentHint(e){this.streamManager.setVideoContentHint(e)}setScreenContentHint(e){this.streamManager.setScreenContentHint(e)}setAudioProfile(e){return T(this,null,function*(){yield this.streamManager.setAudioProfile(e)})}setScreenProfile(e){return T(this,null,function*(){yield this.streamManager.setScreenProfile(za,e)})}setCameraDirection(e){if(e===mi.CAMERA_FRONT)this.streamManager.setCameraVideoConstraints({facingMode:"user"});else{if(e!==mi.CAMERA_REAR)throw new O(H.ERR_CAMERA_OPEN_FAIL,`camera direction set to ${e} failed`);this.streamManager.setCameraVideoConstraints({facingMode:"environment"})}}setCameraDeviceId(e){this.streamManager.setCameraVideoConstraints({deviceId:e})}muteLocalCamera(e){this.streamManager.setCameraMuted(e),this.slsReporter.reportMute(this.callId,!e,"video")}muteLocalMic(e){this.streamManager.setAudioMuted(e),this.slsReporter.reportMute(this.callId,!e,"audio")}muteLocalScreen(e){this.streamManager.setScreenMuted(e),this.slsReporter.reportMute(this.callId,!e,"screen")}setMicrophoneDeviceId(e){this.streamManager.setMicAudioConstraints({deviceId:e})}setMicrophoneConstraints(e){this.streamManager.setMicAudioConstraints(e)}updatePubId(){this.publishId=dt()}clearPublishState(){this.streamTracks=void 0}leave(){return T(this,null,function*(){this.isPublishing&&(yield this.unPublish()),this.joinTime=0,this.dc=void 0})}clear(){return T(this,null,function*(){Gr(Ct.prototype,this,"clear").call(this),this.stopPreview(),this.resetPreviewElements(),this.resetSecondayPreviewElements(),this.clearStream(),yield this.leave(),this.streamManager.cameraCaptureDisabled=!1})}resetElement(e){this.previewElements.includes(e)&&(Rt(e),this.previewElements.splice(this.previewElements.indexOf(e),1)),this.screenPreviewElements.includes(e)&&(Rt(e),this.screenPreviewElements.splice(this.screenPreviewElements.indexOf(e),1))}setPreviewElement(e){const{videoElement:t,screen:i}=e;i?this.screenPreviewElements.includes(t)||(this.screenPreviewElements.push(t),this.preview(e)):this.previewElements.includes(t)||(this.previewElements.push(t),this.preview(e))}startDefaultCamera(e){return T(this,null,function*(){const{hasCamera:t,cameraCaptureDisabled:i,publishLocalVideoStreamEnabled:r}=this;if(!t&&!e&&!i&&r)try{yield this.startCameraCapture()}catch(n){const c=n.errorCode;let o=H.ERR_CAMERA_OPEN_FAIL;throw c===gi.ERROR_DEVICE_AUDIODEVICE_NOTFOUND?o=H.ERR_CAMERA_NOT_AVAILABLE:c===gi.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED&&(o=H.ERR_CAMERA_AUTH_FAIL),new O(o,`camera open fail: ${n.message}`)}})}startDefaultAudio(){return T(this,null,function*(){const{hasMicrophone:e,audioCaptureDisabled:t,publishLocalAudioStreamEnabled:i}=this;if(!e&&!t&&i)try{yield this.startAudioCapture()}catch(r){const n=r.errorCode;let c=H.ERR_MIC_OPEN_FAIL;throw n===gi.ERROR_DEVICE_AUDIODEVICE_NOTFOUND?c=H.ERR_MIC_NOT_AVAILABLE:n===gi.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED&&(c=H.ERR_MIC_AUTH_FAIL),new O(c,`mic open fail: ${r.message}`)}})}setViewConfig(e,t){if(e){if(![ne.AliRtcVideoTrackCamera,ne.AliRtcVideoTrackScreen].includes(t))throw new O(H.ERR_INVALID_ARGUMENTS,"set view config invalid track",{track:t});e.forEach(i=>{this.setPreviewElement({videoElement:i,screen:t===ne.AliRtcVideoTrackScreen})})}else t===ne.AliRtcVideoTrackCamera?this.stopPreview({primary:!0,screen:!1}):this.stopPreview({primary:!1,screen:!0})}startCameraCapture(){return T(this,null,function*(){return this.streamManager.cameraCaptureDisabled=!1,yield this.createLocalStream({video:!0})})}stopCameraCapture(){return T(this,null,function*(){this.streamManager.cameraCaptureDisabled=!0,yield this.stopLocalStream({video:!0})})}startAudioCapture(){return T(this,null,function*(){return this.streamManager.audioCaptureDisabled=!1,yield this.createLocalStream({audio:!0})})}stopAudioCapture(){return T(this,null,function*(){this.streamManager.audioCaptureDisabled=!0,yield this.stopLocalStream({audio:!0})})}preview(e){return T(this,null,function*(){const{videoElement:t,screen:i}=e!=null?e:{};try{let r=i?this.streamManager.screenStreamInfo.previewStream:this.streamManager.cameraStreamInfo.previewStream;if(!t)throw new O(H.ERR_INVALID_ARGUMENTS,"no video element found",{videoElement:t});return r?(Ga(t,r.mediaStream),this.setPreviewElement(e),r.mediaStream):void V.info(`[${Ct.logName}]`,"preview no stream founded")}catch(r){const n=H.ERR_INNER;throw O.fromError(r,n,"preview failed")}})}previewAll(e){return T(this,null,function*(){const{primary:t=!0,screen:i=!0}=e!=null?e:{};if(t&&this.previewElements.length)for(let r=0;r<this.previewElements.length;r++){const n=this.previewElements[r];yield this.preview({videoElement:n})}if(i&&this.screenPreviewElements.length)for(let r=0;r<this.screenPreviewElements.length;r++){const n=this.screenPreviewElements[r];yield this.preview({videoElement:n,screen:!0})}})}stopPreview(e){const{videoElement:t,primary:i=!0,screen:r=!0}=e||{};if(t){const n=this.previewElements.findIndex(c=>c===t);if(n>=0)this.previewElements.splice(n,1),Rt(t);else{const c=this.screenPreviewElements.findIndex(o=>o===t);c>=0&&(this.screenPreviewElements.splice(c,1),Rt(t))}}else i&&(this.previewElements.forEach(n=>{Rt(n)}),this.previewElements=[]),r&&(this.screenPreviewElements.forEach(n=>{Rt(n)}),this.screenPreviewElements=[])}resumePublish(){return T(this,null,function*(){yield this.startPublish(!0)})}createLocalStream(e){return T(this,null,function*(){try{if(e.video)for(let i=0;i<this.previewElements.length;i++){const r=this.previewElements[i];Rt(r)}else if(e.screen)for(let i=0;i<this.screenPreviewElements.length;i++){const r=this.screenPreviewElements[i];Rt(r)}const t=yield this.streamManager.createLocalStream(e);return t!=null&&t.audioTrack&&this.audioVolumeIndicationInterval>0&&this.audioLevelMonitor.start(t.audioTrack,this.audioVolumeIndicationInterval),e.video?this.previewAll({primary:!0}):e.screen&&this.previewAll({screen:!0}),t}catch(t){const i=Go[t.errorCode];throw i&&(e.audio?this.emit("localDeviceException",yt.AliEngineLocalDeviceTypeMic,i,""):e.video?this.emit("localDeviceException",yt.AliEngineLocalDeviceTypeCamera,i,""):e.screen?this.emit("localDeviceException",yt.AliEngineLocalDeviceTypeDisplay,i,""):this.emit("localDeviceException",yt.AliEngineLocalDeviceTypeUnknown,i,"")),t}})}stopLocalStream(e){return T(this,null,function*(){e.audio&&this.audioLevelMonitor.stop(),yield this.streamManager.stopLocalStream(e)})}compareAndPublish(e,t,i){return T(this,null,function*(){var n,c;if(!e&&!t)return;if(e&&!t){const o={};return i===M.Audio?o.audio=!0:i===M.VideoLarge||i===M.VideoSmall?(o.video=!0,o.vMsid=i):i===M.Screen&&(o.screen=!0),yield this.publishDeleteTracks(o)}const r={};if(t!=null&&t.hasVideo&&(r.isScreen=i===M.Screen,r.vMsid=i),t!=null&&t.hasAudio&&(r.aMsid=i),!e&&t)return yield this.publishAdd(t,r,!1);if(e&&t&&e.trackId!==(((n=t.videoTrack)==null?void 0:n.id)||((c=t.audioTrack)==null?void 0:c.id)))return yield this.publishReplace(t,r)})}reportAudioProfile(){const e=this.streamManager.cameraStreamInfo.audioProfile||"standard",t=q.AliRTS.AudioProfileMap.get(e);this.slsReporter.reportPublishProfile(M.Audio,{a_profile:e,bits:(t==null?void 0:t.maxBitrate)||0,samplerate:(t==null?void 0:t.sampleRate)||0,channel:(t==null?void 0:t.channelCount)||0})}reportVideoProfile(){const e=this.streamManager.cameraStreamInfo.videoProfile||"",t=q.AliRTS.VideoProfileMap.get(e);t&&this.slsReporter.reportPublishProfile(M.VideoLarge,{v_profile:e,wdth:(t==null?void 0:t.width)||0,hgt:(t==null?void 0:t.height)||0,fps:(t==null?void 0:t.frameRate)||0,bitrate:(t==null?void 0:t.maxBitrate)||0})}reportScreenProfile(){const e=this.streamManager.screenStreamInfo.videoProfile||"",t=q.AliRTS.VideoProfileMap.get(e);t&&this.slsReporter.reportPublishProfile(M.Screen,{v_profile:e,wdth:(t==null?void 0:t.width)||0,hgt:(t==null?void 0:t.height)||0,fps:(t==null?void 0:t.frameRate)||0,bitrate:(t==null?void 0:t.maxBitrate)||0})}updateDataChannel(e){e&&(this.dc=e,this.dc.datachannel&&(this.dc.datachannel.binaryType="arraybuffer"))}publishDataChannel(){return T(this,null,function*(){if(this.dataPubState.state!==ie.AliRtcStatePublishing){this.dataPubState.setState(ie.AliRtcStatePublishing);try{const e=yield this.rtsManager.publishAddDataChannel(this.url);e?(this.updateDataChannel(e),this.dataPubState.setState(ie.AliRtcStatePublished)):(this.dataPubState.setState(ie.AliRtcStateNoPublish),this.emit("publishDataError",new O(H.ERR_INNER,"publishDataError")))}catch(e){this.dataPubState.setState(ie.AliRtcStateNoPublish)}}})}startPublish(){return T(this,arguments,function*(e=!1,t=bt.MANUAL){var d;if(!this.joined)return;const i=this.streamManager.publishStreams,{audio:r,video:n,videoSmall:c,screen:o}=i;if(r||n||c||o){this.createCallId();try{const h=new Date().getTime();r&&this.audioPubState.setState(ie.AliRtcStatePublishing),n&&this.videoPubState.setState(ie.AliRtcStatePublishing),c&&this.videoSmallPubState.setState(ie.AliRtcStatePublishing),o&&this.screenPubState.setState(ie.AliRtcStatePublishing),this.publishPromise=this.rtsManager.publish(this.url,this.callId,e,t);const{traceId:l,l1ip:p}=yield this.publishPromise;this.streamTracks=this.rtsManager.publishingTracks,this.traceId=l;const u={type:Pt.Add,userid:this.userId,sessionid:"",displayname:this.name,pubid:this.publishId,resume:e,subscribe:{signal:"",pullstreamurl:this.url},l1ip:this.parameter.reportL1IP?p:void 0,callid:this.callId,tracks:this.streamTracks,traceid:l};(d=this.parameter.data)!=null&&d.enablePubDataChannel&&this.publishDataChannel().then(()=>{this.syncPublishToRoomServer(u,i,h)}),r&&(this.trackTraceIdMap[M.Audio]=l,this.reportAudioProfile()),c&&(this.trackTraceIdMap[M.VideoSmall]=l),n&&(this.trackTraceIdMap[M.VideoLarge]=l,this.reportVideoProfile()),o&&(this.trackTraceIdMap[M.Screen]=l,this.reportScreenProfile()),yield this.syncPublishToRoomServer(u,i,h),r&&this.audioPubState.setState(ie.AliRtcStatePublished),n&&this.videoPubState.setState(ie.AliRtcStatePublished),c&&this.videoSmallPubState.setState(ie.AliRtcStatePublished),o&&this.screenPubState.setState(ie.AliRtcStatePublished)}catch(h){throw r&&this.audioPubState.setState(ie.AliRtcStateNoPublish),n&&this.videoPubState.setState(ie.AliRtcStateNoPublish),c&&this.videoSmallPubState.setState(ie.AliRtcStateNoPublish),o&&this.screenPubState.setState(ie.AliRtcStateNoPublish),h}}else V.event(`[${Ct.logName}]`,"startPublish no stream founded")})}updateStreams(){return T(this,null,function*(){yield this.streamManager.updateStreams()})}publishUpdate(e){return T(this,null,function*(){var n,c,o,d,h,l;if(!this.rtsManager.isConnecting&&!this.rtsManager.isConnected)return;yield this.publishPromise;const t=this.streamManager.publishStreams;let i;const r=new Date().getTime();try{const p=(n=this.streamTracks)==null?void 0:n.find(({ssrc:w,type:y,msid:R})=>y==="audio"&&w&&R===M.Audio),u=yield this.compareAndPublish(p,t.audio,M.Audio);u&&(i=u);const g=(c=this.streamTracks)==null?void 0:c.find(({ssrc:w,type:y,msid:R})=>y==="video"&&w&&R===M.VideoLarge),m=yield this.compareAndPublish(g,t.video,M.VideoLarge);m&&(i=m);const b=(o=this.streamTracks)==null?void 0:o.find(({ssrc:w,type:y,msid:R})=>y==="video"&&w&&R===M.VideoSmall),S=yield this.compareAndPublish(b,t.videoSmall,M.VideoSmall);S&&(i=S);const v=(d=this.streamTracks)==null?void 0:d.find(({ssrc:w,type:y,msid:R})=>y==="video"&&w&&R===M.Screen),_=yield this.compareAndPublish(v,t.screen,M.Screen);if(_&&(i=_),!i){if(!(e===bt.RECONNECT&&this.rtsManager.publishingTracks.length>0))return;{if((h=this.parameter.data)!=null&&h.enablePubDataChannel){const R=this.rtsManager.getDatachannelByMsid({url:this.url,msid:M.Data});this.updateDataChannel(R)}const w=this.rtsManager.publishingTracks.find(({type:R})=>R==="video"),y=this.rtsManager.publishingTracks.find(({type:R})=>R==="audio");(w||y)&&(yield this.rtsManager.waitPublishSender(this.url,!w,w?w.msid:y==null?void 0:y.msid)),i={type:Pt.Add,userid:this.userId,sessionid:"",displayname:this.name,pubid:this.publishId,resume:!0,subscribe:{signal:"",pullstreamurl:this.url},callid:this.callId,tracks:this.rtsManager.publishingTracks,traceid:this.traceId}}}(l=this.parameter.data)!=null&&l.enablePubDataChannel&&!this.dc&&(yield this.publishDataChannel()),yield this.syncPublishToRoomServer(i,t,r)}catch(p){const{code:u}=p!=null?p:{},g=this.url;throw u===403&&g&&(yield this.refreshPushStreamUrl(),i=yield this.publishUpdate()),p}return i})}syncPublishToRoomServer(e,t,i){return T(this,null,function*(){var o;if(!e)throw new O(H.ERR_INNER,"sync publish to room server failed because no publishInfo");let r=e;if(this.dc){const c=e,{tracks:d}=c,h=Qt(c,["tracks"]);r=kt(X({},h),{tracks:[...d,{type:"data",msid:M.Data,ssrc:`${((o=this.callId)==null?void 0:o.length)>8?this.callId.substring(0,8):"web"}${this.dc.datachannel.id||"0"}`,codec:"text"}]})}const n=yield this.signalingManager.publish(r);e.signaltid=n.tid})}refreshPushStreamUrl(){return T(this,null,function*(){const e=new O(H.ERR_INNER,"refresh push stream url error"),t=this.url;if(!t)throw e;const i=yield this.signalingManager.refreshUrl({pushstreamurl:t});if(!(i!=null&&i.pushstreamurl))throw e;this.url=i.pushstreamurl})}publishAdd(e,t,i=!1,r=0){return T(this,null,function*(){this.createCallId();const n=(t==null?void 0:t.aMsid)===M.Audio,c=(t==null?void 0:t.vMsid)===M.VideoLarge,o=(t==null?void 0:t.vMsid)===M.VideoSmall,d=(t==null?void 0:t.vMsid)===M.Screen;n&&this.audioPubState.setState(ie.AliRtcStatePublishing),c&&this.videoPubState.setState(ie.AliRtcStatePublishing),o&&this.videoSmallPubState.setState(ie.AliRtcStatePublishing),d&&this.screenPubState.setState(ie.AliRtcStatePublishing);try{const h=yield this.rtsManager.publishAdd(this.url,e,this.callId,t,!1,!0);n&&(this.audioPubState.setState(ie.AliRtcStatePublished),this.reportAudioProfile(),this.trackTraceIdMap[M.Audio]=h),c&&(this.videoPubState.setState(ie.AliRtcStatePublished),this.reportVideoProfile(),this.trackTraceIdMap[M.VideoLarge]=h),o&&(this.videoSmallPubState.setState(ie.AliRtcStatePublished),this.trackTraceIdMap[M.VideoSmall]=h),d&&(this.screenPubState.setState(ie.AliRtcStatePublished),this.reportScreenProfile(),this.trackTraceIdMap[M.Screen]=h),this.streamTracks=this.rtsManager.publishingTracks;const l={type:Pt.Add,userid:this.userId,sessionid:"",displayname:this.name,pubid:this.publishId,resume:i,subscribe:{signal:"",pullstreamurl:this.url},callid:this.callId,tracks:this.streamTracks,traceid:h};return this.reportSelfDeviceStatus(),this.monitorTimerId||this.startStreamMonitor(),l}catch(h){let l=H.ERR_SDK_PUBLISH_INVAILD;if(n&&(this.audioPubState.setState(ie.AliRtcStateNoPublish),l=H.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED),c&&(this.videoPubState.setState(ie.AliRtcStateNoPublish),l=H.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED),o&&(this.videoSmallPubState.setState(ie.AliRtcStateNoPublish),l=H.ERR_SDK_PUBLISH_DUAL_STREAM_FAILED),d&&(this.screenPubState.setState(ie.AliRtcStateNoPublish),l=H.ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED),h.errorCode===15006&&r<3)return this.publishAdd(e,t,i,r+1);throw O.fromError(h,l,"publish add failed")}})}publishReplace(e,t){return T(this,null,function*(){try{yield this.rtsManager.publishReplace(this.url,e,t),this.streamTracks=this.rtsManager.publishingTracks;const i=(t==null?void 0:t.vMsid)===M.VideoLarge,r=(t==null?void 0:t.vMsid)===M.Screen;i&&this.streamManager.setVideoProfile(void 0,void 0,!0),r&&this.streamManager.setScreenProfile(void 0,void 0);const n={type:Pt.Replace,userid:this.userId,sessionid:"",pubid:this.publishId,displayname:this.name,subscribe:{signal:"",pullstreamurl:this.url},callid:this.callId,tracks:this.streamTracks};return this.reportSelfDeviceStatus(),n}catch(i){throw O.fromError(i,H.ERR_INNER,`publish replace failed, vMsid: ${t==null?void 0:t.vMsid} aMsid: ${t==null?void 0:t.aMsid}`)}})}publishDeleteTracks(e){return T(this,null,function*(){const t={type:Pt.Delete,userid:this.userId,sessionid:"",displayname:this.displayname,callid:this.callId,pubid:this.publishId,subscribe:{signal:"",pullstreamurl:this.url},tracks:[]};try{return yield this.rtsManager.publishDelete(this.url,e),this.streamTracks=this.rtsManager.publishingTracks,e.audio&&this.audioPubState.setState(ie.AliRtcStateNoPublish),e.video&&(e.vMsid===M.VideoSmall?this.videoSmallPubState.setState(ie.AliRtcStateNoPublish):this.videoPubState.setState(ie.AliRtcStateNoPublish)),e.screen&&this.screenPubState.setState(ie.AliRtcStateNoPublish),t.tracks=this.streamTracks,this.reportSelfDeviceStatus(),t}catch(i){throw O.fromError(i,H.ERR_INNER,"publish delete tracks failed")}})}publishStop(){return T(this,null,function*(){V.info(`[${Ct.logName}]`,"publishStop",{url:this.url});const e=new Date().getTime();try{const t=this.hasAudioTrackInMS,i=this.hasCameraTrackInMS,r=this.hasCameraDualTrackInMS,n=this.hasScreenTrackInMS;yield this.rtsManager.publishStop(this.url),t&&this.audioPubState.setState(ie.AliRtcStateNoPublish),i&&this.videoPubState.setState(ie.AliRtcStateNoPublish),r&&this.videoSmallPubState.setState(ie.AliRtcStateNoPublish),n&&this.screenPubState.setState(ie.AliRtcStateNoPublish),this.traceId="",Object.keys(this.monitorDataCache).forEach(o=>{this.reportPublishMonitor(o)}),this.streamTracks=[];const c={type:Pt.Stop,userid:this.userId,sessionid:"",displayname:this.displayname,callid:this.callId,pubid:this.publishId,subscribe:{signal:"",pullstreamurl:this.url},tracks:[]};return this.syncPublishToRoomServer(c,{},e),c}catch(t){throw O.fromError(t,H.ERR_INNER,"publish stop failed")}})}unPublish(){return T(this,null,function*(){const e=new Date().getTime();let t={type:Pt.UnPublish,userid:this.userId,sessionid:"",displayname:this.displayname,callid:this.callId,pubid:this.publishId,subscribe:{signal:"",pullstreamurl:this.url},tracks:[]};try{if(this.isPublishing){const i=this.hasAudioTrackInMS,r=this.hasCameraTrackInMS,n=this.hasCameraDualTrackInMS,c=this.hasScreenTrackInMS;yield this.rtsManager.unpublish(),this.streamTracks=[],this.stopStreamMonitor(),i&&this.audioPubState.setState(ie.AliRtcStateNoPublish),r&&this.videoPubState.setState(ie.AliRtcStateNoPublish),n&&this.videoSmallPubState.setState(ie.AliRtcStateNoPublish),c&&this.screenPubState.setState(ie.AliRtcStateNoPublish),this.traceId="",this.clearStream()}return this.dc&&(this.rtsManager.publishStopDataChannel(this.url,this.dc),this.dataPubState.setState(ie.AliRtcStateNoPublish),this.dc=void 0),this.slsReporter.reportUnpublish(this.callId||"",e,0,""),t}catch(i){throw O.fromError(i,H.ERR_INNER,"unpublish failed")}})}reportSelfDeviceStatus(){this.emit(Xe.Local,this.getDeviceStatus())}getDeviceStatus(){var t,i,r,n;let e={micOpen:!1,micInterrupted:!1,cameraOpen:!1,screenShare:!1,audioDisable:!0,videoDisable:!0,screenDisable:!0,backgroundMode:!1,accompanyPlaying:!1};return e.cameraOpen=this.hasCameraTrackInMS,e.videoDisable=this.hasCamera&&!((t=this.streamManager.cameraStreamInfo.originVideoTrack)!=null&&t.enabled),e.micOpen=this.hasAudioTrackInMS,e.audioDisable=this.hasMicrophone&&!((i=this.streamManager.cameraStreamInfo.originAudioTrack)!=null&&i.enabled),e.screenShare=this.hasScreenTrackInMS,e.screenDisable=this.hasScreenShare&&!((n=(r=this.streamManager.screenStreamInfo)==null?void 0:r.originVideoTrack)!=null&&n.enabled),Fa.getCurrentStatus(e)}resetPreviewElements(){this.previewElements.forEach(e=>{e.srcObject=null,e._playPromise=void 0},[]),this.previewElements=[]}resetSecondayPreviewElements(){this.screenPreviewElements.forEach(e=>{e.srcObject=null,e._playPromise=void 0},[]),this.screenPreviewElements=[]}getMediaStats(e){return this.pcMediaStatsMap[e]}reportPublishMonitor(e){if(!e)return;let t;try{t=e===M.Audio?this.rtsManager.getStreamByMsid({url:this.url,aMsid:e}).audioTrack:this.rtsManager.getStreamByMsid({url:this.url,vMsid:e}).videoTrack}catch(i){}this.slsReporter.reportPublishMonitor(this.callId,this.trackTraceIdMap[e]||"",e,t,this.monitorDataCache[e]),this.monitorDataCache[e]=[]}reportNetwork(){this.slsReporter.reportNetworkMonitor(this.candidateDataCache),this.candidateDataCache=[]}startStreamMonitor(){this.monitorTimerId||(this.monitorTimerId=window.setInterval(()=>T(this,null,function*(){var e,i;try{const r=yield this.rtsManager.getPCStats();let n,c;if(r==null||r.forEach(d=>{d.type==="media-source"||d.type==="media-playout"?d.id&&(this.pcMediaStatsMap[d.id]=d):d.type==="candidate-pair"&&d.state==="succeeded"&&(n=d)}),((e=this.candidateDataCache)==null?void 0:e.length)>0){const d=this.candidateDataCache[this.candidateDataCache.length-1]||{},t=d,{_last:h}=t;c=Qt(t,["_last"])}((i=this.candidateDataCache)==null?void 0:i.length)>=30&&this.reportNetwork(),n&&(n._last=c,this.candidateDataCache.push(n));let o=Object.keys(this.monitorDataCache).filter(d=>{var h;return((h=this.monitorDataCache[d])==null?void 0:h.length)>0});(this.streamTracks||[]).forEach(d=>{const h=d.msid;if(!h)return;let l;o.includes(h)&&(o=o.filter(p=>p!==h)),l=h===M.Audio?this.rtsManager.getPublishAudioStats(this.url):this.rtsManager.getPublishVideoStats(this.url,h),l.then(p=>{if(!p.timestamp)return;this.monitorDataCache[h]||(this.monitorDataCache[h]=[]);const u=this.getMediaStats(p.mediaSourceId);p._source=u;const g=this.monitorDataCache[h];let m;if((g==null?void 0:g.length)>0){const S=g[g.length-1]||{},b=S,{_last:v}=b;m=Qt(b,["_last"])}(g==null?void 0:g.length)>=30&&this.reportPublishMonitor(h),p._last=m,p._codec=d.codec||"",this.monitorDataCache[h].push(p)})}),o.forEach(d=>{this.reportPublishMonitor(d)})}catch(r){}}),1e3))}stopStreamMonitor(){this.monitorTimerId&&(clearInterval(this.monitorTimerId),this.monitorTimerId=void 0),Object.keys(this.monitorDataCache).forEach(e=>{this.reportPublishMonitor(e)})}clearStream(){this.streamManager.stop(),this.audioPubState.setState(ie.AliRtcStatePublishIdle),this.videoPubState.setState(ie.AliRtcStatePublishIdle),this.videoSmallPubState.setState(ie.AliRtcStatePublishIdle),this.screenPubState.setState(ie.AliRtcStatePublishIdle)}getCurrentCameraDeviceId(){var e;return(e=this.streamManager.cameraStreamInfo.originVideoTrack)==null?void 0:e.getSettings().deviceId}getCurrentMicDeviceId(){var e;return(e=this.streamManager.cameraStreamInfo.originAudioTrack)==null?void 0:e.getSettings().deviceId}enableAudioVolumeIndication(e){this.audioVolumeIndicationInterval!==e&&(this.audioVolumeIndicationInterval>0&&e<=0&&this.audioLevelMonitor.stop(),e>0&&this.streamManager.cameraStreamInfo.originAudioTrack&&this.audioLevelMonitor.start(this.streamManager.cameraStreamInfo.originAudioTrack,e),this.audioVolumeIndicationInterval=e)}sendSEI(e,t,i){return T(this,null,function*(){if(!this.url)return;let r=0;return r=!t||t<1?1:t-1,this.rtsManager.sendSEI(this.url,e,r,i)})}sendDataChannelMessage(e){var i;if(!((i=this.parameter.data)!=null&&i.enablePubDataChannel))throw new O(H.ERR_INNER,"data channel publish is not enabled");if(!this.dc)throw new O(H.ERR_INNER,"data channel is not ready");const t=function(r,n){let c=0;const o=[];for(;c<r.byteLength;){const d=Math.min(n,r.byteLength-c),h=r.slice(c,c+d);o.push(h),c+=d}return o}(e.toBuffer(),1156);t.forEach((r,n)=>{const c=new Hi(new bi(r.byteLength,n===t.length-1,n===0?1:0),r);this.dc.send(c.toGRTNBuffer())})}getStats(){return T(this,null,function*(){const e=[];if(this.hasAudioTrackInMS){const n=yield this.rtsManager.getPublishAudioStats(this.url);n&&e.push({stats:n,track:ri.AliRtcAudioTrackMic})}const t=[];if(this.hasCameraTrackInMS){const n=yield this.rtsManager.getPublishVideoStats(this.url,M.VideoLarge);n&&t.push({track:ne.AliRtcVideoTrackCamera,streamType:We.AliRtcVideoStreamTypeHigh,stats:n})}if(this.hasCameraDualTrackInMS){const n=yield this.rtsManager.getPublishVideoStats(this.url,M.VideoSmall);n&&t.push({track:ne.AliRtcVideoTrackCamera,streamType:We.AliRtcVideoStreamTypeLow,stats:n})}if(this.hasScreenTrackInMS){const n=yield this.rtsManager.getPublishVideoStats(this.url,M.Screen);n&&t.push({track:ne.AliRtcVideoTrackScreen,stats:n})}let i;const r=yield this.rtsManager.getPCStats();return r==null||r.forEach(n=>{n.type==="candidate-pair"&&n.state==="succeeded"&&(i=n)}),{audio:e,video:t,candidate:i}})}},f(Ct,"logName","LocalUser"),Ct);Ce([C()],Ie.prototype,"clearPublishState",1),Ce([C()],Ie.prototype,"clear",1),Ce([C(U)],Ie.prototype,"startDefaultCamera",1),Ce([C(U)],Ie.prototype,"startDefaultAudio",1),Ce([C()],Ie.prototype,"setViewConfig",1),Ce([C()],Ie.prototype,"startCameraCapture",1),Ce([C()],Ie.prototype,"stopCameraCapture",1),Ce([C()],Ie.prototype,"startAudioCapture",1),Ce([C()],Ie.prototype,"stopAudioCapture",1),Ce([C()],Ie.prototype,"stopPreview",1),Ce([C()],Ie.prototype,"resumePublish",1),Ce([C()],Ie.prototype,"createLocalStream",1),Ce([C()],Ie.prototype,"stopLocalStream",1),Ce([C(U)],Ie.prototype,"startPublish",1),Ce([C()],Ie.prototype,"updateStreams",1),Ce([C(U)],Ie.prototype,"publishUpdate",1),Ce([C(([s])=>[s])],Ie.prototype,"syncPublishToRoomServer",1),Ce([C()],Ie.prototype,"refreshPushStreamUrl",1),Ce([C(([s,a,e])=>[JSON.stringify(e)])],Ie.prototype,"publishAdd",1),Ce([C(([s,a])=>[JSON.stringify(a)])],Ie.prototype,"publishReplace",1),Ce([C(U)],Ie.prototype,"publishDeleteTracks",1),Ce([C()],Ie.prototype,"publishStop",1),Ce([C()],Ie.prototype,"unPublish",1),Ce([C(([s,a,e])=>[s.length,a,e])],Ie.prototype,"sendSEI",1);let Yo=Ie;var Vt=(s=>(s.OPUS="opus",s.H264="H264",s.UNKNOWN="",s))(Vt||{}),oe=(s=>(s[s.NotSubscribe=0]="NotSubscribe",s[s.Subscribing=1]="Subscribing",s[s.Subscribed=2]="Subscribed",s))(oe||{}),Jt=(s=>(s.VideoTrackEnded="videoTrackEnded",s.AudioTrackEnded="audioTrackEnded",s.ScreenTrackEnded="screenTrackEnded",s))(Jt||{});const Xa=s=>T(this,null,function*(){return yield q.AliRTS.createStream({custom:!0,mediaStream:s})}),yi=s=>T(this,null,function*(){const a=(e=>{const t=new MediaStream;return t.addTrack(e),t})(s);return yield Xa(a)});var Zo=Object.defineProperty,Qo=Object.getOwnPropertyDescriptor;class Fi extends se{constructor(){super();f(this,"audioInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Vt.UNKNOWN});f(this,"videoLargeInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Vt.UNKNOWN});f(this,"videoSmallInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Vt.UNKNOWN});f(this,"screenInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Vt.UNKNOWN});f(this,"dataInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Vt.UNKNOWN});f(this,"audioVolume",1);f(this,"audioMuted",!1);f(this,"userStatus")}getAudioInfo(){return this.audioInfo}getVideoSmallInfo(){return this.videoSmallInfo}getVideoLargeInfo(){return this.videoLargeInfo}getScreenInfo(){return this.screenInfo}getDataInfo(){return this.dataInfo}get subscribingInfos(){return[this.audioInfo,this.videoLargeInfo,this.videoSmallInfo,this.screenInfo].filter(e=>e.msid&&e.subscribeState===oe.Subscribed)}get hasTrack(){return this.hasAudio||this.hasVideo||this.hasScreen||this.hasData}get hasAudio(){return this.audioInfo.ssrc!==""}get hasVideo(){return this.videoLargeInfo.ssrc!==""||this.videoSmallInfo.ssrc!==""}get hasVideoLarge(){return this.videoLargeInfo.ssrc!==""}get hasVideoSmall(){return this.videoSmallInfo.ssrc!==""}get hasScreen(){return this.screenInfo.ssrc!==""}get hasData(){return this.dataInfo.ssrc!==""}get isAudioSubscribed(){return this.audioInfo.subscribeState===oe.Subscribed}get isAudioSubscribing(){return this.audioInfo.subscribeState===oe.Subscribing}get isVideoSubscribed(){return this.isVideoLargeSubscribed||this.isVideoSmallSubscribed}get isVideoSubscribing(){return this.isVideoLargeSubscribing||this.isVideoSmallSubscribing}get isVideoLargeSubscribed(){return this.videoLargeInfo.subscribeState===oe.Subscribed}get isVideoLargeSubscribing(){return this.videoLargeInfo.subscribeState===oe.Subscribing}get isVideoSmallSubscribed(){return this.videoSmallInfo.subscribeState===oe.Subscribed}get isVideoSmallSubscribing(){return this.videoSmallInfo.subscribeState===oe.Subscribing}get isScreenSubscribed(){return this.screenInfo.subscribeState===oe.Subscribed}get isScreenSubscribing(){return this.screenInfo.subscribeState===oe.Subscribing}get isDataSubscribed(){return this.dataInfo.subscribeState===oe.Subscribed}get isDataSubscribing(){return this.dataInfo.subscribeState===oe.Subscribing}get audioCodec(){return this.audioInfo.codec}get videoCodec(){return this.hasVideoLarge?this.videoLargeInfo.codec:this.hasVideoSmall?this.videoSmallInfo.codec:this.hasScreen?this.screenInfo.codec:Vt.UNKNOWN}get audioTrackInfo(){return this.hasAudio?ri.AliRtcAudioTrackMic:ri.AliRtcAudioTrackNo}get videoTrackInfo(){return this.hasVideo&&this.hasScreen?ne.AliRtcVideoTrackBoth:this.hasVideo?ne.AliRtcVideoTrackCamera:this.hasScreen?ne.AliRtcVideoTrackScreen:ne.AliRtcVideoTrackNo}updateTracks(e){let t="",i="",r="",n="",c="";return e?(e.forEach(o=>{var p;let d=Vt.UNKNOWN;const h=((p=o==null?void 0:o.attr)==null?void 0:p.reason)==="reconnect";if(o.userdata){const{codec:u}=JSON.parse(o.userdata);u&&(d=u)}var l;(l=o.msid)===M.Audio||l===dr.Audio?(t=o.ssrc,this.audioInfo.msid=o.msid,this.audioInfo.codec=d,(h||this.audioInfo.ssrc!==t)&&(this.audioInfo.subscribeState=oe.NotSubscribe)):(u=>u===M.VideoSmall)(o.msid)?(r=o.ssrc,this.videoSmallInfo.msid=o.msid,this.videoSmallInfo.codec=d,(h||this.videoSmallInfo.ssrc!==r)&&(this.videoSmallInfo.subscribeState=oe.NotSubscribe)):(u=>u===M.VideoLarge||u===dr.VideoLarge)(o.msid)?(i=o.ssrc,this.videoLargeInfo.msid=o.msid,this.videoLargeInfo.codec=d,(h||this.videoLargeInfo.ssrc!==i)&&(this.videoLargeInfo.subscribeState=oe.NotSubscribe)):(u=>u===M.Screen)(o.msid)?(n=o.ssrc,this.screenInfo.msid=o.msid,this.screenInfo.codec=d,(h||this.screenInfo.ssrc!==n)&&(this.screenInfo.subscribeState=oe.NotSubscribe)):(u=>u===M.Data)(o.msid)&&(c=o.ssrc,this.dataInfo.msid=o.msid,this.dataInfo.codec=d,(h||this.dataInfo.ssrc!==c)&&(this.dataInfo.subscribeState=oe.NotSubscribe))}),this.updateRemoteTrackSsrc(t,i,r,n,c)):this.updateRemoteTrackSsrc(t,i,r,n,c),{}}updateRemoteTrackSsrc(e,t,i,r,n){this.audioInfo.ssrc=e,this.videoSmallInfo.ssrc=i,this.videoLargeInfo.ssrc=t,this.screenInfo.ssrc=r,this.dataInfo.ssrc=n}markRemoteTrackSubscribing(e){return e.video&&(e.vMsid===this.videoSmallInfo.msid&&(this.videoSmallInfo.subscribeState=oe.Subscribing),e.vMsid!==this.videoLargeInfo.msid&&e.vMsid||(this.videoLargeInfo.subscribeState=oe.Subscribing)),e.screen&&(this.screenInfo.subscribeState=oe.Subscribing),e.audio&&(this.audioInfo.subscribeState=oe.Subscribing),e.data&&(this.dataInfo.subscribeState=oe.Subscribing),{videoLargeInfo:this.videoLargeInfo,videoSmallInfo:this.videoSmallInfo}}updateRemoteTrackSubState(e){return e.video!==void 0&&(e.vMsid!==this.videoSmallInfo.msid&&e.vMsid||(this.videoSmallInfo.subscribeState=e.video?oe.Subscribed:oe.NotSubscribe),e.vMsid!==this.videoLargeInfo.msid&&e.vMsid||(this.videoLargeInfo.subscribeState=e.video?oe.Subscribed:oe.NotSubscribe)),e.screen!==void 0&&(this.screenInfo.subscribeState=e.screen?oe.Subscribed:oe.NotSubscribe),e.audio!==void 0&&(this.audioInfo.subscribeState=e.audio?oe.Subscribed:oe.NotSubscribe),e.data!==void 0&&(this.dataInfo.subscribeState=e.data?oe.Subscribed:oe.NotSubscribe),{audioInfo:this.audioInfo,videoLargeInfo:this.videoLargeInfo,videoSmallInfo:this.videoSmallInfo,screenInfo:this.screenInfo,dataInfo:this.dataInfo}}updateRemoteUserDeviceStatus(e){let t=Fa.parseStatus(e);const{audioDisable:i,videoDisable:r,screenDisable:n}=t;return this.userStatus?(this.userStatus.audioDisable!=i&&(this.userStatus.audioDisable=i,this.emit(Xe.Remote,i?we.MuteAudio:we.UnmuteAudio)),this.userStatus.videoDisable!=r&&(this.userStatus.videoDisable=r,this.emit(Xe.Remote,r?we.MuteVideo:we.UnmuteVideo)),this.userStatus.screenDisable!=n&&(this.userStatus.screenDisable=n,this.emit(Xe.Remote,n?we.MuteScreen:we.UnmuteScreen))):(this.userStatus=t,this.emit(Xe.Remote,i?we.MuteAudio:we.UnmuteAudio),this.emit(Xe.Remote,r?we.MuteVideo:we.UnmuteVideo),this.emit(Xe.Remote,n?we.MuteScreen:we.UnmuteScreen)),!1}}f(Fi,"logName","RemoteStreamInfo"),((s,a,e,t)=>{for(var i,r=t>1?void 0:t?Qo(a,e):a,n=s.length-1;n>=0;n--)(i=s[n])&&(r=(t?i(a,e,r):i(r))||r);t&&r&&Zo(a,e,r)})([C()],Fi.prototype,"updateRemoteTrackSubState",1);class Ya{constructor(a){f(this,"remoteUser");this.remoteUser=a}get userId(){return this.remoteUser.userId}get displayName(){return this.remoteUser.displayname}get isMuteAudioPlaying(){return this.remoteUser.getAudioMuted()}get hasAudio(){return this.remoteUser.hasAudioTrack}get hasCamera(){return this.remoteUser.hasVideoTrack}get hasCameraLarge(){return this.remoteUser.hasVideoLargeTrack}get hasCameraSmall(){return this.remoteUser.hasVideoSmallTrack}get hasScreenShare(){return this.remoteUser.hasScreenTrack}get isAudioSubscribing(){return this.remoteUser.isAudioSubscribing}get isVideoSubscribing(){return this.remoteUser.isVideoSubscribing}get isVideoLargeSubscribing(){return this.remoteUser.isVideoLargeSubscribing}get isVideoSmallSubscribing(){return this.remoteUser.isVideoSmallSubscribing}get isScreenSubscribing(){return this.remoteUser.isScreenSubscribing}get audioElement(){return this.remoteUser.getAudioElement()}}var ec=Object.defineProperty,tc=Object.getOwnPropertyDescriptor,Je=(s,a,e,t)=>{for(var i,r=t>1?void 0:t?tc(a,e):a,n=s.length-1;n>=0;n--)(i=s[n])&&(r=(t?i(a,e,r):i(r))||r);return t&&r&&ec(a,e,r),r};class ai extends se{constructor(){super();f(this,"state");f(this,"time");f(this,"_enabled");this.state=me.AliRtcStateSubscribeIdle,this.time=Date.now(),this._enabled=!0}setState(e){if(this.state===e)return;const t=this.state,i=this.time;this.state=e,this.time=Date.now(),this.emit("change",t,e,Math.floor((this.time-i)/1e3))}get currentState(){return this.state}getEnabled(){return this._enabled}setEnabled(e){this._enabled=e}}const Ke=(Ze=class extends Ha{constructor(e){var u;const{userId:t,displayName:i,rtsManager:r,usersViewMap:n,slsReporter:c,signalingManager:o,localUser:d,audioVolumeIndicationInterval:h,playoutVolume:l,parameter:p}=e;super(t,i,r,h);f(this,"remoteCallid","");f(this,"remoteUserInfo");f(this,"localUser");f(this,"lastPubId","");f(this,"stream");f(this,"screenStream");f(this,"viewMap");f(this,"audioTrack");f(this,"audioElement");f(this,"subscribed",!1);f(this,"mediaStream");f(this,"secondaryMediaStream");f(this,"prevSubConfig");f(this,"signalingManager");f(this,"slsReporter");f(this,"wantSubAudio",!1);f(this,"wantSubVideo",!1);f(this,"wantSubScreen",!1);f(this,"defaultVideoStreamType",We.AliRtcVideoStreamTypeHigh);f(this,"audioMuted",!1);f(this,"playoutVolume",1);f(this,"playoutGainNode");f(this,"audioSubState");f(this,"videoSubState");f(this,"videoLargeSubState",new ai);f(this,"videoSmallSubState",new ai);f(this,"screenSubState");f(this,"dataSubState");f(this,"dc");f(this,"dcMsgWaitingPieces",[]);f(this,"streamInfo");f(this,"_streamUrl","");f(this,"parameter",{});f(this,"monitorTimerId");f(this,"monitorDataCache",{});f(this,"trackTraceIdMap",{});f(this,"handleAudioContextSuspended",e=>{e.target.state==="suspended"&&this.emit("remoteAudioPlayError",this.uid,"AudioContext suspended")});f(this,"onDataChannelMessage",e=>{var r;const t=Hi.parse(e.slice(4));let i;if(t.body){if(!t.isFin)return t.header.frameType===1&&(this.dcMsgWaitingPieces=[]),void this.dcMsgWaitingPieces.push(t.body);if(this.dcMsgWaitingPieces.length>0){const n=this.dcMsgWaitingPieces.reduce((c,o)=>c+o.byteLength,t.body.byteLength);try{const c=new ArrayBuffer(n);let o=0;for(let d=0;d<this.dcMsgWaitingPieces.length;d++){const h=this.dcMsgWaitingPieces[d];new Uint8Array(c,o,h.byteLength).set(new Uint8Array(h)),o+=h.byteLength}new Uint8Array(c,o,t.body.byteLength).set(new Uint8Array(t.body)),i=xt.parse(c)}catch(c){}this.dcMsgWaitingPieces=[],i||(i=xt.parse(t.body))}else i=xt.parse(t.body);i||V.event(`[${Ze.logName}]`,`parse data channel message fail, piece count: ${this.dcMsgWaitingPieces.length+1}`)}i&&(V.event(`[${Ze.logName}]`,`receive data channel message, length: ${(r=i.data)==null?void 0:r.byteLength}`),this.emit("remoteDataChannelMessage",this.uid,i))});f(this,"onDataChannelError",e=>{this.emit("occurError",O.fromError(e,H.ERR_SDK_SUBSCRIBE_DATA_ERROR))});f(this,"dataChannelConnected",e=>{e&&(this.dc=e,this.dc.datachannel&&(this.dc.datachannel.binaryType="arraybuffer"),this.dc.off("message",this.onDataChannelMessage),this.dc.off("error",this.onDataChannelError),this.dc.on("message",this.onDataChannelMessage),this.dc.on("error",this.onDataChannelError))});f(this,"handleAudioPaused",()=>{this.emit("remoteAudioPlayError",this.uid,"paused")});this.streamInfo=new Fi,this.remoteUserInfo=new Ya(this),this.parameter=p,this.streamInfo.on(Xe.Remote,g=>{this.emit(Xe.Remote,g,this.userId)}),this.signalingManager=o,this.viewMap=(u=n[t])!=null?u:{cameraViews:[],screenViews:[]},n[t]=this.viewMap,this.slsReporter=c,this.localUser=d,this.audioSubState=new ai,this.audioSubState.on("change",(g,m,b)=>{this.emit("audioSubscribeStateChanged",this.uid,g,m,b)}),this.videoSubState=new ai,this.videoSubState.on("change",(g,m,b)=>{this.emit("videoSubscribeStateChanged",this.uid,g,m,b)}),this.screenSubState=new ai,this.screenSubState.on("change",(g,m,b)=>{this.emit("screenSubscribeStateChanged",this.uid,g,m,b)}),this.dataSubState=new ai,this.dataSubState.on("change",(g,m,b)=>{this.emit("dataSubscribeStateChanged",this.uid,g,m,b)}),this.playoutVolume=l}get streamUrl(){return this._streamUrl}set streamUrl(e){this._streamUrl=e,this.rtsManager.updateAuth(e)}isWantSubAudio(){return this.wantSubAudio}setWantSubAudio(e){this.wantSubAudio=e}isWantSubVideo(){return this.wantSubVideo}setWantSubVideo(e){this.wantSubVideo=e}isWantSubScreen(){return this.wantSubScreen}setWantSubScreen(e){this.wantSubScreen=e}setRemoteDefaultVideoStreamType(e){e!==this.defaultVideoStreamType&&(this.defaultVideoStreamType=e,this.updateSubscribe(Se.User))}setAudioMuted(e){this.audioMuted=e,this.toggleAudio(!e)}getAudioElement(){return this.audioElement}setPlayoutVolume(e){if(this.playoutVolume=e,this.audioElement)if(this.parameter.enableAudioContextPlayoutVolume)if(this.playoutGainNode)this.playoutGainNode.gain.value=e;else{const t=this.audioElement.srcObject;if(t){const i=$t.getInstance();i.addEventListener("statechange",this.handleAudioContextSuspended);const r=i.createMediaStreamSource(t);this.audioElement.muted=!0,this.playoutGainNode=i.createGain(),r.connect(this.playoutGainNode),this.playoutGainNode.gain.value=e,this.playoutGainNode.connect(i.destination)}}else this.audioElement.volume=e}getAudioMuted(){return this.audioMuted}get hasAudioTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasAudio)}get hasVideoTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasVideo)}get hasVideoLargeTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasVideoLarge)}get hasVideoSmallTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasVideoSmall)}get hasScreenTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasScreen)}get isAudioSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isAudioSubscribed)||!!((t=this.streamInfo)!=null&&t.isAudioSubscribing)}get isVideoSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isVideoSubscribed)||!!((t=this.streamInfo)!=null&&t.isVideoSubscribing)}get isVideoLargeSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isVideoLargeSubscribed)||!!((t=this.streamInfo)!=null&&t.isVideoLargeSubscribing)}get isVideoSmallSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isVideoSmallSubscribed)||!!((t=this.streamInfo)!=null&&t.isVideoSmallSubscribing)}get isScreenSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isScreenSubscribed)||!!((t=this.streamInfo)!=null&&t.isScreenSubscribing)}get isDataSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isDataSubscribed)||!!((t=this.streamInfo)!=null&&t.isDataSubscribing)}get audioEnabled(){var e,t;return!!((t=(e=this.stream)==null?void 0:e.audioTrack)!=null&&t.enabled)}get videoEnabled(){var e,t;return!!((t=(e=this.stream)==null?void 0:e.videoTrack)!=null&&t.enabled)}get screenEnabled(){var e,t;return!!((t=(e=this.screenStream)==null?void 0:e.videoTrack)!=null&&t.enabled)}get getAudioTrack(){return this.audioTrack}get getCameraStream(){return this.stream}get getScreenStream(){return this.screenStream}setViewConfig(e,t){if(t!==ne.AliRtcVideoTrackScreen&&t!==ne.AliRtcVideoTrackCamera)throw new O(H.ERR_INVALID_ARGUMENTS,"track is not AliRtcVideoTrackScreen or AliRtcVideoTrackCamera");e?Nr(e).forEach(i=>{i.setAttribute("playsinline",""),q.AliRTS.BrowserUtil.isMicroMessenger&&(i.setAttribute("x5-video-player-type","h5-page"),i.setAttribute("x5-playsinline",""),q.AliRTS.SystenUtil.isAndroid||q.AliRTS.SystenUtil.isIos&&i.setAttribute("x-webkit-airplay","allow")),t===ne.AliRtcVideoTrackScreen?this.viewMap.screenViews.push(i):this.viewMap.cameraViews.push(i),this.play(i,t===ne.AliRtcVideoTrackScreen)}):(this.stopPlayAll(t===ne.AliRtcVideoTrackScreen),t===ne.AliRtcVideoTrackScreen?this.viewMap.screenViews=[]:this.viewMap.cameraViews=[])}clear(e=!0){return T(this,null,function*(){var t;this.subscribeStopDataChannel(),e&&this.doStopSubscribe(this.streamUrl),Gr(Ze.prototype,this,"clear").call(this),this.stopPlayAudio(),this.clearStream(),this.clearScreenStream(),this.playoutGainNode&&(this.playoutGainNode.disconnect(),this.playoutGainNode=void 0,$t.getInstance().removeEventListener("statechange",this.handleAudioContextSuspended)),(t=this.streamInfo)==null||t.removeAllListeners(Xe.Remote)})}updateRemoteUserDeviceStatus(e){var t;(t=this.streamInfo)==null||t.updateRemoteUserDeviceStatus(e)}updateRemoteTracks(e,t,i,r){return T(this,null,function*(){var c;return this.remoteCallid=e,this.streamUrl&&this.streamInfo.hasTrack||(this.streamUrl=t),this.callId=e!=null?e:"",this.streamInfo||(this.streamInfo=new Fi),(c=this.streamInfo)==null?void 0:c.updateTracks(r)})}subscribe(r,n){return T(this,arguments,function*(e,t,i=Date.now()){var u,g;let c=e;if(!c){const{hasAudio:m,hasVideo:b,hasScreen:S,hasData:v}=(u=this.streamInfo)!=null?u:{};c={audio:this.wantSubAudio&&m,video:this.wantSubVideo&&b,screen:this.wantSubScreen&&S,data:((g=this.parameter.data)==null?void 0:g.enableSubDataChannel)&&v}}this.streamInfo.markRemoteTrackSubscribing(c);const{screen:o,audio:d,video:h,vMsid:l}=c,p=[];(h||d)&&p.push({audio:d,video:h,vMsid:l}),o&&p.push({screen:o}),(p.length!==0||e!=null&&e.data)&&(yield Promise.all(p.map(m=>this.subscribeProxy(m,t||Se.User,i))),e!=null&&e.data&&this.subscribeDataChannel())})}subscribeProxy(e,t,i){return T(this,null,function*(){var c,o,d,h;let r=new Date().getTime(),n="";try{e.audio&&this.audioSubState.setState(me.AliRtcStateSubscribing),e.video&&(this.videoSubState.currentState!==me.AliRtcStateSubscribeIdle&&this.videoSubState.currentState!==me.AliRtcStateNoSubscribe||this.videoSubState.setState(me.AliRtcStateSubscribing)),e.screen&&this.screenSubState.setState(me.AliRtcStateSubscribing);const l=yield this.rtsManager.subscribe({remoteUser:this,options:e},t,((c=this.localUser)==null?void 0:c.callId)||"",this.callId,i);this.streamInfo.updateRemoteTrackSubState(e),n=l.traceId||"";const{stream:p}=l;if(e.audio){this.trackTraceIdMap[M.Audio]=n;const g=p.audioTrack;g&&(this.audioTrack=g,(o=p.mediaStream)==null||o.removeTrack(g),this.playAudio(),this.audioVolumeIndicationInterval&&this.audioLevelMonitor.start(g,this.audioVolumeIndicationInterval)),this.audioSubState.getEnabled()||this.toggleAudio(!1),this.audioSubState.setState(me.AliRtcStateSubscribed)}e.video&&(this.updateStream(p,this.isVideoLargeSubscribing&&this.isVideoSmallSubscribing),this.videoSubState.getEnabled()||this.toggleVideo(!1),this.videoSubState.setState(me.AliRtcStateSubscribed),e.vMsid===M.VideoSmall?(this.trackTraceIdMap[M.VideoSmall]=n,this.videoSmallSubState.setState(me.AliRtcStateSubscribed)):(this.trackTraceIdMap[M.VideoLarge]=n,this.videoLargeSubState.setState(me.AliRtcStateSubscribed))),e.screen&&(this.trackTraceIdMap[M.Screen]=n,this.updateScreenStream(p),this.videoSubState.getEnabled()||this.toggleScreen(!1),this.screenSubState.setState(me.AliRtcStateSubscribed));const u=new Date().getTime()-r;this.slsReporter.reportSubscribe(((d=this.localUser)==null?void 0:d.callId)||"",this.callId,!!e.video&&e.vMsid===M.VideoLarge,!!e.video&&e.vMsid===M.VideoSmall,!!e.screen,!!e.audio,0,"",u,{pctid:this.rtsManager.pcTraceId,subtid:n,ajsub:t===Se.Join?1:0,url:this.streamUrl,est:r}),this.startStreamMonitor()}catch(l){const p=new Date().getTime()-r;e.audio&&this.audioSubState.setState(me.AliRtcStateNoSubscribe),e.video&&this.videoSubState.setState(me.AliRtcStateNoSubscribe),e.screen&&this.screenSubState.setState(me.AliRtcStateNoSubscribe),l&&(l.message=`user(${this.uid}) subscribe error, ${(l==null?void 0:l.message)||""}`);let u=H.ERR_INNER;e.audio&&(u=H.ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED),e.video&&(u=e.vMsid===M.VideoSmall?H.ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED:H.ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED),e.screen&&(u=H.ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED),this.slsReporter.reportSubscribe(((h=this.localUser)==null?void 0:h.callId)||"",this.callId,!!e.video&&e.vMsid===M.VideoLarge,!!e.video&&e.vMsid===M.VideoSmall,!!e.screen,!!e.audio,u,"",p,{pctid:this.rtsManager.pcTraceId,subtid:"",ajsub:t===Se.Join?1:0,url:this.streamUrl,est:r});const g=O.fromError(l,u);throw this.emit("remoteSubscribeError",g),g}})}subscribeDeleteTracks(e){return T(this,null,function*(){const{audio:t,video:i,screen:r,data:n,vMsid:c}=e,o=[];(t||i||n)&&o.push({audio:t,video:i,vMsid:c}),r&&o.push({screen:r}),o.length!==0&&(yield Promise.all(o.map(d=>this.subscribeDeleteProxy(d))),e.data&&this.subscribeStopDataChannel())})}subscribeDeleteProxy(e){return T(this,null,function*(){try{const t=yield this.rtsManager.subscribeDelete({remoteUser:this,options:e}),{stream:i}=t!=null?t:{},r={};e.audio===!0&&(r.audio=!1,this.audioSubState.setState(me.AliRtcStateNoSubscribe)),e.video===!0&&(r.video=!1,e.vMsid===M.VideoSmall?(this.videoSmallSubState.setState(me.AliRtcStateNoSubscribe),this.videoLargeSubState.currentState!==me.AliRtcStateNoSubscribe&&this.videoLargeSubState.currentState!==me.AliRtcStateSubscribeIdle||this.videoSubState.setState(me.AliRtcStateNoSubscribe)):(this.videoLargeSubState.setState(me.AliRtcStateNoSubscribe),this.videoSmallSubState.currentState!==me.AliRtcStateNoSubscribe&&this.videoSmallSubState.currentState!==me.AliRtcStateSubscribeIdle||this.videoSubState.setState(me.AliRtcStateNoSubscribe))),e.screen===!0&&(r.screen=!1,this.screenSubState.setState(me.AliRtcStateNoSubscribe));const{callId:n,remoteCallid:c}=this,o={callid:n,remoteCallid:c,remoteStream:i};return e.audio&&(this.audioLevelMonitor.stop(),this.stopPlayAudio(),this.audioTrack=void 0),this.streamInfo.updateRemoteTrackSubState({audio:e.audio!==!0&&void 0,video:e.video!==!0&&void 0,screen:e.screen!==!0&&void 0,vMsid:e.vMsid}),o}catch(t){throw O.fromError(t,H.ERR_INNER,"subscribe delete failed")}})}restore(){this.callId="",this.clearStream(),this.clearScreenStream(),this.audioTrack=void 0,this.streamInfo.updateRemoteTrackSubState({audio:!1,video:!1,screen:!1,data:!1}),this.audioElement&&this.audioElement.removeEventListener("pause",this.handleAudioPaused)}resumeAudio(){return T(this,null,function*(){const e=$t.getInstance();return e.state!=="running"&&e.resume(),this.audioElement?this.audioElement.play():this.playAudio()})}resumeVideo(e){return T(this,null,function*(){return e&&e!==ne.AliRtcVideoTrackCamera&&e!==ne.AliRtcVideoTrackBoth?e&&e!==ne.AliRtcVideoTrackScreen&&e!==ne.AliRtcVideoTrackBoth?void 0:this.playAll(!0):this.playAll()})}resumePlay(){this.playAudio(),this.playAll(),this.playAll(!0)}stopSubscribe(e){return T(this,null,function*(){var i,r;let t=new Date().getTime();try{let n;n=e?yield this.subscribeDeleteTracks(e):yield this.doStopSubscribe(this.streamUrl),this.slsReporter.reportUnsubscribe(((i=this.localUser)==null?void 0:i.callId)||(n==null?void 0:n.callid)||"",this.callId,new Date().getTime()-t,0,"")}catch(n){throw this.slsReporter.reportUnsubscribe(((r=this.localUser)==null?void 0:r.callId)||"",this.callId,new Date().getTime()-t,0,""),n}})}doStopSubscribe(e){return T(this,null,function*(){var r,n,c,o;const{callId:t,remoteCallid:i}=this;if((this.isAudioSubscribing||this.isVideoSubscribing||this.isScreenSubscribing)&&e)try{this.stopStreamMonitor(),yield this.rtsManager.subscibeStop(e),this.restore();const d={callid:t,remoteCallid:i,remoteStream:this.stream};return this.callId="",d}catch(d){if(((o=(c=(n=(r=d==null?void 0:d.extraInfo)==null?void 0:r.parsedData)==null?void 0:n.streams)==null?void 0:c[0])==null?void 0:o.res_code)!==404)throw O.fromError(d,H.ERR_INNER,"subscribe stop failed")}})}updateStream(e,t=!1){return T(this,null,function*(){this.stream&&this.stream.videoTrack&&e.mediaStream&&t&&(yield new Promise(i=>{let r,n;if(e.mediaStream){n=document.createElement("video");const c=()=>{V.event(`uid: ${this.userId} new mediaStream canplay`),n&&n.removeEventListener("canplaythrough",c,!1),n=void 0,clearTimeout(r),i(!0)};n.addEventListener("canplaythrough",c,!1),(n._playPromise||Promise.resolve()).then(()=>{n&&e.mediaStream&&(n.srcObject=e.mediaStream)})}else i(!0);r=window.setTimeout(()=>{V.event(`uid: ${this.userId} new mediaStream timeout`),n=void 0,i(!0)},3e3)}),this.updateSubscribe(Se.User)),this.stream=e,this.playAll(!1,t),!this.subscribed&&e&&(this.subscribed=!0),e.hasAudio&&this.isAudioSubscribing&&e.enableAudio(),e.hasVideo&&this.isVideoSubscribing&&e.enableVideo()})}updateScreenStream(e){this.screenStream=e,this.playAll(!0),!this.subscribed&&e&&(this.subscribed=!0),e.hasVideo&&this.isScreenSubscribing&&e.enableVideo()}clearStream(){var e;(e=this.stream)==null||e.stop(),this.stream=void 0}clearScreenStream(){var e;(e=this.screenStream)==null||e.stop(),this.screenStream=void 0}subscribeDataChannel(){if(this.dc)try{this.dc.dispose(),this.dcMsgWaitingPieces=[],this.dc.off("message",this.onDataChannelMessage),this.dc=void 0}catch(e){}(this.streamInfo.hasAudio||this.streamInfo.hasVideo||this.streamInfo.hasScreen)&&(this.dataSubState.setState(me.AliRtcStateSubscribing),this.rtsManager.subscribeAddDataChannel(this.streamUrl).then(e=>{if(e)return this.dataChannelConnected(e),this.dataSubState.setState(me.AliRtcStateSubscribed),void this.streamInfo.updateRemoteTrackSubState({data:!0});throw new Error("no dc founded")}).catch(e=>{const t=O.fromError(e,H.ERR_INNER,"subscribe data failed");this.emit("remoteSubscribeError",t),this.dataSubState.setState(me.AliRtcStateNoSubscribe)}))}subscribeStopDataChannel(){if(this.dc){try{this.rtsManager.subscribeStopDatachannel(this.streamUrl,this.dc)}catch(e){}this.dcMsgWaitingPieces=[],this.dc.off("message",this.onDataChannelMessage),this.dc.off("error",this.onDataChannelError),this.dataSubState.setState(me.AliRtcStateNoSubscribe),this.dc=void 0,this.streamInfo.updateRemoteTrackSubState({data:!1})}}getRetryOptions(){var i,r,n,c,o,d,h;const e={};this.wantSubAudio&&((i=this.streamInfo)!=null&&i.hasAudio)&&(e.audio=!0,e.aMsid=((r=this.streamInfo.getAudioInfo())==null?void 0:r.msid)||M.Audio),this.wantSubVideo&&((n=this.streamInfo)!=null&&n.hasVideo)&&(this.defaultVideoStreamType===We.AliRtcVideoStreamTypeLow&&((c=this.streamInfo)!=null&&c.hasVideoSmall)?(e.video=!0,e.vMsid=M.VideoSmall):(o=this.streamInfo)!=null&&o.hasVideoLarge&&(e.video=!0,e.vMsid=((d=this.streamInfo.getVideoLargeInfo())==null?void 0:d.msid)||M.VideoLarge)),this.wantSubScreen&&((h=this.streamInfo)!=null&&h.hasScreen)&&(e.screen=!0);let t={};if(e.audio||e.video)t={audio:e.audio,video:e.video},this.streamInfo.updateRemoteTrackSubState({screen:!1,data:!1});else{if(!e.screen)return;t={screen:e.screen},this.streamInfo.updateRemoteTrackSubState({data:!1})}return{remoteUser:this,options:t}}updateSubscribe(e){var n,c,o,d,h,l,p,u,g,m,b,S,v,_,w,y,R;const t=Date.now(),i={},r={};if(this.wantSubAudio&&!this.isAudioSubscribing&&((n=this.streamInfo)!=null&&n.hasAudio)?(i.audio=!0,i.aMsid=((c=this.streamInfo.getAudioInfo())==null?void 0:c.msid)||M.Audio):this.wantSubAudio&&((o=this.streamInfo)!=null&&o.hasAudio)||!this.isAudioSubscribing||(r.audio=!0,r.aMsid=((d=this.streamInfo.getAudioInfo())==null?void 0:d.msid)||M.Audio),this.wantSubVideo&&((h=this.streamInfo)!=null&&h.hasVideo)?(this.defaultVideoStreamType===We.AliRtcVideoStreamTypeLow&&!this.isVideoSmallSubscribing&&((l=this.streamInfo)!=null&&l.hasVideoSmall)?(i.video=!0,i.vMsid=M.VideoSmall):this.isVideoLargeSubscribing||!((p=this.streamInfo)!=null&&p.hasVideoLarge)||this.defaultVideoStreamType===We.AliRtcVideoStreamTypeLow&&this.isVideoSmallSubscribing||(i.video=!0,i.vMsid=((u=this.streamInfo.getVideoLargeInfo())==null?void 0:u.msid)||M.VideoLarge),this.defaultVideoStreamType===We.AliRtcVideoStreamTypeLow&&this.isVideoLargeSubscribing&&this.isVideoSmallSubscribing&&this.streamInfo.hasVideoSmall?(r.video=!0,r.vMsid=M.VideoLarge):this.defaultVideoStreamType===We.AliRtcVideoStreamTypeHigh&&this.isVideoLargeSubscribing&&this.isVideoSmallSubscribing&&(r.video=!0,r.vMsid=M.VideoSmall)):this.wantSubVideo&&((g=this.streamInfo)!=null&&g.hasVideo)||!this.isVideoSubscribing||(r.video=!0,r.vMsid=this.streamInfo.isVideoSmallSubscribed||this.streamInfo.isVideoSmallSubscribing?M.VideoSmall:((m=this.streamInfo.getVideoLargeInfo())==null?void 0:m.msid)||M.VideoLarge),this.wantSubScreen&&!this.isScreenSubscribing&&((b=this.streamInfo)!=null&&b.hasScreen)?i.screen=!0:this.wantSubScreen&&((S=this.streamInfo)!=null&&S.hasScreen)||!this.isScreenSubscribing||(r.screen=!0),(v=this.parameter.data)!=null&&v.enableSubDataChannel&&!this.isDataSubscribing&&((_=this.streamInfo)!=null&&_.hasData)?i.data=!0:(w=this.parameter.data)!=null&&w.enableSubDataChannel&&((y=this.streamInfo)!=null&&y.hasData)||!this.isDataSubscribing||(r.data=!0),(i.audio||i.video||i.screen||i.data)&&(this.createCallId(),this.subscribe(i,e,t)),(r.audio||r.video||r.screen)&&this.subscribeDeleteTracks(r),e===Se.Reconnect){if(V.event(`[${Ze.logName}]`,"reconnect, try to resume"),this.streamInfo.hasData&&!i.data){const A=this.rtsManager.getDatachannelByMsid({url:this.streamUrl,msid:this.streamInfo.getDataInfo().msid||M.Data});this.dataChannelConnected(A)}if(this.streamInfo.hasAudio&&!i.audio){const A=this.rtsManager.getStreamByMsid({url:this.streamUrl,aMsid:this.streamInfo.getAudioInfo().msid||M.Audio});A&&A.audioTrack&&(this.audioTrack=A.audioTrack,this.playAudio())}if(this.streamInfo.hasVideo&&!i.video){const A=this.rtsManager.getStreamByMsid({url:this.streamUrl,vMsid:this.streamInfo.isVideoSmallSubscribed||this.streamInfo.isVideoSmallSubscribing?M.VideoSmall:((R=this.streamInfo.getVideoLargeInfo())==null?void 0:R.msid)||M.VideoLarge});A&&A.mediaStream&&(this.stream=A,this.playAll(!1))}if(this.streamInfo.hasScreen&&!i.screen){const A=this.rtsManager.getStreamByMsid({url:this.streamUrl,sMsid:this.streamInfo.getScreenInfo().msid||M.Screen});A&&A.mediaStream&&(this.screenStream=A,this.playAll(!0))}}return{addOption:i,deleteOption:r}}handleAutoPlayFailed(){V.event(`[${Ze.logName}]`,"auto play failed"),this.emit("remoteAudioAutoPlayFail",this.uid);const e=()=>{this.resumeAudio().then(()=>{document.removeEventListener("click",e,!1),document.removeEventListener("touchstart",e,!1)})};document.addEventListener("click",e,!1),document.addEventListener("touchstart",e,!1)}handleVideoPlayFailded(e,t){this.emit("remoteVideoAutoPlayFail",this.uid,t);const i=()=>{var n;const r=(n=t===ne.AliRtcVideoTrackScreen?this.screenStream:this.stream)==null?void 0:n.mediaStream;e.srcObject===r&&this.play(e,t===ne.AliRtcVideoTrackScreen),document.removeEventListener("click",i,!1),document.removeEventListener("touchstart",i,!1)};document.addEventListener("click",i,!1),document.addEventListener("touchstart",i,!1)}playAudio(){return T(this,null,function*(){var e,t;if(this.audioTrack){if(this.toggleAudio(!this.audioMuted),this.audioElement||(V.event(`[${Ze.logName}]`,this.userId,"create audio element"),this.audioElement=document.createElement("audio"),this.audioElement.setAttribute("autoplay","autoplay"),this.audioElement.addEventListener("pause",this.handleAudioPaused),this.setPlayoutVolume(this.playoutVolume)),((t=(e=this.audioElement.srcObject)==null?void 0:e.getAudioTracks())==null?void 0:t[0])!==this.audioTrack){let i=this.audioElement.srcObject;i?i.getAudioTracks().forEach(r=>{i.removeTrack(r)}):(i=new MediaStream,this.audioElement.srcObject=i),i.addTrack(this.audioTrack)}if(q.AliRTS.SystenUtil.isIos&&parseInt(q.AliRTS.SystenUtil.systemVersion)<=13){V.event(`[${Ze.logName}]`,"play audio for iOS 13-");const i=this.audioElement;i.setAttribute("autoplay","");const r=()=>{i.removeEventListener("playing",r),i.pause(),i.play().catch(()=>{this.handleAutoPlayFailed()})};this.audioElement.addEventListener("playing",r)}else(()=>{var i;V.event(`[${Ze.logName}]`,"try play audio"),(i=this.audioElement)==null||i.play().then(()=>{V.event(`[${Ze.logName}]`,"play audio success")}).catch(()=>{this.handleAutoPlayFailed()})})()}else V.event(`[${Ze.logName}]`,this.userId,"audio track is null")})}stopPlayAudio(){this.audioElement&&(this.audioElement.pause(),this.audioElement.removeEventListener("pause",this.handleAudioPaused))}playAll(e=!1,t=!1){e?(this.viewMap.screenViews||[]).forEach(i=>{this.play(i,e,t)}):(this.viewMap.cameraViews||[]).forEach(i=>{this.play(i,e,t)})}play(e,t=!1,i=!1){const r=t?this.screenStream:this.stream;e&&r&&r.mediaStream&&Ga(e,r.mediaStream,i).catch(n=>{n.code!==20&&n.name!=="AbortError"&&this.handleVideoPlayFailded(e,t?ne.AliRtcVideoTrackScreen:ne.AliRtcVideoTrackCamera)})}stopPlayAll(e=!1){e?this.viewMap.screenViews.forEach(t=>{Rt(t)}):this.viewMap.cameraViews.forEach(t=>{Rt(t)})}toggleAudio(e=!0){this.audioSubState.setEnabled(e),this.audioElement&&(this.audioElement.muted=!e)}toggleVideo(e=!0){this.videoSubState.setEnabled(e),this.stream&&(e?this.stream.enableVideo():this.stream.disableVideo())}toggleScreen(e=!0){this.screenSubState.setEnabled(e),this.screenStream&&(e?this.screenStream.enableVideo():this.screenStream.disableVideo())}getStats(){return T(this,null,function*(){var i,r,n,c,o;const e=[];if(this.isAudioSubscribing){const d=yield this.rtsManager.getSubscribeAudioStats(this.streamUrl);d&&e.push({uid:this.uid,track:ri.AliRtcAudioTrackMic,stats:d})}const t=[];if((i=this.streamInfo)!=null&&i.isVideoLargeSubscribed){const d=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((r=this.streamInfo.getVideoLargeInfo())==null?void 0:r.msid)||M.VideoLarge);d&&t.push({uid:this.uid,track:ne.AliRtcVideoTrackCamera,streamType:We.AliRtcVideoStreamTypeHigh,stats:d})}if((n=this.streamInfo)!=null&&n.isVideoSmallSubscribed){const d=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((c=this.streamInfo.getVideoSmallInfo())==null?void 0:c.msid)||M.VideoSmall);d&&t.push({uid:this.uid,track:ne.AliRtcVideoTrackCamera,streamType:We.AliRtcVideoStreamTypeLow,stats:d})}if(this.isScreenSubscribing){const d=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((o=this.streamInfo.getScreenInfo())==null?void 0:o.msid)||M.Screen);d&&t.push({uid:this.uid,track:ne.AliRtcVideoTrackScreen,stats:d})}return{audio:e,video:t}})}enableAudioVolumeIndication(e){this.audioVolumeIndicationInterval!==e&&(this.audioVolumeIndicationInterval>0&&e<=0&&this.audioLevelMonitor.stop(),e>0&&this.audioTrack&&this.audioLevelMonitor.start(this.audioTrack,e),this.audioVolumeIndicationInterval=e)}reportSubscribeMonitor(e){var t;e&&(this.slsReporter.reportSubscribeMonitor(((t=this.localUser)==null?void 0:t.callId)||"",this.callId,this.trackTraceIdMap[e]||"",e,this.monitorDataCache[e]),this.monitorDataCache[e]=[])}startStreamMonitor(){this.monitorTimerId||(this.monitorTimerId=window.setInterval(()=>T(this,null,function*(){try{if(this.streamInfo.subscribingInfos.length===0)return void this.stopStreamMonitor();let e=Object.keys(this.monitorDataCache).filter(t=>{var i;return((i=this.monitorDataCache[t])==null?void 0:i.length)>0});this.streamInfo.subscribingInfos.forEach(t=>{const i=t.msid;if(!i)return;let r;e.includes(i)&&(e=e.filter(c=>c!==i));const n=i===M.Audio;r=n?this.rtsManager.getSubscribeAudioStats(this.streamUrl):this.rtsManager.getSubscribeVideoStats(this.streamUrl,i),r.then(c=>{var l;if(!c.timestamp)return;this.monitorDataCache[i]||(this.monitorDataCache[i]=[]);const o=this.monitorDataCache[i];let d;if((o==null?void 0:o.length)>0){const p=o[o.length-1]||{},h=p,{_last:u}=h;d=Qt(h,["_last"])}(o==null?void 0:o.length)>=30&&this.reportSubscribeMonitor(i),c._last=d,c._codec=t.codec,n&&(c._source=(l=this.localUser)==null?void 0:l.getMediaStats(c.playoutId)),this.monitorDataCache[i].push(c)})}),e.forEach(t=>{this.reportSubscribeMonitor(t)})}catch(e){}}),1e3))}stopStreamMonitor(){this.monitorTimerId&&(clearInterval(this.monitorTimerId),this.monitorTimerId=void 0),Object.keys(this.monitorDataCache).forEach(e=>{this.reportSubscribeMonitor(e)})}},f(Ze,"logName","RemoteUser"),Ze);Je([C()],Ke.prototype,"clear",1),Je([C()],Ke.prototype,"updateRemoteUserDeviceStatus",1),Je([C()],Ke.prototype,"updateRemoteTracks",1),Je([C(U)],Ke.prototype,"subscribe",1),Je([C()],Ke.prototype,"subscribeProxy",1),Je([C(U)],Ke.prototype,"subscribeDeleteProxy",1),Je([C()],Ke.prototype,"restore",1),Je([C(U)],Ke.prototype,"resumeAudio",1),Je([C(U)],Ke.prototype,"stopSubscribe",1),Je([C(U)],Ke.prototype,"doStopSubscribe",1),Je([C()],Ke.prototype,"clearStream",1),Je([C()],Ke.prototype,"clearScreenStream",1),Je([C()],Ke.prototype,"updateSubscribe",1),Je([C()],Ke.prototype,"playAudio",1),Je([C()],Ke.prototype,"stopPlayAudio",1),Je([C((s,a,e)=>[typeof s=="string"?s:s==null?void 0:s.nodeType,a,e])],Ke.prototype,"play",1),Je([C()],Ke.prototype,"stopPlayAll",1);let ic=Ke;var Ot=(s=>(s[s.AliRtcPluginErrorCodeSuccess=0]="AliRtcPluginErrorCodeSuccess",s[s.AliRtcPluginErrorCodeFailed=-1]="AliRtcPluginErrorCodeFailed",s[s.AliRtcPluginErrorNoFindPlugin=-2]="AliRtcPluginErrorNoFindPlugin",s[s.AliRtcPluginErrorParameterError=-3]="AliRtcPluginErrorParameterError",s[s.AliRtcPluginErrorLoadError=-4]="AliRtcPluginErrorLoadError",s[s.AliRtcPluginErrorCreateError=-5]="AliRtcPluginErrorCreateError",s[s.AliRtcPluginErrorInitError=-6]="AliRtcPluginErrorInitError",s[s.AliRtcPluginErrorInitTokenError=-7]="AliRtcPluginErrorInitTokenError",s))(Ot||{});class rc extends se{constructor(){super(...arguments);f(this,"plugins",new Map)}add(e,t){if(this.plugins.has(e.name))throw new O(Ot.AliRtcPluginErrorCreateError,`Plugin ${e.name} already exists`);this.plugins.set(e.name,e),t&&e.setOptions(t),this.emit("added",e),e.on("enabled",()=>this.emit("added",e)),e.on("disabled",()=>this.emit("removed",e)),e.on("updated",()=>this.emit("updated",e))}remove(e){const t=this.plugins.get(e);if(!t)throw new O(Ot.AliRtcPluginErrorNoFindPlugin,`Plugin ${e} not founded`);this.plugins.delete(e),t.removeAllListeners(),this.emit("removed",t)}removeAll(){this.plugins.forEach(e=>{this.remove(e.name)})}get(e){return this.plugins.get(e)}has(e){return!!this.plugins.get(e)}getAll(){return Array.from(this.plugins.values())}}var sc=Object.defineProperty,ac=Object.getOwnPropertyDescriptor,Be=(s,a,e,t)=>{for(var i,r=t>1?void 0:t?ac(a,e):a,n=s.length-1;n>=0;n--)(i=s[n])&&(r=(t?i(a,e,r):i(r))||r);return t&&r&&sc(a,e,r),r};const ji=([s])=>{const{remoteUser:a,options:e}=s;return[`user(${a.userId})`,e]},xe=(Fe=class extends se{constructor(e,t,i){super();f(this,"rts");f(this,"encodedInsertableStreams",!0);f(this,"audioRedEnabled",!1);f(this,"localStreamManager");f(this,"slsReporter");f(this,"_rtsPeerConnectionType","publish");f(this,"connecting",!1);f(this,"connected",!1);f(this,"_pcTraceId","");f(this,"_localJoinTime",0);f(this,"connectionResolve");f(this,"connectingPromise");f(this,"dcResolve");f(this,"dcReject");f(this,"dcConnectingPromise");f(this,"_publishingTracks",[]);f(this,"parameter",{});this.localStreamManager=e,this.slsReporter=t,this.parameter=i,this.rts=q.AliRTS.createClient({singlePcConfig:{usePcReconnect:!0}}),this.addRTSListener()}addRTSListener(){this.rts.on("connectStatusChange",e=>{var t,i,r,n;if(V.event(`[${Fe.logName}]`,"rts connectStatusChange to:",e.status),e.status===q.EConnectStatus.CONNECT_STATUS_DISCONNECTED)this.dcReject&&this.dcReject(),this.setConnected(!1),this.slsReporter.reportWarning("rts disconnected"),this.emit("disconnected");else if(e.status===q.EConnectStatus.CONNECT_STATUS_CONNECTED){const c=(n=(r=(i=(t=this.rts.commonController)==null?void 0:t.peerCore)==null?void 0:i.getSignal())==null?void 0:r.getDatachannelCore())==null?void 0:n.readyState;V.event(`[${Fe.logName}]`,"dcReadyState:",c),c==="open"&&this.dcResolve&&this.dcResolve(!0),this.setConnected(!0)}}),this.rts.on("reconnectFinish",()=>{V.event(`[${Fe.logName}]`,"rts reconnectFinish");try{this.emit("connected",!0,this._rtsPeerConnectionType)}catch(e){V.error(`[${Fe.logName}]`,"emit connected error:",e)}}),this.rts.on("datachannelStatusChange",e=>{V.event(`[${Fe.logName}]`,"rts datachannelStatusChange to:",e.status),e.status===q.EDatachannelStatus.DATACHANNEL_STATUS_OPEN?this.dcResolve&&this.dcResolve(!0):e.status===q.EDatachannelStatus.DATACHANNEL_STATUS_CLOSE&&(this.dcReject&&this.dcReject(),this.dcConnectingPromise=new Promise((t,i)=>{this.dcResolve=t,this.dcReject=i}))}),this.rts.on("receivedSEI",e=>{this.emit("seimessage",e.url,e.sei.payloadType,e.sei.data)}),this.rts.on("onError",e=>{V.event(`[${Fe.logName}]`,"rts onError event:",e)}),this.rts.on("reconnect",e=>{V.event(`[${Fe.logName}]`,"rts reconnect event:",e)})}updateAuth(e){this.rts.updateAuth(e)}get pcTraceId(){return this._pcTraceId}set localJoinTime(e){this._localJoinTime=e}setEncodedInsertableStreams(e){this.encodedInsertableStreams=e}setAudioRedEnabled(e){var t;if(e!==this.audioRedEnabled){try{const i=[...((t=RTCRtpReceiver.getCapabilities("audio"))==null?void 0:t.codecs)||[]];if(i.length>0){if(e){const r=i.findIndex(c=>c.mimeType==="audio/red"),n=i.findIndex(c=>c.mimeType==="audio/opus");if(r>-1&&n>-1&&r>n){const c=i[n];i[n]=i[r],i[r]=c}}this.rts.setSenderCodecPreferences({audio:i}),this.rts.setReceiverCodecPreferences({audio:i})}}catch(i){}this.audioRedEnabled=e}}clear(){this.setConnected(!1),this._publishingTracks=[];try{this.rts.unpublish()}catch(e){}this.rts=q.AliRTS.createClient(),this.addRTSListener()}startConnect(){this.connecting=!0,this.connectingPromise=new Promise(e=>{this.connectionResolve=e}),this.dcConnectingPromise=new Promise((e,t)=>{this.dcResolve=e,this.dcReject=t})}setConnected(e){var t;this.connected=e,this.connecting=!1,(t=this.connectionResolve)==null||t.call(this,!0)}get isConnecting(){return this.connecting}get isConnected(){return this.connected}get publishingTracks(){return this._publishingTracks}getPubMsid(e,t){const{aMsid:i,vMsid:r}=t!=null?t:{},n={};return e.hasAudio&&(n.aMsid=[i!=null?i:M.Audio]),e.hasScreen&&(n.vMsid=[M.Screen]),e.hasVideo&&(n.vMsid=[r!=null?r:t!=null&&t.isScreen?M.Screen:M.VideoLarge]),n}updatePublishingTracks(e){e&&(this._publishingTracks=e.map(({msid:t,from:i,ssrc:r,codec:n,type:c,trackId:o})=>({msid:t,from:i,type:c,ssrc:`${r}`,codec:n!=null?n:"",trackId:o})))}httpPublish(n,c){return T(this,arguments,function*(e,t,i=!1,r=bt.MANUAL){var _,w;let o;const d=Date.now(),{publishStream:h,videoSmallStream:l,screenStream:p,vMsid:u}=yield this.localStreamManager.createHTTPPublishStream();if(!h)return V.warn(`[${Fe.logName}]`,"publishStream is null"),{traceId:"",l1ip:o};const g=this.getPubMsid(h,{vMsid:u});this.encodedInsertableStreams&&(g.encodedInsertableStreams=!0),g.answerSdpHook=y=>{const R=/\d+\.\d+\.\d+\.\d+(?=\s+1106|\s+8000)/.exec(y);return R!=null&&R[0]&&(o=R[0]),y},(w=(_=this.parameter)==null?void 0:_.net)!=null&&w.useTCP&&(g.tcpOnly=!0),g.retryTimes=17,g.retryInterval=5e3,this._rtsPeerConnectionType="publish";let m=!h.hasVideo,b=u,S="";this.startConnect();const v=Date.now();try{S=yield this.rts.publish(Ja(e),h,g)}catch(y){this.setConnected(!1);const R=2e3-(Date.now()-v);throw R<=0?this.emit("disconnected"):setTimeout(()=>{this.emit("disconnected")},R),this.slsReporter.reportPublish(i,e,t,h.hasVideo&&(!u||u===M.VideoLarge),h.hasVideo&&u===M.VideoSmall,h.hasVideo&&u===M.Screen,h.hasAudio,(y==null?void 0:y.errorCode)||-1,this.pcTraceId,"",v),O.fromRtsError(y)}V.event(`[${Fe.logName}]`,"rts publish success",S),this.slsReporter.reportPublish(i,e,t,h.hasVideo&&(!u||u===M.VideoLarge),h.hasVideo&&u===M.VideoSmall,h.hasVideo&&u===M.Screen,h.hasAudio,0,S,S,v),this.slsReporter.reportConnectionLatencyEvent(ot.HANDLE_PUB_TASK,lt.START,t,S,d),this.slsReporter.reportConnectionLatencyEvent(ot.HANDLE_PUB_TASK,lt.END,t,S,Date.now());try{const y=Date.now();return this._pcTraceId=S,this.setConnected(!0),this._publishingTracks=this.rts.getPublishTrackInfoList(),l&&(yield this.publishAdd(e,l,t,{vMsid:M.VideoSmall},i),m=!1,b=M.VideoSmall),p&&(yield this.publishAdd(e,p,t,{vMsid:M.Screen},i),m=!1,b=M.Screen),yield this.waitPublishSender(e,m,b),this.slsReporter.reportPublishFirstPacket(i,t,v,y,this._localJoinTime,m?M.Audio:g.vMsid,S||"",S||"",r),{traceId:S,l1ip:o}}catch(y){throw this.setConnected(!1),O.fromError(y)}})}waitPublishSender(e,t=!1,i){return T(this,null,function*(){return Promise.race([Lt(1e3),((r,n)=>{let c=0;const o=()=>(t?this.rts.getPublishAudioStats(e,i):this.rts.getPublishVideoStats(e,i)).then(d=>!(d.bytesSent>0)&&c<r?(c++,new Promise(h=>setTimeout(()=>h(o()),n))):Promise.resolve());return o()})(5,100)]).catch(()=>{})})}getPublishVideoStats(e,t){return T(this,null,function*(){return yield this.rts.getPublishVideoStats(e,t)})}getPublishAudioStats(e,t){return T(this,null,function*(){return yield this.rts.getPublishAudioStats(e,t)})}publishAdd(d,h,l,p){return T(this,arguments,function*(e,t,i,r,n=!1,c=!1,o=bt.MANUAL){var m,b,S,v,_,w,y,R;yield this.dcConnectingPromise;const u=Date.now(),g=this.getPubMsid(t,r);try{const A=yield $a(E=>T(this,null,function*(){return E>0&&V.event(`[${Fe.logName}]`,`publishAdd retry times: ${E}`),this.isConnected?(yield this.dcConnectingPromise,this.rts.publishAdd([X({url:e,stream:t,updateSourceStream:!1},g)])):Promise.reject(new O(H.ERR_INNER,"rts not connected"))}),5,0,E=>(E==null?void 0:E.errorCode)===15006);if(A){const E=Date.now(),[I]=A;return this.slsReporter.reportPublish(!1,e,i,((m=g.vMsid)==null?void 0:m[0])===M.VideoLarge,((b=g.vMsid)==null?void 0:b[0])===M.VideoSmall,((S=g.vMsid)==null?void 0:S[0])===M.Screen,((v=g.aMsid)==null?void 0:v[0])===M.Audio,0,this.pcTraceId,I.traceId||"",u),this.updatePublishingTracks(I.trackInfoList),c&&(yield this.waitPublishSender(e,!t.hasVideo,t.hasVideo?r==null?void 0:r.vMsid:r==null?void 0:r.aMsid)),this.slsReporter.reportPublishFirstPacket(n,i,u,E,this._localJoinTime,(t.hasVideo?r==null?void 0:r.vMsid:r==null?void 0:r.aMsid)||"",this.pcTraceId,I.traceId||"",o),I.traceId||""}}catch(A){throw this.slsReporter.reportPublish(!1,e,i,((_=g.vMsid)==null?void 0:_[0])===M.VideoLarge,((w=g.vMsid)==null?void 0:w[0])===M.VideoSmall,((y=g.vMsid)==null?void 0:y[0])===M.Screen,((R=g.aMsid)==null?void 0:R[0])===M.Audio,(A==null?void 0:A.errorCode)||-1,this.pcTraceId,"",u),A!=null&&A.errorCode?O.fromRtsError(A):O.fromError(A)}return""})}publishDelete(e,t){return T(this,null,function*(){var d,h,l,p,u,g,m,b;yield this.dcConnectingPromise;const i=(h=(d=this.publishingTracks)==null?void 0:d.find(({msid:S})=>S===M.Audio))==null?void 0:h.msid,r=(p=(l=this.publishingTracks)==null?void 0:l.find(({msid:S})=>S===M.VideoLarge))==null?void 0:p.msid,n=(g=(u=this.publishingTracks)==null?void 0:u.find(({msid:S})=>S===M.Screen))==null?void 0:g.msid,c=[];t.screen&&n?c.push(n):t.video&&c.push(t.vMsid||r);const o=[];t.audio&&i&&o.push(i),V.event(Fe.logName,"publishDelete",{streamUrl:e,aMsid:o,vMsid:c});try{const[S]=(yield this.rts.publishDeleteTracks([{url:e,aMsid:o,vMsid:c}]))||[];return V.event(Fe.logName,"publishDelete",{result:S}),S&&this.updatePublishingTracks(S.trackInfoList),((b=(m=S==null?void 0:S.trackInfoList)==null?void 0:m[0])==null?void 0:b.trackId)||""}catch(S){throw O.fromRtsError(S)}})}publishReplace(e,t,i){return T(this,null,function*(){var c,o;yield this.dcConnectingPromise;const{vMsid:r,aMsid:n}=i!=null?i:{};try{const d=yield this.rts.publishReplaceTracks([{url:e,stream:t,vMsid:r,aMsid:n}]),[h]=d;return this.updatePublishingTracks(h.trackInfoList),((o=(c=h==null?void 0:h.trackInfoList)==null?void 0:c[0])==null?void 0:o.trackId)||""}catch(d){throw O.fromRtsError(d)}})}publishStop(e){return T(this,null,function*(){return yield this.rts.publishStop([{url:e}]),this._publishingTracks=[],""})}publishAddDataChannel(e){return T(this,null,function*(){yield this.dcConnectingPromise;const t=yield this.rts.publishAddDatachannel({signalUrl:e,url:e,label:M.Data,msid:M.Data}),i=t==null?void 0:t.datachannel;if(i&&i.send){const r=new ArrayBuffer(4);new DataView(r).setUint8(0,240),i.datachannel.send(r)}return i})}publishStopDataChannel(e,t){return T(this,null,function*(){return yield this.rts.publishStopDatachannel({url:e,datachannel:t})})}unpublish(){return T(this,null,function*(){yield this.rts.unpublish(),this._publishingTracks=[],this.connecting=!1,this.connected=!1})}getSubConfig(e,t){let i=t!=null?t:{};t||(i={audio:!0,video:!0,screen:!0});const r={};return i.audio&&(r.aMsid=[(e==null?void 0:e.getAudioInfo().msid)||M.Audio]),i.video?i.vMsid?r.vMsid=[i.vMsid]:r.vMsid=e!=null&&e.hasVideoLarge?[(e==null?void 0:e.getVideoLargeInfo().msid)||M.VideoLarge]:e!=null&&e.hasVideoSmall?[(e==null?void 0:e.getVideoSmallInfo().msid)||M.VideoSmall]:[M.VideoLarge]:i.screen&&(r.vMsid=[(e==null?void 0:e.getScreenInfo().msid)||M.Screen]),r}httpSubscribe(e){return T(this,null,function*(){var c,o,d,h,l,p;const{remoteUser:t,options:i}=e;let r=t.streamUrl;i.video||i.screen?i!=null&&i.audio||(r+="@subaudio=no"):r+="@subvideo=no";const n=this.getSubConfig(t.streamInfo,i);if(this.encodedInsertableStreams&&(n.encodedInsertableStreams=!0),(o=(c=this.parameter)==null?void 0:c.net)!=null&&o.useTCP&&(n.tcpOnly=!0),(h=(d=this.parameter)==null?void 0:d.net)==null?void 0:h.mediaTimeout){const u=(p=(l=this.parameter)==null?void 0:l.net)==null?void 0:p.mediaTimeout;u>1e3&&u<1e5&&(n.mediaTimeout=u)}n.retryTimes=17,n.retryInterval=5e3,this._rtsPeerConnectionType="subscribe";try{this.startConnect();const u=yield this.rts.subscribe(Ja(r),n);return this._pcTraceId=u.traceId,this.setConnected(!0),{traceId:u.traceId,stream:u}}catch(u){throw this.setConnected(!1),this.emit("disconnected"),O.fromRtsError(u)}})}subscribeAdd(e){return T(this,null,function*(){var n,c,o,d;const{remoteUser:t,options:i}=e,r=kt(X({url:t.streamUrl,subAudio:!!i.audio,subVideo:!(!i.screen&&!i.video)},this.getSubConfig(t.streamInfo,i)),{targetStream:i.screen?t.getScreenStream:t.getCameraStream});yield this.dcConnectingPromise;try{return(yield $a(h=>T(this,null,function*(){return yield this.dcConnectingPromise,h>0&&V.event(`[${Fe.logName}]`,`subscribeAdd retry times: ${h}`),this.isConnected?this.rts.subscribeAdd([r]):Promise.reject()}),5,0,h=>(h==null?void 0:h.errorCode)===15006))[0]}catch(h){if(((d=(o=(c=(n=h==null?void 0:h.extraInfo)==null?void 0:n.parsedData)==null?void 0:c.streams)==null?void 0:o[0])==null?void 0:d.res_code)===508)return this.emit("subscribeexceeds"),null;throw O.fromRtsError(h)}})}subscribeDelete(e){return T(this,null,function*(){var n,c,o,d;const{remoteUser:t,options:i}=e,r=kt(X({url:t.streamUrl,subAudio:!!i.audio,subVideo:!(!i.screen&&!i.video)},this.getSubConfig(t.streamInfo,i)),{targetStream:i.screen?t.getScreenStream:t.getCameraStream});yield this.dcConnectingPromise;try{return(yield this.rts.subscribeDeleteTracks([r]))[0]}catch(h){if(((d=(o=(c=(n=h==null?void 0:h.extraInfo)==null?void 0:n.parsedData)==null?void 0:c.streams)==null?void 0:o[0])==null?void 0:d.res_code)===404)return;throw O.fromRtsError(h)}})}subscibeStop(e){return T(this,null,function*(){var t,i,r,n;try{yield this.rts.subscribeStop([{url:e}])}catch(c){if(((n=(r=(i=(t=c==null?void 0:c.extraInfo)==null?void 0:t.parsedData)==null?void 0:i.streams)==null?void 0:r[0])==null?void 0:n.res_code)===404)return;throw O.fromRtsError(c)}})}subscribeAddDataChannel(e){return T(this,null,function*(){yield this.dcConnectingPromise;const t=yield this.rts.subscribeAddDatachannel({signalUrl:e,url:e,label:M.Data,msid:M.Data}),i=t==null?void 0:t.datachannel;if(i&&i.send){const r=new ArrayBuffer(4);new DataView(r).setUint8(0,240),i.send(r)}return i})}subscribeStopDatachannel(e,t){return T(this,null,function*(){let i;try{i=yield this.rts.subscribeStopDatachannel({url:e,datachannel:t})}catch(r){}return t==null||t.dispose(),i})}publish(n,c){return T(this,arguments,function*(e,t,i=!1,r=bt.MANUAL){let o,d="";if(this.connecting&&(yield this.connectingPromise),this.connected){yield this.dcConnectingPromise;let h,l=!1;const{audio:p,video:u,videoSmall:g,screen:m}=this.localStreamManager.publishStreams;p&&(d=yield this.publishAdd(e,p,t,{aMsid:M.Audio},i),l=!0,h=M.Audio,yield Lt(100)),u&&(d=yield this.publishAdd(e,u,t,{vMsid:M.VideoLarge},i),l=!1,h=M.VideoLarge,yield Lt(100)),g&&(d=yield this.publishAdd(e,g,t,{vMsid:M.VideoSmall},i),l=!1,h=M.VideoSmall,yield Lt(100)),m&&(d=yield this.publishAdd(e,m,t,{isScreen:!0,vMsid:M.Screen},i),l=!1,h=M.Screen),h&&(yield this.waitPublishSender(e,l,h))}else{const h=yield this.httpPublish(e,t,i,r);d=h.traceId,o=h.l1ip}return{traceId:d,l1ip:o}})}reportSubscribeLatency(e,t,i,r){const n=[];e.audio&&n.push(e.aMsid||M.Audio),e.video?n.push(e.vMsid||M.VideoLarge):e.screen&&n.push(M.Screen),n.forEach(c=>{this.slsReporter.reportConnectionLatencyEvent(ot.HANDLE_SUB_TASK,lt.START,t,c,i,0,r),this.slsReporter.reportConnectionLatencyEvent(ot.HANDLE_SUB_TASK,lt.END,t,c,Date.now(),0,r)})}subscribe(e,t,i,r,n){return T(this,null,function*(){let c=!1;const{options:o,remoteUser:d}=e;if(o.video&&o.screen)throw new O(H.ERR_INNER,"subscribe error, video and screen cannot be subscribed at the same time");let h;this.connecting&&(yield this.connectingPromise);let l=Date.now();this.connected?h=yield this.subscribeAdd(e):(c=!0,h=yield this.httpSubscribe(e)),this.reportSubscribeLatency(o,i,l,c);const p=Date.now();let u=M.VideoLarge,g=o.video||o.screen,m=o.audio;o.video&&o.vMsid?u=o.vMsid:o.screen&&(u=M.Screen);let b=0,S=0,v=0;const _=((w,y)=>{let R=0;const A=()=>{let E;return m&&!b&&(E=this.rts.getSubscribeAudioStats(d.streamUrl).then(I=>{if(I.packetsReceived>0)b=Date.now();else if(!g)return R<w&&(R++,new Promise(k=>setTimeout(()=>k(A()),y)));return!0})),g&&!v&&(E=this.rts.getSubscribeVideoStats(d.streamUrl,u).then(I=>(I.packetsReceived>0&&(S=Date.now()),I.framesDecoded>0?(v=Date.now(),!0):R<w?(R++,new Promise(k=>setTimeout(()=>k(A()),y))):(V.event(`[${Fe.logName}]`,d.userId,"尝试获取首帧数据失败"),!1)))),Promise.resolve(E)};return A()})(40,100);return _.then(()=>{S&&this.slsReporter.reportSubscribeFirstPacket(t===Se.Resume,i,r,u,{fprt:S-l,ifsprtc:v?v-l:0,ajsub:t===Se.Join?1:0,pctid:this.pcTraceId,subtid:(h==null?void 0:h.traceId)||"",sstc:p-l}),v&&this.slsReporter.reportSubscribeFirstFrame(t===Se.Resume,i,r,u,{fvfrt:v-l,fp2fftc:v-S,ajsub:t===Se.Join?1:0,tffrtc:t===Se.Join?v-this.localJoinTime:v-n,pctid:this.pcTraceId,subtid:(h==null?void 0:h.traceId)||"",fvfdtc:v-l}),b&&(this.slsReporter.reportConnectionLatencyEvent(ot.FIRST_REMOTE,lt.DECODED,i,M.Audio,b),this.slsReporter.reportSubscribeFirstPacket(t===Se.Resume,i,r,M.Audio,{fprt:b-l,ifsprtc:b-l,ajsub:t===Se.Join?1:0,pctid:this.pcTraceId,subtid:(h==null?void 0:h.traceId)||"",sstc:p-l}))}),c&&(yield Promise.race([_,Lt(1500)])),h})}getSubscribeVideoStats(e,t){return T(this,null,function*(){return yield this.rts.getSubscribeVideoStats(e,t)})}getSubscribeAudioStats(e,t){return T(this,null,function*(){return yield this.rts.getSubscribeAudioStats(e,t)})}getStreamByMsid(e){return this.rts.commonController.streamManager.getStreamByMsid(e)}getDatachannelByMsid(e){return this.rts.commonController.streamManager.getDatachannelByMsid(e)}getPCStats(){return T(this,null,function*(){var e,t;return(t=(e=this.rts.commonController.peerCore)==null?void 0:e.pc)==null?void 0:t.getStats()})}sendSEI(e,t,i,r){return T(this,null,function*(){return this.rts.sendSEI({url:e,vMsid:M.VideoLarge,data:t,repeatCount:i,payloadType:r})})}},f(Fe,"logName","RtsManager"),Fe);Be([C(U)],xe.prototype,"startConnect",1),Be([C()],xe.prototype,"updatePublishingTracks",1),Be([C(U,U)],xe.prototype,"httpPublish",1),Be([C(U,U)],xe.prototype,"waitPublishSender",1),Be([C(([s,a,e])=>[s,JSON.stringify(e)],U)],xe.prototype,"publishAdd",1),Be([C(U,U)],xe.prototype,"publishDelete",1),Be([C(([s,a,e])=>[s,JSON.stringify(e)])],xe.prototype,"publishReplace",1),Be([C(U)],xe.prototype,"publishStop",1),Be([C(U)],xe.prototype,"publishAddDataChannel",1),Be([C(U)],xe.prototype,"publishStopDataChannel",1),Be([C()],xe.prototype,"unpublish",1),Be([C(ji,({traceId:s})=>s)],xe.prototype,"httpSubscribe",1),Be([C(ji,({traceId:s})=>s)],xe.prototype,"subscribeAdd",1),Be([C(ji)],xe.prototype,"subscribeDelete",1),Be([C(U)],xe.prototype,"subscibeStop",1),Be([C(U)],xe.prototype,"subscribeAddDataChannel",1),Be([C(U)],xe.prototype,"subscribeStopDatachannel",1),Be([C(U)],xe.prototype,"publish",1),Be([C(ji)],xe.prototype,"subscribe",1),Be([C()],xe.prototype,"sendSEI",1);let nc=xe;class Vr{constructor(a=Mr){f(this,"defaultProfile");f(this,"profile");f(this,"profileMap",new Map);f(this,"audioProfile");f(this,"contentHint");this.defaultProfile=X({},a)}updateProfile(a,e){this.profileMap.set(a,X(X(X({},this.defaultProfile),this.profileMap.get(a)||{}),e||{})),this.profile=a}get videoProfile(){return this.profile}updateAudioProfile(a){this.audioProfile=a}setContentHint(a,e){e&&(this.contentHint=e),this.contentHint&&a&&(a.contentHint=this.contentHint)}setVideoProfile(a,e,t=!1){return T(this,null,function*(){if(!this.profile)return;const i=this.profileMap.get(this.profile)||(e==null?void 0:e.VideoProfileMap.get(this.profile));if(i){if(!t&&a&&a.readyState==="live"&&a.applyConstraints)try{yield a.applyConstraints(i)}catch(r){}if(e){const r=X({},i);i.maxSendFrameRate&&(r.frameRate=i.maxSendFrameRate),e==null||e.VideoProfileMap.set(this.profile,r),yield e.setVideoProfile(this.profile)}}})}}class Or extends se{constructor(e){super();f(this,"type");f(this,"originVideoTrack");f(this,"videoSource");f(this,"_videoMuted",!1);f(this,"originAudioTrack");f(this,"audioSource");f(this,"_audioMuted",!1);f(this,"_targetVideoTrack");f(this,"_targetDualVideoTrack");f(this,"_targetAudioTrack");f(this,"_publishVideoStream");f(this,"_publishDualVideoStream");f(this,"_publishAudioStream");f(this,"_previewStream");f(this,"plugins",[]);f(this,"_profileManager");f(this,"cameraVideoConstraints");f(this,"micAudioConstraints");f(this,"onVideoTrackEnded",()=>{this.emit("videotrackended")});f(this,"onAudioTrackEnded",()=>{this.emit("audiotrackended")});this.type=e}get profileManager(){return this._profileManager}get audioProfile(){var e;return(e=this.profileManager)==null?void 0:e.audioProfile}updateSource(e,t,i){return T(this,null,function*(){var c,o,d,h,l,p;const{videoTrack:r,audioTrack:n}=e;r&&((c=this.originVideoTrack)==null||c.removeEventListener("ended",this.onVideoTrackEnded)),n&&((o=this.originAudioTrack)==null||o.removeEventListener("ended",this.onAudioTrackEnded)),this.type===Ne.AliRtcSdkStreamTypeScreen?this.stop():(r&&((d=this.originVideoTrack)==null||d.stop()),n&&((h=this.originAudioTrack)==null||h.stop())),r&&(this.originVideoTrack=r,(l=this.originVideoTrack)==null||l.addEventListener("ended",this.onVideoTrackEnded),this.videoSource=t||ei.Camera,this.updateVideoTrack(r)),n&&(this.originAudioTrack=n,(p=this.originAudioTrack)==null||p.addEventListener("ended",this.onAudioTrackEnded),this.audioSource=i||Ei.Microphone,this.updateAudioTrack(n))})}get currentProfile(){var e;return(e=this.profileManager)==null?void 0:e.profile}get currentVideoTrack(){return this._targetVideoTrack}get currentDualVideoTrack(){return this._targetDualVideoTrack}get publishVideoStream(){return this._publishVideoStream}get publishDualVideoStream(){return this._publishDualVideoStream}get currentAudioTrack(){return this._targetAudioTrack}get publishAudioStream(){return this._publishAudioStream}get previewStream(){return this._previewStream}updateVideoTrack(e,t=!1){return T(this,null,function*(){(this._targetVideoTrack!==e||t)&&(this._targetVideoTrack=e)})}updateDualVideoTrack(e,t=!1){return T(this,null,function*(){(this._targetDualVideoTrack!==e||t)&&(this._targetDualVideoTrack=e)})}updateAudioTrack(e,t=!1){return T(this,null,function*(){(this._targetAudioTrack!==e||t)&&(this._targetAudioTrack=e)})}setAudioMuted(e){var t,i;this._audioMuted=e,e?(t=this.publishAudioStream)==null||t.disableAudio():(i=this.publishAudioStream)==null||i.enableAudio()}get isAudioMuted(){return this._audioMuted}setVideoMuted(e){var t,i;this._videoMuted=e,e?(t=this.publishVideoStream)==null||t.disableVideo():(i=this.publishVideoStream)==null||i.enableVideo()}get isVideoMuted(){return this._videoMuted}process(e){return T(this,null,function*(){var t,i,r,n,c,o,d,h,l,p,u,g;this._targetAudioTrack=this.originAudioTrack,this._targetVideoTrack=this.originVideoTrack;for(const m of this.plugins)try{yield m.execute(this,e)}catch(b){console.error(`error in plugin-${m.name}, error: ${b}`)}this._targetVideoTrack?((i=(t=this._publishVideoStream)==null?void 0:t.videoTrack)==null?void 0:i.id)!==this._targetVideoTrack.id&&(this._publishVideoStream=yield yi(this._targetVideoTrack),this.setVideoMuted(this._videoMuted),(r=this.profileManager)==null||r.setVideoProfile(this.originVideoTrack,this._publishVideoStream,!0),(n=this.profileManager)==null||n.setContentHint(this._targetVideoTrack),this.previewStream?(c=this.previewStream)==null||c.mergeStream(this._publishVideoStream):this._previewStream=yield yi(this._targetVideoTrack)):(this._publishVideoStream=void 0,(o=this.previewStream)==null||o.deleteTracks({video:!0})),this._targetDualVideoTrack?((h=(d=this._publishDualVideoStream)==null?void 0:d.videoTrack)==null?void 0:h.id)!==this._targetDualVideoTrack.id&&(this._publishDualVideoStream=yield yi(this._targetDualVideoTrack),this._videoMuted?this._publishDualVideoStream.disableVideo():this._publishDualVideoStream.enableVideo()):this._publishDualVideoStream=void 0,this._targetAudioTrack?((p=(l=this._publishAudioStream)==null?void 0:l.audioTrack)==null?void 0:p.id)!==this._targetAudioTrack.id&&(this._publishAudioStream=yield yi(this._targetAudioTrack),this.setAudioMuted(this._audioMuted),this.previewStream?(u=this.previewStream)==null||u.mergeStream(this._publishAudioStream):this._previewStream=yield yi(this._targetAudioTrack)):(this._publishAudioStream=void 0,(g=this.previewStream)==null||g.deleteTracks({audio:!0}))})}stopVideo(){var e,t;this.originVideoTrack&&((e=this.originVideoTrack)==null||e.removeEventListener("ended",this.onAudioTrackEnded),(t=this.originVideoTrack)==null||t.stop(),this.originVideoTrack=void 0),this.updateVideoTrack(void 0)}stopAudio(){var e,t;this.originAudioTrack&&((e=this.originAudioTrack)==null||e.removeEventListener("ended",this.onAudioTrackEnded),(t=this.originAudioTrack)==null||t.stop(),this.originAudioTrack=void 0),this.updateAudioTrack(void 0)}stop(){this.stopVideo(),this.stopAudio()}updateVideoProfile(e,t,i=!1){return T(this,null,function*(){this._profileManager||(this._profileManager=new Vr(this.type===Ne.AliRtcSdkStreamTypeScreen?Wa:Mr)),e&&this._profileManager.updateProfile(e,t),yield this._profileManager.setVideoProfile(this.originVideoTrack,this._publishVideoStream,i||this.type===Ne.AliRtcSdkStreamTypeScreen)})}get videoProfile(){var e;return(e=this.profileManager)==null?void 0:e.videoProfile}setVideoContentHint(e){this._profileManager||(this._profileManager=new Vr(this.type===Ne.AliRtcSdkStreamTypeScreen?Wa:Mr)),this._profileManager.setContentHint(this.currentVideoTrack,e)}updateAudioProfile(e){return T(this,null,function*(){this._profileManager||(this._profileManager=new Vr),this._profileManager.updateAudioProfile(e)})}cloneVideoProfile(e){return T(this,null,function*(){var t;yield(t=this.profileManager)==null?void 0:t.setVideoProfile(void 0,e)})}addPlugin(e){const t=this.plugins.findIndex(i=>i.zIndex>e.zIndex);t>-1?this.plugins.splice(t,0,e):this.plugins.push(e)}removePlugin(e){const t=this.plugins.indexOf(e);return t>-1&&(e.clear(this),this.plugins.splice(t,1),!0)}}var oc=Object.defineProperty,cc=Object.getOwnPropertyDescriptor,gt=(s,a,e,t)=>{for(var i,r=t>1?void 0:t?cc(a,e):a,n=s.length-1;n>=0;n--)(i=s[n])&&(r=(t?i(a,e,r):i(r))||r);return t&&r&&oc(a,e,r),r};const ut=(Bt=class extends se{constructor(e,t){super();f(this,"pluginManager");f(this,"slsReporter");f(this,"publishingCameraVideoStream");f(this,"publishingScreenVideoStream");f(this,"cameraStreamInfo",new Or(Ne.AliRtcSdkStreamTypeCapture));f(this,"screenStreamInfo",new Or(Ne.AliRtcSdkStreamTypeScreen));f(this,"streamInfos",[this.cameraStreamInfo,this.screenStreamInfo]);f(this,"_audioCaptureDisabled",!1);f(this,"_cameraCaptureDisabled",!1);f(this,"_publishLocalAudioStreamEnabled",!0);f(this,"_publishLocalVideoStreamEnabled",!0);f(this,"_publishLocalScreenStreamEnabled",!0);this.screenStreamInfo.setVideoContentHint("motion"),this.pluginManager=e,this.slsReporter=t,this.cameraStreamInfo.on("videotrackended",()=>T(this,null,function*(){yield this.stopLocalStream({video:!0}),this.emit("trackended",Jt.VideoTrackEnded)})),this.cameraStreamInfo.on("audiotrackended",()=>T(this,null,function*(){yield this.stopLocalStream({audio:!0}),this.emit("trackended",Jt.AudioTrackEnded)})),this.screenStreamInfo.on("videotrackended",()=>T(this,null,function*(){yield this.stopLocalStream({screen:!0}),this.emit("trackended",Jt.ScreenTrackEnded)})),this.pluginManager.on("added",i=>T(this,null,function*(){if(V.info(`[${Bt.logName}]`,"plugin added",i.name),!i.isSupported("7.0.1"))return console.warn(`${i.name} is not supported!!!`),void i.emit("unsupported");try{yield i.init()}catch(r){i.emit("error",O.fromError(r,Ot.AliRtcPluginErrorInitError))}i.streamType===Ne.AliRtcSdkStreamTypeCapture&&(this.cameraStreamInfo.addPlugin(i),yield this.cameraStreamInfo.process(this.streamInfos)),i.streamType===Ne.AliRtcSdkStreamTypeScreen&&(this.screenStreamInfo.addPlugin(i),yield this.screenStreamInfo.process(this.streamInfos)),this.emit("publishupdate")})),this.pluginManager.on("removed",i=>T(this,null,function*(){this.cameraStreamInfo.removePlugin(i)&&(yield this.cameraStreamInfo.process(this.streamInfos)),this.screenStreamInfo.removePlugin(i)&&(yield this.screenStreamInfo.process(this.streamInfos)),this.emit("publishupdate")})),this.pluginManager.on("updated",()=>T(this,null,function*(){yield this.updateStreams()}))}get hasCamera(){return!!this.cameraStreamInfo.originVideoTrack}get audioCaptureDisabled(){return this._audioCaptureDisabled}set audioCaptureDisabled(e){this._audioCaptureDisabled=e}get cameraCaptureDisabled(){return this._cameraCaptureDisabled}set cameraCaptureDisabled(e){this._cameraCaptureDisabled=e}setAudioMuted(e){this.cameraStreamInfo.setAudioMuted(e)}get isAudioMuted(){return this.cameraStreamInfo.isAudioMuted}setCameraMuted(e){this.cameraStreamInfo.setVideoMuted(e)}get isCameraMuted(){return this.cameraStreamInfo.isVideoMuted}setScreenMuted(e){this.screenStreamInfo.setVideoMuted(e)}get isScreenMuted(){return this.screenStreamInfo.isVideoMuted}get publishLocalAudioStreamEnabled(){return this._publishLocalAudioStreamEnabled}set publishLocalAudioStreamEnabled(e){this._publishLocalAudioStreamEnabled=e}get publishLocalVideoStreamEnabled(){return this._publishLocalVideoStreamEnabled}set publishLocalVideoStreamEnabled(e){this._publishLocalVideoStreamEnabled=e}get publishLocalScreenStreamEnabled(){return this._publishLocalScreenStreamEnabled}set publishLocalScreenStreamEnabled(e){this._publishLocalScreenStreamEnabled=e}updateStreams(){return T(this,null,function*(){yield this.cameraStreamInfo.process(this.streamInfos),yield this.screenStreamInfo.process(this.streamInfos),this.emit("publishupdate")})}setAvailableCameraDeviceId(){return T(this,null,function*(){var e,t,i,r;if((e=this.cameraStreamInfo.cameraVideoConstraints)!=null&&e.deviceId){let n=(t=this.cameraStreamInfo.cameraVideoConstraints)==null?void 0:t.deviceId;const c=yield q.AliRTS.getCameraList();c.find(o=>o.deviceId===n)||(n=(r=(i=c.find(o=>!!o.deviceId))==null?void 0:i.deviceId)!=null?r:""),this.cameraStreamInfo.cameraVideoConstraints.deviceId=n}})}setAvailableMicrophoneDeviceId(){return T(this,null,function*(){var e,t,i,r;if((e=this.cameraStreamInfo.micAudioConstraints)!=null&&e.deviceId){let n=(t=this.cameraStreamInfo.micAudioConstraints)==null?void 0:t.deviceId;const c=yield q.AliRTS.getMicList();c.find(o=>o.deviceId===n)||(n=(r=(i=c.find(o=>!!o.deviceId))==null?void 0:i.deviceId)!=null?r:""),this.cameraStreamInfo.micAudioConstraints.deviceId=n}})}createLocalStream(e){return T(this,null,function*(){var l;const{screen:t,mediaStream:i,videoProfile:r,screenProfile:n}=e;let{video:c,audio:o}=e;const d=(p=>{const{audio:u,video:g,screen:m}=p;if(g&&m)throw new O(H.ERR_INNER,"create stream error, cannot create video && screen together");return!!(g||u||m)})(e);let h;if(d){i||(c===!0&&this.cameraStreamInfo.cameraVideoConstraints?(yield this.setAvailableCameraDeviceId(),c=X({},this.cameraStreamInfo.cameraVideoConstraints)):typeof c=="object"&&(yield this.setAvailableCameraDeviceId(),c=X(X({},c),this.cameraStreamInfo.cameraVideoConstraints)),o===void 0&&this.audioCaptureDisabled?o=!1:o&&(o===!0&&this.cameraStreamInfo.micAudioConstraints?(yield this.setAvailableMicrophoneDeviceId(),o=X({},this.cameraStreamInfo.micAudioConstraints)):typeof o=="object"&&(yield this.setAvailableMicrophoneDeviceId(),o=X(X({},o),this.cameraStreamInfo.micAudioConstraints)),this._audioCaptureDisabled=!1));const p=Date.now();try{h=yield q.AliRTS.createStream({audio:o,video:c,screen:t,custom:!!i,mediaStream:i,skipProfile:!0}),V.info(`[${Bt.logName}]`,"createLocalStream",{audio:o,video:c,screen:t,custom:!!i,time:Date.now()-p}),o&&!i&&this.slsReporter.reportAudio(null,Date.now()-p,((l=h==null?void 0:h.audioTrack)==null?void 0:l.label)||""),t&&!i&&this.slsReporter.reportScreen(null,Date.now()-p)}catch(u){throw o&&!i&&this.slsReporter.reportAudio(u,Date.now()-p,""),t&&!i&&this.slsReporter.reportScreen(null,Date.now()-p),u}if(t)yield this.screenStreamInfo.updateSource(h,ei.Screen,Ei.Screen),yield this.setScreenProfile(n||za),this.setScreenContentHint(),this.publishingScreenVideoStream=void 0;else if(yield this.cameraStreamInfo.updateSource(h,ei.Camera,Ei.Microphone),h.hasVideo&&(yield this.setVideoProfile(r||ja),this.setVideoContentHint(),this.publishingCameraVideoStream=void 0),h.hasAudio&&typeof o=="boolean"){const u=this.cameraStreamInfo.audioProfile;u&&(yield h.setAudioProfile(u))}}return q.AliRTS.SystenUtil.isIos&&q.AliRTS.SystenUtil.compareVersion("15.1")&&!q.AliRTS.SystenUtil.compareVersion("15.2")&&(yield Lt(1e3)),yield this.updateStreams(),h})}stopLocalStream(e){return T(this,null,function*(){const{screen:t,video:i,audio:r}=e!=null?e:{};let n=!1;i&&this.cameraStreamInfo.originVideoTrack&&(n=!0,this.cameraStreamInfo.stopVideo(),this.publishingCameraVideoStream=void 0),r&&this.cameraStreamInfo.originAudioTrack&&(n=!0,this.cameraStreamInfo.stopAudio()),t&&this.screenStreamInfo.originVideoTrack&&(n=!0,this.screenStreamInfo.stop(),this.publishingScreenVideoStream=void 0,this.slsReporter.reportScreenStop(null)),n&&(yield this.updateStreams())})}get publishStreams(){const{publishLocalVideoStreamEnabled:e,publishLocalAudioStreamEnabled:t,publishLocalScreenStreamEnabled:i}=this;return{video:e?this.cameraStreamInfo.publishVideoStream:void 0,videoSmall:e?this.cameraStreamInfo.publishDualVideoStream:void 0,audio:t?this.cameraStreamInfo.publishAudioStream:void 0,screen:i?this.screenStreamInfo.publishVideoStream:void 0}}createHTTPPublishStream(){return T(this,null,function*(){var o,d,h,l;let e,t,i,r,n=!1;const c=this.publishStreams;try{if(!(c.audio||c.video||c.videoSmall||c.screen))throw V.error(`[${Bt.logName}]`,"no tracks founded"),new O(H.ERR_SDK_PUBLISH_INVAILD,"no tracks founded");const p=new MediaStream;(o=c.audio)!=null&&o.audioTrack&&p.addTrack(c.audio.audioTrack),(d=c.video)!=null&&d.videoTrack?(p.addTrack(c.video.videoTrack),i=c.videoSmall,r=c.screen):(h=c.screen)!=null&&h.videoTrack&&(t=M.Screen,p.addTrack((l=c.screen)==null?void 0:l.videoTrack),n=!0),e=yield Xa(p),n?(this.screenStreamInfo.cloneVideoProfile(e),this.publishingScreenVideoStream=e):(this.cameraStreamInfo.cloneVideoProfile(e),this.publishingCameraVideoStream=e)}catch(p){}return{publishStream:e,videoSmallStream:i,screenStream:r,vMsid:t}})}stop(){this.cameraStreamInfo.stop(),this.screenStreamInfo.stop(),this.updateStreams()}setVideoProfile(e,t,i=!1){return T(this,null,function*(){yield this.cameraStreamInfo.updateVideoProfile(e,t,i),this.publishingCameraVideoStream&&this.cameraStreamInfo.cloneVideoProfile(this.publishingCameraVideoStream)})}setVideoContentHint(e){this.cameraStreamInfo.setVideoContentHint(e)}setAudioProfile(e){return T(this,null,function*(){var t;yield this.cameraStreamInfo.updateAudioProfile(e),yield(t=this.publishingCameraVideoStream)==null?void 0:t.setAudioProfile(e)})}setScreenProfile(e,t){return T(this,null,function*(){yield this.screenStreamInfo.updateVideoProfile(e,t),this.publishingScreenVideoStream&&this.screenStreamInfo.cloneVideoProfile(this.publishingScreenVideoStream)})}setScreenContentHint(e){this.screenStreamInfo.setVideoContentHint(e)}setCameraVideoConstraints(e){var t;this.cameraStreamInfo.cameraVideoConstraints=X(X({},(t=this.cameraStreamInfo.cameraVideoConstraints)!=null?t:{}),e)}setMicAudioConstraints(e){var t;this.cameraStreamInfo.micAudioConstraints=X(X({},(t=this.cameraStreamInfo.micAudioConstraints)!=null?t:{}),e)}},f(Bt,"logName","LocalStreamManager"),Bt);gt([C(([s])=>{const{audio:a,video:e,screen:t,custom:i,skipProfile:r,videoProfile:n,screenProfile:c}=s;return[{audio:a,video:e,screen:t,custom:i,skipProfile:r,videoProfile:n,screenProfile:c}]})],ut.prototype,"createLocalStream",1),gt([C(U)],ut.prototype,"stopLocalStream",1),gt([C()],ut.prototype,"createHTTPPublishStream",1),gt([C()],ut.prototype,"stop",1),gt([C(U)],ut.prototype,"setVideoProfile",1),gt([C(U)],ut.prototype,"setVideoContentHint",1),gt([C(U)],ut.prototype,"setAudioProfile",1),gt([C(U)],ut.prototype,"setScreenProfile",1),gt([C(U)],ut.prototype,"setScreenContentHint",1),gt([C(U)],ut.prototype,"setCameraVideoConstraints",1),gt([C(U)],ut.prototype,"setMicAudioConstraints",1);let dc=ut;class hc extends Mt{constructor(){super("AliRtcScreenStandardize",Ne.AliRtcSdkStreamTypeScreen);f(this,"canvas");f(this,"lastWidth");f(this,"lastHeight");f(this,"hasScreenTrack",!1)}get initOptions(){return{base:4}}setOptions(e){this.options=e}isSupported(){return!(typeof TransformStream=="undefined"||typeof MediaStreamTrackProcessor=="undefined"||typeof MediaStreamTrackGenerator=="undefined")}updateProcessCanvas(e,t){if(this.canvas&&this.lastWidth===e&&this.lastHeight===t)return;const i=Math.ceil(e/this.options.base)*this.options.base,r=Math.ceil(t/this.options.base)*this.options.base;if(this.canvas||(this.canvas=document.createElement("canvas")),this.canvas.width=i,this.canvas.height=r,this.lastWidth&&e>this.lastWidth||this.lastHeight&&t>this.lastHeight){const n=this.canvas.getContext("2d");n&&n.clearRect(0,0,i,r)}this.lastWidth=e,this.lastHeight=t}shouldUpdate(e){return this.hasScreenTrack!==(!!e.originVideoTrack&&e.videoSource===ei.Screen)}handleFrame(e,t){return T(this,null,function*(){var c;const{displayWidth:i,displayHeight:r}=e;if(!i||!r||i%this.options.base===0&&r%this.options.base===0)return this.clear(t),e;this.updateProcessCanvas(i,r);const n=(c=this.canvas)==null?void 0:c.getContext("2d");if(this.canvas&&n){n.drawImage(e,0,0,i,r);const o=new VideoFrame(this.canvas,{timestamp:e.timestamp});return e.close(),o}return e})}process(e){return T(this,null,function*(){var h;if(!e.originVideoTrack||e.videoSource!==ei.Screen)return this.clear(e),void(this.hasScreenTrack=!1);const t=new MediaStreamTrackProcessor({track:e.originVideoTrack}),i=new MediaStreamTrackGenerator({kind:"video"}),r=new MediaStream([i]),n=this,c=new TransformStream({transform(l,p){return T(this,null,function*(){const u=yield n.handleFrame(l,e);yield p.enqueue(u),u==null||u.close()})}});t.readable.pipeThrough(c).pipeTo(i.writable);const o=(h=r.getVideoTracks())==null?void 0:h[0];e.updateVideoTrack(o),this.hasScreenTrack=!0})}clear(e){this.canvas=void 0,this.lastWidth=void 0,this.lastHeight=void 0,super.clear(e)}}class lc extends Mt{constructor(){super("blankAudio",Ne.AliRtcSdkStreamTypeCapture,ti.BOTH);f(this,"hasTrack",!1);f(this,"oscillator",null);f(this,"audioTrack",null);f(this,"createAudioTrack",()=>{const e=new AudioContext;this.oscillator=e.createOscillator();const t=e.createGain();t.gain.value=0;const i=e.createMediaStreamDestination();this.oscillator.connect(t),t.connect(i),this.oscillator.start();const r=i.stream;return this.audioTrack=r.getAudioTracks()[0],this.audioTrack});this.zIndex=9}isSupported(){return!0}setOptions(){throw new Error("Method not implemented.")}shouldUpdate(e,t){return this.hasTrack!==t.some(i=>i.originVideoTrack||i.originAudioTrack)}process(e,t){return T(this,null,function*(){var r;const i=t.some(n=>n.originVideoTrack||n.originAudioTrack);this.hasTrack=i,i?this.audioTrack&&((r=this.oscillator)==null||r.stop(),this.oscillator=null,this.audioTrack.stop(),this.audioTrack=null):(this.audioTrack||(this.audioTrack=this.createAudioTrack()),e.updateAudioTrack(this.audioTrack))})}}class Za{constructor(a){f(this,"name","COMMON");this.name=a||this.name}info(...a){}warn(...a){}print(a,...e){const t=a.toLowerCase();t&&console[t](`[${a}][${this.name}]`,...e)}}f(Za,"LEVEL",0);class uc{constructor(){f(this,"logger",new Za("AudioMixer"));f(this,"audioContext",new AudioContext);f(this,"audioDestination",this.audioContext.createMediaStreamDestination());f(this,"audioTrack",(a=>a.getAudioTracks()[0])(this.audioDestination.stream));f(this,"sourceNodeMap",{})}get sourceNodeList(){return Object.values(this.sourceNodeMap).map(a=>a.sourceNode).filter(a=>!!a)}get gainNodeList(){return Object.values(this.sourceNodeMap).map(a=>a.gainNode).filter(a=>!!a)}get sourceCount(){return this.sourceNodeList.length}resume(){var a;return(a=this.audioContext)==null?void 0:a.resume()}addTrack(a){this.connectTrack(a)}hasTrack(a){return!!this.sourceNodeMap[a]}removeTrack(a){const{sourceNode:e,gainNode:t}=this.sourceNodeMap[a]||{};t==null||t.disconnect(),e==null||e.disconnect(),delete this.sourceNodeMap[a],e?this.logger.info("SourceNode disconnected. Active source node:",this.sourceNodeList.length):this.logger.warn(`SourceNode ${a} does not exit. Active source node: ${this.sourceNodeList.length}`)}getAudioTrack(){return this.audioTrack}setVolume(a,e){const{gainNode:t}=this.sourceNodeMap[e]||{};t?(this.logger.info(`Setting node(${e}) volume to ${this.scale(a)}`),t.gain.value=this.scale(a)):this.logger.warn(`GainNode ${e} does not exit.`)}reset(){this.disconnectSourceNode(),this.sourceNodeMap={}}dispose(){var a;this.reset(),(a=this.audioTrack)==null||a.stop(),this.audioDestination.disconnect(),this.audioContext.close()}connectTrack(a){if(!this.audioContext)return this.logger.warn("AudioContext not initialized");let e=new MediaStream;e.addTrack(a);const t=this.audioContext.createMediaStreamSource(e),i=this.audioContext.createGain();i.gain.value=1,t.connect(i),i.connect(this.audioDestination),this.sourceNodeMap[a.id]={track:a,sourceNode:t,gainNode:i},this.logger.info("New sourceNode connected. Active source node:",this.sourceNodeList.length)}disconnectSourceNode(){this.sourceNodeList.forEach(a=>a.disconnect()),this.gainNodeList.forEach(a=>a.disconnect())}scale(a){return a/100}}class pc extends Mt{constructor(){super("audioMixer",Ne.AliRtcSdkStreamTypeCapture,ti.AUDIO);f(this,"audioMixer");f(this,"primaryAudioTrackId");f(this,"screenAudioTrackId");f(this,"dirty",!1);this.zIndex=8}get initOptions(){return{audio:1,screen:1}}setOptions(e){Object.entries(e).forEach(([t,i])=>{this.isValidVolume(i)&&(this.options[t]=i)}),this.dirty=!0,this.emit("updated")}isSupported(){return"AudioContext"in window}shouldUpdate(e,t){var n,c;if(e.type!==Ne.AliRtcSdkStreamTypeCapture)return!1;const i=t.find(o=>o.type===Ne.AliRtcSdkStreamTypeCapture),r=t.find(o=>o.type===Ne.AliRtcSdkStreamTypeScreen);return!(this.primaryAudioTrackId===((n=i==null?void 0:i.currentAudioTrack)==null?void 0:n.id)&&this.screenAudioTrackId===((c=r==null?void 0:r.currentAudioTrack)==null?void 0:c.id)&&!this.dirty)}process(e,t){return T(this,null,function*(){var c,o;this.dirty=!1;const i=t.find(d=>d.type===Ne.AliRtcSdkStreamTypeScreen),r=e.currentAudioTrack,n=i==null?void 0:i.currentAudioTrack;if(!n&&this.options.audio===1)return this.audioMixer&&(this.audioMixer.dispose(),this.audioMixer=void 0),this.primaryAudioTrackId=r==null?void 0:r.id,void e.updateAudioTrack(r);this.audioMixer||(this.audioMixer=new uc),yield this.audioMixer.resume(),this.primaryAudioTrackId&&(r==null?void 0:r.id)!==this.primaryAudioTrackId&&((c=this.audioMixer)==null||c.removeTrack(this.primaryAudioTrackId)),r&&!this.audioMixer.hasTrack(r==null?void 0:r.id)&&this.audioMixer.addTrack(r),this.primaryAudioTrackId=r==null?void 0:r.id,this.screenAudioTrackId&&(n==null?void 0:n.id)!==this.screenAudioTrackId&&((o=this.audioMixer)==null||o.removeTrack(this.screenAudioTrackId)),n&&!this.audioMixer.hasTrack(n==null?void 0:n.id)&&this.audioMixer.addTrack(n),this.screenAudioTrackId=n==null?void 0:n.id,this.updateVolume(),e.updateAudioTrack(this.audioMixer.getAudioTrack())})}isValidVolume(e){return e!==void 0&&e>=0&&e<=4}updateVolume(){this.audioMixer&&(this.primaryAudioTrackId&&this.audioMixer.setVolume(100*this.options.audio,this.primaryAudioTrackId),this.screenAudioTrackId&&this.audioMixer.setVolume(100*this.options.screen,this.screenAudioTrackId))}clear(e){var t;(t=this.audioMixer)==null||t.dispose(),super.clear(e)}}class Ur{constructor(a,e){f(this,"originTrack");f(this,"originVideo");f(this,"targetWidth");f(this,"targetHeight");f(this,"targetFrameRate");f(this,"targetCanvas");f(this,"animationFrameId");f(this,"resultTrack");this.targetWidth=e.width,this.targetHeight=e.height,this.targetFrameRate=e.frameRate,this.originTrack=a,this.originVideo=document.createElement("video"),this.originVideo.muted=!0,this.originVideo.autoplay=!0,this.originVideo.controls=!1,this.targetCanvas=document.createElement("canvas"),this.targetCanvas.width=this.targetWidth,this.targetCanvas.height=this.targetHeight}updateOptions(a){this.targetWidth=a.width,this.targetHeight=a.height,this.targetFrameRate=a.frameRate,this.targetCanvas.width=this.targetWidth,this.targetCanvas.height=this.targetHeight,this.resultTrack&&this.resultTrack.applyConstraints({frameRate:this.targetFrameRate})}dispose(){}getVideoTrack(){return this.resultTrack||(this.resultTrack=this.targetCanvas.captureStream().getVideoTracks()[0],this.resultTrack.applyConstraints({frameRate:this.targetFrameRate})),this.resultTrack}cancelAnimation(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}getPositionAndSize(a,e,t,i){const r=e/a,n=i/t;let c=t,o=i,d=0,h=0;return n>r?(c=Math.round(o/r),d=Math.round((t-c)/2)):n<r&&(o=Math.round(c*r),h=Math.round((i-o)/2)),{x:d,y:h,width:c,height:o}}}class mc extends Ur{constructor(e,t){super(e,t);f(this,"targetCtx");this.targetCtx=this.targetCanvas.getContext("2d"),this.startRender=this.startRender.bind(this),this.stopRender=this.startRender.bind(this),this.initStream(e)}initStream(e){const t=new MediaStream;t.addTrack(e),this.originVideo.srcObject=t,this.originVideo.play(),this.originVideo.addEventListener("canplay",this.startRender),this.originVideo.addEventListener("pause",this.stopRender),this.originVideo.addEventListener("ended",this.stopRender)}startRender(){this.cancelAnimation();const e=()=>{if(!this.targetCtx)return;const t=this.getPositionAndSize(this.originVideo.videoWidth,this.originVideo.videoHeight,this.targetWidth,this.targetHeight);this.targetCtx.drawImage(this.originVideo,0,0,this.originVideo.videoWidth,this.originVideo.videoHeight,t.x,t.y,t.width,t.height),this.originVideo.paused||this.originVideo.ended||(this.animationFrameId=requestAnimationFrame(e))};e()}stopRender(){this.cancelAnimation()}dispose(){this.stopRender(),this.originVideo.removeEventListener("play",this.startRender),this.originVideo.removeEventListener("pause",this.stopRender),this.originVideo.removeEventListener("ended",this.stopRender),this.originVideo.pause(),this.originVideo.srcObject=null}}function Qa(s,a,e){const t=s.createShader(a);if(t)return s.shaderSource(t,e),s.compileShader(t),s.getShaderParameter(t,s.COMPILE_STATUS)?t:(console.error(`An error occurred compiling the shaders: ${s.getShaderInfoLog(t)}`),s.deleteShader(t),null);console.error("create shader failed")}class en extends Ur{constructor(e,t){super(e,t);f(this,"targetCtx");f(this,"targetTexture");f(this,"locationMap");this.targetCtx=this.targetCanvas.getContext("webgl2"),this.locationMap={},this.startRender=this.startRender.bind(this),this.stopRender=this.startRender.bind(this),this.updateBuffer=this.updateBuffer.bind(this),this.initGL(),this.initStream(e)}static isSupport(){return function(){let e;try{const t=document.createElement("canvas");t.width=1,t.height=1;const i={alpha:!1,depth:!1,stencil:!1,antialias:!1,preferLowPowerToHighPerformance:!0};e=t.getContext("webgl2",i)}catch(t){return!1}return!!e}()}initGL(){const e=this.targetCtx;if(!e)return;this.targetTexture=function(o){const d=o.createTexture();return o.bindTexture(o.TEXTURE_2D,d),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),d}(e);const t=function(o,d,h){const l=Qa(o,o.VERTEX_SHADER,d),p=Qa(o,o.FRAGMENT_SHADER,h),u=o.createProgram();if(u&&l&&p)return o.attachShader(u,l),o.attachShader(u,p),o.linkProgram(u),o.getProgramParameter(u,o.LINK_STATUS)?u:(console.error(`Unable to initialize the shader program: ${o.getProgramInfoLog(u)}`),null)}(e,`
14
+ `).join("");A+=P}catch(P){}A+=m,v.size>0&&(A+="?");try{A+=[...v.entries()].sort(E).map(P=>P[0]+"="+P[1]).join("&")}catch(P){}const k="LOG "+b+":"+di.HmacSHA1(A,S).toString(di.enc.Base64);_.set("Authorization",k),_.set("x-log-date",y)}("POST",n,s.accessKeyId,s.accessKeySecret,l,p,o,h);let u=Object.fromEntries(p);return{data:e,header:u}},new Promise((n,c)=>{var o=l=>{try{h(r.next(l))}catch(p){c(p)}},d=l=>{try{h(r.throw(l))}catch(p){c(p)}},h=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,d);h((r=r.apply(t,i)).next())});var t,i,r}}}typeof window!="undefined"&&Is(window,"stsPlugin",pr);var bo=/d{1,4}|D{3,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|W{1,2}|[LlopSZN]|"[^"]*"|'[^']*'/g,vo=/\b(?:[A-Z]{1,3}[A-Z][TC])(?:[-+]\d{4})?|((?:Australian )?(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time)\b/g,yo=/[^-+\dA-Z]/g;function mr(s,a,e,t){if(arguments.length!==1||typeof s!="string"||/\d/.test(s)||(a=s,s=void 0),(s=s||s===0?s:new Date)instanceof Date||(s=new Date(s)),isNaN(s))throw TypeError("Invalid date");var i=(a=String(Ma[a]||a||Ma.default)).slice(0,4);i!=="UTC:"&&i!=="GMT:"||(a=a.slice(4),e=!0,i==="GMT:"&&(t=!0));var r=function(){return e?"getUTC":"get"},n=function(){return s[r()+"Date"]()},c=function(){return s[r()+"Day"]()},o=function(){return s[r()+"Month"]()},d=function(){return s[r()+"FullYear"]()},h=function(){return s[r()+"Hours"]()},l=function(){return s[r()+"Minutes"]()},p=function(){return s[r()+"Seconds"]()},u=function(){return s[r()+"Milliseconds"]()},g=function(){return e?0:s.getTimezoneOffset()},m=function(){return Ro(s)},b={d:function(){return n()},dd:function(){return nt(n())},ddd:function(){return tt.dayNames[c()]},DDD:function(){return Na({y:d(),m:o(),d:n(),_:r(),dayName:tt.dayNames[c()],short:!0})},dddd:function(){return tt.dayNames[c()+7]},DDDD:function(){return Na({y:d(),m:o(),d:n(),_:r(),dayName:tt.dayNames[c()+7]})},m:function(){return o()+1},mm:function(){return nt(o()+1)},mmm:function(){return tt.monthNames[o()]},mmmm:function(){return tt.monthNames[o()+12]},yy:function(){return String(d()).slice(2)},yyyy:function(){return nt(d(),4)},h:function(){return h()%12||12},hh:function(){return nt(h()%12||12)},H:function(){return h()},HH:function(){return nt(h())},M:function(){return l()},MM:function(){return nt(l())},s:function(){return p()},ss:function(){return nt(p())},l:function(){return nt(u(),3)},L:function(){return nt(Math.floor(u()/10))},t:function(){return h()<12?tt.timeNames[0]:tt.timeNames[1]},tt:function(){return h()<12?tt.timeNames[2]:tt.timeNames[3]},T:function(){return h()<12?tt.timeNames[4]:tt.timeNames[5]},TT:function(){return h()<12?tt.timeNames[6]:tt.timeNames[7]},Z:function(){return t?"GMT":e?"UTC":_o(s)},o:function(){return(g()>0?"-":"+")+nt(100*Math.floor(Math.abs(g())/60)+Math.abs(g())%60,4)},p:function(){return(g()>0?"-":"+")+nt(Math.floor(Math.abs(g())/60),2)+":"+nt(Math.floor(Math.abs(g())%60),2)},S:function(){return["th","st","nd","rd"][n()%10>3?0:(n()%100-n()%10!=10)*n()%10]},W:function(){return m()},WW:function(){return nt(m())},N:function(){return Ao(s)}};return a.replace(bo,function(S){return S in b?b[S]():S.slice(1,S.length-1)})}var Ma={default:"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",paddedShortDate:"mm/dd/yyyy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:sso",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'",expiresHeaderFormat:"ddd, dd mmm yyyy HH:MM:ss Z"},tt={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"],timeNames:["a","p","am","pm","A","P","AM","PM"]},nt=function(s){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;return String(s).padStart(a,"0")},Na=function(s){var a=s.y,e=s.m,t=s.d,i=s._,r=s.dayName,n=s.short,c=n!==void 0&&n,o=new Date,d=new Date;d.setDate(d[i+"Date"]()-1);var h=new Date;return h.setDate(h[i+"Date"]()+1),o[i+"FullYear"]()===a&&o[i+"Month"]()===e&&o[i+"Date"]()===t?c?"Tdy":"Today":d[i+"FullYear"]()===a&&d[i+"Month"]()===e&&d[i+"Date"]()===t?c?"Ysd":"Yesterday":h[i+"FullYear"]()===a&&h[i+"Month"]()===e&&h[i+"Date"]()===t?c?"Tmw":"Tomorrow":r},Ro=function(s){var a=new Date(s.getFullYear(),s.getMonth(),s.getDate());a.setDate(a.getDate()-(a.getDay()+6)%7+3);var e=new Date(a.getFullYear(),0,4);e.setDate(e.getDate()-(e.getDay()+6)%7+3);var t=a.getTimezoneOffset()-e.getTimezoneOffset();a.setHours(a.getHours()-t);var i=(a-e)/6048e5;return 1+Math.floor(i)},Ao=function(s){var a=s.getDay();return a===0&&(a=7),a},_o=function(s){return(String(s).match(vo)||[""]).pop().replace(yo,"").replace(/GMT\+0000/g,"UTC")};const{BrowserUtil:wo}=q.AliRTS,Eo="EdgeHTML",La="Blink",Io="Trident",To="Gecko",Co="WebKit",Pi=(s,a)=>{const e=a.match(s);return e&&e.length>0&&e[1]||""},ko=[{test:[/\sedg\//i,[/edg([ea]|ios)/i]],describe(s){if(/\sedg\//i.test(s))return{name:La};const a=Pi(/edge\/(\d+(\.?_?\d+)+)/i,s);return{name:Eo,version:a}}},{test:[/trident/i],describe(s){const a={name:Io},e=Pi(/trident\/(\d+(\.?_?\d+)+)/i,s);return e&&(a.version=e),a}},{test(s){const a=/gecko/i.test(s),e=/like gecko/i.test(s);return a&&!e},describe(s){const a={name:To},e=Pi(/gecko\/(\d+(\.?_?\d+)+)/i,s);return e&&(a.version=e),a}},{test:[/(apple)?webkit\/537\.36/i],describe:()=>({name:La})},{test:[/(apple)?webkit/i],describe(s){const a={name:Co},e=Pi(/webkit\/(\d+(\.?_?\d+)+)/i,s);return e&&(a.version=e),a}}],gr=(s,a)=>s.find(e=>typeof e.test=="function"?e.test(a):Array.isArray(e.test)?e.test.some(t=>typeof t=="string"?a.indexOf(t)>-1:t instanceof RegExp&&t.test(a)):void 0),Po=()=>{try{const s=navigator.userAgent||"",a=gr(ko,s);if(a){const e=a.describe(s);return`${e.name}/${e.version||wo.browserVersion}`}}catch(s){}return navigator.userAgent},Do=[{test:["wow64","win64","x64"],describe:()=>"amd64"},{test:["i686","x86"],describe:()=>"x86"},{test:["aarch64","arm64"],describe:()=>"arm64"},{test:["arm"],describe:()=>"arm"}],xa=()=>{let s="unknown";try{const a=navigator.userAgent||"",e=gr(Do,a);if(!e)return s;s=e.describe(a)}catch(a){}return s},Mo=[{test:[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],describe:()=>"Samsung"},{test:[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i,/\((ipad);[-\w\),; ]+apple/i,/(macintosh);/i],describe:()=>"Apple"},{test:[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],describe:()=>"Huawei"},{test:[/(?:honor)([-\w ]+)[;\)]/i],describe:()=>"Honor"},{test:[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],describe:()=>"Xiaomi"},{test:[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],describe:()=>"Oppo"},{test:[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],describe:()=>"Vivo"},{test:[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],describe:()=>"Realme"},{test:[/(pixel c)\b/i,/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],describe:()=>"Google"},{test:[/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],describe:()=>"ZTE"},{test:[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],describe:()=>"Meizu"}],No=()=>{let s="Unknown";try{const a=navigator.userAgent||"",e=gr(Mo,a);if(!e)return s;s=e.describe(a)}catch(a){}return s},{BrowserUtil:Va,SystenUtil:Oa}=q.AliRTS,Lo=xa(),Di=6e5,Mi={host:"cn-hangzhou.log.aliyuncs.com",project:"alivc-aio",logstore:"logger",time:10,count:10};function fr(){return mr(new Date,"HH:MM:ss.l")}function Ua(){return mr(new Date,"isoDate")}var Sr=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.API=2]="API",s[s.WARNING=3]="WARNING",s[s.ERROR=4]="ERROR",s[s.NONE=5]="NONE",s))(Sr||{});class xo{constructor(){f(this,"tracker");f(this,"slsPlugin");f(this,"stsData");f(this,"stsExpiration",Date.now());f(this,"clientId",dt());f(this,"bSesid",dt());f(this,"logLevel",3);f(this,"appId","");f(this,"sessionId","");f(this,"logCache",[]);f(this,"updateTaskTimer");f(this,"endReported",!0);f(this,"logSequence",0);f(this,"sendLogBeforeUnload",a=>T(this,null,function*(){if(!this.slsPlugin)return;this.logSequence+=1,a.unshift(this.getLogParams(710203,{log:`[${Ua()} ${fr()}] [INF] beforeunload`,stat_log_seq:this.logSequence}));const e=`https://${Mi.project}.${Mi.host}/logstores/${Mi.logstore}`,t={__logs__:a.map(n=>this.slsPlugin.transString(n))},{data:i,header:r}=yield this.slsPlugin.process(e,JSON.stringify(t));fetch(e,{keepalive:!0,method:"POST",headers:r,body:i})}));f(this,"logMethod",(a,e=console.log)=>(...t)=>{let i=fr();this.logLevel<=a&&e(i,...t);let r=et.paramArrayToString(t);a>0&&this.addLog(r)});f(this,"d",this.logMethod(0,console.debug));f(this,"i",this.logMethod(1));f(this,"w",this.logMethod(3,console.warn));f(this,"e",this.logMethod(4,(...a)=>{const[e,...t]=a;console.error(e,"<error>",t)}));f(this,"ev",this.logMethod(2));f(this,"a",this.logMethod(2,(...a)=>{const[e,...t]=a;if(t.length>2){const i=`${t[1]}`;i.startsWith("__g__")&&console.group(`${i.substring(5)}_${t[2]}`)}console.log(e,...t)}));f(this,"ar",this.logMethod(2,(...a)=>{const[e,...t]=a;console.log(e,...t),t.length>2&&`${t[1]}`.startsWith("__g__")&&console.groupEnd()}));f(this,"ae",this.logMethod(2,(...a)=>{const[e,...t]=a;console.error(e,"<error>",...t),t.length>2&&`${t[1]}`.startsWith("__g__")&&console.groupEnd()}));window.addEventListener("beforeunload",()=>{this.reportEnd(!0)})}init(){this.reset(),this.startSTSUpdateTask()}destroy(){this.updateTaskTimer&&clearTimeout(this.updateTaskTimer)}reset(){this.bSesid=dt(),this.endReported=!0,this.logSequence=0,this.appId="",this.sessionId=""}startSTSUpdateTask(){return T(this,null,function*(){this.updateTaskTimer&&clearTimeout(this.updateTaskTimer);try{const a=yield this.refreshSTSToken();this.createTracker(a)}catch(a){}this.updateTaskTimer=setTimeout(()=>{this.startSTSUpdateTask()},Di)})}refreshSTSToken(){return T(this,null,function*(){if(!this.stsData||this.stsExpiration<=Date.now()-Di){const a=yield this.requestSTSToken(),e=new Date(a==null?void 0:a.Expiration).getTime()||0,t=Date.now()+Di;this.stsExpiration=Math.max(e,t),this.stsData=a}return this.stsData})}requestSTSToken(){const a=Date.now(),e=`${this.clientId}|woMMssV6jmyol9fr|${a}`,t={Action:"AssumeSlsRoleV2",AuthInfo:di.MD5(e).toString(di.enc.Hex),ClientId:this.clientId,BusinessType:"logger",AppVersion:"1.0",Version:"2017-03-14",AuthTimestamp:`${a}`,TerminalType:"web",DeviceModel:"",Format:"JSON",SignatureMethod:"HMAC-SHA1",SignatureVersion:"1.0",Timestamp:mr(a,"isoUtcDateTime")},i=new URLSearchParams(t).toString();return fetch(`https://slsrole.alicdn.com/?${i}`).then(r=>r.json()).then(r=>JSON.parse(window.atob(r.SlsAuthResult)))}createTracker(a){if(!this.tracker){const e={accessKeyId:a.AccessKeyId,accessKeySecret:a.AccessKeySecret,securityToken:a.SecurityToken,refreshSTSTokenInterval:Di,stsTokenFreshTime:void 0,refreshSTSToken:()=>{this.refreshSTSToken().then(r=>{e.accessKeyId=r.AccessKeyId,e.accessKeySecret=r.AccessKeySecret,e.securityToken=r.SecurityToken}).catch(()=>{})}},t=new hr(Mi),i=pr(e);t.useStsPlugin(i),this.slsPlugin=i,this.tracker=t,this.reportStartAndCache()}}changeConfig(a){a.logLevel!==void 0&&a.logLevel>=0&&a.logLevel<=5&&(this.logLevel=a.logLevel)}setSessionID(a,e){a&&e&&(this.appId=a,this.sessionId=e,this.reportStartAndCache())}reportStartAndCache(){if(!this.tracker||!this.sessionId)return;this.endReported=!1;const a={task_btm_sec:0,task_duration:0,task_etm_sec:0,task_type:"session"},e=[this.getLogParams(710201,a),this.getLogParams(710202,a)];this.tracker.sendBatchLogsImmediate(e),this.logCache.forEach(t=>{this.sendLog(t)})}reportEnd(a=!1){if(!this.tracker||!this.sessionId||this.endReported)return void this.reset();const e={task_btm_sec:0,task_duration:0,task_etm_sec:0,task_type:"session"},t=[this.getLogParams(710204,e),this.getLogParams(710205,e)];a?this.sendLogBeforeUnload(t):(this.tracker.sendBatchLogsImmediate(t),this.endReported=!0),this.reset()}getLogParams(a,e){return X({appid:`${window.location.host}`,appid_list:this.appId,appver:"",b_sesid:this.bSesid,biz_type:"rtc",cpu_info:Lo,db:Va.browserName,dm:Va.browserVersion,install_uuid:this.clientId,logger_v:"0.0.1",os:Oa.systemName,osv:Oa.systemVersion,p_sesid:this.bSesid,sdk_version:Ti,sdkname:"AliRTCSdk",stm:Date.now(),tar_pf:"web",traceid:this.sessionId,event_id:a},e||{})}sendLog(a){if(!this.tracker||!this.sessionId)return;this.logSequence+=1;const e=this.getLogParams(710203,{log:a,stat_log_seq:this.logSequence});this.tracker.send(e)}addLog(a){const e=fr(),t=`[${Ua()} ${e}] ${a}`;this.sessionId&&this.tracker?this.sendLog(t):(this.logCache.push(t),this.logCache.length>=200&&this.logCache.shift())}}class V{static getLogger(){return this.logger||(this.logger=new xo),this.logger}static init(){this.getLogger().init()}static destroy(){this.getLogger().destroy()}static setLogLevel(a){this.getLogger().changeConfig({logLevel:a})}static setSessionID(a,e){this.getLogger().setSessionID(a,e)}static reportEnd(){this.getLogger().reportEnd()}static interface(...a){this.getLogger().a("[API]",...a)}static interfaceResult(a,e,t,...i){t?this.getLogger().ar("[ARE]",a,e,...i):this.getLogger().ae("[ARE]",a,e,...i)}static event(...a){this.getLogger().ev("[EVT]",...a)}static debug(...a){this.getLogger().d("[DBG]",...a)}static info(...a){this.getLogger().i("[INF]",...a)}static warn(...a){this.getLogger().w("[WARN]",...a)}static error(...a){this.getLogger().e("[ERR]",...a)}}f(V,"logger");const Vo=s=>T(this,null,function*(){const a=new q.AliRTS.SupportUtil;let e={support:!1,detail:{isWebRTCSupported:a.checkMediaDevices()&&a.checkWebRtcSupport(),isH264DecodeSupported:!1,isH264EncodeSupported:!1,isScreenShareSupported:!1,isSendMediaExtensionMsgSupported:!1,isBrowserSupported:!0}},t=!1;try{yield a.isSupport({isReceiveVideo:!0}),t=!0}catch(i){t=!1,e.detail.isBrowserSupported=a.checkBrowser({errorCode:0,message:""})}if(e.support=t,a.checkWebRtcSupport()&&s!=="sendonly"){const i=yield a.checkH264Decode();e.detail.isH264DecodeSupported=i,e.support=e.support&&i}if(a.checkWebRtcSupport()&&s!=="recvonly"){const i=yield a.checkH264Encode();e.detail.isH264EncodeSupported=i,e.support=e.support&&i}return e.detail.isScreenShareSupported=a.checkWebRtcSupport()&&a.checkScreenCapture()&&!q.AliRTS.SystenUtil.isAndroid&&!q.AliRTS.SystenUtil.isIos,e.detail.isSendMediaExtensionMsgSupported=a.checkWebRtcSupport()&&a.checkEncodedTransformSupport(),e});var Ne=(s=>(s[s.AliRtcSdkStreamTypeCapture=0]="AliRtcSdkStreamTypeCapture",s[s.AliRtcSdkStreamTypeScreen=1]="AliRtcSdkStreamTypeScreen",s))(Ne||{}),Ba=(s=>(s[s.PRE_PROCESSOR=0]="PRE_PROCESSOR",s[s.POST_PROCESSOR=1]="POST_PROCESSOR",s))(Ba||{}),ti=(s=>(s[s.AUDIO=0]="AUDIO",s[s.VIDEO=1]="VIDEO",s[s.BOTH=2]="BOTH",s))(ti||{});class Mt extends se{constructor(e,t=Ne.AliRtcSdkStreamTypeCapture,i=1){super();f(this,"name");f(this,"options");f(this,"type",0);f(this,"streamType");f(this,"trackType");f(this,"zIndex",1);f(this,"_isEnable",!0);f(this,"lastInputAudioTrack");f(this,"lastOutputAudioTrack");f(this,"lastInputVideoTrack");f(this,"lastOutputVideoTrack");f(this,"_hasCleared",!0);this.name=e,this.streamType=t,this.trackType=i,this.options=this.initOptions}get initOptions(){return{}}getOptions(){return this.options}init(){return T(this,null,function*(){})}enable(){this._isEnable||(this._isEnable=!0,this.init(),this.emit("enabled"))}disable(){this._isEnable&&(this._isEnable=!1,this.clear(),this.emit("disabled"))}get isEnable(){return this._isEnable}audioUpdated(e){var t,i;return((t=this.lastInputAudioTrack)==null?void 0:t.id)!==((i=e.currentAudioTrack)==null?void 0:i.id)}videoUpdated(e){var t,i;return((t=this.lastInputVideoTrack)==null?void 0:t.id)!==((i=e.currentVideoTrack)==null?void 0:i.id)}execute(e,t){return T(this,null,function*(){const i=this.shouldUpdate(e,t);this.lastInputAudioTrack=e.currentAudioTrack,this.lastInputVideoTrack=e.currentVideoTrack,this._hasCleared||i?(yield this.process(e,t),this._hasCleared=!1):(!this.lastOutputAudioTrack||this.trackType!==2&&this.trackType!==0||this.lastOutputAudioTrack&&e.updateAudioTrack(this.lastOutputAudioTrack),!this.lastOutputVideoTrack||this.trackType!==2&&this.trackType!==1||this.lastOutputVideoTrack&&e.updateVideoTrack(this.lastOutputVideoTrack)),this.lastOutputAudioTrack=e.currentAudioTrack,this.lastOutputVideoTrack=e.currentVideoTrack})}clear(e){this._hasCleared=!0,this.lastInputAudioTrack=void 0,this.lastInputVideoTrack=void 0,this.lastOutputAudioTrack=void 0,this.lastOutputVideoTrack=void 0}}var hi=(s=>(s[s.LiveTranscodingSingle=0]="LiveTranscodingSingle",s[s.LiveTranscodingMix=1]="LiveTranscodingMix",s))(hi||{}),br=(s=>(s[s.LiveTranscodingOrigin=0]="LiveTranscodingOrigin",s[s.LiveTranscodingAudio=1]="LiveTranscodingAudio",s[s.LiveTranscodingVideo=2]="LiveTranscodingVideo",s))(br||{}),ii=(s=>(s[s.LiveTranscodingCamera=0]="LiveTranscodingCamera",s[s.LiveTranscodingShareScreen=1]="LiveTranscodingShareScreen",s))(ii||{});const li={0:"camera",1:"shareScreen"};var vr=(s=>(s[s.LiveTranscoding_Profile_1IN_1080P=0]="LiveTranscoding_Profile_1IN_1080P",s[s.LiveTranscoding_Profile_1IN_720P=1]="LiveTranscoding_Profile_1IN_720P",s[s.LiveTranscoding_Profile_1IN_360P=2]="LiveTranscoding_Profile_1IN_360P",s[s.LiveTranscoding_Profile_2IN_1080P=3]="LiveTranscoding_Profile_2IN_1080P",s[s.LiveTranscoding_Profile_2IN_720P=4]="LiveTranscoding_Profile_2IN_720P",s[s.LiveTranscoding_Profile_2IN_360P=5]="LiveTranscoding_Profile_2IN_360P",s[s.LiveTranscoding_Profile_4IN_1080P=6]="LiveTranscoding_Profile_4IN_1080P",s[s.LiveTranscoding_Profile_4IN_720P=7]="LiveTranscoding_Profile_4IN_720P",s[s.LiveTranscoding_Profile_4IN_360P=8]="LiveTranscoding_Profile_4IN_360P",s[s.LiveTranscoding_Profile_9IN_1080P=9]="LiveTranscoding_Profile_9IN_1080P",s[s.LiveTranscoding_Profile_9IN_720P=10]="LiveTranscoding_Profile_9IN_720P",s[s.LiveTranscoding_Profile_9IN_360P=11]="LiveTranscoding_Profile_9IN_360P",s[s.LiveTranscoding_Profile_12IN_1080P=12]="LiveTranscoding_Profile_12IN_1080P",s[s.LiveTranscoding_Profile_12IN_720P=13]="LiveTranscoding_Profile_12IN_720P",s[s.LiveTranscoding_Profile_12IN_360P=14]="LiveTranscoding_Profile_12IN_360P",s[s.LiveTranscoding_Profile_16IN_1080P=15]="LiveTranscoding_Profile_16IN_1080P",s[s.LiveTranscoding_Profile_16IN_720P=16]="LiveTranscoding_Profile_16IN_720P",s[s.LiveTranscoding_Profile_16IN_360P=17]="LiveTranscoding_Profile_16IN_360P",s[s.LiveTranscoding_Profile_Mixed=9999]="LiveTranscoding_Profile_Mixed",s))(vr||{});const Oo={0:"1IN_1080P",1:"1IN_720P",2:"1IN_360P",3:"2IN_1080P",4:"2IN_720P",5:"2IN_360P",6:"4IN_1080P",7:"4IN_720P",8:"4IN_360P",9:"9IN_1080P",10:"9IN_720P",11:"9IN_360P",12:"12IN_1080P",13:"12IN_720P",14:"12IN_360P",15:"16IN_1080P",16:"16IN_720P",17:"16IN_360P",9999:"Mixed_Audio"};var Ni=(s=>(s[s.LiveTranscoding_HZ_48000=48e3]="LiveTranscoding_HZ_48000",s[s.LiveTranscoding_HZ_44100=44100]="LiveTranscoding_HZ_44100",s[s.LiveTranscoding_HZ_32000=32e3]="LiveTranscoding_HZ_32000",s[s.LiveTranscoding_HZ_16000=16e3]="LiveTranscoding_HZ_16000",s[s.LiveTranscoding_HZ_8000=8e3]="LiveTranscoding_HZ_8000",s))(Ni||{}),ui=(s=>(s[s.LiveTranscodingNoBody=0]="LiveTranscodingNoBody",s[s.LiveTranscodingBody=1]="LiveTranscodingBody",s))(ui||{}),pi=(s=>(s[s.NOTO_SERIF_CJKSC_REGULAR=0]="NOTO_SERIF_CJKSC_REGULAR",s[s.ALIBABA_PUHUITI_REGULAR=1]="ALIBABA_PUHUITI_REGULAR",s[s.ALIBABA_PUHUITI_BOLD=2]="ALIBABA_PUHUITI_BOLD",s[s.ALIBABA_PUHUITI_Heavy=3]="ALIBABA_PUHUITI_Heavy",s[s.ALIBABA_PUHUITI_LIGHT=4]="ALIBABA_PUHUITI_LIGHT",s[s.ALIBABA_PUHUITI_MEDIUM=5]="ALIBABA_PUHUITI_MEDIUM",s))(pi||{}),yr=(s=>(s[s.LiveTranscodingOrigin=0]="LiveTranscodingOrigin",s[s.LiveTranscodingCrop=1]="LiveTranscodingCrop",s[s.LiveTranscodingFill=2]="LiveTranscodingFill",s))(yr||{}),Li=(s=>(s[s.LiveTranscodingNormal=0]="LiveTranscodingNormal",s[s.LiveTranscodingVirtualBackground=1]="LiveTranscodingVirtualBackground",s))(Li||{}),Rr=(s=>(s[s.LiveTranscodingState_IDLE=0]="LiveTranscodingState_IDLE",s[s.LiveTranscodingState_CONNNECT=1]="LiveTranscodingState_CONNNECT",s[s.LiveTranscodingState_RUNNING=2]="LiveTranscodingState_RUNNING",s[s.LiveTranscodingState_RECOVERING=3]="LiveTranscodingState_RECOVERING",s[s.LiveTranscodingState_FAILURE=4]="LiveTranscodingState_FAILURE",s[s.LiveTranscodingState_END=5]="LiveTranscodingState_END",s))(Rr||{}),vt=(s=>(s[s.LiveTranscodingErrorPublishOk=0]="LiveTranscodingErrorPublishOk",s[s.LiveTranscodingErrorStreamNotFound=17825793]="LiveTranscodingErrorStreamNotFound",s[s.LiveTranscodingErrorStreamAlreadyExist=17825794]="LiveTranscodingErrorStreamAlreadyExist",s[s.LiveTranscodingErrorInvalidParam=17825795]="LiveTranscodingErrorInvalidParam",s[s.LiveTranscodingErrorInternalError=17825796]="LiveTranscodingErrorInternalError",s[s.LiveTranscodingErrorRtmpServerError=17825797]="LiveTranscodingErrorRtmpServerError",s[s.LiveTranscodingErrorRtmpStreamUrlError=17825798]="LiveTranscodingErrorRtmpStreamUrlError",s[s.LiveTranscodingErrorPublishTimeout=17825799]="LiveTranscodingErrorPublishTimeout",s[s.LiveTranscodingErrorNotAuthorized=17825800]="LiveTranscodingErrorNotAuthorized",s))(vt||{}),Ar=(s=>(s[s.TrascodingPublishTaskStatusStart=0]="TrascodingPublishTaskStatusStart",s[s.TrascodingPublishTaskStatusUpdate=1]="TrascodingPublishTaskStatusUpdate",s[s.TrascodingPublishTaskStatusStop=2]="TrascodingPublishTaskStatusStop",s))(Ar||{}),it=(s=>(s[s.MPU_TASK_TRANSACTION_START=0]="MPU_TASK_TRANSACTION_START",s[s.MPU_TASK_TRANSACTION_UPDATE=1]="MPU_TASK_TRANSACTION_UPDATE",s[s.MPU_TASK_TRANSACTION_STOP=2]="MPU_TASK_TRANSACTION_STOP",s[s.MPU_TASK_TRANSACTION_LIST=3]="MPU_TASK_TRANSACTION_LIST",s[s.MPU_TASK_TRANSACTION_POLLING=4]="MPU_TASK_TRANSACTION_POLLING",s[s.MPU_TASK_TRANSACTION_ACKNOWLEDGE=5]="MPU_TASK_TRANSACTION_ACKNOWLEDGE",s[s.MPU_TASK_TRANSACTION_END=6]="MPU_TASK_TRANSACTION_END",s))(it||{});const Uo={0:"/libra/v1/sdk/start-task",1:"/libra/v1/sdk/update-task",2:"/libra/v1/sdk/stop-task",3:"/libra/v1/sdk/list-task",4:"/libra/v1/sdk/polling",5:"/libra/v1/sdk/acknowledge",6:"/"};class _r{constructor(a,e,t,i,r,n,c,o){f(this,"videoWidth");f(this,"videoHeight");f(this,"videoFramerate",20);f(this,"videoBitrate",2e3);f(this,"videoGop",30);f(this,"audioSamplerate",Ni.LiveTranscoding_HZ_44100);f(this,"audioBitrate",500);f(this,"audioChannels",1);this.videoWidth=a,this.videoHeight=e,t&&(this.videoFramerate=t),i&&(this.videoBitrate=i),r&&(this.videoGop=r),n&&(this.audioSamplerate=n),c&&(this.audioBitrate=c),o&&(this.audioChannels=o)}}const wr=s=>((16711680&s)>>16)+(65280&s)+((255&s)<<16),ht=(s=0,a)=>{if(a==0)return 0;let e=s/a;return e<0&&(e=0),e>1&&(e=1),e};class xi{constructor(a,e,t){f(this,"mixMode",hi.LiveTranscodingSingle);f(this,"singleParam");f(this,"mixParam");a&&(this.mixMode=a),e&&(this.singleParam=e),t&&(this.mixParam=t)}toJson(a,e,t,i,r){const n={appid:e.appId,channelid:e.channelId};if(a===it.MPU_TASK_TRANSACTION_POLLING||a===it.MPU_TASK_TRANSACTION_LIST||a===it.MPU_TASK_TRANSACTION_ACKNOWLEDGE)return a===it.MPU_TASK_TRANSACTION_ACKNOWLEDGE&&(n.messageid=r),n;if(n.taskid=t,a!==it.MPU_TASK_TRANSACTION_STOP){if(n.mixmode=this.mixMode,i&&(n.streamurl=i),this.mixMode===hi.LiveTranscodingSingle){const c=this.singleParam;if(c){n.streamtype=c.streamType,c.sourceType===ii.LiveTranscodingShareScreen?n.sourcetype=li[c.sourceType]:n.sourcetype=li[ii.LiveTranscodingCamera];const o=[];c.userId&&o.push(c.userId),n.subspecusers=o}}else if(a===it.MPU_TASK_TRANSACTION_START||a===it.MPU_TASK_TRANSACTION_UPDATE){const c=this.mixParam;if(c){c.taskProfile&&(n.taskprofile=Oo[c.taskProfile]);const o=c.encodeParam||new _r(1280,720);let d=o.videoWidth,h=o.videoHeight;const l={};Object.keys(o).forEach(u=>{const g=o[u];g>0&&(l[u.toLowerCase()]=g)}),l.lowbitratehighquality=0,n.encodeparam=l,n.backgrounds=c.backgrounds.map(u=>u.toJson(d,h)),n.watermarks=c.watermarks.map(u=>u.toJson(d,h)),n.clockwidgets=c.clockWidgets.map(u=>u.toJson(d,h));const p=c.users.map(u=>u.userId);n.subspecusers=[...new Set(p)],n.layouts=[{audiomixcount:c.users.length,panes:c.users.map((u,g)=>u.toJson(g,d,h,c.mediaProcessMode))}],n.layoutids=["0"],n.cropmode=c.cropMode,n.backgroundcolor=wr(c.backgroundColor),n.taskmode=c.mediaProcessMode}}}return n}}var It=(s=>(s.pre="pre",s.prod="prod",s))(It||{}),Tt=(s=>(s.AliRtcSdkCommunication="communication",s.AliRtcSdkInteractiveLive="interactive_live",s.AliRtcSdkInteractiveWithLowLatencyLive="cdn_live",s))(Tt||{}),Nt=(s=>(s.AliRtcSdkInteractive="interactive",s.AliRtcSdkLive="live",s))(Nt||{}),yt=(s=>(s[s.AliEngineLocalDeviceTypeUnknown=0]="AliEngineLocalDeviceTypeUnknown",s[s.AliEngineLocalDeviceTypeMic=1]="AliEngineLocalDeviceTypeMic",s[s.AliEngineLocalDeviceTypeSpeaker=2]="AliEngineLocalDeviceTypeSpeaker",s[s.AliEngineLocalDeviceTypeAudioDevice=3]="AliEngineLocalDeviceTypeAudioDevice",s[s.AliEngineLocalDeviceTypeCamera=4]="AliEngineLocalDeviceTypeCamera",s[s.AliEngineLocalDeviceTypeDisplay=5]="AliEngineLocalDeviceTypeDisplay",s[s.AliEngineLocalDeviceTypeVideoDevice=6]="AliEngineLocalDeviceTypeVideoDevice",s))(yt||{}),Oe=(s=>(s[s.AliEngineLocalDeviceExceptionTypeUnknown=0]="AliEngineLocalDeviceExceptionTypeUnknown",s[s.AliEngineLocalDeviceExceptionTypeMicOpenFail=1]="AliEngineLocalDeviceExceptionTypeMicOpenFail",s[s.AliEngineLocalDeviceExceptionTypeMicInterrupt=2]="AliEngineLocalDeviceExceptionTypeMicInterrupt",s[s.AliEngineLocalDeviceExceptionTypeMicAuthFail=3]="AliEngineLocalDeviceExceptionTypeMicAuthFail",s[s.AliEngineLocalDeviceExceptionTypeMicNotAvailable=4]="AliEngineLocalDeviceExceptionTypeMicNotAvailable",s[s.AliEngineLocalDeviceExceptionTypeSpeakerOpenFail=5]="AliEngineLocalDeviceExceptionTypeSpeakerOpenFail",s[s.AliEngineLocalDeviceExceptionTypeSpeakerInterrupt=6]="AliEngineLocalDeviceExceptionTypeSpeakerInterrupt",s[s.AliEngineLocalDeviceExceptionTypeSpeakerNotAvailable=7]="AliEngineLocalDeviceExceptionTypeSpeakerNotAvailable",s[s.AliEngineLocalDeviceExceptionTypeAudioDeviceException=8]="AliEngineLocalDeviceExceptionTypeAudioDeviceException",s[s.AliEngineLocalDeviceExceptionTypeCameraOpenFail=9]="AliEngineLocalDeviceExceptionTypeCameraOpenFail",s[s.AliEngineLocalDeviceExceptionTypeCameraInterrupt=10]="AliEngineLocalDeviceExceptionTypeCameraInterrupt",s[s.AliEngineLocalDeviceExceptionTypeCameraAuthFail=11]="AliEngineLocalDeviceExceptionTypeCameraAuthFail",s[s.AliEngineLocalDeviceExceptionTypeDisplayException=12]="AliEngineLocalDeviceExceptionTypeDisplayException",s[s.AliEngineLocalDeviceExceptionTypeVideoDeviceException=13]="AliEngineLocalDeviceExceptionTypeVideoDeviceException",s))(Oe||{}),ue=(s=>(s[s.AliRtcConnectionStatusInit=0]="AliRtcConnectionStatusInit",s[s.AliRtcConnectionStatusDisconnected=1]="AliRtcConnectionStatusDisconnected",s[s.AliRtcConnectionStatusConnecting=2]="AliRtcConnectionStatusConnecting",s[s.AliRtcConnectionStatusConnected=3]="AliRtcConnectionStatusConnected",s[s.AliRtcConnectionStatusReconnecting=4]="AliRtcConnectionStatusReconnecting",s[s.AliRtcConnectionStatusFailed=5]="AliRtcConnectionStatusFailed",s))(ue||{}),Kt=(s=>(s[s.AliRtcConnectionChangedDummyReason=0]="AliRtcConnectionChangedDummyReason",s[s.AliRtcConnectionMediaPathChanged=1]="AliRtcConnectionMediaPathChanged",s[s.AliRtcConnectionSignalingHeartbeatTimeout=2]="AliRtcConnectionSignalingHeartbeatTimeout",s[s.AliRtcConnectionSignalingHeartbeatAlive=3]="AliRtcConnectionSignalingHeartbeatAlive",s[s.AliRtcConnectionSignalingHttpDnsResolved=4]="AliRtcConnectionSignalingHttpDnsResolved",s[s.AliRtcConnectionSignalingHttpDnsFailure=5]="AliRtcConnectionSignalingHttpDnsFailure",s[s.AliRtcConnectionSignalingGslbFailure=6]="AliRtcConnectionSignalingGslbFailure",s[s.AliRtcConnectionSignalingGslbSuccess=7]="AliRtcConnectionSignalingGslbSuccess",s[s.AliRtcConnectionSignalingJoinRoomFailure=8]="AliRtcConnectionSignalingJoinRoomFailure",s[s.AliRtcConnectionSignalingJoinRoomSuccess=9]="AliRtcConnectionSignalingJoinRoomSuccess",s[s.AliRtcConnectionSignalingLeaveRoom=10]="AliRtcConnectionSignalingLeaveRoom",s[s.AliRtcConnectionSignalingConnecting=11]="AliRtcConnectionSignalingConnecting",s[s.AliRtcConnectionChangedNetworkInterrupted=12]="AliRtcConnectionChangedNetworkInterrupted",s))(Kt||{}),Er=(s=>(s[s.AliRtcUserOfflineQuit=0]="AliRtcUserOfflineQuit",s[s.AliRtcUserOfflineDropped=1]="AliRtcUserOfflineDropped",s[s.AliRtcUserOfflineBecomeAudience=2]="AliRtcUserOfflineBecomeAudience",s))(Er||{}),ri=(s=>(s[s.AliRtcAudioTrackNo=0]="AliRtcAudioTrackNo",s[s.AliRtcAudioTrackMic=1]="AliRtcAudioTrackMic",s[s.AliRtcAudioTrackDual=2]="AliRtcAudioTrackDual",s))(ri||{}),ne=(s=>(s[s.AliRtcVideoTrackNo=0]="AliRtcVideoTrackNo",s[s.AliRtcVideoTrackCamera=1]="AliRtcVideoTrackCamera",s[s.AliRtcVideoTrackScreen=2]="AliRtcVideoTrackScreen",s[s.AliRtcVideoTrackBoth=3]="AliRtcVideoTrackBoth",s))(ne||{}),ie=(s=>(s[s.AliRtcStatePublishIdle=0]="AliRtcStatePublishIdle",s[s.AliRtcStateNoPublish=1]="AliRtcStateNoPublish",s[s.AliRtcStatePublishing=2]="AliRtcStatePublishing",s[s.AliRtcStatePublished=3]="AliRtcStatePublished",s))(ie||{}),me=(s=>(s[s.AliRtcStateSubscribeIdle=0]="AliRtcStateSubscribeIdle",s[s.AliRtcStateNoSubscribe=1]="AliRtcStateNoSubscribe",s[s.AliRtcStateSubscribing=2]="AliRtcStateSubscribing",s[s.AliRtcStateSubscribed=3]="AliRtcStateSubscribed",s))(me||{}),We=(s=>(s[s.AliRtcVideoStreamTypeNone=0]="AliRtcVideoStreamTypeNone",s[s.AliRtcVideoStreamTypeHigh=1]="AliRtcVideoStreamTypeHigh",s[s.AliRtcVideoStreamTypeLow=2]="AliRtcVideoStreamTypeLow",s))(We||{}),mi=(s=>(s[s.CAMERA_INVALID=-1]="CAMERA_INVALID",s[s.CAMERA_REAR=0]="CAMERA_REAR",s[s.CAMERA_FRONT=1]="CAMERA_FRONT",s))(mi||{});const oi=class oi extends se{constructor(e){super();f(this,"ws");f(this,"socketStatus",0);f(this,"wsUrl","");f(this,"lastConnectStartTime",0);f(this,"maxConnectRetryCount",12);f(this,"connectRetryCount",0);f(this,"gotErr",!1);f(this,"closedByInvoke",!0);f(this,"isReconnecting",!1);f(this,"networkAvailableChecked",!0);f(this,"reconnectTimeoutId",0);this.maxConnectRetryCount=e!=null?e:12,this.onOpen=this.onOpen.bind(this),this.onMessage=this.onMessage.bind(this),this.onError=this.onError.bind(this),this.onClose=this.onClose.bind(this)}get connectUrl(){return this.wsUrl}get connectStatus(){return this.socketStatus}start(e){this.wsUrl=e,this.initWebSocket()}send(e){return!(!this.ws||this.socketStatus!==2)&&(this.ws.send(JSON.stringify(e)),!0)}close(){this.closedByInvoke=!0,this.uninitWebsocket()}reconnect(){this.reconnectTimeoutId&&(clearTimeout(this.reconnectTimeoutId),this.reconnectTimeoutId=0),this.emit("onReconnectStart"),this.isReconnecting=!0,this.initWebSocket()}onOpen(e){V.info(`[${oi.logName}]`,"onOpen"),this.socketStatus=2,this.connectRetryCount=0,this.networkAvailableChecked=!1,this.closedByInvoke=!1,this.gotErr=!1,this.isReconnecting=!1,this.emit("onOpen",e)}onMessage(e){this.emit("onMessage",e)}onError(e){this.isReconnecting&&this.emit("onReconnectFail",e),this.emit("onError",e),this.isReconnecting=!1,this.socketStatus!==2&&et.isNetworkAvailable().then(t=>{t&&console.error(oi.logName,"onError, Network is available, token may be invalid")})}onClose(e){return T(this,null,function*(){if(this.closedByInvoke)this.socketStatus=0;else{if(V.info(`[${oi.logName}]`,`onClose, code: ${e.code}, reason: ${e.reason}, status: ${status}, retryCount: ${this.connectRetryCount}`),(yield et.isNetworkAvailable())&&!this.networkAvailableChecked)return this.reconnect(),void(this.networkAvailableChecked=!0);this.connectRetryCount||this.emit("onNetworkError"),!this.reconnectTimeoutId&&(this.connectRetryCount+=1,this.connectRetryCount>this.maxConnectRetryCount?this.emit("onConnectFail"):Date.now()-this.lastConnectStartTime>=5e3?this.reconnect():this.reconnectTimeoutId=window.setTimeout(()=>{this.reconnect()},5e3)),this.socketStatus=0,this.emit("onClose",e)}})}initWebSocket(){this.uninitWebsocket(),this.socketStatus=1,this.lastConnectStartTime=Date.now(),this.ws=new WebSocket(this.wsUrl),this.ws.addEventListener("open",this.onOpen),this.ws.addEventListener("message",this.onMessage),this.ws.addEventListener("error",this.onError),this.ws.addEventListener("close",this.onClose)}uninitWebsocket(){this.ws&&(this.ws.removeEventListener("open",this.onOpen),this.ws.removeEventListener("message",this.onMessage),this.ws.removeEventListener("error",this.onError),this.ws.removeEventListener("close",this.onClose),this.ws.readyState!==WebSocket.CLOSED&&this.ws.close(),this.ws=void 0,this.socketStatus=0)}};f(oi,"logName","Socket");let Ir=oi;var Tr={exports:{}};(function(s,a){(function(e,t){var i="function",r="undefined",n="object",c="string",o="major",d="model",h="name",l="type",p="vendor",u="version",g="architecture",m="console",b="mobile",S="tablet",v="smarttv",_="wearable",w="embedded",y="Amazon",R="Apple",A="ASUS",E="BlackBerry",I="Browser",k="Chrome",P="Firefox",B="Google",G="Huawei",Y="LG",J="Microsoft",z="Motorola",Q="Opera",ee="Samsung",pe="Sharp",D="Sony",L="Xiaomi",N="Zebra",x="Facebook",ce="Chromium OS",ke="Mac OS",$=" Browser",ge=function(ae){for(var re={},te=0;te<ae.length;te++)re[ae[te].toUpperCase()]=ae[te];return re},De=function(ae,re){return typeof ae===c&&Ae(re).indexOf(Ae(ae))!==-1},Ae=function(ae){return ae.toLowerCase()},Te=function(ae,re){if(typeof ae===c)return ae=ae.replace(/^\s\s*/,""),typeof re===r?ae:ae.substring(0,500)},fe=function(ae,re){for(var te,be,Ve,he,je,Z,Me=0;Me<re.length&&!je;){var at=re[Me],Le=re[Me+1];for(te=be=0;te<at.length&&!je&&at[te];)if(je=at[te++].exec(ae))for(Ve=0;Ve<Le.length;Ve++)Z=je[++be],typeof(he=Le[Ve])===n&&he.length>0?he.length===2?typeof he[1]==i?this[he[0]]=he[1].call(this,Z):this[he[0]]=he[1]:he.length===3?typeof he[1]!==i||he[1].exec&&he[1].test?this[he[0]]=Z?Z.replace(he[1],he[2]):t:this[he[0]]=Z?he[1].call(this,Z,he[2]):t:he.length===4&&(this[he[0]]=Z?he[3].call(this,Z.replace(he[1],he[2])):t):this[he]=Z||t;Me+=2}},_e=function(ae,re){for(var te in re)if(typeof re[te]===n&&re[te].length>0){for(var be=0;be<re[te].length;be++)if(De(re[te][be],ae))return te==="?"?t:te}else if(De(re[te],ae))return te==="?"?t:te;return re.hasOwnProperty("*")?re["*"]:ae},de={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},Pe={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[u,[h,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[u,[h,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[h,u],[/opios[\/ ]+([\w\.]+)/i],[u,[h,Q+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[u,[h,Q+" GX"]],[/\bopr\/([\w\.]+)/i],[u,[h,Q]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[u,[h,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[u,[h,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[h,u],[/quark(?:pc)?\/([-\w\.]+)/i],[u,[h,"Quark"]],[/\bddg\/([\w\.]+)/i],[u,[h,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[u,[h,"UC"+I]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[u,[h,"WeChat"]],[/konqueror\/([\w\.]+)/i],[u,[h,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[u,[h,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[u,[h,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[u,[h,"Smart Lenovo "+I]],[/(avast|avg)\/([\w\.]+)/i],[[h,/(.+)/,"$1 Secure "+I],u],[/\bfocus\/([\w\.]+)/i],[u,[h,P+" Focus"]],[/\bopt\/([\w\.]+)/i],[u,[h,Q+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[u,[h,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[u,[h,"Dolphin"]],[/coast\/([\w\.]+)/i],[u,[h,Q+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[u,[h,"MIUI"+$]],[/fxios\/([\w\.-]+)/i],[u,[h,P]],[/\bqihoobrowser\/?([\w\.]*)/i],[u,[h,"360"]],[/\b(qq)\/([\w\.]+)/i],[[h,/(.+)/,"$1Browser"],u],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[h,/(.+)/,"$1"+$],u],[/samsungbrowser\/([\w\.]+)/i],[u,[h,ee+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[u,[h,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[h,"Sogou Mobile"],u],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[h,u],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[h],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[u,h],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[h,x],u],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[h,u],[/\bgsa\/([\w\.]+) .*safari\//i],[u,[h,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[u,[h,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[u,[h,k+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[h,k+" WebView"],u],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[u,[h,"Android "+I]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[h,u],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[u,[h,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[u,h],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[h,[u,_e,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[h,u],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[h,"Netscape"],u],[/(wolvic|librewolf)\/([\w\.]+)/i],[h,u],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[u,[h,P+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i],[h,[u,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[h,[u,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[g,"amd64"]],[/(ia32(?=;))/i],[[g,Ae]],[/((?:i[346]|x)86)[;\)]/i],[[g,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[g,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[g,"armhf"]],[/windows (ce|mobile); ppc;/i],[[g,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[g,/ower/,"",Ae]],[/(sun4\w)[;\)]/i],[[g,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[g,Ae]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[d,[p,ee],[l,S]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[d,[p,ee],[l,b]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[d,[p,R],[l,b]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[d,[p,R],[l,S]],[/(macintosh);/i],[d,[p,R]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[d,[p,pe],[l,b]],[/(?:honor)([-\w ]+)[;\)]/i],[d,[p,"Honor"],[l,b]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[d,[p,G],[l,S]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[d,[p,G],[l,b]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i],[[d,/_/g," "],[p,L],[l,b]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[d,/_/g," "],[p,L],[l,S]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[d,[p,"OPPO"],[l,b]],[/\b(opd2\d{3}a?) bui/i],[d,[p,"OPPO"],[l,S]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[d,[p,"Vivo"],[l,b]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[d,[p,"Realme"],[l,b]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[d,[p,z],[l,b]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[d,[p,z],[l,S]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[p,Y],[l,S]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[d,[p,Y],[l,b]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[d,[p,"Lenovo"],[l,S]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[d,/_/g," "],[p,"Nokia"],[l,b]],[/(pixel c)\b/i],[d,[p,B],[l,S]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[d,[p,B],[l,b]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[d,[p,D],[l,b]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[d,"Xperia Tablet"],[p,D],[l,S]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[d,[p,"OnePlus"],[l,b]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[d,[p,y],[l,S]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[d,/(.+)/g,"Fire Phone $1"],[p,y],[l,b]],[/(playbook);[-\w\),; ]+(rim)/i],[d,p,[l,S]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[d,[p,E],[l,b]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[d,[p,A],[l,S]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[d,[p,A],[l,b]],[/(nexus 9)/i],[d,[p,"HTC"],[l,S]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[p,[d,/_/g," "],[l,b]],[/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])\w*(\)| bui)/i],[d,[p,"TCL"],[l,S]],[/(itel) ((\w+))/i],[[p,Ae],d,[l,_e,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[d,[p,"Acer"],[l,S]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[d,[p,"Meizu"],[l,b]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[d,[p,"Ulefone"],[l,b]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[d,[p,"Energizer"],[l,b]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[d,[p,"Cat"],[l,b]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[d,[p,"Smartfren"],[l,b]],[/droid.+; (a(?:015|06[35]|142p?))/i],[d,[p,"Nothing"],[l,b]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (imo) ((?!tab)[\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[p,d,[l,b]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[p,d,[l,S]],[/(surface duo)/i],[d,[p,J],[l,S]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[d,[p,"Fairphone"],[l,b]],[/(u304aa)/i],[d,[p,"AT&T"],[l,b]],[/\bsie-(\w*)/i],[d,[p,"Siemens"],[l,b]],[/\b(rct\w+) b/i],[d,[p,"RCA"],[l,S]],[/\b(venue[\d ]{2,7}) b/i],[d,[p,"Dell"],[l,S]],[/\b(q(?:mv|ta)\w+) b/i],[d,[p,"Verizon"],[l,S]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[d,[p,"Barnes & Noble"],[l,S]],[/\b(tm\d{3}\w+) b/i],[d,[p,"NuVision"],[l,S]],[/\b(k88) b/i],[d,[p,"ZTE"],[l,S]],[/\b(nx\d{3}j) b/i],[d,[p,"ZTE"],[l,b]],[/\b(gen\d{3}) b.+49h/i],[d,[p,"Swiss"],[l,b]],[/\b(zur\d{3}) b/i],[d,[p,"Swiss"],[l,S]],[/\b((zeki)?tb.*\b) b/i],[d,[p,"Zeki"],[l,S]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[p,"Dragon Touch"],d,[l,S]],[/\b(ns-?\w{0,9}) b/i],[d,[p,"Insignia"],[l,S]],[/\b((nxa|next)-?\w{0,9}) b/i],[d,[p,"NextBook"],[l,S]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[p,"Voice"],d,[l,b]],[/\b(lvtel\-)?(v1[12]) b/i],[[p,"LvTel"],d,[l,b]],[/\b(ph-1) /i],[d,[p,"Essential"],[l,b]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[d,[p,"Envizen"],[l,S]],[/\b(trio[-\w\. ]+) b/i],[d,[p,"MachSpeed"],[l,S]],[/\btu_(1491) b/i],[d,[p,"Rotor"],[l,S]],[/(shield[\w ]+) b/i],[d,[p,"Nvidia"],[l,S]],[/(sprint) (\w+)/i],[p,d,[l,b]],[/(kin\.[onetw]{3})/i],[[d,/\./g," "],[p,J],[l,b]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[d,[p,N],[l,S]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[d,[p,N],[l,b]],[/smart-tv.+(samsung)/i],[p,[l,v]],[/hbbtv.+maple;(\d+)/i],[[d,/^/,"SmartTV"],[p,ee],[l,v]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[p,Y],[l,v]],[/(apple) ?tv/i],[p,[d,R+" TV"],[l,v]],[/crkey/i],[[d,k+"cast"],[p,B],[l,v]],[/droid.+aft(\w+)( bui|\))/i],[d,[p,y],[l,v]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[d,[p,pe],[l,v]],[/(bravia[\w ]+)( bui|\))/i],[d,[p,D],[l,v]],[/(mitv-\w{5}) bui/i],[d,[p,L],[l,v]],[/Hbbtv.*(technisat) (.*);/i],[p,d,[l,v]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[p,Te],[d,Te],[l,v]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[l,v]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[p,d,[l,m]],[/droid.+; (shield) bui/i],[d,[p,"Nvidia"],[l,m]],[/(playstation [345portablevi]+)/i],[d,[p,D],[l,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[d,[p,J],[l,m]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[d,[p,ee],[l,_]],[/((pebble))app/i],[p,d,[l,_]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[d,[p,R],[l,_]],[/droid.+; (glass) \d/i],[d,[p,B],[l,_]],[/droid.+; (wt63?0{2,3})\)/i],[d,[p,N],[l,_]],[/droid.+; (glass) \d/i],[d,[p,B],[l,_]],[/(pico) (4|neo3(?: link|pro)?)/i],[p,d,[l,_]],[/; (quest( \d| pro)?)/i],[d,[p,x],[l,_]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[p,[l,w]],[/(aeobc)\b/i],[d,[p,y],[l,w]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[d,[l,b]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[d,[l,S]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[l,S]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[l,b]],[/(android[-\w\. ]{0,9});.+buil/i],[d,[p,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[u,[h,"EdgeHTML"]],[/(arkweb)\/([\w\.]+)/i],[h,u],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[u,[h,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[h,u],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[u,h]],os:[[/microsoft (windows) (vista|xp)/i],[h,u],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[h,[u,_e,de]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[u,_e,de],[h,"Windows"]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[u,/_/g,"."],[h,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[h,ke],[u,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[u,h],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[h,u],[/\(bb(10);/i],[u,[h,E]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[u,[h,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[u,[h,P+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[u,[h,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[u,[h,"watchOS"]],[/crkey\/([\d\.]+)/i],[u,[h,k+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[h,ce],u],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[h,u],[/(sunos) ?([\w\.\d]*)/i],[[h,"Solaris"],u],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[h,u]]},ye=function(ae,re){if(typeof ae===n&&(re=ae,ae=t),!(this instanceof ye))return new ye(ae,re).getResult();var te=typeof e!==r&&e.navigator?e.navigator:t,be=ae||(te&&te.userAgent?te.userAgent:""),Ve=te&&te.userAgentData?te.userAgentData:t,he=re?function(Z,Me){var at={};for(var Le in Z)Me[Le]&&Me[Le].length%2==0?at[Le]=Me[Le].concat(Z[Le]):at[Le]=Z[Le];return at}(Pe,re):Pe,je=te&&te.userAgent==be;return this.getBrowser=function(){var Z,Me={};return Me[h]=t,Me[u]=t,fe.call(Me,be,he.browser),Me[o]=typeof(Z=Me[u])===c?Z.replace(/[^\d\.]/g,"").split(".")[0]:t,je&&te&&te.brave&&typeof te.brave.isBrave==i&&(Me[h]="Brave"),Me},this.getCPU=function(){var Z={};return Z[g]=t,fe.call(Z,be,he.cpu),Z},this.getDevice=function(){var Z={};return Z[p]=t,Z[d]=t,Z[l]=t,fe.call(Z,be,he.device),je&&!Z[l]&&Ve&&Ve.mobile&&(Z[l]=b),je&&Z[d]=="Macintosh"&&te&&typeof te.standalone!==r&&te.maxTouchPoints&&te.maxTouchPoints>2&&(Z[d]="iPad",Z[l]=S),Z},this.getEngine=function(){var Z={};return Z[h]=t,Z[u]=t,fe.call(Z,be,he.engine),Z},this.getOS=function(){var Z={};return Z[h]=t,Z[u]=t,fe.call(Z,be,he.os),je&&!Z[h]&&Ve&&Ve.platform&&Ve.platform!="Unknown"&&(Z[h]=Ve.platform.replace(/chrome os/i,ce).replace(/macos/i,ke)),Z},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return be},this.setUA=function(Z){return be=typeof Z===c&&Z.length>500?Te(Z,500):Z,this},this.setUA(be),this};ye.VERSION="1.0.40",ye.BROWSER=ge([h,u,o]),ye.CPU=ge([g]),ye.DEVICE=ge([d,p,l,m,b,v,S,_,w]),ye.ENGINE=ye.OS=ge([h,u]),s.exports&&(a=s.exports=ye),a.UAParser=ye;var Ge=typeof e!==r&&(e.jQuery||e.Zepto);if(Ge&&!Ge.ua){var st=new ye;Ge.ua=st.getResult(),Ge.ua.get=function(){return st.getUA()},Ge.ua.set=function(ae){st.setUA(ae);var re=st.getResult();for(var te in re)Ge.ua[te]=re[te]}}})(typeof window=="object"?window:Ci)})(Tr,Tr.exports);var Bo=Tr.exports,Ue=(s=>(s.KEEPALIVE="keepalive",s.JOINCHANNEL="joinchannel",s.NOTIFYJOIN="notifyjoin",s.NOTIFYSTATUS="notifystatus",s.STATUSREPORT="statusreport",s.LEAVECHANNEL="leavechannel",s.NOTIFYLEAVE="notifyleave",s.NOTIFYPUBLISH="notifypublish",s.BYE="bye",s.RECONNECT="reconnect",s.PUBLISH="publish",s.REFRESHURL="refreshurl",s.UNSUBSCRIBE="unsubscribe",s.ROLEUPDATE="roleupdate",s))(Ue||{});class Ho{constructor(a,e){f(this,"authInfo");f(this,"userName");f(this,"seqIndex",0);this.authInfo=a,this.userName=e}get roleAuth(){if(this.authInfo.role){const{timestamp:a,nonce:e,token:t,role:i}=this.authInfo;return{timestamp:a,nonce:e,token:t,tokenrole:i}}}get adaptInfo(){var e,t,i,r;let a=new Bo.UAParser().getResult();return{os_name:((e=a.os.name)==null?void 0:e.replace(" ",""))+"_"+((t=a.browser.name)==null?void 0:t.replace(" ","")),device_name:((i=a.device.model)==null?void 0:i.replace(" ",""))||"",brand_name:((r=a.device.vendor)==null?void 0:r.replace(" ",""))||"",device_key:window.navigator.userAgent,os_version:a.browser.version||"",sdk_version:"7.0.2",version:"v1"}}refreshAuthInfo(a){this.authInfo=a}getSeqIndex(){return this.seqIndex}createKeepAlivePackage(){return this.createBaseSendPackage("keepalive")}createJoinPackage(a){let e=this.createBaseSendPackage("joinchannel");return e.header.displayName=this.userName,e.header.clientversion=et.getVersionNumber().toString(),e.header.platform="web",this.roleAuth&&(e.data.auth=this.roleAuth),this.adaptInfo&&(e.data.adapt=this.adaptInfo),a&&(e.data=X(X({},e.data),a)),e}crateLeavePackage(){return this.createBaseSendPackage("leavechannel")}createStatusPackage(a){let e=this.createBaseSendPackage("statusreport");return e.header.displayName=this.userName,e.data.status=a,e}createPublishPackage(){let a=this.createBaseSendPackage("publish");return a.data.users=[{}],this.roleAuth&&(a.data.auth=this.roleAuth),a}createRoleUpdatePackage(){let a=this.createBaseSendPackage("roleupdate");return a.header.displayName=this.userName,a}createReconnectPackage(a){let e=this.createBaseSendPackage("reconnect");return e.header.displayName=this.userName,e.header.clientversion=et.getVersionNumber().toString(),e.header.platform="web",e.data=X(X({},e.data),a!=null?a:{}),this.roleAuth&&(e.data.auth=this.roleAuth),e}createRefreshUrlPackage(){let a=this.createBaseSendPackage("refreshurl");return a.header.displayName=this.userName,a}createResponsePackage(a,e){return{version:1,code:200,tid:a,msgtype:e}}createBaseSendPackage(a){var e;return++this.seqIndex,{version:1,msgtype:a,tid:dt(),header:{appid:this.authInfo.appId,channelid:this.authInfo.channelId,sessionid:(e=this.authInfo.sessionId)!=null?e:"",userid:this.authInfo.userId},data:{seq:this.seqIndex}}}}var H=(s=>(s[s.ERR_JOIN_ALREADY_JOINED=16843521]="ERR_JOIN_ALREADY_JOINED",s[s.ERR_JOIN_BAD_APPID=33620481]="ERR_JOIN_BAD_APPID",s[s.ERR_JOIN_INVALID_APPID=33620482]="ERR_JOIN_INVALID_APPID",s[s.ERR_JOIN_BAD_CHANNEL=33620484]="ERR_JOIN_BAD_CHANNEL",s[s.ERR_JOIN_INVALID_CHANNEL=33620483]="ERR_JOIN_INVALID_CHANNEL",s[s.ERR_JOIN_BAD_TOKEN=33620485]="ERR_JOIN_BAD_TOKEN",s[s.ERR_JOIN_TIMEOUT=16908804]="ERR_JOIN_TIMEOUT",s[s.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD=16974081]="ERR_JOIN_ERR_JOIN_BAD_PARAMBAD",s[s.ERR_JOIN_CHANNEL_FAILED=16974338]="ERR_JOIN_CHANNEL_FAILED",s[s.ERR_LOG_ALREADY_INIT=16974085]="ERR_LOG_ALREADY_INIT",s[s.ERR_LOG_ROOT_PATH_ERROR=16974086]="ERR_LOG_ROOT_PATH_ERROR",s[s.ERR_MIC_OPEN_FAIL=17040388]="ERR_MIC_OPEN_FAIL",s[s.ERR_SPEAKER_OPEN_FAIL=17040389]="ERR_SPEAKER_OPEN_FAIL",s[s.ERR_MIC_INTERRUPT=17040390]="ERR_MIC_INTERRUPT",s[s.ERR_SPEAKER_INTERRUPT=17040391]="ERR_SPEAKER_INTERRUPT",s[s.ERR_MIC_AUTH_FAIL=17040392]="ERR_MIC_AUTH_FAIL",s[s.ERR_MIC_NOT_AVAILABLE=17040393]="ERR_MIC_NOT_AVAILABLE",s[s.ERR_SPEAKER_NOT_AVAILABLE=17040400]="ERR_SPEAKER_NOT_AVAILABLE",s[s.ERR_CAMERA_OPEN_FAIL=17039620]="ERR_CAMERA_OPEN_FAIL",s[s.ERR_CAMERA_AUTH_FAIL=17039621]="ERR_CAMERA_AUTH_FAIL",s[s.ERR_CAMERA_INTERRUPT=17039622]="ERR_CAMERA_INTERRUPT",s[s.ERR_CAMERA_NOT_AVAILABLE=17039623]="ERR_CAMERA_NOT_AVAILABLE",s[s.ERR_VIDEO_DISPLAY_OPEN_FAIL=17039873]="ERR_VIDEO_DISPLAY_OPEN_FAIL",s[s.ERR_VIDEO_DISPLAY_INTERRUPT=1064992]="ERR_VIDEO_DISPLAY_INTERRUPT",s[s.ERR_ICE_CONNECTION_CONNECT_FAIL=17105409]="ERR_ICE_CONNECTION_CONNECT_FAIL",s[s.ERR_ICE_CONNECTION_RECONNECT_FAI=17105410]="ERR_ICE_CONNECTION_RECONNECT_FAI",s[s.ERR_ICE_CONNECTION_MOBILITY_FAIL=17105411]="ERR_ICE_CONNECTION_MOBILITY_FAIL",s[s.ERR_ICE_CONNECTION_HEARTBEAT_TIMEOUT=16908812]="ERR_ICE_CONNECTION_HEARTBEAT_TIMEOUT",s[s.ERR_LATENCY_LIVE_COMMUNICATION_FAILED=17235971]="ERR_LATENCY_LIVE_COMMUNICATION_FAILED",s[s.ERR_LATENCY_LIVE_MEIDASETTING_FAILED=17235972]="ERR_LATENCY_LIVE_MEIDASETTING_FAILED",s[s.ERR_LATENCY_LIVE_NONE_BROADCASTER=17235973]="ERR_LATENCY_LIVE_NONE_BROADCASTER",s[s.ERR_LATENCY_LIVE_NEED_RESTART=17235974]="ERR_LATENCY_LIVE_NEED_RESTART",s[s.ERR_LATENCY_LIVE_NEED_RESTART_AGAIN_LATER=17235975]="ERR_LATENCY_LIVE_NEED_RESTART_AGAIN_LATER",s[s.ERR_LATENCY_LIVE_SERVICE_UNAVAILABLE=17235976]="ERR_LATENCY_LIVE_SERVICE_UNAVAILABLE",s[s.ERR_LATENCY_LIVE_MEDIACONNECTION_INTERRUPTION=17235977]="ERR_LATENCY_LIVE_MEDIACONNECTION_INTERRUPTION",s[s.ERR_SDK_PUBLISH_INVAILD=16974597]="ERR_SDK_PUBLISH_INVAILD",s[s.ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL=16843782]="ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL",s[s.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED=16843856]="ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED",s[s.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED=16843857]="ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED",s[s.ERR_SDK_PUBLISH_DUAL_STREAM_FAILED=16843858]="ERR_SDK_PUBLISH_DUAL_STREAM_FAILED",s[s.ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED=16843859]="ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED",s[s.ERR_SDK_PUBLISH_SCREEN_SHARE_CONFIG_ERROR=16843860]="ERR_SDK_PUBLISH_SCREEN_SHARE_CONFIG_ERROR",s[s.ERR_SDK_SUBSCRIBE_INVAILD=16974852]="ERR_SDK_SUBSCRIBE_INVAILD",s[s.ERR_SDK_SUBSCRIBE_NOT_JOIN_CHANNEL=16844112]="ERR_SDK_SUBSCRIBE_NOT_JOIN_CHANNEL",s[s.ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED=16844113]="ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED",s[s.ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED=16844114]="ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED",s[s.ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED=16844115]="ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED",s[s.ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED=16844116]="ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED",s[s.ERR_SDK_SUBSCRIBE_DATA_FAILED=16844117]="ERR_SDK_SUBSCRIBE_DATA_FAILED",s[s.ERR_SDK_SUBSCRIBE_DATA_ERROR=16844118]="ERR_SDK_SUBSCRIBE_DATA_ERROR",s[s.ERR_SDK_INVALID_STATE=16974340]="ERR_SDK_INVALID_STATE",s[s.ERR_INVALID_ARGUMENTS=16974083]="ERR_INVALID_ARGUMENTS",s[s.ERR_SESSION_REMOVED=33620229]="ERR_SESSION_REMOVED",s[s.ERR_SDK_UPDATE_ROLE_CHANNEL=16908801]="ERR_SDK_UPDATE_ROLE_CHANNEL",s[s.ERR_INNER=-1]="ERR_INNER",s[s.ERR_SDK_MPU_TASK_PUBLISH_OK=0]="ERR_SDK_MPU_TASK_PUBLISH_OK",s[s.ERR_SDK_MPU_TASK_STREAM_NOT_FOUND=17825793]="ERR_SDK_MPU_TASK_STREAM_NOT_FOUND",s[s.ERR_SDK_MPU_TASK_STREAM_ALREADY_EXIST=17825794]="ERR_SDK_MPU_TASK_STREAM_ALREADY_EXIST",s[s.ERR_SDK_MPU_TASK_INVALID_PARAM=17825795]="ERR_SDK_MPU_TASK_INVALID_PARAM",s[s.ERR_SDK_MPU_TASK_INTERNAL_ERROR=17825796]="ERR_SDK_MPU_TASK_INTERNAL_ERROR",s[s.ERR_SDK_MPU_TASK_RTMP_SERVER_ERROR=17825797]="ERR_SDK_MPU_TASK_RTMP_SERVER_ERROR",s[s.ERR_SDK_MPU_TASK_RTMP_STREAM_URL_ERROR=17825798]="ERR_SDK_MPU_TASK_RTMP_STREAM_URL_ERROR",s[s.ERR_SDK_MPU_TASK_PUBLISH_TIMEOUT=17825799]="ERR_SDK_MPU_TASK_PUBLISH_TIMEOUT",s[s.ERR_SDK_MPU_TASK_NOT_AUTHORIZED=17825800]="ERR_SDK_MPU_TASK_NOT_AUTHORIZED",s[s.ERR_SDK_CHANNEL_RELAY_STATE_ERROR=18874369]="ERR_SDK_CHANNEL_RELAY_STATE_ERROR",s[s.ERR_SDK_CHANNEL_RELAY_SRC_NOT_ALLOW=18874370]="ERR_SDK_CHANNEL_RELAY_SRC_NOT_ALLOW",s[s.ERR_SDK_CHANNEL_RELAY_JOIN_DEST_FAILED=18874371]="ERR_SDK_CHANNEL_RELAY_JOIN_DEST_FAILED",s[s.ERR_SDK_CHANNEL_RELAY_TOKEN_INVALID=18874372]="ERR_SDK_CHANNEL_RELAY_TOKEN_INVALID",s[s.ERR_SDK_CHANNEL_RELAY_ROLE_ERROR=18874373]="ERR_SDK_CHANNEL_RELAY_ROLE_ERROR",s[s.ERR_SDK_CHANNEL_RELAY_INVALID_PARAM=18874374]="ERR_SDK_CHANNEL_RELAY_INVALID_PARAM",s[s.ERR_SDK_CHANNEL_RELAY_TO_SELF_ERROR=18874375]="ERR_SDK_CHANNEL_RELAY_TO_SELF_ERROR",s))(H||{});class O extends Error{constructor(e,t,i){super(t);f(this,"_code");f(this,"_extra");this._code=e,this._extra=i}static fromRtsError(e){return e instanceof O?e:new O((e==null?void 0:e.errorCode)||-1,(e==null?void 0:e.message)||(e==null?void 0:e.errorCodeName)||"rts error",e)}static fromError(e,t=-1,i=""){return new O(t,(e==null?void 0:e.message)||(e==null?void 0:e.reason)||i||"error",e)}get code(){return this._code}set code(e){this._code=e}get reason(){return this.message}get extra(){return this._extra}}const ct=class ct extends se{constructor(e,t,i,r,n,c){super();f(this,"authInfo");f(this,"userName");f(this,"channelProfile");f(this,"clientRole");f(this,"slsReporter");f(this,"wsClient");f(this,"packageCreater");f(this,"keepAliveTimer",0);f(this,"packageCache",new Map);f(this,"isFirstConnect",!0);f(this,"aliveChecker",0);f(this,"reconnectData");f(this,"joinChannelExtraData");this.authInfo=e,this.userName=t,this.packageCreater=new Ho(e,t),this.channelProfile=i,this.clientRole=r,this.slsReporter=n,this.wsClient=new Ir(c),this.wsClient.on("onOpen",this.onOpen.bind(this)),this.wsClient.on("onMessage",this.onMessage.bind(this)),this.wsClient.on("onError",this.onError.bind(this)),this.wsClient.on("onClose",this.onClose.bind(this)),this.wsClient.on("onConnectFail",this.onConnectFail.bind(this)),this.wsClient.on("onAuthInvalid",this.onAuthInvalid.bind(this)),this.wsClient.on("onNetworkError",this.onNetworkError.bind(this)),this.wsClient.on("onReconnectStart",this.onReconnectStart.bind(this)),this.wsClient.on("onReconnectFail",this.onReconnectFail.bind(this))}get retryCount(){return this.wsClient.connectRetryCount}start(e,t){this.joinChannelExtraData=t,this.wsClient.start(e)}startKeepAlive(){this.keepAliveTimer===0&&(this.keepAliveTimer=window.setInterval(()=>{let e=this.packageCreater.createKeepAlivePackage();this.sendPackage(e)},5e3)),this.checkAlive()}stopKeepAlive(){this.keepAliveTimer!==0&&(clearInterval(this.keepAliveTimer),this.keepAliveTimer=0),this.aliveChecker&&(window.clearTimeout(this.aliveChecker),this.aliveChecker=0)}sendPkgCache(){this.packageCache.forEach(e=>{this.wsClient.send(e)})}leave(){let e=this.packageCreater.crateLeavePackage();this.sendPackage(e)}reportStatus(e){let t=this.packageCreater.createStatusPackage(e);this.sendPackage(t)}publish(e){const d=e,{l1ip:t}=d,i=Qt(d,["l1ip"]);let r=this.packageCreater.createPublishPackage();r.data.users=[],r.data.l1ip=t,i.subscribe.signal=this.wsClient.connectUrl;const{tracks:n,resume:c}=i;let o="7.0.2";o&&(o=o.split("-")[0]),n.forEach(h=>{const{codec:l,ssrc:p}=h;h.userdata=JSON.stringify({sdk_version:o,codec:l}),h.ssrc=`${p}`,c&&(h.attr={reason:"reconnect"})}),r.data.users.push(i),this.sendPackage(r)}roleUpdate(e){let t=this.packageCreater.createRoleUpdatePackage();t.data.clientrole=e,this.sendPackage(t)}refreshUrl(e){const t=this.packageCreater.createRefreshUrlPackage();t.data=X(kt(X({},t.data),{sessionid:t.header.sessionid}),e),this.sendPackage(t)}refreshAuthInfo(e){this.authInfo=e,this.packageCreater.refreshAuthInfo(e)}close(){V.info(`[${ct.logName}] close`),this.stopKeepAlive(),this.wsClient.off("onOpen",this.onOpen.bind(this)),this.wsClient.off("onMessage",this.onMessage.bind(this)),this.wsClient.off("onError",this.onError.bind(this)),this.wsClient.off("onClose",this.onClose.bind(this)),this.wsClient.off("onConnectFail",this.onConnectFail.bind(this)),this.wsClient.off("onAuthInvalid",this.onAuthInvalid.bind(this)),this.wsClient.off("onReconnectStart"),this.wsClient.off("onReconnectFail"),this.wsClient.close()}sendPackage(e){[Ue.KEEPALIVE,Ue.RECONNECT,Ue.JOINCHANNEL].includes(e.msgtype)||this.packageCache.set(e.tid,e),this.wsClient.send(e),e.msgtype!==Ue.KEEPALIVE&&this.slsReporter.reportRoomServerEvent(!0,e.msgtype,e.tid,e)}updateReconnectData(e){this.reconnectData=e}onOpen(){if(V.info(`[${ct.logName}] onOpen`),this.isFirstConnect){let e=this.packageCreater.createJoinPackage(this.joinChannelExtraData);e.data.configure={channelprofile:this.channelProfile},this.channelProfile!==Tt.AliRtcSdkInteractiveLive&&this.channelProfile!==Tt.AliRtcSdkInteractiveWithLowLatencyLive||(e.data.configure.clientrole=this.clientRole),this.sendPackage(e)}else{this.stopKeepAlive();const e=this.packageCreater.createReconnectPackage(this.reconnectData);this.sendPackage(e)}}onMessage(e){try{let t=JSON.parse(e.data);this.packageCache.delete(t.tid),this.onRecvMessage(t),t!=null&&t.msgtype&&(t==null?void 0:t.msgtype)!==Ue.KEEPALIVE&&this.slsReporter.reportRoomServerEvent(!1,t.msgtype,t.tid,t)}catch(t){V.warn(`[${ct.logName}] onMessage err`,t,e)}}onError(e){V.warn(`[${ct.logName}] onError`,e),this.isFirstConnect&&this.onConnectFail()}onConnectFail(){V.warn(`[${ct.logName}] onConnectFail`);const e=new O(H.ERR_INNER,"Signaling connect failed.");this.isFirstConnect?this.emit("onJoinChannelResult",e):this.emit("onConnectFail",e)}onAuthInvalid(){V.warn(`[${ct.logName}] onAuthInvalid`),this.isFirstConnect&&this.emit("onAuthInvalid")}onNetworkError(){V.warn(`[${ct.logName}] onNetworkError`);const e=new O(H.ERR_INNER,"Network error, signaling connect failed.");this.emit("onNetworkError",e)}onClose(e){V.info(`[${ct.logName}] onClose`,e),this.stopKeepAlive()}onKeepAliveRsp(){this.emit("onKeepAliveRsp"),this.checkAlive()}onReconnectStart(){this.emit("onReconnectStart")}onReconnectFail(){this.emit("onReconnectFail",new O(H.ERR_INNER,"signaling reconnect failed."))}checkAlive(){window.clearTimeout(this.aliveChecker),this.aliveChecker=window.setTimeout(()=>{V.info(`[${ct.logName}] not alive, reconnect`),this.stopKeepAlive(),this.emit("onReconnectStart"),this.wsClient.reconnect()},3e4)}onRecvMessage(e){switch(e.msgtype!==Ue.KEEPALIVE&&V.info(`[${ct.logName}] recv msg: ${e.msgtype}`),e.msgtype){case Ue.JOINCHANNEL:this.onJoinResult(e);break;case Ue.KEEPALIVE:this.onKeepAliveRsp();break;case Ue.PUBLISH:this.onPublishResult(e);break;case Ue.NOTIFYJOIN:this.onNotifyJoin(e);break;case Ue.NOTIFYSTATUS:this.onNotifyStatus(e);break;case Ue.LEAVECHANNEL:this.onLeaveResult(e);break;case Ue.NOTIFYLEAVE:this.onNotifyLeave(e);break;case Ue.NOTIFYPUBLISH:this.onNotifyPublish(e);break;case Ue.STATUSREPORT:this.onStatusReport(e);break;case Ue.BYE:this.onBye(e);break;case Ue.ROLEUPDATE:this.onRoleUpdateResult(e);break;case Ue.REFRESHURL:this.onRefreshUrlResult(e);break;case Ue.RECONNECT:this.onReconnectResult(e);break;default:this.onUnknownMessage(e)}}onJoinResult(e){this.isFirstConnect=!1,this.emit("onJoinChannelResult",e)}onLeaveResult(e){this.emit("onLeaveResult",e.code,e.tid)}onPublishResult(e){this.emit("onPublishResult",e.code,e.tid,e.description)}onRoleUpdateResult(e){this.emit("onRoleUpdateResult",e.code,e.tid,e.description)}onRefreshUrlResult(e){this.emit("onRefreshUrlResult",e)}onReconnectResult(e){if(e.code===200)this.sendPkgCache(),this.startKeepAlive(),this.emit("onReconnectSuccess",e.data.users);else{const t=new O(H.ERR_INNER,`reconnect failed, code: ${e.code};description: ${e.description}`);e.code===403&&(t.code=403),this.emit("onReconnectFail",t),this.close()}}onNotifyJoin(e){let t=this.packageCreater.createResponsePackage(e.tid,e.msgtype);this.wsClient.send(t),e&&e.data&&e.data.users&&this.emit("onNotifyJoin",e.data.users)}onNotifyStatus(e){let t=this.packageCreater.createResponsePackage(e.tid,e.msgtype);this.wsClient.send(t),e.data&&e.data.status&&e.data.status.length&&this.emit("onNotifyStatus",e.data.status)}onNotifyLeave(e){let t=this.packageCreater.createResponsePackage(e.tid,e.msgtype);this.wsClient.send(t),e.data&&e.data.users&&e.data.users.length&&this.emit("onNotifyLeave",e.data.users)}onNotifyPublish(e){let t=this.packageCreater.createResponsePackage(e.tid,e.msgtype);this.wsClient.send(t),e.data&&e.data.users&&e.data.users.length&&this.emit("onNotifyPublish",e.data.users)}onStatusReport(e){this.emit("onStatusReport",e.code,e.tid,e.description)}onBye(e){this.stopKeepAlive(),this.emit("onBye",e.reason,e.description)}onUnknownMessage(e){this.emit("onUnknownMessage",e)}};f(ct,"logName","RSMessageCenter");let Cr=ct;const C=(s,a)=>(e,t,i)=>{const r=i.value;return i.value=function(...n){var l;const c=`[${((l=e.constructor)==null?void 0:l.logName)||""}]`,o=Date.now();let d=[];if(s)try{d=s(n)}catch(p){}V.interface(c,t,...d);const h=r.apply(this,n);return Promise.resolve(h).then(p=>p).catch(p=>p).then(p=>{var b;let u="";const g=p instanceof Error,m=g&&((b=e.constructor)==null?void 0:b.logError);if(a||g){if(m)u=p;else if(g)u=p.message||"";else{if(!a)return;if(p===void 0)u="";else try{u=a(p)}catch(S){}}V.interfaceResult(c,t,!(g&&m),Date.now()-o+"ms",u)}}),h},i},U=s=>s;var Fo=Object.defineProperty,jo=Object.getOwnPropertyDescriptor,kr=(s,a,e,t)=>{for(var i,r=t>1?void 0:t?jo(a,e):a,n=s.length-1;n>=0;n--)(i=s[n])&&(r=(t?i(a,e,r):i(r))||r);return t&&r&&Fo(a,e,r),r};const Vi=(Ye=class extends se{constructor(e,t,i,r=It.prod){super();f(this,"messageCenter");f(this,"authInfo");f(this,"userName");f(this,"channelProfile");f(this,"clientRole");f(this,"slsReporter");f(this,"reconnectData");f(this,"roomServerUri","");this.channelProfile=e,this.clientRole=t,this.slsReporter=i,this.reconnectData={role:{channelprofile:e,clientrole:t}};const n=r===It.pre?Ii.pre:Ii.prod;this.roomServerUri=`wss://${n}/roomserver/v1/ws`}updateReconnectData(e){var t;this.reconnectData=e,(t=this.messageCenter)==null||t.updateReconnectData(this.reconnectData)}reset(){V.info("[roomsig] reset"),this.messageCenter&&(this.messageCenter.close(),this.messageCenter=void 0),this.authInfo=void 0}join(e,t,i,r){return T(this,null,function*(){return new Promise((n,c)=>{const o={};this.authInfo=e,this.userName=t,this.messageCenter=new Cr(e,t,this.channelProfile,this.clientRole,this.slsReporter,i),this.initMessageCenter(),this.messageCenter.once("onJoinChannelResult",h=>{var l,p,u;if(V.info(`[${Ye.logName}]`,"join result: ",h),o.taskretrynum=((l=this.messageCenter)==null?void 0:l.retryCount)||0,h.code==200){(p=this.messageCenter)==null||p.sendPkgCache(),(u=this.messageCenter)==null||u.startKeepAlive();let g=h.data;g.tid=h.tid,g.users=h.data.users,g.timestamp=h.timestamp,o.est&&(o.joinconnecttc=Date.now()-o.est),this.slsReporter.reportJoinConnection(o),n(g)}else this.reset(),c(this.handleSignalError(h.code,h.reason,H.ERR_JOIN_CHANNEL_FAILED))}),this.messageCenter.once("onAuthInvalid",()=>{this.reset(),c(new O(H.ERR_JOIN_BAD_TOKEN,"join failed because authentication failed"))}),V.info(`[${Ye.logName}]`,"start ws connecting roomserver and auto join when connected");const d={appid:this.authInfo.appId,callid:this.authInfo.sessionId,channelid:this.authInfo.channelId,userid:this.authInfo.userId,nonce:this.authInfo.nonce||"",timestamp:this.authInfo.timestamp,token:this.authInfo.token,authtype:"app",tid:dt()};e.role&&(d.tokenrole=e.role),o.est=Date.now(),this.messageCenter.start(this.roomServerUri+"?"+et.queryingParam(d),r)})})}leave(){return V.info("[roomsig] leave .."),new Promise((e,t)=>{this.messageCenter?(this.messageCenter.on("onLeaveResult",(i,r)=>{V.info(`[${Ye.logName}]`,"recv leave response "+i),i===200?(this.updateReconnectData(),this.reset(),e({tid:r})):t(this.handleSignalError(i,"leave error"))}),V.info(`[${Ye.logName}]`,"send leave request"),this.messageCenter.leave()):(V.info(`[${Ye.logName}]`,"no message center, ok to leave"),e({tid:""}))})}publish(e){return new Promise((t,i)=>{var r;this.messageCenter?(this.messageCenter.once("onPublishResult",(n,c,o)=>{V.info(`[${Ye.logName}]`,"recv pubish response "+n),n===200?(this.updateReconnectData(kt(X({},this.reconnectData),{publish:{users:[e]}})),t({tid:c})):i(this.handleSignalError(n,`publish error, ${o}`))}),this.authInfo&&(e.sessionid=(r=this.authInfo.sessionId)!=null?r:""),e.callid||(e.callid=dt()),V.info(`[${Ye.logName}]`,"assign callid "+e.callid+" and send publish request"),this.messageCenter.publish(e)):i(this.handleSignalError(-1,"publish error, no message center"))})}roleUpdate(e){return new Promise((t,i)=>{this.messageCenter?(this.messageCenter.on("onRoleUpdateResult",(r,n,c)=>{var o,d;V.info(`[${Ye.logName}]`,"recv role update response "+r),r===200?((d=(o=this.reconnectData)==null?void 0:o.role)!=null&&d.clientrole&&(this.reconnectData.role.clientrole=e,this.updateReconnectData(this.reconnectData)),t({tid:n})):i(this.handleSignalError(r,`role update error, ${c}`))}),this.messageCenter.roleUpdate(e)):i(this.handleSignalError(-1,"role update error, no message center"))})}setChannelProfile(e){this.channelProfile=e}refreshUrl(e){return V.info(`[${Ye.logName}]`,"refreshUrl .."),new Promise((t,i)=>{this.messageCenter?(this.messageCenter.on("onRefreshUrlResult",r=>{const{code:n,description:c,data:o={}}=r||{};V.info("recv refresh url response "+n),n===200?t(o):i(this.handleSignalError(n,`refresh url error, ${c}`))}),V.info("send refresh url request"),this.messageCenter.refreshUrl(e)):i(this.handleSignalError(-1,"refresh url error, no message center"))})}reportStatus(e){return V.info(`[${Ye.logName}]`,"reportStatus "+e),new Promise((t,i)=>{this.messageCenter?(this.messageCenter.once("onStatusReport",(r,n)=>{r===200?t():i(new O(r,n))}),this.messageCenter.reportStatus(e)):i(new O(-1,"No messageCenter"))})}handleSignalError(e,t,i=H.ERR_INNER){return new O(i,`signal error: code - ${e}; description - ${t}`)}refreshAuthInfo(e){return T(this,null,function*(){var t;this.authInfo&&(this.authInfo=e,(t=this.messageCenter)==null||t.refreshAuthInfo(this.authInfo))})}initMessageCenter(){var e,t,i,r,n,c,o,d,h,l,p,u,g;(e=this.messageCenter)==null||e.on("onKeepAliveRsp",()=>{this.emit("onKeepAliveRsp")}),(t=this.messageCenter)==null||t.on("onNotifyJoin",m=>{this.emit("onNotifyJoin",m)}),(i=this.messageCenter)==null||i.on("onNotifyStatus",m=>{this.emit("onNotifyStatus",m)}),(r=this.messageCenter)==null||r.on("onNotifyLeave",m=>{this.emit("onNotifyLeave",m)}),(n=this.messageCenter)==null||n.on("onNotifyPublish",m=>{this.emit("onNotifyPublish",m)}),(c=this.messageCenter)==null||c.on("onBye",(m,b)=>{this.emit("onBye",m,b)}),(o=this.messageCenter)==null||o.on("onReconnectStart",()=>{this.emit("onReconnectStart")}),(d=this.messageCenter)==null||d.on("onReconnectSuccess",m=>{this.emit("onReconnectSuccess",m)}),(h=this.messageCenter)==null||h.on("onReconnectFail",m=>{this.emit("onReconnectFail",m)}),(l=this.messageCenter)==null||l.on("onConnectFail",m=>{this.emit("onConnectFail",m),this.reset()}),(p=this.messageCenter)==null||p.on("onNetworkError",m=>{this.emit("onNetworkError",m)}),(u=this.messageCenter)==null||u.on("onAuthInvalid",()=>{this.emit("onAuthInvalid")}),(g=this.messageCenter)==null||g.on("onUnknownMessage",m=>{this.emit("onUnknownMessage",m)})}},f(Ye,"logName","RoomServerSignaling"),Ye);kr([C()],Vi.prototype,"join",1),kr([C()],Vi.prototype,"publish",1),kr([C()],Vi.prototype,"roleUpdate",1);let zo=Vi;const Wo=6e5,Ri=class Ri extends se{constructor(e,t){super();f(this,"env");f(this,"authInfo");f(this,"timer");f(this,"slsReporter");f(this,"expiration",0);f(this,"skipTime",0);f(this,"requestToken",()=>T(this,null,function*(){if(this.skipTime=0,!this.authInfo)return;const{appId:e,channelId:t,userId:i,nonce:r="",token:n,timestamp:c,sessionId:o,role:d}=this.authInfo;let h="https://gw.rtn.aliyuncs.com";this.env===It.pre&&(h="https://pgw.rtn.aliyuncs.com");const l=`${h}/gslb/v1/stsupdate?appid=${e}&channelid=${t}&userid=${i}&nonce=${r}&token=${n}&timestamp=${c}&session=${o}${d?`&tokenrole=${d}`:""}&slstoken=true&osstoken=true&tokensid=false`,p=Date.now();fetch(l).then(u=>u.json()).then(u=>{var g,m;if(u.code!==0)throw new Error;{const b=(g=u.data)==null?void 0:g.oss,S=(m=u.data)==null?void 0:m.sls;this.expiration=b.expiration||S.expiration,this.emit("onTokenUpdate",b,S),V.event(`[${Ri.logName}]`,"getToken",b,S)}this.slsReporter.reportSTSResult(200,p)}).catch(u=>{this.slsReporter.reportSTSResult(-1,p),V.error(`[${Ri.logName}]`,"getToken",u.message)})}));this.slsReporter=e,this.env=t}refreshAuthInfo(e){this.authInfo=e}startSTSUpdate(e){this.authInfo=e,this.requestToken(),this.timer&&clearInterval(this.timer),this.timer=window.setInterval(()=>{this.expiration&&Math.floor((Date.now()+9e5)/1e3)<this.expiration&&this.skipTime<12?this.skipTime+=1:this.requestToken()},Wo)}clear(){this.timer&&clearInterval(this.timer)}};f(Ri,"logName","StsManager");let Pr=Ri;var Ko=Object.defineProperty,$o=Object.getOwnPropertyDescriptor;class Dr extends se{constructor(e,t,i,r=It.prod){super();f(this,"signaling");f(this,"authInfo");f(this,"userName");f(this,"channelProfile");f(this,"clientRole");f(this,"env",It.prod);f(this,"maxConnectRetryCount");f(this,"stsManager");f(this,"slsReporter");this.channelProfile=e,this.clientRole=t,this.env=r,this.slsReporter=i,this.stsManager=new Pr(i,r)}reset(){var e;V.info("[signalingmanager] reset"),(e=this.signaling)==null||e.reset(),this.stsManager.clear(),this.signaling=void 0,this.authInfo=void 0}join(e,t=e.userId,i,r,n){return this.maxConnectRetryCount=i,this.userName=t,new Promise((c,o)=>{this.signaling?o(new O(H.ERR_JOIN_ALREADY_JOINED,"already joined")):(V.info("[signalingmanager] create signaling"),this.signaling=new zo(this.channelProfile,this.clientRole,this.slsReporter,this.env),this.initSignaling(),r&&(r.rs=Date.now()),this.signaling.join(e,t,i,n).then(d=>{this.authInfo=e,r&&(r.re=Date.now()),c(d)}).catch(d=>{this.reset(),o(d)}),this.stsManager.startSTSUpdate(e))})}retryJoin(){const e=this.authInfo;this.reset(),e&&this.join(e,this.userName,this.maxConnectRetryCount)}leave(){return new Promise((e,t)=>{this.signaling?this.signaling.leave().then(i=>{this.reset(),e(i)}).catch(i=>{t(i)}):e({tid:""})})}publish(e){return new Promise((t,i)=>{var r;this.signaling&&this.authInfo?(e.userid=this.authInfo.userId,e.displayname=(r=this.userName)!=null?r:this.authInfo.userId,this.signaling.publish(e).then(n=>{t(n)}).catch(n=>{i(n)})):i(new O(H.ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL,"no signaling"))})}reportStatus(e){return new Promise((t,i)=>{this.signaling?this.signaling.reportStatus(e).then(()=>{t()}).catch(r=>{i(r)}):i(new O(-1,"no signaling"))})}setClientRole(e){return T(this,null,function*(){const t=this.clientRole;if(!this.signaling)return void(this.clientRole=e);const i=Date.now();try{const r=yield this.signaling.roleUpdate(e);return this.slsReporter.reportRoleUpdateResult(t,e,Date.now()-i,0),r}catch(r){this.slsReporter.reportRoleUpdateResult(t,e,Date.now()-i,r.code||-1)}})}setChannelProfile(e){this.signaling?this.signaling.setChannelProfile(e):this.channelProfile=e}refreshUrl(e){return this.signaling?this.signaling.refreshUrl(e):Promise.reject(new O(H.ERR_SDK_INVALID_STATE,"should join first"))}refreshAuthInfo(e){return T(this,null,function*(){var t;try{this.authInfo&&(this.authInfo=X(X({},this.authInfo),e),(t=this.signaling)==null||t.refreshAuthInfo(this.authInfo),this.stsManager.refreshAuthInfo(this.authInfo))}catch(i){throw i}})}initSignaling(){var e,t,i,r,n,c,o,d,h,l,p,u,g,m;(e=this.signaling)==null||e.on("onKeepAliveRsp",this.onKeepAliveRsp.bind(this)),(t=this.signaling)==null||t.on("onNotifyJoin",this.onNotifyJoin.bind(this)),(i=this.signaling)==null||i.on("onNotifyStatus",this.onNotifyStatus.bind(this)),(r=this.signaling)==null||r.on("onNotifyLeave",this.onNotifyLeave.bind(this)),(n=this.signaling)==null||n.on("onNotifyPublish",this.onNotifyPublish.bind(this)),(c=this.signaling)==null||c.on("onBye",this.onBye.bind(this)),(o=this.signaling)==null||o.on("onReconnectStart",this.onReconnectStart.bind(this)),(d=this.signaling)==null||d.on("onReconnectSuccess",this.onReconnectSuccess.bind(this)),(h=this.signaling)==null||h.on("onReconnectFail",this.onReconnectFail.bind(this)),(l=this.signaling)==null||l.on("onConnectFail",this.onConnectFail.bind(this)),(p=this.signaling)==null||p.on("onNetworkError",this.onNetworkError.bind(this)),(u=this.signaling)==null||u.on("onAuthInvalid",this.onAuthInvalid.bind(this)),(g=this.signaling)==null||g.on("onError",this.onError.bind(this)),(m=this.signaling)==null||m.on("onUnknownMessage",this.onUnknownMessage.bind(this))}onKeepAliveRsp(){this.emit("onKeepAliveRsp")}onNotifyJoin(e){this.emit("onNotifyJoin",e)}onNotifyStatus(e){this.emit("onNotifyStatus",e)}onNotifyLeave(e){this.emit("onNotifyLeave",e)}onNotifyPublish(e){this.emit("onNotifyPublish",e)}onBye(e,t){this.emit("onBye",e,t)}onConnectFail(e){this.reset(),this.emit("onConnectFail",e)}onNetworkError(e){this.emit("onNetworkError",e)}onAuthInvalid(){}onReconnectStart(){this.emit("onReconnectStart")}onReconnectSuccess(e){this.emit("onReconnectSuccess",e)}onReconnectFail(e){this.emit("onReconnectFail",e)}onError(e){this.emit("onError",e)}onUnknownMessage(e){this.emit("onUnknownMessage",e)}}f(Dr,"logName","SignalingManager");function si(){}((s,a,e,t)=>{for(var i,r=t>1?void 0:t?$o(a,e):a,n=s.length-1;n>=0;n--)(i=s[n])&&(r=(t?i(a,e,r):i(r))||r);t&&r&&Ko(a,e,r)})([C(U)],Dr.prototype,"publish",1);const Xt=class Xt{static getInstance(){var a;return Xt.instance||(Xt.instance=new AudioContext),(a=Xt.instance.resume())==null||a.then(si,si).catch(si),Xt.instance}};f(Xt,"instance");let $t=Xt;const Oi=()=>{var a;const s=$t.getInstance();s.state!=="running"&&s.state!=="closed"&&((a=s.resume())==null||a.then(si,si).catch(si)),window.removeEventListener("mousedown",Oi),window.removeEventListener("touchstart",Oi)};window.addEventListener("mousedown",Oi),window.addEventListener("touchstart",Oi);class Jo extends se{constructor(){super();f(this,"audioContext");f(this,"stream");f(this,"sourceNode");f(this,"analyser");this.audioContext=$t.getInstance(),this.stream=new MediaStream}getLevel(){return this.analyser?this.analyser.getLevel():0}start(e,t=1e3){this.sourceNode&&this.stop(),this.stream.addTrack(e),this.sourceNode=this.audioContext.createMediaStreamSource(this.stream);const i=this.audioContext.createMediaStreamDestination();this.analyser=function(r,n,c,o,d){let h,l=o,p=0;const u=r.createAnalyser();u.fftSize=256;const g=new Uint8Array(u.frequencyBinCount);n.connect(u),u.connect(c);const m=()=>{h&&window.clearInterval(h)},b=()=>{r.state==="suspended"&&r.resume(),h=window.setInterval(()=>{u.getByteFrequencyData(g);let S=Math.round(g.reduce((v,_)=>v+_)/g.length);S=Math.min(100,S),p=S,d&&d(S)},l)};return b(),{updateInterval:S=>{m(),l=S,b()},getLevel:()=>p,dispose:()=>{m(),n.disconnect(),u.disconnect()}}}(this.audioContext,this.sourceNode,i,t,r=>{this.emit("audioLevel",r)})}stop(){this.analyser&&this.analyser.dispose(),this.analyser=void 0,this.sourceNode=void 0,this.stream.getAudioTracks().forEach(e=>{this.stream.removeTrack(e)})}dispose(){this.stop()}}class Ha extends se{constructor(e,t,i,r){super();f(this,"uid");f(this,"name");f(this,"rtsManager");f(this,"callId","");f(this,"audioLevelMonitor");f(this,"audioVolumeIndicationInterval",0);this.uid=e,this.name=t,this.rtsManager=i,this.audioVolumeIndicationInterval=r,this.audioLevelMonitor=new Jo}get userId(){return this.uid}get displayname(){return this.name}createCallId(){this.callId||(this.callId=et.createCallid())}setUserInfo(e,t){this.uid=e,this.name=t}refreshUserInfo(e){this.uid=e}getAudioLevel(){return this.audioLevelMonitor.getLevel()}enableAudioVolumeIndication(e){this.audioVolumeIndicationInterval=e}clear(){this.audioLevelMonitor.dispose()}}class Fa{static getCurrentStatus(a){let e=0;a.micOpen&&(e+=1),a.micInterrupted&&(e+=2),a.cameraOpen&&(e+=4),a.screenShare&&(e+=128),a.audioDisable&&(e+=8),a.videoDisable&&(e+=16),a.screenDisable&&(e+=256);let t=e.toString(16);for(;t.length<16;)t="0"+t;return t}static parseStatus(a){let e=parseInt(a,16);return{micOpen:!!(1&e),micInterrupted:!!(2&e),cameraOpen:!!(4&e),screenShare:!!(128&e),audioDisable:!!(8&e),videoDisable:!!(16&e),screenDisable:!!(256&e),backgroundMode:!!(32&e),accompanyPlaying:!!(64&e)}}}const ja="customVideoProfile",za="customScreenProfile",Mr={width:1280,height:720,frameRate:30,maxBitrate:2e3},Wa={width:1920,height:1080,frameRate:30,maxBitrate:2600};var gi=(s=>(s[s.ERROR_DEVICE_UNKNOWNERROR=1e4]="ERROR_DEVICE_UNKNOWNERROR",s[s.ERROR_DEVICE_AUDIODEVICE_NOTFOUND=10001]="ERROR_DEVICE_AUDIODEVICE_NOTFOUND",s[s.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED=10002]="ERROR_DEVICE_AUDIODEVICE_NOTALLOWED",s[s.ERROR_DEVICE_AUDIODEVICE_NOTREADABLE=10003]="ERROR_DEVICE_AUDIODEVICE_NOTREADABLE",s[s.ERROR_DEVICE_VIDEODEVICE_NOTFOUND=10004]="ERROR_DEVICE_VIDEODEVICE_NOTFOUND",s[s.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED=10005]="ERROR_DEVICE_VIDEODEVICE_NOTALLOWED",s[s.ERROR_DEVICE_VIDEODEVICE_NOTREADABLE=10006]="ERROR_DEVICE_VIDEODEVICE_NOTREADABLE",s[s.ERROR_SCREENSHARE_NOTSUPPORT=10010]="ERROR_SCREENSHARE_NOTSUPPORT",s[s.ERROR_SCREENSHARE_NOTALLOWED=10011]="ERROR_SCREENSHARE_NOTALLOWED",s[s.ERROR_SCREENSHARE_ENDED=10012]="ERROR_SCREENSHARE_ENDED",s[s.ERROR_SCREENSHARE_NOPERMISSION=10013]="ERROR_SCREENSHARE_NOPERMISSION",s[s.ERROR_SCREENSHARE_SAFARI_INVALIDACCESS=10014]="ERROR_SCREENSHARE_SAFARI_INVALIDACCESS",s[s.ERROR_SCREENSHARE_UNKNOWNERRO=10019]="ERROR_SCREENSHARE_UNKNOWNERRO",s[s.ERROR_DEVICE_NOTSUPPORT=2e4]="ERROR_DEVICE_NOTSUPPORT",s))(gi||{});const Go={1e4:Oe.AliEngineLocalDeviceExceptionTypeUnknown,2e4:Oe.AliEngineLocalDeviceExceptionTypeUnknown,10001:Oe.AliEngineLocalDeviceExceptionTypeMicNotAvailable,10002:Oe.AliEngineLocalDeviceExceptionTypeMicAuthFail,10003:Oe.AliEngineLocalDeviceExceptionTypeMicOpenFail,10005:Oe.AliEngineLocalDeviceExceptionTypeCameraAuthFail,10004:Oe.AliEngineLocalDeviceExceptionTypeVideoDeviceException,10006:Oe.AliEngineLocalDeviceExceptionTypeCameraOpenFail,10010:Oe.AliEngineLocalDeviceExceptionTypeDisplayException,10011:Oe.AliEngineLocalDeviceExceptionTypeDisplayException,10012:Oe.AliEngineLocalDeviceExceptionTypeDisplayException,10013:Oe.AliEngineLocalDeviceExceptionTypeDisplayException,10014:Oe.AliEngineLocalDeviceExceptionTypeDisplayException,10019:Oe.AliEngineLocalDeviceExceptionTypeDisplayException};var ot=(s=>(s.CREATE_ENGINE="create_engine",s.JOIN="join",s.WANT_INSERT_PUB_TASK="wantInsertPubTask",s.INSERT_PUB_TASK="InsertPubTask",s.HANDLE_PUB_TASK="HandlePubTask",s.RECV_NOTIFY_PUBLISH="RecvNotifyPublish",s.INSERT_SUB_TASK="InsertSubTask",s.HANDLE_SUB_TASK="HandleSubTask",s.FIRST_REMOTE="first_remote",s))(ot||{}),lt=(s=>(s.START="start",s.SEND_SIG="send_sig",s.RECV_RST="recv_rst",s.END="end",s.RECEIVED="received",s.DECODED="decoded",s.PLAYED="played",s))(lt||{});function Ka(s){var a;if(((a=s==null?void 0:s.nodeName)==null?void 0:a.toLowerCase())==="video")return s.setAttribute("playsinline",""),s;if(typeof s=="string"){let e=document.getElementById(s);if(e){if(e.nodeName.toLocaleLowerCase()==="video")return e.setAttribute("playsinline",""),e;throw new O(H.ERR_INVALID_ARGUMENTS,"element should be HtmlVideoElement")}throw new O(H.ERR_INVALID_ARGUMENTS,"element not founded")}throw new O(H.ERR_INVALID_ARGUMENTS,"element id should be string")}function Nr(s){var e;const a=[];if(Array.isArray(s))s.forEach(t=>{try{a.push(Ka(t))}catch(i){}});else if(typeof s=="string"||((e=s==null?void 0:s.nodeName)==null?void 0:e.toLowerCase())==="video")try{a.push(Ka(s))}catch(t){}return a}function Lt(s){return new Promise(a=>setTimeout(a,s))}function $a(s,a,e=1e3,t=i=>!0){return T(this,null,function*(){let i=0;for(;i<a;)try{return yield s(i)}catch(r){if(i++,i>=a||!t(r))throw r||void 0;yield new Promise(n=>setTimeout(n,e))}})}function Ja(s,a){let e=a;return typeof window.__ali_prefer_media_server=="string"&&window.__ali_prefer_media_server!==""&&(e=window.__ali_prefer_media_server),e?`${s}&ali_prefer_media_server=${e}`:s}function fi(s,a){var e;try{const{archCfgs:t}=s;if(!t||!Array.isArray(t))return;const i=t.find(r=>r.arch==="grtn");return i?(e=i.user_specified)==null?void 0:e[a]:void 0}catch(t){return}}function Si(s,a){try{const{config:e}=s;return e?e==null?void 0:e[a]:void 0}catch(e){return}}const Ga=(s,a,e=!1)=>{const t=()=>(s.muted=!0,Promise.race([Lt(500),s._playPromise||Promise.resolve()]).catch(()=>{}).then(()=>{let i;return e&&s.srcObject===a?i=Promise.resolve():(s.load(),s.srcObject=a,i=s.play(),s._playPromise=i),i}));return new Promise(i=>{if(q.AliRTS.BrowserUtil.isMicroMessenger){const r=window.top!==window.self,n=window.WeixinJSBridge||window.top.WeixinJSBridge;n?n.invoke("getNetworkType",{},()=>{i(t())}):(r?window.top.document:document).addEventListener("WeixinJSBridgeReady",()=>{n.invoke("getNetworkType",{},()=>{i(t())})}),setTimeout(()=>{i(t())},1e3)}else setTimeout(()=>{i(t())},0)})},Rt=s=>{Promise.race([Lt(100),s._playPromise||Promise.resolve()]).catch(()=>{}).then(()=>{s.srcObject=null,s._playPromise=void 0})};var Lr=(s=>(s[s.AliEngineDataMsgNone=0]="AliEngineDataMsgNone",s[s.AliEngineDataMsgMusicProgress=1]="AliEngineDataMsgMusicProgress",s[s.AliEngineDataMsgCustom=2]="AliEngineDataMsgCustom",s))(Lr||{});class Ui{constructor(a,e,t,i=0){f(this,"msgType");f(this,"msgId");f(this,"protocolVersion");f(this,"tlvVersion");this.msgType=a,this.msgId=e,this.protocolVersion=t,this.tlvVersion=i}build(){const a=new Uint8Array(4);return a.set(Uint8Array.from([this.protocolVersion,this.tlvVersion<<4|15&this.msgType]),0),a.set(Uint16Array.from([this.msgId]),2),a}static parse(a){const e=new DataView(a),t=e.getUint8(0),i=e.getUint8(1)>>4,r=15&e.getUint8(1),n=e.getUint16(2);return new Ui(r,n,t,i)}}class Bi{constructor(a,e,t){f(this,"_byteArray");if(this._byteArray=new Uint8Array(0),a!==void 0&&e!==void 0&&t!==void 0){const i=new Ui(a,e,t).build();this._byteArray=new Uint8Array(i.byteLength+this._byteArray.byteLength),this._byteArray.set(i,0)}}write(a,e){const t=this._byteArray,i=new ArrayBuffer(5),r=new DataView(i);r.setUint8(0,a),r.setUint32(1,e.byteLength);const n=new Uint8Array(t.byteLength+5+e.byteLength);n.set(t,0),n.set(new Uint8Array(i),t.byteLength),n.set(new Uint8Array(e),t.byteLength+5),this._byteArray=n}static parse(a){const e={},t=new DataView(a);let i=0;for(;i<a.byteLength;){const r=t.getUint8(i),n=t.getUint32(i+1);if(!(i+5+n<=a.byteLength))break;{const c=a.slice(i+5,i+5+n);e[r]=c,i+=5+n}}return e}get buffer(){return this._byteArray.buffer}}class bi{constructor(a=0,e=!0,t=1,i=!1,r=0,n=!1,c=!1,o=3){f(this,"_fin",!0);f(this,"_hasExtension",!1);f(this,"_version",0);f(this,"_frameType",1);f(this,"_isEncrypted",!1);f(this,"_isCompressed",!1);f(this,"_signalType",3);f(this,"_payloadLength",0);this._fin=e,this._hasExtension=i,this._version=r,this._frameType=t,this._isEncrypted=n,this._isCompressed=c,this._signalType=o,this._payloadLength=a}get fin(){return this._fin}get hasExtension(){return this._hasExtension}get version(){return this._version}get frameType(){return this._frameType}get isEncrypted(){return this._isEncrypted}get isCompressed(){return this._isCompressed}get signalType(){return this._signalType}get payloadLength(){return this._payloadLength}toBuffer(){const a=new ArrayBuffer(4),e=new DataView(a);return e.setUint8(0,(this._fin?1:0)<<7|(this._hasExtension?1:0)<<6|this._version<<4|15&this._frameType),e.setUint8(1,(this._isEncrypted?1:0)<<7|(this._isCompressed?1:0)<<6|15&this._signalType),e.setUint16(2,this._payloadLength),a}static parse(a){const e=new DataView(a),t=e.getUint8(0)>>7==1,i=(64&e.getUint8(0))>>6==1,r=(48&e.getUint8(0))>>4,n=15&e.getUint8(0),c=e.getUint8(1)>>7==1,o=(64&e.getUint8(1))>>6==1,d=15&e.getUint8(1),h=e.getUint16(2);return new bi(h,t,n,i,r,c,o,d)}}class Hi{constructor(a,e){f(this,"_body");f(this,"_header",new bi);this._header=a,this._body=e}get header(){return this._header}get isFin(){return this._header.fin}get body(){return this._body}toGRTNBuffer(){const a=this._header.toBuffer(),e=this._body,t=new ArrayBuffer(4);new DataView(t).setUint8(0,1*Math.pow(2,4));const i=new Uint8Array(t.byteLength+a.byteLength+e.byteLength);return i.set(new Uint8Array(t),0),i.set(new Uint8Array(a),t.byteLength),i.set(new Uint8Array(e),t.byteLength+a.byteLength),i.buffer}static parse(a){const e=a.slice(0,4),t=bi.parse(e);let i=new ArrayBuffer(0);return a.byteLength-4>=t.payloadLength&&(i=a.slice(4,4+t.payloadLength)),new Hi(t,i)}}const xr=s=>{const a=s.byteLength,e=new DataView(s);let t=0;for(let i=0;i<a;i++)t=256*t+e.getUint8(i);return t};let qa=0;class xt{constructor(a,e=0,t=0,i=0){f(this,"data");f(this,"networkTime");f(this,"futureOrProgress");f(this,"type");this.data=a,this.type=e,this.networkTime=t,this.futureOrProgress=i}toBuffer(){const a=new Bi(0,0,0);a.write(1,Uint8Array.from([0]).buffer),a.write(2,Uint16Array.from([0]).buffer),qa++,a.write(3,Uint32Array.from([qa]).buffer);const e=new Bi;return e.write(1,Uint8Array.from([0]).buffer),e.write(2,Uint8Array.from([this.type]).buffer),e.write(3,Uint32Array.from([this.futureOrProgress]).buffer),e.write(4,Uint32Array.from([Number(this.networkTime>>32&4294967295),Number(4294967295&this.networkTime)]).buffer),e.write(5,this.data),a.write(30,e.buffer),a.buffer}static parse(a){if(!a||a.byteLength<4)return;Ui.parse(a.slice(0,4));const e=Bi.parse(a.slice(4))[30];if(!e)return;const t=Bi.parse(e),i=t[2],r=t[3],n=t[4],c=t[5];return c.byteLength!==0?new xt(c,xr(i),xr(n),xr(r)):void 0}}var qo=Object.defineProperty,Xo=Object.getOwnPropertyDescriptor,Ce=(s,a,e,t)=>{for(var i,r=t>1?void 0:t?Xo(a,e):a,n=s.length-1;n>=0;n--)(i=s[n])&&(r=(t?i(a,e,r):i(r))||r);return t&&r&&qo(a,e,r),r};class vi extends se{constructor(){super();f(this,"_state");f(this,"time");this._state=ie.AliRtcStatePublishIdle,this.time=Date.now()}get state(){return this._state}setState(e){const t=this._state,i=this.time;this._state=e,this.time=Date.now(),this.emit("change",t,e,Math.floor((this.time-i)/1e3))}}const Ie=(Ct=class extends Ha{constructor(e){const{rtsManager:t,localStreamManager:i,slsReporter:r,signalingManager:n,audioVolumeIndicationInterval:c,parameter:o}=e;super("","",t,c);f(this,"_url","");f(this,"joinTime",0);f(this,"publishPromise",Promise.resolve({traceId:"",l1ip:void 0}));f(this,"previewElements",[]);f(this,"screenPreviewElements",[]);f(this,"streamManager");f(this,"dc");f(this,"streamTracks");f(this,"publishId",dt());f(this,"signalingManager");f(this,"traceId","");f(this,"monitorTimerId");f(this,"monitorDataCache",{});f(this,"trackTraceIdMap",{});f(this,"candidateDataCache",[]);f(this,"pcMediaStatsMap",{});f(this,"slsReporter");f(this,"audioPubState");f(this,"videoPubState");f(this,"videoSmallPubState");f(this,"screenPubState");f(this,"dataPubState");f(this,"parameter",{});f(this,"onTrackEnd",e=>{this.emit(e)});this.streamManager=i,this.signalingManager=n,this.slsReporter=r,this.parameter=o,this.streamManager.on("trackended",d=>{this.onTrackEnd(d)}),this.streamManager.on("publishupdate",()=>{this.publishUpdate()}),this.audioPubState=new vi,this.audioPubState.on("change",(d,h,l)=>{this.emit("audioPublishStateChanged",d,h,l)}),this.videoPubState=new vi,this.videoPubState.on("change",(d,h,l)=>{this.emit("videoPublishStateChanged",d,h,l)}),this.videoSmallPubState=new vi,this.videoSmallPubState.on("change",(d,h,l)=>{this.emit("dualStreamPublishStateChanged",d,h,l)}),this.screenPubState=new vi,this.screenPubState.on("change",(d,h,l)=>{this.emit("screenPublishStateChanged",d,h,l)}),this.dataPubState=new vi,this.dataPubState.on("change",(d,h,l)=>{this.emit("dataPublishStateChanged",d,h,l)}),this.startStreamMonitor()}get url(){return this._url}set url(e){this._url=e,this.rtsManager.updateAuth(e)}get joined(){return!!this.uid}get isPublishing(){return this.rtsManager.publishingTracks.length>0}get publishStreams(){return this.streamManager.publishStreams}get cameraTrack(){return this.streamManager.cameraStreamInfo.originVideoTrack}get screenTrack(){return this.streamManager.screenStreamInfo.originVideoTrack}get audioTrack(){return this.streamManager.cameraStreamInfo.originAudioTrack}get hasCamera(){return!!this.streamManager.cameraStreamInfo.originVideoTrack}get hasMicrophone(){return!!this.streamManager.cameraStreamInfo.originAudioTrack}get hasScreenShare(){return!!this.streamManager.screenStreamInfo.originVideoTrack}get hasCameraTrackInMS(){var e;return!!((e=this.streamTracks)!=null&&e.find(({ssrc:t,type:i,msid:r})=>i==="video"&&t&&r===M.VideoLarge))}get hasCameraDualTrackInMS(){var e;return!!((e=this.streamTracks)!=null&&e.find(({ssrc:t,type:i,msid:r})=>i==="video"&&t&&r===M.VideoSmall))}get hasScreenTrackInMS(){var e;return!!((e=this.streamTracks)!=null&&e.find(({ssrc:t,type:i,msid:r})=>i==="video"&&t&&r===M.Screen))}get hasAudioTrackInMS(){var e;return!!((e=this.streamTracks)!=null&&e.find(({ssrc:t,type:i,msid:r})=>i==="audio"&&t&&r===M.Audio))}get cameraDirection(){var e,t;return(t=(e=this.streamManager.cameraStreamInfo)==null?void 0:e.cameraVideoConstraints)==null?void 0:t.facingMode}get audioCaptureDisabled(){return this.streamManager.audioCaptureDisabled}get cameraCaptureDisabled(){return this.streamManager.cameraCaptureDisabled}get publishLocalVideoStreamEnabled(){return this.streamManager.publishLocalVideoStreamEnabled}get publishLocalAudioStreamEnabled(){return this.streamManager.publishLocalAudioStreamEnabled}get publishLocalScreenStreamEnabled(){return this.streamManager.publishLocalScreenStreamEnabled}setPublishLocalAudioStreamEnabled(e){this.streamManager.publishLocalAudioStreamEnabled=e}setPublishLocalVideoStreamEnabled(e){this.streamManager.publishLocalVideoStreamEnabled=e}setPublishLocalScreenStreamEnabled(e){this.streamManager.publishLocalScreenStreamEnabled=e}initInfo(e,t){this.joinTime=Date.now(),this.rtsManager.localJoinTime=this.joinTime,this.setUserInfo(e.userId,e.userId),this.url=t,this.callId=e.sessionId||et.createCallid(),this.updatePubId()}setVideoProfile(e){return T(this,null,function*(){yield this.streamManager.setVideoProfile(ja,e)})}setVideoContentHint(e){this.streamManager.setVideoContentHint(e)}setScreenContentHint(e){this.streamManager.setScreenContentHint(e)}setAudioProfile(e){return T(this,null,function*(){yield this.streamManager.setAudioProfile(e)})}setScreenProfile(e){return T(this,null,function*(){yield this.streamManager.setScreenProfile(za,e)})}setCameraDirection(e){if(e===mi.CAMERA_FRONT)this.streamManager.setCameraVideoConstraints({facingMode:"user"});else{if(e!==mi.CAMERA_REAR)throw new O(H.ERR_CAMERA_OPEN_FAIL,`camera direction set to ${e} failed`);this.streamManager.setCameraVideoConstraints({facingMode:"environment"})}}setCameraDeviceId(e){this.streamManager.setCameraVideoConstraints({deviceId:e})}muteLocalCamera(e){this.streamManager.setCameraMuted(e),this.slsReporter.reportMute(this.callId,!e,"video")}muteLocalMic(e){this.streamManager.setAudioMuted(e),this.slsReporter.reportMute(this.callId,!e,"audio")}muteLocalScreen(e){this.streamManager.setScreenMuted(e),this.slsReporter.reportMute(this.callId,!e,"screen")}setMicrophoneDeviceId(e){this.streamManager.setMicAudioConstraints({deviceId:e})}setMicrophoneConstraints(e){this.streamManager.setMicAudioConstraints(e)}updatePubId(){this.publishId=dt()}clearPublishState(){this.streamTracks=void 0}leave(){return T(this,null,function*(){this.isPublishing&&(yield this.unPublish()),this.joinTime=0,this.dc=void 0})}clear(){return T(this,null,function*(){Gr(Ct.prototype,this,"clear").call(this),this.stopPreview(),this.resetPreviewElements(),this.resetSecondayPreviewElements(),this.clearStream(),yield this.leave(),this.streamManager.cameraCaptureDisabled=!1})}resetElement(e){this.previewElements.includes(e)&&(Rt(e),this.previewElements.splice(this.previewElements.indexOf(e),1)),this.screenPreviewElements.includes(e)&&(Rt(e),this.screenPreviewElements.splice(this.screenPreviewElements.indexOf(e),1))}setPreviewElement(e){const{videoElement:t,screen:i}=e;i?this.screenPreviewElements.includes(t)||(this.screenPreviewElements.push(t),this.preview(e)):this.previewElements.includes(t)||(this.previewElements.push(t),this.preview(e))}startDefaultCamera(e){return T(this,null,function*(){const{hasCamera:t,cameraCaptureDisabled:i,publishLocalVideoStreamEnabled:r}=this;if(!t&&!e&&!i&&r)try{yield this.startCameraCapture()}catch(n){const c=n.errorCode;let o=H.ERR_CAMERA_OPEN_FAIL;throw c===gi.ERROR_DEVICE_AUDIODEVICE_NOTFOUND?o=H.ERR_CAMERA_NOT_AVAILABLE:c===gi.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED&&(o=H.ERR_CAMERA_AUTH_FAIL),new O(o,`camera open fail: ${n.message}`)}})}startDefaultAudio(){return T(this,null,function*(){const{hasMicrophone:e,audioCaptureDisabled:t,publishLocalAudioStreamEnabled:i}=this;if(!e&&!t&&i)try{yield this.startAudioCapture()}catch(r){const n=r.errorCode;let c=H.ERR_MIC_OPEN_FAIL;throw n===gi.ERROR_DEVICE_AUDIODEVICE_NOTFOUND?c=H.ERR_MIC_NOT_AVAILABLE:n===gi.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED&&(c=H.ERR_MIC_AUTH_FAIL),new O(c,`mic open fail: ${r.message}`)}})}setViewConfig(e,t){if(e){if(![ne.AliRtcVideoTrackCamera,ne.AliRtcVideoTrackScreen].includes(t))throw new O(H.ERR_INVALID_ARGUMENTS,"set view config invalid track",{track:t});e.forEach(i=>{this.setPreviewElement({videoElement:i,screen:t===ne.AliRtcVideoTrackScreen})})}else t===ne.AliRtcVideoTrackCamera?this.stopPreview({primary:!0,screen:!1}):this.stopPreview({primary:!1,screen:!0})}startCameraCapture(){return T(this,null,function*(){return this.streamManager.cameraCaptureDisabled=!1,yield this.createLocalStream({video:!0})})}stopCameraCapture(){return T(this,null,function*(){this.streamManager.cameraCaptureDisabled=!0,yield this.stopLocalStream({video:!0})})}startAudioCapture(){return T(this,null,function*(){return this.streamManager.audioCaptureDisabled=!1,yield this.createLocalStream({audio:!0})})}stopAudioCapture(){return T(this,null,function*(){this.streamManager.audioCaptureDisabled=!0,yield this.stopLocalStream({audio:!0})})}preview(e){return T(this,null,function*(){const{videoElement:t,screen:i}=e!=null?e:{};try{let r=i?this.streamManager.screenStreamInfo.previewStream:this.streamManager.cameraStreamInfo.previewStream;if(!t)throw new O(H.ERR_INVALID_ARGUMENTS,"no video element found",{videoElement:t});return r?(Ga(t,r.mediaStream),this.setPreviewElement(e),r.mediaStream):void V.info(`[${Ct.logName}]`,"preview no stream founded")}catch(r){const n=H.ERR_INNER;throw O.fromError(r,n,"preview failed")}})}previewAll(e){return T(this,null,function*(){const{primary:t=!0,screen:i=!0}=e!=null?e:{};if(t&&this.previewElements.length)for(let r=0;r<this.previewElements.length;r++){const n=this.previewElements[r];yield this.preview({videoElement:n})}if(i&&this.screenPreviewElements.length)for(let r=0;r<this.screenPreviewElements.length;r++){const n=this.screenPreviewElements[r];yield this.preview({videoElement:n,screen:!0})}})}stopPreview(e){const{videoElement:t,primary:i=!0,screen:r=!0}=e||{};if(t){const n=this.previewElements.findIndex(c=>c===t);if(n>=0)this.previewElements.splice(n,1),Rt(t);else{const c=this.screenPreviewElements.findIndex(o=>o===t);c>=0&&(this.screenPreviewElements.splice(c,1),Rt(t))}}else i&&(this.previewElements.forEach(n=>{Rt(n)}),this.previewElements=[]),r&&(this.screenPreviewElements.forEach(n=>{Rt(n)}),this.screenPreviewElements=[])}resumePublish(){return T(this,null,function*(){yield this.startPublish(!0)})}createLocalStream(e){return T(this,null,function*(){try{if(e.video)for(let i=0;i<this.previewElements.length;i++){const r=this.previewElements[i];Rt(r)}else if(e.screen)for(let i=0;i<this.screenPreviewElements.length;i++){const r=this.screenPreviewElements[i];Rt(r)}const t=yield this.streamManager.createLocalStream(e);return t!=null&&t.audioTrack&&this.audioVolumeIndicationInterval>0&&this.audioLevelMonitor.start(t.audioTrack,this.audioVolumeIndicationInterval),e.video?this.previewAll({primary:!0}):e.screen&&this.previewAll({screen:!0}),t}catch(t){const i=Go[t.errorCode];throw i&&(e.audio?this.emit("localDeviceException",yt.AliEngineLocalDeviceTypeMic,i,""):e.video?this.emit("localDeviceException",yt.AliEngineLocalDeviceTypeCamera,i,""):e.screen?this.emit("localDeviceException",yt.AliEngineLocalDeviceTypeDisplay,i,""):this.emit("localDeviceException",yt.AliEngineLocalDeviceTypeUnknown,i,"")),t}})}stopLocalStream(e){return T(this,null,function*(){e.audio&&this.audioLevelMonitor.stop(),yield this.streamManager.stopLocalStream(e)})}compareAndPublish(e,t,i){return T(this,null,function*(){var n,c;if(!e&&!t)return;if(e&&!t){const o={};return i===M.Audio?o.audio=!0:i===M.VideoLarge||i===M.VideoSmall?(o.video=!0,o.vMsid=i):i===M.Screen&&(o.screen=!0),yield this.publishDeleteTracks(o)}const r={};if(t!=null&&t.hasVideo&&(r.isScreen=i===M.Screen,r.vMsid=i),t!=null&&t.hasAudio&&(r.aMsid=i),!e&&t)return yield this.publishAdd(t,r,!1);if(e&&t&&e.trackId!==(((n=t.videoTrack)==null?void 0:n.id)||((c=t.audioTrack)==null?void 0:c.id)))return yield this.publishReplace(t,r)})}reportAudioProfile(){const e=this.streamManager.cameraStreamInfo.audioProfile||"standard",t=q.AliRTS.AudioProfileMap.get(e);this.slsReporter.reportPublishProfile(M.Audio,{a_profile:e,bits:(t==null?void 0:t.maxBitrate)||0,samplerate:(t==null?void 0:t.sampleRate)||0,channel:(t==null?void 0:t.channelCount)||0})}reportVideoProfile(){const e=this.streamManager.cameraStreamInfo.videoProfile||"",t=q.AliRTS.VideoProfileMap.get(e);t&&this.slsReporter.reportPublishProfile(M.VideoLarge,{v_profile:e,wdth:(t==null?void 0:t.width)||0,hgt:(t==null?void 0:t.height)||0,fps:(t==null?void 0:t.frameRate)||0,bitrate:(t==null?void 0:t.maxBitrate)||0})}reportScreenProfile(){const e=this.streamManager.screenStreamInfo.videoProfile||"",t=q.AliRTS.VideoProfileMap.get(e);t&&this.slsReporter.reportPublishProfile(M.Screen,{v_profile:e,wdth:(t==null?void 0:t.width)||0,hgt:(t==null?void 0:t.height)||0,fps:(t==null?void 0:t.frameRate)||0,bitrate:(t==null?void 0:t.maxBitrate)||0})}updateDataChannel(e){e&&(this.dc=e,this.dc.datachannel&&(this.dc.datachannel.binaryType="arraybuffer"))}publishDataChannel(){return T(this,null,function*(){if(this.dataPubState.state!==ie.AliRtcStatePublishing){this.dataPubState.setState(ie.AliRtcStatePublishing);try{const e=yield this.rtsManager.publishAddDataChannel(this.url);e?(this.updateDataChannel(e),this.dataPubState.setState(ie.AliRtcStatePublished)):(this.dataPubState.setState(ie.AliRtcStateNoPublish),this.emit("publishDataError",new O(H.ERR_INNER,"publishDataError")))}catch(e){this.dataPubState.setState(ie.AliRtcStateNoPublish)}}})}startPublish(){return T(this,arguments,function*(e=!1,t=bt.MANUAL){var d;if(!this.joined)return;const i=this.streamManager.publishStreams,{audio:r,video:n,videoSmall:c,screen:o}=i;if(r||n||c||o){this.createCallId();try{const h=new Date().getTime();r&&this.audioPubState.setState(ie.AliRtcStatePublishing),n&&this.videoPubState.setState(ie.AliRtcStatePublishing),c&&this.videoSmallPubState.setState(ie.AliRtcStatePublishing),o&&this.screenPubState.setState(ie.AliRtcStatePublishing),this.publishPromise=this.rtsManager.publish(this.url,this.callId,e,t);const{traceId:l,l1ip:p}=yield this.publishPromise;this.streamTracks=this.rtsManager.publishingTracks,this.traceId=l;const u={type:Pt.Add,userid:this.userId,sessionid:"",displayname:this.name,pubid:this.publishId,resume:e,subscribe:{signal:"",pullstreamurl:this.url},l1ip:this.parameter.reportL1IP?p:void 0,callid:this.callId,tracks:this.streamTracks,traceid:l};(d=this.parameter.data)!=null&&d.enablePubDataChannel&&this.publishDataChannel().then(()=>{this.syncPublishToRoomServer(u,i,h)}),r&&(this.trackTraceIdMap[M.Audio]=l,this.reportAudioProfile()),c&&(this.trackTraceIdMap[M.VideoSmall]=l),n&&(this.trackTraceIdMap[M.VideoLarge]=l,this.reportVideoProfile()),o&&(this.trackTraceIdMap[M.Screen]=l,this.reportScreenProfile()),yield this.syncPublishToRoomServer(u,i,h),r&&this.audioPubState.setState(ie.AliRtcStatePublished),n&&this.videoPubState.setState(ie.AliRtcStatePublished),c&&this.videoSmallPubState.setState(ie.AliRtcStatePublished),o&&this.screenPubState.setState(ie.AliRtcStatePublished)}catch(h){throw r&&this.audioPubState.setState(ie.AliRtcStateNoPublish),n&&this.videoPubState.setState(ie.AliRtcStateNoPublish),c&&this.videoSmallPubState.setState(ie.AliRtcStateNoPublish),o&&this.screenPubState.setState(ie.AliRtcStateNoPublish),h}}else V.event(`[${Ct.logName}]`,"startPublish no stream founded")})}updateStreams(){return T(this,null,function*(){yield this.streamManager.updateStreams()})}publishUpdate(e){return T(this,null,function*(){var n,c,o,d,h,l;if(!this.rtsManager.isConnecting&&!this.rtsManager.isConnected)return void(yield this.startPublish());yield this.publishPromise;const t=this.streamManager.publishStreams;let i;const r=new Date().getTime();try{const p=(n=this.streamTracks)==null?void 0:n.find(({ssrc:w,type:y,msid:R})=>y==="audio"&&w&&R===M.Audio),u=yield this.compareAndPublish(p,t.audio,M.Audio);u&&(i=u);const g=(c=this.streamTracks)==null?void 0:c.find(({ssrc:w,type:y,msid:R})=>y==="video"&&w&&R===M.VideoLarge),m=yield this.compareAndPublish(g,t.video,M.VideoLarge);m&&(i=m);const b=(o=this.streamTracks)==null?void 0:o.find(({ssrc:w,type:y,msid:R})=>y==="video"&&w&&R===M.VideoSmall),S=yield this.compareAndPublish(b,t.videoSmall,M.VideoSmall);S&&(i=S);const v=(d=this.streamTracks)==null?void 0:d.find(({ssrc:w,type:y,msid:R})=>y==="video"&&w&&R===M.Screen),_=yield this.compareAndPublish(v,t.screen,M.Screen);if(_&&(i=_),!i){if(!(e===bt.RECONNECT&&this.rtsManager.publishingTracks.length>0))return;{if((h=this.parameter.data)!=null&&h.enablePubDataChannel){const R=this.rtsManager.getDatachannelByMsid({url:this.url,msid:M.Data});this.updateDataChannel(R)}const w=this.rtsManager.publishingTracks.find(({type:R})=>R==="video"),y=this.rtsManager.publishingTracks.find(({type:R})=>R==="audio");(w||y)&&(yield this.rtsManager.waitPublishSender(this.url,!w,w?w.msid:y==null?void 0:y.msid)),i={type:Pt.Add,userid:this.userId,sessionid:"",displayname:this.name,pubid:this.publishId,resume:!0,subscribe:{signal:"",pullstreamurl:this.url},callid:this.callId,tracks:this.rtsManager.publishingTracks,traceid:this.traceId}}}(l=this.parameter.data)!=null&&l.enablePubDataChannel&&!this.dc&&(yield this.publishDataChannel()),yield this.syncPublishToRoomServer(i,t,r)}catch(p){const{code:u}=p!=null?p:{},g=this.url;throw u===403&&g&&(yield this.refreshPushStreamUrl(),i=yield this.publishUpdate()),p}return i})}syncPublishToRoomServer(e,t,i){return T(this,null,function*(){var o;if(!e)throw new O(H.ERR_INNER,"sync publish to room server failed because no publishInfo");let r=e;if(this.dc){const c=e,{tracks:d}=c,h=Qt(c,["tracks"]);r=kt(X({},h),{tracks:[...d,{type:"data",msid:M.Data,ssrc:`${((o=this.callId)==null?void 0:o.length)>8?this.callId.substring(0,8):"web"}${this.dc.datachannel.id||"0"}`,codec:"text"}]})}const n=yield this.signalingManager.publish(r);e.signaltid=n.tid})}refreshPushStreamUrl(){return T(this,null,function*(){const e=new O(H.ERR_INNER,"refresh push stream url error"),t=this.url;if(!t)throw e;const i=yield this.signalingManager.refreshUrl({pushstreamurl:t});if(!(i!=null&&i.pushstreamurl))throw e;this.url=i.pushstreamurl})}publishAdd(e,t,i=!1,r=0){return T(this,null,function*(){this.createCallId();const n=(t==null?void 0:t.aMsid)===M.Audio,c=(t==null?void 0:t.vMsid)===M.VideoLarge,o=(t==null?void 0:t.vMsid)===M.VideoSmall,d=(t==null?void 0:t.vMsid)===M.Screen;n&&this.audioPubState.setState(ie.AliRtcStatePublishing),c&&this.videoPubState.setState(ie.AliRtcStatePublishing),o&&this.videoSmallPubState.setState(ie.AliRtcStatePublishing),d&&this.screenPubState.setState(ie.AliRtcStatePublishing);try{const h=yield this.rtsManager.publishAdd(this.url,e,this.callId,t,!1,!0);n&&(this.audioPubState.setState(ie.AliRtcStatePublished),this.reportAudioProfile(),this.trackTraceIdMap[M.Audio]=h),c&&(this.videoPubState.setState(ie.AliRtcStatePublished),this.reportVideoProfile(),this.trackTraceIdMap[M.VideoLarge]=h),o&&(this.videoSmallPubState.setState(ie.AliRtcStatePublished),this.trackTraceIdMap[M.VideoSmall]=h),d&&(this.screenPubState.setState(ie.AliRtcStatePublished),this.reportScreenProfile(),this.trackTraceIdMap[M.Screen]=h),this.streamTracks=this.rtsManager.publishingTracks;const l={type:Pt.Add,userid:this.userId,sessionid:"",displayname:this.name,pubid:this.publishId,resume:i,subscribe:{signal:"",pullstreamurl:this.url},callid:this.callId,tracks:this.streamTracks,traceid:h};return this.reportSelfDeviceStatus(),this.monitorTimerId||this.startStreamMonitor(),l}catch(h){let l=H.ERR_SDK_PUBLISH_INVAILD;if(n&&(this.audioPubState.setState(ie.AliRtcStateNoPublish),l=H.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED),c&&(this.videoPubState.setState(ie.AliRtcStateNoPublish),l=H.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED),o&&(this.videoSmallPubState.setState(ie.AliRtcStateNoPublish),l=H.ERR_SDK_PUBLISH_DUAL_STREAM_FAILED),d&&(this.screenPubState.setState(ie.AliRtcStateNoPublish),l=H.ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED),h.errorCode===15006&&r<3)return this.publishAdd(e,t,i,r+1);throw O.fromError(h,l,"publish add failed")}})}publishReplace(e,t){return T(this,null,function*(){try{yield this.rtsManager.publishReplace(this.url,e,t),this.streamTracks=this.rtsManager.publishingTracks;const i=(t==null?void 0:t.vMsid)===M.VideoLarge,r=(t==null?void 0:t.vMsid)===M.Screen;i&&this.streamManager.setVideoProfile(void 0,void 0,!0),r&&this.streamManager.setScreenProfile(void 0,void 0);const n={type:Pt.Replace,userid:this.userId,sessionid:"",pubid:this.publishId,displayname:this.name,subscribe:{signal:"",pullstreamurl:this.url},callid:this.callId,tracks:this.streamTracks};return this.reportSelfDeviceStatus(),n}catch(i){throw O.fromError(i,H.ERR_INNER,`publish replace failed, vMsid: ${t==null?void 0:t.vMsid} aMsid: ${t==null?void 0:t.aMsid}`)}})}publishDeleteTracks(e){return T(this,null,function*(){const t={type:Pt.Delete,userid:this.userId,sessionid:"",displayname:this.displayname,callid:this.callId,pubid:this.publishId,subscribe:{signal:"",pullstreamurl:this.url},tracks:[]};try{return yield this.rtsManager.publishDelete(this.url,e),this.streamTracks=this.rtsManager.publishingTracks,e.audio&&this.audioPubState.setState(ie.AliRtcStateNoPublish),e.video&&(e.vMsid===M.VideoSmall?this.videoSmallPubState.setState(ie.AliRtcStateNoPublish):this.videoPubState.setState(ie.AliRtcStateNoPublish)),e.screen&&this.screenPubState.setState(ie.AliRtcStateNoPublish),t.tracks=this.streamTracks,this.reportSelfDeviceStatus(),t}catch(i){throw O.fromError(i,H.ERR_INNER,"publish delete tracks failed")}})}publishStop(){return T(this,null,function*(){V.info(`[${Ct.logName}]`,"publishStop",{url:this.url});const e=new Date().getTime();try{const t=this.hasAudioTrackInMS,i=this.hasCameraTrackInMS,r=this.hasCameraDualTrackInMS,n=this.hasScreenTrackInMS;yield this.rtsManager.publishStop(this.url),t&&this.audioPubState.setState(ie.AliRtcStateNoPublish),i&&this.videoPubState.setState(ie.AliRtcStateNoPublish),r&&this.videoSmallPubState.setState(ie.AliRtcStateNoPublish),n&&this.screenPubState.setState(ie.AliRtcStateNoPublish),this.traceId="",Object.keys(this.monitorDataCache).forEach(o=>{this.reportPublishMonitor(o)}),this.streamTracks=[];const c={type:Pt.Stop,userid:this.userId,sessionid:"",displayname:this.displayname,callid:this.callId,pubid:this.publishId,subscribe:{signal:"",pullstreamurl:this.url},tracks:[]};return this.syncPublishToRoomServer(c,{},e),c}catch(t){throw O.fromError(t,H.ERR_INNER,"publish stop failed")}})}unPublish(){return T(this,null,function*(){const e=new Date().getTime();let t={type:Pt.UnPublish,userid:this.userId,sessionid:"",displayname:this.displayname,callid:this.callId,pubid:this.publishId,subscribe:{signal:"",pullstreamurl:this.url},tracks:[]};try{if(this.isPublishing){const i=this.hasAudioTrackInMS,r=this.hasCameraTrackInMS,n=this.hasCameraDualTrackInMS,c=this.hasScreenTrackInMS;yield this.rtsManager.unpublish(),this.streamTracks=[],this.stopStreamMonitor(),i&&this.audioPubState.setState(ie.AliRtcStateNoPublish),r&&this.videoPubState.setState(ie.AliRtcStateNoPublish),n&&this.videoSmallPubState.setState(ie.AliRtcStateNoPublish),c&&this.screenPubState.setState(ie.AliRtcStateNoPublish),this.traceId="",this.clearStream()}return this.dc&&(this.rtsManager.publishStopDataChannel(this.url,this.dc),this.dataPubState.setState(ie.AliRtcStateNoPublish),this.dc=void 0),this.slsReporter.reportUnpublish(this.callId||"",e,0,""),t}catch(i){throw O.fromError(i,H.ERR_INNER,"unpublish failed")}})}reportSelfDeviceStatus(){this.emit(Xe.Local,this.getDeviceStatus())}getDeviceStatus(){var t,i,r,n;let e={micOpen:!1,micInterrupted:!1,cameraOpen:!1,screenShare:!1,audioDisable:!0,videoDisable:!0,screenDisable:!0,backgroundMode:!1,accompanyPlaying:!1};return e.cameraOpen=this.hasCameraTrackInMS,e.videoDisable=this.hasCamera&&!((t=this.streamManager.cameraStreamInfo.originVideoTrack)!=null&&t.enabled),e.micOpen=this.hasAudioTrackInMS,e.audioDisable=this.hasMicrophone&&!((i=this.streamManager.cameraStreamInfo.originAudioTrack)!=null&&i.enabled),e.screenShare=this.hasScreenTrackInMS,e.screenDisable=this.hasScreenShare&&!((n=(r=this.streamManager.screenStreamInfo)==null?void 0:r.originVideoTrack)!=null&&n.enabled),Fa.getCurrentStatus(e)}resetPreviewElements(){this.previewElements.forEach(e=>{e.srcObject=null,e._playPromise=void 0},[]),this.previewElements=[]}resetSecondayPreviewElements(){this.screenPreviewElements.forEach(e=>{e.srcObject=null,e._playPromise=void 0},[]),this.screenPreviewElements=[]}getMediaStats(e){return this.pcMediaStatsMap[e]}reportPublishMonitor(e){if(!e)return;let t;try{t=e===M.Audio?this.rtsManager.getStreamByMsid({url:this.url,aMsid:e}).audioTrack:this.rtsManager.getStreamByMsid({url:this.url,vMsid:e}).videoTrack}catch(i){}this.slsReporter.reportPublishMonitor(this.callId,this.trackTraceIdMap[e]||"",e,t,this.monitorDataCache[e]),this.monitorDataCache[e]=[]}reportNetwork(){this.slsReporter.reportNetworkMonitor(this.candidateDataCache),this.candidateDataCache=[]}startStreamMonitor(){this.monitorTimerId||(this.monitorTimerId=window.setInterval(()=>T(this,null,function*(){var e,i;try{const r=yield this.rtsManager.getPCStats();let n,c;if(r==null||r.forEach(d=>{d.type==="media-source"||d.type==="media-playout"?d.id&&(this.pcMediaStatsMap[d.id]=d):d.type==="candidate-pair"&&d.state==="succeeded"&&(n=d)}),((e=this.candidateDataCache)==null?void 0:e.length)>0){const d=this.candidateDataCache[this.candidateDataCache.length-1]||{},t=d,{_last:h}=t;c=Qt(t,["_last"])}((i=this.candidateDataCache)==null?void 0:i.length)>=30&&this.reportNetwork(),n&&(n._last=c,this.candidateDataCache.push(n));let o=Object.keys(this.monitorDataCache).filter(d=>{var h;return((h=this.monitorDataCache[d])==null?void 0:h.length)>0});(this.streamTracks||[]).forEach(d=>{const h=d.msid;if(!h)return;let l;o.includes(h)&&(o=o.filter(p=>p!==h)),l=h===M.Audio?this.rtsManager.getPublishAudioStats(this.url):this.rtsManager.getPublishVideoStats(this.url,h),l.then(p=>{if(!p.timestamp)return;this.monitorDataCache[h]||(this.monitorDataCache[h]=[]);const u=this.getMediaStats(p.mediaSourceId);p._source=u;const g=this.monitorDataCache[h];let m;if((g==null?void 0:g.length)>0){const S=g[g.length-1]||{},b=S,{_last:v}=b;m=Qt(b,["_last"])}(g==null?void 0:g.length)>=30&&this.reportPublishMonitor(h),p._last=m,p._codec=d.codec||"",this.monitorDataCache[h].push(p)})}),o.forEach(d=>{this.reportPublishMonitor(d)})}catch(r){}}),1e3))}stopStreamMonitor(){this.monitorTimerId&&(clearInterval(this.monitorTimerId),this.monitorTimerId=void 0),Object.keys(this.monitorDataCache).forEach(e=>{this.reportPublishMonitor(e)})}clearStream(){this.streamManager.stop(),this.audioPubState.setState(ie.AliRtcStatePublishIdle),this.videoPubState.setState(ie.AliRtcStatePublishIdle),this.videoSmallPubState.setState(ie.AliRtcStatePublishIdle),this.screenPubState.setState(ie.AliRtcStatePublishIdle)}getCurrentCameraDeviceId(){var e;return(e=this.streamManager.cameraStreamInfo.originVideoTrack)==null?void 0:e.getSettings().deviceId}getCurrentMicDeviceId(){var e;return(e=this.streamManager.cameraStreamInfo.originAudioTrack)==null?void 0:e.getSettings().deviceId}enableAudioVolumeIndication(e){this.audioVolumeIndicationInterval!==e&&(this.audioVolumeIndicationInterval>0&&e<=0&&this.audioLevelMonitor.stop(),e>0&&this.streamManager.cameraStreamInfo.originAudioTrack&&this.audioLevelMonitor.start(this.streamManager.cameraStreamInfo.originAudioTrack,e),this.audioVolumeIndicationInterval=e)}sendSEI(e,t,i){return T(this,null,function*(){if(!this.url)return;let r=0;return r=!t||t<1?1:t-1,this.rtsManager.sendSEI(this.url,e,r,i)})}sendDataChannelMessage(e){var i;if(!((i=this.parameter.data)!=null&&i.enablePubDataChannel))throw new O(H.ERR_INNER,"data channel publish is not enabled");if(!this.dc)throw new O(H.ERR_INNER,"data channel is not ready");const t=function(r,n){let c=0;const o=[];for(;c<r.byteLength;){const d=Math.min(n,r.byteLength-c),h=r.slice(c,c+d);o.push(h),c+=d}return o}(e.toBuffer(),1156);t.forEach((r,n)=>{const c=new Hi(new bi(r.byteLength,n===t.length-1,n===0?1:0),r);this.dc.send(c.toGRTNBuffer())})}getStats(){return T(this,null,function*(){const e=[];if(this.hasAudioTrackInMS){const n=yield this.rtsManager.getPublishAudioStats(this.url);n&&e.push({stats:n,track:ri.AliRtcAudioTrackMic})}const t=[];if(this.hasCameraTrackInMS){const n=yield this.rtsManager.getPublishVideoStats(this.url,M.VideoLarge);n&&t.push({track:ne.AliRtcVideoTrackCamera,streamType:We.AliRtcVideoStreamTypeHigh,stats:n})}if(this.hasCameraDualTrackInMS){const n=yield this.rtsManager.getPublishVideoStats(this.url,M.VideoSmall);n&&t.push({track:ne.AliRtcVideoTrackCamera,streamType:We.AliRtcVideoStreamTypeLow,stats:n})}if(this.hasScreenTrackInMS){const n=yield this.rtsManager.getPublishVideoStats(this.url,M.Screen);n&&t.push({track:ne.AliRtcVideoTrackScreen,stats:n})}let i;const r=yield this.rtsManager.getPCStats();return r==null||r.forEach(n=>{n.type==="candidate-pair"&&n.state==="succeeded"&&(i=n)}),{audio:e,video:t,candidate:i}})}},f(Ct,"logName","LocalUser"),Ct);Ce([C()],Ie.prototype,"clearPublishState",1),Ce([C()],Ie.prototype,"clear",1),Ce([C(U)],Ie.prototype,"startDefaultCamera",1),Ce([C(U)],Ie.prototype,"startDefaultAudio",1),Ce([C()],Ie.prototype,"setViewConfig",1),Ce([C()],Ie.prototype,"startCameraCapture",1),Ce([C()],Ie.prototype,"stopCameraCapture",1),Ce([C()],Ie.prototype,"startAudioCapture",1),Ce([C()],Ie.prototype,"stopAudioCapture",1),Ce([C()],Ie.prototype,"stopPreview",1),Ce([C()],Ie.prototype,"resumePublish",1),Ce([C()],Ie.prototype,"createLocalStream",1),Ce([C()],Ie.prototype,"stopLocalStream",1),Ce([C(U)],Ie.prototype,"startPublish",1),Ce([C()],Ie.prototype,"updateStreams",1),Ce([C(U)],Ie.prototype,"publishUpdate",1),Ce([C(([s])=>[s])],Ie.prototype,"syncPublishToRoomServer",1),Ce([C()],Ie.prototype,"refreshPushStreamUrl",1),Ce([C(([s,a,e])=>[JSON.stringify(e)])],Ie.prototype,"publishAdd",1),Ce([C(([s,a])=>[JSON.stringify(a)])],Ie.prototype,"publishReplace",1),Ce([C(U)],Ie.prototype,"publishDeleteTracks",1),Ce([C()],Ie.prototype,"publishStop",1),Ce([C()],Ie.prototype,"unPublish",1),Ce([C(([s,a,e])=>[s.length,a,e])],Ie.prototype,"sendSEI",1);let Yo=Ie;var Vt=(s=>(s.OPUS="opus",s.H264="H264",s.UNKNOWN="",s))(Vt||{}),oe=(s=>(s[s.NotSubscribe=0]="NotSubscribe",s[s.Subscribing=1]="Subscribing",s[s.Subscribed=2]="Subscribed",s))(oe||{}),Jt=(s=>(s.VideoTrackEnded="videoTrackEnded",s.AudioTrackEnded="audioTrackEnded",s.ScreenTrackEnded="screenTrackEnded",s))(Jt||{});const Xa=s=>T(this,null,function*(){return yield q.AliRTS.createStream({custom:!0,mediaStream:s})}),yi=s=>T(this,null,function*(){const a=(e=>{const t=new MediaStream;return t.addTrack(e),t})(s);return yield Xa(a)});var Zo=Object.defineProperty,Qo=Object.getOwnPropertyDescriptor;class Fi extends se{constructor(){super();f(this,"audioInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Vt.UNKNOWN});f(this,"videoLargeInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Vt.UNKNOWN});f(this,"videoSmallInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Vt.UNKNOWN});f(this,"screenInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Vt.UNKNOWN});f(this,"dataInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Vt.UNKNOWN});f(this,"audioVolume",1);f(this,"audioMuted",!1);f(this,"userStatus")}getAudioInfo(){return this.audioInfo}getVideoSmallInfo(){return this.videoSmallInfo}getVideoLargeInfo(){return this.videoLargeInfo}getScreenInfo(){return this.screenInfo}getDataInfo(){return this.dataInfo}get subscribingInfos(){return[this.audioInfo,this.videoLargeInfo,this.videoSmallInfo,this.screenInfo].filter(e=>e.msid&&e.subscribeState===oe.Subscribed)}get hasTrack(){return this.hasAudio||this.hasVideo||this.hasScreen||this.hasData}get hasAudio(){return this.audioInfo.ssrc!==""}get hasVideo(){return this.videoLargeInfo.ssrc!==""||this.videoSmallInfo.ssrc!==""}get hasVideoLarge(){return this.videoLargeInfo.ssrc!==""}get hasVideoSmall(){return this.videoSmallInfo.ssrc!==""}get hasScreen(){return this.screenInfo.ssrc!==""}get hasData(){return this.dataInfo.ssrc!==""}get isAudioSubscribed(){return this.audioInfo.subscribeState===oe.Subscribed}get isAudioSubscribing(){return this.audioInfo.subscribeState===oe.Subscribing}get isVideoSubscribed(){return this.isVideoLargeSubscribed||this.isVideoSmallSubscribed}get isVideoSubscribing(){return this.isVideoLargeSubscribing||this.isVideoSmallSubscribing}get isVideoLargeSubscribed(){return this.videoLargeInfo.subscribeState===oe.Subscribed}get isVideoLargeSubscribing(){return this.videoLargeInfo.subscribeState===oe.Subscribing}get isVideoSmallSubscribed(){return this.videoSmallInfo.subscribeState===oe.Subscribed}get isVideoSmallSubscribing(){return this.videoSmallInfo.subscribeState===oe.Subscribing}get isScreenSubscribed(){return this.screenInfo.subscribeState===oe.Subscribed}get isScreenSubscribing(){return this.screenInfo.subscribeState===oe.Subscribing}get isDataSubscribed(){return this.dataInfo.subscribeState===oe.Subscribed}get isDataSubscribing(){return this.dataInfo.subscribeState===oe.Subscribing}get audioCodec(){return this.audioInfo.codec}get videoCodec(){return this.hasVideoLarge?this.videoLargeInfo.codec:this.hasVideoSmall?this.videoSmallInfo.codec:this.hasScreen?this.screenInfo.codec:Vt.UNKNOWN}get audioTrackInfo(){return this.hasAudio?ri.AliRtcAudioTrackMic:ri.AliRtcAudioTrackNo}get videoTrackInfo(){return this.hasVideo&&this.hasScreen?ne.AliRtcVideoTrackBoth:this.hasVideo?ne.AliRtcVideoTrackCamera:this.hasScreen?ne.AliRtcVideoTrackScreen:ne.AliRtcVideoTrackNo}updateTracks(e){let t="",i="",r="",n="",c="";return e?(e.forEach(o=>{var p;let d=Vt.UNKNOWN;const h=((p=o==null?void 0:o.attr)==null?void 0:p.reason)==="reconnect";if(o.userdata){const{codec:u}=JSON.parse(o.userdata);u&&(d=u)}var l;(l=o.msid)===M.Audio||l===dr.Audio?(t=o.ssrc,this.audioInfo.msid=o.msid,this.audioInfo.codec=d,(h||this.audioInfo.ssrc!==t)&&(this.audioInfo.subscribeState=oe.NotSubscribe)):(u=>u===M.VideoSmall)(o.msid)?(r=o.ssrc,this.videoSmallInfo.msid=o.msid,this.videoSmallInfo.codec=d,(h||this.videoSmallInfo.ssrc!==r)&&(this.videoSmallInfo.subscribeState=oe.NotSubscribe)):(u=>u===M.VideoLarge||u===dr.VideoLarge)(o.msid)?(i=o.ssrc,this.videoLargeInfo.msid=o.msid,this.videoLargeInfo.codec=d,(h||this.videoLargeInfo.ssrc!==i)&&(this.videoLargeInfo.subscribeState=oe.NotSubscribe)):(u=>u===M.Screen)(o.msid)?(n=o.ssrc,this.screenInfo.msid=o.msid,this.screenInfo.codec=d,(h||this.screenInfo.ssrc!==n)&&(this.screenInfo.subscribeState=oe.NotSubscribe)):(u=>u===M.Data)(o.msid)&&(c=o.ssrc,this.dataInfo.msid=o.msid,this.dataInfo.codec=d,(h||this.dataInfo.ssrc!==c)&&(this.dataInfo.subscribeState=oe.NotSubscribe))}),this.updateRemoteTrackSsrc(t,i,r,n,c)):this.updateRemoteTrackSsrc(t,i,r,n,c),{}}updateRemoteTrackSsrc(e,t,i,r,n){this.audioInfo.ssrc=e,this.videoSmallInfo.ssrc=i,this.videoLargeInfo.ssrc=t,this.screenInfo.ssrc=r,this.dataInfo.ssrc=n}markRemoteTrackSubscribing(e){return e.video&&(e.vMsid===this.videoSmallInfo.msid&&(this.videoSmallInfo.subscribeState=oe.Subscribing),e.vMsid!==this.videoLargeInfo.msid&&e.vMsid||(this.videoLargeInfo.subscribeState=oe.Subscribing)),e.screen&&(this.screenInfo.subscribeState=oe.Subscribing),e.audio&&(this.audioInfo.subscribeState=oe.Subscribing),e.data&&(this.dataInfo.subscribeState=oe.Subscribing),{videoLargeInfo:this.videoLargeInfo,videoSmallInfo:this.videoSmallInfo}}updateRemoteTrackSubState(e){return e.video!==void 0&&(e.vMsid!==this.videoSmallInfo.msid&&e.vMsid||(this.videoSmallInfo.subscribeState=e.video?oe.Subscribed:oe.NotSubscribe),e.vMsid!==this.videoLargeInfo.msid&&e.vMsid||(this.videoLargeInfo.subscribeState=e.video?oe.Subscribed:oe.NotSubscribe)),e.screen!==void 0&&(this.screenInfo.subscribeState=e.screen?oe.Subscribed:oe.NotSubscribe),e.audio!==void 0&&(this.audioInfo.subscribeState=e.audio?oe.Subscribed:oe.NotSubscribe),e.data!==void 0&&(this.dataInfo.subscribeState=e.data?oe.Subscribed:oe.NotSubscribe),{audioInfo:this.audioInfo,videoLargeInfo:this.videoLargeInfo,videoSmallInfo:this.videoSmallInfo,screenInfo:this.screenInfo,dataInfo:this.dataInfo}}updateRemoteUserDeviceStatus(e){let t=Fa.parseStatus(e);const{audioDisable:i,videoDisable:r,screenDisable:n}=t;return this.userStatus?(this.userStatus.audioDisable!=i&&(this.userStatus.audioDisable=i,this.emit(Xe.Remote,i?we.MuteAudio:we.UnmuteAudio)),this.userStatus.videoDisable!=r&&(this.userStatus.videoDisable=r,this.emit(Xe.Remote,r?we.MuteVideo:we.UnmuteVideo)),this.userStatus.screenDisable!=n&&(this.userStatus.screenDisable=n,this.emit(Xe.Remote,n?we.MuteScreen:we.UnmuteScreen))):(this.userStatus=t,this.emit(Xe.Remote,i?we.MuteAudio:we.UnmuteAudio),this.emit(Xe.Remote,r?we.MuteVideo:we.UnmuteVideo),this.emit(Xe.Remote,n?we.MuteScreen:we.UnmuteScreen)),!1}}f(Fi,"logName","RemoteStreamInfo"),((s,a,e,t)=>{for(var i,r=t>1?void 0:t?Qo(a,e):a,n=s.length-1;n>=0;n--)(i=s[n])&&(r=(t?i(a,e,r):i(r))||r);t&&r&&Zo(a,e,r)})([C()],Fi.prototype,"updateRemoteTrackSubState",1);class Ya{constructor(a){f(this,"remoteUser");this.remoteUser=a}get userId(){return this.remoteUser.userId}get displayName(){return this.remoteUser.displayname}get isMuteAudioPlaying(){return this.remoteUser.getAudioMuted()}get hasAudio(){return this.remoteUser.hasAudioTrack}get hasCamera(){return this.remoteUser.hasVideoTrack}get hasCameraLarge(){return this.remoteUser.hasVideoLargeTrack}get hasCameraSmall(){return this.remoteUser.hasVideoSmallTrack}get hasScreenShare(){return this.remoteUser.hasScreenTrack}get isAudioSubscribing(){return this.remoteUser.isAudioSubscribing}get isVideoSubscribing(){return this.remoteUser.isVideoSubscribing}get isVideoLargeSubscribing(){return this.remoteUser.isVideoLargeSubscribing}get isVideoSmallSubscribing(){return this.remoteUser.isVideoSmallSubscribing}get isScreenSubscribing(){return this.remoteUser.isScreenSubscribing}get audioElement(){return this.remoteUser.getAudioElement()}}var ec=Object.defineProperty,tc=Object.getOwnPropertyDescriptor,Je=(s,a,e,t)=>{for(var i,r=t>1?void 0:t?tc(a,e):a,n=s.length-1;n>=0;n--)(i=s[n])&&(r=(t?i(a,e,r):i(r))||r);return t&&r&&ec(a,e,r),r};class ai extends se{constructor(){super();f(this,"state");f(this,"time");f(this,"_enabled");this.state=me.AliRtcStateSubscribeIdle,this.time=Date.now(),this._enabled=!0}setState(e){if(this.state===e)return;const t=this.state,i=this.time;this.state=e,this.time=Date.now(),this.emit("change",t,e,Math.floor((this.time-i)/1e3))}get currentState(){return this.state}getEnabled(){return this._enabled}setEnabled(e){this._enabled=e}}const Ke=(Ze=class extends Ha{constructor(e){var u;const{userId:t,displayName:i,rtsManager:r,usersViewMap:n,slsReporter:c,signalingManager:o,localUser:d,audioVolumeIndicationInterval:h,playoutVolume:l,parameter:p}=e;super(t,i,r,h);f(this,"remoteCallid","");f(this,"remoteUserInfo");f(this,"localUser");f(this,"lastPubId","");f(this,"stream");f(this,"screenStream");f(this,"viewMap");f(this,"audioTrack");f(this,"audioElement");f(this,"subscribed",!1);f(this,"mediaStream");f(this,"secondaryMediaStream");f(this,"prevSubConfig");f(this,"signalingManager");f(this,"slsReporter");f(this,"wantSubAudio",!1);f(this,"wantSubVideo",!1);f(this,"wantSubScreen",!1);f(this,"defaultVideoStreamType",We.AliRtcVideoStreamTypeHigh);f(this,"audioMuted",!1);f(this,"playoutVolume",1);f(this,"playoutGainNode");f(this,"audioSubState");f(this,"videoSubState");f(this,"videoLargeSubState",new ai);f(this,"videoSmallSubState",new ai);f(this,"screenSubState");f(this,"dataSubState");f(this,"dc");f(this,"dcMsgWaitingPieces",[]);f(this,"streamInfo");f(this,"_streamUrl","");f(this,"parameter",{});f(this,"monitorTimerId");f(this,"monitorDataCache",{});f(this,"trackTraceIdMap",{});f(this,"handleAudioContextSuspended",e=>{e.target.state==="suspended"&&this.emit("remoteAudioPlayError",this.uid,"AudioContext suspended")});f(this,"onDataChannelMessage",e=>{var r;const t=Hi.parse(e.slice(4));let i;if(t.body){if(!t.isFin)return t.header.frameType===1&&(this.dcMsgWaitingPieces=[]),void this.dcMsgWaitingPieces.push(t.body);if(this.dcMsgWaitingPieces.length>0){const n=this.dcMsgWaitingPieces.reduce((c,o)=>c+o.byteLength,t.body.byteLength);try{const c=new ArrayBuffer(n);let o=0;for(let d=0;d<this.dcMsgWaitingPieces.length;d++){const h=this.dcMsgWaitingPieces[d];new Uint8Array(c,o,h.byteLength).set(new Uint8Array(h)),o+=h.byteLength}new Uint8Array(c,o,t.body.byteLength).set(new Uint8Array(t.body)),i=xt.parse(c)}catch(c){}this.dcMsgWaitingPieces=[],i||(i=xt.parse(t.body))}else i=xt.parse(t.body);i||V.event(`[${Ze.logName}]`,`parse data channel message fail, piece count: ${this.dcMsgWaitingPieces.length+1}`)}i&&(V.event(`[${Ze.logName}]`,`receive data channel message, length: ${(r=i.data)==null?void 0:r.byteLength}`),this.emit("remoteDataChannelMessage",this.uid,i))});f(this,"onDataChannelError",e=>{this.emit("occurError",O.fromError(e,H.ERR_SDK_SUBSCRIBE_DATA_ERROR))});f(this,"dataChannelConnected",e=>{e&&(this.dc=e,this.dc.datachannel&&(this.dc.datachannel.binaryType="arraybuffer"),this.dc.off("message",this.onDataChannelMessage),this.dc.off("error",this.onDataChannelError),this.dc.on("message",this.onDataChannelMessage),this.dc.on("error",this.onDataChannelError))});f(this,"handleAudioPaused",()=>{this.emit("remoteAudioPlayError",this.uid,"paused")});this.streamInfo=new Fi,this.remoteUserInfo=new Ya(this),this.parameter=p,this.streamInfo.on(Xe.Remote,g=>{this.emit(Xe.Remote,g,this.userId)}),this.signalingManager=o,this.viewMap=(u=n[t])!=null?u:{cameraViews:[],screenViews:[]},n[t]=this.viewMap,this.slsReporter=c,this.localUser=d,this.audioSubState=new ai,this.audioSubState.on("change",(g,m,b)=>{this.emit("audioSubscribeStateChanged",this.uid,g,m,b)}),this.videoSubState=new ai,this.videoSubState.on("change",(g,m,b)=>{this.emit("videoSubscribeStateChanged",this.uid,g,m,b)}),this.screenSubState=new ai,this.screenSubState.on("change",(g,m,b)=>{this.emit("screenSubscribeStateChanged",this.uid,g,m,b)}),this.dataSubState=new ai,this.dataSubState.on("change",(g,m,b)=>{this.emit("dataSubscribeStateChanged",this.uid,g,m,b)}),this.playoutVolume=l}get streamUrl(){return this._streamUrl}set streamUrl(e){this._streamUrl=e,this.rtsManager.updateAuth(e)}isWantSubAudio(){return this.wantSubAudio}setWantSubAudio(e){this.wantSubAudio=e}isWantSubVideo(){return this.wantSubVideo}setWantSubVideo(e){this.wantSubVideo=e}isWantSubScreen(){return this.wantSubScreen}setWantSubScreen(e){this.wantSubScreen=e}setRemoteDefaultVideoStreamType(e){e!==this.defaultVideoStreamType&&(this.defaultVideoStreamType=e,this.updateSubscribe(Se.User))}setAudioMuted(e){this.audioMuted=e,this.toggleAudio(!e)}getAudioElement(){return this.audioElement}setPlayoutVolume(e){if(this.playoutVolume=e,this.audioElement)if(this.parameter.enableAudioContextPlayoutVolume)if(this.playoutGainNode)this.playoutGainNode.gain.value=e;else{const t=this.audioElement.srcObject;if(t){const i=$t.getInstance();i.addEventListener("statechange",this.handleAudioContextSuspended);const r=i.createMediaStreamSource(t);this.audioElement.muted=!0,this.playoutGainNode=i.createGain(),r.connect(this.playoutGainNode),this.playoutGainNode.gain.value=e,this.playoutGainNode.connect(i.destination)}}else this.audioElement.volume=e}getAudioMuted(){return this.audioMuted}get hasAudioTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasAudio)}get hasVideoTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasVideo)}get hasVideoLargeTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasVideoLarge)}get hasVideoSmallTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasVideoSmall)}get hasScreenTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasScreen)}get isAudioSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isAudioSubscribed)||!!((t=this.streamInfo)!=null&&t.isAudioSubscribing)}get isVideoSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isVideoSubscribed)||!!((t=this.streamInfo)!=null&&t.isVideoSubscribing)}get isVideoLargeSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isVideoLargeSubscribed)||!!((t=this.streamInfo)!=null&&t.isVideoLargeSubscribing)}get isVideoSmallSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isVideoSmallSubscribed)||!!((t=this.streamInfo)!=null&&t.isVideoSmallSubscribing)}get isScreenSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isScreenSubscribed)||!!((t=this.streamInfo)!=null&&t.isScreenSubscribing)}get isDataSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isDataSubscribed)||!!((t=this.streamInfo)!=null&&t.isDataSubscribing)}get audioEnabled(){var e,t;return!!((t=(e=this.stream)==null?void 0:e.audioTrack)!=null&&t.enabled)}get videoEnabled(){var e,t;return!!((t=(e=this.stream)==null?void 0:e.videoTrack)!=null&&t.enabled)}get screenEnabled(){var e,t;return!!((t=(e=this.screenStream)==null?void 0:e.videoTrack)!=null&&t.enabled)}get getAudioTrack(){return this.audioTrack}get getCameraStream(){return this.stream}get getScreenStream(){return this.screenStream}setViewConfig(e,t){if(t!==ne.AliRtcVideoTrackScreen&&t!==ne.AliRtcVideoTrackCamera)throw new O(H.ERR_INVALID_ARGUMENTS,"track is not AliRtcVideoTrackScreen or AliRtcVideoTrackCamera");e?Nr(e).forEach(i=>{i.setAttribute("playsinline",""),q.AliRTS.BrowserUtil.isMicroMessenger&&(i.setAttribute("x5-video-player-type","h5-page"),i.setAttribute("x5-playsinline",""),q.AliRTS.SystenUtil.isAndroid||q.AliRTS.SystenUtil.isIos&&i.setAttribute("x-webkit-airplay","allow")),t===ne.AliRtcVideoTrackScreen?this.viewMap.screenViews.push(i):this.viewMap.cameraViews.push(i),this.play(i,t===ne.AliRtcVideoTrackScreen)}):(this.stopPlayAll(t===ne.AliRtcVideoTrackScreen),t===ne.AliRtcVideoTrackScreen?this.viewMap.screenViews=[]:this.viewMap.cameraViews=[])}clear(e=!0){return T(this,null,function*(){var t;this.subscribeStopDataChannel(),e&&this.doStopSubscribe(this.streamUrl),Gr(Ze.prototype,this,"clear").call(this),this.stopPlayAudio(),this.clearStream(),this.clearScreenStream(),this.playoutGainNode&&(this.playoutGainNode.disconnect(),this.playoutGainNode=void 0,$t.getInstance().removeEventListener("statechange",this.handleAudioContextSuspended)),(t=this.streamInfo)==null||t.removeAllListeners(Xe.Remote)})}updateRemoteUserDeviceStatus(e){var t;(t=this.streamInfo)==null||t.updateRemoteUserDeviceStatus(e)}updateRemoteTracks(e,t,i,r){return T(this,null,function*(){var c;return this.remoteCallid=e,this.streamUrl&&this.streamInfo.hasTrack||(this.streamUrl=t),this.callId=e!=null?e:"",this.streamInfo||(this.streamInfo=new Fi),(c=this.streamInfo)==null?void 0:c.updateTracks(r)})}subscribe(r,n){return T(this,arguments,function*(e,t,i=Date.now()){var u,g;let c=e;if(!c){const{hasAudio:m,hasVideo:b,hasScreen:S,hasData:v}=(u=this.streamInfo)!=null?u:{};c={audio:this.wantSubAudio&&m,video:this.wantSubVideo&&b,screen:this.wantSubScreen&&S,data:((g=this.parameter.data)==null?void 0:g.enableSubDataChannel)&&v}}this.streamInfo.markRemoteTrackSubscribing(c);const{screen:o,audio:d,video:h,vMsid:l}=c,p=[];(h||d)&&p.push({audio:d,video:h,vMsid:l}),o&&p.push({screen:o}),(p.length!==0||e!=null&&e.data)&&(yield Promise.all(p.map(m=>this.subscribeProxy(m,t||Se.User,i))),e!=null&&e.data&&this.subscribeDataChannel())})}subscribeProxy(e,t,i){return T(this,null,function*(){var c,o,d,h;let r=new Date().getTime(),n="";try{e.audio&&this.audioSubState.setState(me.AliRtcStateSubscribing),e.video&&(this.videoSubState.currentState!==me.AliRtcStateSubscribeIdle&&this.videoSubState.currentState!==me.AliRtcStateNoSubscribe||this.videoSubState.setState(me.AliRtcStateSubscribing)),e.screen&&this.screenSubState.setState(me.AliRtcStateSubscribing);const l=yield this.rtsManager.subscribe({remoteUser:this,options:e},t,((c=this.localUser)==null?void 0:c.callId)||"",this.callId,i);this.streamInfo.updateRemoteTrackSubState(e),n=l.traceId||"";const{stream:p}=l;if(e.audio){this.trackTraceIdMap[M.Audio]=n;const g=p.audioTrack;g&&(this.audioTrack=g,(o=p.mediaStream)==null||o.removeTrack(g),this.playAudio(),this.audioVolumeIndicationInterval&&this.audioLevelMonitor.start(g,this.audioVolumeIndicationInterval)),this.audioSubState.getEnabled()||this.toggleAudio(!1),this.audioSubState.setState(me.AliRtcStateSubscribed)}e.video&&(this.updateStream(p,this.isVideoLargeSubscribing&&this.isVideoSmallSubscribing),this.videoSubState.getEnabled()||this.toggleVideo(!1),this.videoSubState.setState(me.AliRtcStateSubscribed),e.vMsid===M.VideoSmall?(this.trackTraceIdMap[M.VideoSmall]=n,this.videoSmallSubState.setState(me.AliRtcStateSubscribed)):(this.trackTraceIdMap[M.VideoLarge]=n,this.videoLargeSubState.setState(me.AliRtcStateSubscribed))),e.screen&&(this.trackTraceIdMap[M.Screen]=n,this.updateScreenStream(p),this.videoSubState.getEnabled()||this.toggleScreen(!1),this.screenSubState.setState(me.AliRtcStateSubscribed));const u=new Date().getTime()-r;this.slsReporter.reportSubscribe(((d=this.localUser)==null?void 0:d.callId)||"",this.callId,!!e.video&&e.vMsid===M.VideoLarge,!!e.video&&e.vMsid===M.VideoSmall,!!e.screen,!!e.audio,0,"",u,{pctid:this.rtsManager.pcTraceId,subtid:n,ajsub:t===Se.Join?1:0,url:this.streamUrl,est:r}),this.startStreamMonitor()}catch(l){const p=new Date().getTime()-r;e.audio&&this.audioSubState.setState(me.AliRtcStateNoSubscribe),e.video&&this.videoSubState.setState(me.AliRtcStateNoSubscribe),e.screen&&this.screenSubState.setState(me.AliRtcStateNoSubscribe),l&&(l.message=`user(${this.uid}) subscribe error, ${(l==null?void 0:l.message)||""}`);let u=H.ERR_INNER;e.audio&&(u=H.ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED),e.video&&(u=e.vMsid===M.VideoSmall?H.ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED:H.ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED),e.screen&&(u=H.ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED),this.slsReporter.reportSubscribe(((h=this.localUser)==null?void 0:h.callId)||"",this.callId,!!e.video&&e.vMsid===M.VideoLarge,!!e.video&&e.vMsid===M.VideoSmall,!!e.screen,!!e.audio,u,"",p,{pctid:this.rtsManager.pcTraceId,subtid:"",ajsub:t===Se.Join?1:0,url:this.streamUrl,est:r});const g=O.fromError(l,u);throw this.emit("remoteSubscribeError",g),g}})}subscribeDeleteTracks(e){return T(this,null,function*(){const{audio:t,video:i,screen:r,data:n,vMsid:c}=e,o=[];(t||i||n)&&o.push({audio:t,video:i,vMsid:c}),r&&o.push({screen:r}),o.length!==0&&(yield Promise.all(o.map(d=>this.subscribeDeleteProxy(d))),e.data&&this.subscribeStopDataChannel())})}subscribeDeleteProxy(e){return T(this,null,function*(){try{const t=yield this.rtsManager.subscribeDelete({remoteUser:this,options:e}),{stream:i}=t!=null?t:{},r={};e.audio===!0&&(r.audio=!1,this.audioSubState.setState(me.AliRtcStateNoSubscribe)),e.video===!0&&(r.video=!1,e.vMsid===M.VideoSmall?(this.videoSmallSubState.setState(me.AliRtcStateNoSubscribe),this.videoLargeSubState.currentState!==me.AliRtcStateNoSubscribe&&this.videoLargeSubState.currentState!==me.AliRtcStateSubscribeIdle||this.videoSubState.setState(me.AliRtcStateNoSubscribe)):(this.videoLargeSubState.setState(me.AliRtcStateNoSubscribe),this.videoSmallSubState.currentState!==me.AliRtcStateNoSubscribe&&this.videoSmallSubState.currentState!==me.AliRtcStateSubscribeIdle||this.videoSubState.setState(me.AliRtcStateNoSubscribe))),e.screen===!0&&(r.screen=!1,this.screenSubState.setState(me.AliRtcStateNoSubscribe));const{callId:n,remoteCallid:c}=this,o={callid:n,remoteCallid:c,remoteStream:i};return e.audio&&(this.audioLevelMonitor.stop(),this.stopPlayAudio(),this.audioTrack=void 0),this.streamInfo.updateRemoteTrackSubState({audio:e.audio!==!0&&void 0,video:e.video!==!0&&void 0,screen:e.screen!==!0&&void 0,vMsid:e.vMsid}),o}catch(t){throw O.fromError(t,H.ERR_INNER,"subscribe delete failed")}})}restore(){this.callId="",this.clearStream(),this.clearScreenStream(),this.audioTrack=void 0,this.streamInfo.updateRemoteTrackSubState({audio:!1,video:!1,screen:!1,data:!1}),this.audioElement&&this.audioElement.removeEventListener("pause",this.handleAudioPaused)}resumeAudio(){return T(this,null,function*(){const e=$t.getInstance();return e.state!=="running"&&e.resume(),this.audioElement?this.audioElement.play():this.playAudio()})}resumeVideo(e){return T(this,null,function*(){return e&&e!==ne.AliRtcVideoTrackCamera&&e!==ne.AliRtcVideoTrackBoth?e&&e!==ne.AliRtcVideoTrackScreen&&e!==ne.AliRtcVideoTrackBoth?void 0:this.playAll(!0):this.playAll()})}resumePlay(){this.playAudio(),this.playAll(),this.playAll(!0)}stopSubscribe(e){return T(this,null,function*(){var i,r;let t=new Date().getTime();try{let n;n=e?yield this.subscribeDeleteTracks(e):yield this.doStopSubscribe(this.streamUrl),this.slsReporter.reportUnsubscribe(((i=this.localUser)==null?void 0:i.callId)||(n==null?void 0:n.callid)||"",this.callId,new Date().getTime()-t,0,"")}catch(n){throw this.slsReporter.reportUnsubscribe(((r=this.localUser)==null?void 0:r.callId)||"",this.callId,new Date().getTime()-t,0,""),n}})}doStopSubscribe(e){return T(this,null,function*(){var r,n,c,o;const{callId:t,remoteCallid:i}=this;if((this.isAudioSubscribing||this.isVideoSubscribing||this.isScreenSubscribing)&&e)try{this.stopStreamMonitor(),yield this.rtsManager.subscibeStop(e),this.restore();const d={callid:t,remoteCallid:i,remoteStream:this.stream};return this.callId="",d}catch(d){if(((o=(c=(n=(r=d==null?void 0:d.extraInfo)==null?void 0:r.parsedData)==null?void 0:n.streams)==null?void 0:c[0])==null?void 0:o.res_code)!==404)throw O.fromError(d,H.ERR_INNER,"subscribe stop failed")}})}updateStream(e,t=!1){return T(this,null,function*(){this.stream&&this.stream.videoTrack&&e.mediaStream&&t&&(yield new Promise(i=>{let r,n;if(e.mediaStream){n=document.createElement("video");const c=()=>{V.event(`uid: ${this.userId} new mediaStream canplay`),n&&n.removeEventListener("canplaythrough",c,!1),n=void 0,clearTimeout(r),i(!0)};n.addEventListener("canplaythrough",c,!1),(n._playPromise||Promise.resolve()).then(()=>{n&&e.mediaStream&&(n.srcObject=e.mediaStream)})}else i(!0);r=window.setTimeout(()=>{V.event(`uid: ${this.userId} new mediaStream timeout`),n=void 0,i(!0)},3e3)}),this.updateSubscribe(Se.User)),this.stream=e,this.playAll(!1,t),!this.subscribed&&e&&(this.subscribed=!0),e.hasAudio&&this.isAudioSubscribing&&e.enableAudio(),e.hasVideo&&this.isVideoSubscribing&&e.enableVideo()})}updateScreenStream(e){this.screenStream=e,this.playAll(!0),!this.subscribed&&e&&(this.subscribed=!0),e.hasVideo&&this.isScreenSubscribing&&e.enableVideo()}clearStream(){var e;(e=this.stream)==null||e.stop(),this.stream=void 0}clearScreenStream(){var e;(e=this.screenStream)==null||e.stop(),this.screenStream=void 0}subscribeDataChannel(){if(this.dc)try{this.dc.dispose(),this.dcMsgWaitingPieces=[],this.dc.off("message",this.onDataChannelMessage),this.dc=void 0}catch(e){}(this.streamInfo.hasAudio||this.streamInfo.hasVideo||this.streamInfo.hasScreen)&&(this.dataSubState.setState(me.AliRtcStateSubscribing),this.rtsManager.subscribeAddDataChannel(this.streamUrl).then(e=>{if(e)return this.dataChannelConnected(e),this.dataSubState.setState(me.AliRtcStateSubscribed),void this.streamInfo.updateRemoteTrackSubState({data:!0});throw new Error("no dc founded")}).catch(e=>{const t=O.fromError(e,H.ERR_INNER,"subscribe data failed");this.emit("remoteSubscribeError",t),this.dataSubState.setState(me.AliRtcStateNoSubscribe)}))}subscribeStopDataChannel(){if(this.dc){try{this.rtsManager.subscribeStopDatachannel(this.streamUrl,this.dc)}catch(e){}this.dcMsgWaitingPieces=[],this.dc.off("message",this.onDataChannelMessage),this.dc.off("error",this.onDataChannelError),this.dataSubState.setState(me.AliRtcStateNoSubscribe),this.dc=void 0,this.streamInfo.updateRemoteTrackSubState({data:!1})}}getRetryOptions(){var i,r,n,c,o,d,h;const e={};this.wantSubAudio&&((i=this.streamInfo)!=null&&i.hasAudio)&&(e.audio=!0,e.aMsid=((r=this.streamInfo.getAudioInfo())==null?void 0:r.msid)||M.Audio),this.wantSubVideo&&((n=this.streamInfo)!=null&&n.hasVideo)&&(this.defaultVideoStreamType===We.AliRtcVideoStreamTypeLow&&((c=this.streamInfo)!=null&&c.hasVideoSmall)?(e.video=!0,e.vMsid=M.VideoSmall):(o=this.streamInfo)!=null&&o.hasVideoLarge&&(e.video=!0,e.vMsid=((d=this.streamInfo.getVideoLargeInfo())==null?void 0:d.msid)||M.VideoLarge)),this.wantSubScreen&&((h=this.streamInfo)!=null&&h.hasScreen)&&(e.screen=!0);let t={};if(e.audio||e.video)t={audio:e.audio,video:e.video},this.streamInfo.updateRemoteTrackSubState({screen:!1,data:!1});else{if(!e.screen)return;t={screen:e.screen},this.streamInfo.updateRemoteTrackSubState({data:!1})}return{remoteUser:this,options:t}}updateSubscribe(e){var n,c,o,d,h,l,p,u,g,m,b,S,v,_,w,y,R;const t=Date.now(),i={},r={};if(this.wantSubAudio&&!this.isAudioSubscribing&&((n=this.streamInfo)!=null&&n.hasAudio)?(i.audio=!0,i.aMsid=((c=this.streamInfo.getAudioInfo())==null?void 0:c.msid)||M.Audio):this.wantSubAudio&&((o=this.streamInfo)!=null&&o.hasAudio)||!this.isAudioSubscribing||(r.audio=!0,r.aMsid=((d=this.streamInfo.getAudioInfo())==null?void 0:d.msid)||M.Audio),this.wantSubVideo&&((h=this.streamInfo)!=null&&h.hasVideo)?(this.defaultVideoStreamType===We.AliRtcVideoStreamTypeLow&&!this.isVideoSmallSubscribing&&((l=this.streamInfo)!=null&&l.hasVideoSmall)?(i.video=!0,i.vMsid=M.VideoSmall):this.isVideoLargeSubscribing||!((p=this.streamInfo)!=null&&p.hasVideoLarge)||this.defaultVideoStreamType===We.AliRtcVideoStreamTypeLow&&this.isVideoSmallSubscribing||(i.video=!0,i.vMsid=((u=this.streamInfo.getVideoLargeInfo())==null?void 0:u.msid)||M.VideoLarge),this.defaultVideoStreamType===We.AliRtcVideoStreamTypeLow&&this.isVideoLargeSubscribing&&this.isVideoSmallSubscribing&&this.streamInfo.hasVideoSmall?(r.video=!0,r.vMsid=M.VideoLarge):this.defaultVideoStreamType===We.AliRtcVideoStreamTypeHigh&&this.isVideoLargeSubscribing&&this.isVideoSmallSubscribing&&(r.video=!0,r.vMsid=M.VideoSmall)):this.wantSubVideo&&((g=this.streamInfo)!=null&&g.hasVideo)||!this.isVideoSubscribing||(r.video=!0,r.vMsid=this.streamInfo.isVideoSmallSubscribed||this.streamInfo.isVideoSmallSubscribing?M.VideoSmall:((m=this.streamInfo.getVideoLargeInfo())==null?void 0:m.msid)||M.VideoLarge),this.wantSubScreen&&!this.isScreenSubscribing&&((b=this.streamInfo)!=null&&b.hasScreen)?i.screen=!0:this.wantSubScreen&&((S=this.streamInfo)!=null&&S.hasScreen)||!this.isScreenSubscribing||(r.screen=!0),(v=this.parameter.data)!=null&&v.enableSubDataChannel&&!this.isDataSubscribing&&((_=this.streamInfo)!=null&&_.hasData)?i.data=!0:(w=this.parameter.data)!=null&&w.enableSubDataChannel&&((y=this.streamInfo)!=null&&y.hasData)||!this.isDataSubscribing||(r.data=!0),(i.audio||i.video||i.screen||i.data)&&(this.createCallId(),this.subscribe(i,e,t)),(r.audio||r.video||r.screen)&&this.subscribeDeleteTracks(r),e===Se.Reconnect){if(V.event(`[${Ze.logName}]`,"reconnect, try to resume"),this.streamInfo.hasData&&!i.data){const A=this.rtsManager.getDatachannelByMsid({url:this.streamUrl,msid:this.streamInfo.getDataInfo().msid||M.Data});this.dataChannelConnected(A)}if(this.streamInfo.hasAudio&&!i.audio){const A=this.rtsManager.getStreamByMsid({url:this.streamUrl,aMsid:this.streamInfo.getAudioInfo().msid||M.Audio});A&&A.audioTrack&&(this.audioTrack=A.audioTrack,this.playAudio())}if(this.streamInfo.hasVideo&&!i.video){const A=this.rtsManager.getStreamByMsid({url:this.streamUrl,vMsid:this.streamInfo.isVideoSmallSubscribed||this.streamInfo.isVideoSmallSubscribing?M.VideoSmall:((R=this.streamInfo.getVideoLargeInfo())==null?void 0:R.msid)||M.VideoLarge});A&&A.mediaStream&&(this.stream=A,this.playAll(!1))}if(this.streamInfo.hasScreen&&!i.screen){const A=this.rtsManager.getStreamByMsid({url:this.streamUrl,sMsid:this.streamInfo.getScreenInfo().msid||M.Screen});A&&A.mediaStream&&(this.screenStream=A,this.playAll(!0))}}return{addOption:i,deleteOption:r}}handleAutoPlayFailed(){V.event(`[${Ze.logName}]`,"auto play failed"),this.emit("remoteAudioAutoPlayFail",this.uid);const e=()=>{this.resumeAudio().then(()=>{document.removeEventListener("click",e,!1),document.removeEventListener("touchstart",e,!1)})};document.addEventListener("click",e,!1),document.addEventListener("touchstart",e,!1)}handleVideoPlayFailded(e,t){this.emit("remoteVideoAutoPlayFail",this.uid,t);const i=()=>{var n;const r=(n=t===ne.AliRtcVideoTrackScreen?this.screenStream:this.stream)==null?void 0:n.mediaStream;e.srcObject===r&&this.play(e,t===ne.AliRtcVideoTrackScreen),document.removeEventListener("click",i,!1),document.removeEventListener("touchstart",i,!1)};document.addEventListener("click",i,!1),document.addEventListener("touchstart",i,!1)}playAudio(){return T(this,null,function*(){var e,t;if(this.audioTrack){if(this.toggleAudio(!this.audioMuted),this.audioElement||(V.event(`[${Ze.logName}]`,this.userId,"create audio element"),this.audioElement=document.createElement("audio"),this.audioElement.setAttribute("autoplay","autoplay"),this.audioElement.addEventListener("pause",this.handleAudioPaused),this.setPlayoutVolume(this.playoutVolume)),((t=(e=this.audioElement.srcObject)==null?void 0:e.getAudioTracks())==null?void 0:t[0])!==this.audioTrack){let i=this.audioElement.srcObject;i?i.getAudioTracks().forEach(r=>{i.removeTrack(r)}):(i=new MediaStream,this.audioElement.srcObject=i),i.addTrack(this.audioTrack)}if(q.AliRTS.SystenUtil.isIos&&parseInt(q.AliRTS.SystenUtil.systemVersion)<=13){V.event(`[${Ze.logName}]`,"play audio for iOS 13-");const i=this.audioElement;i.setAttribute("autoplay","");const r=()=>{i.removeEventListener("playing",r),i.pause(),i.play().catch(()=>{this.handleAutoPlayFailed()})};this.audioElement.addEventListener("playing",r)}else(()=>{var i;V.event(`[${Ze.logName}]`,"try play audio"),(i=this.audioElement)==null||i.play().then(()=>{V.event(`[${Ze.logName}]`,"play audio success")}).catch(()=>{this.handleAutoPlayFailed()})})()}else V.event(`[${Ze.logName}]`,this.userId,"audio track is null")})}stopPlayAudio(){this.audioElement&&(this.audioElement.pause(),this.audioElement.removeEventListener("pause",this.handleAudioPaused))}playAll(e=!1,t=!1){e?(this.viewMap.screenViews||[]).forEach(i=>{this.play(i,e,t)}):(this.viewMap.cameraViews||[]).forEach(i=>{this.play(i,e,t)})}play(e,t=!1,i=!1){const r=t?this.screenStream:this.stream;e&&r&&r.mediaStream&&Ga(e,r.mediaStream,i).catch(n=>{n.code!==20&&n.name!=="AbortError"&&this.handleVideoPlayFailded(e,t?ne.AliRtcVideoTrackScreen:ne.AliRtcVideoTrackCamera)})}stopPlayAll(e=!1){e?this.viewMap.screenViews.forEach(t=>{Rt(t)}):this.viewMap.cameraViews.forEach(t=>{Rt(t)})}toggleAudio(e=!0){this.audioSubState.setEnabled(e),this.audioElement&&(this.audioElement.muted=!e)}toggleVideo(e=!0){this.videoSubState.setEnabled(e),this.stream&&(e?this.stream.enableVideo():this.stream.disableVideo())}toggleScreen(e=!0){this.screenSubState.setEnabled(e),this.screenStream&&(e?this.screenStream.enableVideo():this.screenStream.disableVideo())}getStats(){return T(this,null,function*(){var i,r,n,c,o;const e=[];if(this.isAudioSubscribing){const d=yield this.rtsManager.getSubscribeAudioStats(this.streamUrl);d&&e.push({uid:this.uid,track:ri.AliRtcAudioTrackMic,stats:d})}const t=[];if((i=this.streamInfo)!=null&&i.isVideoLargeSubscribed){const d=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((r=this.streamInfo.getVideoLargeInfo())==null?void 0:r.msid)||M.VideoLarge);d&&t.push({uid:this.uid,track:ne.AliRtcVideoTrackCamera,streamType:We.AliRtcVideoStreamTypeHigh,stats:d})}if((n=this.streamInfo)!=null&&n.isVideoSmallSubscribed){const d=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((c=this.streamInfo.getVideoSmallInfo())==null?void 0:c.msid)||M.VideoSmall);d&&t.push({uid:this.uid,track:ne.AliRtcVideoTrackCamera,streamType:We.AliRtcVideoStreamTypeLow,stats:d})}if(this.isScreenSubscribing){const d=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((o=this.streamInfo.getScreenInfo())==null?void 0:o.msid)||M.Screen);d&&t.push({uid:this.uid,track:ne.AliRtcVideoTrackScreen,stats:d})}return{audio:e,video:t}})}enableAudioVolumeIndication(e){this.audioVolumeIndicationInterval!==e&&(this.audioVolumeIndicationInterval>0&&e<=0&&this.audioLevelMonitor.stop(),e>0&&this.audioTrack&&this.audioLevelMonitor.start(this.audioTrack,e),this.audioVolumeIndicationInterval=e)}reportSubscribeMonitor(e){var t;e&&(this.slsReporter.reportSubscribeMonitor(((t=this.localUser)==null?void 0:t.callId)||"",this.callId,this.trackTraceIdMap[e]||"",e,this.monitorDataCache[e]),this.monitorDataCache[e]=[])}startStreamMonitor(){this.monitorTimerId||(this.monitorTimerId=window.setInterval(()=>T(this,null,function*(){try{if(this.streamInfo.subscribingInfos.length===0)return void this.stopStreamMonitor();let e=Object.keys(this.monitorDataCache).filter(t=>{var i;return((i=this.monitorDataCache[t])==null?void 0:i.length)>0});this.streamInfo.subscribingInfos.forEach(t=>{const i=t.msid;if(!i)return;let r;e.includes(i)&&(e=e.filter(c=>c!==i));const n=i===M.Audio;r=n?this.rtsManager.getSubscribeAudioStats(this.streamUrl):this.rtsManager.getSubscribeVideoStats(this.streamUrl,i),r.then(c=>{var l;if(!c.timestamp)return;this.monitorDataCache[i]||(this.monitorDataCache[i]=[]);const o=this.monitorDataCache[i];let d;if((o==null?void 0:o.length)>0){const p=o[o.length-1]||{},h=p,{_last:u}=h;d=Qt(h,["_last"])}(o==null?void 0:o.length)>=30&&this.reportSubscribeMonitor(i),c._last=d,c._codec=t.codec,n&&(c._source=(l=this.localUser)==null?void 0:l.getMediaStats(c.playoutId)),this.monitorDataCache[i].push(c)})}),e.forEach(t=>{this.reportSubscribeMonitor(t)})}catch(e){}}),1e3))}stopStreamMonitor(){this.monitorTimerId&&(clearInterval(this.monitorTimerId),this.monitorTimerId=void 0),Object.keys(this.monitorDataCache).forEach(e=>{this.reportSubscribeMonitor(e)})}},f(Ze,"logName","RemoteUser"),Ze);Je([C()],Ke.prototype,"clear",1),Je([C()],Ke.prototype,"updateRemoteUserDeviceStatus",1),Je([C()],Ke.prototype,"updateRemoteTracks",1),Je([C(U)],Ke.prototype,"subscribe",1),Je([C()],Ke.prototype,"subscribeProxy",1),Je([C(U)],Ke.prototype,"subscribeDeleteProxy",1),Je([C()],Ke.prototype,"restore",1),Je([C(U)],Ke.prototype,"resumeAudio",1),Je([C(U)],Ke.prototype,"stopSubscribe",1),Je([C(U)],Ke.prototype,"doStopSubscribe",1),Je([C()],Ke.prototype,"clearStream",1),Je([C()],Ke.prototype,"clearScreenStream",1),Je([C()],Ke.prototype,"updateSubscribe",1),Je([C()],Ke.prototype,"playAudio",1),Je([C()],Ke.prototype,"stopPlayAudio",1),Je([C((s,a,e)=>[typeof s=="string"?s:s==null?void 0:s.nodeType,a,e])],Ke.prototype,"play",1),Je([C()],Ke.prototype,"stopPlayAll",1);let ic=Ke;var Ot=(s=>(s[s.AliRtcPluginErrorCodeSuccess=0]="AliRtcPluginErrorCodeSuccess",s[s.AliRtcPluginErrorCodeFailed=-1]="AliRtcPluginErrorCodeFailed",s[s.AliRtcPluginErrorNoFindPlugin=-2]="AliRtcPluginErrorNoFindPlugin",s[s.AliRtcPluginErrorParameterError=-3]="AliRtcPluginErrorParameterError",s[s.AliRtcPluginErrorLoadError=-4]="AliRtcPluginErrorLoadError",s[s.AliRtcPluginErrorCreateError=-5]="AliRtcPluginErrorCreateError",s[s.AliRtcPluginErrorInitError=-6]="AliRtcPluginErrorInitError",s[s.AliRtcPluginErrorInitTokenError=-7]="AliRtcPluginErrorInitTokenError",s))(Ot||{});class rc extends se{constructor(){super(...arguments);f(this,"plugins",new Map)}add(e,t){if(this.plugins.has(e.name))throw new O(Ot.AliRtcPluginErrorCreateError,`Plugin ${e.name} already exists`);this.plugins.set(e.name,e),t&&e.setOptions(t),this.emit("added",e),e.on("enabled",()=>this.emit("added",e)),e.on("disabled",()=>this.emit("removed",e)),e.on("updated",()=>this.emit("updated",e))}remove(e){const t=this.plugins.get(e);if(!t)throw new O(Ot.AliRtcPluginErrorNoFindPlugin,`Plugin ${e} not founded`);this.plugins.delete(e),t.removeAllListeners(),this.emit("removed",t)}removeAll(){this.plugins.forEach(e=>{this.remove(e.name)})}get(e){return this.plugins.get(e)}has(e){return!!this.plugins.get(e)}getAll(){return Array.from(this.plugins.values())}}var sc=Object.defineProperty,ac=Object.getOwnPropertyDescriptor,Be=(s,a,e,t)=>{for(var i,r=t>1?void 0:t?ac(a,e):a,n=s.length-1;n>=0;n--)(i=s[n])&&(r=(t?i(a,e,r):i(r))||r);return t&&r&&sc(a,e,r),r};const ji=([s])=>{const{remoteUser:a,options:e}=s;return[`user(${a.userId})`,e]},xe=(Fe=class extends se{constructor(e,t,i){super();f(this,"rts");f(this,"encodedInsertableStreams",!0);f(this,"audioRedEnabled",!1);f(this,"localStreamManager");f(this,"slsReporter");f(this,"_rtsPeerConnectionType","publish");f(this,"connecting",!1);f(this,"connected",!1);f(this,"_pcTraceId","");f(this,"_localJoinTime",0);f(this,"connectionResolve");f(this,"connectingPromise");f(this,"dcResolve");f(this,"dcReject");f(this,"dcConnectingPromise");f(this,"_publishingTracks",[]);f(this,"parameter",{});this.localStreamManager=e,this.slsReporter=t,this.parameter=i,this.rts=q.AliRTS.createClient({singlePcConfig:{usePcReconnect:!0}}),this.addRTSListener()}addRTSListener(){this.rts.on("connectStatusChange",e=>{var t,i,r,n;if(V.event(`[${Fe.logName}]`,"rts connectStatusChange to:",e.status),e.status===q.EConnectStatus.CONNECT_STATUS_DISCONNECTED)this.dcReject&&this.dcReject(),this.setConnected(!1),this.slsReporter.reportWarning("rts disconnected"),this.emit("disconnected");else if(e.status===q.EConnectStatus.CONNECT_STATUS_CONNECTED){const c=(n=(r=(i=(t=this.rts.commonController)==null?void 0:t.peerCore)==null?void 0:i.getSignal())==null?void 0:r.getDatachannelCore())==null?void 0:n.readyState;V.event(`[${Fe.logName}]`,"dcReadyState:",c),c==="open"&&this.dcResolve&&this.dcResolve(!0),this.setConnected(!0)}}),this.rts.on("reconnectFinish",()=>{V.event(`[${Fe.logName}]`,"rts reconnectFinish");try{this.emit("connected",!0,this._rtsPeerConnectionType)}catch(e){V.error(`[${Fe.logName}]`,"emit connected error:",e)}}),this.rts.on("datachannelStatusChange",e=>{V.event(`[${Fe.logName}]`,"rts datachannelStatusChange to:",e.status),e.status===q.EDatachannelStatus.DATACHANNEL_STATUS_OPEN?this.dcResolve&&this.dcResolve(!0):e.status===q.EDatachannelStatus.DATACHANNEL_STATUS_CLOSE&&(this.dcReject&&this.dcReject(),this.dcConnectingPromise=new Promise((t,i)=>{this.dcResolve=t,this.dcReject=i}))}),this.rts.on("receivedSEI",e=>{this.emit("seimessage",e.url,e.sei.payloadType,e.sei.data)}),this.rts.on("onError",e=>{V.event(`[${Fe.logName}]`,"rts onError event:",e)}),this.rts.on("reconnect",e=>{V.event(`[${Fe.logName}]`,"rts reconnect event:",e)})}updateAuth(e){this.rts.updateAuth(e)}get pcTraceId(){return this._pcTraceId}set localJoinTime(e){this._localJoinTime=e}setEncodedInsertableStreams(e){this.encodedInsertableStreams=e}setAudioRedEnabled(e){var t;if(e!==this.audioRedEnabled){try{const i=[...((t=RTCRtpReceiver.getCapabilities("audio"))==null?void 0:t.codecs)||[]];if(i.length>0){if(e){const r=i.findIndex(c=>c.mimeType==="audio/red"),n=i.findIndex(c=>c.mimeType==="audio/opus");if(r>-1&&n>-1&&r>n){const c=i[n];i[n]=i[r],i[r]=c}}this.rts.setSenderCodecPreferences({audio:i}),this.rts.setReceiverCodecPreferences({audio:i})}}catch(i){}this.audioRedEnabled=e}}clear(){this.setConnected(!1),this._publishingTracks=[];try{this.rts.unpublish()}catch(e){}this.rts=q.AliRTS.createClient(),this.addRTSListener()}startConnect(){this.connecting=!0,this.connectingPromise=new Promise(e=>{this.connectionResolve=e}),this.dcConnectingPromise=new Promise((e,t)=>{this.dcResolve=e,this.dcReject=t})}setConnected(e){var t;this.connected=e,this.connecting=!1,(t=this.connectionResolve)==null||t.call(this,!0)}get isConnecting(){return this.connecting}get isConnected(){return this.connected}get publishingTracks(){return this._publishingTracks}getPubMsid(e,t){const{aMsid:i,vMsid:r}=t!=null?t:{},n={};return e.hasAudio&&(n.aMsid=[i!=null?i:M.Audio]),e.hasScreen&&(n.vMsid=[M.Screen]),e.hasVideo&&(n.vMsid=[r!=null?r:t!=null&&t.isScreen?M.Screen:M.VideoLarge]),n}updatePublishingTracks(e){e&&(this._publishingTracks=e.map(({msid:t,from:i,ssrc:r,codec:n,type:c,trackId:o})=>({msid:t,from:i,type:c,ssrc:`${r}`,codec:n!=null?n:"",trackId:o})))}httpPublish(n,c){return T(this,arguments,function*(e,t,i=!1,r=bt.MANUAL){var _,w;let o;const d=Date.now(),{publishStream:h,videoSmallStream:l,screenStream:p,vMsid:u}=yield this.localStreamManager.createHTTPPublishStream();if(!h)return V.warn(`[${Fe.logName}]`,"publishStream is null"),{traceId:"",l1ip:o};const g=this.getPubMsid(h,{vMsid:u});this.encodedInsertableStreams&&(g.encodedInsertableStreams=!0),g.answerSdpHook=y=>{const R=/\d+\.\d+\.\d+\.\d+(?=\s+1106|\s+8000)/.exec(y);return R!=null&&R[0]&&(o=R[0]),y},(w=(_=this.parameter)==null?void 0:_.net)!=null&&w.useTCP&&(g.tcpOnly=!0),g.retryTimes=17,g.retryInterval=5e3,this._rtsPeerConnectionType="publish";let m=!h.hasVideo,b=u,S="";this.startConnect();const v=Date.now();try{S=yield this.rts.publish(Ja(e),h,g)}catch(y){this.setConnected(!1);const R=2e3-(Date.now()-v);throw R<=0?this.emit("disconnected"):setTimeout(()=>{this.emit("disconnected")},R),this.slsReporter.reportPublish(i,e,t,h.hasVideo&&(!u||u===M.VideoLarge),h.hasVideo&&u===M.VideoSmall,h.hasVideo&&u===M.Screen,h.hasAudio,(y==null?void 0:y.errorCode)||-1,this.pcTraceId,"",v),O.fromRtsError(y)}V.event(`[${Fe.logName}]`,"rts publish success",S),this.slsReporter.reportPublish(i,e,t,h.hasVideo&&(!u||u===M.VideoLarge),h.hasVideo&&u===M.VideoSmall,h.hasVideo&&u===M.Screen,h.hasAudio,0,S,S,v),this.slsReporter.reportConnectionLatencyEvent(ot.HANDLE_PUB_TASK,lt.START,t,S,d),this.slsReporter.reportConnectionLatencyEvent(ot.HANDLE_PUB_TASK,lt.END,t,S,Date.now());try{const y=Date.now();return this._pcTraceId=S,this.setConnected(!0),this._publishingTracks=this.rts.getPublishTrackInfoList(),l&&(yield this.publishAdd(e,l,t,{vMsid:M.VideoSmall},i),m=!1,b=M.VideoSmall),p&&(yield this.publishAdd(e,p,t,{vMsid:M.Screen},i),m=!1,b=M.Screen),yield this.waitPublishSender(e,m,b),this.slsReporter.reportPublishFirstPacket(i,t,v,y,this._localJoinTime,m?M.Audio:g.vMsid,S||"",S||"",r),{traceId:S,l1ip:o}}catch(y){throw this.setConnected(!1),O.fromError(y)}})}waitPublishSender(e,t=!1,i){return T(this,null,function*(){return Promise.race([Lt(1e3),((r,n)=>{let c=0;const o=()=>(t?this.rts.getPublishAudioStats(e,i):this.rts.getPublishVideoStats(e,i)).then(d=>!(d.bytesSent>0)&&c<r?(c++,new Promise(h=>setTimeout(()=>h(o()),n))):Promise.resolve());return o()})(5,100)]).catch(()=>{})})}getPublishVideoStats(e,t){return T(this,null,function*(){return yield this.rts.getPublishVideoStats(e,t)})}getPublishAudioStats(e,t){return T(this,null,function*(){return yield this.rts.getPublishAudioStats(e,t)})}publishAdd(d,h,l,p){return T(this,arguments,function*(e,t,i,r,n=!1,c=!1,o=bt.MANUAL){var m,b,S,v,_,w,y,R;yield this.dcConnectingPromise;const u=Date.now(),g=this.getPubMsid(t,r);try{const A=yield $a(E=>T(this,null,function*(){return E>0&&V.event(`[${Fe.logName}]`,`publishAdd retry times: ${E}`),this.isConnected?(yield this.dcConnectingPromise,this.rts.publishAdd([X({url:e,stream:t,updateSourceStream:!1},g)])):Promise.reject(new O(H.ERR_INNER,"rts not connected"))}),5,0,E=>(E==null?void 0:E.errorCode)===15006);if(A){const E=Date.now(),[I]=A;return this.slsReporter.reportPublish(!1,e,i,((m=g.vMsid)==null?void 0:m[0])===M.VideoLarge,((b=g.vMsid)==null?void 0:b[0])===M.VideoSmall,((S=g.vMsid)==null?void 0:S[0])===M.Screen,((v=g.aMsid)==null?void 0:v[0])===M.Audio,0,this.pcTraceId,I.traceId||"",u),this.updatePublishingTracks(I.trackInfoList),c&&(yield this.waitPublishSender(e,!t.hasVideo,t.hasVideo?r==null?void 0:r.vMsid:r==null?void 0:r.aMsid)),this.slsReporter.reportPublishFirstPacket(n,i,u,E,this._localJoinTime,(t.hasVideo?r==null?void 0:r.vMsid:r==null?void 0:r.aMsid)||"",this.pcTraceId,I.traceId||"",o),I.traceId||""}}catch(A){throw this.slsReporter.reportPublish(!1,e,i,((_=g.vMsid)==null?void 0:_[0])===M.VideoLarge,((w=g.vMsid)==null?void 0:w[0])===M.VideoSmall,((y=g.vMsid)==null?void 0:y[0])===M.Screen,((R=g.aMsid)==null?void 0:R[0])===M.Audio,(A==null?void 0:A.errorCode)||-1,this.pcTraceId,"",u),A!=null&&A.errorCode?O.fromRtsError(A):O.fromError(A)}return""})}publishDelete(e,t){return T(this,null,function*(){var d,h,l,p,u,g,m,b;yield this.dcConnectingPromise;const i=(h=(d=this.publishingTracks)==null?void 0:d.find(({msid:S})=>S===M.Audio))==null?void 0:h.msid,r=(p=(l=this.publishingTracks)==null?void 0:l.find(({msid:S})=>S===M.VideoLarge))==null?void 0:p.msid,n=(g=(u=this.publishingTracks)==null?void 0:u.find(({msid:S})=>S===M.Screen))==null?void 0:g.msid,c=[];t.screen&&n?c.push(n):t.video&&c.push(t.vMsid||r);const o=[];t.audio&&i&&o.push(i),V.event(Fe.logName,"publishDelete",{streamUrl:e,aMsid:o,vMsid:c});try{const[S]=(yield this.rts.publishDeleteTracks([{url:e,aMsid:o,vMsid:c}]))||[];return V.event(Fe.logName,"publishDelete",{result:S}),S&&this.updatePublishingTracks(S.trackInfoList),((b=(m=S==null?void 0:S.trackInfoList)==null?void 0:m[0])==null?void 0:b.trackId)||""}catch(S){throw O.fromRtsError(S)}})}publishReplace(e,t,i){return T(this,null,function*(){var c,o;yield this.dcConnectingPromise;const{vMsid:r,aMsid:n}=i!=null?i:{};try{const d=yield this.rts.publishReplaceTracks([{url:e,stream:t,vMsid:r,aMsid:n}]),[h]=d;return this.updatePublishingTracks(h.trackInfoList),((o=(c=h==null?void 0:h.trackInfoList)==null?void 0:c[0])==null?void 0:o.trackId)||""}catch(d){throw O.fromRtsError(d)}})}publishStop(e){return T(this,null,function*(){return yield this.rts.publishStop([{url:e}]),this._publishingTracks=[],""})}publishAddDataChannel(e){return T(this,null,function*(){yield this.dcConnectingPromise;const t=yield this.rts.publishAddDatachannel({signalUrl:e,url:e,label:M.Data,msid:M.Data}),i=t==null?void 0:t.datachannel;if(i&&i.send){const r=new ArrayBuffer(4);new DataView(r).setUint8(0,240),i.datachannel.send(r)}return i})}publishStopDataChannel(e,t){return T(this,null,function*(){return yield this.rts.publishStopDatachannel({url:e,datachannel:t})})}unpublish(){return T(this,null,function*(){yield this.rts.unpublish(),this._publishingTracks=[],this.connecting=!1,this.connected=!1})}getSubConfig(e,t){let i=t!=null?t:{};t||(i={audio:!0,video:!0,screen:!0});const r={};return i.audio&&(r.aMsid=[(e==null?void 0:e.getAudioInfo().msid)||M.Audio]),i.video?i.vMsid?r.vMsid=[i.vMsid]:r.vMsid=e!=null&&e.hasVideoLarge?[(e==null?void 0:e.getVideoLargeInfo().msid)||M.VideoLarge]:e!=null&&e.hasVideoSmall?[(e==null?void 0:e.getVideoSmallInfo().msid)||M.VideoSmall]:[M.VideoLarge]:i.screen&&(r.vMsid=[(e==null?void 0:e.getScreenInfo().msid)||M.Screen]),r}httpSubscribe(e){return T(this,null,function*(){var c,o,d,h,l,p;const{remoteUser:t,options:i}=e;let r=t.streamUrl;i.video||i.screen?i!=null&&i.audio||(r+="@subaudio=no"):r+="@subvideo=no";const n=this.getSubConfig(t.streamInfo,i);if(this.encodedInsertableStreams&&(n.encodedInsertableStreams=!0),(o=(c=this.parameter)==null?void 0:c.net)!=null&&o.useTCP&&(n.tcpOnly=!0),(h=(d=this.parameter)==null?void 0:d.net)==null?void 0:h.mediaTimeout){const u=(p=(l=this.parameter)==null?void 0:l.net)==null?void 0:p.mediaTimeout;u>1e3&&u<1e5&&(n.mediaTimeout=u)}n.retryTimes=17,n.retryInterval=5e3,this._rtsPeerConnectionType="subscribe";try{this.startConnect();const u=yield this.rts.subscribe(Ja(r),n);return this._pcTraceId=u.traceId,this.setConnected(!0),{traceId:u.traceId,stream:u}}catch(u){throw this.setConnected(!1),this.emit("disconnected"),O.fromRtsError(u)}})}subscribeAdd(e){return T(this,null,function*(){var n,c,o,d;const{remoteUser:t,options:i}=e,r=kt(X({url:t.streamUrl,subAudio:!!i.audio,subVideo:!(!i.screen&&!i.video)},this.getSubConfig(t.streamInfo,i)),{targetStream:i.screen?t.getScreenStream:t.getCameraStream});yield this.dcConnectingPromise;try{return(yield $a(h=>T(this,null,function*(){return yield this.dcConnectingPromise,h>0&&V.event(`[${Fe.logName}]`,`subscribeAdd retry times: ${h}`),this.isConnected?this.rts.subscribeAdd([r]):Promise.reject()}),5,0,h=>(h==null?void 0:h.errorCode)===15006))[0]}catch(h){if(((d=(o=(c=(n=h==null?void 0:h.extraInfo)==null?void 0:n.parsedData)==null?void 0:c.streams)==null?void 0:o[0])==null?void 0:d.res_code)===508)return this.emit("subscribeexceeds"),null;throw O.fromRtsError(h)}})}subscribeDelete(e){return T(this,null,function*(){var n,c,o,d;const{remoteUser:t,options:i}=e,r=kt(X({url:t.streamUrl,subAudio:!!i.audio,subVideo:!(!i.screen&&!i.video)},this.getSubConfig(t.streamInfo,i)),{targetStream:i.screen?t.getScreenStream:t.getCameraStream});yield this.dcConnectingPromise;try{return(yield this.rts.subscribeDeleteTracks([r]))[0]}catch(h){if(((d=(o=(c=(n=h==null?void 0:h.extraInfo)==null?void 0:n.parsedData)==null?void 0:c.streams)==null?void 0:o[0])==null?void 0:d.res_code)===404)return;throw O.fromRtsError(h)}})}subscibeStop(e){return T(this,null,function*(){var t,i,r,n;try{yield this.rts.subscribeStop([{url:e}])}catch(c){if(((n=(r=(i=(t=c==null?void 0:c.extraInfo)==null?void 0:t.parsedData)==null?void 0:i.streams)==null?void 0:r[0])==null?void 0:n.res_code)===404)return;throw O.fromRtsError(c)}})}subscribeAddDataChannel(e){return T(this,null,function*(){yield this.dcConnectingPromise;const t=yield this.rts.subscribeAddDatachannel({signalUrl:e,url:e,label:M.Data,msid:M.Data}),i=t==null?void 0:t.datachannel;if(i&&i.send){const r=new ArrayBuffer(4);new DataView(r).setUint8(0,240),i.send(r)}return i})}subscribeStopDatachannel(e,t){return T(this,null,function*(){let i;try{i=yield this.rts.subscribeStopDatachannel({url:e,datachannel:t})}catch(r){}return t==null||t.dispose(),i})}publish(n,c){return T(this,arguments,function*(e,t,i=!1,r=bt.MANUAL){let o,d="";if(this.connecting&&(yield this.connectingPromise),this.connected){yield this.dcConnectingPromise;let h,l=!1;const{audio:p,video:u,videoSmall:g,screen:m}=this.localStreamManager.publishStreams;p&&(d=yield this.publishAdd(e,p,t,{aMsid:M.Audio},i),l=!0,h=M.Audio,yield Lt(100)),u&&(d=yield this.publishAdd(e,u,t,{vMsid:M.VideoLarge},i),l=!1,h=M.VideoLarge,yield Lt(100)),g&&(d=yield this.publishAdd(e,g,t,{vMsid:M.VideoSmall},i),l=!1,h=M.VideoSmall,yield Lt(100)),m&&(d=yield this.publishAdd(e,m,t,{isScreen:!0,vMsid:M.Screen},i),l=!1,h=M.Screen),h&&(yield this.waitPublishSender(e,l,h))}else{const h=yield this.httpPublish(e,t,i,r);d=h.traceId,o=h.l1ip}return{traceId:d,l1ip:o}})}reportSubscribeLatency(e,t,i,r){const n=[];e.audio&&n.push(e.aMsid||M.Audio),e.video?n.push(e.vMsid||M.VideoLarge):e.screen&&n.push(M.Screen),n.forEach(c=>{this.slsReporter.reportConnectionLatencyEvent(ot.HANDLE_SUB_TASK,lt.START,t,c,i,0,r),this.slsReporter.reportConnectionLatencyEvent(ot.HANDLE_SUB_TASK,lt.END,t,c,Date.now(),0,r)})}subscribe(e,t,i,r,n){return T(this,null,function*(){let c=!1;const{options:o,remoteUser:d}=e;if(o.video&&o.screen)throw new O(H.ERR_INNER,"subscribe error, video and screen cannot be subscribed at the same time");let h;this.connecting&&(yield this.connectingPromise);let l=Date.now();this.connected?h=yield this.subscribeAdd(e):(c=!0,h=yield this.httpSubscribe(e)),this.reportSubscribeLatency(o,i,l,c);const p=Date.now();let u=M.VideoLarge,g=o.video||o.screen,m=o.audio;o.video&&o.vMsid?u=o.vMsid:o.screen&&(u=M.Screen);let b=0,S=0,v=0;const _=((w,y)=>{let R=0;const A=()=>{let E;return m&&!b&&(E=this.rts.getSubscribeAudioStats(d.streamUrl).then(I=>{if(I.packetsReceived>0)b=Date.now();else if(!g)return R<w&&(R++,new Promise(k=>setTimeout(()=>k(A()),y)));return!0})),g&&!v&&(E=this.rts.getSubscribeVideoStats(d.streamUrl,u).then(I=>(I.packetsReceived>0&&(S=Date.now()),I.framesDecoded>0?(v=Date.now(),!0):R<w?(R++,new Promise(k=>setTimeout(()=>k(A()),y))):(V.event(`[${Fe.logName}]`,d.userId,"尝试获取首帧数据失败"),!1)))),Promise.resolve(E)};return A()})(40,100);return _.then(()=>{S&&this.slsReporter.reportSubscribeFirstPacket(t===Se.Resume,i,r,u,{fprt:S-l,ifsprtc:v?v-l:0,ajsub:t===Se.Join?1:0,pctid:this.pcTraceId,subtid:(h==null?void 0:h.traceId)||"",sstc:p-l}),v&&this.slsReporter.reportSubscribeFirstFrame(t===Se.Resume,i,r,u,{fvfrt:v-l,fp2fftc:v-S,ajsub:t===Se.Join?1:0,tffrtc:t===Se.Join?v-this.localJoinTime:v-n,pctid:this.pcTraceId,subtid:(h==null?void 0:h.traceId)||"",fvfdtc:v-l}),b&&(this.slsReporter.reportConnectionLatencyEvent(ot.FIRST_REMOTE,lt.DECODED,i,M.Audio,b),this.slsReporter.reportSubscribeFirstPacket(t===Se.Resume,i,r,M.Audio,{fprt:b-l,ifsprtc:b-l,ajsub:t===Se.Join?1:0,pctid:this.pcTraceId,subtid:(h==null?void 0:h.traceId)||"",sstc:p-l}))}),c&&(yield Promise.race([_,Lt(1500)])),h})}getSubscribeVideoStats(e,t){return T(this,null,function*(){return yield this.rts.getSubscribeVideoStats(e,t)})}getSubscribeAudioStats(e,t){return T(this,null,function*(){return yield this.rts.getSubscribeAudioStats(e,t)})}getStreamByMsid(e){return this.rts.commonController.streamManager.getStreamByMsid(e)}getDatachannelByMsid(e){return this.rts.commonController.streamManager.getDatachannelByMsid(e)}getPCStats(){return T(this,null,function*(){var e,t;return(t=(e=this.rts.commonController.peerCore)==null?void 0:e.pc)==null?void 0:t.getStats()})}sendSEI(e,t,i,r){return T(this,null,function*(){return this.rts.sendSEI({url:e,vMsid:M.VideoLarge,data:t,repeatCount:i,payloadType:r})})}},f(Fe,"logName","RtsManager"),Fe);Be([C(U)],xe.prototype,"startConnect",1),Be([C()],xe.prototype,"updatePublishingTracks",1),Be([C(U,U)],xe.prototype,"httpPublish",1),Be([C(U,U)],xe.prototype,"waitPublishSender",1),Be([C(([s,a,e])=>[s,JSON.stringify(e)],U)],xe.prototype,"publishAdd",1),Be([C(U,U)],xe.prototype,"publishDelete",1),Be([C(([s,a,e])=>[s,JSON.stringify(e)])],xe.prototype,"publishReplace",1),Be([C(U)],xe.prototype,"publishStop",1),Be([C(U)],xe.prototype,"publishAddDataChannel",1),Be([C(U)],xe.prototype,"publishStopDataChannel",1),Be([C()],xe.prototype,"unpublish",1),Be([C(ji,({traceId:s})=>s)],xe.prototype,"httpSubscribe",1),Be([C(ji,({traceId:s})=>s)],xe.prototype,"subscribeAdd",1),Be([C(ji)],xe.prototype,"subscribeDelete",1),Be([C(U)],xe.prototype,"subscibeStop",1),Be([C(U)],xe.prototype,"subscribeAddDataChannel",1),Be([C(U)],xe.prototype,"subscribeStopDatachannel",1),Be([C(U)],xe.prototype,"publish",1),Be([C(ji)],xe.prototype,"subscribe",1),Be([C()],xe.prototype,"sendSEI",1);let nc=xe;class Vr{constructor(a=Mr){f(this,"defaultProfile");f(this,"profile");f(this,"profileMap",new Map);f(this,"audioProfile");f(this,"contentHint");this.defaultProfile=X({},a)}updateProfile(a,e){this.profileMap.set(a,X(X(X({},this.defaultProfile),this.profileMap.get(a)||{}),e||{})),this.profile=a}get videoProfile(){return this.profile}updateAudioProfile(a){this.audioProfile=a}setContentHint(a,e){e&&(this.contentHint=e),this.contentHint&&a&&(a.contentHint=this.contentHint)}setVideoProfile(a,e,t=!1){return T(this,null,function*(){if(!this.profile)return;const i=this.profileMap.get(this.profile)||(e==null?void 0:e.VideoProfileMap.get(this.profile));if(i){if(!t&&a&&a.readyState==="live"&&a.applyConstraints)try{yield a.applyConstraints(i)}catch(r){}if(e){const r=X({},i);i.maxSendFrameRate&&(r.frameRate=i.maxSendFrameRate),e==null||e.VideoProfileMap.set(this.profile,r),yield e.setVideoProfile(this.profile)}}})}}class Or extends se{constructor(e){super();f(this,"type");f(this,"originVideoTrack");f(this,"videoSource");f(this,"_videoMuted",!1);f(this,"originAudioTrack");f(this,"audioSource");f(this,"_audioMuted",!1);f(this,"_targetVideoTrack");f(this,"_targetDualVideoTrack");f(this,"_targetAudioTrack");f(this,"_publishVideoStream");f(this,"_publishDualVideoStream");f(this,"_publishAudioStream");f(this,"_previewStream");f(this,"plugins",[]);f(this,"_profileManager");f(this,"cameraVideoConstraints");f(this,"micAudioConstraints");f(this,"onVideoTrackEnded",()=>{this.emit("videotrackended")});f(this,"onAudioTrackEnded",()=>{this.emit("audiotrackended")});this.type=e}get profileManager(){return this._profileManager}get audioProfile(){var e;return(e=this.profileManager)==null?void 0:e.audioProfile}updateSource(e,t,i){return T(this,null,function*(){var c,o,d,h,l,p;const{videoTrack:r,audioTrack:n}=e;r&&((c=this.originVideoTrack)==null||c.removeEventListener("ended",this.onVideoTrackEnded)),n&&((o=this.originAudioTrack)==null||o.removeEventListener("ended",this.onAudioTrackEnded)),this.type===Ne.AliRtcSdkStreamTypeScreen?this.stop():(r&&((d=this.originVideoTrack)==null||d.stop()),n&&((h=this.originAudioTrack)==null||h.stop())),r&&(this.originVideoTrack=r,(l=this.originVideoTrack)==null||l.addEventListener("ended",this.onVideoTrackEnded),this.videoSource=t||ei.Camera,this.updateVideoTrack(r)),n&&(this.originAudioTrack=n,(p=this.originAudioTrack)==null||p.addEventListener("ended",this.onAudioTrackEnded),this.audioSource=i||Ei.Microphone,this.updateAudioTrack(n))})}get currentProfile(){var e;return(e=this.profileManager)==null?void 0:e.profile}get currentVideoTrack(){return this._targetVideoTrack}get currentDualVideoTrack(){return this._targetDualVideoTrack}get publishVideoStream(){return this._publishVideoStream}get publishDualVideoStream(){return this._publishDualVideoStream}get currentAudioTrack(){return this._targetAudioTrack}get publishAudioStream(){return this._publishAudioStream}get previewStream(){return this._previewStream}updateVideoTrack(e,t=!1){return T(this,null,function*(){(this._targetVideoTrack!==e||t)&&(this._targetVideoTrack=e)})}updateDualVideoTrack(e,t=!1){return T(this,null,function*(){(this._targetDualVideoTrack!==e||t)&&(this._targetDualVideoTrack=e)})}updateAudioTrack(e,t=!1){return T(this,null,function*(){(this._targetAudioTrack!==e||t)&&(this._targetAudioTrack=e)})}setAudioMuted(e){var t,i;this._audioMuted=e,e?(t=this.publishAudioStream)==null||t.disableAudio():(i=this.publishAudioStream)==null||i.enableAudio()}get isAudioMuted(){return this._audioMuted}setVideoMuted(e){var t,i;this._videoMuted=e,e?(t=this.publishVideoStream)==null||t.disableVideo():(i=this.publishVideoStream)==null||i.enableVideo()}get isVideoMuted(){return this._videoMuted}process(e){return T(this,null,function*(){var t,i,r,n,c,o,d,h,l,p,u,g;this._targetAudioTrack=this.originAudioTrack,this._targetVideoTrack=this.originVideoTrack;for(const m of this.plugins)try{yield m.execute(this,e)}catch(b){console.error(`error in plugin-${m.name}, error: ${b}`)}this._targetVideoTrack?((i=(t=this._publishVideoStream)==null?void 0:t.videoTrack)==null?void 0:i.id)!==this._targetVideoTrack.id&&(this._publishVideoStream=yield yi(this._targetVideoTrack),this.setVideoMuted(this._videoMuted),(r=this.profileManager)==null||r.setVideoProfile(this.originVideoTrack,this._publishVideoStream,!0),(n=this.profileManager)==null||n.setContentHint(this._targetVideoTrack),this.previewStream?(c=this.previewStream)==null||c.mergeStream(this._publishVideoStream):this._previewStream=yield yi(this._targetVideoTrack)):(this._publishVideoStream=void 0,(o=this.previewStream)==null||o.deleteTracks({video:!0})),this._targetDualVideoTrack?((h=(d=this._publishDualVideoStream)==null?void 0:d.videoTrack)==null?void 0:h.id)!==this._targetDualVideoTrack.id&&(this._publishDualVideoStream=yield yi(this._targetDualVideoTrack),this._videoMuted?this._publishDualVideoStream.disableVideo():this._publishDualVideoStream.enableVideo()):this._publishDualVideoStream=void 0,this._targetAudioTrack?((p=(l=this._publishAudioStream)==null?void 0:l.audioTrack)==null?void 0:p.id)!==this._targetAudioTrack.id&&(this._publishAudioStream=yield yi(this._targetAudioTrack),this.setAudioMuted(this._audioMuted),this.previewStream?(u=this.previewStream)==null||u.mergeStream(this._publishAudioStream):this._previewStream=yield yi(this._targetAudioTrack)):(this._publishAudioStream=void 0,(g=this.previewStream)==null||g.deleteTracks({audio:!0}))})}stopVideo(){var e,t;this.originVideoTrack&&((e=this.originVideoTrack)==null||e.removeEventListener("ended",this.onAudioTrackEnded),(t=this.originVideoTrack)==null||t.stop(),this.originVideoTrack=void 0),this.updateVideoTrack(void 0)}stopAudio(){var e,t;this.originAudioTrack&&((e=this.originAudioTrack)==null||e.removeEventListener("ended",this.onAudioTrackEnded),(t=this.originAudioTrack)==null||t.stop(),this.originAudioTrack=void 0),this.updateAudioTrack(void 0)}stop(){this.stopVideo(),this.stopAudio()}updateVideoProfile(e,t,i=!1){return T(this,null,function*(){this._profileManager||(this._profileManager=new Vr(this.type===Ne.AliRtcSdkStreamTypeScreen?Wa:Mr)),e&&this._profileManager.updateProfile(e,t),yield this._profileManager.setVideoProfile(this.originVideoTrack,this._publishVideoStream,i||this.type===Ne.AliRtcSdkStreamTypeScreen)})}get videoProfile(){var e;return(e=this.profileManager)==null?void 0:e.videoProfile}setVideoContentHint(e){this._profileManager||(this._profileManager=new Vr(this.type===Ne.AliRtcSdkStreamTypeScreen?Wa:Mr)),this._profileManager.setContentHint(this.currentVideoTrack,e)}updateAudioProfile(e){return T(this,null,function*(){this._profileManager||(this._profileManager=new Vr),this._profileManager.updateAudioProfile(e)})}cloneVideoProfile(e){return T(this,null,function*(){var t;yield(t=this.profileManager)==null?void 0:t.setVideoProfile(void 0,e)})}addPlugin(e){const t=this.plugins.findIndex(i=>i.zIndex>e.zIndex);t>-1?this.plugins.splice(t,0,e):this.plugins.push(e)}removePlugin(e){const t=this.plugins.indexOf(e);return t>-1&&(e.clear(this),this.plugins.splice(t,1),!0)}}var oc=Object.defineProperty,cc=Object.getOwnPropertyDescriptor,gt=(s,a,e,t)=>{for(var i,r=t>1?void 0:t?cc(a,e):a,n=s.length-1;n>=0;n--)(i=s[n])&&(r=(t?i(a,e,r):i(r))||r);return t&&r&&oc(a,e,r),r};const ut=(Bt=class extends se{constructor(e,t){super();f(this,"pluginManager");f(this,"slsReporter");f(this,"publishingCameraVideoStream");f(this,"publishingScreenVideoStream");f(this,"cameraStreamInfo",new Or(Ne.AliRtcSdkStreamTypeCapture));f(this,"screenStreamInfo",new Or(Ne.AliRtcSdkStreamTypeScreen));f(this,"streamInfos",[this.cameraStreamInfo,this.screenStreamInfo]);f(this,"_audioCaptureDisabled",!1);f(this,"_cameraCaptureDisabled",!1);f(this,"_publishLocalAudioStreamEnabled",!0);f(this,"_publishLocalVideoStreamEnabled",!0);f(this,"_publishLocalScreenStreamEnabled",!0);this.screenStreamInfo.setVideoContentHint("motion"),this.pluginManager=e,this.slsReporter=t,this.cameraStreamInfo.on("videotrackended",()=>T(this,null,function*(){yield this.stopLocalStream({video:!0}),this.emit("trackended",Jt.VideoTrackEnded)})),this.cameraStreamInfo.on("audiotrackended",()=>T(this,null,function*(){yield this.stopLocalStream({audio:!0}),this.emit("trackended",Jt.AudioTrackEnded)})),this.screenStreamInfo.on("videotrackended",()=>T(this,null,function*(){yield this.stopLocalStream({screen:!0}),this.emit("trackended",Jt.ScreenTrackEnded)})),this.pluginManager.on("added",i=>T(this,null,function*(){if(V.info(`[${Bt.logName}]`,"plugin added",i.name),!i.isSupported("7.0.2"))return console.warn(`${i.name} is not supported!!!`),void i.emit("unsupported");try{yield i.init()}catch(r){i.emit("error",O.fromError(r,Ot.AliRtcPluginErrorInitError))}i.streamType===Ne.AliRtcSdkStreamTypeCapture&&(this.cameraStreamInfo.addPlugin(i),yield this.cameraStreamInfo.process(this.streamInfos)),i.streamType===Ne.AliRtcSdkStreamTypeScreen&&(this.screenStreamInfo.addPlugin(i),yield this.screenStreamInfo.process(this.streamInfos)),this.emit("publishupdate")})),this.pluginManager.on("removed",i=>T(this,null,function*(){this.cameraStreamInfo.removePlugin(i)&&(yield this.cameraStreamInfo.process(this.streamInfos)),this.screenStreamInfo.removePlugin(i)&&(yield this.screenStreamInfo.process(this.streamInfos)),this.emit("publishupdate")})),this.pluginManager.on("updated",()=>T(this,null,function*(){yield this.updateStreams()}))}get hasCamera(){return!!this.cameraStreamInfo.originVideoTrack}get audioCaptureDisabled(){return this._audioCaptureDisabled}set audioCaptureDisabled(e){this._audioCaptureDisabled=e}get cameraCaptureDisabled(){return this._cameraCaptureDisabled}set cameraCaptureDisabled(e){this._cameraCaptureDisabled=e}setAudioMuted(e){this.cameraStreamInfo.setAudioMuted(e)}get isAudioMuted(){return this.cameraStreamInfo.isAudioMuted}setCameraMuted(e){this.cameraStreamInfo.setVideoMuted(e)}get isCameraMuted(){return this.cameraStreamInfo.isVideoMuted}setScreenMuted(e){this.screenStreamInfo.setVideoMuted(e)}get isScreenMuted(){return this.screenStreamInfo.isVideoMuted}get publishLocalAudioStreamEnabled(){return this._publishLocalAudioStreamEnabled}set publishLocalAudioStreamEnabled(e){this._publishLocalAudioStreamEnabled=e}get publishLocalVideoStreamEnabled(){return this._publishLocalVideoStreamEnabled}set publishLocalVideoStreamEnabled(e){this._publishLocalVideoStreamEnabled=e}get publishLocalScreenStreamEnabled(){return this._publishLocalScreenStreamEnabled}set publishLocalScreenStreamEnabled(e){this._publishLocalScreenStreamEnabled=e}updateStreams(){return T(this,null,function*(){yield this.cameraStreamInfo.process(this.streamInfos),yield this.screenStreamInfo.process(this.streamInfos),this.emit("publishupdate")})}setAvailableCameraDeviceId(){return T(this,null,function*(){var e,t,i,r;if((e=this.cameraStreamInfo.cameraVideoConstraints)!=null&&e.deviceId){let n=(t=this.cameraStreamInfo.cameraVideoConstraints)==null?void 0:t.deviceId;const c=yield q.AliRTS.getCameraList();c.find(o=>o.deviceId===n)||(n=(r=(i=c.find(o=>!!o.deviceId))==null?void 0:i.deviceId)!=null?r:""),this.cameraStreamInfo.cameraVideoConstraints.deviceId=n}})}setAvailableMicrophoneDeviceId(){return T(this,null,function*(){var e,t,i,r;if((e=this.cameraStreamInfo.micAudioConstraints)!=null&&e.deviceId){let n=(t=this.cameraStreamInfo.micAudioConstraints)==null?void 0:t.deviceId;const c=yield q.AliRTS.getMicList();c.find(o=>o.deviceId===n)||(n=(r=(i=c.find(o=>!!o.deviceId))==null?void 0:i.deviceId)!=null?r:""),this.cameraStreamInfo.micAudioConstraints.deviceId=n}})}createLocalStream(e){return T(this,null,function*(){var l;const{screen:t,mediaStream:i,videoProfile:r,screenProfile:n}=e;let{video:c,audio:o}=e;const d=(p=>{const{audio:u,video:g,screen:m}=p;if(g&&m)throw new O(H.ERR_INNER,"create stream error, cannot create video && screen together");return!!(g||u||m)})(e);let h;if(d){i||(c===!0&&this.cameraStreamInfo.cameraVideoConstraints?(yield this.setAvailableCameraDeviceId(),c=X({},this.cameraStreamInfo.cameraVideoConstraints)):typeof c=="object"&&(yield this.setAvailableCameraDeviceId(),c=X(X({},c),this.cameraStreamInfo.cameraVideoConstraints)),o===void 0&&this.audioCaptureDisabled?o=!1:o&&(o===!0&&this.cameraStreamInfo.micAudioConstraints?(yield this.setAvailableMicrophoneDeviceId(),o=X({},this.cameraStreamInfo.micAudioConstraints)):typeof o=="object"&&(yield this.setAvailableMicrophoneDeviceId(),o=X(X({},o),this.cameraStreamInfo.micAudioConstraints)),this._audioCaptureDisabled=!1));const p=Date.now();try{h=yield q.AliRTS.createStream({audio:o,video:c,screen:t,custom:!!i,mediaStream:i,skipProfile:!0}),V.info(`[${Bt.logName}]`,"createLocalStream",{audio:o,video:c,screen:t,custom:!!i,time:Date.now()-p}),o&&!i&&this.slsReporter.reportAudio(null,Date.now()-p,((l=h==null?void 0:h.audioTrack)==null?void 0:l.label)||""),t&&!i&&this.slsReporter.reportScreen(null,Date.now()-p)}catch(u){throw o&&!i&&this.slsReporter.reportAudio(u,Date.now()-p,""),t&&!i&&this.slsReporter.reportScreen(null,Date.now()-p),u}if(t)yield this.screenStreamInfo.updateSource(h,ei.Screen,Ei.Screen),yield this.setScreenProfile(n||za),this.setScreenContentHint(),this.publishingScreenVideoStream=void 0;else if(yield this.cameraStreamInfo.updateSource(h,ei.Camera,Ei.Microphone),h.hasVideo&&(yield this.setVideoProfile(r||ja),this.setVideoContentHint(),this.publishingCameraVideoStream=void 0),h.hasAudio&&typeof o=="boolean"){const u=this.cameraStreamInfo.audioProfile;u&&(yield h.setAudioProfile(u))}}return q.AliRTS.SystenUtil.isIos&&q.AliRTS.SystenUtil.compareVersion("15.1")&&!q.AliRTS.SystenUtil.compareVersion("15.2")&&(yield Lt(1e3)),yield this.updateStreams(),h})}stopLocalStream(e){return T(this,null,function*(){const{screen:t,video:i,audio:r}=e!=null?e:{};let n=!1;i&&this.cameraStreamInfo.originVideoTrack&&(n=!0,this.cameraStreamInfo.stopVideo(),this.publishingCameraVideoStream=void 0),r&&this.cameraStreamInfo.originAudioTrack&&(n=!0,this.cameraStreamInfo.stopAudio()),t&&this.screenStreamInfo.originVideoTrack&&(n=!0,this.screenStreamInfo.stop(),this.publishingScreenVideoStream=void 0,this.slsReporter.reportScreenStop(null)),n&&(yield this.updateStreams())})}get publishStreams(){const{publishLocalVideoStreamEnabled:e,publishLocalAudioStreamEnabled:t,publishLocalScreenStreamEnabled:i}=this;return{video:e?this.cameraStreamInfo.publishVideoStream:void 0,videoSmall:e?this.cameraStreamInfo.publishDualVideoStream:void 0,audio:t?this.cameraStreamInfo.publishAudioStream:void 0,screen:i?this.screenStreamInfo.publishVideoStream:void 0}}createHTTPPublishStream(){return T(this,null,function*(){var o,d,h,l;let e,t,i,r,n=!1;const c=this.publishStreams;try{if(!(c.audio||c.video||c.videoSmall||c.screen))throw V.error(`[${Bt.logName}]`,"no tracks founded"),new O(H.ERR_SDK_PUBLISH_INVAILD,"no tracks founded");const p=new MediaStream;(o=c.audio)!=null&&o.audioTrack&&p.addTrack(c.audio.audioTrack),(d=c.video)!=null&&d.videoTrack?(p.addTrack(c.video.videoTrack),i=c.videoSmall,r=c.screen):(h=c.screen)!=null&&h.videoTrack&&(t=M.Screen,p.addTrack((l=c.screen)==null?void 0:l.videoTrack),n=!0),e=yield Xa(p),n?(this.screenStreamInfo.cloneVideoProfile(e),this.publishingScreenVideoStream=e):(this.cameraStreamInfo.cloneVideoProfile(e),this.publishingCameraVideoStream=e)}catch(p){}return{publishStream:e,videoSmallStream:i,screenStream:r,vMsid:t}})}stop(){this.cameraStreamInfo.stop(),this.screenStreamInfo.stop(),this.updateStreams()}setVideoProfile(e,t,i=!1){return T(this,null,function*(){yield this.cameraStreamInfo.updateVideoProfile(e,t,i),this.publishingCameraVideoStream&&this.cameraStreamInfo.cloneVideoProfile(this.publishingCameraVideoStream)})}setVideoContentHint(e){this.cameraStreamInfo.setVideoContentHint(e)}setAudioProfile(e){return T(this,null,function*(){var t;yield this.cameraStreamInfo.updateAudioProfile(e),yield(t=this.publishingCameraVideoStream)==null?void 0:t.setAudioProfile(e)})}setScreenProfile(e,t){return T(this,null,function*(){yield this.screenStreamInfo.updateVideoProfile(e,t),this.publishingScreenVideoStream&&this.screenStreamInfo.cloneVideoProfile(this.publishingScreenVideoStream)})}setScreenContentHint(e){this.screenStreamInfo.setVideoContentHint(e)}setCameraVideoConstraints(e){var t;this.cameraStreamInfo.cameraVideoConstraints=X(X({},(t=this.cameraStreamInfo.cameraVideoConstraints)!=null?t:{}),e)}setMicAudioConstraints(e){var t;this.cameraStreamInfo.micAudioConstraints=X(X({},(t=this.cameraStreamInfo.micAudioConstraints)!=null?t:{}),e)}},f(Bt,"logName","LocalStreamManager"),Bt);gt([C(([s])=>{const{audio:a,video:e,screen:t,custom:i,skipProfile:r,videoProfile:n,screenProfile:c}=s;return[{audio:a,video:e,screen:t,custom:i,skipProfile:r,videoProfile:n,screenProfile:c}]})],ut.prototype,"createLocalStream",1),gt([C(U)],ut.prototype,"stopLocalStream",1),gt([C()],ut.prototype,"createHTTPPublishStream",1),gt([C()],ut.prototype,"stop",1),gt([C(U)],ut.prototype,"setVideoProfile",1),gt([C(U)],ut.prototype,"setVideoContentHint",1),gt([C(U)],ut.prototype,"setAudioProfile",1),gt([C(U)],ut.prototype,"setScreenProfile",1),gt([C(U)],ut.prototype,"setScreenContentHint",1),gt([C(U)],ut.prototype,"setCameraVideoConstraints",1),gt([C(U)],ut.prototype,"setMicAudioConstraints",1);let dc=ut;class hc extends Mt{constructor(){super("AliRtcScreenStandardize",Ne.AliRtcSdkStreamTypeScreen);f(this,"canvas");f(this,"lastWidth");f(this,"lastHeight");f(this,"hasScreenTrack",!1)}get initOptions(){return{base:4}}setOptions(e){this.options=e}isSupported(){return!(typeof TransformStream=="undefined"||typeof MediaStreamTrackProcessor=="undefined"||typeof MediaStreamTrackGenerator=="undefined")}updateProcessCanvas(e,t){if(this.canvas&&this.lastWidth===e&&this.lastHeight===t)return;const i=Math.ceil(e/this.options.base)*this.options.base,r=Math.ceil(t/this.options.base)*this.options.base;if(this.canvas||(this.canvas=document.createElement("canvas")),this.canvas.width=i,this.canvas.height=r,this.lastWidth&&e>this.lastWidth||this.lastHeight&&t>this.lastHeight){const n=this.canvas.getContext("2d");n&&n.clearRect(0,0,i,r)}this.lastWidth=e,this.lastHeight=t}shouldUpdate(e){return this.hasScreenTrack!==(!!e.originVideoTrack&&e.videoSource===ei.Screen)}handleFrame(e,t){return T(this,null,function*(){var c;const{displayWidth:i,displayHeight:r}=e;if(!i||!r||i%this.options.base===0&&r%this.options.base===0)return this.clear(t),e;this.updateProcessCanvas(i,r);const n=(c=this.canvas)==null?void 0:c.getContext("2d");if(this.canvas&&n){n.drawImage(e,0,0,i,r);const o=new VideoFrame(this.canvas,{timestamp:e.timestamp});return e.close(),o}return e})}process(e){return T(this,null,function*(){var h;if(!e.originVideoTrack||e.videoSource!==ei.Screen)return this.clear(e),void(this.hasScreenTrack=!1);const t=new MediaStreamTrackProcessor({track:e.originVideoTrack}),i=new MediaStreamTrackGenerator({kind:"video"}),r=new MediaStream([i]),n=this,c=new TransformStream({transform(l,p){return T(this,null,function*(){const u=yield n.handleFrame(l,e);yield p.enqueue(u),u==null||u.close()})}});t.readable.pipeThrough(c).pipeTo(i.writable);const o=(h=r.getVideoTracks())==null?void 0:h[0];e.updateVideoTrack(o),this.hasScreenTrack=!0})}clear(e){this.canvas=void 0,this.lastWidth=void 0,this.lastHeight=void 0,super.clear(e)}}class lc extends Mt{constructor(){super("blankAudio",Ne.AliRtcSdkStreamTypeCapture,ti.BOTH);f(this,"hasTrack",!1);f(this,"oscillator",null);f(this,"audioTrack",null);f(this,"createAudioTrack",()=>{const e=new AudioContext;this.oscillator=e.createOscillator();const t=e.createGain();t.gain.value=0;const i=e.createMediaStreamDestination();this.oscillator.connect(t),t.connect(i),this.oscillator.start();const r=i.stream;return this.audioTrack=r.getAudioTracks()[0],this.audioTrack});this.zIndex=9}isSupported(){return!0}setOptions(){throw new Error("Method not implemented.")}shouldUpdate(e,t){return this.hasTrack!==t.some(i=>i.originVideoTrack||i.originAudioTrack)}process(e,t){return T(this,null,function*(){var r;const i=t.some(n=>n.originVideoTrack||n.originAudioTrack);this.hasTrack=i,i?this.audioTrack&&((r=this.oscillator)==null||r.stop(),this.oscillator=null,this.audioTrack.stop(),this.audioTrack=null):(this.audioTrack||(this.audioTrack=this.createAudioTrack()),e.updateAudioTrack(this.audioTrack))})}}class Za{constructor(a){f(this,"name","COMMON");this.name=a||this.name}info(...a){}warn(...a){}print(a,...e){const t=a.toLowerCase();t&&console[t](`[${a}][${this.name}]`,...e)}}f(Za,"LEVEL",0);class uc{constructor(){f(this,"logger",new Za("AudioMixer"));f(this,"audioContext",new AudioContext);f(this,"audioDestination",this.audioContext.createMediaStreamDestination());f(this,"audioTrack",(a=>a.getAudioTracks()[0])(this.audioDestination.stream));f(this,"sourceNodeMap",{})}get sourceNodeList(){return Object.values(this.sourceNodeMap).map(a=>a.sourceNode).filter(a=>!!a)}get gainNodeList(){return Object.values(this.sourceNodeMap).map(a=>a.gainNode).filter(a=>!!a)}get sourceCount(){return this.sourceNodeList.length}resume(){var a;return(a=this.audioContext)==null?void 0:a.resume()}addTrack(a){this.connectTrack(a)}hasTrack(a){return!!this.sourceNodeMap[a]}removeTrack(a){const{sourceNode:e,gainNode:t}=this.sourceNodeMap[a]||{};t==null||t.disconnect(),e==null||e.disconnect(),delete this.sourceNodeMap[a],e?this.logger.info("SourceNode disconnected. Active source node:",this.sourceNodeList.length):this.logger.warn(`SourceNode ${a} does not exit. Active source node: ${this.sourceNodeList.length}`)}getAudioTrack(){return this.audioTrack}setVolume(a,e){const{gainNode:t}=this.sourceNodeMap[e]||{};t?(this.logger.info(`Setting node(${e}) volume to ${this.scale(a)}`),t.gain.value=this.scale(a)):this.logger.warn(`GainNode ${e} does not exit.`)}reset(){this.disconnectSourceNode(),this.sourceNodeMap={}}dispose(){var a;this.reset(),(a=this.audioTrack)==null||a.stop(),this.audioDestination.disconnect(),this.audioContext.close()}connectTrack(a){if(!this.audioContext)return this.logger.warn("AudioContext not initialized");let e=new MediaStream;e.addTrack(a);const t=this.audioContext.createMediaStreamSource(e),i=this.audioContext.createGain();i.gain.value=1,t.connect(i),i.connect(this.audioDestination),this.sourceNodeMap[a.id]={track:a,sourceNode:t,gainNode:i},this.logger.info("New sourceNode connected. Active source node:",this.sourceNodeList.length)}disconnectSourceNode(){this.sourceNodeList.forEach(a=>a.disconnect()),this.gainNodeList.forEach(a=>a.disconnect())}scale(a){return a/100}}class pc extends Mt{constructor(){super("audioMixer",Ne.AliRtcSdkStreamTypeCapture,ti.AUDIO);f(this,"audioMixer");f(this,"primaryAudioTrackId");f(this,"screenAudioTrackId");f(this,"dirty",!1);this.zIndex=8}get initOptions(){return{audio:1,screen:1}}setOptions(e){Object.entries(e).forEach(([t,i])=>{this.isValidVolume(i)&&(this.options[t]=i)}),this.dirty=!0,this.emit("updated")}isSupported(){return"AudioContext"in window}shouldUpdate(e,t){var n,c;if(e.type!==Ne.AliRtcSdkStreamTypeCapture)return!1;const i=t.find(o=>o.type===Ne.AliRtcSdkStreamTypeCapture),r=t.find(o=>o.type===Ne.AliRtcSdkStreamTypeScreen);return!(this.primaryAudioTrackId===((n=i==null?void 0:i.currentAudioTrack)==null?void 0:n.id)&&this.screenAudioTrackId===((c=r==null?void 0:r.currentAudioTrack)==null?void 0:c.id)&&!this.dirty)}process(e,t){return T(this,null,function*(){var c,o;this.dirty=!1;const i=t.find(d=>d.type===Ne.AliRtcSdkStreamTypeScreen),r=e.currentAudioTrack,n=i==null?void 0:i.currentAudioTrack;if(!n&&this.options.audio===1)return this.audioMixer&&(this.audioMixer.dispose(),this.audioMixer=void 0),this.primaryAudioTrackId=r==null?void 0:r.id,void e.updateAudioTrack(r);this.audioMixer||(this.audioMixer=new uc),yield this.audioMixer.resume(),this.primaryAudioTrackId&&(r==null?void 0:r.id)!==this.primaryAudioTrackId&&((c=this.audioMixer)==null||c.removeTrack(this.primaryAudioTrackId)),r&&!this.audioMixer.hasTrack(r==null?void 0:r.id)&&this.audioMixer.addTrack(r),this.primaryAudioTrackId=r==null?void 0:r.id,this.screenAudioTrackId&&(n==null?void 0:n.id)!==this.screenAudioTrackId&&((o=this.audioMixer)==null||o.removeTrack(this.screenAudioTrackId)),n&&!this.audioMixer.hasTrack(n==null?void 0:n.id)&&this.audioMixer.addTrack(n),this.screenAudioTrackId=n==null?void 0:n.id,this.updateVolume(),e.updateAudioTrack(this.audioMixer.getAudioTrack())})}isValidVolume(e){return e!==void 0&&e>=0&&e<=4}updateVolume(){this.audioMixer&&(this.primaryAudioTrackId&&this.audioMixer.setVolume(100*this.options.audio,this.primaryAudioTrackId),this.screenAudioTrackId&&this.audioMixer.setVolume(100*this.options.screen,this.screenAudioTrackId))}clear(e){var t;(t=this.audioMixer)==null||t.dispose(),super.clear(e)}}class Ur{constructor(a,e){f(this,"originTrack");f(this,"originVideo");f(this,"targetWidth");f(this,"targetHeight");f(this,"targetFrameRate");f(this,"targetCanvas");f(this,"animationFrameId");f(this,"resultTrack");this.targetWidth=e.width,this.targetHeight=e.height,this.targetFrameRate=e.frameRate,this.originTrack=a,this.originVideo=document.createElement("video"),this.originVideo.muted=!0,this.originVideo.autoplay=!0,this.originVideo.controls=!1,this.targetCanvas=document.createElement("canvas"),this.targetCanvas.width=this.targetWidth,this.targetCanvas.height=this.targetHeight}updateOptions(a){this.targetWidth=a.width,this.targetHeight=a.height,this.targetFrameRate=a.frameRate,this.targetCanvas.width=this.targetWidth,this.targetCanvas.height=this.targetHeight,this.resultTrack&&this.resultTrack.applyConstraints({frameRate:this.targetFrameRate})}dispose(){}getVideoTrack(){return this.resultTrack||(this.resultTrack=this.targetCanvas.captureStream().getVideoTracks()[0],this.resultTrack.applyConstraints({frameRate:this.targetFrameRate})),this.resultTrack}cancelAnimation(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}getPositionAndSize(a,e,t,i){const r=e/a,n=i/t;let c=t,o=i,d=0,h=0;return n>r?(c=Math.round(o/r),d=Math.round((t-c)/2)):n<r&&(o=Math.round(c*r),h=Math.round((i-o)/2)),{x:d,y:h,width:c,height:o}}}class mc extends Ur{constructor(e,t){super(e,t);f(this,"targetCtx");this.targetCtx=this.targetCanvas.getContext("2d"),this.startRender=this.startRender.bind(this),this.stopRender=this.startRender.bind(this),this.initStream(e)}initStream(e){const t=new MediaStream;t.addTrack(e),this.originVideo.srcObject=t,this.originVideo.play(),this.originVideo.addEventListener("canplay",this.startRender),this.originVideo.addEventListener("pause",this.stopRender),this.originVideo.addEventListener("ended",this.stopRender)}startRender(){this.cancelAnimation();const e=()=>{if(!this.targetCtx)return;const t=this.getPositionAndSize(this.originVideo.videoWidth,this.originVideo.videoHeight,this.targetWidth,this.targetHeight);this.targetCtx.drawImage(this.originVideo,0,0,this.originVideo.videoWidth,this.originVideo.videoHeight,t.x,t.y,t.width,t.height),this.originVideo.paused||this.originVideo.ended||(this.animationFrameId=requestAnimationFrame(e))};e()}stopRender(){this.cancelAnimation()}dispose(){this.stopRender(),this.originVideo.removeEventListener("play",this.startRender),this.originVideo.removeEventListener("pause",this.stopRender),this.originVideo.removeEventListener("ended",this.stopRender),this.originVideo.pause(),this.originVideo.srcObject=null}}function Qa(s,a,e){const t=s.createShader(a);if(t)return s.shaderSource(t,e),s.compileShader(t),s.getShaderParameter(t,s.COMPILE_STATUS)?t:(console.error(`An error occurred compiling the shaders: ${s.getShaderInfoLog(t)}`),s.deleteShader(t),null);console.error("create shader failed")}class en extends Ur{constructor(e,t){super(e,t);f(this,"targetCtx");f(this,"targetTexture");f(this,"locationMap");this.targetCtx=this.targetCanvas.getContext("webgl2"),this.locationMap={},this.startRender=this.startRender.bind(this),this.stopRender=this.startRender.bind(this),this.updateBuffer=this.updateBuffer.bind(this),this.initGL(),this.initStream(e)}static isSupport(){return function(){let e;try{const t=document.createElement("canvas");t.width=1,t.height=1;const i={alpha:!1,depth:!1,stencil:!1,antialias:!1,preferLowPowerToHighPerformance:!0};e=t.getContext("webgl2",i)}catch(t){return!1}return!!e}()}initGL(){const e=this.targetCtx;if(!e)return;this.targetTexture=function(o){const d=o.createTexture();return o.bindTexture(o.TEXTURE_2D,d),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),d}(e);const t=function(o,d,h){const l=Qa(o,o.VERTEX_SHADER,d),p=Qa(o,o.FRAGMENT_SHADER,h),u=o.createProgram();if(u&&l&&p)return o.attachShader(u,l),o.attachShader(u,p),o.linkProgram(u),o.getProgramParameter(u,o.LINK_STATUS)?u:(console.error(`Unable to initialize the shader program: ${o.getProgramInfoLog(u)}`),null)}(e,`
15
15
  attribute vec2 a_position;
16
16
  attribute vec2 a_texCoord;
17
17