aliyun-rtc-sdk 6.14.4-beta.5 → 6.14.4
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 +112 -81
- package/dist/aliyun-rtc-sdk.umd.js +8 -8
- package/dist/types/index.d.ts +15 -0
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var jc=Object.defineProperty,zc=Object.defineProperties;var Wc=Object.getOwnPropertyDescriptors;var Hi=Object.getOwnPropertySymbols,$c=Object.getPrototypeOf,Fn=Object.prototype.hasOwnProperty,Vn=Object.prototype.propertyIsEnumerable,Kc=Reflect.get;var bs=($,G,re)=>G in $?jc($,G,{enumerable:!0,configurable:!0,writable:!0,value:re}):$[G]=re,
|
|
1
|
+
var jc=Object.defineProperty,zc=Object.defineProperties;var Wc=Object.getOwnPropertyDescriptors;var Hi=Object.getOwnPropertySymbols,$c=Object.getPrototypeOf,Fn=Object.prototype.hasOwnProperty,Vn=Object.prototype.propertyIsEnumerable,Kc=Reflect.get;var bs=($,G,re)=>G in $?jc($,G,{enumerable:!0,configurable:!0,writable:!0,value:re}):$[G]=re,X=($,G)=>{for(var re in G||(G={}))Fn.call(G,re)&&bs($,re,G[re]);if(Hi)for(var re of Hi(G))Vn.call(G,re)&&bs($,re,G[re]);return $},vt=($,G)=>zc($,Wc(G));var qt=($,G)=>{var re={};for(var We in $)Fn.call($,We)&&G.indexOf(We)<0&&(re[We]=$[We]);if($!=null&&Hi)for(var We of Hi($))G.indexOf(We)<0&&Vn.call($,We)&&(re[We]=$[We]);return re};var g=($,G,re)=>(bs($,typeof G!="symbol"?G+"":G,re),re);var Es=($,G,re)=>Kc($c($),re,G);var w=($,G,re)=>new Promise((We,vi)=>{var lt=tt=>{try{Dt(re.next(tt))}catch(Jt){vi(Jt)}},ri=tt=>{try{Dt(re.throw(tt))}catch(Jt){vi(Jt)}},Dt=tt=>tt.done?We(tt.value):Promise.resolve(tt.value).then(lt,ri);Dt((re=re.apply($,G)).next())});(function($,G){typeof exports=="object"&&typeof module!="undefined"?G(exports,require("aliyun-rts-sdk"),require("eventemitter3")):typeof define=="function"&&define.amd?define(["exports","aliyun-rts-sdk","eventemitter3"],G):($=typeof globalThis!="undefined"?globalThis:$||self,G($.AliRtcEngine={},$.AliyunRts,$.EventEmitter))})(this,function($,G,re){var Le,mt,Me,Ce,Rt,q,wn;"use strict";var We=Object.defineProperty,vi=(r,n,e)=>n in r?We(r,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[n]=e,lt=(r,n,e)=>(vi(r,typeof n!="symbol"?n+"":n,e),e),ri={exports:{}},Dt={exports:{}},tt,Jt;function Be(){if(Jt)return tt;Jt=1,Date.now=Date.now||function(){return new Date().getTime()};var r=Date.now(),n=function(){},e=function(){var i=typeof console=="object"?console.warn:n;try{var s={warn:i};s.warn.call(s)}catch(a){return n}return i},t={noop:n,warn:e(),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(i){if(Object.create)return Object.create(i);var s=function(){};return s.prototype=i,new s},each:function(i,s){var a=0,c=i.length;if(this.T(i,"Array"))for(;a<c&&s.call(i[a],i[a],a)!==!1;a++);else for(a in i)if(s.call(i[a],i[a],a)===!1)break;return i},safetyCall:function(i,s,a){if(typeof i!="function")return a;try{return i.apply(this,s)}catch(c){return a}},T:function(i,s){var a=Object.prototype.toString.call(i).substring(8).replace("]","");return s?a===s:a},duration:function(){var i=Date;try{performance&&this.T(performance.now,"Function")&&(i=performance)}catch(a){i=Date}var s=i.now();return function(){return Math.round(i.now()-s)}},filterByRule:function(){var i=[].slice.call(arguments),s=i.length;if(s<2)return i[0];var a=i[s-1],c=i[0];if(!c)return"";if(!a)return c;var o=this,u=o.T(a),h=i.slice(0,s-1);return u==="Function"?o.safetyCall(a,h,c):u==="Array"?(this.each(a,function(p){h[0]=c=o.filterByRule.apply(o,[].concat(h,p))}),c):u==="Object"?c.replace(a.rule,a.target||""):c.replace(a,"")},ignoreByRule:function(i,s){if(!i||!s)return!1;if((this.isString(s)||s.source||this.T(s)==="Function")&&(s=[s]),!this.isArray(s))return this.warn("[arms] invalid rules of ignore config, (list of) String/RegExp/Funcitons are available"),!1;for(var a,c=[],o=0,u=s.length;o<u;o++)if(a=s[o],this.isString(a))c.push(a.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"));else if(a&&a.source)c.push(a.source);else if(a&&this.T(a)==="Function"&&this.safetyCall(a,[i],!1)===!0)return!0;var h=new RegExp(c.join("|"),"i");return!!(c.length&&h.test&&h.test(i))},J:function(i){if(!i||typeof i!="string")return i;var s=null;try{s=JSON.parse(i)}catch(a){}return s},pick:function(i){return i===1||Math.ceil(Math.random()*i)===1},verifyConfig:function(i){if("sample"in i){var s=i.sample,a=s;s&&/^\d+(\.\d+)?%$/.test(s)&&(a=parseInt(100/parseFloat(s))),0<a&&1>a&&(a=parseInt(1/a)),a>=1&&a<=100?i.sample=a:delete i.sample}return i},on:function(i,s,a,c,o){return i.addEventListener?(o=o||!1,i.addEventListener(s,function u(h){c&&i.removeEventListener(s,u,o),a.call(this,h)},o)):i.attachEvent&&i.attachEvent("on"+s,function u(h){c&&i.detachEvent("on"+s,u),a.call(this,h)}),this},off:function(i,s,a){return a?(i.removeEventListener?i.removeEventListener(s,a):i.detachEvent&&i.detachEvent(s,a),this):this},delay:function(i,s){return s===-1?(i(),null):setTimeout(i,s||0)},ext:function(i){for(var s=1,a=arguments.length;s<a;s++){var c=arguments[s];for(var o in c)Object.prototype.hasOwnProperty.call(c,o)&&(i[o]=c[o])}return i},sub:function(i,s){var a={};return this.each(i,function(c,o){s.indexOf(o)!==-1&&(a[o]=c)}),a},uu:function(){for(var i,s,a=20,c=new Array(a),o=Date.now().toString(36).split("");a-- >0;)s=(i=36*Math.random()|0).toString(36),c[a]=i%3?s:s.toUpperCase();for(var u=0;u<8;u++)c.splice(3*u+2,0,o[u]);return c.join("")},guid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var s=16*Math.random()|0;return(i==="x"?s:3&s|8).toString(16)})},seq:function(){return(r++).toString(36)},decode:function(i){try{i=decodeURIComponent(i)}catch(s){}return i},encode:function(i,s){try{i=s?encodeURIComponent(i).replace(/\(/g,"%28").replace(/\)/g,"%29"):encodeURIComponent(i)}catch(a){}return i},serialize:function(i){i=i||{};var s=[];for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&i[a]!==void 0&&s.push(a+"="+this.encode(i[a],a==="msg"));return s.join("&")},checkAPI:function(i,s){if(!i||typeof i!="string")return!1;var a=/arms-retcode[\w-]*\.aliyuncs/.test(i);return!a&&s&&(a=/(alicdn\.com)|(mmstat\.com)/.test(i)),!a},checkAutoError:function(i){return!(!i||!i.message)&&!/failed[\w\s]+fetch/i.test(i.message)},cutUrlSearch:function(i){return i&&typeof i=="string"?i.replace(/^(https?:)?\/\//,"").replace(/\?.*$/,""):""},removeUrlSearch:function(i){return i&&typeof i=="string"?i.replace(/\?.*$/,""):""},createFakeToString:function(i){return function(){return i+"() { [native code] }"}},checkSameOrigin:function(i,s){if(!s||!i)return!1;var a="//"+s.split("/")[2];return i===s||i.slice(0,s.length+1)===s+"/"||i===a||i.slice(0,a.length+1)===a+"/"||!/^(\/\/|http:|https:).*/.test(i)},getRandIP:function(){for(var i=[],s=0;s<4;s++){var a=Math.floor(256*Math.random());i[s]=(a>15?"":"0")+a.toString(16)}return i.join("").replace(/^0/,"1")},getSortNum:function(i){return i?(i+=1)>=1e3&&i<=9999?i:i<1e3?i+1e3:i%1e4+1e3:1e3},getRandNum:function(i){return i&&typeof i=="string"?i.length<5?this.getNum(5):i.substring(i.length-5):this.getNum(5)},getNum:function(i){for(var s=[],a=0;a<i;a++){var c=Math.floor(16*Math.random());s[a]=c.toString(16)}return s.join("")},getCurDomain:function(){return location&&location.hostname||""},getSrcType:function(i,s){var a=location&&location.host||"";if(!a)return"";var c=new URL(i).host;if(c===a)return"self";for(var o=0;o<s.length;o+=1)if(c.includes(s[o]))return"cdn";return"others"},parseFetchHeaders:function(i){if(!i)return{};var s={};try{if(typeof i.keys=="function")for(var a=i.keys(),c=a.next();!c.done;){var o=c.value;s[o]=i.get(o),c=a.next()}else s=i}catch(u){s={}}return s},parseXhrHeaders:function(i){if(!i&&typeof i!="string")return{};var s={};try{var a=i.split(`\r
|
|
2
2
|
`);s=a.reduce(function(c,o){var u=o.split(": ");return c[u[0]]=u[1],c},{})}catch(c){s={}}return s},getQuerys:function(i){if(!i)return"";var s={},a=[],c="",o="";try{var u=[];if(i.indexOf("?")>=0&&(u=i.substring(i.indexOf("?")+1,i.length).split("&")),u.length>0)for(var h in u)c=(a=u[h].split("="))[0],o=a[1],s[c]=o}catch(p){s={}}return s},getURL:function(i){if(!i)return null;var s={},a=i.length,c=i.indexOf("://");if(c<0)return null;s.protocol=i.substring(0,c+1);var o=i.indexOf("#"),u=i.indexOf("?");o<0&&(o=a),u<0&&(u=o),s.search=i.substring(u,o).substring(0,1e3);var h=i.substring(c+3,u),p=h.indexOf("/");return p<0&&(p=h.length),s.domain=h.substring(0,p).split(":")[0],s.path=h.substring(p,h.length).substring(0,1e3),s},getResType:function(i,s){if(["script","img","other"].indexOf(i)>-1)return i;if(["video"].indexOf(i)>-1)return"media";if(["document","iframe"].indexOf(i)>-1)return"doc";var a=s?this.getURL(s):null,c=a&&a.path?a.path.lastIndexOf("."):-1,o=(c>0?a.path.substr(c+1):"").toLowerCase();if(o){if(["eot","woff","woff2","ttf"].indexOf(o)>-1)return"font";if(o==="css")return"css";if(o==="js")return"script"}return["fetch","xmlhttprequest","beacon"].indexOf(i)>-1?"api":"others"},areInOrder:function(){for(var i=1;i<arguments.length;i+=1)if(arguments[i-1]>arguments[i])return!1;return!0},getFetchSnapshot:function(i,s,a){var c,o;try{var u=(i&&typeof i[0]!="string"?i[0].url:i[0])||"",h=(i&&typeof i[0]!="string"?i[0]:i[1])||{},p=h.method.toUpperCase()==="POST"?h.body:this.getQuerys(u);c={originApi:u,method:h.method||"unknown",params:p,response:s||"",reqHeaders:this.parseFetchHeaders(h.headers||null),resHeaders:this.parseFetchHeaders(a)},o=JSON&&JSON.stringify(c)||"{}"}catch(d){o="{}"}return o},getXhrSnapshot:function(i,s,a){if(!i||!s||!a)return{};var c,o;try{var u="";a.responseType===""||a.responseType==="text"?u=a.responseText:a.responseType==="document"&&(u=a.responseXML),c={originApi:i,method:s,params:this.getQuerys(i),response:u,reqHeaders:{},resHeaders:this.parseXhrHeaders(typeof a.getAllResponseHeaders=="function"&&a.getAllResponseHeaders()||"")},o=JSON&&JSON.stringify(c)||"{}"}catch(h){o="{}"}return o},isRobot:function(){var i=["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 s=navigator.userAgent.toLowerCase(),a=0;a<i.length;a++){var c=i[a];if(s.lastIndexOf(c)>=0)return!0}}catch(o){this.warn("[arms] useragent parse error")}return!1},isFunction:function(i){return typeof i=="function"},isPlainObject:function(i){return Object.prototype.toString.call(i)==="[object Object]"},isString:function(i){return Object.prototype.toString.call(i)==="[object String]"},isArray:function(i){return Object.prototype.toString.call(i)==="[object Array]"},joinRegExp:function(i){for(var s,a=[],c=0,o=i.length;c<o;c++)s=i[c],this.isString(s)?a.push(s.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):s&&s.source&&a.push(s.source);return new RegExp(a.join("|"),"i")},reWriteMethod:function(i,s,a){if(i!==null){var c=i[s];i[s]=a(c)}},checkSDKError:function(i,s){return!i&&!s?!1:new RegExp(this.selfErrKey,"i").test(i)?!0:!!this.ignoreByRule(s,[/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(i){return{msg:i,message:this.selfErrKey}},dealParam:function(i,s,a){var c={};try{c=this.isPlainObject(i)?this.ext({key:i.key||"default",val:i.val||i.value||a},i,{begin:Date.now()}):{key:i||"default",val:s||a,begin:Date.now()}}catch(o){this.warn("[retcode] baseLog error: "+o)}return c}};return tt=t,tt}var ji={exports:{}},zi={exports:{}},Wi,As;function On(){if(As)return Wi;As=1;var r=Be();return Wi=function(n,e,t){typeof n=="object"&&(n=r.serialize(n));var i=e+n+(t?"&post_res=":"");window&&window.navigator&&typeof window.navigator.sendBeacon=="function"?window.navigator.sendBeacon(i,t||"&post_res="):r.warn("[arms] navigator.sendBeacon not surported")},Wi}var _s;function Un(){if(_s)return zi.exports;_s=1;var r=Be(),n=On(),e="aokcdqn3ly@e629dabd48a9933",t=function(s,a){var c;if(a.t==="error"&&(c=s.requestQueue[0])&&c.t==="error"&&a.msg===c.msg)return a.times=c.times+1,void(s.requestQueue[0]=a);if(a.t==="behavior"){var o=s.requestQueue&&s.requestQueue.length;if(o>0&&s.requestQueue[o-1].t==="behavior"){var u=a.behavior||[];s.requestQueue[o-1].behavior.concat(u)}else s.requestQueue.push(a)}else s.requestQueue.unshift(a);return s.onReady(function(){s.requestTimmer=r.delay(function(){s.clear()},s.requestQueue[0]&&s.requestQueue[0].t==="error"?3e3:-1)}),!0},i=function(s){return this.ver="1.8.36-beta.12",this._conf=r.ext({},i.dftCon),this.sampleCache={},this.requestQueue=[],this.selfQueue=[],this.sdkFlag=!0,this.hash=r.seq(),this.resetPageview(),this.setConfig(s),this.rip=r.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(s){return s()},getPage:function(){var s=this._conf.page;return r.safetyCall(s,[],s+"")},setPage:function(){},setConfig:function(s){s&&typeof s=="object"&&(r.verifyConfig(s),s=this.setImgUrl(s),this._conf=r.ext({},this._conf,s))},setImgUrl:function(s){var a=s.region,c=s.imgUrl;if(a){var o=r.regionMap[a];return s.imgUrl=o||r.defaultImgUrl,s}return c&&(s.imgUrl=c),s},checkImgUrl:function(){return!0},sendRequest:function(){},sendBeacon:function(s,a,c){n(s,a||this.getConfig("imgUrl"),c)},postData:function(){},commonInfo:function(){return{}},setCommonInfo:function(s){s&&typeof s=="object"&&(this._common=r.ext({},this._common,s))},resetPageview:function(){this.pageview=r.uu(),this.sBegin=Date.now()},getUsername:function(){if(this.username)return this.username;var s=this._conf,a=s&&s.setUsername;if(typeof a=="function")try{var c=a();typeof c=="string"&&(c=c.substr(0,40),this.username=c)}catch(o){r.warn("[arms] setUsername fail",o)}return this.username},getTraceId:function(){var s=this.rip,a=Date.now(),c=r.getSortNum(this.record),o=s+a+c+r.getRandNum(this._conf.pid);return this["EagleEye-TraceID"]=o,this.record=c,{"EagleEye-TraceID":o}},getUberTraceId:function(s){var a=this.rip,c=Date.now(),o=r.getSortNum(this.record),u=r.getRandNum(this._conf.pid),h=a+c+o+r.getNum(2)+u,p=h.substring(0,16);return s=s?"1":"0",h[0]==="0"&&(h[0]="1"),h[16]==="0"&&(h[16]="1"),{"uber-trace-id":h+":"+p+":0:"+s,traceId:h}},getB3TraceId:function(s){var a=this.rip,c=Date.now(),o=r.getSortNum(this.record),u=r.getRandNum(this._conf.pid),h=a+c+o+r.getNum(2)+u,p=h.substring(0,16);return s=s?"1":"0",h[0]==="0"&&(h[0]="1"),h[16]==="0"&&(h[16]="1"),{b3:h+"-"+p+"-"+s+"-0","X-B3-TraceId":h,"X-B3-ParentSpanId":"0","X-B3-SpanId":p,"X-B3-Sampled":s}},getPageviewId:function(){return{"EagleEye-SessionID":this.pageview}},getConfig:function(s){return s?this._conf[s]:r.ext({},this._conf)},sampling:function(s){return s===1||(typeof this.sampleCache[s]=="boolean"?this.sampleCache[s]:(this.sampleCache[s]=r.pick(s),this.sampleCache[s]))},clear:function(s){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 o=JSON.stringify({resource:a.resource});delete a.resource,this.sendBeacon(a,null,o)}else a.t==="resource"?this.postData(a,"resource"):this.sendRequest(a);return s&&this.clearSelf(),this},clearSelf:function(){var s;for(clearTimeout(this.Timmer),this.Timmer=null;s=this.selfQueue.pop();)this.postData(s,"err");return this},_lg:function(s,a,c,o){var u=this,h=u._conf,p=u.getPage(),d=h.ignore||{},f=d.ignoreErrors,m=d.ignoreResErrors,l=d.ignoreUrls,S=d.ignoreApis;if(u._isRobot||r.ignoreByRule(p,l)||r.ignoreByRule(r.decode(p),l)||s==="error"&&(r.ignoreByRule(a.msg,f)||r.ignoreByRule(r.decode(a.msg),f))||s==="resourceError"&&(r.ignoreByRule(a.src,m)||r.ignoreByRule(r.decode(a.src),m))||s==="api"&&(r.ignoreByRule(a.api,S)||r.ignoreByRule(r.decode(a.api),S))||!u.checkImgUrl(h.imgUrl)||!a||h.disabled||!h.pid||o===0)return u;var v=a.dl;if(delete a.dl,a=r.ext({t:s,times:1,page:p,tag:h.tag||"",release:h.release||"",environment:h.environment,begin:Date.now(),c1:h.c1,c2:h.c2,c3:h.c3},a,u.commonInfo(),u._common,{pid:h.pid,_v:u.ver,pv_id:u.pageview,username:u.getUsername(),sampling:c||1,dl:v,z:r.seq()}),r.T(h.beforeReport)==="Function")try{if(!(a=h.beforeReport(a)))return u}catch(x){return u}return o===1?t(u,a):c&&!u.sampling(c)?u:t(u,a)},_self:function(s,a,c){var o=this,u=o._conf;if(s!=="error"||!o.checkImgUrl(u.imgUrl)||!a||u.disabled||!u.pid||!e||c&&!o.sampling(c))return o;a=r.ext({t:s,times:1,page:r.selfErrPage,tag:u.pid,begin:Date.now()},a,{pid:e,_v:o.ver,sampling:c||1,z:r.seq()});var h=o.selfQueue[0];if(h){h.times++;try{h.err&&a.err&&h.err.msg_raw&&a.err.msg_raw&&h.err.msg_raw.split("&").indexOf(a.err.msg_raw)<0&&h.err.msg_raw.length<1e3&&(h.err.msg_raw+="&"+a.err.msg_raw)}catch(p){}}else o.selfQueue.unshift(a),o.onReady(function(){o.sdkFlag&&(o.sdkFlag=!1,o.Timmer=r.delay(function(){o.clearSelf()},1e4))})},custom:function(s,a){if(!s||typeof s!="object")return this;var c=!1,o={begin:Date.now()};return r.each(s,function(u,h){return!(c=h&&h.length<=20)&&r.warn("[retcode] invalid key: "+h),o["x-"+h]=u,c}),c?this._lg("custom",o,a||1):this}},zi.exports=i,zi.exports}var ys;function Hn(){if(ys)return ji.exports;ys=1;var r=Be(),n=Un(),e=["api","success","time","code","msg","trace","traceId","begin","pv_id","sid","seq","domain","flag","apiSnapshot","tag","c1","c2","c3"],t=function(s){var a=(s.key||"default").split("::");return a.length>1?r.ext(s,{group:a[0],key:a[1]}):r.ext(s,{group:"default_group",key:a[0]})},i=function(s){n.call(this,s);var a;try{a=typeof performance=="object"?performance.timing.fetchStart:Date.now()}catch(c){a=Date.now()}return this._startTime=a,this};return i.prototype=r.createObject(n.prototype),r.ext(n.dftCon,{startTime:null}),r.ext(i.prototype,{constructor:i,_super:n,sum:function(s,a,c){try{var o=r.dealParam(s,a,1);return this._lg("sum",t(o),c)}catch(u){r.warn("[retcode] can not get parseStatData: "+u)}},avg:function(s,a,c){try{var o=r.dealParam(s,a,0);return this._lg("avg",t(o),c)}catch(u){r.warn("[retcode] can not get parseStatData: "+u)}},percent:function(s,a,c,o){try{return this._lg("percent",t({key:s,subkey:a,val:c||0,begin:Date.now()}),o)}catch(u){r.warn("[retcode] can not get parseStatData: "+u)}},msg:function(s,a){if(s&&!(s.length>180))return this.custom({msg:s},a)},error:function(s,a){if(!s)return r.warn("[retcode] invalid param e: "+s),this;arguments.length===1?(typeof s=="string"&&(s={message:s},a={}),typeof s=="object"&&(a=s=s.error||s)):(typeof s=="string"&&(s={message:s}),typeof a!="object"&&(a={}));var c=s.name||"CustomError",o=s.message||"",u=s.stack||"";a=a||{};var h=typeof location=="object"&&typeof location.href=="string"&&location.href.substring(0,500)||"";if(r.checkSDKError(o,a.filename)){var p=/^Script error\.?$/,d=s.msg||s.message;if(r.ignoreByRule(d,p)||r.ignoreByRule(r.decode(d),p))return this;var f={msg:r.selfErrKey,err:{msg_raw:r.encode(s.msg||s.message)}};return this._self("error",f,1)}for(var m={begin:Date.now(),cate:c,msg:o&&o.substring(0,1e3),stack:u&&u.substring(0,1e3),file:r.removeUrlSearch(a.filename||""),line:a.lineno||"",col:a.colno||"",err:{msg_raw:r.encode(o),stack_raw:r.encode(u)},dl:h},l=["tag","c1","c2","c3"],S=0;S<l.length;S++){var v=l[S];a[v]&&(m[v]=a[v])}var x=(this.getConfig("ignore")||{}).ignoreErrors;return r.ignoreByRule(m.msg,x)||r.ignoreByRule(r.decode(m.msg),x)?this:(this.beforeSend&&this.beforeSend("error",m),this._lg("error",m,1))},behavior:function(s){if(s){var a=typeof s=="object"&&s.behavior?s:{behavior:s};return this.beforeSend&&this.beforeSend("behavior",a),this._lg("behavior",a,1)}},api:function(s,a,c,o,u,h,p,d,f,m,l,S,v,x,b,E){if(!s)return r.warn("[retcode] api is null"),this;if(s=typeof s=="string"?{api:s,success:a,time:c,code:o,msg:u,begin:h,traceId:p,pv_id:d,apiSnapshot:f,domain:m,flag:S,tag:v,c1:x,c2:b,c3:E}:r.sub(s,e),!r.checkAPI(s.api,!0))return this;s.code=s.code||"";var A=s.msg||"";if(A=typeof A=="string"?A.substring(0,1e3):A,s.msg=A,s.success=s.success?1:0,s.time=+s.time,s.begin=s.begin,s.traceId=s.traceId||"",s.pv_id=s.pv_id||"",s.domain=s.domain||"",s.flag=s.flag,s.dl=typeof location=="object"&&typeof location.href=="string"&&location.href.substring(0,500)||"",s.apiSnapshot&&(typeof s.apiSnapshot=="object"&&(s.apiSnapshot=JSON.stringify(s.apiSnapshot)),typeof s.apiSnapshot!="string"&&delete s.apiSnapshot,s.apiSnapshot.length>2e3&&(s.apiSnapshot=s.apiSnapshot.substring(0,2e3))),l&&(s.traceOrigin=l),!s.api||isNaN(s.time))return r.warn("[retcode] invalid time or api"),this;var y=(this.getConfig("ignore")||{}).ignoreApis;return r.ignoreByRule(s.api,y)||r.ignoreByRule(r.decode(s.api),y)?this:s.time<0?this:(this.beforeSend&&this.beforeSend("api",s),this._lg("api",s,s.success&&this.getConfig("sample"),s.flag))},speed:function(s,a,c){var o=this,u=this.getConfig("startTime")||this._startTime;return/^s(\d|1[0])$/.test(s)?(a=typeof a!="number"?Date.now()-u:a>=u?a-u:a,o.speedCache=o.speedCache||{},o.speedCache[s]=a,o.speedCache.begin=u,clearTimeout(o.speedTimmer),o.speedTimmer=setTimeout(function(){c||(o.speedCache.page=o.getPage(!0)),o._lg("speed",o.speedCache),o.speedCache=null},5e3),o):(r.warn("[retcode] invalid point: "+s),o)},performance:function(s){if(s&&typeof s=="object"&&!this.hasSendPerf){var a={},c={},o=this.getConfig("autoSendPerf");if(s.autoSend&&o)return c=r.ext(this.perfData||{},s),this.hasSendPerf=!0,this._lg("perf",c,this.getConfig("sample"));if(s.autoSend&&!o)return delete s.autoSend,this.perfData?(c=r.ext(this.perfData||{},s),this.hasSendPerf=!0,this._lg("perf",c,this.getConfig("sample"))):void(this.perfData=s);for(var u in s)(/^t([1-9]|1[0])$/.test(u)||u==="ctti"||u==="cfpt")&&(a[u]=s[u]);if(s.autoSend===!0||!o&&(o||this.perfData))return s.autoSend!==!0&&o===!1&&this.perfData?(a=r.ext(this.perfData||{},a),this.hasSendPerf=!0,this._lg("perf",a,this.getConfig("sample"))):void 0;this.perfData=r.ext(this.perfData||{},a)}},resource:function(s,a){if(!s||!r.isPlainObject(s))return r.warn("[arms] invalid param data: "+s),this;var c=Object.keys(s),o=["begin","dom","load","res","dl"],u=!1;for(var h in o)if(c.indexOf(o[h])<0){u=!0;break}if(u)return r.warn("[arms] lack param data: "+s),this;var p={begin:s.begin||Date.now(),dom:s.dom||"",load:s.load||"",res:r.isArray(s.res)?JSON.stringify(s.res):JSON.stringify([]),dl:s.dl||""};return this._lg("res",p,a)},event:function(s,a){if(typeof s=="object"&&s&&s.key){var c={},o=["key","success","time","c1","c2","c3"];for(var u in s)o.indexOf(u)>-1&&(c[u]=s[u]);c.success=s.success===!1?0:1,this._lg("event",c,a)}}}),i._super=n,i._root=n,n.Reporter=i,ji.exports=i,ji.exports}var $i={exports:{}},Cs;function jn(){if(Cs)return $i.exports;Cs=1;var r=Be(),n=typeof window=="object"?window:{},e="catch",t=n.__oFetch_||n.fetch;return t=typeof t=="function"?t:void 0,$i.exports=function(i,s){var a=-1;typeof i=="object"&&(a=i.z,i=r.serialize(i));var c=s+i;if(t)return t(c,{method:"HEAD",mode:"no-cors"})[e](r.noop);if(n.document&&n.document.createElement){var o="__request_hold_"+a,u=n[o]=new Image;u.onload=u.onerror=function(){n[o]=void 0},u.src=c,u=null}},$i.exports}var Ki={exports:{}},Rs;function zn(){if(Rs)return Ki.exports;Rs=1;var r=Be(),n=typeof window=="object"?window:{},e=n.__oXMLHttpRequest_||n.XMLHttpRequest;return e=typeof e=="function"?e:void 0,Ki.exports=function(t,i){try{var s=new e;s.open("POST",i,!0),s.setRequestHeader("Content-Type","text/plain"),s.send(JSON.stringify(t))}catch(a){r.warn(`[retcode] Failed to log, exception is :
|
|
3
|
-
`+a)}},Ki.exports}var qi,Is;function Wn(){if(Is)return qi;Is=1;var r=Be();return qi=function(n,e){var t=[],i=null,s=e&&e.location&&e.location.href,a=void 0,c=null,o=function(d,f,m){if(d!==null){var l=d[f];d[f]=m(l)}},u=function(d){var f,m,l,S,v,x=[];if(!d||typeof d.tagName!="string")return"";if(x.push(d.tagName.toLowerCase()),typeof d.id=="string"&&x.push("#".concat(d.id)),typeof(f=d.className)=="string")for(m=f.split(/\s+/),v=0;v<m.length;v++)x.push(".".concat(m[v]));var b=["type","name","title","alt","data-arms-attr"];for(v=0;v<b.length;v++)l=b[v],typeof(S=d.getAttribute(l))=="string"&&x.push("[".concat(l,'="').concat(S,'"]'));return x.join("")},h=function(d,f){return function(m){if(m&&m!==c){c=m;var l;try{l=m.target}catch(v){l="<unknown>"}if(l.length!==0){var S={type:"ui.".concat(d),data:{message:function(v){if(!v||v.nodeType!==1)return"";for(var x=v||null,b=[],E=0,A=0,y=3,_="";x&&E++<5&&!((_=u(x))==="html"||E>1&&A+b.length*y+_.length>=80);)b.push(_),A+=_.length,x=x.parentNode;return b.reverse().join(" > ")}(l)},timestamp:Date.now()};d==="click"?i&&i.addBehavior(S):d==="keypress"&&(a||i&&i.addBehavior(S),clearTimeout(a),a=setTimeout(function(){a=void 0},100))}}}},p=function(){if(function(){var l=e&&e.chrome,S=l&&l.app&&l.app.runtime,v="history"in e&&!!e.history.pushState&&!!e.history.replaceState;return!S&&v}()){var d=function(l,S){var v={type:"navigation",data:{from:l,to:S}};i&&i.addBehavior(v),s=S},f=e.onpopstate;e.onpopstate=function(){for(var l=arguments.length,S=new Array(l),v=0;v<l;v++)S[v]=arguments[v];var x=e.location.href;if(d(s,x),f)return f.apply(this,S)};var m=function(l){return function(){for(var S=arguments.length,v=new Array(S),x=0;x<S;x++)v[x]=arguments[x];var b=v.length>2?v[2]:void 0;return b&&d(s,String(b)),l.apply(this,v)}};o(e.history,"pushState",m),o(e.history,"replaceState",m)}};r.ext(n.prototype,{addBehavior:function(d){if(this.getConfig("behavior")&&d&&typeof d=="object"){var f={},m=d.data||{};if(d.type)f=m;else{if(typeof m.name!="string"||typeof m.message!="string")return;f.name=m.name.substr(0,20),f.message=m.message.substr(0,200)}f.message&&(f.message=r.encode(f.message));var l={type:d.type||"custom",data:f||{},timestamp:d.timestamp||Date.now(),page:d.page||e&&e.location&&e.location.pathname};return t.push(l),t=t.slice(-100)}},getBehavior:function(){return t||[]},setBehavior:function(d){return d&&(t=d),t},reportBehavior:function(d){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,d&&typeof d=="function"&&d())},0))},initBehavior:function(){if(!this.hasInitBehavior&&!i){try{(function(){if(document&&document.referrer&&document.location){var f=document.referrer,m=document.location.href;if(f!==""){var l={type:"navigation",data:{from:f,to:m}};s=m,i&&i.addBehavior(l)}}})(),e&&e.document&&e.document.addEventListener&&(e.document.addEventListener("click",h("click"),!1),e.document.addEventListener("keypress",h("keypress"),!1)),p();var d=this.getConfig("enableConsole");d&&function(f){if(e&&e.console){var m=["debug","info","warn","log","error","assert"];r.isArray(f)&&(m=f);for(var l=0;l<m.length;l++){var S=m[l];S&&r.isString(S)&&e.console[S]&&typeof e.console[S]=="function"&&o(e.console,S,function(v){var x=S;return function(){for(var b=arguments.length,E=new Array(b),A=0;A<b;A++)E[A]=arguments[A];var y={type:"console",data:{level:x,message:E}};if(i&&i.addBehavior(y),x==="error")for(var _=0;_<E.length;_++){var R=E[_];R&&R.message&&R.stack&&i&&i.errorHandler(new ErrorEvent("error",{error:R,message:R.message}))}v&&Function.prototype.apply.call(v,e.console,E)}})}}}(d)}catch(f){r.warn("[arms] error in initBehavior",f)}i=this,this.hasInitBehavior=!0}return this}})},qi}var ws={},Ts;function Ji(){return Ts||(Ts=1,ws.TIMING_KEYS=["startTime","fetchStart","domainLookupStart","domainLookupEnd","connectStart","connectEnd","requestStart","responseStart","responseEnd","","domInteractive","","domContentLoadedEventEnd","","loadEventStart","","msFirstPaint","secureConnectionStart","redirectStart","redirectEnd"]),ws}var Gi,Ds;function $n(){if(Ds)return Gi;Ds=1;var r=Be(),n=Ji(),e=n.TIMING_KEYS;return Gi=function(){var t=r.win||{},i=t.performance;if(!i||typeof i!="object"||typeof i.getEntriesByType!="function")return null;var s={},a=i.timing||{},c=i.getEntriesByType("resource")||[];if(s.begin=a[e[1]]||Date.now(),typeof t.PerformanceNavigationTiming=="function"){var o=i.getEntriesByType("navigation")[0];o&&(a=o)}return r.each({dom:[10,8],load:[14,1]},function(u,h){var p=a[e[u[1]]],d=a[e[u[0]]];if(p>0&&d>0){var f=Math.round(d-p);f>=0&&f<6e5&&(s[h]=f)}}),s.res=JSON.stringify(c),s},Gi}var Xi,Ps;function Kn(){if(Ps)return Xi;Ps=1;var r=Be(),n=Ji(),e=n.TIMING_KEYS;return Xi=function(){var t=r.win||{},i=t.performance;if(!i||typeof i!="object")return null;var s={},a=i.timing||{},c=Date.now(),o=1;if(typeof t.PerformanceNavigationTiming=="function"){var u=i.getEntriesByType("navigation")[0];u&&(a=u,o=2)}r.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(m,l){var S=a[e[m[1]]],v=a[e[m[0]]];if(o===2||S>0&&v>0){var x=Math.round(v-S);x>=0&&x<6e5&&(s[l]=x)}});var h=t.navigator.connection,p=i.navigation||{};s.ct=h?h.effectiveType||h.type:"";var d=h&&(h.downlink||h.downlinkMax||h.bandwidth)||null;if((d=d>999?999:d)&&(s.bandwidth=d),s.navtype=p.type===1?"Reload":"Other",o===1&&a[e[16]]>0&&a[e[1]]>0){var f=a[e[16]]-a[e[1]];f>=0&&f<36e5&&(s.fpt=f)}return o===1&&a[e[1]]>0?s.begin=a[e[1]]:o===2&&s.load>0?s.begin=c-s.load:s.begin=c,s},Xi}var ks,Bs;function qn(){return Bs||(Bs=1,ks=function(r,n,e){var t=Be(),i=$n(),s=Kn(),a=null,c=e.documentElement,o=n.innerWidth||c.clientWidth||e.body.clientWidth,u=n.innerHeight||c.clientHeight||e.body.clientHeight,h=n.navigator.connection,p={sr:screen.width+"x"+screen.height,vp:o+"x"+u,ct:h?h.effectiveType||h.type:""},d={},f=function(l,S,v,x,b){if(S===void 0){var E,A;if(!d[l]){E=new RegExp(l+"=([^;]+)");try{A=E.exec(e.cookie)}catch(_){return t.warn("[retcode] can not get cookie:",_),null}A&&(d[l]=A[1])}return d[l]}var y=l+"="+S;y+="; path=/",v&&(y+="; max-age="+v);try{return e.cookie=y,!!e.cookie}catch(_){return t.warn("[retcode] can not set cookie: ",_),!1}},m=function(l){var S=l._conf.uid||f("_nk_")||f("_bl_uid");return!S&&(S=t.uu(),!f("_bl_uid",S,15552e3))?null:S};return t.ext(r.prototype,{activeErrHandler:function(l){return a&&!l?this:(a=this,this)},errorHandler:function(l){if(!l)return this;var S=l.type;if(S==="error"){var v=l.target||l.srcElement;!v||!v.tagName||l.message||l.filename||l.lineno||l.colno?this.error(l.error||{message:l.message},l):this.resourceErrorHandler(l)}else S==="unhandledrejection"&&t.T(l.reason,"Error")&&t.checkAutoError(l.reason)&&this.error(l.reason);try{this.getConfig("behavior")&&this.reportBehavior&&this.reportBehavior()}catch(x){}return this},resourceErrorHandler:function(l){var S=this,v=l.target||l.srcElement;try{var x=S.getSrc(v),b=typeof v.tagName=="string"?v.tagName.toLowerCase():"",E=S.getXPath(v,5),A=t.getURL(x),y={src:x&&x.substring(0,1e3),node_name:b,xpath:E,res_type:t.getResType(b,x),res_name:A.path,domain:A.domain};return S._conf.enableResource&&S.fixResourceStatus&&l.timeStamp&&S.fixResourceStatus({src:x,node_name:b,res_type:t.getResType(b,x),timeStamp:l.timeStamp,domain:A.domain}),S._lg("resourceError",y),S}catch(_){return t.warn("[ARMS] resourceErrorHandler error :",_),S}},getSrc:function(l){var S=l.src||l.href;try{if(!S){var v=(typeof l.tagName=="string"?l.tagName.toLowerCase():"")==="object",x=l.getAttribute("classid")&&l.getAttribute("classid").toLowerCase()==="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"||l.getAttribute("type")==="application/x-shockwave-flash";v&&x&&(S=l.getAttribute("data")||l.getAttribute("codebase")),S||(S=l.outerHTML||l.innerHTML)}}catch(b){S=""}return S},getXPath:function(l,S){var v=l.id?"#"+l.id:"",x=typeof l.className=="string"?"."+l.className.split(" ").join("."):"",b=(typeof l.tagName=="string"?l.tagName.toLowerCase():"")+v+x;return l.parentNode&&l.parentNode.tagName&&S-1!=0?this.getXPath(l.parentNode,S-1)+" > "+b:b},sendPerformance:function(l){var S=this;S.onReady(function(){var v=s();v&&v.load&&v.load>0&&(v.page=S.getPage(!0),l&&(v=t.ext(v,l)),v.autoSend=!0,S.performance(v))})},sendResources:function(l){var S=this;S.onReady(function(){var v=i();v&&v.load&&v.load>0&&(v.load&&v.load<=2e3||v.load&&v.load<=8e3&&Math.random()>.05||(v.page=S.getPage(!0),v.dl=location.href,l&&(v=t.ext(v,l)),S._lg("res",v,S.getConfig("sample"))))})},sendPV:function(){var l=this;l.onReady(function(){var S=function(v){var x=m(v),b=n.devicePixelRatio||1;return{uid:x,dt:e.title,dl:location.href,dr:e.referrer,dpr:b.toFixed(2),de:(e.characterSet||e.defaultCharset||"").toLowerCase(),ul:c.lang,begin:Date.now()}}(l);S&&S.uid&&l._lg("pv",S,l.getConfig("pvSample"))})},commonInfo:function(){return p.uid=m(this),p.sid=function(l){if(l.session)return l.session;var S;try{if(typeof window=="object"&&typeof sessionStorage=="object"&&typeof sessionStorage.getItem=="function")return typeof(S=sessionStorage.getItem("_bl_sid"))=="string"?(l.session=S,S):(S=t.uu(),l.session=S,typeof sessionStorage.setItem=="function"&&sessionStorage.setItem("_bl_sid",S),S)}catch(v){t.warn("[ARMS] getSid error :",v)}return l.session=S=t.uu(),S}(this),p},handleUnload:function(l){var S=Date.now();if(S-this._lastUnload<200)return this;this._lastUnload=S,this.sendHealth(l),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(l){var S=this;if(!l^S.hashChangeHandler)return S;l?(S.hackHistoryState(),S.hashChangeHandler=function(v){var x=S._conf.parseHash(location.hash);x&&S.setPage(x,v!==!1)},S.stateChangeHandler=function(v){var x=S._conf.parseHash(v.detail);x&&S.setPage(x)},t.on(n,"hashchange",S.hashChangeHandler),t.on(n,"historystatechange",S.stateChangeHandler),S.hashChangeHandler(!1)):(t.off(n,"hashchange",S.hashChangeHandler),t.off(n,"historystatechange",S.stateChangeHandler),S.hashChangeHandler=null,S.stateChangeHandler=null)},initHandler:function(){var l=this;if(l.hasInitHandler)return l;var S=l._conf;return t.on(n,"beforeunload",function(){l.handleUnload(0)}),l.bindHashChange(S.enableSPA),l.activeErrHandler(!1),l.hasInitHandler=!0,l}}),t.on(n,"error",function(l){a&&a.errorHandler(l)},!1,!0).on(n,"unhandledrejection",function(l){a&&a.errorHandler(l)}),r}),ks}var Yi,Ns;function Jn(){if(Ns)return Yi;Ns=1;var r=Be(),n=500;return Yi=function(e,t,i){function s(p,d,f){var m=0,l=p.tagName;if(l!=="SCRIPT"&&l!=="STYLE"&&l!=="META"&&l!=="HEAD"){var S=p.children?p.children.length:0;if(S>0)for(var v=p.children,x=S-1;x>=0;x--)m+=s(v[x],d+1,m>0);if(m<=0&&!f&&!(p.getBoundingClientRect&&p.getBoundingClientRect().top<c))return 0;m+=1+.5*d}return m}function a(p){for(var d=1;d<p.length;d++)if(p[d].score<p[d-1].score)return p.splice(d,1),a(p);return p}var c=t.innerHeight||0,o=[],u=null,h=0;r.ext(e.prototype,{initFmpObserver:function(p){var d=this;if(!d._conf||!d._conf.useFmp)return null;if(!t.MutationObserver)return r.warn("[retcode] first meaningful paint can not be retrieved"),d.sendPerformance(),null;r.on(t,"beforeunload",function(){d.endObserving(0,!0)});var f=t.MutationObserver;return(u=new f(function(){(function(m){var l=Date.now()-m,S=i.querySelector("body");if(S){var v=0;v+=s(S,1,!1),o.push({score:v,t:l})}else o.push({score:0,t:l})})(d._startTime)})).observe(document,{childList:!0,subtree:!0}),h=1,d.onReady(function(){d.endObserving(p)}),u},endObserving:function(p,d){var f=this;if(u&&h)if(f.fmpTimmer&&(clearTimeout(f.fmpTimmer),f.fmpTimmer=null),d||!function(v,x){var b=Date.now()-v;return!(b>x||b-(o&&o.length&&o[o.length-1].t||0)>2*n)}(f._startTime,p)){u.disconnect(),h=0,o=a(o);for(var m=null,l=1;l<o.length;l++)if(o[l].t>=o[l-1].t){var S=o[l].score-o[l-1].score;(!m||m.rate<=S)&&(m={t:o[l].t,rate:S})}m&&m.t>0&&m.t<36e5?f.sendPerformance({fmp:m.t}):f.sendPerformance()}else f.fmpTimmer=r.delay(function(){f.endObserving(p)},n)}})},Yi}var Ls,Ms;function Gn(){return Ms||(Ms=1,Ls=function(r,n){var e=Be(),t=null,i=e.getCurDomain(),s=function(h,p,d,f,m,l,S,v,x,b,E,A,y){var _=e.J(m)||null,R=e.safetyCall(p,[_,f],null);if(!R)return!1;var L=R.code||l,C=!("success"in R)||R.success;h.api(d,C,S,L,R.msg,v,x,b,C?{}:E,i,A,y)},a="fetch",c="__oFetch_",o="__oXMLHttpRequest_",u="XMLHttpRequest";return e.ext(r.prototype,{removeHook:function(h,p){return t&&(p||this===t)?(n[c]&&(n[a]=n[c],delete n[c]),n[o]&&(n[u]=n[o],delete n[o]),t=null,this):this},addHook:function(h){return!h&&t?this:(t||(function(){if(typeof n[a]=="function"){var p=n[a];n[c]=p,n[a]=function(d,f){var m=arguments.length===1?[arguments[0]]:Array.apply(null,arguments),l=t;if(!l||!l.api||f&&(f.method==="HEAD"||f.mode==="no-cors"))return p.apply(n,m);f||(f={});var S=Date.now(),v=l._conf,x=e.duration(),b=(d&&typeof d!="string"?d.url:d)||"",E=b;b=e.cutUrlSearch(b);var A=(v.ignore||{}).ignoreApis,y=v.parseTraceId;if(!e.checkAPI(b,!0)||e.ignoreByRule(b,A))return p.apply(n,m);b=e.filterByRule(b,E,v.ignoreApiPath?v.ignoreApiPath:v.apiHelper);var _=v.enableLinkTrace,R="",L="",C=l.getConfig("pid"),I=null,P=l.getConfig("sample"),B=l.getConfig("linkType"),K=1;if(P&&!l.sampling(P)&&(K=0),_){var J="";try{J=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(X){J=""}var Q=e.checkSameOrigin(E,J);if(l.getConfig("enableApiCors")||Q)if(d&&typeof d!="string")try{if(m[0].headers&&typeof m[0].headers.get=="function"&&typeof m[0].headers.append=="function")switch(B){case"arms":var ue=m[0].headers.get("EagleEye-TraceID"),te=m[0].headers.get("EagleEye-SessionID"),se=m[0].headers.get("EagleEye-pAppName");ue?R=ue:(R=l.getTraceId()["EagleEye-TraceID"],m[0].headers.append("EagleEye-TraceID",R)),te?L=te:(L=l.getPageviewId()["EagleEye-SessionID"],m[0].headers.append("EagleEye-SessionID",L)),se||m[0].headers.append("EagleEye-pAppName",C);break;case"b3":var ie=m[0].headers.get("X-B3-TraceId");if(ie)R=ie;else{var k=l.getB3TraceId(K);m[0].headers.append("X-B3-TraceId",k["X-B3-TraceId"]),m[0].headers.append("X-B3-ParentSpanId",k["X-B3-ParentSpanId"]),m[0].headers.append("X-B3-SpanId",k["X-B3-SpanId"]),m[0].headers.append("X-B3-Sampled",k["X-B3-Sampled"]),m[0].headers.append("X-Request-ID",e.guid()),R=k["X-B3-TraceId"]}L=l.pageview;break;case"tracing":default:var M=m[0].headers.get("uber-trace-id");M?R=M.split(":")[0]:(M=l.getUberTraceId(K),m[0].headers.append("uber-trace-id",M["uber-trace-id"]),R=M.traceId),L=l.pageview}}catch(X){e.warn(`[retcode] fetch failed to set header, exception is :
|
|
4
|
-
`+X)}else switch(f.headers=f.headers?f.headers:{},B){case"arms":f.headers["EagleEye-TraceID"]?R=f.headers["EagleEye-TraceID"]:(R=l.getTraceId()["EagleEye-TraceID"],f.headers["EagleEye-TraceID"]=R),f.headers["EagleEye-SessionID"]?L=f.headers["EagleEye-SessionID"]:(L=l.getPageviewId()["EagleEye-SessionID"],f.headers["EagleEye-SessionID"]=L),f.headers["EagleEye-pAppName"]||(f.headers["EagleEye-pAppName"]=C);break;case"b3":if(f.headers["X-B3-TraceId"])R=f.headers["X-B3-TraceId"];else{var F=l.getB3TraceId(K);f.headers["X-B3-TraceId"]=F["X-B3-TraceId"],f.headers["X-B3-ParentSpanId"]=F["X-B3-ParentSpanId"],f.headers["X-B3-SpanId"]=F["X-B3-SpanId"],f.headers["X-B3-Sampled"]=F["X-B3-Sampled"],f.headers["X-Request-ID"]=e.guid(),R=F["X-B3-TraceId"]}L=l.getPageviewId()["EagleEye-SessionID"];break;case"tracing":default:if(f.headers["uber-trace-id"])R=f.headers["uber-trace-id"].split(":")[0];else{var N=l.getUberTraceId(K);f.headers["uber-trace-id"]=N["uber-trace-id"],R=N.traceId}L=l.getPageviewId()["EagleEye-SessionID"]}}return p.apply(n,m).then(function(X){if(!l||!l.api)return X;try{if(!X||typeof X.clone!="function")return X;var j=X.clone(),fe=j.headers;if(fe&&typeof fe.get=="function"){var ee=fe.get("content-type");if(ee&&!/(text)|(json)/.test(ee))return X;if(!R){var ze=e.parseFetchHeaders(fe);typeof ze=="object"&&ze["eagleeye-traceid"]&&(R=ze["eagleeye-traceid"],I="response")}}var Je=x();return j.text().then(function(st){if(!R&&e.isFunction(y)){var at=y(j,st);at&&e.isString(at)&&(R=at)}var ye=e.getFetchSnapshot(m,st,fe);j.ok?s(l,v.parseResponse,b,E,st,j.status||200,Je,S,R,L,ye,I,K):(l.api(b,!1,Je,j.status||404,j.statusText,S,R,L,ye,i,I,K),v.enableResource&&t.fixResourceStatus&&t.fixResourceStatus({src:j.url,res_type:"api"}))}),X}catch(st){return e.warn("[ARMS] fetch response error :",st),X}}).catch(function(X){if(!l||!l.api)throw X;var j=x();throw l.api(b,!1,j,X.name||"Error",X.message,S,R,L,{},i),v.enableResource&&t.fixResourceStatus&&t.fixResourceStatus({src:E,res_type:"api"}),X})},n[a].toString=e.createFakeToString(a)}}(),function(){if(typeof n[u]=="function"){var p,d=n[u];n[o]=d;var f=function(m){var l=new d(m),S=t;if(!S||!S.api||!l.addEventListener)return l;var v,x,b,E,A=l.send,y=l.open,_=l.setRequestHeader,R=S._conf,L=(R.ignore||{}).ignoreApis,C=R.parseTraceId,I=S.getConfig("enableLinkTrace"),P="",B="",K="",J=null,Q=S.getConfig("sample"),ue=S.getConfig("linkType"),te=1;return Q&&!S.sampling(Q)&&(te=0),l.open=function(se,ie){p=se;var k=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);y.apply(l,k),E=ie||"",b=e.cutUrlSearch(E);var M=!e.checkAPI(b,!0)||e.ignoreByRule(b,L);if(b=b?e.filterByRule(b,E,R.ignoreApiPath?R.ignoreApiPath:R.apiHelper):"",!M&&I){var F="";try{F=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(fe){F=""}var N=e.checkSameOrigin(E,F);if((S.getConfig("enableApiCors")||N)&&_&&typeof _=="function")switch(ue){case"arms":P=S.getTraceId()["EagleEye-TraceID"],_.apply(l,["EagleEye-TraceID",P]),B=S.getPageviewId()["EagleEye-SessionID"],_.apply(l,["EagleEye-SessionID",B]),K=S.getConfig("pid"),_.apply(l,["EagleEye-pAppName",K]);break;case"b3":var X=S.getB3TraceId(te);_.apply(l,["X-B3-TraceId",X["X-B3-TraceId"]]),_.apply(l,["X-B3-ParentSpanId",X["X-B3-ParentSpanId"]]),_.apply(l,["X-B3-SpanId",X["X-B3-SpanId"]]),_.apply(l,["X-B3-Sampled",X["X-B3-Sampled"]]),_.apply(l,["X-Request-ID",e.guid()]),P=X["X-B3-TraceId"],B=S.getPageviewId()["EagleEye-SessionID"];break;case"tracing":default:var j=S.getUberTraceId(te);_.apply(l,["uber-trace-id",j["uber-trace-id"]]),P=j.traceId,B=S.getPageviewId()["EagleEye-SessionID"]}}},l.send=function(){v=Date.now(),x=e.duration();var se=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);A.apply(l,se)},e.on(l,"readystatechange",function(){if(b&&l.readyState===4){var se=x(),ie=e.getXhrSnapshot(E,p,l);if(!P){var k=e.parseXhrHeaders(typeof l.getAllResponseHeaders=="function"&&l.getAllResponseHeaders()||"");typeof k=="object"&&k["eagleeye-traceid"]&&(P=k["eagleeye-traceid"],J="response")}if(!P&&e.isFunction(C)){var M=C(l);M&&e.isString(M)&&(P=M)}if(l.status>=200&&l.status<=299){var F=l.status||200;if(typeof l.getResponseHeader=="function"){var N=l.getResponseHeader("Content-Type");if(N&&!/(text)|(json)/.test(N))return}l.responseType&&l.responseType!=="text"?S.api(b,!0,se,F,"",v,P,B,{},i,J,te):s(S,R.parseResponse,b,E,l.responseText,F,se,v,P,B,ie,J,te)}else S.api(b,!1,se,l.status||"FAILED",l.statusText,v,P,B,ie,i,J,te),R.enableResource&&t.fixResourceStatus&&t.fixResourceStatus({src:l.responseURL||E,res_type:"api"})}}),l};f.prototype=d.prototype,e.each(Object.keys(d),function(m){f[m]=d[m]}),n[u]=f,n[u].toString=e.createFakeToString(u)}}()),t=this,this)},initHook:function(){return this.hasInitHook?this:(this.getConfig("disableHook")||this.addHook(),this.hasInitHook=!0,this)}}),r}),Ls}var Fs,Vs;function Xn(){return Vs||(Vs=1,Fs=function(r,n){var e=Be(),t=n.history||{},i=n.document,s=function(c,o){var u;n.CustomEvent?u=new CustomEvent(c,{detail:o}):((u=i.createEvent("HTMLEvents")).initEvent(c,!1,!0),u.detail=o),n.dispatchEvent(u)},a=function(c){var o=t[c];typeof o=="function"&&(t[c]=function(u,h,p){var d=arguments.length===1?[arguments[0]]:Array.apply(null,arguments),f=location.href,m=o.apply(t,d);if(!p||typeof p!="string"||p===f)return m;try{var l=f.split("#"),S=p.split("#"),v=e.cutUrlSearch(l[0]),x=e.cutUrlSearch(S[0]),b=l[1]&&l[1].replace(/^\/?(.*)/,"$1"),E=S[1]&&S[1].replace(/^\/?(.*)/,"$1");b!==E?s("historystatechange",E):v!==x&&s("historystatechange",x)}catch(A){e.warn("[retcode] error in "+c+": "+A)}return m},t[c].toString=e.createFakeToString(c))};e.ext(r.prototype,{hackHistoryState:function(){return this.hasHackedHistoryState?this:(a("pushState"),a("replaceState"),this.hasHackedHistoryState=!0,this)}})}),Fs}var Zi,Os;function Yn(){if(Os)return Zi;Os=1;var r=Be(),n=Ji(),e=n.TIMING_KEYS;return Zi=function(t,i){function s(o,u,h){if(o instanceof i.PerformanceResourceTiming&&o.initiatorType){var p=r.getResType(o.initiatorType,o.name),d=u.resourceTypes||[],f=(u.ignore||{}).ignoreResources;if(p&&d.includes(p)&&!r.ignoreByRule(o.name,f)&&!r.ignoreByRule(r.decode(o.name),f)){var m=o[e[0]],l=o[e[1]],S=o[e[2]],v=o[e[3]],x=o[e[4]],b=o[e[5]],E=o[e[6]],A=o[e[7]],y=o[e[8]],_=o[e[18]],R=o[e[19]];if(!h.has(o)&&(!r.areInOrder(m,l,S,v,x,b,E,A,y)||m>A))return;if(_<m&&(_=m),R<m&&(R=l),r.areInOrder(m,_,R,l))return{domain:r.getURL(o.name).domain,res_type:p,src_type:r.getSrcType(o.name,u.cdnHostList),success:1,size:Math.round(o.decodedBodySize),duration:Math.round(o.duration),timeStamp:o.responseEnd,timing:o}}}}var a="_resource-"+Date.now(),c="_resource_error-"+Date.now();r.ext(t.prototype,{initResource:function(){var o=this,u=i.performance,h=i.PerformanceObserver;if(o[c]||(o[c]=new WeakMap),!u||!h||typeof u!="object"||typeof u.getEntriesByType!="function")return null;var p=u.getEntriesByType("resource")||[];return setTimeout(function(){o.setResource(p)},10),new h(function(d){setTimeout(function(){o.setResource(d.getEntries())},10)}).observe({entryTypes:["resource"]}),this.onReady(function(){setTimeout(o.resourceComboReport.bind(o),5e3)}),o},setResource:function(o){var u=this._conf,h=this[c];if(r.isArray(o)&&o.length){this[a]||(this[a]={});for(var p=this[a],d=0,f=o.length;d<f;d+=1){var m=o[d];if(r.checkAPI(m.name,!1)){var l=s(m,u,h);if(l){var S=l.res_type+"-"+l.domain;S in p||(p[S]=[]),p[S].push(l)}}}return this}},fixResourceStatus:function(o){var u=i.performance;if(!u||typeof u.getEntriesByName!="function")return null;var h=this[c];if(!o.src||!r.checkAPI(o.src,!1))return this;var p=o.timeStamp||u.now(),d=u.getEntriesByName(o.src,"resource");return r.each(d,function(f){h.has(f)||p-f.responseEnd<100&&h.set(f,{success:0})}),this},resourceComboReport:function(){var o=this[a]||{},u=this._conf.resourceSlow||2e3,h=this[c];this[a]={};var p=Object.keys(o);if(p.length!==0){var d=[];r.each(p,function(S){var v=o[S],x={domain:"",res_type:"",src_type:"",size:0,duration:0,count:0,err_count:0,err_duration:0,slow_count:0,slow_duration:0,timings:[]};r.each(v,function(b){var E=b.timing||{},A=h.get(b.timing),y=A?A.success:1,_=b.duration>u?1:0;x.domain=b.domain,x.res_type=b.res_type,x.src_type=b.src_type,x.count+=1,x.duration+=b.duration,x.size+=b.size,y||(x.err_count+=1,x.err_duration+=b.duration),_&&(x.slow_count+=1,x.slow_duration+=b.duration);try{var R=JSON.parse(JSON.stringify(E));R.success=y,R.resourceSlow=u,R.isSlow=_,x.timings.push(R)}catch(L){}}),x.count&&(x.size=Math.round(x.size/x.count),x.duration=Math.round(x.duration/x.count)),x.slow_count&&(x.slow_duration=Math.round(x.slow_duration/x.slow_count)),x.err_count&&(x.err_duration=Math.round(x.err_duration/x.err_count)),x.timings.length>20&&(x.timings.sort(function(b,E){return E.duration-b.duration}),x.timings.length=20),x.timings=encodeURIComponent(JSON.stringify(x.timings)),d.push(x)});var f={_combo:1,resource:JSON.stringify(d)},m=i.navigator.connection;f.ct=m?m.effectiveType||m.type:"";var l=m&&(m.downlink||m.downlinkMax||m.bandwidth)||null;(l=l>999?999:l)&&(f.bandwidth=l),this._lg("resource",f,this.getConfig("sample"))}}})},Zi}var Us;function Zn(){if(Us)return Dt.exports;Us=1;var r=Be(),n=Hn(),e=jn(),t=zn(),i=r.win,s=i.document,a=/^(error|api|speed|sum|avg|percent|custom|msg|setPage|setConfig|behavior|performance)$/,c=function(o){var u=this;return n.call(u,o),u._initialPage=o.page&&r.safetyCall(o.page,[],o.page+"")||null,u._isRobot=r.isRobot(),u._health={errcount:0,apisucc:0,apifail:0},u.beforeSend=function(h,p){h==="error"?u._health.errcount++:h==="api"&&u._health[p.success?"apisucc":"apifail"]++},o.enableInstanceAutoSend!==!1&&(u.initHandler(),u.initHook(),u.initFmpObserver(1e4),u._conf&&u._conf.behavior&&typeof u.initBehavior=="function"&&u.initBehavior(),u._conf&&u._conf.enableResource&&typeof u.initResource=="function"&&u.initResource()),Object.defineProperty&&i.addEventListener&&Object.defineProperty(u,"pipe",{set:u.sendPipe}),u};return c.prototype=r.createObject(n.prototype),r.ext(n._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?r.cutUrlSearch(o.replace(/^#\/?/,"")):"")||"[index]"},parseResponse:function(o){if(!o||typeof o!="object")return{};var u=o.code,h=o.msg||o.message||o.subMsg||o.errorMsg||o.ret||o.errorResponse||"";return typeof h=="object"&&(u=u||h.code,h=h.msg||h.message||h.info||h.ret||JSON.stringify(h)),{msg:h,code:u,success:!0}}}),r.ext(c.prototype,{constructor:c,_super:n,onReady:function(o){var u=this;if(u.hasReady)return o();s.readyState==="complete"?(u.hasReady=!0,o()):r.on(i,"load",function(){u.hasReady=!0,o()},!0)},getPage:function(o){var u=this._conf,h=u.page,p=location,d=p.host+p.pathname;return h&&!o?r.safetyCall(h,[],h+""):this._initialPage||r.filterByRule(u.ignoreUrlCase?d.toLowerCase():d,p.href,u.ignoreUrlPath?u.ignoreUrlPath:u.urlHelper)},setPage:function(o,u){var h=this,p=h.prevPage;if(u!==!1){if(!o||o===p)return h;h.prevPage=o,clearTimeout(h.sendPVTimmer),h.handleUnload(1),h.resetPageview(),h.sendPVTimmer=setTimeout(function(){h.sendPV()},10)}else h.prevPage=o;return h._conf.page=o,h},setConfig:function(o,u){if(o&&typeof o=="object"){r.verifyConfig(o),o=this.setImgUrl(o);var h=this._conf;if(this._conf=r.ext({},h,o),!u){var p="disableHook";p in o&&h[p]!==o[p]&&(o[p]?this.removeHook():this.addHook()),(p="enableSPA")in o&&h[p]!==o[p]&&this.bindHashChange(o[p])}}},sendRequest:function(o){e(o,this.getConfig("imgUrl"))},postData:function(o,u){var h={};h[u]=o[u],delete o[u];var p="";typeof o=="object"&&(p=r.serialize(o)),t(h,this.getConfig("imgUrl")+p+"&post_res=")},sendPipe:function(o){var u=this;if(!o||!o.length)return u;try{if(r.T(o[0])==="Array")return r.each(o,function(p){return u.sendPipe(p)});if(r.T(o)!=="Array")return u;var h=o.shift();if(!a.test(h))return u;u[h].apply(u,o)}catch(p){return r.warn("[retcode] error in sendPipe",p),u}},sendHealth:function(){var o=r.ext({},this._health);o.healthy=o.errcount>0?0:1,o.begin=Date.now();var u=o.begin-this.sBegin;o.stay=u,this._lg("health",o,1),this._health={errcount:0,apisucc:0,apifail:0}},createInstance:function(o){o=r.ext({pid:this._conf.pid},o);var u=this.__proto__.constructor(o);return o.page&&u.sendPV(),u}}),Wn()(c,i),qn()(c,i,s),Jn()(c,i,s),Gn()(c,i),Xn()(c,i),Yn()(c,i),c._super=n,c._root=n._root,n.Browser=c,Dt.exports=c,Dt.exports}var Hs;function Qn(){if(Hs)return ri.exports;Hs=1;function r(c,o){var u=e[i]=new t(c);u.sendPipe(o);var h=u._conf;return h.autoSendPv!==!1&&u.sendPV(),h&&h.useFmp||u.sendPerformance(),h&&h.sendResource&&u.sendResources(),e[s]=!0,u}function n(){if(e[s])return e[i];var c={},o=[];return i in e&&(c=e[i].config||{},o=e[i].pipe||[]),r(c,o)}var e=window,t=e.BrowserLogger=Zn(),i=Be().key,s="__hasInitBlSdk";t.singleton=function(c,o){return e[s]?e[i]:r(c,o)},t.createExtraInstance=function(c){c&&typeof c=="object"&&c.enableInstanceAutoSend!==!0&&(c.enableInstanceAutoSend=!1);var o=new t(c),u=o._conf;return u.enableInstanceAutoSend&&(u.autoSendPv!==!1&&o.sendPV(),u&&u.useFmp||o.sendPerformance(),u&&u.sendResource&&o.sendResources()),o};var a=typeof window=="object"&&!!window.navigator;return a&&e[i]&&(t.bl=n()),ri.exports=t,ri.exports}function eo(){return Qn()}var to={getArmsLogger:eo};const js="https://arms-retcode.aliyuncs.com/r.png?",zs="https://arms-retcode-sg.aliyuncs.com/r.png?",Ws="https://retcode-us-west-1.arms.aliyuncs.com/r.png?",$s="e1iftji1w7@7ec1cef2cc88733",Ks="e1iftji1w7@10a06d1ec260adc",qs="e1iftji1w7@10a06d1ec260adc",Qi={cn:{reportUrl:js,pid:$s},"cn-hangzhou":{reportUrl:js,pid:$s},sg:{reportUrl:zs,pid:Ks},"ap-southeast-1":{reportUrl:zs,pid:Ks},usw:{reportUrl:Ws,pid:qs},"us-west-1":{reportUrl:Ws,pid:qs}},io=r=>r!==null&&typeof r=="object",ro=r=>Object.prototype.toString.call(r).slice(8,-1),so=r=>Object.isExtensible(r)?ro(r)==="Object":!1;function ao(r,n,e){var a;if(Reflect.get(r,"__v_skip")===!0)return r;const t=[],i=typeof Object.getOwnPropertyDescriptors=="function"?Object.getOwnPropertyDescriptors((a=Object.getPrototypeOf(r))!=null?a:{}):{};for(const c of Object.keys(i))i[c].get&&t.push(c);const s={MediaboxWrapperObjectGetter(c,o){if(typeof o=="string"&&t.indexOf(o)>-1){let u;try{u=c[o]}catch(h){throw e(h),h}return ft(u,n,e)}return n>10?c[o]:ft(c[o],n,e)},MediaboxWrapperObjectSetter(c,o,u){return c[o]=ft(u,n,e),!0}};return Object.defineProperty(r,"__v_skip",{configurable:!0,enumerable:!1,writable:!1,value:!0}),new Proxy(r,{get:s.MediaboxWrapperObjectGetter,set:s.MediaboxWrapperObjectSetter})}function no(r,n,e){const t={MediaboxWrapperFunctionApply(i,s,a){let c;try{c=Reflect.apply(i,s,a)}catch(o){throw e(o),o}return ft(c,n,e)},MediaboxWrapperFunctionGet(i,s){const a=Object.getOwnPropertyDescriptor(i,s);return a&&!a.writable&&!a.configurable?i[s]:ft(i[s],n,e)},MediaboxWrapperClassConstructor(i,s){let a;try{a=new i(...s)}catch(c){throw e(c),c}return ft(a,n,e)}};return new Proxy(r,{apply:t.MediaboxWrapperFunctionApply,get:t.MediaboxWrapperFunctionGet,construct:t.MediaboxWrapperClassConstructor})}function oo(r,n){if(typeof r!="string")return n;if(Js(r,n))return r;const e=r.indexOf(`
|
|
3
|
+
`+a)}},Ki.exports}var qi,Is;function Wn(){if(Is)return qi;Is=1;var r=Be();return qi=function(n,e){var t=[],i=null,s=e&&e.location&&e.location.href,a=void 0,c=null,o=function(d,f,m){if(d!==null){var l=d[f];d[f]=m(l)}},u=function(d){var f,m,l,S,v,x=[];if(!d||typeof d.tagName!="string")return"";if(x.push(d.tagName.toLowerCase()),typeof d.id=="string"&&x.push("#".concat(d.id)),typeof(f=d.className)=="string")for(m=f.split(/\s+/),v=0;v<m.length;v++)x.push(".".concat(m[v]));var b=["type","name","title","alt","data-arms-attr"];for(v=0;v<b.length;v++)l=b[v],typeof(S=d.getAttribute(l))=="string"&&x.push("[".concat(l,'="').concat(S,'"]'));return x.join("")},h=function(d,f){return function(m){if(m&&m!==c){c=m;var l;try{l=m.target}catch(v){l="<unknown>"}if(l.length!==0){var S={type:"ui.".concat(d),data:{message:function(v){if(!v||v.nodeType!==1)return"";for(var x=v||null,b=[],E=0,A=0,y=3,_="";x&&E++<5&&!((_=u(x))==="html"||E>1&&A+b.length*y+_.length>=80);)b.push(_),A+=_.length,x=x.parentNode;return b.reverse().join(" > ")}(l)},timestamp:Date.now()};d==="click"?i&&i.addBehavior(S):d==="keypress"&&(a||i&&i.addBehavior(S),clearTimeout(a),a=setTimeout(function(){a=void 0},100))}}}},p=function(){if(function(){var l=e&&e.chrome,S=l&&l.app&&l.app.runtime,v="history"in e&&!!e.history.pushState&&!!e.history.replaceState;return!S&&v}()){var d=function(l,S){var v={type:"navigation",data:{from:l,to:S}};i&&i.addBehavior(v),s=S},f=e.onpopstate;e.onpopstate=function(){for(var l=arguments.length,S=new Array(l),v=0;v<l;v++)S[v]=arguments[v];var x=e.location.href;if(d(s,x),f)return f.apply(this,S)};var m=function(l){return function(){for(var S=arguments.length,v=new Array(S),x=0;x<S;x++)v[x]=arguments[x];var b=v.length>2?v[2]:void 0;return b&&d(s,String(b)),l.apply(this,v)}};o(e.history,"pushState",m),o(e.history,"replaceState",m)}};r.ext(n.prototype,{addBehavior:function(d){if(this.getConfig("behavior")&&d&&typeof d=="object"){var f={},m=d.data||{};if(d.type)f=m;else{if(typeof m.name!="string"||typeof m.message!="string")return;f.name=m.name.substr(0,20),f.message=m.message.substr(0,200)}f.message&&(f.message=r.encode(f.message));var l={type:d.type||"custom",data:f||{},timestamp:d.timestamp||Date.now(),page:d.page||e&&e.location&&e.location.pathname};return t.push(l),t=t.slice(-100)}},getBehavior:function(){return t||[]},setBehavior:function(d){return d&&(t=d),t},reportBehavior:function(d){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,d&&typeof d=="function"&&d())},0))},initBehavior:function(){if(!this.hasInitBehavior&&!i){try{(function(){if(document&&document.referrer&&document.location){var f=document.referrer,m=document.location.href;if(f!==""){var l={type:"navigation",data:{from:f,to:m}};s=m,i&&i.addBehavior(l)}}})(),e&&e.document&&e.document.addEventListener&&(e.document.addEventListener("click",h("click"),!1),e.document.addEventListener("keypress",h("keypress"),!1)),p();var d=this.getConfig("enableConsole");d&&function(f){if(e&&e.console){var m=["debug","info","warn","log","error","assert"];r.isArray(f)&&(m=f);for(var l=0;l<m.length;l++){var S=m[l];S&&r.isString(S)&&e.console[S]&&typeof e.console[S]=="function"&&o(e.console,S,function(v){var x=S;return function(){for(var b=arguments.length,E=new Array(b),A=0;A<b;A++)E[A]=arguments[A];var y={type:"console",data:{level:x,message:E}};if(i&&i.addBehavior(y),x==="error")for(var _=0;_<E.length;_++){var R=E[_];R&&R.message&&R.stack&&i&&i.errorHandler(new ErrorEvent("error",{error:R,message:R.message}))}v&&Function.prototype.apply.call(v,e.console,E)}})}}}(d)}catch(f){r.warn("[arms] error in initBehavior",f)}i=this,this.hasInitBehavior=!0}return this}})},qi}var ws={},Ts;function Ji(){return Ts||(Ts=1,ws.TIMING_KEYS=["startTime","fetchStart","domainLookupStart","domainLookupEnd","connectStart","connectEnd","requestStart","responseStart","responseEnd","","domInteractive","","domContentLoadedEventEnd","","loadEventStart","","msFirstPaint","secureConnectionStart","redirectStart","redirectEnd"]),ws}var Gi,Ds;function $n(){if(Ds)return Gi;Ds=1;var r=Be(),n=Ji(),e=n.TIMING_KEYS;return Gi=function(){var t=r.win||{},i=t.performance;if(!i||typeof i!="object"||typeof i.getEntriesByType!="function")return null;var s={},a=i.timing||{},c=i.getEntriesByType("resource")||[];if(s.begin=a[e[1]]||Date.now(),typeof t.PerformanceNavigationTiming=="function"){var o=i.getEntriesByType("navigation")[0];o&&(a=o)}return r.each({dom:[10,8],load:[14,1]},function(u,h){var p=a[e[u[1]]],d=a[e[u[0]]];if(p>0&&d>0){var f=Math.round(d-p);f>=0&&f<6e5&&(s[h]=f)}}),s.res=JSON.stringify(c),s},Gi}var Xi,Ps;function Kn(){if(Ps)return Xi;Ps=1;var r=Be(),n=Ji(),e=n.TIMING_KEYS;return Xi=function(){var t=r.win||{},i=t.performance;if(!i||typeof i!="object")return null;var s={},a=i.timing||{},c=Date.now(),o=1;if(typeof t.PerformanceNavigationTiming=="function"){var u=i.getEntriesByType("navigation")[0];u&&(a=u,o=2)}r.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(m,l){var S=a[e[m[1]]],v=a[e[m[0]]];if(o===2||S>0&&v>0){var x=Math.round(v-S);x>=0&&x<6e5&&(s[l]=x)}});var h=t.navigator.connection,p=i.navigation||{};s.ct=h?h.effectiveType||h.type:"";var d=h&&(h.downlink||h.downlinkMax||h.bandwidth)||null;if((d=d>999?999:d)&&(s.bandwidth=d),s.navtype=p.type===1?"Reload":"Other",o===1&&a[e[16]]>0&&a[e[1]]>0){var f=a[e[16]]-a[e[1]];f>=0&&f<36e5&&(s.fpt=f)}return o===1&&a[e[1]]>0?s.begin=a[e[1]]:o===2&&s.load>0?s.begin=c-s.load:s.begin=c,s},Xi}var ks,Bs;function qn(){return Bs||(Bs=1,ks=function(r,n,e){var t=Be(),i=$n(),s=Kn(),a=null,c=e.documentElement,o=n.innerWidth||c.clientWidth||e.body.clientWidth,u=n.innerHeight||c.clientHeight||e.body.clientHeight,h=n.navigator.connection,p={sr:screen.width+"x"+screen.height,vp:o+"x"+u,ct:h?h.effectiveType||h.type:""},d={},f=function(l,S,v,x,b){if(S===void 0){var E,A;if(!d[l]){E=new RegExp(l+"=([^;]+)");try{A=E.exec(e.cookie)}catch(_){return t.warn("[retcode] can not get cookie:",_),null}A&&(d[l]=A[1])}return d[l]}var y=l+"="+S;y+="; path=/",v&&(y+="; max-age="+v);try{return e.cookie=y,!!e.cookie}catch(_){return t.warn("[retcode] can not set cookie: ",_),!1}},m=function(l){var S=l._conf.uid||f("_nk_")||f("_bl_uid");return!S&&(S=t.uu(),!f("_bl_uid",S,15552e3))?null:S};return t.ext(r.prototype,{activeErrHandler:function(l){return a&&!l?this:(a=this,this)},errorHandler:function(l){if(!l)return this;var S=l.type;if(S==="error"){var v=l.target||l.srcElement;!v||!v.tagName||l.message||l.filename||l.lineno||l.colno?this.error(l.error||{message:l.message},l):this.resourceErrorHandler(l)}else S==="unhandledrejection"&&t.T(l.reason,"Error")&&t.checkAutoError(l.reason)&&this.error(l.reason);try{this.getConfig("behavior")&&this.reportBehavior&&this.reportBehavior()}catch(x){}return this},resourceErrorHandler:function(l){var S=this,v=l.target||l.srcElement;try{var x=S.getSrc(v),b=typeof v.tagName=="string"?v.tagName.toLowerCase():"",E=S.getXPath(v,5),A=t.getURL(x),y={src:x&&x.substring(0,1e3),node_name:b,xpath:E,res_type:t.getResType(b,x),res_name:A.path,domain:A.domain};return S._conf.enableResource&&S.fixResourceStatus&&l.timeStamp&&S.fixResourceStatus({src:x,node_name:b,res_type:t.getResType(b,x),timeStamp:l.timeStamp,domain:A.domain}),S._lg("resourceError",y),S}catch(_){return t.warn("[ARMS] resourceErrorHandler error :",_),S}},getSrc:function(l){var S=l.src||l.href;try{if(!S){var v=(typeof l.tagName=="string"?l.tagName.toLowerCase():"")==="object",x=l.getAttribute("classid")&&l.getAttribute("classid").toLowerCase()==="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"||l.getAttribute("type")==="application/x-shockwave-flash";v&&x&&(S=l.getAttribute("data")||l.getAttribute("codebase")),S||(S=l.outerHTML||l.innerHTML)}}catch(b){S=""}return S},getXPath:function(l,S){var v=l.id?"#"+l.id:"",x=typeof l.className=="string"?"."+l.className.split(" ").join("."):"",b=(typeof l.tagName=="string"?l.tagName.toLowerCase():"")+v+x;return l.parentNode&&l.parentNode.tagName&&S-1!=0?this.getXPath(l.parentNode,S-1)+" > "+b:b},sendPerformance:function(l){var S=this;S.onReady(function(){var v=s();v&&v.load&&v.load>0&&(v.page=S.getPage(!0),l&&(v=t.ext(v,l)),v.autoSend=!0,S.performance(v))})},sendResources:function(l){var S=this;S.onReady(function(){var v=i();v&&v.load&&v.load>0&&(v.load&&v.load<=2e3||v.load&&v.load<=8e3&&Math.random()>.05||(v.page=S.getPage(!0),v.dl=location.href,l&&(v=t.ext(v,l)),S._lg("res",v,S.getConfig("sample"))))})},sendPV:function(){var l=this;l.onReady(function(){var S=function(v){var x=m(v),b=n.devicePixelRatio||1;return{uid:x,dt:e.title,dl:location.href,dr:e.referrer,dpr:b.toFixed(2),de:(e.characterSet||e.defaultCharset||"").toLowerCase(),ul:c.lang,begin:Date.now()}}(l);S&&S.uid&&l._lg("pv",S,l.getConfig("pvSample"))})},commonInfo:function(){return p.uid=m(this),p.sid=function(l){if(l.session)return l.session;var S;try{if(typeof window=="object"&&typeof sessionStorage=="object"&&typeof sessionStorage.getItem=="function")return typeof(S=sessionStorage.getItem("_bl_sid"))=="string"?(l.session=S,S):(S=t.uu(),l.session=S,typeof sessionStorage.setItem=="function"&&sessionStorage.setItem("_bl_sid",S),S)}catch(v){t.warn("[ARMS] getSid error :",v)}return l.session=S=t.uu(),S}(this),p},handleUnload:function(l){var S=Date.now();if(S-this._lastUnload<200)return this;this._lastUnload=S,this.sendHealth(l),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(l){var S=this;if(!l^S.hashChangeHandler)return S;l?(S.hackHistoryState(),S.hashChangeHandler=function(v){var x=S._conf.parseHash(location.hash);x&&S.setPage(x,v!==!1)},S.stateChangeHandler=function(v){var x=S._conf.parseHash(v.detail);x&&S.setPage(x)},t.on(n,"hashchange",S.hashChangeHandler),t.on(n,"historystatechange",S.stateChangeHandler),S.hashChangeHandler(!1)):(t.off(n,"hashchange",S.hashChangeHandler),t.off(n,"historystatechange",S.stateChangeHandler),S.hashChangeHandler=null,S.stateChangeHandler=null)},initHandler:function(){var l=this;if(l.hasInitHandler)return l;var S=l._conf;return t.on(n,"beforeunload",function(){l.handleUnload(0)}),l.bindHashChange(S.enableSPA),l.activeErrHandler(!1),l.hasInitHandler=!0,l}}),t.on(n,"error",function(l){a&&a.errorHandler(l)},!1,!0).on(n,"unhandledrejection",function(l){a&&a.errorHandler(l)}),r}),ks}var Yi,Ns;function Jn(){if(Ns)return Yi;Ns=1;var r=Be(),n=500;return Yi=function(e,t,i){function s(p,d,f){var m=0,l=p.tagName;if(l!=="SCRIPT"&&l!=="STYLE"&&l!=="META"&&l!=="HEAD"){var S=p.children?p.children.length:0;if(S>0)for(var v=p.children,x=S-1;x>=0;x--)m+=s(v[x],d+1,m>0);if(m<=0&&!f&&!(p.getBoundingClientRect&&p.getBoundingClientRect().top<c))return 0;m+=1+.5*d}return m}function a(p){for(var d=1;d<p.length;d++)if(p[d].score<p[d-1].score)return p.splice(d,1),a(p);return p}var c=t.innerHeight||0,o=[],u=null,h=0;r.ext(e.prototype,{initFmpObserver:function(p){var d=this;if(!d._conf||!d._conf.useFmp)return null;if(!t.MutationObserver)return r.warn("[retcode] first meaningful paint can not be retrieved"),d.sendPerformance(),null;r.on(t,"beforeunload",function(){d.endObserving(0,!0)});var f=t.MutationObserver;return(u=new f(function(){(function(m){var l=Date.now()-m,S=i.querySelector("body");if(S){var v=0;v+=s(S,1,!1),o.push({score:v,t:l})}else o.push({score:0,t:l})})(d._startTime)})).observe(document,{childList:!0,subtree:!0}),h=1,d.onReady(function(){d.endObserving(p)}),u},endObserving:function(p,d){var f=this;if(u&&h)if(f.fmpTimmer&&(clearTimeout(f.fmpTimmer),f.fmpTimmer=null),d||!function(v,x){var b=Date.now()-v;return!(b>x||b-(o&&o.length&&o[o.length-1].t||0)>2*n)}(f._startTime,p)){u.disconnect(),h=0,o=a(o);for(var m=null,l=1;l<o.length;l++)if(o[l].t>=o[l-1].t){var S=o[l].score-o[l-1].score;(!m||m.rate<=S)&&(m={t:o[l].t,rate:S})}m&&m.t>0&&m.t<36e5?f.sendPerformance({fmp:m.t}):f.sendPerformance()}else f.fmpTimmer=r.delay(function(){f.endObserving(p)},n)}})},Yi}var Ls,Ms;function Gn(){return Ms||(Ms=1,Ls=function(r,n){var e=Be(),t=null,i=e.getCurDomain(),s=function(h,p,d,f,m,l,S,v,x,b,E,A,y){var _=e.J(m)||null,R=e.safetyCall(p,[_,f],null);if(!R)return!1;var L=R.code||l,C=!("success"in R)||R.success;h.api(d,C,S,L,R.msg,v,x,b,C?{}:E,i,A,y)},a="fetch",c="__oFetch_",o="__oXMLHttpRequest_",u="XMLHttpRequest";return e.ext(r.prototype,{removeHook:function(h,p){return t&&(p||this===t)?(n[c]&&(n[a]=n[c],delete n[c]),n[o]&&(n[u]=n[o],delete n[o]),t=null,this):this},addHook:function(h){return!h&&t?this:(t||(function(){if(typeof n[a]=="function"){var p=n[a];n[c]=p,n[a]=function(d,f){var m=arguments.length===1?[arguments[0]]:Array.apply(null,arguments),l=t;if(!l||!l.api||f&&(f.method==="HEAD"||f.mode==="no-cors"))return p.apply(n,m);f||(f={});var S=Date.now(),v=l._conf,x=e.duration(),b=(d&&typeof d!="string"?d.url:d)||"",E=b;b=e.cutUrlSearch(b);var A=(v.ignore||{}).ignoreApis,y=v.parseTraceId;if(!e.checkAPI(b,!0)||e.ignoreByRule(b,A))return p.apply(n,m);b=e.filterByRule(b,E,v.ignoreApiPath?v.ignoreApiPath:v.apiHelper);var _=v.enableLinkTrace,R="",L="",C=l.getConfig("pid"),I=null,P=l.getConfig("sample"),B=l.getConfig("linkType"),K=1;if(P&&!l.sampling(P)&&(K=0),_){var J="";try{J=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(Y){J=""}var Q=e.checkSameOrigin(E,J);if(l.getConfig("enableApiCors")||Q)if(d&&typeof d!="string")try{if(m[0].headers&&typeof m[0].headers.get=="function"&&typeof m[0].headers.append=="function")switch(B){case"arms":var ue=m[0].headers.get("EagleEye-TraceID"),te=m[0].headers.get("EagleEye-SessionID"),se=m[0].headers.get("EagleEye-pAppName");ue?R=ue:(R=l.getTraceId()["EagleEye-TraceID"],m[0].headers.append("EagleEye-TraceID",R)),te?L=te:(L=l.getPageviewId()["EagleEye-SessionID"],m[0].headers.append("EagleEye-SessionID",L)),se||m[0].headers.append("EagleEye-pAppName",C);break;case"b3":var ie=m[0].headers.get("X-B3-TraceId");if(ie)R=ie;else{var k=l.getB3TraceId(K);m[0].headers.append("X-B3-TraceId",k["X-B3-TraceId"]),m[0].headers.append("X-B3-ParentSpanId",k["X-B3-ParentSpanId"]),m[0].headers.append("X-B3-SpanId",k["X-B3-SpanId"]),m[0].headers.append("X-B3-Sampled",k["X-B3-Sampled"]),m[0].headers.append("X-Request-ID",e.guid()),R=k["X-B3-TraceId"]}L=l.pageview;break;case"tracing":default:var M=m[0].headers.get("uber-trace-id");M?R=M.split(":")[0]:(M=l.getUberTraceId(K),m[0].headers.append("uber-trace-id",M["uber-trace-id"]),R=M.traceId),L=l.pageview}}catch(Y){e.warn(`[retcode] fetch failed to set header, exception is :
|
|
4
|
+
`+Y)}else switch(f.headers=f.headers?f.headers:{},B){case"arms":f.headers["EagleEye-TraceID"]?R=f.headers["EagleEye-TraceID"]:(R=l.getTraceId()["EagleEye-TraceID"],f.headers["EagleEye-TraceID"]=R),f.headers["EagleEye-SessionID"]?L=f.headers["EagleEye-SessionID"]:(L=l.getPageviewId()["EagleEye-SessionID"],f.headers["EagleEye-SessionID"]=L),f.headers["EagleEye-pAppName"]||(f.headers["EagleEye-pAppName"]=C);break;case"b3":if(f.headers["X-B3-TraceId"])R=f.headers["X-B3-TraceId"];else{var F=l.getB3TraceId(K);f.headers["X-B3-TraceId"]=F["X-B3-TraceId"],f.headers["X-B3-ParentSpanId"]=F["X-B3-ParentSpanId"],f.headers["X-B3-SpanId"]=F["X-B3-SpanId"],f.headers["X-B3-Sampled"]=F["X-B3-Sampled"],f.headers["X-Request-ID"]=e.guid(),R=F["X-B3-TraceId"]}L=l.getPageviewId()["EagleEye-SessionID"];break;case"tracing":default:if(f.headers["uber-trace-id"])R=f.headers["uber-trace-id"].split(":")[0];else{var N=l.getUberTraceId(K);f.headers["uber-trace-id"]=N["uber-trace-id"],R=N.traceId}L=l.getPageviewId()["EagleEye-SessionID"]}}return p.apply(n,m).then(function(Y){if(!l||!l.api)return Y;try{if(!Y||typeof Y.clone!="function")return Y;var j=Y.clone(),fe=j.headers;if(fe&&typeof fe.get=="function"){var ee=fe.get("content-type");if(ee&&!/(text)|(json)/.test(ee))return Y;if(!R){var ze=e.parseFetchHeaders(fe);typeof ze=="object"&&ze["eagleeye-traceid"]&&(R=ze["eagleeye-traceid"],I="response")}}var Je=x();return j.text().then(function(st){if(!R&&e.isFunction(y)){var at=y(j,st);at&&e.isString(at)&&(R=at)}var ye=e.getFetchSnapshot(m,st,fe);j.ok?s(l,v.parseResponse,b,E,st,j.status||200,Je,S,R,L,ye,I,K):(l.api(b,!1,Je,j.status||404,j.statusText,S,R,L,ye,i,I,K),v.enableResource&&t.fixResourceStatus&&t.fixResourceStatus({src:j.url,res_type:"api"}))}),Y}catch(st){return e.warn("[ARMS] fetch response error :",st),Y}}).catch(function(Y){if(!l||!l.api)throw Y;var j=x();throw l.api(b,!1,j,Y.name||"Error",Y.message,S,R,L,{},i),v.enableResource&&t.fixResourceStatus&&t.fixResourceStatus({src:E,res_type:"api"}),Y})},n[a].toString=e.createFakeToString(a)}}(),function(){if(typeof n[u]=="function"){var p,d=n[u];n[o]=d;var f=function(m){var l=new d(m),S=t;if(!S||!S.api||!l.addEventListener)return l;var v,x,b,E,A=l.send,y=l.open,_=l.setRequestHeader,R=S._conf,L=(R.ignore||{}).ignoreApis,C=R.parseTraceId,I=S.getConfig("enableLinkTrace"),P="",B="",K="",J=null,Q=S.getConfig("sample"),ue=S.getConfig("linkType"),te=1;return Q&&!S.sampling(Q)&&(te=0),l.open=function(se,ie){p=se;var k=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);y.apply(l,k),E=ie||"",b=e.cutUrlSearch(E);var M=!e.checkAPI(b,!0)||e.ignoreByRule(b,L);if(b=b?e.filterByRule(b,E,R.ignoreApiPath?R.ignoreApiPath:R.apiHelper):"",!M&&I){var F="";try{F=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(fe){F=""}var N=e.checkSameOrigin(E,F);if((S.getConfig("enableApiCors")||N)&&_&&typeof _=="function")switch(ue){case"arms":P=S.getTraceId()["EagleEye-TraceID"],_.apply(l,["EagleEye-TraceID",P]),B=S.getPageviewId()["EagleEye-SessionID"],_.apply(l,["EagleEye-SessionID",B]),K=S.getConfig("pid"),_.apply(l,["EagleEye-pAppName",K]);break;case"b3":var Y=S.getB3TraceId(te);_.apply(l,["X-B3-TraceId",Y["X-B3-TraceId"]]),_.apply(l,["X-B3-ParentSpanId",Y["X-B3-ParentSpanId"]]),_.apply(l,["X-B3-SpanId",Y["X-B3-SpanId"]]),_.apply(l,["X-B3-Sampled",Y["X-B3-Sampled"]]),_.apply(l,["X-Request-ID",e.guid()]),P=Y["X-B3-TraceId"],B=S.getPageviewId()["EagleEye-SessionID"];break;case"tracing":default:var j=S.getUberTraceId(te);_.apply(l,["uber-trace-id",j["uber-trace-id"]]),P=j.traceId,B=S.getPageviewId()["EagleEye-SessionID"]}}},l.send=function(){v=Date.now(),x=e.duration();var se=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);A.apply(l,se)},e.on(l,"readystatechange",function(){if(b&&l.readyState===4){var se=x(),ie=e.getXhrSnapshot(E,p,l);if(!P){var k=e.parseXhrHeaders(typeof l.getAllResponseHeaders=="function"&&l.getAllResponseHeaders()||"");typeof k=="object"&&k["eagleeye-traceid"]&&(P=k["eagleeye-traceid"],J="response")}if(!P&&e.isFunction(C)){var M=C(l);M&&e.isString(M)&&(P=M)}if(l.status>=200&&l.status<=299){var F=l.status||200;if(typeof l.getResponseHeader=="function"){var N=l.getResponseHeader("Content-Type");if(N&&!/(text)|(json)/.test(N))return}l.responseType&&l.responseType!=="text"?S.api(b,!0,se,F,"",v,P,B,{},i,J,te):s(S,R.parseResponse,b,E,l.responseText,F,se,v,P,B,ie,J,te)}else S.api(b,!1,se,l.status||"FAILED",l.statusText,v,P,B,ie,i,J,te),R.enableResource&&t.fixResourceStatus&&t.fixResourceStatus({src:l.responseURL||E,res_type:"api"})}}),l};f.prototype=d.prototype,e.each(Object.keys(d),function(m){f[m]=d[m]}),n[u]=f,n[u].toString=e.createFakeToString(u)}}()),t=this,this)},initHook:function(){return this.hasInitHook?this:(this.getConfig("disableHook")||this.addHook(),this.hasInitHook=!0,this)}}),r}),Ls}var Fs,Vs;function Xn(){return Vs||(Vs=1,Fs=function(r,n){var e=Be(),t=n.history||{},i=n.document,s=function(c,o){var u;n.CustomEvent?u=new CustomEvent(c,{detail:o}):((u=i.createEvent("HTMLEvents")).initEvent(c,!1,!0),u.detail=o),n.dispatchEvent(u)},a=function(c){var o=t[c];typeof o=="function"&&(t[c]=function(u,h,p){var d=arguments.length===1?[arguments[0]]:Array.apply(null,arguments),f=location.href,m=o.apply(t,d);if(!p||typeof p!="string"||p===f)return m;try{var l=f.split("#"),S=p.split("#"),v=e.cutUrlSearch(l[0]),x=e.cutUrlSearch(S[0]),b=l[1]&&l[1].replace(/^\/?(.*)/,"$1"),E=S[1]&&S[1].replace(/^\/?(.*)/,"$1");b!==E?s("historystatechange",E):v!==x&&s("historystatechange",x)}catch(A){e.warn("[retcode] error in "+c+": "+A)}return m},t[c].toString=e.createFakeToString(c))};e.ext(r.prototype,{hackHistoryState:function(){return this.hasHackedHistoryState?this:(a("pushState"),a("replaceState"),this.hasHackedHistoryState=!0,this)}})}),Fs}var Zi,Os;function Yn(){if(Os)return Zi;Os=1;var r=Be(),n=Ji(),e=n.TIMING_KEYS;return Zi=function(t,i){function s(o,u,h){if(o instanceof i.PerformanceResourceTiming&&o.initiatorType){var p=r.getResType(o.initiatorType,o.name),d=u.resourceTypes||[],f=(u.ignore||{}).ignoreResources;if(p&&d.includes(p)&&!r.ignoreByRule(o.name,f)&&!r.ignoreByRule(r.decode(o.name),f)){var m=o[e[0]],l=o[e[1]],S=o[e[2]],v=o[e[3]],x=o[e[4]],b=o[e[5]],E=o[e[6]],A=o[e[7]],y=o[e[8]],_=o[e[18]],R=o[e[19]];if(!h.has(o)&&(!r.areInOrder(m,l,S,v,x,b,E,A,y)||m>A))return;if(_<m&&(_=m),R<m&&(R=l),r.areInOrder(m,_,R,l))return{domain:r.getURL(o.name).domain,res_type:p,src_type:r.getSrcType(o.name,u.cdnHostList),success:1,size:Math.round(o.decodedBodySize),duration:Math.round(o.duration),timeStamp:o.responseEnd,timing:o}}}}var a="_resource-"+Date.now(),c="_resource_error-"+Date.now();r.ext(t.prototype,{initResource:function(){var o=this,u=i.performance,h=i.PerformanceObserver;if(o[c]||(o[c]=new WeakMap),!u||!h||typeof u!="object"||typeof u.getEntriesByType!="function")return null;var p=u.getEntriesByType("resource")||[];return setTimeout(function(){o.setResource(p)},10),new h(function(d){setTimeout(function(){o.setResource(d.getEntries())},10)}).observe({entryTypes:["resource"]}),this.onReady(function(){setTimeout(o.resourceComboReport.bind(o),5e3)}),o},setResource:function(o){var u=this._conf,h=this[c];if(r.isArray(o)&&o.length){this[a]||(this[a]={});for(var p=this[a],d=0,f=o.length;d<f;d+=1){var m=o[d];if(r.checkAPI(m.name,!1)){var l=s(m,u,h);if(l){var S=l.res_type+"-"+l.domain;S in p||(p[S]=[]),p[S].push(l)}}}return this}},fixResourceStatus:function(o){var u=i.performance;if(!u||typeof u.getEntriesByName!="function")return null;var h=this[c];if(!o.src||!r.checkAPI(o.src,!1))return this;var p=o.timeStamp||u.now(),d=u.getEntriesByName(o.src,"resource");return r.each(d,function(f){h.has(f)||p-f.responseEnd<100&&h.set(f,{success:0})}),this},resourceComboReport:function(){var o=this[a]||{},u=this._conf.resourceSlow||2e3,h=this[c];this[a]={};var p=Object.keys(o);if(p.length!==0){var d=[];r.each(p,function(S){var v=o[S],x={domain:"",res_type:"",src_type:"",size:0,duration:0,count:0,err_count:0,err_duration:0,slow_count:0,slow_duration:0,timings:[]};r.each(v,function(b){var E=b.timing||{},A=h.get(b.timing),y=A?A.success:1,_=b.duration>u?1:0;x.domain=b.domain,x.res_type=b.res_type,x.src_type=b.src_type,x.count+=1,x.duration+=b.duration,x.size+=b.size,y||(x.err_count+=1,x.err_duration+=b.duration),_&&(x.slow_count+=1,x.slow_duration+=b.duration);try{var R=JSON.parse(JSON.stringify(E));R.success=y,R.resourceSlow=u,R.isSlow=_,x.timings.push(R)}catch(L){}}),x.count&&(x.size=Math.round(x.size/x.count),x.duration=Math.round(x.duration/x.count)),x.slow_count&&(x.slow_duration=Math.round(x.slow_duration/x.slow_count)),x.err_count&&(x.err_duration=Math.round(x.err_duration/x.err_count)),x.timings.length>20&&(x.timings.sort(function(b,E){return E.duration-b.duration}),x.timings.length=20),x.timings=encodeURIComponent(JSON.stringify(x.timings)),d.push(x)});var f={_combo:1,resource:JSON.stringify(d)},m=i.navigator.connection;f.ct=m?m.effectiveType||m.type:"";var l=m&&(m.downlink||m.downlinkMax||m.bandwidth)||null;(l=l>999?999:l)&&(f.bandwidth=l),this._lg("resource",f,this.getConfig("sample"))}}})},Zi}var Us;function Zn(){if(Us)return Dt.exports;Us=1;var r=Be(),n=Hn(),e=jn(),t=zn(),i=r.win,s=i.document,a=/^(error|api|speed|sum|avg|percent|custom|msg|setPage|setConfig|behavior|performance)$/,c=function(o){var u=this;return n.call(u,o),u._initialPage=o.page&&r.safetyCall(o.page,[],o.page+"")||null,u._isRobot=r.isRobot(),u._health={errcount:0,apisucc:0,apifail:0},u.beforeSend=function(h,p){h==="error"?u._health.errcount++:h==="api"&&u._health[p.success?"apisucc":"apifail"]++},o.enableInstanceAutoSend!==!1&&(u.initHandler(),u.initHook(),u.initFmpObserver(1e4),u._conf&&u._conf.behavior&&typeof u.initBehavior=="function"&&u.initBehavior(),u._conf&&u._conf.enableResource&&typeof u.initResource=="function"&&u.initResource()),Object.defineProperty&&i.addEventListener&&Object.defineProperty(u,"pipe",{set:u.sendPipe}),u};return c.prototype=r.createObject(n.prototype),r.ext(n._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?r.cutUrlSearch(o.replace(/^#\/?/,"")):"")||"[index]"},parseResponse:function(o){if(!o||typeof o!="object")return{};var u=o.code,h=o.msg||o.message||o.subMsg||o.errorMsg||o.ret||o.errorResponse||"";return typeof h=="object"&&(u=u||h.code,h=h.msg||h.message||h.info||h.ret||JSON.stringify(h)),{msg:h,code:u,success:!0}}}),r.ext(c.prototype,{constructor:c,_super:n,onReady:function(o){var u=this;if(u.hasReady)return o();s.readyState==="complete"?(u.hasReady=!0,o()):r.on(i,"load",function(){u.hasReady=!0,o()},!0)},getPage:function(o){var u=this._conf,h=u.page,p=location,d=p.host+p.pathname;return h&&!o?r.safetyCall(h,[],h+""):this._initialPage||r.filterByRule(u.ignoreUrlCase?d.toLowerCase():d,p.href,u.ignoreUrlPath?u.ignoreUrlPath:u.urlHelper)},setPage:function(o,u){var h=this,p=h.prevPage;if(u!==!1){if(!o||o===p)return h;h.prevPage=o,clearTimeout(h.sendPVTimmer),h.handleUnload(1),h.resetPageview(),h.sendPVTimmer=setTimeout(function(){h.sendPV()},10)}else h.prevPage=o;return h._conf.page=o,h},setConfig:function(o,u){if(o&&typeof o=="object"){r.verifyConfig(o),o=this.setImgUrl(o);var h=this._conf;if(this._conf=r.ext({},h,o),!u){var p="disableHook";p in o&&h[p]!==o[p]&&(o[p]?this.removeHook():this.addHook()),(p="enableSPA")in o&&h[p]!==o[p]&&this.bindHashChange(o[p])}}},sendRequest:function(o){e(o,this.getConfig("imgUrl"))},postData:function(o,u){var h={};h[u]=o[u],delete o[u];var p="";typeof o=="object"&&(p=r.serialize(o)),t(h,this.getConfig("imgUrl")+p+"&post_res=")},sendPipe:function(o){var u=this;if(!o||!o.length)return u;try{if(r.T(o[0])==="Array")return r.each(o,function(p){return u.sendPipe(p)});if(r.T(o)!=="Array")return u;var h=o.shift();if(!a.test(h))return u;u[h].apply(u,o)}catch(p){return r.warn("[retcode] error in sendPipe",p),u}},sendHealth:function(){var o=r.ext({},this._health);o.healthy=o.errcount>0?0:1,o.begin=Date.now();var u=o.begin-this.sBegin;o.stay=u,this._lg("health",o,1),this._health={errcount:0,apisucc:0,apifail:0}},createInstance:function(o){o=r.ext({pid:this._conf.pid},o);var u=this.__proto__.constructor(o);return o.page&&u.sendPV(),u}}),Wn()(c,i),qn()(c,i,s),Jn()(c,i,s),Gn()(c,i),Xn()(c,i),Yn()(c,i),c._super=n,c._root=n._root,n.Browser=c,Dt.exports=c,Dt.exports}var Hs;function Qn(){if(Hs)return ri.exports;Hs=1;function r(c,o){var u=e[i]=new t(c);u.sendPipe(o);var h=u._conf;return h.autoSendPv!==!1&&u.sendPV(),h&&h.useFmp||u.sendPerformance(),h&&h.sendResource&&u.sendResources(),e[s]=!0,u}function n(){if(e[s])return e[i];var c={},o=[];return i in e&&(c=e[i].config||{},o=e[i].pipe||[]),r(c,o)}var e=window,t=e.BrowserLogger=Zn(),i=Be().key,s="__hasInitBlSdk";t.singleton=function(c,o){return e[s]?e[i]:r(c,o)},t.createExtraInstance=function(c){c&&typeof c=="object"&&c.enableInstanceAutoSend!==!0&&(c.enableInstanceAutoSend=!1);var o=new t(c),u=o._conf;return u.enableInstanceAutoSend&&(u.autoSendPv!==!1&&o.sendPV(),u&&u.useFmp||o.sendPerformance(),u&&u.sendResource&&o.sendResources()),o};var a=typeof window=="object"&&!!window.navigator;return a&&e[i]&&(t.bl=n()),ri.exports=t,ri.exports}function eo(){return Qn()}var to={getArmsLogger:eo};const js="https://arms-retcode.aliyuncs.com/r.png?",zs="https://arms-retcode-sg.aliyuncs.com/r.png?",Ws="https://retcode-us-west-1.arms.aliyuncs.com/r.png?",$s="e1iftji1w7@7ec1cef2cc88733",Ks="e1iftji1w7@10a06d1ec260adc",qs="e1iftji1w7@10a06d1ec260adc",Qi={cn:{reportUrl:js,pid:$s},"cn-hangzhou":{reportUrl:js,pid:$s},sg:{reportUrl:zs,pid:Ks},"ap-southeast-1":{reportUrl:zs,pid:Ks},usw:{reportUrl:Ws,pid:qs},"us-west-1":{reportUrl:Ws,pid:qs}},io=r=>r!==null&&typeof r=="object",ro=r=>Object.prototype.toString.call(r).slice(8,-1),so=r=>Object.isExtensible(r)?ro(r)==="Object":!1;function ao(r,n,e){var a;if(Reflect.get(r,"__v_skip")===!0)return r;const t=[],i=typeof Object.getOwnPropertyDescriptors=="function"?Object.getOwnPropertyDescriptors((a=Object.getPrototypeOf(r))!=null?a:{}):{};for(const c of Object.keys(i))i[c].get&&t.push(c);const s={MediaboxWrapperObjectGetter(c,o){if(typeof o=="string"&&t.indexOf(o)>-1){let u;try{u=c[o]}catch(h){throw e(h),h}return ft(u,n,e)}return n>10?c[o]:ft(c[o],n,e)},MediaboxWrapperObjectSetter(c,o,u){return c[o]=ft(u,n,e),!0}};return Object.defineProperty(r,"__v_skip",{configurable:!0,enumerable:!1,writable:!1,value:!0}),new Proxy(r,{get:s.MediaboxWrapperObjectGetter,set:s.MediaboxWrapperObjectSetter})}function no(r,n,e){const t={MediaboxWrapperFunctionApply(i,s,a){let c;try{c=Reflect.apply(i,s,a)}catch(o){throw e(o),o}return ft(c,n,e)},MediaboxWrapperFunctionGet(i,s){const a=Object.getOwnPropertyDescriptor(i,s);return a&&!a.writable&&!a.configurable?i[s]:ft(i[s],n,e)},MediaboxWrapperClassConstructor(i,s){let a;try{a=new i(...s)}catch(c){throw e(c),c}return ft(a,n,e)}};return new Proxy(r,{apply:t.MediaboxWrapperFunctionApply,get:t.MediaboxWrapperFunctionGet,construct:t.MediaboxWrapperClassConstructor})}function oo(r,n){if(typeof r!="string")return n;if(Js(r,n))return r;const e=r.indexOf(`
|
|
5
5
|
`);return e<0?`${r}${n}`:`${r.slice(0,e)}${n}${r.slice(e)}`}function Js(r,n){if(typeof r!="string")return!1;const e=r.indexOf(n);if(e<0)return!1;const t=r.indexOf(`
|
|
6
|
-
`);return t<0?!0:e<t}function ft(r,n,e){return typeof r=="function"?no(r,n+1,e):r instanceof Promise?r.then(t=>ft(t,n+1,e)).catch(t=>(e(t),Promise.reject(t))):Array.isArray(r)?(r.forEach((t,i)=>{r[i]=ft(t,n+1,e)}),r):io(r)&&so(r)?ao(r,n+1,e):r}function co(r){return typeof r!="string"?!1:r.indexOf("g.alicdn.com/apsara-media-")>-1||r.indexOf("g.alicdn.com/thor-server")>-1}function Gs(r){return typeof r!="string"?!1:r.indexOf("g.alicdn.com/apsara-media-")>-1||r.indexOf("g.alicdn.com/thor-server")>-1||r.indexOf("MediaboxWrapper")>-1}class Xs extends Error{constructor(n){super(n),this.name="MQTError"}}let uo=1;class er{constructor(n){var e,t;lt(this,"armsLogger"),lt(this,"isReady",!1),lt(this,"isDestroyed",!1),lt(this,"options"),lt(this,"queue",[]),lt(this,"marker"),lt(this,"helper",{MediaboxWrapperQueue(i){return new Xs(i)},MediaboxWrapperInitiative(i){return new Xs(i)}}),this.options=vt(
|
|
6
|
+
`);return t<0?!0:e<t}function ft(r,n,e){return typeof r=="function"?no(r,n+1,e):r instanceof Promise?r.then(t=>ft(t,n+1,e)).catch(t=>(e(t),Promise.reject(t))):Array.isArray(r)?(r.forEach((t,i)=>{r[i]=ft(t,n+1,e)}),r):io(r)&&so(r)?ao(r,n+1,e):r}function co(r){return typeof r!="string"?!1:r.indexOf("g.alicdn.com/apsara-media-")>-1||r.indexOf("g.alicdn.com/thor-server")>-1}function Gs(r){return typeof r!="string"?!1:r.indexOf("g.alicdn.com/apsara-media-")>-1||r.indexOf("g.alicdn.com/thor-server")>-1||r.indexOf("MediaboxWrapper")>-1}class Xs extends Error{constructor(n){super(n),this.name="MQTError"}}let uo=1;class er{constructor(n){var e,t;lt(this,"armsLogger"),lt(this,"isReady",!1),lt(this,"isDestroyed",!1),lt(this,"options"),lt(this,"queue",[]),lt(this,"marker"),lt(this,"helper",{MediaboxWrapperQueue(i){return new Xs(i)},MediaboxWrapperInitiative(i){return new Xs(i)}}),this.options=vt(X({},n),{region:n.deferRegionSet?void 0:(e=n.region)!=null?e:"cn",env:(t=n.env)!=null?t:"prod"}),this.marker=`-${uo++}-`,this.initArmsLogger()}static get version(){return"0.23.0"}initArmsLogger(n){const{region:e,env:t,disabled:i}=this.options;if(i||this.armsLogger)return;if(n&&!e)throw new Error("region is required");if(!e)return;if(!Qi[e])throw new Error(`region ${e} is not supported`);const s=c=>{var o;if(this.isDestroyed||Js(c.stack,this.marker)||c.t!=="pv"&&c.t!=="error")return!1;if(c.c1=(o=this.options.cid)!=null?o:window.location.host,c.c2=er.version,this.options.customData&&(c.c3=new URLSearchParams(this.options.customData).toString()),c.t==="error"){if(co(c.file)||Gs(c.stack)){let u=c;return this.options.beforeSend&&(u=this.options.beforeSend(c)),this.isReady?u:(u&&this.queue.push(u),!1)}return!1}return c},a=to.getArmsLogger();this.armsLogger=a.createExtraInstance({enableInstanceAutoSend:!0,pid:Qi[e].pid,tag:this.options.businessName,release:`${this.options.businessName}_${this.options.version}`,imgUrl:Qi[e].reportUrl,behavior:!0,sample:1,disableHook:!0,environment:t,beforeReport:s})}wrap(n){return this.options.disabled||typeof Proxy>"u"?n:ft(n,0,e=>{var t;e instanceof Error&&typeof e.stack=="string"&&Gs(e.stack)&&((t=this.armsLogger)==null||t.error(e),e.stack=oo(e.stack,this.marker))})}updateOptions(n){this.options=X(X({},this.options),n)}setReady(){this.initArmsLogger(!0),this.isReady=!0,this.queue.length&&this.queue.forEach(n=>{var e;(e=this.armsLogger)==null||e.error(this.helper.MediaboxWrapperQueue(n.msg),{filename:n.file,lineno:n.line,colno:n.col})})}report(n,e){var t;(t=this.armsLogger)==null||t.error(this.helper.MediaboxWrapperInitiative(n),e)}destroy(){this.isDestroyed=!0}}for(var he=(r=>(r.PullStreamStats="remoteStat",r.RtsSubscribeExceeds="rtsSubscribeExceeds",r.UserJoined="userJoined",r.UserLeft="userLeft",r.Bye="bye",r.MuteAudio="muteAudio",r.UnmuteAudio="unmuteAudio",r.MuteVideo="muteVideo",r.UnmuteVideo="unmuteVideo",r.MuteScreen="muteScreen",r.UnmuteScreen="unmuteScreen",r.Error="error",r))(he||{}),Ne=(r=>(r.Local="local-device-status-change",r.Remote="remote-device-status-change",r))(Ne||{}),D=(r=>(r.Audio="sophon_audio",r.VideoLarge="sophon_video_camera_large",r.VideoSmall="sophon_video_camera_small",r.Screen="sophon_video_screen_share",r.Data="sophon_data",r))(D||{}),tr=(r=>(r.Audio="rts audio",r.VideoLarge="rts video",r))(tr||{}),bt=(r=>(r.Add="add",r.Delete="delete",r.Replace="replace",r.Stop="stop",r.UnPublish="unpublish",r))(bt||{}),Gt=(r=>(r[r.Camera=0]="Camera",r[r.Screen=1]="Screen",r[r.Image=2]="Image",r))(Gt||{}),bi=(r=>(r[r.Microphone=0]="Microphone",r[r.Screen=1]="Screen",r[r.Mixed=2]="Mixed",r))(bi||{}),pe=(r=>(r.InRoom="inRoom",r.Join="join",r.Publish="publish",r.User="user",r.Resume="resume",r.Retry="retry",r.Reconnect="reconnect",r))(pe||{}),ct=(r=>(r[r.MANUAL=0]="MANUAL",r[r.JOIN_CHANNEL=1]="JOIN_CHANNEL",r[r.ROLE_CHANGE=2]="ROLE_CHANGE",r[r.RECONNECT=3]="RECONNECT",r))(ct||{}),Te=[],ir=0;ir<256;++ir)Te.push((ir+256).toString(16).slice(1));function ho(r,n=0){return(Te[r[n+0]]+Te[r[n+1]]+Te[r[n+2]]+Te[r[n+3]]+"-"+Te[r[n+4]]+Te[r[n+5]]+"-"+Te[r[n+6]]+Te[r[n+7]]+"-"+Te[r[n+8]]+Te[r[n+9]]+"-"+Te[r[n+10]]+Te[r[n+11]]+Te[r[n+12]]+Te[r[n+13]]+Te[r[n+14]]+Te[r[n+15]]).toLowerCase()}var Ei,lo=new Uint8Array(16);function fo(){if(!Ei&&(Ei=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ei))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ei(lo)}var po=typeof crypto!="undefined"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Ys={randomUUID:po};function it(r,n,e){if(Ys.randomUUID&&!n&&!r)return Ys.randomUUID();r=r||{};var t=r.random||(r.rng||fo)();if(t[6]=t[6]&15|64,t[8]=t[8]&63|128,n){e=e||0;for(var i=0;i<16;++i)n[e+i]=t[i];return n}return ho(t)}var Ai=(r=>(r.prod="rs.rtn.aliyuncs.com",r.pre="prs.rtn.aliyuncs.com",r))(Ai||{});const _i="6.14.4",Zs="web";class Oe{static getVersionNumber(){let n=_i.split("."),e="";return n.forEach(t=>{t.length===1?e+="0"+t:e+=t}),parseInt(e)}static queryingParam(n){let e=[];if(n)for(let t in n)e.push(t+"="+n[t]);return e.join("&")}static getQueryParams(n){const t=window.location.search.substring(1).split("&");for(let i=0;i<t.length;i++){const s=t[i].split("=");if(decodeURIComponent(s[0])===n)return decodeURIComponent(s[1])}}static createCallid(n=""){const e=it();return n&&e&&e.length>n.length?`${n}${e.substring(n.length)}`:e}static checkSubOptionsValid(n){if(n){const{audio:e,video:t,screen:i}=n;if(e===!1&&t===!1&&i===!1)return!1}return!0}static isNetworkAvailable(){return w(this,null,function*(){const n=Ai.prod,{onLine:e}=navigator;if(!e)return!1;try{return yield fetch(`https://${n}/roomserver/v1/ws/version`),!0}catch(t){return!1}})}static toString(n){let e;if(n instanceof Error)e=n.message;else if(typeof n=="string")e=n;else try{e=JSON.stringify(n)}catch(t){e="undefined"}return e}static paramArrayToString(n){let e="";for(let t=0;t<n.length;t++){e!==""&&(e+=" ");let i=Oe.toString(n[t]);e+=i}return e}}function Qs(r,n,e){Object.defineProperty(r,n,{writable:!0,enumerable:!0,configurable:!0,value:e})}function ea(r,n,e,t){t?t(()=>{Qs(r,n,e)}):Qs(r,n,e)}Array(32);class go{constructor(n){this.timer=null,this.time=10,this.count=10,this.arr=[];var e,t;this.time=(e=n.time)!=null?e:10,this.count=(t=n.count)!=null?t:10,n.host.startsWith("http://")||n.host.startsWith("https://")?this.url=n.host+"/logstores/"+n.logstore+"/track":this.url="https://"+n.project+"."+n.host+"/logstores/"+n.logstore+"/track",this.opt=n,n.installUnloadHook&&typeof n.installUnloadHook=="function"&&n.installUnloadHook(()=>{this.sendImmediateInner()})}assemblePayload(n){const e={__logs__:n};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 n=this.assemblePayload(this.arr);this.opt.sendPayload(this.url,n)}}transString(n){let e={};for(let t in n)typeof n[t]=="object"?e[t]=JSON.stringify(n[t]):e[t]=String(n[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 n=this;this.arr.length>=this.count||this.time<=0?this.sendImmediateInner():this.timer=setTimeout(function(){n.sendImmediateInner()},this.time*1e3)}}send(n){const e=this.transString(n);this.arr.push(e),this.sendInner()}sendImmediate(n){const e=this.transString(n);this.arr.push(e),this.sendImmediateInner()}sendBatchLogs(n){const e=n.map(t=>this.transString(t));this.arr.push(...e),this.sendInner()}sendBatchLogsImmediate(n){const e=n.map(t=>this.transString(t));this.arr.push(...e),this.sendImmediateInner()}overwriteTransString(n){this.transString=n.transString}getOpt(){return this.opt}}var mo=(r,n,e)=>new Promise((t,i)=>{var s=o=>{try{c(e.next(o))}catch(u){i(u)}},a=o=>{try{c(e.throw(o))}catch(u){i(u)}},c=o=>o.done?t(o.value):Promise.resolve(o.value).then(s,a);c((e=e.apply(r,n)).next())});function So(r,n){return navigator&&navigator.sendBeacon?navigator.sendBeacon(`${r}?APIVersion=0.6.0`,n):!1}function ta(r,n){const e=new window.XMLHttpRequest;e.open("POST",`${r}?APIVersion=0.6.0`,!0),e.send(n)}function xo(r,n){try{if(n.length>=32768){ta(r,n);return}So(r,n)||ta(r,n)}catch(e){window&&window.console&&typeof window.console.error=="function"&&(console.error(`Failed to log to ali log service because of this exception:
|
|
7
7
|
`+e),console.error("Failed log data:",r))}}function vo(r,n,e){return mo(this,null,function*(){try{r=r.slice(0,-6);const{data:t,header:i}=yield e.process(r,n),s=new window.XMLHttpRequest;s.open("POST",r,!0);for(let a in i)s.setRequestHeader(a,i[a]);s.send(t)}catch(t){window&&window.console&&typeof window.console.error=="function"&&(console.error(`Failed to log to ali log service because of this exception:
|
|
8
|
-
`+t),console.error("Failed log data:",r))}})}class rr extends go{constructor(n){const e=Object.assign({},n,{installUnloadHook:t=>{window.addEventListener("beforeunload",()=>{t()})},sendPayload:(t,i)=>{xo(t,i)}});super(e)}useStsPlugin(n){this.getOpt().sendPayload=(e,t)=>{vo(e,t,n)},this.overwriteTransString(n)}}ea(window,"SLS_Tracker",rr);var ae=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function bo(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Eo(r){if(r.__esModule)return r;var n=r.default;if(typeof n=="function"){var e=function t(){return this instanceof t?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};e.prototype=n.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(t){var i=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:function(){return r[t]}})}),e}var ia={exports:{}};function Ao(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var sr={exports:{}};const _o=Eo(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ra;function ce(){return ra||(ra=1,function(r,n){(function(e,t){r.exports=t()})(ae,function(){var e=e||function(t,i){var s;if(typeof window!="undefined"&&window.crypto&&(s=window.crypto),typeof self!="undefined"&&self.crypto&&(s=self.crypto),typeof globalThis!="undefined"&&globalThis.crypto&&(s=globalThis.crypto),!s&&typeof window!="undefined"&&window.msCrypto&&(s=window.msCrypto),!s&&typeof ae!="undefined"&&ae.crypto&&(s=ae.crypto),!s&&typeof Ao=="function")try{s=_o}catch(x){}var a=function(){if(s){if(typeof s.getRandomValues=="function")try{return s.getRandomValues(new Uint32Array(1))[0]}catch(x){}if(typeof s.randomBytes=="function")try{return s.randomBytes(4).readInt32LE()}catch(x){}}throw new Error("Native crypto module could not be used to get secure random number.")},c=Object.create||function(){function x(){}return function(b){var E;return x.prototype=b,E=new x,x.prototype=null,E}}(),o={},u=o.lib={},h=u.Base=function(){return{extend:function(x){var b=c(this);return x&&b.mixIn(x),(!b.hasOwnProperty("init")||this.init===b.init)&&(b.init=function(){b.$super.init.apply(this,arguments)}),b.init.prototype=b,b.$super=this,b},create:function(){var x=this.extend();return x.init.apply(x,arguments),x},init:function(){},mixIn:function(x){for(var b in x)x.hasOwnProperty(b)&&(this[b]=x[b]);x.hasOwnProperty("toString")&&(this.toString=x.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),p=u.WordArray=h.extend({init:function(x,b){x=this.words=x||[],b!=i?this.sigBytes=b:this.sigBytes=x.length*4},toString:function(x){return(x||f).stringify(this)},concat:function(x){var b=this.words,E=x.words,A=this.sigBytes,y=x.sigBytes;if(this.clamp(),A%4)for(var _=0;_<y;_++){var R=E[_>>>2]>>>24-_%4*8&255;b[A+_>>>2]|=R<<24-(A+_)%4*8}else for(var L=0;L<y;L+=4)b[A+L>>>2]=E[L>>>2];return this.sigBytes+=y,this},clamp:function(){var x=this.words,b=this.sigBytes;x[b>>>2]&=4294967295<<32-b%4*8,x.length=t.ceil(b/4)},clone:function(){var x=h.clone.call(this);return x.words=this.words.slice(0),x},random:function(x){for(var b=[],E=0;E<x;E+=4)b.push(a());return new p.init(b,x)}}),d=o.enc={},f=d.Hex={stringify:function(x){for(var b=x.words,E=x.sigBytes,A=[],y=0;y<E;y++){var _=b[y>>>2]>>>24-y%4*8&255;A.push((_>>>4).toString(16)),A.push((_&15).toString(16))}return A.join("")},parse:function(x){for(var b=x.length,E=[],A=0;A<b;A+=2)E[A>>>3]|=parseInt(x.substr(A,2),16)<<24-A%8*4;return new p.init(E,b/2)}},m=d.Latin1={stringify:function(x){for(var b=x.words,E=x.sigBytes,A=[],y=0;y<E;y++){var _=b[y>>>2]>>>24-y%4*8&255;A.push(String.fromCharCode(_))}return A.join("")},parse:function(x){for(var b=x.length,E=[],A=0;A<b;A++)E[A>>>2]|=(x.charCodeAt(A)&255)<<24-A%4*8;return new p.init(E,b)}},l=d.Utf8={stringify:function(x){try{return decodeURIComponent(escape(m.stringify(x)))}catch(b){throw new Error("Malformed UTF-8 data")}},parse:function(x){return m.parse(unescape(encodeURIComponent(x)))}},S=u.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new p.init,this._nDataBytes=0},_append:function(x){typeof x=="string"&&(x=l.parse(x)),this._data.concat(x),this._nDataBytes+=x.sigBytes},_process:function(x){var b,E=this._data,A=E.words,y=E.sigBytes,_=this.blockSize,R=_*4,L=y/R;x?L=t.ceil(L):L=t.max((L|0)-this._minBufferSize,0);var C=L*_,I=t.min(C*4,y);if(C){for(var P=0;P<C;P+=_)this._doProcessBlock(A,P);b=A.splice(0,C),E.sigBytes-=I}return new p.init(b,I)},clone:function(){var x=h.clone.call(this);return x._data=this._data.clone(),x},_minBufferSize:0});u.Hasher=S.extend({cfg:h.extend(),init:function(x){this.cfg=this.cfg.extend(x),this.reset()},reset:function(){S.reset.call(this),this._doReset()},update:function(x){return this._append(x),this._process(),this},finalize:function(x){x&&this._append(x);var b=this._doFinalize();return b},blockSize:16,_createHelper:function(x){return function(b,E){return new x.init(E).finalize(b)}},_createHmacHelper:function(x){return function(b,E){return new v.HMAC.init(x,E).finalize(b)}}});var v=o.algo={};return o}(Math);return e})}(sr)),sr.exports}var ar={exports:{}},sa;function yi(){return sa||(sa=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(t){var i=e,s=i.lib,a=s.Base,c=s.WordArray,o=i.x64={};o.Word=a.extend({init:function(u,h){this.high=u,this.low=h}}),o.WordArray=a.extend({init:function(u,h){u=this.words=u||[],h!=t?this.sigBytes=h:this.sigBytes=u.length*8},toX32:function(){for(var u=this.words,h=u.length,p=[],d=0;d<h;d++){var f=u[d];p.push(f.high),p.push(f.low)}return c.create(p,this.sigBytes)},clone:function(){for(var u=a.clone.call(this),h=u.words=this.words.slice(0),p=h.length,d=0;d<p;d++)h[d]=h[d].clone();return u}})}(),e})}(ar)),ar.exports}var nr={exports:{}},aa;function yo(){return aa||(aa=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(){if(typeof ArrayBuffer=="function"){var t=e,i=t.lib,s=i.WordArray,a=s.init,c=s.init=function(o){if(o instanceof ArrayBuffer&&(o=new Uint8Array(o)),(o instanceof Int8Array||typeof Uint8ClampedArray!="undefined"&&o instanceof Uint8ClampedArray||o instanceof Int16Array||o instanceof Uint16Array||o instanceof Int32Array||o instanceof Uint32Array||o instanceof Float32Array||o instanceof Float64Array)&&(o=new Uint8Array(o.buffer,o.byteOffset,o.byteLength)),o instanceof Uint8Array){for(var u=o.byteLength,h=[],p=0;p<u;p++)h[p>>>2]|=o[p]<<24-p%4*8;a.call(this,h,u)}else a.apply(this,arguments)};c.prototype=s}}(),e.lib.WordArray})}(nr)),nr.exports}var or={exports:{}},na;function Co(){return na||(na=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.WordArray,a=t.enc;a.Utf16=a.Utf16BE={stringify:function(o){for(var u=o.words,h=o.sigBytes,p=[],d=0;d<h;d+=2){var f=u[d>>>2]>>>16-d%4*8&65535;p.push(String.fromCharCode(f))}return p.join("")},parse:function(o){for(var u=o.length,h=[],p=0;p<u;p++)h[p>>>1]|=o.charCodeAt(p)<<16-p%2*16;return s.create(h,u*2)}},a.Utf16LE={stringify:function(o){for(var u=o.words,h=o.sigBytes,p=[],d=0;d<h;d+=2){var f=c(u[d>>>2]>>>16-d%4*8&65535);p.push(String.fromCharCode(f))}return p.join("")},parse:function(o){for(var u=o.length,h=[],p=0;p<u;p++)h[p>>>1]|=c(o.charCodeAt(p)<<16-p%2*16);return s.create(h,u*2)}};function c(o){return o<<8&4278255360|o>>>8&16711935}}(),e.enc.Utf16})}(or)),or.exports}var cr={exports:{}},oa;function Pt(){return oa||(oa=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.WordArray,a=t.enc;a.Base64={stringify:function(o){var u=o.words,h=o.sigBytes,p=this._map;o.clamp();for(var d=[],f=0;f<h;f+=3)for(var m=u[f>>>2]>>>24-f%4*8&255,l=u[f+1>>>2]>>>24-(f+1)%4*8&255,S=u[f+2>>>2]>>>24-(f+2)%4*8&255,v=m<<16|l<<8|S,x=0;x<4&&f+x*.75<h;x++)d.push(p.charAt(v>>>6*(3-x)&63));var b=p.charAt(64);if(b)for(;d.length%4;)d.push(b);return d.join("")},parse:function(o){var u=o.length,h=this._map,p=this._reverseMap;if(!p){p=this._reverseMap=[];for(var d=0;d<h.length;d++)p[h.charCodeAt(d)]=d}var f=h.charAt(64);if(f){var m=o.indexOf(f);m!==-1&&(u=m)}return c(o,u,p)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function c(o,u,h){for(var p=[],d=0,f=0;f<u;f++)if(f%4){var m=h[o.charCodeAt(f-1)]<<f%4*2,l=h[o.charCodeAt(f)]>>>6-f%4*2,S=m|l;p[d>>>2]|=S<<24-d%4*8,d++}return s.create(p,d)}}(),e.enc.Base64})}(cr)),cr.exports}var ur={exports:{}},ca;function Ro(){return ca||(ca=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.WordArray,a=t.enc;a.Base64url={stringify:function(o,u){u===void 0&&(u=!0);var h=o.words,p=o.sigBytes,d=u?this._safe_map:this._map;o.clamp();for(var f=[],m=0;m<p;m+=3)for(var l=h[m>>>2]>>>24-m%4*8&255,S=h[m+1>>>2]>>>24-(m+1)%4*8&255,v=h[m+2>>>2]>>>24-(m+2)%4*8&255,x=l<<16|S<<8|v,b=0;b<4&&m+b*.75<p;b++)f.push(d.charAt(x>>>6*(3-b)&63));var E=d.charAt(64);if(E)for(;f.length%4;)f.push(E);return f.join("")},parse:function(o,u){u===void 0&&(u=!0);var h=o.length,p=u?this._safe_map:this._map,d=this._reverseMap;if(!d){d=this._reverseMap=[];for(var f=0;f<p.length;f++)d[p.charCodeAt(f)]=f}var m=p.charAt(64);if(m){var l=o.indexOf(m);l!==-1&&(h=l)}return c(o,h,d)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function c(o,u,h){for(var p=[],d=0,f=0;f<u;f++)if(f%4){var m=h[o.charCodeAt(f-1)]<<f%4*2,l=h[o.charCodeAt(f)]>>>6-f%4*2,S=m|l;p[d>>>2]|=S<<24-d%4*8,d++}return s.create(p,d)}}(),e.enc.Base64url})}(ur)),ur.exports}var hr={exports:{}},ua;function kt(){return ua||(ua=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(t){var i=e,s=i.lib,a=s.WordArray,c=s.Hasher,o=i.algo,u=[];(function(){for(var l=0;l<64;l++)u[l]=t.abs(t.sin(l+1))*4294967296|0})();var h=o.MD5=c.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(l,S){for(var v=0;v<16;v++){var x=S+v,b=l[x];l[x]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360}var E=this._hash.words,A=l[S+0],y=l[S+1],_=l[S+2],R=l[S+3],L=l[S+4],C=l[S+5],I=l[S+6],P=l[S+7],B=l[S+8],K=l[S+9],J=l[S+10],Q=l[S+11],ue=l[S+12],te=l[S+13],se=l[S+14],ie=l[S+15],k=E[0],M=E[1],F=E[2],N=E[3];k=p(k,M,F,N,A,7,u[0]),N=p(N,k,M,F,y,12,u[1]),F=p(F,N,k,M,_,17,u[2]),M=p(M,F,N,k,R,22,u[3]),k=p(k,M,F,N,L,7,u[4]),N=p(N,k,M,F,C,12,u[5]),F=p(F,N,k,M,I,17,u[6]),M=p(M,F,N,k,P,22,u[7]),k=p(k,M,F,N,B,7,u[8]),N=p(N,k,M,F,K,12,u[9]),F=p(F,N,k,M,J,17,u[10]),M=p(M,F,N,k,Q,22,u[11]),k=p(k,M,F,N,ue,7,u[12]),N=p(N,k,M,F,te,12,u[13]),F=p(F,N,k,M,se,17,u[14]),M=p(M,F,N,k,ie,22,u[15]),k=d(k,M,F,N,y,5,u[16]),N=d(N,k,M,F,I,9,u[17]),F=d(F,N,k,M,Q,14,u[18]),M=d(M,F,N,k,A,20,u[19]),k=d(k,M,F,N,C,5,u[20]),N=d(N,k,M,F,J,9,u[21]),F=d(F,N,k,M,ie,14,u[22]),M=d(M,F,N,k,L,20,u[23]),k=d(k,M,F,N,K,5,u[24]),N=d(N,k,M,F,se,9,u[25]),F=d(F,N,k,M,R,14,u[26]),M=d(M,F,N,k,B,20,u[27]),k=d(k,M,F,N,te,5,u[28]),N=d(N,k,M,F,_,9,u[29]),F=d(F,N,k,M,P,14,u[30]),M=d(M,F,N,k,ue,20,u[31]),k=f(k,M,F,N,C,4,u[32]),N=f(N,k,M,F,B,11,u[33]),F=f(F,N,k,M,Q,16,u[34]),M=f(M,F,N,k,se,23,u[35]),k=f(k,M,F,N,y,4,u[36]),N=f(N,k,M,F,L,11,u[37]),F=f(F,N,k,M,P,16,u[38]),M=f(M,F,N,k,J,23,u[39]),k=f(k,M,F,N,te,4,u[40]),N=f(N,k,M,F,A,11,u[41]),F=f(F,N,k,M,R,16,u[42]),M=f(M,F,N,k,I,23,u[43]),k=f(k,M,F,N,K,4,u[44]),N=f(N,k,M,F,ue,11,u[45]),F=f(F,N,k,M,ie,16,u[46]),M=f(M,F,N,k,_,23,u[47]),k=m(k,M,F,N,A,6,u[48]),N=m(N,k,M,F,P,10,u[49]),F=m(F,N,k,M,se,15,u[50]),M=m(M,F,N,k,C,21,u[51]),k=m(k,M,F,N,ue,6,u[52]),N=m(N,k,M,F,R,10,u[53]),F=m(F,N,k,M,J,15,u[54]),M=m(M,F,N,k,y,21,u[55]),k=m(k,M,F,N,B,6,u[56]),N=m(N,k,M,F,ie,10,u[57]),F=m(F,N,k,M,I,15,u[58]),M=m(M,F,N,k,te,21,u[59]),k=m(k,M,F,N,L,6,u[60]),N=m(N,k,M,F,Q,10,u[61]),F=m(F,N,k,M,_,15,u[62]),M=m(M,F,N,k,K,21,u[63]),E[0]=E[0]+k|0,E[1]=E[1]+M|0,E[2]=E[2]+F|0,E[3]=E[3]+N|0},_doFinalize:function(){var l=this._data,S=l.words,v=this._nDataBytes*8,x=l.sigBytes*8;S[x>>>5]|=128<<24-x%32;var b=t.floor(v/4294967296),E=v;S[(x+64>>>9<<4)+15]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360,S[(x+64>>>9<<4)+14]=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,l.sigBytes=(S.length+1)*4,this._process();for(var A=this._hash,y=A.words,_=0;_<4;_++){var R=y[_];y[_]=(R<<8|R>>>24)&16711935|(R<<24|R>>>8)&4278255360}return A},clone:function(){var l=c.clone.call(this);return l._hash=this._hash.clone(),l}});function p(l,S,v,x,b,E,A){var y=l+(S&v|~S&x)+b+A;return(y<<E|y>>>32-E)+S}function d(l,S,v,x,b,E,A){var y=l+(S&x|v&~x)+b+A;return(y<<E|y>>>32-E)+S}function f(l,S,v,x,b,E,A){var y=l+(S^v^x)+b+A;return(y<<E|y>>>32-E)+S}function m(l,S,v,x,b,E,A){var y=l+(v^(S|~x))+b+A;return(y<<E|y>>>32-E)+S}i.MD5=c._createHelper(h),i.HmacMD5=c._createHmacHelper(h)}(Math),e.MD5})}(hr)),hr.exports}var dr={exports:{}},ha;function da(){return ha||(ha=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.WordArray,a=i.Hasher,c=t.algo,o=[],u=c.SHA1=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(h,p){for(var d=this._hash.words,f=d[0],m=d[1],l=d[2],S=d[3],v=d[4],x=0;x<80;x++){if(x<16)o[x]=h[p+x]|0;else{var b=o[x-3]^o[x-8]^o[x-14]^o[x-16];o[x]=b<<1|b>>>31}var E=(f<<5|f>>>27)+v+o[x];x<20?E+=(m&l|~m&S)+1518500249:x<40?E+=(m^l^S)+1859775393:x<60?E+=(m&l|m&S|l&S)-1894007588:E+=(m^l^S)-899497514,v=S,S=l,l=m<<30|m>>>2,m=f,f=E}d[0]=d[0]+f|0,d[1]=d[1]+m|0,d[2]=d[2]+l|0,d[3]=d[3]+S|0,d[4]=d[4]+v|0},_doFinalize:function(){var h=this._data,p=h.words,d=this._nDataBytes*8,f=h.sigBytes*8;return p[f>>>5]|=128<<24-f%32,p[(f+64>>>9<<4)+14]=Math.floor(d/4294967296),p[(f+64>>>9<<4)+15]=d,h.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var h=a.clone.call(this);return h._hash=this._hash.clone(),h}});t.SHA1=a._createHelper(u),t.HmacSHA1=a._createHmacHelper(u)}(),e.SHA1})}(dr)),dr.exports}var lr={exports:{}},la;function fr(){return la||(la=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(t){var i=e,s=i.lib,a=s.WordArray,c=s.Hasher,o=i.algo,u=[],h=[];(function(){function f(v){for(var x=t.sqrt(v),b=2;b<=x;b++)if(!(v%b))return!1;return!0}function m(v){return(v-(v|0))*4294967296|0}for(var l=2,S=0;S<64;)f(l)&&(S<8&&(u[S]=m(t.pow(l,1/2))),h[S]=m(t.pow(l,1/3)),S++),l++})();var p=[],d=o.SHA256=c.extend({_doReset:function(){this._hash=new a.init(u.slice(0))},_doProcessBlock:function(f,m){for(var l=this._hash.words,S=l[0],v=l[1],x=l[2],b=l[3],E=l[4],A=l[5],y=l[6],_=l[7],R=0;R<64;R++){if(R<16)p[R]=f[m+R]|0;else{var L=p[R-15],C=(L<<25|L>>>7)^(L<<14|L>>>18)^L>>>3,I=p[R-2],P=(I<<15|I>>>17)^(I<<13|I>>>19)^I>>>10;p[R]=C+p[R-7]+P+p[R-16]}var B=E&A^~E&y,K=S&v^S&x^v&x,J=(S<<30|S>>>2)^(S<<19|S>>>13)^(S<<10|S>>>22),Q=(E<<26|E>>>6)^(E<<21|E>>>11)^(E<<7|E>>>25),ue=_+Q+B+h[R]+p[R],te=J+K;_=y,y=A,A=E,E=b+ue|0,b=x,x=v,v=S,S=ue+te|0}l[0]=l[0]+S|0,l[1]=l[1]+v|0,l[2]=l[2]+x|0,l[3]=l[3]+b|0,l[4]=l[4]+E|0,l[5]=l[5]+A|0,l[6]=l[6]+y|0,l[7]=l[7]+_|0},_doFinalize:function(){var f=this._data,m=f.words,l=this._nDataBytes*8,S=f.sigBytes*8;return m[S>>>5]|=128<<24-S%32,m[(S+64>>>9<<4)+14]=t.floor(l/4294967296),m[(S+64>>>9<<4)+15]=l,f.sigBytes=m.length*4,this._process(),this._hash},clone:function(){var f=c.clone.call(this);return f._hash=this._hash.clone(),f}});i.SHA256=c._createHelper(d),i.HmacSHA256=c._createHmacHelper(d)}(Math),e.SHA256})}(lr)),lr.exports}var pr={exports:{}},fa;function Io(){return fa||(fa=1,function(r,n){(function(e,t,i){r.exports=t(ce(),fr())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.WordArray,a=t.algo,c=a.SHA256,o=a.SHA224=c.extend({_doReset:function(){this._hash=new s.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var u=c._doFinalize.call(this);return u.sigBytes-=4,u}});t.SHA224=c._createHelper(o),t.HmacSHA224=c._createHmacHelper(o)}(),e.SHA224})}(pr)),pr.exports}var gr={exports:{}},pa;function ga(){return pa||(pa=1,function(r,n){(function(e,t,i){r.exports=t(ce(),yi())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.Hasher,a=t.x64,c=a.Word,o=a.WordArray,u=t.algo;function h(){return c.create.apply(c,arguments)}var p=[h(1116352408,3609767458),h(1899447441,602891725),h(3049323471,3964484399),h(3921009573,2173295548),h(961987163,4081628472),h(1508970993,3053834265),h(2453635748,2937671579),h(2870763221,3664609560),h(3624381080,2734883394),h(310598401,1164996542),h(607225278,1323610764),h(1426881987,3590304994),h(1925078388,4068182383),h(2162078206,991336113),h(2614888103,633803317),h(3248222580,3479774868),h(3835390401,2666613458),h(4022224774,944711139),h(264347078,2341262773),h(604807628,2007800933),h(770255983,1495990901),h(1249150122,1856431235),h(1555081692,3175218132),h(1996064986,2198950837),h(2554220882,3999719339),h(2821834349,766784016),h(2952996808,2566594879),h(3210313671,3203337956),h(3336571891,1034457026),h(3584528711,2466948901),h(113926993,3758326383),h(338241895,168717936),h(666307205,1188179964),h(773529912,1546045734),h(1294757372,1522805485),h(1396182291,2643833823),h(1695183700,2343527390),h(1986661051,1014477480),h(2177026350,1206759142),h(2456956037,344077627),h(2730485921,1290863460),h(2820302411,3158454273),h(3259730800,3505952657),h(3345764771,106217008),h(3516065817,3606008344),h(3600352804,1432725776),h(4094571909,1467031594),h(275423344,851169720),h(430227734,3100823752),h(506948616,1363258195),h(659060556,3750685593),h(883997877,3785050280),h(958139571,3318307427),h(1322822218,3812723403),h(1537002063,2003034995),h(1747873779,3602036899),h(1955562222,1575990012),h(2024104815,1125592928),h(2227730452,2716904306),h(2361852424,442776044),h(2428436474,593698344),h(2756734187,3733110249),h(3204031479,2999351573),h(3329325298,3815920427),h(3391569614,3928383900),h(3515267271,566280711),h(3940187606,3454069534),h(4118630271,4000239992),h(116418474,1914138554),h(174292421,2731055270),h(289380356,3203993006),h(460393269,320620315),h(685471733,587496836),h(852142971,1086792851),h(1017036298,365543100),h(1126000580,2618297676),h(1288033470,3409855158),h(1501505948,4234509866),h(1607167915,987167468),h(1816402316,1246189591)],d=[];(function(){for(var m=0;m<80;m++)d[m]=h()})();var f=u.SHA512=s.extend({_doReset:function(){this._hash=new o.init([new c.init(1779033703,4089235720),new c.init(3144134277,2227873595),new c.init(1013904242,4271175723),new c.init(2773480762,1595750129),new c.init(1359893119,2917565137),new c.init(2600822924,725511199),new c.init(528734635,4215389547),new c.init(1541459225,327033209)])},_doProcessBlock:function(m,l){for(var S=this._hash.words,v=S[0],x=S[1],b=S[2],E=S[3],A=S[4],y=S[5],_=S[6],R=S[7],L=v.high,C=v.low,I=x.high,P=x.low,B=b.high,K=b.low,J=E.high,Q=E.low,ue=A.high,te=A.low,se=y.high,ie=y.low,k=_.high,M=_.low,F=R.high,N=R.low,X=L,j=C,fe=I,ee=P,ze=B,Je=K,st=J,at=Q,ye=ue,Fe=te,St=se,zt=ie,ii=k,Wt=M,Si=F,$t=N,Ve=0;Ve<80;Ve++){var Pe,nt,Kt=d[Ve];if(Ve<16)nt=Kt.high=m[l+Ve*2]|0,Pe=Kt.low=m[l+Ve*2+1]|0;else{var It=d[Ve-15],ot=It.high,xt=It.low,vs=(ot>>>1|xt<<31)^(ot>>>8|xt<<24)^ot>>>7,Vi=(xt>>>1|ot<<31)^(xt>>>8|ot<<24)^(xt>>>7|ot<<25),Oi=d[Ve-2],Ge=Oi.high,wt=Oi.low,Ui=(Ge>>>19|wt<<13)^(Ge<<3|wt>>>29)^Ge>>>6,xi=(wt>>>19|Ge<<13)^(wt<<3|Ge>>>29)^(wt>>>6|Ge<<26),Tn=d[Ve-7],Pc=Tn.high,kc=Tn.low,Dn=d[Ve-16],Bc=Dn.high,Pn=Dn.low;Pe=Vi+kc,nt=vs+Pc+(Pe>>>0<Vi>>>0?1:0),Pe=Pe+xi,nt=nt+Ui+(Pe>>>0<xi>>>0?1:0),Pe=Pe+Pn,nt=nt+Bc+(Pe>>>0<Pn>>>0?1:0),Kt.high=nt,Kt.low=Pe}var Nc=ye&St^~ye&ii,kn=Fe&zt^~Fe&Wt,Lc=X&fe^X&ze^fe&ze,Mc=j&ee^j&Je^ee&Je,Fc=(X>>>28|j<<4)^(X<<30|j>>>2)^(X<<25|j>>>7),Bn=(j>>>28|X<<4)^(j<<30|X>>>2)^(j<<25|X>>>7),Vc=(ye>>>14|Fe<<18)^(ye>>>18|Fe<<14)^(ye<<23|Fe>>>9),Oc=(Fe>>>14|ye<<18)^(Fe>>>18|ye<<14)^(Fe<<23|ye>>>9),Nn=p[Ve],Uc=Nn.high,Ln=Nn.low,Xe=$t+Oc,Tt=Si+Vc+(Xe>>>0<$t>>>0?1:0),Xe=Xe+kn,Tt=Tt+Nc+(Xe>>>0<kn>>>0?1:0),Xe=Xe+Ln,Tt=Tt+Uc+(Xe>>>0<Ln>>>0?1:0),Xe=Xe+Pe,Tt=Tt+nt+(Xe>>>0<Pe>>>0?1:0),Mn=Bn+Mc,Hc=Fc+Lc+(Mn>>>0<Bn>>>0?1:0);Si=ii,$t=Wt,ii=St,Wt=zt,St=ye,zt=Fe,Fe=at+Xe|0,ye=st+Tt+(Fe>>>0<at>>>0?1:0)|0,st=ze,at=Je,ze=fe,Je=ee,fe=X,ee=j,j=Xe+Mn|0,X=Tt+Hc+(j>>>0<Xe>>>0?1:0)|0}C=v.low=C+j,v.high=L+X+(C>>>0<j>>>0?1:0),P=x.low=P+ee,x.high=I+fe+(P>>>0<ee>>>0?1:0),K=b.low=K+Je,b.high=B+ze+(K>>>0<Je>>>0?1:0),Q=E.low=Q+at,E.high=J+st+(Q>>>0<at>>>0?1:0),te=A.low=te+Fe,A.high=ue+ye+(te>>>0<Fe>>>0?1:0),ie=y.low=ie+zt,y.high=se+St+(ie>>>0<zt>>>0?1:0),M=_.low=M+Wt,_.high=k+ii+(M>>>0<Wt>>>0?1:0),N=R.low=N+$t,R.high=F+Si+(N>>>0<$t>>>0?1:0)},_doFinalize:function(){var m=this._data,l=m.words,S=this._nDataBytes*8,v=m.sigBytes*8;l[v>>>5]|=128<<24-v%32,l[(v+128>>>10<<5)+30]=Math.floor(S/4294967296),l[(v+128>>>10<<5)+31]=S,m.sigBytes=l.length*4,this._process();var x=this._hash.toX32();return x},clone:function(){var m=s.clone.call(this);return m._hash=this._hash.clone(),m},blockSize:1024/32});t.SHA512=s._createHelper(f),t.HmacSHA512=s._createHmacHelper(f)}(),e.SHA512})}(gr)),gr.exports}var mr={exports:{}},ma;function wo(){return ma||(ma=1,function(r,n){(function(e,t,i){r.exports=t(ce(),yi(),ga())})(ae,function(e){return function(){var t=e,i=t.x64,s=i.Word,a=i.WordArray,c=t.algo,o=c.SHA512,u=c.SHA384=o.extend({_doReset:function(){this._hash=new a.init([new s.init(3418070365,3238371032),new s.init(1654270250,914150663),new s.init(2438529370,812702999),new s.init(355462360,4144912697),new s.init(1731405415,4290775857),new s.init(2394180231,1750603025),new s.init(3675008525,1694076839),new s.init(1203062813,3204075428)])},_doFinalize:function(){var h=o._doFinalize.call(this);return h.sigBytes-=16,h}});t.SHA384=o._createHelper(u),t.HmacSHA384=o._createHmacHelper(u)}(),e.SHA384})}(mr)),mr.exports}var Sr={exports:{}},Sa;function To(){return Sa||(Sa=1,function(r,n){(function(e,t,i){r.exports=t(ce(),yi())})(ae,function(e){return function(t){var i=e,s=i.lib,a=s.WordArray,c=s.Hasher,o=i.x64,u=o.Word,h=i.algo,p=[],d=[],f=[];(function(){for(var S=1,v=0,x=0;x<24;x++){p[S+5*v]=(x+1)*(x+2)/2%64;var b=v%5,E=(2*S+3*v)%5;S=b,v=E}for(var S=0;S<5;S++)for(var v=0;v<5;v++)d[S+5*v]=v+(2*S+3*v)%5*5;for(var A=1,y=0;y<24;y++){for(var _=0,R=0,L=0;L<7;L++){if(A&1){var C=(1<<L)-1;C<32?R^=1<<C:_^=1<<C-32}A&128?A=A<<1^113:A<<=1}f[y]=u.create(_,R)}})();var m=[];(function(){for(var S=0;S<25;S++)m[S]=u.create()})();var l=h.SHA3=c.extend({cfg:c.cfg.extend({outputLength:512}),_doReset:function(){for(var S=this._state=[],v=0;v<25;v++)S[v]=new u.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(S,v){for(var x=this._state,b=this.blockSize/2,E=0;E<b;E++){var A=S[v+2*E],y=S[v+2*E+1];A=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360,y=(y<<8|y>>>24)&16711935|(y<<24|y>>>8)&4278255360;var _=x[E];_.high^=y,_.low^=A}for(var R=0;R<24;R++){for(var L=0;L<5;L++){for(var C=0,I=0,P=0;P<5;P++){var _=x[L+5*P];C^=_.high,I^=_.low}var B=m[L];B.high=C,B.low=I}for(var L=0;L<5;L++)for(var K=m[(L+4)%5],J=m[(L+1)%5],Q=J.high,ue=J.low,C=K.high^(Q<<1|ue>>>31),I=K.low^(ue<<1|Q>>>31),P=0;P<5;P++){var _=x[L+5*P];_.high^=C,_.low^=I}for(var te=1;te<25;te++){var C,I,_=x[te],se=_.high,ie=_.low,k=p[te];k<32?(C=se<<k|ie>>>32-k,I=ie<<k|se>>>32-k):(C=ie<<k-32|se>>>64-k,I=se<<k-32|ie>>>64-k);var M=m[d[te]];M.high=C,M.low=I}var F=m[0],N=x[0];F.high=N.high,F.low=N.low;for(var L=0;L<5;L++)for(var P=0;P<5;P++){var te=L+5*P,_=x[te],X=m[te],j=m[(L+1)%5+5*P],fe=m[(L+2)%5+5*P];_.high=X.high^~j.high&fe.high,_.low=X.low^~j.low&fe.low}var _=x[0],ee=f[R];_.high^=ee.high,_.low^=ee.low}},_doFinalize:function(){var S=this._data,v=S.words;this._nDataBytes*8;var x=S.sigBytes*8,b=this.blockSize*32;v[x>>>5]|=1<<24-x%32,v[(t.ceil((x+1)/b)*b>>>5)-1]|=128,S.sigBytes=v.length*4,this._process();for(var E=this._state,A=this.cfg.outputLength/8,y=A/8,_=[],R=0;R<y;R++){var L=E[R],C=L.high,I=L.low;C=(C<<8|C>>>24)&16711935|(C<<24|C>>>8)&4278255360,I=(I<<8|I>>>24)&16711935|(I<<24|I>>>8)&4278255360,_.push(I),_.push(C)}return new a.init(_,A)},clone:function(){for(var S=c.clone.call(this),v=S._state=this._state.slice(0),x=0;x<25;x++)v[x]=v[x].clone();return S}});i.SHA3=c._createHelper(l),i.HmacSHA3=c._createHmacHelper(l)}(Math),e.SHA3})}(Sr)),Sr.exports}var xr={exports:{}},xa;function Do(){return xa||(xa=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){/** @preserve
|
|
8
|
+
`+t),console.error("Failed log data:",r))}})}class rr extends go{constructor(n){const e=Object.assign({},n,{installUnloadHook:t=>{window.addEventListener("beforeunload",()=>{t()})},sendPayload:(t,i)=>{xo(t,i)}});super(e)}useStsPlugin(n){this.getOpt().sendPayload=(e,t)=>{vo(e,t,n)},this.overwriteTransString(n)}}ea(window,"SLS_Tracker",rr);var ae=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function bo(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Eo(r){if(r.__esModule)return r;var n=r.default;if(typeof n=="function"){var e=function t(){return this instanceof t?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};e.prototype=n.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(t){var i=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:function(){return r[t]}})}),e}var ia={exports:{}};function Ao(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var sr={exports:{}};const _o=Eo(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ra;function ce(){return ra||(ra=1,function(r,n){(function(e,t){r.exports=t()})(ae,function(){var e=e||function(t,i){var s;if(typeof window!="undefined"&&window.crypto&&(s=window.crypto),typeof self!="undefined"&&self.crypto&&(s=self.crypto),typeof globalThis!="undefined"&&globalThis.crypto&&(s=globalThis.crypto),!s&&typeof window!="undefined"&&window.msCrypto&&(s=window.msCrypto),!s&&typeof ae!="undefined"&&ae.crypto&&(s=ae.crypto),!s&&typeof Ao=="function")try{s=_o}catch(x){}var a=function(){if(s){if(typeof s.getRandomValues=="function")try{return s.getRandomValues(new Uint32Array(1))[0]}catch(x){}if(typeof s.randomBytes=="function")try{return s.randomBytes(4).readInt32LE()}catch(x){}}throw new Error("Native crypto module could not be used to get secure random number.")},c=Object.create||function(){function x(){}return function(b){var E;return x.prototype=b,E=new x,x.prototype=null,E}}(),o={},u=o.lib={},h=u.Base=function(){return{extend:function(x){var b=c(this);return x&&b.mixIn(x),(!b.hasOwnProperty("init")||this.init===b.init)&&(b.init=function(){b.$super.init.apply(this,arguments)}),b.init.prototype=b,b.$super=this,b},create:function(){var x=this.extend();return x.init.apply(x,arguments),x},init:function(){},mixIn:function(x){for(var b in x)x.hasOwnProperty(b)&&(this[b]=x[b]);x.hasOwnProperty("toString")&&(this.toString=x.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),p=u.WordArray=h.extend({init:function(x,b){x=this.words=x||[],b!=i?this.sigBytes=b:this.sigBytes=x.length*4},toString:function(x){return(x||f).stringify(this)},concat:function(x){var b=this.words,E=x.words,A=this.sigBytes,y=x.sigBytes;if(this.clamp(),A%4)for(var _=0;_<y;_++){var R=E[_>>>2]>>>24-_%4*8&255;b[A+_>>>2]|=R<<24-(A+_)%4*8}else for(var L=0;L<y;L+=4)b[A+L>>>2]=E[L>>>2];return this.sigBytes+=y,this},clamp:function(){var x=this.words,b=this.sigBytes;x[b>>>2]&=4294967295<<32-b%4*8,x.length=t.ceil(b/4)},clone:function(){var x=h.clone.call(this);return x.words=this.words.slice(0),x},random:function(x){for(var b=[],E=0;E<x;E+=4)b.push(a());return new p.init(b,x)}}),d=o.enc={},f=d.Hex={stringify:function(x){for(var b=x.words,E=x.sigBytes,A=[],y=0;y<E;y++){var _=b[y>>>2]>>>24-y%4*8&255;A.push((_>>>4).toString(16)),A.push((_&15).toString(16))}return A.join("")},parse:function(x){for(var b=x.length,E=[],A=0;A<b;A+=2)E[A>>>3]|=parseInt(x.substr(A,2),16)<<24-A%8*4;return new p.init(E,b/2)}},m=d.Latin1={stringify:function(x){for(var b=x.words,E=x.sigBytes,A=[],y=0;y<E;y++){var _=b[y>>>2]>>>24-y%4*8&255;A.push(String.fromCharCode(_))}return A.join("")},parse:function(x){for(var b=x.length,E=[],A=0;A<b;A++)E[A>>>2]|=(x.charCodeAt(A)&255)<<24-A%4*8;return new p.init(E,b)}},l=d.Utf8={stringify:function(x){try{return decodeURIComponent(escape(m.stringify(x)))}catch(b){throw new Error("Malformed UTF-8 data")}},parse:function(x){return m.parse(unescape(encodeURIComponent(x)))}},S=u.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new p.init,this._nDataBytes=0},_append:function(x){typeof x=="string"&&(x=l.parse(x)),this._data.concat(x),this._nDataBytes+=x.sigBytes},_process:function(x){var b,E=this._data,A=E.words,y=E.sigBytes,_=this.blockSize,R=_*4,L=y/R;x?L=t.ceil(L):L=t.max((L|0)-this._minBufferSize,0);var C=L*_,I=t.min(C*4,y);if(C){for(var P=0;P<C;P+=_)this._doProcessBlock(A,P);b=A.splice(0,C),E.sigBytes-=I}return new p.init(b,I)},clone:function(){var x=h.clone.call(this);return x._data=this._data.clone(),x},_minBufferSize:0});u.Hasher=S.extend({cfg:h.extend(),init:function(x){this.cfg=this.cfg.extend(x),this.reset()},reset:function(){S.reset.call(this),this._doReset()},update:function(x){return this._append(x),this._process(),this},finalize:function(x){x&&this._append(x);var b=this._doFinalize();return b},blockSize:16,_createHelper:function(x){return function(b,E){return new x.init(E).finalize(b)}},_createHmacHelper:function(x){return function(b,E){return new v.HMAC.init(x,E).finalize(b)}}});var v=o.algo={};return o}(Math);return e})}(sr)),sr.exports}var ar={exports:{}},sa;function yi(){return sa||(sa=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(t){var i=e,s=i.lib,a=s.Base,c=s.WordArray,o=i.x64={};o.Word=a.extend({init:function(u,h){this.high=u,this.low=h}}),o.WordArray=a.extend({init:function(u,h){u=this.words=u||[],h!=t?this.sigBytes=h:this.sigBytes=u.length*8},toX32:function(){for(var u=this.words,h=u.length,p=[],d=0;d<h;d++){var f=u[d];p.push(f.high),p.push(f.low)}return c.create(p,this.sigBytes)},clone:function(){for(var u=a.clone.call(this),h=u.words=this.words.slice(0),p=h.length,d=0;d<p;d++)h[d]=h[d].clone();return u}})}(),e})}(ar)),ar.exports}var nr={exports:{}},aa;function yo(){return aa||(aa=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(){if(typeof ArrayBuffer=="function"){var t=e,i=t.lib,s=i.WordArray,a=s.init,c=s.init=function(o){if(o instanceof ArrayBuffer&&(o=new Uint8Array(o)),(o instanceof Int8Array||typeof Uint8ClampedArray!="undefined"&&o instanceof Uint8ClampedArray||o instanceof Int16Array||o instanceof Uint16Array||o instanceof Int32Array||o instanceof Uint32Array||o instanceof Float32Array||o instanceof Float64Array)&&(o=new Uint8Array(o.buffer,o.byteOffset,o.byteLength)),o instanceof Uint8Array){for(var u=o.byteLength,h=[],p=0;p<u;p++)h[p>>>2]|=o[p]<<24-p%4*8;a.call(this,h,u)}else a.apply(this,arguments)};c.prototype=s}}(),e.lib.WordArray})}(nr)),nr.exports}var or={exports:{}},na;function Co(){return na||(na=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.WordArray,a=t.enc;a.Utf16=a.Utf16BE={stringify:function(o){for(var u=o.words,h=o.sigBytes,p=[],d=0;d<h;d+=2){var f=u[d>>>2]>>>16-d%4*8&65535;p.push(String.fromCharCode(f))}return p.join("")},parse:function(o){for(var u=o.length,h=[],p=0;p<u;p++)h[p>>>1]|=o.charCodeAt(p)<<16-p%2*16;return s.create(h,u*2)}},a.Utf16LE={stringify:function(o){for(var u=o.words,h=o.sigBytes,p=[],d=0;d<h;d+=2){var f=c(u[d>>>2]>>>16-d%4*8&65535);p.push(String.fromCharCode(f))}return p.join("")},parse:function(o){for(var u=o.length,h=[],p=0;p<u;p++)h[p>>>1]|=c(o.charCodeAt(p)<<16-p%2*16);return s.create(h,u*2)}};function c(o){return o<<8&4278255360|o>>>8&16711935}}(),e.enc.Utf16})}(or)),or.exports}var cr={exports:{}},oa;function Pt(){return oa||(oa=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.WordArray,a=t.enc;a.Base64={stringify:function(o){var u=o.words,h=o.sigBytes,p=this._map;o.clamp();for(var d=[],f=0;f<h;f+=3)for(var m=u[f>>>2]>>>24-f%4*8&255,l=u[f+1>>>2]>>>24-(f+1)%4*8&255,S=u[f+2>>>2]>>>24-(f+2)%4*8&255,v=m<<16|l<<8|S,x=0;x<4&&f+x*.75<h;x++)d.push(p.charAt(v>>>6*(3-x)&63));var b=p.charAt(64);if(b)for(;d.length%4;)d.push(b);return d.join("")},parse:function(o){var u=o.length,h=this._map,p=this._reverseMap;if(!p){p=this._reverseMap=[];for(var d=0;d<h.length;d++)p[h.charCodeAt(d)]=d}var f=h.charAt(64);if(f){var m=o.indexOf(f);m!==-1&&(u=m)}return c(o,u,p)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function c(o,u,h){for(var p=[],d=0,f=0;f<u;f++)if(f%4){var m=h[o.charCodeAt(f-1)]<<f%4*2,l=h[o.charCodeAt(f)]>>>6-f%4*2,S=m|l;p[d>>>2]|=S<<24-d%4*8,d++}return s.create(p,d)}}(),e.enc.Base64})}(cr)),cr.exports}var ur={exports:{}},ca;function Ro(){return ca||(ca=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.WordArray,a=t.enc;a.Base64url={stringify:function(o,u){u===void 0&&(u=!0);var h=o.words,p=o.sigBytes,d=u?this._safe_map:this._map;o.clamp();for(var f=[],m=0;m<p;m+=3)for(var l=h[m>>>2]>>>24-m%4*8&255,S=h[m+1>>>2]>>>24-(m+1)%4*8&255,v=h[m+2>>>2]>>>24-(m+2)%4*8&255,x=l<<16|S<<8|v,b=0;b<4&&m+b*.75<p;b++)f.push(d.charAt(x>>>6*(3-b)&63));var E=d.charAt(64);if(E)for(;f.length%4;)f.push(E);return f.join("")},parse:function(o,u){u===void 0&&(u=!0);var h=o.length,p=u?this._safe_map:this._map,d=this._reverseMap;if(!d){d=this._reverseMap=[];for(var f=0;f<p.length;f++)d[p.charCodeAt(f)]=f}var m=p.charAt(64);if(m){var l=o.indexOf(m);l!==-1&&(h=l)}return c(o,h,d)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function c(o,u,h){for(var p=[],d=0,f=0;f<u;f++)if(f%4){var m=h[o.charCodeAt(f-1)]<<f%4*2,l=h[o.charCodeAt(f)]>>>6-f%4*2,S=m|l;p[d>>>2]|=S<<24-d%4*8,d++}return s.create(p,d)}}(),e.enc.Base64url})}(ur)),ur.exports}var hr={exports:{}},ua;function kt(){return ua||(ua=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(t){var i=e,s=i.lib,a=s.WordArray,c=s.Hasher,o=i.algo,u=[];(function(){for(var l=0;l<64;l++)u[l]=t.abs(t.sin(l+1))*4294967296|0})();var h=o.MD5=c.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(l,S){for(var v=0;v<16;v++){var x=S+v,b=l[x];l[x]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360}var E=this._hash.words,A=l[S+0],y=l[S+1],_=l[S+2],R=l[S+3],L=l[S+4],C=l[S+5],I=l[S+6],P=l[S+7],B=l[S+8],K=l[S+9],J=l[S+10],Q=l[S+11],ue=l[S+12],te=l[S+13],se=l[S+14],ie=l[S+15],k=E[0],M=E[1],F=E[2],N=E[3];k=p(k,M,F,N,A,7,u[0]),N=p(N,k,M,F,y,12,u[1]),F=p(F,N,k,M,_,17,u[2]),M=p(M,F,N,k,R,22,u[3]),k=p(k,M,F,N,L,7,u[4]),N=p(N,k,M,F,C,12,u[5]),F=p(F,N,k,M,I,17,u[6]),M=p(M,F,N,k,P,22,u[7]),k=p(k,M,F,N,B,7,u[8]),N=p(N,k,M,F,K,12,u[9]),F=p(F,N,k,M,J,17,u[10]),M=p(M,F,N,k,Q,22,u[11]),k=p(k,M,F,N,ue,7,u[12]),N=p(N,k,M,F,te,12,u[13]),F=p(F,N,k,M,se,17,u[14]),M=p(M,F,N,k,ie,22,u[15]),k=d(k,M,F,N,y,5,u[16]),N=d(N,k,M,F,I,9,u[17]),F=d(F,N,k,M,Q,14,u[18]),M=d(M,F,N,k,A,20,u[19]),k=d(k,M,F,N,C,5,u[20]),N=d(N,k,M,F,J,9,u[21]),F=d(F,N,k,M,ie,14,u[22]),M=d(M,F,N,k,L,20,u[23]),k=d(k,M,F,N,K,5,u[24]),N=d(N,k,M,F,se,9,u[25]),F=d(F,N,k,M,R,14,u[26]),M=d(M,F,N,k,B,20,u[27]),k=d(k,M,F,N,te,5,u[28]),N=d(N,k,M,F,_,9,u[29]),F=d(F,N,k,M,P,14,u[30]),M=d(M,F,N,k,ue,20,u[31]),k=f(k,M,F,N,C,4,u[32]),N=f(N,k,M,F,B,11,u[33]),F=f(F,N,k,M,Q,16,u[34]),M=f(M,F,N,k,se,23,u[35]),k=f(k,M,F,N,y,4,u[36]),N=f(N,k,M,F,L,11,u[37]),F=f(F,N,k,M,P,16,u[38]),M=f(M,F,N,k,J,23,u[39]),k=f(k,M,F,N,te,4,u[40]),N=f(N,k,M,F,A,11,u[41]),F=f(F,N,k,M,R,16,u[42]),M=f(M,F,N,k,I,23,u[43]),k=f(k,M,F,N,K,4,u[44]),N=f(N,k,M,F,ue,11,u[45]),F=f(F,N,k,M,ie,16,u[46]),M=f(M,F,N,k,_,23,u[47]),k=m(k,M,F,N,A,6,u[48]),N=m(N,k,M,F,P,10,u[49]),F=m(F,N,k,M,se,15,u[50]),M=m(M,F,N,k,C,21,u[51]),k=m(k,M,F,N,ue,6,u[52]),N=m(N,k,M,F,R,10,u[53]),F=m(F,N,k,M,J,15,u[54]),M=m(M,F,N,k,y,21,u[55]),k=m(k,M,F,N,B,6,u[56]),N=m(N,k,M,F,ie,10,u[57]),F=m(F,N,k,M,I,15,u[58]),M=m(M,F,N,k,te,21,u[59]),k=m(k,M,F,N,L,6,u[60]),N=m(N,k,M,F,Q,10,u[61]),F=m(F,N,k,M,_,15,u[62]),M=m(M,F,N,k,K,21,u[63]),E[0]=E[0]+k|0,E[1]=E[1]+M|0,E[2]=E[2]+F|0,E[3]=E[3]+N|0},_doFinalize:function(){var l=this._data,S=l.words,v=this._nDataBytes*8,x=l.sigBytes*8;S[x>>>5]|=128<<24-x%32;var b=t.floor(v/4294967296),E=v;S[(x+64>>>9<<4)+15]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360,S[(x+64>>>9<<4)+14]=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360,l.sigBytes=(S.length+1)*4,this._process();for(var A=this._hash,y=A.words,_=0;_<4;_++){var R=y[_];y[_]=(R<<8|R>>>24)&16711935|(R<<24|R>>>8)&4278255360}return A},clone:function(){var l=c.clone.call(this);return l._hash=this._hash.clone(),l}});function p(l,S,v,x,b,E,A){var y=l+(S&v|~S&x)+b+A;return(y<<E|y>>>32-E)+S}function d(l,S,v,x,b,E,A){var y=l+(S&x|v&~x)+b+A;return(y<<E|y>>>32-E)+S}function f(l,S,v,x,b,E,A){var y=l+(S^v^x)+b+A;return(y<<E|y>>>32-E)+S}function m(l,S,v,x,b,E,A){var y=l+(v^(S|~x))+b+A;return(y<<E|y>>>32-E)+S}i.MD5=c._createHelper(h),i.HmacMD5=c._createHmacHelper(h)}(Math),e.MD5})}(hr)),hr.exports}var dr={exports:{}},ha;function da(){return ha||(ha=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.WordArray,a=i.Hasher,c=t.algo,o=[],u=c.SHA1=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(h,p){for(var d=this._hash.words,f=d[0],m=d[1],l=d[2],S=d[3],v=d[4],x=0;x<80;x++){if(x<16)o[x]=h[p+x]|0;else{var b=o[x-3]^o[x-8]^o[x-14]^o[x-16];o[x]=b<<1|b>>>31}var E=(f<<5|f>>>27)+v+o[x];x<20?E+=(m&l|~m&S)+1518500249:x<40?E+=(m^l^S)+1859775393:x<60?E+=(m&l|m&S|l&S)-1894007588:E+=(m^l^S)-899497514,v=S,S=l,l=m<<30|m>>>2,m=f,f=E}d[0]=d[0]+f|0,d[1]=d[1]+m|0,d[2]=d[2]+l|0,d[3]=d[3]+S|0,d[4]=d[4]+v|0},_doFinalize:function(){var h=this._data,p=h.words,d=this._nDataBytes*8,f=h.sigBytes*8;return p[f>>>5]|=128<<24-f%32,p[(f+64>>>9<<4)+14]=Math.floor(d/4294967296),p[(f+64>>>9<<4)+15]=d,h.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var h=a.clone.call(this);return h._hash=this._hash.clone(),h}});t.SHA1=a._createHelper(u),t.HmacSHA1=a._createHmacHelper(u)}(),e.SHA1})}(dr)),dr.exports}var lr={exports:{}},la;function fr(){return la||(la=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){return function(t){var i=e,s=i.lib,a=s.WordArray,c=s.Hasher,o=i.algo,u=[],h=[];(function(){function f(v){for(var x=t.sqrt(v),b=2;b<=x;b++)if(!(v%b))return!1;return!0}function m(v){return(v-(v|0))*4294967296|0}for(var l=2,S=0;S<64;)f(l)&&(S<8&&(u[S]=m(t.pow(l,1/2))),h[S]=m(t.pow(l,1/3)),S++),l++})();var p=[],d=o.SHA256=c.extend({_doReset:function(){this._hash=new a.init(u.slice(0))},_doProcessBlock:function(f,m){for(var l=this._hash.words,S=l[0],v=l[1],x=l[2],b=l[3],E=l[4],A=l[5],y=l[6],_=l[7],R=0;R<64;R++){if(R<16)p[R]=f[m+R]|0;else{var L=p[R-15],C=(L<<25|L>>>7)^(L<<14|L>>>18)^L>>>3,I=p[R-2],P=(I<<15|I>>>17)^(I<<13|I>>>19)^I>>>10;p[R]=C+p[R-7]+P+p[R-16]}var B=E&A^~E&y,K=S&v^S&x^v&x,J=(S<<30|S>>>2)^(S<<19|S>>>13)^(S<<10|S>>>22),Q=(E<<26|E>>>6)^(E<<21|E>>>11)^(E<<7|E>>>25),ue=_+Q+B+h[R]+p[R],te=J+K;_=y,y=A,A=E,E=b+ue|0,b=x,x=v,v=S,S=ue+te|0}l[0]=l[0]+S|0,l[1]=l[1]+v|0,l[2]=l[2]+x|0,l[3]=l[3]+b|0,l[4]=l[4]+E|0,l[5]=l[5]+A|0,l[6]=l[6]+y|0,l[7]=l[7]+_|0},_doFinalize:function(){var f=this._data,m=f.words,l=this._nDataBytes*8,S=f.sigBytes*8;return m[S>>>5]|=128<<24-S%32,m[(S+64>>>9<<4)+14]=t.floor(l/4294967296),m[(S+64>>>9<<4)+15]=l,f.sigBytes=m.length*4,this._process(),this._hash},clone:function(){var f=c.clone.call(this);return f._hash=this._hash.clone(),f}});i.SHA256=c._createHelper(d),i.HmacSHA256=c._createHmacHelper(d)}(Math),e.SHA256})}(lr)),lr.exports}var pr={exports:{}},fa;function Io(){return fa||(fa=1,function(r,n){(function(e,t,i){r.exports=t(ce(),fr())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.WordArray,a=t.algo,c=a.SHA256,o=a.SHA224=c.extend({_doReset:function(){this._hash=new s.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var u=c._doFinalize.call(this);return u.sigBytes-=4,u}});t.SHA224=c._createHelper(o),t.HmacSHA224=c._createHmacHelper(o)}(),e.SHA224})}(pr)),pr.exports}var gr={exports:{}},pa;function ga(){return pa||(pa=1,function(r,n){(function(e,t,i){r.exports=t(ce(),yi())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.Hasher,a=t.x64,c=a.Word,o=a.WordArray,u=t.algo;function h(){return c.create.apply(c,arguments)}var p=[h(1116352408,3609767458),h(1899447441,602891725),h(3049323471,3964484399),h(3921009573,2173295548),h(961987163,4081628472),h(1508970993,3053834265),h(2453635748,2937671579),h(2870763221,3664609560),h(3624381080,2734883394),h(310598401,1164996542),h(607225278,1323610764),h(1426881987,3590304994),h(1925078388,4068182383),h(2162078206,991336113),h(2614888103,633803317),h(3248222580,3479774868),h(3835390401,2666613458),h(4022224774,944711139),h(264347078,2341262773),h(604807628,2007800933),h(770255983,1495990901),h(1249150122,1856431235),h(1555081692,3175218132),h(1996064986,2198950837),h(2554220882,3999719339),h(2821834349,766784016),h(2952996808,2566594879),h(3210313671,3203337956),h(3336571891,1034457026),h(3584528711,2466948901),h(113926993,3758326383),h(338241895,168717936),h(666307205,1188179964),h(773529912,1546045734),h(1294757372,1522805485),h(1396182291,2643833823),h(1695183700,2343527390),h(1986661051,1014477480),h(2177026350,1206759142),h(2456956037,344077627),h(2730485921,1290863460),h(2820302411,3158454273),h(3259730800,3505952657),h(3345764771,106217008),h(3516065817,3606008344),h(3600352804,1432725776),h(4094571909,1467031594),h(275423344,851169720),h(430227734,3100823752),h(506948616,1363258195),h(659060556,3750685593),h(883997877,3785050280),h(958139571,3318307427),h(1322822218,3812723403),h(1537002063,2003034995),h(1747873779,3602036899),h(1955562222,1575990012),h(2024104815,1125592928),h(2227730452,2716904306),h(2361852424,442776044),h(2428436474,593698344),h(2756734187,3733110249),h(3204031479,2999351573),h(3329325298,3815920427),h(3391569614,3928383900),h(3515267271,566280711),h(3940187606,3454069534),h(4118630271,4000239992),h(116418474,1914138554),h(174292421,2731055270),h(289380356,3203993006),h(460393269,320620315),h(685471733,587496836),h(852142971,1086792851),h(1017036298,365543100),h(1126000580,2618297676),h(1288033470,3409855158),h(1501505948,4234509866),h(1607167915,987167468),h(1816402316,1246189591)],d=[];(function(){for(var m=0;m<80;m++)d[m]=h()})();var f=u.SHA512=s.extend({_doReset:function(){this._hash=new o.init([new c.init(1779033703,4089235720),new c.init(3144134277,2227873595),new c.init(1013904242,4271175723),new c.init(2773480762,1595750129),new c.init(1359893119,2917565137),new c.init(2600822924,725511199),new c.init(528734635,4215389547),new c.init(1541459225,327033209)])},_doProcessBlock:function(m,l){for(var S=this._hash.words,v=S[0],x=S[1],b=S[2],E=S[3],A=S[4],y=S[5],_=S[6],R=S[7],L=v.high,C=v.low,I=x.high,P=x.low,B=b.high,K=b.low,J=E.high,Q=E.low,ue=A.high,te=A.low,se=y.high,ie=y.low,k=_.high,M=_.low,F=R.high,N=R.low,Y=L,j=C,fe=I,ee=P,ze=B,Je=K,st=J,at=Q,ye=ue,Fe=te,St=se,zt=ie,ii=k,Wt=M,Si=F,$t=N,Ve=0;Ve<80;Ve++){var Pe,nt,Kt=d[Ve];if(Ve<16)nt=Kt.high=m[l+Ve*2]|0,Pe=Kt.low=m[l+Ve*2+1]|0;else{var It=d[Ve-15],ot=It.high,xt=It.low,vs=(ot>>>1|xt<<31)^(ot>>>8|xt<<24)^ot>>>7,Vi=(xt>>>1|ot<<31)^(xt>>>8|ot<<24)^(xt>>>7|ot<<25),Oi=d[Ve-2],Ge=Oi.high,wt=Oi.low,Ui=(Ge>>>19|wt<<13)^(Ge<<3|wt>>>29)^Ge>>>6,xi=(wt>>>19|Ge<<13)^(wt<<3|Ge>>>29)^(wt>>>6|Ge<<26),Tn=d[Ve-7],Pc=Tn.high,kc=Tn.low,Dn=d[Ve-16],Bc=Dn.high,Pn=Dn.low;Pe=Vi+kc,nt=vs+Pc+(Pe>>>0<Vi>>>0?1:0),Pe=Pe+xi,nt=nt+Ui+(Pe>>>0<xi>>>0?1:0),Pe=Pe+Pn,nt=nt+Bc+(Pe>>>0<Pn>>>0?1:0),Kt.high=nt,Kt.low=Pe}var Nc=ye&St^~ye&ii,kn=Fe&zt^~Fe&Wt,Lc=Y&fe^Y&ze^fe&ze,Mc=j&ee^j&Je^ee&Je,Fc=(Y>>>28|j<<4)^(Y<<30|j>>>2)^(Y<<25|j>>>7),Bn=(j>>>28|Y<<4)^(j<<30|Y>>>2)^(j<<25|Y>>>7),Vc=(ye>>>14|Fe<<18)^(ye>>>18|Fe<<14)^(ye<<23|Fe>>>9),Oc=(Fe>>>14|ye<<18)^(Fe>>>18|ye<<14)^(Fe<<23|ye>>>9),Nn=p[Ve],Uc=Nn.high,Ln=Nn.low,Xe=$t+Oc,Tt=Si+Vc+(Xe>>>0<$t>>>0?1:0),Xe=Xe+kn,Tt=Tt+Nc+(Xe>>>0<kn>>>0?1:0),Xe=Xe+Ln,Tt=Tt+Uc+(Xe>>>0<Ln>>>0?1:0),Xe=Xe+Pe,Tt=Tt+nt+(Xe>>>0<Pe>>>0?1:0),Mn=Bn+Mc,Hc=Fc+Lc+(Mn>>>0<Bn>>>0?1:0);Si=ii,$t=Wt,ii=St,Wt=zt,St=ye,zt=Fe,Fe=at+Xe|0,ye=st+Tt+(Fe>>>0<at>>>0?1:0)|0,st=ze,at=Je,ze=fe,Je=ee,fe=Y,ee=j,j=Xe+Mn|0,Y=Tt+Hc+(j>>>0<Xe>>>0?1:0)|0}C=v.low=C+j,v.high=L+Y+(C>>>0<j>>>0?1:0),P=x.low=P+ee,x.high=I+fe+(P>>>0<ee>>>0?1:0),K=b.low=K+Je,b.high=B+ze+(K>>>0<Je>>>0?1:0),Q=E.low=Q+at,E.high=J+st+(Q>>>0<at>>>0?1:0),te=A.low=te+Fe,A.high=ue+ye+(te>>>0<Fe>>>0?1:0),ie=y.low=ie+zt,y.high=se+St+(ie>>>0<zt>>>0?1:0),M=_.low=M+Wt,_.high=k+ii+(M>>>0<Wt>>>0?1:0),N=R.low=N+$t,R.high=F+Si+(N>>>0<$t>>>0?1:0)},_doFinalize:function(){var m=this._data,l=m.words,S=this._nDataBytes*8,v=m.sigBytes*8;l[v>>>5]|=128<<24-v%32,l[(v+128>>>10<<5)+30]=Math.floor(S/4294967296),l[(v+128>>>10<<5)+31]=S,m.sigBytes=l.length*4,this._process();var x=this._hash.toX32();return x},clone:function(){var m=s.clone.call(this);return m._hash=this._hash.clone(),m},blockSize:1024/32});t.SHA512=s._createHelper(f),t.HmacSHA512=s._createHmacHelper(f)}(),e.SHA512})}(gr)),gr.exports}var mr={exports:{}},ma;function wo(){return ma||(ma=1,function(r,n){(function(e,t,i){r.exports=t(ce(),yi(),ga())})(ae,function(e){return function(){var t=e,i=t.x64,s=i.Word,a=i.WordArray,c=t.algo,o=c.SHA512,u=c.SHA384=o.extend({_doReset:function(){this._hash=new a.init([new s.init(3418070365,3238371032),new s.init(1654270250,914150663),new s.init(2438529370,812702999),new s.init(355462360,4144912697),new s.init(1731405415,4290775857),new s.init(2394180231,1750603025),new s.init(3675008525,1694076839),new s.init(1203062813,3204075428)])},_doFinalize:function(){var h=o._doFinalize.call(this);return h.sigBytes-=16,h}});t.SHA384=o._createHelper(u),t.HmacSHA384=o._createHmacHelper(u)}(),e.SHA384})}(mr)),mr.exports}var Sr={exports:{}},Sa;function To(){return Sa||(Sa=1,function(r,n){(function(e,t,i){r.exports=t(ce(),yi())})(ae,function(e){return function(t){var i=e,s=i.lib,a=s.WordArray,c=s.Hasher,o=i.x64,u=o.Word,h=i.algo,p=[],d=[],f=[];(function(){for(var S=1,v=0,x=0;x<24;x++){p[S+5*v]=(x+1)*(x+2)/2%64;var b=v%5,E=(2*S+3*v)%5;S=b,v=E}for(var S=0;S<5;S++)for(var v=0;v<5;v++)d[S+5*v]=v+(2*S+3*v)%5*5;for(var A=1,y=0;y<24;y++){for(var _=0,R=0,L=0;L<7;L++){if(A&1){var C=(1<<L)-1;C<32?R^=1<<C:_^=1<<C-32}A&128?A=A<<1^113:A<<=1}f[y]=u.create(_,R)}})();var m=[];(function(){for(var S=0;S<25;S++)m[S]=u.create()})();var l=h.SHA3=c.extend({cfg:c.cfg.extend({outputLength:512}),_doReset:function(){for(var S=this._state=[],v=0;v<25;v++)S[v]=new u.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(S,v){for(var x=this._state,b=this.blockSize/2,E=0;E<b;E++){var A=S[v+2*E],y=S[v+2*E+1];A=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360,y=(y<<8|y>>>24)&16711935|(y<<24|y>>>8)&4278255360;var _=x[E];_.high^=y,_.low^=A}for(var R=0;R<24;R++){for(var L=0;L<5;L++){for(var C=0,I=0,P=0;P<5;P++){var _=x[L+5*P];C^=_.high,I^=_.low}var B=m[L];B.high=C,B.low=I}for(var L=0;L<5;L++)for(var K=m[(L+4)%5],J=m[(L+1)%5],Q=J.high,ue=J.low,C=K.high^(Q<<1|ue>>>31),I=K.low^(ue<<1|Q>>>31),P=0;P<5;P++){var _=x[L+5*P];_.high^=C,_.low^=I}for(var te=1;te<25;te++){var C,I,_=x[te],se=_.high,ie=_.low,k=p[te];k<32?(C=se<<k|ie>>>32-k,I=ie<<k|se>>>32-k):(C=ie<<k-32|se>>>64-k,I=se<<k-32|ie>>>64-k);var M=m[d[te]];M.high=C,M.low=I}var F=m[0],N=x[0];F.high=N.high,F.low=N.low;for(var L=0;L<5;L++)for(var P=0;P<5;P++){var te=L+5*P,_=x[te],Y=m[te],j=m[(L+1)%5+5*P],fe=m[(L+2)%5+5*P];_.high=Y.high^~j.high&fe.high,_.low=Y.low^~j.low&fe.low}var _=x[0],ee=f[R];_.high^=ee.high,_.low^=ee.low}},_doFinalize:function(){var S=this._data,v=S.words;this._nDataBytes*8;var x=S.sigBytes*8,b=this.blockSize*32;v[x>>>5]|=1<<24-x%32,v[(t.ceil((x+1)/b)*b>>>5)-1]|=128,S.sigBytes=v.length*4,this._process();for(var E=this._state,A=this.cfg.outputLength/8,y=A/8,_=[],R=0;R<y;R++){var L=E[R],C=L.high,I=L.low;C=(C<<8|C>>>24)&16711935|(C<<24|C>>>8)&4278255360,I=(I<<8|I>>>24)&16711935|(I<<24|I>>>8)&4278255360,_.push(I),_.push(C)}return new a.init(_,A)},clone:function(){for(var S=c.clone.call(this),v=S._state=this._state.slice(0),x=0;x<25;x++)v[x]=v[x].clone();return S}});i.SHA3=c._createHelper(l),i.HmacSHA3=c._createHmacHelper(l)}(Math),e.SHA3})}(Sr)),Sr.exports}var xr={exports:{}},xa;function Do(){return xa||(xa=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){/** @preserve
|
|
9
9
|
(c) 2012 by Cédric Mesnil. All rights reserved.
|
|
10
10
|
|
|
11
11
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
@@ -14,7 +14,7 @@ var jc=Object.defineProperty,zc=Object.defineProperties;var Wc=Object.getOwnProp
|
|
|
14
14
|
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
15
15
|
|
|
16
16
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
17
|
-
*/return function(t){var i=e,s=i.lib,a=s.WordArray,c=s.Hasher,o=i.algo,u=a.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=a.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]),p=a.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=a.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=a.create([0,1518500249,1859775393,2400959708,2840853838]),m=a.create([1352829926,1548603684,1836072691,2053994217,0]),l=o.RIPEMD160=c.extend({_doReset:function(){this._hash=a.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(y,_){for(var R=0;R<16;R++){var L=_+R,C=y[L];y[L]=(C<<8|C>>>24)&16711935|(C<<24|C>>>8)&4278255360}var I=this._hash.words,P=f.words,B=m.words,K=u.words,J=h.words,Q=p.words,ue=d.words,te,se,ie,k,M,F,N,X,j,fe;F=te=I[0],N=se=I[1],X=ie=I[2],j=k=I[3],fe=M=I[4];for(var ee,R=0;R<80;R+=1)ee=te+y[_+K[R]]|0,R<16?ee+=S(se,ie,k)+P[0]:R<32?ee+=v(se,ie,k)+P[1]:R<48?ee+=x(se,ie,k)+P[2]:R<64?ee+=b(se,ie,k)+P[3]:ee+=E(se,ie,k)+P[4],ee=ee|0,ee=A(ee,Q[R]),ee=ee+M|0,te=M,M=k,k=A(ie,10),ie=se,se=ee,ee=F+y[_+J[R]]|0,R<16?ee+=E(N,X,j)+B[0]:R<32?ee+=b(N,X,j)+B[1]:R<48?ee+=x(N,X,j)+B[2]:R<64?ee+=v(N,X,j)+B[3]:ee+=S(N,X,j)+B[4],ee=ee|0,ee=A(ee,ue[R]),ee=ee+fe|0,F=fe,fe=j,j=A(X,10),X=N,N=ee;ee=I[1]+ie+j|0,I[1]=I[2]+k+fe|0,I[2]=I[3]+M+F|0,I[3]=I[4]+te+N|0,I[4]=I[0]+se+X|0,I[0]=ee},_doFinalize:function(){var y=this._data,_=y.words,R=this._nDataBytes*8,L=y.sigBytes*8;_[L>>>5]|=128<<24-L%32,_[(L+64>>>9<<4)+14]=(R<<8|R>>>24)&16711935|(R<<24|R>>>8)&4278255360,y.sigBytes=(_.length+1)*4,this._process();for(var C=this._hash,I=C.words,P=0;P<5;P++){var B=I[P];I[P]=(B<<8|B>>>24)&16711935|(B<<24|B>>>8)&4278255360}return C},clone:function(){var y=c.clone.call(this);return y._hash=this._hash.clone(),y}});function S(y,_,R){return y^_^R}function v(y,_,R){return y&_|~y&R}function x(y,_,R){return(y|~_)^R}function b(y,_,R){return y&R|_&~R}function E(y,_,R){return y^(_|~R)}function A(y,_){return y<<_|y>>>32-_}i.RIPEMD160=c._createHelper(l),i.HmacRIPEMD160=c._createHmacHelper(l)}(),e.RIPEMD160})}(xr)),xr.exports}var vr={exports:{}},va;function br(){return va||(va=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){(function(){var t=e,i=t.lib,s=i.Base,a=t.enc,c=a.Utf8,o=t.algo;o.HMAC=s.extend({init:function(u,h){u=this._hasher=new u.init,typeof h=="string"&&(h=c.parse(h));var p=u.blockSize,d=p*4;h.sigBytes>d&&(h=u.finalize(h)),h.clamp();for(var f=this._oKey=h.clone(),m=this._iKey=h.clone(),l=f.words,S=m.words,v=0;v<p;v++)l[v]^=1549556828,S[v]^=909522486;f.sigBytes=m.sigBytes=d,this.reset()},reset:function(){var u=this._hasher;u.reset(),u.update(this._iKey)},update:function(u){return this._hasher.update(u),this},finalize:function(u){var h=this._hasher,p=h.finalize(u);h.reset();var d=h.finalize(this._oKey.clone().concat(p));return d}})})()})}(vr)),vr.exports}var Er={exports:{}},ba;function Po(){return ba||(ba=1,function(r,n){(function(e,t,i){r.exports=t(ce(),fr(),br())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.Base,a=i.WordArray,c=t.algo,o=c.SHA256,u=c.HMAC,h=c.PBKDF2=s.extend({cfg:s.extend({keySize:128/32,hasher:o,iterations:25e4}),init:function(p){this.cfg=this.cfg.extend(p)},compute:function(p,d){for(var f=this.cfg,m=u.create(f.hasher,p),l=a.create(),S=a.create([1]),v=l.words,x=S.words,b=f.keySize,E=f.iterations;v.length<b;){var A=m.update(d).finalize(S);m.reset();for(var y=A.words,_=y.length,R=A,L=1;L<E;L++){R=m.finalize(R),m.reset();for(var C=R.words,I=0;I<_;I++)y[I]^=C[I]}l.concat(A),x[0]++}return l.sigBytes=b*4,l}});t.PBKDF2=function(p,d,f){return h.create(f).compute(p,d)}}(),e.PBKDF2})}(Er)),Er.exports}var Ar={exports:{}},Ea;function Et(){return Ea||(Ea=1,function(r,n){(function(e,t,i){r.exports=t(ce(),da(),br())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.Base,a=i.WordArray,c=t.algo,o=c.MD5,u=c.EvpKDF=s.extend({cfg:s.extend({keySize:128/32,hasher:o,iterations:1}),init:function(h){this.cfg=this.cfg.extend(h)},compute:function(h,p){for(var d,f=this.cfg,m=f.hasher.create(),l=a.create(),S=l.words,v=f.keySize,x=f.iterations;S.length<v;){d&&m.update(d),d=m.update(h).finalize(p),m.reset();for(var b=1;b<x;b++)d=m.finalize(d),m.reset();l.concat(d)}return l.sigBytes=v*4,l}});t.EvpKDF=function(h,p,d){return u.create(d).compute(h,p)}}(),e.EvpKDF})}(Ar)),Ar.exports}var _r={exports:{}},Aa;function Re(){return Aa||(Aa=1,function(r,n){(function(e,t,i){r.exports=t(ce(),Et())})(ae,function(e){e.lib.Cipher||function(t){var i=e,s=i.lib,a=s.Base,c=s.WordArray,o=s.BufferedBlockAlgorithm,u=i.enc;u.Utf8;var h=u.Base64,p=i.algo,d=p.EvpKDF,f=s.Cipher=o.extend({cfg:a.extend(),createEncryptor:function(C,I){return this.create(this._ENC_XFORM_MODE,C,I)},createDecryptor:function(C,I){return this.create(this._DEC_XFORM_MODE,C,I)},init:function(C,I,P){this.cfg=this.cfg.extend(P),this._xformMode=C,this._key=I,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(C){return this._append(C),this._process()},finalize:function(C){C&&this._append(C);var I=this._doFinalize();return I},keySize:128/32,ivSize:128/32,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function C(I){return typeof I=="string"?L:y}return function(I){return{encrypt:function(P,B,K){return C(B).encrypt(I,P,B,K)},decrypt:function(P,B,K){return C(B).decrypt(I,P,B,K)}}}}()});s.StreamCipher=f.extend({_doFinalize:function(){var C=this._process(!0);return C},blockSize:1});var m=i.mode={},l=s.BlockCipherMode=a.extend({createEncryptor:function(C,I){return this.Encryptor.create(C,I)},createDecryptor:function(C,I){return this.Decryptor.create(C,I)},init:function(C,I){this._cipher=C,this._iv=I}}),S=m.CBC=function(){var C=l.extend();C.Encryptor=C.extend({processBlock:function(P,B){var K=this._cipher,J=K.blockSize;I.call(this,P,B,J),K.encryptBlock(P,B),this._prevBlock=P.slice(B,B+J)}}),C.Decryptor=C.extend({processBlock:function(P,B){var K=this._cipher,J=K.blockSize,Q=P.slice(B,B+J);K.decryptBlock(P,B),I.call(this,P,B,J),this._prevBlock=Q}});function I(P,B,K){var J,Q=this._iv;Q?(J=Q,this._iv=t):J=this._prevBlock;for(var ue=0;ue<K;ue++)P[B+ue]^=J[ue]}return C}(),v=i.pad={},x=v.Pkcs7={pad:function(C,I){for(var P=I*4,B=P-C.sigBytes%P,K=B<<24|B<<16|B<<8|B,J=[],Q=0;Q<B;Q+=4)J.push(K);var ue=c.create(J,B);C.concat(ue)},unpad:function(C){var I=C.words[C.sigBytes-1>>>2]&255;C.sigBytes-=I}};s.BlockCipher=f.extend({cfg:f.cfg.extend({mode:S,padding:x}),reset:function(){var C;f.reset.call(this);var I=this.cfg,P=I.iv,B=I.mode;this._xformMode==this._ENC_XFORM_MODE?C=B.createEncryptor:(C=B.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==C?this._mode.init(this,P&&P.words):(this._mode=C.call(B,this,P&&P.words),this._mode.__creator=C)},_doProcessBlock:function(C,I){this._mode.processBlock(C,I)},_doFinalize:function(){var C,I=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(I.pad(this._data,this.blockSize),C=this._process(!0)):(C=this._process(!0),I.unpad(C)),C},blockSize:128/32});var b=s.CipherParams=a.extend({init:function(C){this.mixIn(C)},toString:function(C){return(C||this.formatter).stringify(this)}}),E=i.format={},A=E.OpenSSL={stringify:function(C){var I,P=C.ciphertext,B=C.salt;return B?I=c.create([1398893684,1701076831]).concat(B).concat(P):I=P,I.toString(h)},parse:function(C){var I,P=h.parse(C),B=P.words;return B[0]==1398893684&&B[1]==1701076831&&(I=c.create(B.slice(2,4)),B.splice(0,4),P.sigBytes-=16),b.create({ciphertext:P,salt:I})}},y=s.SerializableCipher=a.extend({cfg:a.extend({format:A}),encrypt:function(C,I,P,B){B=this.cfg.extend(B);var K=C.createEncryptor(P,B),J=K.finalize(I),Q=K.cfg;return b.create({ciphertext:J,key:P,iv:Q.iv,algorithm:C,mode:Q.mode,padding:Q.padding,blockSize:C.blockSize,formatter:B.format})},decrypt:function(C,I,P,B){B=this.cfg.extend(B),I=this._parse(I,B.format);var K=C.createDecryptor(P,B).finalize(I.ciphertext);return K},_parse:function(C,I){return typeof C=="string"?I.parse(C,this):C}}),_=i.kdf={},R=_.OpenSSL={execute:function(C,I,P,B,K){if(B||(B=c.random(64/8)),K)var J=d.create({keySize:I+P,hasher:K}).compute(C,B);else var J=d.create({keySize:I+P}).compute(C,B);var Q=c.create(J.words.slice(I),P*4);return J.sigBytes=I*4,b.create({key:J,iv:Q,salt:B})}},L=s.PasswordBasedCipher=y.extend({cfg:y.cfg.extend({kdf:R}),encrypt:function(C,I,P,B){B=this.cfg.extend(B);var K=B.kdf.execute(P,C.keySize,C.ivSize,B.salt,B.hasher);B.iv=K.iv;var J=y.encrypt.call(this,C,I,K.key,B);return J.mixIn(K),J},decrypt:function(C,I,P,B){B=this.cfg.extend(B),I=this._parse(I,B.format);var K=B.kdf.execute(P,C.keySize,C.ivSize,I.salt,B.hasher);B.iv=K.iv;var J=y.decrypt.call(this,C,I,K.key,B);return J}})}()})}(_r)),_r.exports}var yr={exports:{}},_a;function ko(){return _a||(_a=1,function(r,n){(function(e,t,i){r.exports=t(ce(),Re())})(ae,function(e){return e.mode.CFB=function(){var t=e.lib.BlockCipherMode.extend();t.Encryptor=t.extend({processBlock:function(s,a){var c=this._cipher,o=c.blockSize;i.call(this,s,a,o,c),this._prevBlock=s.slice(a,a+o)}}),t.Decryptor=t.extend({processBlock:function(s,a){var c=this._cipher,o=c.blockSize,u=s.slice(a,a+o);i.call(this,s,a,o,c),this._prevBlock=u}});function i(s,a,c,o){var u,h=this._iv;h?(u=h.slice(0),this._iv=void 0):u=this._prevBlock,o.encryptBlock(u,0);for(var p=0;p<c;p++)s[a+p]^=u[p]}return t}(),e.mode.CFB})}(yr)),yr.exports}var Cr={exports:{}},ya;function Bo(){return ya||(ya=1,function(r,n){(function(e,t,i){r.exports=t(ce(),Re())})(ae,function(e){return e.mode.CTR=function(){var t=e.lib.BlockCipherMode.extend(),i=t.Encryptor=t.extend({processBlock:function(s,a){var c=this._cipher,o=c.blockSize,u=this._iv,h=this._counter;u&&(h=this._counter=u.slice(0),this._iv=void 0);var p=h.slice(0);c.encryptBlock(p,0),h[o-1]=h[o-1]+1|0;for(var d=0;d<o;d++)s[a+d]^=p[d]}});return t.Decryptor=i,t}(),e.mode.CTR})}(Cr)),Cr.exports}var Rr={exports:{}},Ca;function No(){return Ca||(Ca=1,function(r,n){(function(e,t,i){r.exports=t(ce(),Re())})(ae,function(e){/** @preserve
|
|
17
|
+
*/return function(t){var i=e,s=i.lib,a=s.WordArray,c=s.Hasher,o=i.algo,u=a.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=a.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]),p=a.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=a.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=a.create([0,1518500249,1859775393,2400959708,2840853838]),m=a.create([1352829926,1548603684,1836072691,2053994217,0]),l=o.RIPEMD160=c.extend({_doReset:function(){this._hash=a.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(y,_){for(var R=0;R<16;R++){var L=_+R,C=y[L];y[L]=(C<<8|C>>>24)&16711935|(C<<24|C>>>8)&4278255360}var I=this._hash.words,P=f.words,B=m.words,K=u.words,J=h.words,Q=p.words,ue=d.words,te,se,ie,k,M,F,N,Y,j,fe;F=te=I[0],N=se=I[1],Y=ie=I[2],j=k=I[3],fe=M=I[4];for(var ee,R=0;R<80;R+=1)ee=te+y[_+K[R]]|0,R<16?ee+=S(se,ie,k)+P[0]:R<32?ee+=v(se,ie,k)+P[1]:R<48?ee+=x(se,ie,k)+P[2]:R<64?ee+=b(se,ie,k)+P[3]:ee+=E(se,ie,k)+P[4],ee=ee|0,ee=A(ee,Q[R]),ee=ee+M|0,te=M,M=k,k=A(ie,10),ie=se,se=ee,ee=F+y[_+J[R]]|0,R<16?ee+=E(N,Y,j)+B[0]:R<32?ee+=b(N,Y,j)+B[1]:R<48?ee+=x(N,Y,j)+B[2]:R<64?ee+=v(N,Y,j)+B[3]:ee+=S(N,Y,j)+B[4],ee=ee|0,ee=A(ee,ue[R]),ee=ee+fe|0,F=fe,fe=j,j=A(Y,10),Y=N,N=ee;ee=I[1]+ie+j|0,I[1]=I[2]+k+fe|0,I[2]=I[3]+M+F|0,I[3]=I[4]+te+N|0,I[4]=I[0]+se+Y|0,I[0]=ee},_doFinalize:function(){var y=this._data,_=y.words,R=this._nDataBytes*8,L=y.sigBytes*8;_[L>>>5]|=128<<24-L%32,_[(L+64>>>9<<4)+14]=(R<<8|R>>>24)&16711935|(R<<24|R>>>8)&4278255360,y.sigBytes=(_.length+1)*4,this._process();for(var C=this._hash,I=C.words,P=0;P<5;P++){var B=I[P];I[P]=(B<<8|B>>>24)&16711935|(B<<24|B>>>8)&4278255360}return C},clone:function(){var y=c.clone.call(this);return y._hash=this._hash.clone(),y}});function S(y,_,R){return y^_^R}function v(y,_,R){return y&_|~y&R}function x(y,_,R){return(y|~_)^R}function b(y,_,R){return y&R|_&~R}function E(y,_,R){return y^(_|~R)}function A(y,_){return y<<_|y>>>32-_}i.RIPEMD160=c._createHelper(l),i.HmacRIPEMD160=c._createHmacHelper(l)}(),e.RIPEMD160})}(xr)),xr.exports}var vr={exports:{}},va;function br(){return va||(va=1,function(r,n){(function(e,t){r.exports=t(ce())})(ae,function(e){(function(){var t=e,i=t.lib,s=i.Base,a=t.enc,c=a.Utf8,o=t.algo;o.HMAC=s.extend({init:function(u,h){u=this._hasher=new u.init,typeof h=="string"&&(h=c.parse(h));var p=u.blockSize,d=p*4;h.sigBytes>d&&(h=u.finalize(h)),h.clamp();for(var f=this._oKey=h.clone(),m=this._iKey=h.clone(),l=f.words,S=m.words,v=0;v<p;v++)l[v]^=1549556828,S[v]^=909522486;f.sigBytes=m.sigBytes=d,this.reset()},reset:function(){var u=this._hasher;u.reset(),u.update(this._iKey)},update:function(u){return this._hasher.update(u),this},finalize:function(u){var h=this._hasher,p=h.finalize(u);h.reset();var d=h.finalize(this._oKey.clone().concat(p));return d}})})()})}(vr)),vr.exports}var Er={exports:{}},ba;function Po(){return ba||(ba=1,function(r,n){(function(e,t,i){r.exports=t(ce(),fr(),br())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.Base,a=i.WordArray,c=t.algo,o=c.SHA256,u=c.HMAC,h=c.PBKDF2=s.extend({cfg:s.extend({keySize:128/32,hasher:o,iterations:25e4}),init:function(p){this.cfg=this.cfg.extend(p)},compute:function(p,d){for(var f=this.cfg,m=u.create(f.hasher,p),l=a.create(),S=a.create([1]),v=l.words,x=S.words,b=f.keySize,E=f.iterations;v.length<b;){var A=m.update(d).finalize(S);m.reset();for(var y=A.words,_=y.length,R=A,L=1;L<E;L++){R=m.finalize(R),m.reset();for(var C=R.words,I=0;I<_;I++)y[I]^=C[I]}l.concat(A),x[0]++}return l.sigBytes=b*4,l}});t.PBKDF2=function(p,d,f){return h.create(f).compute(p,d)}}(),e.PBKDF2})}(Er)),Er.exports}var Ar={exports:{}},Ea;function Et(){return Ea||(Ea=1,function(r,n){(function(e,t,i){r.exports=t(ce(),da(),br())})(ae,function(e){return function(){var t=e,i=t.lib,s=i.Base,a=i.WordArray,c=t.algo,o=c.MD5,u=c.EvpKDF=s.extend({cfg:s.extend({keySize:128/32,hasher:o,iterations:1}),init:function(h){this.cfg=this.cfg.extend(h)},compute:function(h,p){for(var d,f=this.cfg,m=f.hasher.create(),l=a.create(),S=l.words,v=f.keySize,x=f.iterations;S.length<v;){d&&m.update(d),d=m.update(h).finalize(p),m.reset();for(var b=1;b<x;b++)d=m.finalize(d),m.reset();l.concat(d)}return l.sigBytes=v*4,l}});t.EvpKDF=function(h,p,d){return u.create(d).compute(h,p)}}(),e.EvpKDF})}(Ar)),Ar.exports}var _r={exports:{}},Aa;function Re(){return Aa||(Aa=1,function(r,n){(function(e,t,i){r.exports=t(ce(),Et())})(ae,function(e){e.lib.Cipher||function(t){var i=e,s=i.lib,a=s.Base,c=s.WordArray,o=s.BufferedBlockAlgorithm,u=i.enc;u.Utf8;var h=u.Base64,p=i.algo,d=p.EvpKDF,f=s.Cipher=o.extend({cfg:a.extend(),createEncryptor:function(C,I){return this.create(this._ENC_XFORM_MODE,C,I)},createDecryptor:function(C,I){return this.create(this._DEC_XFORM_MODE,C,I)},init:function(C,I,P){this.cfg=this.cfg.extend(P),this._xformMode=C,this._key=I,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(C){return this._append(C),this._process()},finalize:function(C){C&&this._append(C);var I=this._doFinalize();return I},keySize:128/32,ivSize:128/32,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function C(I){return typeof I=="string"?L:y}return function(I){return{encrypt:function(P,B,K){return C(B).encrypt(I,P,B,K)},decrypt:function(P,B,K){return C(B).decrypt(I,P,B,K)}}}}()});s.StreamCipher=f.extend({_doFinalize:function(){var C=this._process(!0);return C},blockSize:1});var m=i.mode={},l=s.BlockCipherMode=a.extend({createEncryptor:function(C,I){return this.Encryptor.create(C,I)},createDecryptor:function(C,I){return this.Decryptor.create(C,I)},init:function(C,I){this._cipher=C,this._iv=I}}),S=m.CBC=function(){var C=l.extend();C.Encryptor=C.extend({processBlock:function(P,B){var K=this._cipher,J=K.blockSize;I.call(this,P,B,J),K.encryptBlock(P,B),this._prevBlock=P.slice(B,B+J)}}),C.Decryptor=C.extend({processBlock:function(P,B){var K=this._cipher,J=K.blockSize,Q=P.slice(B,B+J);K.decryptBlock(P,B),I.call(this,P,B,J),this._prevBlock=Q}});function I(P,B,K){var J,Q=this._iv;Q?(J=Q,this._iv=t):J=this._prevBlock;for(var ue=0;ue<K;ue++)P[B+ue]^=J[ue]}return C}(),v=i.pad={},x=v.Pkcs7={pad:function(C,I){for(var P=I*4,B=P-C.sigBytes%P,K=B<<24|B<<16|B<<8|B,J=[],Q=0;Q<B;Q+=4)J.push(K);var ue=c.create(J,B);C.concat(ue)},unpad:function(C){var I=C.words[C.sigBytes-1>>>2]&255;C.sigBytes-=I}};s.BlockCipher=f.extend({cfg:f.cfg.extend({mode:S,padding:x}),reset:function(){var C;f.reset.call(this);var I=this.cfg,P=I.iv,B=I.mode;this._xformMode==this._ENC_XFORM_MODE?C=B.createEncryptor:(C=B.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==C?this._mode.init(this,P&&P.words):(this._mode=C.call(B,this,P&&P.words),this._mode.__creator=C)},_doProcessBlock:function(C,I){this._mode.processBlock(C,I)},_doFinalize:function(){var C,I=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(I.pad(this._data,this.blockSize),C=this._process(!0)):(C=this._process(!0),I.unpad(C)),C},blockSize:128/32});var b=s.CipherParams=a.extend({init:function(C){this.mixIn(C)},toString:function(C){return(C||this.formatter).stringify(this)}}),E=i.format={},A=E.OpenSSL={stringify:function(C){var I,P=C.ciphertext,B=C.salt;return B?I=c.create([1398893684,1701076831]).concat(B).concat(P):I=P,I.toString(h)},parse:function(C){var I,P=h.parse(C),B=P.words;return B[0]==1398893684&&B[1]==1701076831&&(I=c.create(B.slice(2,4)),B.splice(0,4),P.sigBytes-=16),b.create({ciphertext:P,salt:I})}},y=s.SerializableCipher=a.extend({cfg:a.extend({format:A}),encrypt:function(C,I,P,B){B=this.cfg.extend(B);var K=C.createEncryptor(P,B),J=K.finalize(I),Q=K.cfg;return b.create({ciphertext:J,key:P,iv:Q.iv,algorithm:C,mode:Q.mode,padding:Q.padding,blockSize:C.blockSize,formatter:B.format})},decrypt:function(C,I,P,B){B=this.cfg.extend(B),I=this._parse(I,B.format);var K=C.createDecryptor(P,B).finalize(I.ciphertext);return K},_parse:function(C,I){return typeof C=="string"?I.parse(C,this):C}}),_=i.kdf={},R=_.OpenSSL={execute:function(C,I,P,B,K){if(B||(B=c.random(64/8)),K)var J=d.create({keySize:I+P,hasher:K}).compute(C,B);else var J=d.create({keySize:I+P}).compute(C,B);var Q=c.create(J.words.slice(I),P*4);return J.sigBytes=I*4,b.create({key:J,iv:Q,salt:B})}},L=s.PasswordBasedCipher=y.extend({cfg:y.cfg.extend({kdf:R}),encrypt:function(C,I,P,B){B=this.cfg.extend(B);var K=B.kdf.execute(P,C.keySize,C.ivSize,B.salt,B.hasher);B.iv=K.iv;var J=y.encrypt.call(this,C,I,K.key,B);return J.mixIn(K),J},decrypt:function(C,I,P,B){B=this.cfg.extend(B),I=this._parse(I,B.format);var K=B.kdf.execute(P,C.keySize,C.ivSize,I.salt,B.hasher);B.iv=K.iv;var J=y.decrypt.call(this,C,I,K.key,B);return J}})}()})}(_r)),_r.exports}var yr={exports:{}},_a;function ko(){return _a||(_a=1,function(r,n){(function(e,t,i){r.exports=t(ce(),Re())})(ae,function(e){return e.mode.CFB=function(){var t=e.lib.BlockCipherMode.extend();t.Encryptor=t.extend({processBlock:function(s,a){var c=this._cipher,o=c.blockSize;i.call(this,s,a,o,c),this._prevBlock=s.slice(a,a+o)}}),t.Decryptor=t.extend({processBlock:function(s,a){var c=this._cipher,o=c.blockSize,u=s.slice(a,a+o);i.call(this,s,a,o,c),this._prevBlock=u}});function i(s,a,c,o){var u,h=this._iv;h?(u=h.slice(0),this._iv=void 0):u=this._prevBlock,o.encryptBlock(u,0);for(var p=0;p<c;p++)s[a+p]^=u[p]}return t}(),e.mode.CFB})}(yr)),yr.exports}var Cr={exports:{}},ya;function Bo(){return ya||(ya=1,function(r,n){(function(e,t,i){r.exports=t(ce(),Re())})(ae,function(e){return e.mode.CTR=function(){var t=e.lib.BlockCipherMode.extend(),i=t.Encryptor=t.extend({processBlock:function(s,a){var c=this._cipher,o=c.blockSize,u=this._iv,h=this._counter;u&&(h=this._counter=u.slice(0),this._iv=void 0);var p=h.slice(0);c.encryptBlock(p,0),h[o-1]=h[o-1]+1|0;for(var d=0;d<o;d++)s[a+d]^=p[d]}});return t.Decryptor=i,t}(),e.mode.CTR})}(Cr)),Cr.exports}var Rr={exports:{}},Ca;function No(){return Ca||(Ca=1,function(r,n){(function(e,t,i){r.exports=t(ce(),Re())})(ae,function(e){/** @preserve
|
|
18
18
|
* Counter block mode compatible with Dr Brian Gladman fileenc.c
|
|
19
19
|
* derived from CryptoJS.mode.CTR
|
|
20
20
|
* Jan Hruby jhruby.web@gmail.com
|
|
@@ -24,7 +24,7 @@ var jc=Object.defineProperty,zc=Object.defineProperties;var Wc=Object.getOwnProp
|
|
|
24
24
|
`+c+`
|
|
25
25
|
`;const h=(m,l)=>m[0].localeCompare(l[0]),p=m=>m[0].startsWith("x-log-")||m[0].startsWith("x-acs-");try{const m=[...s.entries()].filter(p).sort(h).map(l=>l[0]+":"+l[1]+`
|
|
26
26
|
`).join("");u+=m}catch(m){}u+=n,i.size>0&&(u+="?");try{u+=[...i.entries()].sort(h).map(m=>m[0]+"="+m[1]).join("&")}catch(m){}const d=si.HmacSHA1(u,t).toString(si.enc.Base64),f="LOG "+e+":"+d;return s.set("Authorization",f),s.set("x-log-date",c),f}var Zo=(r,n,e)=>new Promise((t,i)=>{var s=o=>{try{c(e.next(o))}catch(u){i(u)}},a=o=>{try{c(e.throw(o))}catch(u){i(u)}},c=o=>o.done?t(o.value):Promise.resolve(o.value).then(s,a);c((e=e.apply(r,n)).next())});function Qo(r){return Zo(this,null,function*(){const n=new Date;if(r.refreshSTSTokenInterval||(r.refreshSTSTokenInterval=3e5),!r.stsTokenFreshTime||+n-r.stsTokenFreshTime>=r.refreshSTSTokenInterval){r.stsTokenFreshTime=n;try{yield r.refreshSTSToken()}catch(e){typeof console.error=="function"&&console.error(`Some error occured during excuting refreshSTSToken, see:
|
|
27
|
-
`+e)}}return null})}var e0=(r,n,e)=>new Promise((t,i)=>{var s=o=>{try{c(e.next(o))}catch(u){i(u)}},a=o=>{try{c(e.throw(o))}catch(u){i(u)}},c=o=>o.done?t(o.value):Promise.resolve(o.value).then(s,a);c((e=e.apply(r,n)).next())});function Hr(r){return{transString:function(n){let e={},t=0,i=!1;for(let s in n){if((s==="time"||s==="__time__")&&typeof n[s]=="number"){t=n[s],i=!0;continue}typeof n[s]=="object"?e[s]=JSON.stringify(n[s]):e[s]=String(n[s])}return e.__time__=i?t:Math.floor(new Date().getTime()/1e3),e},process:function(n,e){return e0(this,null,function*(){yield Qo(r);let t=n.slice(n.indexOf("/logstores")),i=e.length,s=Xo(e),a=new Date().toUTCString(),c=new Map,o=new Map([["Content-Type","application/json"],["Content-MD5",s],["x-log-bodyrawsize",i.toString()]]);r.securityToken&&o.set("x-acs-security-token",r.securityToken),Yo("POST",t,r.accessKeyId,r.accessKeySecret,c,o,s,a);let u=Object.fromEntries(o);return{data:e,header:u}})}}}typeof window!="undefined"&&ea(window,"stsPlugin",Hr);var t0=/d{1,4}|D{3,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|W{1,2}|[LlopSZN]|"[^"]*"|'[^']*'/g,i0=/\b(?:[A-Z]{1,3}[A-Z][TC])(?:[-+]\d{4})?|((?:Australian )?(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time)\b/g,r0=/[^-+\dA-Z]/g;function jr(r,n,e,t){if(arguments.length===1&&typeof r=="string"&&!/\d/.test(r)&&(n=r,r=void 0),r=r||r===0?r:new Date,r instanceof Date||(r=new Date(r)),isNaN(r))throw TypeError("Invalid date");n=String(Ua[n]||n||Ua.default);var i=n.slice(0,4);(i==="UTC:"||i==="GMT:")&&(n=n.slice(4),e=!0,i==="GMT:"&&(t=!0));var s=function(){return e?"getUTC":"get"},a=function(){return r[s()+"Date"]()},c=function(){return r[s()+"Day"]()},o=function(){return r[s()+"Month"]()},u=function(){return r[s()+"FullYear"]()},h=function(){return r[s()+"Hours"]()},p=function(){return r[s()+"Minutes"]()},d=function(){return r[s()+"Seconds"]()},f=function(){return r[s()+"Milliseconds"]()},m=function(){return e?0:r.getTimezoneOffset()},l=function(){return s0(r)},S=function(){return a0(r)},v={d:function(){return a()},dd:function(){return $e(a())},ddd:function(){return Ue.dayNames[c()]},DDD:function(){return Ha({y:u(),m:o(),d:a(),_:s(),dayName:Ue.dayNames[c()],short:!0})},dddd:function(){return Ue.dayNames[c()+7]},DDDD:function(){return Ha({y:u(),m:o(),d:a(),_:s(),dayName:Ue.dayNames[c()+7]})},m:function(){return o()+1},mm:function(){return $e(o()+1)},mmm:function(){return Ue.monthNames[o()]},mmmm:function(){return Ue.monthNames[o()+12]},yy:function(){return String(u()).slice(2)},yyyy:function(){return $e(u(),4)},h:function(){return h()%12||12},hh:function(){return $e(h()%12||12)},H:function(){return h()},HH:function(){return $e(h())},M:function(){return p()},MM:function(){return $e(p())},s:function(){return d()},ss:function(){return $e(d())},l:function(){return $e(f(),3)},L:function(){return $e(Math.floor(f()/10))},t:function(){return h()<12?Ue.timeNames[0]:Ue.timeNames[1]},tt:function(){return h()<12?Ue.timeNames[2]:Ue.timeNames[3]},T:function(){return h()<12?Ue.timeNames[4]:Ue.timeNames[5]},TT:function(){return h()<12?Ue.timeNames[6]:Ue.timeNames[7]},Z:function(){return t?"GMT":e?"UTC":n0(r)},o:function(){return(m()>0?"-":"+")+$e(Math.floor(Math.abs(m())/60)*100+Math.abs(m())%60,4)},p:function(){return(m()>0?"-":"+")+$e(Math.floor(Math.abs(m())/60),2)+":"+$e(Math.floor(Math.abs(m())%60),2)},S:function(){return["th","st","nd","rd"][a()%10>3?0:(a()%100-a()%10!=10)*a()%10]},W:function(){return l()},WW:function(){return $e(l())},N:function(){return S()}};return n.replace(t0,function(x){return x in v?v[x]():x.slice(1,x.length-1)})}var Ua={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"},Ue={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"]},$e=function(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;return String(n).padStart(e,"0")},Ha=function(n){var e=n.y,t=n.m,i=n.d,s=n._,a=n.dayName,c=n.short,o=c===void 0?!1:c,u=new Date,h=new Date;h.setDate(h[s+"Date"]()-1);var p=new Date;p.setDate(p[s+"Date"]()+1);var d=function(){return u[s+"Date"]()},f=function(){return u[s+"Month"]()},m=function(){return u[s+"FullYear"]()},l=function(){return h[s+"Date"]()},S=function(){return h[s+"Month"]()},v=function(){return h[s+"FullYear"]()},x=function(){return p[s+"Date"]()},b=function(){return p[s+"Month"]()},E=function(){return p[s+"FullYear"]()};return m()===e&&f()===t&&d()===i?o?"Tdy":"Today":v()===e&&S()===t&&l()===i?o?"Ysd":"Yesterday":E()===e&&b()===t&&x()===i?o?"Tmw":"Tomorrow":a},s0=function(n){var e=new Date(n.getFullYear(),n.getMonth(),n.getDate());e.setDate(e.getDate()-(e.getDay()+6)%7+3);var t=new Date(e.getFullYear(),0,4);t.setDate(t.getDate()-(t.getDay()+6)%7+3);var i=e.getTimezoneOffset()-t.getTimezoneOffset();e.setHours(e.getHours()-i);var s=(e-t)/(864e5*7);return 1+Math.floor(s)},a0=function(n){var e=n.getDay();return e===0&&(e=7),e},n0=function(n){return(String(n).match(i0)||[""]).pop().replace(r0,"").replace(/GMT\+0000/g,"UTC")};const{BrowserUtil:o0}=G.AliRTS,Xt={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Gecko:"Gecko",WebKit:"WebKit"},Ci=(r,n)=>{const e=n.match(r);return e&&e.length>0&&e[1]||""},c0=[{test:[/\sedg\//i,[/edg([ea]|ios)/i]],describe(r){if(/\sedg\//i.test(r))return{name:Xt.Blink};const e=Ci(/edge\/(\d+(\.?_?\d+)+)/i,r);return{name:Xt.EdgeHTML,version:e}}},{test:[/trident/i],describe(r){const n={name:Xt.Trident},e=Ci(/trident\/(\d+(\.?_?\d+)+)/i,r);return e&&(n.version=e),n}},{test(r){const n=/gecko/i.test(r),e=/like gecko/i.test(r);return n&&!e},describe(r){const n={name:Xt.Gecko},e=Ci(/gecko\/(\d+(\.?_?\d+)+)/i,r);return e&&(n.version=e),n}},{test:[/(apple)?webkit\/537\.36/i],describe(){return{name:Xt.Blink}}},{test:[/(apple)?webkit/i],describe(r){const n={name:Xt.WebKit},e=Ci(/webkit\/(\d+(\.?_?\d+)+)/i,r);return e&&(n.version=e),n}}],zr=(r,n)=>r.find(e=>{if(typeof e.test=="function")return e.test(n);if(Array.isArray(e.test))return e.test.some(t=>typeof t=="string"?n.indexOf(t)>-1:t instanceof RegExp?t.test(n):!1)}),u0=()=>{try{const r=navigator.userAgent||"",n=zr(c0,r);if(n){const e=n.describe(r);return`${e.name}/${e.version||o0.browserVersion}`}}catch(r){}return navigator.userAgent},h0=[{test:["wow64","win64","x64"],describe(){return"amd64"}},{test:["i686","x86"],describe(){return"x86"}},{test:["aarch64","arm64"],describe(){return"arm64"}},{test:["arm"],describe(){return"arm"}}],ja=()=>{let r="unknown";try{const n=navigator.userAgent||"",e=zr(h0,n);if(!e)return r;r=e.describe(n)}catch(n){}return r},d0=[{test:[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],describe(){return"Samsung"}},{test:[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i,/\((ipad);[-\w\),; ]+apple/i,/(macintosh);/i],describe(){return"Apple"}},{test:[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],describe(){return"Huawei"}},{test:[/(?:honor)([-\w ]+)[;\)]/i],describe(){return"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(){return"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(){return"Oppo"}},{test:[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],describe(){return"Vivo"}},{test:[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],describe(){return"Realme"}},{test:[/(pixel c)\b/i,/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],describe(){return"Google"}},{test:[/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],describe(){return"ZTE"}},{test:[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],describe(){return"Meizu"}}],l0=()=>{let r="Unknown";try{const n=navigator.userAgent||"",e=zr(d0,n);if(!e)return r;r=e.describe(n)}catch(n){}return r},{BrowserUtil:za,SystenUtil:Wa}=G.AliRTS,f0=ja(),p0="woMMssV6jmyol9fr",g0=200,Ri=10*60*1e3,Ii={host:"cn-hangzhou.log.aliyuncs.com",project:"alivc-aio",logstore:"logger",time:10,count:10};function Wr(){return jr(new Date,"HH:MM:ss.l")}function $a(){return jr(new Date,"isoDate")}var $r=(r=>(r[r.DEBUG=0]="DEBUG",r[r.INFO=1]="INFO",r[r.API=2]="API",r[r.WARNING=3]="WARNING",r[r.ERROR=4]="ERROR",r[r.NONE=5]="NONE",r))($r||{});class m0{constructor(){g(this,"tracker");g(this,"slsPlugin");g(this,"stsData");g(this,"stsExpiration",Date.now());g(this,"clientId",it());g(this,"bSesid",it());g(this,"logLevel",3);g(this,"appId","");g(this,"sessionId","");g(this,"logCache",[]);g(this,"updateTaskTimer");g(this,"endReported",!0);g(this,"logSequence",0);g(this,"sendLogBeforeUnload",n=>w(this,null,function*(){if(!this.slsPlugin)return;this.logSequence+=1,n.unshift(this.getLogParams(710203,{log:`[${$a()} ${Wr()}] [INF] beforeunload`,stat_log_seq:this.logSequence}));const e=`https://${Ii.project}.${Ii.host}/logstores/${Ii.logstore}`,t={__logs__:n.map(a=>this.slsPlugin.transString(a))},{data:i,header:s}=yield this.slsPlugin.process(e,JSON.stringify(t));fetch(e,{keepalive:!0,method:"POST",headers:s,body:i})}));g(this,"logMethod",(n,e=console.log)=>(...t)=>{let i=Wr();this.logLevel<=n&&e(i,...t);let s=Oe.paramArrayToString(t);n>0&&this.addLog(s)});g(this,"d",this.logMethod(0,console.debug));g(this,"i",this.logMethod(1));g(this,"w",this.logMethod(3,console.warn));g(this,"e",this.logMethod(4,(...n)=>{const[e,...t]=n;console.error(e,"<error>",t)}));g(this,"ev",this.logMethod(2));g(this,"a",this.logMethod(2,(...n)=>{const[e,...t]=n;if(t.length>2){const i=`${t[1]}`;i.startsWith("__g__")&&console.group(`${i.substring(5)}_${t[2]}`)}console.log(e,...t)}));g(this,"ar",this.logMethod(2,(...n)=>{const[e,...t]=n;console.log(e,...t),t.length>2&&`${t[1]}`.startsWith("__g__")&&console.groupEnd()}));g(this,"ae",this.logMethod(2,(...n)=>{const[e,...t]=n;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=it(),this.endReported=!0,this.logSequence=0,this.appId="",this.sessionId=""}startSTSUpdateTask(){return w(this,null,function*(){this.updateTaskTimer&&clearTimeout(this.updateTaskTimer);try{const n=yield this.refreshSTSToken();this.createTracker(n)}catch(n){}this.updateTaskTimer=setTimeout(()=>{this.startSTSUpdateTask()},Ri)})}refreshSTSToken(){return w(this,null,function*(){if(!this.stsData||this.stsExpiration<=Date.now()-Ri){const n=yield this.requestSTSToken(),e=new Date(n==null?void 0:n.Expiration).getTime()||0,t=Date.now()+Ri;this.stsExpiration=Math.max(e,t),this.stsData=n}return this.stsData})}requestSTSToken(){const n=Date.now(),e=`${this.clientId}|${p0}|${n}`,i={Action:"AssumeSlsRoleV2",AuthInfo:si.MD5(e).toString(si.enc.Hex),ClientId:this.clientId,BusinessType:"logger",AppVersion:"1.0",Version:"2017-03-14",AuthTimestamp:`${n}`,TerminalType:"web",DeviceModel:"",Format:"JSON",SignatureMethod:"HMAC-SHA1",SignatureVersion:"1.0",Timestamp:jr(n,"isoUtcDateTime")},a=`https://slsrole.alicdn.com/?${new URLSearchParams(i).toString()}`;return fetch(a).then(c=>c.json()).then(c=>JSON.parse(window.atob(c.SlsAuthResult)))}createTracker(n){if(!this.tracker){const e={accessKeyId:n.AccessKeyId,accessKeySecret:n.AccessKeySecret,securityToken:n.SecurityToken,refreshSTSTokenInterval:Ri,stsTokenFreshTime:void 0,refreshSTSToken:()=>{this.refreshSTSToken().then(s=>{e.accessKeyId=s.AccessKeyId,e.accessKeySecret=s.AccessKeySecret,e.securityToken=s.SecurityToken}).catch(()=>{})}},t=new rr(Ii),i=Hr(e);t.useStsPlugin(i),this.slsPlugin=i,this.tracker=t,this.reportStartAndCache()}}changeConfig(n){n.logLevel!==void 0&&n.logLevel>=0&&n.logLevel<=5&&(this.logLevel=n.logLevel)}setSessionID(n,e){!n||!e||(this.appId=n,this.sessionId=e,this.reportStartAndCache())}reportStartAndCache(){if(!this.tracker||!this.sessionId)return;this.endReported=!1;const n={task_btm_sec:0,task_duration:0,task_etm_sec:0,task_type:"session"},e=[this.getLogParams(710201,n),this.getLogParams(710202,n)];this.tracker.sendBatchLogsImmediate(e),this.logCache.forEach(t=>{this.sendLog(t)})}reportEnd(n=!1){if(!this.tracker||!this.sessionId||this.endReported){this.reset();return}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)];n?this.sendLogBeforeUnload(t):(this.tracker.sendBatchLogsImmediate(t),this.endReported=!0),this.reset()}getLogParams(n,e){return Y({appid:`${window.location.host}`,appid_list:this.appId,appver:"",b_sesid:this.bSesid,biz_type:"rtc",cpu_info:f0,db:za.browserName,dm:za.browserVersion,install_uuid:this.clientId,logger_v:"0.0.1",os:Wa.systemName,osv:Wa.systemVersion,p_sesid:this.bSesid,sdk_version:_i,sdkname:"AliRTCSdk",stm:Date.now(),tar_pf:"web",traceid:this.sessionId,event_id:n},e||{})}sendLog(n){if(!this.tracker||!this.sessionId)return;this.logSequence+=1;const e=this.getLogParams(710203,{log:n,stat_log_seq:this.logSequence});this.tracker.send(e)}addLog(n){const e=Wr(),i=`[${$a()} ${e}] ${n}`;!this.sessionId||!this.tracker?(this.logCache.push(i),this.logCache.length>=g0&&this.logCache.shift()):this.sendLog(i)}}class O{static getLogger(){return this.logger||(this.logger=new m0),this.logger}static init(){this.getLogger().init()}static destroy(){this.getLogger().destroy()}static setLogLevel(n){this.getLogger().changeConfig({logLevel:n})}static setSessionID(n,e){this.getLogger().setSessionID(n,e)}static reportEnd(){this.getLogger().reportEnd()}static interface(...n){this.getLogger().a("[API]",...n)}static interfaceResult(n,e,t,...i){t?this.getLogger().ar("[ARE]",n,e,...i):this.getLogger().ae("[ARE]",n,e,...i)}static event(...n){this.getLogger().ev("[EVT]",...n)}static debug(...n){this.getLogger().d("[DBG]",...n)}static info(...n){this.getLogger().i("[INF]",...n)}static warn(...n){this.getLogger().w("[WARN]",...n)}static error(...n){this.getLogger().e("[ERR]",...n)}}g(O,"logger");const S0=r=>w(this,null,function*(){const n=new G.AliRTS.SupportUtil;let e={support:!1,detail:{isWebRTCSupported:n.checkMediaDevices()&&n.checkWebRtcSupport(),isH264DecodeSupported:!1,isH264EncodeSupported:!1,isScreenShareSupported:!1,isSendMediaExtensionMsgSupported:!1,isBrowserSupported:n.checkBrowser({errorCode:0,message:""})}};if(e.support=e.detail.isWebRTCSupported&&e.detail.isBrowserSupported,n.checkWebRtcSupport()&&r!=="sendonly"){const t=yield n.checkH264Decode();e.detail.isH264DecodeSupported=t,e.support=e.support&&t}if(n.checkWebRtcSupport()&&r!=="recvonly"){const t=yield n.checkH264Encode();e.detail.isH264EncodeSupported=t,e.support=e.support&&t}return e.detail.isScreenShareSupported=n.checkWebRtcSupport()&&n.checkScreenCapture()&&!G.AliRTS.SystenUtil.isAndroid&&!G.AliRTS.SystenUtil.isIos,e.detail.isSendMediaExtensionMsgSupported=n.checkWebRtcSupport()&&n.checkEncodedTransformSupport(),e}),x0=()=>new G.AliRTS.SupportUtil().checkScreenCapture();var ve=(r=>(r[r.AliRtcSdkStreamTypeCapture=0]="AliRtcSdkStreamTypeCapture",r[r.AliRtcSdkStreamTypeScreen=1]="AliRtcSdkStreamTypeScreen",r))(ve||{}),Ka=(r=>(r[r.PRE_PROCESSOR=0]="PRE_PROCESSOR",r[r.POST_PROCESSOR=1]="POST_PROCESSOR",r))(Ka||{}),ai=(r=>(r[r.AUDIO=0]="AUDIO",r[r.VIDEO=1]="VIDEO",r[r.BOTH=2]="BOTH",r))(ai||{});class Bt extends re{constructor(e,t=ve.AliRtcSdkStreamTypeCapture,i=1){super();g(this,"name");g(this,"options");g(this,"type",0);g(this,"streamType");g(this,"trackType");g(this,"zIndex",1);g(this,"_isEnable",!0);g(this,"lastInputAudioTrack");g(this,"lastOutputAudioTrack");g(this,"lastInputVideoTrack");g(this,"lastOutputVideoTrack");g(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 ni=(r=>(r[r.LiveTranscodingSingle=0]="LiveTranscodingSingle",r[r.LiveTranscodingMix=1]="LiveTranscodingMix",r))(ni||{}),Kr=(r=>(r[r.LiveTranscodingOrigin=0]="LiveTranscodingOrigin",r[r.LiveTranscodingAudio=1]="LiveTranscodingAudio",r[r.LiveTranscodingVideo=2]="LiveTranscodingVideo",r))(Kr||{}),Yt=(r=>(r[r.LiveTranscodingCamera=0]="LiveTranscodingCamera",r[r.LiveTranscodingShareScreen=1]="LiveTranscodingShareScreen",r))(Yt||{});const oi={0:"camera",1:"shareScreen"};var qr=(r=>(r[r.LiveTranscoding_Profile_1IN_1080P=0]="LiveTranscoding_Profile_1IN_1080P",r[r.LiveTranscoding_Profile_1IN_720P=1]="LiveTranscoding_Profile_1IN_720P",r[r.LiveTranscoding_Profile_1IN_360P=2]="LiveTranscoding_Profile_1IN_360P",r[r.LiveTranscoding_Profile_2IN_1080P=3]="LiveTranscoding_Profile_2IN_1080P",r[r.LiveTranscoding_Profile_2IN_720P=4]="LiveTranscoding_Profile_2IN_720P",r[r.LiveTranscoding_Profile_2IN_360P=5]="LiveTranscoding_Profile_2IN_360P",r[r.LiveTranscoding_Profile_4IN_1080P=6]="LiveTranscoding_Profile_4IN_1080P",r[r.LiveTranscoding_Profile_4IN_720P=7]="LiveTranscoding_Profile_4IN_720P",r[r.LiveTranscoding_Profile_4IN_360P=8]="LiveTranscoding_Profile_4IN_360P",r[r.LiveTranscoding_Profile_9IN_1080P=9]="LiveTranscoding_Profile_9IN_1080P",r[r.LiveTranscoding_Profile_9IN_720P=10]="LiveTranscoding_Profile_9IN_720P",r[r.LiveTranscoding_Profile_9IN_360P=11]="LiveTranscoding_Profile_9IN_360P",r[r.LiveTranscoding_Profile_12IN_1080P=12]="LiveTranscoding_Profile_12IN_1080P",r[r.LiveTranscoding_Profile_12IN_720P=13]="LiveTranscoding_Profile_12IN_720P",r[r.LiveTranscoding_Profile_12IN_360P=14]="LiveTranscoding_Profile_12IN_360P",r[r.LiveTranscoding_Profile_16IN_1080P=15]="LiveTranscoding_Profile_16IN_1080P",r[r.LiveTranscoding_Profile_16IN_720P=16]="LiveTranscoding_Profile_16IN_720P",r[r.LiveTranscoding_Profile_16IN_360P=17]="LiveTranscoding_Profile_16IN_360P",r[r.LiveTranscoding_Profile_Mixed=9999]="LiveTranscoding_Profile_Mixed",r))(qr||{});const v0={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 wi=(r=>(r[r.LiveTranscoding_HZ_48000=48e3]="LiveTranscoding_HZ_48000",r[r.LiveTranscoding_HZ_44100=44100]="LiveTranscoding_HZ_44100",r[r.LiveTranscoding_HZ_32000=32e3]="LiveTranscoding_HZ_32000",r[r.LiveTranscoding_HZ_16000=16e3]="LiveTranscoding_HZ_16000",r[r.LiveTranscoding_HZ_8000=8e3]="LiveTranscoding_HZ_8000",r))(wi||{}),ci=(r=>(r[r.LiveTranscodingNoBody=0]="LiveTranscodingNoBody",r[r.LiveTranscodingBody=1]="LiveTranscodingBody",r))(ci||{}),ui=(r=>(r[r.NOTO_SERIF_CJKSC_REGULAR=0]="NOTO_SERIF_CJKSC_REGULAR",r[r.ALIBABA_PUHUITI_REGULAR=1]="ALIBABA_PUHUITI_REGULAR",r[r.ALIBABA_PUHUITI_BOLD=2]="ALIBABA_PUHUITI_BOLD",r[r.ALIBABA_PUHUITI_Heavy=3]="ALIBABA_PUHUITI_Heavy",r[r.ALIBABA_PUHUITI_LIGHT=4]="ALIBABA_PUHUITI_LIGHT",r[r.ALIBABA_PUHUITI_MEDIUM=5]="ALIBABA_PUHUITI_MEDIUM",r))(ui||{}),Jr=(r=>(r[r.LiveTranscodingOrigin=0]="LiveTranscodingOrigin",r[r.LiveTranscodingCrop=1]="LiveTranscodingCrop",r[r.LiveTranscodingFill=2]="LiveTranscodingFill",r))(Jr||{}),Ti=(r=>(r[r.LiveTranscodingNormal=0]="LiveTranscodingNormal",r[r.LiveTranscodingVirtualBackground=1]="LiveTranscodingVirtualBackground",r))(Ti||{}),Gr=(r=>(r[r.LiveTranscodingState_IDLE=0]="LiveTranscodingState_IDLE",r[r.LiveTranscodingState_CONNNECT=1]="LiveTranscodingState_CONNNECT",r[r.LiveTranscodingState_RUNNING=2]="LiveTranscodingState_RUNNING",r[r.LiveTranscodingState_RECOVERING=3]="LiveTranscodingState_RECOVERING",r[r.LiveTranscodingState_FAILURE=4]="LiveTranscodingState_FAILURE",r[r.LiveTranscodingState_END=5]="LiveTranscodingState_END",r))(Gr||{}),ut=(r=>(r[r.LiveTranscodingErrorPublishOk=0]="LiveTranscodingErrorPublishOk",r[r.LiveTranscodingErrorStreamNotFound=17825793]="LiveTranscodingErrorStreamNotFound",r[r.LiveTranscodingErrorStreamAlreadyExist=17825794]="LiveTranscodingErrorStreamAlreadyExist",r[r.LiveTranscodingErrorInvalidParam=17825795]="LiveTranscodingErrorInvalidParam",r[r.LiveTranscodingErrorInternalError=17825796]="LiveTranscodingErrorInternalError",r[r.LiveTranscodingErrorRtmpServerError=17825797]="LiveTranscodingErrorRtmpServerError",r[r.LiveTranscodingErrorRtmpStreamUrlError=17825798]="LiveTranscodingErrorRtmpStreamUrlError",r[r.LiveTranscodingErrorPublishTimeout=17825799]="LiveTranscodingErrorPublishTimeout",r[r.LiveTranscodingErrorNotAuthorized=17825800]="LiveTranscodingErrorNotAuthorized",r))(ut||{}),Xr=(r=>(r[r.TrascodingPublishTaskStatusStart=0]="TrascodingPublishTaskStatusStart",r[r.TrascodingPublishTaskStatusUpdate=1]="TrascodingPublishTaskStatusUpdate",r[r.TrascodingPublishTaskStatusStop=2]="TrascodingPublishTaskStatusStop",r))(Xr||{}),He=(r=>(r[r.MPU_TASK_TRANSACTION_START=0]="MPU_TASK_TRANSACTION_START",r[r.MPU_TASK_TRANSACTION_UPDATE=1]="MPU_TASK_TRANSACTION_UPDATE",r[r.MPU_TASK_TRANSACTION_STOP=2]="MPU_TASK_TRANSACTION_STOP",r[r.MPU_TASK_TRANSACTION_LIST=3]="MPU_TASK_TRANSACTION_LIST",r[r.MPU_TASK_TRANSACTION_POLLING=4]="MPU_TASK_TRANSACTION_POLLING",r[r.MPU_TASK_TRANSACTION_ACKNOWLEDGE=5]="MPU_TASK_TRANSACTION_ACKNOWLEDGE",r[r.MPU_TASK_TRANSACTION_END=6]="MPU_TASK_TRANSACTION_END",r))(He||{});const b0={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 Yr{constructor(n,e,t,i,s,a,c,o){g(this,"videoWidth");g(this,"videoHeight");g(this,"videoFramerate",20);g(this,"videoBitrate",2e3);g(this,"videoGop",30);g(this,"audioSamplerate",wi.LiveTranscoding_HZ_44100);g(this,"audioBitrate",500);g(this,"audioChannels",1);this.videoWidth=n,this.videoHeight=e,t&&(this.videoFramerate=t),i&&(this.videoBitrate=i),s&&(this.videoGop=s),a&&(this.audioSamplerate=a),c&&(this.audioBitrate=c),o&&(this.audioChannels=o)}}const Zr=r=>((r&16711680)>>16)+(r&65280)+((r&255)<<16),Ye=(r=0,n)=>{if(n==0)return 0;let e=r/n;return e<0&&(e=0),e>1&&(e=1),e};class Di{constructor(n,e,t){g(this,"mixMode",ni.LiveTranscodingSingle);g(this,"singleParam");g(this,"mixParam");n&&(this.mixMode=n),e&&(this.singleParam=e),t&&(this.mixParam=t)}toJson(n,e,t,i,s){const a={appid:e.appId,channelid:e.channelId};if(n===He.MPU_TASK_TRANSACTION_POLLING||n===He.MPU_TASK_TRANSACTION_LIST||n===He.MPU_TASK_TRANSACTION_ACKNOWLEDGE)return n===He.MPU_TASK_TRANSACTION_ACKNOWLEDGE&&(a.messageid=s),a;if(a.taskid=t,n!==He.MPU_TASK_TRANSACTION_STOP){if(a.mixmode=this.mixMode,i&&(a.streamurl=i),this.mixMode===ni.LiveTranscodingSingle){const c=this.singleParam;if(c){a.streamtype=c.streamType,c.sourceType===Yt.LiveTranscodingShareScreen?a.sourcetype=oi[c.sourceType]:a.sourcetype=oi[Yt.LiveTranscodingCamera];const o=[];c.userId&&o.push(c.userId),a.subspecusers=o}}else if(n===He.MPU_TASK_TRANSACTION_START||n===He.MPU_TASK_TRANSACTION_UPDATE){const c=this.mixParam;if(c){c.taskProfile&&(a.taskprofile=v0[c.taskProfile]);const o=c.encodeParam||new Yr(1280,720);let u=o.videoWidth,h=o.videoHeight;const p={};Object.keys(o).forEach(f=>{const m=o[f];m>0&&(p[f.toLowerCase()]=m)}),p.lowbitratehighquality=0,a.encodeparam=p,a.backgrounds=c.backgrounds.map(f=>f.toJson(u,h)),a.watermarks=c.watermarks.map(f=>f.toJson(u,h)),a.clockwidgets=c.clockWidgets.map(f=>f.toJson(u,h));const d=c.users.map(f=>f.userId);a.subspecusers=[...new Set(d)],a.layouts=[{audiomixcount:c.users.length,panes:c.users.map((f,m)=>f.toJson(m,u,h,c.mediaProcessMode))}],a.layoutids=["0"],a.cropmode=c.cropMode,a.backgroundcolor=Zr(c.backgroundColor),a.taskmode=c.mediaProcessMode}}}return a}}var pt=(r=>(r.pre="pre",r.prod="prod",r))(pt||{}),gt=(r=>(r.AliRtcSdkCommunication="communication",r.AliRtcSdkInteractiveLive="interactive_live",r.AliRtcSdkInteractiveWithLowLatencyLive="cdn_live",r))(gt||{}),At=(r=>(r.AliRtcSdkInteractive="interactive",r.AliRtcSdkLive="live",r))(At||{}),ht=(r=>(r[r.AliEngineLocalDeviceTypeUnknown=0]="AliEngineLocalDeviceTypeUnknown",r[r.AliEngineLocalDeviceTypeMic=1]="AliEngineLocalDeviceTypeMic",r[r.AliEngineLocalDeviceTypeSpeaker=2]="AliEngineLocalDeviceTypeSpeaker",r[r.AliEngineLocalDeviceTypeAudioDevice=3]="AliEngineLocalDeviceTypeAudioDevice",r[r.AliEngineLocalDeviceTypeCamera=4]="AliEngineLocalDeviceTypeCamera",r[r.AliEngineLocalDeviceTypeDisplay=5]="AliEngineLocalDeviceTypeDisplay",r[r.AliEngineLocalDeviceTypeVideoDevice=6]="AliEngineLocalDeviceTypeVideoDevice",r))(ht||{}),Ee=(r=>(r[r.AliEngineLocalDeviceExceptionTypeUnknown=0]="AliEngineLocalDeviceExceptionTypeUnknown",r[r.AliEngineLocalDeviceExceptionTypeMicOpenFail=1]="AliEngineLocalDeviceExceptionTypeMicOpenFail",r[r.AliEngineLocalDeviceExceptionTypeMicInterrupt=2]="AliEngineLocalDeviceExceptionTypeMicInterrupt",r[r.AliEngineLocalDeviceExceptionTypeMicAuthFail=3]="AliEngineLocalDeviceExceptionTypeMicAuthFail",r[r.AliEngineLocalDeviceExceptionTypeMicNotAvailable=4]="AliEngineLocalDeviceExceptionTypeMicNotAvailable",r[r.AliEngineLocalDeviceExceptionTypeSpeakerOpenFail=5]="AliEngineLocalDeviceExceptionTypeSpeakerOpenFail",r[r.AliEngineLocalDeviceExceptionTypeSpeakerInterrupt=6]="AliEngineLocalDeviceExceptionTypeSpeakerInterrupt",r[r.AliEngineLocalDeviceExceptionTypeSpeakerNotAvailable=7]="AliEngineLocalDeviceExceptionTypeSpeakerNotAvailable",r[r.AliEngineLocalDeviceExceptionTypeAudioDeviceException=8]="AliEngineLocalDeviceExceptionTypeAudioDeviceException",r[r.AliEngineLocalDeviceExceptionTypeCameraOpenFail=9]="AliEngineLocalDeviceExceptionTypeCameraOpenFail",r[r.AliEngineLocalDeviceExceptionTypeCameraInterrupt=10]="AliEngineLocalDeviceExceptionTypeCameraInterrupt",r[r.AliEngineLocalDeviceExceptionTypeCameraAuthFail=11]="AliEngineLocalDeviceExceptionTypeCameraAuthFail",r[r.AliEngineLocalDeviceExceptionTypeDisplayException=12]="AliEngineLocalDeviceExceptionTypeDisplayException",r[r.AliEngineLocalDeviceExceptionTypeVideoDeviceException=13]="AliEngineLocalDeviceExceptionTypeVideoDeviceException",r))(Ee||{}),de=(r=>(r[r.AliRtcConnectionStatusInit=0]="AliRtcConnectionStatusInit",r[r.AliRtcConnectionStatusDisconnected=1]="AliRtcConnectionStatusDisconnected",r[r.AliRtcConnectionStatusConnecting=2]="AliRtcConnectionStatusConnecting",r[r.AliRtcConnectionStatusConnected=3]="AliRtcConnectionStatusConnected",r[r.AliRtcConnectionStatusReconnecting=4]="AliRtcConnectionStatusReconnecting",r[r.AliRtcConnectionStatusFailed=5]="AliRtcConnectionStatusFailed",r))(de||{}),Nt=(r=>(r[r.AliRtcConnectionChangedDummyReason=0]="AliRtcConnectionChangedDummyReason",r[r.AliRtcConnectionMediaPathChanged=1]="AliRtcConnectionMediaPathChanged",r[r.AliRtcConnectionSignalingHeartbeatTimeout=2]="AliRtcConnectionSignalingHeartbeatTimeout",r[r.AliRtcConnectionSignalingHeartbeatAlive=3]="AliRtcConnectionSignalingHeartbeatAlive",r[r.AliRtcConnectionSignalingHttpDnsResolved=4]="AliRtcConnectionSignalingHttpDnsResolved",r[r.AliRtcConnectionSignalingHttpDnsFailure=5]="AliRtcConnectionSignalingHttpDnsFailure",r[r.AliRtcConnectionSignalingGslbFailure=6]="AliRtcConnectionSignalingGslbFailure",r[r.AliRtcConnectionSignalingGslbSuccess=7]="AliRtcConnectionSignalingGslbSuccess",r[r.AliRtcConnectionSignalingJoinRoomFailure=8]="AliRtcConnectionSignalingJoinRoomFailure",r[r.AliRtcConnectionSignalingJoinRoomSuccess=9]="AliRtcConnectionSignalingJoinRoomSuccess",r[r.AliRtcConnectionSignalingLeaveRoom=10]="AliRtcConnectionSignalingLeaveRoom",r[r.AliRtcConnectionSignalingConnecting=11]="AliRtcConnectionSignalingConnecting",r[r.AliRtcConnectionChangedNetworkInterrupted=12]="AliRtcConnectionChangedNetworkInterrupted",r))(Nt||{}),Qr=(r=>(r[r.AliRtcUserOfflineQuit=0]="AliRtcUserOfflineQuit",r[r.AliRtcUserOfflineDropped=1]="AliRtcUserOfflineDropped",r[r.AliRtcUserOfflineBecomeAudience=2]="AliRtcUserOfflineBecomeAudience",r))(Qr||{}),Zt=(r=>(r[r.AliRtcAudioTrackNo=0]="AliRtcAudioTrackNo",r[r.AliRtcAudioTrackMic=1]="AliRtcAudioTrackMic",r[r.AliRtcAudioTrackDual=2]="AliRtcAudioTrackDual",r))(Zt||{}),ne=(r=>(r[r.AliRtcVideoTrackNo=0]="AliRtcVideoTrackNo",r[r.AliRtcVideoTrackCamera=1]="AliRtcVideoTrackCamera",r[r.AliRtcVideoTrackScreen=2]="AliRtcVideoTrackScreen",r[r.AliRtcVideoTrackBoth=3]="AliRtcVideoTrackBoth",r))(ne||{}),Z=(r=>(r[r.AliRtcStatePublishIdle=0]="AliRtcStatePublishIdle",r[r.AliRtcStateNoPublish=1]="AliRtcStateNoPublish",r[r.AliRtcStatePublishing=2]="AliRtcStatePublishing",r[r.AliRtcStatePublished=3]="AliRtcStatePublished",r))(Z||{}),le=(r=>(r[r.AliRtcStateSubscribeIdle=0]="AliRtcStateSubscribeIdle",r[r.AliRtcStateNoSubscribe=1]="AliRtcStateNoSubscribe",r[r.AliRtcStateSubscribing=2]="AliRtcStateSubscribing",r[r.AliRtcStateSubscribed=3]="AliRtcStateSubscribed",r))(le||{}),Ie=(r=>(r[r.AliRtcVideoStreamTypeNone=0]="AliRtcVideoStreamTypeNone",r[r.AliRtcVideoStreamTypeHigh=1]="AliRtcVideoStreamTypeHigh",r[r.AliRtcVideoStreamTypeLow=2]="AliRtcVideoStreamTypeLow",r))(Ie||{}),hi=(r=>(r[r.CAMERA_INVALID=-1]="CAMERA_INVALID",r[r.CAMERA_REAR=0]="CAMERA_REAR",r[r.CAMERA_FRONT=1]="CAMERA_FRONT",r))(hi||{});const qa=12,Ja=5e3,ti=class ti extends re{constructor(e){super();g(this,"ws");g(this,"socketStatus",0);g(this,"wsUrl","");g(this,"lastConnectStartTime",0);g(this,"maxConnectRetryCount",qa);g(this,"connectRetryCount",0);g(this,"gotErr",!1);g(this,"closedByInvoke",!0);g(this,"isReconnecting",!1);g(this,"networkAvailableChecked",!0);g(this,"reconnectTimeoutId",0);this.maxConnectRetryCount=e!=null?e:qa,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):!1}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){O.info(`[${ti.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&&Oe.isNetworkAvailable().then(t=>{t&&console.error(ti.logName,"onError, Network is available, token may be invalid")})}onClose(e){return w(this,null,function*(){if(this.closedByInvoke){this.socketStatus=0;return}if(O.info(`[${ti.logName}]`,`onClose, code: ${e.code}, reason: ${e.reason}, status: ${status}, retryCount: ${this.connectRetryCount}`),(yield Oe.isNetworkAvailable())&&!this.networkAvailableChecked){this.reconnect(),this.networkAvailableChecked=!0;return}else this.connectRetryCount||this.emit("onNetworkError"),this.reconnectTimeoutId||(this.connectRetryCount+=1,this.connectRetryCount>this.maxConnectRetryCount?this.emit("onConnectFail"):Date.now()-this.lastConnectStartTime>=Ja?this.reconnect():this.reconnectTimeoutId=window.setTimeout(()=>{this.reconnect()},Ja));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)}};g(ti,"logName","Socket");let es=ti;var Ae=(r=>(r.KEEPALIVE="keepalive",r.JOINCHANNEL="joinchannel",r.NOTIFYJOIN="notifyjoin",r.NOTIFYSTATUS="notifystatus",r.STATUSREPORT="statusreport",r.LEAVECHANNEL="leavechannel",r.NOTIFYLEAVE="notifyleave",r.NOTIFYPUBLISH="notifypublish",r.BYE="bye",r.RECONNECT="reconnect",r.PUBLISH="publish",r.REFRESHURL="refreshurl",r.UNSUBSCRIBE="unsubscribe",r.ROLEUPDATE="roleupdate",r))(Ae||{});class E0{constructor(n,e){g(this,"authInfo");g(this,"userName");g(this,"seqIndex",0);this.authInfo=n,this.userName=e}get roleAuth(){if(this.authInfo.role){const{timestamp:n,nonce:e,token:t,role:i}=this.authInfo;return{timestamp:n,nonce:e,token:t,tokenrole:i}}}refreshAuthInfo(n){this.authInfo=n}getSeqIndex(){return this.seqIndex}createKeepAlivePackage(){return this.createBaseSendPackage("keepalive")}createJoinPackage(){let n=this.createBaseSendPackage("joinchannel");return n.header.displayName=this.userName,n.header.clientversion=Oe.getVersionNumber().toString(),n.header.platform=Zs,this.roleAuth&&(n.data.auth=this.roleAuth),n}crateLeavePackage(){return this.createBaseSendPackage("leavechannel")}createStatusPackage(n){let e=this.createBaseSendPackage("statusreport");return e.header.displayName=this.userName,e.data.status=n,e}createPublishPackage(){let n=this.createBaseSendPackage("publish");return n.data.users=[{}],this.roleAuth&&(n.data.auth=this.roleAuth),n}createRoleUpdatePackage(){let n=this.createBaseSendPackage("roleupdate");return n.header.displayName=this.userName,n}createReconnectPackage(n){let e=this.createBaseSendPackage("reconnect");return e.header.displayName=this.userName,e.header.clientversion=Oe.getVersionNumber().toString(),e.header.platform=Zs,e.data=Y(Y({},e.data),n!=null?n:{}),this.roleAuth&&(e.data.auth=this.roleAuth),e}createRefreshUrlPackage(){let n=this.createBaseSendPackage("refreshurl");return n.header.displayName=this.userName,n}createResponsePackage(n,e){return{version:1,code:200,tid:n,msgtype:e}}createBaseSendPackage(n){var t;return++this.seqIndex,{version:1,msgtype:n,tid:it(),header:{appid:this.authInfo.appId,channelid:this.authInfo.channelId,sessionid:(t=this.authInfo.sessionId)!=null?t:"",userid:this.authInfo.userId},data:{seq:this.seqIndex}}}}var U=(r=>(r[r.ERR_JOIN_ALREADY_JOINED=16843521]="ERR_JOIN_ALREADY_JOINED",r[r.ERR_JOIN_BAD_APPID=33620481]="ERR_JOIN_BAD_APPID",r[r.ERR_JOIN_INVALID_APPID=33620482]="ERR_JOIN_INVALID_APPID",r[r.ERR_JOIN_BAD_CHANNEL=33620484]="ERR_JOIN_BAD_CHANNEL",r[r.ERR_JOIN_INVALID_CHANNEL=33620483]="ERR_JOIN_INVALID_CHANNEL",r[r.ERR_JOIN_BAD_TOKEN=33620485]="ERR_JOIN_BAD_TOKEN",r[r.ERR_JOIN_TIMEOUT=16908804]="ERR_JOIN_TIMEOUT",r[r.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD=16974081]="ERR_JOIN_ERR_JOIN_BAD_PARAMBAD",r[r.ERR_JOIN_CHANNEL_FAILED=16974338]="ERR_JOIN_CHANNEL_FAILED",r[r.ERR_LOG_ALREADY_INIT=16974085]="ERR_LOG_ALREADY_INIT",r[r.ERR_LOG_ROOT_PATH_ERROR=16974086]="ERR_LOG_ROOT_PATH_ERROR",r[r.ERR_MIC_OPEN_FAIL=17040388]="ERR_MIC_OPEN_FAIL",r[r.ERR_SPEAKER_OPEN_FAIL=17040389]="ERR_SPEAKER_OPEN_FAIL",r[r.ERR_MIC_INTERRUPT=17040390]="ERR_MIC_INTERRUPT",r[r.ERR_SPEAKER_INTERRUPT=17040391]="ERR_SPEAKER_INTERRUPT",r[r.ERR_MIC_AUTH_FAIL=17040392]="ERR_MIC_AUTH_FAIL",r[r.ERR_MIC_NOT_AVAILABLE=17040393]="ERR_MIC_NOT_AVAILABLE",r[r.ERR_SPEAKER_NOT_AVAILABLE=17040400]="ERR_SPEAKER_NOT_AVAILABLE",r[r.ERR_CAMERA_OPEN_FAIL=17039620]="ERR_CAMERA_OPEN_FAIL",r[r.ERR_CAMERA_AUTH_FAIL=17039621]="ERR_CAMERA_AUTH_FAIL",r[r.ERR_CAMERA_INTERRUPT=17039622]="ERR_CAMERA_INTERRUPT",r[r.ERR_CAMERA_NOT_AVAILABLE=17039623]="ERR_CAMERA_NOT_AVAILABLE",r[r.ERR_VIDEO_DISPLAY_OPEN_FAIL=17039873]="ERR_VIDEO_DISPLAY_OPEN_FAIL",r[r.ERR_VIDEO_DISPLAY_INTERRUPT=1064992]="ERR_VIDEO_DISPLAY_INTERRUPT",r[r.ERR_ICE_CONNECTION_CONNECT_FAIL=17105409]="ERR_ICE_CONNECTION_CONNECT_FAIL",r[r.ERR_ICE_CONNECTION_RECONNECT_FAI=17105410]="ERR_ICE_CONNECTION_RECONNECT_FAI",r[r.ERR_ICE_CONNECTION_MOBILITY_FAIL=17105411]="ERR_ICE_CONNECTION_MOBILITY_FAIL",r[r.ERR_ICE_CONNECTION_HEARTBEAT_TIMEOUT=16908812]="ERR_ICE_CONNECTION_HEARTBEAT_TIMEOUT",r[r.ERR_LATENCY_LIVE_COMMUNICATION_FAILED=17235971]="ERR_LATENCY_LIVE_COMMUNICATION_FAILED",r[r.ERR_LATENCY_LIVE_MEIDASETTING_FAILED=17235972]="ERR_LATENCY_LIVE_MEIDASETTING_FAILED",r[r.ERR_LATENCY_LIVE_NONE_BROADCASTER=17235973]="ERR_LATENCY_LIVE_NONE_BROADCASTER",r[r.ERR_LATENCY_LIVE_NEED_RESTART=17235974]="ERR_LATENCY_LIVE_NEED_RESTART",r[r.ERR_LATENCY_LIVE_NEED_RESTART_AGAIN_LATER=17235975]="ERR_LATENCY_LIVE_NEED_RESTART_AGAIN_LATER",r[r.ERR_LATENCY_LIVE_SERVICE_UNAVAILABLE=17235976]="ERR_LATENCY_LIVE_SERVICE_UNAVAILABLE",r[r.ERR_LATENCY_LIVE_MEDIACONNECTION_INTERRUPTION=17235977]="ERR_LATENCY_LIVE_MEDIACONNECTION_INTERRUPTION",r[r.ERR_SDK_PUBLISH_INVAILD=16974597]="ERR_SDK_PUBLISH_INVAILD",r[r.ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL=16843782]="ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL",r[r.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED=16843856]="ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED",r[r.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED=16843857]="ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED",r[r.ERR_SDK_PUBLISH_DUAL_STREAM_FAILED=16843858]="ERR_SDK_PUBLISH_DUAL_STREAM_FAILED",r[r.ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED=16843859]="ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED",r[r.ERR_SDK_PUBLISH_SCREEN_SHARE_CONFIG_ERROR=16843860]="ERR_SDK_PUBLISH_SCREEN_SHARE_CONFIG_ERROR",r[r.ERR_SDK_SUBSCRIBE_INVAILD=16974852]="ERR_SDK_SUBSCRIBE_INVAILD",r[r.ERR_SDK_SUBSCRIBE_NOT_JOIN_CHANNEL=16844112]="ERR_SDK_SUBSCRIBE_NOT_JOIN_CHANNEL",r[r.ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED=16844113]="ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED",r[r.ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED=16844114]="ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED",r[r.ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED=16844115]="ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED",r[r.ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED=16844116]="ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED",r[r.ERR_SDK_SUBSCRIBE_DATA_FAILED=16844117]="ERR_SDK_SUBSCRIBE_DATA_FAILED",r[r.ERR_SDK_SUBSCRIBE_DATA_ERROR=16844118]="ERR_SDK_SUBSCRIBE_DATA_ERROR",r[r.ERR_SDK_INVALID_STATE=16974340]="ERR_SDK_INVALID_STATE",r[r.ERR_INVALID_ARGUMENTS=16974083]="ERR_INVALID_ARGUMENTS",r[r.ERR_SESSION_REMOVED=33620229]="ERR_SESSION_REMOVED",r[r.ERR_SDK_UPDATE_ROLE_CHANNEL=16908801]="ERR_SDK_UPDATE_ROLE_CHANNEL",r[r.ERR_INNER=-1]="ERR_INNER",r[r.ERR_SDK_MPU_TASK_PUBLISH_OK=0]="ERR_SDK_MPU_TASK_PUBLISH_OK",r[r.ERR_SDK_MPU_TASK_STREAM_NOT_FOUND=17825793]="ERR_SDK_MPU_TASK_STREAM_NOT_FOUND",r[r.ERR_SDK_MPU_TASK_STREAM_ALREADY_EXIST=17825794]="ERR_SDK_MPU_TASK_STREAM_ALREADY_EXIST",r[r.ERR_SDK_MPU_TASK_INVALID_PARAM=17825795]="ERR_SDK_MPU_TASK_INVALID_PARAM",r[r.ERR_SDK_MPU_TASK_INTERNAL_ERROR=17825796]="ERR_SDK_MPU_TASK_INTERNAL_ERROR",r[r.ERR_SDK_MPU_TASK_RTMP_SERVER_ERROR=17825797]="ERR_SDK_MPU_TASK_RTMP_SERVER_ERROR",r[r.ERR_SDK_MPU_TASK_RTMP_STREAM_URL_ERROR=17825798]="ERR_SDK_MPU_TASK_RTMP_STREAM_URL_ERROR",r[r.ERR_SDK_MPU_TASK_PUBLISH_TIMEOUT=17825799]="ERR_SDK_MPU_TASK_PUBLISH_TIMEOUT",r[r.ERR_SDK_MPU_TASK_NOT_AUTHORIZED=17825800]="ERR_SDK_MPU_TASK_NOT_AUTHORIZED",r[r.ERR_SDK_CHANNEL_RELAY_STATE_ERROR=18874369]="ERR_SDK_CHANNEL_RELAY_STATE_ERROR",r[r.ERR_SDK_CHANNEL_RELAY_SRC_NOT_ALLOW=18874370]="ERR_SDK_CHANNEL_RELAY_SRC_NOT_ALLOW",r[r.ERR_SDK_CHANNEL_RELAY_JOIN_DEST_FAILED=18874371]="ERR_SDK_CHANNEL_RELAY_JOIN_DEST_FAILED",r[r.ERR_SDK_CHANNEL_RELAY_TOKEN_INVALID=18874372]="ERR_SDK_CHANNEL_RELAY_TOKEN_INVALID",r[r.ERR_SDK_CHANNEL_RELAY_ROLE_ERROR=18874373]="ERR_SDK_CHANNEL_RELAY_ROLE_ERROR",r[r.ERR_SDK_CHANNEL_RELAY_INVALID_PARAM=18874374]="ERR_SDK_CHANNEL_RELAY_INVALID_PARAM",r[r.ERR_SDK_CHANNEL_RELAY_TO_SELF_ERROR=18874375]="ERR_SDK_CHANNEL_RELAY_TO_SELF_ERROR",r))(U||{});class V extends Error{constructor(e,t,i){super(t);g(this,"_code");g(this,"_extra");this._code=e,this._extra=i}static fromRtsError(e){return e instanceof V?e:new V((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 V(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 A0=3e4,qe=class qe extends re{constructor(e,t,i,s,a,c){super();g(this,"authInfo");g(this,"userName");g(this,"channelProfile");g(this,"clientRole");g(this,"slsReporter");g(this,"wsClient");g(this,"packageCreater");g(this,"keepAliveTimer",0);g(this,"packageCache",new Map);g(this,"isFirstConnect",!0);g(this,"aliveChecker",0);g(this,"reconnectData");this.authInfo=e,this.userName=t,this.packageCreater=new E0(e,t),this.channelProfile=i,this.clientRole=s,this.slsReporter=a,this.wsClient=new es(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){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 o=e,{l1ip:t}=o,i=qt(o,["l1ip"]);let s=this.packageCreater.createPublishPackage();s.data.users=[],s.data.l1ip=t,i.subscribe.signal=this.wsClient.connectUrl;const{tracks:a,resume:c}=i;a.forEach(u=>{const{codec:h,ssrc:p}=u;u.userdata=JSON.stringify({codec:h}),u.ssrc=`${p}`,c&&(u.attr={reason:"reconnect"})}),s.data.users.push(i),this.sendPackage(s)}roleUpdate(e){let t=this.packageCreater.createRoleUpdatePackage();t.data.clientrole=e,this.sendPackage(t)}refreshUrl(e){const t=this.packageCreater.createRefreshUrlPackage();t.data=Y(vt(Y({},t.data),{sessionid:t.header.sessionid}),e),this.sendPackage(t)}refreshAuthInfo(e){this.authInfo=e,this.packageCreater.refreshAuthInfo(e)}close(){O.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){[Ae.KEEPALIVE,Ae.RECONNECT,Ae.JOINCHANNEL].includes(e.msgtype)||this.packageCache.set(e.tid,e),this.wsClient.send(e),e.msgtype!==Ae.KEEPALIVE&&this.slsReporter.reportRoomServerEvent(!0,e.msgtype,e.tid,e)}updateReconnectData(e){this.reconnectData=e}onOpen(){if(O.info(`[${qe.logName}] onOpen`),this.isFirstConnect){let e=this.packageCreater.createJoinPackage();e.data.configure={channelprofile:this.channelProfile},(this.channelProfile===gt.AliRtcSdkInteractiveLive||this.channelProfile===gt.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)!==Ae.KEEPALIVE&&this.slsReporter.reportRoomServerEvent(!1,t.msgtype,t.tid,t)}catch(t){O.warn(`[${qe.logName}] onMessage err`,t,e)}}onError(e){O.warn(`[${qe.logName}] onError`,e),this.isFirstConnect&&this.onConnectFail()}onConnectFail(){O.warn(`[${qe.logName}] onConnectFail`);const e=new V(U.ERR_INNER,"Signaling connect failed.");this.isFirstConnect?this.emit("onJoinChannelResult",e):this.emit("onConnectFail",e)}onAuthInvalid(){O.warn(`[${qe.logName}] onAuthInvalid`),this.isFirstConnect&&this.emit("onAuthInvalid")}onNetworkError(){O.warn(`[${qe.logName}] onNetworkError`);const e=new V(U.ERR_INNER,"Network error, signaling connect failed.");this.emit("onNetworkError",e)}onClose(e){O.info(`[${qe.logName}] onClose`,e),this.stopKeepAlive()}onKeepAliveRsp(){this.emit("onKeepAliveRsp"),this.checkAlive()}onReconnectStart(){this.emit("onReconnectStart")}onReconnectFail(){this.emit("onReconnectFail",new V(U.ERR_INNER,"signaling reconnect failed."))}checkAlive(){window.clearTimeout(this.aliveChecker),this.aliveChecker=window.setTimeout(()=>{O.info(`[${qe.logName}] not alive, reconnect`),this.stopKeepAlive(),this.emit("onReconnectStart"),this.wsClient.reconnect()},A0)}onRecvMessage(e){switch(e.msgtype!==Ae.KEEPALIVE&&O.info(`[${qe.logName}] recv msg: ${e.msgtype}`),e.msgtype){case Ae.JOINCHANNEL:this.onJoinResult(e);break;case Ae.KEEPALIVE:this.onKeepAliveRsp();break;case Ae.PUBLISH:this.onPublishResult(e);break;case Ae.NOTIFYJOIN:this.onNotifyJoin(e);break;case Ae.NOTIFYSTATUS:this.onNotifyStatus(e);break;case Ae.LEAVECHANNEL:this.onLeaveResult(e);break;case Ae.NOTIFYLEAVE:this.onNotifyLeave(e);break;case Ae.NOTIFYPUBLISH:this.onNotifyPublish(e);break;case Ae.STATUSREPORT:this.onStatusReport(e);break;case Ae.BYE:this.onBye(e);break;case Ae.ROLEUPDATE:this.onRoleUpdateResult(e);break;case Ae.REFRESHURL:this.onRefreshUrlResult(e);break;case Ae.RECONNECT:this.onReconnectResult(e);break}}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 V(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)}};g(qe,"logName","RSMessageCenter");let ts=qe;const T=(r,n)=>(e,t,i)=>{const s=i.value;return i.value=function(...a){var p;const c=`[${((p=e.constructor)==null?void 0:p.logName)||""}]`,o=Date.now();let u=[];if(r)try{u=r(a)}catch(d){}O.interface(c,t,...u);const h=s.apply(this,a);return Promise.resolve(h).then(d=>d).catch(d=>d).then(d=>{var S;let f="";const m=d instanceof Error,l=m&&((S=e.constructor)==null?void 0:S.logError);if(!(!n&&!m)){if(l)f=d;else if(m)f=d.message||"";else if(n)if(d===void 0)f="";else try{f=n(d)}catch(v){}else return;O.interfaceResult(c,t,!(m&&l),`${Date.now()-o}ms`,f)}}),h},i},H=r=>r;var _0=Object.defineProperty,y0=Object.getOwnPropertyDescriptor,is=(r,n,e,t)=>{for(var i=t>1?void 0:t?y0(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&_0(n,e,i),i};const Pi=(Le=class extends re{constructor(e,t,i,s=pt.prod){super();g(this,"messageCenter");g(this,"authInfo");g(this,"userName");g(this,"channelProfile");g(this,"clientRole");g(this,"slsReporter");g(this,"reconnectData");g(this,"roomServerUri","");this.channelProfile=e,this.clientRole=t,this.slsReporter=i,this.reconnectData={role:{channelprofile:e,clientrole:t}};const a=s===pt.pre?Ai.pre:Ai.prod;this.roomServerUri=`wss://${a}/roomserver/v1/ws`}updateReconnectData(e){var t;this.reconnectData=e,(t=this.messageCenter)==null||t.updateReconnectData(this.reconnectData)}reset(){O.info("[roomsig] reset"),this.messageCenter&&(this.messageCenter.close(),this.messageCenter=void 0),this.authInfo=void 0}join(e,t,i){return w(this,null,function*(){return new Promise((s,a)=>{const c={};this.authInfo=e,this.userName=t,this.messageCenter=new ts(e,t,this.channelProfile,this.clientRole,this.slsReporter,i),this.initMessageCenter(),this.messageCenter.once("onJoinChannelResult",u=>{var h,p,d;if(O.info(`[${Le.logName}]`,"join result: ",u),c.taskretrynum=((h=this.messageCenter)==null?void 0:h.retryCount)||0,u.code==200){(p=this.messageCenter)==null||p.sendPkgCache(),(d=this.messageCenter)==null||d.startKeepAlive();let f=u.data;f.tid=u.tid,f.users=u.data.users,f.timestamp=u.timestamp,c.est&&(c.joinconnecttc=Date.now()-c.est),this.slsReporter.reportJoinConnection(c),s(f)}else this.reset(),a(this.handleSignalError(u.code,u.reason,U.ERR_JOIN_CHANNEL_FAILED))}),this.messageCenter.once("onAuthInvalid",()=>{this.reset(),a(new V(U.ERR_JOIN_BAD_TOKEN,"join failed because authentication failed"))}),O.info(`[${Le.logName}]`,"start ws connecting roomserver and auto join when connected");const o={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:it()};e.role&&(o.tokenrole=e.role),c.est=Date.now(),this.messageCenter.start(this.roomServerUri+"?"+Oe.queryingParam(o))})})}leave(){return O.info("[roomsig] leave .."),new Promise((e,t)=>{this.messageCenter?(this.messageCenter.on("onLeaveResult",(i,s)=>{O.info(`[${Le.logName}]`,"recv leave response "+i),i===200?(this.updateReconnectData(),this.reset(),e({tid:s})):t(this.handleSignalError(i,"leave error"))}),O.info(`[${Le.logName}]`,"send leave request"),this.messageCenter.leave()):(O.info(`[${Le.logName}]`,"no message center, ok to leave"),e({tid:""}))})}publish(e){return new Promise((t,i)=>{var s;this.messageCenter?(this.messageCenter.once("onPublishResult",(a,c,o)=>{O.info(`[${Le.logName}]`,"recv pubish response "+a),a===200?(this.updateReconnectData(vt(Y({},this.reconnectData),{publish:{users:[e]}})),t({tid:c})):i(this.handleSignalError(a,`publish error, ${o}`))}),this.authInfo&&(e.sessionid=(s=this.authInfo.sessionId)!=null?s:""),e.callid||(e.callid=it()),O.info(`[${Le.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)=>{if(!this.messageCenter){i(this.handleSignalError(-1,"role update error, no message center"));return}this.messageCenter.on("onRoleUpdateResult",(s,a,c)=>{var o,u;O.info(`[${Le.logName}]`,"recv role update response "+s),s===200?((u=(o=this.reconnectData)==null?void 0:o.role)!=null&&u.clientrole&&(this.reconnectData.role.clientrole=e,this.updateReconnectData(this.reconnectData)),t({tid:a})):i(this.handleSignalError(s,`role update error, ${c}`))}),this.messageCenter.roleUpdate(e)})}setChannelProfile(e){this.channelProfile=e}refreshUrl(e){return O.info(`[${Le.logName}]`,"refreshUrl .."),new Promise((t,i)=>{if(!this.messageCenter){i(this.handleSignalError(-1,"refresh url error, no message center"));return}this.messageCenter.on("onRefreshUrlResult",s=>{const{code:a,description:c,data:o={}}=s||{};O.info("recv refresh url response "+a),a===200?t(o):i(this.handleSignalError(a,`refresh url error, ${c}`))}),O.info("send refresh url request"),this.messageCenter.refreshUrl(e)})}reportStatus(e){return O.info(`[${Le.logName}]`,"reportStatus "+e),new Promise((t,i)=>{this.messageCenter?(this.messageCenter.once("onStatusReport",(s,a)=>{s===200?t():i(new V(s,a))}),this.messageCenter.reportStatus(e)):i(new V(-1,"No messageCenter"))})}handleSignalError(e,t,i=U.ERR_INNER){const s=`signal error: code - ${e}; description - ${t}`;return new V(i,s)}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,s,a,c,o,u,h,p,d,f;(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)}),(s=this.messageCenter)==null||s.on("onNotifyLeave",m=>{this.emit("onNotifyLeave",m)}),(a=this.messageCenter)==null||a.on("onNotifyPublish",m=>{this.emit("onNotifyPublish",m)}),(c=this.messageCenter)==null||c.on("onBye",(m,l)=>{this.emit("onBye",m,l)}),(o=this.messageCenter)==null||o.on("onReconnectStart",()=>{this.emit("onReconnectStart")}),(u=this.messageCenter)==null||u.on("onReconnectSuccess",m=>{this.emit("onReconnectSuccess",m)}),(h=this.messageCenter)==null||h.on("onReconnectFail",m=>{this.emit("onReconnectFail",m)}),(p=this.messageCenter)==null||p.on("onConnectFail",m=>{this.emit("onConnectFail",m),this.reset()}),(d=this.messageCenter)==null||d.on("onNetworkError",m=>{this.emit("onNetworkError",m)}),(f=this.messageCenter)==null||f.on("onAuthInvalid",()=>{this.emit("onAuthInvalid")})}},g(Le,"logName","RoomServerSignaling"),Le);is([T()],Pi.prototype,"join",1),is([T()],Pi.prototype,"publish",1),is([T()],Pi.prototype,"roleUpdate",1);let C0=Pi;const R0="https://pgw.rtn.aliyuncs.com",I0="https://gw.rtn.aliyuncs.com",Ga=10*60*1e3,w0=12,gi=class gi extends re{constructor(e,t){super();g(this,"env");g(this,"authInfo");g(this,"timer");g(this,"slsReporter");g(this,"expiration",0);g(this,"skipTime",0);g(this,"requestToken",()=>w(this,null,function*(){if(this.skipTime=0,!this.authInfo)return;const{appId:e,channelId:t,userId:i,nonce:s="",token:a,timestamp:c,sessionId:o,role:u}=this.authInfo;let h=I0;this.env===pt.pre&&(h=R0);const p=`${h}/gslb/v1/stsupdate?appid=${e}&channelid=${t}&userid=${i}&nonce=${s}&token=${a}×tamp=${c}&session=${o}${u?`&tokenrole=${u}`:""}&slstoken=true&osstoken=true&tokensid=false`,d=Date.now();fetch(p).then(f=>f.json()).then(f=>{var m,l;if(f.code===0){const S=(m=f.data)==null?void 0:m.oss,v=(l=f.data)==null?void 0:l.sls;this.expiration=S.expiration||v.expiration,this.emit("onTokenUpdate",S,v),O.event(`[${gi.logName}]`,"getToken",S,v)}else throw new Error;this.slsReporter.reportSTSResult(200,d)}).catch(f=>{this.slsReporter.reportSTSResult(-1,d),O.error(`[${gi.logName}]`,"getToken",f.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(()=>{if(this.expiration&&Math.floor((Date.now()+Ga*1.5)/1e3)<this.expiration&&this.skipTime<w0){this.skipTime+=1;return}this.requestToken()},Ga)}clear(){this.timer&&clearInterval(this.timer)}};g(gi,"logName","StsManager");let rs=gi;var T0=Object.defineProperty,D0=Object.getOwnPropertyDescriptor,P0=(r,n,e,t)=>{for(var i=t>1?void 0:t?D0(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&T0(n,e,i),i};class ss extends re{constructor(e,t,i,s=pt.prod){super();g(this,"signaling");g(this,"authInfo");g(this,"userName");g(this,"channelProfile");g(this,"clientRole");g(this,"env",pt.prod);g(this,"maxConnectRetryCount");g(this,"stsManager");g(this,"slsReporter");this.channelProfile=e,this.clientRole=t,this.env=s,this.slsReporter=i,this.stsManager=new rs(i,s)}reset(){var e;O.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,s){return this.maxConnectRetryCount=i,this.userName=t,new Promise((a,c)=>{this.signaling?c(new V(U.ERR_JOIN_ALREADY_JOINED,"already joined")):(O.info("[signalingmanager] create signaling"),this.signaling=new C0(this.channelProfile,this.clientRole,this.slsReporter,this.env),this.initSignaling(),s&&(s.rs=Date.now()),this.signaling.join(e,t,i).then(o=>{this.authInfo=e,s&&(s.re=Date.now()),a(o)}).catch(o=>{this.reset(),c(o)}),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 s;this.signaling&&this.authInfo?(e.userid=this.authInfo.userId,e.displayname=(s=this.userName)!=null?s:this.authInfo.userId,this.signaling.publish(e).then(a=>{t(a)}).catch(a=>{i(a)})):i(new V(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(s=>{i(s)}):i(new V(-1,"no signaling"))})}setClientRole(e){return w(this,null,function*(){const t=this.clientRole;if(!this.signaling){this.clientRole=e;return}const i=Date.now();try{const s=yield this.signaling.roleUpdate(e);return this.slsReporter.reportRoleUpdateResult(t,e,Date.now()-i,0),s}catch(s){this.slsReporter.reportRoleUpdateResult(t,e,Date.now()-i,s.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 V(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,s,a,c,o,u,h,p,d,f,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)),(s=this.signaling)==null||s.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)),(o=this.signaling)==null||o.on("onReconnectStart",this.onReconnectStart.bind(this)),(u=this.signaling)==null||u.on("onReconnectSuccess",this.onReconnectSuccess.bind(this)),(h=this.signaling)==null||h.on("onReconnectFail",this.onReconnectFail.bind(this)),(p=this.signaling)==null||p.on("onConnectFail",this.onConnectFail.bind(this)),(d=this.signaling)==null||d.on("onNetworkError",this.onNetworkError.bind(this)),(f=this.signaling)==null||f.on("onAuthInvalid",this.onAuthInvalid.bind(this)),(m=this.signaling)==null||m.on("onError",this.onError.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)}}g(ss,"logName","SignalingManager"),P0([T(H)],ss.prototype,"publish",1);function Qt(){}const Ht=class Ht{static getInstance(){var n;return Ht.instance||(Ht.instance=new AudioContext),(n=Ht.instance.resume())==null||n.then(Qt,Qt).catch(Qt),Ht.instance}};g(Ht,"instance");let Lt=Ht;const ki=()=>{var n;const r=Lt.getInstance();r.state!=="running"&&r.state!=="closed"&&((n=r.resume())==null||n.then(Qt,Qt).catch(Qt)),window.removeEventListener("mousedown",ki),window.removeEventListener("touchstart",ki)};window.addEventListener("mousedown",ki),window.addEventListener("touchend",ki);function k0(r,n,e,t,i){let s=t,a=0,c;const o=r.createAnalyser();o.fftSize=256;const u=new Uint8Array(o.frequencyBinCount);n.connect(o),o.connect(e);const h=()=>{c&&window.clearInterval(c)},p=()=>{r.state==="suspended"&&r.resume(),c=window.setInterval(()=>{o.getByteFrequencyData(u);let d=Math.round(u.reduce((f,m)=>f+m)/u.length);d=Math.min(100,d),a=d,i&&i(d)},s)};return p(),{updateInterval:d=>{h(),s=d,p()},getLevel:()=>a,dispose:()=>{h(),n.disconnect(),o.disconnect()}}}class B0 extends re{constructor(){super();g(this,"audioContext");g(this,"stream");g(this,"sourceNode");g(this,"analyser");this.audioContext=Lt.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=k0(this.audioContext,this.sourceNode,i,t,s=>{this.emit("audioLevel",s)})}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 Xa extends re{constructor(e,t,i,s){super();g(this,"uid");g(this,"name");g(this,"rtsManager");g(this,"callId","");g(this,"audioLevelMonitor");g(this,"audioVolumeIndicationInterval",0);this.uid=e,this.name=t,this.rtsManager=i,this.audioVolumeIndicationInterval=s,this.audioLevelMonitor=new B0}get userId(){return this.uid}get displayname(){return this.name}createCallId(){this.callId||(this.callId=Oe.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 Ya{static getCurrentStatus(n){let e=0;n.micOpen&&(e+=1),n.micInterrupted&&(e+=2),n.cameraOpen&&(e+=4),n.screenShare&&(e+=128),n.audioDisable&&(e+=8),n.videoDisable&&(e+=16),n.screenDisable&&(e+=256);let t=e.toString(16);for(;t.length<16;)t="0"+t;return t}static parseStatus(n){let e=parseInt(n,16);return{micOpen:!!(e&1),micInterrupted:!!(e&2),cameraOpen:!!(e&4),screenShare:!!(e&128),audioDisable:!!(e&8),videoDisable:!!(e&16),screenDisable:!!(e&256),backgroundMode:!!(e&32),accompanyPlaying:!!(e&64)}}}const N0="customVideoProfile",L0="customScreenProfile",as={width:1280,height:720,frameRate:30,maxBitrate:2e3},Za={width:1920,height:1080,frameRate:30,maxBitrate:2600};var di=(r=>(r[r.ERROR_DEVICE_UNKNOWNERROR=1e4]="ERROR_DEVICE_UNKNOWNERROR",r[r.ERROR_DEVICE_AUDIODEVICE_NOTFOUND=10001]="ERROR_DEVICE_AUDIODEVICE_NOTFOUND",r[r.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED=10002]="ERROR_DEVICE_AUDIODEVICE_NOTALLOWED",r[r.ERROR_DEVICE_AUDIODEVICE_NOTREADABLE=10003]="ERROR_DEVICE_AUDIODEVICE_NOTREADABLE",r[r.ERROR_DEVICE_VIDEODEVICE_NOTFOUND=10004]="ERROR_DEVICE_VIDEODEVICE_NOTFOUND",r[r.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED=10005]="ERROR_DEVICE_VIDEODEVICE_NOTALLOWED",r[r.ERROR_DEVICE_VIDEODEVICE_NOTREADABLE=10006]="ERROR_DEVICE_VIDEODEVICE_NOTREADABLE",r[r.ERROR_SCREENSHARE_NOTSUPPORT=10010]="ERROR_SCREENSHARE_NOTSUPPORT",r[r.ERROR_SCREENSHARE_NOTALLOWED=10011]="ERROR_SCREENSHARE_NOTALLOWED",r[r.ERROR_SCREENSHARE_ENDED=10012]="ERROR_SCREENSHARE_ENDED",r[r.ERROR_SCREENSHARE_NOPERMISSION=10013]="ERROR_SCREENSHARE_NOPERMISSION",r[r.ERROR_SCREENSHARE_SAFARI_INVALIDACCESS=10014]="ERROR_SCREENSHARE_SAFARI_INVALIDACCESS",r[r.ERROR_SCREENSHARE_UNKNOWNERRO=10019]="ERROR_SCREENSHARE_UNKNOWNERRO",r[r.ERROR_DEVICE_NOTSUPPORT=2e4]="ERROR_DEVICE_NOTSUPPORT",r))(di||{});const M0={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 Ke=(r=>(r.CREATE_ENGINE="create_engine",r.JOIN="join",r.WANT_INSERT_PUB_TASK="wantInsertPubTask",r.INSERT_PUB_TASK="InsertPubTask",r.HANDLE_PUB_TASK="HandlePubTask",r.RECV_NOTIFY_PUBLISH="RecvNotifyPublish",r.INSERT_SUB_TASK="InsertSubTask",r.HANDLE_SUB_TASK="HandleSubTask",r.FIRST_REMOTE="first_remote",r))(Ke||{}),Ze=(r=>(r.START="start",r.SEND_SIG="send_sig",r.RECV_RST="recv_rst",r.END="end",r.RECEIVED="received",r.DECODED="decoded",r.PLAYED="played",r))(Ze||{});const F0=r=>r.getAudioTracks()[0];function Qa(r){var n;if(((n=r==null?void 0:r.nodeName)==null?void 0:n.toLowerCase())==="video")return r.setAttribute("playsinline",""),r;if(typeof r=="string"){let e=document.getElementById(r);if(e){if(e.nodeName.toLocaleLowerCase()==="video")return e.setAttribute("playsinline",""),e;throw new V(U.ERR_INVALID_ARGUMENTS,"element should be HtmlVideoElement")}else throw new V(U.ERR_INVALID_ARGUMENTS,"element not founded")}else throw new V(U.ERR_INVALID_ARGUMENTS,"element id should be string")}function ns(r){var e;const n=[];if(Array.isArray(r))r.forEach(t=>{try{n.push(Qa(t))}catch(i){}});else if(typeof r=="string"||((e=r==null?void 0:r.nodeName)==null?void 0:e.toLowerCase())==="video")try{n.push(Qa(r))}catch(t){}return n}function _t(r){return new Promise(n=>setTimeout(n,r))}function en(r,n,e=1e3,t=i=>!0){return w(this,null,function*(){let i=0,s;for(;i<n;)try{return yield r(i)}catch(a){if(i++,i>=n||!t(a))throw a||s;yield new Promise(c=>setTimeout(c,e))}})}function V0(r,n){let e=0;const t=[];for(;e<r.byteLength;){const i=Math.min(n,r.byteLength-e),s=r.slice(e,e+i);t.push(s),e+=i}return t}function O0(r){var n,e;try{const t=new URL(r),[i,s]=t.pathname.slice(1).split("/"),a=/(\w+)(web\w{5}-\w{4}-\w{4}-\w{4}-\w{12})/.exec(s),c=a==null?void 0:a[1],o=a==null?void 0:a[2],u=new URLSearchParams(t.search),h=parseInt((e=(n=u.get("auth_key"))==null?void 0:n.split("-")[0])!=null?e:"0")*1e3;return{appId:i,channelId:c,sessionId:o,timeoutTs:h}}catch(t){return null}}function tn(r,n){let e=n;return typeof window.__ali_prefer_media_server=="string"&&window.__ali_prefer_media_server!==""&&(e=window.__ali_prefer_media_server),e?`${r}&ali_prefer_media_server=${e}`:r}const rn=(r,n,e=!1)=>{const t=()=>(r.muted=!0,Promise.race([_t(500),r._playPromise||Promise.resolve()]).catch(()=>{}).then(()=>{let i;return e&&r.srcObject===n?i=Promise.resolve():(r.load(),r.srcObject=n,i=r.play(),r._playPromise=i),i}));return new Promise(i=>{if(G.AliRTS.BrowserUtil.isMicroMessenger){const s=window.top!==window.self,a=window.WeixinJSBridge||window.top.WeixinJSBridge;a?a.invoke("getNetworkType",{},()=>{i(t())}):(s?window.top.document:document).addEventListener("WeixinJSBridgeReady",()=>{a.invoke("getNetworkType",{},()=>{i(t())})}),setTimeout(()=>{i(t())},1e3)}else setTimeout(()=>{i(t())},0)})},dt=r=>{Promise.race([_t(100),r._playPromise||Promise.resolve()]).catch(()=>{}).then(()=>{r.srcObject=null,r._playPromise=void 0})};var os=(r=>(r[r.AliEngineDataMsgNone=0]="AliEngineDataMsgNone",r[r.AliEngineDataMsgMusicProgress=1]="AliEngineDataMsgMusicProgress",r[r.AliEngineDataMsgCustom=2]="AliEngineDataMsgCustom",r))(os||{});class Bi{constructor(n,e,t,i=0){g(this,"msgType");g(this,"msgId");g(this,"protocolVersion");g(this,"tlvVersion");this.msgType=n,this.msgId=e,this.protocolVersion=t,this.tlvVersion=i}build(){const n=new Uint8Array(4);return n.set(Uint8Array.from([this.protocolVersion,this.tlvVersion<<4|this.msgType&15]),0),n.set(Uint16Array.from([this.msgId]),2),n}static parse(n){const e=new DataView(n),t=e.getUint8(0),i=e.getUint8(1)>>4,s=e.getUint8(1)&15,a=e.getUint16(2);return new Bi(s,a,t,i)}}const Mt=5;class Ni{constructor(n,e,t){g(this,"_byteArray");if(this._byteArray=new Uint8Array(0),n!==void 0&&e!==void 0&&t!==void 0){const s=new Bi(n,e,t).build();this._byteArray=new Uint8Array(s.byteLength+this._byteArray.byteLength),this._byteArray.set(s,0)}}write(n,e){const t=this._byteArray,i=new ArrayBuffer(Mt),s=new DataView(i);s.setUint8(0,n),s.setUint32(1,e.byteLength);const a=new Uint8Array(t.byteLength+Mt+e.byteLength);a.set(t,0),a.set(new Uint8Array(i),t.byteLength),a.set(new Uint8Array(e),t.byteLength+Mt),this._byteArray=a}static parse(n){const e={},t=new DataView(n);let i=0;for(;i<n.byteLength;){const s=t.getUint8(i),a=t.getUint32(i+1);if(i+Mt+a<=n.byteLength){const c=n.slice(i+Mt,i+Mt+a);e[s]=c,i+=Mt+a}else break}return e}get buffer(){return this._byteArray.buffer}}class li{constructor(n=0,e=!0,t=1,i=!1,s=0,a=!1,c=!1,o=3){g(this,"_fin",!0);g(this,"_hasExtension",!1);g(this,"_version",0);g(this,"_frameType",1);g(this,"_isEncrypted",!1);g(this,"_isCompressed",!1);g(this,"_signalType",3);g(this,"_payloadLength",0);this._fin=e,this._hasExtension=i,this._version=s,this._frameType=t,this._isEncrypted=a,this._isCompressed=c,this._signalType=o,this._payloadLength=n}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 n=new ArrayBuffer(4),e=new DataView(n);return e.setUint8(0,(this._fin?1:0)<<7|(this._hasExtension?1:0)<<6|this._version<<4|this._frameType&15),e.setUint8(1,(this._isEncrypted?1:0)<<7|(this._isCompressed?1:0)<<6|this._signalType&15),e.setUint16(2,this._payloadLength),n}static parse(n){const e=new DataView(n),t=e.getUint8(0)>>7===1,i=(e.getUint8(0)&64)>>6===1,s=(e.getUint8(0)&48)>>4,a=e.getUint8(0)&15,c=e.getUint8(1)>>7===1,o=(e.getUint8(1)&64)>>6===1,u=e.getUint8(1)&15,h=e.getUint16(2);return new li(h,t,a,i,s,c,o,u)}}class Li{constructor(n,e){g(this,"_body");g(this,"_header",new li);this._header=n,this._body=e}get header(){return this._header}get isFin(){return this._header.fin}get body(){return this._body}toGRTNBuffer(){const n=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+n.byteLength+e.byteLength);return i.set(new Uint8Array(t),0),i.set(new Uint8Array(n),t.byteLength),i.set(new Uint8Array(e),t.byteLength+n.byteLength),i.buffer}static parse(n){const e=n.slice(0,4),t=li.parse(e);let i=new ArrayBuffer(0);return n.byteLength-4>=t.payloadLength&&(i=n.slice(4,4+t.payloadLength)),new Li(t,i)}}const cs=r=>{const n=r.byteLength,e=new DataView(r);let t=0;for(let i=0;i<n;i++)t=t*256+e.getUint8(i);return t};let sn=0;class Ft{constructor(n,e=0,t=0,i=0){g(this,"data");g(this,"networkTime");g(this,"futureOrProgress");g(this,"type");this.data=n,this.type=e,this.networkTime=t,this.futureOrProgress=i}toBuffer(){const n=new Ni(0,0,0);n.write(1,Uint8Array.from([0]).buffer),n.write(2,Uint16Array.from([0]).buffer),sn++,n.write(3,Uint32Array.from([sn]).buffer);const e=new Ni;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(this.networkTime&4294967295)]).buffer),e.write(5,this.data),n.write(30,e.buffer),n.buffer}static parse(n){if(!n||n.byteLength<4)return;Bi.parse(n.slice(0,4));const t=Ni.parse(n.slice(4))[30];if(!t)return;const i=Ni.parse(t),s=i[2],a=i[3],c=i[4],o=i[5];if(o.byteLength!==0)return new Ft(o,cs(s),cs(c),cs(a))}}var U0=Object.defineProperty,H0=Object.getOwnPropertyDescriptor,xe=(r,n,e,t)=>{for(var i=t>1?void 0:t?H0(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&U0(n,e,i),i};const an=30;class fi extends re{constructor(){super();g(this,"_state");g(this,"time");this._state=Z.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 Se=(mt=class extends Xa{constructor(e){const{rtsManager:t,localStreamManager:i,slsReporter:s,signalingManager:a,audioVolumeIndicationInterval:c,parameter:o}=e;super("","",t,c);g(this,"_url","");g(this,"joinTime",0);g(this,"_isPublishing",!1);g(this,"publishPromise",Promise.resolve({traceId:"",l1ip:void 0}));g(this,"previewElements",[]);g(this,"screenPreviewElements",[]);g(this,"streamManager");g(this,"dc");g(this,"streamTracks");g(this,"publishId",it());g(this,"signalingManager");g(this,"traceId","");g(this,"monitorTimerId");g(this,"monitorDataCache",{});g(this,"trackTraceIdMap",{});g(this,"candidateDataCache",[]);g(this,"pcMediaStatsMap",{});g(this,"slsReporter");g(this,"audioPubState");g(this,"videoPubState");g(this,"videoSmallPubState");g(this,"screenPubState");g(this,"dataPubState");g(this,"parameter",{});g(this,"onTrackEnd",e=>{this.emit(e)});this.streamManager=i,this.signalingManager=a,this.slsReporter=s,this.parameter=o,this.streamManager.on("trackended",u=>{this.onTrackEnd(u)}),this.streamManager.on("publishupdate",()=>{this.publishUpdate()}),this.audioPubState=new fi,this.audioPubState.on("change",(u,h,p)=>{this.emit("audioPublishStateChanged",u,h,p)}),this.videoPubState=new fi,this.videoPubState.on("change",(u,h,p)=>{this.emit("videoPublishStateChanged",u,h,p)}),this.videoSmallPubState=new fi,this.videoSmallPubState.on("change",(u,h,p)=>{this.emit("dualStreamPublishStateChanged",u,h,p)}),this.screenPubState=new fi,this.screenPubState.on("change",(u,h,p)=>{this.emit("screenPublishStateChanged",u,h,p)}),this.dataPubState=new fi,this.dataPubState.on("change",(u,h,p)=>{this.emit("dataPublishStateChanged",u,h,p)}),this.startStreamMonitor()}get url(){return this._url}set url(e){this._url=e,this.rtsManager.updateAuth(e)}get joined(){return!!this.uid}get isPublishing(){return this._isPublishing}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:s})=>i==="video"&&t&&s===D.VideoLarge))}get hasCameraDualTrackInMS(){var e;return!!((e=this.streamTracks)!=null&&e.find(({ssrc:t,type:i,msid:s})=>i==="video"&&t&&s===D.VideoSmall))}get hasScreenTrackInMS(){var e;return!!((e=this.streamTracks)!=null&&e.find(({ssrc:t,type:i,msid:s})=>i==="video"&&t&&s===D.Screen))}get hasAudioTrackInMS(){var e;return!!((e=this.streamTracks)!=null&&e.find(({ssrc:t,type:i,msid:s})=>i==="audio"&&t&&s===D.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||Oe.createCallid(),this.updatePubId()}setVideoProfile(e){return w(this,null,function*(){yield this.streamManager.setVideoProfile(N0,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(L0,e)})}setCameraDirection(e){if(e===hi.CAMERA_FRONT)this.streamManager.setCameraVideoConstraints({facingMode:"user"});else if(e===hi.CAMERA_REAR)this.streamManager.setCameraVideoConstraints({facingMode:"environment"});else throw new V(U.ERR_CAMERA_OPEN_FAIL,`camera direction set to ${e} failed`)}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=it()}clearPublishState(){this.streamTracks=void 0}leave(){return w(this,null,function*(){this._isPublishing&&(this._isPublishing=!1,yield this.unPublish()),this.joinTime=0,this.dc=void 0})}clear(){return w(this,null,function*(){Es(mt.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)&&(dt(e),this.previewElements.splice(this.previewElements.indexOf(e),1)),this.screenPreviewElements.includes(e)&&(dt(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.previewElements.includes(t)||this.previewElements.push(t)}startDefaultCamera(e){return w(this,null,function*(){const{hasCamera:t,cameraCaptureDisabled:i,publishLocalVideoStreamEnabled:s}=this;if(!t&&!e&&!i&&s)try{yield this.startCameraCapture()}catch(a){const c=a.errorCode;let o=U.ERR_CAMERA_OPEN_FAIL;throw c===di.ERROR_DEVICE_AUDIODEVICE_NOTFOUND?o=U.ERR_CAMERA_NOT_AVAILABLE:c===di.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED&&(o=U.ERR_CAMERA_AUTH_FAIL),new V(o,`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(s){const a=s.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_VIDEODEVICE_NOTALLOWED&&(c=U.ERR_MIC_AUTH_FAIL),new V(c,`mic open fail: ${s.message}`)}})}setViewConfig(e,t){if(!e){t===ne.AliRtcVideoTrackCamera?this.stopPreview({primary:!0,screen:!1}):this.stopPreview({primary:!1,screen:!0});return}if(![ne.AliRtcVideoTrackCamera,ne.AliRtcVideoTrackScreen].includes(t))throw new V(U.ERR_INVALID_ARGUMENTS,"set view config invalid track",{track:t});e.forEach(i=>{this.setPreviewElement({videoElement:i,screen:t===ne.AliRtcVideoTrackScreen})})}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 s=i?this.streamManager.screenStreamInfo.previewStream:this.streamManager.cameraStreamInfo.previewStream;if(!t)throw new V(U.ERR_INVALID_ARGUMENTS,"no video element found",{videoElement:t});if(!s){O.info(`[${mt.logName}]`,"preview no stream founded");return}return rn(t,s.mediaStream),this.setPreviewElement(e),s.mediaStream}catch(s){const a=U.ERR_INNER;throw V.fromError(s,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 s=0;s<this.previewElements.length;s++){const a=this.previewElements[s];yield this.preview({videoElement:a})}if(i&&this.screenPreviewElements.length)for(let s=0;s<this.screenPreviewElements.length;s++){const a=this.screenPreviewElements[s];yield this.preview({videoElement:a,screen:!0})}})}stopPreview(e){const{videoElement:t,primary:i=!0,screen:s=!0}=e||{};if(!t)i&&(this.previewElements.forEach(a=>{dt(a)}),this.previewElements=[]),s&&(this.screenPreviewElements.forEach(a=>{dt(a)}),this.screenPreviewElements=[]);else{const a=this.previewElements.findIndex(c=>c===t);if(a>=0)this.previewElements.splice(a,1),dt(t);else{const c=this.screenPreviewElements.findIndex(o=>o===t);c>=0&&(this.screenPreviewElements.splice(c,1),dt(t))}}}resumePublish(){return w(this,null,function*(){this._isPublishing=!1,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 s=this.previewElements[i];dt(s)}else if(e.screen)for(let i=0;i<this.screenPreviewElements.length;i++){const s=this.screenPreviewElements[i];dt(s)}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=M0[t.errorCode];throw i&&(e.audio?this.emit("localDeviceException",ht.AliEngineLocalDeviceTypeMic,i,""):e.video?this.emit("localDeviceException",ht.AliEngineLocalDeviceTypeCamera,i,""):e.screen?this.emit("localDeviceException",ht.AliEngineLocalDeviceTypeDisplay,i,""):this.emit("localDeviceException",ht.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 o={};return i===D.Audio?o.audio=!0:i===D.VideoLarge||i===D.VideoSmall?(o.video=!0,o.vMsid=i):i===D.Screen&&(o.screen=!0),yield this.publishDeleteTracks(o)}const s={};if(t!=null&&t.hasVideo&&(s.isScreen=i===D.Screen,s.vMsid=i),t!=null&&t.hasAudio&&(s.aMsid=i),!e&&t)return yield this.publishAdd(t,s,!1);if(e&&t){const o=e.trackId,u=((a=t.videoTrack)==null?void 0:a.id)||((c=t.audioTrack)==null?void 0:c.id);if(o!==u)return yield this.publishReplace(t,s)}})}reportAudioProfile(){const e=this.streamManager.cameraStreamInfo.audioProfile||"standard",t=G.AliRTS.AudioProfileMap.get(e);this.slsReporter.reportPublishProfile(D.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(D.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(D.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!==Z.AliRtcStatePublishing){this.dataPubState.setState(Z.AliRtcStatePublishing);try{const e=yield this.rtsManager.publishAddDataChannel(this.url);e?(this.updateDataChannel(e),this.dataPubState.setState(Z.AliRtcStatePublished)):(this.dataPubState.setState(Z.AliRtcStateNoPublish),this.emit("publishDataError",new V(U.ERR_INNER,"publishDataError")))}catch(e){this.dataPubState.setState(Z.AliRtcStateNoPublish)}}})}startPublish(){return w(this,arguments,function*(e=!1,t=ct.MANUAL){var u;if(!this.joined)return;const i=this.streamManager.publishStreams,{audio:s,video:a,videoSmall:c,screen:o}=i;if(!s&&!a&&!c&&!o){O.event(`[${mt.logName}]`,"startPublish no stream founded");return}this.createCallId();try{const h=new Date().getTime();s&&this.audioPubState.setState(Z.AliRtcStatePublishing),a&&this.videoPubState.setState(Z.AliRtcStatePublishing),c&&this.videoSmallPubState.setState(Z.AliRtcStatePublishing),o&&this.screenPubState.setState(Z.AliRtcStatePublishing),this.publishPromise=this.rtsManager.publish(this.url,this.callId,e,t);const{traceId:p,l1ip:d}=yield this.publishPromise;this._isPublishing=!0,this.streamTracks=this.rtsManager.publishingTracks,this.traceId=p,(u=this.parameter.data)!=null&&u.enablePubDataChannel&&(yield this.publishDataChannel()),s&&(this.trackTraceIdMap[D.Audio]=p,this.reportAudioProfile()),c&&(this.trackTraceIdMap[D.VideoSmall]=p),a&&(this.trackTraceIdMap[D.VideoLarge]=p,this.reportVideoProfile()),o&&(this.trackTraceIdMap[D.Screen]=p,this.reportScreenProfile());const f={type:bt.Add,userid:this.userId,sessionid:"",displayname:this.name,pubid:this.publishId,resume:e,subscribe:{signal:"",pullstreamurl:this.url},l1ip:this.parameter.reportL1IP?d:void 0,callid:this.callId,tracks:this.streamTracks,traceid:p};yield this.syncPublishToRoomServer(f,i,h),s&&this.audioPubState.setState(Z.AliRtcStatePublished),a&&this.videoPubState.setState(Z.AliRtcStatePublished),c&&this.videoSmallPubState.setState(Z.AliRtcStatePublished),o&&this.screenPubState.setState(Z.AliRtcStatePublished)}catch(h){throw s&&this.audioPubState.setState(Z.AliRtcStateNoPublish),a&&this.videoPubState.setState(Z.AliRtcStateNoPublish),c&&this.videoSmallPubState.setState(Z.AliRtcStateNoPublish),o&&this.screenPubState.setState(Z.AliRtcStateNoPublish),h}})}updateStreams(){return w(this,null,function*(){yield this.streamManager.updateStreams()})}publishUpdate(e){return w(this,null,function*(){var a,c,o,u,h,p;if(!this._isPublishing)return;yield this.publishPromise;const t=this.streamManager.publishStreams;let i;const s=new Date().getTime();try{const d=(a=this.streamTracks)==null?void 0:a.find(({ssrc:E,type:A,msid:y})=>A==="audio"&&E&&y===D.Audio),f=yield this.compareAndPublish(d,t.audio,D.Audio);f&&(i=f);const m=(c=this.streamTracks)==null?void 0:c.find(({ssrc:E,type:A,msid:y})=>A==="video"&&E&&y===D.VideoLarge),l=yield this.compareAndPublish(m,t.video,D.VideoLarge);l&&(i=l);const S=(o=this.streamTracks)==null?void 0:o.find(({ssrc:E,type:A,msid:y})=>A==="video"&&E&&y===D.VideoSmall),v=yield this.compareAndPublish(S,t.videoSmall,D.VideoSmall);v&&(i=v);const x=(u=this.streamTracks)==null?void 0:u.find(({ssrc:E,type:A,msid:y})=>A==="video"&&E&&y===D.Screen),b=yield this.compareAndPublish(x,t.screen,D.Screen);if(b&&(i=b),!i)if(e===ct.RECONNECT&&this.rtsManager.publishingTracks.length>0){if((h=this.parameter.data)!=null&&h.enablePubDataChannel){const y=this.rtsManager.getDatachannelByMsid({url:this.url,msid:D.Data});this.updateDataChannel(y)}const E=this.rtsManager.publishingTracks.find(({type:y})=>y==="video"),A=this.rtsManager.publishingTracks.find(({type:y})=>y==="audio");(E||A)&&(yield this.rtsManager.waitPublishSender(this.url,!E,E?E.msid:A==null?void 0:A.msid)),i={type:bt.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}}else return;(p=this.parameter.data)!=null&&p.enablePubDataChannel&&!this.dc&&(yield this.publishDataChannel()),yield this.syncPublishToRoomServer(i,t,s)}catch(d){const{code:f}=d!=null?d:{},m=this.url;throw f===403&&m&&(yield this.refreshPushStreamUrl(),i=yield this.publishUpdate()),d}return i})}syncPublishToRoomServer(e,t,i){return w(this,null,function*(){var o;if(!e)throw new V(U.ERR_INNER,"sync publish to room server failed because no publishInfo");let s=e;if(this.dc){const c=e,{tracks:u}=c,h=qt(c,["tracks"]);s=vt(Y({},h),{tracks:[...u,{type:"data",msid:D.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 a=yield this.signalingManager.publish(s);e.signaltid=a.tid})}refreshPushStreamUrl(){return w(this,null,function*(){const e=new V(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,s=0){return w(this,null,function*(){this.createCallId();const a=(t==null?void 0:t.aMsid)===D.Audio,c=(t==null?void 0:t.vMsid)===D.VideoLarge,o=(t==null?void 0:t.vMsid)===D.VideoSmall,u=(t==null?void 0:t.vMsid)===D.Screen;a&&this.audioPubState.setState(Z.AliRtcStatePublishing),c&&this.videoPubState.setState(Z.AliRtcStatePublishing),o&&this.videoSmallPubState.setState(Z.AliRtcStatePublishing),u&&this.screenPubState.setState(Z.AliRtcStatePublishing);try{const h=yield this.rtsManager.publishAdd(this.url,e,this.callId,t,!1,!0);a&&(this.audioPubState.setState(Z.AliRtcStatePublished),this.reportAudioProfile(),this.trackTraceIdMap[D.Audio]=h),c&&(this.videoPubState.setState(Z.AliRtcStatePublished),this.reportVideoProfile(),this.trackTraceIdMap[D.VideoLarge]=h),o&&(this.videoSmallPubState.setState(Z.AliRtcStatePublished),this.trackTraceIdMap[D.VideoSmall]=h),u&&(this.screenPubState.setState(Z.AliRtcStatePublished),this.reportScreenProfile(),this.trackTraceIdMap[D.Screen]=h),this.streamTracks=this.rtsManager.publishingTracks;const p={type:bt.Add,userid:this.userId,sessionid:"",displayname:this.name,pubid:this.publishId,resume:i,subscribe:{signal:"",pullstreamurl:this.url},callid:this.callId,tracks:this.streamTracks,traceid:h};return this.reportSelfDeviceStatus(),this.monitorTimerId||this.startStreamMonitor(),p}catch(h){let p=U.ERR_SDK_PUBLISH_INVAILD;if(a&&(this.audioPubState.setState(Z.AliRtcStateNoPublish),p=U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED),c&&(this.videoPubState.setState(Z.AliRtcStateNoPublish),p=U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED),o&&(this.videoSmallPubState.setState(Z.AliRtcStateNoPublish),p=U.ERR_SDK_PUBLISH_DUAL_STREAM_FAILED),u&&(this.screenPubState.setState(Z.AliRtcStateNoPublish),p=U.ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED),h.errorCode===15006&&s<3)return this.publishAdd(e,t,i,s+1);throw V.fromError(h,p,"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={type:bt.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(),i}catch(i){throw V.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:bt.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(Z.AliRtcStateNoPublish),e.video&&(e.vMsid===D.VideoSmall?this.videoSmallPubState.setState(Z.AliRtcStateNoPublish):this.videoPubState.setState(Z.AliRtcStateNoPublish)),e.screen&&this.screenPubState.setState(Z.AliRtcStateNoPublish),t.tracks=this.streamTracks,this.reportSelfDeviceStatus(),t}catch(i){throw V.fromError(i,U.ERR_INNER,"publish delete tracks failed")}})}publishStop(){return w(this,null,function*(){if(!this._isPublishing)throw new V(U.ERR_INNER,"publish stop failed, previous localStream is required for publishing stopping");O.info(`[${mt.logName}]`,"publishStop",{url:this.url});const e=new Date().getTime();try{const t=this.hasAudioTrackInMS,i=this.hasCameraTrackInMS,s=this.hasCameraDualTrackInMS,a=this.hasScreenTrackInMS;yield this.rtsManager.publishStop(this.url),t&&this.audioPubState.setState(Z.AliRtcStateNoPublish),i&&this.videoPubState.setState(Z.AliRtcStateNoPublish),s&&this.videoSmallPubState.setState(Z.AliRtcStateNoPublish),a&&this.screenPubState.setState(Z.AliRtcStateNoPublish),this.traceId="",Object.keys(this.monitorDataCache).forEach(o=>{this.reportPublishMonitor(o)}),this.streamTracks=[];const c={type:bt.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 V.fromError(t,U.ERR_INNER,"publish stop failed")}})}unPublish(){return w(this,null,function*(){const e=new Date().getTime();let t={type:bt.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,s=this.hasCameraTrackInMS,a=this.hasCameraDualTrackInMS,c=this.hasScreenTrackInMS;yield this.rtsManager.unpublish(),this.streamTracks=[],this.stopStreamMonitor(),i&&this.audioPubState.setState(Z.AliRtcStateNoPublish),s&&this.videoPubState.setState(Z.AliRtcStateNoPublish),a&&this.videoSmallPubState.setState(Z.AliRtcStateNoPublish),c&&this.screenPubState.setState(Z.AliRtcStateNoPublish),this._isPublishing=!1,this.traceId="",this.clearStream()}return this.dc&&(this.rtsManager.publishStopDataChannel(this.url,this.dc),this.dataPubState.setState(Z.AliRtcStateNoPublish),this.dc=void 0),this.slsReporter.reportUnpublish(this.callId||"",e,0,""),t}catch(i){throw V.fromError(i,U.ERR_INNER,"unpublish failed")}})}reportSelfDeviceStatus(){this.emit(Ne.Local,this.getDeviceStatus())}getDeviceStatus(){var t,i,s,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.hasCamera,e.micOpen=this.hasMicrophone,e.screenShare=this.hasScreenShare,e.audioDisable=!((t=this.streamManager.cameraStreamInfo.originAudioTrack)!=null&&t.enabled),e.videoDisable=!((i=this.streamManager.cameraStreamInfo.originVideoTrack)!=null&&i.enabled),e.screenDisable=!this.hasScreenShare||!((a=(s=this.streamManager.screenStreamInfo)==null?void 0:s.originVideoTrack)!=null&&a.enabled),Ya.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{e===D.Audio?t=this.rtsManager.getStreamByMsid({url:this.url,aMsid:e}).audioTrack:t=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 s=yield this.rtsManager.getPCStats();let a;s==null||s.forEach(u=>{u.type==="media-source"||u.type==="media-playout"?u.id&&(this.pcMediaStatsMap[u.id]=u):u.type==="candidate-pair"&&u.state==="succeeded"&&(a=u)});let c;if(((e=this.candidateDataCache)==null?void 0:e.length)>0){const t=this.candidateDataCache[this.candidateDataCache.length-1]||{},{_last:h}=t;c=qt(t,["_last"])}((i=this.candidateDataCache)==null?void 0:i.length)>=an&&this.reportNetwork(),a&&(a._last=c,this.candidateDataCache.push(a));let o=Object.keys(this.monitorDataCache).filter(u=>{var h;return((h=this.monitorDataCache[u])==null?void 0:h.length)>0});(this.streamTracks||[]).forEach(u=>{const h=u.msid;if(!h)return;o.includes(h)&&(o=o.filter(f=>f!==h));let p;h===D.Audio?p=this.rtsManager.getPublishAudioStats(this.url):p=this.rtsManager.getPublishVideoStats(this.url,h),p.then(f=>{if(!f.timestamp)return;this.monitorDataCache[h]||(this.monitorDataCache[h]=[]);const m=this.getMediaStats(f.mediaSourceId);f._source=m;const l=this.monitorDataCache[h];let S;if((l==null?void 0:l.length)>0){const v=l[l.length-1]||{},{_last:b}=v;S=qt(v,["_last"])}(l==null?void 0:l.length)>=an&&this.reportPublishMonitor(h),f._last=S,f._codec=u.codec||"",this.monitorDataCache[h].push(f)})}),o.forEach(u=>{this.reportPublishMonitor(u)})}catch(s){}}),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(Z.AliRtcStatePublishIdle),this.videoPubState.setState(Z.AliRtcStatePublishIdle),this.videoSmallPubState.setState(Z.AliRtcStatePublishIdle),this.screenPubState.setState(Z.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 s=0;return!t||t<1?s=1:s=t-1,this.rtsManager.sendSEI(this.url,e,s,i)})}sendDataChannelMessage(e){return w(this,null,function*(){var s;if(!((s=this.parameter.data)!=null&&s.enablePubDataChannel))throw new V(U.ERR_INNER,"data channel publish is not enabled");if(!this.dc)throw new V(U.ERR_INNER,"data channel is not ready");const t=e.toBuffer(),i=V0(t,1156);i.forEach((a,c)=>{const o=new Li(new li(a.byteLength,c===i.length-1,c===0?1:0),a);this.dc.send(o.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:Zt.AliRtcAudioTrackMic})}const t=[];if(this.hasCameraTrackInMS){const a=yield this.rtsManager.getPublishVideoStats(this.url,D.VideoLarge);a&&t.push({track:ne.AliRtcVideoTrackCamera,streamType:Ie.AliRtcVideoStreamTypeHigh,stats:a})}if(this.hasCameraDualTrackInMS){const a=yield this.rtsManager.getPublishVideoStats(this.url,D.VideoSmall);a&&t.push({track:ne.AliRtcVideoTrackCamera,streamType:Ie.AliRtcVideoStreamTypeLow,stats:a})}if(this.hasScreenTrackInMS){const a=yield this.rtsManager.getPublishVideoStats(this.url,D.Screen);a&&t.push({track:ne.AliRtcVideoTrackScreen,stats:a})}let i;const s=yield this.rtsManager.getPCStats();return s==null||s.forEach(a=>{a.type==="candidate-pair"&&a.state==="succeeded"&&(i=a)}),{audio:e,video:t,candidate:i}})}},g(mt,"logName","LocalUser"),mt);xe([T()],Se.prototype,"clearPublishState",1),xe([T()],Se.prototype,"clear",1),xe([T(H)],Se.prototype,"startDefaultCamera",1),xe([T(H)],Se.prototype,"startDefaultAudio",1),xe([T()],Se.prototype,"setViewConfig",1),xe([T()],Se.prototype,"startCameraCapture",1),xe([T()],Se.prototype,"stopCameraCapture",1),xe([T()],Se.prototype,"startAudioCapture",1),xe([T()],Se.prototype,"stopAudioCapture",1),xe([T()],Se.prototype,"stopPreview",1),xe([T()],Se.prototype,"resumePublish",1),xe([T()],Se.prototype,"createLocalStream",1),xe([T()],Se.prototype,"stopLocalStream",1),xe([T(H)],Se.prototype,"startPublish",1),xe([T()],Se.prototype,"updateStreams",1),xe([T(H)],Se.prototype,"publishUpdate",1),xe([T(([r])=>[r])],Se.prototype,"syncPublishToRoomServer",1),xe([T()],Se.prototype,"refreshPushStreamUrl",1),xe([T(([r,n,e])=>[JSON.stringify(e)])],Se.prototype,"publishAdd",1),xe([T(([r,n])=>[JSON.stringify(n)])],Se.prototype,"publishReplace",1),xe([T(H)],Se.prototype,"publishDeleteTracks",1),xe([T()],Se.prototype,"publishStop",1),xe([T()],Se.prototype,"unPublish",1),xe([T(([r,n,e])=>[r.length,n,e])],Se.prototype,"sendSEI",1);let j0=Se;var yt=(r=>(r.OPUS="opus",r.H264="H264",r.UNKNOWN="",r))(yt||{}),oe=(r=>(r[r.NotSubscribe=0]="NotSubscribe",r[r.Subscribing=1]="Subscribing",r[r.Subscribed=2]="Subscribed",r))(oe||{}),Vt=(r=>(r.VideoTrackEnded="videoTrackEnded",r.AudioTrackEnded="audioTrackEnded",r.ScreenTrackEnded="screenTrackEnded",r))(Vt||{});const z0=r=>{const n=new MediaStream;return n.addTrack(r),n},nn=r=>w(this,null,function*(){return yield G.AliRTS.createStream({custom:!0,mediaStream:r})}),pi=r=>w(this,null,function*(){const n=z0(r);return yield nn(n)}),W0=r=>{const{audio:n,video:e,screen:t}=r;if(e&&t)throw new V(U.ERR_INNER,"create stream error, cannot create video && screen together");return!(!e&&!n&&!t)},$0=r=>r===D.Audio||r===tr.Audio,K0=r=>r===D.VideoLarge||r===tr.VideoLarge,q0=r=>r===D.VideoSmall,J0=r=>r===D.Screen,G0=r=>r===D.Data;var X0=Object.defineProperty,Y0=Object.getOwnPropertyDescriptor,Z0=(r,n,e,t)=>{for(var i=t>1?void 0:t?Y0(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&X0(n,e,i),i};class Mi extends re{constructor(){super();g(this,"audioInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:yt.UNKNOWN});g(this,"videoLargeInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:yt.UNKNOWN});g(this,"videoSmallInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:yt.UNKNOWN});g(this,"screenInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:yt.UNKNOWN});g(this,"dataInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:yt.UNKNOWN});g(this,"audioVolume",1);g(this,"audioMuted",!1);g(this,"userStatus")}getAudioInfo(){return this.audioInfo}getVideoSmallInfo(){return this.videoSmallInfo}getVideoLargeInfo(){return this.videoLargeInfo}getScreenInfo(){return this.screenInfo}getDataInfo(){return this.dataInfo}get subscribingInfos(){return[this.audioInfo,this.videoLargeInfo,this.videoSmallInfo,this.screenInfo].filter(e=>e.msid&&e.subscribeState===oe.Subscribed)}get hasTrack(){return this.hasAudio||this.hasVideo||this.hasScreen||this.hasData}get hasAudio(){return this.audioInfo.ssrc!==""}get hasVideo(){return this.videoLargeInfo.ssrc!==""||this.videoSmallInfo.ssrc!==""}get hasVideoLarge(){return this.videoLargeInfo.ssrc!==""}get hasVideoSmall(){return this.videoSmallInfo.ssrc!==""}get hasScreen(){return this.screenInfo.ssrc!==""}get hasData(){return this.dataInfo.ssrc!==""}get isAudioSubscribed(){return this.audioInfo.subscribeState===oe.Subscribed}get isAudioSubscribing(){return this.audioInfo.subscribeState===oe.Subscribing}get isVideoSubscribed(){return this.isVideoLargeSubscribed||this.isVideoSmallSubscribed}get isVideoSubscribing(){return this.isVideoLargeSubscribing||this.isVideoSmallSubscribing}get isVideoLargeSubscribed(){return this.videoLargeInfo.subscribeState===oe.Subscribed}get isVideoLargeSubscribing(){return this.videoLargeInfo.subscribeState===oe.Subscribing}get isVideoSmallSubscribed(){return this.videoSmallInfo.subscribeState===oe.Subscribed}get isVideoSmallSubscribing(){return this.videoSmallInfo.subscribeState===oe.Subscribing}get isScreenSubscribed(){return this.screenInfo.subscribeState===oe.Subscribed}get isScreenSubscribing(){return this.screenInfo.subscribeState===oe.Subscribing}get isDataSubscribed(){return this.dataInfo.subscribeState===oe.Subscribed}get isDataSubscribing(){return this.dataInfo.subscribeState===oe.Subscribing}get audioCodec(){return this.audioInfo.codec}get videoCodec(){return this.hasVideoLarge?this.videoLargeInfo.codec:this.hasVideoSmall?this.videoSmallInfo.codec:this.hasScreen?this.screenInfo.codec:yt.UNKNOWN}get audioTrackInfo(){return this.hasAudio?Zt.AliRtcAudioTrackMic:Zt.AliRtcAudioTrackNo}get videoTrackInfo(){return this.hasVideo&&this.hasScreen?ne.AliRtcVideoTrackBoth:this.hasVideo?ne.AliRtcVideoTrackCamera:this.hasScreen?ne.AliRtcVideoTrackScreen:ne.AliRtcVideoTrackNo}updateTracks(e){let t="",i="",s="",a="",c="";return e?(e.forEach(o=>{var p;let u=yt.UNKNOWN;const h=((p=o==null?void 0:o.attr)==null?void 0:p.reason)==="reconnect";if(o.userdata){const{codec:d}=JSON.parse(o.userdata);d&&(u=d)}$0(o.msid)?(t=o.ssrc,this.audioInfo.msid=o.msid,this.audioInfo.codec=u,(h||this.audioInfo.ssrc!==t)&&(this.audioInfo.subscribeState=oe.NotSubscribe)):q0(o.msid)?(s=o.ssrc,this.videoSmallInfo.msid=o.msid,this.videoSmallInfo.codec=u,(h||this.videoSmallInfo.ssrc!==s)&&(this.videoSmallInfo.subscribeState=oe.NotSubscribe)):K0(o.msid)?(i=o.ssrc,this.videoLargeInfo.msid=o.msid,this.videoLargeInfo.codec=u,(h||this.videoLargeInfo.ssrc!==i)&&(this.videoLargeInfo.subscribeState=oe.NotSubscribe)):J0(o.msid)?(a=o.ssrc,this.screenInfo.msid=o.msid,this.screenInfo.codec=u,(h||this.screenInfo.ssrc!==a)&&(this.screenInfo.subscribeState=oe.NotSubscribe)):G0(o.msid)&&(c=o.ssrc,this.dataInfo.msid=o.msid,this.dataInfo.codec=u,(h||this.dataInfo.ssrc!==c)&&(this.dataInfo.subscribeState=oe.NotSubscribe))}),this.updateRemoteTrackSsrc(t,i,s,a,c)):this.updateRemoteTrackSsrc(t,i,s,a,c),{}}updateRemoteTrackSsrc(e,t,i,s,a){this.audioInfo.ssrc=e,this.videoSmallInfo.ssrc=i,this.videoLargeInfo.ssrc=t,this.screenInfo.ssrc=s,this.dataInfo.ssrc=a}markRemoteTrackSubscribing(e){return e.video&&(e.vMsid===this.videoSmallInfo.msid&&(this.videoSmallInfo.subscribeState=oe.Subscribing),(e.vMsid===this.videoLargeInfo.msid||!e.vMsid)&&(this.videoLargeInfo.subscribeState=oe.Subscribing)),e.screen&&(this.screenInfo.subscribeState=oe.Subscribing),e.audio&&(this.audioInfo.subscribeState=oe.Subscribing),e.data&&(this.dataInfo.subscribeState=oe.Subscribing),{videoLargeInfo:this.videoLargeInfo,videoSmallInfo:this.videoSmallInfo}}updateRemoteTrackSubState(e){return e.video!==void 0&&((e.vMsid===this.videoSmallInfo.msid||!e.vMsid)&&(this.videoSmallInfo.subscribeState=e.video?oe.Subscribed:oe.NotSubscribe),(e.vMsid===this.videoLargeInfo.msid||!e.vMsid)&&(this.videoLargeInfo.subscribeState=e.video?oe.Subscribed:oe.NotSubscribe)),e.screen!==void 0&&(this.screenInfo.subscribeState=e.screen?oe.Subscribed:oe.NotSubscribe),e.audio!==void 0&&(this.audioInfo.subscribeState=e.audio?oe.Subscribed:oe.NotSubscribe),e.data!==void 0&&(this.dataInfo.subscribeState=e.data?oe.Subscribed:oe.NotSubscribe),{audioInfo:this.audioInfo,videoLargeInfo:this.videoLargeInfo,videoSmallInfo:this.videoSmallInfo,screenInfo:this.screenInfo,dataInfo:this.dataInfo}}updateRemoteUserDeviceStatus(e){let t=Ya.parseStatus(e);const{audioDisable:i,videoDisable:s,screenDisable:a}=t;return this.userStatus?(this.userStatus.audioDisable!=i&&(this.userStatus.audioDisable=i,this.emit(Ne.Remote,i?he.MuteAudio:he.UnmuteAudio)),this.userStatus.videoDisable!=s&&(this.userStatus.videoDisable=s,this.emit(Ne.Remote,s?he.MuteVideo:he.UnmuteVideo)),this.userStatus.screenDisable!=a&&(this.userStatus.screenDisable=a,this.emit(Ne.Remote,a?he.MuteScreen:he.UnmuteScreen))):(this.userStatus=t,this.emit(Ne.Remote,i?he.MuteAudio:he.UnmuteAudio),this.emit(Ne.Remote,s?he.MuteVideo:he.UnmuteVideo),this.emit(Ne.Remote,a?he.MuteScreen:he.UnmuteScreen)),!1}}g(Mi,"logName","RemoteStreamInfo"),Z0([T()],Mi.prototype,"updateRemoteTrackSubState",1);class on{constructor(n){g(this,"remoteUser");this.remoteUser=n}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 Q0=Object.defineProperty,ec=Object.getOwnPropertyDescriptor,De=(r,n,e,t)=>{for(var i=t>1?void 0:t?ec(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&Q0(n,e,i),i};class ei extends re{constructor(){super();g(this,"state");g(this,"time");g(this,"_enabled");this.state=le.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 tc=30,we=(Me=class extends Xa{constructor(e){var f;const{userId:t,displayName:i,rtsManager:s,usersViewMap:a,slsReporter:c,signalingManager:o,localUser:u,audioVolumeIndicationInterval:h,playoutVolume:p,parameter:d}=e;super(t,i,s,h);g(this,"remoteCallid","");g(this,"remoteUserInfo");g(this,"localUser");g(this,"lastPubId","");g(this,"stream");g(this,"screenStream");g(this,"viewMap");g(this,"audioTrack");g(this,"audioElement");g(this,"subscribed",!1);g(this,"mediaStream");g(this,"secondaryMediaStream");g(this,"prevSubConfig");g(this,"signalingManager");g(this,"slsReporter");g(this,"wantSubAudio",!1);g(this,"wantSubVideo",!1);g(this,"wantSubScreen",!1);g(this,"defaultVideoStreamType",Ie.AliRtcVideoStreamTypeHigh);g(this,"audioMuted",!1);g(this,"playoutVolume",1);g(this,"playoutGainNode");g(this,"audioSubState");g(this,"videoSubState");g(this,"videoLargeSubState",new ei);g(this,"videoSmallSubState",new ei);g(this,"screenSubState");g(this,"dataSubState");g(this,"dc");g(this,"dcMsgWaitingPieces",[]);g(this,"streamInfo");g(this,"_streamUrl","");g(this,"parameter",{});g(this,"monitorTimerId");g(this,"monitorDataCache",{});g(this,"trackTraceIdMap",{});g(this,"handleAudioContextSuspended",e=>{e.target.state==="suspended"&&this.emit("remoteAudioPlayError",this.uid,"AudioContext suspended")});g(this,"onDataChannelMessage",e=>{var s;const t=Li.parse(e.slice(4));let i;if(t.body)if(t.isFin){if(this.dcMsgWaitingPieces.length>0){const a=this.dcMsgWaitingPieces.reduce((c,o)=>c+o.byteLength,t.body.byteLength);try{const c=new ArrayBuffer(a);let o=0;for(let h=0;h<this.dcMsgWaitingPieces.length;h++){const p=this.dcMsgWaitingPieces[h];new Uint8Array(c,o,p.byteLength).set(new Uint8Array(p)),o+=p.byteLength}new Uint8Array(c,o,t.body.byteLength).set(new Uint8Array(t.body)),i=Ft.parse(c)}catch(c){}this.dcMsgWaitingPieces=[],i||(i=Ft.parse(t.body))}else i=Ft.parse(t.body);i||O.event(`[${Me.logName}]`,`parse data channel message fail, piece count: ${this.dcMsgWaitingPieces.length+1}`)}else{t.header.frameType===1&&(this.dcMsgWaitingPieces=[]),this.dcMsgWaitingPieces.push(t.body);return}i&&(O.event(`[${Me.logName}]`,`receive data channel message, length: ${(s=i.data)==null?void 0:s.byteLength}`),this.emit("remoteDataChannelMessage",this.uid,i))});g(this,"onDataChannelError",e=>{this.emit("occurError",V.fromError(e,U.ERR_SDK_SUBSCRIBE_DATA_ERROR))});g(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))});g(this,"handleAudioPaused",()=>{this.emit("remoteAudioPlayError",this.uid,"paused")});this.streamInfo=new Mi,this.remoteUserInfo=new on(this),this.parameter=d,this.streamInfo.on(Ne.Remote,m=>{this.emit(Ne.Remote,m,this.userId)}),this.signalingManager=o,this.viewMap=(f=a[t])!=null?f:{cameraViews:[],screenViews:[]},a[t]=this.viewMap,this.slsReporter=c,this.localUser=u,this.audioSubState=new ei,this.audioSubState.on("change",(m,l,S)=>{this.emit("audioSubscribeStateChanged",this.uid,m,l,S)}),this.videoSubState=new ei,this.videoSubState.on("change",(m,l,S)=>{this.emit("videoSubscribeStateChanged",this.uid,m,l,S)}),this.screenSubState=new ei,this.screenSubState.on("change",(m,l,S)=>{this.emit("screenSubscribeStateChanged",this.uid,m,l,S)}),this.dataSubState=new ei,this.dataSubState.on("change",(m,l,S)=>{this.emit("dataSubscribeStateChanged",this.uid,m,l,S)}),this.playoutVolume=p}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(pe.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=Lt.getInstance();i.addEventListener("statechange",this.handleAudioContextSuspended);const s=i.createMediaStreamSource(t);this.audioElement.muted=!0,this.playoutGainNode=i.createGain(),s.connect(this.playoutGainNode),this.playoutGainNode.gain.value=e,this.playoutGainNode.connect(i.destination)}}else this.audioElement.volume=e}getAudioMuted(){return this.audioMuted}get hasAudioTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasAudio)}get hasVideoTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasVideo)}get hasVideoLargeTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasVideoLarge)}get hasVideoSmallTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasVideoSmall)}get hasScreenTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasScreen)}get isAudioSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isAudioSubscribed)||!!((t=this.streamInfo)!=null&&t.isAudioSubscribing)}get isVideoSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isVideoSubscribed)||!!((t=this.streamInfo)!=null&&t.isVideoSubscribing)}get isVideoLargeSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isVideoLargeSubscribed)||!!((t=this.streamInfo)!=null&&t.isVideoLargeSubscribing)}get isVideoSmallSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isVideoSmallSubscribed)||!!((t=this.streamInfo)!=null&&t.isVideoSmallSubscribing)}get isScreenSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isScreenSubscribed)||!!((t=this.streamInfo)!=null&&t.isScreenSubscribing)}get isDataSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isDataSubscribed)||!!((t=this.streamInfo)!=null&&t.isDataSubscribing)}get audioEnabled(){var e,t;return!!((t=(e=this.stream)==null?void 0:e.audioTrack)!=null&&t.enabled)}get videoEnabled(){var e,t;return!!((t=(e=this.stream)==null?void 0:e.videoTrack)!=null&&t.enabled)}get screenEnabled(){var e,t;return!!((t=(e=this.screenStream)==null?void 0:e.videoTrack)!=null&&t.enabled)}get getAudioTrack(){return this.audioTrack}get getCameraStream(){return this.stream}get getScreenStream(){return this.screenStream}setViewConfig(e,t){if(t!==ne.AliRtcVideoTrackScreen&&t!==ne.AliRtcVideoTrackCamera)throw new V(U.ERR_INVALID_ARGUMENTS,"track is not AliRtcVideoTrackScreen or AliRtcVideoTrackCamera");e?ns(e).forEach(s=>{s.setAttribute("playsinline",""),G.AliRTS.BrowserUtil.isMicroMessenger&&(s.setAttribute("x5-video-player-type","h5-page"),s.setAttribute("x5-playsinline",""),G.AliRTS.SystenUtil.isAndroid||G.AliRTS.SystenUtil.isIos&&s.setAttribute("x-webkit-airplay","allow")),t===ne.AliRtcVideoTrackScreen?this.viewMap.screenViews.push(s):this.viewMap.cameraViews.push(s),this.play(s,t===ne.AliRtcVideoTrackScreen)}):(this.stopPlayAll(t===ne.AliRtcVideoTrackScreen),t===ne.AliRtcVideoTrackScreen?this.viewMap.screenViews=[]:this.viewMap.cameraViews=[])}clear(e=!0){return w(this,null,function*(){var t;this.subscribeStopDataChannel(),e&&this.doStopSubscribe(this.streamUrl),Es(Me.prototype,this,"clear").call(this),this.stopPlayAudio(),this.clearStream(),this.clearScreenStream(),this.playoutGainNode&&(this.playoutGainNode.disconnect(),this.playoutGainNode=void 0,Lt.getInstance().removeEventListener("statechange",this.handleAudioContextSuspended)),(t=this.streamInfo)==null||t.removeAllListeners(Ne.Remote)})}updateRemoteUserDeviceStatus(e){var t;(t=this.streamInfo)==null||t.updateRemoteUserDeviceStatus(e)}updateRemoteTracks(e,t,i,s){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 Mi),(c=this.streamInfo)==null?void 0:c.updateTracks(s)})}subscribe(s,a){return w(this,arguments,function*(e,t,i=Date.now()){var f,m;let c=e;if(!c){const{hasAudio:l,hasVideo:S,hasScreen:v,hasData:x}=(f=this.streamInfo)!=null?f:{};c={audio:this.wantSubAudio&&l,video:this.wantSubVideo&&S,screen:this.wantSubScreen&&v,data:((m=this.parameter.data)==null?void 0:m.enableSubDataChannel)&&x}}this.streamInfo.markRemoteTrackSubscribing(c);const{screen:o,audio:u,video:h,vMsid:p}=c,d=[];(h||u)&&d.push({audio:u,video:h,vMsid:p}),o&&d.push({screen:o}),!(d.length===0&&!(e!=null&&e.data))&&(yield Promise.all(d.map(l=>this.subscribeProxy(l,t||pe.User,i))),e!=null&&e.data&&this.subscribeDataChannel())})}subscribeProxy(e,t,i){return w(this,null,function*(){var c,o,u,h;let s=new Date().getTime(),a="";try{e.audio&&this.audioSubState.setState(le.AliRtcStateSubscribing),e.video&&(this.videoSubState.currentState===le.AliRtcStateSubscribeIdle||this.videoSubState.currentState===le.AliRtcStateNoSubscribe)&&this.videoSubState.setState(le.AliRtcStateSubscribing),e.screen&&this.screenSubState.setState(le.AliRtcStateSubscribing);const p=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=p.traceId||"";const{stream:d}=p;if(e.audio){this.trackTraceIdMap[D.Audio]=a;const m=d.audioTrack;m&&(this.audioTrack=m,(o=d.mediaStream)==null||o.removeTrack(m),this.playAudio(),this.audioVolumeIndicationInterval&&this.audioLevelMonitor.start(m,this.audioVolumeIndicationInterval)),this.audioSubState.setState(le.AliRtcStateSubscribed),this.audioSubState.getEnabled()||this.toggleAudio(!1)}e.video&&(this.videoSubState.setState(le.AliRtcStateSubscribed),e.vMsid===D.VideoSmall?(this.trackTraceIdMap[D.VideoSmall]=a,this.videoSmallSubState.setState(le.AliRtcStateSubscribed)):(this.trackTraceIdMap[D.VideoLarge]=a,this.videoLargeSubState.setState(le.AliRtcStateSubscribed)),this.videoSubState.getEnabled()||this.toggleVideo(!1),this.updateStream(d,this.isVideoLargeSubscribing&&this.isVideoSmallSubscribing)),e.screen&&(this.screenSubState.setState(le.AliRtcStateSubscribed),this.trackTraceIdMap[D.Screen]=a,this.videoSubState.getEnabled()||this.toggleScreen(!1),this.updateScreenStream(d));const f=new Date().getTime()-s;this.slsReporter.reportSubscribe(((u=this.localUser)==null?void 0:u.callId)||"",this.callId,!!e.video&&e.vMsid===D.VideoLarge,!!e.video&&e.vMsid===D.VideoSmall,!!e.screen,!!e.audio,0,"",f,{pctid:this.rtsManager.pcTraceId,subtid:a,ajsub:t===pe.Join?1:0,url:this.streamUrl,est:s}),this.startStreamMonitor()}catch(p){const d=new Date().getTime()-s;e.audio&&this.audioSubState.setState(le.AliRtcStateNoSubscribe),e.video&&this.videoSubState.setState(le.AliRtcStateNoSubscribe),e.screen&&this.screenSubState.setState(le.AliRtcStateNoSubscribe),p&&(p.message=`user(${this.uid}) subscribe error, ${(p==null?void 0:p.message)||""}`);let f=U.ERR_INNER;e.audio&&(f=U.ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED),e.video&&(e.vMsid===D.VideoSmall?f=U.ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED:f=U.ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED),e.screen&&(f=U.ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED),this.slsReporter.reportSubscribe(((h=this.localUser)==null?void 0:h.callId)||"",this.callId,!!e.video&&e.vMsid===D.VideoLarge,!!e.video&&e.vMsid===D.VideoSmall,!!e.screen,!!e.audio,f,"",d,{pctid:this.rtsManager.pcTraceId,subtid:"",ajsub:t===pe.Join?1:0,url:this.streamUrl,est:s});const m=V.fromError(p,f);throw this.emit("remoteSubscribeError",m),m}})}subscribeDeleteTracks(e){return w(this,null,function*(){const{audio:t,video:i,screen:s,data:a,vMsid:c}=e,o=[];(t||i||a)&&o.push({audio:t,video:i,vMsid:c}),s&&o.push({screen:s}),o.length!==0&&(yield Promise.all(o.map(u=>this.subscribeDeleteProxy(u))),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:{},s={};e.audio===!0&&(s.audio=!1,this.audioSubState.setState(le.AliRtcStateNoSubscribe)),e.video===!0&&(s.video=!1,e.vMsid===D.VideoSmall?(this.videoSmallSubState.setState(le.AliRtcStateNoSubscribe),(this.videoLargeSubState.currentState===le.AliRtcStateNoSubscribe||this.videoLargeSubState.currentState===le.AliRtcStateSubscribeIdle)&&this.videoSubState.setState(le.AliRtcStateNoSubscribe)):(this.videoLargeSubState.setState(le.AliRtcStateNoSubscribe),(this.videoSmallSubState.currentState===le.AliRtcStateNoSubscribe||this.videoSmallSubState.currentState===le.AliRtcStateSubscribeIdle)&&this.videoSubState.setState(le.AliRtcStateNoSubscribe))),e.screen===!0&&(s.screen=!1,this.screenSubState.setState(le.AliRtcStateNoSubscribe));const{callId:a,remoteCallid:c}=this,o={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?!1:void 0,video:e.video===!0?!1:void 0,screen:e.screen===!0?!1:void 0,vMsid:e.vMsid}),o}catch(t){throw V.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=Lt.getInstance();return e.state!=="running"&&e.resume(),this.audioElement?this.audioElement.play():this.playAudio()})}resumeVideo(e){return w(this,null,function*(){if(!e||e===ne.AliRtcVideoTrackCamera||e===ne.AliRtcVideoTrackBoth)return this.playAll();if(!e||e===ne.AliRtcVideoTrackScreen||e===ne.AliRtcVideoTrackBoth)return this.playAll(!0)})}resumePlay(){this.playAudio(),this.playAll(),this.playAll(!0)}stopSubscribe(e){return w(this,null,function*(){var i,s;let t=new Date().getTime();try{let a;e?a=yield this.subscribeDeleteTracks(e):a=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(((s=this.localUser)==null?void 0:s.callId)||"",this.callId,new Date().getTime()-t,0,""),a}})}doStopSubscribe(e){return w(this,null,function*(){var s,a,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 u={callid:t,remoteCallid:i,remoteStream:this.stream};return this.callId="",u}catch(u){if(((o=(c=(a=(s=u==null?void 0:u.extraInfo)==null?void 0:s.parsedData)==null?void 0:a.streams)==null?void 0:c[0])==null?void 0:o.res_code)!==404)throw V.fromError(u,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 s,a;if(e.mediaStream){a=document.createElement("video");const c=()=>{O.event(`uid: ${this.userId} new mediaStream canplay`),a&&a.removeEventListener("canplaythrough",c,!1),a=void 0,clearTimeout(s),i(!0)};a.addEventListener("canplaythrough",c,!1),(a._playPromise||Promise.resolve()).then(()=>{a&&e.mediaStream&&(a.srcObject=e.mediaStream)})}else i(!0);s=window.setTimeout(()=>{O.event(`uid: ${this.userId} new mediaStream timeout`),a=void 0,i(!0)},3e3)}),this.updateSubscribe(pe.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(le.AliRtcStateSubscribing),this.rtsManager.subscribeAddDataChannel(this.streamUrl).then(e=>{if(e){this.dataChannelConnected(e),this.dataSubState.setState(le.AliRtcStateSubscribed),this.streamInfo.updateRemoteTrackSubState({data:!0});return}else throw new Error("no dc founded")}).catch(e=>{const t=V.fromError(e,U.ERR_INNER,"subscribe data failed");this.emit("remoteSubscribeError",t),this.dataSubState.setState(le.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(le.AliRtcStateNoSubscribe),this.dc=void 0,this.streamInfo.updateRemoteTrackSubState({data:!1})}}getRetryOptions(){var i,s,a,c,o,u,h;const e={};this.wantSubAudio&&((i=this.streamInfo)!=null&&i.hasAudio)&&(e.audio=!0,e.aMsid=((s=this.streamInfo.getAudioInfo())==null?void 0:s.msid)||D.Audio),this.wantSubVideo&&((a=this.streamInfo)!=null&&a.hasVideo)&&(this.defaultVideoStreamType===Ie.AliRtcVideoStreamTypeLow&&((c=this.streamInfo)!=null&&c.hasVideoSmall)?(e.video=!0,e.vMsid=D.VideoSmall):(o=this.streamInfo)!=null&&o.hasVideoLarge&&(e.video=!0,e.vMsid=((u=this.streamInfo.getVideoLargeInfo())==null?void 0:u.msid)||D.VideoLarge)),this.wantSubScreen&&((h=this.streamInfo)!=null&&h.hasScreen)&&(e.screen=!0);let t={};if(e.audio||e.video)t={audio:e.audio,video:e.video},this.streamInfo.updateRemoteTrackSubState({screen:!1,data:!1});else if(e.screen)t={screen:e.screen},this.streamInfo.updateRemoteTrackSubState({data:!1});else return;return{remoteUser:this,options:t}}updateSubscribe(e){var a,c,o,u,h,p,d,f,m,l,S,v,x,b,E,A,y;const t=Date.now(),i={},s={};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)||D.Audio):(!this.wantSubAudio||!((o=this.streamInfo)!=null&&o.hasAudio))&&this.isAudioSubscribing&&(s.audio=!0,s.aMsid=((u=this.streamInfo.getAudioInfo())==null?void 0:u.msid)||D.Audio),this.wantSubVideo&&((h=this.streamInfo)!=null&&h.hasVideo)?(this.defaultVideoStreamType===Ie.AliRtcVideoStreamTypeLow&&!this.isVideoSmallSubscribing&&((p=this.streamInfo)!=null&&p.hasVideoSmall)?(i.video=!0,i.vMsid=D.VideoSmall):!this.isVideoLargeSubscribing&&((d=this.streamInfo)!=null&&d.hasVideoLarge)&&!(this.defaultVideoStreamType===Ie.AliRtcVideoStreamTypeLow&&this.isVideoSmallSubscribing)&&(i.video=!0,i.vMsid=((f=this.streamInfo.getVideoLargeInfo())==null?void 0:f.msid)||D.VideoLarge),this.defaultVideoStreamType===Ie.AliRtcVideoStreamTypeLow&&this.isVideoLargeSubscribing&&this.isVideoSmallSubscribing&&this.streamInfo.hasVideoSmall?(s.video=!0,s.vMsid=D.VideoLarge):this.defaultVideoStreamType===Ie.AliRtcVideoStreamTypeHigh&&this.isVideoLargeSubscribing&&this.isVideoSmallSubscribing&&(s.video=!0,s.vMsid=D.VideoSmall)):(!this.wantSubVideo||!((m=this.streamInfo)!=null&&m.hasVideo))&&this.isVideoSubscribing&&(s.video=!0,s.vMsid=this.streamInfo.isVideoSmallSubscribed||this.streamInfo.isVideoSmallSubscribing?D.VideoSmall:((l=this.streamInfo.getVideoLargeInfo())==null?void 0:l.msid)||D.VideoLarge),this.wantSubScreen&&!this.isScreenSubscribing&&((S=this.streamInfo)!=null&&S.hasScreen)?i.screen=!0:(!this.wantSubScreen||!((v=this.streamInfo)!=null&&v.hasScreen))&&this.isScreenSubscribing&&(s.screen=!0),(x=this.parameter.data)!=null&&x.enableSubDataChannel&&!this.isDataSubscribing&&((b=this.streamInfo)!=null&&b.hasData)?i.data=!0:(!((E=this.parameter.data)!=null&&E.enableSubDataChannel)||!((A=this.streamInfo)!=null&&A.hasData))&&this.isDataSubscribing&&(s.data=!0),(i.audio||i.video||i.screen||i.data)&&(this.createCallId(),this.subscribe(i,e,t)),(s.audio||s.video||s.screen)&&this.subscribeDeleteTracks(s),e===pe.Reconnect){if(O.event(`[${Me.logName}]`,"reconnect, try to resume"),this.streamInfo.hasData&&!i.data){const _=this.rtsManager.getDatachannelByMsid({url:this.streamUrl,msid:this.streamInfo.getDataInfo().msid||D.Data});this.dataChannelConnected(_)}if(this.streamInfo.hasAudio&&!i.audio){const _=this.rtsManager.getStreamByMsid({url:this.streamUrl,aMsid:this.streamInfo.getAudioInfo().msid||D.Audio}).audioTrack;_&&(this.audioTrack=_,this.playAudio())}if(this.streamInfo.hasVideo&&!i.video){const _=this.rtsManager.getStreamByMsid({url:this.streamUrl,vMsid:this.streamInfo.isVideoSmallSubscribed||this.streamInfo.isVideoSmallSubscribing?D.VideoSmall:((y=this.streamInfo.getVideoLargeInfo())==null?void 0:y.msid)||D.VideoLarge});_&&_.mediaStream&&(this.stream=_,this.playAll(!1))}if(this.streamInfo.hasScreen&&!i.screen){const _=this.rtsManager.getStreamByMsid({url:this.streamUrl,sMsid:this.streamInfo.getScreenInfo().msid||D.Screen});_&&_.mediaStream&&(this.screenStream=_,this.playAll(!0))}}return{addOption:i,deleteOption:s}}handleAutoPlayFailed(){O.event(`[${Me.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 s=(a=t===ne.AliRtcVideoTrackScreen?this.screenStream:this.stream)==null?void 0:a.mediaStream;e.srcObject===s&&this.play(e,t===ne.AliRtcVideoTrackScreen),document.removeEventListener("click",i,!1),document.removeEventListener("touchstart",i,!1)};document.addEventListener("click",i,!1),document.addEventListener("touchstart",i,!1)}playAudio(){return w(this,null,function*(){var e,t;if(!this.audioTrack){O.event(`[${Me.logName}]`,this.userId,"audio track is null");return}if(this.toggleAudio(!this.audioMuted),this.audioElement||(O.event(`[${Me.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(s=>{i.removeTrack(s)}):(i=new MediaStream,this.audioElement.srcObject=i),i.addTrack(this.audioTrack)}if(G.AliRTS.SystenUtil.isIos&&parseInt(G.AliRTS.SystenUtil.systemVersion)<=13){O.event(`[${Me.logName}]`,"play audio for iOS 13-");const i=this.audioElement;i.setAttribute("autoplay","");const s=()=>{i.removeEventListener("playing",s),i.pause(),i.play().catch(()=>{this.handleAutoPlayFailed()})};this.audioElement.addEventListener("playing",s)}else(()=>{var s;O.event(`[${Me.logName}]`,"try play audio"),(s=this.audioElement)==null||s.play().then(()=>{O.event(`[${Me.logName}]`,"play audio success")}).catch(()=>{this.handleAutoPlayFailed()})})()})}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 s=t?this.screenStream:this.stream;!e||!s||!s.mediaStream||rn(e,s.mediaStream,i).catch(a=>{a.code===20||a.name==="AbortError"||this.handleVideoPlayFailded(e,t?ne.AliRtcVideoTrackScreen:ne.AliRtcVideoTrackCamera)})}stopPlayAll(e=!1){e?this.viewMap.screenViews.forEach(t=>{dt(t)}):this.viewMap.cameraViews.forEach(t=>{dt(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,s,a,c,o;const e=[];if(this.isAudioSubscribing){const u=yield this.rtsManager.getSubscribeAudioStats(this.streamUrl);u&&e.push({uid:this.uid,track:Zt.AliRtcAudioTrackMic,stats:u})}const t=[];if((i=this.streamInfo)!=null&&i.isVideoLargeSubscribed){const u=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((s=this.streamInfo.getVideoLargeInfo())==null?void 0:s.msid)||D.VideoLarge);u&&t.push({uid:this.uid,track:ne.AliRtcVideoTrackCamera,streamType:Ie.AliRtcVideoStreamTypeHigh,stats:u})}if((a=this.streamInfo)!=null&&a.isVideoSmallSubscribed){const u=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((c=this.streamInfo.getVideoSmallInfo())==null?void 0:c.msid)||D.VideoSmall);u&&t.push({uid:this.uid,track:ne.AliRtcVideoTrackCamera,streamType:Ie.AliRtcVideoStreamTypeLow,stats:u})}if(this.isScreenSubscribing){const u=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((o=this.streamInfo.getScreenInfo())==null?void 0:o.msid)||D.Screen);u&&t.push({uid:this.uid,track:ne.AliRtcVideoTrackScreen,stats:u})}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){this.stopStreamMonitor();return}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;e.includes(i)&&(e=e.filter(c=>c!==i));let s;const a=i===D.Audio;a?s=this.rtsManager.getSubscribeAudioStats(this.streamUrl):s=this.rtsManager.getSubscribeVideoStats(this.streamUrl,i),s.then(c=>{var p;if(!c.timestamp)return;this.monitorDataCache[i]||(this.monitorDataCache[i]=[]);const o=this.monitorDataCache[i];let u;if((o==null?void 0:o.length)>0){const h=o[o.length-1]||{},{_last:f}=h;u=qt(h,["_last"])}(o==null?void 0:o.length)>=tc&&this.reportSubscribeMonitor(i),c._last=u,c._codec=t.codec,a&&(c._source=(p=this.localUser)==null?void 0:p.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)})}},g(Me,"logName","RemoteUser"),Me);De([T()],we.prototype,"clear",1),De([T()],we.prototype,"updateRemoteUserDeviceStatus",1),De([T()],we.prototype,"updateRemoteTracks",1),De([T(H)],we.prototype,"subscribe",1),De([T()],we.prototype,"subscribeProxy",1),De([T(H)],we.prototype,"subscribeDeleteProxy",1),De([T()],we.prototype,"restore",1),De([T(H)],we.prototype,"resumeAudio",1),De([T(H)],we.prototype,"stopSubscribe",1),De([T(H)],we.prototype,"doStopSubscribe",1),De([T()],we.prototype,"clearStream",1),De([T()],we.prototype,"clearScreenStream",1),De([T()],we.prototype,"updateSubscribe",1),De([T()],we.prototype,"playAudio",1),De([T()],we.prototype,"stopPlayAudio",1),De([T((r,n,e)=>[typeof r=="string"?r:r==null?void 0:r.nodeType,n,e])],we.prototype,"play",1),De([T()],we.prototype,"stopPlayAll",1);let ic=we;var Ct=(r=>(r[r.AliRtcPluginErrorCodeSuccess=0]="AliRtcPluginErrorCodeSuccess",r[r.AliRtcPluginErrorCodeFailed=-1]="AliRtcPluginErrorCodeFailed",r[r.AliRtcPluginErrorNoFindPlugin=-2]="AliRtcPluginErrorNoFindPlugin",r[r.AliRtcPluginErrorParameterError=-3]="AliRtcPluginErrorParameterError",r[r.AliRtcPluginErrorLoadError=-4]="AliRtcPluginErrorLoadError",r[r.AliRtcPluginErrorCreateError=-5]="AliRtcPluginErrorCreateError",r[r.AliRtcPluginErrorInitError=-6]="AliRtcPluginErrorInitError",r[r.AliRtcPluginErrorInitTokenError=-7]="AliRtcPluginErrorInitTokenError",r))(Ct||{});class rc extends re{constructor(){super(...arguments);g(this,"plugins",new Map)}add(e,t){if(this.plugins.has(e.name))throw new V(Ct.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 V(Ct.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,_e=(r,n,e,t)=>{for(var i=t>1?void 0:t?ac(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&sc(n,e,i),i};const Fi=([r])=>{const{remoteUser:n,options:e}=r;return[`user(${n.userId})`,e]},cn=5,un=17,hn=5e3,be=(Ce=class extends re{constructor(e,t,i){super();g(this,"rts");g(this,"encodedInsertableStreams",!0);g(this,"audioRedEnabled",!1);g(this,"localStreamManager");g(this,"slsReporter");g(this,"_rtsReconnecting",!1);g(this,"_rtsPeerConnectionType","publish");g(this,"connecting",!1);g(this,"connected",!1);g(this,"_pcTraceId","");g(this,"_localJoinTime",0);g(this,"connectionResolve");g(this,"connectingPromise");g(this,"dcResolve");g(this,"dcReject");g(this,"dcConnectingPromise");g(this,"_publishingTracks",[]);g(this,"parameter",{});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,s,a;if(O.event(`[${Ce.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_RECONNECTING)this._rtsReconnecting=!0;else if(e.status===G.EConnectStatus.CONNECT_STATUS_CONNECTED){const c=(a=(s=(i=(t=this.rts.commonController)==null?void 0:t.peerCore)==null?void 0:i.getSignal())==null?void 0:s.getDatachannelCore())==null?void 0:a.readyState;O.event(`[${Ce.logName}]`,"dcReadyState:",c),c==="open"&&this.dcResolve&&this.dcResolve(!0),this._rtsReconnecting&&this._rtsPeerConnectionType==="publish"&&(this._publishingTracks=this.rts.getPublishTrackInfoList()),this.setConnected(!0)}}),this.rts.on("reconnectFinish",()=>{O.event(`[${Ce.logName}]`,"rts reconnectFinish");try{this.emit("connected",!0,this._rtsPeerConnectionType)}catch(e){O.error(`[${Ce.logName}]`,"emit connected error:",e)}}),this.rts.on("datachannelStatusChange",e=>{O.event(`[${Ce.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=>{O.event(`[${Ce.logName}]`,"rts onError event:",e)}),this.rts.on("reconnect",e=>{O.event(`[${Ce.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 s=[...((t=RTCRtpReceiver.getCapabilities("audio"))==null?void 0:t.codecs)||[]];if(s.length>0){if(e){const a=s.findIndex(o=>o.mimeType==="audio/red"),c=s.findIndex(o=>o.mimeType==="audio/opus");if(a>-1&&c>-1&&a>c){const o=s[c];s[c]=s[a],s[a]=o}}this.rts.setSenderCodecPreferences({audio:s}),this.rts.setReceiverCodecPreferences({audio:s})}}catch(i){}this.audioRedEnabled=e}}clear(){this.setConnected(!1);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,this._rtsReconnecting=!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:s}=t!=null?t:{},a={};return e.hasAudio&&(a.aMsid=[i!=null?i:D.Audio]),e.hasScreen&&(a.vMsid=[D.Screen]),e.hasVideo&&(a.vMsid=[s!=null?s:t!=null&&t.isScreen?D.Screen:D.VideoLarge]),a}updatePublishingTracks(e){e&&(this._publishingTracks=e.map(({msid:t,from:i,ssrc:s,codec:a,type:c,trackId:o})=>({msid:t,from:i,type:c,ssrc:`${s}`,codec:a!=null?a:"",trackId:o})))}httpPublish(a,c){return w(this,arguments,function*(e,t,i=!1,s=ct.MANUAL){var b,E;let o;const u=Date.now(),{publishStream:h,videoSmallStream:p,screenStream:d,vMsid:f}=yield this.localStreamManager.createHTTPPublishStream();if(!h)return O.warn(`[${Ce.logName}]`,"publishStream is null"),{traceId:"",l1ip:o};const m=this.getPubMsid(h,{vMsid:f});this.encodedInsertableStreams&&(m.encodedInsertableStreams=!0),m.answerSdpHook=A=>{const y=/\d+\.\d+\.\d+\.\d+(?=\s+1106|\s+8000)/.exec(A);return y!=null&&y[0]&&(o=y[0]),A},(E=(b=this.parameter)==null?void 0:b.net)!=null&&E.useTCP&&(m.tcpOnly=!0),m.retryTimes=un,m.retryInterval=hn,this._rtsPeerConnectionType="publish";let l=!h.hasVideo,S=f,v="";this.startConnect();const x=Date.now();try{v=yield this.rts.publish(tn(e),h,m)}catch(A){this.setConnected(!1);const y=2e3-(Date.now()-x);throw y<=0?this.emit("disconnected"):setTimeout(()=>{this.emit("disconnected")},y),this.slsReporter.reportPublish(i,e,t,h.hasVideo&&(!f||f===D.VideoLarge),h.hasVideo&&f===D.VideoSmall,h.hasVideo&&f===D.Screen,h.hasAudio,(A==null?void 0:A.errorCode)||-1,this.pcTraceId,"",x),V.fromRtsError(A)}O.event(`[${Ce.logName}]`,"rts publish success",v),this.slsReporter.reportPublish(i,e,t,h.hasVideo&&(!f||f===D.VideoLarge),h.hasVideo&&f===D.VideoSmall,h.hasVideo&&f===D.Screen,h.hasAudio,0,v,v,x),this.slsReporter.reportConnectionLatencyEvent(Ke.HANDLE_PUB_TASK,Ze.START,t,v,u),this.slsReporter.reportConnectionLatencyEvent(Ke.HANDLE_PUB_TASK,Ze.END,t,v,Date.now());try{const A=Date.now();return this._pcTraceId=v,this.setConnected(!0),this._publishingTracks=this.rts.getPublishTrackInfoList(),p&&(yield this.publishAdd(e,p,t,{vMsid:D.VideoSmall},i),l=!1,S=D.VideoSmall),d&&(yield this.publishAdd(e,d,t,{vMsid:D.Screen},i),l=!1,S=D.Screen),yield this.waitPublishSender(e,l,S),this.slsReporter.reportPublishFirstPacket(i,t,x,A,this._localJoinTime,l?D.Audio:m.vMsid,v||"",v||"",s),{traceId:v,l1ip:o}}catch(A){throw this.setConnected(!1),V.fromError(A)}})}waitPublishSender(e,t=!1,i){return w(this,null,function*(){const s=(a,c)=>{let o=0;const u=()=>(t?this.rts.getPublishAudioStats(e,i):this.rts.getPublishVideoStats(e,i)).then(p=>!(p.bytesSent>0)&&o<a?(o++,new Promise(f=>setTimeout(()=>f(u()),c))):Promise.resolve());return u()};return Promise.race([_t(1e3),s(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(u,h,p,d){return w(this,arguments,function*(e,t,i,s,a=!1,c=!1,o=ct.MANUAL){var l,S,v,x,b,E,A,y;yield this.dcConnectingPromise;const f=Date.now(),m=this.getPubMsid(t,s);try{const _=yield en(R=>w(this,null,function*(){return R>0&&O.event(`[${Ce.logName}]`,`publishAdd retry times: ${R}`),this.isConnected?(yield this.dcConnectingPromise,this.rts.publishAdd([Y({url:e,stream:t,updateSourceStream:!1},m)])):Promise.reject(new V(U.ERR_INNER,"rts not connected"))}),cn,0,R=>(R==null?void 0:R.errorCode)===15006);if(_){const R=Date.now(),[L]=_;return this.slsReporter.reportPublish(!1,e,i,((l=m.vMsid)==null?void 0:l[0])===D.VideoLarge,((S=m.vMsid)==null?void 0:S[0])===D.VideoSmall,((v=m.vMsid)==null?void 0:v[0])===D.Screen,((x=m.aMsid)==null?void 0:x[0])===D.Audio,0,this.pcTraceId,L.traceId||"",f),this.updatePublishingTracks(L.trackInfoList),c&&(yield this.waitPublishSender(e,!t.hasVideo,t.hasVideo?s==null?void 0:s.vMsid:s==null?void 0:s.aMsid)),this.slsReporter.reportPublishFirstPacket(a,i,f,R,this._localJoinTime,(t.hasVideo?s==null?void 0:s.vMsid:s==null?void 0:s.aMsid)||"",this.pcTraceId,L.traceId||"",o),L.traceId||""}}catch(_){throw this.slsReporter.reportPublish(!1,e,i,((b=m.vMsid)==null?void 0:b[0])===D.VideoLarge,((E=m.vMsid)==null?void 0:E[0])===D.VideoSmall,((A=m.vMsid)==null?void 0:A[0])===D.Screen,((y=m.aMsid)==null?void 0:y[0])===D.Audio,(_==null?void 0:_.errorCode)||-1,this.pcTraceId,"",f),_!=null&&_.errorCode?V.fromRtsError(_):V.fromError(_)}return""})}publishDelete(e,t){return w(this,null,function*(){var u,h,p,d,f,m,l,S;yield this.dcConnectingPromise;const i=(h=(u=this.publishingTracks)==null?void 0:u.find(({msid:v})=>v===D.Audio))==null?void 0:h.msid,s=(d=(p=this.publishingTracks)==null?void 0:p.find(({msid:v})=>v===D.VideoLarge))==null?void 0:d.msid,a=(m=(f=this.publishingTracks)==null?void 0:f.find(({msid:v})=>v===D.Screen))==null?void 0:m.msid,c=[];t.screen&&a?c.push(a):t.video&&c.push(t.vMsid||s);const o=[];t.audio&&i&&o.push(i),O.event(Ce.logName,"publishDelete",{streamUrl:e,aMsid:o,vMsid:c});try{const[v]=(yield this.rts.publishDeleteTracks([{url:e,aMsid:o,vMsid:c}]))||[];return O.event(Ce.logName,"publishDelete",{result:v}),v&&this.updatePublishingTracks(v.trackInfoList),((S=(l=v==null?void 0:v.trackInfoList)==null?void 0:l[0])==null?void 0:S.trackId)||""}catch(v){throw V.fromRtsError(v)}})}publishReplace(e,t,i){return w(this,null,function*(){var c,o;yield this.dcConnectingPromise;const{vMsid:s,aMsid:a}=i!=null?i:{};try{const u=yield this.rts.publishReplaceTracks([{url:e,stream:t,updateSourceStream:!1,vMsid:s,aMsid:a}]),[h]=u;return this.updatePublishingTracks(h.trackInfoList),((o=(c=h==null?void 0:h.trackInfoList)==null?void 0:c[0])==null?void 0:o.trackId)||""}catch(u){throw V.fromRtsError(u)}})}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:e,label:D.Data,msid:D.Data}),i=t==null?void 0:t.datachannel;if(i&&i.send){const s=new ArrayBuffer(4);new DataView(s).setUint8(0,240),i.datachannel.send(s)}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.connecting=!1,this.connected=!1})}getSubConfig(e,t){let i=t!=null?t:{};t||(i={audio:!0,video:!0,screen:!0});const s={};return i.audio&&(s.aMsid=[(e==null?void 0:e.getAudioInfo().msid)||D.Audio]),i.video?i.vMsid?s.vMsid=[i.vMsid]:e!=null&&e.hasVideoLarge?s.vMsid=[(e==null?void 0:e.getVideoLargeInfo().msid)||D.VideoLarge]:e!=null&&e.hasVideoSmall?s.vMsid=[(e==null?void 0:e.getVideoSmallInfo().msid)||D.VideoSmall]:s.vMsid=[D.VideoLarge]:i.screen&&(s.vMsid=[(e==null?void 0:e.getScreenInfo().msid)||D.Screen]),s}httpSubscribe(e){return w(this,null,function*(){var c,o,u,h,p,d;const{remoteUser:t,options:i}=e;let s=t.streamUrl;i.video||i.screen?i!=null&&i.audio||(s+="@subaudio=no"):s+="@subvideo=no";const a=this.getSubConfig(t.streamInfo,i);if(this.encodedInsertableStreams&&(a.encodedInsertableStreams=!0),(o=(c=this.parameter)==null?void 0:c.net)!=null&&o.useTCP&&(a.tcpOnly=!0),(h=(u=this.parameter)==null?void 0:u.net)!=null&&h.mediaTimeout){const f=(d=(p=this.parameter)==null?void 0:p.net)==null?void 0:d.mediaTimeout;f>1e3&&f<1e5&&(a.mediaTimeout=f)}a.retryTimes=un,a.retryInterval=hn,this._rtsPeerConnectionType="subscribe";try{this.startConnect();const f=yield this.rts.subscribe(tn(s),a);return this._pcTraceId=f.traceId,this.setConnected(!0),{traceId:f.traceId,stream:f}}catch(f){throw this.setConnected(!1),this.emit("disconnected"),V.fromRtsError(f)}})}subscribeAdd(e){return w(this,null,function*(){var a,c,o,u;const{remoteUser:t,options:i}=e,s=vt(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 en(p=>w(this,null,function*(){return yield this.dcConnectingPromise,p>0&&O.event(`[${Ce.logName}]`,`subscribeAdd retry times: ${p}`),this.isConnected?this.rts.subscribeAdd([s]):Promise.reject()}),cn,0,p=>(p==null?void 0:p.errorCode)===15006))[0]}catch(h){if(((u=(o=(c=(a=h==null?void 0:h.extraInfo)==null?void 0:a.parsedData)==null?void 0:c.streams)==null?void 0:o[0])==null?void 0:u.res_code)===508)return this.emit("subscribeexceeds"),null;throw V.fromRtsError(h)}})}subscribeDelete(e){return w(this,null,function*(){var a,c,o,u;const{remoteUser:t,options:i}=e,s=vt(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([s]))[0]}catch(h){if(((u=(o=(c=(a=h==null?void 0:h.extraInfo)==null?void 0:a.parsedData)==null?void 0:c.streams)==null?void 0:o[0])==null?void 0:u.res_code)===404)return;throw V.fromRtsError(h)}})}subscibeStop(e){return w(this,null,function*(){var t,i,s,a;try{yield this.rts.subscribeStop([{url:e}])}catch(c){if(((a=(s=(i=(t=c==null?void 0:c.extraInfo)==null?void 0:t.parsedData)==null?void 0:i.streams)==null?void 0:s[0])==null?void 0:a.res_code)===404)return;throw V.fromRtsError(c)}})}subscribeAddDataChannel(e){return w(this,null,function*(){yield this.dcConnectingPromise;const t=yield this.rts.subscribeAddDatachannel({signalUrl:e,url:e,label:D.Data,msid:D.Data}),i=t==null?void 0:t.datachannel;if(i&&i.send){const s=new ArrayBuffer(4);new DataView(s).setUint8(0,240),i.send(s)}return i})}subscribeStopDatachannel(e,t){return w(this,null,function*(){let i;try{i=yield this.rts.subscribeStopDatachannel({url:e,datachannel:t})}catch(s){}return t==null||t.dispose(),i})}publish(a,c){return w(this,arguments,function*(e,t,i=!1,s=ct.MANUAL){let o="",u;if(this.connecting&&(yield this.connectingPromise),this.connected){yield this.dcConnectingPromise;let h=!1,p;const{audio:d,video:f,videoSmall:m,screen:l}=this.localStreamManager.publishStreams;d&&(o=yield this.publishAdd(e,d,t,{aMsid:D.Audio},i),h=!0,p=D.Audio,yield _t(100)),f&&(o=yield this.publishAdd(e,f,t,{vMsid:D.VideoLarge},i),h=!1,p=D.VideoLarge,yield _t(100)),m&&(o=yield this.publishAdd(e,m,t,{vMsid:D.VideoSmall},i),h=!1,p=D.VideoSmall,yield _t(100)),l&&(o=yield this.publishAdd(e,l,t,{isScreen:!0,vMsid:D.Screen},i),h=!1,p=D.Screen),p&&(yield this.waitPublishSender(e,h,p))}else{const h=yield this.httpPublish(e,t,i,s);o=h.traceId,u=h.l1ip}return{traceId:o,l1ip:u}})}reportSubscribeLatency(e,t,i,s){const a=[];e.audio&&a.push(e.aMsid||D.Audio),e.video?a.push(e.vMsid||D.VideoLarge):e.screen&&a.push(D.Screen),a.forEach(c=>{this.slsReporter.reportConnectionLatencyEvent(Ke.HANDLE_SUB_TASK,Ze.START,t,c,i,0,s),this.slsReporter.reportConnectionLatencyEvent(Ke.HANDLE_SUB_TASK,Ze.END,t,c,Date.now(),0,s)})}subscribe(e,t,i,s,a){return w(this,null,function*(){let c=!1;const{options:o,remoteUser:u}=e;if(o.video&&o.screen)throw new V(U.ERR_INNER,"subscribe error, video and screen cannot be subscribed at the same time");this.connecting&&(yield this.connectingPromise);let h,p=Date.now();this.connected?h=yield this.subscribeAdd(e):(c=!0,h=yield this.httpSubscribe(e)),this.reportSubscribeLatency(o,i,p,c);const d=Date.now();let f=D.VideoLarge,m=o.video||o.screen,l=o.audio;o.video&&o.vMsid?f=o.vMsid:o.screen&&(f=D.Screen);let S=0,v=0,x=0;const E=((A,y)=>{let _=0;const R=()=>{let L;return l&&!S&&(L=this.rts.getSubscribeAudioStats(u.streamUrl).then(C=>{if(C.packetsReceived>0)S=Date.now();else if(!m)return _<A?(_++,new Promise(I=>setTimeout(()=>I(R()),y))):!1;return!0})),m&&!x&&(L=this.rts.getSubscribeVideoStats(u.streamUrl,f).then(C=>{if(C.packetsReceived>0&&(v=Date.now()),C.framesDecoded>0)x=Date.now();else return _<A?(_++,new Promise(I=>setTimeout(()=>I(R()),y))):(O.event(`[${Ce.logName}]`,u.userId,"尝试获取首帧数据失败"),!1);return!0})),Promise.resolve(L)};return R()})(40,100);return E.then(()=>{v&&this.slsReporter.reportSubscribeFirstPacket(t===pe.Resume,i,s,f,{fprt:v-p,ifsprtc:x?x-p:0,ajsub:t===pe.Join?1:0,pctid:this.pcTraceId,subtid:(h==null?void 0:h.traceId)||"",sstc:d-p}),x&&this.slsReporter.reportSubscribeFirstFrame(t===pe.Resume,i,s,f,{fvfrt:x-p,fp2fftc:x-v,ajsub:t===pe.Join?1:0,tffrtc:t===pe.Join?x-this.localJoinTime:x-a,pctid:this.pcTraceId,subtid:(h==null?void 0:h.traceId)||"",fvfdtc:x-p}),S&&(this.slsReporter.reportConnectionLatencyEvent(Ke.FIRST_REMOTE,Ze.DECODED,i,D.Audio,S),this.slsReporter.reportSubscribeFirstPacket(t===pe.Resume,i,s,D.Audio,{fprt:S-p,ifsprtc:S-p,ajsub:t===pe.Join?1:0,pctid:this.pcTraceId,subtid:(h==null?void 0:h.traceId)||"",sstc:d-p}))}),c&&(yield Promise.race([E,_t(1500)])),h})}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,s){return w(this,null,function*(){return this.rts.sendSEI({url:e,vMsid:D.VideoLarge,data:t,repeatCount:i,payloadType:s})})}},g(Ce,"logName","RtsManager"),Ce);_e([T(H)],be.prototype,"startConnect",1),_e([T()],be.prototype,"updatePublishingTracks",1),_e([T(H,H)],be.prototype,"httpPublish",1),_e([T(H,H)],be.prototype,"waitPublishSender",1),_e([T(([r,n,e])=>[r,JSON.stringify(e)],H)],be.prototype,"publishAdd",1),_e([T(H,H)],be.prototype,"publishDelete",1),_e([T(([r,n,e])=>[r,JSON.stringify(e)])],be.prototype,"publishReplace",1),_e([T(H)],be.prototype,"publishStop",1),_e([T(H)],be.prototype,"publishAddDataChannel",1),_e([T(H)],be.prototype,"publishStopDataChannel",1),_e([T()],be.prototype,"unpublish",1),_e([T(Fi,({traceId:r})=>r)],be.prototype,"httpSubscribe",1),_e([T(Fi,({traceId:r})=>r)],be.prototype,"subscribeAdd",1),_e([T(Fi)],be.prototype,"subscribeDelete",1),_e([T(H)],be.prototype,"subscibeStop",1),_e([T(H)],be.prototype,"subscribeAddDataChannel",1),_e([T(H)],be.prototype,"subscribeStopDatachannel",1),_e([T(H)],be.prototype,"publish",1),_e([T(Fi)],be.prototype,"subscribe",1),_e([T()],be.prototype,"sendSEI",1);let nc=be;class us{constructor(n=as){g(this,"defaultProfile");g(this,"profile");g(this,"profileMap",new Map);g(this,"audioProfile");g(this,"contentHint");this.defaultProfile=Y({},n)}updateProfile(n,e){e&&this.profileMap.set(n,Y(Y(Y({},this.defaultProfile),this.profileMap.get(n)||{}),e)),this.profile=n}get videoProfile(){return this.profile}updateAudioProfile(n){this.audioProfile=n}setContentHint(n,e){e&&(this.contentHint=e),this.contentHint&&n&&(n.contentHint=this.contentHint)}setVideoProfile(n,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&&n&&n.readyState==="live"&&n.applyConstraints)try{yield n.applyConstraints(i)}catch(s){}if(e){const s=Y({},i);i.maxSendFrameRate&&(s.frameRate=i.maxSendFrameRate),e==null||e.VideoProfileMap.set(this.profile,s),yield e.setVideoProfile(this.profile)}}})}}class hs extends re{constructor(e){super();g(this,"type");g(this,"originVideoTrack");g(this,"videoSource");g(this,"_videoMuted",!1);g(this,"originAudioTrack");g(this,"audioSource");g(this,"_audioMuted",!1);g(this,"_targetVideoTrack");g(this,"_targetDualVideoTrack");g(this,"_targetAudioTrack");g(this,"_publishVideoStream");g(this,"_publishDualVideoStream");g(this,"_publishAudioStream");g(this,"_previewStream");g(this,"plugins",[]);g(this,"_profileManager");g(this,"cameraVideoConstraints");g(this,"micAudioConstraints");g(this,"onVideoTrackEnded",()=>{this.emit("videotrackended")});g(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,o,u,h,p,d;const{videoTrack:s,audioTrack:a}=e;s&&((c=this.originVideoTrack)==null||c.removeEventListener("ended",this.onVideoTrackEnded)),a&&((o=this.originAudioTrack)==null||o.removeEventListener("ended",this.onAudioTrackEnded)),this.type===ve.AliRtcSdkStreamTypeScreen?this.stop():(s&&((u=this.originVideoTrack)==null||u.stop()),a&&((h=this.originAudioTrack)==null||h.stop())),s&&(this.originVideoTrack=s,(p=this.originVideoTrack)==null||p.addEventListener("ended",this.onVideoTrackEnded),this.videoSource=t||Gt.Camera,this.updateVideoTrack(s)),a&&(this.originAudioTrack=a,(d=this.originAudioTrack)==null||d.addEventListener("ended",this.onAudioTrackEnded),this.audioSource=i||bi.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,s,a,c,o,u,h,p,d,f,m;this._targetAudioTrack=this.originAudioTrack,this._targetVideoTrack=this.originVideoTrack;for(const l of this.plugins)try{yield l.execute(this,e)}catch(S){console.error(`error in plugin-${l.name}, error: ${S}`)}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),(s=this.profileManager)==null||s.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,(o=this.previewStream)==null||o.deleteTracks({video:!0})),this._targetDualVideoTrack?((h=(u=this._publishDualVideoStream)==null?void 0:u.videoTrack)==null?void 0:h.id)!==this._targetDualVideoTrack.id&&(this._publishDualVideoStream=yield pi(this._targetDualVideoTrack),this._videoMuted?this._publishDualVideoStream.disableVideo():this._publishDualVideoStream.enableVideo()):this._publishDualVideoStream=void 0,this._targetAudioTrack?((d=(p=this._publishAudioStream)==null?void 0:p.audioTrack)==null?void 0:d.id)!==this._targetAudioTrack.id&&(this._publishAudioStream=yield pi(this._targetAudioTrack),this.setAudioMuted(this._audioMuted),this.previewStream?(f=this.previewStream)==null||f.mergeStream(this._publishAudioStream):this._previewStream=yield pi(this._targetAudioTrack)):(this._publishAudioStream=void 0,(m=this.previewStream)==null||m.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){return w(this,null,function*(){this._profileManager||(this._profileManager=new us(this.type===ve.AliRtcSdkStreamTypeScreen?Za:as)),e&&this._profileManager.updateProfile(e,t),yield this._profileManager.setVideoProfile(this.originVideoTrack,this._publishVideoStream,this.type===ve.AliRtcSdkStreamTypeScreen)})}get videoProfile(){var e;return(e=this.profileManager)==null?void 0:e.videoProfile}setVideoContentHint(e){this._profileManager||(this._profileManager=new us(this.type===ve.AliRtcSdkStreamTypeScreen?Za:as)),this._profileManager.setContentHint(this.currentVideoTrack,e)}updateAudioProfile(e){return w(this,null,function*(){this._profileManager||(this._profileManager=new us),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):!1}}var oc=Object.defineProperty,cc=Object.getOwnPropertyDescriptor,rt=(r,n,e,t)=>{for(var i=t>1?void 0:t?cc(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&oc(n,e,i),i};const Qe=(Rt=class extends re{constructor(e,t){super();g(this,"pluginManager");g(this,"slsReporter");g(this,"publishingCameraVideoStream");g(this,"publishingScreenVideoStream");g(this,"cameraStreamInfo",new hs(ve.AliRtcSdkStreamTypeCapture));g(this,"screenStreamInfo",new hs(ve.AliRtcSdkStreamTypeScreen));g(this,"streamInfos",[this.cameraStreamInfo,this.screenStreamInfo]);g(this,"_audioCaptureDisabled",!1);g(this,"_cameraCaptureDisabled",!1);g(this,"_publishLocalAudioStreamEnabled",!0);g(this,"_publishLocalVideoStreamEnabled",!0);g(this,"_publishLocalScreenStreamEnabled",!0);this.screenStreamInfo.setVideoContentHint("motion"),this.pluginManager=e,this.slsReporter=t;const i=s=>w(this,null,function*(){if(O.info(`[${Rt.logName}]`,"plugin added",s.name),!s.isSupported("6.14.4-beta.5")){console.warn(`${s.name} is not supported!!!`),s.emit("unsupported");return}try{yield s.init()}catch(a){s.emit("error",V.fromError(a,Ct.AliRtcPluginErrorInitError))}s.streamType===ve.AliRtcSdkStreamTypeCapture&&(this.cameraStreamInfo.addPlugin(s),yield this.cameraStreamInfo.process(this.streamInfos)),s.streamType===ve.AliRtcSdkStreamTypeScreen&&(this.screenStreamInfo.addPlugin(s),yield this.screenStreamInfo.process(this.streamInfos)),this.emit("publishupdate")});this.cameraStreamInfo.on("videotrackended",()=>w(this,null,function*(){yield this.stopLocalStream({video:!0}),this.emit("trackended",Vt.VideoTrackEnded)})),this.cameraStreamInfo.on("audiotrackended",()=>w(this,null,function*(){yield this.stopLocalStream({audio:!0}),this.emit("trackended",Vt.AudioTrackEnded)})),this.screenStreamInfo.on("videotrackended",()=>w(this,null,function*(){yield this.stopLocalStream({screen:!0}),this.emit("trackended",Vt.ScreenTrackEnded)})),this.pluginManager.on("added",i),this.pluginManager.on("removed",s=>w(this,null,function*(){this.cameraStreamInfo.removePlugin(s)&&(yield this.cameraStreamInfo.process(this.streamInfos)),this.screenStreamInfo.removePlugin(s)&&(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,s;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(o=>o.deviceId===a)||(a=(s=(i=c.find(o=>!!o.deviceId))==null?void 0:i.deviceId)!=null?s:""),this.cameraStreamInfo.cameraVideoConstraints.deviceId=a}})}setAvailableMicrophoneDeviceId(){return w(this,null,function*(){var e,t,i,s;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(o=>o.deviceId===a)||(a=(s=(i=c.find(o=>!!o.deviceId))==null?void 0:i.deviceId)!=null?s:""),this.cameraStreamInfo.micAudioConstraints.deviceId=a}})}createLocalStream(e){return w(this,null,function*(){var p;const{screen:t,mediaStream:i,videoProfile:s,screenProfile:a}=e;let{video:c,audio:o}=e;const u=W0(e);let h;if(u){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)),o===void 0&&this.audioCaptureDisabled?o=!1:o&&(o===!0&&this.cameraStreamInfo.micAudioConstraints?(yield this.setAvailableMicrophoneDeviceId(),o=Y({},this.cameraStreamInfo.micAudioConstraints)):typeof o=="object"&&(yield this.setAvailableMicrophoneDeviceId(),o=Y(Y({},o),this.cameraStreamInfo.micAudioConstraints)),this._audioCaptureDisabled=!1));const d=Date.now();try{h=yield G.AliRTS.createStream({audio:o,video:c,screen:t,custom:!!i,mediaStream:i,skipProfile:!0}),O.info(`[${Rt.logName}]`,"createLocalStream",{audio:o,video:c,screen:t,custom:!!i,time:Date.now()-d}),o&&!i&&this.slsReporter.reportAudio(null,Date.now()-d,((p=h==null?void 0:h.audioTrack)==null?void 0:p.label)||""),t&&!i&&this.slsReporter.reportScreen(null,Date.now()-d)}catch(f){throw o&&!i&&this.slsReporter.reportAudio(f,Date.now()-d,""),t&&!i&&this.slsReporter.reportScreen(null,Date.now()-d),f}if(t)yield this.screenStreamInfo.updateSource(h,Gt.Screen,bi.Screen),yield this.setScreenProfile(a),this.setScreenContentHint(),this.publishingScreenVideoStream=void 0;else if(yield this.cameraStreamInfo.updateSource(h,Gt.Camera,bi.Microphone),h.hasVideo&&(yield this.setVideoProfile(s),this.setVideoContentHint(),this.publishingCameraVideoStream=void 0),h.hasAudio&&typeof o=="boolean"){const f=this.cameraStreamInfo.audioProfile;f&&(yield h.setAudioProfile(f))}}return G.AliRTS.SystenUtil.isIos&&G.AliRTS.SystenUtil.compareVersion("15.1")&&!G.AliRTS.SystenUtil.compareVersion("15.2")&&(yield _t(1e3)),yield this.updateStreams(),h})}stopLocalStream(e){return w(this,null,function*(){const{screen:t,video:i,audio:s}=e!=null?e:{};let a=!1;i&&this.cameraStreamInfo.originVideoTrack&&(a=!0,this.cameraStreamInfo.stopVideo(),this.publishingCameraVideoStream=void 0),s&&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 o,u,h,p;let e,t=!1,i,s,a;const c=this.publishStreams;try{if(!c.audio&&!c.video&&!c.videoSmall&&!c.screen)throw O.error(`[${Rt.logName}]`,"no tracks founded"),new V(U.ERR_SDK_PUBLISH_INVAILD,"no tracks founded");const d=new MediaStream;(o=c.audio)!=null&&o.audioTrack&&d.addTrack(c.audio.audioTrack),(u=c.video)!=null&&u.videoTrack?(d.addTrack(c.video.videoTrack),s=c.videoSmall,a=c.screen):(h=c.screen)!=null&&h.videoTrack&&(i=D.Screen,d.addTrack((p=c.screen)==null?void 0:p.videoTrack),t=!0),e=yield nn(d),t?(this.screenStreamInfo.cloneVideoProfile(e),this.publishingScreenVideoStream=e):(this.cameraStreamInfo.cloneVideoProfile(e),this.publishingCameraVideoStream=e)}catch(d){}return{publishStream:e,videoSmallStream:s,screenStream:a,vMsid:i}})}stop(){this.cameraStreamInfo.stop(),this.screenStreamInfo.stop(),this.updateStreams()}setVideoProfile(e,t){return w(this,null,function*(){yield this.cameraStreamInfo.updateVideoProfile(e,t),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)}},g(Rt,"logName","LocalStreamManager"),Rt);rt([T(([r])=>{const{audio:n,video:e,screen:t,custom:i,skipProfile:s,videoProfile:a,screenProfile:c}=r;return[{audio:n,video:e,screen:t,custom:i,skipProfile:s,videoProfile:a,screenProfile:c}]})],Qe.prototype,"createLocalStream",1),rt([T(H)],Qe.prototype,"stopLocalStream",1),rt([T()],Qe.prototype,"createHTTPPublishStream",1),rt([T()],Qe.prototype,"stop",1),rt([T(H)],Qe.prototype,"setVideoProfile",1),rt([T(H)],Qe.prototype,"setVideoContentHint",1),rt([T(H)],Qe.prototype,"setAudioProfile",1),rt([T(H)],Qe.prototype,"setScreenProfile",1),rt([T(H)],Qe.prototype,"setScreenContentHint",1),rt([T(H)],Qe.prototype,"setCameraVideoConstraints",1),rt([T(H)],Qe.prototype,"setMicAudioConstraints",1);let uc=Qe;class hc extends Bt{constructor(){super("AliRtcScreenStandardize",ve.AliRtcSdkStreamTypeScreen);g(this,"canvas");g(this,"lastWidth");g(this,"lastHeight");g(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,s=Math.ceil(t/this.options.base)*this.options.base;if(this.canvas||(this.canvas=document.createElement("canvas")),this.canvas.width=i,this.canvas.height=s,this.lastWidth&&e>this.lastWidth||this.lastHeight&&t>this.lastHeight){const a=this.canvas.getContext("2d");a&&a.clearRect(0,0,i,s)}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:s}=e;if(!i||!s||i%this.options.base===0&&s%this.options.base===0)return this.clear(t),e;this.updateProcessCanvas(i,s);const a=(c=this.canvas)==null?void 0:c.getContext("2d");if(this.canvas&&a){a.drawImage(e,0,0,i,s);const o=new VideoFrame(this.canvas,{timestamp:e.timestamp});return e.close(),o}return e})}process(e){return w(this,null,function*(){var h;if(!e.originVideoTrack||e.videoSource!==Gt.Screen){this.clear(e),this.hasScreenTrack=!1;return}const t=new MediaStreamTrackProcessor({track:e.originVideoTrack}),i=new MediaStreamTrackGenerator({kind:"video"}),s=new MediaStream([i]),a=this,c=new TransformStream({transform(p,d){return w(this,null,function*(){const f=yield a.handleFrame(p,e);yield d.enqueue(f),f==null||f.close()})}});t.readable.pipeThrough(c).pipeTo(i.writable);const o=(h=s.getVideoTracks())==null?void 0:h[0];e.updateVideoTrack(o),this.hasScreenTrack=!0})}clear(e){this.canvas=void 0,this.lastWidth=void 0,this.lastHeight=void 0,super.clear(e)}}class dc extends Bt{constructor(){super("blankAudio",ve.AliRtcSdkStreamTypeCapture,ai.BOTH);g(this,"hasTrack",!1);g(this,"oscillator",null);g(this,"audioTrack",null);g(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 s=i.stream;return this.audioTrack=s.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 s;const i=t.some(a=>a.originVideoTrack||a.originAudioTrack);this.hasTrack=i,i?this.audioTrack&&((s=this.oscillator)==null||s.stop(),this.oscillator=null,this.audioTrack.stop(),this.audioTrack=null):(this.audioTrack||(this.audioTrack=this.createAudioTrack()),e.updateAudioTrack(this.audioTrack))})}}class dn{constructor(n){g(this,"name","COMMON");this.name=n||this.name}info(...n){}warn(...n){}print(n,...e){const t=n.toLowerCase();t&&console[t](`[${n}][${this.name}]`,...e)}}g(dn,"LEVEL",0);class lc{constructor(){g(this,"logger",new dn("AudioMixer"));g(this,"audioContext",new AudioContext);g(this,"audioDestination",this.audioContext.createMediaStreamDestination());g(this,"audioTrack",F0(this.audioDestination.stream));g(this,"sourceNodeMap",{})}get sourceNodeList(){return Object.values(this.sourceNodeMap).map(n=>n.sourceNode).filter(n=>!!n)}get gainNodeList(){return Object.values(this.sourceNodeMap).map(n=>n.gainNode).filter(n=>!!n)}get sourceCount(){return this.sourceNodeList.length}resume(){var n;return(n=this.audioContext)==null?void 0:n.resume()}addTrack(n){this.connectTrack(n)}hasTrack(n){return!!this.sourceNodeMap[n]}removeTrack(n){const{sourceNode:e,gainNode:t}=this.sourceNodeMap[n]||{};t==null||t.disconnect(),e==null||e.disconnect(),delete this.sourceNodeMap[n],e?this.logger.info("SourceNode disconnected. Active source node:",this.sourceNodeList.length):this.logger.warn(`SourceNode ${n} does not exit. Active source node: ${this.sourceNodeList.length}`)}getAudioTrack(){return this.audioTrack}setVolume(n,e){const{gainNode:t}=this.sourceNodeMap[e]||{};t?(this.logger.info(`Setting node(${e}) volume to ${this.scale(n)}`),t.gain.value=this.scale(n)):this.logger.warn(`GainNode ${e} does not exit.`)}reset(){this.disconnectSourceNode(),this.sourceNodeMap={}}dispose(){var n;this.reset(),(n=this.audioTrack)==null||n.stop(),this.audioDestination.disconnect(),this.audioContext.close()}connectTrack(n){if(!this.audioContext)return this.logger.warn("AudioContext not initialized");let e=new MediaStream;e.addTrack(n);const t=this.audioContext.createMediaStreamSource(e),i=this.audioContext.createGain();i.gain.value=1,t.connect(i),i.connect(this.audioDestination),this.sourceNodeMap[n.id]={track:n,sourceNode:t,gainNode:i},this.logger.info("New sourceNode connected. Active source node:",this.sourceNodeList.length)}disconnectSourceNode(){this.sourceNodeList.forEach(n=>n.disconnect()),this.gainNodeList.forEach(n=>n.disconnect())}scale(n){return n/100}}const fc=4;class pc extends Bt{constructor(){super("audioMixer",ve.AliRtcSdkStreamTypeCapture,ai.AUDIO);g(this,"audioMixer");g(this,"primaryAudioTrackId");g(this,"screenAudioTrackId");g(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(o=>o.type===ve.AliRtcSdkStreamTypeCapture),s=t.find(o=>o.type===ve.AliRtcSdkStreamTypeScreen);return!(this.primaryAudioTrackId===((a=i==null?void 0:i.currentAudioTrack)==null?void 0:a.id)&&this.screenAudioTrackId===((c=s==null?void 0:s.currentAudioTrack)==null?void 0:c.id)&&!this.dirty)}process(e,t){return w(this,null,function*(){var c,o;this.dirty=!1;const i=t.find(u=>u.type===ve.AliRtcSdkStreamTypeScreen),s=e.currentAudioTrack,a=i==null?void 0:i.currentAudioTrack;if(!a&&this.options.audio===1){this.audioMixer&&(this.audioMixer.dispose(),this.audioMixer=void 0),this.primaryAudioTrackId=s==null?void 0:s.id,e.updateAudioTrack(s);return}this.audioMixer||(this.audioMixer=new lc),yield this.audioMixer.resume(),this.primaryAudioTrackId&&(s==null?void 0:s.id)!==this.primaryAudioTrackId&&((c=this.audioMixer)==null||c.removeTrack(this.primaryAudioTrackId)),s&&!this.audioMixer.hasTrack(s==null?void 0:s.id)&&this.audioMixer.addTrack(s),this.primaryAudioTrackId=s==null?void 0:s.id,this.screenAudioTrackId&&(a==null?void 0:a.id)!==this.screenAudioTrackId&&((o=this.audioMixer)==null||o.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<=fc}updateVolume(){this.audioMixer&&(this.primaryAudioTrackId&&this.audioMixer.setVolume(this.options.audio*100,this.primaryAudioTrackId),this.screenAudioTrackId&&this.audioMixer.setVolume(this.options.screen*100,this.screenAudioTrackId))}clear(e){var t;(t=this.audioMixer)==null||t.dispose(),super.clear(e)}}class ds{constructor(n,e){g(this,"originTrack");g(this,"originVideo");g(this,"targetWidth");g(this,"targetHeight");g(this,"targetFrameRate");g(this,"targetCanvas");g(this,"animationFrameId");g(this,"resultTrack");this.targetWidth=e.width,this.targetHeight=e.height,this.targetFrameRate=e.frameRate,this.originTrack=n,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(n){this.targetWidth=n.width,this.targetHeight=n.height,this.targetFrameRate=n.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(n,e,t,i){const s=e/n,a=i/t;let c=t,o=i,u=0,h=0;return a>s?(c=Math.round(o/s),u=Math.round((t-c)/2)):a<s&&(o=Math.round(c*s),h=Math.round((i-o)/2)),{x:u,y:h,width:c,height:o}}}class gc extends ds{constructor(e,t){super(e,t);g(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}}const mc=`
|
|
27
|
+
`+e)}}return null})}var e0=(r,n,e)=>new Promise((t,i)=>{var s=o=>{try{c(e.next(o))}catch(u){i(u)}},a=o=>{try{c(e.throw(o))}catch(u){i(u)}},c=o=>o.done?t(o.value):Promise.resolve(o.value).then(s,a);c((e=e.apply(r,n)).next())});function Hr(r){return{transString:function(n){let e={},t=0,i=!1;for(let s in n){if((s==="time"||s==="__time__")&&typeof n[s]=="number"){t=n[s],i=!0;continue}typeof n[s]=="object"?e[s]=JSON.stringify(n[s]):e[s]=String(n[s])}return e.__time__=i?t:Math.floor(new Date().getTime()/1e3),e},process:function(n,e){return e0(this,null,function*(){yield Qo(r);let t=n.slice(n.indexOf("/logstores")),i=e.length,s=Xo(e),a=new Date().toUTCString(),c=new Map,o=new Map([["Content-Type","application/json"],["Content-MD5",s],["x-log-bodyrawsize",i.toString()]]);r.securityToken&&o.set("x-acs-security-token",r.securityToken),Yo("POST",t,r.accessKeyId,r.accessKeySecret,c,o,s,a);let u=Object.fromEntries(o);return{data:e,header:u}})}}}typeof window!="undefined"&&ea(window,"stsPlugin",Hr);var t0=/d{1,4}|D{3,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|W{1,2}|[LlopSZN]|"[^"]*"|'[^']*'/g,i0=/\b(?:[A-Z]{1,3}[A-Z][TC])(?:[-+]\d{4})?|((?:Australian )?(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time)\b/g,r0=/[^-+\dA-Z]/g;function jr(r,n,e,t){if(arguments.length===1&&typeof r=="string"&&!/\d/.test(r)&&(n=r,r=void 0),r=r||r===0?r:new Date,r instanceof Date||(r=new Date(r)),isNaN(r))throw TypeError("Invalid date");n=String(Ua[n]||n||Ua.default);var i=n.slice(0,4);(i==="UTC:"||i==="GMT:")&&(n=n.slice(4),e=!0,i==="GMT:"&&(t=!0));var s=function(){return e?"getUTC":"get"},a=function(){return r[s()+"Date"]()},c=function(){return r[s()+"Day"]()},o=function(){return r[s()+"Month"]()},u=function(){return r[s()+"FullYear"]()},h=function(){return r[s()+"Hours"]()},p=function(){return r[s()+"Minutes"]()},d=function(){return r[s()+"Seconds"]()},f=function(){return r[s()+"Milliseconds"]()},m=function(){return e?0:r.getTimezoneOffset()},l=function(){return s0(r)},S=function(){return a0(r)},v={d:function(){return a()},dd:function(){return $e(a())},ddd:function(){return Ue.dayNames[c()]},DDD:function(){return Ha({y:u(),m:o(),d:a(),_:s(),dayName:Ue.dayNames[c()],short:!0})},dddd:function(){return Ue.dayNames[c()+7]},DDDD:function(){return Ha({y:u(),m:o(),d:a(),_:s(),dayName:Ue.dayNames[c()+7]})},m:function(){return o()+1},mm:function(){return $e(o()+1)},mmm:function(){return Ue.monthNames[o()]},mmmm:function(){return Ue.monthNames[o()+12]},yy:function(){return String(u()).slice(2)},yyyy:function(){return $e(u(),4)},h:function(){return h()%12||12},hh:function(){return $e(h()%12||12)},H:function(){return h()},HH:function(){return $e(h())},M:function(){return p()},MM:function(){return $e(p())},s:function(){return d()},ss:function(){return $e(d())},l:function(){return $e(f(),3)},L:function(){return $e(Math.floor(f()/10))},t:function(){return h()<12?Ue.timeNames[0]:Ue.timeNames[1]},tt:function(){return h()<12?Ue.timeNames[2]:Ue.timeNames[3]},T:function(){return h()<12?Ue.timeNames[4]:Ue.timeNames[5]},TT:function(){return h()<12?Ue.timeNames[6]:Ue.timeNames[7]},Z:function(){return t?"GMT":e?"UTC":n0(r)},o:function(){return(m()>0?"-":"+")+$e(Math.floor(Math.abs(m())/60)*100+Math.abs(m())%60,4)},p:function(){return(m()>0?"-":"+")+$e(Math.floor(Math.abs(m())/60),2)+":"+$e(Math.floor(Math.abs(m())%60),2)},S:function(){return["th","st","nd","rd"][a()%10>3?0:(a()%100-a()%10!=10)*a()%10]},W:function(){return l()},WW:function(){return $e(l())},N:function(){return S()}};return n.replace(t0,function(x){return x in v?v[x]():x.slice(1,x.length-1)})}var Ua={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"},Ue={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"]},$e=function(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;return String(n).padStart(e,"0")},Ha=function(n){var e=n.y,t=n.m,i=n.d,s=n._,a=n.dayName,c=n.short,o=c===void 0?!1:c,u=new Date,h=new Date;h.setDate(h[s+"Date"]()-1);var p=new Date;p.setDate(p[s+"Date"]()+1);var d=function(){return u[s+"Date"]()},f=function(){return u[s+"Month"]()},m=function(){return u[s+"FullYear"]()},l=function(){return h[s+"Date"]()},S=function(){return h[s+"Month"]()},v=function(){return h[s+"FullYear"]()},x=function(){return p[s+"Date"]()},b=function(){return p[s+"Month"]()},E=function(){return p[s+"FullYear"]()};return m()===e&&f()===t&&d()===i?o?"Tdy":"Today":v()===e&&S()===t&&l()===i?o?"Ysd":"Yesterday":E()===e&&b()===t&&x()===i?o?"Tmw":"Tomorrow":a},s0=function(n){var e=new Date(n.getFullYear(),n.getMonth(),n.getDate());e.setDate(e.getDate()-(e.getDay()+6)%7+3);var t=new Date(e.getFullYear(),0,4);t.setDate(t.getDate()-(t.getDay()+6)%7+3);var i=e.getTimezoneOffset()-t.getTimezoneOffset();e.setHours(e.getHours()-i);var s=(e-t)/(864e5*7);return 1+Math.floor(s)},a0=function(n){var e=n.getDay();return e===0&&(e=7),e},n0=function(n){return(String(n).match(i0)||[""]).pop().replace(r0,"").replace(/GMT\+0000/g,"UTC")};const{BrowserUtil:o0}=G.AliRTS,Xt={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Gecko:"Gecko",WebKit:"WebKit"},Ci=(r,n)=>{const e=n.match(r);return e&&e.length>0&&e[1]||""},c0=[{test:[/\sedg\//i,[/edg([ea]|ios)/i]],describe(r){if(/\sedg\//i.test(r))return{name:Xt.Blink};const e=Ci(/edge\/(\d+(\.?_?\d+)+)/i,r);return{name:Xt.EdgeHTML,version:e}}},{test:[/trident/i],describe(r){const n={name:Xt.Trident},e=Ci(/trident\/(\d+(\.?_?\d+)+)/i,r);return e&&(n.version=e),n}},{test(r){const n=/gecko/i.test(r),e=/like gecko/i.test(r);return n&&!e},describe(r){const n={name:Xt.Gecko},e=Ci(/gecko\/(\d+(\.?_?\d+)+)/i,r);return e&&(n.version=e),n}},{test:[/(apple)?webkit\/537\.36/i],describe(){return{name:Xt.Blink}}},{test:[/(apple)?webkit/i],describe(r){const n={name:Xt.WebKit},e=Ci(/webkit\/(\d+(\.?_?\d+)+)/i,r);return e&&(n.version=e),n}}],zr=(r,n)=>r.find(e=>{if(typeof e.test=="function")return e.test(n);if(Array.isArray(e.test))return e.test.some(t=>typeof t=="string"?n.indexOf(t)>-1:t instanceof RegExp?t.test(n):!1)}),u0=()=>{try{const r=navigator.userAgent||"",n=zr(c0,r);if(n){const e=n.describe(r);return`${e.name}/${e.version||o0.browserVersion}`}}catch(r){}return navigator.userAgent},h0=[{test:["wow64","win64","x64"],describe(){return"amd64"}},{test:["i686","x86"],describe(){return"x86"}},{test:["aarch64","arm64"],describe(){return"arm64"}},{test:["arm"],describe(){return"arm"}}],ja=()=>{let r="unknown";try{const n=navigator.userAgent||"",e=zr(h0,n);if(!e)return r;r=e.describe(n)}catch(n){}return r},d0=[{test:[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],describe(){return"Samsung"}},{test:[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i,/\((ipad);[-\w\),; ]+apple/i,/(macintosh);/i],describe(){return"Apple"}},{test:[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],describe(){return"Huawei"}},{test:[/(?:honor)([-\w ]+)[;\)]/i],describe(){return"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(){return"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(){return"Oppo"}},{test:[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],describe(){return"Vivo"}},{test:[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],describe(){return"Realme"}},{test:[/(pixel c)\b/i,/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],describe(){return"Google"}},{test:[/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],describe(){return"ZTE"}},{test:[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],describe(){return"Meizu"}}],l0=()=>{let r="Unknown";try{const n=navigator.userAgent||"",e=zr(d0,n);if(!e)return r;r=e.describe(n)}catch(n){}return r},{BrowserUtil:za,SystenUtil:Wa}=G.AliRTS,f0=ja(),p0="woMMssV6jmyol9fr",g0=200,Ri=10*60*1e3,Ii={host:"cn-hangzhou.log.aliyuncs.com",project:"alivc-aio",logstore:"logger",time:10,count:10};function Wr(){return jr(new Date,"HH:MM:ss.l")}function $a(){return jr(new Date,"isoDate")}var $r=(r=>(r[r.DEBUG=0]="DEBUG",r[r.INFO=1]="INFO",r[r.API=2]="API",r[r.WARNING=3]="WARNING",r[r.ERROR=4]="ERROR",r[r.NONE=5]="NONE",r))($r||{});class m0{constructor(){g(this,"tracker");g(this,"slsPlugin");g(this,"stsData");g(this,"stsExpiration",Date.now());g(this,"clientId",it());g(this,"bSesid",it());g(this,"logLevel",3);g(this,"appId","");g(this,"sessionId","");g(this,"logCache",[]);g(this,"updateTaskTimer");g(this,"endReported",!0);g(this,"logSequence",0);g(this,"sendLogBeforeUnload",n=>w(this,null,function*(){if(!this.slsPlugin)return;this.logSequence+=1,n.unshift(this.getLogParams(710203,{log:`[${$a()} ${Wr()}] [INF] beforeunload`,stat_log_seq:this.logSequence}));const e=`https://${Ii.project}.${Ii.host}/logstores/${Ii.logstore}`,t={__logs__:n.map(a=>this.slsPlugin.transString(a))},{data:i,header:s}=yield this.slsPlugin.process(e,JSON.stringify(t));fetch(e,{keepalive:!0,method:"POST",headers:s,body:i})}));g(this,"logMethod",(n,e=console.log)=>(...t)=>{let i=Wr();this.logLevel<=n&&e(i,...t);let s=Oe.paramArrayToString(t);n>0&&this.addLog(s)});g(this,"d",this.logMethod(0,console.debug));g(this,"i",this.logMethod(1));g(this,"w",this.logMethod(3,console.warn));g(this,"e",this.logMethod(4,(...n)=>{const[e,...t]=n;console.error(e,"<error>",t)}));g(this,"ev",this.logMethod(2));g(this,"a",this.logMethod(2,(...n)=>{const[e,...t]=n;if(t.length>2){const i=`${t[1]}`;i.startsWith("__g__")&&console.group(`${i.substring(5)}_${t[2]}`)}console.log(e,...t)}));g(this,"ar",this.logMethod(2,(...n)=>{const[e,...t]=n;console.log(e,...t),t.length>2&&`${t[1]}`.startsWith("__g__")&&console.groupEnd()}));g(this,"ae",this.logMethod(2,(...n)=>{const[e,...t]=n;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=it(),this.endReported=!0,this.logSequence=0,this.appId="",this.sessionId=""}startSTSUpdateTask(){return w(this,null,function*(){this.updateTaskTimer&&clearTimeout(this.updateTaskTimer);try{const n=yield this.refreshSTSToken();this.createTracker(n)}catch(n){}this.updateTaskTimer=setTimeout(()=>{this.startSTSUpdateTask()},Ri)})}refreshSTSToken(){return w(this,null,function*(){if(!this.stsData||this.stsExpiration<=Date.now()-Ri){const n=yield this.requestSTSToken(),e=new Date(n==null?void 0:n.Expiration).getTime()||0,t=Date.now()+Ri;this.stsExpiration=Math.max(e,t),this.stsData=n}return this.stsData})}requestSTSToken(){const n=Date.now(),e=`${this.clientId}|${p0}|${n}`,i={Action:"AssumeSlsRoleV2",AuthInfo:si.MD5(e).toString(si.enc.Hex),ClientId:this.clientId,BusinessType:"logger",AppVersion:"1.0",Version:"2017-03-14",AuthTimestamp:`${n}`,TerminalType:"web",DeviceModel:"",Format:"JSON",SignatureMethod:"HMAC-SHA1",SignatureVersion:"1.0",Timestamp:jr(n,"isoUtcDateTime")},a=`https://slsrole.alicdn.com/?${new URLSearchParams(i).toString()}`;return fetch(a).then(c=>c.json()).then(c=>JSON.parse(window.atob(c.SlsAuthResult)))}createTracker(n){if(!this.tracker){const e={accessKeyId:n.AccessKeyId,accessKeySecret:n.AccessKeySecret,securityToken:n.SecurityToken,refreshSTSTokenInterval:Ri,stsTokenFreshTime:void 0,refreshSTSToken:()=>{this.refreshSTSToken().then(s=>{e.accessKeyId=s.AccessKeyId,e.accessKeySecret=s.AccessKeySecret,e.securityToken=s.SecurityToken}).catch(()=>{})}},t=new rr(Ii),i=Hr(e);t.useStsPlugin(i),this.slsPlugin=i,this.tracker=t,this.reportStartAndCache()}}changeConfig(n){n.logLevel!==void 0&&n.logLevel>=0&&n.logLevel<=5&&(this.logLevel=n.logLevel)}setSessionID(n,e){!n||!e||(this.appId=n,this.sessionId=e,this.reportStartAndCache())}reportStartAndCache(){if(!this.tracker||!this.sessionId)return;this.endReported=!1;const n={task_btm_sec:0,task_duration:0,task_etm_sec:0,task_type:"session"},e=[this.getLogParams(710201,n),this.getLogParams(710202,n)];this.tracker.sendBatchLogsImmediate(e),this.logCache.forEach(t=>{this.sendLog(t)})}reportEnd(n=!1){if(!this.tracker||!this.sessionId||this.endReported){this.reset();return}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)];n?this.sendLogBeforeUnload(t):(this.tracker.sendBatchLogsImmediate(t),this.endReported=!0),this.reset()}getLogParams(n,e){return X({appid:`${window.location.host}`,appid_list:this.appId,appver:"",b_sesid:this.bSesid,biz_type:"rtc",cpu_info:f0,db:za.browserName,dm:za.browserVersion,install_uuid:this.clientId,logger_v:"0.0.1",os:Wa.systemName,osv:Wa.systemVersion,p_sesid:this.bSesid,sdk_version:_i,sdkname:"AliRTCSdk",stm:Date.now(),tar_pf:"web",traceid:this.sessionId,event_id:n},e||{})}sendLog(n){if(!this.tracker||!this.sessionId)return;this.logSequence+=1;const e=this.getLogParams(710203,{log:n,stat_log_seq:this.logSequence});this.tracker.send(e)}addLog(n){const e=Wr(),i=`[${$a()} ${e}] ${n}`;!this.sessionId||!this.tracker?(this.logCache.push(i),this.logCache.length>=g0&&this.logCache.shift()):this.sendLog(i)}}class O{static getLogger(){return this.logger||(this.logger=new m0),this.logger}static init(){this.getLogger().init()}static destroy(){this.getLogger().destroy()}static setLogLevel(n){this.getLogger().changeConfig({logLevel:n})}static setSessionID(n,e){this.getLogger().setSessionID(n,e)}static reportEnd(){this.getLogger().reportEnd()}static interface(...n){this.getLogger().a("[API]",...n)}static interfaceResult(n,e,t,...i){t?this.getLogger().ar("[ARE]",n,e,...i):this.getLogger().ae("[ARE]",n,e,...i)}static event(...n){this.getLogger().ev("[EVT]",...n)}static debug(...n){this.getLogger().d("[DBG]",...n)}static info(...n){this.getLogger().i("[INF]",...n)}static warn(...n){this.getLogger().w("[WARN]",...n)}static error(...n){this.getLogger().e("[ERR]",...n)}}g(O,"logger");const S0=r=>w(this,null,function*(){const n=new G.AliRTS.SupportUtil;let e={support:!1,detail:{isWebRTCSupported:n.checkMediaDevices()&&n.checkWebRtcSupport(),isH264DecodeSupported:!1,isH264EncodeSupported:!1,isScreenShareSupported:!1,isSendMediaExtensionMsgSupported:!1,isBrowserSupported:n.checkBrowser({errorCode:0,message:""})}};if(e.support=e.detail.isWebRTCSupported&&e.detail.isBrowserSupported,n.checkWebRtcSupport()&&r!=="sendonly"){const t=yield n.checkH264Decode();e.detail.isH264DecodeSupported=t,e.support=e.support&&t}if(n.checkWebRtcSupport()&&r!=="recvonly"){const t=yield n.checkH264Encode();e.detail.isH264EncodeSupported=t,e.support=e.support&&t}return e.detail.isScreenShareSupported=n.checkWebRtcSupport()&&n.checkScreenCapture()&&!G.AliRTS.SystenUtil.isAndroid&&!G.AliRTS.SystenUtil.isIos,e.detail.isSendMediaExtensionMsgSupported=n.checkWebRtcSupport()&&n.checkEncodedTransformSupport(),e}),x0=()=>new G.AliRTS.SupportUtil().checkScreenCapture();var ve=(r=>(r[r.AliRtcSdkStreamTypeCapture=0]="AliRtcSdkStreamTypeCapture",r[r.AliRtcSdkStreamTypeScreen=1]="AliRtcSdkStreamTypeScreen",r))(ve||{}),Ka=(r=>(r[r.PRE_PROCESSOR=0]="PRE_PROCESSOR",r[r.POST_PROCESSOR=1]="POST_PROCESSOR",r))(Ka||{}),ai=(r=>(r[r.AUDIO=0]="AUDIO",r[r.VIDEO=1]="VIDEO",r[r.BOTH=2]="BOTH",r))(ai||{});class Bt extends re{constructor(e,t=ve.AliRtcSdkStreamTypeCapture,i=1){super();g(this,"name");g(this,"options");g(this,"type",0);g(this,"streamType");g(this,"trackType");g(this,"zIndex",1);g(this,"_isEnable",!0);g(this,"lastInputAudioTrack");g(this,"lastOutputAudioTrack");g(this,"lastInputVideoTrack");g(this,"lastOutputVideoTrack");g(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 ni=(r=>(r[r.LiveTranscodingSingle=0]="LiveTranscodingSingle",r[r.LiveTranscodingMix=1]="LiveTranscodingMix",r))(ni||{}),Kr=(r=>(r[r.LiveTranscodingOrigin=0]="LiveTranscodingOrigin",r[r.LiveTranscodingAudio=1]="LiveTranscodingAudio",r[r.LiveTranscodingVideo=2]="LiveTranscodingVideo",r))(Kr||{}),Yt=(r=>(r[r.LiveTranscodingCamera=0]="LiveTranscodingCamera",r[r.LiveTranscodingShareScreen=1]="LiveTranscodingShareScreen",r))(Yt||{});const oi={0:"camera",1:"shareScreen"};var qr=(r=>(r[r.LiveTranscoding_Profile_1IN_1080P=0]="LiveTranscoding_Profile_1IN_1080P",r[r.LiveTranscoding_Profile_1IN_720P=1]="LiveTranscoding_Profile_1IN_720P",r[r.LiveTranscoding_Profile_1IN_360P=2]="LiveTranscoding_Profile_1IN_360P",r[r.LiveTranscoding_Profile_2IN_1080P=3]="LiveTranscoding_Profile_2IN_1080P",r[r.LiveTranscoding_Profile_2IN_720P=4]="LiveTranscoding_Profile_2IN_720P",r[r.LiveTranscoding_Profile_2IN_360P=5]="LiveTranscoding_Profile_2IN_360P",r[r.LiveTranscoding_Profile_4IN_1080P=6]="LiveTranscoding_Profile_4IN_1080P",r[r.LiveTranscoding_Profile_4IN_720P=7]="LiveTranscoding_Profile_4IN_720P",r[r.LiveTranscoding_Profile_4IN_360P=8]="LiveTranscoding_Profile_4IN_360P",r[r.LiveTranscoding_Profile_9IN_1080P=9]="LiveTranscoding_Profile_9IN_1080P",r[r.LiveTranscoding_Profile_9IN_720P=10]="LiveTranscoding_Profile_9IN_720P",r[r.LiveTranscoding_Profile_9IN_360P=11]="LiveTranscoding_Profile_9IN_360P",r[r.LiveTranscoding_Profile_12IN_1080P=12]="LiveTranscoding_Profile_12IN_1080P",r[r.LiveTranscoding_Profile_12IN_720P=13]="LiveTranscoding_Profile_12IN_720P",r[r.LiveTranscoding_Profile_12IN_360P=14]="LiveTranscoding_Profile_12IN_360P",r[r.LiveTranscoding_Profile_16IN_1080P=15]="LiveTranscoding_Profile_16IN_1080P",r[r.LiveTranscoding_Profile_16IN_720P=16]="LiveTranscoding_Profile_16IN_720P",r[r.LiveTranscoding_Profile_16IN_360P=17]="LiveTranscoding_Profile_16IN_360P",r[r.LiveTranscoding_Profile_Mixed=9999]="LiveTranscoding_Profile_Mixed",r))(qr||{});const v0={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 wi=(r=>(r[r.LiveTranscoding_HZ_48000=48e3]="LiveTranscoding_HZ_48000",r[r.LiveTranscoding_HZ_44100=44100]="LiveTranscoding_HZ_44100",r[r.LiveTranscoding_HZ_32000=32e3]="LiveTranscoding_HZ_32000",r[r.LiveTranscoding_HZ_16000=16e3]="LiveTranscoding_HZ_16000",r[r.LiveTranscoding_HZ_8000=8e3]="LiveTranscoding_HZ_8000",r))(wi||{}),ci=(r=>(r[r.LiveTranscodingNoBody=0]="LiveTranscodingNoBody",r[r.LiveTranscodingBody=1]="LiveTranscodingBody",r))(ci||{}),ui=(r=>(r[r.NOTO_SERIF_CJKSC_REGULAR=0]="NOTO_SERIF_CJKSC_REGULAR",r[r.ALIBABA_PUHUITI_REGULAR=1]="ALIBABA_PUHUITI_REGULAR",r[r.ALIBABA_PUHUITI_BOLD=2]="ALIBABA_PUHUITI_BOLD",r[r.ALIBABA_PUHUITI_Heavy=3]="ALIBABA_PUHUITI_Heavy",r[r.ALIBABA_PUHUITI_LIGHT=4]="ALIBABA_PUHUITI_LIGHT",r[r.ALIBABA_PUHUITI_MEDIUM=5]="ALIBABA_PUHUITI_MEDIUM",r))(ui||{}),Jr=(r=>(r[r.LiveTranscodingOrigin=0]="LiveTranscodingOrigin",r[r.LiveTranscodingCrop=1]="LiveTranscodingCrop",r[r.LiveTranscodingFill=2]="LiveTranscodingFill",r))(Jr||{}),Ti=(r=>(r[r.LiveTranscodingNormal=0]="LiveTranscodingNormal",r[r.LiveTranscodingVirtualBackground=1]="LiveTranscodingVirtualBackground",r))(Ti||{}),Gr=(r=>(r[r.LiveTranscodingState_IDLE=0]="LiveTranscodingState_IDLE",r[r.LiveTranscodingState_CONNNECT=1]="LiveTranscodingState_CONNNECT",r[r.LiveTranscodingState_RUNNING=2]="LiveTranscodingState_RUNNING",r[r.LiveTranscodingState_RECOVERING=3]="LiveTranscodingState_RECOVERING",r[r.LiveTranscodingState_FAILURE=4]="LiveTranscodingState_FAILURE",r[r.LiveTranscodingState_END=5]="LiveTranscodingState_END",r))(Gr||{}),ut=(r=>(r[r.LiveTranscodingErrorPublishOk=0]="LiveTranscodingErrorPublishOk",r[r.LiveTranscodingErrorStreamNotFound=17825793]="LiveTranscodingErrorStreamNotFound",r[r.LiveTranscodingErrorStreamAlreadyExist=17825794]="LiveTranscodingErrorStreamAlreadyExist",r[r.LiveTranscodingErrorInvalidParam=17825795]="LiveTranscodingErrorInvalidParam",r[r.LiveTranscodingErrorInternalError=17825796]="LiveTranscodingErrorInternalError",r[r.LiveTranscodingErrorRtmpServerError=17825797]="LiveTranscodingErrorRtmpServerError",r[r.LiveTranscodingErrorRtmpStreamUrlError=17825798]="LiveTranscodingErrorRtmpStreamUrlError",r[r.LiveTranscodingErrorPublishTimeout=17825799]="LiveTranscodingErrorPublishTimeout",r[r.LiveTranscodingErrorNotAuthorized=17825800]="LiveTranscodingErrorNotAuthorized",r))(ut||{}),Xr=(r=>(r[r.TrascodingPublishTaskStatusStart=0]="TrascodingPublishTaskStatusStart",r[r.TrascodingPublishTaskStatusUpdate=1]="TrascodingPublishTaskStatusUpdate",r[r.TrascodingPublishTaskStatusStop=2]="TrascodingPublishTaskStatusStop",r))(Xr||{}),He=(r=>(r[r.MPU_TASK_TRANSACTION_START=0]="MPU_TASK_TRANSACTION_START",r[r.MPU_TASK_TRANSACTION_UPDATE=1]="MPU_TASK_TRANSACTION_UPDATE",r[r.MPU_TASK_TRANSACTION_STOP=2]="MPU_TASK_TRANSACTION_STOP",r[r.MPU_TASK_TRANSACTION_LIST=3]="MPU_TASK_TRANSACTION_LIST",r[r.MPU_TASK_TRANSACTION_POLLING=4]="MPU_TASK_TRANSACTION_POLLING",r[r.MPU_TASK_TRANSACTION_ACKNOWLEDGE=5]="MPU_TASK_TRANSACTION_ACKNOWLEDGE",r[r.MPU_TASK_TRANSACTION_END=6]="MPU_TASK_TRANSACTION_END",r))(He||{});const b0={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 Yr{constructor(n,e,t,i,s,a,c,o){g(this,"videoWidth");g(this,"videoHeight");g(this,"videoFramerate",20);g(this,"videoBitrate",2e3);g(this,"videoGop",30);g(this,"audioSamplerate",wi.LiveTranscoding_HZ_44100);g(this,"audioBitrate",500);g(this,"audioChannels",1);this.videoWidth=n,this.videoHeight=e,t&&(this.videoFramerate=t),i&&(this.videoBitrate=i),s&&(this.videoGop=s),a&&(this.audioSamplerate=a),c&&(this.audioBitrate=c),o&&(this.audioChannels=o)}}const Zr=r=>((r&16711680)>>16)+(r&65280)+((r&255)<<16),Ye=(r=0,n)=>{if(n==0)return 0;let e=r/n;return e<0&&(e=0),e>1&&(e=1),e};class Di{constructor(n,e,t){g(this,"mixMode",ni.LiveTranscodingSingle);g(this,"singleParam");g(this,"mixParam");n&&(this.mixMode=n),e&&(this.singleParam=e),t&&(this.mixParam=t)}toJson(n,e,t,i,s){const a={appid:e.appId,channelid:e.channelId};if(n===He.MPU_TASK_TRANSACTION_POLLING||n===He.MPU_TASK_TRANSACTION_LIST||n===He.MPU_TASK_TRANSACTION_ACKNOWLEDGE)return n===He.MPU_TASK_TRANSACTION_ACKNOWLEDGE&&(a.messageid=s),a;if(a.taskid=t,n!==He.MPU_TASK_TRANSACTION_STOP){if(a.mixmode=this.mixMode,i&&(a.streamurl=i),this.mixMode===ni.LiveTranscodingSingle){const c=this.singleParam;if(c){a.streamtype=c.streamType,c.sourceType===Yt.LiveTranscodingShareScreen?a.sourcetype=oi[c.sourceType]:a.sourcetype=oi[Yt.LiveTranscodingCamera];const o=[];c.userId&&o.push(c.userId),a.subspecusers=o}}else if(n===He.MPU_TASK_TRANSACTION_START||n===He.MPU_TASK_TRANSACTION_UPDATE){const c=this.mixParam;if(c){c.taskProfile&&(a.taskprofile=v0[c.taskProfile]);const o=c.encodeParam||new Yr(1280,720);let u=o.videoWidth,h=o.videoHeight;const p={};Object.keys(o).forEach(f=>{const m=o[f];m>0&&(p[f.toLowerCase()]=m)}),p.lowbitratehighquality=0,a.encodeparam=p,a.backgrounds=c.backgrounds.map(f=>f.toJson(u,h)),a.watermarks=c.watermarks.map(f=>f.toJson(u,h)),a.clockwidgets=c.clockWidgets.map(f=>f.toJson(u,h));const d=c.users.map(f=>f.userId);a.subspecusers=[...new Set(d)],a.layouts=[{audiomixcount:c.users.length,panes:c.users.map((f,m)=>f.toJson(m,u,h,c.mediaProcessMode))}],a.layoutids=["0"],a.cropmode=c.cropMode,a.backgroundcolor=Zr(c.backgroundColor),a.taskmode=c.mediaProcessMode}}}return a}}var pt=(r=>(r.pre="pre",r.prod="prod",r))(pt||{}),gt=(r=>(r.AliRtcSdkCommunication="communication",r.AliRtcSdkInteractiveLive="interactive_live",r.AliRtcSdkInteractiveWithLowLatencyLive="cdn_live",r))(gt||{}),At=(r=>(r.AliRtcSdkInteractive="interactive",r.AliRtcSdkLive="live",r))(At||{}),ht=(r=>(r[r.AliEngineLocalDeviceTypeUnknown=0]="AliEngineLocalDeviceTypeUnknown",r[r.AliEngineLocalDeviceTypeMic=1]="AliEngineLocalDeviceTypeMic",r[r.AliEngineLocalDeviceTypeSpeaker=2]="AliEngineLocalDeviceTypeSpeaker",r[r.AliEngineLocalDeviceTypeAudioDevice=3]="AliEngineLocalDeviceTypeAudioDevice",r[r.AliEngineLocalDeviceTypeCamera=4]="AliEngineLocalDeviceTypeCamera",r[r.AliEngineLocalDeviceTypeDisplay=5]="AliEngineLocalDeviceTypeDisplay",r[r.AliEngineLocalDeviceTypeVideoDevice=6]="AliEngineLocalDeviceTypeVideoDevice",r))(ht||{}),Ee=(r=>(r[r.AliEngineLocalDeviceExceptionTypeUnknown=0]="AliEngineLocalDeviceExceptionTypeUnknown",r[r.AliEngineLocalDeviceExceptionTypeMicOpenFail=1]="AliEngineLocalDeviceExceptionTypeMicOpenFail",r[r.AliEngineLocalDeviceExceptionTypeMicInterrupt=2]="AliEngineLocalDeviceExceptionTypeMicInterrupt",r[r.AliEngineLocalDeviceExceptionTypeMicAuthFail=3]="AliEngineLocalDeviceExceptionTypeMicAuthFail",r[r.AliEngineLocalDeviceExceptionTypeMicNotAvailable=4]="AliEngineLocalDeviceExceptionTypeMicNotAvailable",r[r.AliEngineLocalDeviceExceptionTypeSpeakerOpenFail=5]="AliEngineLocalDeviceExceptionTypeSpeakerOpenFail",r[r.AliEngineLocalDeviceExceptionTypeSpeakerInterrupt=6]="AliEngineLocalDeviceExceptionTypeSpeakerInterrupt",r[r.AliEngineLocalDeviceExceptionTypeSpeakerNotAvailable=7]="AliEngineLocalDeviceExceptionTypeSpeakerNotAvailable",r[r.AliEngineLocalDeviceExceptionTypeAudioDeviceException=8]="AliEngineLocalDeviceExceptionTypeAudioDeviceException",r[r.AliEngineLocalDeviceExceptionTypeCameraOpenFail=9]="AliEngineLocalDeviceExceptionTypeCameraOpenFail",r[r.AliEngineLocalDeviceExceptionTypeCameraInterrupt=10]="AliEngineLocalDeviceExceptionTypeCameraInterrupt",r[r.AliEngineLocalDeviceExceptionTypeCameraAuthFail=11]="AliEngineLocalDeviceExceptionTypeCameraAuthFail",r[r.AliEngineLocalDeviceExceptionTypeDisplayException=12]="AliEngineLocalDeviceExceptionTypeDisplayException",r[r.AliEngineLocalDeviceExceptionTypeVideoDeviceException=13]="AliEngineLocalDeviceExceptionTypeVideoDeviceException",r))(Ee||{}),de=(r=>(r[r.AliRtcConnectionStatusInit=0]="AliRtcConnectionStatusInit",r[r.AliRtcConnectionStatusDisconnected=1]="AliRtcConnectionStatusDisconnected",r[r.AliRtcConnectionStatusConnecting=2]="AliRtcConnectionStatusConnecting",r[r.AliRtcConnectionStatusConnected=3]="AliRtcConnectionStatusConnected",r[r.AliRtcConnectionStatusReconnecting=4]="AliRtcConnectionStatusReconnecting",r[r.AliRtcConnectionStatusFailed=5]="AliRtcConnectionStatusFailed",r))(de||{}),Nt=(r=>(r[r.AliRtcConnectionChangedDummyReason=0]="AliRtcConnectionChangedDummyReason",r[r.AliRtcConnectionMediaPathChanged=1]="AliRtcConnectionMediaPathChanged",r[r.AliRtcConnectionSignalingHeartbeatTimeout=2]="AliRtcConnectionSignalingHeartbeatTimeout",r[r.AliRtcConnectionSignalingHeartbeatAlive=3]="AliRtcConnectionSignalingHeartbeatAlive",r[r.AliRtcConnectionSignalingHttpDnsResolved=4]="AliRtcConnectionSignalingHttpDnsResolved",r[r.AliRtcConnectionSignalingHttpDnsFailure=5]="AliRtcConnectionSignalingHttpDnsFailure",r[r.AliRtcConnectionSignalingGslbFailure=6]="AliRtcConnectionSignalingGslbFailure",r[r.AliRtcConnectionSignalingGslbSuccess=7]="AliRtcConnectionSignalingGslbSuccess",r[r.AliRtcConnectionSignalingJoinRoomFailure=8]="AliRtcConnectionSignalingJoinRoomFailure",r[r.AliRtcConnectionSignalingJoinRoomSuccess=9]="AliRtcConnectionSignalingJoinRoomSuccess",r[r.AliRtcConnectionSignalingLeaveRoom=10]="AliRtcConnectionSignalingLeaveRoom",r[r.AliRtcConnectionSignalingConnecting=11]="AliRtcConnectionSignalingConnecting",r[r.AliRtcConnectionChangedNetworkInterrupted=12]="AliRtcConnectionChangedNetworkInterrupted",r))(Nt||{}),Qr=(r=>(r[r.AliRtcUserOfflineQuit=0]="AliRtcUserOfflineQuit",r[r.AliRtcUserOfflineDropped=1]="AliRtcUserOfflineDropped",r[r.AliRtcUserOfflineBecomeAudience=2]="AliRtcUserOfflineBecomeAudience",r))(Qr||{}),Zt=(r=>(r[r.AliRtcAudioTrackNo=0]="AliRtcAudioTrackNo",r[r.AliRtcAudioTrackMic=1]="AliRtcAudioTrackMic",r[r.AliRtcAudioTrackDual=2]="AliRtcAudioTrackDual",r))(Zt||{}),ne=(r=>(r[r.AliRtcVideoTrackNo=0]="AliRtcVideoTrackNo",r[r.AliRtcVideoTrackCamera=1]="AliRtcVideoTrackCamera",r[r.AliRtcVideoTrackScreen=2]="AliRtcVideoTrackScreen",r[r.AliRtcVideoTrackBoth=3]="AliRtcVideoTrackBoth",r))(ne||{}),Z=(r=>(r[r.AliRtcStatePublishIdle=0]="AliRtcStatePublishIdle",r[r.AliRtcStateNoPublish=1]="AliRtcStateNoPublish",r[r.AliRtcStatePublishing=2]="AliRtcStatePublishing",r[r.AliRtcStatePublished=3]="AliRtcStatePublished",r))(Z||{}),le=(r=>(r[r.AliRtcStateSubscribeIdle=0]="AliRtcStateSubscribeIdle",r[r.AliRtcStateNoSubscribe=1]="AliRtcStateNoSubscribe",r[r.AliRtcStateSubscribing=2]="AliRtcStateSubscribing",r[r.AliRtcStateSubscribed=3]="AliRtcStateSubscribed",r))(le||{}),Ie=(r=>(r[r.AliRtcVideoStreamTypeNone=0]="AliRtcVideoStreamTypeNone",r[r.AliRtcVideoStreamTypeHigh=1]="AliRtcVideoStreamTypeHigh",r[r.AliRtcVideoStreamTypeLow=2]="AliRtcVideoStreamTypeLow",r))(Ie||{}),hi=(r=>(r[r.CAMERA_INVALID=-1]="CAMERA_INVALID",r[r.CAMERA_REAR=0]="CAMERA_REAR",r[r.CAMERA_FRONT=1]="CAMERA_FRONT",r))(hi||{});const qa=12,Ja=5e3,ti=class ti extends re{constructor(e){super();g(this,"ws");g(this,"socketStatus",0);g(this,"wsUrl","");g(this,"lastConnectStartTime",0);g(this,"maxConnectRetryCount",qa);g(this,"connectRetryCount",0);g(this,"gotErr",!1);g(this,"closedByInvoke",!0);g(this,"isReconnecting",!1);g(this,"networkAvailableChecked",!0);g(this,"reconnectTimeoutId",0);this.maxConnectRetryCount=e!=null?e:qa,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):!1}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){O.info(`[${ti.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&&Oe.isNetworkAvailable().then(t=>{t&&console.error(ti.logName,"onError, Network is available, token may be invalid")})}onClose(e){return w(this,null,function*(){if(this.closedByInvoke){this.socketStatus=0;return}if(O.info(`[${ti.logName}]`,`onClose, code: ${e.code}, reason: ${e.reason}, status: ${status}, retryCount: ${this.connectRetryCount}`),(yield Oe.isNetworkAvailable())&&!this.networkAvailableChecked){this.reconnect(),this.networkAvailableChecked=!0;return}else this.connectRetryCount||this.emit("onNetworkError"),this.reconnectTimeoutId||(this.connectRetryCount+=1,this.connectRetryCount>this.maxConnectRetryCount?this.emit("onConnectFail"):Date.now()-this.lastConnectStartTime>=Ja?this.reconnect():this.reconnectTimeoutId=window.setTimeout(()=>{this.reconnect()},Ja));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)}};g(ti,"logName","Socket");let es=ti;var Ae=(r=>(r.KEEPALIVE="keepalive",r.JOINCHANNEL="joinchannel",r.NOTIFYJOIN="notifyjoin",r.NOTIFYSTATUS="notifystatus",r.STATUSREPORT="statusreport",r.LEAVECHANNEL="leavechannel",r.NOTIFYLEAVE="notifyleave",r.NOTIFYPUBLISH="notifypublish",r.BYE="bye",r.RECONNECT="reconnect",r.PUBLISH="publish",r.REFRESHURL="refreshurl",r.UNSUBSCRIBE="unsubscribe",r.ROLEUPDATE="roleupdate",r))(Ae||{});class E0{constructor(n,e){g(this,"authInfo");g(this,"userName");g(this,"seqIndex",0);this.authInfo=n,this.userName=e}get roleAuth(){if(this.authInfo.role){const{timestamp:n,nonce:e,token:t,role:i}=this.authInfo;return{timestamp:n,nonce:e,token:t,tokenrole:i}}}refreshAuthInfo(n){this.authInfo=n}getSeqIndex(){return this.seqIndex}createKeepAlivePackage(){return this.createBaseSendPackage("keepalive")}createJoinPackage(){let n=this.createBaseSendPackage("joinchannel");return n.header.displayName=this.userName,n.header.clientversion=Oe.getVersionNumber().toString(),n.header.platform=Zs,this.roleAuth&&(n.data.auth=this.roleAuth),n}crateLeavePackage(){return this.createBaseSendPackage("leavechannel")}createStatusPackage(n){let e=this.createBaseSendPackage("statusreport");return e.header.displayName=this.userName,e.data.status=n,e}createPublishPackage(){let n=this.createBaseSendPackage("publish");return n.data.users=[{}],this.roleAuth&&(n.data.auth=this.roleAuth),n}createRoleUpdatePackage(){let n=this.createBaseSendPackage("roleupdate");return n.header.displayName=this.userName,n}createReconnectPackage(n){let e=this.createBaseSendPackage("reconnect");return e.header.displayName=this.userName,e.header.clientversion=Oe.getVersionNumber().toString(),e.header.platform=Zs,e.data=X(X({},e.data),n!=null?n:{}),this.roleAuth&&(e.data.auth=this.roleAuth),e}createRefreshUrlPackage(){let n=this.createBaseSendPackage("refreshurl");return n.header.displayName=this.userName,n}createResponsePackage(n,e){return{version:1,code:200,tid:n,msgtype:e}}createBaseSendPackage(n){var t;return++this.seqIndex,{version:1,msgtype:n,tid:it(),header:{appid:this.authInfo.appId,channelid:this.authInfo.channelId,sessionid:(t=this.authInfo.sessionId)!=null?t:"",userid:this.authInfo.userId},data:{seq:this.seqIndex}}}}var U=(r=>(r[r.ERR_JOIN_ALREADY_JOINED=16843521]="ERR_JOIN_ALREADY_JOINED",r[r.ERR_JOIN_BAD_APPID=33620481]="ERR_JOIN_BAD_APPID",r[r.ERR_JOIN_INVALID_APPID=33620482]="ERR_JOIN_INVALID_APPID",r[r.ERR_JOIN_BAD_CHANNEL=33620484]="ERR_JOIN_BAD_CHANNEL",r[r.ERR_JOIN_INVALID_CHANNEL=33620483]="ERR_JOIN_INVALID_CHANNEL",r[r.ERR_JOIN_BAD_TOKEN=33620485]="ERR_JOIN_BAD_TOKEN",r[r.ERR_JOIN_TIMEOUT=16908804]="ERR_JOIN_TIMEOUT",r[r.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD=16974081]="ERR_JOIN_ERR_JOIN_BAD_PARAMBAD",r[r.ERR_JOIN_CHANNEL_FAILED=16974338]="ERR_JOIN_CHANNEL_FAILED",r[r.ERR_LOG_ALREADY_INIT=16974085]="ERR_LOG_ALREADY_INIT",r[r.ERR_LOG_ROOT_PATH_ERROR=16974086]="ERR_LOG_ROOT_PATH_ERROR",r[r.ERR_MIC_OPEN_FAIL=17040388]="ERR_MIC_OPEN_FAIL",r[r.ERR_SPEAKER_OPEN_FAIL=17040389]="ERR_SPEAKER_OPEN_FAIL",r[r.ERR_MIC_INTERRUPT=17040390]="ERR_MIC_INTERRUPT",r[r.ERR_SPEAKER_INTERRUPT=17040391]="ERR_SPEAKER_INTERRUPT",r[r.ERR_MIC_AUTH_FAIL=17040392]="ERR_MIC_AUTH_FAIL",r[r.ERR_MIC_NOT_AVAILABLE=17040393]="ERR_MIC_NOT_AVAILABLE",r[r.ERR_SPEAKER_NOT_AVAILABLE=17040400]="ERR_SPEAKER_NOT_AVAILABLE",r[r.ERR_CAMERA_OPEN_FAIL=17039620]="ERR_CAMERA_OPEN_FAIL",r[r.ERR_CAMERA_AUTH_FAIL=17039621]="ERR_CAMERA_AUTH_FAIL",r[r.ERR_CAMERA_INTERRUPT=17039622]="ERR_CAMERA_INTERRUPT",r[r.ERR_CAMERA_NOT_AVAILABLE=17039623]="ERR_CAMERA_NOT_AVAILABLE",r[r.ERR_VIDEO_DISPLAY_OPEN_FAIL=17039873]="ERR_VIDEO_DISPLAY_OPEN_FAIL",r[r.ERR_VIDEO_DISPLAY_INTERRUPT=1064992]="ERR_VIDEO_DISPLAY_INTERRUPT",r[r.ERR_ICE_CONNECTION_CONNECT_FAIL=17105409]="ERR_ICE_CONNECTION_CONNECT_FAIL",r[r.ERR_ICE_CONNECTION_RECONNECT_FAI=17105410]="ERR_ICE_CONNECTION_RECONNECT_FAI",r[r.ERR_ICE_CONNECTION_MOBILITY_FAIL=17105411]="ERR_ICE_CONNECTION_MOBILITY_FAIL",r[r.ERR_ICE_CONNECTION_HEARTBEAT_TIMEOUT=16908812]="ERR_ICE_CONNECTION_HEARTBEAT_TIMEOUT",r[r.ERR_LATENCY_LIVE_COMMUNICATION_FAILED=17235971]="ERR_LATENCY_LIVE_COMMUNICATION_FAILED",r[r.ERR_LATENCY_LIVE_MEIDASETTING_FAILED=17235972]="ERR_LATENCY_LIVE_MEIDASETTING_FAILED",r[r.ERR_LATENCY_LIVE_NONE_BROADCASTER=17235973]="ERR_LATENCY_LIVE_NONE_BROADCASTER",r[r.ERR_LATENCY_LIVE_NEED_RESTART=17235974]="ERR_LATENCY_LIVE_NEED_RESTART",r[r.ERR_LATENCY_LIVE_NEED_RESTART_AGAIN_LATER=17235975]="ERR_LATENCY_LIVE_NEED_RESTART_AGAIN_LATER",r[r.ERR_LATENCY_LIVE_SERVICE_UNAVAILABLE=17235976]="ERR_LATENCY_LIVE_SERVICE_UNAVAILABLE",r[r.ERR_LATENCY_LIVE_MEDIACONNECTION_INTERRUPTION=17235977]="ERR_LATENCY_LIVE_MEDIACONNECTION_INTERRUPTION",r[r.ERR_SDK_PUBLISH_INVAILD=16974597]="ERR_SDK_PUBLISH_INVAILD",r[r.ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL=16843782]="ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL",r[r.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED=16843856]="ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED",r[r.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED=16843857]="ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED",r[r.ERR_SDK_PUBLISH_DUAL_STREAM_FAILED=16843858]="ERR_SDK_PUBLISH_DUAL_STREAM_FAILED",r[r.ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED=16843859]="ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED",r[r.ERR_SDK_PUBLISH_SCREEN_SHARE_CONFIG_ERROR=16843860]="ERR_SDK_PUBLISH_SCREEN_SHARE_CONFIG_ERROR",r[r.ERR_SDK_SUBSCRIBE_INVAILD=16974852]="ERR_SDK_SUBSCRIBE_INVAILD",r[r.ERR_SDK_SUBSCRIBE_NOT_JOIN_CHANNEL=16844112]="ERR_SDK_SUBSCRIBE_NOT_JOIN_CHANNEL",r[r.ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED=16844113]="ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED",r[r.ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED=16844114]="ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED",r[r.ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED=16844115]="ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED",r[r.ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED=16844116]="ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED",r[r.ERR_SDK_SUBSCRIBE_DATA_FAILED=16844117]="ERR_SDK_SUBSCRIBE_DATA_FAILED",r[r.ERR_SDK_SUBSCRIBE_DATA_ERROR=16844118]="ERR_SDK_SUBSCRIBE_DATA_ERROR",r[r.ERR_SDK_INVALID_STATE=16974340]="ERR_SDK_INVALID_STATE",r[r.ERR_INVALID_ARGUMENTS=16974083]="ERR_INVALID_ARGUMENTS",r[r.ERR_SESSION_REMOVED=33620229]="ERR_SESSION_REMOVED",r[r.ERR_SDK_UPDATE_ROLE_CHANNEL=16908801]="ERR_SDK_UPDATE_ROLE_CHANNEL",r[r.ERR_INNER=-1]="ERR_INNER",r[r.ERR_SDK_MPU_TASK_PUBLISH_OK=0]="ERR_SDK_MPU_TASK_PUBLISH_OK",r[r.ERR_SDK_MPU_TASK_STREAM_NOT_FOUND=17825793]="ERR_SDK_MPU_TASK_STREAM_NOT_FOUND",r[r.ERR_SDK_MPU_TASK_STREAM_ALREADY_EXIST=17825794]="ERR_SDK_MPU_TASK_STREAM_ALREADY_EXIST",r[r.ERR_SDK_MPU_TASK_INVALID_PARAM=17825795]="ERR_SDK_MPU_TASK_INVALID_PARAM",r[r.ERR_SDK_MPU_TASK_INTERNAL_ERROR=17825796]="ERR_SDK_MPU_TASK_INTERNAL_ERROR",r[r.ERR_SDK_MPU_TASK_RTMP_SERVER_ERROR=17825797]="ERR_SDK_MPU_TASK_RTMP_SERVER_ERROR",r[r.ERR_SDK_MPU_TASK_RTMP_STREAM_URL_ERROR=17825798]="ERR_SDK_MPU_TASK_RTMP_STREAM_URL_ERROR",r[r.ERR_SDK_MPU_TASK_PUBLISH_TIMEOUT=17825799]="ERR_SDK_MPU_TASK_PUBLISH_TIMEOUT",r[r.ERR_SDK_MPU_TASK_NOT_AUTHORIZED=17825800]="ERR_SDK_MPU_TASK_NOT_AUTHORIZED",r[r.ERR_SDK_CHANNEL_RELAY_STATE_ERROR=18874369]="ERR_SDK_CHANNEL_RELAY_STATE_ERROR",r[r.ERR_SDK_CHANNEL_RELAY_SRC_NOT_ALLOW=18874370]="ERR_SDK_CHANNEL_RELAY_SRC_NOT_ALLOW",r[r.ERR_SDK_CHANNEL_RELAY_JOIN_DEST_FAILED=18874371]="ERR_SDK_CHANNEL_RELAY_JOIN_DEST_FAILED",r[r.ERR_SDK_CHANNEL_RELAY_TOKEN_INVALID=18874372]="ERR_SDK_CHANNEL_RELAY_TOKEN_INVALID",r[r.ERR_SDK_CHANNEL_RELAY_ROLE_ERROR=18874373]="ERR_SDK_CHANNEL_RELAY_ROLE_ERROR",r[r.ERR_SDK_CHANNEL_RELAY_INVALID_PARAM=18874374]="ERR_SDK_CHANNEL_RELAY_INVALID_PARAM",r[r.ERR_SDK_CHANNEL_RELAY_TO_SELF_ERROR=18874375]="ERR_SDK_CHANNEL_RELAY_TO_SELF_ERROR",r))(U||{});class V extends Error{constructor(e,t,i){super(t);g(this,"_code");g(this,"_extra");this._code=e,this._extra=i}static fromRtsError(e){return e instanceof V?e:new V((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 V(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 A0=3e4,qe=class qe extends re{constructor(e,t,i,s,a,c){super();g(this,"authInfo");g(this,"userName");g(this,"channelProfile");g(this,"clientRole");g(this,"slsReporter");g(this,"wsClient");g(this,"packageCreater");g(this,"keepAliveTimer",0);g(this,"packageCache",new Map);g(this,"isFirstConnect",!0);g(this,"aliveChecker",0);g(this,"reconnectData");this.authInfo=e,this.userName=t,this.packageCreater=new E0(e,t),this.channelProfile=i,this.clientRole=s,this.slsReporter=a,this.wsClient=new es(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){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 o=e,{l1ip:t}=o,i=qt(o,["l1ip"]);let s=this.packageCreater.createPublishPackage();s.data.users=[],s.data.l1ip=t,i.subscribe.signal=this.wsClient.connectUrl;const{tracks:a,resume:c}=i;a.forEach(u=>{const{codec:h,ssrc:p}=u;u.userdata=JSON.stringify({codec:h}),u.ssrc=`${p}`,c&&(u.attr={reason:"reconnect"})}),s.data.users.push(i),this.sendPackage(s)}roleUpdate(e){let t=this.packageCreater.createRoleUpdatePackage();t.data.clientrole=e,this.sendPackage(t)}refreshUrl(e){const t=this.packageCreater.createRefreshUrlPackage();t.data=X(vt(X({},t.data),{sessionid:t.header.sessionid}),e),this.sendPackage(t)}refreshAuthInfo(e){this.authInfo=e,this.packageCreater.refreshAuthInfo(e)}close(){O.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){[Ae.KEEPALIVE,Ae.RECONNECT,Ae.JOINCHANNEL].includes(e.msgtype)||this.packageCache.set(e.tid,e),this.wsClient.send(e),e.msgtype!==Ae.KEEPALIVE&&this.slsReporter.reportRoomServerEvent(!0,e.msgtype,e.tid,e)}updateReconnectData(e){this.reconnectData=e}onOpen(){if(O.info(`[${qe.logName}] onOpen`),this.isFirstConnect){let e=this.packageCreater.createJoinPackage();e.data.configure={channelprofile:this.channelProfile},(this.channelProfile===gt.AliRtcSdkInteractiveLive||this.channelProfile===gt.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)!==Ae.KEEPALIVE&&this.slsReporter.reportRoomServerEvent(!1,t.msgtype,t.tid,t)}catch(t){O.warn(`[${qe.logName}] onMessage err`,t,e)}}onError(e){O.warn(`[${qe.logName}] onError`,e),this.isFirstConnect&&this.onConnectFail()}onConnectFail(){O.warn(`[${qe.logName}] onConnectFail`);const e=new V(U.ERR_INNER,"Signaling connect failed.");this.isFirstConnect?this.emit("onJoinChannelResult",e):this.emit("onConnectFail",e)}onAuthInvalid(){O.warn(`[${qe.logName}] onAuthInvalid`),this.isFirstConnect&&this.emit("onAuthInvalid")}onNetworkError(){O.warn(`[${qe.logName}] onNetworkError`);const e=new V(U.ERR_INNER,"Network error, signaling connect failed.");this.emit("onNetworkError",e)}onClose(e){O.info(`[${qe.logName}] onClose`,e),this.stopKeepAlive()}onKeepAliveRsp(){this.emit("onKeepAliveRsp"),this.checkAlive()}onReconnectStart(){this.emit("onReconnectStart")}onReconnectFail(){this.emit("onReconnectFail",new V(U.ERR_INNER,"signaling reconnect failed."))}checkAlive(){window.clearTimeout(this.aliveChecker),this.aliveChecker=window.setTimeout(()=>{O.info(`[${qe.logName}] not alive, reconnect`),this.stopKeepAlive(),this.emit("onReconnectStart"),this.wsClient.reconnect()},A0)}onRecvMessage(e){switch(e.msgtype!==Ae.KEEPALIVE&&O.info(`[${qe.logName}] recv msg: ${e.msgtype}`),e.msgtype){case Ae.JOINCHANNEL:this.onJoinResult(e);break;case Ae.KEEPALIVE:this.onKeepAliveRsp();break;case Ae.PUBLISH:this.onPublishResult(e);break;case Ae.NOTIFYJOIN:this.onNotifyJoin(e);break;case Ae.NOTIFYSTATUS:this.onNotifyStatus(e);break;case Ae.LEAVECHANNEL:this.onLeaveResult(e);break;case Ae.NOTIFYLEAVE:this.onNotifyLeave(e);break;case Ae.NOTIFYPUBLISH:this.onNotifyPublish(e);break;case Ae.STATUSREPORT:this.onStatusReport(e);break;case Ae.BYE:this.onBye(e);break;case Ae.ROLEUPDATE:this.onRoleUpdateResult(e);break;case Ae.REFRESHURL:this.onRefreshUrlResult(e);break;case Ae.RECONNECT:this.onReconnectResult(e);break}}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 V(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)}};g(qe,"logName","RSMessageCenter");let ts=qe;const T=(r,n)=>(e,t,i)=>{const s=i.value;return i.value=function(...a){var p;const c=`[${((p=e.constructor)==null?void 0:p.logName)||""}]`,o=Date.now();let u=[];if(r)try{u=r(a)}catch(d){}O.interface(c,t,...u);const h=s.apply(this,a);return Promise.resolve(h).then(d=>d).catch(d=>d).then(d=>{var S;let f="";const m=d instanceof Error,l=m&&((S=e.constructor)==null?void 0:S.logError);if(!(!n&&!m)){if(l)f=d;else if(m)f=d.message||"";else if(n)if(d===void 0)f="";else try{f=n(d)}catch(v){}else return;O.interfaceResult(c,t,!(m&&l),`${Date.now()-o}ms`,f)}}),h},i},H=r=>r;var _0=Object.defineProperty,y0=Object.getOwnPropertyDescriptor,is=(r,n,e,t)=>{for(var i=t>1?void 0:t?y0(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&_0(n,e,i),i};const Pi=(Le=class extends re{constructor(e,t,i,s=pt.prod){super();g(this,"messageCenter");g(this,"authInfo");g(this,"userName");g(this,"channelProfile");g(this,"clientRole");g(this,"slsReporter");g(this,"reconnectData");g(this,"roomServerUri","");this.channelProfile=e,this.clientRole=t,this.slsReporter=i,this.reconnectData={role:{channelprofile:e,clientrole:t}};const a=s===pt.pre?Ai.pre:Ai.prod;this.roomServerUri=`wss://${a}/roomserver/v1/ws`}updateReconnectData(e){var t;this.reconnectData=e,(t=this.messageCenter)==null||t.updateReconnectData(this.reconnectData)}reset(){O.info("[roomsig] reset"),this.messageCenter&&(this.messageCenter.close(),this.messageCenter=void 0),this.authInfo=void 0}join(e,t,i){return w(this,null,function*(){return new Promise((s,a)=>{const c={};this.authInfo=e,this.userName=t,this.messageCenter=new ts(e,t,this.channelProfile,this.clientRole,this.slsReporter,i),this.initMessageCenter(),this.messageCenter.once("onJoinChannelResult",u=>{var h,p,d;if(O.info(`[${Le.logName}]`,"join result: ",u),c.taskretrynum=((h=this.messageCenter)==null?void 0:h.retryCount)||0,u.code==200){(p=this.messageCenter)==null||p.sendPkgCache(),(d=this.messageCenter)==null||d.startKeepAlive();let f=u.data;f.tid=u.tid,f.users=u.data.users,f.timestamp=u.timestamp,c.est&&(c.joinconnecttc=Date.now()-c.est),this.slsReporter.reportJoinConnection(c),s(f)}else this.reset(),a(this.handleSignalError(u.code,u.reason,U.ERR_JOIN_CHANNEL_FAILED))}),this.messageCenter.once("onAuthInvalid",()=>{this.reset(),a(new V(U.ERR_JOIN_BAD_TOKEN,"join failed because authentication failed"))}),O.info(`[${Le.logName}]`,"start ws connecting roomserver and auto join when connected");const o={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:it()};e.role&&(o.tokenrole=e.role),c.est=Date.now(),this.messageCenter.start(this.roomServerUri+"?"+Oe.queryingParam(o))})})}leave(){return O.info("[roomsig] leave .."),new Promise((e,t)=>{this.messageCenter?(this.messageCenter.on("onLeaveResult",(i,s)=>{O.info(`[${Le.logName}]`,"recv leave response "+i),i===200?(this.updateReconnectData(),this.reset(),e({tid:s})):t(this.handleSignalError(i,"leave error"))}),O.info(`[${Le.logName}]`,"send leave request"),this.messageCenter.leave()):(O.info(`[${Le.logName}]`,"no message center, ok to leave"),e({tid:""}))})}publish(e){return new Promise((t,i)=>{var s;this.messageCenter?(this.messageCenter.once("onPublishResult",(a,c,o)=>{O.info(`[${Le.logName}]`,"recv pubish response "+a),a===200?(this.updateReconnectData(vt(X({},this.reconnectData),{publish:{users:[e]}})),t({tid:c})):i(this.handleSignalError(a,`publish error, ${o}`))}),this.authInfo&&(e.sessionid=(s=this.authInfo.sessionId)!=null?s:""),e.callid||(e.callid=it()),O.info(`[${Le.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)=>{if(!this.messageCenter){i(this.handleSignalError(-1,"role update error, no message center"));return}this.messageCenter.on("onRoleUpdateResult",(s,a,c)=>{var o,u;O.info(`[${Le.logName}]`,"recv role update response "+s),s===200?((u=(o=this.reconnectData)==null?void 0:o.role)!=null&&u.clientrole&&(this.reconnectData.role.clientrole=e,this.updateReconnectData(this.reconnectData)),t({tid:a})):i(this.handleSignalError(s,`role update error, ${c}`))}),this.messageCenter.roleUpdate(e)})}setChannelProfile(e){this.channelProfile=e}refreshUrl(e){return O.info(`[${Le.logName}]`,"refreshUrl .."),new Promise((t,i)=>{if(!this.messageCenter){i(this.handleSignalError(-1,"refresh url error, no message center"));return}this.messageCenter.on("onRefreshUrlResult",s=>{const{code:a,description:c,data:o={}}=s||{};O.info("recv refresh url response "+a),a===200?t(o):i(this.handleSignalError(a,`refresh url error, ${c}`))}),O.info("send refresh url request"),this.messageCenter.refreshUrl(e)})}reportStatus(e){return O.info(`[${Le.logName}]`,"reportStatus "+e),new Promise((t,i)=>{this.messageCenter?(this.messageCenter.once("onStatusReport",(s,a)=>{s===200?t():i(new V(s,a))}),this.messageCenter.reportStatus(e)):i(new V(-1,"No messageCenter"))})}handleSignalError(e,t,i=U.ERR_INNER){const s=`signal error: code - ${e}; description - ${t}`;return new V(i,s)}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,s,a,c,o,u,h,p,d,f;(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)}),(s=this.messageCenter)==null||s.on("onNotifyLeave",m=>{this.emit("onNotifyLeave",m)}),(a=this.messageCenter)==null||a.on("onNotifyPublish",m=>{this.emit("onNotifyPublish",m)}),(c=this.messageCenter)==null||c.on("onBye",(m,l)=>{this.emit("onBye",m,l)}),(o=this.messageCenter)==null||o.on("onReconnectStart",()=>{this.emit("onReconnectStart")}),(u=this.messageCenter)==null||u.on("onReconnectSuccess",m=>{this.emit("onReconnectSuccess",m)}),(h=this.messageCenter)==null||h.on("onReconnectFail",m=>{this.emit("onReconnectFail",m)}),(p=this.messageCenter)==null||p.on("onConnectFail",m=>{this.emit("onConnectFail",m),this.reset()}),(d=this.messageCenter)==null||d.on("onNetworkError",m=>{this.emit("onNetworkError",m)}),(f=this.messageCenter)==null||f.on("onAuthInvalid",()=>{this.emit("onAuthInvalid")})}},g(Le,"logName","RoomServerSignaling"),Le);is([T()],Pi.prototype,"join",1),is([T()],Pi.prototype,"publish",1),is([T()],Pi.prototype,"roleUpdate",1);let C0=Pi;const R0="https://pgw.rtn.aliyuncs.com",I0="https://gw.rtn.aliyuncs.com",Ga=10*60*1e3,w0=12,gi=class gi extends re{constructor(e,t){super();g(this,"env");g(this,"authInfo");g(this,"timer");g(this,"slsReporter");g(this,"expiration",0);g(this,"skipTime",0);g(this,"requestToken",()=>w(this,null,function*(){if(this.skipTime=0,!this.authInfo)return;const{appId:e,channelId:t,userId:i,nonce:s="",token:a,timestamp:c,sessionId:o,role:u}=this.authInfo;let h=I0;this.env===pt.pre&&(h=R0);const p=`${h}/gslb/v1/stsupdate?appid=${e}&channelid=${t}&userid=${i}&nonce=${s}&token=${a}×tamp=${c}&session=${o}${u?`&tokenrole=${u}`:""}&slstoken=true&osstoken=true&tokensid=false`,d=Date.now();fetch(p).then(f=>f.json()).then(f=>{var m,l;if(f.code===0){const S=(m=f.data)==null?void 0:m.oss,v=(l=f.data)==null?void 0:l.sls;this.expiration=S.expiration||v.expiration,this.emit("onTokenUpdate",S,v),O.event(`[${gi.logName}]`,"getToken",S,v)}else throw new Error;this.slsReporter.reportSTSResult(200,d)}).catch(f=>{this.slsReporter.reportSTSResult(-1,d),O.error(`[${gi.logName}]`,"getToken",f.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(()=>{if(this.expiration&&Math.floor((Date.now()+Ga*1.5)/1e3)<this.expiration&&this.skipTime<w0){this.skipTime+=1;return}this.requestToken()},Ga)}clear(){this.timer&&clearInterval(this.timer)}};g(gi,"logName","StsManager");let rs=gi;var T0=Object.defineProperty,D0=Object.getOwnPropertyDescriptor,P0=(r,n,e,t)=>{for(var i=t>1?void 0:t?D0(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&T0(n,e,i),i};class ss extends re{constructor(e,t,i,s=pt.prod){super();g(this,"signaling");g(this,"authInfo");g(this,"userName");g(this,"channelProfile");g(this,"clientRole");g(this,"env",pt.prod);g(this,"maxConnectRetryCount");g(this,"stsManager");g(this,"slsReporter");this.channelProfile=e,this.clientRole=t,this.env=s,this.slsReporter=i,this.stsManager=new rs(i,s)}reset(){var e;O.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,s){return this.maxConnectRetryCount=i,this.userName=t,new Promise((a,c)=>{this.signaling?c(new V(U.ERR_JOIN_ALREADY_JOINED,"already joined")):(O.info("[signalingmanager] create signaling"),this.signaling=new C0(this.channelProfile,this.clientRole,this.slsReporter,this.env),this.initSignaling(),s&&(s.rs=Date.now()),this.signaling.join(e,t,i).then(o=>{this.authInfo=e,s&&(s.re=Date.now()),a(o)}).catch(o=>{this.reset(),c(o)}),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 s;this.signaling&&this.authInfo?(e.userid=this.authInfo.userId,e.displayname=(s=this.userName)!=null?s:this.authInfo.userId,this.signaling.publish(e).then(a=>{t(a)}).catch(a=>{i(a)})):i(new V(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(s=>{i(s)}):i(new V(-1,"no signaling"))})}setClientRole(e){return w(this,null,function*(){const t=this.clientRole;if(!this.signaling){this.clientRole=e;return}const i=Date.now();try{const s=yield this.signaling.roleUpdate(e);return this.slsReporter.reportRoleUpdateResult(t,e,Date.now()-i,0),s}catch(s){this.slsReporter.reportRoleUpdateResult(t,e,Date.now()-i,s.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 V(U.ERR_SDK_INVALID_STATE,"should join first"))}refreshAuthInfo(e){return w(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,s,a,c,o,u,h,p,d,f,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)),(s=this.signaling)==null||s.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)),(o=this.signaling)==null||o.on("onReconnectStart",this.onReconnectStart.bind(this)),(u=this.signaling)==null||u.on("onReconnectSuccess",this.onReconnectSuccess.bind(this)),(h=this.signaling)==null||h.on("onReconnectFail",this.onReconnectFail.bind(this)),(p=this.signaling)==null||p.on("onConnectFail",this.onConnectFail.bind(this)),(d=this.signaling)==null||d.on("onNetworkError",this.onNetworkError.bind(this)),(f=this.signaling)==null||f.on("onAuthInvalid",this.onAuthInvalid.bind(this)),(m=this.signaling)==null||m.on("onError",this.onError.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)}}g(ss,"logName","SignalingManager"),P0([T(H)],ss.prototype,"publish",1);function Qt(){}const Ht=class Ht{static getInstance(){var n;return Ht.instance||(Ht.instance=new AudioContext),(n=Ht.instance.resume())==null||n.then(Qt,Qt).catch(Qt),Ht.instance}};g(Ht,"instance");let Lt=Ht;const ki=()=>{var n;const r=Lt.getInstance();r.state!=="running"&&r.state!=="closed"&&((n=r.resume())==null||n.then(Qt,Qt).catch(Qt)),window.removeEventListener("mousedown",ki),window.removeEventListener("touchstart",ki)};window.addEventListener("mousedown",ki),window.addEventListener("touchend",ki);function k0(r,n,e,t,i){let s=t,a=0,c;const o=r.createAnalyser();o.fftSize=256;const u=new Uint8Array(o.frequencyBinCount);n.connect(o),o.connect(e);const h=()=>{c&&window.clearInterval(c)},p=()=>{r.state==="suspended"&&r.resume(),c=window.setInterval(()=>{o.getByteFrequencyData(u);let d=Math.round(u.reduce((f,m)=>f+m)/u.length);d=Math.min(100,d),a=d,i&&i(d)},s)};return p(),{updateInterval:d=>{h(),s=d,p()},getLevel:()=>a,dispose:()=>{h(),n.disconnect(),o.disconnect()}}}class B0 extends re{constructor(){super();g(this,"audioContext");g(this,"stream");g(this,"sourceNode");g(this,"analyser");this.audioContext=Lt.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=k0(this.audioContext,this.sourceNode,i,t,s=>{this.emit("audioLevel",s)})}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 Xa extends re{constructor(e,t,i,s){super();g(this,"uid");g(this,"name");g(this,"rtsManager");g(this,"callId","");g(this,"audioLevelMonitor");g(this,"audioVolumeIndicationInterval",0);this.uid=e,this.name=t,this.rtsManager=i,this.audioVolumeIndicationInterval=s,this.audioLevelMonitor=new B0}get userId(){return this.uid}get displayname(){return this.name}createCallId(){this.callId||(this.callId=Oe.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 Ya{static getCurrentStatus(n){let e=0;n.micOpen&&(e+=1),n.micInterrupted&&(e+=2),n.cameraOpen&&(e+=4),n.screenShare&&(e+=128),n.audioDisable&&(e+=8),n.videoDisable&&(e+=16),n.screenDisable&&(e+=256);let t=e.toString(16);for(;t.length<16;)t="0"+t;return t}static parseStatus(n){let e=parseInt(n,16);return{micOpen:!!(e&1),micInterrupted:!!(e&2),cameraOpen:!!(e&4),screenShare:!!(e&128),audioDisable:!!(e&8),videoDisable:!!(e&16),screenDisable:!!(e&256),backgroundMode:!!(e&32),accompanyPlaying:!!(e&64)}}}const N0="customVideoProfile",L0="customScreenProfile",as={width:1280,height:720,frameRate:30,maxBitrate:2e3},Za={width:1920,height:1080,frameRate:30,maxBitrate:2600};var di=(r=>(r[r.ERROR_DEVICE_UNKNOWNERROR=1e4]="ERROR_DEVICE_UNKNOWNERROR",r[r.ERROR_DEVICE_AUDIODEVICE_NOTFOUND=10001]="ERROR_DEVICE_AUDIODEVICE_NOTFOUND",r[r.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED=10002]="ERROR_DEVICE_AUDIODEVICE_NOTALLOWED",r[r.ERROR_DEVICE_AUDIODEVICE_NOTREADABLE=10003]="ERROR_DEVICE_AUDIODEVICE_NOTREADABLE",r[r.ERROR_DEVICE_VIDEODEVICE_NOTFOUND=10004]="ERROR_DEVICE_VIDEODEVICE_NOTFOUND",r[r.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED=10005]="ERROR_DEVICE_VIDEODEVICE_NOTALLOWED",r[r.ERROR_DEVICE_VIDEODEVICE_NOTREADABLE=10006]="ERROR_DEVICE_VIDEODEVICE_NOTREADABLE",r[r.ERROR_SCREENSHARE_NOTSUPPORT=10010]="ERROR_SCREENSHARE_NOTSUPPORT",r[r.ERROR_SCREENSHARE_NOTALLOWED=10011]="ERROR_SCREENSHARE_NOTALLOWED",r[r.ERROR_SCREENSHARE_ENDED=10012]="ERROR_SCREENSHARE_ENDED",r[r.ERROR_SCREENSHARE_NOPERMISSION=10013]="ERROR_SCREENSHARE_NOPERMISSION",r[r.ERROR_SCREENSHARE_SAFARI_INVALIDACCESS=10014]="ERROR_SCREENSHARE_SAFARI_INVALIDACCESS",r[r.ERROR_SCREENSHARE_UNKNOWNERRO=10019]="ERROR_SCREENSHARE_UNKNOWNERRO",r[r.ERROR_DEVICE_NOTSUPPORT=2e4]="ERROR_DEVICE_NOTSUPPORT",r))(di||{});const M0={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 Ke=(r=>(r.CREATE_ENGINE="create_engine",r.JOIN="join",r.WANT_INSERT_PUB_TASK="wantInsertPubTask",r.INSERT_PUB_TASK="InsertPubTask",r.HANDLE_PUB_TASK="HandlePubTask",r.RECV_NOTIFY_PUBLISH="RecvNotifyPublish",r.INSERT_SUB_TASK="InsertSubTask",r.HANDLE_SUB_TASK="HandleSubTask",r.FIRST_REMOTE="first_remote",r))(Ke||{}),Ze=(r=>(r.START="start",r.SEND_SIG="send_sig",r.RECV_RST="recv_rst",r.END="end",r.RECEIVED="received",r.DECODED="decoded",r.PLAYED="played",r))(Ze||{});const F0=r=>r.getAudioTracks()[0];function Qa(r){var n;if(((n=r==null?void 0:r.nodeName)==null?void 0:n.toLowerCase())==="video")return r.setAttribute("playsinline",""),r;if(typeof r=="string"){let e=document.getElementById(r);if(e){if(e.nodeName.toLocaleLowerCase()==="video")return e.setAttribute("playsinline",""),e;throw new V(U.ERR_INVALID_ARGUMENTS,"element should be HtmlVideoElement")}else throw new V(U.ERR_INVALID_ARGUMENTS,"element not founded")}else throw new V(U.ERR_INVALID_ARGUMENTS,"element id should be string")}function ns(r){var e;const n=[];if(Array.isArray(r))r.forEach(t=>{try{n.push(Qa(t))}catch(i){}});else if(typeof r=="string"||((e=r==null?void 0:r.nodeName)==null?void 0:e.toLowerCase())==="video")try{n.push(Qa(r))}catch(t){}return n}function _t(r){return new Promise(n=>setTimeout(n,r))}function en(r,n,e=1e3,t=i=>!0){return w(this,null,function*(){let i=0,s;for(;i<n;)try{return yield r(i)}catch(a){if(i++,i>=n||!t(a))throw a||s;yield new Promise(c=>setTimeout(c,e))}})}function V0(r,n){let e=0;const t=[];for(;e<r.byteLength;){const i=Math.min(n,r.byteLength-e),s=r.slice(e,e+i);t.push(s),e+=i}return t}function O0(r){var n,e;try{const t=new URL(r),[i,s]=t.pathname.slice(1).split("/"),a=/(\w+)(web\w{5}-\w{4}-\w{4}-\w{4}-\w{12})/.exec(s),c=a==null?void 0:a[1],o=a==null?void 0:a[2],u=new URLSearchParams(t.search),h=parseInt((e=(n=u.get("auth_key"))==null?void 0:n.split("-")[0])!=null?e:"0")*1e3;return{appId:i,channelId:c,sessionId:o,timeoutTs:h}}catch(t){return null}}function tn(r,n){let e=n;return typeof window.__ali_prefer_media_server=="string"&&window.__ali_prefer_media_server!==""&&(e=window.__ali_prefer_media_server),e?`${r}&ali_prefer_media_server=${e}`:r}const rn=(r,n,e=!1)=>{const t=()=>(r.muted=!0,Promise.race([_t(500),r._playPromise||Promise.resolve()]).catch(()=>{}).then(()=>{let i;return e&&r.srcObject===n?i=Promise.resolve():(r.load(),r.srcObject=n,i=r.play(),r._playPromise=i),i}));return new Promise(i=>{if(G.AliRTS.BrowserUtil.isMicroMessenger){const s=window.top!==window.self,a=window.WeixinJSBridge||window.top.WeixinJSBridge;a?a.invoke("getNetworkType",{},()=>{i(t())}):(s?window.top.document:document).addEventListener("WeixinJSBridgeReady",()=>{a.invoke("getNetworkType",{},()=>{i(t())})}),setTimeout(()=>{i(t())},1e3)}else setTimeout(()=>{i(t())},0)})},dt=r=>{Promise.race([_t(100),r._playPromise||Promise.resolve()]).catch(()=>{}).then(()=>{r.srcObject=null,r._playPromise=void 0})};var os=(r=>(r[r.AliEngineDataMsgNone=0]="AliEngineDataMsgNone",r[r.AliEngineDataMsgMusicProgress=1]="AliEngineDataMsgMusicProgress",r[r.AliEngineDataMsgCustom=2]="AliEngineDataMsgCustom",r))(os||{});class Bi{constructor(n,e,t,i=0){g(this,"msgType");g(this,"msgId");g(this,"protocolVersion");g(this,"tlvVersion");this.msgType=n,this.msgId=e,this.protocolVersion=t,this.tlvVersion=i}build(){const n=new Uint8Array(4);return n.set(Uint8Array.from([this.protocolVersion,this.tlvVersion<<4|this.msgType&15]),0),n.set(Uint16Array.from([this.msgId]),2),n}static parse(n){const e=new DataView(n),t=e.getUint8(0),i=e.getUint8(1)>>4,s=e.getUint8(1)&15,a=e.getUint16(2);return new Bi(s,a,t,i)}}const Mt=5;class Ni{constructor(n,e,t){g(this,"_byteArray");if(this._byteArray=new Uint8Array(0),n!==void 0&&e!==void 0&&t!==void 0){const s=new Bi(n,e,t).build();this._byteArray=new Uint8Array(s.byteLength+this._byteArray.byteLength),this._byteArray.set(s,0)}}write(n,e){const t=this._byteArray,i=new ArrayBuffer(Mt),s=new DataView(i);s.setUint8(0,n),s.setUint32(1,e.byteLength);const a=new Uint8Array(t.byteLength+Mt+e.byteLength);a.set(t,0),a.set(new Uint8Array(i),t.byteLength),a.set(new Uint8Array(e),t.byteLength+Mt),this._byteArray=a}static parse(n){const e={},t=new DataView(n);let i=0;for(;i<n.byteLength;){const s=t.getUint8(i),a=t.getUint32(i+1);if(i+Mt+a<=n.byteLength){const c=n.slice(i+Mt,i+Mt+a);e[s]=c,i+=Mt+a}else break}return e}get buffer(){return this._byteArray.buffer}}class li{constructor(n=0,e=!0,t=1,i=!1,s=0,a=!1,c=!1,o=3){g(this,"_fin",!0);g(this,"_hasExtension",!1);g(this,"_version",0);g(this,"_frameType",1);g(this,"_isEncrypted",!1);g(this,"_isCompressed",!1);g(this,"_signalType",3);g(this,"_payloadLength",0);this._fin=e,this._hasExtension=i,this._version=s,this._frameType=t,this._isEncrypted=a,this._isCompressed=c,this._signalType=o,this._payloadLength=n}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 n=new ArrayBuffer(4),e=new DataView(n);return e.setUint8(0,(this._fin?1:0)<<7|(this._hasExtension?1:0)<<6|this._version<<4|this._frameType&15),e.setUint8(1,(this._isEncrypted?1:0)<<7|(this._isCompressed?1:0)<<6|this._signalType&15),e.setUint16(2,this._payloadLength),n}static parse(n){const e=new DataView(n),t=e.getUint8(0)>>7===1,i=(e.getUint8(0)&64)>>6===1,s=(e.getUint8(0)&48)>>4,a=e.getUint8(0)&15,c=e.getUint8(1)>>7===1,o=(e.getUint8(1)&64)>>6===1,u=e.getUint8(1)&15,h=e.getUint16(2);return new li(h,t,a,i,s,c,o,u)}}class Li{constructor(n,e){g(this,"_body");g(this,"_header",new li);this._header=n,this._body=e}get header(){return this._header}get isFin(){return this._header.fin}get body(){return this._body}toGRTNBuffer(){const n=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+n.byteLength+e.byteLength);return i.set(new Uint8Array(t),0),i.set(new Uint8Array(n),t.byteLength),i.set(new Uint8Array(e),t.byteLength+n.byteLength),i.buffer}static parse(n){const e=n.slice(0,4),t=li.parse(e);let i=new ArrayBuffer(0);return n.byteLength-4>=t.payloadLength&&(i=n.slice(4,4+t.payloadLength)),new Li(t,i)}}const cs=r=>{const n=r.byteLength,e=new DataView(r);let t=0;for(let i=0;i<n;i++)t=t*256+e.getUint8(i);return t};let sn=0;class Ft{constructor(n,e=0,t=0,i=0){g(this,"data");g(this,"networkTime");g(this,"futureOrProgress");g(this,"type");this.data=n,this.type=e,this.networkTime=t,this.futureOrProgress=i}toBuffer(){const n=new Ni(0,0,0);n.write(1,Uint8Array.from([0]).buffer),n.write(2,Uint16Array.from([0]).buffer),sn++,n.write(3,Uint32Array.from([sn]).buffer);const e=new Ni;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(this.networkTime&4294967295)]).buffer),e.write(5,this.data),n.write(30,e.buffer),n.buffer}static parse(n){if(!n||n.byteLength<4)return;Bi.parse(n.slice(0,4));const t=Ni.parse(n.slice(4))[30];if(!t)return;const i=Ni.parse(t),s=i[2],a=i[3],c=i[4],o=i[5];if(o.byteLength!==0)return new Ft(o,cs(s),cs(c),cs(a))}}var U0=Object.defineProperty,H0=Object.getOwnPropertyDescriptor,xe=(r,n,e,t)=>{for(var i=t>1?void 0:t?H0(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&U0(n,e,i),i};const an=30;class fi extends re{constructor(){super();g(this,"_state");g(this,"time");this._state=Z.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 Se=(mt=class extends Xa{constructor(e){const{rtsManager:t,localStreamManager:i,slsReporter:s,signalingManager:a,audioVolumeIndicationInterval:c,parameter:o}=e;super("","",t,c);g(this,"_url","");g(this,"joinTime",0);g(this,"_isPublishing",!1);g(this,"publishPromise",Promise.resolve({traceId:"",l1ip:void 0}));g(this,"previewElements",[]);g(this,"screenPreviewElements",[]);g(this,"streamManager");g(this,"dc");g(this,"streamTracks");g(this,"publishId",it());g(this,"signalingManager");g(this,"traceId","");g(this,"monitorTimerId");g(this,"monitorDataCache",{});g(this,"trackTraceIdMap",{});g(this,"candidateDataCache",[]);g(this,"pcMediaStatsMap",{});g(this,"slsReporter");g(this,"audioPubState");g(this,"videoPubState");g(this,"videoSmallPubState");g(this,"screenPubState");g(this,"dataPubState");g(this,"parameter",{});g(this,"onTrackEnd",e=>{this.emit(e)});this.streamManager=i,this.signalingManager=a,this.slsReporter=s,this.parameter=o,this.streamManager.on("trackended",u=>{this.onTrackEnd(u)}),this.streamManager.on("publishupdate",()=>{this.publishUpdate()}),this.audioPubState=new fi,this.audioPubState.on("change",(u,h,p)=>{this.emit("audioPublishStateChanged",u,h,p)}),this.videoPubState=new fi,this.videoPubState.on("change",(u,h,p)=>{this.emit("videoPublishStateChanged",u,h,p)}),this.videoSmallPubState=new fi,this.videoSmallPubState.on("change",(u,h,p)=>{this.emit("dualStreamPublishStateChanged",u,h,p)}),this.screenPubState=new fi,this.screenPubState.on("change",(u,h,p)=>{this.emit("screenPublishStateChanged",u,h,p)}),this.dataPubState=new fi,this.dataPubState.on("change",(u,h,p)=>{this.emit("dataPublishStateChanged",u,h,p)}),this.startStreamMonitor()}get url(){return this._url}set url(e){this._url=e,this.rtsManager.updateAuth(e)}get joined(){return!!this.uid}get isPublishing(){return this._isPublishing}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:s})=>i==="video"&&t&&s===D.VideoLarge))}get hasCameraDualTrackInMS(){var e;return!!((e=this.streamTracks)!=null&&e.find(({ssrc:t,type:i,msid:s})=>i==="video"&&t&&s===D.VideoSmall))}get hasScreenTrackInMS(){var e;return!!((e=this.streamTracks)!=null&&e.find(({ssrc:t,type:i,msid:s})=>i==="video"&&t&&s===D.Screen))}get hasAudioTrackInMS(){var e;return!!((e=this.streamTracks)!=null&&e.find(({ssrc:t,type:i,msid:s})=>i==="audio"&&t&&s===D.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||Oe.createCallid(),this.updatePubId()}setVideoProfile(e){return w(this,null,function*(){yield this.streamManager.setVideoProfile(N0,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(L0,e)})}setCameraDirection(e){if(e===hi.CAMERA_FRONT)this.streamManager.setCameraVideoConstraints({facingMode:"user"});else if(e===hi.CAMERA_REAR)this.streamManager.setCameraVideoConstraints({facingMode:"environment"});else throw new V(U.ERR_CAMERA_OPEN_FAIL,`camera direction set to ${e} failed`)}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=it()}clearPublishState(){this.streamTracks=void 0}leave(){return w(this,null,function*(){this._isPublishing&&(this._isPublishing=!1,yield this.unPublish()),this.joinTime=0,this.dc=void 0})}clear(){return w(this,null,function*(){Es(mt.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)&&(dt(e),this.previewElements.splice(this.previewElements.indexOf(e),1)),this.screenPreviewElements.includes(e)&&(dt(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.previewElements.includes(t)||this.previewElements.push(t)}startDefaultCamera(e){return w(this,null,function*(){const{hasCamera:t,cameraCaptureDisabled:i,publishLocalVideoStreamEnabled:s}=this;if(!t&&!e&&!i&&s)try{yield this.startCameraCapture()}catch(a){const c=a.errorCode;let o=U.ERR_CAMERA_OPEN_FAIL;throw c===di.ERROR_DEVICE_AUDIODEVICE_NOTFOUND?o=U.ERR_CAMERA_NOT_AVAILABLE:c===di.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED&&(o=U.ERR_CAMERA_AUTH_FAIL),new V(o,`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(s){const a=s.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_VIDEODEVICE_NOTALLOWED&&(c=U.ERR_MIC_AUTH_FAIL),new V(c,`mic open fail: ${s.message}`)}})}setViewConfig(e,t){if(!e){t===ne.AliRtcVideoTrackCamera?this.stopPreview({primary:!0,screen:!1}):this.stopPreview({primary:!1,screen:!0});return}if(![ne.AliRtcVideoTrackCamera,ne.AliRtcVideoTrackScreen].includes(t))throw new V(U.ERR_INVALID_ARGUMENTS,"set view config invalid track",{track:t});e.forEach(i=>{this.setPreviewElement({videoElement:i,screen:t===ne.AliRtcVideoTrackScreen})})}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 s=i?this.streamManager.screenStreamInfo.previewStream:this.streamManager.cameraStreamInfo.previewStream;if(!t)throw new V(U.ERR_INVALID_ARGUMENTS,"no video element found",{videoElement:t});if(!s){O.info(`[${mt.logName}]`,"preview no stream founded");return}return rn(t,s.mediaStream),this.setPreviewElement(e),s.mediaStream}catch(s){const a=U.ERR_INNER;throw V.fromError(s,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 s=0;s<this.previewElements.length;s++){const a=this.previewElements[s];yield this.preview({videoElement:a})}if(i&&this.screenPreviewElements.length)for(let s=0;s<this.screenPreviewElements.length;s++){const a=this.screenPreviewElements[s];yield this.preview({videoElement:a,screen:!0})}})}stopPreview(e){const{videoElement:t,primary:i=!0,screen:s=!0}=e||{};if(!t)i&&(this.previewElements.forEach(a=>{dt(a)}),this.previewElements=[]),s&&(this.screenPreviewElements.forEach(a=>{dt(a)}),this.screenPreviewElements=[]);else{const a=this.previewElements.findIndex(c=>c===t);if(a>=0)this.previewElements.splice(a,1),dt(t);else{const c=this.screenPreviewElements.findIndex(o=>o===t);c>=0&&(this.screenPreviewElements.splice(c,1),dt(t))}}}resumePublish(){return w(this,null,function*(){this._isPublishing=!1,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 s=this.previewElements[i];dt(s)}else if(e.screen)for(let i=0;i<this.screenPreviewElements.length;i++){const s=this.screenPreviewElements[i];dt(s)}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=M0[t.errorCode];throw i&&(e.audio?this.emit("localDeviceException",ht.AliEngineLocalDeviceTypeMic,i,""):e.video?this.emit("localDeviceException",ht.AliEngineLocalDeviceTypeCamera,i,""):e.screen?this.emit("localDeviceException",ht.AliEngineLocalDeviceTypeDisplay,i,""):this.emit("localDeviceException",ht.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 o={};return i===D.Audio?o.audio=!0:i===D.VideoLarge||i===D.VideoSmall?(o.video=!0,o.vMsid=i):i===D.Screen&&(o.screen=!0),yield this.publishDeleteTracks(o)}const s={};if(t!=null&&t.hasVideo&&(s.isScreen=i===D.Screen,s.vMsid=i),t!=null&&t.hasAudio&&(s.aMsid=i),!e&&t)return yield this.publishAdd(t,s,!1);if(e&&t){const o=e.trackId,u=((a=t.videoTrack)==null?void 0:a.id)||((c=t.audioTrack)==null?void 0:c.id);if(o!==u)return yield this.publishReplace(t,s)}})}reportAudioProfile(){const e=this.streamManager.cameraStreamInfo.audioProfile||"standard",t=G.AliRTS.AudioProfileMap.get(e);this.slsReporter.reportPublishProfile(D.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(D.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(D.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!==Z.AliRtcStatePublishing){this.dataPubState.setState(Z.AliRtcStatePublishing);try{const e=yield this.rtsManager.publishAddDataChannel(this.url);e?(this.updateDataChannel(e),this.dataPubState.setState(Z.AliRtcStatePublished)):(this.dataPubState.setState(Z.AliRtcStateNoPublish),this.emit("publishDataError",new V(U.ERR_INNER,"publishDataError")))}catch(e){this.dataPubState.setState(Z.AliRtcStateNoPublish)}}})}startPublish(){return w(this,arguments,function*(e=!1,t=ct.MANUAL){var u;if(!this.joined)return;const i=this.streamManager.publishStreams,{audio:s,video:a,videoSmall:c,screen:o}=i;if(!s&&!a&&!c&&!o){O.event(`[${mt.logName}]`,"startPublish no stream founded");return}this.createCallId();try{const h=new Date().getTime();s&&this.audioPubState.setState(Z.AliRtcStatePublishing),a&&this.videoPubState.setState(Z.AliRtcStatePublishing),c&&this.videoSmallPubState.setState(Z.AliRtcStatePublishing),o&&this.screenPubState.setState(Z.AliRtcStatePublishing),this.publishPromise=this.rtsManager.publish(this.url,this.callId,e,t);const{traceId:p,l1ip:d}=yield this.publishPromise;this._isPublishing=!0,this.streamTracks=this.rtsManager.publishingTracks,this.traceId=p,(u=this.parameter.data)!=null&&u.enablePubDataChannel&&(yield this.publishDataChannel()),s&&(this.trackTraceIdMap[D.Audio]=p,this.reportAudioProfile()),c&&(this.trackTraceIdMap[D.VideoSmall]=p),a&&(this.trackTraceIdMap[D.VideoLarge]=p,this.reportVideoProfile()),o&&(this.trackTraceIdMap[D.Screen]=p,this.reportScreenProfile());const f={type:bt.Add,userid:this.userId,sessionid:"",displayname:this.name,pubid:this.publishId,resume:e,subscribe:{signal:"",pullstreamurl:this.url},l1ip:this.parameter.reportL1IP?d:void 0,callid:this.callId,tracks:this.streamTracks,traceid:p};yield this.syncPublishToRoomServer(f,i,h),s&&this.audioPubState.setState(Z.AliRtcStatePublished),a&&this.videoPubState.setState(Z.AliRtcStatePublished),c&&this.videoSmallPubState.setState(Z.AliRtcStatePublished),o&&this.screenPubState.setState(Z.AliRtcStatePublished)}catch(h){throw s&&this.audioPubState.setState(Z.AliRtcStateNoPublish),a&&this.videoPubState.setState(Z.AliRtcStateNoPublish),c&&this.videoSmallPubState.setState(Z.AliRtcStateNoPublish),o&&this.screenPubState.setState(Z.AliRtcStateNoPublish),h}})}updateStreams(){return w(this,null,function*(){yield this.streamManager.updateStreams()})}publishUpdate(e){return w(this,null,function*(){var a,c,o,u,h,p;if(!this._isPublishing)return;yield this.publishPromise;const t=this.streamManager.publishStreams;let i;const s=new Date().getTime();try{const d=(a=this.streamTracks)==null?void 0:a.find(({ssrc:E,type:A,msid:y})=>A==="audio"&&E&&y===D.Audio),f=yield this.compareAndPublish(d,t.audio,D.Audio);f&&(i=f);const m=(c=this.streamTracks)==null?void 0:c.find(({ssrc:E,type:A,msid:y})=>A==="video"&&E&&y===D.VideoLarge),l=yield this.compareAndPublish(m,t.video,D.VideoLarge);l&&(i=l);const S=(o=this.streamTracks)==null?void 0:o.find(({ssrc:E,type:A,msid:y})=>A==="video"&&E&&y===D.VideoSmall),v=yield this.compareAndPublish(S,t.videoSmall,D.VideoSmall);v&&(i=v);const x=(u=this.streamTracks)==null?void 0:u.find(({ssrc:E,type:A,msid:y})=>A==="video"&&E&&y===D.Screen),b=yield this.compareAndPublish(x,t.screen,D.Screen);if(b&&(i=b),!i)if(e===ct.RECONNECT&&this.rtsManager.publishingTracks.length>0){if((h=this.parameter.data)!=null&&h.enablePubDataChannel){const y=this.rtsManager.getDatachannelByMsid({url:this.url,msid:D.Data});this.updateDataChannel(y)}const E=this.rtsManager.publishingTracks.find(({type:y})=>y==="video"),A=this.rtsManager.publishingTracks.find(({type:y})=>y==="audio");(E||A)&&(yield this.rtsManager.waitPublishSender(this.url,!E,E?E.msid:A==null?void 0:A.msid)),i={type:bt.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}}else return;(p=this.parameter.data)!=null&&p.enablePubDataChannel&&!this.dc&&(yield this.publishDataChannel()),yield this.syncPublishToRoomServer(i,t,s)}catch(d){const{code:f}=d!=null?d:{},m=this.url;throw f===403&&m&&(yield this.refreshPushStreamUrl(),i=yield this.publishUpdate()),d}return i})}syncPublishToRoomServer(e,t,i){return w(this,null,function*(){var o;if(!e)throw new V(U.ERR_INNER,"sync publish to room server failed because no publishInfo");let s=e;if(this.dc){const c=e,{tracks:u}=c,h=qt(c,["tracks"]);s=vt(X({},h),{tracks:[...u,{type:"data",msid:D.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 a=yield this.signalingManager.publish(s);e.signaltid=a.tid})}refreshPushStreamUrl(){return w(this,null,function*(){const e=new V(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,s=0){return w(this,null,function*(){this.createCallId();const a=(t==null?void 0:t.aMsid)===D.Audio,c=(t==null?void 0:t.vMsid)===D.VideoLarge,o=(t==null?void 0:t.vMsid)===D.VideoSmall,u=(t==null?void 0:t.vMsid)===D.Screen;a&&this.audioPubState.setState(Z.AliRtcStatePublishing),c&&this.videoPubState.setState(Z.AliRtcStatePublishing),o&&this.videoSmallPubState.setState(Z.AliRtcStatePublishing),u&&this.screenPubState.setState(Z.AliRtcStatePublishing);try{const h=yield this.rtsManager.publishAdd(this.url,e,this.callId,t,!1,!0);a&&(this.audioPubState.setState(Z.AliRtcStatePublished),this.reportAudioProfile(),this.trackTraceIdMap[D.Audio]=h),c&&(this.videoPubState.setState(Z.AliRtcStatePublished),this.reportVideoProfile(),this.trackTraceIdMap[D.VideoLarge]=h),o&&(this.videoSmallPubState.setState(Z.AliRtcStatePublished),this.trackTraceIdMap[D.VideoSmall]=h),u&&(this.screenPubState.setState(Z.AliRtcStatePublished),this.reportScreenProfile(),this.trackTraceIdMap[D.Screen]=h),this.streamTracks=this.rtsManager.publishingTracks;const p={type:bt.Add,userid:this.userId,sessionid:"",displayname:this.name,pubid:this.publishId,resume:i,subscribe:{signal:"",pullstreamurl:this.url},callid:this.callId,tracks:this.streamTracks,traceid:h};return this.reportSelfDeviceStatus(),this.monitorTimerId||this.startStreamMonitor(),p}catch(h){let p=U.ERR_SDK_PUBLISH_INVAILD;if(a&&(this.audioPubState.setState(Z.AliRtcStateNoPublish),p=U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED),c&&(this.videoPubState.setState(Z.AliRtcStateNoPublish),p=U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED),o&&(this.videoSmallPubState.setState(Z.AliRtcStateNoPublish),p=U.ERR_SDK_PUBLISH_DUAL_STREAM_FAILED),u&&(this.screenPubState.setState(Z.AliRtcStateNoPublish),p=U.ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED),h.errorCode===15006&&s<3)return this.publishAdd(e,t,i,s+1);throw V.fromError(h,p,"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={type:bt.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(),i}catch(i){throw V.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:bt.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(Z.AliRtcStateNoPublish),e.video&&(e.vMsid===D.VideoSmall?this.videoSmallPubState.setState(Z.AliRtcStateNoPublish):this.videoPubState.setState(Z.AliRtcStateNoPublish)),e.screen&&this.screenPubState.setState(Z.AliRtcStateNoPublish),t.tracks=this.streamTracks,this.reportSelfDeviceStatus(),t}catch(i){throw V.fromError(i,U.ERR_INNER,"publish delete tracks failed")}})}publishStop(){return w(this,null,function*(){if(!this._isPublishing)throw new V(U.ERR_INNER,"publish stop failed, previous localStream is required for publishing stopping");O.info(`[${mt.logName}]`,"publishStop",{url:this.url});const e=new Date().getTime();try{const t=this.hasAudioTrackInMS,i=this.hasCameraTrackInMS,s=this.hasCameraDualTrackInMS,a=this.hasScreenTrackInMS;yield this.rtsManager.publishStop(this.url),t&&this.audioPubState.setState(Z.AliRtcStateNoPublish),i&&this.videoPubState.setState(Z.AliRtcStateNoPublish),s&&this.videoSmallPubState.setState(Z.AliRtcStateNoPublish),a&&this.screenPubState.setState(Z.AliRtcStateNoPublish),this.traceId="",Object.keys(this.monitorDataCache).forEach(o=>{this.reportPublishMonitor(o)}),this.streamTracks=[];const c={type:bt.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 V.fromError(t,U.ERR_INNER,"publish stop failed")}})}unPublish(){return w(this,null,function*(){const e=new Date().getTime();let t={type:bt.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,s=this.hasCameraTrackInMS,a=this.hasCameraDualTrackInMS,c=this.hasScreenTrackInMS;yield this.rtsManager.unpublish(),this.streamTracks=[],this.stopStreamMonitor(),i&&this.audioPubState.setState(Z.AliRtcStateNoPublish),s&&this.videoPubState.setState(Z.AliRtcStateNoPublish),a&&this.videoSmallPubState.setState(Z.AliRtcStateNoPublish),c&&this.screenPubState.setState(Z.AliRtcStateNoPublish),this._isPublishing=!1,this.traceId="",this.clearStream()}return this.dc&&(this.rtsManager.publishStopDataChannel(this.url,this.dc),this.dataPubState.setState(Z.AliRtcStateNoPublish),this.dc=void 0),this.slsReporter.reportUnpublish(this.callId||"",e,0,""),t}catch(i){throw V.fromError(i,U.ERR_INNER,"unpublish failed")}})}reportSelfDeviceStatus(){this.emit(Ne.Local,this.getDeviceStatus())}getDeviceStatus(){var t,i,s,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.hasCamera,e.micOpen=this.hasMicrophone,e.screenShare=this.hasScreenShare,e.audioDisable=!((t=this.streamManager.cameraStreamInfo.originAudioTrack)!=null&&t.enabled),e.videoDisable=!((i=this.streamManager.cameraStreamInfo.originVideoTrack)!=null&&i.enabled),e.screenDisable=!this.hasScreenShare||!((a=(s=this.streamManager.screenStreamInfo)==null?void 0:s.originVideoTrack)!=null&&a.enabled),Ya.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{e===D.Audio?t=this.rtsManager.getStreamByMsid({url:this.url,aMsid:e}).audioTrack:t=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 s=yield this.rtsManager.getPCStats();let a;s==null||s.forEach(u=>{u.type==="media-source"||u.type==="media-playout"?u.id&&(this.pcMediaStatsMap[u.id]=u):u.type==="candidate-pair"&&u.state==="succeeded"&&(a=u)});let c;if(((e=this.candidateDataCache)==null?void 0:e.length)>0){const t=this.candidateDataCache[this.candidateDataCache.length-1]||{},{_last:h}=t;c=qt(t,["_last"])}((i=this.candidateDataCache)==null?void 0:i.length)>=an&&this.reportNetwork(),a&&(a._last=c,this.candidateDataCache.push(a));let o=Object.keys(this.monitorDataCache).filter(u=>{var h;return((h=this.monitorDataCache[u])==null?void 0:h.length)>0});(this.streamTracks||[]).forEach(u=>{const h=u.msid;if(!h)return;o.includes(h)&&(o=o.filter(f=>f!==h));let p;h===D.Audio?p=this.rtsManager.getPublishAudioStats(this.url):p=this.rtsManager.getPublishVideoStats(this.url,h),p.then(f=>{if(!f.timestamp)return;this.monitorDataCache[h]||(this.monitorDataCache[h]=[]);const m=this.getMediaStats(f.mediaSourceId);f._source=m;const l=this.monitorDataCache[h];let S;if((l==null?void 0:l.length)>0){const v=l[l.length-1]||{},{_last:b}=v;S=qt(v,["_last"])}(l==null?void 0:l.length)>=an&&this.reportPublishMonitor(h),f._last=S,f._codec=u.codec||"",this.monitorDataCache[h].push(f)})}),o.forEach(u=>{this.reportPublishMonitor(u)})}catch(s){}}),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(Z.AliRtcStatePublishIdle),this.videoPubState.setState(Z.AliRtcStatePublishIdle),this.videoSmallPubState.setState(Z.AliRtcStatePublishIdle),this.screenPubState.setState(Z.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 s=0;return!t||t<1?s=1:s=t-1,this.rtsManager.sendSEI(this.url,e,s,i)})}sendDataChannelMessage(e){return w(this,null,function*(){var s;if(!((s=this.parameter.data)!=null&&s.enablePubDataChannel))throw new V(U.ERR_INNER,"data channel publish is not enabled");if(!this.dc)throw new V(U.ERR_INNER,"data channel is not ready");const t=e.toBuffer(),i=V0(t,1156);i.forEach((a,c)=>{const o=new Li(new li(a.byteLength,c===i.length-1,c===0?1:0),a);this.dc.send(o.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:Zt.AliRtcAudioTrackMic})}const t=[];if(this.hasCameraTrackInMS){const a=yield this.rtsManager.getPublishVideoStats(this.url,D.VideoLarge);a&&t.push({track:ne.AliRtcVideoTrackCamera,streamType:Ie.AliRtcVideoStreamTypeHigh,stats:a})}if(this.hasCameraDualTrackInMS){const a=yield this.rtsManager.getPublishVideoStats(this.url,D.VideoSmall);a&&t.push({track:ne.AliRtcVideoTrackCamera,streamType:Ie.AliRtcVideoStreamTypeLow,stats:a})}if(this.hasScreenTrackInMS){const a=yield this.rtsManager.getPublishVideoStats(this.url,D.Screen);a&&t.push({track:ne.AliRtcVideoTrackScreen,stats:a})}let i;const s=yield this.rtsManager.getPCStats();return s==null||s.forEach(a=>{a.type==="candidate-pair"&&a.state==="succeeded"&&(i=a)}),{audio:e,video:t,candidate:i}})}},g(mt,"logName","LocalUser"),mt);xe([T()],Se.prototype,"clearPublishState",1),xe([T()],Se.prototype,"clear",1),xe([T(H)],Se.prototype,"startDefaultCamera",1),xe([T(H)],Se.prototype,"startDefaultAudio",1),xe([T()],Se.prototype,"setViewConfig",1),xe([T()],Se.prototype,"startCameraCapture",1),xe([T()],Se.prototype,"stopCameraCapture",1),xe([T()],Se.prototype,"startAudioCapture",1),xe([T()],Se.prototype,"stopAudioCapture",1),xe([T()],Se.prototype,"stopPreview",1),xe([T()],Se.prototype,"resumePublish",1),xe([T()],Se.prototype,"createLocalStream",1),xe([T()],Se.prototype,"stopLocalStream",1),xe([T(H)],Se.prototype,"startPublish",1),xe([T()],Se.prototype,"updateStreams",1),xe([T(H)],Se.prototype,"publishUpdate",1),xe([T(([r])=>[r])],Se.prototype,"syncPublishToRoomServer",1),xe([T()],Se.prototype,"refreshPushStreamUrl",1),xe([T(([r,n,e])=>[JSON.stringify(e)])],Se.prototype,"publishAdd",1),xe([T(([r,n])=>[JSON.stringify(n)])],Se.prototype,"publishReplace",1),xe([T(H)],Se.prototype,"publishDeleteTracks",1),xe([T()],Se.prototype,"publishStop",1),xe([T()],Se.prototype,"unPublish",1),xe([T(([r,n,e])=>[r.length,n,e])],Se.prototype,"sendSEI",1);let j0=Se;var yt=(r=>(r.OPUS="opus",r.H264="H264",r.UNKNOWN="",r))(yt||{}),oe=(r=>(r[r.NotSubscribe=0]="NotSubscribe",r[r.Subscribing=1]="Subscribing",r[r.Subscribed=2]="Subscribed",r))(oe||{}),Vt=(r=>(r.VideoTrackEnded="videoTrackEnded",r.AudioTrackEnded="audioTrackEnded",r.ScreenTrackEnded="screenTrackEnded",r))(Vt||{});const z0=r=>{const n=new MediaStream;return n.addTrack(r),n},nn=r=>w(this,null,function*(){return yield G.AliRTS.createStream({custom:!0,mediaStream:r})}),pi=r=>w(this,null,function*(){const n=z0(r);return yield nn(n)}),W0=r=>{const{audio:n,video:e,screen:t}=r;if(e&&t)throw new V(U.ERR_INNER,"create stream error, cannot create video && screen together");return!(!e&&!n&&!t)},$0=r=>r===D.Audio||r===tr.Audio,K0=r=>r===D.VideoLarge||r===tr.VideoLarge,q0=r=>r===D.VideoSmall,J0=r=>r===D.Screen,G0=r=>r===D.Data;var X0=Object.defineProperty,Y0=Object.getOwnPropertyDescriptor,Z0=(r,n,e,t)=>{for(var i=t>1?void 0:t?Y0(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&X0(n,e,i),i};class Mi extends re{constructor(){super();g(this,"audioInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:yt.UNKNOWN});g(this,"videoLargeInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:yt.UNKNOWN});g(this,"videoSmallInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:yt.UNKNOWN});g(this,"screenInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:yt.UNKNOWN});g(this,"dataInfo",{subscribeState:oe.NotSubscribe,ssrc:"",msid:"",pt:0,red:0,codec:yt.UNKNOWN});g(this,"audioVolume",1);g(this,"audioMuted",!1);g(this,"userStatus")}getAudioInfo(){return this.audioInfo}getVideoSmallInfo(){return this.videoSmallInfo}getVideoLargeInfo(){return this.videoLargeInfo}getScreenInfo(){return this.screenInfo}getDataInfo(){return this.dataInfo}get subscribingInfos(){return[this.audioInfo,this.videoLargeInfo,this.videoSmallInfo,this.screenInfo].filter(e=>e.msid&&e.subscribeState===oe.Subscribed)}get hasTrack(){return this.hasAudio||this.hasVideo||this.hasScreen||this.hasData}get hasAudio(){return this.audioInfo.ssrc!==""}get hasVideo(){return this.videoLargeInfo.ssrc!==""||this.videoSmallInfo.ssrc!==""}get hasVideoLarge(){return this.videoLargeInfo.ssrc!==""}get hasVideoSmall(){return this.videoSmallInfo.ssrc!==""}get hasScreen(){return this.screenInfo.ssrc!==""}get hasData(){return this.dataInfo.ssrc!==""}get isAudioSubscribed(){return this.audioInfo.subscribeState===oe.Subscribed}get isAudioSubscribing(){return this.audioInfo.subscribeState===oe.Subscribing}get isVideoSubscribed(){return this.isVideoLargeSubscribed||this.isVideoSmallSubscribed}get isVideoSubscribing(){return this.isVideoLargeSubscribing||this.isVideoSmallSubscribing}get isVideoLargeSubscribed(){return this.videoLargeInfo.subscribeState===oe.Subscribed}get isVideoLargeSubscribing(){return this.videoLargeInfo.subscribeState===oe.Subscribing}get isVideoSmallSubscribed(){return this.videoSmallInfo.subscribeState===oe.Subscribed}get isVideoSmallSubscribing(){return this.videoSmallInfo.subscribeState===oe.Subscribing}get isScreenSubscribed(){return this.screenInfo.subscribeState===oe.Subscribed}get isScreenSubscribing(){return this.screenInfo.subscribeState===oe.Subscribing}get isDataSubscribed(){return this.dataInfo.subscribeState===oe.Subscribed}get isDataSubscribing(){return this.dataInfo.subscribeState===oe.Subscribing}get audioCodec(){return this.audioInfo.codec}get videoCodec(){return this.hasVideoLarge?this.videoLargeInfo.codec:this.hasVideoSmall?this.videoSmallInfo.codec:this.hasScreen?this.screenInfo.codec:yt.UNKNOWN}get audioTrackInfo(){return this.hasAudio?Zt.AliRtcAudioTrackMic:Zt.AliRtcAudioTrackNo}get videoTrackInfo(){return this.hasVideo&&this.hasScreen?ne.AliRtcVideoTrackBoth:this.hasVideo?ne.AliRtcVideoTrackCamera:this.hasScreen?ne.AliRtcVideoTrackScreen:ne.AliRtcVideoTrackNo}updateTracks(e){let t="",i="",s="",a="",c="";return e?(e.forEach(o=>{var p;let u=yt.UNKNOWN;const h=((p=o==null?void 0:o.attr)==null?void 0:p.reason)==="reconnect";if(o.userdata){const{codec:d}=JSON.parse(o.userdata);d&&(u=d)}$0(o.msid)?(t=o.ssrc,this.audioInfo.msid=o.msid,this.audioInfo.codec=u,(h||this.audioInfo.ssrc!==t)&&(this.audioInfo.subscribeState=oe.NotSubscribe)):q0(o.msid)?(s=o.ssrc,this.videoSmallInfo.msid=o.msid,this.videoSmallInfo.codec=u,(h||this.videoSmallInfo.ssrc!==s)&&(this.videoSmallInfo.subscribeState=oe.NotSubscribe)):K0(o.msid)?(i=o.ssrc,this.videoLargeInfo.msid=o.msid,this.videoLargeInfo.codec=u,(h||this.videoLargeInfo.ssrc!==i)&&(this.videoLargeInfo.subscribeState=oe.NotSubscribe)):J0(o.msid)?(a=o.ssrc,this.screenInfo.msid=o.msid,this.screenInfo.codec=u,(h||this.screenInfo.ssrc!==a)&&(this.screenInfo.subscribeState=oe.NotSubscribe)):G0(o.msid)&&(c=o.ssrc,this.dataInfo.msid=o.msid,this.dataInfo.codec=u,(h||this.dataInfo.ssrc!==c)&&(this.dataInfo.subscribeState=oe.NotSubscribe))}),this.updateRemoteTrackSsrc(t,i,s,a,c)):this.updateRemoteTrackSsrc(t,i,s,a,c),{}}updateRemoteTrackSsrc(e,t,i,s,a){this.audioInfo.ssrc=e,this.videoSmallInfo.ssrc=i,this.videoLargeInfo.ssrc=t,this.screenInfo.ssrc=s,this.dataInfo.ssrc=a}markRemoteTrackSubscribing(e){return e.video&&(e.vMsid===this.videoSmallInfo.msid&&(this.videoSmallInfo.subscribeState=oe.Subscribing),(e.vMsid===this.videoLargeInfo.msid||!e.vMsid)&&(this.videoLargeInfo.subscribeState=oe.Subscribing)),e.screen&&(this.screenInfo.subscribeState=oe.Subscribing),e.audio&&(this.audioInfo.subscribeState=oe.Subscribing),e.data&&(this.dataInfo.subscribeState=oe.Subscribing),{videoLargeInfo:this.videoLargeInfo,videoSmallInfo:this.videoSmallInfo}}updateRemoteTrackSubState(e){return e.video!==void 0&&((e.vMsid===this.videoSmallInfo.msid||!e.vMsid)&&(this.videoSmallInfo.subscribeState=e.video?oe.Subscribed:oe.NotSubscribe),(e.vMsid===this.videoLargeInfo.msid||!e.vMsid)&&(this.videoLargeInfo.subscribeState=e.video?oe.Subscribed:oe.NotSubscribe)),e.screen!==void 0&&(this.screenInfo.subscribeState=e.screen?oe.Subscribed:oe.NotSubscribe),e.audio!==void 0&&(this.audioInfo.subscribeState=e.audio?oe.Subscribed:oe.NotSubscribe),e.data!==void 0&&(this.dataInfo.subscribeState=e.data?oe.Subscribed:oe.NotSubscribe),{audioInfo:this.audioInfo,videoLargeInfo:this.videoLargeInfo,videoSmallInfo:this.videoSmallInfo,screenInfo:this.screenInfo,dataInfo:this.dataInfo}}updateRemoteUserDeviceStatus(e){let t=Ya.parseStatus(e);const{audioDisable:i,videoDisable:s,screenDisable:a}=t;return this.userStatus?(this.userStatus.audioDisable!=i&&(this.userStatus.audioDisable=i,this.emit(Ne.Remote,i?he.MuteAudio:he.UnmuteAudio)),this.userStatus.videoDisable!=s&&(this.userStatus.videoDisable=s,this.emit(Ne.Remote,s?he.MuteVideo:he.UnmuteVideo)),this.userStatus.screenDisable!=a&&(this.userStatus.screenDisable=a,this.emit(Ne.Remote,a?he.MuteScreen:he.UnmuteScreen))):(this.userStatus=t,this.emit(Ne.Remote,i?he.MuteAudio:he.UnmuteAudio),this.emit(Ne.Remote,s?he.MuteVideo:he.UnmuteVideo),this.emit(Ne.Remote,a?he.MuteScreen:he.UnmuteScreen)),!1}}g(Mi,"logName","RemoteStreamInfo"),Z0([T()],Mi.prototype,"updateRemoteTrackSubState",1);class on{constructor(n){g(this,"remoteUser");this.remoteUser=n}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 Q0=Object.defineProperty,ec=Object.getOwnPropertyDescriptor,De=(r,n,e,t)=>{for(var i=t>1?void 0:t?ec(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&Q0(n,e,i),i};class ei extends re{constructor(){super();g(this,"state");g(this,"time");g(this,"_enabled");this.state=le.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 tc=30,we=(Me=class extends Xa{constructor(e){var f;const{userId:t,displayName:i,rtsManager:s,usersViewMap:a,slsReporter:c,signalingManager:o,localUser:u,audioVolumeIndicationInterval:h,playoutVolume:p,parameter:d}=e;super(t,i,s,h);g(this,"remoteCallid","");g(this,"remoteUserInfo");g(this,"localUser");g(this,"lastPubId","");g(this,"stream");g(this,"screenStream");g(this,"viewMap");g(this,"audioTrack");g(this,"audioElement");g(this,"subscribed",!1);g(this,"mediaStream");g(this,"secondaryMediaStream");g(this,"prevSubConfig");g(this,"signalingManager");g(this,"slsReporter");g(this,"wantSubAudio",!1);g(this,"wantSubVideo",!1);g(this,"wantSubScreen",!1);g(this,"defaultVideoStreamType",Ie.AliRtcVideoStreamTypeHigh);g(this,"audioMuted",!1);g(this,"playoutVolume",1);g(this,"playoutGainNode");g(this,"audioSubState");g(this,"videoSubState");g(this,"videoLargeSubState",new ei);g(this,"videoSmallSubState",new ei);g(this,"screenSubState");g(this,"dataSubState");g(this,"dc");g(this,"dcMsgWaitingPieces",[]);g(this,"streamInfo");g(this,"_streamUrl","");g(this,"parameter",{});g(this,"monitorTimerId");g(this,"monitorDataCache",{});g(this,"trackTraceIdMap",{});g(this,"handleAudioContextSuspended",e=>{e.target.state==="suspended"&&this.emit("remoteAudioPlayError",this.uid,"AudioContext suspended")});g(this,"onDataChannelMessage",e=>{var s;const t=Li.parse(e.slice(4));let i;if(t.body)if(t.isFin){if(this.dcMsgWaitingPieces.length>0){const a=this.dcMsgWaitingPieces.reduce((c,o)=>c+o.byteLength,t.body.byteLength);try{const c=new ArrayBuffer(a);let o=0;for(let h=0;h<this.dcMsgWaitingPieces.length;h++){const p=this.dcMsgWaitingPieces[h];new Uint8Array(c,o,p.byteLength).set(new Uint8Array(p)),o+=p.byteLength}new Uint8Array(c,o,t.body.byteLength).set(new Uint8Array(t.body)),i=Ft.parse(c)}catch(c){}this.dcMsgWaitingPieces=[],i||(i=Ft.parse(t.body))}else i=Ft.parse(t.body);i||O.event(`[${Me.logName}]`,`parse data channel message fail, piece count: ${this.dcMsgWaitingPieces.length+1}`)}else{t.header.frameType===1&&(this.dcMsgWaitingPieces=[]),this.dcMsgWaitingPieces.push(t.body);return}i&&(O.event(`[${Me.logName}]`,`receive data channel message, length: ${(s=i.data)==null?void 0:s.byteLength}`),this.emit("remoteDataChannelMessage",this.uid,i))});g(this,"onDataChannelError",e=>{this.emit("occurError",V.fromError(e,U.ERR_SDK_SUBSCRIBE_DATA_ERROR))});g(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))});g(this,"handleAudioPaused",()=>{this.emit("remoteAudioPlayError",this.uid,"paused")});this.streamInfo=new Mi,this.remoteUserInfo=new on(this),this.parameter=d,this.streamInfo.on(Ne.Remote,m=>{this.emit(Ne.Remote,m,this.userId)}),this.signalingManager=o,this.viewMap=(f=a[t])!=null?f:{cameraViews:[],screenViews:[]},a[t]=this.viewMap,this.slsReporter=c,this.localUser=u,this.audioSubState=new ei,this.audioSubState.on("change",(m,l,S)=>{this.emit("audioSubscribeStateChanged",this.uid,m,l,S)}),this.videoSubState=new ei,this.videoSubState.on("change",(m,l,S)=>{this.emit("videoSubscribeStateChanged",this.uid,m,l,S)}),this.screenSubState=new ei,this.screenSubState.on("change",(m,l,S)=>{this.emit("screenSubscribeStateChanged",this.uid,m,l,S)}),this.dataSubState=new ei,this.dataSubState.on("change",(m,l,S)=>{this.emit("dataSubscribeStateChanged",this.uid,m,l,S)}),this.playoutVolume=p}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(pe.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=Lt.getInstance();i.addEventListener("statechange",this.handleAudioContextSuspended);const s=i.createMediaStreamSource(t);this.audioElement.muted=!0,this.playoutGainNode=i.createGain(),s.connect(this.playoutGainNode),this.playoutGainNode.gain.value=e,this.playoutGainNode.connect(i.destination)}}else this.audioElement.volume=e}getAudioMuted(){return this.audioMuted}get hasAudioTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasAudio)}get hasVideoTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasVideo)}get hasVideoLargeTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasVideoLarge)}get hasVideoSmallTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasVideoSmall)}get hasScreenTrack(){var e;return!!((e=this.streamInfo)!=null&&e.hasScreen)}get isAudioSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isAudioSubscribed)||!!((t=this.streamInfo)!=null&&t.isAudioSubscribing)}get isVideoSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isVideoSubscribed)||!!((t=this.streamInfo)!=null&&t.isVideoSubscribing)}get isVideoLargeSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isVideoLargeSubscribed)||!!((t=this.streamInfo)!=null&&t.isVideoLargeSubscribing)}get isVideoSmallSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isVideoSmallSubscribed)||!!((t=this.streamInfo)!=null&&t.isVideoSmallSubscribing)}get isScreenSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isScreenSubscribed)||!!((t=this.streamInfo)!=null&&t.isScreenSubscribing)}get isDataSubscribing(){var e,t;return!!((e=this.streamInfo)!=null&&e.isDataSubscribed)||!!((t=this.streamInfo)!=null&&t.isDataSubscribing)}get audioEnabled(){var e,t;return!!((t=(e=this.stream)==null?void 0:e.audioTrack)!=null&&t.enabled)}get videoEnabled(){var e,t;return!!((t=(e=this.stream)==null?void 0:e.videoTrack)!=null&&t.enabled)}get screenEnabled(){var e,t;return!!((t=(e=this.screenStream)==null?void 0:e.videoTrack)!=null&&t.enabled)}get getAudioTrack(){return this.audioTrack}get getCameraStream(){return this.stream}get getScreenStream(){return this.screenStream}setViewConfig(e,t){if(t!==ne.AliRtcVideoTrackScreen&&t!==ne.AliRtcVideoTrackCamera)throw new V(U.ERR_INVALID_ARGUMENTS,"track is not AliRtcVideoTrackScreen or AliRtcVideoTrackCamera");e?ns(e).forEach(s=>{s.setAttribute("playsinline",""),G.AliRTS.BrowserUtil.isMicroMessenger&&(s.setAttribute("x5-video-player-type","h5-page"),s.setAttribute("x5-playsinline",""),G.AliRTS.SystenUtil.isAndroid||G.AliRTS.SystenUtil.isIos&&s.setAttribute("x-webkit-airplay","allow")),t===ne.AliRtcVideoTrackScreen?this.viewMap.screenViews.push(s):this.viewMap.cameraViews.push(s),this.play(s,t===ne.AliRtcVideoTrackScreen)}):(this.stopPlayAll(t===ne.AliRtcVideoTrackScreen),t===ne.AliRtcVideoTrackScreen?this.viewMap.screenViews=[]:this.viewMap.cameraViews=[])}clear(e=!0){return w(this,null,function*(){var t;this.subscribeStopDataChannel(),e&&this.doStopSubscribe(this.streamUrl),Es(Me.prototype,this,"clear").call(this),this.stopPlayAudio(),this.clearStream(),this.clearScreenStream(),this.playoutGainNode&&(this.playoutGainNode.disconnect(),this.playoutGainNode=void 0,Lt.getInstance().removeEventListener("statechange",this.handleAudioContextSuspended)),(t=this.streamInfo)==null||t.removeAllListeners(Ne.Remote)})}updateRemoteUserDeviceStatus(e){var t;(t=this.streamInfo)==null||t.updateRemoteUserDeviceStatus(e)}updateRemoteTracks(e,t,i,s){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 Mi),(c=this.streamInfo)==null?void 0:c.updateTracks(s)})}subscribe(s,a){return w(this,arguments,function*(e,t,i=Date.now()){var f,m;let c=e;if(!c){const{hasAudio:l,hasVideo:S,hasScreen:v,hasData:x}=(f=this.streamInfo)!=null?f:{};c={audio:this.wantSubAudio&&l,video:this.wantSubVideo&&S,screen:this.wantSubScreen&&v,data:((m=this.parameter.data)==null?void 0:m.enableSubDataChannel)&&x}}this.streamInfo.markRemoteTrackSubscribing(c);const{screen:o,audio:u,video:h,vMsid:p}=c,d=[];(h||u)&&d.push({audio:u,video:h,vMsid:p}),o&&d.push({screen:o}),!(d.length===0&&!(e!=null&&e.data))&&(yield Promise.all(d.map(l=>this.subscribeProxy(l,t||pe.User,i))),e!=null&&e.data&&this.subscribeDataChannel())})}subscribeProxy(e,t,i){return w(this,null,function*(){var c,o,u,h;let s=new Date().getTime(),a="";try{e.audio&&this.audioSubState.setState(le.AliRtcStateSubscribing),e.video&&(this.videoSubState.currentState===le.AliRtcStateSubscribeIdle||this.videoSubState.currentState===le.AliRtcStateNoSubscribe)&&this.videoSubState.setState(le.AliRtcStateSubscribing),e.screen&&this.screenSubState.setState(le.AliRtcStateSubscribing);const p=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=p.traceId||"";const{stream:d}=p;if(e.audio){this.trackTraceIdMap[D.Audio]=a;const m=d.audioTrack;m&&(this.audioTrack=m,(o=d.mediaStream)==null||o.removeTrack(m),this.playAudio(),this.audioVolumeIndicationInterval&&this.audioLevelMonitor.start(m,this.audioVolumeIndicationInterval)),this.audioSubState.setState(le.AliRtcStateSubscribed),this.audioSubState.getEnabled()||this.toggleAudio(!1)}e.video&&(this.videoSubState.setState(le.AliRtcStateSubscribed),e.vMsid===D.VideoSmall?(this.trackTraceIdMap[D.VideoSmall]=a,this.videoSmallSubState.setState(le.AliRtcStateSubscribed)):(this.trackTraceIdMap[D.VideoLarge]=a,this.videoLargeSubState.setState(le.AliRtcStateSubscribed)),this.videoSubState.getEnabled()||this.toggleVideo(!1),this.updateStream(d,this.isVideoLargeSubscribing&&this.isVideoSmallSubscribing)),e.screen&&(this.screenSubState.setState(le.AliRtcStateSubscribed),this.trackTraceIdMap[D.Screen]=a,this.videoSubState.getEnabled()||this.toggleScreen(!1),this.updateScreenStream(d));const f=new Date().getTime()-s;this.slsReporter.reportSubscribe(((u=this.localUser)==null?void 0:u.callId)||"",this.callId,!!e.video&&e.vMsid===D.VideoLarge,!!e.video&&e.vMsid===D.VideoSmall,!!e.screen,!!e.audio,0,"",f,{pctid:this.rtsManager.pcTraceId,subtid:a,ajsub:t===pe.Join?1:0,url:this.streamUrl,est:s}),this.startStreamMonitor()}catch(p){const d=new Date().getTime()-s;e.audio&&this.audioSubState.setState(le.AliRtcStateNoSubscribe),e.video&&this.videoSubState.setState(le.AliRtcStateNoSubscribe),e.screen&&this.screenSubState.setState(le.AliRtcStateNoSubscribe),p&&(p.message=`user(${this.uid}) subscribe error, ${(p==null?void 0:p.message)||""}`);let f=U.ERR_INNER;e.audio&&(f=U.ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED),e.video&&(e.vMsid===D.VideoSmall?f=U.ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED:f=U.ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED),e.screen&&(f=U.ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED),this.slsReporter.reportSubscribe(((h=this.localUser)==null?void 0:h.callId)||"",this.callId,!!e.video&&e.vMsid===D.VideoLarge,!!e.video&&e.vMsid===D.VideoSmall,!!e.screen,!!e.audio,f,"",d,{pctid:this.rtsManager.pcTraceId,subtid:"",ajsub:t===pe.Join?1:0,url:this.streamUrl,est:s});const m=V.fromError(p,f);throw this.emit("remoteSubscribeError",m),m}})}subscribeDeleteTracks(e){return w(this,null,function*(){const{audio:t,video:i,screen:s,data:a,vMsid:c}=e,o=[];(t||i||a)&&o.push({audio:t,video:i,vMsid:c}),s&&o.push({screen:s}),o.length!==0&&(yield Promise.all(o.map(u=>this.subscribeDeleteProxy(u))),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:{},s={};e.audio===!0&&(s.audio=!1,this.audioSubState.setState(le.AliRtcStateNoSubscribe)),e.video===!0&&(s.video=!1,e.vMsid===D.VideoSmall?(this.videoSmallSubState.setState(le.AliRtcStateNoSubscribe),(this.videoLargeSubState.currentState===le.AliRtcStateNoSubscribe||this.videoLargeSubState.currentState===le.AliRtcStateSubscribeIdle)&&this.videoSubState.setState(le.AliRtcStateNoSubscribe)):(this.videoLargeSubState.setState(le.AliRtcStateNoSubscribe),(this.videoSmallSubState.currentState===le.AliRtcStateNoSubscribe||this.videoSmallSubState.currentState===le.AliRtcStateSubscribeIdle)&&this.videoSubState.setState(le.AliRtcStateNoSubscribe))),e.screen===!0&&(s.screen=!1,this.screenSubState.setState(le.AliRtcStateNoSubscribe));const{callId:a,remoteCallid:c}=this,o={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?!1:void 0,video:e.video===!0?!1:void 0,screen:e.screen===!0?!1:void 0,vMsid:e.vMsid}),o}catch(t){throw V.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=Lt.getInstance();return e.state!=="running"&&e.resume(),this.audioElement?this.audioElement.play():this.playAudio()})}resumeVideo(e){return w(this,null,function*(){if(!e||e===ne.AliRtcVideoTrackCamera||e===ne.AliRtcVideoTrackBoth)return this.playAll();if(!e||e===ne.AliRtcVideoTrackScreen||e===ne.AliRtcVideoTrackBoth)return this.playAll(!0)})}resumePlay(){this.playAudio(),this.playAll(),this.playAll(!0)}stopSubscribe(e){return w(this,null,function*(){var i,s;let t=new Date().getTime();try{let a;e?a=yield this.subscribeDeleteTracks(e):a=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(((s=this.localUser)==null?void 0:s.callId)||"",this.callId,new Date().getTime()-t,0,""),a}})}doStopSubscribe(e){return w(this,null,function*(){var s,a,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 u={callid:t,remoteCallid:i,remoteStream:this.stream};return this.callId="",u}catch(u){if(((o=(c=(a=(s=u==null?void 0:u.extraInfo)==null?void 0:s.parsedData)==null?void 0:a.streams)==null?void 0:c[0])==null?void 0:o.res_code)!==404)throw V.fromError(u,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 s,a;if(e.mediaStream){a=document.createElement("video");const c=()=>{O.event(`uid: ${this.userId} new mediaStream canplay`),a&&a.removeEventListener("canplaythrough",c,!1),a=void 0,clearTimeout(s),i(!0)};a.addEventListener("canplaythrough",c,!1),(a._playPromise||Promise.resolve()).then(()=>{a&&e.mediaStream&&(a.srcObject=e.mediaStream)})}else i(!0);s=window.setTimeout(()=>{O.event(`uid: ${this.userId} new mediaStream timeout`),a=void 0,i(!0)},3e3)}),this.updateSubscribe(pe.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(le.AliRtcStateSubscribing),this.rtsManager.subscribeAddDataChannel(this.streamUrl).then(e=>{if(e){this.dataChannelConnected(e),this.dataSubState.setState(le.AliRtcStateSubscribed),this.streamInfo.updateRemoteTrackSubState({data:!0});return}else throw new Error("no dc founded")}).catch(e=>{const t=V.fromError(e,U.ERR_INNER,"subscribe data failed");this.emit("remoteSubscribeError",t),this.dataSubState.setState(le.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(le.AliRtcStateNoSubscribe),this.dc=void 0,this.streamInfo.updateRemoteTrackSubState({data:!1})}}getRetryOptions(){var i,s,a,c,o,u,h;const e={};this.wantSubAudio&&((i=this.streamInfo)!=null&&i.hasAudio)&&(e.audio=!0,e.aMsid=((s=this.streamInfo.getAudioInfo())==null?void 0:s.msid)||D.Audio),this.wantSubVideo&&((a=this.streamInfo)!=null&&a.hasVideo)&&(this.defaultVideoStreamType===Ie.AliRtcVideoStreamTypeLow&&((c=this.streamInfo)!=null&&c.hasVideoSmall)?(e.video=!0,e.vMsid=D.VideoSmall):(o=this.streamInfo)!=null&&o.hasVideoLarge&&(e.video=!0,e.vMsid=((u=this.streamInfo.getVideoLargeInfo())==null?void 0:u.msid)||D.VideoLarge)),this.wantSubScreen&&((h=this.streamInfo)!=null&&h.hasScreen)&&(e.screen=!0);let t={};if(e.audio||e.video)t={audio:e.audio,video:e.video},this.streamInfo.updateRemoteTrackSubState({screen:!1,data:!1});else if(e.screen)t={screen:e.screen},this.streamInfo.updateRemoteTrackSubState({data:!1});else return;return{remoteUser:this,options:t}}updateSubscribe(e){var a,c,o,u,h,p,d,f,m,l,S,v,x,b,E,A,y;const t=Date.now(),i={},s={};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)||D.Audio):(!this.wantSubAudio||!((o=this.streamInfo)!=null&&o.hasAudio))&&this.isAudioSubscribing&&(s.audio=!0,s.aMsid=((u=this.streamInfo.getAudioInfo())==null?void 0:u.msid)||D.Audio),this.wantSubVideo&&((h=this.streamInfo)!=null&&h.hasVideo)?(this.defaultVideoStreamType===Ie.AliRtcVideoStreamTypeLow&&!this.isVideoSmallSubscribing&&((p=this.streamInfo)!=null&&p.hasVideoSmall)?(i.video=!0,i.vMsid=D.VideoSmall):!this.isVideoLargeSubscribing&&((d=this.streamInfo)!=null&&d.hasVideoLarge)&&!(this.defaultVideoStreamType===Ie.AliRtcVideoStreamTypeLow&&this.isVideoSmallSubscribing)&&(i.video=!0,i.vMsid=((f=this.streamInfo.getVideoLargeInfo())==null?void 0:f.msid)||D.VideoLarge),this.defaultVideoStreamType===Ie.AliRtcVideoStreamTypeLow&&this.isVideoLargeSubscribing&&this.isVideoSmallSubscribing&&this.streamInfo.hasVideoSmall?(s.video=!0,s.vMsid=D.VideoLarge):this.defaultVideoStreamType===Ie.AliRtcVideoStreamTypeHigh&&this.isVideoLargeSubscribing&&this.isVideoSmallSubscribing&&(s.video=!0,s.vMsid=D.VideoSmall)):(!this.wantSubVideo||!((m=this.streamInfo)!=null&&m.hasVideo))&&this.isVideoSubscribing&&(s.video=!0,s.vMsid=this.streamInfo.isVideoSmallSubscribed||this.streamInfo.isVideoSmallSubscribing?D.VideoSmall:((l=this.streamInfo.getVideoLargeInfo())==null?void 0:l.msid)||D.VideoLarge),this.wantSubScreen&&!this.isScreenSubscribing&&((S=this.streamInfo)!=null&&S.hasScreen)?i.screen=!0:(!this.wantSubScreen||!((v=this.streamInfo)!=null&&v.hasScreen))&&this.isScreenSubscribing&&(s.screen=!0),(x=this.parameter.data)!=null&&x.enableSubDataChannel&&!this.isDataSubscribing&&((b=this.streamInfo)!=null&&b.hasData)?i.data=!0:(!((E=this.parameter.data)!=null&&E.enableSubDataChannel)||!((A=this.streamInfo)!=null&&A.hasData))&&this.isDataSubscribing&&(s.data=!0),(i.audio||i.video||i.screen||i.data)&&(this.createCallId(),this.subscribe(i,e,t)),(s.audio||s.video||s.screen)&&this.subscribeDeleteTracks(s),e===pe.Reconnect){if(O.event(`[${Me.logName}]`,"reconnect, try to resume"),this.streamInfo.hasData&&!i.data){const _=this.rtsManager.getDatachannelByMsid({url:this.streamUrl,msid:this.streamInfo.getDataInfo().msid||D.Data});this.dataChannelConnected(_)}if(this.streamInfo.hasAudio&&!i.audio){const _=this.rtsManager.getStreamByMsid({url:this.streamUrl,aMsid:this.streamInfo.getAudioInfo().msid||D.Audio}).audioTrack;_&&(this.audioTrack=_,this.playAudio())}if(this.streamInfo.hasVideo&&!i.video){const _=this.rtsManager.getStreamByMsid({url:this.streamUrl,vMsid:this.streamInfo.isVideoSmallSubscribed||this.streamInfo.isVideoSmallSubscribing?D.VideoSmall:((y=this.streamInfo.getVideoLargeInfo())==null?void 0:y.msid)||D.VideoLarge});_&&_.mediaStream&&(this.stream=_,this.playAll(!1))}if(this.streamInfo.hasScreen&&!i.screen){const _=this.rtsManager.getStreamByMsid({url:this.streamUrl,sMsid:this.streamInfo.getScreenInfo().msid||D.Screen});_&&_.mediaStream&&(this.screenStream=_,this.playAll(!0))}}return{addOption:i,deleteOption:s}}handleAutoPlayFailed(){O.event(`[${Me.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 s=(a=t===ne.AliRtcVideoTrackScreen?this.screenStream:this.stream)==null?void 0:a.mediaStream;e.srcObject===s&&this.play(e,t===ne.AliRtcVideoTrackScreen),document.removeEventListener("click",i,!1),document.removeEventListener("touchstart",i,!1)};document.addEventListener("click",i,!1),document.addEventListener("touchstart",i,!1)}playAudio(){return w(this,null,function*(){var e,t;if(!this.audioTrack){O.event(`[${Me.logName}]`,this.userId,"audio track is null");return}if(this.toggleAudio(!this.audioMuted),this.audioElement||(O.event(`[${Me.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(s=>{i.removeTrack(s)}):(i=new MediaStream,this.audioElement.srcObject=i),i.addTrack(this.audioTrack)}if(G.AliRTS.SystenUtil.isIos&&parseInt(G.AliRTS.SystenUtil.systemVersion)<=13){O.event(`[${Me.logName}]`,"play audio for iOS 13-");const i=this.audioElement;i.setAttribute("autoplay","");const s=()=>{i.removeEventListener("playing",s),i.pause(),i.play().catch(()=>{this.handleAutoPlayFailed()})};this.audioElement.addEventListener("playing",s)}else(()=>{var s;O.event(`[${Me.logName}]`,"try play audio"),(s=this.audioElement)==null||s.play().then(()=>{O.event(`[${Me.logName}]`,"play audio success")}).catch(()=>{this.handleAutoPlayFailed()})})()})}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 s=t?this.screenStream:this.stream;!e||!s||!s.mediaStream||rn(e,s.mediaStream,i).catch(a=>{a.code===20||a.name==="AbortError"||this.handleVideoPlayFailded(e,t?ne.AliRtcVideoTrackScreen:ne.AliRtcVideoTrackCamera)})}stopPlayAll(e=!1){e?this.viewMap.screenViews.forEach(t=>{dt(t)}):this.viewMap.cameraViews.forEach(t=>{dt(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,s,a,c,o;const e=[];if(this.isAudioSubscribing){const u=yield this.rtsManager.getSubscribeAudioStats(this.streamUrl);u&&e.push({uid:this.uid,track:Zt.AliRtcAudioTrackMic,stats:u})}const t=[];if((i=this.streamInfo)!=null&&i.isVideoLargeSubscribed){const u=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((s=this.streamInfo.getVideoLargeInfo())==null?void 0:s.msid)||D.VideoLarge);u&&t.push({uid:this.uid,track:ne.AliRtcVideoTrackCamera,streamType:Ie.AliRtcVideoStreamTypeHigh,stats:u})}if((a=this.streamInfo)!=null&&a.isVideoSmallSubscribed){const u=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((c=this.streamInfo.getVideoSmallInfo())==null?void 0:c.msid)||D.VideoSmall);u&&t.push({uid:this.uid,track:ne.AliRtcVideoTrackCamera,streamType:Ie.AliRtcVideoStreamTypeLow,stats:u})}if(this.isScreenSubscribing){const u=yield this.rtsManager.getSubscribeVideoStats(this.streamUrl,((o=this.streamInfo.getScreenInfo())==null?void 0:o.msid)||D.Screen);u&&t.push({uid:this.uid,track:ne.AliRtcVideoTrackScreen,stats:u})}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){this.stopStreamMonitor();return}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;e.includes(i)&&(e=e.filter(c=>c!==i));let s;const a=i===D.Audio;a?s=this.rtsManager.getSubscribeAudioStats(this.streamUrl):s=this.rtsManager.getSubscribeVideoStats(this.streamUrl,i),s.then(c=>{var p;if(!c.timestamp)return;this.monitorDataCache[i]||(this.monitorDataCache[i]=[]);const o=this.monitorDataCache[i];let u;if((o==null?void 0:o.length)>0){const h=o[o.length-1]||{},{_last:f}=h;u=qt(h,["_last"])}(o==null?void 0:o.length)>=tc&&this.reportSubscribeMonitor(i),c._last=u,c._codec=t.codec,a&&(c._source=(p=this.localUser)==null?void 0:p.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)})}},g(Me,"logName","RemoteUser"),Me);De([T()],we.prototype,"clear",1),De([T()],we.prototype,"updateRemoteUserDeviceStatus",1),De([T()],we.prototype,"updateRemoteTracks",1),De([T(H)],we.prototype,"subscribe",1),De([T()],we.prototype,"subscribeProxy",1),De([T(H)],we.prototype,"subscribeDeleteProxy",1),De([T()],we.prototype,"restore",1),De([T(H)],we.prototype,"resumeAudio",1),De([T(H)],we.prototype,"stopSubscribe",1),De([T(H)],we.prototype,"doStopSubscribe",1),De([T()],we.prototype,"clearStream",1),De([T()],we.prototype,"clearScreenStream",1),De([T()],we.prototype,"updateSubscribe",1),De([T()],we.prototype,"playAudio",1),De([T()],we.prototype,"stopPlayAudio",1),De([T((r,n,e)=>[typeof r=="string"?r:r==null?void 0:r.nodeType,n,e])],we.prototype,"play",1),De([T()],we.prototype,"stopPlayAll",1);let ic=we;var Ct=(r=>(r[r.AliRtcPluginErrorCodeSuccess=0]="AliRtcPluginErrorCodeSuccess",r[r.AliRtcPluginErrorCodeFailed=-1]="AliRtcPluginErrorCodeFailed",r[r.AliRtcPluginErrorNoFindPlugin=-2]="AliRtcPluginErrorNoFindPlugin",r[r.AliRtcPluginErrorParameterError=-3]="AliRtcPluginErrorParameterError",r[r.AliRtcPluginErrorLoadError=-4]="AliRtcPluginErrorLoadError",r[r.AliRtcPluginErrorCreateError=-5]="AliRtcPluginErrorCreateError",r[r.AliRtcPluginErrorInitError=-6]="AliRtcPluginErrorInitError",r[r.AliRtcPluginErrorInitTokenError=-7]="AliRtcPluginErrorInitTokenError",r))(Ct||{});class rc extends re{constructor(){super(...arguments);g(this,"plugins",new Map)}add(e,t){if(this.plugins.has(e.name))throw new V(Ct.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 V(Ct.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,_e=(r,n,e,t)=>{for(var i=t>1?void 0:t?ac(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&sc(n,e,i),i};const Fi=([r])=>{const{remoteUser:n,options:e}=r;return[`user(${n.userId})`,e]},cn=5,un=17,hn=5e3,be=(Ce=class extends re{constructor(e,t,i){super();g(this,"rts");g(this,"encodedInsertableStreams",!0);g(this,"audioRedEnabled",!1);g(this,"localStreamManager");g(this,"slsReporter");g(this,"_rtsReconnecting",!1);g(this,"_rtsPeerConnectionType","publish");g(this,"connecting",!1);g(this,"connected",!1);g(this,"_pcTraceId","");g(this,"_localJoinTime",0);g(this,"connectionResolve");g(this,"connectingPromise");g(this,"dcResolve");g(this,"dcReject");g(this,"dcConnectingPromise");g(this,"_publishingTracks",[]);g(this,"parameter",{});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,s,a;if(O.event(`[${Ce.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_RECONNECTING)this._rtsReconnecting=!0;else if(e.status===G.EConnectStatus.CONNECT_STATUS_CONNECTED){const c=(a=(s=(i=(t=this.rts.commonController)==null?void 0:t.peerCore)==null?void 0:i.getSignal())==null?void 0:s.getDatachannelCore())==null?void 0:a.readyState;O.event(`[${Ce.logName}]`,"dcReadyState:",c),c==="open"&&this.dcResolve&&this.dcResolve(!0),this._rtsReconnecting&&this._rtsPeerConnectionType==="publish"&&(this._publishingTracks=this.rts.getPublishTrackInfoList()),this.setConnected(!0)}}),this.rts.on("reconnectFinish",()=>{O.event(`[${Ce.logName}]`,"rts reconnectFinish");try{this.emit("connected",!0,this._rtsPeerConnectionType)}catch(e){O.error(`[${Ce.logName}]`,"emit connected error:",e)}}),this.rts.on("datachannelStatusChange",e=>{O.event(`[${Ce.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=>{O.event(`[${Ce.logName}]`,"rts onError event:",e)}),this.rts.on("reconnect",e=>{O.event(`[${Ce.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 s=[...((t=RTCRtpReceiver.getCapabilities("audio"))==null?void 0:t.codecs)||[]];if(s.length>0){if(e){const a=s.findIndex(o=>o.mimeType==="audio/red"),c=s.findIndex(o=>o.mimeType==="audio/opus");if(a>-1&&c>-1&&a>c){const o=s[c];s[c]=s[a],s[a]=o}}this.rts.setSenderCodecPreferences({audio:s}),this.rts.setReceiverCodecPreferences({audio:s})}}catch(i){}this.audioRedEnabled=e}}clear(){this.setConnected(!1);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,this._rtsReconnecting=!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:s}=t!=null?t:{},a={};return e.hasAudio&&(a.aMsid=[i!=null?i:D.Audio]),e.hasScreen&&(a.vMsid=[D.Screen]),e.hasVideo&&(a.vMsid=[s!=null?s:t!=null&&t.isScreen?D.Screen:D.VideoLarge]),a}updatePublishingTracks(e){e&&(this._publishingTracks=e.map(({msid:t,from:i,ssrc:s,codec:a,type:c,trackId:o})=>({msid:t,from:i,type:c,ssrc:`${s}`,codec:a!=null?a:"",trackId:o})))}httpPublish(a,c){return w(this,arguments,function*(e,t,i=!1,s=ct.MANUAL){var b,E;let o;const u=Date.now(),{publishStream:h,videoSmallStream:p,screenStream:d,vMsid:f}=yield this.localStreamManager.createHTTPPublishStream();if(!h)return O.warn(`[${Ce.logName}]`,"publishStream is null"),{traceId:"",l1ip:o};const m=this.getPubMsid(h,{vMsid:f});this.encodedInsertableStreams&&(m.encodedInsertableStreams=!0),m.answerSdpHook=A=>{const y=/\d+\.\d+\.\d+\.\d+(?=\s+1106|\s+8000)/.exec(A);return y!=null&&y[0]&&(o=y[0]),A},(E=(b=this.parameter)==null?void 0:b.net)!=null&&E.useTCP&&(m.tcpOnly=!0),m.retryTimes=un,m.retryInterval=hn,this._rtsPeerConnectionType="publish";let l=!h.hasVideo,S=f,v="";this.startConnect();const x=Date.now();try{v=yield this.rts.publish(tn(e),h,m)}catch(A){this.setConnected(!1);const y=2e3-(Date.now()-x);throw y<=0?this.emit("disconnected"):setTimeout(()=>{this.emit("disconnected")},y),this.slsReporter.reportPublish(i,e,t,h.hasVideo&&(!f||f===D.VideoLarge),h.hasVideo&&f===D.VideoSmall,h.hasVideo&&f===D.Screen,h.hasAudio,(A==null?void 0:A.errorCode)||-1,this.pcTraceId,"",x),V.fromRtsError(A)}O.event(`[${Ce.logName}]`,"rts publish success",v),this.slsReporter.reportPublish(i,e,t,h.hasVideo&&(!f||f===D.VideoLarge),h.hasVideo&&f===D.VideoSmall,h.hasVideo&&f===D.Screen,h.hasAudio,0,v,v,x),this.slsReporter.reportConnectionLatencyEvent(Ke.HANDLE_PUB_TASK,Ze.START,t,v,u),this.slsReporter.reportConnectionLatencyEvent(Ke.HANDLE_PUB_TASK,Ze.END,t,v,Date.now());try{const A=Date.now();return this._pcTraceId=v,this.setConnected(!0),this._publishingTracks=this.rts.getPublishTrackInfoList(),p&&(yield this.publishAdd(e,p,t,{vMsid:D.VideoSmall},i),l=!1,S=D.VideoSmall),d&&(yield this.publishAdd(e,d,t,{vMsid:D.Screen},i),l=!1,S=D.Screen),yield this.waitPublishSender(e,l,S),this.slsReporter.reportPublishFirstPacket(i,t,x,A,this._localJoinTime,l?D.Audio:m.vMsid,v||"",v||"",s),{traceId:v,l1ip:o}}catch(A){throw this.setConnected(!1),V.fromError(A)}})}waitPublishSender(e,t=!1,i){return w(this,null,function*(){const s=(a,c)=>{let o=0;const u=()=>(t?this.rts.getPublishAudioStats(e,i):this.rts.getPublishVideoStats(e,i)).then(p=>!(p.bytesSent>0)&&o<a?(o++,new Promise(f=>setTimeout(()=>f(u()),c))):Promise.resolve());return u()};return Promise.race([_t(1e3),s(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(u,h,p,d){return w(this,arguments,function*(e,t,i,s,a=!1,c=!1,o=ct.MANUAL){var l,S,v,x,b,E,A,y;yield this.dcConnectingPromise;const f=Date.now(),m=this.getPubMsid(t,s);try{const _=yield en(R=>w(this,null,function*(){return R>0&&O.event(`[${Ce.logName}]`,`publishAdd retry times: ${R}`),this.isConnected?(yield this.dcConnectingPromise,this.rts.publishAdd([X({url:e,stream:t,updateSourceStream:!1},m)])):Promise.reject(new V(U.ERR_INNER,"rts not connected"))}),cn,0,R=>(R==null?void 0:R.errorCode)===15006);if(_){const R=Date.now(),[L]=_;return this.slsReporter.reportPublish(!1,e,i,((l=m.vMsid)==null?void 0:l[0])===D.VideoLarge,((S=m.vMsid)==null?void 0:S[0])===D.VideoSmall,((v=m.vMsid)==null?void 0:v[0])===D.Screen,((x=m.aMsid)==null?void 0:x[0])===D.Audio,0,this.pcTraceId,L.traceId||"",f),this.updatePublishingTracks(L.trackInfoList),c&&(yield this.waitPublishSender(e,!t.hasVideo,t.hasVideo?s==null?void 0:s.vMsid:s==null?void 0:s.aMsid)),this.slsReporter.reportPublishFirstPacket(a,i,f,R,this._localJoinTime,(t.hasVideo?s==null?void 0:s.vMsid:s==null?void 0:s.aMsid)||"",this.pcTraceId,L.traceId||"",o),L.traceId||""}}catch(_){throw this.slsReporter.reportPublish(!1,e,i,((b=m.vMsid)==null?void 0:b[0])===D.VideoLarge,((E=m.vMsid)==null?void 0:E[0])===D.VideoSmall,((A=m.vMsid)==null?void 0:A[0])===D.Screen,((y=m.aMsid)==null?void 0:y[0])===D.Audio,(_==null?void 0:_.errorCode)||-1,this.pcTraceId,"",f),_!=null&&_.errorCode?V.fromRtsError(_):V.fromError(_)}return""})}publishDelete(e,t){return w(this,null,function*(){var u,h,p,d,f,m,l,S;yield this.dcConnectingPromise;const i=(h=(u=this.publishingTracks)==null?void 0:u.find(({msid:v})=>v===D.Audio))==null?void 0:h.msid,s=(d=(p=this.publishingTracks)==null?void 0:p.find(({msid:v})=>v===D.VideoLarge))==null?void 0:d.msid,a=(m=(f=this.publishingTracks)==null?void 0:f.find(({msid:v})=>v===D.Screen))==null?void 0:m.msid,c=[];t.screen&&a?c.push(a):t.video&&c.push(t.vMsid||s);const o=[];t.audio&&i&&o.push(i),O.event(Ce.logName,"publishDelete",{streamUrl:e,aMsid:o,vMsid:c});try{const[v]=(yield this.rts.publishDeleteTracks([{url:e,aMsid:o,vMsid:c}]))||[];return O.event(Ce.logName,"publishDelete",{result:v}),v&&this.updatePublishingTracks(v.trackInfoList),((S=(l=v==null?void 0:v.trackInfoList)==null?void 0:l[0])==null?void 0:S.trackId)||""}catch(v){throw V.fromRtsError(v)}})}publishReplace(e,t,i){return w(this,null,function*(){var c,o;yield this.dcConnectingPromise;const{vMsid:s,aMsid:a}=i!=null?i:{};try{const u=yield this.rts.publishReplaceTracks([{url:e,stream:t,updateSourceStream:!1,vMsid:s,aMsid:a}]),[h]=u;return this.updatePublishingTracks(h.trackInfoList),((o=(c=h==null?void 0:h.trackInfoList)==null?void 0:c[0])==null?void 0:o.trackId)||""}catch(u){throw V.fromRtsError(u)}})}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:e,label:D.Data,msid:D.Data}),i=t==null?void 0:t.datachannel;if(i&&i.send){const s=new ArrayBuffer(4);new DataView(s).setUint8(0,240),i.datachannel.send(s)}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.connecting=!1,this.connected=!1})}getSubConfig(e,t){let i=t!=null?t:{};t||(i={audio:!0,video:!0,screen:!0});const s={};return i.audio&&(s.aMsid=[(e==null?void 0:e.getAudioInfo().msid)||D.Audio]),i.video?i.vMsid?s.vMsid=[i.vMsid]:e!=null&&e.hasVideoLarge?s.vMsid=[(e==null?void 0:e.getVideoLargeInfo().msid)||D.VideoLarge]:e!=null&&e.hasVideoSmall?s.vMsid=[(e==null?void 0:e.getVideoSmallInfo().msid)||D.VideoSmall]:s.vMsid=[D.VideoLarge]:i.screen&&(s.vMsid=[(e==null?void 0:e.getScreenInfo().msid)||D.Screen]),s}httpSubscribe(e){return w(this,null,function*(){var c,o,u,h,p,d;const{remoteUser:t,options:i}=e;let s=t.streamUrl;i.video||i.screen?i!=null&&i.audio||(s+="@subaudio=no"):s+="@subvideo=no";const a=this.getSubConfig(t.streamInfo,i);if(this.encodedInsertableStreams&&(a.encodedInsertableStreams=!0),(o=(c=this.parameter)==null?void 0:c.net)!=null&&o.useTCP&&(a.tcpOnly=!0),(h=(u=this.parameter)==null?void 0:u.net)!=null&&h.mediaTimeout){const f=(d=(p=this.parameter)==null?void 0:p.net)==null?void 0:d.mediaTimeout;f>1e3&&f<1e5&&(a.mediaTimeout=f)}a.retryTimes=un,a.retryInterval=hn,this._rtsPeerConnectionType="subscribe";try{this.startConnect();const f=yield this.rts.subscribe(tn(s),a);return this._pcTraceId=f.traceId,this.setConnected(!0),{traceId:f.traceId,stream:f}}catch(f){throw this.setConnected(!1),this.emit("disconnected"),V.fromRtsError(f)}})}subscribeAdd(e){return w(this,null,function*(){var a,c,o,u;const{remoteUser:t,options:i}=e,s=vt(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 en(p=>w(this,null,function*(){return yield this.dcConnectingPromise,p>0&&O.event(`[${Ce.logName}]`,`subscribeAdd retry times: ${p}`),this.isConnected?this.rts.subscribeAdd([s]):Promise.reject()}),cn,0,p=>(p==null?void 0:p.errorCode)===15006))[0]}catch(h){if(((u=(o=(c=(a=h==null?void 0:h.extraInfo)==null?void 0:a.parsedData)==null?void 0:c.streams)==null?void 0:o[0])==null?void 0:u.res_code)===508)return this.emit("subscribeexceeds"),null;throw V.fromRtsError(h)}})}subscribeDelete(e){return w(this,null,function*(){var a,c,o,u;const{remoteUser:t,options:i}=e,s=vt(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([s]))[0]}catch(h){if(((u=(o=(c=(a=h==null?void 0:h.extraInfo)==null?void 0:a.parsedData)==null?void 0:c.streams)==null?void 0:o[0])==null?void 0:u.res_code)===404)return;throw V.fromRtsError(h)}})}subscibeStop(e){return w(this,null,function*(){var t,i,s,a;try{yield this.rts.subscribeStop([{url:e}])}catch(c){if(((a=(s=(i=(t=c==null?void 0:c.extraInfo)==null?void 0:t.parsedData)==null?void 0:i.streams)==null?void 0:s[0])==null?void 0:a.res_code)===404)return;throw V.fromRtsError(c)}})}subscribeAddDataChannel(e){return w(this,null,function*(){yield this.dcConnectingPromise;const t=yield this.rts.subscribeAddDatachannel({signalUrl:e,url:e,label:D.Data,msid:D.Data}),i=t==null?void 0:t.datachannel;if(i&&i.send){const s=new ArrayBuffer(4);new DataView(s).setUint8(0,240),i.send(s)}return i})}subscribeStopDatachannel(e,t){return w(this,null,function*(){let i;try{i=yield this.rts.subscribeStopDatachannel({url:e,datachannel:t})}catch(s){}return t==null||t.dispose(),i})}publish(a,c){return w(this,arguments,function*(e,t,i=!1,s=ct.MANUAL){let o="",u;if(this.connecting&&(yield this.connectingPromise),this.connected){yield this.dcConnectingPromise;let h=!1,p;const{audio:d,video:f,videoSmall:m,screen:l}=this.localStreamManager.publishStreams;d&&(o=yield this.publishAdd(e,d,t,{aMsid:D.Audio},i),h=!0,p=D.Audio,yield _t(100)),f&&(o=yield this.publishAdd(e,f,t,{vMsid:D.VideoLarge},i),h=!1,p=D.VideoLarge,yield _t(100)),m&&(o=yield this.publishAdd(e,m,t,{vMsid:D.VideoSmall},i),h=!1,p=D.VideoSmall,yield _t(100)),l&&(o=yield this.publishAdd(e,l,t,{isScreen:!0,vMsid:D.Screen},i),h=!1,p=D.Screen),p&&(yield this.waitPublishSender(e,h,p))}else{const h=yield this.httpPublish(e,t,i,s);o=h.traceId,u=h.l1ip}return{traceId:o,l1ip:u}})}reportSubscribeLatency(e,t,i,s){const a=[];e.audio&&a.push(e.aMsid||D.Audio),e.video?a.push(e.vMsid||D.VideoLarge):e.screen&&a.push(D.Screen),a.forEach(c=>{this.slsReporter.reportConnectionLatencyEvent(Ke.HANDLE_SUB_TASK,Ze.START,t,c,i,0,s),this.slsReporter.reportConnectionLatencyEvent(Ke.HANDLE_SUB_TASK,Ze.END,t,c,Date.now(),0,s)})}subscribe(e,t,i,s,a){return w(this,null,function*(){let c=!1;const{options:o,remoteUser:u}=e;if(o.video&&o.screen)throw new V(U.ERR_INNER,"subscribe error, video and screen cannot be subscribed at the same time");this.connecting&&(yield this.connectingPromise);let h,p=Date.now();this.connected?h=yield this.subscribeAdd(e):(c=!0,h=yield this.httpSubscribe(e)),this.reportSubscribeLatency(o,i,p,c);const d=Date.now();let f=D.VideoLarge,m=o.video||o.screen,l=o.audio;o.video&&o.vMsid?f=o.vMsid:o.screen&&(f=D.Screen);let S=0,v=0,x=0;const E=((A,y)=>{let _=0;const R=()=>{let L;return l&&!S&&(L=this.rts.getSubscribeAudioStats(u.streamUrl).then(C=>{if(C.packetsReceived>0)S=Date.now();else if(!m)return _<A?(_++,new Promise(I=>setTimeout(()=>I(R()),y))):!1;return!0})),m&&!x&&(L=this.rts.getSubscribeVideoStats(u.streamUrl,f).then(C=>{if(C.packetsReceived>0&&(v=Date.now()),C.framesDecoded>0)x=Date.now();else return _<A?(_++,new Promise(I=>setTimeout(()=>I(R()),y))):(O.event(`[${Ce.logName}]`,u.userId,"尝试获取首帧数据失败"),!1);return!0})),Promise.resolve(L)};return R()})(40,100);return E.then(()=>{v&&this.slsReporter.reportSubscribeFirstPacket(t===pe.Resume,i,s,f,{fprt:v-p,ifsprtc:x?x-p:0,ajsub:t===pe.Join?1:0,pctid:this.pcTraceId,subtid:(h==null?void 0:h.traceId)||"",sstc:d-p}),x&&this.slsReporter.reportSubscribeFirstFrame(t===pe.Resume,i,s,f,{fvfrt:x-p,fp2fftc:x-v,ajsub:t===pe.Join?1:0,tffrtc:t===pe.Join?x-this.localJoinTime:x-a,pctid:this.pcTraceId,subtid:(h==null?void 0:h.traceId)||"",fvfdtc:x-p}),S&&(this.slsReporter.reportConnectionLatencyEvent(Ke.FIRST_REMOTE,Ze.DECODED,i,D.Audio,S),this.slsReporter.reportSubscribeFirstPacket(t===pe.Resume,i,s,D.Audio,{fprt:S-p,ifsprtc:S-p,ajsub:t===pe.Join?1:0,pctid:this.pcTraceId,subtid:(h==null?void 0:h.traceId)||"",sstc:d-p}))}),c&&(yield Promise.race([E,_t(1500)])),h})}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,s){return w(this,null,function*(){return this.rts.sendSEI({url:e,vMsid:D.VideoLarge,data:t,repeatCount:i,payloadType:s})})}},g(Ce,"logName","RtsManager"),Ce);_e([T(H)],be.prototype,"startConnect",1),_e([T()],be.prototype,"updatePublishingTracks",1),_e([T(H,H)],be.prototype,"httpPublish",1),_e([T(H,H)],be.prototype,"waitPublishSender",1),_e([T(([r,n,e])=>[r,JSON.stringify(e)],H)],be.prototype,"publishAdd",1),_e([T(H,H)],be.prototype,"publishDelete",1),_e([T(([r,n,e])=>[r,JSON.stringify(e)])],be.prototype,"publishReplace",1),_e([T(H)],be.prototype,"publishStop",1),_e([T(H)],be.prototype,"publishAddDataChannel",1),_e([T(H)],be.prototype,"publishStopDataChannel",1),_e([T()],be.prototype,"unpublish",1),_e([T(Fi,({traceId:r})=>r)],be.prototype,"httpSubscribe",1),_e([T(Fi,({traceId:r})=>r)],be.prototype,"subscribeAdd",1),_e([T(Fi)],be.prototype,"subscribeDelete",1),_e([T(H)],be.prototype,"subscibeStop",1),_e([T(H)],be.prototype,"subscribeAddDataChannel",1),_e([T(H)],be.prototype,"subscribeStopDatachannel",1),_e([T(H)],be.prototype,"publish",1),_e([T(Fi)],be.prototype,"subscribe",1),_e([T()],be.prototype,"sendSEI",1);let nc=be;class us{constructor(n=as){g(this,"defaultProfile");g(this,"profile");g(this,"profileMap",new Map);g(this,"audioProfile");g(this,"contentHint");this.defaultProfile=X({},n)}updateProfile(n,e){e&&this.profileMap.set(n,X(X(X({},this.defaultProfile),this.profileMap.get(n)||{}),e)),this.profile=n}get videoProfile(){return this.profile}updateAudioProfile(n){this.audioProfile=n}setContentHint(n,e){e&&(this.contentHint=e),this.contentHint&&n&&(n.contentHint=this.contentHint)}setVideoProfile(n,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&&n&&n.readyState==="live"&&n.applyConstraints)try{yield n.applyConstraints(i)}catch(s){}if(e){const s=X({},i);i.maxSendFrameRate&&(s.frameRate=i.maxSendFrameRate),e==null||e.VideoProfileMap.set(this.profile,s),yield e.setVideoProfile(this.profile)}}})}}class hs extends re{constructor(e){super();g(this,"type");g(this,"originVideoTrack");g(this,"videoSource");g(this,"_videoMuted",!1);g(this,"originAudioTrack");g(this,"audioSource");g(this,"_audioMuted",!1);g(this,"_targetVideoTrack");g(this,"_targetDualVideoTrack");g(this,"_targetAudioTrack");g(this,"_publishVideoStream");g(this,"_publishDualVideoStream");g(this,"_publishAudioStream");g(this,"_previewStream");g(this,"plugins",[]);g(this,"_profileManager");g(this,"cameraVideoConstraints");g(this,"micAudioConstraints");g(this,"onVideoTrackEnded",()=>{this.emit("videotrackended")});g(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,o,u,h,p,d;const{videoTrack:s,audioTrack:a}=e;s&&((c=this.originVideoTrack)==null||c.removeEventListener("ended",this.onVideoTrackEnded)),a&&((o=this.originAudioTrack)==null||o.removeEventListener("ended",this.onAudioTrackEnded)),this.type===ve.AliRtcSdkStreamTypeScreen?this.stop():(s&&((u=this.originVideoTrack)==null||u.stop()),a&&((h=this.originAudioTrack)==null||h.stop())),s&&(this.originVideoTrack=s,(p=this.originVideoTrack)==null||p.addEventListener("ended",this.onVideoTrackEnded),this.videoSource=t||Gt.Camera,this.updateVideoTrack(s)),a&&(this.originAudioTrack=a,(d=this.originAudioTrack)==null||d.addEventListener("ended",this.onAudioTrackEnded),this.audioSource=i||bi.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,s,a,c,o,u,h,p,d,f,m;this._targetAudioTrack=this.originAudioTrack,this._targetVideoTrack=this.originVideoTrack;for(const l of this.plugins)try{yield l.execute(this,e)}catch(S){console.error(`error in plugin-${l.name}, error: ${S}`)}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),(s=this.profileManager)==null||s.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,(o=this.previewStream)==null||o.deleteTracks({video:!0})),this._targetDualVideoTrack?((h=(u=this._publishDualVideoStream)==null?void 0:u.videoTrack)==null?void 0:h.id)!==this._targetDualVideoTrack.id&&(this._publishDualVideoStream=yield pi(this._targetDualVideoTrack),this._videoMuted?this._publishDualVideoStream.disableVideo():this._publishDualVideoStream.enableVideo()):this._publishDualVideoStream=void 0,this._targetAudioTrack?((d=(p=this._publishAudioStream)==null?void 0:p.audioTrack)==null?void 0:d.id)!==this._targetAudioTrack.id&&(this._publishAudioStream=yield pi(this._targetAudioTrack),this.setAudioMuted(this._audioMuted),this.previewStream?(f=this.previewStream)==null||f.mergeStream(this._publishAudioStream):this._previewStream=yield pi(this._targetAudioTrack)):(this._publishAudioStream=void 0,(m=this.previewStream)==null||m.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){return w(this,null,function*(){this._profileManager||(this._profileManager=new us(this.type===ve.AliRtcSdkStreamTypeScreen?Za:as)),e&&this._profileManager.updateProfile(e,t),yield this._profileManager.setVideoProfile(this.originVideoTrack,this._publishVideoStream,this.type===ve.AliRtcSdkStreamTypeScreen)})}get videoProfile(){var e;return(e=this.profileManager)==null?void 0:e.videoProfile}setVideoContentHint(e){this._profileManager||(this._profileManager=new us(this.type===ve.AliRtcSdkStreamTypeScreen?Za:as)),this._profileManager.setContentHint(this.currentVideoTrack,e)}updateAudioProfile(e){return w(this,null,function*(){this._profileManager||(this._profileManager=new us),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):!1}}var oc=Object.defineProperty,cc=Object.getOwnPropertyDescriptor,rt=(r,n,e,t)=>{for(var i=t>1?void 0:t?cc(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&oc(n,e,i),i};const Qe=(Rt=class extends re{constructor(e,t){super();g(this,"pluginManager");g(this,"slsReporter");g(this,"publishingCameraVideoStream");g(this,"publishingScreenVideoStream");g(this,"cameraStreamInfo",new hs(ve.AliRtcSdkStreamTypeCapture));g(this,"screenStreamInfo",new hs(ve.AliRtcSdkStreamTypeScreen));g(this,"streamInfos",[this.cameraStreamInfo,this.screenStreamInfo]);g(this,"_audioCaptureDisabled",!1);g(this,"_cameraCaptureDisabled",!1);g(this,"_publishLocalAudioStreamEnabled",!0);g(this,"_publishLocalVideoStreamEnabled",!0);g(this,"_publishLocalScreenStreamEnabled",!0);this.screenStreamInfo.setVideoContentHint("motion"),this.pluginManager=e,this.slsReporter=t;const i=s=>w(this,null,function*(){if(O.info(`[${Rt.logName}]`,"plugin added",s.name),!s.isSupported("6.14.4")){console.warn(`${s.name} is not supported!!!`),s.emit("unsupported");return}try{yield s.init()}catch(a){s.emit("error",V.fromError(a,Ct.AliRtcPluginErrorInitError))}s.streamType===ve.AliRtcSdkStreamTypeCapture&&(this.cameraStreamInfo.addPlugin(s),yield this.cameraStreamInfo.process(this.streamInfos)),s.streamType===ve.AliRtcSdkStreamTypeScreen&&(this.screenStreamInfo.addPlugin(s),yield this.screenStreamInfo.process(this.streamInfos)),this.emit("publishupdate")});this.cameraStreamInfo.on("videotrackended",()=>w(this,null,function*(){yield this.stopLocalStream({video:!0}),this.emit("trackended",Vt.VideoTrackEnded)})),this.cameraStreamInfo.on("audiotrackended",()=>w(this,null,function*(){yield this.stopLocalStream({audio:!0}),this.emit("trackended",Vt.AudioTrackEnded)})),this.screenStreamInfo.on("videotrackended",()=>w(this,null,function*(){yield this.stopLocalStream({screen:!0}),this.emit("trackended",Vt.ScreenTrackEnded)})),this.pluginManager.on("added",i),this.pluginManager.on("removed",s=>w(this,null,function*(){this.cameraStreamInfo.removePlugin(s)&&(yield this.cameraStreamInfo.process(this.streamInfos)),this.screenStreamInfo.removePlugin(s)&&(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,s;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(o=>o.deviceId===a)||(a=(s=(i=c.find(o=>!!o.deviceId))==null?void 0:i.deviceId)!=null?s:""),this.cameraStreamInfo.cameraVideoConstraints.deviceId=a}})}setAvailableMicrophoneDeviceId(){return w(this,null,function*(){var e,t,i,s;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(o=>o.deviceId===a)||(a=(s=(i=c.find(o=>!!o.deviceId))==null?void 0:i.deviceId)!=null?s:""),this.cameraStreamInfo.micAudioConstraints.deviceId=a}})}createLocalStream(e){return w(this,null,function*(){var p;const{screen:t,mediaStream:i,videoProfile:s,screenProfile:a}=e;let{video:c,audio:o}=e;const u=W0(e);let h;if(u){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 d=Date.now();try{h=yield G.AliRTS.createStream({audio:o,video:c,screen:t,custom:!!i,mediaStream:i,skipProfile:!0}),O.info(`[${Rt.logName}]`,"createLocalStream",{audio:o,video:c,screen:t,custom:!!i,time:Date.now()-d}),o&&!i&&this.slsReporter.reportAudio(null,Date.now()-d,((p=h==null?void 0:h.audioTrack)==null?void 0:p.label)||""),t&&!i&&this.slsReporter.reportScreen(null,Date.now()-d)}catch(f){throw o&&!i&&this.slsReporter.reportAudio(f,Date.now()-d,""),t&&!i&&this.slsReporter.reportScreen(null,Date.now()-d),f}if(t)yield this.screenStreamInfo.updateSource(h,Gt.Screen,bi.Screen),yield this.setScreenProfile(a),this.setScreenContentHint(),this.publishingScreenVideoStream=void 0;else if(yield this.cameraStreamInfo.updateSource(h,Gt.Camera,bi.Microphone),h.hasVideo&&(yield this.setVideoProfile(s),this.setVideoContentHint(),this.publishingCameraVideoStream=void 0),h.hasAudio&&typeof o=="boolean"){const f=this.cameraStreamInfo.audioProfile;f&&(yield h.setAudioProfile(f))}}return G.AliRTS.SystenUtil.isIos&&G.AliRTS.SystenUtil.compareVersion("15.1")&&!G.AliRTS.SystenUtil.compareVersion("15.2")&&(yield _t(1e3)),yield this.updateStreams(),h})}stopLocalStream(e){return w(this,null,function*(){const{screen:t,video:i,audio:s}=e!=null?e:{};let a=!1;i&&this.cameraStreamInfo.originVideoTrack&&(a=!0,this.cameraStreamInfo.stopVideo(),this.publishingCameraVideoStream=void 0),s&&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 o,u,h,p;let e,t=!1,i,s,a;const c=this.publishStreams;try{if(!c.audio&&!c.video&&!c.videoSmall&&!c.screen)throw O.error(`[${Rt.logName}]`,"no tracks founded"),new V(U.ERR_SDK_PUBLISH_INVAILD,"no tracks founded");const d=new MediaStream;(o=c.audio)!=null&&o.audioTrack&&d.addTrack(c.audio.audioTrack),(u=c.video)!=null&&u.videoTrack?(d.addTrack(c.video.videoTrack),s=c.videoSmall,a=c.screen):(h=c.screen)!=null&&h.videoTrack&&(i=D.Screen,d.addTrack((p=c.screen)==null?void 0:p.videoTrack),t=!0),e=yield nn(d),t?(this.screenStreamInfo.cloneVideoProfile(e),this.publishingScreenVideoStream=e):(this.cameraStreamInfo.cloneVideoProfile(e),this.publishingCameraVideoStream=e)}catch(d){}return{publishStream:e,videoSmallStream:s,screenStream:a,vMsid:i}})}stop(){this.cameraStreamInfo.stop(),this.screenStreamInfo.stop(),this.updateStreams()}setVideoProfile(e,t){return w(this,null,function*(){yield this.cameraStreamInfo.updateVideoProfile(e,t),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=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)}},g(Rt,"logName","LocalStreamManager"),Rt);rt([T(([r])=>{const{audio:n,video:e,screen:t,custom:i,skipProfile:s,videoProfile:a,screenProfile:c}=r;return[{audio:n,video:e,screen:t,custom:i,skipProfile:s,videoProfile:a,screenProfile:c}]})],Qe.prototype,"createLocalStream",1),rt([T(H)],Qe.prototype,"stopLocalStream",1),rt([T()],Qe.prototype,"createHTTPPublishStream",1),rt([T()],Qe.prototype,"stop",1),rt([T(H)],Qe.prototype,"setVideoProfile",1),rt([T(H)],Qe.prototype,"setVideoContentHint",1),rt([T(H)],Qe.prototype,"setAudioProfile",1),rt([T(H)],Qe.prototype,"setScreenProfile",1),rt([T(H)],Qe.prototype,"setScreenContentHint",1),rt([T(H)],Qe.prototype,"setCameraVideoConstraints",1),rt([T(H)],Qe.prototype,"setMicAudioConstraints",1);let uc=Qe;class hc extends Bt{constructor(){super("AliRtcScreenStandardize",ve.AliRtcSdkStreamTypeScreen);g(this,"canvas");g(this,"lastWidth");g(this,"lastHeight");g(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,s=Math.ceil(t/this.options.base)*this.options.base;if(this.canvas||(this.canvas=document.createElement("canvas")),this.canvas.width=i,this.canvas.height=s,this.lastWidth&&e>this.lastWidth||this.lastHeight&&t>this.lastHeight){const a=this.canvas.getContext("2d");a&&a.clearRect(0,0,i,s)}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:s}=e;if(!i||!s||i%this.options.base===0&&s%this.options.base===0)return this.clear(t),e;this.updateProcessCanvas(i,s);const a=(c=this.canvas)==null?void 0:c.getContext("2d");if(this.canvas&&a){a.drawImage(e,0,0,i,s);const o=new VideoFrame(this.canvas,{timestamp:e.timestamp});return e.close(),o}return e})}process(e){return w(this,null,function*(){var h;if(!e.originVideoTrack||e.videoSource!==Gt.Screen){this.clear(e),this.hasScreenTrack=!1;return}const t=new MediaStreamTrackProcessor({track:e.originVideoTrack}),i=new MediaStreamTrackGenerator({kind:"video"}),s=new MediaStream([i]),a=this,c=new TransformStream({transform(p,d){return w(this,null,function*(){const f=yield a.handleFrame(p,e);yield d.enqueue(f),f==null||f.close()})}});t.readable.pipeThrough(c).pipeTo(i.writable);const o=(h=s.getVideoTracks())==null?void 0:h[0];e.updateVideoTrack(o),this.hasScreenTrack=!0})}clear(e){this.canvas=void 0,this.lastWidth=void 0,this.lastHeight=void 0,super.clear(e)}}class dc extends Bt{constructor(){super("blankAudio",ve.AliRtcSdkStreamTypeCapture,ai.BOTH);g(this,"hasTrack",!1);g(this,"oscillator",null);g(this,"audioTrack",null);g(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 s=i.stream;return this.audioTrack=s.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 s;const i=t.some(a=>a.originVideoTrack||a.originAudioTrack);this.hasTrack=i,i?this.audioTrack&&((s=this.oscillator)==null||s.stop(),this.oscillator=null,this.audioTrack.stop(),this.audioTrack=null):(this.audioTrack||(this.audioTrack=this.createAudioTrack()),e.updateAudioTrack(this.audioTrack))})}}class dn{constructor(n){g(this,"name","COMMON");this.name=n||this.name}info(...n){}warn(...n){}print(n,...e){const t=n.toLowerCase();t&&console[t](`[${n}][${this.name}]`,...e)}}g(dn,"LEVEL",0);class lc{constructor(){g(this,"logger",new dn("AudioMixer"));g(this,"audioContext",new AudioContext);g(this,"audioDestination",this.audioContext.createMediaStreamDestination());g(this,"audioTrack",F0(this.audioDestination.stream));g(this,"sourceNodeMap",{})}get sourceNodeList(){return Object.values(this.sourceNodeMap).map(n=>n.sourceNode).filter(n=>!!n)}get gainNodeList(){return Object.values(this.sourceNodeMap).map(n=>n.gainNode).filter(n=>!!n)}get sourceCount(){return this.sourceNodeList.length}resume(){var n;return(n=this.audioContext)==null?void 0:n.resume()}addTrack(n){this.connectTrack(n)}hasTrack(n){return!!this.sourceNodeMap[n]}removeTrack(n){const{sourceNode:e,gainNode:t}=this.sourceNodeMap[n]||{};t==null||t.disconnect(),e==null||e.disconnect(),delete this.sourceNodeMap[n],e?this.logger.info("SourceNode disconnected. Active source node:",this.sourceNodeList.length):this.logger.warn(`SourceNode ${n} does not exit. Active source node: ${this.sourceNodeList.length}`)}getAudioTrack(){return this.audioTrack}setVolume(n,e){const{gainNode:t}=this.sourceNodeMap[e]||{};t?(this.logger.info(`Setting node(${e}) volume to ${this.scale(n)}`),t.gain.value=this.scale(n)):this.logger.warn(`GainNode ${e} does not exit.`)}reset(){this.disconnectSourceNode(),this.sourceNodeMap={}}dispose(){var n;this.reset(),(n=this.audioTrack)==null||n.stop(),this.audioDestination.disconnect(),this.audioContext.close()}connectTrack(n){if(!this.audioContext)return this.logger.warn("AudioContext not initialized");let e=new MediaStream;e.addTrack(n);const t=this.audioContext.createMediaStreamSource(e),i=this.audioContext.createGain();i.gain.value=1,t.connect(i),i.connect(this.audioDestination),this.sourceNodeMap[n.id]={track:n,sourceNode:t,gainNode:i},this.logger.info("New sourceNode connected. Active source node:",this.sourceNodeList.length)}disconnectSourceNode(){this.sourceNodeList.forEach(n=>n.disconnect()),this.gainNodeList.forEach(n=>n.disconnect())}scale(n){return n/100}}const fc=4;class pc extends Bt{constructor(){super("audioMixer",ve.AliRtcSdkStreamTypeCapture,ai.AUDIO);g(this,"audioMixer");g(this,"primaryAudioTrackId");g(this,"screenAudioTrackId");g(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(o=>o.type===ve.AliRtcSdkStreamTypeCapture),s=t.find(o=>o.type===ve.AliRtcSdkStreamTypeScreen);return!(this.primaryAudioTrackId===((a=i==null?void 0:i.currentAudioTrack)==null?void 0:a.id)&&this.screenAudioTrackId===((c=s==null?void 0:s.currentAudioTrack)==null?void 0:c.id)&&!this.dirty)}process(e,t){return w(this,null,function*(){var c,o;this.dirty=!1;const i=t.find(u=>u.type===ve.AliRtcSdkStreamTypeScreen),s=e.currentAudioTrack,a=i==null?void 0:i.currentAudioTrack;if(!a&&this.options.audio===1){this.audioMixer&&(this.audioMixer.dispose(),this.audioMixer=void 0),this.primaryAudioTrackId=s==null?void 0:s.id,e.updateAudioTrack(s);return}this.audioMixer||(this.audioMixer=new lc),yield this.audioMixer.resume(),this.primaryAudioTrackId&&(s==null?void 0:s.id)!==this.primaryAudioTrackId&&((c=this.audioMixer)==null||c.removeTrack(this.primaryAudioTrackId)),s&&!this.audioMixer.hasTrack(s==null?void 0:s.id)&&this.audioMixer.addTrack(s),this.primaryAudioTrackId=s==null?void 0:s.id,this.screenAudioTrackId&&(a==null?void 0:a.id)!==this.screenAudioTrackId&&((o=this.audioMixer)==null||o.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<=fc}updateVolume(){this.audioMixer&&(this.primaryAudioTrackId&&this.audioMixer.setVolume(this.options.audio*100,this.primaryAudioTrackId),this.screenAudioTrackId&&this.audioMixer.setVolume(this.options.screen*100,this.screenAudioTrackId))}clear(e){var t;(t=this.audioMixer)==null||t.dispose(),super.clear(e)}}class ds{constructor(n,e){g(this,"originTrack");g(this,"originVideo");g(this,"targetWidth");g(this,"targetHeight");g(this,"targetFrameRate");g(this,"targetCanvas");g(this,"animationFrameId");g(this,"resultTrack");this.targetWidth=e.width,this.targetHeight=e.height,this.targetFrameRate=e.frameRate,this.originTrack=n,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(n){this.targetWidth=n.width,this.targetHeight=n.height,this.targetFrameRate=n.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(n,e,t,i){const s=e/n,a=i/t;let c=t,o=i,u=0,h=0;return a>s?(c=Math.round(o/s),u=Math.round((t-c)/2)):a<s&&(o=Math.round(c*s),h=Math.round((i-o)/2)),{x:u,y:h,width:c,height:o}}}class gc extends ds{constructor(e,t){super(e,t);g(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}}const mc=`
|
|
28
28
|
attribute vec2 a_position;
|
|
29
29
|
attribute vec2 a_texCoord;
|
|
30
30
|
|
|
@@ -139,4 +139,4 @@ onmessage = function(evt) {
|
|
|
139
139
|
break;
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
`;class pn extends ds{constructor(e,t){super(e,t);g(this,"processor");g(this,"trackGenerator");g(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([Ac],{type:"text/javascript"}),i=(window.URL||window.webkitURL).createObjectURL(e);this.worker=new Worker(i);const{readable:s}=this.processor,{writable:a}=this.trackGenerator;this.worker.postMessage({type:"startRender",readable:s,writable:a,width:this.targetWidth,height:this.targetHeight,frameRate:this.targetFrameRate},[s,a])}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 ls{static isSupport(){return typeof HTMLCanvasElement.prototype.captureStream=="function"}static getInstance(n,e){return pn.isSupport()?new pn(n,e):fn.isSupport()?new fn(n,e):new gc(n,e)}}class _c extends Bt{constructor(){super(...arguments);g(this,"hasVideoTrack",!1);g(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 ls.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=ls.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 yc=Object.defineProperty,Cc=Object.getOwnPropertyDescriptor,je=(r,n,e,t)=>{for(var i=t>1?void 0:t?Cc(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&yc(n,e,i),i};class ke extends re{constructor(e){super();g(this,"self");g(this,"userMap",{});g(this,"usersViewMap",{});g(this,"rtsManager");g(this,"localStreamManager");g(this,"authInfo");g(this,"signalingManager");g(this,"pluginManager");g(this,"audioMixerPlugin");g(this,"dualVideoPlugin");g(this,"blankAudioPlugin");g(this,"slsReporter");g(this,"statsMonitorId");g(this,"autoSubAudio",!0);g(this,"autoSubVideo",!0);g(this,"autoSubScreen",!0);g(this,"wantSubAudio",!0);g(this,"wantSubVideo",!0);g(this,"wantSubScreen",!0);g(this,"defaultStreamType",Ie.AliRtcVideoStreamTypeHigh);g(this,"audioMuted",!1);g(this,"playoutVolume",1);g(this,"refreshUrlTimer");g(this,"audioVolumeIndicationInterval",0);g(this,"indicationTimer",0);g(this,"parameter",{});const{signalingManager:t,slsReporter:i}=e;this.signalingManager=t,this.addSignalingManagerListener(),this.slsReporter=i,this.pluginManager=new rc,this.localStreamManager=new uc(this.pluginManager,this.slsReporter),this.rtsManager=new nc(this.localStreamManager,this.slsReporter,this.parameter),this.self=new j0({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 _c("dualVideoPlugin"),x0()&&this.pluginManager.add(new hc)}addSignalingManagerListener(){this.signalingManager.on("onNotifyPublish",e=>{this.slsReporter.reportConnectionLatencyEvent(Ke.RECV_NOTIFY_PUBLISH,"","",""),O.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(pe.User)})}isWantSubVideo(){return this.wantSubVideo}setWantSubVideo(e){this.wantSubVideo=e,this.remoteUsers.forEach(t=>{t.setWantSubVideo(e),t.updateSubscribe(pe.User)})}isWantSubScreen(){return this.wantSubScreen}setWantSubScreen(e){this.wantSubScreen=e,this.remoteUsers.forEach(t=>{t.setWantSubScreen(e),t.updateSubscribe(pe.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 s;if(!e)return(s=this.publisher)==null?void 0:s.setViewConfig(null,t);const i=ns(e);i.length!==0&&i.forEach(a=>{var c,o;(c=this.publisher)==null||c.resetElement(a),Object.values(this.usersViewMap).forEach(({cameraViews:u=[],screenViews:h=[]})=>{u.includes(a)&&u.splice(u.indexOf(a),1),h.includes(a)&&h.splice(h.indexOf(a),1)}),(o=this.publisher)==null||o.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 s=ns(t);s.length!==0&&(s.forEach(o=>{var u;(u=this.publisher)==null||u.resetElement(o),Object.values(this.usersViewMap).forEach(({cameraViews:h=[],screenViews:p=[]})=>{h.includes(o)&&h.splice(h.indexOf(o),1),p.includes(o)&&p.splice(p.indexOf(o),1)})}),(c=this.userMap[e])==null||c.setViewConfig(s,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:s,isScreenSubscribing:a}=t;return i||s||a})}onRemotePublishStateChange(e){var d;const{userid:t,callid:i,subscribe:s,pubid:a="",tracks:c}=e,o=(d=s==null?void 0:s.pullstreamurl)!=null?d:"";let u=this.getRemoteUser(t);if(!u)return;const h=u.streamInfo.audioTrackInfo,p=u.streamInfo.videoTrackInfo;u.updateRemoteTracks(i,o,a,c),u.updateSubscribe(pe.Publish),(h!==u.streamInfo.audioTrackInfo||p!==u.streamInfo.videoTrackInfo)&&this.emit("remoteTrackAvailableChange",t,u.streamInfo.audioTrackInfo,u.streamInfo.videoTrackInfo)}setTimeoutToUpdateAllStreamUrls(e){var s;if(!e)return;let t=59*60*1e3;const i=(s=O0(e))==null?void 0:s.timeoutTs;i&&(t=i-Date.now()-60*1e3),this.refreshUrlTimer=window.setTimeout(()=>w(this,null,function*(){var c;const a=yield this.signalingManager.refreshUrl({pushstreamurl:this.self.url,users:this.remoteUsers.map(o=>({userid:o.userId,subscribe:{pullstreamurl:o.streamUrl}}))});a.pushstreamurl&&(this.self.url=a.pushstreamurl),(c=a.users)==null||c.forEach(o=>{var h;const u=this.getRemoteUser(o.userid);u&&((h=o.subscribe)!=null&&h.pullstreamurl)&&(u.streamUrl=o.subscribe.pullstreamurl)}),this.setTimeoutToUpdateAllStreamUrls(a.pushstreamurl)}),t)}init(e,t){this.authInfo=e,this.self.enableAudioVolumeIndication(this.audioVolumeIndicationInterval),this.self.initInfo(e,t.pushstreamurl),this.setTimeoutToUpdateAllStreamUrls(t.pushstreamurl),t.users.forEach(i=>{const s=i.userid;if(s){const a=this.addUser(s,i.displayname,pe.InRoom),{callid:c,subscribe:o,tracks:u}=i;a.updateRemoteTracks(c,(o==null?void 0:o.pullstreamurl)||"","",u),this.emit("remoteTrackAvailableChange",s,a.streamInfo.audioTrackInfo,a.streamInfo.videoTrackInfo)}}),this.startStatsMonitor()}leave(){return w(this,null,function*(){this.stopStatsMonitor(),typeof this.refreshUrlTimer!="undefined"&&(window.clearTimeout(this.refreshUrlTimer),this.refreshUrlTimer=void 0),Object.values(this.usersViewMap).forEach(({cameraViews:e=[],screenViews:t=[]})=>{e.forEach(i=>{i.srcObject=null,i._playPromise=void 0}),t.forEach(i=>{i.srcObject=null,i._playPromise=void 0})}),this.usersViewMap={};for(let e in this.userMap)this.userMap[e]&&(this.userMap[e].clear(),delete this.userMap[e]);this.self.leave(),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:s,candidate:a}=yield this.publisher.getStats();i&&i.length>0&&this.emit("rtcLocalAudioStats",i),s&&s.length>0&&this.emit("rtcLocalVideoStats",s),a&&this.emit("rtcStats",a)}const e=[],t=[];for(const i of this.remoteUsers){const{audio:s,video:a}=yield i.getStats();s&&s.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 s=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 s.on(Ne.Remote,this.onRemoteDeviceStatusChange.bind(this)),s.on(he.PullStreamStats,this.onRemoteStatReport.bind(this)),s.on(he.RtsSubscribeExceeds,this.onSubscribeExceeds.bind(this)),s.on("audioSubscribeStateChanged",(a,c,o,u)=>{this.emit("audioSubscribeStateChanged",a,c,o,u,this.channel||"")}),s.on("videoSubscribeStateChanged",(a,c,o,u)=>{this.emit("videoSubscribeStateChanged",a,c,o,u,this.channel||"")}),s.on("screenSubscribeStateChanged",(a,c,o,u)=>{this.emit("screenSubscribeStateChanged",a,c,o,u,this.channel||"")}),s.on("dataSubscribeStateChanged",(a,c,o,u)=>{this.emit("dataSubscribeStateChanged",a,c,o,u,this.channel||"")}),s.on("remoteAudioAutoPlayFail",a=>{this.emit("remoteAudioAutoPlayFail",a)}),s.on("remoteVideoAutoPlayFail",(a,c)=>{this.emit("remoteVideoAutoPlayFail",a,c)}),s.on("remoteAudioPlayError",(a,c)=>{this.emit("remoteAudioPlayError",a,c)}),s.on("remoteVideoPlayError",(a,c)=>{this.emit("remoteVideoPlayError",a,c)}),s.on("remoteSubscribeError",a=>{this.emit("remoteSubscribeError",a,s.userId)}),s.on("occurError",a=>{this.emit("occurError",a,s.userId)}),s.on("remoteDataChannelMessage",(a,c)=>{this.emit("remoteDataChannelMessage",a,c)}),s.setWantSubAudio(this.autoSubAudio&&this.wantSubAudio),s.setWantSubVideo(this.autoSubVideo&&this.wantSubVideo),s.setWantSubScreen(this.autoSubScreen&&this.wantSubScreen),s.setRemoteDefaultVideoStreamType(this.defaultStreamType),s.setAudioMuted(this.audioMuted),(this.autoSubAudio||this.autoSubVideo||this.autoSubScreen)&&s.updateSubscribe(i),s}onRemoteDeviceStatusChange(e,t){e===he.MuteAudio?this.emit("userAudioMuted",t,!0):e===he.UnmuteAudio?this.emit("userAudioMuted",t,!1):e===he.MuteVideo?this.emit("userVideoMuted",t,!0):e===he.UnmuteVideo?this.emit("userVideoMuted",t,!1):e===he.MuteScreen?this.emit("userScreenMuted",t,!0):e===he.UnmuteScreen&&this.emit("userScreenMuted",t,!1)}onRemoteStatReport(e,t,i){this.emit(he.PullStreamStats,e,t,i)}onSubscribeExceeds(e,t){this.emit(he.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=[],s={};e.forEach(o=>{o.userid&&(this.userMap[o.userid]?(i.push(o),s[o.userid]=this.userMap[o.userid]):(t.push(o),s[o.userid]=this.executeAddUser(o.userid,o.displayname,pe.Resume)))});const a=Object.keys(this.userMap),c=[];return a.forEach(o=>{s[o]||c.push({userid:o,reason:"",leavecode:Qr.AliRtcUserOfflineQuit})}),this.userMap=s,{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 V(U.ERR_INNER,`no remote user(${e}) founded`);i.setWantSubAudio(t),t?i.updateSubscribe(pe.User):i.stopSubscribe({audio:!0})}updateVideoWant(e,t){const i=this.userMap[e];if(!i)throw new V(U.ERR_INNER,`no remote user(${e}) founded`);i.setWantSubVideo(t),t?i.updateSubscribe(pe.User):i.stopSubscribe({video:!0})}updateScreenWant(e,t){const i=this.userMap[e];if(!i)throw new V(U.ERR_INNER,`no remote user(${e}) founded`);i.setWantSubScreen(t),t?i.updateSubscribe(pe.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,s,a;const t=JSON.parse(e);Object.keys(t).forEach(c=>{const o=this.parameter[c],u=t[c];typeof o=="object"&&typeof u=="object"?this.parameter[c]=Y(Y({},o),u):this.parameter[c]=u}),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((s=this.blankAudioPlugin)==null?void 0:s.name),(a=this.blankAudioPlugin)==null||a.clear(),this.blankAudioPlugin=void 0)}getParameter(){return JSON.stringify(this.parameter)}sendDataChannelMessage(e){return this.self.sendDataChannelMessage(e)}}g(ke,"logName","BizControl"),je([T()],ke.prototype,"init",1),je([T()],ke.prototype,"leave",1),je([T()],ke.prototype,"clear",1),je([T(H)],ke.prototype,"addUser",1),je([T()],ke.prototype,"removeLeftUser",1),je([T()],ke.prototype,"updateUsers",1),je([T(H)],ke.prototype,"updateAudioWant",1),je([T(H)],ke.prototype,"updateVideoWant",1),je([T(H)],ke.prototype,"updateScreenWant",1),je([T()],ke.prototype,"stopIndication",1),je([T()],ke.prototype,"startIndication",1),je([T(H)],ke.prototype,"setEnableDualVideoStream",1),je([T(H)],ke.prototype,"setAudioVolume",1),je([T()],ke.prototype,"enableAudioVolumeIndication",1);const fs=r=>w(this,null,function*(){const n=new Uint8Array(160).fill(170),e=new TextEncoder().encode(r),t=yield window.crypto.subtle.importKey("raw",n,{name:"HMAC",hash:{name:"SHA-1"}},!1,["sign"]),i=yield window.crypto.subtle.sign("HMAC",t,e);return Array.from(new Uint8Array(i)).map(s=>s.toString(16).padStart(2,"0")).join("")});class Rc{constructor(n){g(this,"authInfo");g(this,"slsReporter");this.slsReporter=n}doRequest(n,e){var u;const t=this.authInfo;if(!t)return Promise.reject(ut.LiveTranscodingErrorInvalidParam);const i="https://gw.rtn.aliyuncs.com",s=b0[n],a={appid:t.appId,userid:t.userId,channelid:t.channelId,timestamp:t.timestamp,token:t.token,nonce:t.nonce?t.nonce:"",requestid:Oe.createCallid(),tokensid:!1,session:(u=t.sessionId)!=null?u:Oe.createCallid()},c=Object.keys(a).map(h=>`${h}=${encodeURIComponent(a[h])}`).join("&"),o=`${i}${s}?${c}`;return fetch(o,{method:"POST",headers:{"Content-Type":"application/json; charset=UTF-8"},body:JSON.stringify(e)}).then(h=>h.status!==200?(this.slsReporter.reportTranscodingError(h.status,e.taskid||""),Promise.reject(new V(U.ERR_INNER,`transcoding request failed, status: ${h.status}`))):h).catch(h=>Promise.reject(new V(U.ERR_INNER,`transcoding request failed, err: ${h.message}`)))}setAuthInfo(n){this.authInfo=n}clear(){this.authInfo=void 0}startPublishLiveStream(n,e){return w(this,null,function*(){if(!this.authInfo)return Promise.reject(ut.LiveTranscodingErrorInvalidParam);const t=yield fs(n.split("?")[0]),i=He.MPU_TASK_TRANSACTION_UPDATE,s=e.toJson(i,this.authInfo,t,n);return this.doRequest(i,s)})}startPublishLiveStreamWithTaskId(n,e){return w(this,null,function*(){if(!this.authInfo)return Promise.reject(ut.LiveTranscodingErrorInvalidParam);const t=He.MPU_TASK_TRANSACTION_UPDATE,i=e.toJson(t,this.authInfo,n);return this.doRequest(t,i)})}updatePublishLiveStream(n,e){return w(this,null,function*(){if(!this.authInfo)return Promise.reject(ut.LiveTranscodingErrorInvalidParam);const t=yield fs(n.split("?")[0]),i=He.MPU_TASK_TRANSACTION_UPDATE,s=e.toJson(i,this.authInfo,t,n);return this.doRequest(i,s)})}updatePublishLiveStreamWithTaskId(n,e){return w(this,null,function*(){if(!this.authInfo)return Promise.reject(ut.LiveTranscodingErrorInvalidParam);const t=He.MPU_TASK_TRANSACTION_UPDATE,i=e.toJson(t,this.authInfo,n);return this.doRequest(t,i)})}stopPublishLiveStream(n){return w(this,null,function*(){if(!this.authInfo)return Promise.reject(ut.LiveTranscodingErrorInvalidParam);const e=yield fs(n.split("?")[0]),t=He.MPU_TASK_TRANSACTION_STOP,i=new Di().toJson(t,this.authInfo,e,n);return this.doRequest(t,i)})}stopPublishLiveStreamWithTaskId(n){if(!this.authInfo)return Promise.reject(ut.LiveTranscodingErrorInvalidParam);const e=He.MPU_TASK_TRANSACTION_STOP,t=new Di().toJson(e,this.authInfo,n);return this.doRequest(e,t)}refreshAuthInfo(n){this.authInfo&&this.setAuthInfo(Y(Y({},this.authInfo),n))}}class ps{static checkString(n){return typeof n=="string"}static checkNumber(n){return typeof n=="number"}static checkHtmlVideoElement(n){return n&&n.nodeName==="VIDEO"}static checkHtmlAudioElement(n){return n&&n.nodeName==="AUDIO"}static checkAuthInfo(n){if(!n)return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no authInfo founded");if(!n.appId)return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no appId founded");if(!n.channelId)return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no channelId founded");if(!n.userId)return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no userId founded");if(n.timestamp){if(!ps.checkNumber(n.timestamp))return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"timestamp is not number")}else return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no timestamp founded");return n.token?null:new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no token founded")}static checkMediaStreamTrack(n){return n instanceof MediaStreamTrack}static checkVideoEncoderConfiguration(n){return n&&(n.width||n.height||n.frameRate||n.bitrateMax)}}class gn{constructor(n){g(this,"taskProfile");g(this,"encodeParam");g(this,"users",[]);g(this,"backgroundColor",0);g(this,"backgrounds",[]);g(this,"watermarks",[]);g(this,"clockWidgets",[]);g(this,"cropMode");g(this,"mediaProcessMode");this.taskProfile=n}}class mn{constructor(n,e,t){g(this,"userId");g(this,"streamType");g(this,"sourceType");this.userId=n,this.streamType=e,this.sourceType=t}}class Sn{constructor(n,e,t,i=0,s=16777215,a=ui.NOTO_SERIF_CJKSC_REGULAR){g(this,"x");g(this,"y");g(this,"fontSize");g(this,"zOrder");g(this,"fontColor");g(this,"fontType");this.x=n,this.y=e,this.fontSize=t,this.zOrder=i,this.fontColor=s,this.fontType=a}toJson(n,e){return{x:Ye(this.x,n),y:Ye(this.y,e),fonttype:this.fontType,fontsize:this.fontSize,fontcolor:Zr(this.fontColor),zorder:this.zOrder}}}var xn=(r=>(r[r.NOT_DISPLAY=0]="NOT_DISPLAY",r[r.ALWAYS=1]="ALWAYS",r[r.WHEN_NO_VIDEO=2]="WHEN_NO_VIDEO",r))(xn||{});class gs{constructor(n,e,t,i,s,a=0,c=1,o=1){g(this,"url");g(this,"x");g(this,"y");g(this,"width");g(this,"height");g(this,"alpha");g(this,"display",1);g(this,"zOrder");this.url=n,this.x=e,this.y=t,this.width=i,this.height=s,this.zOrder=a,this.alpha=c,this.display=o}toJson(n,e){return{url:this.url,alpha:this.alpha,display:this.display,x:Ye(this.x,n),y:Ye(this.y,e),width:Ye(this.width,n),height:Ye(this.height,e),zorder:this.zOrder}}}g(gs,"DisplayType",xn);class vn{constructor(n,e,t,i,s=0,a=16777215,c=ui.NOTO_SERIF_CJKSC_REGULAR){g(this,"text");g(this,"x");g(this,"y");g(this,"fontSize");g(this,"zOrder");g(this,"fontColor");g(this,"fontType");this.text=n,this.x=e,this.y=t,this.fontSize=i,this.zOrder=s,this.fontColor=a,this.fontType=c}toJson(n,e){return{text:this.text,x:Ye(this.x,n),y:Ye(this.y,e),fonttype:this.fontType,fontsize:this.fontSize,fontcolor:Zr(this.fontColor),zorder:this.zOrder}}}class bn{constructor(n,e,t,i,s,a=0,c){g(this,"userId");g(this,"x");g(this,"y");g(this,"width");g(this,"height");g(this,"zOrder");g(this,"sourceType");g(this,"segmentType",ci.LiveTranscodingNoBody);g(this,"images",[]);g(this,"texts",[]);typeof n=="number"?this.userId=n.toString():this.userId=n,this.x=e,this.y=t,this.width=i,this.height=s,this.zOrder=a,c&&(this.sourceType=c)}toJson(n,e,t,i){const s={paneid:n,majorpane:0,x:Ye(this.x,e),y:Ye(this.y,t),width:Ye(this.width,e),height:Ye(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&&oi[this.sourceType]?s.sourcetype=oi[this.sourceType]:s.sourcetype=oi[Yt.LiveTranscodingCamera],this.segmentType&&i===Ti.LiveTranscodingVirtualBackground?s.segmenttype=this.segmentType:s.segmenttype=ci.LiveTranscodingNoBody,s}}const jt=class jt{constructor(){g(this,"ntpClock");this.ntpClock=new G.AliRTS.Clock}static getInstance(){return jt.instance||(jt.instance=new jt),jt.instance}now(){return this.ntpClock.now()}};g(jt,"instance");let ms=jt;const En=()=>ms.getInstance(),{BrowserUtil:Ss,SystenUtil:An}=G.AliRTS;class _n{constructor(){g(this,"tracker");g(this,"param");g(this,"msgCacheArr",[]);g(this,"index",0);g(this,"stsOpt");g(this,"slsToken");g(this,"ossToken");g(this,"ntpClock");this.ntpClock=En()}createTracker(){if(!this.tracker&&this.slsToken&&this.param){const n=this.slsToken;this.ossToken&&(this.param.ossbn=this.ossToken.bucket_name,this.param.ossep=this.ossToken.region_endpoint);const e=new rr({host:n.region_endpoint,project:n.project,logstore:n.log_store_stats}),t={accessKeyId:n.access_key_id,accessKeySecret:n.access_key_secret,securityToken:n.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=Hr(t);e.useStsPlugin(i),this.tracker=e,this.msgCacheArr.forEach((s,a)=>{var c,o;(o=this.tracker)==null||o.send(Y(vt(Y({},this.param),{stat_log_id:`${((c=this.param)==null?void 0:c.sesid)||"nosession"}-${a}`}),s))}),this.index=this.index+this.msgCacheArr.length,this.msgCacheArr=[]}}start(n){this.initParam(n),this.createTracker()}updateToken(n,e){this.slsToken=n,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(n){var t,i;n.tm=Date.now();let e;try{e=JSON.parse(JSON.stringify(Y(vt(Y({bt:Ss.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}`}),n)))}catch(s){}if(e){if(!this.tracker){this.msgCacheArr.push(e);return}(i=this.tracker)==null||i.send(e),this.index++}}initParam(n){let e=localStorage==null?void 0:localStorage.getItem("AliRtcUUID");e||(e=it(),localStorage==null||localStorage.setItem("AliRtcUUID",e)),this.param||(this.param={apid:n.appId,usrid:n.userId,statsvrs:"0.6.1",evetid:0,sesid:n.sessionId,sessionId:n.sessionId,channelid:n.channelId,usrn:n.userId,osn:An.systemName,osv:An.systemVersion,deb:l0(),den:u0(),udid:e,sdkvrs:_i,acs:"Unknown",cput:ja(),dm:`${window.location.protocol}//${window.location.host}`,bt:Ss.browserName,bv:Ss.browserVersion,envir:"PRODUCT",args:"",instid:it()})}}const ge=(r,n=1,e=6e4,t=0)=>{let i=r;return i||(i=0),Math.min(e,Math.max(t,Math.round(i*n)))},et=(r,n,e=2e7,t=0)=>{let i=n;(!n||n<0||n>1e4)&&(i=1e3);let s=r;return s||(s=0),Math.min(e,Math.max(t,Math.round(s/(i/1e3))))},Ot=(r,n)=>{if(n===0||!n)return"0.00";let e=r;return(!e||e<0)&&(e=0),(e/n*100).toFixed(2)},yn=r=>r>=0&&r<=1?ge(Math.floor(32767*r),1,32767):0,me=(r,n)=>{var t,i,s;let e=((t=r._last)==null?void 0:t[n])||0;return r.ssrc&&((i=r._last)!=null&&i.ssrc)&&r.ssrc!==((s=r._last)==null?void 0:s.ssrc)&&(e=0),((r==null?void 0:r[n])||0)-e},Ic=(r,n)=>{var e,t,i;return(((e=r==null?void 0:r._source)==null?void 0:e[n])||0)-(((i=(t=r==null?void 0:r._last)==null?void 0:t._source)==null?void 0:i[n])||0)},Cn=(r,n)=>ge(me(r,n),1e3,1e4),Ut=(r,n=2e7)=>ge(r,1,n),mi=class mi{constructor(n){g(this,"engine");g(this,"logClient");g(this,"authInfo");g(this,"ntpClock");this.logClient=new _n,this.engine=n,this.ntpClock=En()}static getLogClient(){return this.staticClient||(this.staticClient=new _n),this.staticClient}static reportOSSUpload(n,e,t=0){mi.getLogClient().sendReport({errmsg:`${e}/${n}.log`,errtype:t,evetid:70017,sesid:n,sessionId:n,stat_log_id:`${n}-70017`})}start(n){this.authInfo=n,this.logClient.start(n)}updateToken(n,e){this.logClient.updateToken(n,e),mi.getLogClient().updateToken(n,e)}stop(){this.logClient.stop()}reportPublishMonitor(n,e,t,i,s){if(!t||s.length<=0)return;const a=t===D.Audio,c={ctm:Math.floor(s[0].timestamp||0),src:s[0].ssrc||"",codec:s[0]._codec||""},o=[],u=[],h=[],p=[],d=[],f=[],m=[],l=[],S=[],v=[],x=[],b=[],E=[],A=[],y=[],_=[],R=[],L=[],C=[];try{if(s.forEach(I=>{var F,N,X,j,fe,ee;if(!I||!I.timestamp)return;const P=(F=I._last)!=null&&F.timestamp?I.timestamp-I._last.timestamp:1e3,B=me(I,"bytesSent"),K=me(I,"headerBytesSent"),J=et(ge(B+K,8,2e7),P);o.push(J);const Q=et(ge(B,8,2e7),P);u.push(Q);const ue=et(ge(K,8,2e7),P);h.push(ue);const te=me(I,"packetsSent"),se=et(te,P);p.push(se);const ie=me(I,"packetsLost"),k=et(ie,P);d.push(k);const M=Ot(ie,te);if(f.push(M),a)(N=I._source)!=null&&N.audioLevel&&m.push(yn(I._source.audioLevel)),l.push(0);else{S.push(Cn(I,"totalEncodeTime")),v.push(Ut((X=I._source)==null?void 0:X.framesPerSecond,100)),x.push(Ut((j=I._source)==null?void 0:j.framesPerSecond,100)),b.push(Ut(I.framesPerSecond,100)),E.push(Ut((fe=I._source)==null?void 0:fe.height,4400)),A.push(Ut((ee=I._source)==null?void 0:ee.width,7700)),y.push(Ut(I.frameHeight,4400)),_.push(Ut(I.frameWidth,7700));const ze=me(I,"totalPacketSendDelay");R.push(ge(ze,1/(ie||1),2e3));const Je=me(I,"qpSum");L.push(ge(Je,1/(I.framesPerSecond||1),51)),C.push(0)}}),c.sbr=o.join(","),c.mbrs=u.join(","),c.pbrs=h.join(","),c.ps=p.join(","),c.pl=d.join(","),c.plr=f.join(","),a){const I=(i==null?void 0:i.getSettings().sampleRate)||0;c.ailevel=m.join(","),c.arpc=l.join(","),c.arsr=I,c.aesr=I,c.publevel=-90,c.rawlevel=-90}else c.em=S.join(","),c.cfps=v.join(","),c.ifps=x.join(","),c.sfps=b.join(","),c.ih=E.join(","),c.iw=A.join(","),c.sh=y.join(","),c.sw=_.join(","),c.sd=R.join(","),c.aqp=L.join(","),c.caf=C.join(","),c.can=C.join(","),c.cav=u.join(","),c.ifimax=C.join(","),c.ifimin=C.join(","),c.efimax=C.join(","),c.efimin=C.join(","),c.sfimax=C.join(","),c.sfimin=C.join(","),c.apsnr=C.join(",")}catch(I){}this.log({evetid:10070,traceid:e,calid:n,args:this.data2String(Y({calid:n,tckid:t,traceid:e},c))})}reportSubscribeMonitor(n,e,t,i,s){if(!i||!s||s.length<=0)return;const a=i===D.Audio,c={ctm:Math.floor(s[0].timestamp||0),src:s[0].ssrc||"",codec:s[0]._codec||""},o=[],u=[],h=[],p=[],d=[],f=[],m=[],l=[],S=[],v=[],x=[],b=[],E=[],A=[],y=[],_=[],R=[],L=[],C=[],I=[],P=[],B=[],K=[],J=[],Q=[],ue=[],te=[],se=[],ie=[],k=[],M=[],F=[],N=[],X=[];try{s.forEach(j=>{var nt,Kt;if(!j||!j.timestamp)return;const fe=(nt=j._last)!=null&&nt.timestamp?j.timestamp-j._last.timestamp:1e3,ee=me(j,"bytesReceived"),ze=me(j,"headerBytesReceived"),Je=et(ge(ee+ze,8,2e7),fe);o.push(Je);const st=et(ge(ee,8,2e7),fe);u.push(st);const at=et(ge(ze,8,2e7),fe);h.push(at);const ye=me(j,"packetsReceived"),Fe=et(ye,fe);p.push(Fe);const St=me(j,"packetsLost"),zt=et(St,fe);d.push(zt);const ii=Ot(St,ye);f.push(ii);const Wt=me(j,"jitterBufferDelay"),Si=me(j,"jitterBufferEmittedCount");if(j.jitterBufferDelay&&j.jitterBufferEmittedCount){const It=ge(Wt,1e3/Si,1e4);m.push(It)}else m.push(0);const $t=me(j,"fecPacketsReceived");b.push(Ot($t,ye));const Ve=me(j,"retransmittedPacketsReceived"),Pe=ye+St-Ve;if(S.push(Ot(ye-Ve,Pe)),v.push(Ot(St,Pe)),l.push(Ot(Ve,Pe)),x.push(Pe),N.push(0),X.push(""),a){A.push(yn(j.audioLevel));const It=Ic(j,"synthesizedSamplesEvents");y.push(It);const ot=Cn(j,"synthesizedSamplesDuration");_.push(ot);const xt=Ot(ot,fe);E.push(xt),R.push(0)}else{const It=(Kt=j._last)!=null&&Kt.totalInterFrameDelay?j.totalInterFrameDelay-j._last.totalInterFrameDelay:0;L.push(ge(It,1e3/(j.framesDecoded||30),500)),C.push(ge(j.framesPerSecond,1,100)),I.push(me(j,"framesReceived")),F.push(me(j,"framesRendered")),P.push(ge(j.frameHeight,1,4400)),B.push(ge(j.frameWidth,1,7700));const ot=me(j,"totalProcessingDelay");K.push(ge(ot,1e3/(j.framesDecoded||30),12e4));const xt=me(j,"nackCount");Q.push(xt);const vs=me(j,"pliCount");J.push(vs);const Vi=me(j,"qpSum");ue.push(ge(Vi,1/(j.framesPerSecond||1),51)),te.push(ge(j.framesDropped));const Oi=me(j,"totalFreezesDuration");se.push(ge(Oi,1e3,3e4));const Ge=me(j,"jitterBufferEmittedCount"),wt=me(j,"jitterBufferDelay");wt&&Ge?ie.push(ge(wt,1e3/Ge,3e4)):ie.push(0);const Ui=me(j,"jitterBufferTargetDelay");Ui&&Ge?k.push(ge(Ui,1e3/Ge,3e4)):k.push(0);const xi=me(j,"jitterBufferMinimumDelay");xi&&Ge?M.push(ge(xi,1e3/Ge,3e4)):M.push(0)}}),c.rbr=o.join(","),c.mbrs=u.join(","),c.pbrs=h.join(","),c.pr=p.join(","),c.pl=d.join(","),c.plr=f.join(","),c.jd=m.join(","),c.fecr=b.join(","),c.retransr=l.join(","),c.baser=S.join(","),c.basel=v.join(","),c.recoverr=N.join(","),c.alll=v.join(","),c.totalc=x.join(","),a?(c.er=E.join(","),c.aolevel=A.join(","),c.asrc=R.join(","),c.scnt=y.join(","),c.sdura=_.join(",")):(c.dm=L.join(","),c.dfps=C.join(","),c.rfps=I.join(","),c.rh=P.join(","),c.rw=B.join(","),c.fpt=X.join(","),c.ns=Q.join(","),c.pliss=J.join(","),c.aqp=ue.join(","),c.ofimax=N.join(","),c.ofimin=N.join(","),c.dfimax=N.join(","),c.dfimin=N.join(","),c.rfimax=N.join(","),c.rfimin=N.join(","),c.vrstutter=se.join(","),c.cdm=ie.join(","),c.tdm=k.join(","),c.pdm=M.join(","),c.ofps=F.join(","),c.dfbd=te.join(","))}catch(j){}this.log({evetid:10080,traceid:t,rmtid:e,calid:n,args:this.data2String(Y({calid:n,rmtid:e,tckid:i,traceid:t},c))})}reportNetworkMonitor(n){if(n.length<=0)return;const e=[],t=[],i=[],s=[],a=[],c=[],o=[],u=[],h=[],p=[];n.forEach((f,m)=>{var S;if(!f.timestamp)return;const l=(S=f._last)!=null&&S.timestamp?f.timestamp-f._last.timestamp:1e3;e.push(ge(f.currentRoundTripTime,1e3)),t.push(ge(f.availableOutgoingBitrate,8,2e8)),i.push(et(ge(f.bytesSent,8,2e7),l,25e6)),s.push(et(ge(f.bytesReceived,8,2e7),l,25e6)),a.push(0),c.push(0),m%5===0&&(o.push(""),u.push(""),h.push(""),p.push(""))});const d={ctm:Math.floor(n[0].timestamp||0),rtt:e.join(","),bsps:i.join(","),brps:s.join(","),cpu:o.join(","),mem:u.join(","),sysmem:h.join(","),systotalmem:p.join(","),audioonly:this.engine.isAudioOnly()?1:0};this.log({evetid:10071,args:this.data2String(Y({asb:t.join(","),abms:a.join(","),vbms:c.join(",")},d))}),this.log({evetid:10081,args:this.data2String(Y({},d))})}reportJoin(n,e,t=""){var p,d;const{start:i,rs:s=0,re:a=0}=e,c=Date.now()-i,o=a-s;let u=0;s&&(u=s-i);let h=0;a&&(h=a-s),this.log({evetid:10010,args:this.data2String({sesid:((p=this.authInfo)==null?void 0:p.sessionId)||"",joitm:c,rslt:n,gslbtm:0,dnstm:0,avcftm:0,gslbrslt:0,dnsrslt:0,avcfrslt:0,mode:2,jrtc:o,usrn:(d=this.authInfo)==null?void 0:d.userId,mgt:"cdn",cttc:u,iptc:h,ndn:1,gslbloc:1,ccag:0,ucag:0,cpg:0,upg:0,tid:t})})}reportJoinConnection(n){this.log({evetid:20002,args:this.data2String(Y({transretrynum:0,ldnstc:0,tcptc:0,ssltc:0,url:""},n))})}reportLeave(n,e,t){this.log({evetid:10020,args:this.data2String({lvetm:n,rslt:e,tid:t})})}reportPublish(n,e,t,i,s,a,c,o,u,h,p){this.log({evetid:n?10032:10030,calid:t,args:this.data2String({calid:t,url:e,isvl:i?1:0,isvs:s?1:0,isvss:a?1:0,isaudio:c?1:0,rslt:o,tid:"123",pubtm:Date.now()-p,pctid:u,pubtid:h,isvp:0,isarecording:0,isad:0,isdc:0,pubretry:0,pbrttimes:0})})}reportPublishFirstPacket(n,e,t,i,s,a,c,o,u){const h=Date.now();this.log({evetid:n?10033:10031,calid:e,args:this.data2String({calid:e,fpst:h-t,tckid:a,est:t,pctid:c,pubtid:o,totaltm:h-s,jorm:u===ct.JOIN_CHANNEL?1:0,cptc:0,sptc:i-t,iptc:0,ipc2fptc:0,dctc:0,patc:0})})}reportUnpublish(n,e,t,i){var s;this.log({evetid:10040,args:this.data2String({calid:n,unpubtm:e,rslt:t,tid:i,sesid:((s=this.authInfo)==null?void 0:s.sessionId)||""})})}reportSubscribe(n,e,t,i,s,a,c,o,u,h){this.log({evetid:10050,calid:n,rmtid:e,args:this.data2String(Y({calid:n,rmtid:e,isvl:t?1:0,isvs:i?1:0,isvss:s?1:0,isaudio:a?1:0,rslt:c,tid:o,subtm:u,isvp:0,isaplaying:0,isad:0,isdc:0,subretry:0,sbrttimes:0},h))})}reportSubscribeFirstPacket(n,e,t,i,s){this.log({evetid:n?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},s))})}reportSubscribeFirstFrame(n,e,t,i,s){this.log({evetid:n?10055:10052,calid:e,rmtid:t,args:this.data2String(Y({calid:e,rmtid:t,tckid:i},s))}),this.log({evetid:n?10058:10057,args:this.data2String(Y({calid:e,rmtid:t,tckid:i},s))})}reportUnsubscribe(n,e,t,i,s){this.log({evetid:10060,calid:n,args:this.data2String({calid:n,rmtid:e,unsubtm:t,rslt:i,tid:s})})}reportMute(n,e,t){this.log({evetid:11030,args:this.data2String({calid:n,rmtid:"",enable:e?1:0,mt:t})})}reportRoleUpdate(n,e){this.log({evetid:11040,args:this.data2String({or:n||"",nr:e,ctm:Date.now(),rslt:0})})}reportRoleUpdateResult(n,e,t,i){this.log({evetid:11041,args:this.data2String({or:n||"",nr:e,ctm:t,rslt:i})})}reportVideoProfile(n){this.log({evetid:20074,args:this.data2String({pf:n,tckid:"sophon_camera_large"})})}reportScreenProfile(n){this.log({evetid:20074,args:this.data2String({pf:n,tckid:"sophon_screenshare"})})}reportError(n){this.log({evetid:10091,args:this.data2String({rslt:(n==null?void 0:n.code)||-1})})}reportWarning(n){this.log({evetid:10092,args:this.data2String({rslt:-1,errmsg:n})})}reportRoomServerEvent(n,e,t,i){this.log({evetid:20005,args:this.data2String({calid:"",rmtid:"",rt:n?0:1,dr:n?"s":"r",mt:e,ri:t,cs:1,srt:Date.now(),rspc:(i==null?void 0:i.code)||"",mc:JSON.stringify(i)})})}reportTranscodingError(n,e){this.log({evetid:10101,args:this.data2String({rslt:n,taskid:e})})}reportBye(n){var e;this.log({evetid:10093,args:this.data2String({rslt:n,sesid:((e=this.authInfo)==null?void 0:e.sessionId)||""})})}reportAudio(n,e,t){var i;this.log({evetid:80013,args:this.data2String({rslt:n?-1:0,adm:1,adt:0,adr:n?2:0,acms:e,adrpn:t})}),this.log({evetid:80014,args:this.data2String({sesid:((i=this.authInfo)==null?void 0:i.sessionId)||"",rslt:n?-1:0,adm:1,adt:0,adr:n?2:0,acms:e,adrpn:t})})}reportScreen(n,e){var t,i,s,a;this.log({evetid:90013,args:this.data2String({rslt:n?-1:0,vcms:e,vde:(t=n==null?void 0:n.code)!=null?t:-1,sesid:((i=this.authInfo)==null?void 0:i.sessionId)||""})}),this.log({evetid:90014,args:this.data2String({rslt:n?-1:0,vcms:e,vde:(s=n==null?void 0:n.code)!=null?s:-1,sesid:((a=this.authInfo)==null?void 0:a.sessionId)||""})})}reportScreenStop(n){this.log({evetid:90019,args:this.data2String({rslt:n?n.code||-1:0})}),this.log({evetid:90020,args:this.data2String({rslt:n?n.code||-1:0})})}reportSwitchCamera(n){var e;this.log({evetid:90025,args:this.data2String({rslt:0,td:n,sesid:((e=this.authInfo)==null?void 0:e.sessionId)||""})})}reportPublishProfile(n,e){this.log({evetid:10201,args:this.data2String(Y({tckid:n},e))})}reportSDKCreated(n){this.log({evetid:70011,createtm:Date.now()-n,tm:n})}reportJoinInvoked(n){this.log({evetid:70012,jnnonce:n.nonce||"",jntoken:n.token||"",jntm:n.timestamp||""})}reportJoinResult(n){this.log({evetid:70013,rslt:n?n.code||-1:0,dnsrslt:0})}reportSTSResult(n,e){this.log({evetid:70014,rslt:n,asty:1,reqtm:Date.now()-e})}reportLeaveInvoked(){this.log({evetid:70015})}reportSEIMessage(n,e,t,i,s){this.log({evetid:40301,args:this.data2String({tm:Date.now(),sei_pt:n,sei_len:e,sei_rep:t,sei_delay:i,sei_key:s})})}reportConnectionLatencyEvent(n,e,t,i,s,a,c=!1){this.log({evetid:12001,args:this.data2String({tm:s||Date.now(),ntptm:a||this.ntpClock.now(),stage:n,status:e,calid:t,tckid:i,cltp:1,http:c?1:0})})}log(n){n&&(n.tm=new Date().getTime(),O.debug("[ConsoleLogger]","log",n),this.logClient.sendReport(n))}data2String(n){let e="";for(let t in n)e.length&&(e+="&"),e+=t+"="+n[t];return e}};g(mi,"staticClient");let xs=mi;var wc=Object.defineProperty,Tc=Object.getOwnPropertyDescriptor,W=(r,n,e,t)=>{for(var i=t>1?void 0:t?Tc(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&wc(n,e,i),i};const z=(q=class extends re{constructor(e){super();g(this,"channelProfile");g(this,"clientRole");g(this,"signalingManager");g(this,"bizControl");g(this,"liveTranscoding");g(this,"maxSignalingConnectRetryCount");g(this,"slsReporter");g(this,"connectState",de.AliRtcConnectionStatusInit);g(this,"networkError",!1);g(this,"_audioOnlyMode",!1);g(this,"_authInfoWillExpireTimer",null);g(this,"_authInfoExpiredTimer",null);g(this,"_serverCheckAuthInfoTimestamp",null);g(this,"_localCheckAuthInfoTimestamp",null);const t=Date.now();O.init(),this.slsReporter=new xs(this),this.channelProfile=gt.AliRtcSdkCommunication,this.clientRole=At.AliRtcSdkLive,this.liveTranscoding=new Rc(this.slsReporter),this.signalingManager=new ss(this.channelProfile,this.clientRole,this.slsReporter,(e==null?void 0:e.env)===pt.pre?pt.pre:pt.prod),this.addSignalingManagerListeners(),this.maxSignalingConnectRetryCount=e==null?void 0:e.maxSignalingConnectRetryCount,this.bizControl=new ke({slsReporter:this.slsReporter,signalingManager:this.signalingManager}),this.addBizControlListeners(),this.addPublisherListeners(),this.slsReporter.reportConnectionLatencyEvent(Ke.CREATE_ENGINE,Ze.START,"","",t),this.slsReporter.reportConnectionLatencyEvent(Ke.CREATE_ENGINE,Ze.END,"","",Date.now()),this.slsReporter.reportSDKCreated(t)}static getSdkVersion(){return _i}static setLogLevel(e){O.setLogLevel(e)}static getInstance(e){return q._instance||(q._instance=new q(e)),q._instance}destroy(){return w(this,null,function*(){q._instance=void 0,yield this.leaveChannel(),yield this.bizControl.clear(),O.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:!1}get currentRoleCanPublish(){return this.channelProfile===gt.AliRtcSdkCommunication||this.clientRole===At.AliRtcSdkInteractive}addPublisherListeners(){var e,t,i,s,a,c,o,u,h,p;(e=this.publisher)==null||e.on(Ne.Local,d=>{O.event("[Publisher] Device Status Change",d),this.onLocalDeviceStatusChange(d)}),(t=this.publisher)==null||t.on(Vt.VideoTrackEnded,()=>{O.event("[Publisher] VideoTrack Ended"),this.emit("localDeviceException",ht.AliEngineLocalDeviceTypeCamera,Ee.AliEngineLocalDeviceExceptionTypeCameraInterrupt,"")}),(i=this.publisher)==null||i.on(Vt.ScreenTrackEnded,()=>{O.event("[Publisher] ScreenTrack Ended"),this.emit("localDeviceException",ht.AliEngineLocalDeviceTypeDisplay,Ee.AliEngineLocalDeviceExceptionTypeDisplayException,"")}),(s=this.publisher)==null||s.on(Vt.AudioTrackEnded,()=>{O.event("[Publisher] AudioTrack Ended"),this.emit("localDeviceException",ht.AliEngineLocalDeviceTypeMic,Ee.AliEngineLocalDeviceExceptionTypeMicInterrupt,"")}),(a=this.publisher)==null||a.on("localDeviceException",(d,f,m="")=>{this.emit("localDeviceException",d,f,m)}),(c=this.publisher)==null||c.on("audioPublishStateChanged",(d,f,m)=>{var l;this.emit("audioPublishStateChanged",d,f,m,(l=this.channel)!=null?l:"")}),(o=this.publisher)==null||o.on("videoPublishStateChanged",(d,f,m)=>{var l;this.emit("videoPublishStateChanged",d,f,m,(l=this.channel)!=null?l:"")}),(u=this.publisher)==null||u.on("dualStreamPublishStateChanged",(d,f,m)=>{var l;this.emit("dualStreamPublishStateChanged",d,f,m,(l=this.channel)!=null?l:"")}),(h=this.publisher)==null||h.on("screenPublishStateChanged",(d,f,m)=>{var l;this.emit("screenSharePublishStateChanged",d,f,m,(l=this.channel)!=null?l:"")}),(p=this.publisher)==null||p.on("dataPublishStateChanged",(d,f,m)=>{var l;this.emit("dataPublishStateChanged",d,f,m,(l=this.channel)!=null?l:"")})}occurError(e,t){O.event(`[${q.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(ct.RECONNECT),this.remoteUsers.forEach(i=>{i.updateSubscribe(pe.Reconnect)}))}),this.bizControl.rtsManager.on("disconnected",()=>w(this,null,function*(){O.event(`[${q.logName}]`,"RTS Disconnected"),(yield Oe.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 s=this.remoteUsers.find(a=>a.streamUrl===e);s&&this.emit("mediaExtensionMsgReceived",s.userId,i,t)}),this.bizControl.on(Ne.Remote,(e,t)=>{O.event(`[${q.logName}]`,"RemoteUser Device Status Change",e,t)}),this.bizControl.on("remoteTrackAvailableChange",(e,t,i)=>{this.emit("remoteTrackAvailableNotify",e,t,i)}),this.bizControl.on("audioSubscribeStateChanged",(e,t,i,s,a)=>{this.emit("audioSubscribeStateChanged",e,t,i,s,a)}),this.bizControl.on("videoSubscribeStateChanged",(e,t,i,s,a)=>{this.emit("videoSubscribeStateChanged",e,t,i,s,a)}),this.bizControl.on("screenSubscribeStateChanged",(e,t,i,s,a)=>{this.emit("screenShareSubscribeStateChanged",e,t,i,s,a)}),this.bizControl.on("dataSubscribeStateChanged",(e,t,i,s,a)=>{this.emit("dataSubscribeStateChanged",e,t,i,s,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)})}addSignalingManagerListeners(){this.signalingManager.on("onKeepAliveRsp",()=>{this.networkError&&(O.event("[Signaling] Receive KeepAlive Response",`networkError: ${this.networkError}`),this.onNetworkRecovery())}),this.signalingManager.on("onNotifyJoin",e=>{O.event("[Signaling] Notify Join ",e),this.handleUsersJoin(e),e.forEach(t=>{this.emit("remoteUserOnLineNotify",t.userid,0)})}),this.signalingManager.on("onNotifyStatus",e=>{O.event("[Signaling] Notify Status ",e),e.forEach(t=>{this.bizControl.updateRemoteUserDeviceStatus(t)})}),this.signalingManager.on("onNotifyLeave",e=>{O.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)=>{O.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=>{O.event("[Signaling] Connect Failed ",e),this.onError(e),this.backToUnpublishStatus(),this.connectState=de.AliRtcConnectionStatusFailed,this.emit("connectionStatusChange",de.AliRtcConnectionStatusFailed,Nt.AliRtcConnectionChangedNetworkInterrupted)}),this.signalingManager.on("onNetworkError",e=>{this.slsReporter.reportWarning("signaling network error"),O.event("[Signaling] Network error ",e),this.onNetworkError()}),this.signalingManager.on("onAuthInvalid",()=>{O.event("[Signaling] Auth Invalid")}),this.signalingManager.on("onReconnectStart",()=>{O.event("[Signaling] Reconnect Start "),this.connectState=de.AliRtcConnectionStatusReconnecting,this.emit("connectionStatusChange",de.AliRtcConnectionStatusReconnecting,Nt.AliRtcConnectionSignalingConnecting)}),this.signalingManager.on("onReconnectSuccess",e=>{O.event("[Signaling] Reconnect Success ",e),this.onNetworkRecovery(e)}),this.signalingManager.on("onReconnectFail",e=>{this.slsReporter.reportWarning("signaling reconnect fail: ${err.code}"),O.event("[Signaling] Reconnect Failed ",e),e.code===403&&this.emit("authInfoExpired")}),this.signalingManager.on("onError",e=>{this.slsReporter.reportWarning("signaling error: ${err.message}"),O.event("[Signaling] Error ",e),this.onError(e)})}backToUnpublishStatus(){var e,t;this.connectState=de.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 s=this.bizControl.addUser(i,t.displayname,pe.Join);O.event(`[${q.logName}]`,he.UserJoined,s)}})}onLocalDeviceStatusChange(e){O.event(`[${q.logName}]`,Ne.Local,e),this.signalingManager.reportStatus(e).then(()=>{O.debug("[signaling] reportStatus suc")}).catch(t=>{O.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,o)=>{const u=setInterval(()=>w(this,null,function*(){var h;a>1&&(clearInterval(u),o()),a+=1;try{yield(h=this.publisher)==null?void 0:h.resumePublish(),clearInterval(u),c()}catch(p){const{code:d}=p;d!==10205&&(clearInterval(u),o())}}),1e3)})}catch(c){}}throw t}})}onNetworkRecovery(e){return w(this,null,function*(){var t;O.event(q.logName,"onNetworkRecovery",`rts isConnected: ${this.bizControl.rtsManager.isConnected}; rts isConnecting: ${this.bizControl.rtsManager.isConnecting}`,{users:e}),!this.bizControl.rtsManager.isConnected&&!this.bizControl.rtsManager.isConnecting?(this.currentRoleCanPublish&&(yield this.resumePublishForNetworkRecovery()),yield this.resumeSubList()):e&&(yield this.resumeSubList(e)),this.networkError&&(this.networkError=!1,(t=this.publisher)==null||t.reportSelfDeviceStatus(),this.connectState=de.AliRtcConnectionStatusConnected,this.emit("connectionStatusChange",de.AliRtcConnectionStatusConnected,Nt.AliRtcConnectionSignalingHeartbeatAlive))})}resumeSubList(e){return w(this,null,function*(){if(e!=null&&e.length){const{joinList:t,leaveList:i,presentList:s}=this.bizControl.updateUsers(e);O.info(`[${q.logName}]`,"resumeSubList",{joinList:t,leaveList:i,presentList:s}),this.handleUsersJoin(t),i.forEach(a=>{O.event(q.logName,he.UserLeft,a.userid,a.reason),this.emit("remoteUserOffLineNotify",a.userid,Qr.AliRtcUserOfflineQuit)});for(let a=0;a<s.length;a++){const c=s[a],o=c.userid,u=this.bizControl.getRemoteUser(o);this.bizControl.onRemotePublishStateChange(c),u==null||u.updateSubscribe(pe.Resume)}}else for(let t=0;t<this.remoteUsers.length;t++){const i=this.remoteUsers[t];try{i.restore(),i.updateSubscribe(pe.Resume)}catch(s){}}})}retrySubscribe(e){return w(this,null,function*(){const t=this.bizControl.getRemoteUser(e);if(!t)throw new V(U.ERR_INNER,`no remote user(${e}) founded`);t.restore(),t.updateSubscribe(pe.Retry)})}onNetworkError(){this.connectState===de.AliRtcConnectionStatusConnected&&(this.networkError||(this.connectState=de.AliRtcConnectionStatusDisconnected,this.emit("connectionStatusChange",de.AliRtcConnectionStatusDisconnected,Nt.AliRtcConnectionChangedNetworkInterrupted)),this.networkError=!0)}onError(e){this.slsReporter.reportError(e),O.event(q.logName,he.Error,e)}setEnableDualVideoStream(e,t){this.bizControl.setEnableDualVideoStream(e,t)}hadPushStream(e){if(!(this.publisher&&e))throw new V(U.ERR_INNER,"stream is not publishing")}getCurrentMicDeviceId(){var e;return(e=this.publisher)==null?void 0:e.getCurrentMicDeviceId()}setChannelProfile(e){if(![de.AliRtcConnectionStatusInit,de.AliRtcConnectionStatusDisconnected,de.AliRtcConnectionStatusFailed].includes(this.connectState))throw new V(U.ERR_INNER,"cannot set channel profile in call");this.channelProfile=e,this.channelProfile===gt.AliRtcSdkCommunication&&(this.clientRole=At.AliRtcSdkLive),this.signalingManager.setChannelProfile(e)}startAndPublishDefaultDevices(e){return w(this,null,function*(){var c,o,u,h,p;if(!this.publisher)return;const{hasCamera:t,hasMicrophone:i,hasScreenShare:s}=this.publisher;if(!t&&!i&&!s){try{yield(c=this.publisher)==null?void 0:c.startDefaultCamera(this._audioOnlyMode)}catch(d){O.warn(`[${q.logName}]`,"startDefaultCamera failed",d.code,d.message),d instanceof V&&this.occurError(d),this.occurError(new V(U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED,`auto start video failed, ${d.message||""}`))}try{yield(o=this.publisher)==null?void 0:o.startDefaultAudio()}catch(d){O.warn(`[${q.logName}]`,"startDefaultAUdio failed",d.code,d.message),d instanceof V&&this.occurError(d),this.occurError(new V(U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED,`auto start audio failed, ${d.message||""}`))}yield(u=this.publisher)==null?void 0:u.previewAll()}const a=((h=this.publisher)==null?void 0:h.publishStreams)||{};if(Object.values(a).some(d=>d))try{yield(p=this.publisher)==null?void 0:p.startPublish(!1,e)}catch(d){const f=[];a!=null&&a.audio&&f.push(U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED),a!=null&&a.video&&f.push(U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED),f.forEach(m=>{this.occurError(new V(m,`auto publish stream failed, ${d.message||""}`))})}})}setClientRole(e){return w(this,null,function*(){var t,i;try{if(this.channelProfile===gt.AliRtcSdkCommunication)return;if(!Object.values(At).includes(e))throw new V(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===At.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(ct.ROLE_CHANGE)):yield this.signalingManager.setClientRole(e),this.clientRole=e}catch(s){throw s.code===403&&this.emit("authInfoExpired"),s}})}getCurrentClientRole(){return this.clientRole}setAudioOnlyMode(e){if(this.isInCall())throw new V(U.ERR_INNER,"can not change audioOnly mode in call");this._audioOnlyMode=e}setAudioRedEnabled(e){if(this.isInCall())throw new V(U.ERR_INNER,"can not change audioRedEnabled in call");this.bizControl.setAudioRedEnabled(e)}setCheckAuthInfoTimer(e,t){const i=(e-t)*1e3;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){return w(this,null,function*(){var u,h;const i=Date.now();let s,a=t;if(typeof e=="string")try{const p=JSON.parse(window.atob(e));s={appId:p.appid,channelId:p.channelid,userId:p.userid,timestamp:p.timestamp,nonce:p.nonce,token:p.token}}catch(p){throw new V(U.ERR_INVALID_ARGUMENTS,`authInfo is invalid: ${p.message||""}`)}else s=e;a||(a=s.userId);const c={start:Date.now()};let o=ps.checkAuthInfo(s);if(de.AliRtcConnectionStatusInit===this.connectState||de.AliRtcConnectionStatusDisconnected===this.connectState||de.AliRtcConnectionStatusFailed===this.connectState){if(s.sessionId=Oe.createCallid("web"),this.slsReporter.start(s),this.slsReporter.reportConnectionLatencyEvent(Ke.JOIN,Ze.START,"","",i),this.connectState=de.AliRtcConnectionStatusConnecting,o)throw this.connectState=de.AliRtcConnectionStatusFailed,this.slsReporter.reportJoin(o.code,c,""),this.slsReporter.reportJoinResult(o),o;O.setSessionID(s.appId,s.sessionId);try{const p=Date.now(),d=yield this.signalingManager.join(s,a,this.maxSignalingConnectRetryCount,c),f=Date.now();this.connectState=de.AliRtcConnectionStatusConnected,(u=this.publisher)==null||u.reportSelfDeviceStatus(),this.bizControl.init(s,d),this.setCheckAuthInfoTimer(s.timestamp,d.timestamp),this.liveTranscoding.setAuthInfo(s),this.slsReporter.reportJoin(0,c,d.tid),this.slsReporter.reportJoinResult(null),this.slsReporter.reportConnectionLatencyEvent(Ke.JOIN,Ze.SEND_SIG,"","",p),this.slsReporter.reportConnectionLatencyEvent(Ke.JOIN,Ze.RECV_RST,"","",f),this.slsReporter.reportConnectionLatencyEvent(Ke.JOIN,Ze.END,"","")}catch(p){const d=(h=p.code)!=null?h:-1,f=p.reason||p.message||"";throw this.connectState=de.AliRtcConnectionStatusDisconnected,this.slsReporter.reportJoin(d,c,""),this.slsReporter.reportJoinResult(p),new V(d,f)}this.currentRoleCanPublish&&(yield this.startAndPublishDefaultDevices(ct.JOIN_CHANNEL)),this.remoteUsers.forEach(p=>{p.updateSubscribe(pe.Join)})}else{const p=new V(U.ERR_JOIN_ALREADY_JOINED,"already joined");throw this.connectState===de.AliRtcConnectionStatusConnecting&&(p.message="Repeated operation during login"),this.slsReporter.reportJoin(p.code,c,""),p}})}leaveChannel(){return w(this,null,function*(){var t;this.slsReporter.reportLeaveInvoked(),yield this.bizControl.leave();let e=new Date().getTime();if(de.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=de.AliRtcConnectionStatusDisconnected,this.clearCheckAuthInfoTimer(),this.liveTranscoding.clear(),this.slsReporter.stop(),this.signalingManager.reset(),O.reportEnd()})}isInCall(){return this.connectState===de.AliRtcConnectionStatusConnected}refreshAuthInfo(e){return w(this,null,function*(){let t;if(typeof e=="string")try{const h=JSON.parse(window.atob(e));t={userId:h.userid,timestamp:h.timestamp,nonce:h.nonce,token:h.token}}catch(h){throw new V(U.ERR_INVALID_ARGUMENTS,`authInfo is invalid: ${h.message||""}`)}else t=e;const{userId:i,nonce:s,timestamp:a,token:c,role:o}=t,u={userId:i,nonce:s,timestamp:a,token:c,role:o};try{yield this.signalingManager.refreshAuthInfo(u),this.bizControl.refreshAuthInfo(u),this.liveTranscoding.refreshAuthInfo(u),this.clearCheckAuthInfoTimer(),this._serverCheckAuthInfoTimestamp&&this._localCheckAuthInfoTimestamp&&t.timestamp&&this.setCheckAuthInfoTimer(t.timestamp,this._serverCheckAuthInfoTimestamp+(Date.now()-this._localCheckAuthInfoTimestamp))}catch(h){throw h}})}isAudioOnly(){return this._audioOnlyMode}publishLocalAudioStream(e){return w(this,null,function*(){var t,i,s,a;(t=this.publisher)==null||t.setPublishLocalAudioStreamEnabled(e),this.connectState===de.AliRtcConnectionStatusConnected&&(e?(i=this.publisher)!=null&&i.hasMicrophone?yield(s=this.publisher)==null?void 0:s.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 V(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 V(U.ERR_INNER,`no remote user(${e}) founded`);t.resumeAudio()}stopRemoteAudioPlay(e){const t=this.bizControl.getRemoteUser(e);if(!t)throw new V(U.ERR_INNER,`no remote user(${e}) founded`);t.stopPlayAudio()}publishLocalVideoStream(e){return w(this,null,function*(){var t,i,s,a;(t=this.publisher)==null||t.setPublishLocalVideoStreamEnabled(e),this.connectState===de.AliRtcConnectionStatusConnected&&(e?(i=this.publisher)!=null&&i.hasCamera?yield(s=this.publisher)==null?void 0:s.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){[Ie.AliRtcVideoStreamTypeHigh,Ie.AliRtcVideoStreamTypeLow].includes(e)&&this.bizControl.setRemoteDefaultVideoStreamType(e)}setRemoteUserVideoStreamType(e,t){[Ie.AliRtcVideoStreamTypeHigh,Ie.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,s){const a=this.bizControl.getRemoteUser(e);if(!a)throw new V(U.ERR_INNER,`no remote user(${e}) founded`);i&&(t===ne.AliRtcVideoTrackScreen||t===ne.AliRtcVideoTrackBoth)?a.setWantSubScreen(!0):a.setWantSubScreen(!1),i&&(t===ne.AliRtcVideoTrackCamera||t===ne.AliRtcVideoTrackBoth)?a.setWantSubVideo(!0):a.setWantSubVideo(!1),a.setWantSubAudio(s),a.updateSubscribe(pe.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:s,audioTrack:a}=e||{};if(s||a){t.screen=!0;const o=new MediaStream;s&&o.addTrack(s),a&&o.addTrack(a),t.mediaStream=o}else t.screen=i?{audio:!0}:!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,s={};t&&(s.frameRate=t),i&&(s.maxBitrate=i),yield(a=this.publisher)==null?void 0:a.setScreenProfile(s)})}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,s,a;(i=this.publisher)==null||i.setPublishLocalScreenStreamEnabled(e),this.connectState===de.AliRtcConnectionStatusConnected&&(e?(s=this.publisher)!=null&&s.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 V(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;this.isPublishing&&this.onLocalDeviceStatusChange(e?he.MuteAudio:he.UnmuteAudio),(t=this.publisher)==null||t.muteLocalMic(e)}muteRemoteAudioPlaying(e,t=!1){const i=this.bizControl.getRemoteUser(e);if(!i)throw new V(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,s,a,c;if(yield(i=this.publisher)==null?void 0:i.setMicrophoneDeviceId(e),!((s=this.publisher)!=null&&s.audioCaptureDisabled)){if(t){yield(a=this.publisher)==null?void 0:a.createLocalStream({audio:!0,mediaStream:new MediaStream([t])});return}yield(c=this.publisher)==null?void 0:c.createLocalStream({audio:{deviceId:e}})}})}setRecordingVolume(e){if(typeof e!="number")throw new V(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 V(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 V(U.ERR_INNER,`no remote user(${e}) founded`);if(typeof t!="number")throw new V(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,s,a;if(this._audioOnlyMode)throw new V(U.ERR_INNER,"Cannot set local view in audio only mode");(i=this.bizControl)==null||i.setLocalViewConfig(e,t),t===ne.AliRtcVideoTrackCamera&&((s=this.publisher)!=null&&s.hasCamera)?yield this.startPreview():t===ne.AliRtcVideoTrackScreen&&((a=this.publisher)!=null&&a.hasScreenShare)&&(yield this.startPreviewScreen())})}setCameraCapturerConfiguration(e){return w(this,null,function*(){var h,p,d;const u=e,{cameraDirection:t,deviceId:i,bitrate:s,maxSendFrameRate:a}=u,c=qt(u,["cameraDirection","deviceId","bitrate","maxSendFrameRate"]),o=Y({},c);s&&(o.maxBitrate=s),a&&(o.maxSendFrameRate=a),Object.keys(o).length>0&&(yield(h=this.publisher)==null?void 0:h.setVideoProfile(o)),t!==void 0&&((p=this.publisher)==null||p.setCameraDirection(t)),i&&((d=this.publisher)==null||d.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,s,a,c,o,u,h,p,d,f;if(this._audioOnlyMode)throw new V(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=(s=this.publisher)==null?void 0:s.publishStreams)==null?void 0:a.video)==null||c.disableVideo(),(p=(h=(u=(o=this.publisher)==null?void 0:o.publishStreams)==null?void 0:u.video)==null?void 0:h.videoTrack)==null||p.stop()),yield(d=this.publisher)==null?void 0:d.startCameraCapture()):yield(f=this.publisher)==null?void 0:f.stopCameraCapture()})}muteLocalCamera(e){return w(this,null,function*(){var t;this.isPublishing&&this.onLocalDeviceStatusChange(e?he.MuteVideo:he.UnmuteVideo),(t=this.publisher)==null||t.muteLocalCamera(e)})}muteLocalScreen(e){return w(this,null,function*(){var t;this.isPublishing&&this.onLocalDeviceStatusChange(e?he.MuteScreen:he.UnmuteScreen),(t=this.publisher)==null||t.muteLocalScreen(e)})}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 s,a,c,o,u,h;if(this._audioOnlyMode)throw new V(U.ERR_INNER,"Cannot switch camera in audio only mode");const i={};if(e?(i.deviceId=e,this.slsReporter.reportSwitchCamera(e)):t||(i.cameraDirection=((s=this.publisher)==null?void 0:s.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)){(u=(o=this.publisher)==null?void 0:o.cameraTrack)==null||u.stop();const p={video:!0};t&&(p.mediaStream=new MediaStream([t])),yield(h=this.publisher)==null?void 0:h.createLocalStream(p)}})}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 V(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 V(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,o,u;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 s=this.bizControl.getRemoteUser(t);return i===ve.AliRtcSdkStreamTypeCapture?(o=s==null?void 0:s.getCameraStream)==null?void 0:o.videoTrack:(u=s==null?void 0:s.getScreenStream)==null?void 0:u.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 s;if(!this.publisher||!this.isPublishing)throw new V(U.ERR_INNER,"you should publish first");return this.slsReporter.reportSEIMessage(i,e.byteLength,t,0,!1),(s=this.publisher)==null?void 0:s.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 V(Ct.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 V(Ct.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 V(Ct.AliRtcPluginErrorNoFindPlugin,"you should enable beautyPlugin first");const s={setSegmentBackgroundImage:{backgroundImgUrl:e?t:""}};e&&(s.segmentBackgroundProcess={enable:!1}),i.setOptions(s)}enableBackgroundBlur(e){const t=this.bizControl.pluginManager.get("AliRtcBeauty");if(!t||!t.isEnable)throw new V(Ct.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)}},g(q,"logName","AliRtcEngine"),g(q,"logError",!0),g(q,"isSupported",S0),g(q,"isDualVideoStreamSupported",ls.isSupport),g(q,"getCameraList",()=>w(q,null,function*(){return(yield G.AliRTS.getCameraList()).filter(t=>t.deviceId)})),g(q,"getMicrophoneList",()=>w(q,null,function*(){return(yield G.AliRTS.getMicList()).filter(t=>t.deviceId)})),g(q,"getSpeakerList",()=>w(q,null,function*(){return(yield G.AliRTS.getSpeakerList()).filter(t=>t.deviceId)})),g(q,"_instance"),g(q,"AliRtcSdkChannelProfile",gt),g(q,"AliRtcSdkClientRole",At),g(q,"AliRtcVideoStreamType",Ie),g(q,"AliRtcVideoTrack",ne),g(q,"AliRtcAudioTrack",Zt),g(q,"AliRtcPublishState",Z),g(q,"AliRtcSubscribeState",le),g(q,"AliRtcRawDataStreamType",ve),g(q,"AliRtcLogLevel",$r),g(q,"AliRtcEngineLocalDeviceType",ht),g(q,"AliRtcEngineLocalDeviceExceptionType",Ee),g(q,"AliRtcConnectionStatus",de),g(q,"AliRtcConnectionStatusChangeReason",Nt),g(q,"AliRtcPlugin",Bt),g(q,"AliRtcPluginTrackType",ai),g(q,"AliRtcLiveTranscodingParam",Di),g(q,"AliRtcLiveTranscodingEncodeParam",Yr),g(q,"AliRtcLiveTranscodingMixParam",gn),g(q,"AliRtcLiveTranscodingSingleParam",mn),g(q,"AliRtcTranscodingClockWidget",Sn),g(q,"AliRtcTranscodingImage",gs),g(q,"AliRtcTranscodingText",vn),g(q,"AliRtcTranscodingUser",bn),g(q,"AliRtcLiveTranscodingMixMode",ni),g(q,"AliRtcLiveTranscodingStreamType",Kr),g(q,"AliRtcLiveTranscodingSourceType",Yt),g(q,"AliRtcLiveTranscodingTaskProfile",qr),g(q,"AliRtcLiveTranscodingAudioSampleRate",wi),g(q,"AliRtcLiveTranscodingSegmentType",ci),g(q,"AliRtcLiveTranscodingFontType",ui),g(q,"AliRtcLiveTranscodingCropMode",Jr),g(q,"AliRtcLiveTranscodingMediaProcessMode",Ti),g(q,"AliRtcLiveTranscodingState",Gr),g(q,"AliRtcLiveTranscodingErrorCode",ut),g(q,"AliRtcTrascodingPublishTaskStatus",Xr),g(q,"AliRtcDataChannelMsg",Ft),g(q,"AliRtcDataMsgType",os),g(q,"Plugin",Bt),q);W([T()],z.prototype,"destroy",1),W([T()],z.prototype,"backToUnpublishStatus",1),W([T()],z.prototype,"resumePublishForNetworkRecovery",1),W([T()],z.prototype,"onNetworkRecovery",1),W([T()],z.prototype,"resumeSubList",1),W([T(H)],z.prototype,"retrySubscribe",1),W([T(H)],z.prototype,"setEnableDualVideoStream",1),W([T(H)],z.prototype,"setChannelProfile",1),W([T(H)],z.prototype,"setClientRole",1),W([T(H)],z.prototype,"setAudioOnlyMode",1),W([T()],z.prototype,"clearCheckAuthInfoTimer",1),W([T(H)],z.prototype,"joinChannel",1),W([T(H)],z.prototype,"leaveChannel",1),W([T(H)],z.prototype,"refreshAuthInfo",1),W([T(H)],z.prototype,"publishLocalAudioStream",1),W([T(H)],z.prototype,"setDefaultSubscribeAllRemoteAudioStreams",1),W([T(H)],z.prototype,"subscribeAllRemoteAudioStreams",1),W([T(H)],z.prototype,"subscribeRemoteAudioStream",1),W([T(H)],z.prototype,"resumeRemoteAudioStream",1),W([T(H)],z.prototype,"stopRemoteAudioPlay",1),W([T(H)],z.prototype,"publishLocalVideoStream",1),W([T(H)],z.prototype,"setRemoteDefaultVideoStreamType",1),W([T(H)],z.prototype,"setRemoteUserVideoStreamType",1),W([T(H)],z.prototype,"setDefaultSubscribeAllRemoteVideoStreams",1),W([T(H)],z.prototype,"subscribeAllRemoteVideoStreams",1),W([T(H)],z.prototype,"subscribeRemoteMediaStream",1),W([T(H)],z.prototype,"resumeRemoteMediaStream",1),W([T(([r])=>[`${r==null?void 0:r.audio}`])],z.prototype,"startScreenShare",1),W([T()],z.prototype,"stopScreenShare",1),W([T(H)],z.prototype,"setScreenShareConfiguration",1),W([T(H)],z.prototype,"setScreenShareContentHint",1),W([T()],z.prototype,"publishLocalScreenShareStream",1),W([T(H)],z.prototype,"setAudioShareVolume",1),W([T(H)],z.prototype,"enableAudioVolumeIndication",1),W([T(H)],z.prototype,"muteLocalMic",1),W([T(H)],z.prototype,"muteRemoteAudioPlaying",1),W([T(H)],z.prototype,"muteAllRemoteAudioPlaying",1),W([T(H)],z.prototype,"startAudioCapture",1),W([T(H)],z.prototype,"setAudioConstraints",1),W([T()],z.prototype,"stopAudioCapture",1),W([T(H)],z.prototype,"switchMicrophone",1),W([T(H)],z.prototype,"setRecordingVolume",1),W([T(H)],z.prototype,"setPlayoutVolume",1),W([T(H)],z.prototype,"setRemoteAudioVolume",1),W([T(H)],z.prototype,"setAudioProfile",1),W([T(H)],z.prototype,"getAudioTrack",1),W([T(H)],z.prototype,"setLocalViewConfig",1),W([T(H)],z.prototype,"setCameraCapturerConfiguration",1),W([T(H)],z.prototype,"setCameraCapturerContentHint",1),W([T(H)],z.prototype,"enableLocalVideo",1),W([T(H)],z.prototype,"muteLocalCamera",1),W([T(H)],z.prototype,"muteLocalScreen",1),W([T(H)],z.prototype,"setRemoteViewConfig",1),W([T(H)],z.prototype,"switchCamera",1),W([T()],z.prototype,"startPreview",1),W([T()],z.prototype,"startPreviewScreen",1),W([T()],z.prototype,"stopPreview",1),W([T()],z.prototype,"stopPreviewScreen",1),W([T()],z.prototype,"startPublishLiveStream",1),W([T()],z.prototype,"updatePublishLiveStream",1),W([T()],z.prototype,"updatePublishLiveStreamWithTaskId",1),W([T()],z.prototype,"stopPublishLiveStream",1),W([T()],z.prototype,"stopPublishLiveStreamWithTaskId",1),W([T(H)],z.prototype,"setEnableMediaExtensionMsg",1),W([T(([r,n,e])=>[r.byteLength,n,e])],z.prototype,"sendMediaExtensionMsgEx",1),W([T(([r,n])=>[r.name||"",n])],z.prototype,"enablePlugin",1),W([T(H)],z.prototype,"removePlugin",1),W([T(H)],z.prototype,"setPluginOption",1),W([T(H)],z.prototype,"getPluginOption",1),W([T(H)],z.prototype,"setBeautyEffect",1),W([T(H)],z.prototype,"enableBackgroundExchange",1),W([T(H)],z.prototype,"enableBackgroundBlur",1),W([T(H)],z.prototype,"setParameter",1),W([T(([r])=>{var n;return[(n=r.data)==null?void 0:n.byteLength]})],z.prototype,"sendDataChannelMessage",1),W([T(H)],z,"setLogLevel",1);let Rn=z;const In=new er({businessName:"imp-web-rtc",version:(wn=Rn.getSdkVersion())!=null?wn:"unknown",env:"prod",disabled:window.AliRtcOptionsDisableProxy===!0});In.setReady();const Dc=In.wrap(Rn);$.AliRtcConnectionStatus=de,$.AliRtcConnectionStatusChangeReason=Nt,$.AliRtcDataChannelMsg=Ft,$.AliRtcDataMsgType=os,$.AliRtcEngineLocalDeviceExceptionType=Ee,$.AliRtcEngineLocalDeviceType=ht,$.AliRtcErrorCode=U,$.AliRtcLiveTranscodingAudioSampleRate=wi,$.AliRtcLiveTranscodingCropMode=Jr,$.AliRtcLiveTranscodingEncodeParam=Yr,$.AliRtcLiveTranscodingErrorCode=ut,$.AliRtcLiveTranscodingFontType=ui,$.AliRtcLiveTranscodingMediaProcessMode=Ti,$.AliRtcLiveTranscodingMixMode=ni,$.AliRtcLiveTranscodingMixParam=gn,$.AliRtcLiveTranscodingParam=Di,$.AliRtcLiveTranscodingSegmentType=ci,$.AliRtcLiveTranscodingSingleParam=mn,$.AliRtcLiveTranscodingSourceType=Yt,$.AliRtcLiveTranscodingState=Gr,$.AliRtcLiveTranscodingStreamType=Kr,$.AliRtcLiveTranscodingTaskProfile=qr,$.AliRtcLocalStreamInfo=hs,$.AliRtcLogLevel=$r,$.AliRtcPlugin=Bt,$.AliRtcPluginTrackType=ai,$.AliRtcPluginType=Ka,$.AliRtcPublishState=Z,$.AliRtcRawDataStreamType=ve,$.AliRtcRemoteUserInfo=on,$.AliRtcSdkChannelProfile=gt,$.AliRtcSdkClientRole=At,$.AliRtcSubscribeState=le,$.AliRtcTranscodingClockWidget=Sn,$.AliRtcTranscodingImage=gs,$.AliRtcTranscodingText=vn,$.AliRtcTranscodingUser=bn,$.AliRtcTrascodingPublishTaskStatus=Xr,$.AliRtcVideoStreamType=Ie,$.AliRtcVideoTrack=ne,$.default=Dc,Object.defineProperties($,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
142
|
+
`;class pn extends ds{constructor(e,t){super(e,t);g(this,"processor");g(this,"trackGenerator");g(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([Ac],{type:"text/javascript"}),i=(window.URL||window.webkitURL).createObjectURL(e);this.worker=new Worker(i);const{readable:s}=this.processor,{writable:a}=this.trackGenerator;this.worker.postMessage({type:"startRender",readable:s,writable:a,width:this.targetWidth,height:this.targetHeight,frameRate:this.targetFrameRate},[s,a])}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 ls{static isSupport(){return typeof HTMLCanvasElement.prototype.captureStream=="function"}static getInstance(n,e){return pn.isSupport()?new pn(n,e):fn.isSupport()?new fn(n,e):new gc(n,e)}}class _c extends Bt{constructor(){super(...arguments);g(this,"hasVideoTrack",!1);g(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 ls.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=ls.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 yc=Object.defineProperty,Cc=Object.getOwnPropertyDescriptor,je=(r,n,e,t)=>{for(var i=t>1?void 0:t?Cc(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&yc(n,e,i),i};class ke extends re{constructor(e){super();g(this,"self");g(this,"userMap",{});g(this,"usersViewMap",{});g(this,"rtsManager");g(this,"localStreamManager");g(this,"authInfo");g(this,"signalingManager");g(this,"pluginManager");g(this,"audioMixerPlugin");g(this,"dualVideoPlugin");g(this,"blankAudioPlugin");g(this,"slsReporter");g(this,"statsMonitorId");g(this,"autoSubAudio",!0);g(this,"autoSubVideo",!0);g(this,"autoSubScreen",!0);g(this,"wantSubAudio",!0);g(this,"wantSubVideo",!0);g(this,"wantSubScreen",!0);g(this,"defaultStreamType",Ie.AliRtcVideoStreamTypeHigh);g(this,"audioMuted",!1);g(this,"playoutVolume",1);g(this,"refreshUrlTimer");g(this,"audioVolumeIndicationInterval",0);g(this,"indicationTimer",0);g(this,"parameter",{});const{signalingManager:t,slsReporter:i}=e;this.signalingManager=t,this.addSignalingManagerListener(),this.slsReporter=i,this.pluginManager=new rc,this.localStreamManager=new uc(this.pluginManager,this.slsReporter),this.rtsManager=new nc(this.localStreamManager,this.slsReporter,this.parameter),this.self=new j0({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 _c("dualVideoPlugin"),x0()&&this.pluginManager.add(new hc)}addSignalingManagerListener(){this.signalingManager.on("onNotifyPublish",e=>{e.forEach(t=>{var i;(i=t==null?void 0:t.tracks)==null||i.forEach(s=>{var a;if(s.msid===D.Audio&&s.userdata)try{const c=JSON.parse(s.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(Ke.RECV_NOTIFY_PUBLISH,"","",""),O.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(pe.User)})}isWantSubVideo(){return this.wantSubVideo}setWantSubVideo(e){this.wantSubVideo=e,this.remoteUsers.forEach(t=>{t.setWantSubVideo(e),t.updateSubscribe(pe.User)})}isWantSubScreen(){return this.wantSubScreen}setWantSubScreen(e){this.wantSubScreen=e,this.remoteUsers.forEach(t=>{t.setWantSubScreen(e),t.updateSubscribe(pe.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 s;if(!e)return(s=this.publisher)==null?void 0:s.setViewConfig(null,t);const i=ns(e);i.length!==0&&i.forEach(a=>{var c,o;(c=this.publisher)==null||c.resetElement(a),Object.values(this.usersViewMap).forEach(({cameraViews:u=[],screenViews:h=[]})=>{u.includes(a)&&u.splice(u.indexOf(a),1),h.includes(a)&&h.splice(h.indexOf(a),1)}),(o=this.publisher)==null||o.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 s=ns(t);s.length!==0&&(s.forEach(o=>{var u;(u=this.publisher)==null||u.resetElement(o),Object.values(this.usersViewMap).forEach(({cameraViews:h=[],screenViews:p=[]})=>{h.includes(o)&&h.splice(h.indexOf(o),1),p.includes(o)&&p.splice(p.indexOf(o),1)})}),(c=this.userMap[e])==null||c.setViewConfig(s,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:s,isScreenSubscribing:a}=t;return i||s||a})}onRemotePublishStateChange(e){var d;const{userid:t,callid:i,subscribe:s,pubid:a="",tracks:c}=e,o=(d=s==null?void 0:s.pullstreamurl)!=null?d:"";let u=this.getRemoteUser(t);if(!u)return;const h=u.streamInfo.audioTrackInfo,p=u.streamInfo.videoTrackInfo;u.updateRemoteTracks(i,o,a,c),u.updateSubscribe(pe.Publish),(h!==u.streamInfo.audioTrackInfo||p!==u.streamInfo.videoTrackInfo)&&this.emit("remoteTrackAvailableChange",t,u.streamInfo.audioTrackInfo,u.streamInfo.videoTrackInfo)}setTimeoutToUpdateAllStreamUrls(e){var s;if(!e)return;let t=59*60*1e3;const i=(s=O0(e))==null?void 0:s.timeoutTs;i&&(t=i-Date.now()-60*1e3),this.refreshUrlTimer=window.setTimeout(()=>w(this,null,function*(){var c;const a=yield this.signalingManager.refreshUrl({pushstreamurl:this.self.url,users:this.remoteUsers.map(o=>({userid:o.userId,subscribe:{pullstreamurl:o.streamUrl}}))});a.pushstreamurl&&(this.self.url=a.pushstreamurl),(c=a.users)==null||c.forEach(o=>{var h;const u=this.getRemoteUser(o.userid);u&&((h=o.subscribe)!=null&&h.pullstreamurl)&&(u.streamUrl=o.subscribe.pullstreamurl)}),this.setTimeoutToUpdateAllStreamUrls(a.pushstreamurl)}),t)}init(e,t){this.authInfo=e,this.self.enableAudioVolumeIndication(this.audioVolumeIndicationInterval),this.self.initInfo(e,t.pushstreamurl),this.setTimeoutToUpdateAllStreamUrls(t.pushstreamurl),t.users.forEach(i=>{const s=i.userid;if(s){const a=this.addUser(s,i.displayname,pe.InRoom),{callid:c,subscribe:o,tracks:u}=i;a.updateRemoteTracks(c,(o==null?void 0:o.pullstreamurl)||"","",u),this.emit("remoteTrackAvailableChange",s,a.streamInfo.audioTrackInfo,a.streamInfo.videoTrackInfo)}}),this.startStatsMonitor()}leave(){return w(this,null,function*(){this.stopStatsMonitor(),typeof this.refreshUrlTimer!="undefined"&&(window.clearTimeout(this.refreshUrlTimer),this.refreshUrlTimer=void 0),Object.values(this.usersViewMap).forEach(({cameraViews:e=[],screenViews:t=[]})=>{e.forEach(i=>{i.srcObject=null,i._playPromise=void 0}),t.forEach(i=>{i.srcObject=null,i._playPromise=void 0})}),this.usersViewMap={};for(let e in this.userMap)this.userMap[e]&&(this.userMap[e].clear(),delete this.userMap[e]);this.self.leave(),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:s,candidate:a}=yield this.publisher.getStats();i&&i.length>0&&this.emit("rtcLocalAudioStats",i),s&&s.length>0&&this.emit("rtcLocalVideoStats",s),a&&this.emit("rtcStats",a)}const e=[],t=[];for(const i of this.remoteUsers){const{audio:s,video:a}=yield i.getStats();s&&s.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 s=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 s.on(Ne.Remote,this.onRemoteDeviceStatusChange.bind(this)),s.on(he.PullStreamStats,this.onRemoteStatReport.bind(this)),s.on(he.RtsSubscribeExceeds,this.onSubscribeExceeds.bind(this)),s.on("audioSubscribeStateChanged",(a,c,o,u)=>{this.emit("audioSubscribeStateChanged",a,c,o,u,this.channel||"")}),s.on("videoSubscribeStateChanged",(a,c,o,u)=>{this.emit("videoSubscribeStateChanged",a,c,o,u,this.channel||"")}),s.on("screenSubscribeStateChanged",(a,c,o,u)=>{this.emit("screenSubscribeStateChanged",a,c,o,u,this.channel||"")}),s.on("dataSubscribeStateChanged",(a,c,o,u)=>{this.emit("dataSubscribeStateChanged",a,c,o,u,this.channel||"")}),s.on("remoteAudioAutoPlayFail",a=>{this.emit("remoteAudioAutoPlayFail",a)}),s.on("remoteVideoAutoPlayFail",(a,c)=>{this.emit("remoteVideoAutoPlayFail",a,c)}),s.on("remoteAudioPlayError",(a,c)=>{this.emit("remoteAudioPlayError",a,c)}),s.on("remoteVideoPlayError",(a,c)=>{this.emit("remoteVideoPlayError",a,c)}),s.on("remoteSubscribeError",a=>{this.emit("remoteSubscribeError",a,s.userId)}),s.on("occurError",a=>{this.emit("occurError",a,s.userId)}),s.on("remoteDataChannelMessage",(a,c)=>{this.emit("remoteDataChannelMessage",a,c)}),s.setWantSubAudio(this.autoSubAudio&&this.wantSubAudio),s.setWantSubVideo(this.autoSubVideo&&this.wantSubVideo),s.setWantSubScreen(this.autoSubScreen&&this.wantSubScreen),s.setRemoteDefaultVideoStreamType(this.defaultStreamType),s.setAudioMuted(this.audioMuted),(this.autoSubAudio||this.autoSubVideo||this.autoSubScreen)&&s.updateSubscribe(i),s}onRemoteDeviceStatusChange(e,t){e===he.MuteAudio?this.emit("userAudioMuted",t,!0):e===he.UnmuteAudio?this.emit("userAudioMuted",t,!1):e===he.MuteVideo?this.emit("userVideoMuted",t,!0):e===he.UnmuteVideo?this.emit("userVideoMuted",t,!1):e===he.MuteScreen?this.emit("userScreenMuted",t,!0):e===he.UnmuteScreen&&this.emit("userScreenMuted",t,!1)}onRemoteStatReport(e,t,i){this.emit(he.PullStreamStats,e,t,i)}onSubscribeExceeds(e,t){this.emit(he.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=[],s={};e.forEach(o=>{o.userid&&(this.userMap[o.userid]?(i.push(o),s[o.userid]=this.userMap[o.userid]):(t.push(o),s[o.userid]=this.executeAddUser(o.userid,o.displayname,pe.Resume)))});const a=Object.keys(this.userMap),c=[];return a.forEach(o=>{s[o]||c.push({userid:o,reason:"",leavecode:Qr.AliRtcUserOfflineQuit})}),this.userMap=s,{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 V(U.ERR_INNER,`no remote user(${e}) founded`);i.setWantSubAudio(t),t?i.updateSubscribe(pe.User):i.stopSubscribe({audio:!0})}updateVideoWant(e,t){const i=this.userMap[e];if(!i)throw new V(U.ERR_INNER,`no remote user(${e}) founded`);i.setWantSubVideo(t),t?i.updateSubscribe(pe.User):i.stopSubscribe({video:!0})}updateScreenWant(e,t){const i=this.userMap[e];if(!i)throw new V(U.ERR_INNER,`no remote user(${e}) founded`);i.setWantSubScreen(t),t?i.updateSubscribe(pe.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,s,a;const t=JSON.parse(e);Object.keys(t).forEach(c=>{const o=this.parameter[c],u=t[c];typeof o=="object"&&typeof u=="object"?this.parameter[c]=X(X({},o),u):this.parameter[c]=u}),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((s=this.blankAudioPlugin)==null?void 0:s.name),(a=this.blankAudioPlugin)==null||a.clear(),this.blankAudioPlugin=void 0)}getParameter(){return JSON.stringify(this.parameter)}sendDataChannelMessage(e){return this.self.sendDataChannelMessage(e)}}g(ke,"logName","BizControl"),je([T()],ke.prototype,"init",1),je([T()],ke.prototype,"leave",1),je([T()],ke.prototype,"clear",1),je([T(H)],ke.prototype,"addUser",1),je([T()],ke.prototype,"removeLeftUser",1),je([T()],ke.prototype,"updateUsers",1),je([T(H)],ke.prototype,"updateAudioWant",1),je([T(H)],ke.prototype,"updateVideoWant",1),je([T(H)],ke.prototype,"updateScreenWant",1),je([T()],ke.prototype,"stopIndication",1),je([T()],ke.prototype,"startIndication",1),je([T(H)],ke.prototype,"setEnableDualVideoStream",1),je([T(H)],ke.prototype,"setAudioVolume",1),je([T()],ke.prototype,"enableAudioVolumeIndication",1);const fs=r=>w(this,null,function*(){const n=new Uint8Array(160).fill(170),e=new TextEncoder().encode(r),t=yield window.crypto.subtle.importKey("raw",n,{name:"HMAC",hash:{name:"SHA-1"}},!1,["sign"]),i=yield window.crypto.subtle.sign("HMAC",t,e);return Array.from(new Uint8Array(i)).map(s=>s.toString(16).padStart(2,"0")).join("")});class Rc{constructor(n){g(this,"authInfo");g(this,"slsReporter");this.slsReporter=n}doRequest(n,e){var u;const t=this.authInfo;if(!t)return Promise.reject(ut.LiveTranscodingErrorInvalidParam);const i="https://gw.rtn.aliyuncs.com",s=b0[n],a={appid:t.appId,userid:t.userId,channelid:t.channelId,timestamp:t.timestamp,token:t.token,nonce:t.nonce?t.nonce:"",requestid:Oe.createCallid(),tokensid:!1,session:(u=t.sessionId)!=null?u:Oe.createCallid()},c=Object.keys(a).map(h=>`${h}=${encodeURIComponent(a[h])}`).join("&"),o=`${i}${s}?${c}`;return fetch(o,{method:"POST",headers:{"Content-Type":"application/json; charset=UTF-8"},body:JSON.stringify(e)}).then(h=>h.status!==200?(this.slsReporter.reportTranscodingError(h.status,e.taskid||""),Promise.reject(new V(U.ERR_INNER,`transcoding request failed, status: ${h.status}`))):h).catch(h=>Promise.reject(new V(U.ERR_INNER,`transcoding request failed, err: ${h.message}`)))}setAuthInfo(n){this.authInfo=n}clear(){this.authInfo=void 0}startPublishLiveStream(n,e){return w(this,null,function*(){if(!this.authInfo)return Promise.reject(ut.LiveTranscodingErrorInvalidParam);const t=yield fs(n.split("?")[0]),i=He.MPU_TASK_TRANSACTION_UPDATE,s=e.toJson(i,this.authInfo,t,n);return this.doRequest(i,s)})}startPublishLiveStreamWithTaskId(n,e){return w(this,null,function*(){if(!this.authInfo)return Promise.reject(ut.LiveTranscodingErrorInvalidParam);const t=He.MPU_TASK_TRANSACTION_UPDATE,i=e.toJson(t,this.authInfo,n);return this.doRequest(t,i)})}updatePublishLiveStream(n,e){return w(this,null,function*(){if(!this.authInfo)return Promise.reject(ut.LiveTranscodingErrorInvalidParam);const t=yield fs(n.split("?")[0]),i=He.MPU_TASK_TRANSACTION_UPDATE,s=e.toJson(i,this.authInfo,t,n);return this.doRequest(i,s)})}updatePublishLiveStreamWithTaskId(n,e){return w(this,null,function*(){if(!this.authInfo)return Promise.reject(ut.LiveTranscodingErrorInvalidParam);const t=He.MPU_TASK_TRANSACTION_UPDATE,i=e.toJson(t,this.authInfo,n);return this.doRequest(t,i)})}stopPublishLiveStream(n){return w(this,null,function*(){if(!this.authInfo)return Promise.reject(ut.LiveTranscodingErrorInvalidParam);const e=yield fs(n.split("?")[0]),t=He.MPU_TASK_TRANSACTION_STOP,i=new Di().toJson(t,this.authInfo,e,n);return this.doRequest(t,i)})}stopPublishLiveStreamWithTaskId(n){if(!this.authInfo)return Promise.reject(ut.LiveTranscodingErrorInvalidParam);const e=He.MPU_TASK_TRANSACTION_STOP,t=new Di().toJson(e,this.authInfo,n);return this.doRequest(e,t)}refreshAuthInfo(n){this.authInfo&&this.setAuthInfo(X(X({},this.authInfo),n))}}class ps{static checkString(n){return typeof n=="string"}static checkNumber(n){return typeof n=="number"}static checkHtmlVideoElement(n){return n&&n.nodeName==="VIDEO"}static checkHtmlAudioElement(n){return n&&n.nodeName==="AUDIO"}static checkAuthInfo(n){if(!n)return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no authInfo founded");if(!n.appId)return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no appId founded");if(!n.channelId)return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no channelId founded");if(!n.userId)return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no userId founded");if(n.timestamp){if(!ps.checkNumber(n.timestamp))return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"timestamp is not number")}else return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no timestamp founded");return n.token?null:new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD,"no token founded")}static checkMediaStreamTrack(n){return n instanceof MediaStreamTrack}static checkVideoEncoderConfiguration(n){return n&&(n.width||n.height||n.frameRate||n.bitrateMax)}}class gn{constructor(n){g(this,"taskProfile");g(this,"encodeParam");g(this,"users",[]);g(this,"backgroundColor",0);g(this,"backgrounds",[]);g(this,"watermarks",[]);g(this,"clockWidgets",[]);g(this,"cropMode");g(this,"mediaProcessMode");this.taskProfile=n}}class mn{constructor(n,e,t){g(this,"userId");g(this,"streamType");g(this,"sourceType");this.userId=n,this.streamType=e,this.sourceType=t}}class Sn{constructor(n,e,t,i=0,s=16777215,a=ui.NOTO_SERIF_CJKSC_REGULAR){g(this,"x");g(this,"y");g(this,"fontSize");g(this,"zOrder");g(this,"fontColor");g(this,"fontType");this.x=n,this.y=e,this.fontSize=t,this.zOrder=i,this.fontColor=s,this.fontType=a}toJson(n,e){return{x:Ye(this.x,n),y:Ye(this.y,e),fonttype:this.fontType,fontsize:this.fontSize,fontcolor:Zr(this.fontColor),zorder:this.zOrder}}}var xn=(r=>(r[r.NOT_DISPLAY=0]="NOT_DISPLAY",r[r.ALWAYS=1]="ALWAYS",r[r.WHEN_NO_VIDEO=2]="WHEN_NO_VIDEO",r))(xn||{});class gs{constructor(n,e,t,i,s,a=0,c=1,o=1){g(this,"url");g(this,"x");g(this,"y");g(this,"width");g(this,"height");g(this,"alpha");g(this,"display",1);g(this,"zOrder");this.url=n,this.x=e,this.y=t,this.width=i,this.height=s,this.zOrder=a,this.alpha=c,this.display=o}toJson(n,e){return{url:this.url,alpha:this.alpha,display:this.display,x:Ye(this.x,n),y:Ye(this.y,e),width:Ye(this.width,n),height:Ye(this.height,e),zorder:this.zOrder}}}g(gs,"DisplayType",xn);class vn{constructor(n,e,t,i,s=0,a=16777215,c=ui.NOTO_SERIF_CJKSC_REGULAR){g(this,"text");g(this,"x");g(this,"y");g(this,"fontSize");g(this,"zOrder");g(this,"fontColor");g(this,"fontType");this.text=n,this.x=e,this.y=t,this.fontSize=i,this.zOrder=s,this.fontColor=a,this.fontType=c}toJson(n,e){return{text:this.text,x:Ye(this.x,n),y:Ye(this.y,e),fonttype:this.fontType,fontsize:this.fontSize,fontcolor:Zr(this.fontColor),zorder:this.zOrder}}}class bn{constructor(n,e,t,i,s,a=0,c){g(this,"userId");g(this,"x");g(this,"y");g(this,"width");g(this,"height");g(this,"zOrder");g(this,"sourceType");g(this,"segmentType",ci.LiveTranscodingNoBody);g(this,"images",[]);g(this,"texts",[]);typeof n=="number"?this.userId=n.toString():this.userId=n,this.x=e,this.y=t,this.width=i,this.height=s,this.zOrder=a,c&&(this.sourceType=c)}toJson(n,e,t,i){const s={paneid:n,majorpane:0,x:Ye(this.x,e),y:Ye(this.y,t),width:Ye(this.width,e),height:Ye(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&&oi[this.sourceType]?s.sourcetype=oi[this.sourceType]:s.sourcetype=oi[Yt.LiveTranscodingCamera],this.segmentType&&i===Ti.LiveTranscodingVirtualBackground?s.segmenttype=this.segmentType:s.segmenttype=ci.LiveTranscodingNoBody,s}}const jt=class jt{constructor(){g(this,"ntpClock");this.ntpClock=new G.AliRTS.Clock}static getInstance(){return jt.instance||(jt.instance=new jt),jt.instance}now(){return this.ntpClock.now()}};g(jt,"instance");let ms=jt;const En=()=>ms.getInstance(),{BrowserUtil:Ss,SystenUtil:An}=G.AliRTS;class _n{constructor(){g(this,"tracker");g(this,"param");g(this,"msgCacheArr",[]);g(this,"index",0);g(this,"stsOpt");g(this,"slsToken");g(this,"ossToken");g(this,"ntpClock");this.ntpClock=En()}createTracker(){if(!this.tracker&&this.slsToken&&this.param){const n=this.slsToken;this.ossToken&&(this.param.ossbn=this.ossToken.bucket_name,this.param.ossep=this.ossToken.region_endpoint);const e=new rr({host:n.region_endpoint,project:n.project,logstore:n.log_store_stats}),t={accessKeyId:n.access_key_id,accessKeySecret:n.access_key_secret,securityToken:n.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=Hr(t);e.useStsPlugin(i),this.tracker=e,this.msgCacheArr.forEach((s,a)=>{var c,o;(o=this.tracker)==null||o.send(X(vt(X({},this.param),{stat_log_id:`${((c=this.param)==null?void 0:c.sesid)||"nosession"}-${a}`}),s))}),this.index=this.index+this.msgCacheArr.length,this.msgCacheArr=[]}}start(n){this.initParam(n),this.createTracker()}updateToken(n,e){this.slsToken=n,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(n){var t,i;n.tm=Date.now();let e;try{e=JSON.parse(JSON.stringify(X(vt(X({bt:Ss.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}`}),n)))}catch(s){}if(e){if(!this.tracker){this.msgCacheArr.push(e);return}(i=this.tracker)==null||i.send(e),this.index++}}initParam(n){let e=localStorage==null?void 0:localStorage.getItem("AliRtcUUID");e||(e=it(),localStorage==null||localStorage.setItem("AliRtcUUID",e)),this.param||(this.param={apid:n.appId,usrid:n.userId,statsvrs:"0.6.1",evetid:0,sesid:n.sessionId,sessionId:n.sessionId,channelid:n.channelId,usrn:n.userId,osn:An.systemName,osv:An.systemVersion,deb:l0(),den:u0(),udid:e,sdkvrs:_i,acs:"Unknown",cput:ja(),dm:`${window.location.protocol}//${window.location.host}`,bt:Ss.browserName,bv:Ss.browserVersion,envir:"PRODUCT",args:"",instid:it()})}}const ge=(r,n=1,e=6e4,t=0)=>{let i=r;return i||(i=0),Math.min(e,Math.max(t,Math.round(i*n)))},et=(r,n,e=2e7,t=0)=>{let i=n;(!n||n<0||n>1e4)&&(i=1e3);let s=r;return s||(s=0),Math.min(e,Math.max(t,Math.round(s/(i/1e3))))},Ot=(r,n)=>{if(n===0||!n)return"0.00";let e=r;return(!e||e<0)&&(e=0),(e/n*100).toFixed(2)},yn=r=>r>=0&&r<=1?ge(Math.floor(32767*r),1,32767):0,me=(r,n)=>{var t,i,s;let e=((t=r._last)==null?void 0:t[n])||0;return r.ssrc&&((i=r._last)!=null&&i.ssrc)&&r.ssrc!==((s=r._last)==null?void 0:s.ssrc)&&(e=0),((r==null?void 0:r[n])||0)-e},Ic=(r,n)=>{var e,t,i;return(((e=r==null?void 0:r._source)==null?void 0:e[n])||0)-(((i=(t=r==null?void 0:r._last)==null?void 0:t._source)==null?void 0:i[n])||0)},Cn=(r,n)=>ge(me(r,n),1e3,1e4),Ut=(r,n=2e7)=>ge(r,1,n),mi=class mi{constructor(n){g(this,"engine");g(this,"logClient");g(this,"authInfo");g(this,"ntpClock");g(this,"customFields",{});this.logClient=new _n,this.engine=n,this.ntpClock=En()}static getLogClient(){return this.staticClient||(this.staticClient=new _n),this.staticClient}static reportOSSUpload(n,e,t=0){mi.getLogClient().sendReport({errmsg:`${e}/${n}.log`,errtype:t,evetid:70017,sesid:n,sessionId:n,stat_log_id:`${n}-70017`})}setCustomFields(n){this.customFields=X(X({},this.customFields),n)}getCustomField(n){return this.customFields[n]}start(n){this.authInfo=n,this.logClient.start(n)}updateToken(n,e){this.logClient.updateToken(n,e),mi.getLogClient().updateToken(n,e)}stop(){this.logClient.stop()}reportPublishMonitor(n,e,t,i,s){if(!t||s.length<=0)return;const a=t===D.Audio,c={ctm:Math.floor(s[0].timestamp||0),src:s[0].ssrc||"",codec:s[0]._codec||""},o=[],u=[],h=[],p=[],d=[],f=[],m=[],l=[],S=[],v=[],x=[],b=[],E=[],A=[],y=[],_=[],R=[],L=[],C=[];try{if(s.forEach(I=>{var F,N,Y,j,fe,ee;if(!I||!I.timestamp)return;const P=(F=I._last)!=null&&F.timestamp?I.timestamp-I._last.timestamp:1e3,B=me(I,"bytesSent"),K=me(I,"headerBytesSent"),J=et(ge(B+K,8,2e7),P);o.push(J);const Q=et(ge(B,8,2e7),P);u.push(Q);const ue=et(ge(K,8,2e7),P);h.push(ue);const te=me(I,"packetsSent"),se=et(te,P);p.push(se);const ie=me(I,"packetsLost"),k=et(ie,P);d.push(k);const M=Ot(ie,te);if(f.push(M),a)(N=I._source)!=null&&N.audioLevel&&m.push(yn(I._source.audioLevel)),l.push(0);else{S.push(Cn(I,"totalEncodeTime")),v.push(Ut((Y=I._source)==null?void 0:Y.framesPerSecond,100)),x.push(Ut((j=I._source)==null?void 0:j.framesPerSecond,100)),b.push(Ut(I.framesPerSecond,100)),E.push(Ut((fe=I._source)==null?void 0:fe.height,4400)),A.push(Ut((ee=I._source)==null?void 0:ee.width,7700)),y.push(Ut(I.frameHeight,4400)),_.push(Ut(I.frameWidth,7700));const ze=me(I,"totalPacketSendDelay");R.push(ge(ze,1/(ie||1),2e3));const Je=me(I,"qpSum");L.push(ge(Je,1/(I.framesPerSecond||1),51)),C.push(0)}}),c.sbr=o.join(","),c.mbrs=u.join(","),c.pbrs=h.join(","),c.ps=p.join(","),c.pl=d.join(","),c.plr=f.join(","),a){const I=(i==null?void 0:i.getSettings().sampleRate)||0;c.ailevel=m.join(","),c.arpc=l.join(","),c.arsr=I,c.aesr=I,c.publevel=-90,c.rawlevel=-90}else c.em=S.join(","),c.cfps=v.join(","),c.ifps=x.join(","),c.sfps=b.join(","),c.ih=E.join(","),c.iw=A.join(","),c.sh=y.join(","),c.sw=_.join(","),c.sd=R.join(","),c.aqp=L.join(","),c.caf=C.join(","),c.can=C.join(","),c.cav=u.join(","),c.ifimax=C.join(","),c.ifimin=C.join(","),c.efimax=C.join(","),c.efimin=C.join(","),c.sfimax=C.join(","),c.sfimin=C.join(","),c.apsnr=C.join(",")}catch(I){}this.log({evetid:10070,traceid:e,calid:n,args:this.data2String(X({calid:n,tckid:t,traceid:e},c))})}reportSubscribeMonitor(n,e,t,i,s){if(!i||!s||s.length<=0)return;const a=i===D.Audio,c={ctm:Math.floor(s[0].timestamp||0),src:s[0].ssrc||"",codec:s[0]._codec||""},o=[],u=[],h=[],p=[],d=[],f=[],m=[],l=[],S=[],v=[],x=[],b=[],E=[],A=[],y=[],_=[],R=[],L=[],C=[],I=[],P=[],B=[],K=[],J=[],Q=[],ue=[],te=[],se=[],ie=[],k=[],M=[],F=[],N=[],Y=[];try{s.forEach(j=>{var nt,Kt;if(!j||!j.timestamp)return;const fe=(nt=j._last)!=null&&nt.timestamp?j.timestamp-j._last.timestamp:1e3,ee=me(j,"bytesReceived"),ze=me(j,"headerBytesReceived"),Je=et(ge(ee+ze,8,2e7),fe);o.push(Je);const st=et(ge(ee,8,2e7),fe);u.push(st);const at=et(ge(ze,8,2e7),fe);h.push(at);const ye=me(j,"packetsReceived"),Fe=et(ye,fe);p.push(Fe);const St=me(j,"packetsLost"),zt=et(St,fe);d.push(zt);const ii=Ot(St,ye);f.push(ii);const Wt=me(j,"jitterBufferDelay"),Si=me(j,"jitterBufferEmittedCount");if(j.jitterBufferDelay&&j.jitterBufferEmittedCount){const It=ge(Wt,1e3/Si,1e4);m.push(It)}else m.push(0);const $t=me(j,"fecPacketsReceived");b.push(Ot($t,ye));const Ve=me(j,"retransmittedPacketsReceived"),Pe=ye+St-Ve;if(S.push(Ot(ye-Ve,Pe)),v.push(Ot(St,Pe)),l.push(Ot(Ve,Pe)),x.push(Pe),N.push(0),Y.push(""),a){A.push(yn(j.audioLevel));const It=Ic(j,"synthesizedSamplesEvents");y.push(It);const ot=Cn(j,"synthesizedSamplesDuration");_.push(ot);const xt=Ot(ot,fe);E.push(xt),R.push(0)}else{const It=(Kt=j._last)!=null&&Kt.totalInterFrameDelay?j.totalInterFrameDelay-j._last.totalInterFrameDelay:0;L.push(ge(It,1e3/(j.framesDecoded||30),500)),C.push(ge(j.framesPerSecond,1,100)),I.push(me(j,"framesReceived")),F.push(me(j,"framesRendered")),P.push(ge(j.frameHeight,1,4400)),B.push(ge(j.frameWidth,1,7700));const ot=me(j,"totalProcessingDelay");K.push(ge(ot,1e3/(j.framesDecoded||30),12e4));const xt=me(j,"nackCount");Q.push(xt);const vs=me(j,"pliCount");J.push(vs);const Vi=me(j,"qpSum");ue.push(ge(Vi,1/(j.framesPerSecond||1),51)),te.push(ge(j.framesDropped));const Oi=me(j,"totalFreezesDuration");se.push(ge(Oi,1e3,3e4));const Ge=me(j,"jitterBufferEmittedCount"),wt=me(j,"jitterBufferDelay");wt&&Ge?ie.push(ge(wt,1e3/Ge,3e4)):ie.push(0);const Ui=me(j,"jitterBufferTargetDelay");Ui&&Ge?k.push(ge(Ui,1e3/Ge,3e4)):k.push(0);const xi=me(j,"jitterBufferMinimumDelay");xi&&Ge?M.push(ge(xi,1e3/Ge,3e4)):M.push(0)}}),c.rbr=o.join(","),c.mbrs=u.join(","),c.pbrs=h.join(","),c.pr=p.join(","),c.pl=d.join(","),c.plr=f.join(","),c.jd=m.join(","),c.fecr=b.join(","),c.retransr=l.join(","),c.baser=S.join(","),c.basel=v.join(","),c.recoverr=N.join(","),c.alll=v.join(","),c.totalc=x.join(","),a?(c.er=E.join(","),c.aolevel=A.join(","),c.asrc=R.join(","),c.scnt=y.join(","),c.sdura=_.join(",")):(c.dm=L.join(","),c.dfps=C.join(","),c.rfps=I.join(","),c.rh=P.join(","),c.rw=B.join(","),c.fpt=Y.join(","),c.ns=Q.join(","),c.pliss=J.join(","),c.aqp=ue.join(","),c.ofimax=N.join(","),c.ofimin=N.join(","),c.dfimax=N.join(","),c.dfimin=N.join(","),c.rfimax=N.join(","),c.rfimin=N.join(","),c.vrstutter=se.join(","),c.cdm=ie.join(","),c.tdm=k.join(","),c.pdm=M.join(","),c.ofps=F.join(","),c.dfbd=te.join(","))}catch(j){}this.log({evetid:10080,traceid:t,rmtid:e,calid:n,args:this.data2String(X({calid:n,rmtid:e,tckid:i,traceid:t},c))})}reportNetworkMonitor(n){if(n.length<=0)return;const e=[],t=[],i=[],s=[],a=[],c=[],o=[],u=[],h=[],p=[];n.forEach((f,m)=>{var S;if(!f.timestamp)return;const l=(S=f._last)!=null&&S.timestamp?f.timestamp-f._last.timestamp:1e3;e.push(ge(f.currentRoundTripTime,1e3)),t.push(ge(f.availableOutgoingBitrate,8,2e8)),i.push(et(ge(f.bytesSent,8,2e7),l,25e6)),s.push(et(ge(f.bytesReceived,8,2e7),l,25e6)),a.push(0),c.push(0),m%5===0&&(o.push(""),u.push(""),h.push(""),p.push(""))});const d={ctm:Math.floor(n[0].timestamp||0),rtt:e.join(","),bsps:i.join(","),brps:s.join(","),cpu:o.join(","),mem:u.join(","),sysmem:h.join(","),systotalmem:p.join(","),audioonly:this.engine.isAudioOnly()?1:0};this.log({evetid:10071,args:this.data2String(X({asb:t.join(","),abms:a.join(","),vbms:c.join(",")},d))}),this.log({evetid:10081,args:this.data2String(X({},d))})}reportJoin(n,e,t=""){var p,d;const{start:i,rs:s=0,re:a=0}=e,c=Date.now()-i,o=a-s;let u=0;s&&(u=s-i);let h=0;a&&(h=a-s),this.log({evetid:10010,args:this.data2String({sesid:((p=this.authInfo)==null?void 0:p.sessionId)||"",joitm:c,rslt:n,gslbtm:0,dnstm:0,avcftm:0,gslbrslt:0,dnsrslt:0,avcfrslt:0,mode:2,jrtc:o,usrn:(d=this.authInfo)==null?void 0:d.userId,mgt:"cdn",cttc:u,iptc:h,ndn:1,gslbloc:1,ccag:0,ucag:0,cpg:0,upg:0,tid:t})})}reportJoinConnection(n){this.log({evetid:20002,args:this.data2String(X({transretrynum:0,ldnstc:0,tcptc:0,ssltc:0,url:""},n))})}reportLeave(n,e,t){this.log({evetid:10020,args:this.data2String({lvetm:n,rslt:e,tid:t})})}reportPublish(n,e,t,i,s,a,c,o,u,h,p){this.log({evetid:n?10032:10030,calid:t,args:this.data2String({calid:t,url:e,isvl:i?1:0,isvs:s?1:0,isvss:a?1:0,isaudio:c?1:0,rslt:o,tid:"123",pubtm:Date.now()-p,pctid:u,pubtid:h,isvp:0,isarecording:0,isad:0,isdc:0,pubretry:0,pbrttimes:0})})}reportPublishFirstPacket(n,e,t,i,s,a,c,o,u){const h=Date.now();this.log({evetid:n?10033:10031,calid:e,args:this.data2String({calid:e,fpst:h-t,tckid:a,est:t,pctid:c,pubtid:o,totaltm:h-s,jorm:u===ct.JOIN_CHANNEL?1:0,cptc:0,sptc:i-t,iptc:0,ipc2fptc:0,dctc:0,patc:0})})}reportUnpublish(n,e,t,i){var s;this.log({evetid:10040,args:this.data2String({calid:n,unpubtm:e,rslt:t,tid:i,sesid:((s=this.authInfo)==null?void 0:s.sessionId)||""})})}reportSubscribe(n,e,t,i,s,a,c,o,u,h){this.log({evetid:10050,calid:n,rmtid:e,args:this.data2String(X({calid:n,rmtid:e,isvl:t?1:0,isvs:i?1:0,isvss:s?1:0,isaudio:a?1:0,rslt:c,tid:o,subtm:u,isvp:0,isaplaying:0,isad:0,isdc:0,subretry:0,sbrttimes:0},h))})}reportSubscribeFirstPacket(n,e,t,i,s){this.log({evetid:n?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},s))})}reportSubscribeFirstFrame(n,e,t,i,s){this.log({evetid:n?10055:10052,calid:e,rmtid:t,args:this.data2String(X({calid:e,rmtid:t,tckid:i},s))}),this.log({evetid:n?10058:10057,args:this.data2String(X({calid:e,rmtid:t,tckid:i},s))})}reportUnsubscribe(n,e,t,i,s){this.log({evetid:10060,calid:n,args:this.data2String({calid:n,rmtid:e,unsubtm:t,rslt:i,tid:s})})}reportMute(n,e,t){this.log({evetid:11030,args:this.data2String({calid:n,rmtid:"",enable:e?1:0,mt:t})})}reportRoleUpdate(n,e){this.log({evetid:11040,args:this.data2String({or:n||"",nr:e,ctm:Date.now(),rslt:0})})}reportRoleUpdateResult(n,e,t,i){this.log({evetid:11041,args:this.data2String({or:n||"",nr:e,ctm:t,rslt:i})})}reportVideoProfile(n){this.log({evetid:20074,args:this.data2String({pf:n,tckid:"sophon_camera_large"})})}reportScreenProfile(n){this.log({evetid:20074,args:this.data2String({pf:n,tckid:"sophon_screenshare"})})}reportError(n){this.log({evetid:10091,args:this.data2String({rslt:(n==null?void 0:n.code)||-1})})}reportWarning(n){this.log({evetid:10092,args:this.data2String({rslt:-1,errmsg:n})})}reportRoomServerEvent(n,e,t,i){this.log({evetid:20005,args:this.data2String({calid:"",rmtid:"",rt:n?0:1,dr:n?"s":"r",mt:e,ri:t,cs:1,srt:Date.now(),rspc:(i==null?void 0:i.code)||"",mc:JSON.stringify(i)})})}reportTranscodingError(n,e){this.log({evetid:10101,args:this.data2String({rslt:n,taskid:e})})}reportBye(n){var e;this.log({evetid:10093,args:this.data2String({rslt:n,sesid:((e=this.authInfo)==null?void 0:e.sessionId)||""})})}reportAudio(n,e,t){var i;this.log({evetid:80013,args:this.data2String({rslt:n?-1:0,adm:1,adt:0,adr:n?2:0,acms:e,adrpn:t})}),this.log({evetid:80014,args:this.data2String({sesid:((i=this.authInfo)==null?void 0:i.sessionId)||"",rslt:n?-1:0,adm:1,adt:0,adr:n?2:0,acms:e,adrpn:t})})}reportScreen(n,e){var t,i,s,a;this.log({evetid:90013,args:this.data2String({rslt:n?-1:0,vcms:e,vde:(t=n==null?void 0:n.code)!=null?t:-1,sesid:((i=this.authInfo)==null?void 0:i.sessionId)||""})}),this.log({evetid:90014,args:this.data2String({rslt:n?-1:0,vcms:e,vde:(s=n==null?void 0:n.code)!=null?s:-1,sesid:((a=this.authInfo)==null?void 0:a.sessionId)||""})})}reportScreenStop(n){this.log({evetid:90019,args:this.data2String({rslt:n?n.code||-1:0})}),this.log({evetid:90020,args:this.data2String({rslt:n?n.code||-1:0})})}reportSwitchCamera(n){var e;this.log({evetid:90025,args:this.data2String({rslt:0,td:n,sesid:((e=this.authInfo)==null?void 0:e.sessionId)||""})})}reportPublishProfile(n,e){this.log({evetid:10201,args:this.data2String(X({tckid:n},e))})}reportSDKCreated(n){this.log({evetid:70011,createtm:Date.now()-n,tm:n})}reportJoinInvoked(n){this.log({evetid:70012,jnnonce:n.nonce||"",jntoken:n.token||"",jntm:n.timestamp||""})}reportJoinResult(n){this.log({evetid:70013,rslt:n?n.code||-1:0,dnsrslt:0})}reportSTSResult(n,e){this.log({evetid:70014,rslt:n,asty:1,reqtm:Date.now()-e})}reportLeaveInvoked(){this.log({evetid:70015})}reportSEIMessage(n,e,t,i,s){this.log({evetid:40301,args:this.data2String({tm:Date.now(),sei_pt:n,sei_len:e,sei_rep:t,sei_delay:i,sei_key:s})})}reportConnectionLatencyEvent(n,e,t,i,s,a,c=!1){const o={ageniid:this.getCustomField("ageniid")},u=X({tm:s||Date.now(),ntptm:a||this.ntpClock.now(),stage:n,status:e,calid:t,tckid:i,cltp:1,http:c?1:0},o);this.log({evetid:12001,args:this.data2String(u)})}log(n){n&&(n.tm=new Date().getTime(),O.debug("[ConsoleLogger]","log",n),this.logClient.sendReport(n))}data2String(n){let e="";for(let t in n)e.length&&(e+="&"),e+=t+"="+n[t];return e}};g(mi,"staticClient");let xs=mi;var wc=Object.defineProperty,Tc=Object.getOwnPropertyDescriptor,W=(r,n,e,t)=>{for(var i=t>1?void 0:t?Tc(n,e):n,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(t?a(n,e,i):a(i))||i);return t&&i&&wc(n,e,i),i};const z=(q=class extends re{constructor(e){super();g(this,"channelProfile");g(this,"clientRole");g(this,"signalingManager");g(this,"bizControl");g(this,"liveTranscoding");g(this,"maxSignalingConnectRetryCount");g(this,"slsReporter");g(this,"connectState",de.AliRtcConnectionStatusInit);g(this,"networkError",!1);g(this,"_audioOnlyMode",!1);g(this,"_authInfoWillExpireTimer",null);g(this,"_authInfoExpiredTimer",null);g(this,"_serverCheckAuthInfoTimestamp",null);g(this,"_localCheckAuthInfoTimestamp",null);const t=Date.now();O.init(),this.slsReporter=new xs(this),this.channelProfile=gt.AliRtcSdkCommunication,this.clientRole=At.AliRtcSdkLive,this.liveTranscoding=new Rc(this.slsReporter),this.signalingManager=new ss(this.channelProfile,this.clientRole,this.slsReporter,(e==null?void 0:e.env)===pt.pre?pt.pre:pt.prod),this.addSignalingManagerListeners(),this.maxSignalingConnectRetryCount=e==null?void 0:e.maxSignalingConnectRetryCount,this.bizControl=new ke({slsReporter:this.slsReporter,signalingManager:this.signalingManager}),this.addBizControlListeners(),this.addPublisherListeners(),this.slsReporter.reportConnectionLatencyEvent(Ke.CREATE_ENGINE,Ze.START,"","",t),this.slsReporter.reportConnectionLatencyEvent(Ke.CREATE_ENGINE,Ze.END,"","",Date.now()),this.slsReporter.reportSDKCreated(t)}static getSdkVersion(){return _i}static setLogLevel(e){O.setLogLevel(e)}static getInstance(e){return q._instance||(q._instance=new q(e)),q._instance}destroy(){return w(this,null,function*(){q._instance=void 0,yield this.leaveChannel(),yield this.bizControl.clear(),O.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:!1}get currentRoleCanPublish(){return this.channelProfile===gt.AliRtcSdkCommunication||this.clientRole===At.AliRtcSdkInteractive}addPublisherListeners(){var e,t,i,s,a,c,o,u,h,p;(e=this.publisher)==null||e.on(Ne.Local,d=>{O.event("[Publisher] Device Status Change",d),this.onLocalDeviceStatusChange(d)}),(t=this.publisher)==null||t.on(Vt.VideoTrackEnded,()=>{O.event("[Publisher] VideoTrack Ended"),this.emit("localDeviceException",ht.AliEngineLocalDeviceTypeCamera,Ee.AliEngineLocalDeviceExceptionTypeCameraInterrupt,"")}),(i=this.publisher)==null||i.on(Vt.ScreenTrackEnded,()=>{O.event("[Publisher] ScreenTrack Ended"),this.emit("localDeviceException",ht.AliEngineLocalDeviceTypeDisplay,Ee.AliEngineLocalDeviceExceptionTypeDisplayException,"")}),(s=this.publisher)==null||s.on(Vt.AudioTrackEnded,()=>{O.event("[Publisher] AudioTrack Ended"),this.emit("localDeviceException",ht.AliEngineLocalDeviceTypeMic,Ee.AliEngineLocalDeviceExceptionTypeMicInterrupt,"")}),(a=this.publisher)==null||a.on("localDeviceException",(d,f,m="")=>{this.emit("localDeviceException",d,f,m)}),(c=this.publisher)==null||c.on("audioPublishStateChanged",(d,f,m)=>{var l;this.emit("audioPublishStateChanged",d,f,m,(l=this.channel)!=null?l:"")}),(o=this.publisher)==null||o.on("videoPublishStateChanged",(d,f,m)=>{var l;this.emit("videoPublishStateChanged",d,f,m,(l=this.channel)!=null?l:"")}),(u=this.publisher)==null||u.on("dualStreamPublishStateChanged",(d,f,m)=>{var l;this.emit("dualStreamPublishStateChanged",d,f,m,(l=this.channel)!=null?l:"")}),(h=this.publisher)==null||h.on("screenPublishStateChanged",(d,f,m)=>{var l;this.emit("screenSharePublishStateChanged",d,f,m,(l=this.channel)!=null?l:"")}),(p=this.publisher)==null||p.on("dataPublishStateChanged",(d,f,m)=>{var l;this.emit("dataPublishStateChanged",d,f,m,(l=this.channel)!=null?l:"")})}occurError(e,t){O.event(`[${q.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(ct.RECONNECT),this.remoteUsers.forEach(i=>{i.updateSubscribe(pe.Reconnect)}))}),this.bizControl.rtsManager.on("disconnected",()=>w(this,null,function*(){O.event(`[${q.logName}]`,"RTS Disconnected"),(yield Oe.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 s=this.remoteUsers.find(a=>a.streamUrl===e);s&&this.emit("mediaExtensionMsgReceived",s.userId,i,t)}),this.bizControl.on(Ne.Remote,(e,t)=>{O.event(`[${q.logName}]`,"RemoteUser Device Status Change",e,t)}),this.bizControl.on("remoteTrackAvailableChange",(e,t,i)=>{this.emit("remoteTrackAvailableNotify",e,t,i)}),this.bizControl.on("audioSubscribeStateChanged",(e,t,i,s,a)=>{this.emit("audioSubscribeStateChanged",e,t,i,s,a)}),this.bizControl.on("videoSubscribeStateChanged",(e,t,i,s,a)=>{this.emit("videoSubscribeStateChanged",e,t,i,s,a)}),this.bizControl.on("screenSubscribeStateChanged",(e,t,i,s,a)=>{this.emit("screenShareSubscribeStateChanged",e,t,i,s,a)}),this.bizControl.on("dataSubscribeStateChanged",(e,t,i,s,a)=>{this.emit("dataSubscribeStateChanged",e,t,i,s,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)})}addSignalingManagerListeners(){this.signalingManager.on("onKeepAliveRsp",()=>{this.networkError&&(O.event("[Signaling] Receive KeepAlive Response",`networkError: ${this.networkError}`),this.onNetworkRecovery())}),this.signalingManager.on("onNotifyJoin",e=>{O.event("[Signaling] Notify Join ",e),this.handleUsersJoin(e),e.forEach(t=>{this.emit("remoteUserOnLineNotify",t.userid,0)})}),this.signalingManager.on("onNotifyStatus",e=>{O.event("[Signaling] Notify Status ",e),e.forEach(t=>{this.bizControl.updateRemoteUserDeviceStatus(t)})}),this.signalingManager.on("onNotifyLeave",e=>{O.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)=>{O.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=>{O.event("[Signaling] Connect Failed ",e),this.onError(e),this.backToUnpublishStatus(),this.connectState=de.AliRtcConnectionStatusFailed,this.emit("connectionStatusChange",de.AliRtcConnectionStatusFailed,Nt.AliRtcConnectionChangedNetworkInterrupted)}),this.signalingManager.on("onNetworkError",e=>{this.slsReporter.reportWarning("signaling network error"),O.event("[Signaling] Network error ",e),this.onNetworkError()}),this.signalingManager.on("onAuthInvalid",()=>{O.event("[Signaling] Auth Invalid")}),this.signalingManager.on("onReconnectStart",()=>{O.event("[Signaling] Reconnect Start "),this.connectState=de.AliRtcConnectionStatusReconnecting,this.emit("connectionStatusChange",de.AliRtcConnectionStatusReconnecting,Nt.AliRtcConnectionSignalingConnecting)}),this.signalingManager.on("onReconnectSuccess",e=>{O.event("[Signaling] Reconnect Success ",e),this.onNetworkRecovery(e)}),this.signalingManager.on("onReconnectFail",e=>{this.slsReporter.reportWarning("signaling reconnect fail: ${err.code}"),O.event("[Signaling] Reconnect Failed ",e),e.code===403&&this.emit("authInfoExpired")}),this.signalingManager.on("onError",e=>{this.slsReporter.reportWarning("signaling error: ${err.message}"),O.event("[Signaling] Error ",e),this.onError(e)})}backToUnpublishStatus(){var e,t;this.connectState=de.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 s=this.bizControl.addUser(i,t.displayname,pe.Join);O.event(`[${q.logName}]`,he.UserJoined,s)}})}onLocalDeviceStatusChange(e){O.event(`[${q.logName}]`,Ne.Local,e),this.signalingManager.reportStatus(e).then(()=>{O.debug("[signaling] reportStatus suc")}).catch(t=>{O.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,o)=>{const u=setInterval(()=>w(this,null,function*(){var h;a>1&&(clearInterval(u),o()),a+=1;try{yield(h=this.publisher)==null?void 0:h.resumePublish(),clearInterval(u),c()}catch(p){const{code:d}=p;d!==10205&&(clearInterval(u),o())}}),1e3)})}catch(c){}}throw t}})}onNetworkRecovery(e){return w(this,null,function*(){var t;O.event(q.logName,"onNetworkRecovery",`rts isConnected: ${this.bizControl.rtsManager.isConnected}; rts isConnecting: ${this.bizControl.rtsManager.isConnecting}`,{users:e}),!this.bizControl.rtsManager.isConnected&&!this.bizControl.rtsManager.isConnecting?(this.currentRoleCanPublish&&(yield this.resumePublishForNetworkRecovery()),yield this.resumeSubList()):e&&(yield this.resumeSubList(e)),this.networkError&&(this.networkError=!1,(t=this.publisher)==null||t.reportSelfDeviceStatus(),this.connectState=de.AliRtcConnectionStatusConnected,this.emit("connectionStatusChange",de.AliRtcConnectionStatusConnected,Nt.AliRtcConnectionSignalingHeartbeatAlive))})}resumeSubList(e){return w(this,null,function*(){if(e!=null&&e.length){const{joinList:t,leaveList:i,presentList:s}=this.bizControl.updateUsers(e);O.info(`[${q.logName}]`,"resumeSubList",{joinList:t,leaveList:i,presentList:s}),this.handleUsersJoin(t),i.forEach(a=>{O.event(q.logName,he.UserLeft,a.userid,a.reason),this.emit("remoteUserOffLineNotify",a.userid,Qr.AliRtcUserOfflineQuit)});for(let a=0;a<s.length;a++){const c=s[a],o=c.userid,u=this.bizControl.getRemoteUser(o);this.bizControl.onRemotePublishStateChange(c),u==null||u.updateSubscribe(pe.Resume)}}else for(let t=0;t<this.remoteUsers.length;t++){const i=this.remoteUsers[t];try{i.restore(),i.updateSubscribe(pe.Resume)}catch(s){}}})}retrySubscribe(e){return w(this,null,function*(){const t=this.bizControl.getRemoteUser(e);if(!t)throw new V(U.ERR_INNER,`no remote user(${e}) founded`);t.restore(),t.updateSubscribe(pe.Retry)})}onNetworkError(){this.connectState===de.AliRtcConnectionStatusConnected&&(this.networkError||(this.connectState=de.AliRtcConnectionStatusDisconnected,this.emit("connectionStatusChange",de.AliRtcConnectionStatusDisconnected,Nt.AliRtcConnectionChangedNetworkInterrupted)),this.networkError=!0)}onError(e){this.slsReporter.reportError(e),O.event(q.logName,he.Error,e)}setEnableDualVideoStream(e,t){this.bizControl.setEnableDualVideoStream(e,t)}hadPushStream(e){if(!(this.publisher&&e))throw new V(U.ERR_INNER,"stream is not publishing")}getCurrentMicDeviceId(){var e;return(e=this.publisher)==null?void 0:e.getCurrentMicDeviceId()}setChannelProfile(e){if(![de.AliRtcConnectionStatusInit,de.AliRtcConnectionStatusDisconnected,de.AliRtcConnectionStatusFailed].includes(this.connectState))throw new V(U.ERR_INNER,"cannot set channel profile in call");this.channelProfile=e,this.channelProfile===gt.AliRtcSdkCommunication&&(this.clientRole=At.AliRtcSdkLive),this.signalingManager.setChannelProfile(e)}startAndPublishDefaultDevices(e){return w(this,null,function*(){var c,o,u,h,p;if(!this.publisher)return;const{hasCamera:t,hasMicrophone:i,hasScreenShare:s}=this.publisher;if(!t&&!i&&!s){try{yield(c=this.publisher)==null?void 0:c.startDefaultCamera(this._audioOnlyMode)}catch(d){O.warn(`[${q.logName}]`,"startDefaultCamera failed",d.code,d.message),d instanceof V&&this.occurError(d),this.occurError(new V(U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED,`auto start video failed, ${d.message||""}`))}try{yield(o=this.publisher)==null?void 0:o.startDefaultAudio()}catch(d){O.warn(`[${q.logName}]`,"startDefaultAUdio failed",d.code,d.message),d instanceof V&&this.occurError(d),this.occurError(new V(U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED,`auto start audio failed, ${d.message||""}`))}yield(u=this.publisher)==null?void 0:u.previewAll()}const a=((h=this.publisher)==null?void 0:h.publishStreams)||{};if(Object.values(a).some(d=>d))try{yield(p=this.publisher)==null?void 0:p.startPublish(!1,e)}catch(d){const f=[];a!=null&&a.audio&&f.push(U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED),a!=null&&a.video&&f.push(U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED),f.forEach(m=>{this.occurError(new V(m,`auto publish stream failed, ${d.message||""}`))})}})}setClientRole(e){return w(this,null,function*(){var t,i;try{if(this.channelProfile===gt.AliRtcSdkCommunication)return;if(!Object.values(At).includes(e))throw new V(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===At.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(ct.ROLE_CHANGE)):yield this.signalingManager.setClientRole(e),this.clientRole=e}catch(s){throw s.code===403&&this.emit("authInfoExpired"),s}})}getCurrentClientRole(){return this.clientRole}setAudioOnlyMode(e){if(this.isInCall())throw new V(U.ERR_INNER,"can not change audioOnly mode in call");this._audioOnlyMode=e}setAudioRedEnabled(e){if(this.isInCall())throw new V(U.ERR_INNER,"can not change audioRedEnabled in call");this.bizControl.setAudioRedEnabled(e)}setCheckAuthInfoTimer(e,t){const i=(e-t)*1e3;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){return w(this,null,function*(){var u,h;const i=Date.now();let s,a=t;if(typeof e=="string")try{const p=JSON.parse(window.atob(e));s={appId:p.appid,channelId:p.channelid,userId:p.userid,timestamp:p.timestamp,nonce:p.nonce,token:p.token}}catch(p){throw new V(U.ERR_INVALID_ARGUMENTS,`authInfo is invalid: ${p.message||""}`)}else s=e;a||(a=s.userId);const c={start:Date.now()};let o=ps.checkAuthInfo(s);if(de.AliRtcConnectionStatusInit===this.connectState||de.AliRtcConnectionStatusDisconnected===this.connectState||de.AliRtcConnectionStatusFailed===this.connectState){if(s.sessionId=Oe.createCallid("web"),this.slsReporter.start(s),this.slsReporter.reportConnectionLatencyEvent(Ke.JOIN,Ze.START,"","",i),this.connectState=de.AliRtcConnectionStatusConnecting,o)throw this.connectState=de.AliRtcConnectionStatusFailed,this.slsReporter.reportJoin(o.code,c,""),this.slsReporter.reportJoinResult(o),o;O.setSessionID(s.appId,s.sessionId);try{const p=Date.now(),d=yield this.signalingManager.join(s,a,this.maxSignalingConnectRetryCount,c),f=Date.now();this.connectState=de.AliRtcConnectionStatusConnected,(u=this.publisher)==null||u.reportSelfDeviceStatus(),this.bizControl.init(s,d),this.setCheckAuthInfoTimer(s.timestamp,d.timestamp),this.liveTranscoding.setAuthInfo(s),this.slsReporter.reportJoin(0,c,d.tid),this.slsReporter.reportJoinResult(null),this.slsReporter.reportConnectionLatencyEvent(Ke.JOIN,Ze.SEND_SIG,"","",p),this.slsReporter.reportConnectionLatencyEvent(Ke.JOIN,Ze.RECV_RST,"","",f),this.slsReporter.reportConnectionLatencyEvent(Ke.JOIN,Ze.END,"","")}catch(p){const d=(h=p.code)!=null?h:-1,f=p.reason||p.message||"";throw this.connectState=de.AliRtcConnectionStatusDisconnected,this.slsReporter.reportJoin(d,c,""),this.slsReporter.reportJoinResult(p),new V(d,f)}this.currentRoleCanPublish&&(yield this.startAndPublishDefaultDevices(ct.JOIN_CHANNEL)),this.remoteUsers.forEach(p=>{p.updateSubscribe(pe.Join)})}else{const p=new V(U.ERR_JOIN_ALREADY_JOINED,"already joined");throw this.connectState===de.AliRtcConnectionStatusConnecting&&(p.message="Repeated operation during login"),this.slsReporter.reportJoin(p.code,c,""),p}})}leaveChannel(){return w(this,null,function*(){var t;this.slsReporter.reportLeaveInvoked(),yield this.bizControl.leave();let e=new Date().getTime();if(de.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=de.AliRtcConnectionStatusDisconnected,this.clearCheckAuthInfoTimer(),this.liveTranscoding.clear(),this.slsReporter.stop(),this.signalingManager.reset(),O.reportEnd()})}isInCall(){return this.connectState===de.AliRtcConnectionStatusConnected}refreshAuthInfo(e){return w(this,null,function*(){let t;if(typeof e=="string")try{const h=JSON.parse(window.atob(e));t={userId:h.userid,timestamp:h.timestamp,nonce:h.nonce,token:h.token}}catch(h){throw new V(U.ERR_INVALID_ARGUMENTS,`authInfo is invalid: ${h.message||""}`)}else t=e;const{userId:i,nonce:s,timestamp:a,token:c,role:o}=t,u={userId:i,nonce:s,timestamp:a,token:c,role:o};try{yield this.signalingManager.refreshAuthInfo(u),this.bizControl.refreshAuthInfo(u),this.liveTranscoding.refreshAuthInfo(u),this.clearCheckAuthInfoTimer(),this._serverCheckAuthInfoTimestamp&&this._localCheckAuthInfoTimestamp&&t.timestamp&&this.setCheckAuthInfoTimer(t.timestamp,this._serverCheckAuthInfoTimestamp+(Date.now()-this._localCheckAuthInfoTimestamp))}catch(h){throw h}})}isAudioOnly(){return this._audioOnlyMode}publishLocalAudioStream(e){return w(this,null,function*(){var t,i,s,a;(t=this.publisher)==null||t.setPublishLocalAudioStreamEnabled(e),this.connectState===de.AliRtcConnectionStatusConnected&&(e?(i=this.publisher)!=null&&i.hasMicrophone?yield(s=this.publisher)==null?void 0:s.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 V(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 V(U.ERR_INNER,`no remote user(${e}) founded`);t.resumeAudio()}stopRemoteAudioPlay(e){const t=this.bizControl.getRemoteUser(e);if(!t)throw new V(U.ERR_INNER,`no remote user(${e}) founded`);t.stopPlayAudio()}publishLocalVideoStream(e){return w(this,null,function*(){var t,i,s,a;(t=this.publisher)==null||t.setPublishLocalVideoStreamEnabled(e),this.connectState===de.AliRtcConnectionStatusConnected&&(e?(i=this.publisher)!=null&&i.hasCamera?yield(s=this.publisher)==null?void 0:s.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){[Ie.AliRtcVideoStreamTypeHigh,Ie.AliRtcVideoStreamTypeLow].includes(e)&&this.bizControl.setRemoteDefaultVideoStreamType(e)}setRemoteUserVideoStreamType(e,t){[Ie.AliRtcVideoStreamTypeHigh,Ie.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,s){const a=this.bizControl.getRemoteUser(e);if(!a)throw new V(U.ERR_INNER,`no remote user(${e}) founded`);i&&(t===ne.AliRtcVideoTrackScreen||t===ne.AliRtcVideoTrackBoth)?a.setWantSubScreen(!0):a.setWantSubScreen(!1),i&&(t===ne.AliRtcVideoTrackCamera||t===ne.AliRtcVideoTrackBoth)?a.setWantSubVideo(!0):a.setWantSubVideo(!1),a.setWantSubAudio(s),a.updateSubscribe(pe.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:s,audioTrack:a}=e||{};if(s||a){t.screen=!0;const o=new MediaStream;s&&o.addTrack(s),a&&o.addTrack(a),t.mediaStream=o}else t.screen=i?{audio:!0}:!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,s={};t&&(s.frameRate=t),i&&(s.maxBitrate=i),yield(a=this.publisher)==null?void 0:a.setScreenProfile(s)})}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,s,a;(i=this.publisher)==null||i.setPublishLocalScreenStreamEnabled(e),this.connectState===de.AliRtcConnectionStatusConnected&&(e?(s=this.publisher)!=null&&s.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 V(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;this.isPublishing&&this.onLocalDeviceStatusChange(e?he.MuteAudio:he.UnmuteAudio),(t=this.publisher)==null||t.muteLocalMic(e)}muteRemoteAudioPlaying(e,t=!1){const i=this.bizControl.getRemoteUser(e);if(!i)throw new V(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,s,a,c;if(yield(i=this.publisher)==null?void 0:i.setMicrophoneDeviceId(e),!((s=this.publisher)!=null&&s.audioCaptureDisabled)){if(t){yield(a=this.publisher)==null?void 0:a.createLocalStream({audio:!0,mediaStream:new MediaStream([t])});return}yield(c=this.publisher)==null?void 0:c.createLocalStream({audio:{deviceId:e}})}})}setRecordingVolume(e){if(typeof e!="number")throw new V(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 V(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 V(U.ERR_INNER,`no remote user(${e}) founded`);if(typeof t!="number")throw new V(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,s,a;if(this._audioOnlyMode)throw new V(U.ERR_INNER,"Cannot set local view in audio only mode");(i=this.bizControl)==null||i.setLocalViewConfig(e,t),t===ne.AliRtcVideoTrackCamera&&((s=this.publisher)!=null&&s.hasCamera)?yield this.startPreview():t===ne.AliRtcVideoTrackScreen&&((a=this.publisher)!=null&&a.hasScreenShare)&&(yield this.startPreviewScreen())})}setCameraCapturerConfiguration(e){return w(this,null,function*(){var h,p,d;const u=e,{cameraDirection:t,deviceId:i,bitrate:s,maxSendFrameRate:a}=u,c=qt(u,["cameraDirection","deviceId","bitrate","maxSendFrameRate"]),o=X({},c);s&&(o.maxBitrate=s),a&&(o.maxSendFrameRate=a),Object.keys(o).length>0&&(yield(h=this.publisher)==null?void 0:h.setVideoProfile(o)),t!==void 0&&((p=this.publisher)==null||p.setCameraDirection(t)),i&&((d=this.publisher)==null||d.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,s,a,c,o,u,h,p,d,f;if(this._audioOnlyMode)throw new V(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=(s=this.publisher)==null?void 0:s.publishStreams)==null?void 0:a.video)==null||c.disableVideo(),(p=(h=(u=(o=this.publisher)==null?void 0:o.publishStreams)==null?void 0:u.video)==null?void 0:h.videoTrack)==null||p.stop()),yield(d=this.publisher)==null?void 0:d.startCameraCapture()):yield(f=this.publisher)==null?void 0:f.stopCameraCapture()})}muteLocalCamera(e){return w(this,null,function*(){var t;this.isPublishing&&this.onLocalDeviceStatusChange(e?he.MuteVideo:he.UnmuteVideo),(t=this.publisher)==null||t.muteLocalCamera(e)})}muteLocalScreen(e){return w(this,null,function*(){var t;this.isPublishing&&this.onLocalDeviceStatusChange(e?he.MuteScreen:he.UnmuteScreen),(t=this.publisher)==null||t.muteLocalScreen(e)})}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 s,a,c,o,u,h;if(this._audioOnlyMode)throw new V(U.ERR_INNER,"Cannot switch camera in audio only mode");const i={};if(e?(i.deviceId=e,this.slsReporter.reportSwitchCamera(e)):t||(i.cameraDirection=((s=this.publisher)==null?void 0:s.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)){(u=(o=this.publisher)==null?void 0:o.cameraTrack)==null||u.stop();const p={video:!0};t&&(p.mediaStream=new MediaStream([t])),yield(h=this.publisher)==null?void 0:h.createLocalStream(p)}})}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 V(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 V(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,o,u;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 s=this.bizControl.getRemoteUser(t);return i===ve.AliRtcSdkStreamTypeCapture?(o=s==null?void 0:s.getCameraStream)==null?void 0:o.videoTrack:(u=s==null?void 0:s.getScreenStream)==null?void 0:u.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 s;if(!this.publisher||!this.isPublishing)throw new V(U.ERR_INNER,"you should publish first");return this.slsReporter.reportSEIMessage(i,e.byteLength,t,0,!1),(s=this.publisher)==null?void 0:s.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 V(Ct.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 V(Ct.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 V(Ct.AliRtcPluginErrorNoFindPlugin,"you should enable beautyPlugin first");const s={setSegmentBackgroundImage:{backgroundImgUrl:e?t:""}};e&&(s.segmentBackgroundProcess={enable:!1}),i.setOptions(s)}enableBackgroundBlur(e){const t=this.bizControl.pluginManager.get("AliRtcBeauty");if(!t||!t.isEnable)throw new V(Ct.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)}},g(q,"logName","AliRtcEngine"),g(q,"logError",!0),g(q,"isSupported",S0),g(q,"isDualVideoStreamSupported",ls.isSupport),g(q,"getCameraList",()=>w(q,null,function*(){return(yield G.AliRTS.getCameraList()).filter(t=>t.deviceId)})),g(q,"getMicrophoneList",()=>w(q,null,function*(){return(yield G.AliRTS.getMicList()).filter(t=>t.deviceId)})),g(q,"getSpeakerList",()=>w(q,null,function*(){return(yield G.AliRTS.getSpeakerList()).filter(t=>t.deviceId)})),g(q,"_instance"),g(q,"AliRtcSdkChannelProfile",gt),g(q,"AliRtcSdkClientRole",At),g(q,"AliRtcVideoStreamType",Ie),g(q,"AliRtcVideoTrack",ne),g(q,"AliRtcAudioTrack",Zt),g(q,"AliRtcPublishState",Z),g(q,"AliRtcSubscribeState",le),g(q,"AliRtcRawDataStreamType",ve),g(q,"AliRtcLogLevel",$r),g(q,"AliRtcEngineLocalDeviceType",ht),g(q,"AliRtcEngineLocalDeviceExceptionType",Ee),g(q,"AliRtcConnectionStatus",de),g(q,"AliRtcConnectionStatusChangeReason",Nt),g(q,"AliRtcPlugin",Bt),g(q,"AliRtcPluginTrackType",ai),g(q,"AliRtcLiveTranscodingParam",Di),g(q,"AliRtcLiveTranscodingEncodeParam",Yr),g(q,"AliRtcLiveTranscodingMixParam",gn),g(q,"AliRtcLiveTranscodingSingleParam",mn),g(q,"AliRtcTranscodingClockWidget",Sn),g(q,"AliRtcTranscodingImage",gs),g(q,"AliRtcTranscodingText",vn),g(q,"AliRtcTranscodingUser",bn),g(q,"AliRtcLiveTranscodingMixMode",ni),g(q,"AliRtcLiveTranscodingStreamType",Kr),g(q,"AliRtcLiveTranscodingSourceType",Yt),g(q,"AliRtcLiveTranscodingTaskProfile",qr),g(q,"AliRtcLiveTranscodingAudioSampleRate",wi),g(q,"AliRtcLiveTranscodingSegmentType",ci),g(q,"AliRtcLiveTranscodingFontType",ui),g(q,"AliRtcLiveTranscodingCropMode",Jr),g(q,"AliRtcLiveTranscodingMediaProcessMode",Ti),g(q,"AliRtcLiveTranscodingState",Gr),g(q,"AliRtcLiveTranscodingErrorCode",ut),g(q,"AliRtcTrascodingPublishTaskStatus",Xr),g(q,"AliRtcDataChannelMsg",Ft),g(q,"AliRtcDataMsgType",os),g(q,"Plugin",Bt),q);W([T()],z.prototype,"destroy",1),W([T()],z.prototype,"backToUnpublishStatus",1),W([T()],z.prototype,"resumePublishForNetworkRecovery",1),W([T()],z.prototype,"onNetworkRecovery",1),W([T()],z.prototype,"resumeSubList",1),W([T(H)],z.prototype,"retrySubscribe",1),W([T(H)],z.prototype,"setEnableDualVideoStream",1),W([T(H)],z.prototype,"setChannelProfile",1),W([T(H)],z.prototype,"setClientRole",1),W([T(H)],z.prototype,"setAudioOnlyMode",1),W([T()],z.prototype,"clearCheckAuthInfoTimer",1),W([T(H)],z.prototype,"joinChannel",1),W([T(H)],z.prototype,"leaveChannel",1),W([T(H)],z.prototype,"refreshAuthInfo",1),W([T(H)],z.prototype,"publishLocalAudioStream",1),W([T(H)],z.prototype,"setDefaultSubscribeAllRemoteAudioStreams",1),W([T(H)],z.prototype,"subscribeAllRemoteAudioStreams",1),W([T(H)],z.prototype,"subscribeRemoteAudioStream",1),W([T(H)],z.prototype,"resumeRemoteAudioStream",1),W([T(H)],z.prototype,"stopRemoteAudioPlay",1),W([T(H)],z.prototype,"publishLocalVideoStream",1),W([T(H)],z.prototype,"setRemoteDefaultVideoStreamType",1),W([T(H)],z.prototype,"setRemoteUserVideoStreamType",1),W([T(H)],z.prototype,"setDefaultSubscribeAllRemoteVideoStreams",1),W([T(H)],z.prototype,"subscribeAllRemoteVideoStreams",1),W([T(H)],z.prototype,"subscribeRemoteMediaStream",1),W([T(H)],z.prototype,"resumeRemoteMediaStream",1),W([T(([r])=>[`${r==null?void 0:r.audio}`])],z.prototype,"startScreenShare",1),W([T()],z.prototype,"stopScreenShare",1),W([T(H)],z.prototype,"setScreenShareConfiguration",1),W([T(H)],z.prototype,"setScreenShareContentHint",1),W([T()],z.prototype,"publishLocalScreenShareStream",1),W([T(H)],z.prototype,"setAudioShareVolume",1),W([T(H)],z.prototype,"enableAudioVolumeIndication",1),W([T(H)],z.prototype,"muteLocalMic",1),W([T(H)],z.prototype,"muteRemoteAudioPlaying",1),W([T(H)],z.prototype,"muteAllRemoteAudioPlaying",1),W([T(H)],z.prototype,"startAudioCapture",1),W([T(H)],z.prototype,"setAudioConstraints",1),W([T()],z.prototype,"stopAudioCapture",1),W([T(H)],z.prototype,"switchMicrophone",1),W([T(H)],z.prototype,"setRecordingVolume",1),W([T(H)],z.prototype,"setPlayoutVolume",1),W([T(H)],z.prototype,"setRemoteAudioVolume",1),W([T(H)],z.prototype,"setAudioProfile",1),W([T(H)],z.prototype,"getAudioTrack",1),W([T(H)],z.prototype,"setLocalViewConfig",1),W([T(H)],z.prototype,"setCameraCapturerConfiguration",1),W([T(H)],z.prototype,"setCameraCapturerContentHint",1),W([T(H)],z.prototype,"enableLocalVideo",1),W([T(H)],z.prototype,"muteLocalCamera",1),W([T(H)],z.prototype,"muteLocalScreen",1),W([T(H)],z.prototype,"setRemoteViewConfig",1),W([T(H)],z.prototype,"switchCamera",1),W([T()],z.prototype,"startPreview",1),W([T()],z.prototype,"startPreviewScreen",1),W([T()],z.prototype,"stopPreview",1),W([T()],z.prototype,"stopPreviewScreen",1),W([T()],z.prototype,"startPublishLiveStream",1),W([T()],z.prototype,"updatePublishLiveStream",1),W([T()],z.prototype,"updatePublishLiveStreamWithTaskId",1),W([T()],z.prototype,"stopPublishLiveStream",1),W([T()],z.prototype,"stopPublishLiveStreamWithTaskId",1),W([T(H)],z.prototype,"setEnableMediaExtensionMsg",1),W([T(([r,n,e])=>[r.byteLength,n,e])],z.prototype,"sendMediaExtensionMsgEx",1),W([T(([r,n])=>[r.name||"",n])],z.prototype,"enablePlugin",1),W([T(H)],z.prototype,"removePlugin",1),W([T(H)],z.prototype,"setPluginOption",1),W([T(H)],z.prototype,"getPluginOption",1),W([T(H)],z.prototype,"setBeautyEffect",1),W([T(H)],z.prototype,"enableBackgroundExchange",1),W([T(H)],z.prototype,"enableBackgroundBlur",1),W([T(H)],z.prototype,"setParameter",1),W([T(([r])=>{var n;return[(n=r.data)==null?void 0:n.byteLength]})],z.prototype,"sendDataChannelMessage",1),W([T(H)],z,"setLogLevel",1);let Rn=z;const In=new er({businessName:"imp-web-rtc",version:(wn=Rn.getSdkVersion())!=null?wn:"unknown",env:"prod",disabled:window.AliRtcOptionsDisableProxy===!0});In.setReady();const Dc=In.wrap(Rn);$.AliRtcConnectionStatus=de,$.AliRtcConnectionStatusChangeReason=Nt,$.AliRtcDataChannelMsg=Ft,$.AliRtcDataMsgType=os,$.AliRtcEngineLocalDeviceExceptionType=Ee,$.AliRtcEngineLocalDeviceType=ht,$.AliRtcErrorCode=U,$.AliRtcLiveTranscodingAudioSampleRate=wi,$.AliRtcLiveTranscodingCropMode=Jr,$.AliRtcLiveTranscodingEncodeParam=Yr,$.AliRtcLiveTranscodingErrorCode=ut,$.AliRtcLiveTranscodingFontType=ui,$.AliRtcLiveTranscodingMediaProcessMode=Ti,$.AliRtcLiveTranscodingMixMode=ni,$.AliRtcLiveTranscodingMixParam=gn,$.AliRtcLiveTranscodingParam=Di,$.AliRtcLiveTranscodingSegmentType=ci,$.AliRtcLiveTranscodingSingleParam=mn,$.AliRtcLiveTranscodingSourceType=Yt,$.AliRtcLiveTranscodingState=Gr,$.AliRtcLiveTranscodingStreamType=Kr,$.AliRtcLiveTranscodingTaskProfile=qr,$.AliRtcLocalStreamInfo=hs,$.AliRtcLogLevel=$r,$.AliRtcPlugin=Bt,$.AliRtcPluginTrackType=ai,$.AliRtcPluginType=Ka,$.AliRtcPublishState=Z,$.AliRtcRawDataStreamType=ve,$.AliRtcRemoteUserInfo=on,$.AliRtcSdkChannelProfile=gt,$.AliRtcSdkClientRole=At,$.AliRtcSubscribeState=le,$.AliRtcTranscodingClockWidget=Sn,$.AliRtcTranscodingImage=gs,$.AliRtcTranscodingText=vn,$.AliRtcTranscodingUser=bn,$.AliRtcTrascodingPublishTaskStatus=Xr,$.AliRtcVideoStreamType=Ie,$.AliRtcVideoTrack=ne,$.default=Dc,Object.defineProperties($,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|