aliyun-rtc-sdk 7.1.0-beta.1 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aliyun-rtc-sdk.es.js +3139 -2601
- package/dist/aliyun-rtc-sdk.umd.js +14 -14
- package/dist/plugins/audioProcessPlugin.d.ts +5504 -0
- package/dist/plugins/audioProcessPlugin.js +160 -0
- package/dist/plugins/beautyPlugin.d.ts +915 -5
- package/dist/plugins/beautyPlugin.js +1 -1
- package/dist/plugins/index-BGdMdvjC.js +1 -0
- package/dist/types/index.d.ts +23 -1
- package/package.json +3 -2
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
`).reduce(function(r,a){var c=a.split(": ");return r[c[0]]=c[1],r},{})}catch(r){i={}}return i},getQuerys:function(t){if(!t)return"";var i={},r=[],a="",c="";try{var n=[];if(t.indexOf("?")>=0&&(n=t.substring(t.indexOf("?")+1,t.length).split("&")),n.length>0)for(var h in n)a=(r=n[h].split("="))[0],c=r[1],i[a]=c}catch(d){i={}}return i},getURL:function(t){if(!t)return null;var i={},r=t.length,a=t.indexOf("://");if(a<0)return null;i.protocol=t.substring(0,a+1);var c=t.indexOf("#"),n=t.indexOf("?");c<0&&(c=r),n<0&&(n=c),i.search=t.substring(n,c).substring(0,1e3);var h=t.substring(a+3,n),d=h.indexOf("/");return d<0&&(d=h.length),i.domain=h.substring(0,d).split(":")[0],i.path=h.substring(d,h.length).substring(0,1e3),i},getResType:function(t,i){if(["script","img","other"].indexOf(t)>-1)return t;if(["video"].indexOf(t)>-1)return"media";if(["document","iframe"].indexOf(t)>-1)return"doc";var r=i?this.getURL(i):null,a=r&&r.path?r.path.lastIndexOf("."):-1,c=(a>0?r.path.substr(a+1):"").toLowerCase();if(c){if(["eot","woff","woff2","ttf"].indexOf(c)>-1)return"font";if(c==="css")return"css";if(c==="js")return"script"}return["fetch","xmlhttprequest","beacon"].indexOf(t)>-1?"api":"others"},areInOrder:function(){for(var t=1;t<arguments.length;t+=1)if(arguments[t-1]>arguments[t])return!1;return!0},getFetchSnapshot:function(t,i,r){var a,c;try{var n=(t&&typeof t[0]!="string"?t[0].url:t[0])||"",h=(t&&typeof t[0]!="string"?t[0]:t[1])||{},d=h.method.toUpperCase()==="POST"?h.body:this.getQuerys(n);a={originApi:n,method:h.method||"unknown",params:d,response:i||"",reqHeaders:this.parseFetchHeaders(h.headers||null),resHeaders:this.parseFetchHeaders(r)},c=JSON&&JSON.stringify(a)||"{}"}catch(u){c="{}"}return c},getXhrSnapshot:function(t,i,r){if(!t||!i||!r)return{};var a,c;try{var n="";r.responseType===""||r.responseType==="text"?n=r.responseText:r.responseType==="document"&&(n=r.responseXML),a={originApi:t,method:i,params:this.getQuerys(t),response:n,reqHeaders:{},resHeaders:this.parseXhrHeaders(typeof r.getAllResponseHeaders=="function"&&r.getAllResponseHeaders()||"")},c=JSON&&JSON.stringify(a)||"{}"}catch(h){c="{}"}return c},isRobot:function(){var t=["nuhk","googlebot/","googlebot-image","yammybot","openbot","slurp","msnbot","ask jeeves/teoma","ia_archiver","baiduspider","bingbot/","adsbot"];if(!navigator||typeof navigator.userAgent!="string")return!1;try{for(var i=navigator.userAgent.toLowerCase(),r=0;r<t.length;r++){var a=t[r];if(i.lastIndexOf(a)>=0)return!0}}catch(c){this.warn("[arms] useragent parse error")}return!1},isFunction:function(t){return typeof t=="function"},isPlainObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},isString:function(t){return Object.prototype.toString.call(t)==="[object String]"},isArray:function(t){return Object.prototype.toString.call(t)==="[object Array]"},joinRegExp:function(t){for(var i,r=[],a=0,c=t.length;a<c;a++)i=t[a],this.isString(i)?r.push(i.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):i&&i.source&&r.push(i.source);return new RegExp(r.join("|"),"i")},reWriteMethod:function(t,i,r){if(t!==null){var a=t[i];t[i]=r(a)}},checkSDKError:function(t,i){return!(!t&&!i)&&(!!new RegExp(this.selfErrKey,"i").test(t)||!!this.ignoreByRule(i,[/retcode.alicdn.com\/retcode\/bl.js/,/g.alicdn.com\/retcode\/cloud-sdk\/bl.js/,/laz-g-cdn.alicdn.com\/retcode\/cloud-sdk\/bl.js/,/local.taobao.com:8880\/build\/bl/]))},sdkError:function(t){return{msg:t,message:this.selfErrKey}},dealParam:function(t,i,r){var a={};try{a=this.isPlainObject(t)?this.ext({key:t.key||"default",val:t.val||t.value||r},t,{begin:Date.now()}):{key:t||"default",val:i||r,begin:Date.now()}}catch(c){this.warn("[retcode] baseLog error: "+c)}return a}};return je=e}var Hr,Fr,jr,zr,Hi={exports:{}},Fi={exports:{}};function vn(){if(jr)return Fi.exports;jr=1;var s=ke(),o=function(){if(Fr)return Hr;Fr=1;var r=ke();return Hr=function(a,c,n){typeof a=="object"&&(a=r.serialize(a));var h=c+a+(n?"&post_res=":"");window&&window.navigator&&typeof window.navigator.sendBeacon=="function"?window.navigator.sendBeacon(h,n||"&post_res="):r.warn("[arms] navigator.sendBeacon not surported")}}(),e="aokcdqn3ly@e629dabd48a9933",t=function(r,a){var c;if(a.t==="error"&&(c=r.requestQueue[0])&&c.t==="error"&&a.msg===c.msg)return a.times=c.times+1,void(r.requestQueue[0]=a);if(a.t==="behavior"){var n=r.requestQueue&&r.requestQueue.length;if(n>0&&r.requestQueue[n-1].t==="behavior"){var h=a.behavior||[];r.requestQueue[n-1].behavior.concat(h)}else r.requestQueue.push(a)}else r.requestQueue.unshift(a);return r.onReady(function(){r.requestTimmer=s.delay(function(){r.clear()},r.requestQueue[0]&&r.requestQueue[0].t==="error"?3e3:-1)}),!0},i=function(r){return this.ver="1.8.36-beta.12",this._conf=s.ext({},i.dftCon),this.sampleCache={},this.requestQueue=[],this.selfQueue=[],this.sdkFlag=!0,this.hash=s.seq(),this.resetPageview(),this.setConfig(r),this.rip=s.getRandIP(),this.record=999,this["EagleEye-TraceID"]=this.getTraceId()["EagleEye-TraceID"],this._common={},this};return i.dftCon={sample:1,pvSample:1,tag:"",imgUrl:"https://arms-retcode.aliyuncs.com/r.png?",region:null,ignore:{ignoreUrls:[],ignoreApis:[],ignoreErrors:[/^Script error\.?$/],ignoreResErrors:[],ignoreResources:[/\/(bl|wl)(.debug)?.js$/]},release:void 0,environment:"prod",beforeReport:null,parseTraceId:null},i.prototype={constructor:i,onReady:function(r){return r()},getPage:function(){var r=this._conf.page;return s.safetyCall(r,[],r+"")},setPage:function(){},setConfig:function(r){r&&typeof r=="object"&&(s.verifyConfig(r),r=this.setImgUrl(r),this._conf=s.ext({},this._conf,r))},setImgUrl:function(r){var a=r.region,c=r.imgUrl;if(a){var n=s.regionMap[a];return r.imgUrl=n||s.defaultImgUrl,r}return c&&(r.imgUrl=c),r},checkImgUrl:function(){return!0},sendRequest:function(){},sendBeacon:function(r,a,c){o(r,a||this.getConfig("imgUrl"),c)},postData:function(){},commonInfo:function(){return{}},setCommonInfo:function(r){r&&typeof r=="object"&&(this._common=s.ext({},this._common,r))},resetPageview:function(){this.pageview=s.uu(),this.sBegin=Date.now()},getUsername:function(){if(this.username)return this.username;var r=this._conf,a=r&&r.setUsername;if(typeof a=="function")try{var c=a();typeof c=="string"&&(c=c.substr(0,40),this.username=c)}catch(n){s.warn("[arms] setUsername fail",n)}return this.username},getTraceId:function(){var r=this.rip,a=Date.now(),c=s.getSortNum(this.record),n=r+a+c+s.getRandNum(this._conf.pid);return this["EagleEye-TraceID"]=n,this.record=c,{"EagleEye-TraceID":n}},getUberTraceId:function(r){var a=this.rip,c=Date.now(),n=s.getSortNum(this.record),h=s.getRandNum(this._conf.pid),d=a+c+n+s.getNum(2)+h,u=d.substring(0,16);return r=r?"1":"0",d[0]==="0"&&(d[0]="1"),d[16]==="0"&&(d[16]="1"),{"uber-trace-id":d+":"+u+":0:"+r,traceId:d}},getB3TraceId:function(r){var a=this.rip,c=Date.now(),n=s.getSortNum(this.record),h=s.getRandNum(this._conf.pid),d=a+c+n+s.getNum(2)+h,u=d.substring(0,16);return r=r?"1":"0",d[0]==="0"&&(d[0]="1"),d[16]==="0"&&(d[16]="1"),{b3:d+"-"+u+"-"+r+"-0","X-B3-TraceId":d,"X-B3-ParentSpanId":"0","X-B3-SpanId":u,"X-B3-Sampled":r}},getPageviewId:function(){return{"EagleEye-SessionID":this.pageview}},getConfig:function(r){return r?this._conf[r]:s.ext({},this._conf)},sampling:function(r){return r===1||(typeof this.sampleCache[r]=="boolean"||(this.sampleCache[r]=s.pick(r)),this.sampleCache[r])},clear:function(r){var a;clearTimeout(this.requestTimmer),this.requestTimmer=null;for(var c=this._conf&&typeof this._conf.sendRequest=="function";a=this.requestQueue.pop();)if(a.t==="res")this.postData(a,"res");else if(a.t==="error")this.postData(a,"err");else if(a.t==="api")this.postData(a,"apiSnapshot");else if(a.t==="behavior")this.postData(a,"behavior");else if(a.t==="health"&&!c&&window&&window.navigator&&typeof window.navigator.sendBeacon=="function")this.sendBeacon(a);else if(a.t==="resource"&&!c&&window&&window.navigator&&typeof window.navigator.sendBeacon=="function"){var n=JSON.stringify({resource:a.resource});delete a.resource,this.sendBeacon(a,null,n)}else a.t==="resource"?this.postData(a,"resource"):this.sendRequest(a);return r&&this.clearSelf(),this},clearSelf:function(){var r;for(clearTimeout(this.Timmer),this.Timmer=null;r=this.selfQueue.pop();)this.postData(r,"err");return this},_lg:function(r,a,c,n){var h=this,d=h._conf,u=h.getPage(),f=d.ignore||{},l=f.ignoreErrors,g=f.ignoreResErrors,p=f.ignoreUrls,b=f.ignoreApis;if(h._isRobot||s.ignoreByRule(u,p)||s.ignoreByRule(s.decode(u),p)||r==="error"&&(s.ignoreByRule(a.msg,l)||s.ignoreByRule(s.decode(a.msg),l))||r==="resourceError"&&(s.ignoreByRule(a.src,g)||s.ignoreByRule(s.decode(a.src),g))||r==="api"&&(s.ignoreByRule(a.api,b)||s.ignoreByRule(s.decode(a.api),b))||!h.checkImgUrl(d.imgUrl)||!a||d.disabled||!d.pid||n===0)return h;var S=a.dl;if(delete a.dl,a=s.ext({t:r,times:1,page:u,tag:d.tag||"",release:d.release||"",environment:d.environment,begin:Date.now(),c1:d.c1,c2:d.c2,c3:d.c3},a,h.commonInfo(),h._common,{pid:d.pid,_v:h.ver,pv_id:h.pageview,username:h.getUsername(),sampling:c||1,dl:S,z:s.seq()}),s.T(d.beforeReport)==="Function")try{if(!(a=d.beforeReport(a)))return h}catch(v){return h}return n===1?t(h,a):c&&!h.sampling(c)?h:t(h,a)},_self:function(r,a,c){var n=this,h=n._conf;if(r!=="error"||!n.checkImgUrl(h.imgUrl)||!a||h.disabled||!h.pid||c&&!n.sampling(c))return n;a=s.ext({t:r,times:1,page:s.selfErrPage,tag:h.pid,begin:Date.now()},a,{pid:e,_v:n.ver,sampling:c||1,z:s.seq()});var d=n.selfQueue[0];if(d){d.times++;try{d.err&&a.err&&d.err.msg_raw&&a.err.msg_raw&&d.err.msg_raw.split("&").indexOf(a.err.msg_raw)<0&&d.err.msg_raw.length<1e3&&(d.err.msg_raw+="&"+a.err.msg_raw)}catch(u){}}else n.selfQueue.unshift(a),n.onReady(function(){n.sdkFlag&&(n.sdkFlag=!1,n.Timmer=s.delay(function(){n.clearSelf()},1e4))})},custom:function(r,a){if(!r||typeof r!="object")return this;var c=!1,n={begin:Date.now()};return s.each(r,function(h,d){return!(c=d&&d.length<=20)&&s.warn("[retcode] invalid key: "+d),n["x-"+d]=h,c}),c?this._lg("custom",n,a||1):this}},Fi.exports=i,Fi.exports}var Kr,ji={exports:{}},Wr,zi,$r,Ki={exports:{}};function yn(){if($r)return zi;$r=1;var s=ke();return zi=function(o,e){var t=[],i=null,r=e&&e.location&&e.location.href,a=void 0,c=null,n=function(u,f,l){if(u!==null){var g=u[f];u[f]=l(g)}},h=function(u){var f,l,g,p,b,S=[];if(!u||typeof u.tagName!="string")return"";if(S.push(u.tagName.toLowerCase()),typeof u.id=="string"&&S.push("#".concat(u.id)),typeof(f=u.className)=="string")for(l=f.split(/\s+/),b=0;b<l.length;b++)S.push(".".concat(l[b]));var v=["type","name","title","alt","data-arms-attr"];for(b=0;b<v.length;b++)g=v[b],typeof(p=u.getAttribute(g))=="string"&&S.push("[".concat(g,'="').concat(p,'"]'));return S.join("")},d=function(u,f){return function(l){if(l&&l!==c){var g;c=l;try{g=l.target}catch(b){g="<unknown>"}if(g.length!==0){var p={type:"ui.".concat(u),data:{message:function(b){if(!b||b.nodeType!==1)return"";for(var S=b||null,v=[],_=0,E=0,y="";S&&_++<5&&!((y=h(S))==="html"||_>1&&E+3*v.length+y.length>=80);)v.push(y),E+=y.length,S=S.parentNode;return v.reverse().join(" > ")}(g)},timestamp:Date.now()};u==="click"?i&&i.addBehavior(p):u==="keypress"&&(a||i&&i.addBehavior(p),clearTimeout(a),a=setTimeout(function(){a=void 0},100))}}}};s.ext(o.prototype,{addBehavior:function(u){if(this.getConfig("behavior")&&u&&typeof u=="object"){var f={},l=u.data||{};if(u.type)f=l;else{if(typeof l.name!="string"||typeof l.message!="string")return;f.name=l.name.substr(0,20),f.message=l.message.substr(0,200)}f.message&&(f.message=s.encode(f.message));var g={type:u.type||"custom",data:f||{},timestamp:u.timestamp||Date.now(),page:u.page||e&&e.location&&e.location.pathname};return t.push(g),t=t.slice(-100)}},getBehavior:function(){return t||[]},setBehavior:function(u){return u&&(t=u),t},reportBehavior:function(u){var f=this;f.getConfig("behavior")&&(f.sendBhTimer&&(clearTimeout(f.sendBhTimer),f.sendBhTimer=void 0),f.sendBhTimer=setTimeout(function(){t&&t.length>0&&(f.behavior(t),t=[],f.sendBhTimer=void 0,u&&typeof u=="function"&&u())},0))},initBehavior:function(){if(!this.hasInitBehavior&&!i){try{(function(){if(document&&document.referrer&&document.location){var f=document.referrer,l=document.location.href;if(f!==""){var g={type:"navigation",data:{from:f,to:l}};r=l,i&&i.addBehavior(g)}}})(),e&&e.document&&e.document.addEventListener&&(e.document.addEventListener("click",d("click"),!1),e.document.addEventListener("keypress",d("keypress"),!1)),function(){if(function(){var p=e&&e.chrome,b=p&&p.app&&p.app.runtime,S="history"in e&&!!e.history.pushState&&!!e.history.replaceState;return!b&&S}()){var f=function(p,b){var S={type:"navigation",data:{from:p,to:b}};i&&i.addBehavior(S),r=b},l=e.onpopstate;e.onpopstate=function(){for(var p=arguments.length,b=new Array(p),S=0;S<p;S++)b[S]=arguments[S];var v=e.location.href;if(f(r,v),l)return l.apply(this,b)};var g=function(p){return function(){for(var b=arguments.length,S=new Array(b),v=0;v<b;v++)S[v]=arguments[v];var _=S.length>2?S[2]:void 0;return _&&f(r,String(_)),p.apply(this,S)}};n(e.history,"pushState",g),n(e.history,"replaceState",g)}}();var u=this.getConfig("enableConsole");u&&function(f){if(e&&e.console){var l=["debug","info","warn","log","error","assert"];s.isArray(f)&&(l=f);for(var g=0;g<l.length;g++){var p=l[g];p&&s.isString(p)&&e.console[p]&&typeof e.console[p]=="function"&&n(e.console,p,function(b){var S=p;return function(){for(var v=arguments.length,_=new Array(v),E=0;E<v;E++)_[E]=arguments[E];var y={type:"console",data:{level:S,message:_}};if(i&&i.addBehavior(y),S==="error")for(var R=0;R<_.length;R++){var A=_[R];A&&A.message&&A.stack&&i&&i.errorHandler(new ErrorEvent("error",{error:A,message:A.message}))}b&&Function.prototype.apply.call(b,e.console,_)}})}}}(u)}catch(f){s.warn("[arms] error in initBehavior",f)}i=this,this.hasInitBehavior=!0}return this}})},zi}var Jr,Gr,qr,Wi,Yr,Xr,Qr,$i,Zr,es,ts,is,rs,Ji,ss,as,ns,os={};function Gi(){return Jr||(Jr=1,os.TIMING_KEYS=["startTime","fetchStart","domainLookupStart","domainLookupEnd","connectStart","connectEnd","requestStart","responseStart","responseEnd","","domInteractive","","domContentLoadedEventEnd","","loadEventStart","","msFirstPaint","secureConnectionStart","redirectStart","redirectEnd"]),os}function Rn(){return Qr||(Qr=1,Xr=function(s,o,e){var t=ke(),i=function(){if(qr)return Gr;qr=1;var p=ke(),b=Gi().TIMING_KEYS;return Gr=function(){var S=p.win||{},v=S.performance;if(!v||typeof v!="object"||typeof v.getEntriesByType!="function")return null;var _={},E=v.timing||{},y=v.getEntriesByType("resource")||[];if(_.begin=E[b[1]]||Date.now(),typeof S.PerformanceNavigationTiming=="function"){var R=v.getEntriesByType("navigation")[0];R&&(E=R)}return p.each({dom:[10,8],load:[14,1]},function(A,T){var I=E[b[A[1]]],k=E[b[A[0]]];if(I>0&&k>0){var P=Math.round(k-I);P>=0&&P<6e5&&(_[T]=P)}}),_.res=JSON.stringify(y),_}}(),r=function(){if(Yr)return Wi;Yr=1;var p=ke(),b=Gi().TIMING_KEYS;return Wi=function(){var S=p.win||{},v=S.performance;if(!v||typeof v!="object")return null;var _={},E=v.timing||{},y=Date.now(),R=1;if(typeof S.PerformanceNavigationTiming=="function"){var A=v.getEntriesByType("navigation")[0];A&&(E=A,R=2)}p.each({dns:[3,2],tcp:[5,4],ssl:[5,17],ttfb:[7,6],trans:[8,7],dom:[10,8],res:[14,12],firstbyte:[7,2],fpt:[8,1],tti:[10,1],ready:[12,1],load:[14,1]},function(H,q){var X=E[b[H[1]]],J=E[b[H[0]]];if(R===2||X>0&&J>0){var z=Math.round(J-X);z>=0&&z<6e5&&(_[q]=z)}});var T=S.navigator.connection,I=v.navigation||{};_.ct=T?T.effectiveType||T.type:"";var k=T&&(T.downlink||T.downlinkMax||T.bandwidth)||null;if((k=k>999?999:k)&&(_.bandwidth=k),_.navtype=I.type===1?"Reload":"Other",R===1&&E[b[16]]>0&&E[b[1]]>0){var P=E[b[16]]-E[b[1]];P>=0&&P<36e5&&(_.fpt=P)}return R===1&&E[b[1]]>0?_.begin=E[b[1]]:R===2&&_.load>0?_.begin=y-_.load:_.begin=y,_},Wi}(),a=null,c=e.documentElement,n=o.innerWidth||c.clientWidth||e.body.clientWidth,h=o.innerHeight||c.clientHeight||e.body.clientHeight,d=o.navigator.connection,u={sr:screen.width+"x"+screen.height,vp:n+"x"+h,ct:d?d.effectiveType||d.type:""},f={},l=function(p,b,S,v,_){if(b===void 0){var E,y;if(!f[p]){E=new RegExp(p+"=([^;]+)");try{y=E.exec(e.cookie)}catch(A){return t.warn("[retcode] can not get cookie:",A),null}y&&(f[p]=y[1])}return f[p]}var R=p+"="+b;R+="; path=/",S&&(R+="; max-age="+S);try{return e.cookie=R,!!e.cookie}catch(A){return t.warn("[retcode] can not set cookie: ",A),!1}},g=function(p){var b=p._conf.uid||l("_nk_")||l("_bl_uid");return b||(b=t.uu(),l("_bl_uid",b,15552e3))?b:null};return t.ext(s.prototype,{activeErrHandler:function(p){return a&&!p||(a=this),this},errorHandler:function(p){if(!p)return this;var b=p.type;if(b==="error"){var S=p.target||p.srcElement;!S||!S.tagName||p.message||p.filename||p.lineno||p.colno?this.error(p.error||{message:p.message},p):this.resourceErrorHandler(p)}else b==="unhandledrejection"&&t.T(p.reason,"Error")&&t.checkAutoError(p.reason)&&this.error(p.reason);try{this.getConfig("behavior")&&this.reportBehavior&&this.reportBehavior()}catch(v){}return this},resourceErrorHandler:function(p){var b=this,S=p.target||p.srcElement;try{var v=b.getSrc(S),_=typeof S.tagName=="string"?S.tagName.toLowerCase():"",E=b.getXPath(S,5),y=t.getURL(v),R={src:v&&v.substring(0,1e3),node_name:_,xpath:E,res_type:t.getResType(_,v),res_name:y.path,domain:y.domain};return b._conf.enableResource&&b.fixResourceStatus&&p.timeStamp&&b.fixResourceStatus({src:v,node_name:_,res_type:t.getResType(_,v),timeStamp:p.timeStamp,domain:y.domain}),b._lg("resourceError",R),b}catch(A){return t.warn("[ARMS] resourceErrorHandler error :",A),b}},getSrc:function(p){var b=p.src||p.href;try{if(!b){var S=(typeof p.tagName=="string"?p.tagName.toLowerCase():"")==="object",v=p.getAttribute("classid")&&p.getAttribute("classid").toLowerCase()==="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"||p.getAttribute("type")==="application/x-shockwave-flash";S&&v&&(b=p.getAttribute("data")||p.getAttribute("codebase")),b||(b=p.outerHTML||p.innerHTML)}}catch(_){b=""}return b},getXPath:function(p,b){var S=p.id?"#"+p.id:"",v=typeof p.className=="string"?"."+p.className.split(" ").join("."):"",_=(typeof p.tagName=="string"?p.tagName.toLowerCase():"")+S+v;return p.parentNode&&p.parentNode.tagName&&b-1!=0?this.getXPath(p.parentNode,b-1)+" > "+_:_},sendPerformance:function(p){var b=this;b.onReady(function(){var S=r();S&&S.load&&S.load>0&&(S.page=b.getPage(!0),p&&(S=t.ext(S,p)),S.autoSend=!0,b.performance(S))})},sendResources:function(p){var b=this;b.onReady(function(){var S=i();S&&S.load&&S.load>0&&(S.load&&S.load<=2e3||S.load&&S.load<=8e3&&Math.random()>.05||(S.page=b.getPage(!0),S.dl=location.href,p&&(S=t.ext(S,p)),b._lg("res",S,b.getConfig("sample"))))})},sendPV:function(){var p=this;p.onReady(function(){var b,S,v=(b=g(p),S=o.devicePixelRatio||1,{uid:b,dt:e.title,dl:location.href,dr:e.referrer,dpr:S.toFixed(2),de:(e.characterSet||e.defaultCharset||"").toLowerCase(),ul:c.lang,begin:Date.now()});v&&v.uid&&p._lg("pv",v,p.getConfig("pvSample"))})},commonInfo:function(){return u.uid=g(this),u.sid=function(p){if(p.session)return p.session;var b;try{if(typeof window=="object"&&typeof sessionStorage=="object"&&typeof sessionStorage.getItem=="function")return typeof(b=sessionStorage.getItem("_bl_sid"))=="string"?(p.session=b,b):(b=t.uu(),p.session=b,typeof sessionStorage.setItem=="function"&&sessionStorage.setItem("_bl_sid",b),b)}catch(S){t.warn("[ARMS] getSid error :",S)}return p.session=b=t.uu(),b}(this),u},handleUnload:function(p){var b=Date.now();if(b-this._lastUnload<200)return this;this._lastUnload=b,this.sendHealth(p),this.speedCache&&(this._lg("speed",this.speedCache),this.speedCache=null,clearTimeout(this.speedTimmer)),this._conf&&this._conf.enableResource&&this.resourceComboReport(),this.clear(!0)},bindHashChange:function(p){var b=this;if(!p^b.hashChangeHandler)return b;p?(b.hackHistoryState(),b.hashChangeHandler=function(S){var v=b._conf.parseHash(location.hash);v&&b.setPage(v,S!==!1)},b.stateChangeHandler=function(S){var v=b._conf.parseHash(S.detail);v&&b.setPage(v)},t.on(o,"hashchange",b.hashChangeHandler),t.on(o,"historystatechange",b.stateChangeHandler),b.hashChangeHandler(!1)):(t.off(o,"hashchange",b.hashChangeHandler),t.off(o,"historystatechange",b.stateChangeHandler),b.hashChangeHandler=null,b.stateChangeHandler=null)},initHandler:function(){var p=this;if(p.hasInitHandler)return p;var b=p._conf;return t.on(o,"beforeunload",function(){p.handleUnload(0)}),p.bindHashChange(b.enableSPA),p.activeErrHandler(!1),p.hasInitHandler=!0,p}}),t.on(o,"error",function(p){a&&a.errorHandler(p)},!1,!0).on(o,"unhandledrejection",function(p){a&&a.errorHandler(p)}),s}),Xr}function An(){if(Zr)return $i;Zr=1;var s=ke();return $i=function(o,e,t){function i(d,u,f){var l=0,g=d.tagName;if(g!=="SCRIPT"&&g!=="STYLE"&&g!=="META"&&g!=="HEAD"){var p=d.children?d.children.length:0;if(p>0)for(var b=d.children,S=p-1;S>=0;S--)l+=i(b[S],u+1,l>0);if(l<=0&&!f&&!(d.getBoundingClientRect&&d.getBoundingClientRect().top<a))return 0;l+=1+.5*u}return l}function r(d){for(var u=1;u<d.length;u++)if(d[u].score<d[u-1].score)return d.splice(u,1),r(d);return d}var a=e.innerHeight||0,c=[],n=null,h=0;s.ext(o.prototype,{initFmpObserver:function(d){var u=this;if(!u._conf||!u._conf.useFmp)return null;if(!e.MutationObserver)return s.warn("[retcode] first meaningful paint can not be retrieved"),u.sendPerformance(),null;s.on(e,"beforeunload",function(){u.endObserving(0,!0)});var f=e.MutationObserver;return(n=new f(function(){(function(l){var g=Date.now()-l,p=t.querySelector("body");if(p){var b=0;b+=i(p,1,!1),c.push({score:b,t:g})}else c.push({score:0,t:g})})(u._startTime)})).observe(document,{childList:!0,subtree:!0}),h=1,u.onReady(function(){u.endObserving(d)}),n},endObserving:function(d,u){var f,l,g,p=this;if(n&&h)if(p.fmpTimmer&&(clearTimeout(p.fmpTimmer),p.fmpTimmer=null),u||(f=p._startTime,l=d,(g=Date.now()-f)>l||g-(c&&c.length&&c[c.length-1].t||0)>1e3)){n.disconnect(),h=0,c=r(c);for(var b=null,S=1;S<c.length;S++)if(c[S].t>=c[S-1].t){var v=c[S].score-c[S-1].score;(!b||b.rate<=v)&&(b={t:c[S].t,rate:v})}b&&b.t>0&&b.t<36e5?p.sendPerformance({fmp:b.t}):p.sendPerformance()}else p.fmpTimmer=s.delay(function(){p.endObserving(d)},500)}})},$i}function _n(){if(as)return rt.exports;as=1;var s=ke(),o=function(){if(zr)return Hi.exports;zr=1;var n=ke(),h=vn(),d=["api","success","time","code","msg","trace","traceId","begin","pv_id","sid","seq","domain","flag","apiSnapshot","tag","c1","c2","c3"],u=function(l){var g=(l.key||"default").split("::");return g.length>1?n.ext(l,{group:g[0],key:g[1]}):n.ext(l,{group:"default_group",key:g[0]})},f=function(l){var g;h.call(this,l);try{g=typeof performance=="object"?performance.timing.fetchStart:Date.now()}catch(p){g=Date.now()}return this._startTime=g,this};return f.prototype=n.createObject(h.prototype),n.ext(h.dftCon,{startTime:null}),n.ext(f.prototype,{constructor:f,_super:h,sum:function(l,g,p){try{var b=n.dealParam(l,g,1);return this._lg("sum",u(b),p)}catch(S){n.warn("[retcode] can not get parseStatData: "+S)}},avg:function(l,g,p){try{var b=n.dealParam(l,g,0);return this._lg("avg",u(b),p)}catch(S){n.warn("[retcode] can not get parseStatData: "+S)}},percent:function(l,g,p,b){try{return this._lg("percent",u({key:l,subkey:g,val:p||0,begin:Date.now()}),b)}catch(S){n.warn("[retcode] can not get parseStatData: "+S)}},msg:function(l,g){if(l&&!(l.length>180))return this.custom({msg:l},g)},error:function(l,g){if(!l)return n.warn("[retcode] invalid param e: "+l),this;arguments.length===1?(typeof l=="string"&&(l={message:l},g={}),typeof l=="object"&&(g=l=l.error||l)):(typeof l=="string"&&(l={message:l}),typeof g!="object"&&(g={}));var p=l.name||"CustomError",b=l.message||"",S=l.stack||"";g=g||{};var v=typeof location=="object"&&typeof location.href=="string"&&location.href.substring(0,500)||"";if(n.checkSDKError(b,g.filename)){var _=/^Script error\.?$/,E=l.msg||l.message;if(n.ignoreByRule(E,_)||n.ignoreByRule(n.decode(E),_))return this;var y={msg:n.selfErrKey,err:{msg_raw:n.encode(l.msg||l.message)}};return this._self("error",y,1)}for(var R={begin:Date.now(),cate:p,msg:b&&b.substring(0,1e3),stack:S&&S.substring(0,1e3),file:n.removeUrlSearch(g.filename||""),line:g.lineno||"",col:g.colno||"",err:{msg_raw:n.encode(b),stack_raw:n.encode(S)},dl:v},A=["tag","c1","c2","c3"],T=0;T<A.length;T++){var I=A[T];g[I]&&(R[I]=g[I])}var k=(this.getConfig("ignore")||{}).ignoreErrors;return n.ignoreByRule(R.msg,k)||n.ignoreByRule(n.decode(R.msg),k)?this:(this.beforeSend&&this.beforeSend("error",R),this._lg("error",R,1))},behavior:function(l){if(l){var g=typeof l=="object"&&l.behavior?l:{behavior:l};return this.beforeSend&&this.beforeSend("behavior",g),this._lg("behavior",g,1)}},api:function(l,g,p,b,S,v,_,E,y,R,A,T,I,k,P,H){if(!l)return n.warn("[retcode] api is null"),this;if(l=typeof l=="string"?{api:l,success:g,time:p,code:b,msg:S,begin:v,traceId:_,pv_id:E,apiSnapshot:y,domain:R,flag:T,tag:I,c1:k,c2:P,c3:H}:n.sub(l,d),!n.checkAPI(l.api,!0))return this;l.code=l.code||"";var q=l.msg||"";if(q=typeof q=="string"?q.substring(0,1e3):q,l.msg=q,l.success=l.success?1:0,l.time=+l.time,l.begin=l.begin,l.traceId=l.traceId||"",l.pv_id=l.pv_id||"",l.domain=l.domain||"",l.flag=l.flag,l.dl=typeof location=="object"&&typeof location.href=="string"&&location.href.substring(0,500)||"",l.apiSnapshot&&(typeof l.apiSnapshot=="object"&&(l.apiSnapshot=JSON.stringify(l.apiSnapshot)),typeof l.apiSnapshot!="string"&&delete l.apiSnapshot,l.apiSnapshot.length>2e3&&(l.apiSnapshot=l.apiSnapshot.substring(0,2e3))),A&&(l.traceOrigin=A),!l.api||isNaN(l.time))return n.warn("[retcode] invalid time or api"),this;var X=(this.getConfig("ignore")||{}).ignoreApis;return n.ignoreByRule(l.api,X)||n.ignoreByRule(n.decode(l.api),X)||l.time<0?this:(this.beforeSend&&this.beforeSend("api",l),this._lg("api",l,l.success&&this.getConfig("sample"),l.flag))},speed:function(l,g,p){var b=this,S=this.getConfig("startTime")||this._startTime;return/^s(\d|1[0])$/.test(l)?(g=typeof g!="number"?Date.now()-S:g>=S?g-S:g,b.speedCache=b.speedCache||{},b.speedCache[l]=g,b.speedCache.begin=S,clearTimeout(b.speedTimmer),b.speedTimmer=setTimeout(function(){p||(b.speedCache.page=b.getPage(!0)),b._lg("speed",b.speedCache),b.speedCache=null},5e3),b):(n.warn("[retcode] invalid point: "+l),b)},performance:function(l){if(l&&typeof l=="object"&&!this.hasSendPerf){var g={},p={},b=this.getConfig("autoSendPerf");if(l.autoSend&&b)return p=n.ext(this.perfData||{},l),this.hasSendPerf=!0,this._lg("perf",p,this.getConfig("sample"));if(l.autoSend&&!b)return delete l.autoSend,this.perfData?(p=n.ext(this.perfData||{},l),this.hasSendPerf=!0,this._lg("perf",p,this.getConfig("sample"))):void(this.perfData=l);for(var S in l)(/^t([1-9]|1[0])$/.test(S)||S==="ctti"||S==="cfpt")&&(g[S]=l[S]);if(l.autoSend===!0||!b&&(b||this.perfData))return l.autoSend!==!0&&b===!1&&this.perfData?(g=n.ext(this.perfData||{},g),this.hasSendPerf=!0,this._lg("perf",g,this.getConfig("sample"))):void 0;this.perfData=n.ext(this.perfData||{},g)}},resource:function(l,g){if(!l||!n.isPlainObject(l))return n.warn("[arms] invalid param data: "+l),this;var p=Object.keys(l),b=["begin","dom","load","res","dl"],S=!1;for(var v in b)if(p.indexOf(b[v])<0){S=!0;break}if(S)return n.warn("[arms] lack param data: "+l),this;var _={begin:l.begin||Date.now(),dom:l.dom||"",load:l.load||"",res:n.isArray(l.res)?JSON.stringify(l.res):JSON.stringify([]),dl:l.dl||""};return this._lg("res",_,g)},event:function(l,g){if(typeof l=="object"&&l&&l.key){var p={},b=["key","success","time","c1","c2","c3"];for(var S in l)b.indexOf(S)>-1&&(p[S]=l[S]);p.success=l.success===!1?0:1,this._lg("event",p,g)}}}),f._super=h,f._root=h,h.Reporter=f,Hi.exports=f,Hi.exports}(),e=function(){if(Kr)return ji.exports;Kr=1;var n=ke(),h=typeof window=="object"?window:{},d=h.__oFetch_||h.fetch;return d=typeof d=="function"?d:void 0,ji.exports=function(u,f){var l=-1;typeof u=="object"&&(l=u.z,u=n.serialize(u));var g=f+u;if(d)return d(g,{method:"HEAD",mode:"no-cors"}).catch(n.noop);if(h.document&&h.document.createElement){var p="__request_hold_"+l,b=h[p]=new Image;b.onload=b.onerror=function(){h[p]=void 0},b.src=g,b=null}},ji.exports}(),t=function(){if(Wr)return Ki.exports;Wr=1;var n=ke(),h=typeof window=="object"?window:{},d=h.__oXMLHttpRequest_||h.XMLHttpRequest;return d=typeof d=="function"?d:void 0,Ki.exports=function(u,f){try{var l=new d;l.open("POST",f,!0),l.setRequestHeader("Content-Type","text/plain"),l.send(JSON.stringify(u))}catch(g){n.warn(`[retcode] Failed to log, exception is :
|
|
3
|
-
`+g)}},
|
|
4
|
-
`+oe)}else switch(y.headers=y.headers?y.headers:{},N){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"]?Z=y.headers["EagleEye-SessionID"]:(Z=A.getPageviewId()["EagleEye-SessionID"],y.headers["EagleEye-SessionID"]=Z),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 me=A.getB3TraceId(D);y.headers["X-B3-TraceId"]=me["X-B3-TraceId"],y.headers["X-B3-ParentSpanId"]=me["X-B3-ParentSpanId"],y.headers["X-B3-SpanId"]=me["X-B3-SpanId"],y.headers["X-B3-Sampled"]=me["X-B3-Sampled"],y.headers["X-Request-ID"]=d.guid(),z=me["X-B3-TraceId"]}Z=A.getPageviewId()["EagleEye-SessionID"];break;default:if(y.headers["uber-trace-id"])z=y.headers["uber-trace-id"].split(":")[0];else{var be=A.getUberTraceId(D);y.headers["uber-trace-id"]=be["uber-trace-id"],z=be.traceId}Z=A.getPageviewId()["EagleEye-SessionID"]}}return _.apply(h,R).then(function(oe){if(!A||!A.api)return oe;try{if(!oe||typeof oe.clone!="function")return oe;var _e=oe.clone(),Ue=_e.headers;if(Ue&&typeof Ue.get=="function"){var pt=Ue.get("content-type");if(pt&&!/(text)|(json)/.test(pt))return oe;if(!z){var Rt=d.parseFetchHeaders(Ue);typeof Rt=="object"&&Rt["eagleeye-traceid"]&&(z=Rt["eagleeye-traceid"],he="response")}}var gt=k();return _e.text().then(function(Me){if(!z&&d.isFunction(X)){var Ye=X(_e,Me);Ye&&d.isString(Ye)&&(z=Ye)}var Xe=d.getFetchSnapshot(R,Me,Ue);_e.ok?l(A,I.parseResponse,P,H,Me,_e.status||200,gt,T,z,Z,Xe,he,D):(A.api(P,!1,gt,_e.status||404,_e.statusText,T,z,Z,Xe,f,he,D),I.enableResource&&u.fixResourceStatus&&u.fixResourceStatus({src:_e.url,res_type:"api"}))}),oe}catch(Me){return d.warn("[ARMS] fetch response error :",Me),oe}}).catch(function(oe){if(!A||!A.api)throw oe;var _e=k();throw A.api(P,!1,_e,oe.name||"Error",oe.message,T,z,Z,{},f),I.enableResource&&u.fixResourceStatus&&u.fixResourceStatus({src:H,res_type:"api"}),oe})},h[g].toString=d.createFakeToString(g)}}(),function(){if(typeof h[S]=="function"){var _,E=h[S];h[b]=E;var y=function(R){var A=new E(R),T=u;if(!T||!T.api||!A.addEventListener)return A;var I,k,P,H,q=A.send,X=A.open,J=A.setRequestHeader,z=T._conf,Z=(z.ignore||{}).ignoreApis,ee=z.parseTraceId,he=T.getConfig("enableLinkTrace"),L="",N="",D="",V=null,ne=T.getConfig("sample"),Re=T.getConfig("linkType"),$=1;return ne&&!T.sampling(ne)&&($=0),A.open=function(ue,we){_=ue;var Ce=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);X.apply(A,Ce),H=we||"",P=d.cutUrlSearch(H);var Ae=!d.checkAPI(P,!0)||d.ignoreByRule(P,Z);if(P=P?d.filterByRule(P,H,z.ignoreApiPath?z.ignoreApiPath:z.apiHelper):"",!Ae&&he){var me="";try{me=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(Ue){me=""}var be=d.checkSameOrigin(H,me);if((T.getConfig("enableApiCors")||be)&&J&&typeof J=="function")switch(Re){case"arms":L=T.getTraceId()["EagleEye-TraceID"],J.apply(A,["EagleEye-TraceID",L]),N=T.getPageviewId()["EagleEye-SessionID"],J.apply(A,["EagleEye-SessionID",N]),D=T.getConfig("pid"),J.apply(A,["EagleEye-pAppName",D]);break;case"b3":var oe=T.getB3TraceId($);J.apply(A,["X-B3-TraceId",oe["X-B3-TraceId"]]),J.apply(A,["X-B3-ParentSpanId",oe["X-B3-ParentSpanId"]]),J.apply(A,["X-B3-SpanId",oe["X-B3-SpanId"]]),J.apply(A,["X-B3-Sampled",oe["X-B3-Sampled"]]),J.apply(A,["X-Request-ID",d.guid()]),L=oe["X-B3-TraceId"],N=T.getPageviewId()["EagleEye-SessionID"];break;default:var _e=T.getUberTraceId($);J.apply(A,["uber-trace-id",_e["uber-trace-id"]]),L=_e.traceId,N=T.getPageviewId()["EagleEye-SessionID"]}}},A.send=function(){I=Date.now(),k=d.duration();var ue=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);q.apply(A,ue)},d.on(A,"readystatechange",function(){if(P&&A.readyState===4){var ue=k(),we=d.getXhrSnapshot(H,_,A);if(!L){var Ce=d.parseXhrHeaders(typeof A.getAllResponseHeaders=="function"&&A.getAllResponseHeaders()||"");typeof Ce=="object"&&Ce["eagleeye-traceid"]&&(L=Ce["eagleeye-traceid"],V="response")}if(!L&&d.isFunction(ee)){var Ae=ee(A);Ae&&d.isString(Ae)&&(L=Ae)}if(A.status>=200&&A.status<=299){var me=A.status||200;if(typeof A.getResponseHeader=="function"){var be=A.getResponseHeader("Content-Type");if(be&&!/(text)|(json)/.test(be))return}A.responseType&&A.responseType!=="text"?T.api(P,!0,ue,me,"",I,L,N,{},f,V,$):l(T,z.parseResponse,P,H,A.responseText,me,ue,I,L,N,we,V,$)}else T.api(P,!1,ue,A.status||"FAILED",A.statusText,I,L,N,we,f,V,$),z.enableResource&&u.fixResourceStatus&&u.fixResourceStatus({src:A.responseURL||H,res_type:"api"})}}),A};y.prototype=E.prototype,d.each(Object.keys(E),function(R){y[R]=E[R]}),h[S]=y,h[S].toString=d.createFakeToString(S)}}()),u=this),this},initHook:function(){return this.hasInitHook||(this.getConfig("disableHook")||this.addHook(),this.hasInitHook=!0),this}}),n}),es)(c,i),(rs||(rs=1,is=function(n,h){var d=ke(),u=h.history||{},f=h.document,l=function(p,b){var S;h.CustomEvent?S=new CustomEvent(p,{detail:b}):((S=f.createEvent("HTMLEvents")).initEvent(p,!1,!0),S.detail=b),h.dispatchEvent(S)},g=function(p){var b=u[p];typeof b=="function"&&(u[p]=function(S,v,_){var E=arguments.length===1?[arguments[0]]:Array.apply(null,arguments),y=location.href,R=b.apply(u,E);if(!_||typeof _!="string"||_===y)return R;try{var A=y.split("#"),T=_.split("#"),I=d.cutUrlSearch(A[0]),k=d.cutUrlSearch(T[0]),P=A[1]&&A[1].replace(/^\/?(.*)/,"$1"),H=T[1]&&T[1].replace(/^\/?(.*)/,"$1");P!==H?l("historystatechange",H):I!==k&&l("historystatechange",k)}catch(q){d.warn("[retcode] error in "+p+": "+q)}return R},u[p].toString=d.createFakeToString(p))};d.ext(n.prototype,{hackHistoryState:function(){return this.hasHackedHistoryState||(g("pushState"),g("replaceState"),this.hasHackedHistoryState=!0),this}})}),is)(c,i),function(){if(ss)return Ji;ss=1;var n=ke(),h=Gi().TIMING_KEYS;return Ji=function(d,u){function f(p,b,S){if(p instanceof u.PerformanceResourceTiming&&p.initiatorType){var v=n.getResType(p.initiatorType,p.name),_=b.resourceTypes||[],E=(b.ignore||{}).ignoreResources;if(v&&_.includes(v)&&!n.ignoreByRule(p.name,E)&&!n.ignoreByRule(n.decode(p.name),E)){var y=p[h[0]],R=p[h[1]],A=p[h[2]],T=p[h[3]],I=p[h[4]],k=p[h[5]],P=p[h[6]],H=p[h[7]],q=p[h[8]],X=p[h[18]],J=p[h[19]];if(!S.has(p)&&(!n.areInOrder(y,R,A,T,I,k,P,H,q)||y>H))return;if(X<y&&(X=y),J<y&&(J=R),n.areInOrder(y,X,J,R))return{domain:n.getURL(p.name).domain,res_type:v,src_type:n.getSrcType(p.name,b.cdnHostList),success:1,size:Math.round(p.decodedBodySize),duration:Math.round(p.duration),timeStamp:p.responseEnd,timing:p}}}}var l="_resource-"+Date.now(),g="_resource_error-"+Date.now();n.ext(d.prototype,{initResource:function(){var p=this,b=u.performance,S=u.PerformanceObserver;if(p[g]||(p[g]=new WeakMap),!b||!S||typeof b!="object"||typeof b.getEntriesByType!="function")return null;var v=b.getEntriesByType("resource")||[];return setTimeout(function(){p.setResource(v)},10),new S(function(_){setTimeout(function(){p.setResource(_.getEntries())},10)}).observe({entryTypes:["resource"]}),this.onReady(function(){setTimeout(p.resourceComboReport.bind(p),5e3)}),p},setResource:function(p){var b=this._conf,S=this[g];if(n.isArray(p)&&p.length){this[l]||(this[l]={});for(var v=this[l],_=0,E=p.length;_<E;_+=1){var y=p[_];if(n.checkAPI(y.name,!1)){var R=f(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(p){var b=u.performance;if(!b||typeof b.getEntriesByName!="function")return null;var S=this[g];if(!p.src||!n.checkAPI(p.src,!1))return this;var v=p.timeStamp||b.now(),_=b.getEntriesByName(p.src,"resource");return n.each(_,function(E){S.has(E)||v-E.responseEnd<100&&S.set(E,{success:0})}),this},resourceComboReport:function(){var p=this[l]||{},b=this._conf.resourceSlow||2e3,S=this[g];this[l]={};var v=Object.keys(p);if(v.length!==0){var _=[];n.each(v,function(A){var T=p[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:[]};n.each(T,function(k){var P=k.timing||{},H=S.get(k.timing),q=H?H.success:1,X=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,q||(I.err_count+=1,I.err_duration+=k.duration),X&&(I.slow_count+=1,I.slow_duration+=k.duration);try{var J=JSON.parse(JSON.stringify(P));J.success=q,J.resourceSlow=b,J.isSlow=X,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 E={_combo:1,resource:JSON.stringify(_)},y=u.navigator.connection;E.ct=y?y.effectiveType||y.type:"";var R=y&&(y.downlink||y.downlinkMax||y.bandwidth)||null;(R=R>999?999:R)&&(E.bandwidth=R),this._lg("resource",E,this.getConfig("sample"))}}})},Ji}()(c,i),c._super=o,c._root=o._root,o.Browser=c,rt.exports=c,rt.exports}var En={getArmsLogger:function(){return function(){if(ns)return Vt.exports;function s(r,a){var c=o[t]=new e(r);c.sendPipe(a);var n=c._conf;return n.autoSendPv!==!1&&c.sendPV(),n&&n.useFmp||c.sendPerformance(),n&&n.sendResource&&c.sendResources(),o[i]=!0,c}ns=1;var o=window,e=o.BrowserLogger=_n(),t=ke().key,i="__hasInitBlSdk";return e.singleton=function(r,a){return o[i]?o[t]:s(r,a)},e.createExtraInstance=function(r){r&&typeof r=="object"&&r.enableInstanceAutoSend!==!0&&(r.enableInstanceAutoSend=!1);var a=new e(r),c=a._conf;return c.enableInstanceAutoSend&&(c.autoSendPv!==!1&&a.sendPV(),c&&c.useFmp||a.sendPerformance(),c&&c.sendResource&&a.sendResources()),a},typeof window=="object"&&window.navigator&&o[t]&&(e.bl=function(){if(o[i])return o[t];var r={},a=[];return t in o&&(r=o[t].config||{},a=o[t].pipe||[]),s(r,a)}()),Vt.exports=e,Vt.exports}()}};const cs="https://arms-retcode.aliyuncs.com/r.png?",hs="https://arms-retcode-sg.aliyuncs.com/r.png?",ds="https://retcode-us-west-1.arms.aliyuncs.com/r.png?",ls="e1iftji1w7@7ec1cef2cc88733",us="e1iftji1w7@10a06d1ec260adc",ps="e1iftji1w7@10a06d1ec260adc",qi={cn:{reportUrl:cs,pid:ls},"cn-hangzhou":{reportUrl:cs,pid:ls},sg:{reportUrl:hs,pid:us},"ap-southeast-1":{reportUrl:hs,pid:us},usw:{reportUrl:ds,pid:ps},"us-west-1":{reportUrl:ds,pid:ps}},Tn=s=>!!Object.isExtensible(s)&&(o=>Object.prototype.toString.call(o).slice(8,-1))(s)==="Object";function gs(s,o){if(typeof s!="string")return!1;const e=s.indexOf(o);if(e<0)return!1;const t=s.indexOf(`
|
|
5
|
-
`);return t<0||e<t}function
|
|
6
|
-
`);return
|
|
7
|
-
`+e),console.error("Failed log data:",s))}}function
|
|
8
|
-
`+a),console.error("Failed log data:",s))}},new Promise((a,c)=>{var n=u=>{try{d(r.next(u))}catch(f){c(f)}},h=u=>{try{d(r.throw(u))}catch(f){c(f)}},d=u=>u.done?a(u.value):Promise.resolve(u.value).then(n,h);d((r=r.apply(t,i)).next())});var t,i,r}class er extends kn{constructor(o){super(Object.assign({},o,{installUnloadHook:e=>{window.addEventListener("beforeunload",()=>{e()})},sendPayload:(e,t)=>{Pn(e,t)}}))}useStsPlugin(o){this.getOpt().sendPayload=(e,t)=>{Mn(e,t,o)},this.overwriteTransString(o)}}vs(window,"SLS_Tracker",er);var tr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ln(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Dn(s){if(s.__esModule)return s;var o=s.default;if(typeof o=="function"){var e=function t(){return this instanceof t?Reflect.construct(o,arguments,this.constructor):o.apply(this,arguments)};e.prototype=o.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 Rs={exports:{}},As={exports:{}};const Nn=Dn(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var _s;function se(){return _s||(_s=1,function(s){s.exports=function(){var o=o||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&&tr!==void 0&&tr.crypto&&(i=tr.crypto),!i)try{i=Nn}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.")},a=Object.create||function(){function S(){}return function(v){var _;return S.prototype=v,_=new S,S.prototype=null,_}}(),c={},n=c.lib={},h=n.Base={extend:function(S){var v=a(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)}},d=n.WordArray=h.extend({init:function(S,v){S=this.words=S||[],this.sigBytes=v!=t?v:4*S.length},toString:function(S){return(S||f).stringify(this)},concat:function(S){var v=this.words,_=S.words,E=this.sigBytes,y=S.sigBytes;if(this.clamp(),E%4)for(var R=0;R<y;R++){var A=_[R>>>2]>>>24-R%4*8&255;v[E+R>>>2]|=A<<24-(E+R)%4*8}else for(var T=0;T<y;T+=4)v[E+T>>>2]=_[T>>>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=h.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 d.init(v,S)}}),u=c.enc={},f=u.Hex={stringify:function(S){for(var v=S.words,_=S.sigBytes,E=[],y=0;y<_;y++){var R=v[y>>>2]>>>24-y%4*8&255;E.push((R>>>4).toString(16)),E.push((15&R).toString(16))}return E.join("")},parse:function(S){for(var v=S.length,_=[],E=0;E<v;E+=2)_[E>>>3]|=parseInt(S.substr(E,2),16)<<24-E%8*4;return new d.init(_,v/2)}},l=u.Latin1={stringify:function(S){for(var v=S.words,_=S.sigBytes,E=[],y=0;y<_;y++){var R=v[y>>>2]>>>24-y%4*8&255;E.push(String.fromCharCode(R))}return E.join("")},parse:function(S){for(var v=S.length,_=[],E=0;E<v;E++)_[E>>>2]|=(255&S.charCodeAt(E))<<24-E%4*8;return new d.init(_,v)}},g=u.Utf8={stringify:function(S){try{return decodeURIComponent(escape(l.stringify(S)))}catch(v){throw new Error("Malformed UTF-8 data")}},parse:function(S){return l.parse(unescape(encodeURIComponent(S)))}},p=n.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new d.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,E=_.words,y=_.sigBytes,R=this.blockSize,A=y/(4*R),T=(A=S?e.ceil(A):e.max((0|A)-this._minBufferSize,0))*R,I=e.min(4*T,y);if(T){for(var k=0;k<T;k+=R)this._doProcessBlock(E,k);v=E.splice(0,T),_.sigBytes-=I}return new d.init(v,I)},clone:function(){var S=h.clone.call(this);return S._data=this._data.clone(),S},_minBufferSize:0});n.Hasher=p.extend({cfg:h.extend(),init:function(S){this.cfg=this.cfg.extend(S),this.reset()},reset:function(){p.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 o}()}(As)),As.exports}var Es,Ts={exports:{}};function Ai(){return Es||(Es=1,function(s){s.exports=function(o){return i=(t=o).lib,r=i.Base,a=i.WordArray,(c=t.x64={}).Word=r.extend({init:function(n,h){this.high=n,this.low=h}}),c.WordArray=r.extend({init:function(n,h){n=this.words=n||[],this.sigBytes=h!=e?h:8*n.length},toX32:function(){for(var n=this.words,h=n.length,d=[],u=0;u<h;u++){var f=n[u];d.push(f.high),d.push(f.low)}return a.create(d,this.sigBytes)},clone:function(){for(var n=r.clone.call(this),h=n.words=this.words.slice(0),d=h.length,u=0;u<d;u++)h[u]=h[u].clone();return n}}),o;var e,t,i,r,a,c}(se())}(Ts)),Ts.exports}var Is,ws={exports:{}};function Vn(){return Is||(Is=1,function(s){s.exports=function(o){return function(){if(typeof ArrayBuffer=="function"){var e=o.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 a=r.byteLength,c=[],n=0;n<a;n++)c[n>>>2]|=r[n]<<24-n%4*8;t.call(this,c,a)}else t.apply(this,arguments)};i.prototype=e}}(),o.lib.WordArray}(se())}(ws)),ws.exports}var Cs,ks={exports:{}};function On(){return Cs||(Cs=1,function(s){s.exports=function(o){return function(){var e=o,t=e.lib.WordArray,i=e.enc;function r(a){return a<<8&4278255360|a>>>8&16711935}i.Utf16=i.Utf16BE={stringify:function(a){for(var c=a.words,n=a.sigBytes,h=[],d=0;d<n;d+=2){var u=c[d>>>2]>>>16-d%4*8&65535;h.push(String.fromCharCode(u))}return h.join("")},parse:function(a){for(var c=a.length,n=[],h=0;h<c;h++)n[h>>>1]|=a.charCodeAt(h)<<16-h%2*16;return t.create(n,2*c)}},i.Utf16LE={stringify:function(a){for(var c=a.words,n=a.sigBytes,h=[],d=0;d<n;d+=2){var u=r(c[d>>>2]>>>16-d%4*8&65535);h.push(String.fromCharCode(u))}return h.join("")},parse:function(a){for(var c=a.length,n=[],h=0;h<c;h++)n[h>>>1]|=r(a.charCodeAt(h)<<16-h%2*16);return t.create(n,2*c)}}}(),o.enc.Utf16}(se())}(ks)),ks.exports}var Ps,Ms={exports:{}};function Ot(){return Ps||(Ps=1,function(s){s.exports=function(o){return function(){var e=o,t=e.lib.WordArray;function i(r,a,c){for(var n=[],h=0,d=0;d<a;d++)if(d%4){var u=c[r.charCodeAt(d-1)]<<d%4*2|c[r.charCodeAt(d)]>>>6-d%4*2;n[h>>>2]|=u<<24-h%4*8,h++}return t.create(n,h)}e.enc.Base64={stringify:function(r){var a=r.words,c=r.sigBytes,n=this._map;r.clamp();for(var h=[],d=0;d<c;d+=3)for(var u=(a[d>>>2]>>>24-d%4*8&255)<<16|(a[d+1>>>2]>>>24-(d+1)%4*8&255)<<8|a[d+2>>>2]>>>24-(d+2)%4*8&255,f=0;f<4&&d+.75*f<c;f++)h.push(n.charAt(u>>>6*(3-f)&63));var l=n.charAt(64);if(l)for(;h.length%4;)h.push(l);return h.join("")},parse:function(r){var a=r.length,c=this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var h=0;h<c.length;h++)n[c.charCodeAt(h)]=h}var d=c.charAt(64);if(d){var u=r.indexOf(d);u!==-1&&(a=u)}return i(r,a,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),o.enc.Base64}(se())}(Ms)),Ms.exports}var Ls,Ds={exports:{}};function xn(){return Ls||(Ls=1,function(s){s.exports=function(o){return function(){var e=o,t=e.lib.WordArray;function i(r,a,c){for(var n=[],h=0,d=0;d<a;d++)if(d%4){var u=c[r.charCodeAt(d-1)]<<d%4*2|c[r.charCodeAt(d)]>>>6-d%4*2;n[h>>>2]|=u<<24-h%4*8,h++}return t.create(n,h)}e.enc.Base64url={stringify:function(r,a){a===void 0&&(a=!0);var c=r.words,n=r.sigBytes,h=a?this._safe_map:this._map;r.clamp();for(var d=[],u=0;u<n;u+=3)for(var f=(c[u>>>2]>>>24-u%4*8&255)<<16|(c[u+1>>>2]>>>24-(u+1)%4*8&255)<<8|c[u+2>>>2]>>>24-(u+2)%4*8&255,l=0;l<4&&u+.75*l<n;l++)d.push(h.charAt(f>>>6*(3-l)&63));var g=h.charAt(64);if(g)for(;d.length%4;)d.push(g);return d.join("")},parse:function(r,a){a===void 0&&(a=!0);var c=r.length,n=a?this._safe_map:this._map,h=this._reverseMap;if(!h){h=this._reverseMap=[];for(var d=0;d<n.length;d++)h[n.charCodeAt(d)]=d}var u=n.charAt(64);if(u){var f=r.indexOf(u);f!==-1&&(c=f)}return i(r,c,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"}}(),o.enc.Base64url}(se())}(Ds)),Ds.exports}var Ns,Vs={exports:{}};function xt(){return Ns||(Ns=1,function(s){s.exports=function(o){return function(e){var t=o,i=t.lib,r=i.WordArray,a=i.Hasher,c=t.algo,n=[];(function(){for(var g=0;g<64;g++)n[g]=4294967296*e.abs(e.sin(g+1))|0})();var h=c.MD5=a.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(g,p){for(var b=0;b<16;b++){var S=p+b,v=g[S];g[S]=16711935&(v<<8|v>>>24)|4278255360&(v<<24|v>>>8)}var _=this._hash.words,E=g[p+0],y=g[p+1],R=g[p+2],A=g[p+3],T=g[p+4],I=g[p+5],k=g[p+6],P=g[p+7],H=g[p+8],q=g[p+9],X=g[p+10],J=g[p+11],z=g[p+12],Z=g[p+13],ee=g[p+14],he=g[p+15],L=_[0],N=_[1],D=_[2],V=_[3];L=d(L,N,D,V,E,7,n[0]),V=d(V,L,N,D,y,12,n[1]),D=d(D,V,L,N,R,17,n[2]),N=d(N,D,V,L,A,22,n[3]),L=d(L,N,D,V,T,7,n[4]),V=d(V,L,N,D,I,12,n[5]),D=d(D,V,L,N,k,17,n[6]),N=d(N,D,V,L,P,22,n[7]),L=d(L,N,D,V,H,7,n[8]),V=d(V,L,N,D,q,12,n[9]),D=d(D,V,L,N,X,17,n[10]),N=d(N,D,V,L,J,22,n[11]),L=d(L,N,D,V,z,7,n[12]),V=d(V,L,N,D,Z,12,n[13]),D=d(D,V,L,N,ee,17,n[14]),L=u(L,N=d(N,D,V,L,he,22,n[15]),D,V,y,5,n[16]),V=u(V,L,N,D,k,9,n[17]),D=u(D,V,L,N,J,14,n[18]),N=u(N,D,V,L,E,20,n[19]),L=u(L,N,D,V,I,5,n[20]),V=u(V,L,N,D,X,9,n[21]),D=u(D,V,L,N,he,14,n[22]),N=u(N,D,V,L,T,20,n[23]),L=u(L,N,D,V,q,5,n[24]),V=u(V,L,N,D,ee,9,n[25]),D=u(D,V,L,N,A,14,n[26]),N=u(N,D,V,L,H,20,n[27]),L=u(L,N,D,V,Z,5,n[28]),V=u(V,L,N,D,R,9,n[29]),D=u(D,V,L,N,P,14,n[30]),L=f(L,N=u(N,D,V,L,z,20,n[31]),D,V,I,4,n[32]),V=f(V,L,N,D,H,11,n[33]),D=f(D,V,L,N,J,16,n[34]),N=f(N,D,V,L,ee,23,n[35]),L=f(L,N,D,V,y,4,n[36]),V=f(V,L,N,D,T,11,n[37]),D=f(D,V,L,N,P,16,n[38]),N=f(N,D,V,L,X,23,n[39]),L=f(L,N,D,V,Z,4,n[40]),V=f(V,L,N,D,E,11,n[41]),D=f(D,V,L,N,A,16,n[42]),N=f(N,D,V,L,k,23,n[43]),L=f(L,N,D,V,q,4,n[44]),V=f(V,L,N,D,z,11,n[45]),D=f(D,V,L,N,he,16,n[46]),L=l(L,N=f(N,D,V,L,R,23,n[47]),D,V,E,6,n[48]),V=l(V,L,N,D,P,10,n[49]),D=l(D,V,L,N,ee,15,n[50]),N=l(N,D,V,L,I,21,n[51]),L=l(L,N,D,V,z,6,n[52]),V=l(V,L,N,D,A,10,n[53]),D=l(D,V,L,N,X,15,n[54]),N=l(N,D,V,L,y,21,n[55]),L=l(L,N,D,V,H,6,n[56]),V=l(V,L,N,D,he,10,n[57]),D=l(D,V,L,N,k,15,n[58]),N=l(N,D,V,L,Z,21,n[59]),L=l(L,N,D,V,T,6,n[60]),V=l(V,L,N,D,J,10,n[61]),D=l(D,V,L,N,R,15,n[62]),N=l(N,D,V,L,q,21,n[63]),_[0]=_[0]+L|0,_[1]=_[1]+N|0,_[2]=_[2]+D|0,_[3]=_[3]+V|0},_doFinalize:function(){var g=this._data,p=g.words,b=8*this._nDataBytes,S=8*g.sigBytes;p[S>>>5]|=128<<24-S%32;var v=e.floor(b/4294967296),_=b;p[15+(S+64>>>9<<4)]=16711935&(v<<8|v>>>24)|4278255360&(v<<24|v>>>8),p[14+(S+64>>>9<<4)]=16711935&(_<<8|_>>>24)|4278255360&(_<<24|_>>>8),g.sigBytes=4*(p.length+1),this._process();for(var E=this._hash,y=E.words,R=0;R<4;R++){var A=y[R];y[R]=16711935&(A<<8|A>>>24)|4278255360&(A<<24|A>>>8)}return E},clone:function(){var g=a.clone.call(this);return g._hash=this._hash.clone(),g}});function d(g,p,b,S,v,_,E){var y=g+(p&b|~p&S)+v+E;return(y<<_|y>>>32-_)+p}function u(g,p,b,S,v,_,E){var y=g+(p&S|b&~S)+v+E;return(y<<_|y>>>32-_)+p}function f(g,p,b,S,v,_,E){var y=g+(p^b^S)+v+E;return(y<<_|y>>>32-_)+p}function l(g,p,b,S,v,_,E){var y=g+(b^(p|~S))+v+E;return(y<<_|y>>>32-_)+p}t.MD5=a._createHelper(h),t.HmacMD5=a._createHmacHelper(h)}(Math),o.MD5}(se())}(Vs)),Vs.exports}var Os,xs={exports:{}};function Us(){return Os||(Os=1,function(s){s.exports=function(o){return t=(e=o).lib,i=t.WordArray,r=t.Hasher,a=e.algo,c=[],n=a.SHA1=r.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(h,d){for(var u=this._hash.words,f=u[0],l=u[1],g=u[2],p=u[3],b=u[4],S=0;S<80;S++){if(S<16)c[S]=0|h[d+S];else{var v=c[S-3]^c[S-8]^c[S-14]^c[S-16];c[S]=v<<1|v>>>31}var _=(f<<5|f>>>27)+b+c[S];_+=S<20?1518500249+(l&g|~l&p):S<40?1859775393+(l^g^p):S<60?(l&g|l&p|g&p)-1894007588:(l^g^p)-899497514,b=p,p=g,g=l<<30|l>>>2,l=f,f=_}u[0]=u[0]+f|0,u[1]=u[1]+l|0,u[2]=u[2]+g|0,u[3]=u[3]+p|0,u[4]=u[4]+b|0},_doFinalize:function(){var h=this._data,d=h.words,u=8*this._nDataBytes,f=8*h.sigBytes;return d[f>>>5]|=128<<24-f%32,d[14+(f+64>>>9<<4)]=Math.floor(u/4294967296),d[15+(f+64>>>9<<4)]=u,h.sigBytes=4*d.length,this._process(),this._hash},clone:function(){var h=r.clone.call(this);return h._hash=this._hash.clone(),h}}),e.SHA1=r._createHelper(n),e.HmacSHA1=r._createHmacHelper(n),o.SHA1;var e,t,i,r,a,c,n}(se())}(xs)),xs.exports}var Bs,Hs={exports:{}};function ir(){return Bs||(Bs=1,function(s){s.exports=function(o){return function(e){var t=o,i=t.lib,r=i.WordArray,a=i.Hasher,c=t.algo,n=[],h=[];(function(){function f(b){for(var S=e.sqrt(b),v=2;v<=S;v++)if(!(b%v))return!1;return!0}function l(b){return 4294967296*(b-(0|b))|0}for(var g=2,p=0;p<64;)f(g)&&(p<8&&(n[p]=l(e.pow(g,.5))),h[p]=l(e.pow(g,1/3)),p++),g++})();var d=[],u=c.SHA256=a.extend({_doReset:function(){this._hash=new r.init(n.slice(0))},_doProcessBlock:function(f,l){for(var g=this._hash.words,p=g[0],b=g[1],S=g[2],v=g[3],_=g[4],E=g[5],y=g[6],R=g[7],A=0;A<64;A++){if(A<16)d[A]=0|f[l+A];else{var T=d[A-15],I=(T<<25|T>>>7)^(T<<14|T>>>18)^T>>>3,k=d[A-2],P=(k<<15|k>>>17)^(k<<13|k>>>19)^k>>>10;d[A]=I+d[A-7]+P+d[A-16]}var H=p&b^p&S^b&S,q=(p<<30|p>>>2)^(p<<19|p>>>13)^(p<<10|p>>>22),X=R+((_<<26|_>>>6)^(_<<21|_>>>11)^(_<<7|_>>>25))+(_&E^~_&y)+h[A]+d[A];R=y,y=E,E=_,_=v+X|0,v=S,S=b,b=p,p=X+(q+H)|0}g[0]=g[0]+p|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]+E|0,g[6]=g[6]+y|0,g[7]=g[7]+R|0},_doFinalize:function(){var f=this._data,l=f.words,g=8*this._nDataBytes,p=8*f.sigBytes;return l[p>>>5]|=128<<24-p%32,l[14+(p+64>>>9<<4)]=e.floor(g/4294967296),l[15+(p+64>>>9<<4)]=g,f.sigBytes=4*l.length,this._process(),this._hash},clone:function(){var f=a.clone.call(this);return f._hash=this._hash.clone(),f}});t.SHA256=a._createHelper(u),t.HmacSHA256=a._createHmacHelper(u)}(Math),o.SHA256}(se())}(Hs)),Hs.exports}var Fs,Un={exports:{}},js,zs={exports:{}};function Ks(){return js||(js=1,function(s){s.exports=function(o){return function(){var e=o,t=e.lib.Hasher,i=e.x64,r=i.Word,a=i.WordArray,c=e.algo;function n(){return r.create.apply(r,arguments)}var h=[n(1116352408,3609767458),n(1899447441,602891725),n(3049323471,3964484399),n(3921009573,2173295548),n(961987163,4081628472),n(1508970993,3053834265),n(2453635748,2937671579),n(2870763221,3664609560),n(3624381080,2734883394),n(310598401,1164996542),n(607225278,1323610764),n(1426881987,3590304994),n(1925078388,4068182383),n(2162078206,991336113),n(2614888103,633803317),n(3248222580,3479774868),n(3835390401,2666613458),n(4022224774,944711139),n(264347078,2341262773),n(604807628,2007800933),n(770255983,1495990901),n(1249150122,1856431235),n(1555081692,3175218132),n(1996064986,2198950837),n(2554220882,3999719339),n(2821834349,766784016),n(2952996808,2566594879),n(3210313671,3203337956),n(3336571891,1034457026),n(3584528711,2466948901),n(113926993,3758326383),n(338241895,168717936),n(666307205,1188179964),n(773529912,1546045734),n(1294757372,1522805485),n(1396182291,2643833823),n(1695183700,2343527390),n(1986661051,1014477480),n(2177026350,1206759142),n(2456956037,344077627),n(2730485921,1290863460),n(2820302411,3158454273),n(3259730800,3505952657),n(3345764771,106217008),n(3516065817,3606008344),n(3600352804,1432725776),n(4094571909,1467031594),n(275423344,851169720),n(430227734,3100823752),n(506948616,1363258195),n(659060556,3750685593),n(883997877,3785050280),n(958139571,3318307427),n(1322822218,3812723403),n(1537002063,2003034995),n(1747873779,3602036899),n(1955562222,1575990012),n(2024104815,1125592928),n(2227730452,2716904306),n(2361852424,442776044),n(2428436474,593698344),n(2756734187,3733110249),n(3204031479,2999351573),n(3329325298,3815920427),n(3391569614,3928383900),n(3515267271,566280711),n(3940187606,3454069534),n(4118630271,4000239992),n(116418474,1914138554),n(174292421,2731055270),n(289380356,3203993006),n(460393269,320620315),n(685471733,587496836),n(852142971,1086792851),n(1017036298,365543100),n(1126000580,2618297676),n(1288033470,3409855158),n(1501505948,4234509866),n(1607167915,987167468),n(1816402316,1246189591)],d=[];(function(){for(var f=0;f<80;f++)d[f]=n()})();var u=c.SHA512=t.extend({_doReset:function(){this._hash=new a.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(f,l){for(var g=this._hash.words,p=g[0],b=g[1],S=g[2],v=g[3],_=g[4],E=g[5],y=g[6],R=g[7],A=p.high,T=p.low,I=b.high,k=b.low,P=S.high,H=S.low,q=v.high,X=v.low,J=_.high,z=_.low,Z=E.high,ee=E.low,he=y.high,L=y.low,N=R.high,D=R.low,V=A,ne=T,Re=I,$=k,ue=P,we=H,Ce=q,Ae=X,me=J,be=z,oe=Z,_e=ee,Ue=he,pt=L,Rt=N,gt=D,Me=0;Me<80;Me++){var Ye,Xe,At=d[Me];if(Me<16)Xe=At.high=0|f[l+2*Me],Ye=At.low=0|f[l+2*Me+1];else{var fi=d[Me-15],_t=fi.high,at=fi.low,ei=(_t>>>1|at<<31)^(_t>>>8|at<<24)^_t>>>7,ti=(at>>>1|_t<<31)^(at>>>8|_t<<24)^(at>>>7|_t<<25),nt=d[Me-2],ot=nt.high,mt=nt.low,ct=(ot>>>19|mt<<13)^(ot<<3|mt>>>29)^ot>>>6,Nt=(mt>>>19|ot<<13)^(mt<<3|ot>>>29)^(mt>>>6|ot<<26),Si=d[Me-7],xi=Si.high,gc=Si.low,dn=d[Me-16],mc=dn.high,ln=dn.low;Xe=(Xe=(Xe=ei+xi+((Ye=ti+gc)>>>0<ti>>>0?1:0))+ct+((Ye+=Nt)>>>0<Nt>>>0?1:0))+mc+((Ye+=ln)>>>0<ln>>>0?1:0),At.high=Xe,At.low=Ye}var $t,fc=me&oe^~me&Ue,un=be&_e^~be&pt,Sc=V&Re^V&ue^Re&ue,bc=ne&$^ne&we^$&we,vc=(V>>>28|ne<<4)^(V<<30|ne>>>2)^(V<<25|ne>>>7),pn=(ne>>>28|V<<4)^(ne<<30|V>>>2)^(ne<<25|V>>>7),yc=(me>>>14|be<<18)^(me>>>18|be<<14)^(me<<23|be>>>9),Rc=(be>>>14|me<<18)^(be>>>18|me<<14)^(be<<23|me>>>9),gn=h[Me],Ac=gn.high,mn=gn.low,bi=Rt+yc+(($t=gt+Rc)>>>0<gt>>>0?1:0),fn=pn+bc;Rt=Ue,gt=pt,Ue=oe,pt=_e,oe=me,_e=be,me=Ce+(bi=(bi=(bi=bi+fc+(($t+=un)>>>0<un>>>0?1:0))+Ac+(($t+=mn)>>>0<mn>>>0?1:0))+Xe+(($t+=Ye)>>>0<Ye>>>0?1:0))+((be=Ae+$t|0)>>>0<Ae>>>0?1:0)|0,Ce=ue,Ae=we,ue=Re,we=$,Re=V,$=ne,V=bi+(vc+Sc+(fn>>>0<pn>>>0?1:0))+((ne=$t+fn|0)>>>0<$t>>>0?1:0)|0}T=p.low=T+ne,p.high=A+V+(T>>>0<ne>>>0?1:0),k=b.low=k+$,b.high=I+Re+(k>>>0<$>>>0?1:0),H=S.low=H+we,S.high=P+ue+(H>>>0<we>>>0?1:0),X=v.low=X+Ae,v.high=q+Ce+(X>>>0<Ae>>>0?1:0),z=_.low=z+be,_.high=J+me+(z>>>0<be>>>0?1:0),ee=E.low=ee+_e,E.high=Z+oe+(ee>>>0<_e>>>0?1:0),L=y.low=L+pt,y.high=he+Ue+(L>>>0<pt>>>0?1:0),D=R.low=D+gt,R.high=N+Rt+(D>>>0<gt>>>0?1:0)},_doFinalize:function(){var f=this._data,l=f.words,g=8*this._nDataBytes,p=8*f.sigBytes;return l[p>>>5]|=128<<24-p%32,l[30+(p+128>>>10<<5)]=Math.floor(g/4294967296),l[31+(p+128>>>10<<5)]=g,f.sigBytes=4*l.length,this._process(),this._hash.toX32()},clone:function(){var f=t.clone.call(this);return f._hash=this._hash.clone(),f},blockSize:32});e.SHA512=t._createHelper(u),e.HmacSHA512=t._createHmacHelper(u)}(),o.SHA512}(se(),Ai())}(zs)),zs.exports}var Ws,Bn={exports:{}},$s,Js={exports:{}};function Hn(){return $s||($s=1,function(s){s.exports=function(o){return function(e){var t=o,i=t.lib,r=i.WordArray,a=i.Hasher,c=t.x64.Word,n=t.algo,h=[],d=[],u=[];(function(){for(var g=1,p=0,b=0;b<24;b++){h[g+5*p]=(b+1)*(b+2)/2%64;var S=(2*g+3*p)%5;g=p%5,p=S}for(g=0;g<5;g++)for(p=0;p<5;p++)d[g+5*p]=p+(2*g+3*p)%5*5;for(var v=1,_=0;_<24;_++){for(var E=0,y=0,R=0;R<7;R++){if(1&v){var A=(1<<R)-1;A<32?y^=1<<A:E^=1<<A-32}128&v?v=v<<1^113:v<<=1}u[_]=c.create(E,y)}})();var f=[];(function(){for(var g=0;g<25;g++)f[g]=c.create()})();var l=n.SHA3=a.extend({cfg:a.cfg.extend({outputLength:512}),_doReset:function(){for(var g=this._state=[],p=0;p<25;p++)g[p]=new c.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(g,p){for(var b=this._state,S=this.blockSize/2,v=0;v<S;v++){var _=g[p+2*v],E=g[p+2*v+1];_=16711935&(_<<8|_>>>24)|4278255360&(_<<24|_>>>8),E=16711935&(E<<8|E>>>24)|4278255360&(E<<24|E>>>8),(D=b[v]).high^=E,D.low^=_}for(var y=0;y<24;y++){for(var R=0;R<5;R++){for(var A=0,T=0,I=0;I<5;I++)A^=(D=b[R+5*I]).high,T^=D.low;var k=f[R];k.high=A,k.low=T}for(R=0;R<5;R++){var P=f[(R+4)%5],H=f[(R+1)%5],q=H.high,X=H.low;for(A=P.high^(q<<1|X>>>31),T=P.low^(X<<1|q>>>31),I=0;I<5;I++)(D=b[R+5*I]).high^=A,D.low^=T}for(var J=1;J<25;J++){var z=(D=b[J]).high,Z=D.low,ee=h[J];ee<32?(A=z<<ee|Z>>>32-ee,T=Z<<ee|z>>>32-ee):(A=Z<<ee-32|z>>>64-ee,T=z<<ee-32|Z>>>64-ee);var he=f[d[J]];he.high=A,he.low=T}var L=f[0],N=b[0];for(L.high=N.high,L.low=N.low,R=0;R<5;R++)for(I=0;I<5;I++){var D=b[J=R+5*I],V=f[J],ne=f[(R+1)%5+5*I],Re=f[(R+2)%5+5*I];D.high=V.high^~ne.high&Re.high,D.low=V.low^~ne.low&Re.low}D=b[0];var $=u[y];D.high^=$.high,D.low^=$.low}},_doFinalize:function(){var g=this._data,p=g.words;this._nDataBytes;var b=8*g.sigBytes,S=32*this.blockSize;p[b>>>5]|=1<<24-b%32,p[(e.ceil((b+1)/S)*S>>>5)-1]|=128,g.sigBytes=4*p.length,this._process();for(var v=this._state,_=this.cfg.outputLength/8,E=_/8,y=[],R=0;R<E;R++){var A=v[R],T=A.high,I=A.low;T=16711935&(T<<8|T>>>24)|4278255360&(T<<24|T>>>8),I=16711935&(I<<8|I>>>24)|4278255360&(I<<24|I>>>8),y.push(I),y.push(T)}return new r.init(y,_)},clone:function(){for(var g=a.clone.call(this),p=g._state=this._state.slice(0),b=0;b<25;b++)p[b]=p[b].clone();return g}});t.SHA3=a._createHelper(l),t.HmacSHA3=a._createHmacHelper(l)}(Math),o.SHA3}(se(),Ai())}(Js)),Js.exports}var Gs,Fn={exports:{}},qs,Ys={exports:{}};function rr(){return qs||(qs=1,function(s){s.exports=function(o){var e,t,i;t=(e=o).lib.Base,i=e.enc.Utf8,e.algo.HMAC=t.extend({init:function(r,a){r=this._hasher=new r.init,typeof a=="string"&&(a=i.parse(a));var c=r.blockSize,n=4*c;a.sigBytes>n&&(a=r.finalize(a)),a.clamp();for(var h=this._oKey=a.clone(),d=this._iKey=a.clone(),u=h.words,f=d.words,l=0;l<c;l++)u[l]^=1549556828,f[l]^=909522486;h.sigBytes=d.sigBytes=n,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 a=this._hasher,c=a.finalize(r);return a.reset(),a.finalize(this._oKey.clone().concat(c))}})}(se())}(Ys)),Ys.exports}var Xs,jn={exports:{}},Qs,Zs={exports:{}};function It(){return Qs||(Qs=1,function(s){s.exports=function(o){return t=(e=o).lib,i=t.Base,r=t.WordArray,a=e.algo,c=a.MD5,n=a.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:c,iterations:1}),init:function(h){this.cfg=this.cfg.extend(h)},compute:function(h,d){for(var u,f=this.cfg,l=f.hasher.create(),g=r.create(),p=g.words,b=f.keySize,S=f.iterations;p.length<b;){u&&l.update(u),u=l.update(h).finalize(d),l.reset();for(var v=1;v<S;v++)u=l.finalize(u),l.reset();g.concat(u)}return g.sigBytes=4*b,g}}),e.EvpKDF=function(h,d,u){return n.create(u).compute(h,d)},o.EvpKDF;var e,t,i,r,a,c,n}(se(),Us(),rr())}(Zs)),Zs.exports}var ea,ta={exports:{}};function Le(){return ea||(ea=1,function(s){s.exports=function(o){o.lib.Cipher||function(e){var t=o,i=t.lib,r=i.Base,a=i.WordArray,c=i.BufferedBlockAlgorithm,n=t.enc;n.Utf8;var h=n.Base64,d=t.algo.EvpKDF,u=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"?E:v}return function(R){return{encrypt:function(A,T,I){return y(T).encrypt(R,A,T,I)},decrypt:function(A,T,I){return y(T).decrypt(R,A,T,I)}}}}()});i.StreamCipher=u.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var f=t.mode={},l=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=f.CBC=function(){var y=l.extend();function R(A,T,I){var k,P=this._iv;P?(k=P,this._iv=e):k=this._prevBlock;for(var H=0;H<I;H++)A[T+H]^=k[H]}return y.Encryptor=y.extend({processBlock:function(A,T){var I=this._cipher,k=I.blockSize;R.call(this,A,T,k),I.encryptBlock(A,T),this._prevBlock=A.slice(T,T+k)}}),y.Decryptor=y.extend({processBlock:function(A,T){var I=this._cipher,k=I.blockSize,P=A.slice(T,T+k);I.decryptBlock(A,T),R.call(this,A,T,k),this._prevBlock=P}}),y}(),p=(t.pad={}).Pkcs7={pad:function(y,R){for(var A=4*R,T=A-y.sigBytes%A,I=T<<24|T<<16|T<<8|T,k=[],P=0;P<T;P+=4)k.push(I);var H=a.create(k,T);y.concat(H)},unpad:function(y){var R=255&y.words[y.sigBytes-1>>>2];y.sigBytes-=R}};i.BlockCipher=u.extend({cfg:u.cfg.extend({mode:g,padding:p}),reset:function(){var y;u.reset.call(this);var R=this.cfg,A=R.iv,T=R.mode;this._xformMode==this._ENC_XFORM_MODE?y=T.createEncryptor:(y=T.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==y?this._mode.init(this,A&&A.words):(this._mode=y.call(T,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?a.create([1398893684,1701076831]).concat(A).concat(R):R).toString(h)},parse:function(y){var R,A=h.parse(y),T=A.words;return T[0]==1398893684&&T[1]==1701076831&&(R=a.create(T.slice(2,4)),T.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,T){T=this.cfg.extend(T);var I=y.createEncryptor(A,T),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:T.format})},decrypt:function(y,R,A,T){return T=this.cfg.extend(T),R=this._parse(R,T.format),y.createDecryptor(A,T).finalize(R.ciphertext)},_parse:function(y,R){return typeof y=="string"?R.parse(y,this):y}}),_=(t.kdf={}).OpenSSL={execute:function(y,R,A,T,I){if(T||(T=a.random(8)),I)k=d.create({keySize:R+A,hasher:I}).compute(y,T);else var k=d.create({keySize:R+A}).compute(y,T);var P=a.create(k.words.slice(R),4*A);return k.sigBytes=4*R,b.create({key:k,iv:P,salt:T})}},E=i.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:_}),encrypt:function(y,R,A,T){var I=(T=this.cfg.extend(T)).kdf.execute(A,y.keySize,y.ivSize,T.salt,T.hasher);T.iv=I.iv;var k=v.encrypt.call(this,y,R,I.key,T);return k.mixIn(I),k},decrypt:function(y,R,A,T){T=this.cfg.extend(T),R=this._parse(R,T.format);var I=T.kdf.execute(A,y.keySize,y.ivSize,R.salt,T.hasher);return T.iv=I.iv,v.decrypt.call(this,y,R,I.key,T)}})}()}(se(),It())}(ta)),ta.exports}var ia,ra={exports:{}};function zn(){return ia||(ia=1,function(s){s.exports=function(o){return o.mode.CFB=function(){var e=o.lib.BlockCipherMode.extend();function t(i,r,a,c){var n,h=this._iv;h?(n=h.slice(0),this._iv=void 0):n=this._prevBlock,c.encryptBlock(n,0);for(var d=0;d<a;d++)i[r+d]^=n[d]}return e.Encryptor=e.extend({processBlock:function(i,r){var a=this._cipher,c=a.blockSize;t.call(this,i,r,c,a),this._prevBlock=i.slice(r,r+c)}}),e.Decryptor=e.extend({processBlock:function(i,r){var a=this._cipher,c=a.blockSize,n=i.slice(r,r+c);t.call(this,i,r,c,a),this._prevBlock=n}}),e}(),o.mode.CFB}(se(),Le())}(ra)),ra.exports}var sa,aa={exports:{}};function Kn(){return sa||(sa=1,function(s){s.exports=function(o){return o.mode.CTR=(e=o.lib.BlockCipherMode.extend(),t=e.Encryptor=e.extend({processBlock:function(i,r){var a=this._cipher,c=a.blockSize,n=this._iv,h=this._counter;n&&(h=this._counter=n.slice(0),this._iv=void 0);var d=h.slice(0);a.encryptBlock(d,0),h[c-1]=h[c-1]+1|0;for(var u=0;u<c;u++)i[r+u]^=d[u]}}),e.Decryptor=t,e),o.mode.CTR;var e,t}(se(),Le())}(aa)),aa.exports}var na,oa={exports:{}};function Wn(){return na||(na=1,function(s){s.exports=function(o){return o.mode.CTRGladman=function(){var e=o.lib.BlockCipherMode.extend();function t(a){if(255&~(a>>24))a+=1<<24;else{var c=a>>16&255,n=a>>8&255,h=255&a;c===255?(c=0,n===255?(n=0,h===255?h=0:++h):++n):++c,a=0,a+=c<<16,a+=n<<8,a+=h}return a}function i(a){return(a[0]=t(a[0]))===0&&(a[1]=t(a[1])),a}var r=e.Encryptor=e.extend({processBlock:function(a,c){var n=this._cipher,h=n.blockSize,d=this._iv,u=this._counter;d&&(u=this._counter=d.slice(0),this._iv=void 0),i(u);var f=u.slice(0);n.encryptBlock(f,0);for(var l=0;l<h;l++)a[c+l]^=f[l]}});return e.Decryptor=r,e}(),o.mode.CTRGladman}(se(),Le())}(oa)),oa.exports}var ca,ha={exports:{}};function $n(){return ca||(ca=1,function(s){s.exports=function(o){return o.mode.OFB=(e=o.lib.BlockCipherMode.extend(),t=e.Encryptor=e.extend({processBlock:function(i,r){var a=this._cipher,c=a.blockSize,n=this._iv,h=this._keystream;n&&(h=this._keystream=n.slice(0),this._iv=void 0),a.encryptBlock(h,0);for(var d=0;d<c;d++)i[r+d]^=h[d]}}),e.Decryptor=t,e),o.mode.OFB;var e,t}(se(),Le())}(ha)),ha.exports}var da,Jn={exports:{}},la,Gn={exports:{}},ua,qn={exports:{}},pa,Yn={exports:{}},ga,Xn={exports:{}},ma,Qn={exports:{}},fa,Zn={exports:{}},Sa,eo={exports:{}},ba,va={exports:{}};function to(){return ba||(ba=1,function(s){s.exports=function(o){return function(){var e=o,t=e.lib,i=t.WordArray,r=t.BlockCipher,a=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],n=[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],h=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],d=[{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}],u=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],f=a.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 E=this._subKeys=[],y=0;y<16;y++){var R=E[y]=[],A=h[y];for(v=0;v<24;v++)R[v/6|0]|=S[(n[v]-1+A)%28]<<31-v%6,R[4+(v/6|0)]|=S[28+(n[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 T=this._invSubKeys=[];for(v=0;v<16;v++)T[v]=E[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],l.call(this,4,252645135),l.call(this,16,65535),g.call(this,2,858993459),g.call(this,8,16711935),l.call(this,1,1431655765);for(var _=0;_<16;_++){for(var E=v[_],y=this._lBlock,R=this._rBlock,A=0,T=0;T<8;T++)A|=d[T][((R^E[T])&u[T])>>>0];this._lBlock=R,this._rBlock=y^A}var I=this._lBlock;this._lBlock=this._rBlock,this._rBlock=I,l.call(this,1,1431655765),g.call(this,8,16711935),g.call(this,2,858993459),l.call(this,16,65535),l.call(this,4,252645135),b[S]=this._lBlock,b[S+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function l(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(f);var p=a.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=f.createEncryptor(i.create(S)),this._des2=f.createEncryptor(i.create(v)),this._des3=f.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(p)}(),o.TripleDES}(se(),Ot(),xt(),It(),Le())}(va)),va.exports}var ya,io={exports:{}},Ra,ro={exports:{}},Aa,so={exports:{}},_a,Ea={exports:{}};function ao(){return _a||(_a=1,function(s){s.exports=function(o){return function(){var e=o,t=e.lib.BlockCipher,i=e.algo;const r=16,a=[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 n={pbox:[],sbox:[]};function h(g,p){let b=p>>24&255,S=p>>16&255,v=p>>8&255,_=255&p,E=g.sbox[0][b]+g.sbox[1][S];return E^=g.sbox[2][v],E+=g.sbox[3][_],E}function d(g,p,b){let S,v=p,_=b;for(let E=0;E<r;++E)v^=g.pbox[E],_=h(g,v)^_,S=v,v=_,_=S;return S=v,v=_,_=S,_^=g.pbox[r],v^=g.pbox[r+1],{left:v,right:_}}function u(g,p,b){let S,v=p,_=b;for(let E=r+1;E>1;--E)v^=g.pbox[E],_=h(g,v)^_,S=v,v=_,_=S;return S=v,v=_,_=S,_^=g.pbox[1],v^=g.pbox[0],{left:v,right:_}}function f(g,p,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]=a[y]^p[S],S++,S>=b&&(S=0);let v=0,_=0,E=0;for(let y=0;y<r+2;y+=2)E=d(g,v,_),v=E.left,_=E.right,g.pbox[y]=v,g.pbox[y+1]=_;for(let y=0;y<4;y++)for(let R=0;R<256;R+=2)E=d(g,v,_),v=E.left,_=E.right,g.sbox[y][R]=v,g.sbox[y][R+1]=_;return!0}var l=i.Blowfish=t.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var g=this._keyPriorReset=this._key,p=g.words,b=g.sigBytes/4;f(n,p,b)}},encryptBlock:function(g,p){var b=d(n,g[p],g[p+1]);g[p]=b.left,g[p+1]=b.right},decryptBlock:function(g,p){var b=u(n,g[p],g[p+1]);g[p]=b.left,g[p+1]=b.right},blockSize:2,keySize:4,ivSize:2});e.Blowfish=t._createHelper(l)}(),o.Blowfish}(se(),Ot(),xt(),It(),Le())}(Ea)),Ea.exports}(function(s){s.exports=function(o){return o}(se(),Ai(),Vn(),On(),Ot(),xn(),xt(),Us(),ir(),Fs||(Fs=1,function(o){o.exports=function(e){return i=(t=e).lib.WordArray,r=t.algo,a=r.SHA256,c=r.SHA224=a.extend({_doReset:function(){this._hash=new i.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var n=a._doFinalize.call(this);return n.sigBytes-=4,n}}),t.SHA224=a._createHelper(c),t.HmacSHA224=a._createHmacHelper(c),e.SHA224;var t,i,r,a,c}(se(),ir())}(Un)),Ks(),Ws||(Ws=1,function(o){o.exports=function(e){return i=(t=e).x64,r=i.Word,a=i.WordArray,c=t.algo,n=c.SHA512,h=c.SHA384=n.extend({_doReset:function(){this._hash=new a.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 d=n._doFinalize.call(this);return d.sigBytes-=16,d}}),t.SHA384=n._createHelper(h),t.HmacSHA384=n._createHmacHelper(h),e.SHA384;var t,i,r,a,c,n,h}(se(),Ai(),Ks())}(Bn)),Hn(),Gs||(Gs=1,function(o){o.exports=function(e){return function(){var t=e,i=t.lib,r=i.WordArray,a=i.Hasher,c=t.algo,n=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]),h=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]),d=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]),u=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]),f=r.create([0,1518500249,1859775393,2400959708,2840853838]),l=r.create([1352829926,1548603684,1836072691,2053994217,0]),g=c.RIPEMD160=a.extend({_doReset:function(){this._hash=r.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(y,R){for(var A=0;A<16;A++){var T=R+A,I=y[T];y[T]=16711935&(I<<8|I>>>24)|4278255360&(I<<24|I>>>8)}var k,P,H,q,X,J,z,Z,ee,he,L,N=this._hash.words,D=f.words,V=l.words,ne=n.words,Re=h.words,$=d.words,ue=u.words;for(J=k=N[0],z=P=N[1],Z=H=N[2],ee=q=N[3],he=X=N[4],A=0;A<80;A+=1)L=k+y[R+ne[A]]|0,L+=A<16?p(P,H,q)+D[0]:A<32?b(P,H,q)+D[1]:A<48?S(P,H,q)+D[2]:A<64?v(P,H,q)+D[3]:_(P,H,q)+D[4],L=(L=E(L|=0,$[A]))+X|0,k=X,X=q,q=E(H,10),H=P,P=L,L=J+y[R+Re[A]]|0,L+=A<16?_(z,Z,ee)+V[0]:A<32?v(z,Z,ee)+V[1]:A<48?S(z,Z,ee)+V[2]:A<64?b(z,Z,ee)+V[3]:p(z,Z,ee)+V[4],L=(L=E(L|=0,ue[A]))+he|0,J=he,he=ee,ee=E(Z,10),Z=z,z=L;L=N[1]+H+ee|0,N[1]=N[2]+q+he|0,N[2]=N[3]+X+J|0,N[3]=N[4]+k+z|0,N[4]=N[0]+P+Z|0,N[0]=L},_doFinalize:function(){var y=this._data,R=y.words,A=8*this._nDataBytes,T=8*y.sigBytes;R[T>>>5]|=128<<24-T%32,R[14+(T+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 H=k[P];k[P]=16711935&(H<<8|H>>>24)|4278255360&(H<<24|H>>>8)}return I},clone:function(){var y=a.clone.call(this);return y._hash=this._hash.clone(),y}});function p(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 E(y,R){return y<<R|y>>>32-R}t.RIPEMD160=a._createHelper(g),t.HmacRIPEMD160=a._createHmacHelper(g)}(),e.RIPEMD160}(se())}(Fn)),rr(),Xs||(Xs=1,function(o){o.exports=function(e){return r=(i=(t=e).lib).Base,a=i.WordArray,n=(c=t.algo).SHA256,h=c.HMAC,d=c.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:n,iterations:25e4}),init:function(u){this.cfg=this.cfg.extend(u)},compute:function(u,f){for(var l=this.cfg,g=h.create(l.hasher,u),p=a.create(),b=a.create([1]),S=p.words,v=b.words,_=l.keySize,E=l.iterations;S.length<_;){var y=g.update(f).finalize(b);g.reset();for(var R=y.words,A=R.length,T=y,I=1;I<E;I++){T=g.finalize(T),g.reset();for(var k=T.words,P=0;P<A;P++)R[P]^=k[P]}p.concat(y),v[0]++}return p.sigBytes=4*_,p}}),t.PBKDF2=function(u,f,l){return d.create(l).compute(u,f)},e.PBKDF2;var t,i,r,a,c,n,h,d}(se(),ir(),rr())}(jn)),It(),Le(),zn(),Kn(),Wn(),$n(),da||(da=1,function(o){o.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}(se(),Le())}(Jn)),la||(la=1,function(o){o.exports=function(e){return e.pad.AnsiX923={pad:function(t,i){var r=t.sigBytes,a=4*i,c=a-r%a,n=r+c-1;t.clamp(),t.words[n>>>2]|=c<<24-n%4*8,t.sigBytes+=c},unpad:function(t){var i=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=i}},e.pad.Ansix923}(se(),Le())}(Gn)),ua||(ua=1,function(o){o.exports=function(e){return e.pad.Iso10126={pad:function(t,i){var r=4*i,a=r-t.sigBytes%r;t.concat(e.lib.WordArray.random(a-1)).concat(e.lib.WordArray.create([a<<24],1))},unpad:function(t){var i=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=i}},e.pad.Iso10126}(se(),Le())}(qn)),pa||(pa=1,function(o){o.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}(se(),Le())}(Yn)),ga||(ga=1,function(o){o.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}(se(),Le())}(Xn)),ma||(ma=1,function(o){o.exports=function(e){return e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding}(se(),Le())}(Qn)),fa||(fa=1,function(o){o.exports=function(e){return i=(t=e).lib.CipherParams,r=t.enc.Hex,t.format.Hex={stringify:function(a){return a.ciphertext.toString(r)},parse:function(a){var c=r.parse(a);return i.create({ciphertext:c})}},e.format.Hex;var t,i,r}(se(),Le())}(Zn)),Sa||(Sa=1,function(o){o.exports=function(e){return function(){var t=e,i=t.lib.BlockCipher,r=t.algo,a=[],c=[],n=[],h=[],d=[],u=[],f=[],l=[],g=[],p=[];(function(){for(var v=[],_=0;_<256;_++)v[_]=_<128?_<<1:_<<1^283;var E=0,y=0;for(_=0;_<256;_++){var R=y^y<<1^y<<2^y<<3^y<<4;R=R>>>8^255&R^99,a[E]=R,c[R]=E;var A=v[E],T=v[A],I=v[T],k=257*v[R]^16843008*R;n[E]=k<<24|k>>>8,h[E]=k<<16|k>>>16,d[E]=k<<8|k>>>24,u[E]=k,k=16843009*I^65537*T^257*A^16843008*E,f[R]=k<<24|k>>>8,l[R]=k<<16|k>>>16,g[R]=k<<8|k>>>24,p[R]=k,E?(E=A^v[v[v[I^A]]],y^=v[v[y]]):E=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,E=v.sigBytes/4,y=4*((this._nRounds=E+6)+1),R=this._keySchedule=[],A=0;A<y;A++)A<E?R[A]=_[A]:(k=R[A-1],A%E?E>6&&A%E==4&&(k=a[k>>>24]<<24|a[k>>>16&255]<<16|a[k>>>8&255]<<8|a[255&k]):(k=a[(k=k<<8|k>>>24)>>>24]<<24|a[k>>>16&255]<<16|a[k>>>8&255]<<8|a[255&k],k^=b[A/E|0]<<24),R[A]=R[A-E]^k);for(var T=this._invKeySchedule=[],I=0;I<y;I++){if(A=y-I,I%4)var k=R[A];else k=R[A-4];T[I]=I<4||A<=4?k:f[a[k>>>24]]^l[a[k>>>16&255]]^g[a[k>>>8&255]]^p[a[255&k]]}}},encryptBlock:function(v,_){this._doCryptBlock(v,_,this._keySchedule,n,h,d,u,a)},decryptBlock:function(v,_){var E=v[_+1];v[_+1]=v[_+3],v[_+3]=E,this._doCryptBlock(v,_,this._invKeySchedule,f,l,g,p,c),E=v[_+1],v[_+1]=v[_+3],v[_+3]=E},_doCryptBlock:function(v,_,E,y,R,A,T,I){for(var k=this._nRounds,P=v[_]^E[0],H=v[_+1]^E[1],q=v[_+2]^E[2],X=v[_+3]^E[3],J=4,z=1;z<k;z++){var Z=y[P>>>24]^R[H>>>16&255]^A[q>>>8&255]^T[255&X]^E[J++],ee=y[H>>>24]^R[q>>>16&255]^A[X>>>8&255]^T[255&P]^E[J++],he=y[q>>>24]^R[X>>>16&255]^A[P>>>8&255]^T[255&H]^E[J++],L=y[X>>>24]^R[P>>>16&255]^A[H>>>8&255]^T[255&q]^E[J++];P=Z,H=ee,q=he,X=L}Z=(I[P>>>24]<<24|I[H>>>16&255]<<16|I[q>>>8&255]<<8|I[255&X])^E[J++],ee=(I[H>>>24]<<24|I[q>>>16&255]<<16|I[X>>>8&255]<<8|I[255&P])^E[J++],he=(I[q>>>24]<<24|I[X>>>16&255]<<16|I[P>>>8&255]<<8|I[255&H])^E[J++],L=(I[X>>>24]<<24|I[P>>>16&255]<<16|I[H>>>8&255]<<8|I[255&q])^E[J++],v[_]=Z,v[_+1]=ee,v[_+2]=he,v[_+3]=L},keySize:8});t.AES=i._createHelper(S)}(),e.AES}(se(),Ot(),xt(),It(),Le())}(eo)),to(),ya||(ya=1,function(o){o.exports=function(e){return function(){var t=e,i=t.lib.StreamCipher,r=t.algo,a=r.RC4=i.extend({_doReset:function(){for(var h=this._key,d=h.words,u=h.sigBytes,f=this._S=[],l=0;l<256;l++)f[l]=l;l=0;for(var g=0;l<256;l++){var p=l%u,b=d[p>>>2]>>>24-p%4*8&255;g=(g+f[l]+b)%256;var S=f[l];f[l]=f[g],f[g]=S}this._i=this._j=0},_doProcessBlock:function(h,d){h[d]^=c.call(this)},keySize:8,ivSize:0});function c(){for(var h=this._S,d=this._i,u=this._j,f=0,l=0;l<4;l++){u=(u+h[d=(d+1)%256])%256;var g=h[d];h[d]=h[u],h[u]=g,f|=h[(h[d]+h[u])%256]<<24-8*l}return this._i=d,this._j=u,f}t.RC4=i._createHelper(a);var n=r.RC4Drop=a.extend({cfg:a.cfg.extend({drop:192}),_doReset:function(){a._doReset.call(this);for(var h=this.cfg.drop;h>0;h--)c.call(this)}});t.RC4Drop=i._createHelper(n)}(),e.RC4}(se(),Ot(),xt(),It(),Le())}(io)),Ra||(Ra=1,function(o){o.exports=function(e){return function(){var t=e,i=t.lib.StreamCipher,r=t.algo,a=[],c=[],n=[],h=r.Rabbit=i.extend({_doReset:function(){for(var u=this._key.words,f=this.cfg.iv,l=0;l<4;l++)u[l]=16711935&(u[l]<<8|u[l]>>>24)|4278255360&(u[l]<<24|u[l]>>>8);var g=this._X=[u[0],u[3]<<16|u[2]>>>16,u[1],u[0]<<16|u[3]>>>16,u[2],u[1]<<16|u[0]>>>16,u[3],u[2]<<16|u[1]>>>16],p=this._C=[u[2]<<16|u[2]>>>16,4294901760&u[0]|65535&u[1],u[3]<<16|u[3]>>>16,4294901760&u[1]|65535&u[2],u[0]<<16|u[0]>>>16,4294901760&u[2]|65535&u[3],u[1]<<16|u[1]>>>16,4294901760&u[3]|65535&u[0]];for(this._b=0,l=0;l<4;l++)d.call(this);for(l=0;l<8;l++)p[l]^=g[l+4&7];if(f){var b=f.words,S=b[0],v=b[1],_=16711935&(S<<8|S>>>24)|4278255360&(S<<24|S>>>8),E=16711935&(v<<8|v>>>24)|4278255360&(v<<24|v>>>8),y=_>>>16|4294901760&E,R=E<<16|65535&_;for(p[0]^=_,p[1]^=y,p[2]^=E,p[3]^=R,p[4]^=_,p[5]^=y,p[6]^=E,p[7]^=R,l=0;l<4;l++)d.call(this)}},_doProcessBlock:function(u,f){var l=this._X;d.call(this),a[0]=l[0]^l[5]>>>16^l[3]<<16,a[1]=l[2]^l[7]>>>16^l[5]<<16,a[2]=l[4]^l[1]>>>16^l[7]<<16,a[3]=l[6]^l[3]>>>16^l[1]<<16;for(var g=0;g<4;g++)a[g]=16711935&(a[g]<<8|a[g]>>>24)|4278255360&(a[g]<<24|a[g]>>>8),u[f+g]^=a[g]},blockSize:4,ivSize:2});function d(){for(var u=this._X,f=this._C,l=0;l<8;l++)c[l]=f[l];for(f[0]=f[0]+1295307597+this._b|0,f[1]=f[1]+3545052371+(f[0]>>>0<c[0]>>>0?1:0)|0,f[2]=f[2]+886263092+(f[1]>>>0<c[1]>>>0?1:0)|0,f[3]=f[3]+1295307597+(f[2]>>>0<c[2]>>>0?1:0)|0,f[4]=f[4]+3545052371+(f[3]>>>0<c[3]>>>0?1:0)|0,f[5]=f[5]+886263092+(f[4]>>>0<c[4]>>>0?1:0)|0,f[6]=f[6]+1295307597+(f[5]>>>0<c[5]>>>0?1:0)|0,f[7]=f[7]+3545052371+(f[6]>>>0<c[6]>>>0?1:0)|0,this._b=f[7]>>>0<c[7]>>>0?1:0,l=0;l<8;l++){var g=u[l]+f[l],p=65535&g,b=g>>>16,S=((p*p>>>17)+p*b>>>15)+b*b,v=((4294901760&g)*g|0)+((65535&g)*g|0);n[l]=S^v}u[0]=n[0]+(n[7]<<16|n[7]>>>16)+(n[6]<<16|n[6]>>>16)|0,u[1]=n[1]+(n[0]<<8|n[0]>>>24)+n[7]|0,u[2]=n[2]+(n[1]<<16|n[1]>>>16)+(n[0]<<16|n[0]>>>16)|0,u[3]=n[3]+(n[2]<<8|n[2]>>>24)+n[1]|0,u[4]=n[4]+(n[3]<<16|n[3]>>>16)+(n[2]<<16|n[2]>>>16)|0,u[5]=n[5]+(n[4]<<8|n[4]>>>24)+n[3]|0,u[6]=n[6]+(n[5]<<16|n[5]>>>16)+(n[4]<<16|n[4]>>>16)|0,u[7]=n[7]+(n[6]<<8|n[6]>>>24)+n[5]|0}t.Rabbit=i._createHelper(h)}(),e.Rabbit}(se(),Ot(),xt(),It(),Le())}(ro)),Aa||(Aa=1,function(o){o.exports=function(e){return function(){var t=e,i=t.lib.StreamCipher,r=t.algo,a=[],c=[],n=[],h=r.RabbitLegacy=i.extend({_doReset:function(){var u=this._key.words,f=this.cfg.iv,l=this._X=[u[0],u[3]<<16|u[2]>>>16,u[1],u[0]<<16|u[3]>>>16,u[2],u[1]<<16|u[0]>>>16,u[3],u[2]<<16|u[1]>>>16],g=this._C=[u[2]<<16|u[2]>>>16,4294901760&u[0]|65535&u[1],u[3]<<16|u[3]>>>16,4294901760&u[1]|65535&u[2],u[0]<<16|u[0]>>>16,4294901760&u[2]|65535&u[3],u[1]<<16|u[1]>>>16,4294901760&u[3]|65535&u[0]];this._b=0;for(var p=0;p<4;p++)d.call(this);for(p=0;p<8;p++)g[p]^=l[p+4&7];if(f){var b=f.words,S=b[0],v=b[1],_=16711935&(S<<8|S>>>24)|4278255360&(S<<24|S>>>8),E=16711935&(v<<8|v>>>24)|4278255360&(v<<24|v>>>8),y=_>>>16|4294901760&E,R=E<<16|65535&_;for(g[0]^=_,g[1]^=y,g[2]^=E,g[3]^=R,g[4]^=_,g[5]^=y,g[6]^=E,g[7]^=R,p=0;p<4;p++)d.call(this)}},_doProcessBlock:function(u,f){var l=this._X;d.call(this),a[0]=l[0]^l[5]>>>16^l[3]<<16,a[1]=l[2]^l[7]>>>16^l[5]<<16,a[2]=l[4]^l[1]>>>16^l[7]<<16,a[3]=l[6]^l[3]>>>16^l[1]<<16;for(var g=0;g<4;g++)a[g]=16711935&(a[g]<<8|a[g]>>>24)|4278255360&(a[g]<<24|a[g]>>>8),u[f+g]^=a[g]},blockSize:4,ivSize:2});function d(){for(var u=this._X,f=this._C,l=0;l<8;l++)c[l]=f[l];for(f[0]=f[0]+1295307597+this._b|0,f[1]=f[1]+3545052371+(f[0]>>>0<c[0]>>>0?1:0)|0,f[2]=f[2]+886263092+(f[1]>>>0<c[1]>>>0?1:0)|0,f[3]=f[3]+1295307597+(f[2]>>>0<c[2]>>>0?1:0)|0,f[4]=f[4]+3545052371+(f[3]>>>0<c[3]>>>0?1:0)|0,f[5]=f[5]+886263092+(f[4]>>>0<c[4]>>>0?1:0)|0,f[6]=f[6]+1295307597+(f[5]>>>0<c[5]>>>0?1:0)|0,f[7]=f[7]+3545052371+(f[6]>>>0<c[6]>>>0?1:0)|0,this._b=f[7]>>>0<c[7]>>>0?1:0,l=0;l<8;l++){var g=u[l]+f[l],p=65535&g,b=g>>>16,S=((p*p>>>17)+p*b>>>15)+b*b,v=((4294901760&g)*g|0)+((65535&g)*g|0);n[l]=S^v}u[0]=n[0]+(n[7]<<16|n[7]>>>16)+(n[6]<<16|n[6]>>>16)|0,u[1]=n[1]+(n[0]<<8|n[0]>>>24)+n[7]|0,u[2]=n[2]+(n[1]<<16|n[1]>>>16)+(n[0]<<16|n[0]>>>16)|0,u[3]=n[3]+(n[2]<<8|n[2]>>>24)+n[1]|0,u[4]=n[4]+(n[3]<<16|n[3]>>>16)+(n[2]<<16|n[2]>>>16)|0,u[5]=n[5]+(n[4]<<8|n[4]>>>24)+n[3]|0,u[6]=n[6]+(n[5]<<16|n[5]>>>16)+(n[4]<<16|n[4]>>>16)|0,u[7]=n[7]+(n[6]<<8|n[6]>>>24)+n[5]|0}t.RabbitLegacy=i._createHelper(h)}(),e.RabbitLegacy}(se(),Ot(),xt(),It(),Le())}(so)),ao())})(Rs);const ri=Ln(Rs.exports);function no(s){return o=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
|
-
`+r)}}return null},new Promise((i,r)=>{var
|
|
10
|
-
`+
|
|
1
|
+
(function(W,q){typeof exports=="object"&&typeof module!="undefined"?q(exports,require("aliyun-rts-sdk"),require("eventemitter3")):typeof define=="function"&&define.amd?define(["exports","aliyun-rts-sdk","eventemitter3"],q):q((W=typeof globalThis!="undefined"?globalThis:W||self).AliRtcEngine={},W.AliyunRts,W.EventEmitter)})(this,function(W,q,se){var Ye,kt,Ze,Fe,Ht,Ft,K,vn;"use strict";var Qe,ci,Ji=Object.defineProperty,Et=(s,a,e)=>(((t,i,r)=>{i in t?Ji(t,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[i]=r})(s,typeof a!="symbol"?a+"":a,e),e),zt={exports:{}},mt={exports:{}};function He(){if(ci)return Qe;ci=1,Date.now=Date.now||function(){return new Date().getTime()};var s=Date.now(),a=function(){},e={noop:a,warn:function(){var t=typeof console=="object"?console.warn:a;try{var i={warn:t};i.warn.call(i)}catch(r){return a}return t}(),key:"__bl",selfErrKey:"ARMS_SDK_ERROR",selfErrPage:"ARMSSDK",win:typeof window=="object"&&window.document?window:void 0,regionMap:{cn:"https://arms-retcode.aliyuncs.com/r.png?",sg:"https://arms-retcode-sg.aliyuncs.com/r.png?",sg_2:"https://retcode-sg-lazada.arms.aliyuncs.com/r.png?",daily:"http://arms-retcode-daily.alibaba.net/r.png?",daily_2:"https://arms-retcode-daily.alibaba.net/r.png?",daily_3:"http://arms-retcode-daily.aliyun.test/r.png?",us:"https://retcode-us-west-1.arms.aliyuncs.com/r.png?",tw:"https://arms-retcode.orientalgame.com.tw/r.png?",tw_sg:"https://arms-retcode-sg.orientalgame.com.tw/r.png?",hz_finance:"https://arms-retcode-hz-finance.aliyuncs.com/r.png?"},defaultImgUrl:"https://arms-retcode.aliyuncs.com/r.png?",createObject:function(t){if(Object.create)return Object.create(t);var i=function(){};return i.prototype=t,new i},each:function(t,i){var r=0,n=t.length;if(this.T(t,"Array"))for(;r<n&&i.call(t[r],t[r],r)!==!1;r++);else for(r in t)if(i.call(t[r],t[r],r)===!1)break;return t},safetyCall:function(t,i,r){if(typeof t!="function")return r;try{return t.apply(this,i)}catch(n){return r}},T:function(t,i){var r=Object.prototype.toString.call(t).substring(8).replace("]","");return i?r===i:r},duration:function(){var t=Date;try{performance&&this.T(performance.now,"Function")&&(t=performance)}catch(r){t=Date}var i=t.now();return function(){return Math.round(t.now()-i)}},filterByRule:function(){var t=[].slice.call(arguments),i=t.length;if(i<2)return t[0];var r=t[i-1],n=t[0];if(!n)return"";if(!r)return n;var c=this,o=c.T(r),h=t.slice(0,i-1);return o==="Function"?c.safetyCall(r,h,n):o==="Array"?(this.each(r,function(l){h[0]=n=c.filterByRule.apply(c,[].concat(h,l))}),n):o==="Object"?n.replace(r.rule,r.target||""):n.replace(r,"")},ignoreByRule:function(t,i){if(!t||!i)return!1;if((this.isString(i)||i.source||this.T(i)==="Function")&&(i=[i]),!this.isArray(i))return this.warn("[arms] invalid rules of ignore config, (list of) String/RegExp/Funcitons are available"),!1;for(var r,n=[],c=0,o=i.length;c<o;c++)if(r=i[c],this.isString(r))n.push(r.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"));else if(r&&r.source)n.push(r.source);else if(r&&this.T(r)==="Function"&&this.safetyCall(r,[t],!1)===!0)return!0;var h=new RegExp(n.join("|"),"i");return!!(n.length&&h.test&&h.test(t))},J:function(t){if(!t||typeof t!="string")return t;var i=null;try{i=JSON.parse(t)}catch(r){}return i},pick:function(t){return t===1||Math.ceil(Math.random()*t)===1},verifyConfig:function(t){if("sample"in t){var i=t.sample,r=i;i&&/^\d+(\.\d+)?%$/.test(i)&&(r=parseInt(100/parseFloat(i))),0<r&&1>r&&(r=parseInt(1/r)),r>=1&&r<=100?t.sample=r:delete t.sample}return t},on:function(t,i,r,n,c){return t.addEventListener?(c=c||!1,t.addEventListener(i,function o(h){n&&t.removeEventListener(i,o,c),r.call(this,h)},c)):t.attachEvent&&t.attachEvent("on"+i,function o(h){n&&t.detachEvent("on"+i,o),r.call(this,h)}),this},off:function(t,i,r){return r?(t.removeEventListener?t.removeEventListener(i,r):t.detachEvent&&t.detachEvent(i,r),this):this},delay:function(t,i){return i===-1?(t(),null):setTimeout(t,i||0)},ext:function(t){for(var i=1,r=arguments.length;i<r;i++){var n=arguments[i];for(var c in n)Object.prototype.hasOwnProperty.call(n,c)&&(t[c]=n[c])}return t},sub:function(t,i){var r={};return this.each(t,function(n,c){i.indexOf(c)!==-1&&(r[c]=n)}),r},uu:function(){for(var t,i,r=20,n=new Array(r),c=Date.now().toString(36).split("");r-- >0;)i=(t=36*Math.random()|0).toString(36),n[r]=t%3?i:i.toUpperCase();for(var o=0;o<8;o++)n.splice(3*o+2,0,c[o]);return n.join("")},guid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var i=16*Math.random()|0;return(t==="x"?i:3&i|8).toString(16)})},seq:function(){return(s++).toString(36)},decode:function(t){try{t=decodeURIComponent(t)}catch(i){}return t},encode:function(t,i){try{t=i?encodeURIComponent(t).replace(/\(/g,"%28").replace(/\)/g,"%29"):encodeURIComponent(t)}catch(r){}return t},serialize:function(t){t=t||{};var i=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&t[r]!==void 0&&i.push(r+"="+this.encode(t[r],r==="msg"));return i.join("&")},checkAPI:function(t,i){if(!t||typeof t!="string")return!1;var r=/arms-retcode[\w-]*\.aliyuncs/.test(t);return!r&&i&&(r=/(alicdn\.com)|(mmstat\.com)/.test(t)),!r},checkAutoError:function(t){return!(!t||!t.message||/failed[\w\s]+fetch/i.test(t.message))},cutUrlSearch:function(t){return t&&typeof t=="string"?t.replace(/^(https?:)?\/\//,"").replace(/\?.*$/,""):""},removeUrlSearch:function(t){return t&&typeof t=="string"?t.replace(/\?.*$/,""):""},createFakeToString:function(t){return function(){return t+"() { [native code] }"}},checkSameOrigin:function(t,i){if(!i||!t)return!1;var r="//"+i.split("/")[2];return t===i||t.slice(0,i.length+1)===i+"/"||t===r||t.slice(0,r.length+1)===r+"/"||!/^(\/\/|http:|https:).*/.test(t)},getRandIP:function(){for(var t=[],i=0;i<4;i++){var r=Math.floor(256*Math.random());t[i]=(r>15?"":"0")+r.toString(16)}return t.join("").replace(/^0/,"1")},getSortNum:function(t){return t?(t+=1)>=1e3&&t<=9999?t:t<1e3?t+1e3:t%1e4+1e3:1e3},getRandNum:function(t){return t&&typeof t=="string"?t.length<5?this.getNum(5):t.substring(t.length-5):this.getNum(5)},getNum:function(t){for(var i=[],r=0;r<t;r++){var n=Math.floor(16*Math.random());i[r]=n.toString(16)}return i.join("")},getCurDomain:function(){return location&&location.hostname||""},getSrcType:function(t,i){var r=location&&location.host||"";if(!r)return"";var n=new URL(t).host;if(n===r)return"self";for(var c=0;c<i.length;c+=1)if(n.includes(i[c]))return"cdn";return"others"},parseFetchHeaders:function(t){if(!t)return{};var i={};try{if(typeof t.keys=="function")for(var r=t.keys(),n=r.next();!n.done;){var c=n.value;i[c]=t.get(c),n=r.next()}else i=t}catch(o){i={}}return i},parseXhrHeaders:function(t){if(!t&&typeof t!="string")return{};var i={};try{i=t.split(`\r
|
|
2
|
+
`).reduce(function(r,n){var c=n.split(": ");return r[c[0]]=c[1],r},{})}catch(r){i={}}return i},getQuerys:function(t){if(!t)return"";var i={},r=[],n="",c="";try{var o=[];if(t.indexOf("?")>=0&&(o=t.substring(t.indexOf("?")+1,t.length).split("&")),o.length>0)for(var h in o)n=(r=o[h].split("="))[0],c=r[1],i[n]=c}catch(l){i={}}return i},getURL:function(t){if(!t)return null;var i={},r=t.length,n=t.indexOf("://");if(n<0)return null;i.protocol=t.substring(0,n+1);var c=t.indexOf("#"),o=t.indexOf("?");c<0&&(c=r),o<0&&(o=c),i.search=t.substring(o,c).substring(0,1e3);var h=t.substring(n+3,o),l=h.indexOf("/");return l<0&&(l=h.length),i.domain=h.substring(0,l).split(":")[0],i.path=h.substring(l,h.length).substring(0,1e3),i},getResType:function(t,i){if(["script","img","other"].indexOf(t)>-1)return t;if(["video"].indexOf(t)>-1)return"media";if(["document","iframe"].indexOf(t)>-1)return"doc";var r=i?this.getURL(i):null,n=r&&r.path?r.path.lastIndexOf("."):-1,c=(n>0?r.path.substr(n+1):"").toLowerCase();if(c){if(["eot","woff","woff2","ttf"].indexOf(c)>-1)return"font";if(c==="css")return"css";if(c==="js")return"script"}return["fetch","xmlhttprequest","beacon"].indexOf(t)>-1?"api":"others"},areInOrder:function(){for(var t=1;t<arguments.length;t+=1)if(arguments[t-1]>arguments[t])return!1;return!0},getFetchSnapshot:function(t,i,r){var n,c;try{var o=(t&&typeof t[0]!="string"?t[0].url:t[0])||"",h=(t&&typeof t[0]!="string"?t[0]:t[1])||{},l=h.method.toUpperCase()==="POST"?h.body:this.getQuerys(o);n={originApi:o,method:h.method||"unknown",params:l,response:i||"",reqHeaders:this.parseFetchHeaders(h.headers||null),resHeaders:this.parseFetchHeaders(r)},c=JSON&&JSON.stringify(n)||"{}"}catch(d){c="{}"}return c},getXhrSnapshot:function(t,i,r){if(!t||!i||!r)return{};var n,c;try{var o="";r.responseType===""||r.responseType==="text"?o=r.responseText:r.responseType==="document"&&(o=r.responseXML),n={originApi:t,method:i,params:this.getQuerys(t),response:o,reqHeaders:{},resHeaders:this.parseXhrHeaders(typeof r.getAllResponseHeaders=="function"&&r.getAllResponseHeaders()||"")},c=JSON&&JSON.stringify(n)||"{}"}catch(h){c="{}"}return c},isRobot:function(){var t=["nuhk","googlebot/","googlebot-image","yammybot","openbot","slurp","msnbot","ask jeeves/teoma","ia_archiver","baiduspider","bingbot/","adsbot"];if(!navigator||typeof navigator.userAgent!="string")return!1;try{for(var i=navigator.userAgent.toLowerCase(),r=0;r<t.length;r++){var n=t[r];if(i.lastIndexOf(n)>=0)return!0}}catch(c){this.warn("[arms] useragent parse error")}return!1},isFunction:function(t){return typeof t=="function"},isPlainObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},isString:function(t){return Object.prototype.toString.call(t)==="[object String]"},isArray:function(t){return Object.prototype.toString.call(t)==="[object Array]"},joinRegExp:function(t){for(var i,r=[],n=0,c=t.length;n<c;n++)i=t[n],this.isString(i)?r.push(i.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):i&&i.source&&r.push(i.source);return new RegExp(r.join("|"),"i")},reWriteMethod:function(t,i,r){if(t!==null){var n=t[i];t[i]=r(n)}},checkSDKError:function(t,i){return!(!t&&!i)&&(!!new RegExp(this.selfErrKey,"i").test(t)||!!this.ignoreByRule(i,[/retcode.alicdn.com\/retcode\/bl.js/,/g.alicdn.com\/retcode\/cloud-sdk\/bl.js/,/laz-g-cdn.alicdn.com\/retcode\/cloud-sdk\/bl.js/,/local.taobao.com:8880\/build\/bl/]))},sdkError:function(t){return{msg:t,message:this.selfErrKey}},dealParam:function(t,i,r){var n={};try{n=this.isPlainObject(t)?this.ext({key:t.key||"default",val:t.val||t.value||r},t,{begin:Date.now()}):{key:t||"default",val:i||r,begin:Date.now()}}catch(c){this.warn("[retcode] baseLog error: "+c)}return n}};return Qe=e}var Gi,Xr,Yr,Zr,qi={exports:{}},Xi={exports:{}};function kn(){if(Yr)return Xi.exports;Yr=1;var s=He(),a=function(){if(Xr)return Gi;Xr=1;var r=He();return Gi=function(n,c,o){typeof n=="object"&&(n=r.serialize(n));var h=c+n+(o?"&post_res=":"");window&&window.navigator&&typeof window.navigator.sendBeacon=="function"?window.navigator.sendBeacon(h,o||"&post_res="):r.warn("[arms] navigator.sendBeacon not surported")},Gi}(),e="aokcdqn3ly@e629dabd48a9933",t=function(r,n){var c;if(n.t==="error"&&(c=r.requestQueue[0])&&c.t==="error"&&n.msg===c.msg)return n.times=c.times+1,void(r.requestQueue[0]=n);if(n.t==="behavior"){var o=r.requestQueue&&r.requestQueue.length;if(o>0&&r.requestQueue[o-1].t==="behavior"){var h=n.behavior||[];r.requestQueue[o-1].behavior.concat(h)}else r.requestQueue.push(n)}else r.requestQueue.unshift(n);return r.onReady(function(){r.requestTimmer=s.delay(function(){r.clear()},r.requestQueue[0]&&r.requestQueue[0].t==="error"?3e3:-1)}),!0},i=function(r){return this.ver="1.8.36-beta.12",this._conf=s.ext({},i.dftCon),this.sampleCache={},this.requestQueue=[],this.selfQueue=[],this.sdkFlag=!0,this.hash=s.seq(),this.resetPageview(),this.setConfig(r),this.rip=s.getRandIP(),this.record=999,this["EagleEye-TraceID"]=this.getTraceId()["EagleEye-TraceID"],this._common={},this};return i.dftCon={sample:1,pvSample:1,tag:"",imgUrl:"https://arms-retcode.aliyuncs.com/r.png?",region:null,ignore:{ignoreUrls:[],ignoreApis:[],ignoreErrors:[/^Script error\.?$/],ignoreResErrors:[],ignoreResources:[/\/(bl|wl)(.debug)?.js$/]},release:void 0,environment:"prod",beforeReport:null,parseTraceId:null},i.prototype={constructor:i,onReady:function(r){return r()},getPage:function(){var r=this._conf.page;return s.safetyCall(r,[],r+"")},setPage:function(){},setConfig:function(r){r&&typeof r=="object"&&(s.verifyConfig(r),r=this.setImgUrl(r),this._conf=s.ext({},this._conf,r))},setImgUrl:function(r){var n=r.region,c=r.imgUrl;if(n){var o=s.regionMap[n];return r.imgUrl=o||s.defaultImgUrl,r}return c&&(r.imgUrl=c),r},checkImgUrl:function(){return!0},sendRequest:function(){},sendBeacon:function(r,n,c){a(r,n||this.getConfig("imgUrl"),c)},postData:function(){},commonInfo:function(){return{}},setCommonInfo:function(r){r&&typeof r=="object"&&(this._common=s.ext({},this._common,r))},resetPageview:function(){this.pageview=s.uu(),this.sBegin=Date.now()},getUsername:function(){if(this.username)return this.username;var r=this._conf,n=r&&r.setUsername;if(typeof n=="function")try{var c=n();typeof c=="string"&&(c=c.substr(0,40),this.username=c)}catch(o){s.warn("[arms] setUsername fail",o)}return this.username},getTraceId:function(){var r=this.rip,n=Date.now(),c=s.getSortNum(this.record),o=r+n+c+s.getRandNum(this._conf.pid);return this["EagleEye-TraceID"]=o,this.record=c,{"EagleEye-TraceID":o}},getUberTraceId:function(r){var n=this.rip,c=Date.now(),o=s.getSortNum(this.record),h=s.getRandNum(this._conf.pid),l=n+c+o+s.getNum(2)+h,d=l.substring(0,16);return r=r?"1":"0",l[0]==="0"&&(l[0]="1"),l[16]==="0"&&(l[16]="1"),{"uber-trace-id":l+":"+d+":0:"+r,traceId:l}},getB3TraceId:function(r){var n=this.rip,c=Date.now(),o=s.getSortNum(this.record),h=s.getRandNum(this._conf.pid),l=n+c+o+s.getNum(2)+h,d=l.substring(0,16);return r=r?"1":"0",l[0]==="0"&&(l[0]="1"),l[16]==="0"&&(l[16]="1"),{b3:l+"-"+d+"-"+r+"-0","X-B3-TraceId":l,"X-B3-ParentSpanId":"0","X-B3-SpanId":d,"X-B3-Sampled":r}},getPageviewId:function(){return{"EagleEye-SessionID":this.pageview}},getConfig:function(r){return r?this._conf[r]:s.ext({},this._conf)},sampling:function(r){return r===1||(typeof this.sampleCache[r]=="boolean"||(this.sampleCache[r]=s.pick(r)),this.sampleCache[r])},clear:function(r){var n;clearTimeout(this.requestTimmer),this.requestTimmer=null;for(var c=this._conf&&typeof this._conf.sendRequest=="function";n=this.requestQueue.pop();)if(n.t==="res")this.postData(n,"res");else if(n.t==="error")this.postData(n,"err");else if(n.t==="api")this.postData(n,"apiSnapshot");else if(n.t==="behavior")this.postData(n,"behavior");else if(n.t==="health"&&!c&&window&&window.navigator&&typeof window.navigator.sendBeacon=="function")this.sendBeacon(n);else if(n.t==="resource"&&!c&&window&&window.navigator&&typeof window.navigator.sendBeacon=="function"){var o=JSON.stringify({resource:n.resource});delete n.resource,this.sendBeacon(n,null,o)}else n.t==="resource"?this.postData(n,"resource"):this.sendRequest(n);return r&&this.clearSelf(),this},clearSelf:function(){var r;for(clearTimeout(this.Timmer),this.Timmer=null;r=this.selfQueue.pop();)this.postData(r,"err");return this},_lg:function(r,n,c,o){var h=this,l=h._conf,d=h.getPage(),p=l.ignore||{},u=p.ignoreErrors,g=p.ignoreResErrors,m=p.ignoreUrls,b=p.ignoreApis;if(h._isRobot||s.ignoreByRule(d,m)||s.ignoreByRule(s.decode(d),m)||r==="error"&&(s.ignoreByRule(n.msg,u)||s.ignoreByRule(s.decode(n.msg),u))||r==="resourceError"&&(s.ignoreByRule(n.src,g)||s.ignoreByRule(s.decode(n.src),g))||r==="api"&&(s.ignoreByRule(n.api,b)||s.ignoreByRule(s.decode(n.api),b))||!h.checkImgUrl(l.imgUrl)||!n||l.disabled||!l.pid||o===0)return h;var S=n.dl;if(delete n.dl,n=s.ext({t:r,times:1,page:d,tag:l.tag||"",release:l.release||"",environment:l.environment,begin:Date.now(),c1:l.c1,c2:l.c2,c3:l.c3},n,h.commonInfo(),h._common,{pid:l.pid,_v:h.ver,pv_id:h.pageview,username:h.getUsername(),sampling:c||1,dl:S,z:s.seq()}),s.T(l.beforeReport)==="Function")try{if(!(n=l.beforeReport(n)))return h}catch(v){return h}return o===1?t(h,n):c&&!h.sampling(c)?h:t(h,n)},_self:function(r,n,c){var o=this,h=o._conf;if(r!=="error"||!o.checkImgUrl(h.imgUrl)||!n||h.disabled||!h.pid||c&&!o.sampling(c))return o;n=s.ext({t:r,times:1,page:s.selfErrPage,tag:h.pid,begin:Date.now()},n,{pid:e,_v:o.ver,sampling:c||1,z:s.seq()});var l=o.selfQueue[0];if(l){l.times++;try{l.err&&n.err&&l.err.msg_raw&&n.err.msg_raw&&l.err.msg_raw.split("&").indexOf(n.err.msg_raw)<0&&l.err.msg_raw.length<1e3&&(l.err.msg_raw+="&"+n.err.msg_raw)}catch(d){}}else o.selfQueue.unshift(n),o.onReady(function(){o.sdkFlag&&(o.sdkFlag=!1,o.Timmer=s.delay(function(){o.clearSelf()},1e4))})},custom:function(r,n){if(!r||typeof r!="object")return this;var c=!1,o={begin:Date.now()};return s.each(r,function(h,l){return!(c=l&&l.length<=20)&&s.warn("[retcode] invalid key: "+l),o["x-"+l]=h,c}),c?this._lg("custom",o,n||1):this}},Xi.exports=i,Xi.exports}var Qr,Yi={exports:{}},es,Zi,ts,Qi={exports:{}};function Pn(){if(ts)return Zi;ts=1;var s=He();return Zi=function(a,e){var t=[],i=null,r=e&&e.location&&e.location.href,n=void 0,c=null,o=function(d,p,u){if(d!==null){var g=d[p];d[p]=u(g)}},h=function(d){var p,u,g,m,b,S=[];if(!d||typeof d.tagName!="string")return"";if(S.push(d.tagName.toLowerCase()),typeof d.id=="string"&&S.push("#".concat(d.id)),typeof(p=d.className)=="string")for(u=p.split(/\s+/),b=0;b<u.length;b++)S.push(".".concat(u[b]));var v=["type","name","title","alt","data-arms-attr"];for(b=0;b<v.length;b++)g=v[b],typeof(m=d.getAttribute(g))=="string"&&S.push("[".concat(g,'="').concat(m,'"]'));return S.join("")},l=function(d,p){return function(u){if(u&&u!==c){var g;c=u;try{g=u.target}catch(b){g="<unknown>"}if(g.length!==0){var m={type:"ui.".concat(d),data:{message:function(b){if(!b||b.nodeType!==1)return"";for(var S=b||null,v=[],_=0,w=0,y="";S&&_++<5&&!((y=h(S))==="html"||_>1&&w+3*v.length+y.length>=80);)v.push(y),w+=y.length,S=S.parentNode;return v.reverse().join(" > ")}(g)},timestamp:Date.now()};d==="click"?i&&i.addBehavior(m):d==="keypress"&&(n||i&&i.addBehavior(m),clearTimeout(n),n=setTimeout(function(){n=void 0},100))}}}};s.ext(a.prototype,{addBehavior:function(d){if(this.getConfig("behavior")&&d&&typeof d=="object"){var p={},u=d.data||{};if(d.type)p=u;else{if(typeof u.name!="string"||typeof u.message!="string")return;p.name=u.name.substr(0,20),p.message=u.message.substr(0,200)}p.message&&(p.message=s.encode(p.message));var g={type:d.type||"custom",data:p||{},timestamp:d.timestamp||Date.now(),page:d.page||e&&e.location&&e.location.pathname};return t.push(g),t=t.slice(-100)}},getBehavior:function(){return t||[]},setBehavior:function(d){return d&&(t=d),t},reportBehavior:function(d){var p=this;p.getConfig("behavior")&&(p.sendBhTimer&&(clearTimeout(p.sendBhTimer),p.sendBhTimer=void 0),p.sendBhTimer=setTimeout(function(){t&&t.length>0&&(p.behavior(t),t=[],p.sendBhTimer=void 0,d&&typeof d=="function"&&d())},0))},initBehavior:function(){if(!this.hasInitBehavior&&!i){try{(function(){if(document&&document.referrer&&document.location){var p=document.referrer,u=document.location.href;if(p!==""){var g={type:"navigation",data:{from:p,to:u}};r=u,i&&i.addBehavior(g)}}})(),e&&e.document&&e.document.addEventListener&&(e.document.addEventListener("click",l("click"),!1),e.document.addEventListener("keypress",l("keypress"),!1)),function(){if(function(){var m=e&&e.chrome,b=m&&m.app&&m.app.runtime,S="history"in e&&!!e.history.pushState&&!!e.history.replaceState;return!b&&S}()){var p=function(m,b){var S={type:"navigation",data:{from:m,to:b}};i&&i.addBehavior(S),r=b},u=e.onpopstate;e.onpopstate=function(){for(var m=arguments.length,b=new Array(m),S=0;S<m;S++)b[S]=arguments[S];var v=e.location.href;if(p(r,v),u)return u.apply(this,b)};var g=function(m){return function(){for(var b=arguments.length,S=new Array(b),v=0;v<b;v++)S[v]=arguments[v];var _=S.length>2?S[2]:void 0;return _&&p(r,String(_)),m.apply(this,S)}};o(e.history,"pushState",g),o(e.history,"replaceState",g)}}();var d=this.getConfig("enableConsole");d&&function(p){if(e&&e.console){var u=["debug","info","warn","log","error","assert"];s.isArray(p)&&(u=p);for(var g=0;g<u.length;g++){var m=u[g];m&&s.isString(m)&&e.console[m]&&typeof e.console[m]=="function"&&o(e.console,m,function(b){var S=m;return function(){for(var v=arguments.length,_=new Array(v),w=0;w<v;w++)_[w]=arguments[w];var y={type:"console",data:{level:S,message:_}};if(i&&i.addBehavior(y),S==="error")for(var R=0;R<_.length;R++){var A=_[R];A&&A.message&&A.stack&&i&&i.errorHandler(new ErrorEvent("error",{error:A,message:A.message}))}b&&Function.prototype.apply.call(b,e.console,_)}})}}}(d)}catch(p){s.warn("[arms] error in initBehavior",p)}i=this,this.hasInitBehavior=!0}return this}})},Zi}var is,er,rs,tr,ss,as,ns,ir,os,cs,hs,ls,ds,rr,us,ps,ms,gs={};function sr(){return is||(is=1,gs.TIMING_KEYS=["startTime","fetchStart","domainLookupStart","domainLookupEnd","connectStart","connectEnd","requestStart","responseStart","responseEnd","","domInteractive","","domContentLoadedEventEnd","","loadEventStart","","msFirstPaint","secureConnectionStart","redirectStart","redirectEnd"]),gs}function Dn(){return ns||(ns=1,as=function(s,a,e){var t=He(),i=function(){if(rs)return er;rs=1;var m=He(),b=sr().TIMING_KEYS;return er=function(){var S=m.win||{},v=S.performance;if(!v||typeof v!="object"||typeof v.getEntriesByType!="function")return null;var _={},w=v.timing||{},y=v.getEntriesByType("resource")||[];if(_.begin=w[b[1]]||Date.now(),typeof S.PerformanceNavigationTiming=="function"){var R=v.getEntriesByType("navigation")[0];R&&(w=R)}return m.each({dom:[10,8],load:[14,1]},function(A,E){var I=w[b[A[1]]],k=w[b[A[0]]];if(I>0&&k>0){var P=Math.round(k-I);P>=0&&P<6e5&&(_[E]=P)}}),_.res=JSON.stringify(y),_},er}(),r=function(){if(ss)return tr;ss=1;var m=He(),b=sr().TIMING_KEYS;return tr=function(){var S=m.win||{},v=S.performance;if(!v||typeof v!="object")return null;var _={},w=v.timing||{},y=Date.now(),R=1;if(typeof S.PerformanceNavigationTiming=="function"){var A=v.getEntriesByType("navigation")[0];A&&(w=A,R=2)}m.each({dns:[3,2],tcp:[5,4],ssl:[5,17],ttfb:[7,6],trans:[8,7],dom:[10,8],res:[14,12],firstbyte:[7,2],fpt:[8,1],tti:[10,1],ready:[12,1],load:[14,1]},function(H,G){var Y=w[b[H[1]]],J=w[b[H[0]]];if(R===2||Y>0&&J>0){var z=Math.round(J-Y);z>=0&&z<6e5&&(_[G]=z)}});var E=S.navigator.connection,I=v.navigation||{};_.ct=E?E.effectiveType||E.type:"";var k=E&&(E.downlink||E.downlinkMax||E.bandwidth)||null;if((k=k>999?999:k)&&(_.bandwidth=k),_.navtype=I.type===1?"Reload":"Other",R===1&&w[b[16]]>0&&w[b[1]]>0){var P=w[b[16]]-w[b[1]];P>=0&&P<36e5&&(_.fpt=P)}return R===1&&w[b[1]]>0?_.begin=w[b[1]]:R===2&&_.load>0?_.begin=y-_.load:_.begin=y,_},tr}(),n=null,c=e.documentElement,o=a.innerWidth||c.clientWidth||e.body.clientWidth,h=a.innerHeight||c.clientHeight||e.body.clientHeight,l=a.navigator.connection,d={sr:screen.width+"x"+screen.height,vp:o+"x"+h,ct:l?l.effectiveType||l.type:""},p={},u=function(m,b,S,v,_){if(b===void 0){var w,y;if(!p[m]){w=new RegExp(m+"=([^;]+)");try{y=w.exec(e.cookie)}catch(A){return t.warn("[retcode] can not get cookie:",A),null}y&&(p[m]=y[1])}return p[m]}var R=m+"="+b;R+="; path=/",S&&(R+="; max-age="+S);try{return e.cookie=R,!!e.cookie}catch(A){return t.warn("[retcode] can not set cookie: ",A),!1}},g=function(m){var b=m._conf.uid||u("_nk_")||u("_bl_uid");return b||(b=t.uu(),u("_bl_uid",b,15552e3))?b:null};return t.ext(s.prototype,{activeErrHandler:function(m){return n&&!m||(n=this),this},errorHandler:function(m){if(!m)return this;var b=m.type;if(b==="error"){var S=m.target||m.srcElement;!S||!S.tagName||m.message||m.filename||m.lineno||m.colno?this.error(m.error||{message:m.message},m):this.resourceErrorHandler(m)}else b==="unhandledrejection"&&t.T(m.reason,"Error")&&t.checkAutoError(m.reason)&&this.error(m.reason);try{this.getConfig("behavior")&&this.reportBehavior&&this.reportBehavior()}catch(v){}return this},resourceErrorHandler:function(m){var b=this,S=m.target||m.srcElement;try{var v=b.getSrc(S),_=typeof S.tagName=="string"?S.tagName.toLowerCase():"",w=b.getXPath(S,5),y=t.getURL(v),R={src:v&&v.substring(0,1e3),node_name:_,xpath:w,res_type:t.getResType(_,v),res_name:y.path,domain:y.domain};return b._conf.enableResource&&b.fixResourceStatus&&m.timeStamp&&b.fixResourceStatus({src:v,node_name:_,res_type:t.getResType(_,v),timeStamp:m.timeStamp,domain:y.domain}),b._lg("resourceError",R),b}catch(A){return t.warn("[ARMS] resourceErrorHandler error :",A),b}},getSrc:function(m){var b=m.src||m.href;try{if(!b){var S=(typeof m.tagName=="string"?m.tagName.toLowerCase():"")==="object",v=m.getAttribute("classid")&&m.getAttribute("classid").toLowerCase()==="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"||m.getAttribute("type")==="application/x-shockwave-flash";S&&v&&(b=m.getAttribute("data")||m.getAttribute("codebase")),b||(b=m.outerHTML||m.innerHTML)}}catch(_){b=""}return b},getXPath:function(m,b){var S=m.id?"#"+m.id:"",v=typeof m.className=="string"?"."+m.className.split(" ").join("."):"",_=(typeof m.tagName=="string"?m.tagName.toLowerCase():"")+S+v;return m.parentNode&&m.parentNode.tagName&&b-1!=0?this.getXPath(m.parentNode,b-1)+" > "+_:_},sendPerformance:function(m){var b=this;b.onReady(function(){var S=r();S&&S.load&&S.load>0&&(S.page=b.getPage(!0),m&&(S=t.ext(S,m)),S.autoSend=!0,b.performance(S))})},sendResources:function(m){var b=this;b.onReady(function(){var S=i();S&&S.load&&S.load>0&&(S.load&&S.load<=2e3||S.load&&S.load<=8e3&&Math.random()>.05||(S.page=b.getPage(!0),S.dl=location.href,m&&(S=t.ext(S,m)),b._lg("res",S,b.getConfig("sample"))))})},sendPV:function(){var m=this;m.onReady(function(){var b,S,v=(b=g(m),S=a.devicePixelRatio||1,{uid:b,dt:e.title,dl:location.href,dr:e.referrer,dpr:S.toFixed(2),de:(e.characterSet||e.defaultCharset||"").toLowerCase(),ul:c.lang,begin:Date.now()});v&&v.uid&&m._lg("pv",v,m.getConfig("pvSample"))})},commonInfo:function(){return d.uid=g(this),d.sid=function(m){if(m.session)return m.session;var b;try{if(typeof window=="object"&&typeof sessionStorage=="object"&&typeof sessionStorage.getItem=="function")return typeof(b=sessionStorage.getItem("_bl_sid"))=="string"?(m.session=b,b):(b=t.uu(),m.session=b,typeof sessionStorage.setItem=="function"&&sessionStorage.setItem("_bl_sid",b),b)}catch(S){t.warn("[ARMS] getSid error :",S)}return m.session=b=t.uu(),b}(this),d},handleUnload:function(m){var b=Date.now();if(b-this._lastUnload<200)return this;this._lastUnload=b,this.sendHealth(m),this.speedCache&&(this._lg("speed",this.speedCache),this.speedCache=null,clearTimeout(this.speedTimmer)),this._conf&&this._conf.enableResource&&this.resourceComboReport(),this.clear(!0)},bindHashChange:function(m){var b=this;if(!m^b.hashChangeHandler)return b;m?(b.hackHistoryState(),b.hashChangeHandler=function(S){var v=b._conf.parseHash(location.hash);v&&b.setPage(v,S!==!1)},b.stateChangeHandler=function(S){var v=b._conf.parseHash(S.detail);v&&b.setPage(v)},t.on(a,"hashchange",b.hashChangeHandler),t.on(a,"historystatechange",b.stateChangeHandler),b.hashChangeHandler(!1)):(t.off(a,"hashchange",b.hashChangeHandler),t.off(a,"historystatechange",b.stateChangeHandler),b.hashChangeHandler=null,b.stateChangeHandler=null)},initHandler:function(){var m=this;if(m.hasInitHandler)return m;var b=m._conf;return t.on(a,"beforeunload",function(){m.handleUnload(0)}),m.bindHashChange(b.enableSPA),m.activeErrHandler(!1),m.hasInitHandler=!0,m}}),t.on(a,"error",function(m){n&&n.errorHandler(m)},!1,!0).on(a,"unhandledrejection",function(m){n&&n.errorHandler(m)}),s}),as}function Mn(){if(os)return ir;os=1;var s=He();return ir=function(a,e,t){function i(l,d,p){var u=0,g=l.tagName;if(g!=="SCRIPT"&&g!=="STYLE"&&g!=="META"&&g!=="HEAD"){var m=l.children?l.children.length:0;if(m>0)for(var b=l.children,S=m-1;S>=0;S--)u+=i(b[S],d+1,u>0);if(u<=0&&!p&&!(l.getBoundingClientRect&&l.getBoundingClientRect().top<n))return 0;u+=1+.5*d}return u}function r(l){for(var d=1;d<l.length;d++)if(l[d].score<l[d-1].score)return l.splice(d,1),r(l);return l}var n=e.innerHeight||0,c=[],o=null,h=0;s.ext(a.prototype,{initFmpObserver:function(l){var d=this;if(!d._conf||!d._conf.useFmp)return null;if(!e.MutationObserver)return s.warn("[retcode] first meaningful paint can not be retrieved"),d.sendPerformance(),null;s.on(e,"beforeunload",function(){d.endObserving(0,!0)});var p=e.MutationObserver;return(o=new p(function(){(function(u){var g=Date.now()-u,m=t.querySelector("body");if(m){var b=0;b+=i(m,1,!1),c.push({score:b,t:g})}else c.push({score:0,t:g})})(d._startTime)})).observe(document,{childList:!0,subtree:!0}),h=1,d.onReady(function(){d.endObserving(l)}),o},endObserving:function(l,d){var p,u,g,m=this;if(o&&h)if(m.fmpTimmer&&(clearTimeout(m.fmpTimmer),m.fmpTimmer=null),d||(p=m._startTime,u=l,(g=Date.now()-p)>u||g-(c&&c.length&&c[c.length-1].t||0)>1e3)){o.disconnect(),h=0,c=r(c);for(var b=null,S=1;S<c.length;S++)if(c[S].t>=c[S-1].t){var v=c[S].score-c[S-1].score;(!b||b.rate<=v)&&(b={t:c[S].t,rate:v})}b&&b.t>0&&b.t<36e5?m.sendPerformance({fmp:b.t}):m.sendPerformance()}else m.fmpTimmer=s.delay(function(){m.endObserving(l)},500)}})},ir}function Nn(){if(ps)return mt.exports;ps=1;var s=He(),a=function(){if(Zr)return qi.exports;Zr=1;var o=He(),h=kn(),l=["api","success","time","code","msg","trace","traceId","begin","pv_id","sid","seq","domain","flag","apiSnapshot","tag","c1","c2","c3"],d=function(u){var g=(u.key||"default").split("::");return g.length>1?o.ext(u,{group:g[0],key:g[1]}):o.ext(u,{group:"default_group",key:g[0]})},p=function(u){var g;h.call(this,u);try{g=typeof performance=="object"?performance.timing.fetchStart:Date.now()}catch(m){g=Date.now()}return this._startTime=g,this};return p.prototype=o.createObject(h.prototype),o.ext(h.dftCon,{startTime:null}),o.ext(p.prototype,{constructor:p,_super:h,sum:function(u,g,m){try{var b=o.dealParam(u,g,1);return this._lg("sum",d(b),m)}catch(S){o.warn("[retcode] can not get parseStatData: "+S)}},avg:function(u,g,m){try{var b=o.dealParam(u,g,0);return this._lg("avg",d(b),m)}catch(S){o.warn("[retcode] can not get parseStatData: "+S)}},percent:function(u,g,m,b){try{return this._lg("percent",d({key:u,subkey:g,val:m||0,begin:Date.now()}),b)}catch(S){o.warn("[retcode] can not get parseStatData: "+S)}},msg:function(u,g){if(u&&!(u.length>180))return this.custom({msg:u},g)},error:function(u,g){if(!u)return o.warn("[retcode] invalid param e: "+u),this;arguments.length===1?(typeof u=="string"&&(u={message:u},g={}),typeof u=="object"&&(g=u=u.error||u)):(typeof u=="string"&&(u={message:u}),typeof g!="object"&&(g={}));var m=u.name||"CustomError",b=u.message||"",S=u.stack||"";g=g||{};var v=typeof location=="object"&&typeof location.href=="string"&&location.href.substring(0,500)||"";if(o.checkSDKError(b,g.filename)){var _=/^Script error\.?$/,w=u.msg||u.message;if(o.ignoreByRule(w,_)||o.ignoreByRule(o.decode(w),_))return this;var y={msg:o.selfErrKey,err:{msg_raw:o.encode(u.msg||u.message)}};return this._self("error",y,1)}for(var R={begin:Date.now(),cate:m,msg:b&&b.substring(0,1e3),stack:S&&S.substring(0,1e3),file:o.removeUrlSearch(g.filename||""),line:g.lineno||"",col:g.colno||"",err:{msg_raw:o.encode(b),stack_raw:o.encode(S)},dl:v},A=["tag","c1","c2","c3"],E=0;E<A.length;E++){var I=A[E];g[I]&&(R[I]=g[I])}var k=(this.getConfig("ignore")||{}).ignoreErrors;return o.ignoreByRule(R.msg,k)||o.ignoreByRule(o.decode(R.msg),k)?this:(this.beforeSend&&this.beforeSend("error",R),this._lg("error",R,1))},behavior:function(u){if(u){var g=typeof u=="object"&&u.behavior?u:{behavior:u};return this.beforeSend&&this.beforeSend("behavior",g),this._lg("behavior",g,1)}},api:function(u,g,m,b,S,v,_,w,y,R,A,E,I,k,P,H){if(!u)return o.warn("[retcode] api is null"),this;if(u=typeof u=="string"?{api:u,success:g,time:m,code:b,msg:S,begin:v,traceId:_,pv_id:w,apiSnapshot:y,domain:R,flag:E,tag:I,c1:k,c2:P,c3:H}:o.sub(u,l),!o.checkAPI(u.api,!0))return this;u.code=u.code||"";var G=u.msg||"";if(G=typeof G=="string"?G.substring(0,1e3):G,u.msg=G,u.success=u.success?1:0,u.time=+u.time,u.begin=u.begin,u.traceId=u.traceId||"",u.pv_id=u.pv_id||"",u.domain=u.domain||"",u.flag=u.flag,u.dl=typeof location=="object"&&typeof location.href=="string"&&location.href.substring(0,500)||"",u.apiSnapshot&&(typeof u.apiSnapshot=="object"&&(u.apiSnapshot=JSON.stringify(u.apiSnapshot)),typeof u.apiSnapshot!="string"&&delete u.apiSnapshot,u.apiSnapshot.length>2e3&&(u.apiSnapshot=u.apiSnapshot.substring(0,2e3))),A&&(u.traceOrigin=A),!u.api||isNaN(u.time))return o.warn("[retcode] invalid time or api"),this;var Y=(this.getConfig("ignore")||{}).ignoreApis;return o.ignoreByRule(u.api,Y)||o.ignoreByRule(o.decode(u.api),Y)||u.time<0?this:(this.beforeSend&&this.beforeSend("api",u),this._lg("api",u,u.success&&this.getConfig("sample"),u.flag))},speed:function(u,g,m){var b=this,S=this.getConfig("startTime")||this._startTime;return/^s(\d|1[0])$/.test(u)?(g=typeof g!="number"?Date.now()-S:g>=S?g-S:g,b.speedCache=b.speedCache||{},b.speedCache[u]=g,b.speedCache.begin=S,clearTimeout(b.speedTimmer),b.speedTimmer=setTimeout(function(){m||(b.speedCache.page=b.getPage(!0)),b._lg("speed",b.speedCache),b.speedCache=null},5e3),b):(o.warn("[retcode] invalid point: "+u),b)},performance:function(u){if(u&&typeof u=="object"&&!this.hasSendPerf){var g={},m={},b=this.getConfig("autoSendPerf");if(u.autoSend&&b)return m=o.ext(this.perfData||{},u),this.hasSendPerf=!0,this._lg("perf",m,this.getConfig("sample"));if(u.autoSend&&!b)return delete u.autoSend,this.perfData?(m=o.ext(this.perfData||{},u),this.hasSendPerf=!0,this._lg("perf",m,this.getConfig("sample"))):void(this.perfData=u);for(var S in u)(/^t([1-9]|1[0])$/.test(S)||S==="ctti"||S==="cfpt")&&(g[S]=u[S]);if(u.autoSend===!0||!b&&(b||this.perfData))return u.autoSend!==!0&&b===!1&&this.perfData?(g=o.ext(this.perfData||{},g),this.hasSendPerf=!0,this._lg("perf",g,this.getConfig("sample"))):void 0;this.perfData=o.ext(this.perfData||{},g)}},resource:function(u,g){if(!u||!o.isPlainObject(u))return o.warn("[arms] invalid param data: "+u),this;var m=Object.keys(u),b=["begin","dom","load","res","dl"],S=!1;for(var v in b)if(m.indexOf(b[v])<0){S=!0;break}if(S)return o.warn("[arms] lack param data: "+u),this;var _={begin:u.begin||Date.now(),dom:u.dom||"",load:u.load||"",res:o.isArray(u.res)?JSON.stringify(u.res):JSON.stringify([]),dl:u.dl||""};return this._lg("res",_,g)},event:function(u,g){if(typeof u=="object"&&u&&u.key){var m={},b=["key","success","time","c1","c2","c3"];for(var S in u)b.indexOf(S)>-1&&(m[S]=u[S]);m.success=u.success===!1?0:1,this._lg("event",m,g)}}}),p._super=h,p._root=h,h.Reporter=p,qi.exports=p,qi.exports}(),e=function(){if(Qr)return Yi.exports;Qr=1;var o=He(),h=typeof window=="object"?window:{},l=h.__oFetch_||h.fetch;return l=typeof l=="function"?l:void 0,Yi.exports=function(d,p){var u=-1;typeof d=="object"&&(u=d.z,d=o.serialize(d));var g=p+d;if(l)return l(g,{method:"HEAD",mode:"no-cors"}).catch(o.noop);if(h.document&&h.document.createElement){var m="__request_hold_"+u,b=h[m]=new Image;b.onload=b.onerror=function(){h[m]=void 0},b.src=g,b=null}},Yi.exports}(),t=function(){if(es)return Qi.exports;es=1;var o=He(),h=typeof window=="object"?window:{},l=h.__oXMLHttpRequest_||h.XMLHttpRequest;return l=typeof l=="function"?l:void 0,Qi.exports=function(d,p){try{var u=new l;u.open("POST",p,!0),u.setRequestHeader("Content-Type","text/plain"),u.send(JSON.stringify(d))}catch(g){o.warn(`[retcode] Failed to log, exception is :
|
|
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 h=this;return a.call(h,o),h._initialPage=o.page&&s.safetyCall(o.page,[],o.page+"")||null,h._isRobot=s.isRobot(),h._health={errcount:0,apisucc:0,apifail:0},h.beforeSend=function(l,d){l==="error"?h._health.errcount++:l==="api"&&h._health[d.success?"apisucc":"apifail"]++},o.enableInstanceAutoSend!==!1&&(h.initHandler(),h.initHook(),h.initFmpObserver(1e4),h._conf&&h._conf.behavior&&typeof h.initBehavior=="function"&&h.initBehavior(),h._conf&&h._conf.enableResource&&typeof h.initResource=="function"&&h.initResource()),Object.defineProperty&&i.addEventListener&&Object.defineProperty(h,"pipe",{set:h.sendPipe}),h};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 h=o.code,l=o.msg||o.message||o.subMsg||o.errorMsg||o.ret||o.errorResponse||"";return typeof l=="object"&&(h=h||l.code,l=l.msg||l.message||l.info||l.ret||JSON.stringify(l)),{msg:l,code:h,success:!0}}}),s.ext(c.prototype,{constructor:c,_super:a,onReady:function(o){var h=this;if(h.hasReady)return o();r.readyState==="complete"?(h.hasReady=!0,o()):s.on(i,"load",function(){h.hasReady=!0,o()},!0)},getPage:function(o){var h=this._conf,l=h.page,d=location,p=d.host+d.pathname;return l&&!o?s.safetyCall(l,[],l+""):this._initialPage||s.filterByRule(h.ignoreUrlCase?p.toLowerCase():p,d.href,h.ignoreUrlPath?h.ignoreUrlPath:h.urlHelper)},setPage:function(o,h){var l=this,d=l.prevPage;if(h!==!1){if(!o||o===d)return l;l.prevPage=o,clearTimeout(l.sendPVTimmer),l.handleUnload(1),l.resetPageview(),l.sendPVTimmer=setTimeout(function(){l.sendPV()},10)}else l.prevPage=o;return l._conf.page=o,l},setConfig:function(o,h){if(o&&typeof o=="object"){s.verifyConfig(o),o=this.setImgUrl(o);var l=this._conf;if(this._conf=s.ext({},l,o),!h){var d="disableHook";d in o&&l[d]!==o[d]&&(o[d]?this.removeHook():this.addHook()),(d="enableSPA")in o&&l[d]!==o[d]&&this.bindHashChange(o[d])}}},sendRequest:function(o){e(o,this.getConfig("imgUrl"))},postData:function(o,h){var l={};l[h]=o[h],delete o[h];var d="";typeof o=="object"&&(d=s.serialize(o)),t(l,this.getConfig("imgUrl")+d+"&post_res=")},sendPipe:function(o){var h=this;if(!o||!o.length)return h;try{if(s.T(o[0])==="Array")return s.each(o,function(d){return h.sendPipe(d)});if(s.T(o)!=="Array")return h;var l=o.shift();if(!n.test(l))return h;h[l].apply(h,o)}catch(d){return s.warn("[retcode] error in sendPipe",d),h}},sendHealth:function(){var o=s.ext({},this._health);o.healthy=o.errcount>0?0:1,o.begin=Date.now();var h=o.begin-this.sBegin;o.stay=h,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 h=this.__proto__.constructor(o);return o.page&&h.sendPV(),h}}),Pn()(c,i),Dn()(c,i,r),Mn()(c,i,r),(hs||(hs=1,cs=function(o,h){var l=He(),d=null,p=l.getCurDomain(),u=function(v,_,w,y,R,A,E,I,k,P,H,G,Y){var J=l.J(R)||null,z=l.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?{}:H,p,G,Y)},g="fetch",m="__oFetch_",b="__oXMLHttpRequest_",S="XMLHttpRequest";return l.ext(o.prototype,{removeHook:function(v,_){return d&&(_||this===d)?(h[m]&&(h[g]=h[m],delete h[m]),h[b]&&(h[S]=h[b],delete h[b]),d=null,this):this},addHook:function(v){return!v&&d||(d||(function(){if(typeof h[g]=="function"){var _=h[g];h[m]=_,h[g]=function(w,y){var R=arguments.length===1?[arguments[0]]:Array.apply(null,arguments),A=d;if(!A||!A.api||y&&(y.method==="HEAD"||y.mode==="no-cors"))return _.apply(h,R);y||(y={});var E=Date.now(),I=A._conf,k=l.duration(),P=(w&&typeof w!="string"?w.url:w)||"",H=P;P=l.cutUrlSearch(P);var G=(I.ignore||{}).ignoreApis,Y=I.parseTraceId;if(!l.checkAPI(P,!0)||l.ignoreByRule(P,G))return _.apply(h,R);P=l.filterByRule(P,H,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(le){x=""}var he=l.checkSameOrigin(H,x);if(A.getConfig("enableApiCors")||he)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",l.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(le){l.warn(`[retcode] fetch failed to set header, exception is :
|
|
4
|
+
`+le)}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"]=l.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(h,R).then(function(le){if(!A||!A.api)return le;try{if(!le||typeof le.clone!="function")return le;var Pe=le.clone(),ye=Pe.headers;if(ye&&typeof ye.get=="function"){var Ge=ye.get("content-type");if(Ge&&!/(text)|(json)/.test(Ge))return le;if(!z){var st=l.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&&l.isFunction(Y)){var te=Y(Pe,re);te&&l.isString(te)&&(z=te)}var be=l.getFetchSnapshot(R,re,ye);Pe.ok?u(A,I.parseResponse,P,H,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&&d.fixResourceStatus&&d.fixResourceStatus({src:Pe.url,res_type:"api"}))}),le}catch(re){return l.warn("[ARMS] fetch response error :",re),le}}).catch(function(le){if(!A||!A.api)throw le;var Pe=k();throw A.api(P,!1,Pe,le.name||"Error",le.message,E,z,Q,{},p),I.enableResource&&d.fixResourceStatus&&d.fixResourceStatus({src:H,res_type:"api"}),le})},h[g].toString=l.createFakeToString(g)}}(),function(){if(typeof h[S]=="function"){var _,w=h[S];h[b]=w;var y=function(R){var A=new w(R),E=d;if(!E||!E.api||!A.addEventListener)return A;var I,k,P,H,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,he=E.getConfig("sample"),ke=E.getConfig("linkType"),$=1;return he&&!E.sampling(he)&&($=0),A.open=function(ge,De){_=ge;var Ae=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);Y.apply(A,Ae),H=De||"",P=l.cutUrlSearch(H);var Te=!l.checkAPI(P,!0)||l.ignoreByRule(P,Q);if(P=P?l.filterByRule(P,H,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=l.checkSameOrigin(H,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 le=E.getB3TraceId($);J.apply(A,["X-B3-TraceId",le["X-B3-TraceId"]]),J.apply(A,["X-B3-ParentSpanId",le["X-B3-ParentSpanId"]]),J.apply(A,["X-B3-SpanId",le["X-B3-SpanId"]]),J.apply(A,["X-B3-Sampled",le["X-B3-Sampled"]]),J.apply(A,["X-Request-ID",l.guid()]),D=le["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=l.duration();var ge=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);G.apply(A,ge)},l.on(A,"readystatechange",function(){if(P&&A.readyState===4){var ge=k(),De=l.getXhrSnapshot(H,_,A);if(!D){var Ae=l.parseXhrHeaders(typeof A.getAllResponseHeaders=="function"&&A.getAllResponseHeaders()||"");typeof Ae=="object"&&Ae["eagleeye-traceid"]&&(D=Ae["eagleeye-traceid"],x="response")}if(!D&&l.isFunction(ee)){var Te=ee(A);Te&&l.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,H,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&&d.fixResourceStatus&&d.fixResourceStatus({src:A.responseURL||H,res_type:"api"})}}),A};y.prototype=w.prototype,l.each(Object.keys(w),function(R){y[R]=w[R]}),h[S]=y,h[S].toString=l.createFakeToString(S)}}()),d=this),this},initHook:function(){return this.hasInitHook||(this.getConfig("disableHook")||this.addHook(),this.hasInitHook=!0),this}}),o}),cs)(c,i),(ds||(ds=1,ls=function(o,h){var l=He(),d=h.history||{},p=h.document,u=function(m,b){var S;h.CustomEvent?S=new CustomEvent(m,{detail:b}):((S=p.createEvent("HTMLEvents")).initEvent(m,!1,!0),S.detail=b),h.dispatchEvent(S)},g=function(m){var b=d[m];typeof b=="function"&&(d[m]=function(S,v,_){var w=arguments.length===1?[arguments[0]]:Array.apply(null,arguments),y=location.href,R=b.apply(d,w);if(!_||typeof _!="string"||_===y)return R;try{var A=y.split("#"),E=_.split("#"),I=l.cutUrlSearch(A[0]),k=l.cutUrlSearch(E[0]),P=A[1]&&A[1].replace(/^\/?(.*)/,"$1"),H=E[1]&&E[1].replace(/^\/?(.*)/,"$1");P!==H?u("historystatechange",H):I!==k&&u("historystatechange",k)}catch(G){l.warn("[retcode] error in "+m+": "+G)}return R},d[m].toString=l.createFakeToString(m))};l.ext(o.prototype,{hackHistoryState:function(){return this.hasHackedHistoryState||(g("pushState"),g("replaceState"),this.hasHackedHistoryState=!0),this}})}),ls)(c,i),function(){if(us)return rr;us=1;var o=He(),h=sr().TIMING_KEYS;return rr=function(l,d){function p(m,b,S){if(m instanceof d.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[h[0]],R=m[h[1]],A=m[h[2]],E=m[h[3]],I=m[h[4]],k=m[h[5]],P=m[h[6]],H=m[h[7]],G=m[h[8]],Y=m[h[18]],J=m[h[19]];if(!S.has(m)&&(!o.areInOrder(y,R,A,E,I,k,P,H,G)||y>H))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(l.prototype,{initResource:function(){var m=this,b=d.performance,S=d.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=d.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||{},H=S.get(k.timing),G=H?H.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=d.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(ms)return zt.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}ms=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)}()),zt.exports=e,zt.exports}()}};const fs="https://arms-retcode.aliyuncs.com/r.png?",Ss="https://arms-retcode-sg.aliyuncs.com/r.png?",bs="https://retcode-us-west-1.arms.aliyuncs.com/r.png?",vs="e1iftji1w7@7ec1cef2cc88733",ys="e1iftji1w7@10a06d1ec260adc",Rs="e1iftji1w7@10a06d1ec260adc",ar={cn:{reportUrl:fs,pid:vs},"cn-hangzhou":{reportUrl:fs,pid:vs},sg:{reportUrl:Ss,pid:ys},"ap-southeast-1":{reportUrl:Ss,pid:ys},usw:{reportUrl:bs,pid:Rs},"us-west-1":{reportUrl:bs,pid:Rs}},xn=s=>!!Object.isExtensible(s)&&(a=>Object.prototype.toString.call(a).slice(8,-1))(s)==="Object";function As(s,a){if(typeof s!="string")return!1;const e=s.indexOf(a);if(e<0)return!1;const t=s.indexOf(`
|
|
5
|
+
`);return t<0||e<t}function It(s,a,e){return typeof s=="function"?function(t,i,r){const n={MediaboxWrapperFunctionApply(c,o,h){let l;try{l=Reflect.apply(c,o,h)}catch(d){throw r(d),d}return It(l,i,r)},MediaboxWrapperFunctionGet(c,o){const h=Object.getOwnPropertyDescriptor(c,o);return!h||h.writable||h.configurable?It(c[o],i,r):c[o]},MediaboxWrapperClassConstructor(c,o){let h;try{h=new c(...o)}catch(l){throw r(l),l}return It(h,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=>It(t,a+1,e)).catch(t=>(e(t),Promise.reject(t))):Array.isArray(s)?(s.forEach((t,i)=>{s[i]=It(t,a+1,e)}),s):(t=>t!==null&&typeof t=="object")(s)&&xn(s)?function(t,i,r){var h;if(Reflect.get(t,"__v_skip")===!0)return t;const n=[],c=typeof Object.getOwnPropertyDescriptors=="function"?Object.getOwnPropertyDescriptors((h=Object.getPrototypeOf(t))!=null?h:{}):{};for(const l of Object.keys(c))c[l].get&&n.push(l);const o={MediaboxWrapperObjectGetter(l,d){if(typeof d=="string"&&n.indexOf(d)>-1){let p;try{p=l[d]}catch(u){throw r(u),u}return It(p,i,r)}return i>10?l[d]:It(l[d],i,r)},MediaboxWrapperObjectSetter:(l,d,p)=>(l[d]=It(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 _s(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 ws extends Error{constructor(a){super(a),this.name="MQTError"}}let Vn=1;class nr{constructor(a){var e,t;Et(this,"armsLogger"),Et(this,"isReady",!1),Et(this,"isDestroyed",!1),Et(this,"options"),Et(this,"queue",[]),Et(this,"marker"),Et(this,"helper",{MediaboxWrapperQueue:i=>new ws(i),MediaboxWrapperInitiative:i=>new ws(i)}),this.options=Pt(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||As(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)||_s(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:It(a,0,e=>{var t;e instanceof Error&&typeof e.stack=="string"&&_s(e.stack)&&((t=this.armsLogger)==null||t.error(e),e.stack=function(i,r){if(typeof i!="string")return r;if(As(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 Es={randomUUID:typeof crypto!="undefined"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ht(s,a,e){if(Es.randomUUID&&!a&&!s)return Es.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||{}),hr=(s=>(s.Audio="rts audio",s.VideoLarge="rts video",s))(hr||{}),Dt=(s=>(s.Add="add",s.Delete="delete",s.Replace="replace",s.Stop="stop",s.UnPublish="unpublish",s))(Dt||{}),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.1.0";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=ht();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 Is(s,a,e){Object.defineProperty(s,a,{writable:!0,enumerable:!0,configurable:!0,value:e})}function Ts(s,a,e,t){t?t(()=>{Is(s,a,e)}):Is(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 Cs(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 Cs(s,a);(function(e,t){return!(!navigator||!navigator.sendBeacon)&&navigator.sendBeacon(`${e}?APIVersion=0.6.0`,t)})(s,a)||Cs(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
|
+
`+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 h in c)o.setRequestHeader(h,c[h]);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
|
+
`+n),console.error("Failed log data:",s))}},new Promise((n,c)=>{var o=d=>{try{l(r.next(d))}catch(p){c(p)}},h=d=>{try{l(r.throw(d))}catch(p){c(p)}},l=d=>d.done?n(d.value):Promise.resolve(d.value).then(o,h);l((r=r.apply(t,i)).next())});var t,i,r}class lr 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)}}Ts(window,"SLS_Tracker",lr);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 ks={exports:{}},Ps={exports:{}};const Wn=zn(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Ds;function ue(){return Ds||(Ds=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={},h=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)}},l=o.WordArray=h.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=h.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 l.init(v,S)}}),d=c.enc={},p=d.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 l.init(_,v/2)}},u=d.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 l.init(_,v)}},g=d.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=h.extend({reset:function(){this._data=new l.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 l.init(v,I)},clone:function(){var S=h.clone.call(this);return S._data=this._data.clone(),S},_minBufferSize:0});o.Hasher=m.extend({cfg:h.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}()}(Ps)),Ps.exports}var Ms,Ns={exports:{}};function ki(){return Ms||(Ms=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,h){this.high=o,this.low=h}}),c.WordArray=r.extend({init:function(o,h){o=this.words=o||[],this.sigBytes=h!=e?h:8*o.length},toX32:function(){for(var o=this.words,h=o.length,l=[],d=0;d<h;d++){var p=o[d];l.push(p.high),l.push(p.low)}return n.create(l,this.sigBytes)},clone:function(){for(var o=r.clone.call(this),h=o.words=this.words.slice(0),l=h.length,d=0;d<l;d++)h[d]=h[d].clone();return o}}),a;var e,t,i,r,n,c}(ue())}(Ns)),Ns.exports}var Ls,xs={exports:{}};function Kn(){return Ls||(Ls=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}(ue())}(xs)),xs.exports}var Vs,Os={exports:{}};function $n(){return Vs||(Vs=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,h=[],l=0;l<o;l+=2){var d=c[l>>>2]>>>16-l%4*8&65535;h.push(String.fromCharCode(d))}return h.join("")},parse:function(n){for(var c=n.length,o=[],h=0;h<c;h++)o[h>>>1]|=n.charCodeAt(h)<<16-h%2*16;return t.create(o,2*c)}},i.Utf16LE={stringify:function(n){for(var c=n.words,o=n.sigBytes,h=[],l=0;l<o;l+=2){var d=r(c[l>>>2]>>>16-l%4*8&65535);h.push(String.fromCharCode(d))}return h.join("")},parse:function(n){for(var c=n.length,o=[],h=0;h<c;h++)o[h>>>1]|=r(n.charCodeAt(h)<<16-h%2*16);return t.create(o,2*c)}}}(),a.enc.Utf16}(ue())}(Os)),Os.exports}var Us,Bs={exports:{}};function Wt(){return Us||(Us=1,function(s){s.exports=function(a){return function(){var e=a,t=e.lib.WordArray;function i(r,n,c){for(var o=[],h=0,l=0;l<n;l++)if(l%4){var d=c[r.charCodeAt(l-1)]<<l%4*2|c[r.charCodeAt(l)]>>>6-l%4*2;o[h>>>2]|=d<<24-h%4*8,h++}return t.create(o,h)}e.enc.Base64={stringify:function(r){var n=r.words,c=r.sigBytes,o=this._map;r.clamp();for(var h=[],l=0;l<c;l+=3)for(var d=(n[l>>>2]>>>24-l%4*8&255)<<16|(n[l+1>>>2]>>>24-(l+1)%4*8&255)<<8|n[l+2>>>2]>>>24-(l+2)%4*8&255,p=0;p<4&&l+.75*p<c;p++)h.push(o.charAt(d>>>6*(3-p)&63));var u=o.charAt(64);if(u)for(;h.length%4;)h.push(u);return h.join("")},parse:function(r){var n=r.length,c=this._map,o=this._reverseMap;if(!o){o=this._reverseMap=[];for(var h=0;h<c.length;h++)o[c.charCodeAt(h)]=h}var l=c.charAt(64);if(l){var d=r.indexOf(l);d!==-1&&(n=d)}return i(r,n,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),a.enc.Base64}(ue())}(Bs)),Bs.exports}var Hs,Fs={exports:{}};function Jn(){return Hs||(Hs=1,function(s){s.exports=function(a){return function(){var e=a,t=e.lib.WordArray;function i(r,n,c){for(var o=[],h=0,l=0;l<n;l++)if(l%4){var d=c[r.charCodeAt(l-1)]<<l%4*2|c[r.charCodeAt(l)]>>>6-l%4*2;o[h>>>2]|=d<<24-h%4*8,h++}return t.create(o,h)}e.enc.Base64url={stringify:function(r,n){n===void 0&&(n=!0);var c=r.words,o=r.sigBytes,h=n?this._safe_map:this._map;r.clamp();for(var l=[],d=0;d<o;d+=3)for(var p=(c[d>>>2]>>>24-d%4*8&255)<<16|(c[d+1>>>2]>>>24-(d+1)%4*8&255)<<8|c[d+2>>>2]>>>24-(d+2)%4*8&255,u=0;u<4&&d+.75*u<o;u++)l.push(h.charAt(p>>>6*(3-u)&63));var g=h.charAt(64);if(g)for(;l.length%4;)l.push(g);return l.join("")},parse:function(r,n){n===void 0&&(n=!0);var c=r.length,o=n?this._safe_map:this._map,h=this._reverseMap;if(!h){h=this._reverseMap=[];for(var l=0;l<o.length;l++)h[o.charCodeAt(l)]=l}var d=o.charAt(64);if(d){var p=r.indexOf(d);p!==-1&&(c=p)}return i(r,c,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"}}(),a.enc.Base64url}(ue())}(Fs)),Fs.exports}var js,zs={exports:{}};function Kt(){return js||(js=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 h=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],H=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=l(D,L,N,x,w,7,o[0]),x=l(x,D,L,N,y,12,o[1]),N=l(N,x,D,L,R,17,o[2]),L=l(L,N,x,D,A,22,o[3]),D=l(D,L,N,x,E,7,o[4]),x=l(x,D,L,N,I,12,o[5]),N=l(N,x,D,L,k,17,o[6]),L=l(L,N,x,D,P,22,o[7]),D=l(D,L,N,x,H,7,o[8]),x=l(x,D,L,N,G,12,o[9]),N=l(N,x,D,L,Y,17,o[10]),L=l(L,N,x,D,J,22,o[11]),D=l(D,L,N,x,z,7,o[12]),x=l(x,D,L,N,Q,12,o[13]),N=l(N,x,D,L,ee,17,o[14]),D=d(D,L=l(L,N,x,D,pe,22,o[15]),N,x,y,5,o[16]),x=d(x,D,L,N,k,9,o[17]),N=d(N,x,D,L,J,14,o[18]),L=d(L,N,x,D,w,20,o[19]),D=d(D,L,N,x,I,5,o[20]),x=d(x,D,L,N,Y,9,o[21]),N=d(N,x,D,L,pe,14,o[22]),L=d(L,N,x,D,E,20,o[23]),D=d(D,L,N,x,G,5,o[24]),x=d(x,D,L,N,ee,9,o[25]),N=d(N,x,D,L,A,14,o[26]),L=d(L,N,x,D,H,20,o[27]),D=d(D,L,N,x,Q,5,o[28]),x=d(x,D,L,N,R,9,o[29]),N=d(N,x,D,L,P,14,o[30]),D=p(D,L=d(L,N,x,D,z,20,o[31]),N,x,I,4,o[32]),x=p(x,D,L,N,H,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,H,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 l(g,m,b,S,v,_,w){var y=g+(m&b|~m&S)+v+w;return(y<<_|y>>>32-_)+m}function d(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(h),t.HmacMD5=n._createHmacHelper(h)}(Math),a.MD5}(ue())}(zs)),zs.exports}var Ws,Ks={exports:{}};function $s(){return Ws||(Ws=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(h,l){for(var d=this._hash.words,p=d[0],u=d[1],g=d[2],m=d[3],b=d[4],S=0;S<80;S++){if(S<16)c[S]=0|h[l+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=_}d[0]=d[0]+p|0,d[1]=d[1]+u|0,d[2]=d[2]+g|0,d[3]=d[3]+m|0,d[4]=d[4]+b|0},_doFinalize:function(){var h=this._data,l=h.words,d=8*this._nDataBytes,p=8*h.sigBytes;return l[p>>>5]|=128<<24-p%32,l[14+(p+64>>>9<<4)]=Math.floor(d/4294967296),l[15+(p+64>>>9<<4)]=d,h.sigBytes=4*l.length,this._process(),this._hash},clone:function(){var h=r.clone.call(this);return h._hash=this._hash.clone(),h}}),e.SHA1=r._createHelper(o),e.HmacSHA1=r._createHmacHelper(o),a.SHA1;var e,t,i,r,n,c,o}(ue())}(Ks)),Ks.exports}var Js,Gs={exports:{}};function dr(){return Js||(Js=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=[],h=[];(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))),h[m]=u(e.pow(g,1/3)),m++),g++})();var l=[],d=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)l[A]=0|p[u+A];else{var E=l[A-15],I=(E<<25|E>>>7)^(E<<14|E>>>18)^E>>>3,k=l[A-2],P=(k<<15|k>>>17)^(k<<13|k>>>19)^k>>>10;l[A]=I+l[A-7]+P+l[A-16]}var H=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)+h[A]+l[A];R=y,y=w,w=_,_=v+Y|0,v=S,S=b,b=m,m=Y+(G+H)|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(d),t.HmacSHA256=n._createHmacHelper(d)}(Math),a.SHA256}(ue())}(Gs)),Gs.exports}var qs,Gn={exports:{}},Xs,Ys={exports:{}};function Zs(){return Xs||(Xs=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 h=[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)],l=[];(function(){for(var p=0;p<80;p++)l[p]=o()})();var d=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,H=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,he=E,ke=I,$=k,ge=P,De=H,Ae=G,Te=Y,fe=J,_e=z,le=Q,Pe=ee,ye=pe,Ge=D,st=L,ae=N,re=0;re<80;re++){var te,be,Ve=l[re];if(re<16)be=Ve.high=0|p[u+2*re],te=Ve.low=0|p[u+2*re+1];else{var de=l[re-15],je=de.high,Z=de.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),Ne=l[re-2],ft=Ne.high,wt=Ne.low,St=(ft>>>19|wt<<13)^(ft<<3|wt>>>29)^ft>>>6,jt=(wt>>>19|ft<<13)^(wt<<3|ft>>>29)^(wt>>>6|ft<<26),_i=l[re-7],Ki=_i.high,Cc=_i.low,yn=l[re-16],kc=yn.high,Rn=yn.low;be=(be=(be=Me+Ki+((te=at+Cc)>>>0<at>>>0?1:0))+St+((te+=jt)>>>0<jt>>>0?1:0))+kc+((te+=Rn)>>>0<Rn>>>0?1:0),Ve.high=be,Ve.low=te}var Zt,Pc=fe&le^~fe&ye,An=_e&Pe^~_e&Ge,Dc=x&ke^x&ge^ke&ge,Mc=he&$^he&De^$&De,Nc=(x>>>28|he<<4)^(x<<30|he>>>2)^(x<<25|he>>>7),_n=(he>>>28|x<<4)^(he<<30|x>>>2)^(he<<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=h[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=le,Ge=Pe,le=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,$=he,x=wi+(Nc+Dc+(In>>>0<_n>>>0?1:0))+((he=Zt+In|0)>>>0<Zt>>>0?1:0)|0}E=m.low=E+he,m.high=A+x+(E>>>0<he>>>0?1:0),k=b.low=k+$,b.high=I+ke+(k>>>0<$>>>0?1:0),H=S.low=H+De,S.high=P+ge+(H>>>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+le+(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(d),e.HmacSHA512=t._createHmacHelper(d)}(),a.SHA512}(ue(),ki())}(Ys)),Ys.exports}var Qs,qn={exports:{}},ea,ta={exports:{}};function Xn(){return ea||(ea=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,h=[],l=[],d=[];(function(){for(var g=1,m=0,b=0;b<24;b++){h[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++)l[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}d[_]=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],H=p[(R+1)%5],G=H.high,Y=H.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=h[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[l[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],he=p[(R+1)%5+5*I],ke=p[(R+2)%5+5*I];N.high=x.high^~he.high&ke.high,N.low=x.low^~he.low&ke.low}N=b[0];var $=d[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}(ue(),ki())}(ta)),ta.exports}var ia,Yn={exports:{}},ra,sa={exports:{}};function ur(){return ra||(ra=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 h=this._oKey=n.clone(),l=this._iKey=n.clone(),d=h.words,p=l.words,u=0;u<c;u++)d[u]^=1549556828,p[u]^=909522486;h.sigBytes=l.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))}})}(ue())}(sa)),sa.exports}var aa,Zn={exports:{}},na,oa={exports:{}};function Mt(){return na||(na=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(h){this.cfg=this.cfg.extend(h)},compute:function(h,l){for(var d,p=this.cfg,u=p.hasher.create(),g=r.create(),m=g.words,b=p.keySize,S=p.iterations;m.length<b;){d&&u.update(d),d=u.update(h).finalize(l),u.reset();for(var v=1;v<S;v++)d=u.finalize(d),u.reset();g.concat(d)}return g.sigBytes=4*b,g}}),e.EvpKDF=function(h,l,d){return o.create(d).compute(h,l)},a.EvpKDF;var e,t,i,r,n,c,o}(ue(),$s(),ur())}(oa)),oa.exports}var ca,ha={exports:{}};function ze(){return ca||(ca=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 h=o.Base64,l=t.algo.EvpKDF,d=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=d.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 H=0;H<I;H++)A[E+H]^=k[H]}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 H=n.create(k,E);y.concat(H)},unpad:function(y){var R=255&y.words[y.sigBytes-1>>>2];y.sigBytes-=R}};i.BlockCipher=d.extend({cfg:d.cfg.extend({mode:g,padding:m}),reset:function(){var y;d.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(h)},parse:function(y){var R,A=h.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=l.create({keySize:R+A,hasher:I}).compute(y,E);else var k=l.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)}})}()}(ue(),Mt())}(ha)),ha.exports}var la,da={exports:{}};function Qn(){return la||(la=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,h=this._iv;h?(o=h.slice(0),this._iv=void 0):o=this._prevBlock,c.encryptBlock(o,0);for(var l=0;l<n;l++)i[r+l]^=o[l]}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}(ue(),ze())}(da)),da.exports}var ua,pa={exports:{}};function eo(){return ua||(ua=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,h=this._counter;o&&(h=this._counter=o.slice(0),this._iv=void 0);var l=h.slice(0);n.encryptBlock(l,0),h[c-1]=h[c-1]+1|0;for(var d=0;d<c;d++)i[r+d]^=l[d]}}),e.Decryptor=t,e),a.mode.CTR;var e,t}(ue(),ze())}(pa)),pa.exports}var ma,ga={exports:{}};function to(){return ma||(ma=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,h=255&n;c===255?(c=0,o===255?(o=0,h===255?h=0:++h):++o):++c,n=0,n+=c<<16,n+=o<<8,n+=h}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,h=o.blockSize,l=this._iv,d=this._counter;l&&(d=this._counter=l.slice(0),this._iv=void 0),i(d);var p=d.slice(0);o.encryptBlock(p,0);for(var u=0;u<h;u++)n[c+u]^=p[u]}});return e.Decryptor=r,e}(),a.mode.CTRGladman}(ue(),ze())}(ga)),ga.exports}var fa,Sa={exports:{}};function io(){return fa||(fa=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,h=this._keystream;o&&(h=this._keystream=o.slice(0),this._iv=void 0),n.encryptBlock(h,0);for(var l=0;l<c;l++)i[r+l]^=h[l]}}),e.Decryptor=t,e),a.mode.OFB;var e,t}(ue(),ze())}(Sa)),Sa.exports}var ba,ro={exports:{}},va,so={exports:{}},ya,ao={exports:{}},Ra,no={exports:{}},Aa,oo={exports:{}},_a,co={exports:{}},wa,ho={exports:{}},Ea,lo={exports:{}},Ia,Ta={exports:{}};function uo(){return Ia||(Ia=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],h=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],l=[{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}],d=[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=h[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|=l[E][((R^w[E])&d[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}(ue(),Wt(),Kt(),Mt(),ze())}(Ta)),Ta.exports}var Ca,po={exports:{}},ka,mo={exports:{}},Pa,go={exports:{}},Da,Ma={exports:{}};function fo(){return Da||(Da=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 h(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 l(g,m,b){let S,v=m,_=b;for(let w=0;w<r;++w)v^=g.pbox[w],_=h(g,v)^_,S=v,v=_,_=S;return S=v,v=_,_=S,_^=g.pbox[r],v^=g.pbox[r+1],{left:v,right:_}}function d(g,m,b){let S,v=m,_=b;for(let w=r+1;w>1;--w)v^=g.pbox[w],_=h(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=l(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=l(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=l(o,g[m],g[m+1]);g[m]=b.left,g[m+1]=b.right},decryptBlock:function(g,m){var b=d(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}(ue(),Wt(),Kt(),Mt(),ze())}(Ma)),Ma.exports}(function(s){s.exports=function(a){return a}(ue(),ki(),Kn(),$n(),Wt(),Jn(),Kt(),$s(),dr(),qs||(qs=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}(ue(),dr())}(Gn)),Zs(),Qs||(Qs=1,function(a){a.exports=function(e){return i=(t=e).x64,r=i.Word,n=i.WordArray,c=t.algo,o=c.SHA512,h=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 l=o._doFinalize.call(this);return l.sigBytes-=16,l}}),t.SHA384=o._createHelper(h),t.HmacSHA384=o._createHmacHelper(h),e.SHA384;var t,i,r,n,c,o,h}(ue(),ki(),Zs())}(qn)),Xn(),ia||(ia=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]),h=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]),l=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]),d=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,H,G,Y,J,z,Q,ee,pe,D,L=this._hash.words,N=p.words,x=u.words,he=o.words,ke=h.words,$=l.words,ge=d.words;for(J=k=L[0],z=P=L[1],Q=H=L[2],ee=G=L[3],pe=Y=L[4],A=0;A<80;A+=1)D=k+y[R+he[A]]|0,D+=A<16?m(P,H,G)+N[0]:A<32?b(P,H,G)+N[1]:A<48?S(P,H,G)+N[2]:A<64?v(P,H,G)+N[3]:_(P,H,G)+N[4],D=(D=w(D|=0,$[A]))+Y|0,k=Y,Y=G,G=w(H,10),H=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]+H+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 H=k[P];k[P]=16711935&(H<<8|H>>>24)|4278255360&(H<<24|H>>>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}(ue())}(Yn)),ur(),aa||(aa=1,function(a){a.exports=function(e){return r=(i=(t=e).lib).Base,n=i.WordArray,o=(c=t.algo).SHA256,h=c.HMAC,l=c.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:o,iterations:25e4}),init:function(d){this.cfg=this.cfg.extend(d)},compute:function(d,p){for(var u=this.cfg,g=h.create(u.hasher,d),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(d,p,u){return l.create(u).compute(d,p)},e.PBKDF2;var t,i,r,n,c,o,h,l}(ue(),dr(),ur())}(Zn)),Mt(),ze(),Qn(),eo(),to(),io(),ba||(ba=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}(ue(),ze())}(ro)),va||(va=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}(ue(),ze())}(so)),ya||(ya=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}(ue(),ze())}(ao)),Ra||(Ra=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}(ue(),ze())}(no)),Aa||(Aa=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}(ue(),ze())}(oo)),_a||(_a=1,function(a){a.exports=function(e){return e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding}(ue(),ze())}(co)),wa||(wa=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}(ue(),ze())}(ho)),Ea||(Ea=1,function(a){a.exports=function(e){return function(){var t=e,i=t.lib.BlockCipher,r=t.algo,n=[],c=[],o=[],h=[],l=[],d=[],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,h[w]=k<<16|k>>>16,l[w]=k<<8|k>>>24,d[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,h,l,d,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],H=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[H>>>16&255]^A[G>>>8&255]^E[255&Y]^w[J++],ee=y[H>>>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&H]^w[J++],D=y[Y>>>24]^R[P>>>16&255]^A[H>>>8&255]^E[255&G]^w[J++];P=Q,H=ee,G=pe,Y=D}Q=(I[P>>>24]<<24|I[H>>>16&255]<<16|I[G>>>8&255]<<8|I[255&Y])^w[J++],ee=(I[H>>>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&H])^w[J++],D=(I[Y>>>24]<<24|I[P>>>16&255]<<16|I[H>>>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}(ue(),Wt(),Kt(),Mt(),ze())}(lo)),uo(),Ca||(Ca=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 h=this._key,l=h.words,d=h.sigBytes,p=this._S=[],u=0;u<256;u++)p[u]=u;u=0;for(var g=0;u<256;u++){var m=u%d,b=l[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(h,l){h[l]^=c.call(this)},keySize:8,ivSize:0});function c(){for(var h=this._S,l=this._i,d=this._j,p=0,u=0;u<4;u++){d=(d+h[l=(l+1)%256])%256;var g=h[l];h[l]=h[d],h[d]=g,p|=h[(h[l]+h[d])%256]<<24-8*u}return this._i=l,this._j=d,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 h=this.cfg.drop;h>0;h--)c.call(this)}});t.RC4Drop=i._createHelper(o)}(),e.RC4}(ue(),Wt(),Kt(),Mt(),ze())}(po)),ka||(ka=1,function(a){a.exports=function(e){return function(){var t=e,i=t.lib.StreamCipher,r=t.algo,n=[],c=[],o=[],h=r.Rabbit=i.extend({_doReset:function(){for(var d=this._key.words,p=this.cfg.iv,u=0;u<4;u++)d[u]=16711935&(d[u]<<8|d[u]>>>24)|4278255360&(d[u]<<24|d[u]>>>8);var g=this._X=[d[0],d[3]<<16|d[2]>>>16,d[1],d[0]<<16|d[3]>>>16,d[2],d[1]<<16|d[0]>>>16,d[3],d[2]<<16|d[1]>>>16],m=this._C=[d[2]<<16|d[2]>>>16,4294901760&d[0]|65535&d[1],d[3]<<16|d[3]>>>16,4294901760&d[1]|65535&d[2],d[0]<<16|d[0]>>>16,4294901760&d[2]|65535&d[3],d[1]<<16|d[1]>>>16,4294901760&d[3]|65535&d[0]];for(this._b=0,u=0;u<4;u++)l.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++)l.call(this)}},_doProcessBlock:function(d,p){var u=this._X;l.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),d[p+g]^=n[g]},blockSize:4,ivSize:2});function l(){for(var d=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=d[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}d[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,d[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,d[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,d[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,d[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,d[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,d[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,d[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}t.Rabbit=i._createHelper(h)}(),e.Rabbit}(ue(),Wt(),Kt(),Mt(),ze())}(mo)),Pa||(Pa=1,function(a){a.exports=function(e){return function(){var t=e,i=t.lib.StreamCipher,r=t.algo,n=[],c=[],o=[],h=r.RabbitLegacy=i.extend({_doReset:function(){var d=this._key.words,p=this.cfg.iv,u=this._X=[d[0],d[3]<<16|d[2]>>>16,d[1],d[0]<<16|d[3]>>>16,d[2],d[1]<<16|d[0]>>>16,d[3],d[2]<<16|d[1]>>>16],g=this._C=[d[2]<<16|d[2]>>>16,4294901760&d[0]|65535&d[1],d[3]<<16|d[3]>>>16,4294901760&d[1]|65535&d[2],d[0]<<16|d[0]>>>16,4294901760&d[2]|65535&d[3],d[1]<<16|d[1]>>>16,4294901760&d[3]|65535&d[0]];this._b=0;for(var m=0;m<4;m++)l.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++)l.call(this)}},_doProcessBlock:function(d,p){var u=this._X;l.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),d[p+g]^=n[g]},blockSize:4,ivSize:2});function l(){for(var d=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=d[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}d[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,d[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,d[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,d[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,d[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,d[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,d[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,d[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}t.RabbitLegacy=i._createHelper(h)}(),e.RabbitLegacy}(ue(),Wt(),Kt(),Mt(),ze())}(go)),fo())})(ks);const hi=jn(ks.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
|
+
`+r)}}return null},new Promise((i,r)=>{var n=h=>{try{o(t.next(h))}catch(l){r(l)}},c=h=>{try{o(t.throw(h))}catch(l){r(l)}},o=h=>h.done?i(h.value):Promise.resolve(h.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=(h=e,hi.MD5(h).toString().toUpperCase());var h;let l=new Date().toUTCString(),d=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+`
|
|
10
|
+
`+w+`
|
|
11
11
|
`+((R=_.get("Content-Type"))!=null?R:"")+`
|
|
12
12
|
`+y+`
|
|
13
|
-
`;const
|
|
14
|
-
`).join("")}catch(P){}A+=p,v.size>0&&(A+="?");try{A+=[...v.entries()].sort(T).map(P=>P[0]+"="+P[1]).join("&")}catch(P){}const k="LOG "+b+":"+ri.HmacSHA1(A,S).toString(ri.enc.Base64);_.set("Authorization",k),_.set("x-log-date",y)}("POST",a,s.accessKeyId,s.accessKeySecret,u,f,n,d);let l=Object.fromEntries(f);return{data:e,header:l}},new Promise((a,c)=>{var n=u=>{try{d(r.next(u))}catch(f){c(f)}},h=u=>{try{d(r.throw(u))}catch(f){c(f)}},d=u=>u.done?a(u.value):Promise.resolve(u.value).then(n,h);d((r=r.apply(t,i)).next())});var t,i,r}}}typeof window!="undefined"&&vs(window,"stsPlugin",sr);var oo=/d{1,4}|D{3,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|W{1,2}|[LlopSZN]|"[^"]*"|'[^']*'/g,co=/\b(?:[A-Z]{1,3}[A-Z][TC])(?:[-+]\d{4})?|((?:Australian )?(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time)\b/g,ho=/[^-+\dA-Z]/g;function ar(s,o,e,t){if(arguments.length!==1||typeof s!="string"||/\d/.test(s)||(o=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=(o=String(Ta[o]||o||Ta.default)).slice(0,4);i!=="UTC:"&&i!=="GMT:"||(o=o.slice(4),e=!0,i==="GMT:"&&(t=!0));var r=function(){return e?"getUTC":"get"},a=function(){return s[r()+"Date"]()},c=function(){return s[r()+"Day"]()},n=function(){return s[r()+"Month"]()},h=function(){return s[r()+"FullYear"]()},d=function(){return s[r()+"Hours"]()},u=function(){return s[r()+"Minutes"]()},f=function(){return s[r()+"Seconds"]()},l=function(){return s[r()+"Milliseconds"]()},g=function(){return e?0:s.getTimezoneOffset()},p=function(){return lo(s)},b={d:function(){return a()},dd:function(){return Je(a())},ddd:function(){return Ke.dayNames[c()]},DDD:function(){return Ia({y:h(),m:n(),d:a(),_:r(),dayName:Ke.dayNames[c()],short:!0})},dddd:function(){return Ke.dayNames[c()+7]},DDDD:function(){return Ia({y:h(),m:n(),d:a(),_:r(),dayName:Ke.dayNames[c()+7]})},m:function(){return n()+1},mm:function(){return Je(n()+1)},mmm:function(){return Ke.monthNames[n()]},mmmm:function(){return Ke.monthNames[n()+12]},yy:function(){return String(h()).slice(2)},yyyy:function(){return Je(h(),4)},h:function(){return d()%12||12},hh:function(){return Je(d()%12||12)},H:function(){return d()},HH:function(){return Je(d())},M:function(){return u()},MM:function(){return Je(u())},s:function(){return f()},ss:function(){return Je(f())},l:function(){return Je(l(),3)},L:function(){return Je(Math.floor(l()/10))},t:function(){return d()<12?Ke.timeNames[0]:Ke.timeNames[1]},tt:function(){return d()<12?Ke.timeNames[2]:Ke.timeNames[3]},T:function(){return d()<12?Ke.timeNames[4]:Ke.timeNames[5]},TT:function(){return d()<12?Ke.timeNames[6]:Ke.timeNames[7]},Z:function(){return t?"GMT":e?"UTC":po(s)},o:function(){return(g()>0?"-":"+")+Je(100*Math.floor(Math.abs(g())/60)+Math.abs(g())%60,4)},p:function(){return(g()>0?"-":"+")+Je(Math.floor(Math.abs(g())/60),2)+":"+Je(Math.floor(Math.abs(g())%60),2)},S:function(){return["th","st","nd","rd"][a()%10>3?0:(a()%100-a()%10!=10)*a()%10]},W:function(){return p()},WW:function(){return Je(p())},N:function(){return uo(s)}};return o.replace(oo,function(S){return S in b?b[S]():S.slice(1,S.length-1)})}var Ta={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"},Ke={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"]},Je=function(s){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;return String(s).padStart(o,"0")},Ia=function(s){var o=s.y,e=s.m,t=s.d,i=s._,r=s.dayName,a=s.short,c=a!==void 0&&a,n=new Date,h=new Date;h.setDate(h[i+"Date"]()-1);var d=new Date;return d.setDate(d[i+"Date"]()+1),n[i+"FullYear"]()===o&&n[i+"Month"]()===e&&n[i+"Date"]()===t?c?"Tdy":"Today":h[i+"FullYear"]()===o&&h[i+"Month"]()===e&&h[i+"Date"]()===t?c?"Ysd":"Yesterday":d[i+"FullYear"]()===o&&d[i+"Month"]()===e&&d[i+"Date"]()===t?c?"Tmw":"Tomorrow":r},lo=function(s){var o=new Date(s.getFullYear(),s.getMonth(),s.getDate());o.setDate(o.getDate()-(o.getDay()+6)%7+3);var e=new Date(o.getFullYear(),0,4);e.setDate(e.getDate()-(e.getDay()+6)%7+3);var t=o.getTimezoneOffset()-e.getTimezoneOffset();o.setHours(o.getHours()-t);var i=(o-e)/6048e5;return 1+Math.floor(i)},uo=function(s){var o=s.getDay();return o===0&&(o=7),o},po=function(s){return(String(s).match(co)||[""]).pop().replace(ho,"").replace(/GMT\+0000/g,"UTC")};const{BrowserUtil:go}=G.AliRTS,mo="EdgeHTML",wa="Blink",fo="Trident",So="Gecko",bo="WebKit",_i=(s,o)=>{const e=o.match(s);return e&&e.length>0&&e[1]||""},vo=[{test:[/\sedg\//i,[/edg([ea]|ios)/i]],describe(s){if(/\sedg\//i.test(s))return{name:wa};const o=_i(/edge\/(\d+(\.?_?\d+)+)/i,s);return{name:mo,version:o}}},{test:[/trident/i],describe(s){const o={name:fo},e=_i(/trident\/(\d+(\.?_?\d+)+)/i,s);return e&&(o.version=e),o}},{test(s){const o=/gecko/i.test(s),e=/like gecko/i.test(s);return o&&!e},describe(s){const o={name:So},e=_i(/gecko\/(\d+(\.?_?\d+)+)/i,s);return e&&(o.version=e),o}},{test:[/(apple)?webkit\/537\.36/i],describe:()=>({name:wa})},{test:[/(apple)?webkit/i],describe(s){const o={name:bo},e=_i(/webkit\/(\d+(\.?_?\d+)+)/i,s);return e&&(o.version=e),o}}],nr=(s,o)=>s.find(e=>typeof e.test=="function"?e.test(o):Array.isArray(e.test)?e.test.some(t=>typeof t=="string"?o.indexOf(t)>-1:t instanceof RegExp&&t.test(o)):void 0),yo=()=>{try{const s=navigator.userAgent||"",o=nr(vo,s);if(o){const e=o.describe(s);return`${e.name}/${e.version||go.browserVersion}`}}catch(s){}return navigator.userAgent},Ro=[{test:["wow64","win64","x64"],describe:()=>"amd64"},{test:["i686","x86"],describe:()=>"x86"},{test:["aarch64","arm64"],describe:()=>"arm64"},{test:["arm"],describe:()=>"arm"}],Ca=()=>{let s="unknown";try{const o=navigator.userAgent||"",e=nr(Ro,o);if(!e)return s;s=e.describe(o)}catch(o){}return s},Ao=[{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"}],_o=()=>{let s="Unknown";try{const o=navigator.userAgent||"",e=nr(Ao,o);if(!e)return s;s=e.describe(o)}catch(o){}return s},{BrowserUtil:ka,SystenUtil:Pa}=G.AliRTS,Eo=Ca(),Ei=6e5,Ti={host:"cn-hangzhou.log.aliyuncs.com",project:"alivc-aio",logstore:"logger",time:10,count:10};function or(){return ar(new Date,"HH:MM:ss.l")}function Ma(){return ar(new Date,"isoDate")}var cr=(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))(cr||{});class To{constructor(){m(this,"tracker");m(this,"slsPlugin");m(this,"stsData");m(this,"stsExpiration",Date.now());m(this,"clientId",Qe());m(this,"bSesid",Qe());m(this,"logLevel",3);m(this,"appId","");m(this,"sessionId","");m(this,"logCache",[]);m(this,"updateTaskTimer");m(this,"endReported",!0);m(this,"logSequence",0);m(this,"sendLogBeforeUnload",o=>w(this,null,function*(){if(!this.slsPlugin)return;this.logSequence+=1,o.unshift(this.getLogParams(710203,{log:`[${Ma()} ${or()}] [INF] beforeunload`,stat_log_seq:this.logSequence}));const e=`https://${Ti.project}.${Ti.host}/logstores/${Ti.logstore}`,t={__logs__:o.map(a=>this.slsPlugin.transString(a))},{data:i,header:r}=yield this.slsPlugin.process(e,JSON.stringify(t));fetch(e,{keepalive:!0,method:"POST",headers:r,body:i})}));m(this,"logMethod",(o,e=console.log)=>(...t)=>{let i=or();this.logLevel<=o&&e(i,...t);let r=ze.paramArrayToString(t);o>0&&this.addLog(r)});m(this,"d",this.logMethod(0,console.debug));m(this,"i",this.logMethod(1));m(this,"w",this.logMethod(3,console.warn));m(this,"e",this.logMethod(4,(...o)=>{const[e,...t]=o;console.error(e,"<error>",t)}));m(this,"ev",this.logMethod(2));m(this,"a",this.logMethod(2,(...o)=>{const[e,...t]=o;if(t.length>2){const i=`${t[1]}`;i.startsWith("__g__")&&console.group(`${i.substring(5)}_${t[2]}`)}console.log(e,...t)}));m(this,"ar",this.logMethod(2,(...o)=>{const[e,...t]=o;console.log(e,...t),t.length>2&&`${t[1]}`.startsWith("__g__")&&console.groupEnd()}));m(this,"ae",this.logMethod(2,(...o)=>{const[e,...t]=o;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=Qe(),this.endReported=!0,this.logSequence=0,this.appId="",this.sessionId=""}startSTSUpdateTask(){return w(this,null,function*(){this.updateTaskTimer&&clearTimeout(this.updateTaskTimer);try{const o=yield this.refreshSTSToken();this.createTracker(o)}catch(o){}this.updateTaskTimer=setTimeout(()=>{this.startSTSUpdateTask()},Ei)})}refreshSTSToken(){return w(this,null,function*(){if(!this.stsData||this.stsExpiration<=Date.now()-Ei){const o=yield this.requestSTSToken(),e=new Date(o==null?void 0:o.Expiration).getTime()||0,t=Date.now()+Ei;this.stsExpiration=Math.max(e,t),this.stsData=o}return this.stsData})}requestSTSToken(){const o=Date.now(),e=`${this.clientId}|woMMssV6jmyol9fr|${o}`,t={Action:"AssumeSlsRoleV2",AuthInfo:ri.MD5(e).toString(ri.enc.Hex),ClientId:this.clientId,BusinessType:"logger",AppVersion:"1.0",Version:"2017-03-14",AuthTimestamp:`${o}`,TerminalType:"web",DeviceModel:"",Format:"JSON",SignatureMethod:"HMAC-SHA1",SignatureVersion:"1.0",Timestamp:ar(o,"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(o){if(!this.tracker){const e={accessKeyId:o.AccessKeyId,accessKeySecret:o.AccessKeySecret,securityToken:o.SecurityToken,refreshSTSTokenInterval:Ei,stsTokenFreshTime:void 0,refreshSTSToken:()=>{this.refreshSTSToken().then(r=>{e.accessKeyId=r.AccessKeyId,e.accessKeySecret=r.AccessKeySecret,e.securityToken=r.SecurityToken}).catch(()=>{})}},t=new er(Ti),i=sr(e);t.useStsPlugin(i),this.slsPlugin=i,this.tracker=t,this.reportStartAndCache()}}changeConfig(o){o.logLevel!==void 0&&o.logLevel>=0&&o.logLevel<=5&&(this.logLevel=o.logLevel)}setSessionID(o,e){o&&e&&(this.appId=o,this.sessionId=e,this.reportStartAndCache())}reportStartAndCache(){if(!this.tracker||!this.sessionId)return;this.endReported=!1;const o={task_btm_sec:0,task_duration:0,task_etm_sec:0,task_type:"session"},e=[this.getLogParams(710201,o),this.getLogParams(710202,o)];this.tracker.sendBatchLogsImmediate(e),this.logCache.forEach(t=>{this.sendLog(t)})}reportEnd(o=!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)];o?this.sendLogBeforeUnload(t):(this.tracker.sendBatchLogsImmediate(t),this.endReported=!0),this.reset()}getLogParams(o,e){return Y({appid:`${window.location.host}`,appid_list:this.appId,appver:"",b_sesid:this.bSesid,biz_type:"rtc",cpu_info:Eo,db:ka.browserName,dm:ka.browserVersion,install_uuid:this.clientId,logger_v:"0.0.1",os:Pa.systemName,osv:Pa.systemVersion,p_sesid:this.bSesid,sdk_version:Ri,sdkname:"AliRTCSdk",stm:Date.now(),tar_pf:"web",traceid:this.sessionId,event_id:o},e||{})}sendLog(o){if(!this.tracker||!this.sessionId)return;this.logSequence+=1;const e=this.getLogParams(710203,{log:o,stat_log_seq:this.logSequence});this.tracker.send(e)}addLog(o){const e=or(),t=`[${Ma()} ${e}] ${o}`;this.sessionId&&this.tracker?this.sendLog(t):(this.logCache.push(t),this.logCache.length>=200&&this.logCache.shift())}}class x{static getLogger(){return this.logger||(this.logger=new To),this.logger}static init(){this.getLogger().init()}static destroy(){this.getLogger().destroy()}static setLogLevel(o){this.getLogger().changeConfig({logLevel:o})}static setSessionID(o,e){this.getLogger().setSessionID(o,e)}static reportEnd(){this.getLogger().reportEnd()}static interface(...o){this.getLogger().a("[API]",...o)}static interfaceResult(o,e,t,...i){t?this.getLogger().ar("[ARE]",o,e,...i):this.getLogger().ae("[ARE]",o,e,...i)}static event(...o){this.getLogger().ev("[EVT]",...o)}static debug(...o){this.getLogger().d("[DBG]",...o)}static info(...o){this.getLogger().i("[INF]",...o)}static warn(...o){this.getLogger().w("[WARN]",...o)}static error(...o){this.getLogger().e("[ERR]",...o)}}m(x,"logger");const Io=s=>w(this,null,function*(){const o=new G.AliRTS.SupportUtil;let e={support:!1,detail:{isWebRTCSupported:o.checkMediaDevices()&&o.checkWebRtcSupport(),isH264DecodeSupported:!1,isH264EncodeSupported:!1,isScreenShareSupported:!1,isSendMediaExtensionMsgSupported:!1,isBrowserSupported:!0}},t=!1;try{yield o.isSupport({isReceiveVideo:!0}),t=!0}catch(i){t=!1,e.detail.isBrowserSupported=o.checkBrowser({errorCode:0,message:""})}if(e.support=t,o.checkWebRtcSupport()&&s!=="sendonly"){const i=yield o.checkH264Decode();e.detail.isH264DecodeSupported=i,e.support=e.support&&i}if(o.checkWebRtcSupport()&&s!=="recvonly"){const i=yield o.checkH264Encode();e.detail.isH264EncodeSupported=i,e.support=e.support&&i}return e.detail.isScreenShareSupported=o.checkWebRtcSupport()&&o.checkScreenCapture()&&!G.AliRTS.SystenUtil.isAndroid&&!G.AliRTS.SystenUtil.isIos,e.detail.isSendMediaExtensionMsgSupported=o.checkWebRtcSupport()&&o.checkEncodedTransformSupport(),e});var ve=(s=>(s[s.AliRtcSdkStreamTypeCapture=0]="AliRtcSdkStreamTypeCapture",s[s.AliRtcSdkStreamTypeScreen=1]="AliRtcSdkStreamTypeScreen",s))(ve||{}),La=(s=>(s[s.PRE_PROCESSOR=0]="PRE_PROCESSOR",s[s.POST_PROCESSOR=1]="POST_PROCESSOR",s))(La||{}),si=(s=>(s[s.AUDIO=0]="AUDIO",s[s.VIDEO=1]="VIDEO",s[s.BOTH=2]="BOTH",s))(si||{});class Ut extends te{constructor(e,t=ve.AliRtcSdkStreamTypeCapture,i=1){super();m(this,"name");m(this,"options");m(this,"type",0);m(this,"streamType");m(this,"trackType");m(this,"zIndex",1);m(this,"_isEnable",!0);m(this,"lastInputAudioTrack");m(this,"lastOutputAudioTrack");m(this,"lastInputVideoTrack");m(this,"lastOutputVideoTrack");m(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 w(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 w(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 ai=(s=>(s[s.LiveTranscodingSingle=0]="LiveTranscodingSingle",s[s.LiveTranscodingMix=1]="LiveTranscodingMix",s))(ai||{}),hr=(s=>(s[s.LiveTranscodingOrigin=0]="LiveTranscodingOrigin",s[s.LiveTranscodingAudio=1]="LiveTranscodingAudio",s[s.LiveTranscodingVideo=2]="LiveTranscodingVideo",s))(hr||{}),qt=(s=>(s[s.LiveTranscodingCamera=0]="LiveTranscodingCamera",s[s.LiveTranscodingShareScreen=1]="LiveTranscodingShareScreen",s))(qt||{});const ni={0:"camera",1:"shareScreen"};var dr=(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))(dr||{});const wo={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 Ii=(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))(Ii||{}),oi=(s=>(s[s.LiveTranscodingNoBody=0]="LiveTranscodingNoBody",s[s.LiveTranscodingBody=1]="LiveTranscodingBody",s))(oi||{}),ci=(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))(ci||{}),lr=(s=>(s[s.LiveTranscodingOrigin=0]="LiveTranscodingOrigin",s[s.LiveTranscodingCrop=1]="LiveTranscodingCrop",s[s.LiveTranscodingFill=2]="LiveTranscodingFill",s))(lr||{}),wi=(s=>(s[s.LiveTranscodingNormal=0]="LiveTranscodingNormal",s[s.LiveTranscodingVirtualBackground=1]="LiveTranscodingVirtualBackground",s))(wi||{}),ur=(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))(ur||{}),dt=(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))(dt||{}),pr=(s=>(s[s.TrascodingPublishTaskStatusStart=0]="TrascodingPublishTaskStatusStart",s[s.TrascodingPublishTaskStatusUpdate=1]="TrascodingPublishTaskStatusUpdate",s[s.TrascodingPublishTaskStatusStop=2]="TrascodingPublishTaskStatusStop",s))(pr||{}),We=(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))(We||{});const Co={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 gr{constructor(o,e,t,i,r,a,c,n){m(this,"videoWidth");m(this,"videoHeight");m(this,"videoFramerate",20);m(this,"videoBitrate",2e3);m(this,"videoGop",30);m(this,"audioSamplerate",Ii.LiveTranscoding_HZ_44100);m(this,"audioBitrate",500);m(this,"audioChannels",1);this.videoWidth=o,this.videoHeight=e,t&&(this.videoFramerate=t),i&&(this.videoBitrate=i),r&&(this.videoGop=r),a&&(this.audioSamplerate=a),c&&(this.audioBitrate=c),n&&(this.audioChannels=n)}}const mr=s=>((16711680&s)>>16)+(65280&s)+((255&s)<<16),Ze=(s=0,o)=>{if(o==0)return 0;let e=s/o;return e<0&&(e=0),e>1&&(e=1),e};class Ci{constructor(o,e,t){m(this,"mixMode",ai.LiveTranscodingSingle);m(this,"singleParam");m(this,"mixParam");o&&(this.mixMode=o),e&&(this.singleParam=e),t&&(this.mixParam=t)}toJson(o,e,t,i,r){const a={appid:e.appId,channelid:e.channelId};if(o===We.MPU_TASK_TRANSACTION_POLLING||o===We.MPU_TASK_TRANSACTION_LIST||o===We.MPU_TASK_TRANSACTION_ACKNOWLEDGE)return o===We.MPU_TASK_TRANSACTION_ACKNOWLEDGE&&(a.messageid=r),a;if(a.taskid=t,o!==We.MPU_TASK_TRANSACTION_STOP){if(a.mixmode=this.mixMode,i&&(a.streamurl=i),this.mixMode===ai.LiveTranscodingSingle){const c=this.singleParam;if(c){a.streamtype=c.streamType,c.sourceType===qt.LiveTranscodingShareScreen?a.sourcetype=ni[c.sourceType]:a.sourcetype=ni[qt.LiveTranscodingCamera];const n=[];c.userId&&n.push(c.userId),a.subspecusers=n}}else if(o===We.MPU_TASK_TRANSACTION_START||o===We.MPU_TASK_TRANSACTION_UPDATE){const c=this.mixParam;if(c){c.taskProfile&&(a.taskprofile=wo[c.taskProfile]);const n=c.encodeParam||new gr(1280,720);let h=n.videoWidth,d=n.videoHeight;const u={};Object.keys(n).forEach(l=>{const g=n[l];g>0&&(u[l.toLowerCase()]=g)}),u.lowbitratehighquality=0,a.encodeparam=u,a.backgrounds=c.backgrounds.map(l=>l.toJson(h,d)),a.watermarks=c.watermarks.map(l=>l.toJson(h,d)),a.clockwidgets=c.clockWidgets.map(l=>l.toJson(h,d));const f=c.users.map(l=>l.userId);a.subspecusers=[...new Set(f)],a.layouts=[{audiomixcount:c.users.length,panes:c.users.map((l,g)=>l.toJson(g,h,d,c.mediaProcessMode))}],a.layoutids=["0"],a.cropmode=c.cropMode,a.backgroundcolor=mr(c.backgroundColor),a.taskmode=c.mediaProcessMode}}}return a}}var bt=(s=>(s.pre="pre",s.prod="prod",s))(bt||{}),vt=(s=>(s.AliRtcSdkCommunication="communication",s.AliRtcSdkInteractiveLive="interactive_live",s.AliRtcSdkInteractiveWithLowLatencyLive="cdn_live",s))(vt||{}),wt=(s=>(s.AliRtcSdkInteractive="interactive",s.AliRtcSdkLive="live",s))(wt||{}),lt=(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))(lt||{}),Ee=(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))(Ee||{}),ae=(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))(ae||{}),Bt=(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))(Bt||{}),fr=(s=>(s[s.AliRtcUserOfflineQuit=0]="AliRtcUserOfflineQuit",s[s.AliRtcUserOfflineDropped=1]="AliRtcUserOfflineDropped",s[s.AliRtcUserOfflineBecomeAudience=2]="AliRtcUserOfflineBecomeAudience",s))(fr||{}),Yt=(s=>(s[s.AliRtcAudioTrackNo=0]="AliRtcAudioTrackNo",s[s.AliRtcAudioTrackMic=1]="AliRtcAudioTrackMic",s[s.AliRtcAudioTrackDual=2]="AliRtcAudioTrackDual",s))(Yt||{}),ie=(s=>(s[s.AliRtcVideoTrackNo=0]="AliRtcVideoTrackNo",s[s.AliRtcVideoTrackCamera=1]="AliRtcVideoTrackCamera",s[s.AliRtcVideoTrackScreen=2]="AliRtcVideoTrackScreen",s[s.AliRtcVideoTrackBoth=3]="AliRtcVideoTrackBoth",s))(ie||{}),Q=(s=>(s[s.AliRtcStatePublishIdle=0]="AliRtcStatePublishIdle",s[s.AliRtcStateNoPublish=1]="AliRtcStateNoPublish",s[s.AliRtcStatePublishing=2]="AliRtcStatePublishing",s[s.AliRtcStatePublished=3]="AliRtcStatePublished",s))(Q||{}),ce=(s=>(s[s.AliRtcStateSubscribeIdle=0]="AliRtcStateSubscribeIdle",s[s.AliRtcStateNoSubscribe=1]="AliRtcStateNoSubscribe",s[s.AliRtcStateSubscribing=2]="AliRtcStateSubscribing",s[s.AliRtcStateSubscribed=3]="AliRtcStateSubscribed",s))(ce||{}),De=(s=>(s[s.AliRtcVideoStreamTypeNone=0]="AliRtcVideoStreamTypeNone",s[s.AliRtcVideoStreamTypeHigh=1]="AliRtcVideoStreamTypeHigh",s[s.AliRtcVideoStreamTypeLow=2]="AliRtcVideoStreamTypeLow",s))(De||{}),hi=(s=>(s[s.CAMERA_INVALID=-1]="CAMERA_INVALID",s[s.CAMERA_REAR=0]="CAMERA_REAR",s[s.CAMERA_FRONT=1]="CAMERA_FRONT",s))(hi||{});const Zt=class Zt extends te{constructor(e){super();m(this,"ws");m(this,"socketStatus",0);m(this,"wsUrl","");m(this,"lastConnectStartTime",0);m(this,"maxConnectRetryCount",12);m(this,"connectRetryCount",0);m(this,"gotErr",!1);m(this,"closedByInvoke",!0);m(this,"isReconnecting",!1);m(this,"networkAvailableChecked",!0);m(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){x.info(`[${Zt.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&&ze.isNetworkAvailable().then(t=>{t&&console.error(Zt.logName,"onError, Network is available, token may be invalid")})}onClose(e){return w(this,null,function*(){if(this.closedByInvoke)this.socketStatus=0;else{if(x.info(`[${Zt.logName}]`,`onClose, code: ${e.code}, reason: ${e.reason}, status: ${status}, retryCount: ${this.connectRetryCount}`),(yield ze.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)}};m(Zt,"logName","Socket");let Sr=Zt;var Te=(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))(Te||{});class ko{constructor(o,e){m(this,"authInfo");m(this,"userName");m(this,"seqIndex",0);this.authInfo=o,this.userName=e}get roleAuth(){if(this.authInfo.role){const{timestamp:o,nonce:e,token:t,role:i}=this.authInfo;return{timestamp:o,nonce:e,token:t,tokenrole:i}}}refreshAuthInfo(o){this.authInfo=o}getSeqIndex(){return this.seqIndex}createKeepAlivePackage(){return this.createBaseSendPackage("keepalive")}createJoinPackage(o){let e=this.createBaseSendPackage("joinchannel");return e.header.displayName=this.userName,e.header.clientversion=ze.getVersionNumber().toString(),e.header.platform="web",this.roleAuth&&(e.data.auth=this.roleAuth),o&&(e.data=Y(Y({},e.data),o)),e}crateLeavePackage(){return this.createBaseSendPackage("leavechannel")}createStatusPackage(o){let e=this.createBaseSendPackage("statusreport");return e.header.displayName=this.userName,e.data.status=o,e}createPublishPackage(){let o=this.createBaseSendPackage("publish");return o.data.users=[{}],this.roleAuth&&(o.data.auth=this.roleAuth),o}createRoleUpdatePackage(){let o=this.createBaseSendPackage("roleupdate");return o.header.displayName=this.userName,o}createReconnectPackage(o){let e=this.createBaseSendPackage("reconnect");return e.header.displayName=this.userName,e.header.clientversion=ze.getVersionNumber().toString(),e.header.platform="web",e.data=Y(Y({},e.data),o!=null?o:{}),this.roleAuth&&(e.data.auth=this.roleAuth),e}createRefreshUrlPackage(){let o=this.createBaseSendPackage("refreshurl");return o.header.displayName=this.userName,o}createResponsePackage(o,e){return{version:1,code:200,tid:o,msgtype:e}}createBaseSendPackage(o){var e;return++this.seqIndex,{version:1,msgtype:o,tid:Qe(),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 U=(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))(U||{});class O extends Error{constructor(e,t,i){super(t);m(this,"_code");m(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 qe=class qe extends te{constructor(e,t,i,r,a,c){super();m(this,"authInfo");m(this,"userName");m(this,"channelProfile");m(this,"clientRole");m(this,"slsReporter");m(this,"wsClient");m(this,"packageCreater");m(this,"keepAliveTimer",0);m(this,"packageCache",new Map);m(this,"isFirstConnect",!0);m(this,"aliveChecker",0);m(this,"reconnectData");m(this,"joinChannelExtraData");this.authInfo=e,this.userName=t,this.packageCreater=new ko(e,t),this.channelProfile=i,this.clientRole=r,this.slsReporter=a,this.wsClient=new Sr(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 h=e,{l1ip:t}=h,i=Jt(h,["l1ip"]);let r=this.packageCreater.createPublishPackage();r.data.users=[],r.data.l1ip=t,i.subscribe.signal=this.wsClient.connectUrl;const{tracks:a,resume:c}=i;let n="7.1.0-beta.1";n&&(n=n.split("-")[0]),a.forEach(d=>{const{codec:u,ssrc:f}=d;d.userdata=JSON.stringify({sdk_version:n,codec:u}),d.ssrc=`${f}`,c&&(d.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=Y(Et(Y({},t.data),{sessionid:t.header.sessionid}),e),this.sendPackage(t)}refreshAuthInfo(e){this.authInfo=e,this.packageCreater.refreshAuthInfo(e)}close(){x.info(`[${qe.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){[Te.KEEPALIVE,Te.RECONNECT,Te.JOINCHANNEL].includes(e.msgtype)||this.packageCache.set(e.tid,e),this.wsClient.send(e),e.msgtype!==Te.KEEPALIVE&&this.slsReporter.reportRoomServerEvent(!0,e.msgtype,e.tid,e)}updateReconnectData(e){this.reconnectData=e}onOpen(){if(x.info(`[${qe.logName}] onOpen`),this.isFirstConnect){let e=this.packageCreater.createJoinPackage(this.joinChannelExtraData);e.data.configure={channelprofile:this.channelProfile},this.channelProfile!==vt.AliRtcSdkInteractiveLive&&this.channelProfile!==vt.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)!==Te.KEEPALIVE&&this.slsReporter.reportRoomServerEvent(!1,t.msgtype,t.tid,t)}catch(t){x.warn(`[${qe.logName}] onMessage err`,t,e)}}onError(e){x.warn(`[${qe.logName}] onError`,e),this.isFirstConnect&&this.onConnectFail()}onConnectFail(){x.warn(`[${qe.logName}] onConnectFail`);const e=new O(U.ERR_INNER,"Signaling connect failed.");this.isFirstConnect?this.emit("onJoinChannelResult",e):this.emit("onConnectFail",e)}onAuthInvalid(){x.warn(`[${qe.logName}] onAuthInvalid`),this.isFirstConnect&&this.emit("onAuthInvalid")}onNetworkError(){x.warn(`[${qe.logName}] onNetworkError`);const e=new O(U.ERR_INNER,"Network error, signaling connect failed.");this.emit("onNetworkError",e)}onClose(e){x.info(`[${qe.logName}] onClose`,e),this.stopKeepAlive()}onKeepAliveRsp(){this.emit("onKeepAliveRsp"),this.checkAlive()}onReconnectStart(){this.emit("onReconnectStart")}onReconnectFail(){this.emit("onReconnectFail",new O(U.ERR_INNER,"signaling reconnect failed."))}checkAlive(){window.clearTimeout(this.aliveChecker),this.aliveChecker=window.setTimeout(()=>{x.info(`[${qe.logName}] not alive, reconnect`),this.stopKeepAlive(),this.emit("onReconnectStart"),this.wsClient.reconnect()},3e4)}onRecvMessage(e){switch(e.msgtype!==Te.KEEPALIVE&&x.info(`[${qe.logName}] recv msg: ${e.msgtype}`),e.msgtype){case Te.JOINCHANNEL:this.onJoinResult(e);break;case Te.KEEPALIVE:this.onKeepAliveRsp();break;case Te.PUBLISH:this.onPublishResult(e);break;case Te.NOTIFYJOIN:this.onNotifyJoin(e);break;case Te.NOTIFYSTATUS:this.onNotifyStatus(e);break;case Te.LEAVECHANNEL:this.onLeaveResult(e);break;case Te.NOTIFYLEAVE:this.onNotifyLeave(e);break;case Te.NOTIFYPUBLISH:this.onNotifyPublish(e);break;case Te.STATUSREPORT:this.onStatusReport(e);break;case Te.BYE:this.onBye(e);break;case Te.ROLEUPDATE:this.onRoleUpdateResult(e);break;case Te.REFRESHURL:this.onRefreshUrlResult(e);break;case Te.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(U.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)}};m(qe,"logName","RSMessageCenter");let br=qe;const C=(s,o)=>(e,t,i)=>{const r=i.value;return i.value=function(...a){var u;const c=`[${((u=e.constructor)==null?void 0:u.logName)||""}]`,n=Date.now();let h=[];if(s)try{h=s(a)}catch(f){}x.interface(c,t,...h);const d=r.apply(this,a);return Promise.resolve(d).then(f=>f).catch(f=>f).then(f=>{var b;let l="";const g=f instanceof Error,p=g&&((b=e.constructor)==null?void 0:b.logError);if(o||g){if(p)l=f;else if(g)l=f.message||"";else{if(!o)return;if(f===void 0)l="";else try{l=o(f)}catch(S){}}x.interfaceResult(c,t,!(g&&p),Date.now()-n+"ms",l)}}),d},i},B=s=>s;var Po=Object.defineProperty,Mo=Object.getOwnPropertyDescriptor,vr=(s,o,e,t)=>{for(var i,r=t>1?void 0:t?Mo(o,e):o,a=s.length-1;a>=0;a--)(i=s[a])&&(r=(t?i(o,e,r):i(r))||r);return t&&r&&Po(o,e,r),r};const ki=(He=class extends te{constructor(e,t,i,r=bt.prod){super();m(this,"messageCenter");m(this,"authInfo");m(this,"userName");m(this,"channelProfile");m(this,"clientRole");m(this,"slsReporter");m(this,"reconnectData");m(this,"roomServerUri","");this.channelProfile=e,this.clientRole=t,this.slsReporter=i,this.reconnectData={role:{channelprofile:e,clientrole:t}};const a=r===bt.pre?yi.pre:yi.prod;this.roomServerUri=`wss://${a}/roomserver/v1/ws`}updateReconnectData(e){var t;this.reconnectData=e,(t=this.messageCenter)==null||t.updateReconnectData(this.reconnectData)}reset(){x.info("[roomsig] reset"),this.messageCenter&&(this.messageCenter.close(),this.messageCenter=void 0),this.authInfo=void 0}join(e,t,i,r){return w(this,null,function*(){return new Promise((a,c)=>{const n={};this.authInfo=e,this.userName=t,this.messageCenter=new br(e,t,this.channelProfile,this.clientRole,this.slsReporter,i),this.initMessageCenter(),this.messageCenter.once("onJoinChannelResult",d=>{var u,f,l;if(x.info(`[${He.logName}]`,"join result: ",d),n.taskretrynum=((u=this.messageCenter)==null?void 0:u.retryCount)||0,d.code==200){(f=this.messageCenter)==null||f.sendPkgCache(),(l=this.messageCenter)==null||l.startKeepAlive();let g=d.data;g.tid=d.tid,g.users=d.data.users,g.timestamp=d.timestamp,n.est&&(n.joinconnecttc=Date.now()-n.est),this.slsReporter.reportJoinConnection(n),a(g)}else this.reset(),c(this.handleSignalError(d.code,d.reason,U.ERR_JOIN_CHANNEL_FAILED))}),this.messageCenter.once("onAuthInvalid",()=>{this.reset(),c(new O(U.ERR_JOIN_BAD_TOKEN,"join failed because authentication failed"))}),x.info(`[${He.logName}]`,"start ws connecting roomserver and auto join when connected");const h={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:Qe()};e.role&&(h.tokenrole=e.role),n.est=Date.now(),this.messageCenter.start(this.roomServerUri+"?"+ze.queryingParam(h),r)})})}leave(){return x.info("[roomsig] leave .."),new Promise((e,t)=>{this.messageCenter?(this.messageCenter.on("onLeaveResult",(i,r)=>{x.info(`[${He.logName}]`,"recv leave response "+i),i===200?(this.updateReconnectData(),this.reset(),e({tid:r})):t(this.handleSignalError(i,"leave error"))}),x.info(`[${He.logName}]`,"send leave request"),this.messageCenter.leave()):(x.info(`[${He.logName}]`,"no message center, ok to leave"),e({tid:""}))})}publish(e){return new Promise((t,i)=>{var r;this.messageCenter?(this.messageCenter.once("onPublishResult",(a,c,n)=>{x.info(`[${He.logName}]`,"recv pubish response "+a),a===200?(this.updateReconnectData(Et(Y({},this.reconnectData),{publish:{users:[e]}})),t({tid:c})):i(this.handleSignalError(a,`publish error, ${n}`))}),this.authInfo&&(e.sessionid=(r=this.authInfo.sessionId)!=null?r:""),e.callid||(e.callid=Qe()),x.info(`[${He.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,a,c)=>{var n,h;x.info(`[${He.logName}]`,"recv role update response "+r),r===200?((h=(n=this.reconnectData)==null?void 0:n.role)!=null&&h.clientrole&&(this.reconnectData.role.clientrole=e,this.updateReconnectData(this.reconnectData)),t({tid:a})):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 x.info(`[${He.logName}]`,"refreshUrl .."),new Promise((t,i)=>{this.messageCenter?(this.messageCenter.on("onRefreshUrlResult",r=>{const{code:a,description:c,data:n={}}=r||{};x.info("recv refresh url response "+a),a===200?t(n):i(this.handleSignalError(a,`refresh url error, ${c}`))}),x.info("send refresh url request"),this.messageCenter.refreshUrl(e)):i(this.handleSignalError(-1,"refresh url error, no message center"))})}reportStatus(e){return x.info(`[${He.logName}]`,"reportStatus "+e),new Promise((t,i)=>{this.messageCenter?(this.messageCenter.once("onStatusReport",(r,a)=>{r===200?t():i(new O(r,a))}),this.messageCenter.reportStatus(e)):i(new O(-1,"No messageCenter"))})}handleSignalError(e,t,i=U.ERR_INNER){return new O(i,`signal error: code - ${e}; description - ${t}`)}refreshAuthInfo(e){return w(this,null,function*(){var t;this.authInfo&&(this.authInfo=e,(t=this.messageCenter)==null||t.refreshAuthInfo(this.authInfo))})}initMessageCenter(){var e,t,i,r,a,c,n,h,d,u,f,l,g;(e=this.messageCenter)==null||e.on("onKeepAliveRsp",()=>{this.emit("onKeepAliveRsp")}),(t=this.messageCenter)==null||t.on("onNotifyJoin",p=>{this.emit("onNotifyJoin",p)}),(i=this.messageCenter)==null||i.on("onNotifyStatus",p=>{this.emit("onNotifyStatus",p)}),(r=this.messageCenter)==null||r.on("onNotifyLeave",p=>{this.emit("onNotifyLeave",p)}),(a=this.messageCenter)==null||a.on("onNotifyPublish",p=>{this.emit("onNotifyPublish",p)}),(c=this.messageCenter)==null||c.on("onBye",(p,b)=>{this.emit("onBye",p,b)}),(n=this.messageCenter)==null||n.on("onReconnectStart",()=>{this.emit("onReconnectStart")}),(h=this.messageCenter)==null||h.on("onReconnectSuccess",p=>{this.emit("onReconnectSuccess",p)}),(d=this.messageCenter)==null||d.on("onReconnectFail",p=>{this.emit("onReconnectFail",p)}),(u=this.messageCenter)==null||u.on("onConnectFail",p=>{this.emit("onConnectFail",p),this.reset()}),(f=this.messageCenter)==null||f.on("onNetworkError",p=>{this.emit("onNetworkError",p)}),(l=this.messageCenter)==null||l.on("onAuthInvalid",()=>{this.emit("onAuthInvalid")}),(g=this.messageCenter)==null||g.on("onUnknownMessage",p=>{this.emit("onUnknownMessage",p)})}},m(He,"logName","RoomServerSignaling"),He);vr([C()],ki.prototype,"join",1),vr([C()],ki.prototype,"publish",1),vr([C()],ki.prototype,"roleUpdate",1);let Lo=ki;const Do=6e5,gi=class gi extends te{constructor(e,t){super();m(this,"env");m(this,"authInfo");m(this,"timer");m(this,"slsReporter");m(this,"expiration",0);m(this,"skipTime",0);m(this,"requestToken",()=>w(this,null,function*(){if(this.skipTime=0,!this.authInfo)return;const{appId:e,channelId:t,userId:i,nonce:r="",token:a,timestamp:c,sessionId:n,role:h}=this.authInfo;let d="https://gw.rtn.aliyuncs.com";this.env===bt.pre&&(d="https://pgw.rtn.aliyuncs.com");const u=`${d}/gslb/v1/stsupdate?appid=${e}&channelid=${t}&userid=${i}&nonce=${r}&token=${a}×tamp=${c}&session=${n}${h?`&tokenrole=${h}`:""}&slstoken=true&osstoken=true&tokensid=false`,f=Date.now();fetch(u).then(l=>l.json()).then(l=>{var g,p;if(l.code!==0)throw new Error;{const b=(g=l.data)==null?void 0:g.oss,S=(p=l.data)==null?void 0:p.sls;this.expiration=b.expiration||S.expiration,this.emit("onTokenUpdate",b,S),x.event(`[${gi.logName}]`,"getToken",b,S)}this.slsReporter.reportSTSResult(200,f)}).catch(l=>{this.slsReporter.reportSTSResult(-1,f),x.error(`[${gi.logName}]`,"getToken",l.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()},Do)}clear(){this.timer&&clearInterval(this.timer)}};m(gi,"logName","StsManager");let yr=gi;var No=Object.defineProperty,Vo=Object.getOwnPropertyDescriptor;class Rr extends te{constructor(e,t,i,r=bt.prod){super();m(this,"signaling");m(this,"authInfo");m(this,"userName");m(this,"channelProfile");m(this,"clientRole");m(this,"env",bt.prod);m(this,"maxConnectRetryCount");m(this,"stsManager");m(this,"slsReporter");this.channelProfile=e,this.clientRole=t,this.env=r,this.slsReporter=i,this.stsManager=new yr(i,r)}reset(){var e;x.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,a){return this.maxConnectRetryCount=i,this.userName=t,new Promise((c,n)=>{this.signaling?n(new O(U.ERR_JOIN_ALREADY_JOINED,"already joined")):(x.info("[signalingmanager] create signaling"),this.signaling=new Lo(this.channelProfile,this.clientRole,this.slsReporter,this.env),this.initSignaling(),r&&(r.rs=Date.now()),this.signaling.join(e,t,i,a).then(h=>{this.authInfo=e,r&&(r.re=Date.now()),c(h)}).catch(h=>{this.reset(),n(h)}),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(a=>{t(a)}).catch(a=>{i(a)})):i(new O(U.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 w(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(U.ERR_SDK_INVALID_STATE,"should join first"))}refreshAuthInfo(e){return w(this,null,function*(){var t;try{this.authInfo&&(this.authInfo=Y(Y({},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,a,c,n,h,d,u,f,l,g,p;(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)),(a=this.signaling)==null||a.on("onNotifyPublish",this.onNotifyPublish.bind(this)),(c=this.signaling)==null||c.on("onBye",this.onBye.bind(this)),(n=this.signaling)==null||n.on("onReconnectStart",this.onReconnectStart.bind(this)),(h=this.signaling)==null||h.on("onReconnectSuccess",this.onReconnectSuccess.bind(this)),(d=this.signaling)==null||d.on("onReconnectFail",this.onReconnectFail.bind(this)),(u=this.signaling)==null||u.on("onConnectFail",this.onConnectFail.bind(this)),(f=this.signaling)==null||f.on("onNetworkError",this.onNetworkError.bind(this)),(l=this.signaling)==null||l.on("onAuthInvalid",this.onAuthInvalid.bind(this)),(g=this.signaling)==null||g.on("onError",this.onError.bind(this)),(p=this.signaling)==null||p.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)}}m(Rr,"logName","SignalingManager");function Xt(){}((s,o,e,t)=>{for(var i,r=t>1?void 0:t?Vo(o,e):o,a=s.length-1;a>=0;a--)(i=s[a])&&(r=(t?i(o,e,r):i(r))||r);t&&r&&No(o,e,r)})([C(B)],Rr.prototype,"publish",1);const Kt=class Kt{static getInstance(){var o;return Kt.instance||(Kt.instance=new AudioContext),(o=Kt.instance.resume())==null||o.then(Xt,Xt).catch(Xt),Kt.instance}};m(Kt,"instance");let Ht=Kt;const Pi=()=>{var o;const s=Ht.getInstance();s.state!=="running"&&s.state!=="closed"&&((o=s.resume())==null||o.then(Xt,Xt).catch(Xt)),window.removeEventListener("mousedown",Pi),window.removeEventListener("touchstart",Pi)};window.addEventListener("mousedown",Pi),window.addEventListener("touchstart",Pi);class Oo extends te{constructor(){super();m(this,"audioContext");m(this,"stream");m(this,"sourceNode");m(this,"analyser");this.audioContext=Ht.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,a,c,n,h){let d,u=n,f=0;const l=r.createAnalyser();l.fftSize=256;const g=new Uint8Array(l.frequencyBinCount);a.connect(l),l.connect(c);const p=()=>{d&&window.clearInterval(d)},b=()=>{r.state==="suspended"&&r.resume(),d=window.setInterval(()=>{l.getByteFrequencyData(g);let S=Math.round(g.reduce((v,_)=>v+_)/g.length);S=Math.min(100,S),f=S,h&&h(S)},u)};return b(),{updateInterval:S=>{p(),u=S,b()},getLevel:()=>f,dispose:()=>{p(),a.disconnect(),l.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 Da extends te{constructor(e,t,i,r){super();m(this,"uid");m(this,"name");m(this,"rtsManager");m(this,"callId","");m(this,"audioLevelMonitor");m(this,"audioVolumeIndicationInterval",0);this.uid=e,this.name=t,this.rtsManager=i,this.audioVolumeIndicationInterval=r,this.audioLevelMonitor=new Oo}get userId(){return this.uid}get displayname(){return this.name}createCallId(){this.callId||(this.callId=ze.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 Na{static getCurrentStatus(o){let e=0;o.micOpen&&(e+=1),o.micInterrupted&&(e+=2),o.cameraOpen&&(e+=4),o.screenShare&&(e+=128),o.audioDisable&&(e+=8),o.videoDisable&&(e+=16),o.screenDisable&&(e+=256);let t=e.toString(16);for(;t.length<16;)t="0"+t;return t}static parseStatus(o){let e=parseInt(o,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 Va="customVideoProfile",Oa="customScreenProfile",Ar={width:1280,height:720,frameRate:30,maxBitrate:2e3},xa={width:1920,height:1080,frameRate:30,maxBitrate:2600};var di=(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))(di||{});const xo={1e4:Ee.AliEngineLocalDeviceExceptionTypeUnknown,2e4:Ee.AliEngineLocalDeviceExceptionTypeUnknown,10001:Ee.AliEngineLocalDeviceExceptionTypeMicNotAvailable,10002:Ee.AliEngineLocalDeviceExceptionTypeMicAuthFail,10003:Ee.AliEngineLocalDeviceExceptionTypeMicOpenFail,10005:Ee.AliEngineLocalDeviceExceptionTypeCameraAuthFail,10004:Ee.AliEngineLocalDeviceExceptionTypeVideoDeviceException,10006:Ee.AliEngineLocalDeviceExceptionTypeCameraOpenFail,10010:Ee.AliEngineLocalDeviceExceptionTypeDisplayException,10011:Ee.AliEngineLocalDeviceExceptionTypeDisplayException,10012:Ee.AliEngineLocalDeviceExceptionTypeDisplayException,10013:Ee.AliEngineLocalDeviceExceptionTypeDisplayException,10014:Ee.AliEngineLocalDeviceExceptionTypeDisplayException,10019:Ee.AliEngineLocalDeviceExceptionTypeDisplayException};var Ge=(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))(Ge||{}),et=(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))(et||{});function Ua(s){var o;if(((o=s==null?void 0:s.nodeName)==null?void 0:o.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(U.ERR_INVALID_ARGUMENTS,"element should be HtmlVideoElement")}throw new O(U.ERR_INVALID_ARGUMENTS,"element not founded")}throw new O(U.ERR_INVALID_ARGUMENTS,"element id should be string")}function _r(s){var e;const o=[];if(Array.isArray(s))s.forEach(t=>{try{o.push(Ua(t))}catch(i){}});else if(typeof s=="string"||((e=s==null?void 0:s.nodeName)==null?void 0:e.toLowerCase())==="video")try{o.push(Ua(s))}catch(t){}return o}function Ct(s){return new Promise(o=>setTimeout(o,s))}function Ba(s,o,e=1e3,t=i=>!0){return w(this,null,function*(){let i=0;for(;i<o;)try{return yield s(i)}catch(r){if(i++,i>=o||!t(r))throw r||void 0;yield new Promise(a=>setTimeout(a,e))}})}function Er(s,o){let e=o;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}const Ha=(s,o,e=!1)=>{const t=()=>(s.muted=!0,Promise.race([Ct(500),s._playPromise||Promise.resolve()]).catch(()=>{}).then(()=>{let i;return e&&s.srcObject===o?i=Promise.resolve():(s.load(),s.srcObject=o,i=s.play(),s._playPromise=i),i}));return new Promise(i=>{if(G.AliRTS.BrowserUtil.isMicroMessenger){const r=window.top!==window.self,a=window.WeixinJSBridge||window.top.WeixinJSBridge;a?a.invoke("getNetworkType",{},()=>{i(t())}):(r?window.top.document:document).addEventListener("WeixinJSBridgeReady",()=>{a.invoke("getNetworkType",{},()=>{i(t())})}),setTimeout(()=>{i(t())},1e3)}else setTimeout(()=>{i(t())},0)})},ut=s=>{Promise.race([Ct(100),s._playPromise||Promise.resolve()]).catch(()=>{}).then(()=>{s.srcObject=null,s._playPromise=void 0})};var Tr=(s=>(s[s.AliEngineDataMsgNone=0]="AliEngineDataMsgNone",s[s.AliEngineDataMsgMusicProgress=1]="AliEngineDataMsgMusicProgress",s[s.AliEngineDataMsgCustom=2]="AliEngineDataMsgCustom",s))(Tr||{});class Mi{constructor(o,e,t,i=0){m(this,"msgType");m(this,"msgId");m(this,"protocolVersion");m(this,"tlvVersion");this.msgType=o,this.msgId=e,this.protocolVersion=t,this.tlvVersion=i}build(){const o=new Uint8Array(4);return o.set(Uint8Array.from([this.protocolVersion,this.tlvVersion<<4|15&this.msgType]),0),o.set(Uint16Array.from([this.msgId]),2),o}static parse(o){const e=new DataView(o),t=e.getUint8(0),i=e.getUint8(1)>>4,r=15&e.getUint8(1),a=e.getUint16(2);return new Mi(r,a,t,i)}}class Li{constructor(o,e,t){m(this,"_byteArray");if(this._byteArray=new Uint8Array(0),o!==void 0&&e!==void 0&&t!==void 0){const i=new Mi(o,e,t).build();this._byteArray=new Uint8Array(i.byteLength+this._byteArray.byteLength),this._byteArray.set(i,0)}}write(o,e){const t=this._byteArray,i=new ArrayBuffer(5),r=new DataView(i);r.setUint8(0,o),r.setUint32(1,e.byteLength);const a=new Uint8Array(t.byteLength+5+e.byteLength);a.set(t,0),a.set(new Uint8Array(i),t.byteLength),a.set(new Uint8Array(e),t.byteLength+5),this._byteArray=a}static parse(o){const e={},t=new DataView(o);let i=0;for(;i<o.byteLength;){const r=t.getUint8(i),a=t.getUint32(i+1);if(!(i+5+a<=o.byteLength))break;{const c=o.slice(i+5,i+5+a);e[r]=c,i+=5+a}}return e}get buffer(){return this._byteArray.buffer}}class li{constructor(o=0,e=!0,t=1,i=!1,r=0,a=!1,c=!1,n=3){m(this,"_fin",!0);m(this,"_hasExtension",!1);m(this,"_version",0);m(this,"_frameType",1);m(this,"_isEncrypted",!1);m(this,"_isCompressed",!1);m(this,"_signalType",3);m(this,"_payloadLength",0);this._fin=e,this._hasExtension=i,this._version=r,this._frameType=t,this._isEncrypted=a,this._isCompressed=c,this._signalType=n,this._payloadLength=o}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 o=new ArrayBuffer(4),e=new DataView(o);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),o}static parse(o){const e=new DataView(o),t=e.getUint8(0)>>7==1,i=(64&e.getUint8(0))>>6==1,r=(48&e.getUint8(0))>>4,a=15&e.getUint8(0),c=e.getUint8(1)>>7==1,n=(64&e.getUint8(1))>>6==1,h=15&e.getUint8(1),d=e.getUint16(2);return new li(d,t,a,i,r,c,n,h)}}class Di{constructor(o,e){m(this,"_body");m(this,"_header",new li);this._header=o,this._body=e}get header(){return this._header}get isFin(){return this._header.fin}get body(){return this._body}toGRTNBuffer(){const o=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+o.byteLength+e.byteLength);return i.set(new Uint8Array(t),0),i.set(new Uint8Array(o),t.byteLength),i.set(new Uint8Array(e),t.byteLength+o.byteLength),i.buffer}static parse(o){const e=o.slice(0,4),t=li.parse(e);let i=new ArrayBuffer(0);return o.byteLength-4>=t.payloadLength&&(i=o.slice(4,4+t.payloadLength)),new Di(t,i)}}const Ir=s=>{const o=s.byteLength,e=new DataView(s);let t=0;for(let i=0;i<o;i++)t=256*t+e.getUint8(i);return t};let Fa=0;class kt{constructor(o,e=0,t=0,i=0){m(this,"data");m(this,"networkTime");m(this,"futureOrProgress");m(this,"type");this.data=o,this.type=e,this.networkTime=t,this.futureOrProgress=i}toBuffer(){const o=new Li(0,0,0);o.write(1,Uint8Array.from([0]).buffer),o.write(2,Uint16Array.from([0]).buffer),Fa++,o.write(3,Uint32Array.from([Fa]).buffer);const e=new Li;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),o.write(30,e.buffer),o.buffer}static parse(o){if(!o||o.byteLength<4)return;Mi.parse(o.slice(0,4));const e=Li.parse(o.slice(4))[30];if(!e)return;const t=Li.parse(e),i=t[2],r=t[3],a=t[4],c=t[5];return c.byteLength!==0?new kt(c,Ir(i),Ir(a),Ir(r)):void 0}}var Uo=Object.defineProperty,Bo=Object.getOwnPropertyDescriptor,Se=(s,o,e,t)=>{for(var i,r=t>1?void 0:t?Bo(o,e):o,a=s.length-1;a>=0;a--)(i=s[a])&&(r=(t?i(o,e,r):i(r))||r);return t&&r&&Uo(o,e,r),r};class ui extends te{constructor(){super();m(this,"_state");m(this,"time");this._state=Q.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 fe=(yt=class extends Da{constructor(e){const{rtsManager:t,localStreamManager:i,slsReporter:r,signalingManager:a,audioVolumeIndicationInterval:c,parameter:n}=e;super("","",t,c);m(this,"_url","");m(this,"joinTime",0);m(this,"publishPromise",Promise.resolve({traceId:"",l1ip:void 0}));m(this,"previewElements",[]);m(this,"screenPreviewElements",[]);m(this,"streamManager");m(this,"dc");m(this,"streamTracks");m(this,"publishId",Qe());m(this,"signalingManager");m(this,"traceId","");m(this,"monitorTimerId");m(this,"monitorDataCache",{});m(this,"trackTraceIdMap",{});m(this,"candidateDataCache",[]);m(this,"pcMediaStatsMap",{});m(this,"slsReporter");m(this,"audioPubState");m(this,"videoPubState");m(this,"videoSmallPubState");m(this,"screenPubState");m(this,"dataPubState");m(this,"parameter",{});m(this,"onTrackEnd",e=>{this.emit(e)});this.streamManager=i,this.signalingManager=a,this.slsReporter=r,this.parameter=n,this.streamManager.on("trackended",h=>{this.onTrackEnd(h)}),this.streamManager.on("publishupdate",()=>{this.publishUpdate()}),this.audioPubState=new ui,this.audioPubState.on("change",(h,d,u)=>{this.emit("audioPublishStateChanged",h,d,u)}),this.videoPubState=new ui,this.videoPubState.on("change",(h,d,u)=>{this.emit("videoPublishStateChanged",h,d,u)}),this.videoSmallPubState=new ui,this.videoSmallPubState.on("change",(h,d,u)=>{this.emit("dualStreamPublishStateChanged",h,d,u)}),this.screenPubState=new ui,this.screenPubState.on("change",(h,d,u)=>{this.emit("screenPublishStateChanged",h,d,u)}),this.dataPubState=new ui,this.dataPubState.on("change",(h,d,u)=>{this.emit("dataPublishStateChanged",h,d,u)}),this.startStreamMonitor()}get url(){return this._url}set url(e){this._url=e,this.rtsManager.updateAuth(e)}set preferredPubL1Ip(e){this.rtsManager.preferredPubL1Ip=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||ze.createCallid(),this.updatePubId()}setVideoProfile(e){return w(this,null,function*(){yield this.streamManager.setVideoProfile(Va,e)})}setVideoContentHint(e){this.streamManager.setVideoContentHint(e)}setScreenContentHint(e){this.streamManager.setScreenContentHint(e)}setAudioProfile(e){return w(this,null,function*(){yield this.streamManager.setAudioProfile(e)})}setScreenProfile(e){return w(this,null,function*(){yield this.streamManager.setScreenProfile(Oa,e)})}setCameraDirection(e){if(e===hi.CAMERA_FRONT)this.streamManager.setCameraVideoConstraints({facingMode:"user"});else{if(e!==hi.CAMERA_REAR)throw new O(U.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=Qe()}clearPublishState(){this.streamTracks=void 0}leave(){return w(this,null,function*(){this.isPublishing&&(yield this.unPublish()),this.joinTime=0,this.dc=void 0})}clear(){return w(this,null,function*(){Br(yt.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)&&(ut(e),this.previewElements.splice(this.previewElements.indexOf(e),1)),this.screenPreviewElements.includes(e)&&(ut(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 w(this,null,function*(){const{hasCamera:t,cameraCaptureDisabled:i,publishLocalVideoStreamEnabled:r}=this;if(!t&&!e&&!i&&r)try{yield this.startCameraCapture()}catch(a){const c=a.errorCode;let n=U.ERR_CAMERA_OPEN_FAIL;throw c===di.ERROR_DEVICE_AUDIODEVICE_NOTFOUND?n=U.ERR_CAMERA_NOT_AVAILABLE:c===di.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED&&(n=U.ERR_CAMERA_AUTH_FAIL),new O(n,`camera open fail: ${a.message}`)}})}startDefaultAudio(){return w(this,null,function*(){const{hasMicrophone:e,audioCaptureDisabled:t,publishLocalAudioStreamEnabled:i}=this;if(!e&&!t&&i)try{yield this.startAudioCapture()}catch(r){const a=r.errorCode;let c=U.ERR_MIC_OPEN_FAIL;throw a===di.ERROR_DEVICE_AUDIODEVICE_NOTFOUND?c=U.ERR_MIC_NOT_AVAILABLE:a===di.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED&&(c=U.ERR_MIC_AUTH_FAIL),new O(c,`mic open fail: ${r.message}`)}})}setViewConfig(e,t){if(e){if(![ie.AliRtcVideoTrackCamera,ie.AliRtcVideoTrackScreen].includes(t))throw new O(U.ERR_INVALID_ARGUMENTS,"set view config invalid track",{track:t});e.forEach(i=>{this.setPreviewElement({videoElement:i,screen:t===ie.AliRtcVideoTrackScreen})})}else t===ie.AliRtcVideoTrackCamera?this.stopPreview({primary:!0,screen:!1}):this.stopPreview({primary:!1,screen:!0})}startCameraCapture(){return w(this,null,function*(){return this.streamManager.cameraCaptureDisabled=!1,yield this.createLocalStream({video:!0})})}stopCameraCapture(){return w(this,null,function*(){this.streamManager.cameraCaptureDisabled=!0,yield this.stopLocalStream({video:!0})})}startAudioCapture(){return w(this,null,function*(){return this.streamManager.audioCaptureDisabled=!1,yield this.createLocalStream({audio:!0})})}stopAudioCapture(){return w(this,null,function*(){this.streamManager.audioCaptureDisabled=!0,yield this.stopLocalStream({audio:!0})})}preview(e){return w(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(U.ERR_INVALID_ARGUMENTS,"no video element found",{videoElement:t});return r?(Ha(t,r.mediaStream),this.setPreviewElement(e),r.mediaStream):void x.info(`[${yt.logName}]`,"preview no stream founded")}catch(r){const a=U.ERR_INNER;throw O.fromError(r,a,"preview failed")}})}previewAll(e){return w(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 a=this.previewElements[r];yield this.preview({videoElement:a})}if(i&&this.screenPreviewElements.length)for(let r=0;r<this.screenPreviewElements.length;r++){const a=this.screenPreviewElements[r];yield this.preview({videoElement:a,screen:!0})}})}stopPreview(e){const{videoElement:t,primary:i=!0,screen:r=!0}=e||{};if(t){const a=this.previewElements.findIndex(c=>c===t);if(a>=0)this.previewElements.splice(a,1),ut(t);else{const c=this.screenPreviewElements.findIndex(n=>n===t);c>=0&&(this.screenPreviewElements.splice(c,1),ut(t))}}else i&&(this.previewElements.forEach(a=>{ut(a)}),this.previewElements=[]),r&&(this.screenPreviewElements.forEach(a=>{ut(a)}),this.screenPreviewElements=[])}resumePublish(){return w(this,null,function*(){yield this.startPublish(!0)})}createLocalStream(e){return w(this,null,function*(){try{if(e.video)for(let i=0;i<this.previewElements.length;i++){const r=this.previewElements[i];ut(r)}else if(e.screen)for(let i=0;i<this.screenPreviewElements.length;i++){const r=this.screenPreviewElements[i];ut(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=xo[t.errorCode];throw i&&(e.audio?this.emit("localDeviceException",lt.AliEngineLocalDeviceTypeMic,i,""):e.video?this.emit("localDeviceException",lt.AliEngineLocalDeviceTypeCamera,i,""):e.screen?this.emit("localDeviceException",lt.AliEngineLocalDeviceTypeDisplay,i,""):this.emit("localDeviceException",lt.AliEngineLocalDeviceTypeUnknown,i,"")),t}})}stopLocalStream(e){return w(this,null,function*(){e.audio&&this.audioLevelMonitor.stop(),yield this.streamManager.stopLocalStream(e)})}compareAndPublish(e,t,i){return w(this,null,function*(){var a,c;if(!e&&!t)return;if(e&&!t){const n={};return i===M.Audio?n.audio=!0:i===M.VideoLarge||i===M.VideoSmall?(n.video=!0,n.vMsid=i):i===M.Screen&&(n.screen=!0),yield this.publishDeleteTracks(n)}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!==(((a=t.videoTrack)==null?void 0:a.id)||((c=t.audioTrack)==null?void 0:c.id)))return yield this.publishReplace(t,r)})}reportAudioProfile(){const e=this.streamManager.cameraStreamInfo.audioProfile||"standard",t=G.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=G.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=G.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 w(this,null,function*(){if(this.dataPubState.state!==Q.AliRtcStatePublishing){this.dataPubState.setState(Q.AliRtcStatePublishing);try{const e=yield this.rtsManager.publishAddDataChannel(this.url);e?(this.updateDataChannel(e),this.dataPubState.setState(Q.AliRtcStatePublished)):(this.dataPubState.setState(Q.AliRtcStateNoPublish),this.emit("publishDataError",new O(U.ERR_INNER,"publishDataError")))}catch(e){x.error("[LocalUser]","publishDataChannel error",e),this.dataPubState.setState(Q.AliRtcStateNoPublish)}}})}startPublish(){return w(this,arguments,function*(e=!1,t=ht.MANUAL){var h;if(!this.joined)return;const i=this.streamManager.publishStreams,{audio:r,video:a,videoSmall:c,screen:n}=i;if(r||a||c||n){this.createCallId();try{const d=new Date().getTime();r&&this.audioPubState.setState(Q.AliRtcStatePublishing),a&&this.videoPubState.setState(Q.AliRtcStatePublishing),c&&this.videoSmallPubState.setState(Q.AliRtcStatePublishing),n&&this.screenPubState.setState(Q.AliRtcStatePublishing),this.publishPromise=this.rtsManager.publish(this.url,this.callId,e,t);const{traceId:u,l1ip:f}=yield this.publishPromise;this.streamTracks=this.rtsManager.publishingTracks,this.traceId=u;const l={type:Tt.Add,userid:this.userId,sessionid:"",displayname:this.name,pubid:this.publishId,resume:e,subscribe:{signal:"",pullstreamurl:this.url},l1ip:this.parameter.reportL1IP?f:void 0,callid:this.callId,tracks:this.streamTracks,traceid:u};(h=this.parameter.data)!=null&&h.enablePubDataChannel&&this.publishDataChannel().then(()=>{this.syncPublishToRoomServer(l,i,d)}),r&&(this.trackTraceIdMap[M.Audio]=u,this.reportAudioProfile()),c&&(this.trackTraceIdMap[M.VideoSmall]=u),a&&(this.trackTraceIdMap[M.VideoLarge]=u,this.reportVideoProfile()),n&&(this.trackTraceIdMap[M.Screen]=u,this.reportScreenProfile()),yield this.syncPublishToRoomServer(l,i,d),r&&this.audioPubState.setState(Q.AliRtcStatePublished),a&&this.videoPubState.setState(Q.AliRtcStatePublished),c&&this.videoSmallPubState.setState(Q.AliRtcStatePublished),n&&this.screenPubState.setState(Q.AliRtcStatePublished)}catch(d){throw r&&this.audioPubState.setState(Q.AliRtcStateNoPublish),a&&this.videoPubState.setState(Q.AliRtcStateNoPublish),c&&this.videoSmallPubState.setState(Q.AliRtcStateNoPublish),n&&this.screenPubState.setState(Q.AliRtcStateNoPublish),d}}else x.event(`[${yt.logName}]`,"startPublish no stream founded")})}updateStreams(){return w(this,null,function*(){yield this.streamManager.updateStreams()})}publishUpdate(e){return w(this,null,function*(){var a,c,n,h,d,u;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 f=(a=this.streamTracks)==null?void 0:a.find(({ssrc:E,type:y,msid:R})=>y==="audio"&&E&&R===M.Audio),l=yield this.compareAndPublish(f,t.audio,M.Audio);l&&(i=l);const g=(c=this.streamTracks)==null?void 0:c.find(({ssrc:E,type:y,msid:R})=>y==="video"&&E&&R===M.VideoLarge),p=yield this.compareAndPublish(g,t.video,M.VideoLarge);p&&(i=p);const b=(n=this.streamTracks)==null?void 0:n.find(({ssrc:E,type:y,msid:R})=>y==="video"&&E&&R===M.VideoSmall),S=yield this.compareAndPublish(b,t.videoSmall,M.VideoSmall);S&&(i=S);const v=(h=this.streamTracks)==null?void 0:h.find(({ssrc:E,type:y,msid:R})=>y==="video"&&E&&R===M.Screen),_=yield this.compareAndPublish(v,t.screen,M.Screen);if(_&&(i=_),!i){if(!(e===ht.RECONNECT&&this.rtsManager.publishingTracks.length>0))return;{if((d=this.parameter.data)!=null&&d.enablePubDataChannel){const R=this.rtsManager.getDatachannelByMsid({url:this.url,msid:M.Data});this.updateDataChannel(R)}const E=this.rtsManager.publishingTracks.find(({type:R})=>R==="video"),y=this.rtsManager.publishingTracks.find(({type:R})=>R==="audio");(E||y)&&(yield this.rtsManager.waitPublishSender(this.url,!E,E?E.msid:y==null?void 0:y.msid)),i={type:Tt.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}}}(u=this.parameter.data)!=null&&u.enablePubDataChannel&&!this.dc&&(yield this.publishDataChannel()),yield this.syncPublishToRoomServer(i,t,r)}catch(f){const{code:l}=f!=null?f:{},g=this.url;throw l===403&&g&&(yield this.refreshPushStreamUrl(),i=yield this.publishUpdate()),f}return i})}syncPublishToRoomServer(e,t,i){return w(this,null,function*(){var n;if(!e)throw new O(U.ERR_INNER,"sync publish to room server failed because no publishInfo");let r=e;if(this.dc){const c=e,{tracks:h}=c,d=Jt(c,["tracks"]);r=Et(Y({},d),{tracks:[...h,{type:"data",msid:M.Data,ssrc:`${((n=this.callId)==null?void 0:n.length)>8?this.callId.substring(0,8):"web"}${this.dc.datachannel.id||"0"}`,codec:"text"}]})}const a=yield this.signalingManager.publish(r);e.signaltid=a.tid})}refreshPushStreamUrl(){return w(this,null,function*(){const e=new O(U.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 w(this,null,function*(){this.createCallId();const a=(t==null?void 0:t.aMsid)===M.Audio,c=(t==null?void 0:t.vMsid)===M.VideoLarge,n=(t==null?void 0:t.vMsid)===M.VideoSmall,h=(t==null?void 0:t.vMsid)===M.Screen;a&&this.audioPubState.setState(Q.AliRtcStatePublishing),c&&this.videoPubState.setState(Q.AliRtcStatePublishing),n&&this.videoSmallPubState.setState(Q.AliRtcStatePublishing),h&&this.screenPubState.setState(Q.AliRtcStatePublishing);try{const d=yield this.rtsManager.publishAdd(this.url,e,this.callId,t,!1,!0);a&&(this.audioPubState.setState(Q.AliRtcStatePublished),this.reportAudioProfile(),this.trackTraceIdMap[M.Audio]=d),c&&(this.videoPubState.setState(Q.AliRtcStatePublished),this.reportVideoProfile(),this.trackTraceIdMap[M.VideoLarge]=d),n&&(this.videoSmallPubState.setState(Q.AliRtcStatePublished),this.trackTraceIdMap[M.VideoSmall]=d),h&&(this.screenPubState.setState(Q.AliRtcStatePublished),this.reportScreenProfile(),this.trackTraceIdMap[M.Screen]=d),this.streamTracks=this.rtsManager.publishingTracks;const u={type:Tt.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:d};return this.reportSelfDeviceStatus(),this.monitorTimerId||this.startStreamMonitor(),u}catch(d){let u=U.ERR_SDK_PUBLISH_INVAILD;if(a&&(this.audioPubState.setState(Q.AliRtcStateNoPublish),u=U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED),c&&(this.videoPubState.setState(Q.AliRtcStateNoPublish),u=U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED),n&&(this.videoSmallPubState.setState(Q.AliRtcStateNoPublish),u=U.ERR_SDK_PUBLISH_DUAL_STREAM_FAILED),h&&(this.screenPubState.setState(Q.AliRtcStateNoPublish),u=U.ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED),d.errorCode===15006&&r<3)return this.publishAdd(e,t,i,r+1);throw O.fromError(d,u,"publish add failed")}})}publishReplace(e,t){return w(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 a={type:Tt.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(),a}catch(i){throw O.fromError(i,U.ERR_INNER,`publish replace failed, vMsid: ${t==null?void 0:t.vMsid} aMsid: ${t==null?void 0:t.aMsid}`)}})}publishDeleteTracks(e){return w(this,null,function*(){const t={type:Tt.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(Q.AliRtcStateNoPublish),e.video&&(e.vMsid===M.VideoSmall?this.videoSmallPubState.setState(Q.AliRtcStateNoPublish):this.videoPubState.setState(Q.AliRtcStateNoPublish)),e.screen&&this.screenPubState.setState(Q.AliRtcStateNoPublish),t.tracks=this.streamTracks,this.reportSelfDeviceStatus(),t}catch(i){throw O.fromError(i,U.ERR_INNER,"publish delete tracks failed")}})}publishStop(){return w(this,null,function*(){x.info(`[${yt.logName}]`,"publishStop",{url:this.url});const e=new Date().getTime();try{const t=this.hasAudioTrackInMS,i=this.hasCameraTrackInMS,r=this.hasCameraDualTrackInMS,a=this.hasScreenTrackInMS;yield this.rtsManager.publishStop(this.url),t&&this.audioPubState.setState(Q.AliRtcStateNoPublish),i&&this.videoPubState.setState(Q.AliRtcStateNoPublish),r&&this.videoSmallPubState.setState(Q.AliRtcStateNoPublish),a&&this.screenPubState.setState(Q.AliRtcStateNoPublish),this.traceId="",Object.keys(this.monitorDataCache).forEach(n=>{this.reportPublishMonitor(n)}),this.streamTracks=[];const c={type:Tt.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,U.ERR_INNER,"publish stop failed")}})}unPublish(){return w(this,null,function*(){const e=new Date().getTime();let t={type:Tt.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,a=this.hasCameraDualTrackInMS,c=this.hasScreenTrackInMS;yield this.rtsManager.unpublish(),this.streamTracks=[],this.stopStreamMonitor(),i&&this.audioPubState.setState(Q.AliRtcStateNoPublish),r&&this.videoPubState.setState(Q.AliRtcStateNoPublish),a&&this.videoSmallPubState.setState(Q.AliRtcStateNoPublish),c&&this.screenPubState.setState(Q.AliRtcStateNoPublish),this.traceId="",this.clearStream()}return this.dc&&(this.rtsManager.publishStopDataChannel(this.url,this.dc),this.dataPubState.setState(Q.AliRtcStateNoPublish),this.dc=void 0),this.slsReporter.reportUnpublish(this.callId||"",e,0,""),t}catch(i){throw O.fromError(i,U.ERR_INNER,"unpublish failed")}})}reportSelfDeviceStatus(){this.emit(Be.Local,this.getDeviceStatus())}getDeviceStatus(){var t,i,r,a;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&&!((a=(r=this.streamManager.screenStreamInfo)==null?void 0:r.originVideoTrack)!=null&&a.enabled),Na.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(()=>w(this,null,function*(){var e,i;try{const r=yield this.rtsManager.getPCStats();let a,c;if(r==null||r.forEach(h=>{h.type==="media-source"||h.type==="media-playout"?h.id&&(this.pcMediaStatsMap[h.id]=h):h.type==="candidate-pair"&&h.state==="succeeded"&&(a=h)}),((e=this.candidateDataCache)==null?void 0:e.length)>0){const h=this.candidateDataCache[this.candidateDataCache.length-1]||{},t=h,{_last:d}=t;c=Jt(t,["_last"])}((i=this.candidateDataCache)==null?void 0:i.length)>=30&&this.reportNetwork(),a&&(a._last=c,this.candidateDataCache.push(a));let n=Object.keys(this.monitorDataCache).filter(h=>{var d;return((d=this.monitorDataCache[h])==null?void 0:d.length)>0});(this.streamTracks||[]).forEach(h=>{const d=h.msid;if(!d)return;let u;n.includes(d)&&(n=n.filter(f=>f!==d)),u=d===M.Audio?this.rtsManager.getPublishAudioStats(this.url):this.rtsManager.getPublishVideoStats(this.url,d),u.then(f=>{if(!f.timestamp)return;this.monitorDataCache[d]||(this.monitorDataCache[d]=[]);const l=this.getMediaStats(f.mediaSourceId);f._source=l;const g=this.monitorDataCache[d];let p;if((g==null?void 0:g.length)>0){const S=g[g.length-1]||{},b=S,{_last:v}=b;p=Jt(b,["_last"])}(g==null?void 0:g.length)>=30&&this.reportPublishMonitor(d),f._last=p,f._codec=h.codec||"",this.monitorDataCache[d].push(f)})}),n.forEach(h=>{this.reportPublishMonitor(h)})}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(Q.AliRtcStatePublishIdle),this.videoPubState.setState(Q.AliRtcStatePublishIdle),this.videoSmallPubState.setState(Q.AliRtcStatePublishIdle),this.screenPubState.setState(Q.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 w(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(U.ERR_INNER,"data channel publish is not enabled");if(!this.dc)throw new O(U.ERR_INNER,"data channel is not ready");const t=function(r,a){let c=0;const n=[];for(;c<r.byteLength;){const h=Math.min(a,r.byteLength-c),d=r.slice(c,c+h);n.push(d),c+=h}return n}(e.toBuffer(),1156);t.forEach((r,a)=>{const c=new Di(new li(r.byteLength,a===t.length-1,a===0?1:0),r);this.dc.send(c.toGRTNBuffer())})}getStats(){return w(this,null,function*(){const e=[];if(this.hasAudioTrackInMS){const a=yield this.rtsManager.getPublishAudioStats(this.url);a&&e.push({stats:a,track:Yt.AliRtcAudioTrackMic})}const t=[];if(this.hasCameraTrackInMS){const a=yield this.rtsManager.getPublishVideoStats(this.url,M.VideoLarge);a&&t.push({track:ie.AliRtcVideoTrackCamera,streamType:De.AliRtcVideoStreamTypeHigh,stats:a})}if(this.hasCameraDualTrackInMS){const a=yield this.rtsManager.getPublishVideoStats(this.url,M.VideoSmall);a&&t.push({track:ie.AliRtcVideoTrackCamera,streamType:De.AliRtcVideoStreamTypeLow,stats:a})}if(this.hasScreenTrackInMS){const a=yield this.rtsManager.getPublishVideoStats(this.url,M.Screen);a&&t.push({track:ie.AliRtcVideoTrackScreen,stats:a})}let i;const r=yield this.rtsManager.getPCStats();return r==null||r.forEach(a=>{a.type==="candidate-pair"&&a.state==="succeeded"&&(i=a)}),{audio:e,video:t,candidate:i}})}},m(yt,"logName","LocalUser"),yt);Se([C()],fe.prototype,"clearPublishState",1),Se([C()],fe.prototype,"clear",1),Se([C(B)],fe.prototype,"startDefaultCamera",1),Se([C(B)],fe.prototype,"startDefaultAudio",1),Se([C()],fe.prototype,"setViewConfig",1),Se([C()],fe.prototype,"startCameraCapture",1),Se([C()],fe.prototype,"stopCameraCapture",1),Se([C()],fe.prototype,"startAudioCapture",1),Se([C()],fe.prototype,"stopAudioCapture",1),Se([C()],fe.prototype,"stopPreview",1),Se([C()],fe.prototype,"resumePublish",1),Se([C()],fe.prototype,"createLocalStream",1),Se([C()],fe.prototype,"stopLocalStream",1),Se([C(B)],fe.prototype,"startPublish",1),Se([C()],fe.prototype,"updateStreams",1),Se([C(B)],fe.prototype,"publishUpdate",1),Se([C(([s])=>[s])],fe.prototype,"syncPublishToRoomServer",1),Se([C()],fe.prototype,"refreshPushStreamUrl",1),Se([C(([s,o,e])=>[JSON.stringify(e)])],fe.prototype,"publishAdd",1),Se([C(([s,o])=>[JSON.stringify(o)])],fe.prototype,"publishReplace",1),Se([C(B)],fe.prototype,"publishDeleteTracks",1),Se([C()],fe.prototype,"publishStop",1),Se([C()],fe.prototype,"unPublish",1),Se([C(([s,o,e])=>[s.length,o,e])],fe.prototype,"sendSEI",1);let Ho=fe;var Pt=(s=>(s.OPUS="opus",s.H264="H264",s.UNKNOWN="",s))(Pt||{}),re=(s=>(s[s.NotSubscribe=0]="NotSubscribe",s[s.Subscribing=1]="Subscribing",s[s.Subscribed=2]="Subscribed",s))(re||{}),Ft=(s=>(s.VideoTrackEnded="videoTrackEnded",s.AudioTrackEnded="audioTrackEnded",s.ScreenTrackEnded="screenTrackEnded",s))(Ft||{});const ja=s=>w(this,null,function*(){return yield G.AliRTS.createStream({custom:!0,mediaStream:s})}),pi=s=>w(this,null,function*(){const o=(e=>{const t=new MediaStream;return t.addTrack(e),t})(s);return yield ja(o)});var Fo=Object.defineProperty,jo=Object.getOwnPropertyDescriptor;class Ni extends te{constructor(){super();m(this,"audioInfo",{subscribeState:re.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Pt.UNKNOWN});m(this,"videoLargeInfo",{subscribeState:re.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Pt.UNKNOWN});m(this,"videoSmallInfo",{subscribeState:re.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Pt.UNKNOWN});m(this,"screenInfo",{subscribeState:re.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Pt.UNKNOWN});m(this,"dataInfo",{subscribeState:re.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Pt.UNKNOWN});m(this,"audioVolume",1);m(this,"audioMuted",!1);m(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===re.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===re.Subscribed}get isAudioSubscribing(){return this.audioInfo.subscribeState===re.Subscribing}get isVideoSubscribed(){return this.isVideoLargeSubscribed||this.isVideoSmallSubscribed}get isVideoSubscribing(){return this.isVideoLargeSubscribing||this.isVideoSmallSubscribing}get isVideoLargeSubscribed(){return this.videoLargeInfo.subscribeState===re.Subscribed}get isVideoLargeSubscribing(){return this.videoLargeInfo.subscribeState===re.Subscribing}get isVideoSmallSubscribed(){return this.videoSmallInfo.subscribeState===re.Subscribed}get isVideoSmallSubscribing(){return this.videoSmallInfo.subscribeState===re.Subscribing}get isScreenSubscribed(){return this.screenInfo.subscribeState===re.Subscribed}get isScreenSubscribing(){return this.screenInfo.subscribeState===re.Subscribing}get isDataSubscribed(){return this.dataInfo.subscribeState===re.Subscribed}get isDataSubscribing(){return this.dataInfo.subscribeState===re.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:Pt.UNKNOWN}get audioTrackInfo(){return this.hasAudio?Yt.AliRtcAudioTrackMic:Yt.AliRtcAudioTrackNo}get videoTrackInfo(){return this.hasVideo&&this.hasScreen?ie.AliRtcVideoTrackBoth:this.hasVideo?ie.AliRtcVideoTrackCamera:this.hasScreen?ie.AliRtcVideoTrackScreen:ie.AliRtcVideoTrackNo}updateTracks(e){let t="",i="",r="",a="",c="";return e?(e.forEach(n=>{var f;let h=Pt.UNKNOWN;const d=((f=n==null?void 0:n.attr)==null?void 0:f.reason)==="reconnect";if(n.userdata){const{codec:l}=JSON.parse(n.userdata);l&&(h=l)}var u;(u=n.msid)===M.Audio||u===Zi.Audio?(t=n.ssrc,this.audioInfo.msid=n.msid,this.audioInfo.codec=h,(d||this.audioInfo.ssrc!==t)&&(this.audioInfo.subscribeState=re.NotSubscribe)):(l=>l===M.VideoSmall)(n.msid)?(r=n.ssrc,this.videoSmallInfo.msid=n.msid,this.videoSmallInfo.codec=h,(d||this.videoSmallInfo.ssrc!==r)&&(this.videoSmallInfo.subscribeState=re.NotSubscribe)):(l=>l===M.VideoLarge||l===Zi.VideoLarge)(n.msid)?(i=n.ssrc,this.videoLargeInfo.msid=n.msid,this.videoLargeInfo.codec=h,(d||this.videoLargeInfo.ssrc!==i)&&(this.videoLargeInfo.subscribeState=re.NotSubscribe)):(l=>l===M.Screen)(n.msid)?(a=n.ssrc,this.screenInfo.msid=n.msid,this.screenInfo.codec=h,(d||this.screenInfo.ssrc!==a)&&(this.screenInfo.subscribeState=re.NotSubscribe)):(l=>l===M.Data)(n.msid)&&(c=n.ssrc,this.dataInfo.msid=n.msid,this.dataInfo.codec=h,(d||this.dataInfo.ssrc!==c)&&(this.dataInfo.subscribeState=re.NotSubscribe))}),this.updateRemoteTrackSsrc(t,i,r,a,c)):this.updateRemoteTrackSsrc(t,i,r,a,c),{}}updateRemoteTrackSsrc(e,t,i,r,a){this.audioInfo.ssrc=e,this.videoSmallInfo.ssrc=i,this.videoLargeInfo.ssrc=t,this.screenInfo.ssrc=r,this.dataInfo.ssrc=a}markRemoteTrackSubscribing(e){return e.video&&(e.vMsid===this.videoSmallInfo.msid&&(this.videoSmallInfo.subscribeState=re.Subscribing),e.vMsid!==this.videoLargeInfo.msid&&e.vMsid||(this.videoLargeInfo.subscribeState=re.Subscribing)),e.screen&&(this.screenInfo.subscribeState=re.Subscribing),e.audio&&(this.audioInfo.subscribeState=re.Subscribing),e.data&&(this.dataInfo.subscribeState=re.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?re.Subscribed:re.NotSubscribe),e.vMsid!==this.videoLargeInfo.msid&&e.vMsid||(this.videoLargeInfo.subscribeState=e.video?re.Subscribed:re.NotSubscribe)),e.screen!==void 0&&(this.screenInfo.subscribeState=e.screen?re.Subscribed:re.NotSubscribe),e.audio!==void 0&&(this.audioInfo.subscribeState=e.audio?re.Subscribed:re.NotSubscribe),e.data!==void 0&&(this.dataInfo.subscribeState=e.data?re.Subscribed:re.NotSubscribe),{audioInfo:this.audioInfo,videoLargeInfo:this.videoLargeInfo,videoSmallInfo:this.videoSmallInfo,screenInfo:this.screenInfo,dataInfo:this.dataInfo}}updateRemoteUserDeviceStatus(e){let t=Na.parseStatus(e);const{audioDisable:i,videoDisable:r,screenDisable:a}=t;return this.userStatus?(this.userStatus.audioDisable!=i&&(this.userStatus.audioDisable=i,this.emit(Be.Remote,i?pe.MuteAudio:pe.UnmuteAudio)),this.userStatus.videoDisable!=r&&(this.userStatus.videoDisable=r,this.emit(Be.Remote,r?pe.MuteVideo:pe.UnmuteVideo)),this.userStatus.screenDisable!=a&&(this.userStatus.screenDisable=a,this.emit(Be.Remote,a?pe.MuteScreen:pe.UnmuteScreen))):(this.userStatus=t,this.emit(Be.Remote,i?pe.MuteAudio:pe.UnmuteAudio),this.emit(Be.Remote,r?pe.MuteVideo:pe.UnmuteVideo),this.emit(Be.Remote,a?pe.MuteScreen:pe.UnmuteScreen)),!1}}m(Ni,"logName","RemoteStreamInfo"),((s,o,e,t)=>{for(var i,r=t>1?void 0:t?jo(o,e):o,a=s.length-1;a>=0;a--)(i=s[a])&&(r=(t?i(o,e,r):i(r))||r);t&&r&&Fo(o,e,r)})([C()],Ni.prototype,"updateRemoteTrackSubState",1);class za{constructor(o){m(this,"remoteUser");this.remoteUser=o}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 zo=Object.defineProperty,Ko=Object.getOwnPropertyDescriptor,Oe=(s,o,e,t)=>{for(var i,r=t>1?void 0:t?Ko(o,e):o,a=s.length-1;a>=0;a--)(i=s[a])&&(r=(t?i(o,e,r):i(r))||r);return t&&r&&zo(o,e,r),r};class Qt extends te{constructor(){super();m(this,"state");m(this,"time");m(this,"_enabled");this.state=ce.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 Ne=(Fe=class extends Da{constructor(e){var l;const{userId:t,displayName:i,rtsManager:r,usersViewMap:a,slsReporter:c,signalingManager:n,localUser:h,audioVolumeIndicationInterval:d,playoutVolume:u,parameter:f}=e;super(t,i,r,d);m(this,"remoteCallid","");m(this,"remoteUserInfo");m(this,"localUser");m(this,"lastPubId","");m(this,"stream");m(this,"screenStream");m(this,"viewMap");m(this,"audioTrack");m(this,"audioElement");m(this,"subscribed",!1);m(this,"mediaStream");m(this,"secondaryMediaStream");m(this,"prevSubConfig");m(this,"signalingManager");m(this,"slsReporter");m(this,"wantSubAudio",!1);m(this,"wantSubVideo",!1);m(this,"wantSubScreen",!1);m(this,"defaultVideoStreamType",De.AliRtcVideoStreamTypeHigh);m(this,"audioMuted",!1);m(this,"playoutVolume",1);m(this,"playoutGainNode");m(this,"audioSubState");m(this,"videoSubState");m(this,"videoLargeSubState",new Qt);m(this,"videoSmallSubState",new Qt);m(this,"screenSubState");m(this,"dataSubState");m(this,"dc");m(this,"dcMsgWaitingPieces",[]);m(this,"streamInfo");m(this,"_streamUrl","");m(this,"parameter",{});m(this,"monitorTimerId");m(this,"monitorDataCache",{});m(this,"trackTraceIdMap",{});m(this,"handleAudioContextSuspended",e=>{e.target.state==="suspended"&&this.emit("remoteAudioPlayError",this.uid,"AudioContext suspended")});m(this,"onDataChannelMessage",e=>{var r;const t=Di.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 a=this.dcMsgWaitingPieces.reduce((c,n)=>c+n.byteLength,t.body.byteLength);try{const c=new ArrayBuffer(a);let n=0;for(let h=0;h<this.dcMsgWaitingPieces.length;h++){const d=this.dcMsgWaitingPieces[h];new Uint8Array(c,n,d.byteLength).set(new Uint8Array(d)),n+=d.byteLength}new Uint8Array(c,n,t.body.byteLength).set(new Uint8Array(t.body)),i=kt.parse(c)}catch(c){}this.dcMsgWaitingPieces=[],i||(i=kt.parse(t.body))}else i=kt.parse(t.body);i||x.event(`[${Fe.logName}]`,`parse data channel message fail, piece count: ${this.dcMsgWaitingPieces.length+1}`)}i&&(x.event(`[${Fe.logName}]`,`receive data channel message, length: ${(r=i.data)==null?void 0:r.byteLength}`),this.emit("remoteDataChannelMessage",this.uid,i))});m(this,"onDataChannelError",e=>{this.emit("occurError",O.fromError(e,U.ERR_SDK_SUBSCRIBE_DATA_ERROR))});m(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))});m(this,"handleAudioPaused",()=>{this.emit("remoteAudioPlayError",this.uid,"paused")});this.streamInfo=new Ni,this.remoteUserInfo=new za(this),this.parameter=f,this.streamInfo.on(Be.Remote,g=>{this.emit(Be.Remote,g,this.userId)}),this.signalingManager=n,this.viewMap=(l=a[t])!=null?l:{cameraViews:[],screenViews:[]},a[t]=this.viewMap,this.slsReporter=c,this.localUser=h,this.audioSubState=new Qt,this.audioSubState.on("change",(g,p,b)=>{this.emit("audioSubscribeStateChanged",this.uid,g,p,b)}),this.videoSubState=new Qt,this.videoSubState.on("change",(g,p,b)=>{this.emit("videoSubscribeStateChanged",this.uid,g,p,b)}),this.screenSubState=new Qt,this.screenSubState.on("change",(g,p,b)=>{this.emit("screenSubscribeStateChanged",this.uid,g,p,b)}),this.dataSubState=new Qt,this.dataSubState.on("change",(g,p,b)=>{this.emit("dataSubscribeStateChanged",this.uid,g,p,b)}),this.playoutVolume=u}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(de.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=Ht.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!==ie.AliRtcVideoTrackScreen&&t!==ie.AliRtcVideoTrackCamera)throw new O(U.ERR_INVALID_ARGUMENTS,"track is not AliRtcVideoTrackScreen or AliRtcVideoTrackCamera");e?_r(e).forEach(i=>{i.setAttribute("playsinline",""),G.AliRTS.BrowserUtil.isMicroMessenger&&(i.setAttribute("x5-video-player-type","h5-page"),i.setAttribute("x5-playsinline",""),G.AliRTS.SystenUtil.isAndroid||G.AliRTS.SystenUtil.isIos&&i.setAttribute("x-webkit-airplay","allow")),t===ie.AliRtcVideoTrackScreen?this.viewMap.screenViews.push(i):this.viewMap.cameraViews.push(i),this.play(i,t===ie.AliRtcVideoTrackScreen)}):(this.stopPlayAll(t===ie.AliRtcVideoTrackScreen),t===ie.AliRtcVideoTrackScreen?this.viewMap.screenViews=[]:this.viewMap.cameraViews=[])}clear(e=!0){return w(this,null,function*(){var t;this.subscribeStopDataChannel(),e&&this.doStopSubscribe(this.streamUrl),Br(Fe.prototype,this,"clear").call(this),this.stopPlayAudio(),this.clearStream(),this.clearScreenStream(),this.playoutGainNode&&(this.playoutGainNode.disconnect(),this.playoutGainNode=void 0,Ht.getInstance().removeEventListener("statechange",this.handleAudioContextSuspended)),(t=this.streamInfo)==null||t.removeAllListeners(Be.Remote)})}updateRemoteUserDeviceStatus(e){var t;(t=this.streamInfo)==null||t.updateRemoteUserDeviceStatus(e)}updateRemoteTracks(e,t,i,r){return w(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 Ni),(c=this.streamInfo)==null?void 0:c.updateTracks(r)})}subscribe(r,a){return w(this,arguments,function*(e,t,i=Date.now()){var l,g;let c=e;if(!c){const{hasAudio:p,hasVideo:b,hasScreen:S,hasData:v}=(l=this.streamInfo)!=null?l:{};c={audio:this.wantSubAudio&&p,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:n,audio:h,video:d,vMsid:u}=c,f=[];(d||h)&&f.push({audio:h,video:d,vMsid:u}),n&&f.push({screen:n}),(f.length!==0||e!=null&&e.data)&&(yield Promise.all(f.map(p=>this.subscribeProxy(p,t||de.User,i))),e!=null&&e.data&&this.subscribeDataChannel())})}subscribeProxy(e,t,i){return w(this,null,function*(){var c,n,h,d;let r=new Date().getTime(),a="";try{e.audio&&this.audioSubState.setState(ce.AliRtcStateSubscribing),e.video&&(this.videoSubState.currentState!==ce.AliRtcStateSubscribeIdle&&this.videoSubState.currentState!==ce.AliRtcStateNoSubscribe||this.videoSubState.setState(ce.AliRtcStateSubscribing)),e.screen&&this.screenSubState.setState(ce.AliRtcStateSubscribing);const u=yield this.rtsManager.subscribe({remoteUser:this,options:e},t,((c=this.localUser)==null?void 0:c.callId)||"",this.callId,i);this.streamInfo.updateRemoteTrackSubState(e),a=u.traceId||"";const{stream:f}=u;if(e.audio){this.trackTraceIdMap[M.Audio]=a;const g=f.audioTrack;g&&(this.audioTrack=g,(n=f.mediaStream)==null||n.removeTrack(g),this.playAudio(),this.audioVolumeIndicationInterval&&this.audioLevelMonitor.start(g,this.audioVolumeIndicationInterval)),this.audioSubState.getEnabled()||this.toggleAudio(!1),this.audioSubState.setState(ce.AliRtcStateSubscribed)}e.video&&(this.updateStream(f,this.isVideoLargeSubscribing&&this.isVideoSmallSubscribing),this.videoSubState.getEnabled()||this.toggleVideo(!1),this.videoSubState.setState(ce.AliRtcStateSubscribed),e.vMsid===M.VideoSmall?(this.trackTraceIdMap[M.VideoSmall]=a,this.videoSmallSubState.setState(ce.AliRtcStateSubscribed)):(this.trackTraceIdMap[M.VideoLarge]=a,this.videoLargeSubState.setState(ce.AliRtcStateSubscribed))),e.screen&&(this.trackTraceIdMap[M.Screen]=a,this.updateScreenStream(f),this.videoSubState.getEnabled()||this.toggleScreen(!1),this.screenSubState.setState(ce.AliRtcStateSubscribed));const l=new Date().getTime()-r;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,0,"",l,{pctid:this.rtsManager.pcTraceId,subtid:a,ajsub:t===de.Join?1:0,url:this.streamUrl,est:r}),this.startStreamMonitor()}catch(u){const f=new Date().getTime()-r;e.audio&&this.audioSubState.setState(ce.AliRtcStateNoSubscribe),e.video&&this.videoSubState.setState(ce.AliRtcStateNoSubscribe),e.screen&&this.screenSubState.setState(ce.AliRtcStateNoSubscribe),u&&(u.message=`user(${this.uid}) subscribe error, ${(u==null?void 0:u.message)||""}`);let l=U.ERR_INNER;e.audio&&(l=U.ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED),e.video&&(l=e.vMsid===M.VideoSmall?U.ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED:U.ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED),e.screen&&(l=U.ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED),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,l,"",f,{pctid:this.rtsManager.pcTraceId,subtid:"",ajsub:t===de.Join?1:0,url:this.streamUrl,est:r});const g=O.fromError(u,l);throw this.emit("remoteSubscribeError",g),g}})}subscribeDeleteTracks(e){return w(this,null,function*(){const{audio:t,video:i,screen:r,data:a,vMsid:c}=e,n=[];(t||i||a)&&n.push({audio:t,video:i,vMsid:c}),r&&n.push({screen:r}),n.length!==0&&(yield Promise.all(n.map(h=>this.subscribeDeleteProxy(h))),e.data&&this.subscribeStopDataChannel())})}subscribeDeleteProxy(e){return w(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(ce.AliRtcStateNoSubscribe)),e.video===!0&&(r.video=!1,e.vMsid===M.VideoSmall?(this.videoSmallSubState.setState(ce.AliRtcStateNoSubscribe),this.videoLargeSubState.currentState!==ce.AliRtcStateNoSubscribe&&this.videoLargeSubState.currentState!==ce.AliRtcStateSubscribeIdle||this.videoSubState.setState(ce.AliRtcStateNoSubscribe)):(this.videoLargeSubState.setState(ce.AliRtcStateNoSubscribe),this.videoSmallSubState.currentState!==ce.AliRtcStateNoSubscribe&&this.videoSmallSubState.currentState!==ce.AliRtcStateSubscribeIdle||this.videoSubState.setState(ce.AliRtcStateNoSubscribe))),e.screen===!0&&(r.screen=!1,this.screenSubState.setState(ce.AliRtcStateNoSubscribe));const{callId:a,remoteCallid:c}=this,n={callid:a,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}),n}catch(t){throw O.fromError(t,U.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 w(this,null,function*(){const e=Ht.getInstance();return e.state!=="running"&&e.resume(),this.audioElement?this.audioElement.play():this.playAudio()})}resumeVideo(e){return w(this,null,function*(){return e&&e!==ie.AliRtcVideoTrackCamera&&e!==ie.AliRtcVideoTrackBoth?e&&e!==ie.AliRtcVideoTrackScreen&&e!==ie.AliRtcVideoTrackBoth?void 0:this.playAll(!0):this.playAll()})}resumePlay(){this.playAudio(),this.playAll(),this.playAll(!0)}stopSubscribe(e){return w(this,null,function*(){var i,r;let t=new Date().getTime();try{let a;a=e?yield this.subscribeDeleteTracks(e):yield this.doStopSubscribe(this.streamUrl),this.slsReporter.reportUnsubscribe(((i=this.localUser)==null?void 0:i.callId)||(a==null?void 0:a.callid)||"",this.callId,new Date().getTime()-t,0,"")}catch(a){throw this.slsReporter.reportUnsubscribe(((r=this.localUser)==null?void 0:r.callId)||"",this.callId,new Date().getTime()-t,0,""),a}})}doStopSubscribe(e){return w(this,null,function*(){var r,a,c,n;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 h={callid:t,remoteCallid:i,remoteStream:this.stream};return this.callId="",h}catch(h){if(((n=(c=(a=(r=h==null?void 0:h.extraInfo)==null?void 0:r.parsedData)==null?void 0:a.streams)==null?void 0:c[0])==null?void 0:n.res_code)!==404)throw O.fromError(h,U.ERR_INNER,"subscribe stop failed")}})}updateStream(e,t=!1){return w(this,null,function*(){this.stream&&this.stream.videoTrack&&e.mediaStream&&t&&(yield new Promise(i=>{let r,a;if(e.mediaStream){a=document.createElement("video");const c=()=>{x.event(`uid: ${this.userId} new mediaStream canplay`),a&&a.removeEventListener("canplaythrough",c,!1),a=void 0,clearTimeout(r),i(!0)};a.addEventListener("canplaythrough",c,!1),(a._playPromise||Promise.resolve()).then(()=>{a&&e.mediaStream&&(a.srcObject=e.mediaStream)})}else i(!0);r=window.setTimeout(()=>{x.event(`uid: ${this.userId} new mediaStream timeout`),a=void 0,i(!0)},3e3)}),this.updateSubscribe(de.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(ce.AliRtcStateSubscribing),this.rtsManager.subscribeAddDataChannel(this.streamUrl).then(e=>{if(e)return this.dataChannelConnected(e),this.dataSubState.setState(ce.AliRtcStateSubscribed),void this.streamInfo.updateRemoteTrackSubState({data:!0});throw new Error("no dc founded")}).catch(e=>{const t=O.fromError(e,U.ERR_INNER,"subscribe data failed");this.emit("remoteSubscribeError",t),this.dataSubState.setState(ce.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(ce.AliRtcStateNoSubscribe),this.dc=void 0,this.streamInfo.updateRemoteTrackSubState({data:!1})}}getRetryOptions(){var i,r,a,c,n,h,d;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&&((a=this.streamInfo)!=null&&a.hasVideo)&&(this.defaultVideoStreamType===De.AliRtcVideoStreamTypeLow&&((c=this.streamInfo)!=null&&c.hasVideoSmall)?(e.video=!0,e.vMsid=M.VideoSmall):(n=this.streamInfo)!=null&&n.hasVideoLarge&&(e.video=!0,e.vMsid=((h=this.streamInfo.getVideoLargeInfo())==null?void 0:h.msid)||M.VideoLarge)),this.wantSubScreen&&((d=this.streamInfo)!=null&&d.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 a,c,n,h,d,u,f,l,g,p,b,S,v,_,E,y,R;const t=Date.now(),i={},r={};if(this.wantSubAudio&&!this.isAudioSubscribing&&((a=this.streamInfo)!=null&&a.hasAudio)?(i.audio=!0,i.aMsid=((c=this.streamInfo.getAudioInfo())==null?void 0:c.msid)||M.Audio):this.wantSubAudio&&((n=this.streamInfo)!=null&&n.hasAudio)||!this.isAudioSubscribing||(r.audio=!0,r.aMsid=((h=this.streamInfo.getAudioInfo())==null?void 0:h.msid)||M.Audio),this.wantSubVideo&&((d=this.streamInfo)!=null&&d.hasVideo)?(this.defaultVideoStreamType===De.AliRtcVideoStreamTypeLow&&!this.isVideoSmallSubscribing&&((u=this.streamInfo)!=null&&u.hasVideoSmall)?(i.video=!0,i.vMsid=M.VideoSmall):this.isVideoLargeSubscribing||!((f=this.streamInfo)!=null&&f.hasVideoLarge)||this.defaultVideoStreamType===De.AliRtcVideoStreamTypeLow&&this.isVideoSmallSubscribing||(i.video=!0,i.vMsid=((l=this.streamInfo.getVideoLargeInfo())==null?void 0:l.msid)||M.VideoLarge),this.defaultVideoStreamType===De.AliRtcVideoStreamTypeLow&&this.isVideoLargeSubscribing&&this.isVideoSmallSubscribing&&this.streamInfo.hasVideoSmall?(r.video=!0,r.vMsid=M.VideoLarge):this.defaultVideoStreamType===De.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:((p=this.streamInfo.getVideoLargeInfo())==null?void 0:p.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:(E=this.parameter.data)!=null&&E.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===de.Reconnect){if(x.event(`[${Fe.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(){x.event(`[${Fe.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 a;const r=(a=t===ie.AliRtcVideoTrackScreen?this.screenStream:this.stream)==null?void 0:a.mediaStream;e.srcObject===r&&this.play(e,t===ie.AliRtcVideoTrackScreen),document.removeEventListener("click",i,!1),document.removeEventListener("touchstart",i,!1)};document.addEventListener("click",i,!1),document.addEventListener("touchstart",i,!1)}playAudio(){return w(this,null,function*(){var e,t;if(this.audioTrack){if(this.toggleAudio(!this.audioMuted),this.audioElement||(x.event(`[${Fe.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(G.AliRTS.SystenUtil.isIos&&parseInt(G.AliRTS.SystenUtil.systemVersion)<=13){x.event(`[${Fe.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;x.event(`[${Fe.logName}]`,"try play audio"),(i=this.audioElement)==null||i.play().then(()=>{x.event(`[${Fe.logName}]`,"play audio success")}).catch(()=>{this.handleAutoPlayFailed()})})()}else x.event(`[${Fe.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&&Ha(e,r.mediaStream,i).catch(a=>{a.code!==20&&a.name!=="AbortError"&&this.handleVideoPlayFailded(e,t?ie.AliRtcVideoTrackScreen:ie.AliRtcVideoTrackCamera)})}stopPlayAll(e=!1){e?this.viewMap.screenViews.forEach(t=>{ut(t)}):this.viewMap.cameraViews.forEach(t=>{ut(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 w(this,null,function*(){var i,r,a,c,n;const e=[];if(this.isAudioSubscribing){const h=yield this.rtsManager.getSubscribeAudioStats(this.streamUrl);h&&e.push({uid:this.uid,track:Yt.AliRtcAudioTrackMic,stats:h})}const t=[];if((i=this.streamInfo)!=null&&i.isVideoLargeSubscribed){const h=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((r=this.streamInfo.getVideoLargeInfo())==null?void 0:r.msid)||M.VideoLarge);h&&t.push({uid:this.uid,track:ie.AliRtcVideoTrackCamera,streamType:De.AliRtcVideoStreamTypeHigh,stats:h})}if((a=this.streamInfo)!=null&&a.isVideoSmallSubscribed){const h=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((c=this.streamInfo.getVideoSmallInfo())==null?void 0:c.msid)||M.VideoSmall);h&&t.push({uid:this.uid,track:ie.AliRtcVideoTrackCamera,streamType:De.AliRtcVideoStreamTypeLow,stats:h})}if(this.isScreenSubscribing){const h=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((n=this.streamInfo.getScreenInfo())==null?void 0:n.msid)||M.Screen);h&&t.push({uid:this.uid,track:ie.AliRtcVideoTrackScreen,stats:h})}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(()=>w(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 a=i===M.Audio;r=a?this.rtsManager.getSubscribeAudioStats(this.streamUrl):this.rtsManager.getSubscribeVideoStats(this.streamUrl,i),r.then(c=>{var u;if(!c.timestamp)return;this.monitorDataCache[i]||(this.monitorDataCache[i]=[]);const n=this.monitorDataCache[i];let h;if((n==null?void 0:n.length)>0){const f=n[n.length-1]||{},d=f,{_last:l}=d;h=Jt(d,["_last"])}(n==null?void 0:n.length)>=30&&this.reportSubscribeMonitor(i),c._last=h,c._codec=t.codec,a&&(c._source=(u=this.localUser)==null?void 0:u.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)})}},m(Fe,"logName","RemoteUser"),Fe);Oe([C()],Ne.prototype,"clear",1),Oe([C()],Ne.prototype,"updateRemoteUserDeviceStatus",1),Oe([C()],Ne.prototype,"updateRemoteTracks",1),Oe([C(B)],Ne.prototype,"subscribe",1),Oe([C()],Ne.prototype,"subscribeProxy",1),Oe([C(B)],Ne.prototype,"subscribeDeleteProxy",1),Oe([C()],Ne.prototype,"restore",1),Oe([C(B)],Ne.prototype,"resumeAudio",1),Oe([C(B)],Ne.prototype,"stopSubscribe",1),Oe([C(B)],Ne.prototype,"doStopSubscribe",1),Oe([C()],Ne.prototype,"clearStream",1),Oe([C()],Ne.prototype,"clearScreenStream",1),Oe([C()],Ne.prototype,"updateSubscribe",1),Oe([C()],Ne.prototype,"playAudio",1),Oe([C()],Ne.prototype,"stopPlayAudio",1),Oe([C((s,o,e)=>[typeof s=="string"?s:s==null?void 0:s.nodeType,o,e])],Ne.prototype,"play",1),Oe([C()],Ne.prototype,"stopPlayAll",1);let Wo=Ne;var Mt=(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))(Mt||{});class $o extends te{constructor(){super(...arguments);m(this,"plugins",new Map)}add(e,t){if(this.plugins.has(e.name))throw new O(Mt.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(Mt.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 Jo=Object.defineProperty,Go=Object.getOwnPropertyDescriptor,Ie=(s,o,e,t)=>{for(var i,r=t>1?void 0:t?Go(o,e):o,a=s.length-1;a>=0;a--)(i=s[a])&&(r=(t?i(o,e,r):i(r))||r);return t&&r&&Jo(o,e,r),r};const Vi=([s])=>{const{remoteUser:o,options:e}=s;return[`user(${o.userId})`,e]},ye=(Pe=class extends te{constructor(e,t,i){super();m(this,"rts");m(this,"encodedInsertableStreams",!0);m(this,"audioRedEnabled",!1);m(this,"localStreamManager");m(this,"slsReporter");m(this,"_rtsPeerConnectionType","publish");m(this,"connecting",!1);m(this,"connected",!1);m(this,"_pcTraceId","");m(this,"_localJoinTime",0);m(this,"connectionResolve");m(this,"connectingPromise");m(this,"dcResolve");m(this,"dcReject");m(this,"dcConnectingPromise");m(this,"_publishingTracks",[]);m(this,"parameter",{});m(this,"preferredPubL1Ip");this.localStreamManager=e,this.slsReporter=t,this.parameter=i,this.rts=G.AliRTS.createClient({singlePcConfig:{usePcReconnect:!0}}),this.addRTSListener()}addRTSListener(){this.rts.on("connectStatusChange",e=>{var t,i,r,a;if(x.event(`[${Pe.logName}]`,"rts connectStatusChange to:",e.status),e.status===G.EConnectStatus.CONNECT_STATUS_DISCONNECTED)this.dcReject&&this.dcReject(),this.setConnected(!1),this.slsReporter.reportWarning("rts disconnected"),this.emit("disconnected");else if(e.status===G.EConnectStatus.CONNECT_STATUS_CONNECTED){const c=(a=(r=(i=(t=this.rts.commonController)==null?void 0:t.peerCore)==null?void 0:i.getSignal())==null?void 0:r.getDatachannelCore())==null?void 0:a.readyState;x.event(`[${Pe.logName}]`,"dcReadyState:",c),c==="open"&&this.dcResolve&&this.dcResolve(!0),this.setConnected(!0)}}),this.rts.on("reconnectFinish",()=>{x.event(`[${Pe.logName}]`,"rts reconnectFinish");try{this.emit("connected",!0,this._rtsPeerConnectionType)}catch(e){x.error(`[${Pe.logName}]`,"emit connected error:",e)}}),this.rts.on("datachannelStatusChange",e=>{x.event(`[${Pe.logName}]`,"rts datachannelStatusChange to:",e.status),e.status===G.EDatachannelStatus.DATACHANNEL_STATUS_OPEN?this.dcResolve&&this.dcResolve(!0):e.status===G.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=>{x.event(`[${Pe.logName}]`,"rts onError event:",e)}),this.rts.on("reconnect",e=>{x.event(`[${Pe.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"),a=i.findIndex(c=>c.mimeType==="audio/opus");if(r>-1&&a>-1&&r>a){const c=i[a];i[a]=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=G.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:{},a={};return e.hasAudio&&(a.aMsid=[i!=null?i:M.Audio]),e.hasScreen&&(a.vMsid=[M.Screen]),e.hasVideo&&(a.vMsid=[r!=null?r:t!=null&&t.isScreen?M.Screen:M.VideoLarge]),a}updatePublishingTracks(e){e&&(this._publishingTracks=e.map(({msid:t,from:i,ssrc:r,codec:a,type:c,trackId:n})=>({msid:t,from:i,type:c,ssrc:`${r}`,codec:a!=null?a:"",trackId:n})))}httpPublish(a,c){return w(this,arguments,function*(e,t,i=!1,r=ht.MANUAL){var _,E;let n;const h=Date.now(),{publishStream:d,videoSmallStream:u,screenStream:f,vMsid:l}=yield this.localStreamManager.createHTTPPublishStream();if(!d)return x.warn(`[${Pe.logName}]`,"publishStream is null"),{traceId:"",l1ip:n};const g=this.getPubMsid(d,{vMsid:l});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]&&(n=R[0]),y},(E=(_=this.parameter)==null?void 0:_.net)!=null&&E.useTCP&&(g.tcpOnly=!0),g.retryTimes=17,g.retryInterval=5e3,this._rtsPeerConnectionType="publish";let p=!d.hasVideo,b=l,S="";this.startConnect();const v=Date.now();try{S=yield this.rts.publish(Er(e,this.preferredPubL1Ip),d,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,d.hasVideo&&(!l||l===M.VideoLarge),d.hasVideo&&l===M.VideoSmall,d.hasVideo&&l===M.Screen,d.hasAudio,(y==null?void 0:y.errorCode)||-1,this.pcTraceId,"",v),O.fromRtsError(y)}x.event(`[${Pe.logName}]`,"rts publish success",S),this.slsReporter.reportPublish(i,e,t,d.hasVideo&&(!l||l===M.VideoLarge),d.hasVideo&&l===M.VideoSmall,d.hasVideo&&l===M.Screen,d.hasAudio,0,S,S,v),this.slsReporter.reportConnectionLatencyEvent(Ge.HANDLE_PUB_TASK,et.START,t,S,h),this.slsReporter.reportConnectionLatencyEvent(Ge.HANDLE_PUB_TASK,et.END,t,S,Date.now());try{const y=Date.now();return this._pcTraceId=S,this.setConnected(!0),this._publishingTracks=this.rts.getPublishTrackInfoList(),u&&(yield this.publishAdd(e,u,t,{vMsid:M.VideoSmall},i),p=!1,b=M.VideoSmall),f&&(yield this.publishAdd(e,f,t,{vMsid:M.Screen},i),p=!1,b=M.Screen),yield this.waitPublishSender(e,p,b),this.slsReporter.reportPublishFirstPacket(i,t,v,y,this._localJoinTime,p?M.Audio:g.vMsid,S||"",S||"",r),{traceId:S,l1ip:n}}catch(y){throw this.setConnected(!1),O.fromError(y)}})}waitPublishSender(e,t=!1,i){return w(this,null,function*(){return Promise.race([Ct(1e3),((r,a)=>{let c=0;const n=()=>(t?this.rts.getPublishAudioStats(e,i):this.rts.getPublishVideoStats(e,i)).then(h=>!(h.bytesSent>0)&&c<r?(c++,new Promise(d=>setTimeout(()=>d(n()),a))):Promise.resolve());return n()})(5,100)]).catch(()=>{})})}getPublishVideoStats(e,t){return w(this,null,function*(){return yield this.rts.getPublishVideoStats(e,t)})}getPublishAudioStats(e,t){return w(this,null,function*(){return yield this.rts.getPublishAudioStats(e,t)})}publishAdd(h,d,u,f){return w(this,arguments,function*(e,t,i,r,a=!1,c=!1,n=ht.MANUAL){var p,b,S,v,_,E,y,R;yield this.dcConnectingPromise;const l=Date.now(),g=this.getPubMsid(t,r);try{const A=yield Ba(T=>w(this,null,function*(){return T>0&&x.event(`[${Pe.logName}]`,`publishAdd retry times: ${T}`),this.isConnected?(yield this.dcConnectingPromise,this.rts.publishAdd([Y({url:e,stream:t,updateSourceStream:!1},g)])):Promise.reject(new O(U.ERR_INNER,"rts not connected"))}),5,0,T=>(T==null?void 0:T.errorCode)===15006);if(A){const T=Date.now(),[I]=A;return this.slsReporter.reportPublish(!1,e,i,((p=g.vMsid)==null?void 0:p[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||"",l),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(a,i,l,T,this._localJoinTime,(t.hasVideo?r==null?void 0:r.vMsid:r==null?void 0:r.aMsid)||"",this.pcTraceId,I.traceId||"",n),I.traceId||""}}catch(A){throw this.slsReporter.reportPublish(!1,e,i,((_=g.vMsid)==null?void 0:_[0])===M.VideoLarge,((E=g.vMsid)==null?void 0:E[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,"",l),A!=null&&A.errorCode?O.fromRtsError(A):O.fromError(A)}return""})}publishDelete(e,t){return w(this,null,function*(){var h,d,u,f,l,g,p,b;yield this.dcConnectingPromise;const i=(d=(h=this.publishingTracks)==null?void 0:h.find(({msid:S})=>S===M.Audio))==null?void 0:d.msid,r=(f=(u=this.publishingTracks)==null?void 0:u.find(({msid:S})=>S===M.VideoLarge))==null?void 0:f.msid,a=(g=(l=this.publishingTracks)==null?void 0:l.find(({msid:S})=>S===M.Screen))==null?void 0:g.msid,c=[];t.screen&&a?c.push(a):t.video&&c.push(t.vMsid||r);const n=[];t.audio&&i&&n.push(i),x.event(Pe.logName,"publishDelete",{streamUrl:e,aMsid:n,vMsid:c});try{const[S]=(yield this.rts.publishDeleteTracks([{url:e,aMsid:n,vMsid:c}]))||[];return x.event(Pe.logName,"publishDelete",{result:S}),S&&this.updatePublishingTracks(S.trackInfoList),((b=(p=S==null?void 0:S.trackInfoList)==null?void 0:p[0])==null?void 0:b.trackId)||""}catch(S){throw O.fromRtsError(S)}})}publishReplace(e,t,i){return w(this,null,function*(){var c,n;yield this.dcConnectingPromise;const{vMsid:r,aMsid:a}=i!=null?i:{};try{const h=yield this.rts.publishReplaceTracks([{url:e,stream:t,vMsid:r,aMsid:a}]),[d]=h;return this.updatePublishingTracks(d.trackInfoList),((n=(c=d==null?void 0:d.trackInfoList)==null?void 0:c[0])==null?void 0:n.trackId)||""}catch(h){throw O.fromRtsError(h)}})}publishStop(e){return w(this,null,function*(){return yield this.rts.publishStop([{url:e}]),this._publishingTracks=[],""})}publishAddDataChannel(e){return w(this,null,function*(){yield this.dcConnectingPromise;const t=yield this.rts.publishAddDatachannel({signalUrl:e,url:Er(e,this.preferredPubL1Ip),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 w(this,null,function*(){return yield this.rts.publishStopDatachannel({url:e,datachannel:t})})}unpublish(){return w(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 w(this,null,function*(){var c,n,h,d,u,f;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 a=this.getSubConfig(t.streamInfo,i);if(this.encodedInsertableStreams&&(a.encodedInsertableStreams=!0),(n=(c=this.parameter)==null?void 0:c.net)!=null&&n.useTCP&&(a.tcpOnly=!0),(d=(h=this.parameter)==null?void 0:h.net)==null?void 0:d.mediaTimeout){const l=(f=(u=this.parameter)==null?void 0:u.net)==null?void 0:f.mediaTimeout;l>1e3&&l<1e5&&(a.mediaTimeout=l)}a.retryTimes=17,a.retryInterval=5e3,this._rtsPeerConnectionType="subscribe";try{this.startConnect();const l=yield this.rts.subscribe(Er(r),a);return this._pcTraceId=l.traceId,this.setConnected(!0),{traceId:l.traceId,stream:l}}catch(l){throw this.setConnected(!1),this.emit("disconnected"),O.fromRtsError(l)}})}subscribeAdd(e){return w(this,null,function*(){var a,c,n,h;const{remoteUser:t,options:i}=e,r=Et(Y({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 Ba(d=>w(this,null,function*(){return yield this.dcConnectingPromise,d>0&&x.event(`[${Pe.logName}]`,`subscribeAdd retry times: ${d}`),this.isConnected?this.rts.subscribeAdd([r]):Promise.reject()}),5,0,d=>(d==null?void 0:d.errorCode)===15006))[0]}catch(d){if(((h=(n=(c=(a=d==null?void 0:d.extraInfo)==null?void 0:a.parsedData)==null?void 0:c.streams)==null?void 0:n[0])==null?void 0:h.res_code)===508)return this.emit("subscribeexceeds"),null;throw O.fromRtsError(d)}})}subscribeDelete(e){return w(this,null,function*(){var a,c,n,h;const{remoteUser:t,options:i}=e,r=Et(Y({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(d){if(((h=(n=(c=(a=d==null?void 0:d.extraInfo)==null?void 0:a.parsedData)==null?void 0:c.streams)==null?void 0:n[0])==null?void 0:h.res_code)===404)return;throw O.fromRtsError(d)}})}subscibeStop(e){return w(this,null,function*(){var t,i,r,a;try{yield this.rts.subscribeStop([{url:e}])}catch(c){if(((a=(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:a.res_code)===404)return;throw O.fromRtsError(c)}})}subscribeAddDataChannel(e){return w(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 w(this,null,function*(){let i;try{i=yield this.rts.subscribeStopDatachannel({url:e,datachannel:t})}catch(r){}return t==null||t.dispose(),i})}publish(a,c){return w(this,arguments,function*(e,t,i=!1,r=ht.MANUAL){let n,h="";if(this.connecting&&(yield this.connectingPromise),this.connected){yield this.dcConnectingPromise;let d,u=!1;const{audio:f,video:l,videoSmall:g,screen:p}=this.localStreamManager.publishStreams;f&&(h=yield this.publishAdd(e,f,t,{aMsid:M.Audio},i),u=!0,d=M.Audio,yield Ct(100)),l&&(h=yield this.publishAdd(e,l,t,{vMsid:M.VideoLarge},i),u=!1,d=M.VideoLarge,yield Ct(100)),g&&(h=yield this.publishAdd(e,g,t,{vMsid:M.VideoSmall},i),u=!1,d=M.VideoSmall,yield Ct(100)),p&&(h=yield this.publishAdd(e,p,t,{isScreen:!0,vMsid:M.Screen},i),u=!1,d=M.Screen),d&&(yield this.waitPublishSender(e,u,d))}else{const d=yield this.httpPublish(e,t,i,r);h=d.traceId,n=d.l1ip}return{traceId:h,l1ip:n}})}reportSubscribeLatency(e,t,i,r){const a=[];e.audio&&a.push(e.aMsid||M.Audio),e.video?a.push(e.vMsid||M.VideoLarge):e.screen&&a.push(M.Screen),a.forEach(c=>{this.slsReporter.reportConnectionLatencyEvent(Ge.HANDLE_SUB_TASK,et.START,t,c,i,0,r),this.slsReporter.reportConnectionLatencyEvent(Ge.HANDLE_SUB_TASK,et.END,t,c,Date.now(),0,r)})}subscribe(e,t,i,r,a){return w(this,null,function*(){let c=!1;const{options:n,remoteUser:h}=e;if(n.video&&n.screen)throw new O(U.ERR_INNER,"subscribe error, video and screen cannot be subscribed at the same time");let d;this.connecting&&(yield this.connectingPromise);let u=Date.now();this.connected?d=yield this.subscribeAdd(e):(c=!0,d=yield this.httpSubscribe(e)),this.reportSubscribeLatency(n,i,u,c);const f=Date.now();let l=M.VideoLarge,g=n.video||n.screen,p=n.audio;n.video&&n.vMsid?l=n.vMsid:n.screen&&(l=M.Screen);let b=0,S=0,v=0;const _=((E,y)=>{let R=0;const A=()=>{let T;return p&&!b&&(T=this.rts.getSubscribeAudioStats(h.streamUrl).then(I=>{if(I.packetsReceived>0)b=Date.now();else if(!g)return R<E&&(R++,new Promise(k=>setTimeout(()=>k(A()),y)));return!0})),g&&!v&&(T=this.rts.getSubscribeVideoStats(h.streamUrl,l).then(I=>(I.packetsReceived>0&&(S=Date.now()),I.framesDecoded>0?(v=Date.now(),!0):R<E?(R++,new Promise(k=>setTimeout(()=>k(A()),y))):(x.event(`[${Pe.logName}]`,h.userId,"尝试获取首帧数据失败"),!1)))),Promise.resolve(T)};return A()})(40,100);return _.then(()=>{S&&this.slsReporter.reportSubscribeFirstPacket(t===de.Resume,i,r,l,{fprt:S-u,ifsprtc:v?v-u:0,ajsub:t===de.Join?1:0,pctid:this.pcTraceId,subtid:(d==null?void 0:d.traceId)||"",sstc:f-u}),v&&this.slsReporter.reportSubscribeFirstFrame(t===de.Resume,i,r,l,{fvfrt:v-u,fp2fftc:v-S,ajsub:t===de.Join?1:0,tffrtc:t===de.Join?v-this.localJoinTime:v-a,pctid:this.pcTraceId,subtid:(d==null?void 0:d.traceId)||"",fvfdtc:v-u}),b&&(this.slsReporter.reportConnectionLatencyEvent(Ge.FIRST_REMOTE,et.DECODED,i,M.Audio,b),this.slsReporter.reportSubscribeFirstPacket(t===de.Resume,i,r,M.Audio,{fprt:b-u,ifsprtc:b-u,ajsub:t===de.Join?1:0,pctid:this.pcTraceId,subtid:(d==null?void 0:d.traceId)||"",sstc:f-u}))}),c&&(yield Promise.race([_,Ct(1500)])),d})}getSubscribeVideoStats(e,t){return w(this,null,function*(){return yield this.rts.getSubscribeVideoStats(e,t)})}getSubscribeAudioStats(e,t){return w(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 w(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 w(this,null,function*(){return this.rts.sendSEI({url:e,vMsid:M.VideoLarge,data:t,repeatCount:i,payloadType:r})})}},m(Pe,"logName","RtsManager"),Pe);Ie([C(B)],ye.prototype,"startConnect",1),Ie([C()],ye.prototype,"updatePublishingTracks",1),Ie([C(B,B)],ye.prototype,"httpPublish",1),Ie([C(B,B)],ye.prototype,"waitPublishSender",1),Ie([C(([s,o,e])=>[s,JSON.stringify(e)],B)],ye.prototype,"publishAdd",1),Ie([C(B,B)],ye.prototype,"publishDelete",1),Ie([C(([s,o,e])=>[s,JSON.stringify(e)])],ye.prototype,"publishReplace",1),Ie([C(B)],ye.prototype,"publishStop",1),Ie([C(B)],ye.prototype,"publishAddDataChannel",1),Ie([C(B)],ye.prototype,"publishStopDataChannel",1),Ie([C()],ye.prototype,"unpublish",1),Ie([C(Vi,({traceId:s})=>s)],ye.prototype,"httpSubscribe",1),Ie([C(Vi,({traceId:s})=>s)],ye.prototype,"subscribeAdd",1),Ie([C(Vi)],ye.prototype,"subscribeDelete",1),Ie([C(B)],ye.prototype,"subscibeStop",1),Ie([C(B)],ye.prototype,"subscribeAddDataChannel",1),Ie([C(B)],ye.prototype,"subscribeStopDatachannel",1),Ie([C(B)],ye.prototype,"publish",1),Ie([C(Vi)],ye.prototype,"subscribe",1),Ie([C()],ye.prototype,"sendSEI",1);let qo=ye;class wr{constructor(o=Ar){m(this,"defaultProfile");m(this,"profile");m(this,"profileMap",new Map);m(this,"audioProfile");m(this,"contentHint");this.defaultProfile=Y({},o)}updateProfile(o,e){this.profileMap.set(o,Y(Y(Y({},this.defaultProfile),this.profileMap.get(o)||{}),e||{})),this.profile=o}get videoProfile(){return this.profile}updateAudioProfile(o){this.audioProfile=o}setContentHint(o,e){e&&(this.contentHint=e),this.contentHint&&o&&(o.contentHint=this.contentHint)}setVideoProfile(o,e,t=!1){return w(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&&o&&o.readyState==="live"&&o.applyConstraints)try{yield o.applyConstraints(i)}catch(r){}if(e){const r=Y({},i);i.maxSendFrameRate&&(r.frameRate=i.maxSendFrameRate),e==null||e.VideoProfileMap.set(this.profile,r),yield e.setVideoProfile(this.profile)}}})}}class Cr extends te{constructor(e){super();m(this,"type");m(this,"originVideoTrack");m(this,"videoSource");m(this,"_videoMuted",!1);m(this,"originAudioTrack");m(this,"audioSource");m(this,"_audioMuted",!1);m(this,"_targetVideoTrack");m(this,"_targetDualVideoTrack");m(this,"_targetAudioTrack");m(this,"_publishVideoStream");m(this,"_publishDualVideoStream");m(this,"_publishAudioStream");m(this,"_previewStream");m(this,"plugins",[]);m(this,"_profileManager");m(this,"cameraVideoConstraints");m(this,"micAudioConstraints");m(this,"onVideoTrackEnded",()=>{this.emit("videotrackended")});m(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 w(this,null,function*(){var c,n,h,d,u,f;const{videoTrack:r,audioTrack:a}=e;r&&((c=this.originVideoTrack)==null||c.removeEventListener("ended",this.onVideoTrackEnded)),a&&((n=this.originAudioTrack)==null||n.removeEventListener("ended",this.onAudioTrackEnded)),this.type===ve.AliRtcSdkStreamTypeScreen?this.stop():(r&&((h=this.originVideoTrack)==null||h.stop()),a&&((d=this.originAudioTrack)==null||d.stop())),r&&(this.originVideoTrack=r,(u=this.originVideoTrack)==null||u.addEventListener("ended",this.onVideoTrackEnded),this.videoSource=t||Gt.Camera,this.updateVideoTrack(r)),a&&(this.originAudioTrack=a,(f=this.originAudioTrack)==null||f.addEventListener("ended",this.onAudioTrackEnded),this.audioSource=i||vi.Microphone,this.updateAudioTrack(a))})}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 w(this,null,function*(){(this._targetVideoTrack!==e||t)&&(this._targetVideoTrack=e)})}updateDualVideoTrack(e,t=!1){return w(this,null,function*(){(this._targetDualVideoTrack!==e||t)&&(this._targetDualVideoTrack=e)})}updateAudioTrack(e,t=!1){return w(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 w(this,null,function*(){var t,i,r,a,c,n,h,d,u,f,l,g;this._targetAudioTrack=this.originAudioTrack,this._targetVideoTrack=this.originVideoTrack;for(const p of this.plugins)try{yield p.execute(this,e)}catch(b){console.error(`error in plugin-${p.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 pi(this._targetVideoTrack),this.setVideoMuted(this._videoMuted),(r=this.profileManager)==null||r.setVideoProfile(this.originVideoTrack,this._publishVideoStream,!0),(a=this.profileManager)==null||a.setContentHint(this._targetVideoTrack),this.previewStream?(c=this.previewStream)==null||c.mergeStream(this._publishVideoStream):this._previewStream=yield pi(this._targetVideoTrack)):(this._publishVideoStream=void 0,(n=this.previewStream)==null||n.deleteTracks({video:!0})),this._targetDualVideoTrack?((d=(h=this._publishDualVideoStream)==null?void 0:h.videoTrack)==null?void 0:d.id)!==this._targetDualVideoTrack.id&&(this._publishDualVideoStream=yield pi(this._targetDualVideoTrack),this._videoMuted?this._publishDualVideoStream.disableVideo():this._publishDualVideoStream.enableVideo()):this._publishDualVideoStream=void 0,this._targetAudioTrack?((f=(u=this._publishAudioStream)==null?void 0:u.audioTrack)==null?void 0:f.id)!==this._targetAudioTrack.id&&(this._publishAudioStream=yield pi(this._targetAudioTrack),this.setAudioMuted(this._audioMuted),this.previewStream?(l=this.previewStream)==null||l.mergeStream(this._publishAudioStream):this._previewStream=yield pi(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 w(this,null,function*(){this._profileManager||(this._profileManager=new wr(this.type===ve.AliRtcSdkStreamTypeScreen?xa:Ar)),e&&this._profileManager.updateProfile(e,t),yield this._profileManager.setVideoProfile(this.originVideoTrack,this._publishVideoStream,i||this.type===ve.AliRtcSdkStreamTypeScreen)})}get videoProfile(){var e;return(e=this.profileManager)==null?void 0:e.videoProfile}setVideoContentHint(e){this._profileManager||(this._profileManager=new wr(this.type===ve.AliRtcSdkStreamTypeScreen?xa:Ar)),this._profileManager.setContentHint(this.currentVideoTrack,e)}updateAudioProfile(e){return w(this,null,function*(){this._profileManager||(this._profileManager=new wr),this._profileManager.updateAudioProfile(e)})}cloneVideoProfile(e){return w(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 Yo=Object.defineProperty,Xo=Object.getOwnPropertyDescriptor,st=(s,o,e,t)=>{for(var i,r=t>1?void 0:t?Xo(o,e):o,a=s.length-1;a>=0;a--)(i=s[a])&&(r=(t?i(o,e,r):i(r))||r);return t&&r&&Yo(o,e,r),r};const tt=(Lt=class extends te{constructor(e,t){super();m(this,"pluginManager");m(this,"slsReporter");m(this,"publishingCameraVideoStream");m(this,"publishingScreenVideoStream");m(this,"cameraStreamInfo",new Cr(ve.AliRtcSdkStreamTypeCapture));m(this,"screenStreamInfo",new Cr(ve.AliRtcSdkStreamTypeScreen));m(this,"streamInfos",[this.cameraStreamInfo,this.screenStreamInfo]);m(this,"_audioCaptureDisabled",!1);m(this,"_cameraCaptureDisabled",!1);m(this,"_publishLocalAudioStreamEnabled",!0);m(this,"_publishLocalVideoStreamEnabled",!0);m(this,"_publishLocalScreenStreamEnabled",!0);this.screenStreamInfo.setVideoContentHint("motion"),this.pluginManager=e,this.slsReporter=t,this.cameraStreamInfo.on("videotrackended",()=>w(this,null,function*(){yield this.stopLocalStream({video:!0}),this.emit("trackended",Ft.VideoTrackEnded)})),this.cameraStreamInfo.on("audiotrackended",()=>w(this,null,function*(){yield this.stopLocalStream({audio:!0}),this.emit("trackended",Ft.AudioTrackEnded)})),this.screenStreamInfo.on("videotrackended",()=>w(this,null,function*(){yield this.stopLocalStream({screen:!0}),this.emit("trackended",Ft.ScreenTrackEnded)})),this.pluginManager.on("added",i=>w(this,null,function*(){if(x.info(`[${Lt.logName}]`,"plugin added",i.name),!i.isSupported("7.1.0-beta.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,Mt.AliRtcPluginErrorInitError))}i.streamType===ve.AliRtcSdkStreamTypeCapture&&(this.cameraStreamInfo.addPlugin(i),yield this.cameraStreamInfo.process(this.streamInfos)),i.streamType===ve.AliRtcSdkStreamTypeScreen&&(this.screenStreamInfo.addPlugin(i),yield this.screenStreamInfo.process(this.streamInfos)),this.emit("publishupdate")})),this.pluginManager.on("removed",i=>w(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",()=>w(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 w(this,null,function*(){yield this.cameraStreamInfo.process(this.streamInfos),yield this.screenStreamInfo.process(this.streamInfos),this.emit("publishupdate")})}setAvailableCameraDeviceId(){return w(this,null,function*(){var e,t,i,r;if((e=this.cameraStreamInfo.cameraVideoConstraints)!=null&&e.deviceId){let a=(t=this.cameraStreamInfo.cameraVideoConstraints)==null?void 0:t.deviceId;const c=yield G.AliRTS.getCameraList();c.find(n=>n.deviceId===a)||(a=(r=(i=c.find(n=>!!n.deviceId))==null?void 0:i.deviceId)!=null?r:""),this.cameraStreamInfo.cameraVideoConstraints.deviceId=a}})}setAvailableMicrophoneDeviceId(){return w(this,null,function*(){var e,t,i,r;if((e=this.cameraStreamInfo.micAudioConstraints)!=null&&e.deviceId){let a=(t=this.cameraStreamInfo.micAudioConstraints)==null?void 0:t.deviceId;const c=yield G.AliRTS.getMicList();c.find(n=>n.deviceId===a)||(a=(r=(i=c.find(n=>!!n.deviceId))==null?void 0:i.deviceId)!=null?r:""),this.cameraStreamInfo.micAudioConstraints.deviceId=a}})}createLocalStream(e){return w(this,null,function*(){var u;const{screen:t,mediaStream:i,videoProfile:r,screenProfile:a}=e;let{video:c,audio:n}=e;const h=(f=>{const{audio:l,video:g,screen:p}=f;if(g&&p)throw new O(U.ERR_INNER,"create stream error, cannot create video && screen together");return!!(g||l||p)})(e);let d;if(h){i||(c===!0&&this.cameraStreamInfo.cameraVideoConstraints?(yield this.setAvailableCameraDeviceId(),c=Y({},this.cameraStreamInfo.cameraVideoConstraints)):typeof c=="object"&&(yield this.setAvailableCameraDeviceId(),c=Y(Y({},c),this.cameraStreamInfo.cameraVideoConstraints)),n===void 0&&this.audioCaptureDisabled?n=!1:n&&(n===!0&&this.cameraStreamInfo.micAudioConstraints?(yield this.setAvailableMicrophoneDeviceId(),n=Y({},this.cameraStreamInfo.micAudioConstraints)):typeof n=="object"&&(yield this.setAvailableMicrophoneDeviceId(),n=Y(Y({},n),this.cameraStreamInfo.micAudioConstraints)),this._audioCaptureDisabled=!1));const f=Date.now();try{d=yield G.AliRTS.createStream({audio:n,video:c,screen:t,custom:!!i,mediaStream:i,skipProfile:!0}),x.info(`[${Lt.logName}]`,"createLocalStream",{audio:n,video:c,screen:t,custom:!!i,time:Date.now()-f}),n&&!i&&this.slsReporter.reportAudio(null,Date.now()-f,((u=d==null?void 0:d.audioTrack)==null?void 0:u.label)||""),t&&!i&&this.slsReporter.reportScreen(null,Date.now()-f)}catch(l){throw n&&!i&&this.slsReporter.reportAudio(l,Date.now()-f,""),t&&!i&&this.slsReporter.reportScreen(null,Date.now()-f),l}if(t)yield this.screenStreamInfo.updateSource(d,Gt.Screen,vi.Screen),yield this.setScreenProfile(a||Oa),this.setScreenContentHint(),this.publishingScreenVideoStream=void 0;else if(yield this.cameraStreamInfo.updateSource(d,Gt.Camera,vi.Microphone),d.hasVideo&&(yield this.setVideoProfile(r||Va),this.setVideoContentHint(),this.publishingCameraVideoStream=void 0),d.hasAudio&&typeof n=="boolean"){const l=this.cameraStreamInfo.audioProfile;l&&(yield d.setAudioProfile(l))}}return G.AliRTS.SystenUtil.isIos&&G.AliRTS.SystenUtil.compareVersion("15.1")&&!G.AliRTS.SystenUtil.compareVersion("15.2")&&(yield Ct(1e3)),yield this.updateStreams(),d})}stopLocalStream(e){return w(this,null,function*(){const{screen:t,video:i,audio:r}=e!=null?e:{};let a=!1;i&&this.cameraStreamInfo.originVideoTrack&&(a=!0,this.cameraStreamInfo.stopVideo(),this.publishingCameraVideoStream=void 0),r&&this.cameraStreamInfo.originAudioTrack&&(a=!0,this.cameraStreamInfo.stopAudio()),t&&this.screenStreamInfo.originVideoTrack&&(a=!0,this.screenStreamInfo.stop(),this.publishingScreenVideoStream=void 0,this.slsReporter.reportScreenStop(null)),a&&(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 w(this,null,function*(){var n,h,d,u;let e,t,i,r,a=!1;const c=this.publishStreams;try{if(!(c.audio||c.video||c.videoSmall||c.screen))throw x.error(`[${Lt.logName}]`,"no tracks founded"),new O(U.ERR_SDK_PUBLISH_INVAILD,"no tracks founded");const f=new MediaStream;(n=c.audio)!=null&&n.audioTrack&&f.addTrack(c.audio.audioTrack),(h=c.video)!=null&&h.videoTrack?(f.addTrack(c.video.videoTrack),i=c.videoSmall,r=c.screen):(d=c.screen)!=null&&d.videoTrack&&(t=M.Screen,f.addTrack((u=c.screen)==null?void 0:u.videoTrack),a=!0),e=yield ja(f),a?(this.screenStreamInfo.cloneVideoProfile(e),this.publishingScreenVideoStream=e):(this.cameraStreamInfo.cloneVideoProfile(e),this.publishingCameraVideoStream=e)}catch(f){}return{publishStream:e,videoSmallStream:i,screenStream:r,vMsid:t}})}stop(){this.cameraStreamInfo.stop(),this.screenStreamInfo.stop(),this.updateStreams()}setVideoProfile(e,t,i=!1){return w(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 w(this,null,function*(){var t;yield this.cameraStreamInfo.updateAudioProfile(e),yield(t=this.publishingCameraVideoStream)==null?void 0:t.setAudioProfile(e)})}setScreenProfile(e,t){return w(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=Y(Y({},(t=this.cameraStreamInfo.cameraVideoConstraints)!=null?t:{}),e)}setMicAudioConstraints(e){var t;this.cameraStreamInfo.micAudioConstraints=Y(Y({},(t=this.cameraStreamInfo.micAudioConstraints)!=null?t:{}),e)}},m(Lt,"logName","LocalStreamManager"),Lt);st([C(([s])=>{const{audio:o,video:e,screen:t,custom:i,skipProfile:r,videoProfile:a,screenProfile:c}=s;return[{audio:o,video:e,screen:t,custom:i,skipProfile:r,videoProfile:a,screenProfile:c}]})],tt.prototype,"createLocalStream",1),st([C(B)],tt.prototype,"stopLocalStream",1),st([C()],tt.prototype,"createHTTPPublishStream",1),st([C()],tt.prototype,"stop",1),st([C(B)],tt.prototype,"setVideoProfile",1),st([C(B)],tt.prototype,"setVideoContentHint",1),st([C(B)],tt.prototype,"setAudioProfile",1),st([C(B)],tt.prototype,"setScreenProfile",1),st([C(B)],tt.prototype,"setScreenContentHint",1),st([C(B)],tt.prototype,"setCameraVideoConstraints",1),st([C(B)],tt.prototype,"setMicAudioConstraints",1);let Qo=tt;class Zo extends Ut{constructor(){super("AliRtcScreenStandardize",ve.AliRtcSdkStreamTypeScreen);m(this,"canvas");m(this,"lastWidth");m(this,"lastHeight");m(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 a=this.canvas.getContext("2d");a&&a.clearRect(0,0,i,r)}this.lastWidth=e,this.lastHeight=t}shouldUpdate(e){return this.hasScreenTrack!==(!!e.originVideoTrack&&e.videoSource===Gt.Screen)}handleFrame(e,t){return w(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 a=(c=this.canvas)==null?void 0:c.getContext("2d");if(this.canvas&&a){a.drawImage(e,0,0,i,r);const n=new VideoFrame(this.canvas,{timestamp:e.timestamp});return e.close(),n}return e})}process(e){return w(this,null,function*(){var d;if(!e.originVideoTrack||e.videoSource!==Gt.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]),a=this,c=new TransformStream({transform(u,f){return w(this,null,function*(){const l=yield a.handleFrame(u,e);yield f.enqueue(l),l==null||l.close()})}});t.readable.pipeThrough(c).pipeTo(i.writable);const n=(d=r.getVideoTracks())==null?void 0:d[0];e.updateVideoTrack(n),this.hasScreenTrack=!0})}clear(e){this.canvas=void 0,this.lastWidth=void 0,this.lastHeight=void 0,super.clear(e)}}class ec extends Ut{constructor(){super("blankAudio",ve.AliRtcSdkStreamTypeCapture,si.BOTH);m(this,"hasTrack",!1);m(this,"oscillator",null);m(this,"audioTrack",null);m(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 w(this,null,function*(){var r;const i=t.some(a=>a.originVideoTrack||a.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 Ka{constructor(o){m(this,"name","COMMON");this.name=o||this.name}info(...o){}warn(...o){}print(o,...e){const t=o.toLowerCase();t&&console[t](`[${o}][${this.name}]`,...e)}}m(Ka,"LEVEL",0);class tc{constructor(){m(this,"logger",new Ka("AudioMixer"));m(this,"audioContext",new AudioContext);m(this,"audioDestination",this.audioContext.createMediaStreamDestination());m(this,"audioTrack",(o=>o.getAudioTracks()[0])(this.audioDestination.stream));m(this,"sourceNodeMap",{})}get sourceNodeList(){return Object.values(this.sourceNodeMap).map(o=>o.sourceNode).filter(o=>!!o)}get gainNodeList(){return Object.values(this.sourceNodeMap).map(o=>o.gainNode).filter(o=>!!o)}get sourceCount(){return this.sourceNodeList.length}resume(){var o;return(o=this.audioContext)==null?void 0:o.resume()}addTrack(o){this.connectTrack(o)}hasTrack(o){return!!this.sourceNodeMap[o]}removeTrack(o){const{sourceNode:e,gainNode:t}=this.sourceNodeMap[o]||{};t==null||t.disconnect(),e==null||e.disconnect(),delete this.sourceNodeMap[o],e?this.logger.info("SourceNode disconnected. Active source node:",this.sourceNodeList.length):this.logger.warn(`SourceNode ${o} does not exit. Active source node: ${this.sourceNodeList.length}`)}getAudioTrack(){return this.audioTrack}setVolume(o,e){const{gainNode:t}=this.sourceNodeMap[e]||{};t?(this.logger.info(`Setting node(${e}) volume to ${this.scale(o)}`),t.gain.value=this.scale(o)):this.logger.warn(`GainNode ${e} does not exit.`)}reset(){this.disconnectSourceNode(),this.sourceNodeMap={}}dispose(){var o;this.reset(),(o=this.audioTrack)==null||o.stop(),this.audioDestination.disconnect(),this.audioContext.close()}connectTrack(o){if(!this.audioContext)return this.logger.warn("AudioContext not initialized");let e=new MediaStream;e.addTrack(o);const t=this.audioContext.createMediaStreamSource(e),i=this.audioContext.createGain();i.gain.value=1,t.connect(i),i.connect(this.audioDestination),this.sourceNodeMap[o.id]={track:o,sourceNode:t,gainNode:i},this.logger.info("New sourceNode connected. Active source node:",this.sourceNodeList.length)}disconnectSourceNode(){this.sourceNodeList.forEach(o=>o.disconnect()),this.gainNodeList.forEach(o=>o.disconnect())}scale(o){return o/100}}class ic extends Ut{constructor(){super("audioMixer",ve.AliRtcSdkStreamTypeCapture,si.AUDIO);m(this,"audioMixer");m(this,"primaryAudioTrackId");m(this,"screenAudioTrackId");m(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 a,c;if(e.type!==ve.AliRtcSdkStreamTypeCapture)return!1;const i=t.find(n=>n.type===ve.AliRtcSdkStreamTypeCapture),r=t.find(n=>n.type===ve.AliRtcSdkStreamTypeScreen);return!(this.primaryAudioTrackId===((a=i==null?void 0:i.currentAudioTrack)==null?void 0:a.id)&&this.screenAudioTrackId===((c=r==null?void 0:r.currentAudioTrack)==null?void 0:c.id)&&!this.dirty)}process(e,t){return w(this,null,function*(){var c,n;this.dirty=!1;const i=t.find(h=>h.type===ve.AliRtcSdkStreamTypeScreen),r=e.currentAudioTrack,a=i==null?void 0:i.currentAudioTrack;if(!a&&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 tc),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&&(a==null?void 0:a.id)!==this.screenAudioTrackId&&((n=this.audioMixer)==null||n.removeTrack(this.screenAudioTrackId)),a&&!this.audioMixer.hasTrack(a==null?void 0:a.id)&&this.audioMixer.addTrack(a),this.screenAudioTrackId=a==null?void 0:a.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 kr{constructor(o,e){m(this,"originTrack");m(this,"originVideo");m(this,"targetWidth");m(this,"targetHeight");m(this,"targetFrameRate");m(this,"targetCanvas");m(this,"animationFrameId");m(this,"resultTrack");this.targetWidth=e.width,this.targetHeight=e.height,this.targetFrameRate=e.frameRate,this.originTrack=o,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(o){this.targetWidth=o.width,this.targetHeight=o.height,this.targetFrameRate=o.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(o,e,t,i){const r=e/o,a=i/t;let c=t,n=i,h=0,d=0;return a>r?(c=Math.round(n/r),h=Math.round((t-c)/2)):a<r&&(n=Math.round(c*r),d=Math.round((i-n)/2)),{x:h,y:d,width:c,height:n}}}class rc extends kr{constructor(e,t){super(e,t);m(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 Wa(s,o,e){const t=s.createShader(o);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 $a extends kr{constructor(e,t){super(e,t);m(this,"targetCtx");m(this,"targetTexture");m(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(n){const h=n.createTexture();return n.bindTexture(n.TEXTURE_2D,h),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),h}(e);const t=function(n,h,d){const u=Wa(n,n.VERTEX_SHADER,h),f=Wa(n,n.FRAGMENT_SHADER,d),l=n.createProgram();if(l&&u&&f)return n.attachShader(l,u),n.attachShader(l,f),n.linkProgram(l),n.getProgramParameter(l,n.LINK_STATUS)?l:(console.error(`Unable to initialize the shader program: ${n.getProgramInfoLog(l)}`),null)}(e,`
|
|
13
|
+
`;const E=(P,H)=>P[0].localeCompare(H[0]),I=P=>P[0].startsWith("x-log-")||P[0].startsWith("x-acs-");try{const P=[..._.entries()].filter(I).sort(E).map(H=>H[0]+":"+H[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+":"+hi.HmacSHA1(A,S).toString(hi.enc.Base64);_.set("Authorization",k),_.set("x-log-date",y)}("POST",n,s.accessKeyId,s.accessKeySecret,d,p,o,l);let u=Object.fromEntries(p);return{data:e,header:u}},new Promise((n,c)=>{var o=d=>{try{l(r.next(d))}catch(p){c(p)}},h=d=>{try{l(r.throw(d))}catch(p){c(p)}},l=d=>d.done?n(d.value):Promise.resolve(d.value).then(o,h);l((r=r.apply(t,i)).next())});var t,i,r}}}typeof window!="undefined"&&Ts(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(Na[a]||a||Na.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"]()},h=function(){return s[r()+"FullYear"]()},l=function(){return s[r()+"Hours"]()},d=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 La({y:h(),m:o(),d:n(),_:r(),dayName:tt.dayNames[c()],short:!0})},dddd:function(){return tt.dayNames[c()+7]},DDDD:function(){return La({y:h(),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(h()).slice(2)},yyyy:function(){return nt(h(),4)},h:function(){return l()%12||12},hh:function(){return nt(l()%12||12)},H:function(){return l()},HH:function(){return nt(l())},M:function(){return d()},MM:function(){return nt(d())},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 l()<12?tt.timeNames[0]:tt.timeNames[1]},tt:function(){return l()<12?tt.timeNames[2]:tt.timeNames[3]},T:function(){return l()<12?tt.timeNames[4]:tt.timeNames[5]},TT:function(){return l()<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 Na={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")},La=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,h=new Date;h.setDate(h[i+"Date"]()-1);var l=new Date;return l.setDate(l[i+"Date"]()+1),o[i+"FullYear"]()===a&&o[i+"Month"]()===e&&o[i+"Date"]()===t?c?"Tdy":"Today":h[i+"FullYear"]()===a&&h[i+"Month"]()===e&&h[i+"Date"]()===t?c?"Ysd":"Yesterday":l[i+"FullYear"]()===a&&l[i+"Month"]()===e&&l[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",xa="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:xa};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:xa})},{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"}],Va=()=>{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:Oa,SystenUtil:Ua}=q.AliRTS,Lo=Va(),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 Ba(){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",ht());f(this,"bSesid",ht());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:`[${Ba()} ${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=ht(),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:hi.MD5(e).toString(hi.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 lr(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:Oa.browserName,dm:Oa.browserVersion,install_uuid:this.clientId,logger_v:"0.0.1",os:Ua.systemName,osv:Ua.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=`[${Ba()} ${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 Le=(s=>(s[s.AliRtcSdkStreamTypeCapture=0]="AliRtcSdkStreamTypeCapture",s[s.AliRtcSdkStreamTypeScreen=1]="AliRtcSdkStreamTypeScreen",s))(Le||{}),Ha=(s=>(s[s.PRE_PROCESSOR=0]="PRE_PROCESSOR",s[s.POST_PROCESSOR=1]="POST_PROCESSOR",s))(Ha||{}),ti=(s=>(s[s.AUDIO=0]="AUDIO",s[s.VIDEO=1]="VIDEO",s[s.BOTH=2]="BOTH",s))(ti||{});class Nt extends se{constructor(e,t=Le.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 li=(s=>(s[s.LiveTranscodingSingle=0]="LiveTranscodingSingle",s[s.LiveTranscodingMix=1]="LiveTranscodingMix",s))(li||{}),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 di={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),lt=(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",li.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===li.LiveTranscodingSingle){const c=this.singleParam;if(c){n.streamtype=c.streamType,c.sourceType===ii.LiveTranscodingShareScreen?n.sourcetype=di[c.sourceType]:n.sourcetype=di[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 h=o.videoWidth,l=o.videoHeight;const d={};Object.keys(o).forEach(u=>{const g=o[u];g>0&&(d[u.toLowerCase()]=g)}),d.lowbitratehighquality=0,n.encodeparam=d,n.backgrounds=c.backgrounds.map(u=>u.toJson(h,l)),n.watermarks=c.watermarks.map(u=>u.toJson(h,l)),n.clockwidgets=c.clockWidgets.map(u=>u.toJson(h,l));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,h,l,c.mediaProcessMode))}],n.layoutids=["0"],n.cropmode=c.cropMode,n.backgroundcolor=wr(c.backgroundColor),n.taskmode=c.mediaProcessMode}}}return n}}var Tt=(s=>(s.pre="pre",s.prod="prod",s))(Tt||{}),Ct=(s=>(s.AliRtcSdkCommunication="communication",s.AliRtcSdkInteractiveLive="interactive_live",s.AliRtcSdkInteractiveWithLowLatencyLive="cdn_live",s))(Ct||{}),Lt=(s=>(s.AliRtcSdkInteractive="interactive",s.AliRtcSdkLive="live",s))(Lt||{}),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||{}),ne=(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))(ne||{}),Rt=(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))(Rt||{}),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||{}),oe=(s=>(s[s.AliRtcVideoTrackNo=0]="AliRtcVideoTrackNo",s[s.AliRtcVideoTrackCamera=1]="AliRtcVideoTrackCamera",s[s.AliRtcVideoTrackScreen=2]="AliRtcVideoTrackScreen",s[s.AliRtcVideoTrackBoth=3]="AliRtcVideoTrackBoth",s))(oe||{}),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",h="model",l="name",d="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",H="Google",G="Huawei",Y="LG",J="Microsoft",z="Motorola",Q="Opera",ee="Samsung",pe="Sharp",D="Sony",L="Xiaomi",N="Zebra",x="Facebook",he="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,de,je,Z,Me=0;Me<re.length&&!je;){var at=re[Me],Ne=re[Me+1];for(te=be=0;te<at.length&&!je&&at[te];)if(je=at[te++].exec(ae))for(Ve=0;Ve<Ne.length;Ve++)Z=je[++be],typeof(de=Ne[Ve])===n&&de.length>0?de.length===2?typeof de[1]==i?this[de[0]]=de[1].call(this,Z):this[de[0]]=de[1]:de.length===3?typeof de[1]!==i||de[1].exec&&de[1].test?this[de[0]]=Z?Z.replace(de[1],de[2]):t:this[de[0]]=Z?de[1].call(this,Z,de[2]):t:de.length===4&&(this[de[0]]=Z?de[3].call(this,Z.replace(de[1],de[2])):t):this[de]=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},le={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,[l,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[u,[l,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[l,u],[/opios[\/ ]+([\w\.]+)/i],[u,[l,Q+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[u,[l,Q+" GX"]],[/\bopr\/([\w\.]+)/i],[u,[l,Q]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[u,[l,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[u,[l,"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],[l,u],[/quark(?:pc)?\/([-\w\.]+)/i],[u,[l,"Quark"]],[/\bddg\/([\w\.]+)/i],[u,[l,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[u,[l,"UC"+I]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[u,[l,"WeChat"]],[/konqueror\/([\w\.]+)/i],[u,[l,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[u,[l,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[u,[l,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[u,[l,"Smart Lenovo "+I]],[/(avast|avg)\/([\w\.]+)/i],[[l,/(.+)/,"$1 Secure "+I],u],[/\bfocus\/([\w\.]+)/i],[u,[l,P+" Focus"]],[/\bopt\/([\w\.]+)/i],[u,[l,Q+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[u,[l,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[u,[l,"Dolphin"]],[/coast\/([\w\.]+)/i],[u,[l,Q+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[u,[l,"MIUI"+$]],[/fxios\/([\w\.-]+)/i],[u,[l,P]],[/\bqihoobrowser\/?([\w\.]*)/i],[u,[l,"360"]],[/\b(qq)\/([\w\.]+)/i],[[l,/(.+)/,"$1Browser"],u],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[l,/(.+)/,"$1"+$],u],[/samsungbrowser\/([\w\.]+)/i],[u,[l,ee+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[u,[l,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[l,"Sogou Mobile"],u],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[l,u],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[l],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[u,l],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[l,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],[l,u],[/\bgsa\/([\w\.]+) .*safari\//i],[u,[l,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[u,[l,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[u,[l,k+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[l,k+" WebView"],u],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[u,[l,"Android "+I]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[l,u],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[u,[l,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[u,l],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[l,[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],[l,u],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[l,"Netscape"],u],[/(wolvic|librewolf)\/([\w\.]+)/i],[l,u],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[u,[l,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],[l,[u,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[l,[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],[h,[p,ee],[d,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],[h,[p,ee],[d,b]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[h,[p,R],[d,b]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[h,[p,R],[d,S]],[/(macintosh);/i],[h,[p,R]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[h,[p,pe],[d,b]],[/(?:honor)([-\w ]+)[;\)]/i],[h,[p,"Honor"],[d,b]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[h,[p,G],[d,S]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[h,[p,G],[d,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],[[h,/_/g," "],[p,L],[d,b]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[h,/_/g," "],[p,L],[d,S]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[h,[p,"OPPO"],[d,b]],[/\b(opd2\d{3}a?) bui/i],[h,[p,"OPPO"],[d,S]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[h,[p,"Vivo"],[d,b]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[h,[p,"Realme"],[d,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],[h,[p,z],[d,b]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[h,[p,z],[d,S]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[h,[p,Y],[d,S]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[h,[p,Y],[d,b]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[h,[p,"Lenovo"],[d,S]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[h,/_/g," "],[p,"Nokia"],[d,b]],[/(pixel c)\b/i],[h,[p,H],[d,S]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[h,[p,H],[d,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],[h,[p,D],[d,b]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[h,"Xperia Tablet"],[p,D],[d,S]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[h,[p,"OnePlus"],[d,b]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[h,[p,y],[d,S]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[h,/(.+)/g,"Fire Phone $1"],[p,y],[d,b]],[/(playbook);[-\w\),; ]+(rim)/i],[h,p,[d,S]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[h,[p,E],[d,b]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[h,[p,A],[d,S]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[h,[p,A],[d,b]],[/(nexus 9)/i],[h,[p,"HTC"],[d,S]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[p,[h,/_/g," "],[d,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],[h,[p,"TCL"],[d,S]],[/(itel) ((\w+))/i],[[p,Ae],h,[d,_e,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[h,[p,"Acer"],[d,S]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[h,[p,"Meizu"],[d,b]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[h,[p,"Ulefone"],[d,b]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[h,[p,"Energizer"],[d,b]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[h,[p,"Cat"],[d,b]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[h,[p,"Smartfren"],[d,b]],[/droid.+; (a(?:015|06[35]|142p?))/i],[h,[p,"Nothing"],[d,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,h,[d,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,h,[d,S]],[/(surface duo)/i],[h,[p,J],[d,S]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[h,[p,"Fairphone"],[d,b]],[/(u304aa)/i],[h,[p,"AT&T"],[d,b]],[/\bsie-(\w*)/i],[h,[p,"Siemens"],[d,b]],[/\b(rct\w+) b/i],[h,[p,"RCA"],[d,S]],[/\b(venue[\d ]{2,7}) b/i],[h,[p,"Dell"],[d,S]],[/\b(q(?:mv|ta)\w+) b/i],[h,[p,"Verizon"],[d,S]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[h,[p,"Barnes & Noble"],[d,S]],[/\b(tm\d{3}\w+) b/i],[h,[p,"NuVision"],[d,S]],[/\b(k88) b/i],[h,[p,"ZTE"],[d,S]],[/\b(nx\d{3}j) b/i],[h,[p,"ZTE"],[d,b]],[/\b(gen\d{3}) b.+49h/i],[h,[p,"Swiss"],[d,b]],[/\b(zur\d{3}) b/i],[h,[p,"Swiss"],[d,S]],[/\b((zeki)?tb.*\b) b/i],[h,[p,"Zeki"],[d,S]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[p,"Dragon Touch"],h,[d,S]],[/\b(ns-?\w{0,9}) b/i],[h,[p,"Insignia"],[d,S]],[/\b((nxa|next)-?\w{0,9}) b/i],[h,[p,"NextBook"],[d,S]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[p,"Voice"],h,[d,b]],[/\b(lvtel\-)?(v1[12]) b/i],[[p,"LvTel"],h,[d,b]],[/\b(ph-1) /i],[h,[p,"Essential"],[d,b]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[h,[p,"Envizen"],[d,S]],[/\b(trio[-\w\. ]+) b/i],[h,[p,"MachSpeed"],[d,S]],[/\btu_(1491) b/i],[h,[p,"Rotor"],[d,S]],[/(shield[\w ]+) b/i],[h,[p,"Nvidia"],[d,S]],[/(sprint) (\w+)/i],[p,h,[d,b]],[/(kin\.[onetw]{3})/i],[[h,/\./g," "],[p,J],[d,b]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[h,[p,N],[d,S]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[h,[p,N],[d,b]],[/smart-tv.+(samsung)/i],[p,[d,v]],[/hbbtv.+maple;(\d+)/i],[[h,/^/,"SmartTV"],[p,ee],[d,v]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[p,Y],[d,v]],[/(apple) ?tv/i],[p,[h,R+" TV"],[d,v]],[/crkey/i],[[h,k+"cast"],[p,H],[d,v]],[/droid.+aft(\w+)( bui|\))/i],[h,[p,y],[d,v]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[h,[p,pe],[d,v]],[/(bravia[\w ]+)( bui|\))/i],[h,[p,D],[d,v]],[/(mitv-\w{5}) bui/i],[h,[p,L],[d,v]],[/Hbbtv.*(technisat) (.*);/i],[p,h,[d,v]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[p,Te],[h,Te],[d,v]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[d,v]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[p,h,[d,m]],[/droid.+; (shield) bui/i],[h,[p,"Nvidia"],[d,m]],[/(playstation [345portablevi]+)/i],[h,[p,D],[d,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[h,[p,J],[d,m]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[h,[p,ee],[d,_]],[/((pebble))app/i],[p,h,[d,_]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[h,[p,R],[d,_]],[/droid.+; (glass) \d/i],[h,[p,H],[d,_]],[/droid.+; (wt63?0{2,3})\)/i],[h,[p,N],[d,_]],[/droid.+; (glass) \d/i],[h,[p,H],[d,_]],[/(pico) (4|neo3(?: link|pro)?)/i],[p,h,[d,_]],[/; (quest( \d| pro)?)/i],[h,[p,x],[d,_]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[p,[d,w]],[/(aeobc)\b/i],[h,[p,y],[d,w]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[h,[d,b]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[h,[d,S]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[d,S]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[d,b]],[/(android[-\w\. ]{0,9});.+buil/i],[h,[p,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[u,[l,"EdgeHTML"]],[/(arkweb)\/([\w\.]+)/i],[l,u],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[u,[l,"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],[l,u],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[u,l]],os:[[/microsoft (windows) (vista|xp)/i],[l,u],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[l,[u,_e,le]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[u,_e,le],[l,"Windows"]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[u,/_/g,"."],[l,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[l,ke],[u,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[u,l],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[l,u],[/\(bb(10);/i],[u,[l,E]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[u,[l,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[u,[l,P+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[u,[l,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[u,[l,"watchOS"]],[/crkey\/([\d\.]+)/i],[u,[l,k+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[l,he],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],[l,u],[/(sunos) ?([\w\.\d]*)/i],[[l,"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],[l,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,de=re?function(Z,Me){var at={};for(var Ne in Z)Me[Ne]&&Me[Ne].length%2==0?at[Ne]=Me[Ne].concat(Z[Ne]):at[Ne]=Z[Ne];return at}(Pe,re):Pe,je=te&&te.userAgent==be;return this.getBrowser=function(){var Z,Me={};return Me[l]=t,Me[u]=t,fe.call(Me,be,de.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[l]="Brave"),Me},this.getCPU=function(){var Z={};return Z[g]=t,fe.call(Z,be,de.cpu),Z},this.getDevice=function(){var Z={};return Z[p]=t,Z[h]=t,Z[d]=t,fe.call(Z,be,de.device),je&&!Z[d]&&Ve&&Ve.mobile&&(Z[d]=b),je&&Z[h]=="Macintosh"&&te&&typeof te.standalone!==r&&te.maxTouchPoints&&te.maxTouchPoints>2&&(Z[h]="iPad",Z[d]=S),Z},this.getEngine=function(){var Z={};return Z[l]=t,Z[u]=t,fe.call(Z,be,de.engine),Z},this.getOS=function(){var Z={};return Z[l]=t,Z[u]=t,fe.call(Z,be,de.os),je&&!Z[l]&&Ve&&Ve.platform&&Ve.platform!="Unknown"&&(Z[l]=Ve.platform.replace(/chrome os/i,he).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([l,u,o]),ye.CPU=ge([g]),ye.DEVICE=ge([h,p,d,m,b,v,S,_,w]),ye.ENGINE=ye.OS=ge([l,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.1.0",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:ht(),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 U=(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))(U||{});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 h=e,{l1ip:t}=h,i=Qt(h,["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.1.0";o&&(o=o.split("-")[0]),n.forEach(l=>{const{codec:d,ssrc:p}=l;l.userdata=JSON.stringify({sdk_version:o,codec:d}),l.ssrc=`${p}`,c&&(l.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(Pt(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!==Ct.AliRtcSdkInteractiveLive&&this.channelProfile!==Ct.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(U.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(U.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(U.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(U.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 d;const c=`[${((d=e.constructor)==null?void 0:d.logName)||""}]`,o=Date.now();let h=[];if(s)try{h=s(n)}catch(p){}V.interface(c,t,...h);const l=r.apply(this,n);return Promise.resolve(l).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)}}),l},i},B=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=Tt.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===Tt.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",l=>{var d,p,u;if(V.info(`[${Ye.logName}]`,"join result: ",l),o.taskretrynum=((d=this.messageCenter)==null?void 0:d.retryCount)||0,l.code==200){(p=this.messageCenter)==null||p.sendPkgCache(),(u=this.messageCenter)==null||u.startKeepAlive();let g=l.data;g.tid=l.tid,g.users=l.data.users,g.timestamp=l.timestamp,o.est&&(o.joinconnecttc=Date.now()-o.est),this.slsReporter.reportJoinConnection(o),n(g)}else this.reset(),c(this.handleSignalError(l.code,l.reason,U.ERR_JOIN_CHANNEL_FAILED))}),this.messageCenter.once("onAuthInvalid",()=>{this.reset(),c(new O(U.ERR_JOIN_BAD_TOKEN,"join failed because authentication failed"))}),V.info(`[${Ye.logName}]`,"start ws connecting roomserver and auto join when connected");const h={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:ht()};e.role&&(h.tokenrole=e.role),o.est=Date.now(),this.messageCenter.start(this.roomServerUri+"?"+et.queryingParam(h),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(Pt(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=ht()),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,h;V.info(`[${Ye.logName}]`,"recv role update response "+r),r===200?((h=(o=this.reconnectData)==null?void 0:o.role)!=null&&h.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=U.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,h,l,d,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")}),(h=this.messageCenter)==null||h.on("onReconnectSuccess",m=>{this.emit("onReconnectSuccess",m)}),(l=this.messageCenter)==null||l.on("onReconnectFail",m=>{this.emit("onReconnectFail",m)}),(d=this.messageCenter)==null||d.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:h}=this.authInfo;let l="https://gw.rtn.aliyuncs.com";this.env===Tt.pre&&(l="https://pgw.rtn.aliyuncs.com");const d=`${l}/gslb/v1/stsupdate?appid=${e}&channelid=${t}&userid=${i}&nonce=${r}&token=${n}×tamp=${c}&session=${o}${h?`&tokenrole=${h}`:""}&slstoken=true&osstoken=true&tokensid=false`,p=Date.now();fetch(d).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=Tt.prod){super();f(this,"signaling");f(this,"authInfo");f(this,"userName");f(this,"channelProfile");f(this,"clientRole");f(this,"env",Tt.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(U.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(h=>{this.authInfo=e,r&&(r.re=Date.now()),c(h)}).catch(h=>{this.reset(),o(h)}),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(U.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(U.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,h,l,d,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)),(h=this.signaling)==null||h.on("onReconnectSuccess",this.onReconnectSuccess.bind(this)),(l=this.signaling)==null||l.on("onReconnectFail",this.onReconnectFail.bind(this)),(d=this.signaling)==null||d.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(B)],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,h){let l,d=o,p=0;const u=r.createAnalyser();u.fftSize=256;const g=new Uint8Array(u.frequencyBinCount);n.connect(u),u.connect(c);const m=()=>{l&&window.clearInterval(l)},b=()=>{r.state==="suspended"&&r.resume(),l=window.setInterval(()=>{u.getByteFrequencyData(g);let S=Math.round(g.reduce((v,_)=>v+_)/g.length);S=Math.min(100,S),p=S,h&&h(S)},d)};return b(),{updateInterval:S=>{m(),d=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 Fa 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 ja{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 za="customVideoProfile",Wa="customScreenProfile",Mr={width:1280,height:720,frameRate:30,maxBitrate:2e3},Ka={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||{}),dt=(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))(dt||{});function $a(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(U.ERR_INVALID_ARGUMENTS,"element should be HtmlVideoElement")}throw new O(U.ERR_INVALID_ARGUMENTS,"element not founded")}throw new O(U.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($a(t))}catch(i){}});else if(typeof s=="string"||((e=s==null?void 0:s.nodeName)==null?void 0:e.toLowerCase())==="video")try{a.push($a(s))}catch(t){}return a}function xt(s){return new Promise(a=>setTimeout(a,s))}function Ja(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 Lr(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([xt(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)})},At=s=>{Promise.race([xt(100),s._playPromise||Promise.resolve()]).catch(()=>{}).then(()=>{s.srcObject=null,s._playPromise=void 0})};var xr=(s=>(s[s.AliEngineDataMsgNone=0]="AliEngineDataMsgNone",s[s.AliEngineDataMsgMusicProgress=1]="AliEngineDataMsgMusicProgress",s[s.AliEngineDataMsgCustom=2]="AliEngineDataMsgCustom",s))(xr||{});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,h=15&e.getUint8(1),l=e.getUint16(2);return new bi(l,t,n,i,r,c,o,h)}}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 Vr=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 Vt{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 Vt(c,Vr(i),Vr(n),Vr(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=(kt=class extends Fa{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",ht());f(this,"signalingManager");f(this,"shouldPublish",!1);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",h=>{this.onTrackEnd(h)}),this.streamManager.on("publishupdate",()=>{this.publishUpdate()}),this.audioPubState=new vi,this.audioPubState.on("change",(h,l,d)=>{this.emit("audioPublishStateChanged",h,l,d)}),this.videoPubState=new vi,this.videoPubState.on("change",(h,l,d)=>{this.emit("videoPublishStateChanged",h,l,d)}),this.videoSmallPubState=new vi,this.videoSmallPubState.on("change",(h,l,d)=>{this.emit("dualStreamPublishStateChanged",h,l,d)}),this.screenPubState=new vi,this.screenPubState.on("change",(h,l,d)=>{this.emit("screenPublishStateChanged",h,l,d)}),this.dataPubState=new vi,this.dataPubState.on("change",(h,l,d)=>{this.emit("dataPublishStateChanged",h,l,d)}),this.startStreamMonitor()}get url(){return this._url}set url(e){this._url=e,this.rtsManager.updateAuth(e)}set preferredPubL1Ip(e){this.rtsManager.preferredPubL1Ip=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(za,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(Wa,e)})}setCameraDirection(e){if(e===mi.CAMERA_FRONT)this.streamManager.setCameraVideoConstraints({facingMode:"user"});else{if(e!==mi.CAMERA_REAR)throw new O(U.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=ht()}clearPublishState(){this.streamTracks=void 0}leave(){return T(this,null,function*(){this.shouldPublish=!1,this.isPublishing&&(yield this.unPublish()),this.joinTime=0,this.dc=void 0})}clear(){return T(this,null,function*(){qr(kt.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)&&(At(e),this.previewElements.splice(this.previewElements.indexOf(e),1)),this.screenPreviewElements.includes(e)&&(At(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=U.ERR_CAMERA_OPEN_FAIL;throw c===gi.ERROR_DEVICE_AUDIODEVICE_NOTFOUND?o=U.ERR_CAMERA_NOT_AVAILABLE:c===gi.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED&&(o=U.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=U.ERR_MIC_OPEN_FAIL;throw n===gi.ERROR_DEVICE_AUDIODEVICE_NOTFOUND?c=U.ERR_MIC_NOT_AVAILABLE:n===gi.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED&&(c=U.ERR_MIC_AUTH_FAIL),new O(c,`mic open fail: ${r.message}`)}})}setViewConfig(e,t){if(e){if(![oe.AliRtcVideoTrackCamera,oe.AliRtcVideoTrackScreen].includes(t))throw new O(U.ERR_INVALID_ARGUMENTS,"set view config invalid track",{track:t});e.forEach(i=>{this.setPreviewElement({videoElement:i,screen:t===oe.AliRtcVideoTrackScreen})})}else t===oe.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(U.ERR_INVALID_ARGUMENTS,"no video element found",{videoElement:t});return r?(Ga(t,r.mediaStream),this.setPreviewElement(e),r.mediaStream):void V.info(`[${kt.logName}]`,"preview no stream founded")}catch(r){const n=U.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),At(t);else{const c=this.screenPreviewElements.findIndex(o=>o===t);c>=0&&(this.screenPreviewElements.splice(c,1),At(t))}}else i&&(this.previewElements.forEach(n=>{At(n)}),this.previewElements=[]),r&&(this.screenPreviewElements.forEach(n=>{At(n)}),this.screenPreviewElements=[])}resumePublish(){return T(this,null,function*(){this.shouldPublish&&(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];At(r)}else if(e.screen)for(let i=0;i<this.screenPreviewElements.length;i++){const r=this.screenPreviewElements[i];At(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(U.ERR_INNER,"publishDataError")))}catch(e){V.error("[LocalUser]","publishDataChannel error",e),this.dataPubState.setState(ie.AliRtcStateNoPublish)}}})}startPublish(){return T(this,arguments,function*(e=!1,t=bt.MANUAL){var h;if(console.log("======",this.joined),!this.joined)return;this.shouldPublish=!0;const i=this.streamManager.publishStreams,{audio:r,video:n,videoSmall:c,screen:o}=i;if(r||n||c||o){this.createCallId();try{const l=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:d,l1ip:p}=yield this.publishPromise;this.streamTracks=this.rtsManager.publishingTracks,this.traceId=d;const u={type:Dt.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:d};(h=this.parameter.data)!=null&&h.enablePubDataChannel&&this.publishDataChannel().then(()=>{this.syncPublishToRoomServer(u,i,l)}),r&&(this.trackTraceIdMap[M.Audio]=d,this.reportAudioProfile()),c&&(this.trackTraceIdMap[M.VideoSmall]=d),n&&(this.trackTraceIdMap[M.VideoLarge]=d,this.reportVideoProfile()),o&&(this.trackTraceIdMap[M.Screen]=d,this.reportScreenProfile()),yield this.syncPublishToRoomServer(u,i,l),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(l){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),l}}else V.event(`[${kt.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,h,l,d;if(!this.shouldPublish)return;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=(h=this.streamTracks)==null?void 0:h.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((l=this.parameter.data)!=null&&l.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:Dt.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}}}(d=this.parameter.data)!=null&&d.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(U.ERR_INNER,"sync publish to room server failed because no publishInfo");let r=e;if(this.dc){const c=e,{tracks:h}=c,l=Qt(c,["tracks"]);r=Pt(X({},l),{tracks:[...h,{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(U.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,h=(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),h&&this.screenPubState.setState(ie.AliRtcStatePublishing);try{const l=yield this.rtsManager.publishAdd(this.url,e,this.callId,t,!1,!0);n&&(this.audioPubState.setState(ie.AliRtcStatePublished),this.reportAudioProfile(),this.trackTraceIdMap[M.Audio]=l),c&&(this.videoPubState.setState(ie.AliRtcStatePublished),this.reportVideoProfile(),this.trackTraceIdMap[M.VideoLarge]=l),o&&(this.videoSmallPubState.setState(ie.AliRtcStatePublished),this.trackTraceIdMap[M.VideoSmall]=l),h&&(this.screenPubState.setState(ie.AliRtcStatePublished),this.reportScreenProfile(),this.trackTraceIdMap[M.Screen]=l),this.streamTracks=this.rtsManager.publishingTracks;const d={type:Dt.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:l};return this.reportSelfDeviceStatus(),this.monitorTimerId||this.startStreamMonitor(),d}catch(l){let d=U.ERR_SDK_PUBLISH_INVAILD;if(n&&(this.audioPubState.setState(ie.AliRtcStateNoPublish),d=U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED),c&&(this.videoPubState.setState(ie.AliRtcStateNoPublish),d=U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED),o&&(this.videoSmallPubState.setState(ie.AliRtcStateNoPublish),d=U.ERR_SDK_PUBLISH_DUAL_STREAM_FAILED),h&&(this.screenPubState.setState(ie.AliRtcStateNoPublish),d=U.ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED),l.errorCode===15006&&r<3)return this.publishAdd(e,t,i,r+1);throw O.fromError(l,d,"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:Dt.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,U.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:Dt.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,U.ERR_INNER,"publish delete tracks failed")}})}publishStop(){return T(this,null,function*(){V.info(`[${kt.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:Dt.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,U.ERR_INNER,"publish stop failed")}})}unPublish(){return T(this,null,function*(){this.shouldPublish=!1;const e=new Date().getTime();let t={type:Dt.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,U.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),ja.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(h=>{h.type==="media-source"||h.type==="media-playout"?h.id&&(this.pcMediaStatsMap[h.id]=h):h.type==="candidate-pair"&&h.state==="succeeded"&&(n=h)}),((e=this.candidateDataCache)==null?void 0:e.length)>0){const h=this.candidateDataCache[this.candidateDataCache.length-1]||{},t=h,{_last:l}=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(h=>{var l;return((l=this.monitorDataCache[h])==null?void 0:l.length)>0});(this.streamTracks||[]).forEach(h=>{const l=h.msid;if(!l)return;let d;o.includes(l)&&(o=o.filter(p=>p!==l)),d=l===M.Audio?this.rtsManager.getPublishAudioStats(this.url):this.rtsManager.getPublishVideoStats(this.url,l),d.then(p=>{if(!p.timestamp)return;this.monitorDataCache[l]||(this.monitorDataCache[l]=[]);const u=this.getMediaStats(p.mediaSourceId);p._source=u;const g=this.monitorDataCache[l];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(l),p._last=m,p._codec=h.codec||"",this.monitorDataCache[l].push(p)})}),o.forEach(h=>{this.reportPublishMonitor(h)})}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(U.ERR_INNER,"data channel publish is not enabled");if(!this.dc)throw new O(U.ERR_INNER,"data channel is not ready");const t=function(r,n){let c=0;const o=[];for(;c<r.byteLength;){const h=Math.min(n,r.byteLength-c),l=r.slice(c,c+h);o.push(l),c+=h}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:oe.AliRtcVideoTrackCamera,streamType:We.AliRtcVideoStreamTypeHigh,stats:n})}if(this.hasCameraDualTrackInMS){const n=yield this.rtsManager.getPublishVideoStats(this.url,M.VideoSmall);n&&t.push({track:oe.AliRtcVideoTrackCamera,streamType:We.AliRtcVideoStreamTypeLow,stats:n})}if(this.hasScreenTrackInMS){const n=yield this.rtsManager.getPublishVideoStats(this.url,M.Screen);n&&t.push({track:oe.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(kt,"logName","LocalUser"),kt);Ce([C()],Ie.prototype,"clearPublishState",1),Ce([C()],Ie.prototype,"clear",1),Ce([C(B)],Ie.prototype,"startDefaultCamera",1),Ce([C(B)],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(B)],Ie.prototype,"startPublish",1),Ce([C()],Ie.prototype,"updateStreams",1),Ce([C(B)],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(B)],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 Ot=(s=>(s.OPUS="opus",s.H264="H264",s.UNKNOWN="",s))(Ot||{}),ce=(s=>(s[s.NotSubscribe=0]="NotSubscribe",s[s.Subscribing=1]="Subscribing",s[s.Subscribed=2]="Subscribed",s))(ce||{}),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:ce.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Ot.UNKNOWN});f(this,"videoLargeInfo",{subscribeState:ce.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Ot.UNKNOWN});f(this,"videoSmallInfo",{subscribeState:ce.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Ot.UNKNOWN});f(this,"screenInfo",{subscribeState:ce.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Ot.UNKNOWN});f(this,"dataInfo",{subscribeState:ce.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:Ot.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===ce.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===ce.Subscribed}get isAudioSubscribing(){return this.audioInfo.subscribeState===ce.Subscribing}get isVideoSubscribed(){return this.isVideoLargeSubscribed||this.isVideoSmallSubscribed}get isVideoSubscribing(){return this.isVideoLargeSubscribing||this.isVideoSmallSubscribing}get isVideoLargeSubscribed(){return this.videoLargeInfo.subscribeState===ce.Subscribed}get isVideoLargeSubscribing(){return this.videoLargeInfo.subscribeState===ce.Subscribing}get isVideoSmallSubscribed(){return this.videoSmallInfo.subscribeState===ce.Subscribed}get isVideoSmallSubscribing(){return this.videoSmallInfo.subscribeState===ce.Subscribing}get isScreenSubscribed(){return this.screenInfo.subscribeState===ce.Subscribed}get isScreenSubscribing(){return this.screenInfo.subscribeState===ce.Subscribing}get isDataSubscribed(){return this.dataInfo.subscribeState===ce.Subscribed}get isDataSubscribing(){return this.dataInfo.subscribeState===ce.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:Ot.UNKNOWN}get audioTrackInfo(){return this.hasAudio?ri.AliRtcAudioTrackMic:ri.AliRtcAudioTrackNo}get videoTrackInfo(){return this.hasVideo&&this.hasScreen?oe.AliRtcVideoTrackBoth:this.hasVideo?oe.AliRtcVideoTrackCamera:this.hasScreen?oe.AliRtcVideoTrackScreen:oe.AliRtcVideoTrackNo}updateTracks(e){let t="",i="",r="",n="",c="";return e?(e.forEach(o=>{var p;let h=Ot.UNKNOWN;const l=((p=o==null?void 0:o.attr)==null?void 0:p.reason)==="reconnect";if(o.userdata){const{codec:u}=JSON.parse(o.userdata);u&&(h=u)}var d;(d=o.msid)===M.Audio||d===hr.Audio?(t=o.ssrc,this.audioInfo.msid=o.msid,this.audioInfo.codec=h,(l||this.audioInfo.ssrc!==t)&&(this.audioInfo.subscribeState=ce.NotSubscribe)):(u=>u===M.VideoSmall)(o.msid)?(r=o.ssrc,this.videoSmallInfo.msid=o.msid,this.videoSmallInfo.codec=h,(l||this.videoSmallInfo.ssrc!==r)&&(this.videoSmallInfo.subscribeState=ce.NotSubscribe)):(u=>u===M.VideoLarge||u===hr.VideoLarge)(o.msid)?(i=o.ssrc,this.videoLargeInfo.msid=o.msid,this.videoLargeInfo.codec=h,(l||this.videoLargeInfo.ssrc!==i)&&(this.videoLargeInfo.subscribeState=ce.NotSubscribe)):(u=>u===M.Screen)(o.msid)?(n=o.ssrc,this.screenInfo.msid=o.msid,this.screenInfo.codec=h,(l||this.screenInfo.ssrc!==n)&&(this.screenInfo.subscribeState=ce.NotSubscribe)):(u=>u===M.Data)(o.msid)&&(c=o.ssrc,this.dataInfo.msid=o.msid,this.dataInfo.codec=h,(l||this.dataInfo.ssrc!==c)&&(this.dataInfo.subscribeState=ce.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=ce.Subscribing),e.vMsid!==this.videoLargeInfo.msid&&e.vMsid||(this.videoLargeInfo.subscribeState=ce.Subscribing)),e.screen&&(this.screenInfo.subscribeState=ce.Subscribing),e.audio&&(this.audioInfo.subscribeState=ce.Subscribing),e.data&&(this.dataInfo.subscribeState=ce.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?ce.Subscribed:ce.NotSubscribe),e.vMsid!==this.videoLargeInfo.msid&&e.vMsid||(this.videoLargeInfo.subscribeState=e.video?ce.Subscribed:ce.NotSubscribe)),e.screen!==void 0&&(this.screenInfo.subscribeState=e.screen?ce.Subscribed:ce.NotSubscribe),e.audio!==void 0&&(this.audioInfo.subscribeState=e.audio?ce.Subscribed:ce.NotSubscribe),e.data!==void 0&&(this.dataInfo.subscribeState=e.data?ce.Subscribed:ce.NotSubscribe),{audioInfo:this.audioInfo,videoLargeInfo:this.videoLargeInfo,videoSmallInfo:this.videoSmallInfo,screenInfo:this.screenInfo,dataInfo:this.dataInfo}}updateRemoteUserDeviceStatus(e){let t=ja.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 Fa{constructor(e){var u;const{userId:t,displayName:i,rtsManager:r,usersViewMap:n,slsReporter:c,signalingManager:o,localUser:h,audioVolumeIndicationInterval:l,playoutVolume:d,parameter:p}=e;super(t,i,r,l);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 h=0;h<this.dcMsgWaitingPieces.length;h++){const l=this.dcMsgWaitingPieces[h];new Uint8Array(c,o,l.byteLength).set(new Uint8Array(l)),o+=l.byteLength}new Uint8Array(c,o,t.body.byteLength).set(new Uint8Array(t.body)),i=Vt.parse(c)}catch(c){}this.dcMsgWaitingPieces=[],i||(i=Vt.parse(t.body))}else i=Vt.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,U.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=h,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=d}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!==oe.AliRtcVideoTrackScreen&&t!==oe.AliRtcVideoTrackCamera)throw new O(U.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===oe.AliRtcVideoTrackScreen?this.viewMap.screenViews.push(i):this.viewMap.cameraViews.push(i),this.play(i,t===oe.AliRtcVideoTrackScreen)}):(this.stopPlayAll(t===oe.AliRtcVideoTrackScreen),t===oe.AliRtcVideoTrackScreen?this.viewMap.screenViews=[]:this.viewMap.cameraViews=[])}clear(e=!0){return T(this,null,function*(){var t;this.subscribeStopDataChannel(),e&&this.doStopSubscribe(this.streamUrl),qr(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:h,video:l,vMsid:d}=c,p=[];(l||h)&&p.push({audio:h,video:l,vMsid:d}),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,h,l;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 d=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=d.traceId||"";const{stream:p}=d;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(((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,0,"",u,{pctid:this.rtsManager.pcTraceId,subtid:n,ajsub:t===Se.Join?1:0,url:this.streamUrl,est:r}),this.startStreamMonitor()}catch(d){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),d&&(d.message=`user(${this.uid}) subscribe error, ${(d==null?void 0:d.message)||""}`);let u=U.ERR_INNER;e.audio&&(u=U.ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED),e.video&&(u=e.vMsid===M.VideoSmall?U.ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED:U.ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED),e.screen&&(u=U.ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED),this.slsReporter.reportSubscribe(((l=this.localUser)==null?void 0:l.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(d,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(h=>this.subscribeDeleteProxy(h))),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,U.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!==oe.AliRtcVideoTrackCamera&&e!==oe.AliRtcVideoTrackBoth?e&&e!==oe.AliRtcVideoTrackScreen&&e!==oe.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 h={callid:t,remoteCallid:i,remoteStream:this.stream};return this.callId="",h}catch(h){if(((o=(c=(n=(r=h==null?void 0:h.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(h,U.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,U.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,h,l;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=((h=this.streamInfo.getVideoLargeInfo())==null?void 0:h.msid)||M.VideoLarge)),this.wantSubScreen&&((l=this.streamInfo)!=null&&l.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,h,l,d,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=((h=this.streamInfo.getAudioInfo())==null?void 0:h.msid)||M.Audio),this.wantSubVideo&&((l=this.streamInfo)!=null&&l.hasVideo)?(this.defaultVideoStreamType===We.AliRtcVideoStreamTypeLow&&!this.isVideoSmallSubscribing&&((d=this.streamInfo)!=null&&d.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===oe.AliRtcVideoTrackScreen?this.screenStream:this.stream)==null?void 0:n.mediaStream;e.srcObject===r&&this.play(e,t===oe.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?oe.AliRtcVideoTrackScreen:oe.AliRtcVideoTrackCamera)})}stopPlayAll(e=!1){e?this.viewMap.screenViews.forEach(t=>{At(t)}):this.viewMap.cameraViews.forEach(t=>{At(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 h=yield this.rtsManager.getSubscribeAudioStats(this.streamUrl);h&&e.push({uid:this.uid,track:ri.AliRtcAudioTrackMic,stats:h})}const t=[];if((i=this.streamInfo)!=null&&i.isVideoLargeSubscribed){const h=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((r=this.streamInfo.getVideoLargeInfo())==null?void 0:r.msid)||M.VideoLarge);h&&t.push({uid:this.uid,track:oe.AliRtcVideoTrackCamera,streamType:We.AliRtcVideoStreamTypeHigh,stats:h})}if((n=this.streamInfo)!=null&&n.isVideoSmallSubscribed){const h=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((c=this.streamInfo.getVideoSmallInfo())==null?void 0:c.msid)||M.VideoSmall);h&&t.push({uid:this.uid,track:oe.AliRtcVideoTrackCamera,streamType:We.AliRtcVideoStreamTypeLow,stats:h})}if(this.isScreenSubscribing){const h=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((o=this.streamInfo.getScreenInfo())==null?void 0:o.msid)||M.Screen);h&&t.push({uid:this.uid,track:oe.AliRtcVideoTrackScreen,stats:h})}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 d;if(!c.timestamp)return;this.monitorDataCache[i]||(this.monitorDataCache[i]=[]);const o=this.monitorDataCache[i];let h;if((o==null?void 0:o.length)>0){const p=o[o.length-1]||{},l=p,{_last:u}=l;h=Qt(l,["_last"])}(o==null?void 0:o.length)>=30&&this.reportSubscribeMonitor(i),c._last=h,c._codec=t.codec,n&&(c._source=(d=this.localUser)==null?void 0:d.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(B)],Ke.prototype,"subscribe",1),Je([C()],Ke.prototype,"subscribeProxy",1),Je([C(B)],Ke.prototype,"subscribeDeleteProxy",1),Je([C()],Ke.prototype,"restore",1),Je([C(B)],Ke.prototype,"resumeAudio",1),Je([C(B)],Ke.prototype,"stopSubscribe",1),Je([C(B)],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 Ut=(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))(Ut||{});class rc extends se{constructor(){super(...arguments);f(this,"plugins",new Map)}add(e,t){if(this.plugins.has(e.name))throw new O(Ut.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(Ut.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",{});f(this,"preferredPubL1Ip");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 h=Date.now(),{publishStream:l,videoSmallStream:d,screenStream:p,vMsid:u}=yield this.localStreamManager.createHTTPPublishStream();if(!l)return V.warn(`[${Fe.logName}]`,"publishStream is null"),{traceId:"",l1ip:o};const g=this.getPubMsid(l,{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=!l.hasVideo,b=u,S="";this.startConnect();const v=Date.now();try{S=yield this.rts.publish(Lr(e,this.preferredPubL1Ip),l,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,l.hasVideo&&(!u||u===M.VideoLarge),l.hasVideo&&u===M.VideoSmall,l.hasVideo&&u===M.Screen,l.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,l.hasVideo&&(!u||u===M.VideoLarge),l.hasVideo&&u===M.VideoSmall,l.hasVideo&&u===M.Screen,l.hasAudio,0,S,S,v),this.slsReporter.reportConnectionLatencyEvent(ot.HANDLE_PUB_TASK,dt.START,t,S,h),this.slsReporter.reportConnectionLatencyEvent(ot.HANDLE_PUB_TASK,dt.END,t,S,Date.now());try{const y=Date.now();return this._pcTraceId=S,this.setConnected(!0),this._publishingTracks=this.rts.getPublishTrackInfoList(),d&&(yield this.publishAdd(e,d,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([xt(1e3),((r,n)=>{let c=0;const o=()=>(t?this.rts.getPublishAudioStats(e,i):this.rts.getPublishVideoStats(e,i)).then(h=>!(h.bytesSent>0)&&c<r?(c++,new Promise(l=>setTimeout(()=>l(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(h,l,d,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 Ja(E=>T(this,null,function*(){return E>0&&V.event(`[${Fe.logName}]`,`publishAdd retry times: ${E}`),this.isConnected?(yield this.dcConnectingPromise,console.log("========","publishAdd",{streamUrl:e,stream:t,publishConfig:g}),this.rts.publishAdd([X({url:e,stream:t,updateSourceStream:!1},g)])):Promise.reject(new O(U.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 h,l,d,p,u,g,m,b;yield this.dcConnectingPromise;const i=(l=(h=this.publishingTracks)==null?void 0:h.find(({msid:S})=>S===M.Audio))==null?void 0:l.msid,r=(p=(d=this.publishingTracks)==null?void 0:d.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{console.log("========","publishReplaceTracks",{streamUrl:e,stream:t,vMsid:r,aMsid:n});const h=yield this.rts.publishReplaceTracks([{url:e,stream:t,vMsid:r,aMsid:n}]),[l]=h;return this.updatePublishingTracks(l.trackInfoList),((o=(c=l==null?void 0:l.trackInfoList)==null?void 0:c[0])==null?void 0:o.trackId)||""}catch(h){throw O.fromRtsError(h)}})}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:Lr(e,this.preferredPubL1Ip),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,h,l,d,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),(l=(h=this.parameter)==null?void 0:h.net)==null?void 0:l.mediaTimeout){const u=(p=(d=this.parameter)==null?void 0:d.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(Lr(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,h;const{remoteUser:t,options:i}=e,r=Pt(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 Ja(l=>T(this,null,function*(){return yield this.dcConnectingPromise,l>0&&V.event(`[${Fe.logName}]`,`subscribeAdd retry times: ${l}`),this.isConnected?this.rts.subscribeAdd([r]):Promise.reject()}),5,0,l=>(l==null?void 0:l.errorCode)===15006))[0]}catch(l){if(((h=(o=(c=(n=l==null?void 0:l.extraInfo)==null?void 0:n.parsedData)==null?void 0:c.streams)==null?void 0:o[0])==null?void 0:h.res_code)===508)return this.emit("subscribeexceeds"),null;throw O.fromRtsError(l)}})}subscribeDelete(e){return T(this,null,function*(){var n,c,o,h;const{remoteUser:t,options:i}=e,r=Pt(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(l){if(((h=(o=(c=(n=l==null?void 0:l.extraInfo)==null?void 0:n.parsedData)==null?void 0:c.streams)==null?void 0:o[0])==null?void 0:h.res_code)===404)return;throw O.fromRtsError(l)}})}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,h="";if(this.connecting&&(yield this.connectingPromise),this.connected){yield this.dcConnectingPromise;let l,d=!1;const{audio:p,video:u,videoSmall:g,screen:m}=this.localStreamManager.publishStreams;p&&(h=yield this.publishAdd(e,p,t,{aMsid:M.Audio},i),d=!0,l=M.Audio,yield xt(100)),u&&(h=yield this.publishAdd(e,u,t,{vMsid:M.VideoLarge},i),d=!1,l=M.VideoLarge,yield xt(100)),g&&(h=yield this.publishAdd(e,g,t,{vMsid:M.VideoSmall},i),d=!1,l=M.VideoSmall,yield xt(100)),m&&(h=yield this.publishAdd(e,m,t,{isScreen:!0,vMsid:M.Screen},i),d=!1,l=M.Screen),l&&(yield this.waitPublishSender(e,d,l))}else{const l=yield this.httpPublish(e,t,i,r);h=l.traceId,o=l.l1ip}return{traceId:h,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,dt.START,t,c,i,0,r),this.slsReporter.reportConnectionLatencyEvent(ot.HANDLE_SUB_TASK,dt.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:h}=e;if(o.video&&o.screen)throw new O(U.ERR_INNER,"subscribe error, video and screen cannot be subscribed at the same time");let l;this.connecting&&(yield this.connectingPromise);let d=Date.now();this.connected?l=yield this.subscribeAdd(e):(c=!0,l=yield this.httpSubscribe(e)),this.reportSubscribeLatency(o,i,d,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(h.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(h.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}]`,h.userId,"尝试获取首帧数据失败"),!1)))),Promise.resolve(E)};return A()})(40,100);return _.then(()=>{S&&this.slsReporter.reportSubscribeFirstPacket(t===Se.Resume,i,r,u,{fprt:S-d,ifsprtc:v?v-d:0,ajsub:t===Se.Join?1:0,pctid:this.pcTraceId,subtid:(l==null?void 0:l.traceId)||"",sstc:p-d}),v&&this.slsReporter.reportSubscribeFirstFrame(t===Se.Resume,i,r,u,{fvfrt:v-d,fp2fftc:v-S,ajsub:t===Se.Join?1:0,tffrtc:t===Se.Join?v-this.localJoinTime:v-n,pctid:this.pcTraceId,subtid:(l==null?void 0:l.traceId)||"",fvfdtc:v-d}),b&&(this.slsReporter.reportConnectionLatencyEvent(ot.FIRST_REMOTE,dt.DECODED,i,M.Audio,b),this.slsReporter.reportSubscribeFirstPacket(t===Se.Resume,i,r,M.Audio,{fprt:b-d,ifsprtc:b-d,ajsub:t===Se.Join?1:0,pctid:this.pcTraceId,subtid:(l==null?void 0:l.traceId)||"",sstc:p-d}))}),c&&(yield Promise.race([_,xt(1500)])),l})}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(B)],xe.prototype,"startConnect",1),Be([C()],xe.prototype,"updatePublishingTracks",1),Be([C(B,B)],xe.prototype,"httpPublish",1),Be([C(B,B)],xe.prototype,"waitPublishSender",1),Be([C(([s,a,e])=>[s,JSON.stringify(e)],B)],xe.prototype,"publishAdd",1),Be([C(B,B)],xe.prototype,"publishDelete",1),Be([C(([s,a,e])=>[s,JSON.stringify(e)])],xe.prototype,"publishReplace",1),Be([C(B)],xe.prototype,"publishStop",1),Be([C(B)],xe.prototype,"publishAddDataChannel",1),Be([C(B)],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(B)],xe.prototype,"subscibeStop",1),Be([C(B)],xe.prototype,"subscribeAddDataChannel",1),Be([C(B)],xe.prototype,"subscribeStopDatachannel",1),Be([C(B)],xe.prototype,"publish",1),Be([C(ji)],xe.prototype,"subscribe",1),Be([C()],xe.prototype,"sendSEI",1);let nc=xe;class Or{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 Ur 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,h,l,d,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===Le.AliRtcSdkStreamTypeScreen?this.stop():(r&&((h=this.originVideoTrack)==null||h.stop()),n&&((l=this.originAudioTrack)==null||l.stop())),r&&(this.originVideoTrack=r,(d=this.originVideoTrack)==null||d.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,h,l,d,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?((l=(h=this._publishDualVideoStream)==null?void 0:h.videoTrack)==null?void 0:l.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=(d=this._publishAudioStream)==null?void 0:d.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 Or(this.type===Le.AliRtcSdkStreamTypeScreen?Ka:Mr)),e&&this._profileManager.updateProfile(e,t),yield this._profileManager.setVideoProfile(this.originVideoTrack,this._publishVideoStream,i)})}get videoProfile(){var e;return(e=this.profileManager)==null?void 0:e.videoProfile}setVideoContentHint(e){this._profileManager||(this._profileManager=new Or(this.type===Le.AliRtcSdkStreamTypeScreen?Ka:Mr)),this._profileManager.setContentHint(this.currentVideoTrack,e)}updateAudioProfile(e){return T(this,null,function*(){this._profileManager||(this._profileManager=new Or),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=(Ht=class extends se{constructor(e,t){super();f(this,"pluginManager");f(this,"slsReporter");f(this,"publishingCameraVideoStream");f(this,"publishingScreenVideoStream");f(this,"cameraStreamInfo",new Ur(Le.AliRtcSdkStreamTypeCapture));f(this,"screenStreamInfo",new Ur(Le.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(`[${Ht.logName}]`,"plugin added",i.name),!i.isSupported("7.1.0"))return console.warn(`${i.name} is not supported!!!`),void i.emit("unsupported");try{yield i.init()}catch(r){i.emit("error",O.fromError(r,Ut.AliRtcPluginErrorInitError))}i.streamType===Le.AliRtcSdkStreamTypeCapture&&(this.cameraStreamInfo.addPlugin(i),yield this.cameraStreamInfo.process(this.streamInfos)),i.streamType===Le.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 d;const{screen:t,mediaStream:i,videoProfile:r,screenProfile:n}=e;let{video:c,audio:o}=e;const h=(p=>{const{audio:u,video:g,screen:m}=p;if(g&&m)throw new O(U.ERR_INNER,"create stream error, cannot create video && screen together");return!!(g||u||m)})(e);let l;if(h){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{l=yield q.AliRTS.createStream({audio:o,video:c,screen:t,custom:!!i,mediaStream:i,skipProfile:!0}),V.info(`[${Ht.logName}]`,"createLocalStream",{audio:o,video:c,screen:t,custom:!!i,time:Date.now()-p}),o&&!i&&this.slsReporter.reportAudio(null,Date.now()-p,((d=l==null?void 0:l.audioTrack)==null?void 0:d.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)console.log("=================","createLocalStream",l),yield this.screenStreamInfo.updateSource(l,ei.Screen,Ei.Screen),yield this.setScreenProfile(n||Wa),this.setScreenContentHint(),this.publishingScreenVideoStream=void 0;else if(yield this.cameraStreamInfo.updateSource(l,ei.Camera,Ei.Microphone),l.hasVideo&&(yield this.setVideoProfile(r||za),this.setVideoContentHint(),this.publishingCameraVideoStream=void 0),l.hasAudio&&typeof o=="boolean"){const u=this.cameraStreamInfo.audioProfile;u&&(yield l.setAudioProfile(u))}}return q.AliRTS.SystenUtil.isIos&&q.AliRTS.SystenUtil.compareVersion("15.1")&&!q.AliRTS.SystenUtil.compareVersion("15.2")&&(yield xt(1e3)),yield this.updateStreams(),l})}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,h,l,d;let e,t,i,r,n=!1;const c=this.publishStreams;try{if(!(c.audio||c.video||c.videoSmall||c.screen))throw V.error(`[${Ht.logName}]`,"no tracks founded"),new O(U.ERR_SDK_PUBLISH_INVAILD,"no tracks founded");const p=new MediaStream;(o=c.audio)!=null&&o.audioTrack&&p.addTrack(c.audio.audioTrack),(h=c.video)!=null&&h.videoTrack?(p.addTrack(c.video.videoTrack),i=c.videoSmall,r=c.screen):(l=c.screen)!=null&&l.videoTrack&&(t=M.Screen,p.addTrack((d=c.screen)==null?void 0:d.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(Ht,"logName","LocalStreamManager"),Ht);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(B)],ut.prototype,"stopLocalStream",1),gt([C()],ut.prototype,"createHTTPPublishStream",1),gt([C()],ut.prototype,"stop",1),gt([C(B)],ut.prototype,"setVideoProfile",1),gt([C(B)],ut.prototype,"setVideoContentHint",1),gt([C(B)],ut.prototype,"setAudioProfile",1),gt([C(B)],ut.prototype,"setScreenProfile",1),gt([C(B)],ut.prototype,"setScreenContentHint",1),gt([C(B)],ut.prototype,"setCameraVideoConstraints",1),gt([C(B)],ut.prototype,"setMicAudioConstraints",1);let hc=ut;class lc extends Nt{constructor(){super("AliRtcScreenStandardize",Le.AliRtcSdkStreamTypeScreen);f(this,"canvas");f(this,"lastWidth");f(this,"lastHeight");f(this,"isProcessingScreenTrack",!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){var i;let t=!1;if(e.originVideoTrack&&e.videoSource===ei.Screen){const r=(i=e.originVideoTrack)==null?void 0:i.getSettings();if(r){const{width:n,height:c}=r;t=!n||!c||!(n%this.options.base===0&&c%this.options.base===0)}}return t!==this.isProcessingScreenTrack}handleFrame(e){return T(this,null,function*(){var n;const{displayWidth:t,displayHeight:i}=e;if(!t||!i||t%this.options.base===0&&i%this.options.base===0)return e;this.updateProcessCanvas(t,i);const r=(n=this.canvas)==null?void 0:n.getContext("2d");if(this.canvas&&r){r.drawImage(e,0,0,t,i);const c=new VideoFrame(this.canvas,{timestamp:e.timestamp});return e.close(),c}return e})}process(e){return T(this,null,function*(){var l;if(!e.originVideoTrack||e.videoSource!==ei.Screen)return this.clear(e),void(this.isProcessingScreenTrack=!1);if(e.originVideoTrack){const d=e.originVideoTrack.getSettings();if(d){const{width:p,height:u}=d;if(!(!p||!u||!(p%this.options.base===0&&u%this.options.base===0)))return void this.clear(e)}}const t=new MediaStreamTrackProcessor({track:e.originVideoTrack}),i=new MediaStreamTrackGenerator({kind:"video"}),r=new MediaStream([i]),n=this,c=new TransformStream({transform(d,p){return T(this,null,function*(){const u=yield n.handleFrame(d);yield p.enqueue(u),u==null||u.close()})}});t.readable.pipeThrough(c).pipeTo(i.writable);const o=(l=r.getVideoTracks())==null?void 0:l[0];e.updateVideoTrack(o),this.isProcessingScreenTrack=!0})}clear(e){this.canvas=void 0,this.lastWidth=void 0,this.lastHeight=void 0,super.clear(e)}}class dc extends Nt{constructor(){super("blankAudio",Le.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 Nt{constructor(){super("audioMixer",Le.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!==Le.AliRtcSdkStreamTypeCapture)return!1;const i=t.find(o=>o.type===Le.AliRtcSdkStreamTypeCapture),r=t.find(o=>o.type===Le.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(h=>h.type===Le.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 Br{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,h=0,l=0;return n>r?(c=Math.round(o/r),h=Math.round((t-c)/2)):n<r&&(o=Math.round(c*r),l=Math.round((i-o)/2)),{x:h,y:l,width:c,height:o}}}class mc extends Br{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 Br{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 h=o.createTexture();return o.bindTexture(o.TEXTURE_2D,h),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),h}(e);const t=function(o,h,l){const d=Qa(o,o.VERTEX_SHADER,h),p=Qa(o,o.FRAGMENT_SHADER,l),u=o.createProgram();if(u&&d&&p)return o.attachShader(u,d),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
|
|
|
@@ -41,7 +41,7 @@ uniform sampler2D u_texture;
|
|
|
41
41
|
void main() {
|
|
42
42
|
gl_FragColor = texture2D(u_texture, v_texCoord);
|
|
43
43
|
}
|
|
44
|
-
`);if(!t)return void console.log("[ScalerWebGL] program is null.");e.useProgram(t);const i=e.getAttribLocation(t,"a_position"),r=e.getAttribLocation(t,"a_texCoord"),
|
|
44
|
+
`);if(!t)return void console.log("[ScalerWebGL] program is null.");e.useProgram(t);const i=e.getAttribLocation(t,"a_position"),r=e.getAttribLocation(t,"a_texCoord"),n=e.getUniformLocation(t,"u_resolution");if(!n)return void console.log("[ScalerWebGL] resolutionLocation is null.");const c=e.getUniformLocation(t,"u_texture");c?(this.locationMap={program:t,positionLocation:i,texCoordLocation:r,resolutionLocation:n,textureLocation:c},this.updateBuffer()):console.log("[ScalerWebGL] textureLocation is null.")}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),this.originVideo.addEventListener("resize",this.updateBuffer)}startRender(){this.cancelAnimation();const e=()=>{this.targetCtx&&(this.renderTexture(),this.originVideo.paused||this.originVideo.ended||(this.animationFrameId=requestAnimationFrame(e)))};e()}updateBuffer(){const e=this.targetCtx,t=this.locationMap.positionLocation,i=this.locationMap.texCoordLocation,r=this.locationMap.resolutionLocation;if(!e||!this.originVideo.videoWidth||!this.originVideo.videoHeight)return;const n=this.getPositionAndSize(this.originVideo.videoWidth,this.originVideo.videoHeight,this.targetWidth,this.targetHeight),c=function(h,l,d,p=0,u=0){const g=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,g);const m=l+p,b=d+u,S=[p,u,m,u,p,b,p,b,m,u,m,b];return h.bufferData(h.ARRAY_BUFFER,new Float32Array(S),h.STATIC_DRAW),g}(e,n.width,n.height,n.x,n.y);e.enableVertexAttribArray(t),e.bindBuffer(e.ARRAY_BUFFER,c),e.vertexAttribPointer(t,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(i);const o=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,o),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,o),e.vertexAttribPointer(i,2,e.FLOAT,!1,0,0),e.uniform2f(r,this.targetWidth,this.targetHeight)}renderTexture(){const e=this.targetTexture,t=this.targetCtx,i=this.locationMap.textureLocation;e&&t&&(t.bindTexture(t.TEXTURE_2D,e),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this.originVideo),t.useProgram(this.locationMap.program),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,e),t.uniform1i(i,0),t.viewport(0,0,t.canvas.width,t.canvas.height),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLES,0,6))}stopRender(){this.cancelAnimation()}updateOptions(e){super.updateOptions(e),this.updateBuffer()}dispose(){this.stopRender(),this.originVideo.removeEventListener("play",this.startRender),this.originVideo.removeEventListener("pause",this.stopRender),this.originVideo.removeEventListener("ended",this.stopRender),this.originVideo.removeEventListener("resize",this.updateBuffer),this.originVideo.pause(),this.originVideo.srcObject=null}}class tn extends Br{constructor(e,t){super(e,t);f(this,"processor");f(this,"trackGenerator");f(this,"worker");this.processor=new MediaStreamTrackProcessor({track:e}),this.trackGenerator=new MediaStreamTrackGenerator({kind:"video"}),this.startTransform()}static isSupport(){return"MediaStreamTrackProcessor"in window&&"MediaStreamTrackGenerator"in window&&"TransformStream"in window&&"VideoFrame"in window}startTransform(){const e=new Blob([`
|
|
45
45
|
var targetOptions={
|
|
46
46
|
width: 320,
|
|
47
47
|
height: 180,
|
|
@@ -126,4 +126,4 @@ onmessage = function(evt) {
|
|
|
126
126
|
break;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
`],{type:"text/javascript"}),t=(window.URL||window.webkitURL).createObjectURL(e);this.worker=new Worker(t);const{readable:i}=this.processor,{writable:r}=this.trackGenerator;this.worker.postMessage({type:"startRender",readable:i,writable:r,width:this.targetWidth,height:this.targetHeight,frameRate:this.targetFrameRate},[i,r])}updateOptions(e){super.updateOptions(e),this.worker&&this.worker.postMessage(Y({type:"updateOptions"},e))}dispose(){try{this.processor.readable.cancel(),this.trackGenerator.writable.close()}catch(e){}}getVideoTrack(){return this.trackGenerator}}class Pr{static isSupport(){return typeof HTMLCanvasElement.prototype.captureStream=="function"}static getInstance(o,e){return Ja.isSupport()?new Ja(o,e):$a.isSupport()?new $a(o,e):new rc(o,e)}}class sc extends Ut{constructor(){super(...arguments);m(this,"hasVideoTrack",!1);m(this,"videoScaler")}get initOptions(){return{width:320,height:180,frameRate:15}}setOptions(e){var t;this.options=e,(t=this.videoScaler)==null||t.updateOptions(e)}isSupported(){return Pr.isSupport()}shouldUpdate(e){return this.hasVideoTrack!==!!e.currentVideoTrack}process(e){return w(this,null,function*(){if(e.currentVideoTrack){if(this.hasVideoTrack=!0,!this.videoScaler){const i=this.options||this.initOptions;this.videoScaler=Pr.getInstance(e.currentVideoTrack,i)}const t=this.videoScaler.getVideoTrack();t&&e.updateDualVideoTrack(t)}else e.updateDualVideoTrack(),this.emit("updated"),this.videoScaler&&this.videoScaler.dispose()})}clear(e){super.clear(e),this.hasVideoTrack=!1,e==null||e.updateDualVideoTrack()}}var Oi=(s=>(s[s.Default=0]="Default",s[s.Human=1]="Human",s[s.Robot=2]="Robot",s))(Oi||{}),ac=Object.defineProperty,nc=Object.getOwnPropertyDescriptor,Ga=(s,o,e,t)=>{for(var i,r=t>1?void 0:t?nc(o,e):o,a=s.length-1;a>=0;a--)(i=s[a])&&(r=(t?i(o,e,r):i(r))||r);return t&&r&&ac(o,e,r),r};const Mr=(Dt=class extends te{constructor(e){super();m(this,"self");m(this,"remoteUser");m(this,"sendReadyMsg",!1);m(this,"hasPubDataChannel",!1);m(this,"hasSubDataChannel",!1);m(this,"readyMsgSuccess",!1);m(this,"sendReadyMsgTimer");m(this,"startReadyMsgTime");m(this,"onSubscribeDataChannel",e=>{!this.remoteUser&&e&&(this.hasSubDataChannel=!0,this.remoteUser=e,this.remoteUser.on("remoteDataChannelMessage",this.onCheckReadyMsg),this.trySendReadyMsg())});m(this,"onCheckReadyMsg",(e,t)=>{var i,r;if(this.sendReadyMsg&&!this.readyMsgSuccess)try{const a=new TextDecoder().decode(t.data),c=JSON.parse(a);c.key==="aliyun_aigc"&&c.type==="ready_resp"&&((i=c.data)==null?void 0:i.ready)===!0&&(x.event(`[${Dt.logName}]`,"onCheckReadyMsg success"),this.readyMsgSuccess=!0,this.emit("dcready",e),(r=this.remoteUser)==null||r.off("remoteDataChannelMessage",this.onCheckReadyMsg),window.clearTimeout(this.sendReadyMsgTimer))}catch(a){}});m(this,"onDataPublishStateChange",(e,t)=>{t===Q.AliRtcStatePublished&&(this.hasPubDataChannel=!0,this.trySendReadyMsg())});this.self=e,this.self.on("dataPublishStateChanged",this.onDataPublishStateChange)}destory(){this.self.off("dataPublishStateChanged",this.onDataPublishStateChange),window.clearTimeout(this.sendReadyMsgTimer),this.remoteUser=void 0,this.sendReadyMsg=!1,this.hasPubDataChannel=!1,this.hasSubDataChannel=!1,this.readyMsgSuccess=!1,this.startReadyMsgTime=0}trySendReadyMsg(){x.event(`[${Dt.logName}]`,`trySendReadyMsg: pub(${this.hasPubDataChannel}, sub: ${this.hasSubDataChannel})`),this.hasPubDataChannel&&this.hasSubDataChannel&&(this.sendReadyMsg=!0,this.sendReadyMsgLoop())}sendReadyMsgLoop(e=0){return w(this,null,function*(){const t=JSON.stringify({key:"aliyun_aigc",version:"1.0",type:"ready_req",data:{ready:!0}});try{this.self.sendDataChannelMessage(new kt(new TextEncoder().encode(t).buffer))}catch(a){}this.startReadyMsgTime||(this.startReadyMsgTime=Date.now());let i=50;const r=Date.now()-this.startReadyMsgTime;i=r<1e3?50:r<2e3?100:r<3e3?500:2e3,e>30?x.event(`[${Dt.logName}]`,"sendReadyMsgLoop fail after 30 times"):this.sendReadyMsgTimer=window.setTimeout(()=>{this.sendReadyMsgLoop(e+1)},i)})}},m(Dt,"logName","DataChannelReadyHelper"),Dt);Ga([C()],Mr.prototype,"destory",1),Ga([C()],Mr.prototype,"sendReadyMsgLoop",1);let oc=Mr;var cc=Object.defineProperty,hc=Object.getOwnPropertyDescriptor,$e=(s,o,e,t)=>{for(var i,r=t>1?void 0:t?hc(o,e):o,a=s.length-1;a>=0;a--)(i=s[a])&&(r=(t?i(o,e,r):i(r))||r);return t&&r&&cc(o,e,r),r};class xe extends te{constructor(e){super();m(this,"self");m(this,"userMap",{});m(this,"usersViewMap",{});m(this,"rtsManager");m(this,"localStreamManager");m(this,"authInfo");m(this,"signalingManager");m(this,"pluginManager");m(this,"audioMixerPlugin");m(this,"dualVideoPlugin");m(this,"blankAudioPlugin");m(this,"slsReporter");m(this,"statsMonitorId");m(this,"autoSubAudio",!0);m(this,"autoSubVideo",!0);m(this,"autoSubScreen",!0);m(this,"wantSubAudio",!0);m(this,"wantSubVideo",!0);m(this,"wantSubScreen",!0);m(this,"defaultStreamType",De.AliRtcVideoStreamTypeHigh);m(this,"audioMuted",!1);m(this,"playoutVolume",1);m(this,"refreshUrlTimer");m(this,"audioVolumeIndicationInterval",0);m(this,"indicationTimer",0);m(this,"parameter",{});m(this,"dcReadyHelper");const{signalingManager:t,slsReporter:i}=e;this.signalingManager=t,this.addSignalingManagerListener(),this.slsReporter=i,this.pluginManager=new $o,this.localStreamManager=new Qo(this.pluginManager,this.slsReporter),this.rtsManager=new qo(this.localStreamManager,this.slsReporter,this.parameter),this.self=new Ho({rtsManager:this.rtsManager,localStreamManager:this.localStreamManager,slsReporter:this.slsReporter,signalingManager:this.signalingManager,pluginManager:this.pluginManager,audioVolumeIndicationInterval:this.audioVolumeIndicationInterval,parameter:this.parameter}),this.audioMixerPlugin=new ic,this.pluginManager.add(this.audioMixerPlugin),this.dualVideoPlugin=new sc("dualVideoPlugin"),new G.AliRTS.SupportUtil().checkScreenCapture()&&this.pluginManager.add(new Zo)}addSignalingManagerListener(){this.signalingManager.on("onNotifyPublish",e=>{e.forEach(t=>{var i;(i=t==null?void 0:t.tracks)==null||i.forEach(r=>{var a;if(r.msid===M.Audio&&r.userdata)try{const c=JSON.parse(r.userdata);c.agent_instance&&((a=this.slsReporter)==null||a.setCustomFields({ageniid:c.agent_instance}))}catch(c){console.error("Failed to parse userdata:",c)}})}),this.slsReporter.reportConnectionLatencyEvent(Ge.RECV_NOTIFY_PUBLISH,"","",""),x.event("[Signaling] Notify Publish ",e),e.forEach(t=>{this.onRemotePublishStateChange(t)})}),this.signalingManager.stsManager.on("onTokenUpdate",(e,t)=>{this.slsReporter.updateToken(t,e)})}isAutoSubAudio(){return this.autoSubAudio}setAutoSubAudio(e){this.autoSubAudio=e}isAutoSubVideo(){return this.autoSubVideo}setAutoSubVideo(e){this.autoSubVideo=e}isAutoSubScreen(){return this.autoSubScreen}setAutoSubScreen(e){this.autoSubScreen=e}isWantSubAudio(){return this.wantSubAudio}setWantSubAudio(e){this.wantSubAudio=e,this.remoteUsers.forEach(t=>{t.setWantSubAudio(e),t.updateSubscribe(de.User)})}isWantSubVideo(){return this.wantSubVideo}setWantSubVideo(e){this.wantSubVideo=e,this.remoteUsers.forEach(t=>{t.setWantSubVideo(e),t.updateSubscribe(de.User)})}isWantSubScreen(){return this.wantSubScreen}setWantSubScreen(e){this.wantSubScreen=e,this.remoteUsers.forEach(t=>{t.setWantSubScreen(e),t.updateSubscribe(de.User)})}setRemoteDefaultVideoStreamType(e){this.defaultStreamType=e,this.remoteUsers.forEach(t=>{t.setRemoteDefaultVideoStreamType(e)})}setRemoteUserVideoStreamType(e,t){var i;(i=this.getRemoteUser(e))==null||i.setRemoteDefaultVideoStreamType(t)}setAudioMuted(e){this.audioMuted=e,this.remoteUsers.forEach(t=>{t.setAudioMuted(e)})}setLocalViewConfig(e,t){var r;if(!e)return(r=this.publisher)==null?void 0:r.setViewConfig(null,t);const i=_r(e);i.length!==0&&i.forEach(a=>{var c,n;(c=this.publisher)==null||c.resetElement(a),Object.values(this.usersViewMap).forEach(({cameraViews:h=[],screenViews:d=[]})=>{h.includes(a)&&h.splice(h.indexOf(a),1),d.includes(a)&&d.splice(d.indexOf(a),1)}),(n=this.publisher)==null||n.setViewConfig(i,t)})}setRemoteViewConfig(e,t,i){var a,c;if(!t)return(a=this.userMap[e])==null?void 0:a.setViewConfig(null,i);const r=_r(t);r.length!==0&&(r.forEach(n=>{var h;(h=this.publisher)==null||h.resetElement(n),Object.values(this.usersViewMap).forEach(({cameraViews:d=[],screenViews:u=[]})=>{d.includes(n)&&d.splice(d.indexOf(n),1),u.includes(n)&&u.splice(u.indexOf(n),1)})}),(c=this.userMap[e])==null||c.setViewConfig(r,i))}get channel(){var e;return(e=this.authInfo)==null?void 0:e.channelId}get userId(){var e;return(e=this.authInfo)==null?void 0:e.userId}get remoteUsers(){return Object.values(this.userMap)}get publisher(){return this.self}get isSubscribing(){var e;return((e=this.remoteUsers)!=null?e:[]).some(t=>{const{isAudioSubscribing:i,isVideoSubscribing:r,isScreenSubscribing:a}=t;return i||r||a})}onRemotePublishStateChange(e){var f;const{userid:t,callid:i,subscribe:r,pubid:a="",tracks:c}=e,n=(f=r==null?void 0:r.pullstreamurl)!=null?f:"";let h=this.getRemoteUser(t);if(!h)return;const d=h.streamInfo.audioTrackInfo,u=h.streamInfo.videoTrackInfo;h.updateRemoteTracks(i,n,a,c),h.updateSubscribe(de.Publish),d===h.streamInfo.audioTrackInfo&&u===h.streamInfo.videoTrackInfo||this.emit("remoteTrackAvailableChange",t,h.streamInfo.audioTrackInfo,h.streamInfo.videoTrackInfo)}setTimeoutToUpdateAllStreamUrls(e){var r;if(!e)return;let t=354e4;const i=(r=function(a){var c,n;try{const h=new URL(a),[d,u]=h.pathname.slice(1).split("/"),f=/(\w+)(web\w{5}-\w{4}-\w{4}-\w{4}-\w{12})/.exec(u),l=f==null?void 0:f[1],g=f==null?void 0:f[2],p=new URLSearchParams(h.search);return{appId:d,channelId:l,sessionId:g,timeoutTs:1e3*parseInt((n=(c=p.get("auth_key"))==null?void 0:c.split("-")[0])!=null?n:"0")}}catch(h){return null}}(e))==null?void 0:r.timeoutTs;i&&(t=i-Date.now()-6e4),this.refreshUrlTimer=window.setTimeout(()=>w(this,null,function*(){var c;const a=yield this.signalingManager.refreshUrl({pushstreamurl:this.self.url,users:this.remoteUsers.map(n=>({userid:n.userId,subscribe:{pullstreamurl:n.streamUrl}}))});a.pushstreamurl&&(this.self.url=a.pushstreamurl),(c=a.users)==null||c.forEach(n=>{var d;const h=this.getRemoteUser(n.userid);h&&((d=n.subscribe)!=null&&d.pullstreamurl)&&(h.streamUrl=n.subscribe.pullstreamurl)}),this.setTimeoutToUpdateAllStreamUrls(a.pushstreamurl)}),t)}init(e,t,i){this.authInfo=e,this.self.enableAudioVolumeIndication(this.audioVolumeIndicationInterval),this.self.initInfo(e,t.pushstreamurl),i.capabilityProfile===Oi.Human&&(this.dcReadyHelper=new oc(this.self),this.dcReadyHelper.on("dcready",r=>{var a;this.emit("remoteUserSubscribedDataChannel",r),(a=this.dcReadyHelper)==null||a.destory(),this.dcReadyHelper=void 0})),this.setTimeoutToUpdateAllStreamUrls(t.pushstreamurl),t.users.forEach(r=>{const a=r.userid;if(a){const c=this.addUser(a,r.displayname,de.InRoom);this.emit("remoteUserJoin",a,0);const{callid:n,subscribe:h,tracks:d}=r;c.updateRemoteTracks(n,(h==null?void 0:h.pullstreamurl)||"","",d),this.emit("remoteTrackAvailableChange",a,c.streamInfo.audioTrackInfo,c.streamInfo.videoTrackInfo)}}),this.startStatsMonitor()}leave(){return w(this,null,function*(){var e;this.stopStatsMonitor(),this.refreshUrlTimer!==void 0&&(window.clearTimeout(this.refreshUrlTimer),this.refreshUrlTimer=void 0),Object.values(this.usersViewMap).forEach(({cameraViews:t=[],screenViews:i=[]})=>{t.forEach(r=>{r.srcObject=null,r._playPromise=void 0}),i.forEach(r=>{r.srcObject=null,r._playPromise=void 0})}),this.usersViewMap={};for(let t in this.userMap)this.userMap[t]&&(this.userMap[t].clear(),delete this.userMap[t]);this.self.leave(),(e=this.dcReadyHelper)==null||e.destory(),this.dcReadyHelper=void 0,this.localStreamManager.stop(),this.rtsManager.clear(),this.authInfo=void 0})}clear(){return w(this,null,function*(){yield this.leave(),this.self.clear(),this.pluginManager.removeAll()})}startStatsMonitor(){this.statsMonitorId=window.setInterval(()=>w(this,null,function*(){if(this.publisher){const{audio:i,video:r,candidate:a}=yield this.publisher.getStats();i&&i.length>0&&this.emit("rtcLocalAudioStats",i),r&&r.length>0&&this.emit("rtcLocalVideoStats",r),a&&this.emit("rtcStats",a)}const e=[],t=[];for(const i of this.remoteUsers){const{audio:r,video:a}=yield i.getStats();r&&r.forEach(c=>{e.push(c)}),a&&a.forEach(c=>{t.push(c)})}e.length>0&&this.emit("rtcRemoteAudioStats",e),t.length>0&&this.emit("rtcRemoteVideoStats",t)}),2e3)}stopStatsMonitor(){this.statsMonitorId&&clearInterval(this.statsMonitorId)}addUser(e,t,i){return this.userMap[e]||(this.userMap[e]=this.executeAddUser(e,t,i)),this.userMap[e]}executeAddUser(e,t,i){const r=new Wo({userId:e,displayName:t,rtsManager:this.rtsManager,signalingManager:this.signalingManager,usersViewMap:this.usersViewMap,slsReporter:this.slsReporter,localUser:this.self,audioVolumeIndicationInterval:this.audioVolumeIndicationInterval,playoutVolume:this.playoutVolume,parameter:this.parameter});return r.on(Be.Remote,this.onRemoteDeviceStatusChange.bind(this)),r.on(pe.PullStreamStats,this.onRemoteStatReport.bind(this)),r.on(pe.RtsSubscribeExceeds,this.onSubscribeExceeds.bind(this)),r.on("audioSubscribeStateChanged",(a,c,n,h)=>{this.emit("audioSubscribeStateChanged",a,c,n,h,this.channel||"")}),r.on("videoSubscribeStateChanged",(a,c,n,h)=>{this.emit("videoSubscribeStateChanged",a,c,n,h,this.channel||"")}),r.on("screenSubscribeStateChanged",(a,c,n,h)=>{this.emit("screenSubscribeStateChanged",a,c,n,h,this.channel||"")}),r.on("dataSubscribeStateChanged",(a,c,n,h)=>{var d;n===ce.AliRtcStateSubscribed&&((d=this.dcReadyHelper)==null||d.onSubscribeDataChannel(this.userMap[a])),this.emit("dataSubscribeStateChanged",a,c,n,h,this.channel||"")}),r.on("remoteAudioAutoPlayFail",a=>{this.emit("remoteAudioAutoPlayFail",a)}),r.on("remoteVideoAutoPlayFail",(a,c)=>{this.emit("remoteVideoAutoPlayFail",a,c)}),r.on("remoteAudioPlayError",(a,c)=>{this.emit("remoteAudioPlayError",a,c)}),r.on("remoteVideoPlayError",(a,c)=>{this.emit("remoteVideoPlayError",a,c)}),r.on("remoteSubscribeError",a=>{this.emit("remoteSubscribeError",a,r.userId)}),r.on("occurError",a=>{this.emit("occurError",a,r.userId)}),r.on("remoteDataChannelMessage",(a,c)=>{this.emit("remoteDataChannelMessage",a,c)}),r.setWantSubAudio(this.autoSubAudio&&this.wantSubAudio),r.setWantSubVideo(this.autoSubVideo&&this.wantSubVideo),r.setWantSubScreen(this.autoSubScreen&&this.wantSubScreen),r.setRemoteDefaultVideoStreamType(this.defaultStreamType),r.setAudioMuted(this.audioMuted),(this.autoSubAudio||this.autoSubVideo||this.autoSubScreen)&&r.updateSubscribe(i),r}onRemoteDeviceStatusChange(e,t){e===pe.MuteAudio?this.emit("userAudioMuted",t,!0):e===pe.UnmuteAudio?this.emit("userAudioMuted",t,!1):e===pe.MuteVideo?this.emit("userVideoMuted",t,!0):e===pe.UnmuteVideo?this.emit("userVideoMuted",t,!1):e===pe.MuteScreen?this.emit("userScreenMuted",t,!0):e===pe.UnmuteScreen&&this.emit("userScreenMuted",t,!1)}onRemoteStatReport(e,t,i){this.emit(pe.PullStreamStats,e,t,i)}onSubscribeExceeds(e,t){this.emit(pe.RtsSubscribeExceeds,e,t)}removeLeftUser(e){return w(this,null,function*(){e.userid&&this.userMap[e.userid]&&(yield this.userMap[e.userid].clear(!1),delete this.userMap[e.userid])})}updateUsers(e){const t=[],i=[],r={};e.forEach(n=>{n.userid&&(this.userMap[n.userid]?(i.push(n),r[n.userid]=this.userMap[n.userid]):(t.push(n),r[n.userid]=this.executeAddUser(n.userid,n.displayname,de.Resume)))});const a=Object.keys(this.userMap),c=[];return a.forEach(n=>{r[n]||c.push({userid:n,reason:"",leavecode:fr.AliRtcUserOfflineQuit})}),this.userMap=r,{joinList:t,leaveList:c,presentList:i}}getRemoteUser(e){return this.userMap[e]}updateRemoteUserDeviceStatus(e){e&&e.userid&&this.userMap[e.userid]&&this.userMap[e.userid].updateRemoteUserDeviceStatus(e.status)}updateAudioWant(e,t){const i=this.userMap[e];if(!i)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);i.setWantSubAudio(t),t?i.updateSubscribe(de.User):i.stopSubscribe({audio:!0})}updateVideoWant(e,t){const i=this.userMap[e];if(!i)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);i.setWantSubVideo(t),t?i.updateSubscribe(de.User):i.stopSubscribe({video:!0})}updateScreenWant(e,t){const i=this.userMap[e];if(!i)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);i.setWantSubScreen(t),t?i.updateSubscribe(de.User):i.stopSubscribe({screen:!0})}stopIndication(){this.indicationTimer&&window.clearInterval(this.indicationTimer)}startIndication(e){this.stopIndication(),this.indicationTimer=window.setInterval(()=>{const t=this.remoteUsers.map(i=>({userId:i.userId,volume:i.getAudioLevel()||0}));t.unshift({userId:"",volume:this.self.getAudioLevel()||0}),this.emit("audioVolume",t)},e)}setEnableDualVideoStream(e,t){if(!this.dualVideoPlugin)return;t&&this.dualVideoPlugin.setOptions(t);const i=this.pluginManager.has(this.dualVideoPlugin.name);e?!i&&this.pluginManager.add(this.dualVideoPlugin):i&&this.pluginManager.remove(this.dualVideoPlugin.name)}setAudioVolume(e){var t;(t=this.audioMixerPlugin)==null||t.setOptions(e)}enableAudioVolumeIndication(e){this.audioVolumeIndicationInterval!==e&&(this.audioVolumeIndicationInterval>0&&e<=0&&this.stopIndication(),e>0&&this.startIndication(e),this.audioVolumeIndicationInterval=e,this.remoteUsers.forEach(t=>{t.enableAudioVolumeIndication(e)}),this.self.enableAudioVolumeIndication(e))}setPlayoutVolume(e){this.playoutVolume=e,this.remoteUsers.forEach(t=>{t.setPlayoutVolume(e)})}refreshAuthInfo(e){this.authInfo&&(this.authInfo=Y(Y({},this.authInfo),e)),e.userId&&this.self.refreshUserInfo(e.userId)}setEnableMediaExtensionMsg(e){this.rtsManager.setEncodedInsertableStreams(e)}setAudioRedEnabled(e){this.rtsManager.setAudioRedEnabled(e)}setParameter(e){var i,r,a;const t=JSON.parse(e);Object.keys(t).forEach(c=>{const n=this.parameter[c],h=t[c];this.parameter[c]=typeof n=="object"&&typeof h=="object"?Y(Y({},n),h):h}),t.enableBlankAudio===!0?(this.blankAudioPlugin||(this.blankAudioPlugin=new ec),this.pluginManager.has((i=this.blankAudioPlugin)==null?void 0:i.name)||this.pluginManager.add(this.blankAudioPlugin)):t.enableBlankAudio===!1&&(this.blankAudioPlugin&&this.pluginManager.remove((r=this.blankAudioPlugin)==null?void 0:r.name),(a=this.blankAudioPlugin)==null||a.clear(),this.blankAudioPlugin=void 0)}getParameter(){return JSON.stringify(this.parameter)}sendDataChannelMessage(e){return this.self.sendDataChannelMessage(e)}}m(xe,"logName","BizControl"),$e([C()],xe.prototype,"init",1),$e([C()],xe.prototype,"leave",1),$e([C()],xe.prototype,"clear",1),$e([C(B)],xe.prototype,"addUser",1),$e([C()],xe.prototype,"removeLeftUser",1),$e([C()],xe.prototype,"updateUsers",1),$e([C(B)],xe.prototype,"updateAudioWant",1),$e([C(B)],xe.prototype,"updateVideoWant",1),$e([C(B)],xe.prototype,"updateScreenWant",1),$e([C()],xe.prototype,"stopIndication",1),$e([C()],xe.prototype,"startIndication",1),$e([C(B)],xe.prototype,"setEnableDualVideoStream",1),$e([C(B)],xe.prototype,"setAudioVolume",1),$e([C()],xe.prototype,"enableAudioVolumeIndication",1);const Lr=s=>w(this,null,function*(){const o=new Uint8Array(160).fill(170),e=new TextEncoder().encode(s),t=yield window.crypto.subtle.importKey("raw",o,{name:"HMAC",hash:{name:"SHA-1"}},!1,["sign"]),i=yield window.crypto.subtle.sign("HMAC",t,e);return Array.from(new Uint8Array(i)).map(r=>r.toString(16).padStart(2,"0")).join("")});class dc{constructor(o){m(this,"authInfo");m(this,"slsReporter");this.slsReporter=o}doRequest(o,e){var c;const t=this.authInfo;if(!t)return Promise.reject(dt.LiveTranscodingErrorInvalidParam);const i=Co[o],r={appid:t.appId,userid:t.userId,channelid:t.channelId,timestamp:t.timestamp,token:t.token,nonce:t.nonce?t.nonce:"",requestid:ze.createCallid(),tokensid:!1,session:(c=t.sessionId)!=null?c:ze.createCallid()},a=Object.keys(r).map(n=>`${n}=${encodeURIComponent(r[n])}`).join("&");return fetch(`https://gw.rtn.aliyuncs.com${i}?${a}`,{method:"POST",headers:{"Content-Type":"application/json; charset=UTF-8"},body:JSON.stringify(e)}).then(n=>n.status!==200?(this.slsReporter.reportTranscodingError(n.status,e.taskid||""),Promise.reject(new O(U.ERR_INNER,`transcoding request failed, status: ${n.status}`))):n).catch(n=>Promise.reject(new O(U.ERR_INNER,`transcoding request failed, err: ${n.message}`)))}setAuthInfo(o){this.authInfo=o}clear(){this.authInfo=void 0}startPublishLiveStream(o,e){return w(this,null,function*(){if(!this.authInfo)return Promise.reject(dt.LiveTranscodingErrorInvalidParam);const t=yield Lr(o.split("?")[0]),i=We.MPU_TASK_TRANSACTION_UPDATE,r=e.toJson(i,this.authInfo,t,o);return this.doRequest(i,r)})}startPublishLiveStreamWithTaskId(o,e){return w(this,null,function*(){if(!this.authInfo)return Promise.reject(dt.LiveTranscodingErrorInvalidParam);const t=We.MPU_TASK_TRANSACTION_UPDATE,i=e.toJson(t,this.authInfo,o);return this.doRequest(t,i)})}updatePublishLiveStream(o,e){return w(this,null,function*(){if(!this.authInfo)return Promise.reject(dt.LiveTranscodingErrorInvalidParam);const t=yield Lr(o.split("?")[0]),i=We.MPU_TASK_TRANSACTION_UPDATE,r=e.toJson(i,this.authInfo,t,o);return this.doRequest(i,r)})}updatePublishLiveStreamWithTaskId(o,e){return w(this,null,function*(){if(!this.authInfo)return Promise.reject(dt.LiveTranscodingErrorInvalidParam);const t=We.MPU_TASK_TRANSACTION_UPDATE,i=e.toJson(t,this.authInfo,o);return this.doRequest(t,i)})}stopPublishLiveStream(o){return w(this,null,function*(){if(!this.authInfo)return Promise.reject(dt.LiveTranscodingErrorInvalidParam);const e=yield Lr(o.split("?")[0]),t=We.MPU_TASK_TRANSACTION_STOP,i=new Ci().toJson(t,this.authInfo,e,o);return this.doRequest(t,i)})}stopPublishLiveStreamWithTaskId(o){if(!this.authInfo)return Promise.reject(dt.LiveTranscodingErrorInvalidParam);const e=We.MPU_TASK_TRANSACTION_STOP,t=new Ci().toJson(e,this.authInfo,o);return this.doRequest(e,t)}refreshAuthInfo(o){this.authInfo&&this.setAuthInfo(Y(Y({},this.authInfo),o))}}class Dr{static checkString(o){return typeof o=="string"}static checkNumber(o){return typeof o=="number"}static checkHtmlVideoElement(o){return o&&o.nodeName==="VIDEO"}static checkHtmlAudioElement(o){return o&&o.nodeName==="AUDIO"}static checkAuthInfo(o){return o?o.appId?o.channelId?o.userId?o.timestamp?Dr.checkNumber(o.timestamp)?o.token?null:new O(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no token founded"):new O(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"timestamp is not number"):new O(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no timestamp founded"):new O(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no userId founded"):new O(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no channelId founded"):new O(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no appId founded"):new O(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no authInfo founded")}static checkMediaStreamTrack(o){return o instanceof MediaStreamTrack}static checkVideoEncoderConfiguration(o){return o&&(o.width||o.height||o.frameRate||o.bitrateMax)}}class qa{constructor(o){m(this,"taskProfile");m(this,"encodeParam");m(this,"users",[]);m(this,"backgroundColor",0);m(this,"backgrounds",[]);m(this,"watermarks",[]);m(this,"clockWidgets",[]);m(this,"cropMode");m(this,"mediaProcessMode");this.taskProfile=o}}class Ya{constructor(o,e,t){m(this,"userId");m(this,"streamType");m(this,"sourceType");this.userId=o,this.streamType=e,this.sourceType=t}}class Xa{constructor(o,e,t,i=0,r=16777215,a=ci.NOTO_SERIF_CJKSC_REGULAR){m(this,"x");m(this,"y");m(this,"fontSize");m(this,"zOrder");m(this,"fontColor");m(this,"fontType");this.x=o,this.y=e,this.fontSize=t,this.zOrder=i,this.fontColor=r,this.fontType=a}toJson(o,e){return{x:Ze(this.x,o),y:Ze(this.y,e),fonttype:this.fontType,fontsize:this.fontSize,fontcolor:mr(this.fontColor),zorder:this.zOrder}}}var Qa=(s=>(s[s.NOT_DISPLAY=0]="NOT_DISPLAY",s[s.ALWAYS=1]="ALWAYS",s[s.WHEN_NO_VIDEO=2]="WHEN_NO_VIDEO",s))(Qa||{});class Nr{constructor(o,e,t,i,r,a=0,c=1,n=1){m(this,"url");m(this,"x");m(this,"y");m(this,"width");m(this,"height");m(this,"alpha");m(this,"display",1);m(this,"zOrder");this.url=o,this.x=e,this.y=t,this.width=i,this.height=r,this.zOrder=a,this.alpha=c,this.display=n}toJson(o,e){return{url:this.url,alpha:this.alpha,display:this.display,x:Ze(this.x,o),y:Ze(this.y,e),width:Ze(this.width,o),height:Ze(this.height,e),zorder:this.zOrder}}}m(Nr,"DisplayType",Qa);class Za{constructor(o,e,t,i,r=0,a=16777215,c=ci.NOTO_SERIF_CJKSC_REGULAR){m(this,"text");m(this,"x");m(this,"y");m(this,"fontSize");m(this,"zOrder");m(this,"fontColor");m(this,"fontType");this.text=o,this.x=e,this.y=t,this.fontSize=i,this.zOrder=r,this.fontColor=a,this.fontType=c}toJson(o,e){return{text:this.text,x:Ze(this.x,o),y:Ze(this.y,e),fonttype:this.fontType,fontsize:this.fontSize,fontcolor:mr(this.fontColor),zorder:this.zOrder}}}class en{constructor(o,e,t,i,r,a=0,c){m(this,"userId");m(this,"x");m(this,"y");m(this,"width");m(this,"height");m(this,"zOrder");m(this,"sourceType");m(this,"segmentType",oi.LiveTranscodingNoBody);m(this,"images",[]);m(this,"texts",[]);this.userId=typeof o=="number"?o.toString():o,this.x=e,this.y=t,this.width=i,this.height=r,this.zOrder=a,c&&(this.sourceType=c)}toJson(o,e,t,i){const r={paneid:o,majorpane:0,x:Ze(this.x,e),y:Ze(this.y,t),width:Ze(this.width,e),height:Ze(this.height,t),zorder:this.zOrder,userid:this.userId,images:this.images.map(a=>a.toJson(e,t)),texts:this.texts.map(a=>a.toJson(e,t))};return this.sourceType&&ni[this.sourceType]?r.sourcetype=ni[this.sourceType]:r.sourcetype=ni[qt.LiveTranscodingCamera],this.segmentType&&i===wi.LiveTranscodingVirtualBackground?r.segmenttype=this.segmentType:r.segmenttype=oi.LiveTranscodingNoBody,r}}const Wt=class Wt{constructor(){m(this,"ntpClock");this.ntpClock=new G.AliRTS.Clock}static getInstance(){return Wt.instance||(Wt.instance=new Wt),Wt.instance}now(){return this.ntpClock.now()}};m(Wt,"instance");let Vr=Wt;const tn=()=>Vr.getInstance(),{BrowserUtil:Or,SystenUtil:rn}=G.AliRTS;class sn{constructor(){m(this,"tracker");m(this,"param");m(this,"msgCacheArr",[]);m(this,"index",0);m(this,"stsOpt");m(this,"slsToken");m(this,"ossToken");m(this,"ntpClock");this.ntpClock=tn()}createTracker(){if(!this.tracker&&this.slsToken&&this.param){const o=this.slsToken;this.ossToken&&(this.param.ossbn=this.ossToken.bucket_name,this.param.ossep=this.ossToken.region_endpoint);const e=new er({host:o.region_endpoint,project:o.project,logstore:o.log_store_stats}),t={accessKeyId:o.access_key_id,accessKeySecret:o.access_key_secret,securityToken:o.security_token,refreshSTSToken:()=>{this.slsToken&&(t.accessKeyId=this.slsToken.access_key_id,t.accessKeySecret=this.slsToken.access_key_secret,t.securityToken=this.slsToken.security_token)}};this.stsOpt=t;const i=sr(t);e.useStsPlugin(i),this.tracker=e,this.msgCacheArr.forEach((r,a)=>{var c,n;(n=this.tracker)==null||n.send(Y(Et(Y({},this.param),{stat_log_id:`${((c=this.param)==null?void 0:c.sesid)||"nosession"}-${a}`}),r))}),this.index=this.index+this.msgCacheArr.length,this.msgCacheArr=[]}}start(o){this.initParam(o),this.createTracker()}updateToken(o,e){this.slsToken=o,this.ossToken=e,this.createTracker()}stop(){this.tracker=void 0,this.param=void 0,this.msgCacheArr=[],this.index=0,this.stsOpt=void 0,this.slsToken=void 0,this.ossToken=void 0}sendReport(o){var t,i;let e;o.tm=Date.now();try{e=JSON.parse(JSON.stringify(Y(Et(Y({bt:Or.browserName||"unknown",ntptm:this.ntpClock.now(),ntpofs:this.ntpClock.now()-Date.now()},this.param),{stat_log_id:`${((t=this.param)==null?void 0:t.sesid)||"nosession"}-${this.index}`}),o)))}catch(r){}e&&(this.tracker?((i=this.tracker)==null||i.send(e),this.index++):this.msgCacheArr.push(e))}initParam(o){let e="";try{e=(localStorage==null?void 0:localStorage.getItem("AliRtcUUID"))||"",e||(e=Qe(),localStorage==null||localStorage.setItem("AliRtcUUID",e))}catch(t){}this.param||(this.param={apid:o.appId,usrid:o.userId,statsvrs:"0.6.1",evetid:0,sesid:o.sessionId,sessionId:o.sessionId,channelid:o.channelId,usrn:o.userId,osn:rn.systemName,osv:rn.systemVersion,deb:_o(),den:yo(),udid:e,sdkvrs:Ri,acs:"Unknown",cput:Ca(),dm:`${window.location.protocol}//${window.location.host}`,bt:Or.browserName,bv:Or.browserVersion,envir:"PRODUCT",args:"",instid:Qe()})}}const le=(s,o=1,e=6e4,t=0)=>{let i=s;return i||(i=0),Math.min(e,Math.max(t,Math.round(i*o)))},it=(s,o,e=2e7,t=0)=>{let i=o;(!o||o<0||o>1e4)&&(i=1e3);let r=s;return r||(r=0),Math.min(e,Math.max(t,Math.round(r/(i/1e3))))},jt=(s,o)=>{if(o===0||!o)return"0.00";let e=s;return(!e||e<0)&&(e=0),(e/o*100).toFixed(2)},an=s=>s>=0&&s<=1?le(Math.floor(32767*s),1,32767):0,ge=(s,o)=>{var t,i,r;let e=((t=s._last)==null?void 0:t[o])||0;return s.ssrc&&((i=s._last)!=null&&i.ssrc)&&s.ssrc!==((r=s._last)==null?void 0:r.ssrc)&&(e=0),((s==null?void 0:s[o])||0)-e},nn=(s,o)=>le(ge(s,o),1e3,1e4),zt=(s,o=2e7)=>le(s,1,o),mi=class mi{constructor(o){m(this,"engine");m(this,"logClient");m(this,"authInfo");m(this,"ntpClock");m(this,"customFields",{});this.logClient=new sn,this.engine=o,this.ntpClock=tn()}static getLogClient(){return this.staticClient||(this.staticClient=new sn),this.staticClient}static reportOSSUpload(o,e,t=0){mi.getLogClient().sendReport({errmsg:`${e}/${o}.log`,errtype:t,evetid:70017,sesid:o,sessionId:o,stat_log_id:`${o}-70017`})}setCustomFields(o){this.customFields=Y(Y({},this.customFields),o)}getCustomField(o){return this.customFields[o]}start(o){this.authInfo=o,this.logClient.start(o)}updateToken(o,e){this.logClient.updateToken(o,e),mi.getLogClient().updateToken(o,e)}stop(){this.logClient.stop()}reportPublishMonitor(o,e,t,i,r){if(!t||r.length<=0)return;const a=t===M.Audio,c={ctm:Math.floor(r[0].timestamp||0),src:r[0].ssrc||"",codec:r[0]._codec||""},n=[],h=[],d=[],u=[],f=[],l=[],g=[],p=[],b=[],S=[],v=[],_=[],E=[],y=[],R=[],A=[],T=[],I=[],k=[];try{if(r.forEach(P=>{var V,ne,Re,$,ue,we;if(!P||!P.timestamp)return;const H=(V=P._last)!=null&&V.timestamp?P.timestamp-P._last.timestamp:1e3,q=ge(P,"bytesSent"),X=ge(P,"headerBytesSent"),J=it(le(q+X,8,2e7),H);n.push(J);const z=it(le(q,8,2e7),H);h.push(z);const Z=it(le(X,8,2e7),H);d.push(Z);const ee=ge(P,"packetsSent"),he=it(ee,H);u.push(he);const L=ge(P,"packetsLost"),N=it(L,H);f.push(N);const D=jt(L,ee);if(l.push(D),a)(ne=P._source)!=null&&ne.audioLevel&&g.push(an(P._source.audioLevel)),p.push(0);else{b.push(nn(P,"totalEncodeTime")),S.push(zt((Re=P._source)==null?void 0:Re.framesPerSecond,100)),v.push(zt(($=P._source)==null?void 0:$.framesPerSecond,100)),_.push(zt(P.framesPerSecond,100)),E.push(zt((ue=P._source)==null?void 0:ue.height,4400)),y.push(zt((we=P._source)==null?void 0:we.width,7700)),R.push(zt(P.frameHeight,4400)),A.push(zt(P.frameWidth,7700));const Ce=ge(P,"totalPacketSendDelay");T.push(le(Ce,1/(L||1),2e3));const Ae=ge(P,"qpSum");I.push(le(Ae,1/(P.framesPerSecond||1),51)),k.push(0)}}),c.sbr=n.join(","),c.mbrs=h.join(","),c.pbrs=d.join(","),c.ps=u.join(","),c.pl=f.join(","),c.plr=l.join(","),a){const P=(i==null?void 0:i.getSettings().sampleRate)||0;c.ailevel=g.join(","),c.arpc=p.join(","),c.arsr=P,c.aesr=P,c.publevel=-90,c.rawlevel=-90}else c.em=b.join(","),c.cfps=S.join(","),c.ifps=v.join(","),c.sfps=_.join(","),c.ih=E.join(","),c.iw=y.join(","),c.sh=R.join(","),c.sw=A.join(","),c.sd=T.join(","),c.aqp=I.join(","),c.caf=k.join(","),c.can=k.join(","),c.cav=h.join(","),c.ifimax=k.join(","),c.ifimin=k.join(","),c.efimax=k.join(","),c.efimin=k.join(","),c.sfimax=k.join(","),c.sfimin=k.join(","),c.apsnr=k.join(",")}catch(P){}this.log({evetid:10070,traceid:e,calid:o,args:this.data2String(Y({calid:o,tckid:t,traceid:e},c))})}reportSubscribeMonitor(o,e,t,i,r){if(!i||!r||r.length<=0)return;const a=i===M.Audio,c={ctm:Math.floor(r[0].timestamp||0),src:r[0].ssrc||"",codec:r[0]._codec||""},n=[],h=[],d=[],u=[],f=[],l=[],g=[],p=[],b=[],S=[],v=[],_=[],E=[],y=[],R=[],A=[],T=[],I=[],k=[],P=[],H=[],q=[],X=[],J=[],z=[],Z=[],ee=[],he=[],L=[],N=[],D=[],V=[],ne=[],Re=[];try{r.forEach($=>{var fi,_t;if(!$||!$.timestamp)return;const ue=(fi=$._last)!=null&&fi.timestamp?$.timestamp-$._last.timestamp:1e3,we=ge($,"bytesReceived"),Ce=ge($,"headerBytesReceived"),Ae=it(le(we+Ce,8,2e7),ue);n.push(Ae);const me=it(le(we,8,2e7),ue);h.push(me);const be=it(le(Ce,8,2e7),ue);d.push(be);const oe=ge($,"packetsReceived"),_e=it(oe,ue);u.push(_e);const Ue=ge($,"packetsLost"),pt=it(Ue,ue);f.push(pt);const Rt=jt(Ue,oe);l.push(Rt);const gt=ge($,"jitterBufferDelay"),Me=ge($,"jitterBufferEmittedCount");if($.jitterBufferDelay&&$.jitterBufferEmittedCount){const at=le(gt,1e3/Me,1e4);g.push(at)}else g.push(0);const Ye=ge($,"fecPacketsReceived");_.push(jt(Ye,oe));const Xe=ge($,"retransmittedPacketsReceived"),At=oe+Ue-Xe;if(b.push(jt(oe-Xe,At)),S.push(jt(Ue,At)),p.push(jt(Xe,At)),v.push(At),ne.push(0),Re.push(""),a){y.push(an($.audioLevel));const at=((nt,ot)=>{var mt,ct,Nt;return(((mt=nt==null?void 0:nt._source)==null?void 0:mt[ot])||0)-(((Nt=(ct=nt==null?void 0:nt._last)==null?void 0:ct._source)==null?void 0:Nt[ot])||0)})($,"synthesizedSamplesEvents");R.push(at);const ei=nn($,"synthesizedSamplesDuration");A.push(ei);const ti=jt(ei,ue);E.push(ti),T.push(0)}else{const at=(_t=$._last)!=null&&_t.totalInterFrameDelay?$.totalInterFrameDelay-$._last.totalInterFrameDelay:0;I.push(le(at,1e3/($.framesDecoded||30),500)),k.push(le($.framesPerSecond,1,100)),P.push(ge($,"framesReceived")),V.push(ge($,"framesRendered")),H.push(le($.frameHeight,1,4400)),q.push(le($.frameWidth,1,7700));const ei=ge($,"totalProcessingDelay");X.push(le(ei,1e3/($.framesDecoded||30),12e4));const ti=ge($,"nackCount");z.push(ti);const nt=ge($,"pliCount");J.push(nt);const ot=ge($,"qpSum");Z.push(le(ot,1/($.framesPerSecond||1),51)),ee.push(le($.framesDropped));const mt=ge($,"totalFreezesDuration");he.push(le(mt,1e3,3e4));const ct=ge($,"jitterBufferEmittedCount"),Nt=ge($,"jitterBufferDelay");Nt&&ct?L.push(le(Nt,1e3/ct,3e4)):L.push(0);const Si=ge($,"jitterBufferTargetDelay");Si&&ct?N.push(le(Si,1e3/ct,3e4)):N.push(0);const xi=ge($,"jitterBufferMinimumDelay");xi&&ct?D.push(le(xi,1e3/ct,3e4)):D.push(0)}}),c.rbr=n.join(","),c.mbrs=h.join(","),c.pbrs=d.join(","),c.pr=u.join(","),c.pl=f.join(","),c.plr=l.join(","),c.jd=g.join(","),c.fecr=_.join(","),c.retransr=p.join(","),c.baser=b.join(","),c.basel=S.join(","),c.recoverr=ne.join(","),c.alll=S.join(","),c.totalc=v.join(","),a?(c.er=E.join(","),c.aolevel=y.join(","),c.asrc=T.join(","),c.scnt=R.join(","),c.sdura=A.join(",")):(c.dm=I.join(","),c.dfps=k.join(","),c.rfps=P.join(","),c.rh=H.join(","),c.rw=q.join(","),c.fpt=Re.join(","),c.ns=z.join(","),c.pliss=J.join(","),c.aqp=Z.join(","),c.ofimax=ne.join(","),c.ofimin=ne.join(","),c.dfimax=ne.join(","),c.dfimin=ne.join(","),c.rfimax=ne.join(","),c.rfimin=ne.join(","),c.vrstutter=he.join(","),c.cdm=L.join(","),c.tdm=N.join(","),c.pdm=D.join(","),c.ofps=V.join(","),c.dfbd=ee.join(","))}catch($){}this.log({evetid:10080,traceid:t,rmtid:e,calid:o,args:this.data2String(Y({calid:o,rmtid:e,tckid:i,traceid:t},c))})}reportNetworkMonitor(o){if(o.length<=0)return;const e=[],t=[],i=[],r=[],a=[],c=[],n=[],h=[],d=[],u=[];o.forEach((l,g)=>{var b;if(!l.timestamp)return;const p=(b=l._last)!=null&&b.timestamp?l.timestamp-l._last.timestamp:1e3;e.push(le(l.currentRoundTripTime,1e3)),t.push(le(l.availableOutgoingBitrate,8,2e8)),i.push(it(le(l.bytesSent,8,2e7),p,25e6)),r.push(it(le(l.bytesReceived,8,2e7),p,25e6)),a.push(0),c.push(0),g%5==0&&(n.push(""),h.push(""),d.push(""),u.push(""))});const f={ctm:Math.floor(o[0].timestamp||0),rtt:e.join(","),bsps:i.join(","),brps:r.join(","),cpu:n.join(","),mem:h.join(","),sysmem:d.join(","),systotalmem:u.join(","),audioonly:this.engine.isAudioOnly()?1:0};this.log({evetid:10071,args:this.data2String(Y({asb:t.join(","),abms:a.join(","),vbms:c.join(",")},f))}),this.log({evetid:10081,args:this.data2String(Y({},f))})}reportJoin(o,e,t=""){var u,f;const{start:i,rs:r=0,re:a=0}=e,c=Date.now()-i,n=a-r;let h=0;r&&(h=r-i);let d=0;a&&(d=a-r),this.log({evetid:10010,args:this.data2String({sesid:((u=this.authInfo)==null?void 0:u.sessionId)||"",joitm:c,rslt:o,gslbtm:0,dnstm:0,avcftm:0,gslbrslt:0,dnsrslt:0,avcfrslt:0,mode:2,jrtc:n,usrn:(f=this.authInfo)==null?void 0:f.userId,mgt:"cdn",cttc:h,iptc:d,ndn:1,gslbloc:1,ccag:0,ucag:0,cpg:0,upg:0,tid:t})})}reportJoinConnection(o){this.log({evetid:20002,args:this.data2String(Y({transretrynum:0,ldnstc:0,tcptc:0,ssltc:0,url:""},o))})}reportLeave(o,e,t){this.log({evetid:10020,args:this.data2String({lvetm:o,rslt:e,tid:t})})}reportPublish(o,e,t,i,r,a,c,n,h,d,u){this.log({evetid:o?10032:10030,calid:t,args:this.data2String({calid:t,url:e,isvl:i?1:0,isvs:r?1:0,isvss:a?1:0,isaudio:c?1:0,rslt:n,tid:"123",pubtm:Date.now()-u,pctid:h,pubtid:d,isvp:0,isarecording:0,isad:0,isdc:0,pubretry:0,pbrttimes:0})})}reportPublishFirstPacket(o,e,t,i,r,a,c,n,h){const d=Date.now();this.log({evetid:o?10033:10031,calid:e,args:this.data2String({calid:e,fpst:d-t,tckid:a,est:t,pctid:c,pubtid:n,totaltm:d-r,jorm:h===ht.JOIN_CHANNEL?1:0,cptc:0,sptc:i-t,iptc:0,ipc2fptc:0,dctc:0,patc:0})})}reportUnpublish(o,e,t,i){var r;this.log({evetid:10040,args:this.data2String({calid:o,unpubtm:e,rslt:t,tid:i,sesid:((r=this.authInfo)==null?void 0:r.sessionId)||""})})}reportSubscribe(o,e,t,i,r,a,c,n,h,d){this.log({evetid:10050,calid:o,rmtid:e,args:this.data2String(Y({calid:o,rmtid:e,isvl:t?1:0,isvs:i?1:0,isvss:r?1:0,isaudio:a?1:0,rslt:c,tid:n,subtm:h,isvp:0,isaplaying:0,isad:0,isdc:0,subretry:0,sbrttimes:0},d))})}reportSubscribeFirstPacket(o,e,t,i,r){this.log({evetid:o?10054:10051,calid:e,rmtid:t,args:this.data2String(Y({calid:e,rmtid:t,tckid:i,cptc:0,iptc:0,ipc2fptc:0,dctc:0,patc:0},r))})}reportSubscribeFirstFrame(o,e,t,i,r){this.log({evetid:o?10055:10052,calid:e,rmtid:t,args:this.data2String(Y({calid:e,rmtid:t,tckid:i},r))}),this.log({evetid:o?10058:10057,args:this.data2String(Y({calid:e,rmtid:t,tckid:i},r))})}reportUnsubscribe(o,e,t,i,r){this.log({evetid:10060,calid:o,args:this.data2String({calid:o,rmtid:e,unsubtm:t,rslt:i,tid:r})})}reportMute(o,e,t){this.log({evetid:11030,args:this.data2String({calid:o,rmtid:"",enable:e?1:0,mt:t})})}reportRoleUpdate(o,e){this.log({evetid:11040,args:this.data2String({or:o||"",nr:e,ctm:Date.now(),rslt:0})})}reportRoleUpdateResult(o,e,t,i){this.log({evetid:11041,args:this.data2String({or:o||"",nr:e,ctm:t,rslt:i})})}reportVideoProfile(o){this.log({evetid:20074,args:this.data2String({pf:o,tckid:"sophon_camera_large"})})}reportScreenProfile(o){this.log({evetid:20074,args:this.data2String({pf:o,tckid:"sophon_screenshare"})})}reportError(o){this.log({evetid:10091,args:this.data2String({rslt:(o==null?void 0:o.code)||-1})})}reportWarning(o){this.log({evetid:10092,args:this.data2String({rslt:-1,errmsg:o})})}reportRoomServerEvent(o,e,t,i){this.log({evetid:20005,args:this.data2String({calid:"",rmtid:"",rt:o?0:1,dr:o?"s":"r",mt:e,ri:t,cs:1,srt:Date.now(),rspc:(i==null?void 0:i.code)||"",mc:JSON.stringify(i)})})}reportTranscodingError(o,e){this.log({evetid:10101,args:this.data2String({rslt:o,taskid:e})})}reportBye(o){var e;this.log({evetid:10093,args:this.data2String({rslt:o,sesid:((e=this.authInfo)==null?void 0:e.sessionId)||""})})}reportAudio(o,e,t){var i;this.log({evetid:80013,args:this.data2String({rslt:o?-1:0,adm:1,adt:0,adr:o?2:0,acms:e,adrpn:t})}),this.log({evetid:80014,args:this.data2String({sesid:((i=this.authInfo)==null?void 0:i.sessionId)||"",rslt:o?-1:0,adm:1,adt:0,adr:o?2:0,acms:e,adrpn:t})})}reportScreen(o,e){var t,i,r,a;this.log({evetid:90013,args:this.data2String({rslt:o?-1:0,vcms:e,vde:(t=o==null?void 0:o.code)!=null?t:-1,sesid:((i=this.authInfo)==null?void 0:i.sessionId)||""})}),this.log({evetid:90014,args:this.data2String({rslt:o?-1:0,vcms:e,vde:(r=o==null?void 0:o.code)!=null?r:-1,sesid:((a=this.authInfo)==null?void 0:a.sessionId)||""})})}reportScreenStop(o){this.log({evetid:90019,args:this.data2String({rslt:o?o.code||-1:0})}),this.log({evetid:90020,args:this.data2String({rslt:o?o.code||-1:0})})}reportSwitchCamera(o){var e;this.log({evetid:90025,args:this.data2String({rslt:0,td:o,sesid:((e=this.authInfo)==null?void 0:e.sessionId)||""})})}reportPublishProfile(o,e){this.log({evetid:10201,args:this.data2String(Y({tckid:o},e))})}reportSDKCreated(o){this.log({evetid:70011,createtm:Date.now()-o,tm:o})}reportJoinInvoked(o){this.log({evetid:70012,jnnonce:o.nonce||"",jntoken:o.token||"",jntm:o.timestamp||""})}reportJoinResult(o){this.log({evetid:70013,rslt:o?o.code||-1:0,dnsrslt:0})}reportSTSResult(o,e){this.log({evetid:70014,rslt:o,asty:1,reqtm:Date.now()-e})}reportLeaveInvoked(){this.log({evetid:70015})}reportSEIMessage(o,e,t,i,r){this.log({evetid:40301,args:this.data2String({tm:Date.now(),sei_pt:o,sei_len:e,sei_rep:t,sei_delay:i,sei_key:r})})}reportConnectionLatencyEvent(o,e,t,i,r,a,c=!1){const n={ageniid:this.getCustomField("ageniid")},h=Y({tm:r||Date.now(),ntptm:a||this.ntpClock.now(),stage:o,status:e,calid:t,tckid:i,cltp:1,http:c?1:0},n);this.log({evetid:12001,args:this.data2String(h)})}log(o){o&&(o.tm=new Date().getTime(),x.debug("[ConsoleLogger]","log",o),this.logClient.sendReport(o))}data2String(o){let e="";for(let t in o)e.length&&(e+="&"),e+=t+"="+o[t];return e}};m(mi,"staticClient");let xr=mi;var lc=Object.defineProperty,uc=Object.getOwnPropertyDescriptor,j=(s,o,e,t)=>{for(var i,r=t>1?void 0:t?uc(o,e):o,a=s.length-1;a>=0;a--)(i=s[a])&&(r=(t?i(o,e,r):i(r))||r);return t&&r&&lc(o,e,r),r};const F=(W=class extends te{constructor(e){super();m(this,"channelProfile");m(this,"clientRole");m(this,"signalingManager");m(this,"bizControl");m(this,"liveTranscoding");m(this,"maxSignalingConnectRetryCount");m(this,"slsReporter");m(this,"connectState",ae.AliRtcConnectionStatusInit);m(this,"networkError",!1);m(this,"_audioOnlyMode",!1);m(this,"_authInfoWillExpireTimer",null);m(this,"_authInfoExpiredTimer",null);m(this,"_serverCheckAuthInfoTimestamp",null);m(this,"_localCheckAuthInfoTimestamp",null);m(this,"_proxyAiTid",null);m(this,"_agentParam",null);const t=Date.now();x.init(),this.slsReporter=new xr(this),this.channelProfile=vt.AliRtcSdkCommunication,this.clientRole=wt.AliRtcSdkLive,this.liveTranscoding=new dc(this.slsReporter),this.signalingManager=new Rr(this.channelProfile,this.clientRole,this.slsReporter,(e==null?void 0:e.env)===bt.pre?bt.pre:bt.prod),this.addSignalingManagerListeners(),this.maxSignalingConnectRetryCount=e==null?void 0:e.maxSignalingConnectRetryCount,this.bizControl=new xe({slsReporter:this.slsReporter,signalingManager:this.signalingManager}),this.addBizControlListeners(),this.addPublisherListeners(),this.slsReporter.reportConnectionLatencyEvent(Ge.CREATE_ENGINE,et.START,"","",t),this.slsReporter.reportConnectionLatencyEvent(Ge.CREATE_ENGINE,et.END,"","",Date.now()),this.slsReporter.reportSDKCreated(t)}static getSdkVersion(){return Ri}static setLogLevel(e){x.setLogLevel(e)}static getInstance(e){return W._instance||(W._instance=new W(e)),W._instance}destroy(){return w(this,null,function*(){W._instance=void 0,yield this.leaveChannel(),yield this.bizControl.clear(),x.destroy()})}get channel(){return this.bizControl.channel}get userId(){return this.bizControl.userId}get remoteUsers(){return this.bizControl.remoteUsers}get publisher(){return this.bizControl.publisher}get publishAudioStream(){var e;return(e=this.publisher)==null?void 0:e.publishStreams.audio}get isPublishing(){const{publisher:e}=this.bizControl;return!!e&&e.isPublishing}get currentRoleCanPublish(){return this.channelProfile===vt.AliRtcSdkCommunication||this.clientRole===wt.AliRtcSdkInteractive}addPublisherListeners(){var e,t,i,r,a,c,n,h,d,u;(e=this.publisher)==null||e.on(Be.Local,f=>{x.event("[Publisher] Device Status Change",f),this.onLocalDeviceStatusChange(f)}),(t=this.publisher)==null||t.on(Ft.VideoTrackEnded,()=>{x.event("[Publisher] VideoTrack Ended"),this.emit("localDeviceException",lt.AliEngineLocalDeviceTypeCamera,Ee.AliEngineLocalDeviceExceptionTypeCameraInterrupt,"")}),(i=this.publisher)==null||i.on(Ft.ScreenTrackEnded,()=>{x.event("[Publisher] ScreenTrack Ended"),this.emit("localDeviceException",lt.AliEngineLocalDeviceTypeDisplay,Ee.AliEngineLocalDeviceExceptionTypeDisplayException,"")}),(r=this.publisher)==null||r.on(Ft.AudioTrackEnded,()=>{x.event("[Publisher] AudioTrack Ended"),this.emit("localDeviceException",lt.AliEngineLocalDeviceTypeMic,Ee.AliEngineLocalDeviceExceptionTypeMicInterrupt,"")}),(a=this.publisher)==null||a.on("localDeviceException",(f,l,g="")=>{this.emit("localDeviceException",f,l,g)}),(c=this.publisher)==null||c.on("audioPublishStateChanged",(f,l,g)=>{var p;this.emit("audioPublishStateChanged",f,l,g,(p=this.channel)!=null?p:"")}),(n=this.publisher)==null||n.on("videoPublishStateChanged",(f,l,g)=>{var p;this.emit("videoPublishStateChanged",f,l,g,(p=this.channel)!=null?p:"")}),(h=this.publisher)==null||h.on("dualStreamPublishStateChanged",(f,l,g)=>{var p;this.emit("dualStreamPublishStateChanged",f,l,g,(p=this.channel)!=null?p:"")}),(d=this.publisher)==null||d.on("screenPublishStateChanged",(f,l,g)=>{var p;this.emit("screenSharePublishStateChanged",f,l,g,(p=this.channel)!=null?p:"")}),(u=this.publisher)==null||u.on("dataPublishStateChanged",(f,l,g)=>{var p;this.emit("dataPublishStateChanged",f,l,g,(p=this.channel)!=null?p:"")})}occurError(e,t){x.event(`[${W.logName}]`,"Occur Error",e,t),this.emit("onOccurError",e,t),this.emit("occurError",e,t)}addBizControlListeners(){this.bizControl.rtsManager.on("connected",e=>{var t;e&&((t=this.publisher)==null||t.publishUpdate(ht.RECONNECT),this.remoteUsers.forEach(i=>{i.updateSubscribe(de.Reconnect)}))}),this.bizControl.rtsManager.on("disconnected",()=>w(this,null,function*(){x.event(`[${W.logName}]`,"RTS Disconnected"),(yield ze.isNetworkAvailable())?this.onNetworkRecovery():this.onNetworkError()})),this.bizControl.rtsManager.on("subscribeexceeds",()=>w(this,null,function*(){yield this.resumePublishForNetworkRecovery(),yield this.resumeSubList()})),this.bizControl.rtsManager.on("seimessage",(e,t,i)=>{const r=this.remoteUsers.find(a=>a.streamUrl===e);r&&this.emit("mediaExtensionMsgReceived",r.userId,i,t)}),this.bizControl.on(Be.Remote,(e,t)=>{x.event(`[${W.logName}]`,"RemoteUser Device Status Change",e,t)}),this.bizControl.on("remoteUserJoin",(e,t)=>{this.emit("remoteUserOnLineNotify",e,t)}),this.bizControl.on("remoteTrackAvailableChange",(e,t,i)=>{this.emit("remoteTrackAvailableNotify",e,t,i)}),this.bizControl.on("audioSubscribeStateChanged",(e,t,i,r,a)=>{this.emit("audioSubscribeStateChanged",e,t,i,r,a)}),this.bizControl.on("videoSubscribeStateChanged",(e,t,i,r,a)=>{this.emit("videoSubscribeStateChanged",e,t,i,r,a)}),this.bizControl.on("screenSubscribeStateChanged",(e,t,i,r,a)=>{this.emit("screenShareSubscribeStateChanged",e,t,i,r,a)}),this.bizControl.on("dataSubscribeStateChanged",(e,t,i,r,a)=>{this.emit("dataSubscribeStateChanged",e,t,i,r,a)}),this.bizControl.on("userAudioMuted",(e,t)=>{this.emit("userAudioMuted",e,t)}),this.bizControl.on("userVideoMuted",(e,t)=>{this.emit("userVideoMuted",e,t)}),this.bizControl.on("userScreenMuted",(e,t)=>{this.emit("userScreenMuted",e,t)}),this.bizControl.on("audioVolume",e=>{this.emit("audioVolume",e)}),this.bizControl.on("remoteAudioAutoPlayFail",e=>{this.emit("remoteAudioAutoPlayFail",e)}),this.bizControl.on("remoteVideoAutoPlayFail",(e,t)=>{this.emit("remoteVideoAutoPlayFail",e,t)}),this.bizControl.on("remoteAudioPlayError",(e,t)=>{this.emit("remoteAudioPlayError",e,t)}),this.bizControl.on("remoteVideoPlayError",(e,t)=>{this.emit("remoteVideoPlayError",e,t)}),this.bizControl.on("rtcStats",e=>{this.emit("rtcStats",e)}),this.bizControl.on("rtcLocalAudioStats",e=>{this.emit("rtcLocalAudioStats",e)}),this.bizControl.on("rtcLocalVideoStats",e=>{this.emit("rtcLocalVideoStats",e)}),this.bizControl.on("rtcRemoteAudioStats",e=>{this.emit("rtcRemoteAudioStats",e)}),this.bizControl.on("rtcRemoteVideoStats",e=>{this.emit("rtcRemoteVideoStats",e)}),this.bizControl.on("remoteSubscribeError",(e,t)=>{this.occurError(e,t),this.slsReporter.reportError(e)}),this.bizControl.on("occurError",(e,t)=>{this.occurError(e,t),this.slsReporter.reportError(e)}),this.bizControl.on("remoteDataChannelMessage",(e,t)=>{this.emit("dataChannelMsg",e,t)}),this.bizControl.on("remoteUserSubscribedDataChannel",e=>{this.emit("remoteUserSubscribedDataChannel",e)})}addSignalingManagerListeners(){this.signalingManager.on("onKeepAliveRsp",()=>{this.networkError&&(x.event("[Signaling] Receive KeepAlive Response",`networkError: ${this.networkError}`),this.onNetworkRecovery())}),this.signalingManager.on("onNotifyJoin",e=>{x.event("[Signaling] Notify Join ",e),this.handleUsersJoin(e),e.forEach(t=>{this.emit("remoteUserOnLineNotify",t.userid,0)})}),this.signalingManager.on("onNotifyStatus",e=>{x.event("[Signaling] Notify Status ",e),e.forEach(t=>{this.bizControl.updateRemoteUserDeviceStatus(t)})}),this.signalingManager.on("onNotifyLeave",e=>{x.event("[Signaling] Notify Leave ",e),e.forEach(t=>w(this,null,function*(){yield this.bizControl.removeLeftUser(t),this.emit("remoteUserOffLineNotify",t.userid,t.leavecode)}))}),this.signalingManager.on("onBye",(e,t)=>{x.event("[Signaling] Bye ",e,t),this.slsReporter.reportError({message:`reason: ${e}, description: ${t}`}),this.emit("bye",e),this.leaveChannel(),this.slsReporter.reportBye(e)}),this.signalingManager.on("onConnectFail",e=>{x.event("[Signaling] Connect Failed ",e),this.onError(e),this.backToUnpublishStatus(),this.connectState=ae.AliRtcConnectionStatusFailed,this.emit("connectionStatusChange",ae.AliRtcConnectionStatusFailed,Bt.AliRtcConnectionChangedNetworkInterrupted)}),this.signalingManager.on("onNetworkError",e=>{this.slsReporter.reportWarning("signaling network error"),x.event("[Signaling] Network error ",e),this.onNetworkError()}),this.signalingManager.on("onAuthInvalid",()=>{x.event("[Signaling] Auth Invalid")}),this.signalingManager.on("onReconnectStart",()=>{x.event("[Signaling] Reconnect Start "),this.connectState=ae.AliRtcConnectionStatusReconnecting,this.emit("connectionStatusChange",ae.AliRtcConnectionStatusReconnecting,Bt.AliRtcConnectionSignalingConnecting)}),this.signalingManager.on("onReconnectSuccess",e=>{x.event("[Signaling] Reconnect Success ",e),this.onNetworkRecovery(e)}),this.signalingManager.on("onReconnectFail",e=>{this.slsReporter.reportWarning("signaling reconnect fail: ${err.code}"),x.event("[Signaling] Reconnect Failed ",e),e.code===403&&this.emit("authInfoExpired")}),this.signalingManager.on("onError",e=>{this.slsReporter.reportWarning("signaling error: ${err.message}"),x.event("[Signaling] Error ",e),this.onError(e)}),this.signalingManager.on("onUnknownMessage",e=>{if(e.msgtype==="proxyai"&&e.tid===this._proxyAiTid){let t=e.data.retcode;t===200&&(t=0),this.emit("AIAgentResult",t,this._agentParam.action,e.data.body)}})}backToUnpublishStatus(){var e,t;this.connectState=ae.AliRtcConnectionStatusDisconnected,(e=this.publisher)!=null&&e.isPublishing&&((t=this.publisher)==null||t.clearPublishState()),this.networkError=!1}handleUsersJoin(e){e.forEach(t=>{const i=t.userid;if(i){const r=this.bizControl.addUser(i,t.displayname,de.Join);x.event(`[${W.logName}]`,pe.UserJoined,r)}})}onLocalDeviceStatusChange(e){x.event(`[${W.logName}]`,Be.Local,e),this.signalingManager.reportStatus(e).then(()=>{x.debug("[signaling] reportStatus suc")}).catch(t=>{x.error("[signaling] reportStatus failed",t)})}resumePublishForNetworkRecovery(){return w(this,null,function*(){var e;try{yield(e=this.publisher)==null?void 0:e.resumePublish()}catch(t){const{code:i}=t;if(i===10205){let a=1;try{yield new Promise((c,n)=>{const h=setInterval(()=>w(this,null,function*(){var d;a>1&&(clearInterval(h),n()),a+=1;try{yield(d=this.publisher)==null?void 0:d.resumePublish(),clearInterval(h),c()}catch(u){const{code:f}=u;f!==10205&&(clearInterval(h),n())}}),1e3)})}catch(c){}}throw t}})}onNetworkRecovery(e){return w(this,null,function*(){var t;x.event(W.logName,"onNetworkRecovery",`rts isConnected: ${this.bizControl.rtsManager.isConnected}; rts isConnecting: ${this.bizControl.rtsManager.isConnecting}`,{users:e}),this.bizControl.rtsManager.isConnected||this.bizControl.rtsManager.isConnecting?e&&(yield this.resumeSubList(e)):(this.currentRoleCanPublish&&(yield this.resumePublishForNetworkRecovery()),yield this.resumeSubList()),this.networkError&&(this.networkError=!1,(t=this.publisher)==null||t.reportSelfDeviceStatus(),this.connectState=ae.AliRtcConnectionStatusConnected,this.emit("connectionStatusChange",ae.AliRtcConnectionStatusConnected,Bt.AliRtcConnectionSignalingHeartbeatAlive))})}resumeSubList(e){return w(this,null,function*(){if(e!=null&&e.length){const{joinList:t,leaveList:i,presentList:r}=this.bizControl.updateUsers(e);x.info(`[${W.logName}]`,"resumeSubList",{joinList:t,leaveList:i,presentList:r}),this.handleUsersJoin(t),i.forEach(a=>{x.event(W.logName,pe.UserLeft,a.userid,a.reason),this.emit("remoteUserOffLineNotify",a.userid,fr.AliRtcUserOfflineQuit)});for(let a=0;a<r.length;a++){const c=r[a],n=c.userid,h=this.bizControl.getRemoteUser(n);this.bizControl.onRemotePublishStateChange(c),h==null||h.updateSubscribe(de.Resume)}}else for(let t=0;t<this.remoteUsers.length;t++){const i=this.remoteUsers[t];try{i.restore(),i.updateSubscribe(de.Resume)}catch(r){}}})}retrySubscribe(e){return w(this,null,function*(){const t=this.bizControl.getRemoteUser(e);if(!t)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);t.restore(),t.updateSubscribe(de.Retry)})}onNetworkError(){this.connectState===ae.AliRtcConnectionStatusConnected&&(this.networkError||(this.connectState=ae.AliRtcConnectionStatusDisconnected,this.emit("connectionStatusChange",ae.AliRtcConnectionStatusDisconnected,Bt.AliRtcConnectionChangedNetworkInterrupted)),this.networkError=!0)}onError(e){this.slsReporter.reportError(e),x.event(W.logName,pe.Error,e)}setEnableDualVideoStream(e,t){this.bizControl.setEnableDualVideoStream(e,t)}hadPushStream(e){if(!this.publisher||!e)throw new O(U.ERR_INNER,"stream is not publishing")}getCurrentMicDeviceId(){var e;return(e=this.publisher)==null?void 0:e.getCurrentMicDeviceId()}setChannelProfile(e){if(![ae.AliRtcConnectionStatusInit,ae.AliRtcConnectionStatusDisconnected,ae.AliRtcConnectionStatusFailed].includes(this.connectState))throw new O(U.ERR_INNER,"cannot set channel profile in call");this.channelProfile=e,this.channelProfile===vt.AliRtcSdkCommunication&&(this.clientRole=wt.AliRtcSdkLive),this.signalingManager.setChannelProfile(e)}startAndPublishDefaultDevices(e){return w(this,null,function*(){var c,n,h,d,u;if(!this.publisher)return;const{hasCamera:t,hasMicrophone:i,hasScreenShare:r}=this.publisher;if(!t&&!i&&!r){try{yield(c=this.publisher)==null?void 0:c.startDefaultCamera(this._audioOnlyMode)}catch(f){x.warn(`[${W.logName}]`,"startDefaultCamera failed",f.code,f.message),f instanceof O&&this.occurError(f),this.occurError(new O(U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED,`auto start video failed, ${f.message||""}`))}try{yield(n=this.publisher)==null?void 0:n.startDefaultAudio()}catch(f){x.warn(`[${W.logName}]`,"startDefaultAUdio failed",f.code,f.message),f instanceof O&&this.occurError(f),this.occurError(new O(U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED,`auto start audio failed, ${f.message||""}`))}yield(h=this.publisher)==null?void 0:h.previewAll()}const a=((d=this.publisher)==null?void 0:d.publishStreams)||{};if(Object.values(a).some(f=>f))try{yield(u=this.publisher)==null?void 0:u.startPublish(!1,e)}catch(f){const l=[];a!=null&&a.audio&&l.push(U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED),a!=null&&a.video&&l.push(U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED),l.forEach(g=>{this.occurError(new O(g,`auto publish stream failed, ${f.message||""}`))})}})}setClientRole(e){return w(this,null,function*(){var t,i;try{if(this.channelProfile===vt.AliRtcSdkCommunication)return;if(!Object.values(wt).includes(e))throw new O(U.ERR_INVALID_ARGUMENTS,`set client role error, role value(${e}) is invalid`);if(this.clientRole===e)return;this.slsReporter.reportRoleUpdate(this.clientRole,e),this.isInCall()?this.clientRole===wt.AliRtcSdkInteractive?(this.bizControl.isSubscribing?yield(t=this.publisher)==null?void 0:t.clearStream():yield(i=this.publisher)==null?void 0:i.unPublish(),yield this.signalingManager.setClientRole(e)):(yield this.signalingManager.setClientRole(e),yield this.startAndPublishDefaultDevices(ht.ROLE_CHANGE)):yield this.signalingManager.setClientRole(e),this.clientRole=e}catch(r){throw r.code===403&&this.emit("authInfoExpired"),r}})}getCurrentClientRole(){return this.clientRole}setAudioOnlyMode(e){if(this.isInCall())throw new O(U.ERR_INNER,"can not change audioOnly mode in call");this._audioOnlyMode=e}setAudioRedEnabled(e){if(this.isInCall())throw new O(U.ERR_INNER,"can not change audioRedEnabled in call");this.bizControl.setAudioRedEnabled(e)}setCheckAuthInfoTimer(e,t){const i=1e3*(e-t);this._authInfoExpiredTimer=window.setTimeout(()=>{this.emit("authInfoExpired")},i),this._authInfoWillExpireTimer=window.setTimeout(()=>{this.emit("authInfoWillExpire")},i-3e4),this._serverCheckAuthInfoTimestamp=t,this._localCheckAuthInfoTimestamp=+Date.now()/1e3}clearCheckAuthInfoTimer(){this._authInfoExpiredTimer&&window.clearTimeout(this._authInfoExpiredTimer),this._authInfoWillExpireTimer&&window.clearTimeout(this._authInfoWillExpireTimer)}joinChannel(e,t,i){return w(this,null,function*(){var d,u;const r=Date.now();let a,c=typeof t=="string"?t:t==null?void 0:t.userName;if(typeof e=="string")try{const f=JSON.parse(window.atob(e));a={appId:f.appid,channelId:f.channelid,userId:f.userid,timestamp:f.timestamp,nonce:f.nonce,token:f.token}}catch(f){throw new O(U.ERR_INVALID_ARGUMENTS,`authInfo is invalid: ${f.message||""}`)}else a=e;c||(c=a.userId);const n={start:Date.now()};let h=Dr.checkAuthInfo(a);if(ae.AliRtcConnectionStatusInit!==this.connectState&&ae.AliRtcConnectionStatusDisconnected!==this.connectState&&ae.AliRtcConnectionStatusFailed!==this.connectState){const f=new O(U.ERR_JOIN_ALREADY_JOINED,"already joined");throw this.connectState===ae.AliRtcConnectionStatusConnecting&&(f.message="Repeated operation during login"),this.slsReporter.reportJoin(f.code,n,""),f}if(a.sessionId=ze.createCallid("web"),this.slsReporter.start(a),this.slsReporter.reportConnectionLatencyEvent(Ge.JOIN,et.START,"","",r),this.connectState=ae.AliRtcConnectionStatusConnecting,h)throw this.connectState=ae.AliRtcConnectionStatusFailed,this.slsReporter.reportJoin(h.code,n,""),this.slsReporter.reportJoinResult(h),h;x.setSessionID(a.appId,a.sessionId);try{const f=Date.now(),l=yield this.signalingManager.join(a,c,this.maxSignalingConnectRetryCount,n,i);l.l1ip&&this.publisher&&(this.publisher.preferredPubL1Ip=l.l1ip);const g=Date.now();this.connectState=ae.AliRtcConnectionStatusConnected,this.bizControl.init(a,l,{capabilityProfile:typeof t=="object"?t.capabilityProfile:Oi.Default}),this.setCheckAuthInfoTimer(a.timestamp,l.timestamp),this.liveTranscoding.setAuthInfo(a),this.slsReporter.reportJoin(0,n,l.tid),this.slsReporter.reportJoinResult(null),this.slsReporter.reportConnectionLatencyEvent(Ge.JOIN,et.SEND_SIG,"","",f),this.slsReporter.reportConnectionLatencyEvent(Ge.JOIN,et.RECV_RST,"","",g),this.slsReporter.reportConnectionLatencyEvent(Ge.JOIN,et.END,"","")}catch(f){const l=(d=f.code)!=null?d:-1,g=f.reason||f.message||"";throw this.connectState=ae.AliRtcConnectionStatusDisconnected,this.slsReporter.reportJoin(l,n,""),this.slsReporter.reportJoinResult(f),new O(l,g)}this.currentRoleCanPublish&&(yield this.startAndPublishDefaultDevices(ht.JOIN_CHANNEL)),(u=this.publisher)==null||u.reportSelfDeviceStatus(),this.remoteUsers.forEach(f=>{f.updateSubscribe(de.Join)})})}joinAIChannel(e,t,i){return w(this,null,function*(){return this._proxyAiTid=Qe(),this._agentParam=i,this.joinChannel(e,t,{bizconf:{l1leader:!0},proxyai:{tid:this._proxyAiTid,region:i.region,proxydata:JSON.stringify({Region:i.region,Action:i.action,ActionParams:i.params})}})})}leaveChannel(){return w(this,null,function*(){var t;this.slsReporter.reportLeaveInvoked(),yield this.bizControl.leave();let e=new Date().getTime();if(ae.AliRtcConnectionStatusConnected===this.connectState)try{let i;i=yield this.signalingManager.leave(),this.slsReporter.reportLeave(new Date().getTime()-e,0,(t=i==null?void 0:i.tid)!=null?t:"")}catch(i){this.slsReporter.reportLeave(new Date().getTime()-e,i.code,i.reason)}else this.slsReporter.reportLeave(0,0,"");this.networkError=!1,this.connectState=ae.AliRtcConnectionStatusDisconnected,this.clearCheckAuthInfoTimer(),this.liveTranscoding.clear(),this.slsReporter.stop(),this.signalingManager.reset(),x.reportEnd()})}isInCall(){return this.connectState===ae.AliRtcConnectionStatusConnected}refreshAuthInfo(e){return w(this,null,function*(){let t;if(typeof e=="string")try{const d=JSON.parse(window.atob(e));t={userId:d.userid,timestamp:d.timestamp,nonce:d.nonce,token:d.token}}catch(d){throw new O(U.ERR_INVALID_ARGUMENTS,`authInfo is invalid: ${d.message||""}`)}else t=e;const{userId:i,nonce:r,timestamp:a,token:c,role:n}=t,h={userId:i,nonce:r,timestamp:a,token:c,role:n};try{yield this.signalingManager.refreshAuthInfo(h),this.bizControl.refreshAuthInfo(h),this.liveTranscoding.refreshAuthInfo(h),this.clearCheckAuthInfoTimer(),this._serverCheckAuthInfoTimestamp&&this._localCheckAuthInfoTimestamp&&t.timestamp&&this.setCheckAuthInfoTimer(t.timestamp,this._serverCheckAuthInfoTimestamp+(Date.now()-this._localCheckAuthInfoTimestamp))}catch(d){throw d}})}isAudioOnly(){return this._audioOnlyMode}publishLocalAudioStream(e){return w(this,null,function*(){var t,i,r,a;(t=this.publisher)==null||t.setPublishLocalAudioStreamEnabled(e),this.connectState===ae.AliRtcConnectionStatusConnected&&(e?(i=this.publisher)!=null&&i.hasMicrophone?yield(r=this.publisher)==null?void 0:r.updateStreams():yield this.startAudioCapture():yield(a=this.publisher)==null?void 0:a.publishUpdate())})}isLocalAudioStreamPublished(){var e,t;return(t=(e=this.publisher)==null?void 0:e.publishLocalAudioStreamEnabled)!=null?t:!0}setDefaultSubscribeAllRemoteAudioStreams(e){this.bizControl.setAutoSubAudio(e)}subscribeAllRemoteAudioStreams(e){this.bizControl.setWantSubAudio(e)}subscribeRemoteAudioStream(e,t){if(t&&!this.bizControl.isWantSubAudio)throw new O(U.ERR_INVALID_ARGUMENTS,"subscribeAllRemoteAudioStreams(true) must be called first");this.bizControl.updateAudioWant(e,t)}resumeRemoteAudioStream(e){const t=this.bizControl.getRemoteUser(e);if(!t)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);t.resumeAudio()}stopRemoteAudioPlay(e){const t=this.bizControl.getRemoteUser(e);if(!t)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);t.stopPlayAudio()}publishLocalVideoStream(e){return w(this,null,function*(){var t,i,r,a;(t=this.publisher)==null||t.setPublishLocalVideoStreamEnabled(e),this.connectState===ae.AliRtcConnectionStatusConnected&&(e?(i=this.publisher)!=null&&i.hasCamera?yield(r=this.publisher)==null?void 0:r.updateStreams():yield this.enableLocalVideo():yield(a=this.publisher)==null?void 0:a.publishUpdate())})}isLocalVideoStreamPublished(){var e,t;return(t=(e=this.publisher)==null?void 0:e.publishLocalVideoStreamEnabled)!=null?t:!0}setRemoteDefaultVideoStreamType(e){[De.AliRtcVideoStreamTypeHigh,De.AliRtcVideoStreamTypeLow].includes(e)&&this.bizControl.setRemoteDefaultVideoStreamType(e)}setRemoteUserVideoStreamType(e,t){[De.AliRtcVideoStreamTypeHigh,De.AliRtcVideoStreamTypeLow].includes(t)&&this.bizControl.setRemoteUserVideoStreamType(e,t)}setDefaultSubscribeAllRemoteVideoStreams(e){this.bizControl.setAutoSubVideo(e),this.bizControl.setAutoSubScreen(e)}subscribeAllRemoteVideoStreams(e){this.bizControl.setWantSubVideo(e),this.bizControl.setWantSubScreen(e)}subscribeRemoteMediaStream(e,t,i,r){const a=this.bizControl.getRemoteUser(e);if(!a)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);!i||t!==ie.AliRtcVideoTrackScreen&&t!==ie.AliRtcVideoTrackBoth?a.setWantSubScreen(!1):a.setWantSubScreen(!0),!i||t!==ie.AliRtcVideoTrackCamera&&t!==ie.AliRtcVideoTrackBoth?a.setWantSubVideo(!1):a.setWantSubVideo(!0),a.setWantSubAudio(r),a.updateSubscribe(de.User)}resumeRemoteMediaStream(e,t){const i=this.bizControl.getRemoteUser(e);i&&i.resumeVideo(t)}getOnlineRemoteUsers(){return this.bizControl.remoteUsers.map(e=>e.userId)}getUserInfo(e){var t;return(t=this.bizControl.getRemoteUser(e))==null?void 0:t.remoteUserInfo}isUserOnline(e){return!!this.bizControl.remoteUsers.find(t=>t.userId===e)}startScreenShare(e){return w(this,null,function*(){var c;const t={video:!1,audio:!1},{audio:i=!1,videoTrack:r,audioTrack:a}=e||{};if(r||a){t.screen=!0;const n=new MediaStream;r&&n.addTrack(r),a&&n.addTrack(a),t.mediaStream=n}else t.screen=!i||{audio:!0};yield(c=this.publisher)==null?void 0:c.createLocalStream(t)})}stopScreenShare(){return w(this,null,function*(){var e;(e=this.publisher)==null||e.stopLocalStream({screen:!0})})}setScreenShareConfiguration(e){return w(this,null,function*(){var a;const{frameRate:t,bitrate:i}=e,r={};t&&(r.frameRate=t),i&&(r.maxBitrate=i),yield(a=this.publisher)==null?void 0:a.setScreenProfile(r)})}setScreenShareContentHint(e){return w(this,null,function*(){var t;e&&((t=this.publisher)==null||t.setScreenContentHint(e))})}publishLocalScreenShareStream(e,t){return w(this,null,function*(){var i,r,a;(i=this.publisher)==null||i.setPublishLocalScreenStreamEnabled(e),this.connectState===ae.AliRtcConnectionStatusConnected&&(e?(r=this.publisher)!=null&&r.hasScreenShare?yield this.publisher.updateStreams():yield this.startScreenShare(t):yield(a=this.publisher)==null?void 0:a.publishUpdate())})}isScreenSharePublished(){var e,t;return(t=(e=this.publisher)==null?void 0:e.publishLocalScreenStreamEnabled)!=null?t:!0}setAudioShareVolume(e){if(typeof e!="number")throw new O(U.ERR_INVALID_ARGUMENTS,"volume must be a number");this.bizControl.setAudioVolume({screen:Math.max(0,Math.min(e,400))/100})}enableAudioVolumeIndication(e){this.bizControl.enableAudioVolumeIndication(e)}muteLocalMic(e=!1){var t,i;(t=this.publisher)==null||t.muteLocalMic(e),this.connectState===ae.AliRtcConnectionStatusConnected&&this.isPublishing&&((i=this.publisher)==null||i.reportSelfDeviceStatus())}muteRemoteAudioPlaying(e,t=!1){const i=this.bizControl.getRemoteUser(e);if(!i)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);i.setAudioMuted(t)}muteAllRemoteAudioPlaying(e=!1){this.bizControl.setAudioMuted(e)}startAudioCapture(e){return w(this,null,function*(){var i;const t={audio:e||!0};yield(i=this.publisher)==null?void 0:i.createLocalStream(t)})}setAudioConstraints(e){return w(this,null,function*(){var t;yield(t=this.publisher)==null?void 0:t.setMicrophoneConstraints(e)})}stopAudioCapture(){var e;(e=this.publisher)==null||e.stopAudioCapture()}switchMicrophone(e,t){return w(this,null,function*(){var i,r,a,c;if(yield(i=this.publisher)==null?void 0:i.setMicrophoneDeviceId(e),!((r=this.publisher)!=null&&r.audioCaptureDisabled)){if(t)return void(yield(a=this.publisher)==null?void 0:a.createLocalStream({audio:!0,mediaStream:new MediaStream([t])}));yield(c=this.publisher)==null?void 0:c.createLocalStream({audio:{deviceId:e}})}})}setRecordingVolume(e){if(typeof e!="number")throw new O(U.ERR_INVALID_ARGUMENTS,"volume must be a number");this.bizControl.setAudioVolume({audio:Math.max(0,Math.min(e,400))/100})}setPlayoutVolume(e){if(typeof e!="number")throw new O(U.ERR_INVALID_ARGUMENTS,"volume must be a number");this.bizControl.setPlayoutVolume(Math.max(0,Math.min(e,100))/100)}setRemoteAudioVolume(e,t){const i=this.bizControl.getRemoteUser(e);if(!i)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);if(typeof t!="number")throw new O(U.ERR_INVALID_ARGUMENTS,"volume must be a number");i.setPlayoutVolume(Math.max(0,Math.min(t,100))/100)}setAudioProfile(e){return w(this,null,function*(){var t;yield(t=this.publisher)==null?void 0:t.setAudioProfile(e)})}getAudioTrack(e){return w(this,null,function*(){var i;if(!e)return(i=this.publisher)==null?void 0:i.audioTrack;const t=this.bizControl.getRemoteUser(e);return t==null?void 0:t.getAudioTrack})}setLocalViewConfig(e,t){return w(this,null,function*(){var i,r,a;if(this._audioOnlyMode)throw new O(U.ERR_INNER,"Cannot set local view in audio only mode");(i=this.bizControl)==null||i.setLocalViewConfig(e,t),t===ie.AliRtcVideoTrackCamera&&((r=this.publisher)!=null&&r.hasCamera)?yield this.startPreview():t===ie.AliRtcVideoTrackScreen&&((a=this.publisher)!=null&&a.hasScreenShare)&&(yield this.startPreviewScreen())})}setCameraCapturerConfiguration(e){return w(this,null,function*(){var d,u,f;const h=e,{cameraDirection:t,deviceId:i,bitrate:r,maxSendFrameRate:a}=h,c=Jt(h,["cameraDirection","deviceId","bitrate","maxSendFrameRate"]),n=Y({},c);r&&(n.maxBitrate=r),a&&(n.maxSendFrameRate=a),Object.keys(n).length>0&&(yield(d=this.publisher)==null?void 0:d.setVideoProfile(n)),t!==void 0&&((u=this.publisher)==null||u.setCameraDirection(t)),i&&((f=this.publisher)==null||f.setCameraDeviceId(i))})}setCameraCapturerContentHint(e){return w(this,null,function*(){var t;e&&((t=this.publisher)==null||t.setVideoContentHint(e))})}enableLocalVideo(e=!0){return w(this,null,function*(){var t,i,r,a,c,n,h,d,u,f,l;if(this._audioOnlyMode)throw new O(U.ERR_INNER,"Cannot enable local video in audio only mode");e?((i=(t=this.publisher)==null?void 0:t.publishStreams)!=null&&i.video&&((c=(a=(r=this.publisher)==null?void 0:r.publishStreams)==null?void 0:a.video)==null||c.disableVideo(),(u=(d=(h=(n=this.publisher)==null?void 0:n.publishStreams)==null?void 0:h.video)==null?void 0:d.videoTrack)==null||u.stop()),yield(f=this.publisher)==null?void 0:f.startCameraCapture()):yield(l=this.publisher)==null?void 0:l.stopCameraCapture()})}muteLocalCamera(e){return w(this,null,function*(){var t,i;(t=this.publisher)==null||t.muteLocalCamera(e),this.connectState===ae.AliRtcConnectionStatusConnected&&this.isPublishing&&((i=this.publisher)==null||i.reportSelfDeviceStatus())})}muteLocalScreen(e){return w(this,null,function*(){var t,i;(t=this.publisher)==null||t.muteLocalScreen(e),this.connectState===ae.AliRtcConnectionStatusConnected&&this.isPublishing&&((i=this.publisher)==null||i.reportSelfDeviceStatus())})}setRemoteViewConfig(e,t,i){this.bizControl.setRemoteViewConfig(t,e,i)}isCameraOn(){var e,t;return(t=(e=this.publisher)==null?void 0:e.hasCamera)!=null?t:!1}switchCamera(e,t){return w(this,null,function*(){var r,a,c,n,h,d;if(this._audioOnlyMode)throw new O(U.ERR_INNER,"Cannot switch camera in audio only mode");const i={};if(e?(i.deviceId=e,this.slsReporter.reportSwitchCamera(e)):t||(i.cameraDirection=((r=this.publisher)==null?void 0:r.cameraDirection)==="environment"?hi.CAMERA_FRONT:hi.CAMERA_REAR,this.slsReporter.reportSwitchCamera(((a=this.publisher)==null?void 0:a.cameraDirection)||"")),yield this.setCameraCapturerConfiguration(i),!((c=this.publisher)!=null&&c.cameraCaptureDisabled)){(h=(n=this.publisher)==null?void 0:n.cameraTrack)==null||h.stop();const u={video:!0};t&&(u.mediaStream=new MediaStream([t])),yield(d=this.publisher)==null?void 0:d.createLocalStream(u)}})}getCurrentCameraDeviceId(){var e;return(e=this.publisher)==null?void 0:e.getCurrentCameraDeviceId()}startPreview(){return w(this,null,function*(){var e,t;if(this._audioOnlyMode)throw new O(U.ERR_INNER,"Cannot start preview camera in audio only mode");(e=this.publisher)!=null&&e.hasCamera||(yield this.enableLocalVideo(!0)),yield(t=this.publisher)==null?void 0:t.previewAll({screen:!1})})}startPreviewScreen(e){return w(this,null,function*(){var t,i;if(this._audioOnlyMode)throw new O(U.ERR_INNER,"Cannot start preview screen share in audio only mode");(t=this.publisher)!=null&&t.hasScreenShare||(yield this.startScreenShare(e)),yield(i=this.publisher)==null?void 0:i.previewAll({primary:!1})})}stopPreview(){return w(this,null,function*(){var e;yield(e=this.publisher)==null?void 0:e.stopPreview({primary:!0,screen:!1})})}stopPreviewScreen(){return w(this,null,function*(){var e;yield(e=this.publisher)==null?void 0:e.stopPreview({primary:!1,screen:!0})})}getVideoTrack(e){return w(this,null,function*(){var a,c,n,h;const{userId:t,streamType:i}=e;if(!t)return i===ve.AliRtcSdkStreamTypeCapture?(a=this.publisher)==null?void 0:a.cameraTrack:(c=this.publisher)==null?void 0:c.screenTrack;const r=this.bizControl.getRemoteUser(t);return i===ve.AliRtcSdkStreamTypeCapture?(n=r==null?void 0:r.getCameraStream)==null?void 0:n.videoTrack:(h=r==null?void 0:r.getScreenStream)==null?void 0:h.videoTrack})}startPublishLiveStream(e,t){return w(this,null,function*(){return this.liveTranscoding.startPublishLiveStream(e,t)})}updatePublishLiveStream(e,t){return w(this,null,function*(){return this.liveTranscoding.updatePublishLiveStream(e,t)})}updatePublishLiveStreamWithTaskId(e,t){return this.liveTranscoding.updatePublishLiveStreamWithTaskId(e,t)}stopPublishLiveStream(e){return w(this,null,function*(){return this.liveTranscoding.stopPublishLiveStream(e)})}stopPublishLiveStreamWithTaskId(e){return this.liveTranscoding.stopPublishLiveStreamWithTaskId(e)}setEnableMediaExtensionMsg(e){var t;(t=this.bizControl)==null||t.setEnableMediaExtensionMsg(!!e)}sendMediaExtensionMsg(e,t){return w(this,null,function*(){return this.sendMediaExtensionMsgEx(e,t,5)})}sendMediaExtensionMsgEx(e,t,i){return w(this,null,function*(){var r;if(!this.publisher||!this.isPublishing)throw new O(U.ERR_INNER,"you should publish first");return this.slsReporter.reportSEIMessage(i,e.byteLength,t,0,!1),(r=this.publisher)==null?void 0:r.sendSEI(e,t,i)})}enablePlugin(e,t){this.bizControl.pluginManager.add(e,t)}removePlugin(e){this.bizControl.pluginManager.remove(e)}setPluginOption(e,t){const i=this.bizControl.pluginManager.get(e);i&&t&&i.setOptions(t)}getPluginOption(e){const t=this.bizControl.pluginManager.get(e);return t==null?void 0:t.getOptions()}isBeautyAvailable(){return this.bizControl.pluginManager.has("AliRtcBeauty")}isBeautyEnabled(){const e=this.bizControl.pluginManager.get("AliRtcBeauty");if(!e)throw new O(Mt.AliRtcPluginErrorNoFindPlugin,"you should enable beautyPlugin first");return!!(e!=null&&e.isEnable)}setBeautyEffect(e,t){const i=this.bizControl.pluginManager.get("AliRtcBeauty");if(!i)throw new O(Mt.AliRtcPluginErrorNoFindPlugin,"you should enable beautyPlugin first");e?i.enable():i.disable(),i.setOptions({basicBeauty:{skinBuffing:Math.max(Math.min(1,+t.smoothnessLevel),0),whitening:Math.max(Math.min(1,+t.whiteningLevel),0)}})}enableBackgroundExchange(e,t){const i=this.bizControl.pluginManager.get("AliRtcBeauty");if(!i||!i.isEnable)throw new O(Mt.AliRtcPluginErrorNoFindPlugin,"you should enable beautyPlugin first");const r={setSegmentBackgroundImage:{backgroundImgUrl:e?t:""}};e&&(r.segmentBackgroundProcess={enable:!1}),i.setOptions(r)}enableBackgroundBlur(e){const t=this.bizControl.pluginManager.get("AliRtcBeauty");if(!t||!t.isEnable)throw new O(Mt.AliRtcPluginErrorNoFindPlugin,"you should enable beautyPlugin first");const i={segmentBackgroundProcess:{type:0,enable:e}};e&&(i.setSegmentBackgroundImage={type:0,backgroundImgUrl:""}),t.setOptions(i)}setParameter(e){this.bizControl.setParameter(e)}getParameter(){return this.bizControl.getParameter()}sendDataChannelMessage(e){this.bizControl.sendDataChannelMessage(e)}},m(W,"logName","AliRtcEngine"),m(W,"logError",!0),m(W,"isSupported",Io),m(W,"isDualVideoStreamSupported",Pr.isSupport),m(W,"getCameraList",()=>w(W,null,function*(){return(yield G.AliRTS.getCameraList()).filter(e=>e.deviceId)})),m(W,"getMicrophoneList",()=>w(W,null,function*(){return(yield G.AliRTS.getMicList()).filter(e=>e.deviceId)})),m(W,"getSpeakerList",()=>w(W,null,function*(){return(yield G.AliRTS.getSpeakerList()).filter(e=>e.deviceId)})),m(W,"_instance"),m(W,"AliRtcSdkChannelProfile",vt),m(W,"AliRtcSdkClientRole",wt),m(W,"AliRtcVideoStreamType",De),m(W,"AliRtcVideoTrack",ie),m(W,"AliRtcAudioTrack",Yt),m(W,"AliRtcPublishState",Q),m(W,"AliRtcSubscribeState",ce),m(W,"AliRtcRawDataStreamType",ve),m(W,"AliRtcLogLevel",cr),m(W,"AliRtcEngineLocalDeviceType",lt),m(W,"AliRtcEngineLocalDeviceExceptionType",Ee),m(W,"AliRtcConnectionStatus",ae),m(W,"AliRtcConnectionStatusChangeReason",Bt),m(W,"AliRtcPlugin",Ut),m(W,"AliRtcPluginTrackType",si),m(W,"AliRtcLiveTranscodingParam",Ci),m(W,"AliRtcLiveTranscodingEncodeParam",gr),m(W,"AliRtcLiveTranscodingMixParam",qa),m(W,"AliRtcLiveTranscodingSingleParam",Ya),m(W,"AliRtcTranscodingClockWidget",Xa),m(W,"AliRtcTranscodingImage",Nr),m(W,"AliRtcTranscodingText",Za),m(W,"AliRtcTranscodingUser",en),m(W,"AliRtcLiveTranscodingMixMode",ai),m(W,"AliRtcLiveTranscodingStreamType",hr),m(W,"AliRtcLiveTranscodingSourceType",qt),m(W,"AliRtcLiveTranscodingTaskProfile",dr),m(W,"AliRtcLiveTranscodingAudioSampleRate",Ii),m(W,"AliRtcLiveTranscodingSegmentType",oi),m(W,"AliRtcLiveTranscodingFontType",ci),m(W,"AliRtcLiveTranscodingCropMode",lr),m(W,"AliRtcLiveTranscodingMediaProcessMode",wi),m(W,"AliRtcLiveTranscodingState",ur),m(W,"AliRtcLiveTranscodingErrorCode",dt),m(W,"AliRtcTrascodingPublishTaskStatus",pr),m(W,"AliRtcDataChannelMsg",kt),m(W,"AliRtcDataMsgType",Tr),m(W,"Plugin",Ut),W);j([C()],F.prototype,"destroy",1),j([C()],F.prototype,"backToUnpublishStatus",1),j([C()],F.prototype,"resumePublishForNetworkRecovery",1),j([C()],F.prototype,"onNetworkRecovery",1),j([C()],F.prototype,"resumeSubList",1),j([C(B)],F.prototype,"retrySubscribe",1),j([C(B)],F.prototype,"setEnableDualVideoStream",1),j([C(B)],F.prototype,"setChannelProfile",1),j([C(B)],F.prototype,"setClientRole",1),j([C(B)],F.prototype,"setAudioOnlyMode",1),j([C()],F.prototype,"clearCheckAuthInfoTimer",1),j([C(B)],F.prototype,"joinChannel",1),j([C(B)],F.prototype,"joinAIChannel",1),j([C(B)],F.prototype,"leaveChannel",1),j([C(B)],F.prototype,"refreshAuthInfo",1),j([C(B)],F.prototype,"publishLocalAudioStream",1),j([C(B)],F.prototype,"setDefaultSubscribeAllRemoteAudioStreams",1),j([C(B)],F.prototype,"subscribeAllRemoteAudioStreams",1),j([C(B)],F.prototype,"subscribeRemoteAudioStream",1),j([C(B)],F.prototype,"resumeRemoteAudioStream",1),j([C(B)],F.prototype,"stopRemoteAudioPlay",1),j([C(B)],F.prototype,"publishLocalVideoStream",1),j([C(B)],F.prototype,"setRemoteDefaultVideoStreamType",1),j([C(B)],F.prototype,"setRemoteUserVideoStreamType",1),j([C(B)],F.prototype,"setDefaultSubscribeAllRemoteVideoStreams",1),j([C(B)],F.prototype,"subscribeAllRemoteVideoStreams",1),j([C(B)],F.prototype,"subscribeRemoteMediaStream",1),j([C(B)],F.prototype,"resumeRemoteMediaStream",1),j([C(([s])=>[`${s==null?void 0:s.audio}`])],F.prototype,"startScreenShare",1),j([C()],F.prototype,"stopScreenShare",1),j([C(B)],F.prototype,"setScreenShareConfiguration",1),j([C(B)],F.prototype,"setScreenShareContentHint",1),j([C()],F.prototype,"publishLocalScreenShareStream",1),j([C(B)],F.prototype,"setAudioShareVolume",1),j([C(B)],F.prototype,"enableAudioVolumeIndication",1),j([C(B)],F.prototype,"muteLocalMic",1),j([C(B)],F.prototype,"muteRemoteAudioPlaying",1),j([C(B)],F.prototype,"muteAllRemoteAudioPlaying",1),j([C(B)],F.prototype,"startAudioCapture",1),j([C(B)],F.prototype,"setAudioConstraints",1),j([C()],F.prototype,"stopAudioCapture",1),j([C(B)],F.prototype,"switchMicrophone",1),j([C(B)],F.prototype,"setRecordingVolume",1),j([C(B)],F.prototype,"setPlayoutVolume",1),j([C(B)],F.prototype,"setRemoteAudioVolume",1),j([C(B)],F.prototype,"setAudioProfile",1),j([C(B)],F.prototype,"getAudioTrack",1),j([C(B)],F.prototype,"setLocalViewConfig",1),j([C(B)],F.prototype,"setCameraCapturerConfiguration",1),j([C(B)],F.prototype,"setCameraCapturerContentHint",1),j([C(B)],F.prototype,"enableLocalVideo",1),j([C(B)],F.prototype,"muteLocalCamera",1),j([C(B)],F.prototype,"muteLocalScreen",1),j([C(B)],F.prototype,"setRemoteViewConfig",1),j([C(B)],F.prototype,"switchCamera",1),j([C()],F.prototype,"startPreview",1),j([C()],F.prototype,"startPreviewScreen",1),j([C()],F.prototype,"stopPreview",1),j([C()],F.prototype,"stopPreviewScreen",1),j([C()],F.prototype,"startPublishLiveStream",1),j([C()],F.prototype,"updatePublishLiveStream",1),j([C()],F.prototype,"updatePublishLiveStreamWithTaskId",1),j([C()],F.prototype,"stopPublishLiveStream",1),j([C()],F.prototype,"stopPublishLiveStreamWithTaskId",1),j([C(B)],F.prototype,"setEnableMediaExtensionMsg",1),j([C(([s,o,e])=>[s.byteLength,o,e])],F.prototype,"sendMediaExtensionMsgEx",1),j([C(([s,o])=>[s.name||"",o])],F.prototype,"enablePlugin",1),j([C(B)],F.prototype,"removePlugin",1),j([C(B)],F.prototype,"setPluginOption",1),j([C(B)],F.prototype,"getPluginOption",1),j([C(B)],F.prototype,"setBeautyEffect",1),j([C(B)],F.prototype,"enableBackgroundExchange",1),j([C(B)],F.prototype,"enableBackgroundBlur",1),j([C(B)],F.prototype,"setParameter",1),j([C(([s])=>{var o;return[(o=s.data)==null?void 0:o.byteLength]})],F.prototype,"sendDataChannelMessage",1),j([C(B)],F,"setLogLevel",1);let on=F;const cn=new Yi({businessName:"imp-web-rtc",version:(hn=on.getSdkVersion())!=null?hn:"unknown",env:"prod",disabled:window.AliRtcOptionsDisableProxy===!0});cn.setReady();const pc=cn.wrap(on);K.AliRtcCapabilityProfile=Oi,K.AliRtcConnectionStatus=ae,K.AliRtcConnectionStatusChangeReason=Bt,K.AliRtcDataChannelMsg=kt,K.AliRtcDataMsgType=Tr,K.AliRtcEngineLocalDeviceExceptionType=Ee,K.AliRtcEngineLocalDeviceType=lt,K.AliRtcErrorCode=U,K.AliRtcLiveTranscodingAudioSampleRate=Ii,K.AliRtcLiveTranscodingCropMode=lr,K.AliRtcLiveTranscodingEncodeParam=gr,K.AliRtcLiveTranscodingErrorCode=dt,K.AliRtcLiveTranscodingFontType=ci,K.AliRtcLiveTranscodingMediaProcessMode=wi,K.AliRtcLiveTranscodingMixMode=ai,K.AliRtcLiveTranscodingMixParam=qa,K.AliRtcLiveTranscodingParam=Ci,K.AliRtcLiveTranscodingSegmentType=oi,K.AliRtcLiveTranscodingSingleParam=Ya,K.AliRtcLiveTranscodingSourceType=qt,K.AliRtcLiveTranscodingState=ur,K.AliRtcLiveTranscodingStreamType=hr,K.AliRtcLiveTranscodingTaskProfile=dr,K.AliRtcLocalStreamInfo=Cr,K.AliRtcLogLevel=cr,K.AliRtcPlugin=Ut,K.AliRtcPluginTrackType=si,K.AliRtcPluginType=La,K.AliRtcPublishState=Q,K.AliRtcRawDataStreamType=ve,K.AliRtcRemoteUserInfo=za,K.AliRtcSdkChannelProfile=vt,K.AliRtcSdkClientRole=wt,K.AliRtcSubscribeState=ce,K.AliRtcTranscodingClockWidget=Xa,K.AliRtcTranscodingImage=Nr,K.AliRtcTranscodingText=Za,K.AliRtcTranscodingUser=en,K.AliRtcTrascodingPublishTaskStatus=pr,K.AliRtcVideoStreamType=De,K.AliRtcVideoTrack=ie,K.default=pc,Object.defineProperties(K,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
129
|
+
`],{type:"text/javascript"}),t=(window.URL||window.webkitURL).createObjectURL(e);this.worker=new Worker(t);const{readable:i}=this.processor,{writable:r}=this.trackGenerator;this.worker.postMessage({type:"startRender",readable:i,writable:r,width:this.targetWidth,height:this.targetHeight,frameRate:this.targetFrameRate},[i,r])}updateOptions(e){super.updateOptions(e),this.worker&&this.worker.postMessage(X({type:"updateOptions"},e))}dispose(){try{this.processor.readable.cancel(),this.trackGenerator.writable.close()}catch(e){}}getVideoTrack(){return this.trackGenerator}}class Hr{static isSupport(){return typeof HTMLCanvasElement.prototype.captureStream=="function"}static getInstance(a,e){return tn.isSupport()?new tn(a,e):en.isSupport()?new en(a,e):new mc(a,e)}}class gc extends Nt{constructor(){super(...arguments);f(this,"hasVideoTrack",!1);f(this,"videoScaler")}get initOptions(){return{width:320,height:180,frameRate:15}}setOptions(e){var t;this.options=e,(t=this.videoScaler)==null||t.updateOptions(e)}isSupported(){return Hr.isSupport()}shouldUpdate(e){return this.hasVideoTrack!==!!e.currentVideoTrack}process(e){return T(this,null,function*(){if(e.currentVideoTrack){if(this.hasVideoTrack=!0,!this.videoScaler){const i=this.options||this.initOptions;this.videoScaler=Hr.getInstance(e.currentVideoTrack,i)}const t=this.videoScaler.getVideoTrack();t&&e.updateDualVideoTrack(t)}else e.updateDualVideoTrack(),this.emit("updated"),this.videoScaler&&this.videoScaler.dispose()})}clear(e){super.clear(e),this.hasVideoTrack=!1,e==null||e.updateDualVideoTrack()}}function ni(s,a,e,t){return new(e||(e=Promise))(function(i,r){function n(h){try{o(t.next(h))}catch(l){r(l)}}function c(h){try{o(t.throw(h))}catch(l){r(l)}}function o(h){var l;h.done?i(h.value):(l=h.value,l instanceof e?l:new e(function(d){d(l)})).then(n,c)}o((t=t.apply(s,a||[])).next())})}var Bt,_t;function rn(){return ni(this,void 0,void 0,function*(){let s=!1;try{s=yield(()=>T(this,null,function*(){return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]))}))()}catch(a){s=!1}return console.log("isSupportedSIMD",s),s})}typeof SuppressedError=="function"&&SuppressedError,(_t=Bt||(Bt={}))[_t.ERROR=0]="ERROR",_t[_t.WARN=1]="WARN",_t[_t.INFO=2]="INFO",_t[_t.LOG=3]="LOG",_t[_t.DEBUG=4]="DEBUG";class ve{static error(...a){var e;ve.logLevel>=Bt.ERROR&&((e=console.error)===null||e===void 0||e.call(console,`[${ve.logTag}] `,...a))}static warn(...a){var e;ve.logLevel>=Bt.WARN&&((e=console.warn)===null||e===void 0||e.call(console,`[${ve.logTag}] `,...a))}static info(...a){var e;ve.logLevel>=Bt.INFO&&((e=console.info)===null||e===void 0||e.call(console,`[${ve.logTag}] `,...a))}static log(...a){var e;ve.logLevel>=Bt.LOG&&((e=console.log)===null||e===void 0||e.call(console,`[${ve.logTag}] `,...a))}static debug(...a){var e;ve.logLevel>=Bt.DEBUG&&((e=console.debug)===null||e===void 0||e.call(console,`[${ve.logTag}] `,...a))}}ve.logLevel=Bt.WARN,ve.logTag="aliyun-audio-3a";class fc{}class sn extends fc{static isSupported(){return function(){if(typeof window=="object"&&window!==null){const a="AudioWorklet"in window,e="WebAssembly"in window;return a&&e}return!1}()}static isSupportedSIMD(){return ni(this,void 0,void 0,function*(){return yield rn()})}static setLogger(a){ve.logLevel=a}constructor(a){super(),this.channelCount=1,this.sampleRate=48e3,this.collectDumpOutputData=[],this.collectDumpNearInputData=[],this.collectDumpFarInputData=[],this.collectDumpMetaData=[],this.statUpdateTimer=0,this.statUpdateInterval=5e3,this.options=Object.assign({aecOn:!0,ansOn:!0,agcOn:!0,hdOn:!0,ansMode:1,dumpOn:!1,aiaecOn:!1,wasmCdnPath:"https://g.alicdn.com/code/npm/@ali/aliyun-audio-3a/0.0.5/"},a||{})}initWASM(a,e,t){return ni(this,void 0,void 0,function*(){ve.log("initWASM",a,e,t);const i=n=>ni(this,void 0,void 0,function*(){try{const c=yield fetch(n,{credentials:"same-origin"});if(!c.ok)throw this.onLoadError(new Error(`Failed to fetch WASM: ${c.status}:${c.statusText}, url:${n}`)),new Error(`Failed to fetch WASM: ${c.statusText}`);return c.arrayBuffer()}catch(c){throw this.onLoadError(new Error("WASM load error")),ve.error("Error fetching WASM:",c),c}}),r=n=>ni(this,void 0,void 0,function*(){return fetch(n).then(c=>c.text())});try{const n=yield rn(),c=this.options.wasmCdnPath+"audio_module_v2.wasm",o=this.options.wasmCdnPath+"audio_module_v2_simd.wasm",l=yield i(n?o:c),d=this.options.wasmCdnPath+"audio_module_v2.js",p=this.options.wasmCdnPath+"audio_module_v2_simd.js",u=n?p:d,g=yield r(u);a.port.postMessage(Object.assign({type:"init",channelCount:e,sampleRate:t,wasmBuffer:l,isSupportSIMD:n,audioModuleScript:g,logLevel:ve.logLevel},this.options),[l])}catch(n){throw ve.error("Error initializing WASM:",n),n}a.port.onmessage=n=>{n.data.type==="init_done"&&this.onLoadSuccess(void 0),n.data.type==="dump_output_data"&&this.onDumpOutputData(n.data.data),n.data.type==="dump_near_data"&&this.onDumpNearInputData(n.data.data),n.data.type==="dump_far_data"&&this.onDumpFarInputData(n.data.data),n.data.type==="dump_meta_data"&&this.onDumpMeatData(n.data.data),n.data.type==="output_log"&&this.onOutputLog(n.data.data),n.data.type==="apm_stat_data"&&this.onStatData(n.data.data)}})}createProcessor(a,e,t,i,r){return ni(this,void 0,void 0,function*(){this.audioContext=a,this.audioContext.resume(),this.channelCount=t,this.sampleRate=i;try{const o=new Blob(['!function(){"use strict";var Oc=Object.defineProperty,Uc=Object.defineProperties;var Bc=Object.getOwnPropertyDescriptors;var $i=Object.getOwnPropertySymbols,Hc=Object.getPrototypeOf,Tn=Object.prototype.hasOwnProperty,Cn=Object.prototype.propertyIsEnumerable,Fc=Reflect.get;var Gr=(W,q,se)=>q in W?Oc(W,q,{enumerable:!0,configurable:!0,writable:!0,value:se}):W[q]=se,X=(W,q)=>{for(var se in q||(q={}))Tn.call(q,se)&&Gr(W,se,q[se]);if($i)for(var se of $i(q))Cn.call(q,se)&&Gr(W,se,q[se]);return W},Pt=(W,q)=>Uc(W,Bc(q));var Qt=(W,q)=>{var se={};for(var Qe in W)Tn.call(W,Qe)&&q.indexOf(Qe)<0&&(se[Qe]=W[Qe]);if(W!=null&&$i)for(var Qe of $i(W))q.indexOf(Qe)<0&&Cn.call(W,Qe)&&(se[Qe]=W[Qe]);return se};var f=(W,q,se)=>(Gr(W,typeof q!="symbol"?q+"":q,se),se);var qr=(W,q,se)=>Fc(Hc(W),se,q);var T=(W,q,se)=>new Promise((Qe,ci)=>{var Ji=mt=>{try{zt(se.next(mt))}catch(He){ci(He)}},Et=mt=>{try{zt(se.throw(mt))}catch(He){ci(He)}},zt=mt=>mt.done?Qe(mt.value):Promise.resolve(mt.value).then(Ji,Et);zt((se=se.apply(W,q)).next())});function t(t,e,a,n){return new(a||(a=Promise))((function(s,i){function o(t){try{h(n.next(t))}catch(t){i(t)}}function r(t){try{h(n.throw(t))}catch(t){i(t)}}function h(t){var e;t.done?s(t.value):(e=t.value,e instanceof a?e:new a((function(t){t(e)}))).then(o,r)}h((n=n.apply(t,e||[])).next())}))}var e;"function"==typeof SuppressedError&&SuppressedError,function(t){t[t.ERROR=0]="ERROR",t[t.WARN=1]="WARN",t[t.INFO=2]="INFO",t[t.LOG=3]="LOG",t[t.DEBUG=4]="DEBUG"}(e||(e={}));class a{static error(...t){var n;a.logLevel>=e.ERROR&&(null===(n=console.error)||void 0===n||n.call(console,`[${a.logTag}] `,...t))}static warn(...t){var n;a.logLevel>=e.WARN&&(null===(n=console.warn)||void 0===n||n.call(console,`[${a.logTag}] `,...t))}static info(...t){var n;a.logLevel>=e.INFO&&(null===(n=console.info)||void 0===n||n.call(console,`[${a.logTag}] `,...t))}static log(...t){var n;a.logLevel>=e.LOG&&(null===(n=console.log)||void 0===n||n.call(console,`[${a.logTag}] `,...t))}static debug(...t){var n;a.logLevel>=e.DEBUG&&(null===(n=console.debug)||void 0===n||n.call(console,`[${a.logTag}] `,...t))}}a.logLevel=e.WARN,a.logTag="aliyun-audio-3a";const n=Float32Array.BYTES_PER_ELEMENT,s=Uint16Array.BYTES_PER_ELEMENT;class i{constructor(t,e,a,n,s){this._channelData=[],this._name=t,this._isInitialized=!1,this._module=e,this._length=a,this._ringLength=2*a,this._maxChannelCount=s?Math.min(s,32):n,this._channelCount=n,this._allocateHeap(),this._isInitialized=!0,this._readIndex=0,this._writeIndex=0,this._framesAvailable=0,this._channelDataLocal=[];for(let t=0;t<this._channelCount;++t)this._channelDataLocal[t]=new Float32Array(this._ringLength)}_allocateHeap(){const t=this._length*n,e=this._channelCount*t;this._dataPtr=this._module._malloc(e),this._channelData=[];for(let e=0;e<this._channelCount;++e){const a=this._dataPtr+e*t,n=a+t;this._channelData[e]=this._module.HEAPF32.subarray(a>>s,n>>s)}}adaptChannel(t){t<this._maxChannelCount&&(this._channelCount=t)}get length(){return this._isInitialized?this._length:null}get numberOfChannels(){return this._isInitialized?this._channelCount:null}get maxChannelCount(){return this._isInitialized?this._maxChannelCount:null}getChannelData(t){return void 0!==t&&t>=this._channelCount?null:void 0===t?this._channelData:this._channelData[t]}getHeapAddress(){return this._dataPtr}getPointer(){return this._dataPtr}free(){this._isInitialized=!1,null!==this._dataPtr&&this._module._free(this._dataPtr),this._channelData=[]}get framesAvailable(){return this._framesAvailable}push(t){const e=t[0].length;for(let a=0;a<e;++a){for(let e=0;e<this._channelCount;++e)this._channelDataLocal[e][this._writeIndex]=t[e][a];this._writeIndex=(this._writeIndex+1)%this._ringLength}this._framesAvailable+=e,this._framesAvailable>this._ringLength&&(console.warn(this._name,"Too many frames available, overflow"),this._framesAvailable=this._ringLength,this._writeIndex=0)}pull(t){if(0===this._framesAvailable)return void console.warn(this._name,"No frames available");const e=t[0].length;for(let a=0;a<e;++a){for(let e=0;e<this._channelCount;++e)t[e][a]=this._channelDataLocal[e][this._readIndex];this._readIndex=(this._readIndex+1)%this._ringLength}this._framesAvailable-=e,this._framesAvailable<0&&(this._framesAvailable=0,this._readIndex=0)}}class o{constructor(t){this.inited=!1,this.handle=null,this.channelCount=1,this.isEnable=!0,this.dumpAudioData=!1,this.kernelBufferSize=512,this.node=t,this.onDumpOutputDataFunction=null,this.onDumpNearDataFunction=null,this.onDumpFarDataFunction=null,this.onDumpMetaDataFunction=null,this.wasmInvoker=null,this._nearAudioBuffer={},this._outputAudioBuffer={}}destructor(){this.wasmInvoker=null,this.handle=null}init(n){return t(this,void 0,void 0,(function*(){const{wasmBuffer:t,audioModuleScript:s,channelCount:o=1,sampleRate:r=44100,dumpAudioData:h=!1,logLevel:l=e.DEBUG}=n;a.logLevel=l,a.log("AudioAPM init",JSON.stringify(n)),this.channelCount=o,this.dumpAudioData=h;try{const e=new Function(`let module={};let exports={};${s}; return module`)();this.wasmInvoker=yield e.exports({wasmBinary:t})}catch(t){this.node.port.postMessage({type:"error",message:"audioModule init error"}),a.error(t)}this._nearAudioBuffer=new i("inBuffer",this.wasmInvoker,this.kernelBufferSize,2*this.channelCount,32),this._outputAudioBuffer=new i("outBuffer",this.wasmInvoker,this.kernelBufferSize,this.channelCount,32);const u=this.wasmInvoker.addFunction(((t,e)=>{const a=this.wasmInvoker.HEAPU8.subarray(t,t+e),n=String.fromCharCode.apply(null,a);this.node&&this.node.port&&this.node.port.postMessage({type:"output_log",message:"output_log",data:n})}),"vii");if(this.wasmInvoker.__apm_log_callback(u),this.handle=this.wasmInvoker.__apm_create(n.aecOn?1:0,n.ansOn?1:0,n.agcOn?1:0,n.hdOn?1:0,r,o,n.dumpOn?1:0,this.kernelBufferSize),console.log("options.aiaecOn:",n.aiaecOn),n.aiaecOn){const t=102;this.wasmInvoker.__apm_set_param(this.handle,t,7)}this.node.port.postMessage({type:"init_done",message:"init done"}),this.inited=!0}))}getStatData(){if(this.wasmInvoker&&this.isEnable){let t=this.wasmInvoker.__apm_get_stat(this.handle),e=this.wasmInvoker.UTF8ToString(t);this.wasmInvoker._free(t),console.log("getStatData:",e),this.node&&this.node.port&&this.node.port.postMessage({type:"apm_stat_data",message:"apm_stat_data",data:e})}}onOutputLog(t){console.log("[WASM_LOG]",t)}destory(){return t(this,void 0,void 0,(function*(){var t;try{null===(t=this.wasmInvoker)||void 0===t||t.__apm_destory(this.handle),this.inited=!1}catch(t){a.error(t)}finally{this.handle=null}}))}enable(){this.isEnable=!0,a.log("APM enable")}disable(){this.isEnable=!1,a.log("APM disable")}getStat(){if(null==this.wasmInvoker||null==this.handle)return"";let t=this.wasmInvoker.__apm_get_stat(this.handle),e=this.wasmInvoker.UTF8ToString(t);return this.wasmInvoker._free(t),e}startDump(){this.onDumpOutputDataFunction=this.wasmInvoker.addFunction(((t,e)=>{const a=this.wasmInvoker.HEAPU8.subarray(t,t+e),n=new Uint8Array(a);this.node&&this.node.port&&this.node.port.postMessage({type:"dump_output_data",message:"dump_output_data",data:n})}),"vii"),this.onDumpNearDataFunction=this.wasmInvoker.addFunction(((t,e)=>{const a=this.wasmInvoker.HEAPU8.subarray(t,t+e),n=new Uint8Array(a);this.node&&this.node.port&&this.node.port.postMessage({type:"dump_near_data",message:"dump_near_data",data:n})}),"vii"),this.onDumpFarDataFunction=this.wasmInvoker.addFunction(((t,e)=>{const a=this.wasmInvoker.HEAPU8.subarray(t,t+e),n=new Uint8Array(a);this.node&&this.node.port&&this.node.port.postMessage({type:"dump_far_data",message:"dump_far_data",data:n})}),"vii"),this.onDumpMetaDataFunction=this.wasmInvoker.addFunction(((t,e)=>{const a=this.wasmInvoker.HEAPU8.subarray(t,t+e),n=new Uint8Array(a);this.node&&this.node.port&&this.node.port.postMessage({type:"dump_meta_data",message:"dump_meta_data",data:n})}),"vii"),this.wasmInvoker.__apm_dump_start(this.handle,this.onDumpOutputDataFunction,this.onDumpNearDataFunction,this.onDumpFarDataFunction,this.onDumpMetaDataFunction)}stopDump(){this.wasmInvoker.__apm_dump_stop(this.handle),this.wasmInvoker&&(this.wasmInvoker.removeFunction(this.onDumpOutputDataFunction),this.wasmInvoker.removeFunction(this.onDumpNearDataFunction),this.wasmInvoker.removeFunction(this.onDumpFarDataFunction),this.wasmInvoker.removeFunction(this.onDumpMetaDataFunction))}process(t,e,a){if(!this.inited||!this.isEnable){for(let e=0;e<this.channelCount;e++){a[e].set(t[e])}return}const n=this.channelCount;let s=0;if(this.handle&&this.isEnable){const i=t[0].length,o=[];for(let a=0;a<n;a++)e[a]&&e[a].length>0&&(s=1),o.push(t[a]||new Float32Array(i).fill(0)),o.push(e[a]||new Float32Array(i).fill(0));if(this._nearAudioBuffer.push(o),this._nearAudioBuffer.framesAvailable>=this.kernelBufferSize){this._nearAudioBuffer.pull(this._nearAudioBuffer.getChannelData()),this.wasmInvoker.__apm_process_new(this.handle,this._nearAudioBuffer.getHeapAddress(),this._outputAudioBuffer.getHeapAddress(),n,s);const t=this._outputAudioBuffer.getChannelData();this._outputAudioBuffer.push(t)}this._outputAudioBuffer.pull(a)}}}class r extends AudioWorkletProcessor{constructor(){super(),this.apm=new o(this),this.port.onmessage=t=>{const e=t.data||{};switch(a.log("onmessage data",e),e.type){case"init":this.apm.init(e);break;case"destroy":this.apm.destory();break;case"enable":this.apm.enable();break;case"disable":this.apm.disable();break;case"start_dump":this.apm.startDump();break;case"stop_dump":this.apm.stopDump();break;case"get_stat_data":this.apm.getStatData();break;default:a.warn("Unknown message type:",e.type)}}}process(t,e){const a=t[0],n=t.length>1?t[1]:[],s=e[0];return this.apm.process(a,n,s),!0}}registerProcessor("aliyun-web-3a-processor",r)}();\n'],{type:"application/javascript"}),h=URL.createObjectURL(o);yield this.audioContext.audioWorklet.addModule(h)}catch(o){throw ve.error("Failed to add module to audio worklet:",o),o}let n=new AudioWorkletNode(this.audioContext,"aliyun-web-3a-processor",{numberOfInputs:2,outputChannelCount:[t]});this.workletNode=n,e.connect(n),r&&(this.farNode=r,r.connect(n,0,1));const c=this.audioContext.createMediaStreamDestination();n.connect(c),this.targetMediaTrack=c.stream.getAudioTracks()[0],yield this.initWASM(n,t,i),this.statUpdateTimer=window.setInterval(()=>{this.getStatData()},this.statUpdateInterval)})}addFarNode(a){this.workletNode&&(this.farNode&&this.farNode.disconnect(this.workletNode),a&&(this.farNode=a,a.connect(this.workletNode,0,1)))}getStatData(){var a;try{(a=this.workletNode)===null||a===void 0||a.port.postMessage({type:"get_stat_data"})}catch(e){ve.error("Failed to post message to worklet node:",e)}}destroy(){if(this.statUpdateTimer&&window.clearInterval(this.statUpdateTimer),this.audioContext&&this.workletNode&&this.workletNode.port)try{this.workletNode.port.postMessage({type:"destroy"}),this.workletNode.port.onmessage=null,this.workletNode.disconnect(),ve.log("postMessage destroy")}catch(a){ve.error("Failed to post message to worklet node:",a)}}startDump(){var a;try{(a=this.workletNode)===null||a===void 0||a.port.postMessage({type:"start_dump"})}catch(e){ve.error("Failed to post message to worklet node:",e)}}stopDump(){var a;try{(a=this.workletNode)===null||a===void 0||a.port.postMessage({type:"stop_dump"})}catch(e){ve.error("Failed to post message to worklet node:",e)}setTimeout(()=>{this.onDumpOutputData(null,!0),this.onDumpNearInputData(null,!0),this.onDumpFarInputData(null,!0),this.onDumpMeatData(null,!0)},3e3)}onDumpOutputData(a,e=!1){if(a&&a.length>0&&this.collectDumpOutputData.push(a),e&&this.collectDumpOutputData.length>0||1024*this.collectDumpOutputData.length>=this.getMaxDumpBytes()){let t=new Blob(this.collectDumpOutputData);this.onDumpData(t,"output_"+this.sampleRate+"hz_"+this.channelCount+"ch.pcm"),this.collectDumpOutputData=[]}}onDumpNearInputData(a,e=!1){if(a&&a.length>0&&this.collectDumpNearInputData.push(a),e&&this.collectDumpNearInputData.length>0||1024*this.collectDumpNearInputData.length>=this.getMaxDumpBytes()){let t=new Blob(this.collectDumpNearInputData);this.onDumpData(t,"near_input_"+this.sampleRate+"hz_"+this.channelCount+"ch.pcm"),this.collectDumpNearInputData=[]}}onDumpFarInputData(a,e=!1){if(a&&a.length>0&&this.collectDumpFarInputData.push(a),e&&this.collectDumpFarInputData.length>0||1024*this.collectDumpFarInputData.length>=this.getMaxDumpBytes()){let t=new Blob(this.collectDumpFarInputData);this.onDumpData(t,"far_input_"+this.sampleRate+"hz_"+this.channelCount+"ch.pcm"),this.collectDumpFarInputData=[]}}onDumpMeatData(a,e=!1){if(a&&a.length>0&&this.collectDumpMetaData.push(a),e&&this.collectDumpMetaData.length>0||1024*this.collectDumpMetaData.length>=this.getMaxDumpBytes()){let t=new Blob(this.collectDumpMetaData);this.onDumpData(t,"meta_"+this.sampleRate+"hz_"+this.channelCount+"ch.pcm"),this.collectDumpMetaData=[]}}getMaxDumpBytes(){return 600*Number(this.sampleRate.toFixed(0))*Number(this.channelCount.toFixed(0))*2}enable(){var a;if(!((a=this.workletNode)===null||a===void 0)&&a.port)try{this.workletNode.port.postMessage({type:"enable"}),ve.log("postMessage enable")}catch(e){ve.error("Failed to post message to worklet node:",e)}}disable(){var a;if(!((a=this.workletNode)===null||a===void 0)&&a.port)try{ve.log("postMessage disable"),this.workletNode.port.postMessage({type:"disable"})}catch(e){ve.error("Failed to post message to worklet node:",e)}}on(a,e){a==="loaderror"&&(this.onLoadError=e),a==="loadsuccess"&&(this.onLoadSuccess=e),a==="dumpdata"&&(this.onDumpData=e),a==="outputlog"&&(this.onOutputLog=e),a==="statdata"&&(this.onStatData=e)}onLoadError(a){console.log("onLoadError",a)}onLoadSuccess(a){console.log("onLoadSuccess",a)}onDumpData(a,e){console.log("onDumpData",a,e)}onOutputLog(a){console.log("[WASM]",a)}onStatData(a){console.log("onStatData:",a)}}const zi="[AliyunAudio3A] ";class Sc extends Nt{constructor(e){super("AliRtcAudioProcessPlugin",Le.AliRtcSdkStreamTypeCapture,ti.AUDIO);f(this,"audioProcessor");f(this,"slsReporter");f(this,"audioContext",new AudioContext({sampleRate:48e3}));f(this,"farNode");f(this,"createNode",e=>this.audioContext.createMediaStreamSource(new MediaStream([e])));this.options=e,this.slsReporter=e==null?void 0:e.slsReporter,this.zIndex=7,document.addEventListener("click",this.activeAudioContext)}activeAudioContext(){this.audioContext.resume(),document.removeEventListener("click",this.activeAudioContext)}audioUpdated(e){var t,i;return((t=this.lastInputAudioTrack)==null?void 0:t.id)!==((i=e.currentAudioTrack)==null?void 0:i.id)}videoUpdated(e){return console.log("videoUpdated",e),!1}setOptions(e){var t;!this.farNode&&e.farMediaStream&&(this.farNode=this.audioContext.createMediaStreamSource(e.farMediaStream),this.audioProcessor&&((t=this.audioProcessor)==null||t.addFarNode(this.farNode)),this.options=X(X({},this.options),e))}isSupported(){return sn.isSupported()}shouldUpdate(e){return!!(e.originAudioTrack&&!this.audioProcessor||!e.originAudioTrack&&this.audioProcessor)}process(e){return T(this,null,function*(){var t;if(!e.currentAudioTrack)return e.updateAudioTrack(),void this.clear(e);if(!this.audioProcessor){V.info(zi,"create audio processor this.options:",this.options),this.audioProcessor=new sn({aecOn:!0,ansOn:!0,agcOn:!0,dumpOn:((t=this.options)==null?void 0:t.dumpAudioData)||!1,aiaecOn:this.options.aiaecOn||!1,wasmCdnPath:this.options.wasmCdnPath||"https://g.alicdn.com/code/npm/@ali/aliyun-audio-3a/0.0.5/"});const i=this.createNode(e.currentAudioTrack);yield this.audioProcessor.createProcessor(this.audioContext,i,1,48e3,this.farNode),this.audioProcessor.on("dumpdata",(r,n)=>{let c=3e3;n.includes("far")?c=5e3:n.includes("output")?c=1e4:n.includes("meta")&&(c=8e3),setTimeout(()=>{const o=URL.createObjectURL(r),h=document.createElement("a");h.href=o,h.download=n,document.body.appendChild(h),h.click(),document.body.removeChild(h)},c)}),this.audioProcessor.on("loadsuccess",()=>{var r;V.info(zi,"loadsuccess"),this.options.dumpAudioData&&((r=this.audioProcessor)==null||r.startDump())}),this.audioProcessor.on("loaderror",r=>{V.info(zi,"loaderror:",r==null?void 0:r.message)}),this.audioProcessor.on("outputlog",r=>{V.info(zi,"outputlog:",r)}),this.audioProcessor.on("statdata",r=>{var n;r&&((n=this.slsReporter)==null||n.reportPublishAudio3A("","","",r||""))}),e.updateAudioTrack(this.audioProcessor.targetMediaTrack)}})}clear(e){var t,i,r;this.options.dumpAudioData&&((t=this.audioProcessor)==null||t.stopDump()),super.clear(e),(i=this.audioProcessor)==null||i.destroy(),this.audioProcessor=void 0,document.removeEventListener("click",this.activeAudioContext),(r=this.farNode)==null||r.disconnect(),this.farNode=void 0}dump(){var e;(e=this.audioProcessor)==null||e.stopDump()}}var Wi=(s=>(s[s.Default=0]="Default",s[s.Human=1]="Human",s[s.Robot=2]="Robot",s))(Wi||{}),bc=Object.defineProperty,vc=Object.getOwnPropertyDescriptor,an=(s,a,e,t)=>{for(var i,r=t>1?void 0:t?vc(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&&bc(a,e,r),r};const Fr=(Ft=class extends se{constructor(e){super();f(this,"self");f(this,"remoteUser");f(this,"sendReadyMsg",!1);f(this,"hasPubDataChannel",!1);f(this,"hasSubDataChannel",!1);f(this,"readyMsgSuccess",!1);f(this,"sendReadyMsgTimer");f(this,"startReadyMsgTime");f(this,"onSubscribeDataChannel",e=>{!this.remoteUser&&e&&(this.hasSubDataChannel=!0,this.remoteUser=e,this.remoteUser.on("remoteDataChannelMessage",this.onCheckReadyMsg),this.trySendReadyMsg())});f(this,"onCheckReadyMsg",(e,t)=>{var i,r;if(this.sendReadyMsg&&!this.readyMsgSuccess)try{const n=new TextDecoder().decode(t.data),c=JSON.parse(n);c.key==="aliyun_aigc"&&c.type==="ready_resp"&&((i=c.data)==null?void 0:i.ready)===!0&&(V.event(`[${Ft.logName}]`,"onCheckReadyMsg success"),this.readyMsgSuccess=!0,this.emit("dcready",e),(r=this.remoteUser)==null||r.off("remoteDataChannelMessage",this.onCheckReadyMsg),window.clearTimeout(this.sendReadyMsgTimer))}catch(n){}});f(this,"onDataPublishStateChange",(e,t)=>{t===ie.AliRtcStatePublished&&(this.hasPubDataChannel=!0,this.trySendReadyMsg())});this.self=e,this.self.on("dataPublishStateChanged",this.onDataPublishStateChange)}destory(){this.self.off("dataPublishStateChanged",this.onDataPublishStateChange),window.clearTimeout(this.sendReadyMsgTimer),this.remoteUser=void 0,this.sendReadyMsg=!1,this.hasPubDataChannel=!1,this.hasSubDataChannel=!1,this.readyMsgSuccess=!1,this.startReadyMsgTime=0}trySendReadyMsg(){V.event(`[${Ft.logName}]`,`trySendReadyMsg: pub(${this.hasPubDataChannel}, sub: ${this.hasSubDataChannel})`),this.hasPubDataChannel&&this.hasSubDataChannel&&(this.sendReadyMsg=!0,this.sendReadyMsgLoop())}sendReadyMsgLoop(e=0){return T(this,null,function*(){const t=JSON.stringify({key:"aliyun_aigc",version:"1.0",type:"ready_req",data:{ready:!0}});try{this.self.sendDataChannelMessage(new Vt(new TextEncoder().encode(t).buffer))}catch(n){}this.startReadyMsgTime||(this.startReadyMsgTime=Date.now());let i=50;const r=Date.now()-this.startReadyMsgTime;i=r<1e3?50:r<2e3?100:r<3e3?500:2e3,e>30?V.event(`[${Ft.logName}]`,"sendReadyMsgLoop fail after 30 times"):this.sendReadyMsgTimer=window.setTimeout(()=>{this.sendReadyMsgLoop(e+1)},i)})}},f(Ft,"logName","DataChannelReadyHelper"),Ft);an([C()],Fr.prototype,"destory",1),an([C()],Fr.prototype,"sendReadyMsgLoop",1);let yc=Fr;class Rc{constructor(a){f(this,"_useSysEchoCancellation",!0);f(this,"_useSysNoiseSuppression",!0);f(this,"_useSysAutoGainControl",!0);f(this,"_useAIAEC",!1);f(this,"_enableSoft3A",!1);f(this,"_dumpAudioData",!1);f(this,"_useAudio3AConfigFromServer",!0);a&&Object.assign(this,a)}get useSysEchoCancellation(){return this._useSysEchoCancellation}set useSysEchoCancellation(a){this._useSysEchoCancellation=a}get useSysNoiseSuppression(){return this._useSysNoiseSuppression}set useSysNoiseSuppression(a){this._useSysNoiseSuppression=a}get useSysAutoGainControl(){return this._useSysAutoGainControl}set useSysAutoGainControl(a){this._useSysAutoGainControl=a}get useAIAEC(){return this._useAIAEC}set useAIAEC(a){this._useAIAEC=a}get enableSoft3A(){return this._enableSoft3A}set enableSoft3A(a){this._enableSoft3A=a}get dumpAudioData(){return this._dumpAudioData}set dumpAudioData(a){this._dumpAudioData=a}get useAudio3AConfigFromServer(){return this._useAudio3AConfigFromServer}set useAudio3AConfigFromServer(a){this._useAudio3AConfigFromServer=a}loadFromLocalConfig(a){var e,t,i,r,n,c,o;this.useAudio3AConfigFromServer=(e=a.useAudio3AConfigFromServer)!=null?e:this.useAudio3AConfigFromServer,this.useSysEchoCancellation=(t=a.useSysEchoCancellation)!=null?t:this.useSysEchoCancellation,this.useSysNoiseSuppression=(i=a.useSysNoiseSuppression)!=null?i:this.useSysNoiseSuppression,this.useSysAutoGainControl=(r=a.useSysAutoGainControl)!=null?r:this.useSysAutoGainControl,this.useAIAEC=(n=a.useAIAEC)!=null?n:this.useAIAEC,this.enableSoft3A=(c=a.enableSoft3A)!=null?c:this.enableSoft3A,this.dumpAudioData=(o=a.dumpAudioData)!=null?o:this.dumpAudioData}loadFromServerConfig(a){if(a&&typeof a=="object"){const e=fi(a,"enableSoft3A"),t=Si(a,"enableSoft3A");if(e===!0&&t===!0&&(this.enableSoft3A=!0),this.enableSoft3A){if(a.archCfgs){const i=fi(a,"useAIAEC");i!==void 0&&(this.useAIAEC=i);const r=fi(a,"useSysNoiseSuppression");r!==void 0&&(this.useSysNoiseSuppression=r);const n=fi(a,"useSysEchoCancellation");n!==void 0&&(this.useSysEchoCancellation=n);const c=fi(a,"useSysAutoGainControl");c!==void 0&&(this.useSysAutoGainControl=c)}if(a.config){const i=Si(a,"useAIAEC");i!==void 0&&(this.useAIAEC=i);const r=Si(a,"useSysNoiseSuppression");r!==void 0&&(this.useSysNoiseSuppression=r);const n=Si(a,"useSysEchoCancellation");n!==void 0&&(this.useSysEchoCancellation=n);const c=Si(a,"useSysAutoGainControl");c!==void 0&&(this.useSysAutoGainControl=c)}V.info("setAudio3AConfig:","enableSoft3A",this.enableSoft3A,", useAIAEC",this.useAIAEC,", useSysNoiseSuppression",this.useSysNoiseSuppression,", useSysEchoCancellation",this.useSysEchoCancellation,", useSysAutoGainControl",this.useSysAutoGainControl)}}}}var Ac=Object.defineProperty,_c=Object.getOwnPropertyDescriptor,rt=(s,a,e,t)=>{for(var i,r=t>1?void 0:t?_c(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&&Ac(a,e,r),r};class qe extends se{constructor(e){super();f(this,"self");f(this,"userMap",{});f(this,"usersViewMap",{});f(this,"rtsManager");f(this,"localStreamManager");f(this,"authInfo");f(this,"signalingManager");f(this,"pluginManager");f(this,"audioMixerPlugin");f(this,"dualVideoPlugin");f(this,"blankAudioPlugin");f(this,"audioProcessorPlugin");f(this,"slsReporter");f(this,"statsMonitorId");f(this,"autoSubAudio",!0);f(this,"autoSubVideo",!0);f(this,"autoSubScreen",!0);f(this,"wantSubAudio",!0);f(this,"wantSubVideo",!0);f(this,"wantSubScreen",!0);f(this,"defaultStreamType",We.AliRtcVideoStreamTypeHigh);f(this,"audioMuted",!1);f(this,"playoutVolume",1);f(this,"refreshUrlTimer");f(this,"audioVolumeIndicationInterval",0);f(this,"indicationTimer",0);f(this,"parameter",{});f(this,"audio3AConfig",new Rc);f(this,"dcReadyHelper");const{signalingManager:t,slsReporter:i}=e;this.signalingManager=t,this.addSignalingManagerListener(),this.slsReporter=i,this.pluginManager=new rc,this.localStreamManager=new hc(this.pluginManager,this.slsReporter),this.rtsManager=new nc(this.localStreamManager,this.slsReporter,this.parameter),this.self=new Yo({rtsManager:this.rtsManager,localStreamManager:this.localStreamManager,slsReporter:this.slsReporter,signalingManager:this.signalingManager,pluginManager:this.pluginManager,audioVolumeIndicationInterval:this.audioVolumeIndicationInterval,parameter:this.parameter}),this.audioMixerPlugin=new pc,this.pluginManager.add(this.audioMixerPlugin),this.dualVideoPlugin=new gc("dualVideoPlugin"),new q.AliRTS.SupportUtil().checkScreenCapture()&&this.pluginManager.add(new lc)}addSignalingManagerListener(){this.signalingManager.on("onNotifyPublish",e=>{e.forEach(t=>{var i;(i=t==null?void 0:t.tracks)==null||i.forEach(r=>{var n;if(r.msid===M.Audio&&r.userdata)try{const c=JSON.parse(r.userdata);c.agent_instance&&((n=this.slsReporter)==null||n.setCustomFields({ageniid:c.agent_instance}))}catch(c){console.error("Failed to parse userdata:",c)}})}),this.slsReporter.reportConnectionLatencyEvent(ot.RECV_NOTIFY_PUBLISH,"","",""),V.event("[Signaling] Notify Publish ",e),e.forEach(t=>{this.onRemotePublishStateChange(t)})}),this.signalingManager.stsManager.on("onTokenUpdate",(e,t)=>{this.slsReporter.updateToken(t,e)})}isAutoSubAudio(){return this.autoSubAudio}setAutoSubAudio(e){this.autoSubAudio=e}isAutoSubVideo(){return this.autoSubVideo}setAutoSubVideo(e){this.autoSubVideo=e}isAutoSubScreen(){return this.autoSubScreen}setAutoSubScreen(e){this.autoSubScreen=e}isWantSubAudio(){return this.wantSubAudio}setWantSubAudio(e){this.wantSubAudio=e,this.remoteUsers.forEach(t=>{t.setWantSubAudio(e),t.updateSubscribe(Se.User)})}isWantSubVideo(){return this.wantSubVideo}setWantSubVideo(e){this.wantSubVideo=e,this.remoteUsers.forEach(t=>{t.setWantSubVideo(e),t.updateSubscribe(Se.User)})}isWantSubScreen(){return this.wantSubScreen}setWantSubScreen(e){this.wantSubScreen=e,this.remoteUsers.forEach(t=>{t.setWantSubScreen(e),t.updateSubscribe(Se.User)})}setRemoteDefaultVideoStreamType(e){this.defaultStreamType=e,this.remoteUsers.forEach(t=>{t.setRemoteDefaultVideoStreamType(e)})}setRemoteUserVideoStreamType(e,t){var i;(i=this.getRemoteUser(e))==null||i.setRemoteDefaultVideoStreamType(t)}setAudioMuted(e){this.audioMuted=e,this.remoteUsers.forEach(t=>{t.setAudioMuted(e)})}setLocalViewConfig(e,t){var r;if(!e)return(r=this.publisher)==null?void 0:r.setViewConfig(null,t);const i=Nr(e);i.length!==0&&i.forEach(n=>{var c,o;(c=this.publisher)==null||c.resetElement(n),Object.values(this.usersViewMap).forEach(({cameraViews:h=[],screenViews:l=[]})=>{h.includes(n)&&h.splice(h.indexOf(n),1),l.includes(n)&&l.splice(l.indexOf(n),1)}),(o=this.publisher)==null||o.setViewConfig(i,t)})}setRemoteViewConfig(e,t,i){var n,c;if(!t)return(n=this.userMap[e])==null?void 0:n.setViewConfig(null,i);const r=Nr(t);r.length!==0&&(r.forEach(o=>{var h;(h=this.publisher)==null||h.resetElement(o),Object.values(this.usersViewMap).forEach(({cameraViews:l=[],screenViews:d=[]})=>{l.includes(o)&&l.splice(l.indexOf(o),1),d.includes(o)&&d.splice(d.indexOf(o),1)})}),(c=this.userMap[e])==null||c.setViewConfig(r,i))}get channel(){var e;return(e=this.authInfo)==null?void 0:e.channelId}get userId(){var e;return(e=this.authInfo)==null?void 0:e.userId}get remoteUsers(){return Object.values(this.userMap)}get publisher(){return this.self}get isSubscribing(){var e;return((e=this.remoteUsers)!=null?e:[]).some(t=>{const{isAudioSubscribing:i,isVideoSubscribing:r,isScreenSubscribing:n}=t;return i||r||n})}onRemotePublishStateChange(e){var p;const{userid:t,callid:i,subscribe:r,pubid:n="",tracks:c}=e,o=(p=r==null?void 0:r.pullstreamurl)!=null?p:"";let h=this.getRemoteUser(t);if(!h)return;const l=h.streamInfo.audioTrackInfo,d=h.streamInfo.videoTrackInfo;h.updateRemoteTracks(i,o,n,c),h.updateSubscribe(Se.Publish),l===h.streamInfo.audioTrackInfo&&d===h.streamInfo.videoTrackInfo||this.emit("remoteTrackAvailableChange",t,h.streamInfo.audioTrackInfo,h.streamInfo.videoTrackInfo)}setTimeoutToUpdateAllStreamUrls(e){var r;if(!e)return;let t=354e4;const i=(r=function(n){var c,o;try{const h=new URL(n),[l,d]=h.pathname.slice(1).split("/"),p=/(\w+)(web\w{5}-\w{4}-\w{4}-\w{4}-\w{12})/.exec(d),u=p==null?void 0:p[1],g=p==null?void 0:p[2],m=new URLSearchParams(h.search);return{appId:l,channelId:u,sessionId:g,timeoutTs:1e3*parseInt((o=(c=m.get("auth_key"))==null?void 0:c.split("-")[0])!=null?o:"0")}}catch(h){return null}}(e))==null?void 0:r.timeoutTs;i&&(t=i-Date.now()-6e4),this.refreshUrlTimer=window.setTimeout(()=>T(this,null,function*(){var c;const n=yield this.signalingManager.refreshUrl({pushstreamurl:this.self.url,users:this.remoteUsers.map(o=>({userid:o.userId,subscribe:{pullstreamurl:o.streamUrl}}))});n.pushstreamurl&&(this.self.url=n.pushstreamurl),(c=n.users)==null||c.forEach(o=>{var l;const h=this.getRemoteUser(o.userid);h&&((l=o.subscribe)!=null&&l.pullstreamurl)&&(h.streamUrl=o.subscribe.pullstreamurl)}),this.setTimeoutToUpdateAllStreamUrls(n.pushstreamurl)}),t)}init(e,t,i){var r;this.authInfo=e,this.self.enableAudioVolumeIndication(this.audioVolumeIndicationInterval),this.self.initInfo(e,t.pushstreamurl),this.audio3AConfig.useAudio3AConfigFromServer&&this.audio3AConfig.loadFromServerConfig((r=t==null?void 0:t.config)==null?void 0:r.data),this.setupAudioProcessingPluginIfNeeded(),i.capabilityProfile===Wi.Human&&(this.dcReadyHelper=new yc(this.self),this.dcReadyHelper.on("dcready",n=>{var c;this.emit("remoteUserSubscribedDataChannel",n),(c=this.dcReadyHelper)==null||c.destory(),this.dcReadyHelper=void 0})),this.setTimeoutToUpdateAllStreamUrls(t.pushstreamurl),t.users.forEach(n=>{const c=n.userid;if(c){const o=this.addUser(c,n.displayname,Se.InRoom);this.emit("remoteUserJoin",c,0);const{callid:h,subscribe:l,tracks:d}=n;o.updateRemoteTracks(h,(l==null?void 0:l.pullstreamurl)||"","",d),this.emit("remoteTrackAvailableChange",c,o.streamInfo.audioTrackInfo,o.streamInfo.videoTrackInfo)}}),this.startStatsMonitor()}leave(){return T(this,null,function*(){var e;this.stopStatsMonitor(),this.refreshUrlTimer!==void 0&&(window.clearTimeout(this.refreshUrlTimer),this.refreshUrlTimer=void 0),Object.values(this.usersViewMap).forEach(({cameraViews:t=[],screenViews:i=[]})=>{t.forEach(r=>{r.srcObject=null,r._playPromise=void 0}),i.forEach(r=>{r.srcObject=null,r._playPromise=void 0})}),this.usersViewMap={};for(let t in this.userMap)this.userMap[t]&&(this.userMap[t].clear(),delete this.userMap[t]);this.self.leave(),(e=this.dcReadyHelper)==null||e.destory(),this.dcReadyHelper=void 0,this.localStreamManager.stop(),this.rtsManager.clear(),this.authInfo=void 0})}clear(){return T(this,null,function*(){yield this.leave(),this.self.clear(),this.pluginManager.removeAll()})}startStatsMonitor(){this.statsMonitorId=window.setInterval(()=>T(this,null,function*(){if(this.publisher){const{audio:i,video:r,candidate:n}=yield this.publisher.getStats();i&&i.length>0&&this.emit("rtcLocalAudioStats",i),r&&r.length>0&&this.emit("rtcLocalVideoStats",r),n&&this.emit("rtcStats",n)}const e=[],t=[];for(const i of this.remoteUsers){const{audio:r,video:n}=yield i.getStats();r&&r.forEach(c=>{e.push(c)}),n&&n.forEach(c=>{t.push(c)})}e.length>0&&this.emit("rtcRemoteAudioStats",e),t.length>0&&this.emit("rtcRemoteVideoStats",t)}),2e3)}stopStatsMonitor(){this.statsMonitorId&&clearInterval(this.statsMonitorId)}addUser(e,t,i){return this.userMap[e]||(this.userMap[e]=this.executeAddUser(e,t,i)),this.userMap[e]}executeAddUser(e,t,i){const r=new ic({userId:e,displayName:t,rtsManager:this.rtsManager,signalingManager:this.signalingManager,usersViewMap:this.usersViewMap,slsReporter:this.slsReporter,localUser:this.self,audioVolumeIndicationInterval:this.audioVolumeIndicationInterval,playoutVolume:this.playoutVolume,parameter:this.parameter});return r.on(Xe.Remote,this.onRemoteDeviceStatusChange.bind(this)),r.on(we.PullStreamStats,this.onRemoteStatReport.bind(this)),r.on(we.RtsSubscribeExceeds,this.onSubscribeExceeds.bind(this)),r.on("audioSubscribeStateChanged",(n,c,o,h)=>{this.emit("audioSubscribeStateChanged",n,c,o,h,this.channel||"")}),r.on("videoSubscribeStateChanged",(n,c,o,h)=>{this.emit("videoSubscribeStateChanged",n,c,o,h,this.channel||"")}),r.on("screenSubscribeStateChanged",(n,c,o,h)=>{this.emit("screenSubscribeStateChanged",n,c,o,h,this.channel||"")}),r.on("dataSubscribeStateChanged",(n,c,o,h)=>{var l;o===me.AliRtcStateSubscribed&&((l=this.dcReadyHelper)==null||l.onSubscribeDataChannel(this.userMap[n])),this.emit("dataSubscribeStateChanged",n,c,o,h,this.channel||"")}),r.on("remoteAudioAutoPlayFail",n=>{this.emit("remoteAudioAutoPlayFail",n)}),r.on("remoteVideoAutoPlayFail",(n,c)=>{this.emit("remoteVideoAutoPlayFail",n,c)}),r.on("remoteAudioPlayError",(n,c)=>{this.emit("remoteAudioPlayError",n,c)}),r.on("remoteVideoPlayError",(n,c)=>{this.emit("remoteVideoPlayError",n,c)}),r.on("remoteSubscribeError",n=>{this.emit("remoteSubscribeError",n,r.userId)}),r.on("occurError",n=>{this.emit("occurError",n,r.userId)}),r.on("remoteDataChannelMessage",(n,c)=>{this.emit("remoteDataChannelMessage",n,c)}),r.setWantSubAudio(this.autoSubAudio&&this.wantSubAudio),r.setWantSubVideo(this.autoSubVideo&&this.wantSubVideo),r.setWantSubScreen(this.autoSubScreen&&this.wantSubScreen),r.setRemoteDefaultVideoStreamType(this.defaultStreamType),r.setAudioMuted(this.audioMuted),(this.autoSubAudio||this.autoSubVideo||this.autoSubScreen)&&r.updateSubscribe(i),r}onRemoteDeviceStatusChange(e,t){e===we.MuteAudio?this.emit("userAudioMuted",t,!0):e===we.UnmuteAudio?this.emit("userAudioMuted",t,!1):e===we.MuteVideo?this.emit("userVideoMuted",t,!0):e===we.UnmuteVideo?this.emit("userVideoMuted",t,!1):e===we.MuteScreen?this.emit("userScreenMuted",t,!0):e===we.UnmuteScreen&&this.emit("userScreenMuted",t,!1)}onRemoteStatReport(e,t,i){this.emit(we.PullStreamStats,e,t,i)}onSubscribeExceeds(e,t){this.emit(we.RtsSubscribeExceeds,e,t)}removeLeftUser(e){return T(this,null,function*(){e.userid&&this.userMap[e.userid]&&(yield this.userMap[e.userid].clear(!1),delete this.userMap[e.userid])})}updateUsers(e){const t=[],i=[],r={};e.forEach(o=>{o.userid&&(this.userMap[o.userid]?(i.push(o),r[o.userid]=this.userMap[o.userid]):(t.push(o),r[o.userid]=this.executeAddUser(o.userid,o.displayname,Se.Resume)))});const n=Object.keys(this.userMap),c=[];return n.forEach(o=>{r[o]||c.push({userid:o,reason:"",leavecode:Er.AliRtcUserOfflineQuit})}),this.userMap=r,{joinList:t,leaveList:c,presentList:i}}getRemoteUser(e){return this.userMap[e]}updateRemoteUserDeviceStatus(e){e&&e.userid&&this.userMap[e.userid]&&this.userMap[e.userid].updateRemoteUserDeviceStatus(e.status)}updateAudioWant(e,t){const i=this.userMap[e];if(!i)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);i.setWantSubAudio(t),t?i.updateSubscribe(Se.User):i.stopSubscribe({audio:!0})}updateVideoWant(e,t){const i=this.userMap[e];if(!i)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);i.setWantSubVideo(t),t?i.updateSubscribe(Se.User):i.stopSubscribe({video:!0})}updateScreenWant(e,t){const i=this.userMap[e];if(!i)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);i.setWantSubScreen(t),t?i.updateSubscribe(Se.User):i.stopSubscribe({screen:!0})}stopIndication(){this.indicationTimer&&window.clearInterval(this.indicationTimer)}startIndication(e){this.stopIndication(),this.indicationTimer=window.setInterval(()=>{const t=this.remoteUsers.map(i=>({userId:i.userId,volume:i.getAudioLevel()||0}));t.unshift({userId:"",volume:this.self.getAudioLevel()||0}),this.emit("audioVolume",t)},e)}setEnableDualVideoStream(e,t){if(!this.dualVideoPlugin)return;t&&this.dualVideoPlugin.setOptions(t);const i=this.pluginManager.has(this.dualVideoPlugin.name);e?!i&&this.pluginManager.add(this.dualVideoPlugin):i&&this.pluginManager.remove(this.dualVideoPlugin.name)}setAudioVolume(e){var t;(t=this.audioMixerPlugin)==null||t.setOptions(e)}enableAudioVolumeIndication(e){this.audioVolumeIndicationInterval!==e&&(this.audioVolumeIndicationInterval>0&&e<=0&&this.stopIndication(),e>0&&this.startIndication(e),this.audioVolumeIndicationInterval=e,this.remoteUsers.forEach(t=>{t.enableAudioVolumeIndication(e)}),this.self.enableAudioVolumeIndication(e))}setPlayoutVolume(e){this.playoutVolume=e,this.remoteUsers.forEach(t=>{t.setPlayoutVolume(e)})}refreshAuthInfo(e){this.authInfo&&(this.authInfo=X(X({},this.authInfo),e)),e.userId&&this.self.refreshUserInfo(e.userId)}setEnableMediaExtensionMsg(e){this.rtsManager.setEncodedInsertableStreams(e)}setAudioRedEnabled(e){this.rtsManager.setAudioRedEnabled(e)}setParameter(e){var i,r,n,c;const t=JSON.parse(e);Object.keys(t).forEach(o=>{const h=this.parameter[o],l=t[o];this.parameter[o]=typeof h=="object"&&typeof l=="object"?X(X({},h),l):l}),t.enableBlankAudio===!0?(this.blankAudioPlugin||(this.blankAudioPlugin=new dc),this.pluginManager.has((i=this.blankAudioPlugin)==null?void 0:i.name)||this.pluginManager.add(this.blankAudioPlugin)):t.enableBlankAudio===!1&&(this.blankAudioPlugin&&this.pluginManager.remove((r=this.blankAudioPlugin)==null?void 0:r.name),(n=this.blankAudioPlugin)==null||n.clear(),this.blankAudioPlugin=void 0),t.audio&&((c=this.audio3AConfig)==null||c.loadFromLocalConfig(t.audio))}setupAudioProcessingPluginIfNeeded(){this.audio3AConfig.enableSoft3A?(this.audioProcessorPlugin||(this.audioProcessorPlugin=new Sc({dumpAudioData:this.audio3AConfig.dumpAudioData,aiaecOn:this.audio3AConfig.useAIAEC,slsReporter:this.slsReporter})),this.audioProcessorPlugin&&!this.pluginManager.has(this.audioProcessorPlugin.name)&&this.pluginManager.add(this.audioProcessorPlugin)):this.audioProcessorPlugin&&(this.pluginManager.remove(this.audioProcessorPlugin.name),this.audioProcessorPlugin=void 0),this.self.setMicrophoneConstraints({echoCancellation:this.audio3AConfig.useSysEchoCancellation,noiseSuppression:this.audio3AConfig.useSysNoiseSuppression,autoGainControl:this.audio3AConfig.useSysAutoGainControl})}getParameter(){return JSON.stringify(this.parameter)}sendDataChannelMessage(e){return this.self.sendDataChannelMessage(e)}}f(qe,"logName","BizControl"),rt([C()],qe.prototype,"init",1),rt([C()],qe.prototype,"leave",1),rt([C()],qe.prototype,"clear",1),rt([C(B)],qe.prototype,"addUser",1),rt([C()],qe.prototype,"removeLeftUser",1),rt([C()],qe.prototype,"updateUsers",1),rt([C(B)],qe.prototype,"updateAudioWant",1),rt([C(B)],qe.prototype,"updateVideoWant",1),rt([C(B)],qe.prototype,"updateScreenWant",1),rt([C()],qe.prototype,"stopIndication",1),rt([C()],qe.prototype,"startIndication",1),rt([C(B)],qe.prototype,"setEnableDualVideoStream",1),rt([C(B)],qe.prototype,"setAudioVolume",1),rt([C()],qe.prototype,"enableAudioVolumeIndication",1);const jr=s=>T(this,null,function*(){const a=new Uint8Array(160).fill(170),e=new TextEncoder().encode(s),t=yield window.crypto.subtle.importKey("raw",a,{name:"HMAC",hash:{name:"SHA-1"}},!1,["sign"]),i=yield window.crypto.subtle.sign("HMAC",t,e);return Array.from(new Uint8Array(i)).map(r=>r.toString(16).padStart(2,"0")).join("")});class wc{constructor(a){f(this,"authInfo");f(this,"slsReporter");this.slsReporter=a}doRequest(a,e){var c;const t=this.authInfo;if(!t)return Promise.reject(vt.LiveTranscodingErrorInvalidParam);const i=Uo[a],r={appid:t.appId,userid:t.userId,channelid:t.channelId,timestamp:t.timestamp,token:t.token,nonce:t.nonce?t.nonce:"",requestid:et.createCallid(),tokensid:!1,session:(c=t.sessionId)!=null?c:et.createCallid()},n=Object.keys(r).map(o=>`${o}=${encodeURIComponent(r[o])}`).join("&");return fetch(`https://gw.rtn.aliyuncs.com${i}?${n}`,{method:"POST",headers:{"Content-Type":"application/json; charset=UTF-8"},body:JSON.stringify(e)}).then(o=>o.status!==200?(this.slsReporter.reportTranscodingError(o.status,e.taskid||""),Promise.reject(new O(U.ERR_INNER,`transcoding request failed, status: ${o.status}`))):o).catch(o=>Promise.reject(new O(U.ERR_INNER,`transcoding request failed, err: ${o.message}`)))}setAuthInfo(a){this.authInfo=a}clear(){this.authInfo=void 0}startPublishLiveStream(a,e){return T(this,null,function*(){if(!this.authInfo)return Promise.reject(vt.LiveTranscodingErrorInvalidParam);const t=yield jr(a.split("?")[0]),i=it.MPU_TASK_TRANSACTION_UPDATE,r=e.toJson(i,this.authInfo,t,a);return this.doRequest(i,r)})}startPublishLiveStreamWithTaskId(a,e){return T(this,null,function*(){if(!this.authInfo)return Promise.reject(vt.LiveTranscodingErrorInvalidParam);const t=it.MPU_TASK_TRANSACTION_UPDATE,i=e.toJson(t,this.authInfo,a);return this.doRequest(t,i)})}updatePublishLiveStream(a,e){return T(this,null,function*(){if(!this.authInfo)return Promise.reject(vt.LiveTranscodingErrorInvalidParam);const t=yield jr(a.split("?")[0]),i=it.MPU_TASK_TRANSACTION_UPDATE,r=e.toJson(i,this.authInfo,t,a);return this.doRequest(i,r)})}updatePublishLiveStreamWithTaskId(a,e){return T(this,null,function*(){if(!this.authInfo)return Promise.reject(vt.LiveTranscodingErrorInvalidParam);const t=it.MPU_TASK_TRANSACTION_UPDATE,i=e.toJson(t,this.authInfo,a);return this.doRequest(t,i)})}stopPublishLiveStream(a){return T(this,null,function*(){if(!this.authInfo)return Promise.reject(vt.LiveTranscodingErrorInvalidParam);const e=yield jr(a.split("?")[0]),t=it.MPU_TASK_TRANSACTION_STOP,i=new xi().toJson(t,this.authInfo,e,a);return this.doRequest(t,i)})}stopPublishLiveStreamWithTaskId(a){if(!this.authInfo)return Promise.reject(vt.LiveTranscodingErrorInvalidParam);const e=it.MPU_TASK_TRANSACTION_STOP,t=new xi().toJson(e,this.authInfo,a);return this.doRequest(e,t)}refreshAuthInfo(a){this.authInfo&&this.setAuthInfo(X(X({},this.authInfo),a))}}class zr{static checkString(a){return typeof a=="string"}static checkNumber(a){return typeof a=="number"}static checkHtmlVideoElement(a){return a&&a.nodeName==="VIDEO"}static checkHtmlAudioElement(a){return a&&a.nodeName==="AUDIO"}static checkAuthInfo(a){return a?a.appId?a.channelId?a.userId?a.timestamp?zr.checkNumber(a.timestamp)?a.token?null:new O(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no token founded"):new O(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"timestamp is not number"):new O(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no timestamp founded"):new O(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no userId founded"):new O(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no channelId founded"):new O(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no appId founded"):new O(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no authInfo founded")}static checkMediaStreamTrack(a){return a instanceof MediaStreamTrack}static checkVideoEncoderConfiguration(a){return a&&(a.width||a.height||a.frameRate||a.bitrateMax)}}class nn{constructor(a){f(this,"taskProfile");f(this,"encodeParam");f(this,"users",[]);f(this,"backgroundColor",0);f(this,"backgrounds",[]);f(this,"watermarks",[]);f(this,"clockWidgets",[]);f(this,"cropMode");f(this,"mediaProcessMode");this.taskProfile=a}}class on{constructor(a,e,t){f(this,"userId");f(this,"streamType");f(this,"sourceType");this.userId=a,this.streamType=e,this.sourceType=t}}class cn{constructor(a,e,t,i=0,r=16777215,n=pi.NOTO_SERIF_CJKSC_REGULAR){f(this,"x");f(this,"y");f(this,"fontSize");f(this,"zOrder");f(this,"fontColor");f(this,"fontType");this.x=a,this.y=e,this.fontSize=t,this.zOrder=i,this.fontColor=r,this.fontType=n}toJson(a,e){return{x:lt(this.x,a),y:lt(this.y,e),fonttype:this.fontType,fontsize:this.fontSize,fontcolor:wr(this.fontColor),zorder:this.zOrder}}}var hn=(s=>(s[s.NOT_DISPLAY=0]="NOT_DISPLAY",s[s.ALWAYS=1]="ALWAYS",s[s.WHEN_NO_VIDEO=2]="WHEN_NO_VIDEO",s))(hn||{});class Wr{constructor(a,e,t,i,r,n=0,c=1,o=1){f(this,"url");f(this,"x");f(this,"y");f(this,"width");f(this,"height");f(this,"alpha");f(this,"display",1);f(this,"zOrder");this.url=a,this.x=e,this.y=t,this.width=i,this.height=r,this.zOrder=n,this.alpha=c,this.display=o}toJson(a,e){return{url:this.url,alpha:this.alpha,display:this.display,x:lt(this.x,a),y:lt(this.y,e),width:lt(this.width,a),height:lt(this.height,e),zorder:this.zOrder}}}f(Wr,"DisplayType",hn);class ln{constructor(a,e,t,i,r=0,n=16777215,c=pi.NOTO_SERIF_CJKSC_REGULAR){f(this,"text");f(this,"x");f(this,"y");f(this,"fontSize");f(this,"zOrder");f(this,"fontColor");f(this,"fontType");this.text=a,this.x=e,this.y=t,this.fontSize=i,this.zOrder=r,this.fontColor=n,this.fontType=c}toJson(a,e){return{text:this.text,x:lt(this.x,a),y:lt(this.y,e),fonttype:this.fontType,fontsize:this.fontSize,fontcolor:wr(this.fontColor),zorder:this.zOrder}}}class dn{constructor(a,e,t,i,r,n=0,c){f(this,"userId");f(this,"x");f(this,"y");f(this,"width");f(this,"height");f(this,"zOrder");f(this,"sourceType");f(this,"segmentType",ui.LiveTranscodingNoBody);f(this,"images",[]);f(this,"texts",[]);this.userId=typeof a=="number"?a.toString():a,this.x=e,this.y=t,this.width=i,this.height=r,this.zOrder=n,c&&(this.sourceType=c)}toJson(a,e,t,i){const r={paneid:a,majorpane:0,x:lt(this.x,e),y:lt(this.y,t),width:lt(this.width,e),height:lt(this.height,t),zorder:this.zOrder,userid:this.userId,images:this.images.map(n=>n.toJson(e,t)),texts:this.texts.map(n=>n.toJson(e,t))};return this.sourceType&&di[this.sourceType]?r.sourcetype=di[this.sourceType]:r.sourcetype=di[ii.LiveTranscodingCamera],this.segmentType&&i===Li.LiveTranscodingVirtualBackground?r.segmenttype=this.segmentType:r.segmenttype=ui.LiveTranscodingNoBody,r}}const Yt=class Yt{constructor(){f(this,"ntpClock");this.ntpClock=new q.AliRTS.Clock}static getInstance(){return Yt.instance||(Yt.instance=new Yt),Yt.instance}now(){return this.ntpClock.now()}};f(Yt,"instance");let Kr=Yt;const un=()=>Kr.getInstance(),{BrowserUtil:$r,SystenUtil:pn}=q.AliRTS;class mn{constructor(){f(this,"tracker");f(this,"param");f(this,"msgCacheArr",[]);f(this,"index",0);f(this,"stsOpt");f(this,"slsToken");f(this,"ossToken");f(this,"ntpClock");this.ntpClock=un()}createTracker(){if(!this.tracker&&this.slsToken&&this.param){const a=this.slsToken;this.ossToken&&(this.param.ossbn=this.ossToken.bucket_name,this.param.ossep=this.ossToken.region_endpoint);const e=new lr({host:a.region_endpoint,project:a.project,logstore:a.log_store_stats}),t={accessKeyId:a.access_key_id,accessKeySecret:a.access_key_secret,securityToken:a.security_token,refreshSTSToken:()=>{this.slsToken&&(t.accessKeyId=this.slsToken.access_key_id,t.accessKeySecret=this.slsToken.access_key_secret,t.securityToken=this.slsToken.security_token)}};this.stsOpt=t;const i=pr(t);e.useStsPlugin(i),this.tracker=e,this.msgCacheArr.forEach((r,n)=>{var c,o;(o=this.tracker)==null||o.send(X(Pt(X({},this.param),{stat_log_id:`${((c=this.param)==null?void 0:c.sesid)||"nosession"}-${n}`}),r))}),this.index=this.index+this.msgCacheArr.length,this.msgCacheArr=[]}}start(a){this.initParam(a),this.createTracker()}updateToken(a,e){this.slsToken=a,this.ossToken=e,this.createTracker()}stop(){this.tracker=void 0,this.param=void 0,this.msgCacheArr=[],this.index=0,this.stsOpt=void 0,this.slsToken=void 0,this.ossToken=void 0}sendReport(a){var t,i;let e;a.tm=Date.now();try{e=JSON.parse(JSON.stringify(X(Pt(X({bt:$r.browserName||"unknown",ntptm:this.ntpClock.now(),ntpofs:this.ntpClock.now()-Date.now()},this.param),{stat_log_id:`${((t=this.param)==null?void 0:t.sesid)||"nosession"}-${this.index}`}),a)))}catch(r){}e&&(this.tracker?((i=this.tracker)==null||i.send(e),this.index++):this.msgCacheArr.push(e))}initParam(a){let e="";try{e=(localStorage==null?void 0:localStorage.getItem("AliRtcUUID"))||"",e||(e=ht(),localStorage==null||localStorage.setItem("AliRtcUUID",e))}catch(t){}this.param||(this.param={apid:a.appId,usrid:a.userId,statsvrs:"0.6.1",evetid:0,sesid:a.sessionId,sessionId:a.sessionId,channelid:a.channelId,usrn:a.userId,osn:pn.systemName,osv:pn.systemVersion,deb:No(),den:Po(),udid:e,sdkvrs:Ti,acs:"Unknown",cput:Va(),dm:`${window.location.protocol}//${window.location.host}`,bt:$r.browserName,bv:$r.browserVersion,envir:"PRODUCT",args:"",instid:ht()})}}const Re=(s,a=1,e=6e4,t=0)=>{let i=s;return i||(i=0),Math.min(e,Math.max(t,Math.round(i*a)))},pt=(s,a,e=2e7,t=0)=>{let i=a;(!a||a<0||a>1e4)&&(i=1e3);let r=s;return r||(r=0),Math.min(e,Math.max(t,Math.round(r/(i/1e3))))},Gt=(s,a)=>{if(a===0||!a)return"0.00";let e=s;return(!e||e<0)&&(e=0),(e/a*100).toFixed(2)},gn=s=>s>=0&&s<=1?Re(Math.floor(32767*s),1,32767):0,Ee=(s,a)=>{var t,i,r;let e=((t=s._last)==null?void 0:t[a])||0;return s.ssrc&&((i=s._last)!=null&&i.ssrc)&&s.ssrc!==((r=s._last)==null?void 0:r.ssrc)&&(e=0),((s==null?void 0:s[a])||0)-e},fn=(s,a)=>Re(Ee(s,a),1e3,1e4),qt=(s,a=2e7)=>Re(s,1,a),Ai=class Ai{constructor(a){f(this,"engine");f(this,"logClient");f(this,"authInfo");f(this,"ntpClock");f(this,"customFields",{});this.logClient=new mn,this.engine=a,this.ntpClock=un()}static getLogClient(){return this.staticClient||(this.staticClient=new mn),this.staticClient}static reportOSSUpload(a,e,t=0){Ai.getLogClient().sendReport({errmsg:`${e}/${a}.log`,errtype:t,evetid:70017,sesid:a,sessionId:a,stat_log_id:`${a}-70017`})}setCustomFields(a){this.customFields=X(X({},this.customFields),a)}getCustomField(a){return this.customFields[a]}start(a){this.authInfo=a,this.logClient.start(a)}updateToken(a,e){this.logClient.updateToken(a,e),Ai.getLogClient().updateToken(a,e)}stop(){this.logClient.stop()}reportPublishAudio3A(a,e,t,i){const r={};let n=JSON.parse(i);r.publevel=n.capture_audio_cur_level_db||0,r.eleakrate=n.echo_leak_rate||0,r.playbw=n.render_bandwidth||-1,r.capbw=n.capture_bandwidth||-1,this.log({evetid:10070,traceid:t,calid:a,args:this.data2String(X({calid:a,tckid:e,traceid:t},r))})}reportPublishMonitor(a,e,t,i,r){if(!t||r.length<=0)return;const n=t===M.Audio,c={ctm:Math.floor(r[0].timestamp||0),src:r[0].ssrc||"",codec:r[0]._codec||""},o=[],h=[],l=[],d=[],p=[],u=[],g=[],m=[],b=[],S=[],v=[],_=[],w=[],y=[],R=[],A=[],E=[],I=[],k=[];try{if(r.forEach(P=>{var x,he,ke,$,ge,De;if(!P||!P.timestamp)return;const H=(x=P._last)!=null&&x.timestamp?P.timestamp-P._last.timestamp:1e3,G=Ee(P,"bytesSent"),Y=Ee(P,"headerBytesSent"),J=pt(Re(G+Y,8,2e7),H);o.push(J);const z=pt(Re(G,8,2e7),H);h.push(z);const Q=pt(Re(Y,8,2e7),H);l.push(Q);const ee=Ee(P,"packetsSent"),pe=pt(ee,H);d.push(pe);const D=Ee(P,"packetsLost"),L=pt(D,H);p.push(L);const N=Gt(D,ee);if(u.push(N),n)(he=P._source)!=null&&he.audioLevel&&g.push(gn(P._source.audioLevel)),m.push(0);else{b.push(fn(P,"totalEncodeTime")),S.push(qt((ke=P._source)==null?void 0:ke.framesPerSecond,100)),v.push(qt(($=P._source)==null?void 0:$.framesPerSecond,100)),_.push(qt(P.framesPerSecond,100)),w.push(qt((ge=P._source)==null?void 0:ge.height,4400)),y.push(qt((De=P._source)==null?void 0:De.width,7700)),R.push(qt(P.frameHeight,4400)),A.push(qt(P.frameWidth,7700));const Ae=Ee(P,"totalPacketSendDelay");E.push(Re(Ae,1/(D||1),2e3));const Te=Ee(P,"qpSum");I.push(Re(Te,1/(P.framesPerSecond||1),51)),k.push(0)}}),c.sbr=o.join(","),c.mbrs=h.join(","),c.pbrs=l.join(","),c.ps=d.join(","),c.pl=p.join(","),c.plr=u.join(","),n){const P=(i==null?void 0:i.getSettings().sampleRate)||0;c.ailevel=g.join(","),c.arpc=m.join(","),c.arsr=P,c.aesr=P,c.publevel=-90,c.rawlevel=-90}else c.em=b.join(","),c.cfps=S.join(","),c.ifps=v.join(","),c.sfps=_.join(","),c.ih=w.join(","),c.iw=y.join(","),c.sh=R.join(","),c.sw=A.join(","),c.sd=E.join(","),c.aqp=I.join(","),c.caf=k.join(","),c.can=k.join(","),c.cav=h.join(","),c.ifimax=k.join(","),c.ifimin=k.join(","),c.efimax=k.join(","),c.efimin=k.join(","),c.sfimax=k.join(","),c.sfimin=k.join(","),c.apsnr=k.join(",")}catch(P){}this.log({evetid:10070,traceid:e,calid:a,args:this.data2String(X({calid:a,tckid:t,traceid:e},c))})}reportSubscribeMonitor(a,e,t,i,r){if(!i||!r||r.length<=0)return;const n=i===M.Audio,c={ctm:Math.floor(r[0].timestamp||0),src:r[0].ssrc||"",codec:r[0]._codec||""},o=[],h=[],l=[],d=[],p=[],u=[],g=[],m=[],b=[],S=[],v=[],_=[],w=[],y=[],R=[],A=[],E=[],I=[],k=[],P=[],H=[],G=[],Y=[],J=[],z=[],Q=[],ee=[],pe=[],D=[],L=[],N=[],x=[],he=[],ke=[];try{r.forEach($=>{var de,je;if(!$||!$.timestamp)return;const ge=(de=$._last)!=null&&de.timestamp?$.timestamp-$._last.timestamp:1e3,De=Ee($,"bytesReceived"),Ae=Ee($,"headerBytesReceived"),Te=pt(Re(De+Ae,8,2e7),ge);o.push(Te);const fe=pt(Re(De,8,2e7),ge);h.push(fe);const _e=pt(Re(Ae,8,2e7),ge);l.push(_e);const le=Ee($,"packetsReceived"),Pe=pt(le,ge);d.push(Pe);const ye=Ee($,"packetsLost"),Ge=pt(ye,ge);p.push(Ge);const st=Gt(ye,le);u.push(st);const ae=Ee($,"jitterBufferDelay"),re=Ee($,"jitterBufferEmittedCount");if($.jitterBufferDelay&&$.jitterBufferEmittedCount){const Z=Re(ae,1e3/re,1e4);g.push(Z)}else g.push(0);const te=Ee($,"fecPacketsReceived");_.push(Gt(te,le));const be=Ee($,"retransmittedPacketsReceived"),Ve=le+ye-be;if(b.push(Gt(le-be,Ve)),S.push(Gt(ye,Ve)),m.push(Gt(be,Ve)),v.push(Ve),he.push(0),ke.push(""),n){y.push(gn($.audioLevel));const Z=((Ne,ft)=>{var wt,St,jt;return(((wt=Ne==null?void 0:Ne._source)==null?void 0:wt[ft])||0)-(((jt=(St=Ne==null?void 0:Ne._last)==null?void 0:St._source)==null?void 0:jt[ft])||0)})($,"synthesizedSamplesEvents");R.push(Z);const Me=fn($,"synthesizedSamplesDuration");A.push(Me);const at=Gt(Me,ge);w.push(at),E.push(0)}else{const Z=(je=$._last)!=null&&je.totalInterFrameDelay?$.totalInterFrameDelay-$._last.totalInterFrameDelay:0;I.push(Re(Z,1e3/($.framesDecoded||30),500)),k.push(Re($.framesPerSecond,1,100)),P.push(Ee($,"framesReceived")),x.push(Ee($,"framesRendered")),H.push(Re($.frameHeight,1,4400)),G.push(Re($.frameWidth,1,7700));const Me=Ee($,"totalProcessingDelay");Y.push(Re(Me,1e3/($.framesDecoded||30),12e4));const at=Ee($,"nackCount");z.push(at);const Ne=Ee($,"pliCount");J.push(Ne);const ft=Ee($,"qpSum");Q.push(Re(ft,1/($.framesPerSecond||1),51)),ee.push(Re($.framesDropped));const wt=Ee($,"totalFreezesDuration");pe.push(Re(wt,1e3,3e4));const St=Ee($,"jitterBufferEmittedCount"),jt=Ee($,"jitterBufferDelay");jt&&St?D.push(Re(jt,1e3/St,3e4)):D.push(0);const _i=Ee($,"jitterBufferTargetDelay");_i&&St?L.push(Re(_i,1e3/St,3e4)):L.push(0);const Ki=Ee($,"jitterBufferMinimumDelay");Ki&&St?N.push(Re(Ki,1e3/St,3e4)):N.push(0)}}),c.rbr=o.join(","),c.mbrs=h.join(","),c.pbrs=l.join(","),c.pr=d.join(","),c.pl=p.join(","),c.plr=u.join(","),c.jd=g.join(","),c.fecr=_.join(","),c.retransr=m.join(","),c.baser=b.join(","),c.basel=S.join(","),c.recoverr=he.join(","),c.alll=S.join(","),c.totalc=v.join(","),n?(c.er=w.join(","),c.aolevel=y.join(","),c.asrc=E.join(","),c.scnt=R.join(","),c.sdura=A.join(",")):(c.dm=I.join(","),c.dfps=k.join(","),c.rfps=P.join(","),c.rh=H.join(","),c.rw=G.join(","),c.fpt=ke.join(","),c.ns=z.join(","),c.pliss=J.join(","),c.aqp=Q.join(","),c.ofimax=he.join(","),c.ofimin=he.join(","),c.dfimax=he.join(","),c.dfimin=he.join(","),c.rfimax=he.join(","),c.rfimin=he.join(","),c.vrstutter=pe.join(","),c.cdm=D.join(","),c.tdm=L.join(","),c.pdm=N.join(","),c.ofps=x.join(","),c.dfbd=ee.join(","))}catch($){}this.log({evetid:10080,traceid:t,rmtid:e,calid:a,args:this.data2String(X({calid:a,rmtid:e,tckid:i,traceid:t},c))})}reportNetworkMonitor(a){if(a.length<=0)return;const e=[],t=[],i=[],r=[],n=[],c=[],o=[],h=[],l=[],d=[];a.forEach((u,g)=>{var b;if(!u.timestamp)return;const m=(b=u._last)!=null&&b.timestamp?u.timestamp-u._last.timestamp:1e3;e.push(Re(u.currentRoundTripTime,1e3)),t.push(Re(u.availableOutgoingBitrate,8,2e8)),i.push(pt(Re(u.bytesSent,8,2e7),m,25e6)),r.push(pt(Re(u.bytesReceived,8,2e7),m,25e6)),n.push(0),c.push(0),g%5==0&&(o.push(""),h.push(""),l.push(""),d.push(""))});const p={ctm:Math.floor(a[0].timestamp||0),rtt:e.join(","),bsps:i.join(","),brps:r.join(","),cpu:o.join(","),mem:h.join(","),sysmem:l.join(","),systotalmem:d.join(","),audioonly:this.engine.isAudioOnly()?1:0};this.log({evetid:10071,args:this.data2String(X({asb:t.join(","),abms:n.join(","),vbms:c.join(",")},p))}),this.log({evetid:10081,args:this.data2String(X({},p))})}reportJoin(a,e,t=""){var d,p;const{start:i,rs:r=0,re:n=0}=e,c=Date.now()-i,o=n-r;let h=0;r&&(h=r-i);let l=0;n&&(l=n-r),this.log({evetid:10010,args:this.data2String({sesid:((d=this.authInfo)==null?void 0:d.sessionId)||"",joitm:c,rslt:a,gslbtm:0,dnstm:0,avcftm:0,gslbrslt:0,dnsrslt:0,avcfrslt:0,mode:2,jrtc:o,usrn:(p=this.authInfo)==null?void 0:p.userId,mgt:"cdn",cttc:h,iptc:l,ndn:1,gslbloc:1,ccag:0,ucag:0,cpg:0,upg:0,tid:t})})}reportJoinConnection(a){this.log({evetid:20002,args:this.data2String(X({transretrynum:0,ldnstc:0,tcptc:0,ssltc:0,url:""},a))})}reportLeave(a,e,t){this.log({evetid:10020,args:this.data2String({lvetm:a,rslt:e,tid:t})})}reportPublish(a,e,t,i,r,n,c,o,h,l,d){this.log({evetid:a?10032:10030,calid:t,args:this.data2String({calid:t,url:e,isvl:i?1:0,isvs:r?1:0,isvss:n?1:0,isaudio:c?1:0,rslt:o,tid:"123",pubtm:Date.now()-d,pctid:h,pubtid:l,isvp:0,isarecording:0,isad:0,isdc:0,pubretry:0,pbrttimes:0})})}reportPublishFirstPacket(a,e,t,i,r,n,c,o,h){const l=Date.now();this.log({evetid:a?10033:10031,calid:e,args:this.data2String({calid:e,fpst:l-t,tckid:n,est:t,pctid:c,pubtid:o,totaltm:l-r,jorm:h===bt.JOIN_CHANNEL?1:0,cptc:0,sptc:i-t,iptc:0,ipc2fptc:0,dctc:0,patc:0})})}reportUnpublish(a,e,t,i){var r;this.log({evetid:10040,args:this.data2String({calid:a,unpubtm:e,rslt:t,tid:i,sesid:((r=this.authInfo)==null?void 0:r.sessionId)||""})})}reportSubscribe(a,e,t,i,r,n,c,o,h,l){this.log({evetid:10050,calid:a,rmtid:e,args:this.data2String(X({calid:a,rmtid:e,isvl:t?1:0,isvs:i?1:0,isvss:r?1:0,isaudio:n?1:0,rslt:c,tid:o,subtm:h,isvp:0,isaplaying:0,isad:0,isdc:0,subretry:0,sbrttimes:0},l))})}reportSubscribeFirstPacket(a,e,t,i,r){this.log({evetid:a?10054:10051,calid:e,rmtid:t,args:this.data2String(X({calid:e,rmtid:t,tckid:i,cptc:0,iptc:0,ipc2fptc:0,dctc:0,patc:0},r))})}reportSubscribeFirstFrame(a,e,t,i,r){this.log({evetid:a?10055:10052,calid:e,rmtid:t,args:this.data2String(X({calid:e,rmtid:t,tckid:i},r))}),this.log({evetid:a?10058:10057,args:this.data2String(X({calid:e,rmtid:t,tckid:i},r))})}reportUnsubscribe(a,e,t,i,r){this.log({evetid:10060,calid:a,args:this.data2String({calid:a,rmtid:e,unsubtm:t,rslt:i,tid:r})})}reportMute(a,e,t){this.log({evetid:11030,args:this.data2String({calid:a,rmtid:"",enable:e?1:0,mt:t})})}reportRoleUpdate(a,e){this.log({evetid:11040,args:this.data2String({or:a||"",nr:e,ctm:Date.now(),rslt:0})})}reportRoleUpdateResult(a,e,t,i){this.log({evetid:11041,args:this.data2String({or:a||"",nr:e,ctm:t,rslt:i})})}reportVideoProfile(a){this.log({evetid:20074,args:this.data2String({pf:a,tckid:"sophon_camera_large"})})}reportScreenProfile(a){this.log({evetid:20074,args:this.data2String({pf:a,tckid:"sophon_screenshare"})})}reportError(a){this.log({evetid:10091,args:this.data2String({rslt:(a==null?void 0:a.code)||-1})})}reportWarning(a){this.log({evetid:10092,args:this.data2String({rslt:-1,errmsg:a})})}reportRoomServerEvent(a,e,t,i){this.log({evetid:20005,args:this.data2String({calid:"",rmtid:"",rt:a?0:1,dr:a?"s":"r",mt:e,ri:t,cs:1,srt:Date.now(),rspc:(i==null?void 0:i.code)||"",mc:JSON.stringify(i)})})}reportTranscodingError(a,e){this.log({evetid:10101,args:this.data2String({rslt:a,taskid:e})})}reportBye(a){var e;this.log({evetid:10093,args:this.data2String({rslt:a,sesid:((e=this.authInfo)==null?void 0:e.sessionId)||""})})}reportAudio(a,e,t){var i;this.log({evetid:80013,args:this.data2String({rslt:a?-1:0,adm:1,adt:0,adr:a?2:0,acms:e,adrpn:t})}),this.log({evetid:80014,args:this.data2String({sesid:((i=this.authInfo)==null?void 0:i.sessionId)||"",rslt:a?-1:0,adm:1,adt:0,adr:a?2:0,acms:e,adrpn:t})})}reportScreen(a,e){var t,i,r,n;this.log({evetid:90013,args:this.data2String({rslt:a?-1:0,vcms:e,vde:(t=a==null?void 0:a.code)!=null?t:-1,sesid:((i=this.authInfo)==null?void 0:i.sessionId)||""})}),this.log({evetid:90014,args:this.data2String({rslt:a?-1:0,vcms:e,vde:(r=a==null?void 0:a.code)!=null?r:-1,sesid:((n=this.authInfo)==null?void 0:n.sessionId)||""})})}reportScreenStop(a){this.log({evetid:90019,args:this.data2String({rslt:a?a.code||-1:0})}),this.log({evetid:90020,args:this.data2String({rslt:a?a.code||-1:0})})}reportSwitchCamera(a){var e;this.log({evetid:90025,args:this.data2String({rslt:0,td:a,sesid:((e=this.authInfo)==null?void 0:e.sessionId)||""})})}reportPublishProfile(a,e){this.log({evetid:10201,args:this.data2String(X({tckid:a},e))})}reportSDKCreated(a){this.log({evetid:70011,createtm:Date.now()-a,tm:a})}reportJoinInvoked(a){this.log({evetid:70012,jnnonce:a.nonce||"",jntoken:a.token||"",jntm:a.timestamp||""})}reportJoinResult(a){this.log({evetid:70013,rslt:a?a.code||-1:0,dnsrslt:0})}reportSTSResult(a,e){this.log({evetid:70014,rslt:a,asty:1,reqtm:Date.now()-e})}reportLeaveInvoked(){this.log({evetid:70015})}reportSEIMessage(a,e,t,i,r){this.log({evetid:40301,args:this.data2String({tm:Date.now(),sei_pt:a,sei_len:e,sei_rep:t,sei_delay:i,sei_key:r})})}reportConnectionLatencyEvent(a,e,t,i,r,n,c=!1){const o={ageniid:this.getCustomField("ageniid")},h=X({tm:r||Date.now(),ntptm:n||this.ntpClock.now(),stage:a,status:e,calid:t,tckid:i,cltp:1,http:c?1:0},o);this.log({evetid:12001,args:this.data2String(h)})}log(a){a&&(a.tm=new Date().getTime(),V.debug("[ConsoleLogger]","log",a),this.logClient.sendReport(a))}data2String(a){let e="";for(let t in a)e.length&&(e+="&"),e+=t+"="+a[t];return e}};f(Ai,"staticClient");let Jr=Ai;var Ec=Object.defineProperty,Ic=Object.getOwnPropertyDescriptor,j=(s,a,e,t)=>{for(var i,r=t>1?void 0:t?Ic(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};const F=(K=class extends se{constructor(e){super();f(this,"channelProfile");f(this,"clientRole");f(this,"signalingManager");f(this,"bizControl");f(this,"liveTranscoding");f(this,"maxSignalingConnectRetryCount");f(this,"slsReporter");f(this,"connectState",ne.AliRtcConnectionStatusInit);f(this,"networkError",!1);f(this,"_audioOnlyMode",!1);f(this,"_authInfoWillExpireTimer",null);f(this,"_authInfoExpiredTimer",null);f(this,"_serverCheckAuthInfoTimestamp",null);f(this,"_localCheckAuthInfoTimestamp",null);f(this,"_proxyAiTid",null);f(this,"_agentParam",null);const t=Date.now();V.init(),this.slsReporter=new Jr(this),this.channelProfile=Ct.AliRtcSdkCommunication,this.clientRole=Lt.AliRtcSdkLive,this.liveTranscoding=new wc(this.slsReporter),this.signalingManager=new Dr(this.channelProfile,this.clientRole,this.slsReporter,(e==null?void 0:e.env)===Tt.pre?Tt.pre:Tt.prod),this.addSignalingManagerListeners(),this.maxSignalingConnectRetryCount=e==null?void 0:e.maxSignalingConnectRetryCount,this.bizControl=new qe({slsReporter:this.slsReporter,signalingManager:this.signalingManager}),this.addBizControlListeners(),this.addPublisherListeners(),this.slsReporter.reportConnectionLatencyEvent(ot.CREATE_ENGINE,dt.START,"","",t),this.slsReporter.reportConnectionLatencyEvent(ot.CREATE_ENGINE,dt.END,"","",Date.now()),this.slsReporter.reportSDKCreated(t)}static getSdkVersion(){return Ti}static setLogLevel(e){V.setLogLevel(e)}static getInstance(e){return K._instance||(K._instance=new K(e)),K._instance}destroy(){return T(this,null,function*(){K._instance=void 0,yield this.leaveChannel(),yield this.bizControl.clear(),V.destroy()})}get channel(){return this.bizControl.channel}get userId(){return this.bizControl.userId}get remoteUsers(){return this.bizControl.remoteUsers}get publisher(){return this.bizControl.publisher}get publishAudioStream(){var e;return(e=this.publisher)==null?void 0:e.publishStreams.audio}get isPublishing(){const{publisher:e}=this.bizControl;return!!e&&e.isPublishing}get currentRoleCanPublish(){return this.channelProfile===Ct.AliRtcSdkCommunication||this.clientRole===Lt.AliRtcSdkInteractive}addPublisherListeners(){var e,t,i,r,n,c,o,h,l,d;(e=this.publisher)==null||e.on(Xe.Local,p=>{V.event("[Publisher] Device Status Change",p),this.onLocalDeviceStatusChange(p)}),(t=this.publisher)==null||t.on(Jt.VideoTrackEnded,()=>{V.event("[Publisher] VideoTrack Ended"),this.emit("localDeviceException",yt.AliEngineLocalDeviceTypeCamera,Oe.AliEngineLocalDeviceExceptionTypeCameraInterrupt,"")}),(i=this.publisher)==null||i.on(Jt.ScreenTrackEnded,()=>{V.event("[Publisher] ScreenTrack Ended"),this.emit("localDeviceException",yt.AliEngineLocalDeviceTypeDisplay,Oe.AliEngineLocalDeviceExceptionTypeDisplayException,"")}),(r=this.publisher)==null||r.on(Jt.AudioTrackEnded,()=>{V.event("[Publisher] AudioTrack Ended"),this.emit("localDeviceException",yt.AliEngineLocalDeviceTypeMic,Oe.AliEngineLocalDeviceExceptionTypeMicInterrupt,"")}),(n=this.publisher)==null||n.on("localDeviceException",(p,u,g="")=>{this.emit("localDeviceException",p,u,g)}),(c=this.publisher)==null||c.on("audioPublishStateChanged",(p,u,g)=>{var m;this.emit("audioPublishStateChanged",p,u,g,(m=this.channel)!=null?m:"")}),(o=this.publisher)==null||o.on("videoPublishStateChanged",(p,u,g)=>{var m;this.emit("videoPublishStateChanged",p,u,g,(m=this.channel)!=null?m:"")}),(h=this.publisher)==null||h.on("dualStreamPublishStateChanged",(p,u,g)=>{var m;this.emit("dualStreamPublishStateChanged",p,u,g,(m=this.channel)!=null?m:"")}),(l=this.publisher)==null||l.on("screenPublishStateChanged",(p,u,g)=>{var m;this.emit("screenSharePublishStateChanged",p,u,g,(m=this.channel)!=null?m:"")}),(d=this.publisher)==null||d.on("dataPublishStateChanged",(p,u,g)=>{var m;this.emit("dataPublishStateChanged",p,u,g,(m=this.channel)!=null?m:"")})}occurError(e,t){V.event(`[${K.logName}]`,"Occur Error",e,t),this.emit("onOccurError",e,t),this.emit("occurError",e,t)}addBizControlListeners(){this.bizControl.rtsManager.on("connected",e=>{var t;e&&((t=this.publisher)==null||t.publishUpdate(bt.RECONNECT),this.remoteUsers.forEach(i=>{i.updateSubscribe(Se.Reconnect)}))}),this.bizControl.rtsManager.on("disconnected",()=>T(this,null,function*(){V.event(`[${K.logName}]`,"RTS Disconnected"),(yield et.isNetworkAvailable())?this.onNetworkRecovery():this.onNetworkError()})),this.bizControl.rtsManager.on("subscribeexceeds",()=>T(this,null,function*(){yield this.resumePublishForNetworkRecovery(),yield this.resumeSubList()})),this.bizControl.rtsManager.on("seimessage",(e,t,i)=>{const r=this.remoteUsers.find(n=>n.streamUrl===e);r&&this.emit("mediaExtensionMsgReceived",r.userId,i,t)}),this.bizControl.on(Xe.Remote,(e,t)=>{V.event(`[${K.logName}]`,"RemoteUser Device Status Change",e,t)}),this.bizControl.on("remoteUserJoin",(e,t)=>{this.emit("remoteUserOnLineNotify",e,t)}),this.bizControl.on("remoteTrackAvailableChange",(e,t,i)=>{this.emit("remoteTrackAvailableNotify",e,t,i)}),this.bizControl.on("audioSubscribeStateChanged",(e,t,i,r,n)=>{this.emit("audioSubscribeStateChanged",e,t,i,r,n)}),this.bizControl.on("videoSubscribeStateChanged",(e,t,i,r,n)=>{this.emit("videoSubscribeStateChanged",e,t,i,r,n)}),this.bizControl.on("screenSubscribeStateChanged",(e,t,i,r,n)=>{this.emit("screenShareSubscribeStateChanged",e,t,i,r,n)}),this.bizControl.on("dataSubscribeStateChanged",(e,t,i,r,n)=>{this.emit("dataSubscribeStateChanged",e,t,i,r,n)}),this.bizControl.on("userAudioMuted",(e,t)=>{this.emit("userAudioMuted",e,t)}),this.bizControl.on("userVideoMuted",(e,t)=>{this.emit("userVideoMuted",e,t)}),this.bizControl.on("userScreenMuted",(e,t)=>{this.emit("userScreenMuted",e,t)}),this.bizControl.on("audioVolume",e=>{this.emit("audioVolume",e)}),this.bizControl.on("remoteAudioAutoPlayFail",e=>{this.emit("remoteAudioAutoPlayFail",e)}),this.bizControl.on("remoteVideoAutoPlayFail",(e,t)=>{this.emit("remoteVideoAutoPlayFail",e,t)}),this.bizControl.on("remoteAudioPlayError",(e,t)=>{this.emit("remoteAudioPlayError",e,t)}),this.bizControl.on("remoteVideoPlayError",(e,t)=>{this.emit("remoteVideoPlayError",e,t)}),this.bizControl.on("rtcStats",e=>{this.emit("rtcStats",e)}),this.bizControl.on("rtcLocalAudioStats",e=>{this.emit("rtcLocalAudioStats",e)}),this.bizControl.on("rtcLocalVideoStats",e=>{this.emit("rtcLocalVideoStats",e)}),this.bizControl.on("rtcRemoteAudioStats",e=>{this.emit("rtcRemoteAudioStats",e)}),this.bizControl.on("rtcRemoteVideoStats",e=>{this.emit("rtcRemoteVideoStats",e)}),this.bizControl.on("remoteSubscribeError",(e,t)=>{this.occurError(e,t),this.slsReporter.reportError(e)}),this.bizControl.on("occurError",(e,t)=>{this.occurError(e,t),this.slsReporter.reportError(e)}),this.bizControl.on("remoteDataChannelMessage",(e,t)=>{this.emit("dataChannelMsg",e,t)}),this.bizControl.on("remoteUserSubscribedDataChannel",e=>{this.emit("remoteUserSubscribedDataChannel",e)})}addSignalingManagerListeners(){this.signalingManager.on("onKeepAliveRsp",()=>{this.networkError&&(V.event("[Signaling] Receive KeepAlive Response",`networkError: ${this.networkError}`),this.onNetworkRecovery())}),this.signalingManager.on("onNotifyJoin",e=>{V.event("[Signaling] Notify Join ",e),this.handleUsersJoin(e),e.forEach(t=>{this.emit("remoteUserOnLineNotify",t.userid,0)})}),this.signalingManager.on("onNotifyStatus",e=>{V.event("[Signaling] Notify Status ",e),e.forEach(t=>{this.bizControl.updateRemoteUserDeviceStatus(t)})}),this.signalingManager.on("onNotifyLeave",e=>{V.event("[Signaling] Notify Leave ",e),e.forEach(t=>T(this,null,function*(){yield this.bizControl.removeLeftUser(t),this.emit("remoteUserOffLineNotify",t.userid,t.leavecode)}))}),this.signalingManager.on("onBye",(e,t)=>{V.event("[Signaling] Bye ",e,t),this.slsReporter.reportError({message:`reason: ${e}, description: ${t}`}),this.emit("bye",e),this.leaveChannel(),this.slsReporter.reportBye(e)}),this.signalingManager.on("onConnectFail",e=>{V.event("[Signaling] Connect Failed ",e),this.onError(e),this.backToUnpublishStatus(),this.connectState=ne.AliRtcConnectionStatusFailed,this.emit("connectionStatusChange",ne.AliRtcConnectionStatusFailed,Rt.AliRtcConnectionChangedNetworkInterrupted)}),this.signalingManager.on("onNetworkError",e=>{this.slsReporter.reportWarning("signaling network error"),V.event("[Signaling] Network error ",e),this.onNetworkError()}),this.signalingManager.on("onAuthInvalid",()=>{V.event("[Signaling] Auth Invalid")}),this.signalingManager.on("onReconnectStart",()=>{V.event("[Signaling] Reconnect Start "),this.connectState=ne.AliRtcConnectionStatusReconnecting,this.emit("connectionStatusChange",ne.AliRtcConnectionStatusReconnecting,Rt.AliRtcConnectionSignalingConnecting)}),this.signalingManager.on("onReconnectSuccess",e=>{V.event("[Signaling] Reconnect Success ",e),this.onNetworkRecovery(e)}),this.signalingManager.on("onReconnectFail",e=>{this.slsReporter.reportWarning("signaling reconnect fail: ${err.code}"),V.event("[Signaling] Reconnect Failed ",e),e.code===403&&this.emit("authInfoExpired")}),this.signalingManager.on("onError",e=>{this.slsReporter.reportWarning("signaling error: ${err.message}"),V.event("[Signaling] Error ",e),this.onError(e)}),this.signalingManager.on("onUnknownMessage",e=>{if(e.msgtype==="proxyai"&&e.tid===this._proxyAiTid){let t=e.data.retcode;t===200&&(t=0),this.emit("AIAgentResult",t,this._agentParam.action,e.data.body)}})}backToUnpublishStatus(){var e,t;this.connectState=ne.AliRtcConnectionStatusDisconnected,(e=this.publisher)!=null&&e.isPublishing&&((t=this.publisher)==null||t.clearPublishState()),this.networkError=!1}handleUsersJoin(e){e.forEach(t=>{const i=t.userid;if(i){const r=this.bizControl.addUser(i,t.displayname,Se.Join);V.event(`[${K.logName}]`,we.UserJoined,r)}})}onLocalDeviceStatusChange(e){V.event(`[${K.logName}]`,Xe.Local,e),this.signalingManager.reportStatus(e).then(()=>{V.debug("[signaling] reportStatus suc")}).catch(t=>{V.error("[signaling] reportStatus failed",t)})}resumePublishForNetworkRecovery(){return T(this,null,function*(){var e;try{yield(e=this.publisher)==null?void 0:e.resumePublish()}catch(t){const{code:i}=t;if(i===10205){let n=1;try{yield new Promise((c,o)=>{const h=setInterval(()=>T(this,null,function*(){var l;n>1&&(clearInterval(h),o()),n+=1;try{yield(l=this.publisher)==null?void 0:l.resumePublish(),clearInterval(h),c()}catch(d){const{code:p}=d;p!==10205&&(clearInterval(h),o())}}),1e3)})}catch(c){}}throw t}})}onNetworkRecovery(e){return T(this,null,function*(){var t;V.event(K.logName,"onNetworkRecovery",`rts isConnected: ${this.bizControl.rtsManager.isConnected}; rts isConnecting: ${this.bizControl.rtsManager.isConnecting}`,{users:e}),this.bizControl.rtsManager.isConnected||this.bizControl.rtsManager.isConnecting?e&&(yield this.resumeSubList(e)):(this.currentRoleCanPublish&&(yield this.resumePublishForNetworkRecovery()),yield this.resumeSubList()),this.networkError&&(this.networkError=!1,(t=this.publisher)==null||t.reportSelfDeviceStatus(),this.connectState=ne.AliRtcConnectionStatusConnected,this.emit("connectionStatusChange",ne.AliRtcConnectionStatusConnected,Rt.AliRtcConnectionSignalingHeartbeatAlive))})}resumeSubList(e){return T(this,null,function*(){if(e!=null&&e.length){const{joinList:t,leaveList:i,presentList:r}=this.bizControl.updateUsers(e);V.info(`[${K.logName}]`,"resumeSubList",{joinList:t,leaveList:i,presentList:r}),this.handleUsersJoin(t),i.forEach(n=>{V.event(K.logName,we.UserLeft,n.userid,n.reason),this.emit("remoteUserOffLineNotify",n.userid,Er.AliRtcUserOfflineQuit)});for(let n=0;n<r.length;n++){const c=r[n],o=c.userid,h=this.bizControl.getRemoteUser(o);this.bizControl.onRemotePublishStateChange(c),h==null||h.updateSubscribe(Se.Resume)}}else for(let t=0;t<this.remoteUsers.length;t++){const i=this.remoteUsers[t];try{i.restore(),i.updateSubscribe(Se.Resume)}catch(r){}}})}retrySubscribe(e){return T(this,null,function*(){const t=this.bizControl.getRemoteUser(e);if(!t)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);t.restore(),t.updateSubscribe(Se.Retry)})}onNetworkError(){this.connectState===ne.AliRtcConnectionStatusConnected&&(this.networkError||(this.connectState=ne.AliRtcConnectionStatusDisconnected,this.emit("connectionStatusChange",ne.AliRtcConnectionStatusDisconnected,Rt.AliRtcConnectionChangedNetworkInterrupted)),this.networkError=!0)}onError(e){this.slsReporter.reportError(e),V.event(K.logName,we.Error,e)}setEnableDualVideoStream(e,t){this.bizControl.setEnableDualVideoStream(e,t)}hadPushStream(e){if(!this.publisher||!e)throw new O(U.ERR_INNER,"stream is not publishing")}getCurrentMicDeviceId(){var e;return(e=this.publisher)==null?void 0:e.getCurrentMicDeviceId()}setChannelProfile(e){if(![ne.AliRtcConnectionStatusInit,ne.AliRtcConnectionStatusDisconnected,ne.AliRtcConnectionStatusFailed].includes(this.connectState))throw new O(U.ERR_INNER,"cannot set channel profile in call");this.channelProfile=e,this.channelProfile===Ct.AliRtcSdkCommunication&&(this.clientRole=Lt.AliRtcSdkLive),this.signalingManager.setChannelProfile(e)}startDefaultDevices(){return T(this,null,function*(){var r,n,c;if(!this.publisher)return;const{hasCamera:e,hasMicrophone:t,hasScreenShare:i}=this.publisher;if(!e&&!t&&!i){try{yield(r=this.publisher)==null?void 0:r.startDefaultCamera(this._audioOnlyMode)}catch(o){V.warn(`[${K.logName}]`,"startDefaultCamera failed",o.code,o.message),o instanceof O&&this.occurError(o),this.occurError(new O(U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED,`auto start video failed, ${o.message||""}`))}try{yield(n=this.publisher)==null?void 0:n.startDefaultAudio()}catch(o){V.warn(`[${K.logName}]`,"startDefaultAUdio failed",o.code,o.message),o instanceof O&&this.occurError(o),this.occurError(new O(U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED,`auto start audio failed, ${o.message||""}`))}yield(c=this.publisher)==null?void 0:c.previewAll()}})}startPublish(e){return T(this,null,function*(){var t,i;try{yield(t=this.publisher)==null?void 0:t.startPublish(!1,e)}catch(r){const n=((i=this.publisher)==null?void 0:i.publishStreams)||{},c=[];n!=null&&n.audio&&c.push(U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED),n!=null&&n.video&&c.push(U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED),c.forEach(o=>{this.occurError(new O(o,`auto publish stream failed, ${r.message||""}`))})}})}setClientRole(e){return T(this,null,function*(){var t,i,r;try{if(this.channelProfile===Ct.AliRtcSdkCommunication)return;if(!Object.values(Lt).includes(e))throw new O(U.ERR_INVALID_ARGUMENTS,`set client role error, role value(${e}) is invalid`);if(this.clientRole===e)return;this.slsReporter.reportRoleUpdate(this.clientRole,e),this.isInCall()?this.clientRole===Lt.AliRtcSdkInteractive?((t=this.publisher)!=null&&t.isPublishing?yield(i=this.publisher)==null?void 0:i.unPublish():yield(r=this.publisher)==null?void 0:r.clearStream(),yield this.signalingManager.setClientRole(e)):(yield this.signalingManager.setClientRole(e),yield this.startDefaultDevices(),yield this.startPublish(bt.ROLE_CHANGE)):yield this.signalingManager.setClientRole(e),this.clientRole=e}catch(n){throw n.code===403&&this.emit("authInfoExpired"),n}})}getCurrentClientRole(){return this.clientRole}setAudioOnlyMode(e){if(this.isInCall())throw new O(U.ERR_INNER,"can not change audioOnly mode in call");this._audioOnlyMode=e}setAudioRedEnabled(e){if(this.isInCall())throw new O(U.ERR_INNER,"can not change audioRedEnabled in call");this.bizControl.setAudioRedEnabled(e)}setCheckAuthInfoTimer(e,t){const i=1e3*(e-t);this._authInfoExpiredTimer=window.setTimeout(()=>{this.emit("authInfoExpired")},i),this._authInfoWillExpireTimer=window.setTimeout(()=>{this.emit("authInfoWillExpire")},i-3e4),this._serverCheckAuthInfoTimestamp=t,this._localCheckAuthInfoTimestamp=+Date.now()/1e3}clearCheckAuthInfoTimer(){this._authInfoExpiredTimer&&window.clearTimeout(this._authInfoExpiredTimer),this._authInfoWillExpireTimer&&window.clearTimeout(this._authInfoWillExpireTimer)}joinChannel(e,t,i){return T(this,null,function*(){var l;const r=Date.now();let n,c=typeof t=="string"?t:t==null?void 0:t.userName;if(typeof e=="string")try{const d=JSON.parse(window.atob(e));n={appId:d.appid,channelId:d.channelid,userId:d.userid,timestamp:d.timestamp,nonce:d.nonce,token:d.token}}catch(d){throw new O(U.ERR_INVALID_ARGUMENTS,`authInfo is invalid: ${d.message||""}`)}else n=e;c||(c=n.userId);const o={start:Date.now()};let h=zr.checkAuthInfo(n);if(ne.AliRtcConnectionStatusInit!==this.connectState&&ne.AliRtcConnectionStatusDisconnected!==this.connectState&&ne.AliRtcConnectionStatusFailed!==this.connectState){const d=new O(U.ERR_JOIN_ALREADY_JOINED,"already joined");throw this.connectState===ne.AliRtcConnectionStatusConnecting&&(d.message="Repeated operation during login"),this.slsReporter.reportJoin(d.code,o,""),d}{if(n.sessionId=et.createCallid("web"),this.slsReporter.start(n),this.slsReporter.reportConnectionLatencyEvent(ot.JOIN,dt.START,"","",r),h)throw this.connectState=ne.AliRtcConnectionStatusFailed,this.slsReporter.reportJoin(h.code,o,""),this.slsReporter.reportJoinResult(h),h;this.connectState=ne.AliRtcConnectionStatusConnecting,this.emit("connectionStatusChange",ne.AliRtcConnectionStatusConnecting,Rt.AliRtcConnectionSignalingConnecting),V.setSessionID(n.appId,n.sessionId);const d=()=>T(this,null,function*(){var p;try{const u=Date.now(),g=yield this.signalingManager.join(n,c,this.maxSignalingConnectRetryCount,o,i);g.l1ip&&this.publisher&&(this.publisher.preferredPubL1Ip=g.l1ip);const m=Date.now();this.connectState=ne.AliRtcConnectionStatusConnected,this.emit("connectionStatusChange",ne.AliRtcConnectionStatusConnected,Rt.AliRtcConnectionSignalingJoinRoomSuccess),this.bizControl.init(n,g,{capabilityProfile:typeof t=="object"?t.capabilityProfile:Wi.Default}),this.setCheckAuthInfoTimer(n.timestamp,g.timestamp),this.liveTranscoding.setAuthInfo(n),this.slsReporter.reportJoin(0,o,g.tid),this.slsReporter.reportJoinResult(null),this.slsReporter.reportConnectionLatencyEvent(ot.JOIN,dt.SEND_SIG,"","",u),this.slsReporter.reportConnectionLatencyEvent(ot.JOIN,dt.RECV_RST,"","",m),this.slsReporter.reportConnectionLatencyEvent(ot.JOIN,dt.END,"","")}catch(u){const g=(p=u.code)!=null?p:-1,m=u.reason||u.message||"";throw this.connectState=ne.AliRtcConnectionStatusDisconnected,this.emit("connectionStatusChange",ne.AliRtcConnectionStatusDisconnected,Rt.AliRtcConnectionSignalingJoinRoomFailure),this.slsReporter.reportJoin(g,o,""),this.slsReporter.reportJoinResult(u),new O(g,m)}});this.currentRoleCanPublish?(yield Promise.all([d(),this.startDefaultDevices()]),yield this.startPublish(bt.JOIN_CHANNEL)):yield d(),(l=this.publisher)==null||l.reportSelfDeviceStatus(),this.remoteUsers.forEach(p=>{p.updateSubscribe(Se.Join)})}})}joinAIChannel(e,t,i){return T(this,null,function*(){return this._proxyAiTid=ht(),this._agentParam=i,this.joinChannel(e,t,{bizconf:{l1leader:!0},proxyai:{tid:this._proxyAiTid,region:i.region,proxydata:JSON.stringify({Region:i.region,Action:i.action,ActionParams:i.params})}})})}leaveChannel(){return T(this,null,function*(){var t;this.slsReporter.reportLeaveInvoked(),yield this.bizControl.leave();let e=new Date().getTime();if(ne.AliRtcConnectionStatusConnected===this.connectState)try{let i;i=yield this.signalingManager.leave(),this.slsReporter.reportLeave(new Date().getTime()-e,0,(t=i==null?void 0:i.tid)!=null?t:"")}catch(i){this.slsReporter.reportLeave(new Date().getTime()-e,i.code,i.reason)}else this.slsReporter.reportLeave(0,0,"");this.networkError=!1,this.connectState=ne.AliRtcConnectionStatusDisconnected,this.clearCheckAuthInfoTimer(),this.liveTranscoding.clear(),this.slsReporter.stop(),this.signalingManager.reset(),V.reportEnd()})}isInCall(){return this.connectState===ne.AliRtcConnectionStatusConnected}refreshAuthInfo(e){return T(this,null,function*(){let t;if(typeof e=="string")try{const l=JSON.parse(window.atob(e));t={userId:l.userid,timestamp:l.timestamp,nonce:l.nonce,token:l.token}}catch(l){throw new O(U.ERR_INVALID_ARGUMENTS,`authInfo is invalid: ${l.message||""}`)}else t=e;const{userId:i,nonce:r,timestamp:n,token:c,role:o}=t,h={userId:i,nonce:r,timestamp:n,token:c,role:o};try{yield this.signalingManager.refreshAuthInfo(h),this.bizControl.refreshAuthInfo(h),this.liveTranscoding.refreshAuthInfo(h),this.clearCheckAuthInfoTimer(),this._serverCheckAuthInfoTimestamp&&this._localCheckAuthInfoTimestamp&&t.timestamp&&this.setCheckAuthInfoTimer(t.timestamp,this._serverCheckAuthInfoTimestamp+(Date.now()-this._localCheckAuthInfoTimestamp))}catch(l){throw l}})}isAudioOnly(){return this._audioOnlyMode}publishLocalAudioStream(e){return T(this,null,function*(){var t,i,r,n;(t=this.publisher)==null||t.setPublishLocalAudioStreamEnabled(e),this.connectState===ne.AliRtcConnectionStatusConnected&&(e?(i=this.publisher)!=null&&i.hasMicrophone?yield(r=this.publisher)==null?void 0:r.updateStreams():yield this.startAudioCapture():yield(n=this.publisher)==null?void 0:n.publishUpdate())})}isLocalAudioStreamPublished(){var e,t;return(t=(e=this.publisher)==null?void 0:e.publishLocalAudioStreamEnabled)!=null?t:!0}setDefaultSubscribeAllRemoteAudioStreams(e){this.bizControl.setAutoSubAudio(e)}subscribeAllRemoteAudioStreams(e){this.bizControl.setWantSubAudio(e)}subscribeRemoteAudioStream(e,t){if(t&&!this.bizControl.isWantSubAudio)throw new O(U.ERR_INVALID_ARGUMENTS,"subscribeAllRemoteAudioStreams(true) must be called first");this.bizControl.updateAudioWant(e,t)}resumeRemoteAudioStream(e){const t=this.bizControl.getRemoteUser(e);if(!t)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);t.resumeAudio()}stopRemoteAudioPlay(e){const t=this.bizControl.getRemoteUser(e);if(!t)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);t.stopPlayAudio()}publishLocalVideoStream(e){return T(this,null,function*(){var t,i,r,n;(t=this.publisher)==null||t.setPublishLocalVideoStreamEnabled(e),this.connectState===ne.AliRtcConnectionStatusConnected&&(e?(i=this.publisher)!=null&&i.hasCamera?yield(r=this.publisher)==null?void 0:r.updateStreams():yield this.enableLocalVideo():yield(n=this.publisher)==null?void 0:n.publishUpdate())})}isLocalVideoStreamPublished(){var e,t;return(t=(e=this.publisher)==null?void 0:e.publishLocalVideoStreamEnabled)!=null?t:!0}setRemoteDefaultVideoStreamType(e){[We.AliRtcVideoStreamTypeHigh,We.AliRtcVideoStreamTypeLow].includes(e)&&this.bizControl.setRemoteDefaultVideoStreamType(e)}setRemoteUserVideoStreamType(e,t){[We.AliRtcVideoStreamTypeHigh,We.AliRtcVideoStreamTypeLow].includes(t)&&this.bizControl.setRemoteUserVideoStreamType(e,t)}setDefaultSubscribeAllRemoteVideoStreams(e){this.bizControl.setAutoSubVideo(e),this.bizControl.setAutoSubScreen(e)}subscribeAllRemoteVideoStreams(e){this.bizControl.setWantSubVideo(e),this.bizControl.setWantSubScreen(e)}subscribeRemoteMediaStream(e,t,i,r){const n=this.bizControl.getRemoteUser(e);if(!n)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);!i||t!==oe.AliRtcVideoTrackScreen&&t!==oe.AliRtcVideoTrackBoth?n.setWantSubScreen(!1):n.setWantSubScreen(!0),!i||t!==oe.AliRtcVideoTrackCamera&&t!==oe.AliRtcVideoTrackBoth?n.setWantSubVideo(!1):n.setWantSubVideo(!0),n.setWantSubAudio(r),n.updateSubscribe(Se.User)}resumeRemoteMediaStream(e,t){const i=this.bizControl.getRemoteUser(e);i&&i.resumeVideo(t)}getOnlineRemoteUsers(){return this.bizControl.remoteUsers.map(e=>e.userId)}getUserInfo(e){var t;return(t=this.bizControl.getRemoteUser(e))==null?void 0:t.remoteUserInfo}isUserOnline(e){return!!this.bizControl.remoteUsers.find(t=>t.userId===e)}startScreenShare(e){return T(this,null,function*(){var c;const t={video:!1,audio:!1},{audio:i=!1,videoTrack:r,audioTrack:n}=e||{};if(r||n){t.screen=!0;const o=new MediaStream;r&&o.addTrack(r),n&&o.addTrack(n),t.mediaStream=o}else t.screen=!i||{audio:!0};yield(c=this.publisher)==null?void 0:c.createLocalStream(t)})}stopScreenShare(){return T(this,null,function*(){var e;(e=this.publisher)==null||e.stopLocalStream({screen:!0})})}setScreenShareConfiguration(e){return T(this,null,function*(){var n;const t={},{width:i,height:r}=e;if(i&&!isNaN(i)&&r&&!isNaN(r)&&i*r>9437184)throw new O(U.ERR_INVALID_ARGUMENTS,"width * height must be less than 9437184");Object.keys(e).forEach(c=>{c!=="width"&&c!=="height"||(t[c]=e[c])}),yield(n=this.publisher)==null?void 0:n.setScreenProfile(t)})}setScreenShareContentHint(e){return T(this,null,function*(){var t;e&&((t=this.publisher)==null||t.setScreenContentHint(e))})}publishLocalScreenShareStream(e,t){return T(this,null,function*(){var i,r,n;(i=this.publisher)==null||i.setPublishLocalScreenStreamEnabled(e),this.connectState===ne.AliRtcConnectionStatusConnected&&(e?(r=this.publisher)!=null&&r.hasScreenShare?yield this.publisher.updateStreams():yield this.startScreenShare(t):yield(n=this.publisher)==null?void 0:n.publishUpdate())})}isScreenSharePublished(){var e,t;return(t=(e=this.publisher)==null?void 0:e.publishLocalScreenStreamEnabled)!=null?t:!0}setAudioShareVolume(e){if(typeof e!="number")throw new O(U.ERR_INVALID_ARGUMENTS,"volume must be a number");this.bizControl.setAudioVolume({screen:Math.max(0,Math.min(e,400))/100})}enableAudioVolumeIndication(e){this.bizControl.enableAudioVolumeIndication(e)}muteLocalMic(e=!1){var t,i;(t=this.publisher)==null||t.muteLocalMic(e),this.connectState===ne.AliRtcConnectionStatusConnected&&this.isPublishing&&((i=this.publisher)==null||i.reportSelfDeviceStatus())}muteRemoteAudioPlaying(e,t=!1){const i=this.bizControl.getRemoteUser(e);if(!i)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);i.setAudioMuted(t)}muteAllRemoteAudioPlaying(e=!1){this.bizControl.setAudioMuted(e)}startAudioCapture(e){return T(this,null,function*(){var i;const t={audio:e||!0};yield(i=this.publisher)==null?void 0:i.createLocalStream(t)})}setAudioConstraints(e){return T(this,null,function*(){var t;yield(t=this.publisher)==null?void 0:t.setMicrophoneConstraints(e)})}stopAudioCapture(){var e;(e=this.publisher)==null||e.stopAudioCapture()}switchMicrophone(e,t){return T(this,null,function*(){var i,r,n,c;if(yield(i=this.publisher)==null?void 0:i.setMicrophoneDeviceId(e),!((r=this.publisher)!=null&&r.audioCaptureDisabled)){if(t)return void(yield(n=this.publisher)==null?void 0:n.createLocalStream({audio:!0,mediaStream:new MediaStream([t])}));yield(c=this.publisher)==null?void 0:c.createLocalStream({audio:{deviceId:e}})}})}setRecordingVolume(e){if(typeof e!="number")throw new O(U.ERR_INVALID_ARGUMENTS,"volume must be a number");this.bizControl.setAudioVolume({audio:Math.max(0,Math.min(e,400))/100})}setPlayoutVolume(e){if(typeof e!="number")throw new O(U.ERR_INVALID_ARGUMENTS,"volume must be a number");this.bizControl.setPlayoutVolume(Math.max(0,Math.min(e,100))/100)}setRemoteAudioVolume(e,t){const i=this.bizControl.getRemoteUser(e);if(!i)throw new O(U.ERR_INNER,`no remote user(${e}) founded`);if(typeof t!="number")throw new O(U.ERR_INVALID_ARGUMENTS,"volume must be a number");i.setPlayoutVolume(Math.max(0,Math.min(t,100))/100)}setAudioProfile(e){return T(this,null,function*(){var t;yield(t=this.publisher)==null?void 0:t.setAudioProfile(e)})}getAudioTrack(e){return T(this,null,function*(){var i;if(!e)return(i=this.publisher)==null?void 0:i.audioTrack;const t=this.bizControl.getRemoteUser(e);return t==null?void 0:t.getAudioTrack})}setLocalViewConfig(e,t){return T(this,null,function*(){var i,r,n;if(this._audioOnlyMode)throw new O(U.ERR_INNER,"Cannot set local view in audio only mode");(i=this.bizControl)==null||i.setLocalViewConfig(e,t),t===oe.AliRtcVideoTrackCamera&&((r=this.publisher)!=null&&r.hasCamera)?yield this.startPreview():t===oe.AliRtcVideoTrackScreen&&((n=this.publisher)!=null&&n.hasScreenShare)&&(yield this.startPreviewScreen())})}setCameraCapturerConfiguration(e){return T(this,null,function*(){var l,d,p;const h=e,{cameraDirection:t,deviceId:i,bitrate:r,maxSendFrameRate:n}=h,c=Qt(h,["cameraDirection","deviceId","bitrate","maxSendFrameRate"]),o=X({},c);r&&(o.maxBitrate=r),n&&(o.maxSendFrameRate=n),Object.keys(o).length>0&&(yield(l=this.publisher)==null?void 0:l.setVideoProfile(o)),t!==void 0&&((d=this.publisher)==null||d.setCameraDirection(t)),i&&((p=this.publisher)==null||p.setCameraDeviceId(i))})}setCameraCapturerContentHint(e){return T(this,null,function*(){var t;e&&((t=this.publisher)==null||t.setVideoContentHint(e))})}enableLocalVideo(e=!0){return T(this,null,function*(){var t,i,r,n,c,o,h,l,d,p,u;if(this._audioOnlyMode)throw new O(U.ERR_INNER,"Cannot enable local video in audio only mode");e?((i=(t=this.publisher)==null?void 0:t.publishStreams)!=null&&i.video&&((c=(n=(r=this.publisher)==null?void 0:r.publishStreams)==null?void 0:n.video)==null||c.disableVideo(),(d=(l=(h=(o=this.publisher)==null?void 0:o.publishStreams)==null?void 0:h.video)==null?void 0:l.videoTrack)==null||d.stop()),yield(p=this.publisher)==null?void 0:p.startCameraCapture()):yield(u=this.publisher)==null?void 0:u.stopCameraCapture()})}muteLocalCamera(e){return T(this,null,function*(){var t,i;(t=this.publisher)==null||t.muteLocalCamera(e),this.connectState===ne.AliRtcConnectionStatusConnected&&this.isPublishing&&((i=this.publisher)==null||i.reportSelfDeviceStatus())})}muteLocalScreen(e){return T(this,null,function*(){var t,i;(t=this.publisher)==null||t.muteLocalScreen(e),this.connectState===ne.AliRtcConnectionStatusConnected&&this.isPublishing&&((i=this.publisher)==null||i.reportSelfDeviceStatus())})}setRemoteViewConfig(e,t,i){this.bizControl.setRemoteViewConfig(t,e,i)}isCameraOn(){var e,t;return(t=(e=this.publisher)==null?void 0:e.hasCamera)!=null?t:!1}switchCamera(e,t){return T(this,null,function*(){var r,n,c,o,h,l;if(this._audioOnlyMode)throw new O(U.ERR_INNER,"Cannot switch camera in audio only mode");const i={};if(e?(i.deviceId=e,this.slsReporter.reportSwitchCamera(e)):t||(i.cameraDirection=((r=this.publisher)==null?void 0:r.cameraDirection)==="environment"?mi.CAMERA_FRONT:mi.CAMERA_REAR,this.slsReporter.reportSwitchCamera(((n=this.publisher)==null?void 0:n.cameraDirection)||"")),yield this.setCameraCapturerConfiguration(i),!((c=this.publisher)!=null&&c.cameraCaptureDisabled)){(h=(o=this.publisher)==null?void 0:o.cameraTrack)==null||h.stop();const d={video:!0};t&&(d.mediaStream=new MediaStream([t])),yield(l=this.publisher)==null?void 0:l.createLocalStream(d)}})}getCurrentCameraDeviceId(){var e;return(e=this.publisher)==null?void 0:e.getCurrentCameraDeviceId()}startPreview(){return T(this,null,function*(){var e,t;if(this._audioOnlyMode)throw new O(U.ERR_INNER,"Cannot start preview camera in audio only mode");(e=this.publisher)!=null&&e.hasCamera||(yield this.enableLocalVideo(!0)),yield(t=this.publisher)==null?void 0:t.previewAll({screen:!1})})}startPreviewScreen(e){return T(this,null,function*(){var t,i;if(this._audioOnlyMode)throw new O(U.ERR_INNER,"Cannot start preview screen share in audio only mode");(t=this.publisher)!=null&&t.hasScreenShare||(yield this.startScreenShare(e)),yield(i=this.publisher)==null?void 0:i.previewAll({primary:!1})})}stopPreview(){return T(this,null,function*(){var e;yield(e=this.publisher)==null?void 0:e.stopPreview({primary:!0,screen:!1})})}stopPreviewScreen(){return T(this,null,function*(){var e;yield(e=this.publisher)==null?void 0:e.stopPreview({primary:!1,screen:!0})})}getVideoTrack(e){return T(this,null,function*(){var n,c,o,h;const{userId:t,streamType:i}=e;if(!t)return i===Le.AliRtcSdkStreamTypeCapture?(n=this.publisher)==null?void 0:n.cameraTrack:(c=this.publisher)==null?void 0:c.screenTrack;const r=this.bizControl.getRemoteUser(t);return i===Le.AliRtcSdkStreamTypeCapture?(o=r==null?void 0:r.getCameraStream)==null?void 0:o.videoTrack:(h=r==null?void 0:r.getScreenStream)==null?void 0:h.videoTrack})}startPublishLiveStream(e,t){return T(this,null,function*(){return this.liveTranscoding.startPublishLiveStream(e,t)})}updatePublishLiveStream(e,t){return T(this,null,function*(){return this.liveTranscoding.updatePublishLiveStream(e,t)})}updatePublishLiveStreamWithTaskId(e,t){return this.liveTranscoding.updatePublishLiveStreamWithTaskId(e,t)}stopPublishLiveStream(e){return T(this,null,function*(){return this.liveTranscoding.stopPublishLiveStream(e)})}stopPublishLiveStreamWithTaskId(e){return this.liveTranscoding.stopPublishLiveStreamWithTaskId(e)}setEnableMediaExtensionMsg(e){var t;(t=this.bizControl)==null||t.setEnableMediaExtensionMsg(!!e)}sendMediaExtensionMsg(e,t){return T(this,null,function*(){return this.sendMediaExtensionMsgEx(e,t,5)})}sendMediaExtensionMsgEx(e,t,i){return T(this,null,function*(){var r;if(!this.publisher||!this.isPublishing)throw new O(U.ERR_INNER,"you should publish first");return this.slsReporter.reportSEIMessage(i,e.byteLength,t,0,!1),(r=this.publisher)==null?void 0:r.sendSEI(e,t,i)})}enablePlugin(e,t){this.bizControl.pluginManager.add(e,t)}removePlugin(e){this.bizControl.pluginManager.remove(e)}setPluginOption(e,t){const i=this.bizControl.pluginManager.get(e);i&&t&&i.setOptions(t)}getPluginByName(e){return this.bizControl.pluginManager.get(e)}getPluginOption(e){const t=this.bizControl.pluginManager.get(e);return t==null?void 0:t.getOptions()}isBeautyAvailable(){return this.bizControl.pluginManager.has("AliRtcBeauty")}isBeautyEnabled(){const e=this.bizControl.pluginManager.get("AliRtcBeauty");if(!e)throw new O(Ut.AliRtcPluginErrorNoFindPlugin,"you should enable beautyPlugin first");return!!(e!=null&&e.isEnable)}setBeautyEffect(e,t){const i=this.bizControl.pluginManager.get("AliRtcBeauty");if(!i)throw new O(Ut.AliRtcPluginErrorNoFindPlugin,"you should enable beautyPlugin first");e?i.enable():i.disable(),i.setOptions({basicBeauty:{skinBuffing:Math.max(Math.min(1,+t.smoothnessLevel),0),whitening:Math.max(Math.min(1,+t.whiteningLevel),0)}})}enableBackgroundExchange(e,t){const i=this.bizControl.pluginManager.get("AliRtcBeauty");if(!i||!i.isEnable)throw new O(Ut.AliRtcPluginErrorNoFindPlugin,"you should enable beautyPlugin first");const r={setSegmentBackgroundImage:{backgroundImgUrl:e?t:""}};e&&(r.segmentBackgroundProcess={enable:!1}),i.setOptions(r)}enableBackgroundBlur(e){const t=this.bizControl.pluginManager.get("AliRtcBeauty");if(!t||!t.isEnable)throw new O(Ut.AliRtcPluginErrorNoFindPlugin,"you should enable beautyPlugin first");const i={segmentBackgroundProcess:{type:0,enable:e}};e&&(i.setSegmentBackgroundImage={type:0,backgroundImgUrl:""}),t.setOptions(i)}setParameter(e){this.bizControl.setParameter(e)}getParameter(){return this.bizControl.getParameter()}sendDataChannelMessage(e){this.bizControl.sendDataChannelMessage(e)}},f(K,"logName","AliRtcEngine"),f(K,"logError",!0),f(K,"isSupported",Vo),f(K,"isDualVideoStreamSupported",Hr.isSupport),f(K,"getCameraList",()=>T(K,null,function*(){return(yield q.AliRTS.getCameraList()).filter(e=>e.deviceId)})),f(K,"getMicrophoneList",()=>T(K,null,function*(){return(yield q.AliRTS.getMicList()).filter(e=>e.deviceId)})),f(K,"getSpeakerList",()=>T(K,null,function*(){return(yield q.AliRTS.getSpeakerList()).filter(e=>e.deviceId)})),f(K,"_instance"),f(K,"AliRtcSdkChannelProfile",Ct),f(K,"AliRtcSdkClientRole",Lt),f(K,"AliRtcVideoStreamType",We),f(K,"AliRtcVideoTrack",oe),f(K,"AliRtcAudioTrack",ri),f(K,"AliRtcPublishState",ie),f(K,"AliRtcSubscribeState",me),f(K,"AliRtcRawDataStreamType",Le),f(K,"AliRtcLogLevel",Sr),f(K,"AliRtcEngineLocalDeviceType",yt),f(K,"AliRtcEngineLocalDeviceExceptionType",Oe),f(K,"AliRtcConnectionStatus",ne),f(K,"AliRtcConnectionStatusChangeReason",Rt),f(K,"AliRtcPlugin",Nt),f(K,"AliRtcPluginTrackType",ti),f(K,"AliRtcLiveTranscodingParam",xi),f(K,"AliRtcLiveTranscodingEncodeParam",_r),f(K,"AliRtcLiveTranscodingMixParam",nn),f(K,"AliRtcLiveTranscodingSingleParam",on),f(K,"AliRtcTranscodingClockWidget",cn),f(K,"AliRtcTranscodingImage",Wr),f(K,"AliRtcTranscodingText",ln),f(K,"AliRtcTranscodingUser",dn),f(K,"AliRtcLiveTranscodingMixMode",li),f(K,"AliRtcLiveTranscodingStreamType",br),f(K,"AliRtcLiveTranscodingSourceType",ii),f(K,"AliRtcLiveTranscodingTaskProfile",vr),f(K,"AliRtcLiveTranscodingAudioSampleRate",Ni),f(K,"AliRtcLiveTranscodingSegmentType",ui),f(K,"AliRtcLiveTranscodingFontType",pi),f(K,"AliRtcLiveTranscodingCropMode",yr),f(K,"AliRtcLiveTranscodingMediaProcessMode",Li),f(K,"AliRtcLiveTranscodingState",Rr),f(K,"AliRtcLiveTranscodingErrorCode",vt),f(K,"AliRtcTrascodingPublishTaskStatus",Ar),f(K,"AliRtcDataChannelMsg",Vt),f(K,"AliRtcDataMsgType",xr),f(K,"Plugin",Nt),K);j([C()],F.prototype,"destroy",1),j([C()],F.prototype,"backToUnpublishStatus",1),j([C()],F.prototype,"resumePublishForNetworkRecovery",1),j([C()],F.prototype,"onNetworkRecovery",1),j([C()],F.prototype,"resumeSubList",1),j([C(B)],F.prototype,"retrySubscribe",1),j([C(B)],F.prototype,"setEnableDualVideoStream",1),j([C(B)],F.prototype,"setChannelProfile",1),j([C(B)],F.prototype,"setClientRole",1),j([C(B)],F.prototype,"setAudioOnlyMode",1),j([C()],F.prototype,"clearCheckAuthInfoTimer",1),j([C(B)],F.prototype,"joinChannel",1),j([C(B)],F.prototype,"joinAIChannel",1),j([C(B)],F.prototype,"leaveChannel",1),j([C(B)],F.prototype,"refreshAuthInfo",1),j([C(B)],F.prototype,"publishLocalAudioStream",1),j([C(B)],F.prototype,"setDefaultSubscribeAllRemoteAudioStreams",1),j([C(B)],F.prototype,"subscribeAllRemoteAudioStreams",1),j([C(B)],F.prototype,"subscribeRemoteAudioStream",1),j([C(B)],F.prototype,"resumeRemoteAudioStream",1),j([C(B)],F.prototype,"stopRemoteAudioPlay",1),j([C(B)],F.prototype,"publishLocalVideoStream",1),j([C(B)],F.prototype,"setRemoteDefaultVideoStreamType",1),j([C(B)],F.prototype,"setRemoteUserVideoStreamType",1),j([C(B)],F.prototype,"setDefaultSubscribeAllRemoteVideoStreams",1),j([C(B)],F.prototype,"subscribeAllRemoteVideoStreams",1),j([C(B)],F.prototype,"subscribeRemoteMediaStream",1),j([C(B)],F.prototype,"resumeRemoteMediaStream",1),j([C(([s])=>[`${s==null?void 0:s.audio}`])],F.prototype,"startScreenShare",1),j([C()],F.prototype,"stopScreenShare",1),j([C(B)],F.prototype,"setScreenShareConfiguration",1),j([C(B)],F.prototype,"setScreenShareContentHint",1),j([C()],F.prototype,"publishLocalScreenShareStream",1),j([C(B)],F.prototype,"setAudioShareVolume",1),j([C(B)],F.prototype,"enableAudioVolumeIndication",1),j([C(B)],F.prototype,"muteLocalMic",1),j([C(B)],F.prototype,"muteRemoteAudioPlaying",1),j([C(B)],F.prototype,"muteAllRemoteAudioPlaying",1),j([C(B)],F.prototype,"startAudioCapture",1),j([C(B)],F.prototype,"setAudioConstraints",1),j([C()],F.prototype,"stopAudioCapture",1),j([C(B)],F.prototype,"switchMicrophone",1),j([C(B)],F.prototype,"setRecordingVolume",1),j([C(B)],F.prototype,"setPlayoutVolume",1),j([C(B)],F.prototype,"setRemoteAudioVolume",1),j([C(B)],F.prototype,"setAudioProfile",1),j([C(B)],F.prototype,"getAudioTrack",1),j([C(B)],F.prototype,"setLocalViewConfig",1),j([C(B)],F.prototype,"setCameraCapturerConfiguration",1),j([C(B)],F.prototype,"setCameraCapturerContentHint",1),j([C(B)],F.prototype,"enableLocalVideo",1),j([C(B)],F.prototype,"muteLocalCamera",1),j([C(B)],F.prototype,"muteLocalScreen",1),j([C(B)],F.prototype,"setRemoteViewConfig",1),j([C(B)],F.prototype,"switchCamera",1),j([C()],F.prototype,"startPreview",1),j([C()],F.prototype,"startPreviewScreen",1),j([C()],F.prototype,"stopPreview",1),j([C()],F.prototype,"stopPreviewScreen",1),j([C()],F.prototype,"startPublishLiveStream",1),j([C()],F.prototype,"updatePublishLiveStream",1),j([C()],F.prototype,"updatePublishLiveStreamWithTaskId",1),j([C()],F.prototype,"stopPublishLiveStream",1),j([C()],F.prototype,"stopPublishLiveStreamWithTaskId",1),j([C(B)],F.prototype,"setEnableMediaExtensionMsg",1),j([C(([s,a,e])=>[s.byteLength,a,e])],F.prototype,"sendMediaExtensionMsgEx",1),j([C(([s,a])=>[s.name||"",a])],F.prototype,"enablePlugin",1),j([C(B)],F.prototype,"removePlugin",1),j([C(B)],F.prototype,"setPluginOption",1),j([C(B)],F.prototype,"getPluginByName",1),j([C(B)],F.prototype,"getPluginOption",1),j([C(B)],F.prototype,"setBeautyEffect",1),j([C(B)],F.prototype,"enableBackgroundExchange",1),j([C(B)],F.prototype,"enableBackgroundBlur",1),j([C(B)],F.prototype,"setParameter",1),j([C(([s])=>{var a;return[(a=s.data)==null?void 0:a.byteLength]})],F.prototype,"sendDataChannelMessage",1),j([C(B)],F,"setLogLevel",1);let Sn=F;const bn=new nr({businessName:"imp-web-rtc",version:(vn=Sn.getSdkVersion())!=null?vn:"unknown",env:"prod",disabled:window.AliRtcOptionsDisableProxy===!0});bn.setReady();const Tc=bn.wrap(Sn);W.AliRtcCapabilityProfile=Wi,W.AliRtcConnectionStatus=ne,W.AliRtcConnectionStatusChangeReason=Rt,W.AliRtcDataChannelMsg=Vt,W.AliRtcDataMsgType=xr,W.AliRtcEngineLocalDeviceExceptionType=Oe,W.AliRtcEngineLocalDeviceType=yt,W.AliRtcErrorCode=U,W.AliRtcLiveTranscodingAudioSampleRate=Ni,W.AliRtcLiveTranscodingCropMode=yr,W.AliRtcLiveTranscodingEncodeParam=_r,W.AliRtcLiveTranscodingErrorCode=vt,W.AliRtcLiveTranscodingFontType=pi,W.AliRtcLiveTranscodingMediaProcessMode=Li,W.AliRtcLiveTranscodingMixMode=li,W.AliRtcLiveTranscodingMixParam=nn,W.AliRtcLiveTranscodingParam=xi,W.AliRtcLiveTranscodingSegmentType=ui,W.AliRtcLiveTranscodingSingleParam=on,W.AliRtcLiveTranscodingSourceType=ii,W.AliRtcLiveTranscodingState=Rr,W.AliRtcLiveTranscodingStreamType=br,W.AliRtcLiveTranscodingTaskProfile=vr,W.AliRtcLocalStreamInfo=Ur,W.AliRtcLogLevel=Sr,W.AliRtcPlugin=Nt,W.AliRtcPluginTrackType=ti,W.AliRtcPluginType=Ha,W.AliRtcPublishState=ie,W.AliRtcRawDataStreamType=Le,W.AliRtcRemoteUserInfo=Ya,W.AliRtcSdkChannelProfile=Ct,W.AliRtcSdkClientRole=Lt,W.AliRtcSubscribeState=me,W.AliRtcTranscodingClockWidget=cn,W.AliRtcTranscodingImage=Wr,W.AliRtcTranscodingText=ln,W.AliRtcTranscodingUser=dn,W.AliRtcTrascodingPublishTaskStatus=Ar,W.AliRtcVideoStreamType=We,W.AliRtcVideoTrack=oe,W.default=Tc,Object.defineProperties(W,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|