var Wn = Object.defineProperty, $n = Object.defineProperties; var Kn = Object.getOwnPropertyDescriptors; var li = Object.getOwnPropertySymbols, qn = Object.getPrototypeOf, Ss = Object.prototype.hasOwnProperty, xs = Object.prototype.propertyIsEnumerable, Jn = Reflect.get; var Bi = (r, a, e) => a in r ? Wn(r, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[a] = e, J = (r, a) => { for (var e in a || (a = {})) Ss.call(a, e) && Bi(r, e, a[e]); if (li) for (var e of li(a)) xs.call(a, e) && Bi(r, e, a[e]); return r; }, ut = (r, a) => $n(r, Kn(a)); var Dt = (r, a) => { var e = {}; for (var t in r) Ss.call(r, t) && a.indexOf(t) < 0 && (e[t] = r[t]); if (r != null && li) for (var t of li(r)) a.indexOf(t) < 0 && xs.call(r, t) && (e[t] = r[t]); return e; }; var g = (r, a, e) => (Bi(r, typeof a != "symbol" ? a + "" : a, e), e); var Ni = (r, a, e) => Jn(qn(r), e, a); var w = (r, a, e) => new Promise((t, i) => { var s = (o) => { try { c(e.next(o)); } catch (u) { i(u); } }, n = (o) => { try { c(e.throw(o)); } catch (u) { i(u); } }, c = (o) => o.done ? t(o.value) : Promise.resolve(o.value).then(s, n); c((e = e.apply(r, a)).next()); }); import { AliRTS as le, EConnectStatus as Mi, EDatachannelStatus as vs } from "aliyun-rts-sdk"; import De from "eventemitter3"; var Gn = Object.defineProperty, Xn = (r, a, e) => a in r ? Gn(r, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[a] = e, Tt = (r, a, e) => (Xn(r, typeof a != "symbol" ? a + "" : a, e), e), Li = { exports: {} }, Fi = { exports: {} }, Vi, bs; function Fe() { if (bs) return Vi; bs = 1, Date.now = Date.now || function() { return (/* @__PURE__ */ new Date()).getTime(); }; var r = Date.now(), a = function() { }, e = function() { var i = typeof console == "object" ? console.warn : a; try { var s = { warn: i }; s.warn.call(s); } catch (n) { return a; } return i; }, t = { noop: a, 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 n = 0, c = i.length; if (this.T(i, "Array")) for (; n < c && s.call(i[n], i[n], n) !== !1; n++) ; else for (n in i) if (s.call(i[n], i[n], n) === !1) break; return i; }, safetyCall: function(i, s, n) { if (typeof i != "function") return n; try { return i.apply(this, s); } catch (c) { return n; } }, T: function(i, s) { var n = Object.prototype.toString.call(i).substring(8).replace("]", ""); return s ? n === s : n; }, duration: function() { var i = Date; try { performance && this.T(performance.now, "Function") && (i = performance); } catch (n) { 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 n = i[s - 1], c = i[0]; if (!c) return ""; if (!n) return c; var o = this, u = o.T(n), h = i.slice(0, s - 1); return u === "Function" ? o.safetyCall(n, h, c) : u === "Array" ? (this.each(n, function(p) { h[0] = c = o.filterByRule.apply(o, [].concat(h, p)); }), c) : u === "Object" ? c.replace(n.rule, n.target || "") : c.replace(n, ""); }, 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 n, c = [], o = 0, u = s.length; o < u; o++) if (n = s[o], this.isString(n)) c.push(n.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1")); else if (n && n.source) c.push(n.source); else if (n && this.T(n) === "Function" && this.safetyCall(n, [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 (n) { } 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, n = s; s && /^\d+(\.\d+)?%$/.test(s) && (n = parseInt(100 / parseFloat(s))), 0 < n && 1 > n && (n = parseInt(1 / n)), n >= 1 && n <= 100 ? i.sample = n : delete i.sample; } return i; }, on: function(i, s, n, c, o) { return i.addEventListener ? (o = o || !1, i.addEventListener(s, function u(h) { c && i.removeEventListener(s, u, o), n.call(this, h); }, o)) : i.attachEvent && i.attachEvent("on" + s, function u(h) { c && i.detachEvent("on" + s, u), n.call(this, h); }), this; }, off: function(i, s, n) { return n ? (i.removeEventListener ? i.removeEventListener(s, n) : i.detachEvent && i.detachEvent(s, n), this) : this; }, delay: function(i, s) { return s === -1 ? (i(), null) : setTimeout(i, s || 0); }, ext: function(i) { for (var s = 1, n = arguments.length; s < n; 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 n = {}; return this.each(i, function(c, o) { s.indexOf(o) !== -1 && (n[o] = c); }), n; }, uu: function() { for (var i, s, n = 20, c = new Array(n), o = Date.now().toString(36).split(""); n-- > 0; ) s = (i = 36 * Math.random() | 0).toString(36), c[n] = 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 (n) { } return i; }, serialize: function(i) { i = i || {}; var s = []; for (var n in i) Object.prototype.hasOwnProperty.call(i, n) && i[n] !== void 0 && s.push(n + "=" + this.encode(i[n], n === "msg")); return s.join("&"); }, checkAPI: function(i, s) { if (!i || typeof i != "string") return !1; var n = /arms-retcode[\w-]*\.aliyuncs/.test(i); return !n && s && (n = /(alicdn\.com)|(mmstat\.com)/.test(i)), !n; }, 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 n = "//" + s.split("/")[2]; return i === s || i.slice(0, s.length + 1) === s + "/" || i === n || i.slice(0, n.length + 1) === n + "/" || !/^(\/\/|http:|https:).*/.test(i); }, getRandIP: function() { for (var i = [], s = 0; s < 4; s++) { var n = Math.floor(256 * Math.random()); i[s] = (n > 15 ? "" : "0") + n.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 = [], n = 0; n < i; n++) { var c = Math.floor(16 * Math.random()); s[n] = c.toString(16); } return s.join(""); }, getCurDomain: function() { return location && location.hostname || ""; }, getSrcType: function(i, s) { var n = location && location.host || ""; if (!n) return ""; var c = new URL(i).host; if (c === n) 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 n = i.keys(), c = n.next(); !c.done; ) { var o = c.value; s[o] = i.get(o), c = n.next(); } else s = i; } catch (u) { s = {}; } return s; }, parseXhrHeaders: function(i) { if (!i && typeof i != "string") return {}; var s = {}; try { var n = i.split(`\r `); s = n.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 = {}, n = [], 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 = (n = u[h].split("="))[0], o = n[1], s[c] = o; } catch (p) { s = {}; } return s; }, getURL: function(i) { if (!i) return null; var s = {}, n = 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 = n), 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 n = s ? this.getURL(s) : null, c = n && n.path ? n.path.lastIndexOf(".") : -1, o = (c > 0 ? n.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, n) { 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(n) }, o = JSON && JSON.stringify(c) || "{}"; } catch (d) { o = "{}"; } return o; }, getXhrSnapshot: function(i, s, n) { if (!i || !s || !n) return {}; var c, o; try { var u = ""; n.responseType === "" || n.responseType === "text" ? u = n.responseText : n.responseType === "document" && (u = n.responseXML), c = { originApi: i, method: s, params: this.getQuerys(i), response: u, reqHeaders: {}, resHeaders: this.parseXhrHeaders(typeof n.getAllResponseHeaders == "function" && n.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(), n = 0; n < i.length; n++) { var c = i[n]; 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, n = [], c = 0, o = i.length; c < o; c++) s = i[c], this.isString(s) ? n.push(s.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1")) : s && s.source && n.push(s.source); return new RegExp(n.join("|"), "i"); }, reWriteMethod: function(i, s, n) { if (i !== null) { var c = i[s]; i[s] = n(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, n) { var c = {}; try { c = this.isPlainObject(i) ? this.ext({ key: i.key || "default", val: i.val || i.value || n }, i, { begin: Date.now() }) : { key: i || "default", val: s || n, begin: Date.now() }; } catch (o) { this.warn("[retcode] baseLog error: " + o); } return c; } }; return Vi = t, Vi; } var Oi = { exports: {} }, Ui = { exports: {} }, Hi, Es; function Yn() { if (Es) return Hi; Es = 1; var r = Fe(); return Hi = function(a, e, t) { typeof a == "object" && (a = r.serialize(a)); var i = e + a + (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"); }, Hi; } var _s; function Zn() { if (_s) return Ui.exports; _s = 1; var r = Fe(), a = Yn(), e = "aokcdqn3ly@e629dabd48a9933", t = function(s, n) { var c; if (n.t === "error" && (c = s.requestQueue[0]) && c.t === "error" && n.msg === c.msg) return n.times = c.times + 1, void (s.requestQueue[0] = n); if (n.t === "behavior") { var o = s.requestQueue && s.requestQueue.length; if (o > 0 && s.requestQueue[o - 1].t === "behavior") { var u = n.behavior || []; s.requestQueue[o - 1].behavior.concat(u); } else s.requestQueue.push(n); } else s.requestQueue.unshift(n); 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 n = s.region, c = s.imgUrl; if (n) { var o = r.regionMap[n]; return s.imgUrl = o || r.defaultImgUrl, s; } return c && (s.imgUrl = c), s; }, checkImgUrl: function() { return !0; }, sendRequest: function() { }, sendBeacon: function(s, n, c) { a(s, n || 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, n = s && s.setUsername; if (typeof n == "function") try { var c = n(); 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, n = Date.now(), c = r.getSortNum(this.record), o = s + n + c + r.getRandNum(this._conf.pid); return this["EagleEye-TraceID"] = o, this.record = c, { "EagleEye-TraceID": o }; }, getUberTraceId: function(s) { var n = this.rip, c = Date.now(), o = r.getSortNum(this.record), u = r.getRandNum(this._conf.pid), h = n + 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 n = this.rip, c = Date.now(), o = r.getSortNum(this.record), u = r.getRandNum(this._conf.pid), h = n + 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 n; clearTimeout(this.requestTimmer), this.requestTimmer = null; for (var c = this._conf && typeof this._conf.sendRequest == "function"; n = this.requestQueue.pop(); ) if (n.t === "res") this.postData(n, "res"); else if (n.t === "error") this.postData(n, "err"); else if (n.t === "api") this.postData(n, "apiSnapshot"); else if (n.t === "behavior") this.postData(n, "behavior"); else if (n.t === "health" && !c && window && window.navigator && typeof window.navigator.sendBeacon == "function") this.sendBeacon(n); else if (n.t === "resource" && !c && window && window.navigator && typeof window.navigator.sendBeacon == "function") { var o = JSON.stringify({ resource: n.resource }); delete n.resource, this.sendBeacon(n, null, o); } else n.t === "resource" ? this.postData(n, "resource") : this.sendRequest(n); return 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, n, 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(n.msg, f) || r.ignoreByRule(r.decode(n.msg), f)) || s === "resourceError" && (r.ignoreByRule(n.src, m) || r.ignoreByRule(r.decode(n.src), m)) || s === "api" && (r.ignoreByRule(n.api, S) || r.ignoreByRule(r.decode(n.api), S)) || !u.checkImgUrl(h.imgUrl) || !n || h.disabled || !h.pid || o === 0) return u; var v = n.dl; if (delete n.dl, n = 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 }, n, 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 (!(n = h.beforeReport(n))) return u; } catch (x) { return u; } return o === 1 ? t(u, n) : c && !u.sampling(c) ? u : t(u, n); }, _self: function(s, n, c) { var o = this, u = o._conf; if (s !== "error" || !o.checkImgUrl(u.imgUrl) || !n || u.disabled || !u.pid || !e || c && !o.sampling(c)) return o; n = r.ext({ t: s, times: 1, page: r.selfErrPage, tag: u.pid, begin: Date.now() }, n, { pid: e, _v: o.ver, sampling: c || 1, z: r.seq() }); var h = o.selfQueue[0]; if (h) { h.times++; try { h.err && n.err && h.err.msg_raw && n.err.msg_raw && h.err.msg_raw.split("&").indexOf(n.err.msg_raw) < 0 && h.err.msg_raw.length < 1e3 && (h.err.msg_raw += "&" + n.err.msg_raw); } catch (p) { } } else o.selfQueue.unshift(n), o.onReady(function() { o.sdkFlag && (o.sdkFlag = !1, o.Timmer = r.delay(function() { o.clearSelf(); }, 1e4)); }); }, custom: function(s, n) { 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, n || 1) : this; } }, Ui.exports = i, Ui.exports; } var As; function Qn() { if (As) return Oi.exports; As = 1; var r = Fe(), a = Zn(), e = ["api", "success", "time", "code", "msg", "trace", "traceId", "begin", "pv_id", "sid", "seq", "domain", "flag", "apiSnapshot", "tag", "c1", "c2", "c3"], t = function(s) { var n = (s.key || "default").split("::"); return n.length > 1 ? r.ext(s, { group: n[0], key: n[1] }) : r.ext(s, { group: "default_group", key: n[0] }); }, i = function(s) { a.call(this, s); var n; try { n = typeof performance == "object" ? performance.timing.fetchStart : Date.now(); } catch (c) { n = Date.now(); } return this._startTime = n, this; }; return i.prototype = r.createObject(a.prototype), r.ext(a.dftCon, { startTime: null }), r.ext(i.prototype, { constructor: i, _super: a, sum: function(s, n, c) { try { var o = r.dealParam(s, n, 1); return this._lg("sum", t(o), c); } catch (u) { r.warn("[retcode] can not get parseStatData: " + u); } }, avg: function(s, n, c) { try { var o = r.dealParam(s, n, 0); return this._lg("avg", t(o), c); } catch (u) { r.warn("[retcode] can not get parseStatData: " + u); } }, percent: function(s, n, c, o) { try { return this._lg("percent", t({ key: s, subkey: n, val: c || 0, begin: Date.now() }), o); } catch (u) { r.warn("[retcode] can not get parseStatData: " + u); } }, msg: function(s, n) { if (s && !(s.length > 180)) return this.custom({ msg: s }, n); }, error: function(s, n) { if (!s) return r.warn("[retcode] invalid param e: " + s), this; arguments.length === 1 ? (typeof s == "string" && (s = { message: s }, n = {}), typeof s == "object" && (n = s = s.error || s)) : (typeof s == "string" && (s = { message: s }), typeof n != "object" && (n = {})); var c = s.name || "CustomError", o = s.message || "", u = s.stack || ""; n = n || {}; var h = typeof location == "object" && typeof location.href == "string" && location.href.substring(0, 500) || ""; if (r.checkSDKError(o, n.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(n.filename || ""), line: n.lineno || "", col: n.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]; n[v] && (m[v] = n[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 n = typeof s == "object" && s.behavior ? s : { behavior: s }; return this.beforeSend && this.beforeSend("behavior", n), this._lg("behavior", n, 1); } }, api: function(s, n, 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: n, 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 _ = s.msg || ""; if (_ = typeof _ == "string" ? _.substring(0, 1e3) : _, s.msg = _, 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, n, c) { var o = this, u = this.getConfig("startTime") || this._startTime; return /^s(\d|1[0])$/.test(s) ? (n = typeof n != "number" ? Date.now() - u : n >= u ? n - u : n, o.speedCache = o.speedCache || {}, o.speedCache[s] = n, 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 n = {}, 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") && (n[u] = s[u]); if (s.autoSend === !0 || !o && (o || this.perfData)) return s.autoSend !== !0 && o === !1 && this.perfData ? (n = r.ext(this.perfData || {}, n), this.hasSendPerf = !0, this._lg("perf", n, this.getConfig("sample"))) : void 0; this.perfData = r.ext(this.perfData || {}, n); } }, resource: function(s, n) { 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, n); }, event: function(s, n) { 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, n); } } }), i._super = a, i._root = a, a.Reporter = i, Oi.exports = i, Oi.exports; } var ji = { exports: {} }, ys; function eo() { if (ys) return ji.exports; ys = 1; var r = Fe(), a = typeof window == "object" ? window : {}, e = "catch", t = a.__oFetch_ || a.fetch; return t = typeof t == "function" ? t : void 0, ji.exports = function(i, s) { var n = -1; typeof i == "object" && (n = i.z, i = r.serialize(i)); var c = s + i; if (t) return t(c, { method: "HEAD", mode: "no-cors" })[e](r.noop); if (a.document && a.document.createElement) { var o = "__request_hold_" + n, u = a[o] = new Image(); u.onload = u.onerror = function() { a[o] = void 0; }, u.src = c, u = null; } }, ji.exports; } var zi = { exports: {} }, Cs; function to() { if (Cs) return zi.exports; Cs = 1; var r = Fe(), a = typeof window == "object" ? window : {}, e = a.__oXMLHttpRequest_ || a.XMLHttpRequest; return e = typeof e == "function" ? e : void 0, zi.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 (n) { r.warn(`[retcode] Failed to log, exception is : ` + n); } }, zi.exports; } var Wi, Rs; function io() { if (Rs) return Wi; Rs = 1; var r = Fe(); return Wi = function(a, e) { var t = [], i = null, s = e && e.location && e.location.href, n = 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 = ""; } 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, _ = 0, y = 3, A = ""; x && E++ < 5 && !((A = u(x)) === "html" || E > 1 && _ + b.length * y + A.length >= 80); ) b.push(A), _ += A.length, x = x.parentNode; return b.reverse().join(" > "); }(l) }, timestamp: Date.now() }; d === "click" ? i && i.addBehavior(S) : d === "keypress" && (n || i && i.addBehavior(S), clearTimeout(n), n = setTimeout(function() { n = 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(a.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), _ = 0; _ < b; _++) E[_] = arguments[_]; var y = { type: "console", data: { level: x, message: E } }; if (i && i.addBehavior(y), x === "error") for (var A = 0; A < E.length; A++) { var R = E[A]; 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; } }); }, Wi; } var Is = {}, ws; function Kr() { return ws || (ws = 1, Is.TIMING_KEYS = ["startTime", "fetchStart", "domainLookupStart", "domainLookupEnd", "connectStart", "connectEnd", "requestStart", "responseStart", "responseEnd", "", "domInteractive", "", "domContentLoadedEventEnd", "", "loadEventStart", "", "msFirstPaint", "secureConnectionStart", "redirectStart", "redirectEnd"]), Is; } var $i, Ds; function ro() { if (Ds) return $i; Ds = 1; var r = Fe(), a = Kr(), e = a.TIMING_KEYS; return $i = function() { var t = r.win || {}, i = t.performance; if (!i || typeof i != "object" || typeof i.getEntriesByType != "function") return null; var s = {}, n = i.timing || {}, c = i.getEntriesByType("resource") || []; if (s.begin = n[e[1]] || Date.now(), typeof t.PerformanceNavigationTiming == "function") { var o = i.getEntriesByType("navigation")[0]; o && (n = o); } return r.each({ dom: [10, 8], load: [14, 1] }, function(u, h) { var p = n[e[u[1]]], d = n[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; }, $i; } var Ki, Ts; function so() { if (Ts) return Ki; Ts = 1; var r = Fe(), a = Kr(), e = a.TIMING_KEYS; return Ki = function() { var t = r.win || {}, i = t.performance; if (!i || typeof i != "object") return null; var s = {}, n = i.timing || {}, c = Date.now(), o = 1; if (typeof t.PerformanceNavigationTiming == "function") { var u = i.getEntriesByType("navigation")[0]; u && (n = 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 = n[e[m[1]]], v = n[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 && n[e[16]] > 0 && n[e[1]] > 0) { var f = n[e[16]] - n[e[1]]; f >= 0 && f < 36e5 && (s.fpt = f); } return o === 1 && n[e[1]] > 0 ? s.begin = n[e[1]] : o === 2 && s.load > 0 ? s.begin = c - s.load : s.begin = c, s; }, Ki; } var Ps, ks; function ao() { return ks || (ks = 1, Ps = function(r, a, e) { var t = Fe(), i = ro(), s = so(), n = null, c = e.documentElement, o = a.innerWidth || c.clientWidth || e.body.clientWidth, u = a.innerHeight || c.clientHeight || e.body.clientHeight, h = a.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, _; if (!d[l]) { E = new RegExp(l + "=([^;]+)"); try { _ = E.exec(e.cookie); } catch (A) { return t.warn("[retcode] can not get cookie:", A), null; } _ && (d[l] = _[1]); } return d[l]; } var y = l + "=" + S; y += "; path=/", v && (y += "; max-age=" + v); try { return e.cookie = y, !!e.cookie; } catch (A) { return t.warn("[retcode] can not set cookie: ", A), !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 n && !l ? this : (n = 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), _ = t.getURL(x), y = { src: x && x.substring(0, 1e3), node_name: b, xpath: E, res_type: t.getResType(b, x), res_name: _.path, domain: _.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: _.domain }), S._lg("resourceError", y), S; } catch (A) { return t.warn("[ARMS] resourceErrorHandler error :", A), 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() > 0.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 = a.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(a, "hashchange", S.hashChangeHandler), t.on(a, "historystatechange", S.stateChangeHandler), S.hashChangeHandler(!1)) : (t.off(a, "hashchange", S.hashChangeHandler), t.off(a, "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(a, "beforeunload", function() { l.handleUnload(0); }), l.bindHashChange(S.enableSPA), l.activeErrHandler(!1), l.hasInitHandler = !0, l; } }), t.on(a, "error", function(l) { n && n.errorHandler(l); }, !1, !0).on(a, "unhandledrejection", function(l) { n && n.errorHandler(l); }), r; }), Ps; } var qi, Bs; function no() { if (Bs) return qi; Bs = 1; var r = Fe(), a = 500; return qi = 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 + 0.5 * d; } return m; } function n(p) { for (var d = 1; d < p.length; d++) if (p[d].score < p[d - 1].score) return p.splice(d, 1), n(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 * a); }(f._startTime, p)) { u.disconnect(), h = 0, o = n(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); }, a); } }); }, qi; } var Ns, Ms; function oo() { return Ms || (Ms = 1, Ns = function(r, a) { var e = Fe(), t = null, i = e.getCurDomain(), s = function(h, p, d, f, m, l, S, v, x, b, E, _, y) { var A = e.J(m) || null, R = e.safetyCall(p, [A, f], null); if (!R) return !1; var M = R.code || l, C = !("success" in R) || R.success; h.api(d, C, S, M, R.msg, v, x, b, C ? {} : E, i, _, y); }, n = "fetch", c = "__oFetch_", o = "__oXMLHttpRequest_", u = "XMLHttpRequest"; return e.ext(r.prototype, { removeHook: function(h, p) { return t && (p || this === t) ? (a[c] && (a[n] = a[c], delete a[c]), a[o] && (a[u] = a[o], delete a[o]), t = null, this) : this; }, addHook: function(h) { return !h && t ? this : (t || (function() { if (typeof a[n] == "function") { var p = a[n]; a[c] = p, a[n] = 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(a, 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 _ = (v.ignore || {}).ignoreApis, y = v.parseTraceId; if (!e.checkAPI(b, !0) || e.ignoreByRule(b, _)) return p.apply(a, m); b = e.filterByRule(b, E, v.ignoreApiPath ? v.ignoreApiPath : v.apiHelper); var A = v.enableLinkTrace, R = "", M = "", C = l.getConfig("pid"), I = null, P = l.getConfig("sample"), B = l.getConfig("linkType"), $ = 1; if (P && !l.sampling(P) && ($ = 0), A) { var q = ""; try { q = location.origin ? location.origin : location.protocol + "//" + location.hostname + (location.port ? ":" + location.port : ""); } catch (G) { q = ""; } var X = e.checkSameOrigin(E, q); if (l.getConfig("enableApiCors") || X) 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 ae = m[0].headers.get("EagleEye-TraceID"), Q = m[0].headers.get("EagleEye-SessionID"), te = m[0].headers.get("EagleEye-pAppName"); ae ? R = ae : (R = l.getTraceId()["EagleEye-TraceID"], m[0].headers.append("EagleEye-TraceID", R)), Q ? M = Q : (M = l.getPageviewId()["EagleEye-SessionID"], m[0].headers.append("EagleEye-SessionID", M)), te || m[0].headers.append("EagleEye-pAppName", C); break; case "b3": var ee = m[0].headers.get("X-B3-TraceId"); if (ee) R = ee; else { var k = l.getB3TraceId($); 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"]; } M = l.pageview; break; case "tracing": default: var L = m[0].headers.get("uber-trace-id"); L ? R = L.split(":")[0] : (L = l.getUberTraceId($), m[0].headers.append("uber-trace-id", L["uber-trace-id"]), R = L.traceId), M = l.pageview; } } catch (G) { e.warn(`[retcode] fetch failed to set header, exception is : ` + G); } 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"] ? M = f.headers["EagleEye-SessionID"] : (M = l.getPageviewId()["EagleEye-SessionID"], f.headers["EagleEye-SessionID"] = M), 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($); 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"]; } M = 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($); f.headers["uber-trace-id"] = N["uber-trace-id"], R = N.traceId; } M = l.getPageviewId()["EagleEye-SessionID"]; } } return p.apply(a, m).then(function(G) { if (!l || !l.api) return G; try { if (!G || typeof G.clone != "function") return G; var j = G.clone(), ce = j.headers; if (ce && typeof ce.get == "function") { var Z = ce.get("content-type"); if (Z && !/(text)|(json)/.test(Z)) return G; if (!R) { var Ve = e.parseFetchHeaders(ce); typeof Ve == "object" && Ve["eagleeye-traceid"] && (R = Ve["eagleeye-traceid"], I = "response"); } } var ze = x(); return j.text().then(function(Qe) { if (!R && e.isFunction(y)) { var et = y(j, Qe); et && e.isString(et) && (R = et); } var xe = e.getFetchSnapshot(m, Qe, ce); j.ok ? s(l, v.parseResponse, b, E, Qe, j.status || 200, ze, S, R, M, xe, I, $) : (l.api(b, !1, ze, j.status || 404, j.statusText, S, R, M, xe, i, I, $), v.enableResource && t.fixResourceStatus && t.fixResourceStatus({ src: j.url, res_type: "api" })); }), G; } catch (Qe) { return e.warn("[ARMS] fetch response error :", Qe), G; } }).catch(function(G) { if (!l || !l.api) throw G; var j = x(); throw l.api(b, !1, j, G.name || "Error", G.message, S, R, M, {}, i), v.enableResource && t.fixResourceStatus && t.fixResourceStatus({ src: E, res_type: "api" }), G; }); }, a[n].toString = e.createFakeToString(n); } }(), function() { if (typeof a[u] == "function") { var p, d = a[u]; a[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, _ = l.send, y = l.open, A = l.setRequestHeader, R = S._conf, M = (R.ignore || {}).ignoreApis, C = R.parseTraceId, I = S.getConfig("enableLinkTrace"), P = "", B = "", $ = "", q = null, X = S.getConfig("sample"), ae = S.getConfig("linkType"), Q = 1; return X && !S.sampling(X) && (Q = 0), l.open = function(te, ee) { p = te; var k = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments); y.apply(l, k), E = ee || "", b = e.cutUrlSearch(E); var L = !e.checkAPI(b, !0) || e.ignoreByRule(b, M); if (b = b ? e.filterByRule(b, E, R.ignoreApiPath ? R.ignoreApiPath : R.apiHelper) : "", !L && I) { var F = ""; try { F = location.origin ? location.origin : location.protocol + "//" + location.hostname + (location.port ? ":" + location.port : ""); } catch (ce) { F = ""; } var N = e.checkSameOrigin(E, F); if ((S.getConfig("enableApiCors") || N) && A && typeof A == "function") switch (ae) { case "arms": P = S.getTraceId()["EagleEye-TraceID"], A.apply(l, ["EagleEye-TraceID", P]), B = S.getPageviewId()["EagleEye-SessionID"], A.apply(l, ["EagleEye-SessionID", B]), $ = S.getConfig("pid"), A.apply(l, ["EagleEye-pAppName", $]); break; case "b3": var G = S.getB3TraceId(Q); A.apply(l, ["X-B3-TraceId", G["X-B3-TraceId"]]), A.apply(l, ["X-B3-ParentSpanId", G["X-B3-ParentSpanId"]]), A.apply(l, ["X-B3-SpanId", G["X-B3-SpanId"]]), A.apply(l, ["X-B3-Sampled", G["X-B3-Sampled"]]), A.apply(l, ["X-Request-ID", e.guid()]), P = G["X-B3-TraceId"], B = S.getPageviewId()["EagleEye-SessionID"]; break; case "tracing": default: var j = S.getUberTraceId(Q); A.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 te = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments); _.apply(l, te); }, e.on(l, "readystatechange", function() { if (b && l.readyState === 4) { var te = x(), ee = 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"], q = "response"); } if (!P && e.isFunction(C)) { var L = C(l); L && e.isString(L) && (P = L); } 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, te, F, "", v, P, B, {}, i, q, Q) : s(S, R.parseResponse, b, E, l.responseText, F, te, v, P, B, ee, q, Q); } else S.api(b, !1, te, l.status || "FAILED", l.statusText, v, P, B, ee, i, q, Q), 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]; }), a[u] = f, a[u].toString = e.createFakeToString(u); } }()), t = this, this); }, initHook: function() { return this.hasInitHook ? this : (this.getConfig("disableHook") || this.addHook(), this.hasInitHook = !0, this); } }), r; }), Ns; } var Ls, Fs; function co() { return Fs || (Fs = 1, Ls = function(r, a) { var e = Fe(), t = a.history || {}, i = a.document, s = function(c, o) { var u; a.CustomEvent ? u = new CustomEvent(c, { detail: o }) : ((u = i.createEvent("HTMLEvents")).initEvent(c, !1, !0), u.detail = o), a.dispatchEvent(u); }, n = 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 (_) { e.warn("[retcode] error in " + c + ": " + _); } return m; }, t[c].toString = e.createFakeToString(c)); }; e.ext(r.prototype, { hackHistoryState: function() { return this.hasHackedHistoryState ? this : (n("pushState"), n("replaceState"), this.hasHackedHistoryState = !0, this); } }); }), Ls; } var Ji, Vs; function uo() { if (Vs) return Ji; Vs = 1; var r = Fe(), a = Kr(), e = a.TIMING_KEYS; return Ji = 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]], _ = o[e[7]], y = o[e[8]], A = o[e[18]], R = o[e[19]]; if (!h.has(o) && (!r.areInOrder(m, l, S, v, x, b, E, _, y) || m > _)) return; if (A < m && (A = m), R < m && (R = l), r.areInOrder(m, A, 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 n = "_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] = /* @__PURE__ */ 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[n] || (this[n] = {}); for (var p = this[n], 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[n] || {}, u = this._conf.resourceSlow || 2e3, h = this[c]; this[n] = {}; 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 || {}, _ = h.get(b.timing), y = _ ? _.success : 1, A = 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), A && (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 = A, x.timings.push(R); } catch (M) { } }), 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")); } } }); }, Ji; } var Os; function ho() { if (Os) return Fi.exports; Os = 1; var r = Fe(), a = Qn(), e = eo(), t = to(), i = r.win, s = i.document, n = /^(error|api|speed|sum|avg|percent|custom|msg|setPage|setConfig|behavior|performance)$/, c = function(o) { var u = this; return a.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(a.prototype), r.ext(a._root.dftCon, { uid: null, setUsername: null, ignoreUrlPath: null, ignoreApiPath: null, urlHelper: [{ rule: /\/([a-z\-_]+)?\d{2,20}/g, target: "/$1**" }, /\/$/], resourceHelper: [], apiHelper: { rule: /\/([a-z\-_]+)?\d{2,20}/g, target: "/$1**" }, ignoreUrlCase: !0, imgUrl: "https://arms-retcode.aliyuncs.com/r.png?", cdnHostList: [], resourceTypes: ["css", "script", "img", "font"], resourceSlow: 2e3, disableHook: !1, autoSendPv: !0, autoSendPerf: !0, enableSPA: !1, enableLinkTrace: !1, linkType: "arms", enableApiCors: !1, sendResource: !0, behavior: !0, enableConsole: !1, parseHash: function(o) { return (o ? 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: a, 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 (!n.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; } }), io()(c, i), ao()(c, i, s), no()(c, i, s), oo()(c, i), co()(c, i), uo()(c, i), c._super = a, c._root = a._root, a.Browser = c, Fi.exports = c, Fi.exports; } var Us; function lo() { if (Us) return Li.exports; Us = 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 a() { 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 = ho(), i = Fe().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 n = typeof window == "object" && !!window.navigator; return n && e[i] && (t.bl = a()), Li.exports = t, Li.exports; } function fo() { return lo(); } var po = { getArmsLogger: fo }; const Hs = "https://arms-retcode.aliyuncs.com/r.png?", js = "https://arms-retcode-sg.aliyuncs.com/r.png?", zs = "https://retcode-us-west-1.arms.aliyuncs.com/r.png?", Ws = "e1iftji1w7@7ec1cef2cc88733", $s = "e1iftji1w7@10a06d1ec260adc", Ks = "e1iftji1w7@10a06d1ec260adc", Gi = { cn: { reportUrl: Hs, pid: Ws }, "cn-hangzhou": { reportUrl: Hs, pid: Ws }, sg: { reportUrl: js, pid: $s }, "ap-southeast-1": { reportUrl: js, pid: $s }, usw: { reportUrl: zs, pid: Ks }, "us-west-1": { reportUrl: zs, pid: Ks } }, go = (r) => r !== null && typeof r == "object", mo = (r) => Object.prototype.toString.call(r).slice(8, -1), So = (r) => Object.isExtensible(r) ? mo(r) === "Object" : !1; function xo(r, a, e) { var n; if (Reflect.get(r, "__v_skip") === !0) return r; const t = [], i = typeof Object.getOwnPropertyDescriptors == "function" ? Object.getOwnPropertyDescriptors((n = Object.getPrototypeOf(r)) != null ? n : {}) : {}; 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, a, e); } return a > 10 ? c[o] : ft(c[o], a, e); }, MediaboxWrapperObjectSetter(c, o, u) { return c[o] = ft(u, a, 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 vo(r, a, e) { const t = { MediaboxWrapperFunctionApply(i, s, n) { let c; try { c = Reflect.apply(i, s, n); } catch (o) { throw e(o), o; } return ft(c, a, e); }, MediaboxWrapperFunctionGet(i, s) { const n = Object.getOwnPropertyDescriptor(i, s); return n && !n.writable && !n.configurable ? i[s] : ft(i[s], a, e); }, MediaboxWrapperClassConstructor(i, s) { let n; try { n = new i(...s); } catch (c) { throw e(c), c; } return ft(n, a, e); } }; return new Proxy(r, { apply: t.MediaboxWrapperFunctionApply, get: t.MediaboxWrapperFunctionGet, construct: t.MediaboxWrapperClassConstructor }); } function bo(r, a) { if (typeof r != "string") return a; if (on(r, a)) return r; const e = r.indexOf(` `); return e < 0 ? `${r}${a}` : `${r.slice(0, e)}${a}${r.slice(e)}`; } function on(r, a) { if (typeof r != "string") return !1; const e = r.indexOf(a); if (e < 0) return !1; const t = r.indexOf(` `); return t < 0 ? !0 : e < t; } function ft(r, a, e) { return typeof r == "function" ? vo(r, a + 1, e) : r instanceof Promise ? r.then((t) => ft(t, a + 1, e)).catch((t) => (e(t), Promise.reject(t))) : Array.isArray(r) ? (r.forEach((t, i) => { r[i] = ft(t, a + 1, e); }), r) : go(r) && So(r) ? xo(r, a + 1, e) : r; } function Eo(r) { return typeof r != "string" ? !1 : r.indexOf("g.alicdn.com/apsara-media-") > -1 || r.indexOf("g.alicdn.com/thor-server") > -1; } function qs(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 Js extends Error { constructor(a) { super(a), this.name = "MQTError"; } } let _o = 1; class qr { constructor(a) { var e, t; Tt(this, "armsLogger"), Tt(this, "isReady", !1), Tt(this, "isDestroyed", !1), Tt(this, "options"), Tt(this, "queue", []), Tt(this, "marker"), Tt(this, "helper", { MediaboxWrapperQueue(i) { return new Js(i); }, MediaboxWrapperInitiative(i) { return new Js(i); } }), this.options = ut(J({}, a), { region: a.deferRegionSet ? void 0 : (e = a.region) != null ? e : "cn", env: (t = a.env) != null ? t : "prod" }), this.marker = `-${_o++}-`, this.initArmsLogger(); } static get version() { return "0.23.0"; } initArmsLogger(a) { const { region: e, env: t, disabled: i } = this.options; if (i || this.armsLogger) return; if (a && !e) throw new Error("region is required"); if (!e) return; if (!Gi[e]) throw new Error(`region ${e} is not supported`); const s = (c) => { var o; if (this.isDestroyed || on(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 = qr.version, this.options.customData && (c.c3 = new URLSearchParams(this.options.customData).toString()), c.t === "error") { if (Eo(c.file) || qs(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; }, n = po.getArmsLogger(); this.armsLogger = n.createExtraInstance({ enableInstanceAutoSend: !0, pid: Gi[e].pid, tag: this.options.businessName, release: `${this.options.businessName}_${this.options.version}`, // release 参数只能初始化时设置 // appType: "web", imgUrl: Gi[e].reportUrl, // sendResource: true, behavior: !0, sample: 1, // 100% 采样 disableHook: !0, // 禁止对 xhr, fetch 进行覆盖 environment: t, // (可选)拦截不想上报的数据,返回 null、undefined、0、false 等,会取消本次上报 beforeReport: s }); } wrap(a) { return this.options.disabled || typeof Proxy > "u" ? a : ft(a, 0, (e) => { var t; e instanceof Error && typeof e.stack == "string" && qs(e.stack) && ((t = this.armsLogger) == null || t.error(e), e.stack = bo(e.stack, this.marker)); }); } updateOptions(a) { this.options = J(J({}, this.options), a); } setReady() { this.initArmsLogger(!0), this.isReady = !0, this.queue.length && this.queue.forEach((a) => { var e; (e = this.armsLogger) == null || e.error(this.helper.MediaboxWrapperQueue(a.msg), { filename: a.file, lineno: a.line, colno: a.col }); }); } // 主动上报 report(a, e) { var t; (t = this.armsLogger) == null || t.error( this.helper.MediaboxWrapperInitiative(a), e ); } destroy() { this.isDestroyed = !0; } } var oe = /* @__PURE__ */ ((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))(oe || {}), Le = /* @__PURE__ */ ((r) => (r.Local = "local-device-status-change", r.Remote = "remote-device-status-change", r))(Le || {}), T = /* @__PURE__ */ ((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))(T || {}), Jr = /* @__PURE__ */ ((r) => (r.Audio = "rts audio", r.VideoLarge = "rts video", r))(Jr || {}), xt = /* @__PURE__ */ ((r) => (r.Add = "add", r.Delete = "delete", r.Replace = "replace", r.Stop = "stop", r.UnPublish = "unpublish", r))(xt || {}), Jt = /* @__PURE__ */ ((r) => (r[r.Camera = 0] = "Camera", r[r.Screen = 1] = "Screen", r[r.Image = 2] = "Image", r))(Jt || {}), xi = /* @__PURE__ */ ((r) => (r[r.Microphone = 0] = "Microphone", r[r.Screen = 1] = "Screen", r[r.Mixed = 2] = "Mixed", r))(xi || {}), de = /* @__PURE__ */ ((r) => (r.InRoom = "inRoom", r.Join = "join", r.Publish = "publish", r.User = "user", r.Resume = "resume", r.Retry = "retry", r.Reconnect = "reconnect", r))(de || {}), nt = /* @__PURE__ */ ((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))(nt || {}), Ie = []; for (var Xi = 0; Xi < 256; ++Xi) Ie.push((Xi + 256).toString(16).slice(1)); function Ao(r, a = 0) { return (Ie[r[a + 0]] + Ie[r[a + 1]] + Ie[r[a + 2]] + Ie[r[a + 3]] + "-" + Ie[r[a + 4]] + Ie[r[a + 5]] + "-" + Ie[r[a + 6]] + Ie[r[a + 7]] + "-" + Ie[r[a + 8]] + Ie[r[a + 9]] + "-" + Ie[r[a + 10]] + Ie[r[a + 11]] + Ie[r[a + 12]] + Ie[r[a + 13]] + Ie[r[a + 14]] + Ie[r[a + 15]]).toLowerCase(); } var fi, yo = new Uint8Array(16); function Co() { if (!fi && (fi = typeof crypto != "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !fi)) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported"); return fi(yo); } var Ro = typeof crypto != "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto); const Gs = { randomUUID: Ro }; function rt(r, a, e) { if (Gs.randomUUID && !a && !r) return Gs.randomUUID(); r = r || {}; var t = r.random || (r.rng || Co)(); if (t[6] = t[6] & 15 | 64, t[8] = t[8] & 63 | 128, a) { e = e || 0; for (var i = 0; i < 16; ++i) a[e + i] = t[i]; return a; } return Ao(t); } var vi = /* @__PURE__ */ ((r) => (r.prod = "rs.rtn.aliyuncs.com", r.pre = "prs.rtn.aliyuncs.com", r))(vi || {}); const yi = "6.14.6", Xs = "web"; class He { /** * 将版本号转换为number */ static getVersionNumber() { let a = yi.split("."), e = ""; return a.forEach((t) => { t.length === 1 ? e += "0" + t : e += t; }), parseInt(e); } /** * * @param param * @returns */ static queryingParam(a) { let e = []; if (a) for (let t in a) e.push(t + "=" + a[t]); return e.join("&"); } /** * * @param param * @returns */ static getQueryParams(a) { 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]) === a) return decodeURIComponent(s[1]); } } /** * 生成Sub Callid * 每次Sub都会重新生成这个Callid * @returns */ static createCallid(a = "") { const e = rt(); return a && e && e.length > a.length ? `${a}${e.substring(a.length)}` : e; } /** * 检查订阅配置是否合法 * @param {SubscribeOptions} options * @returns {boolean} */ static checkSubOptionsValid(a) { if (a) { const { audio: e, video: t, screen: i } = a; if (e === !1 && t === !1 && i === !1) return !1; } return !0; } /** * 检查网络是否正常 * @returns {Promise} */ static isNetworkAvailable() { return w(this, null, function* () { const a = vi.prod, { onLine: e } = navigator; if (!e) return !1; try { return yield fetch(`https://${a}/roomserver/v1/ws/version`), !0; } catch (t) { return !1; } }); } /** * 安全转换为字符串 * * @param {*} obj * @return {string} */ static toString(a) { let e; if (a instanceof Error) e = a.message; else if (typeof a == "string") e = a; else try { e = JSON.stringify(a); } catch (t) { e = "undefined"; } return e; } /** * 将参数数组安全转换为字符串 * @param {any[]} rest * @return {string} * @memberof AliRtcUtil */ static paramArrayToString(a) { let e = ""; for (let t = 0; t < a.length; t++) { e !== "" && (e += " "); let i = He.toString(a[t]); e += i; } return e; } } function Ys(r, a, e) { Object.defineProperty(r, a, { writable: !0, enumerable: !0, configurable: !0, value: e }); } function cn(r, a, e, t) { t ? t(() => { Ys(r, a, e); }) : Ys(r, a, e); } Array(32); class Io { constructor(a) { this.timer = null, this.time = 10, this.count = 10, this.arr = []; var e, t; this.time = (e = a.time) != null ? e : 10, this.count = (t = a.count) != null ? t : 10, a.host.startsWith("http://") || a.host.startsWith("https://") ? this.url = a.host + "/logstores/" + a.logstore + "/track" : this.url = "https://" + a.project + "." + a.host + "/logstores/" + a.logstore + "/track", this.opt = a, a.installUnloadHook && typeof a.installUnloadHook == "function" && a.installUnloadHook(() => { this.sendImmediateInner(); }); } assemblePayload(a) { const e = { __logs__: a }; return this.opt.tags && (e.__tags__ = this.opt.tags), this.opt.topic && (e.__topic__ = this.opt.topic), this.opt.source && (e.__source__ = this.opt.source), JSON.stringify(e); } platformSend() { if (this.opt.sendPayload && typeof this.opt.sendPayload == "function") { const a = this.assemblePayload(this.arr); this.opt.sendPayload(this.url, a); } } transString(a) { let e = {}; for (let t in a) typeof a[t] == "object" ? e[t] = JSON.stringify(a[t]) : e[t] = String(a[t]); return e; } sendImmediateInner() { this.arr && this.arr.length > 0 && (this.platformSend(), this.timer != null && (clearTimeout(this.timer), this.timer = null), this.arr = []); } sendInner() { if (this.timer) this.arr.length >= this.count && (clearTimeout(this.timer), this.timer = null, this.sendImmediateInner()); else { const a = this; this.arr.length >= this.count || this.time <= 0 ? this.sendImmediateInner() : this.timer = setTimeout(function() { a.sendImmediateInner(); }, this.time * 1e3); } } send(a) { const e = this.transString(a); this.arr.push(e), this.sendInner(); } sendImmediate(a) { const e = this.transString(a); this.arr.push(e), this.sendImmediateInner(); } sendBatchLogs(a) { const e = a.map((t) => this.transString(t)); this.arr.push(...e), this.sendInner(); } sendBatchLogsImmediate(a) { const e = a.map((t) => this.transString(t)); this.arr.push(...e), this.sendImmediateInner(); } overwriteTransString(a) { this.transString = a.transString; } getOpt() { return this.opt; } } var wo = (r, a, e) => new Promise((t, i) => { var s = (o) => { try { c(e.next(o)); } catch (u) { i(u); } }, n = (o) => { try { c(e.throw(o)); } catch (u) { i(u); } }, c = (o) => o.done ? t(o.value) : Promise.resolve(o.value).then(s, n); c((e = e.apply(r, a)).next()); }); function Do(r, a) { return navigator && navigator.sendBeacon ? navigator.sendBeacon(`${r}?APIVersion=0.6.0`, a) : !1; } function Zs(r, a) { const e = new window.XMLHttpRequest(); e.open("POST", `${r}?APIVersion=0.6.0`, !0), e.send(a); } function To(r, a) { try { if (a.length >= 32768) { Zs(r, a); return; } Do(r, a) || Zs(r, a); } catch (e) { window && window.console && typeof window.console.error == "function" && (console.error(`Failed to log to ali log service because of this exception: ` + e), console.error("Failed log data:", r)); } } function Po(r, a, e) { return wo(this, null, function* () { try { r = r.slice(0, -6); const { data: t, header: i } = yield e.process(r, a), s = new window.XMLHttpRequest(); s.open("POST", r, !0); for (let n in i) s.setRequestHeader(n, i[n]); 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: ` + t), console.error("Failed log data:", r)); } }); } class Gr extends Io { constructor(a) { const e = Object.assign({}, a, { installUnloadHook: (t) => { window.addEventListener("beforeunload", () => { t(); }); }, sendPayload: (t, i) => { To(t, i); } }); super(e); } useStsPlugin(a) { this.getOpt().sendPayload = (e, t) => { Po(e, t, a); }, this.overwriteTransString(a); } } cn(window, "SLS_Tracker", Gr); var ie = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {}; function ko(r) { return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r; } function Bo(r) { if (r.__esModule) return r; var a = r.default; if (typeof a == "function") { var e = function t() { return this instanceof t ? Reflect.construct(a, arguments, this.constructor) : a.apply(this, arguments); }; e.prototype = a.prototype; } else e = {}; return Object.defineProperty(e, "__esModule", { value: !0 }), Object.keys(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 un = { exports: {} }; function No(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 Yi = { exports: {} }; const Mo = {}, Lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: Mo }, Symbol.toStringTag, { value: "Module" })), Fo = /* @__PURE__ */ Bo(Lo); var Qs; function ne() { return Qs || (Qs = 1, function(r, a) { (function(e, t) { r.exports = t(); })(ie, 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 ie != "undefined" && ie.crypto && (s = ie.crypto), !s && typeof No == "function") try { s = Fo; } catch (x) { } var n = 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 { /** * Creates a new object that inherits from this object. * * @param {Object} overrides Properties to copy into the new object. * * @return {Object} The new object. * * @static * * @example * * var MyType = CryptoJS.lib.Base.extend({ * field: 'value', * * method: function () { * } * }); */ 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; }, /** * Extends this object and runs the init method. * Arguments to create() will be passed to init(). * * @return {Object} The new object. * * @static * * @example * * var instance = MyType.create(); */ create: function() { var x = this.extend(); return x.init.apply(x, arguments), x; }, /** * Initializes a newly created object. * Override this method to add some logic when your objects are created. * * @example * * var MyType = CryptoJS.lib.Base.extend({ * init: function () { * // ... * } * }); */ init: function() { }, /** * Copies properties into this object. * * @param {Object} properties The properties to mix in. * * @example * * MyType.mixIn({ * field: 'value' * }); */ mixIn: function(x) { for (var b in x) x.hasOwnProperty(b) && (this[b] = x[b]); x.hasOwnProperty("toString") && (this.toString = x.toString); }, /** * Creates a copy of this object. * * @return {Object} The clone. * * @example * * var clone = instance.clone(); */ clone: function() { return this.init.prototype.extend(this); } }; }(), p = u.WordArray = h.extend({ /** * Initializes a newly created word array. * * @param {Array} words (Optional) An array of 32-bit words. * @param {number} sigBytes (Optional) The number of significant bytes in the words. * * @example * * var wordArray = CryptoJS.lib.WordArray.create(); * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]); * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6); */ init: function(x, b) { x = this.words = x || [], b != i ? this.sigBytes = b : this.sigBytes = x.length * 4; }, /** * Converts this word array to a string. * * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex * * @return {string} The stringified word array. * * @example * * var string = wordArray + ''; * var string = wordArray.toString(); * var string = wordArray.toString(CryptoJS.enc.Utf8); */ toString: function(x) { return (x || f).stringify(this); }, /** * Concatenates a word array to this word array. * * @param {WordArray} wordArray The word array to append. * * @return {WordArray} This word array. * * @example * * wordArray1.concat(wordArray2); */ concat: function(x) { var b = this.words, E = x.words, _ = this.sigBytes, y = x.sigBytes; if (this.clamp(), _ % 4) for (var A = 0; A < y; A++) { var R = E[A >>> 2] >>> 24 - A % 4 * 8 & 255; b[_ + A >>> 2] |= R << 24 - (_ + A) % 4 * 8; } else for (var M = 0; M < y; M += 4) b[_ + M >>> 2] = E[M >>> 2]; return this.sigBytes += y, this; }, /** * Removes insignificant bits. * * @example * * wordArray.clamp(); */ clamp: function() { var x = this.words, b = this.sigBytes; x[b >>> 2] &= 4294967295 << 32 - b % 4 * 8, x.length = t.ceil(b / 4); }, /** * Creates a copy of this word array. * * @return {WordArray} The clone. * * @example * * var clone = wordArray.clone(); */ clone: function() { var x = h.clone.call(this); return x.words = this.words.slice(0), x; }, /** * Creates a word array filled with random bytes. * * @param {number} nBytes The number of random bytes to generate. * * @return {WordArray} The random word array. * * @static * * @example * * var wordArray = CryptoJS.lib.WordArray.random(16); */ random: function(x) { for (var b = [], E = 0; E < x; E += 4) b.push(n()); return new p.init(b, x); } }), d = o.enc = {}, f = d.Hex = { /** * Converts a word array to a hex string. * * @param {WordArray} wordArray The word array. * * @return {string} The hex string. * * @static * * @example * * var hexString = CryptoJS.enc.Hex.stringify(wordArray); */ stringify: function(x) { for (var b = x.words, E = x.sigBytes, _ = [], y = 0; y < E; y++) { var A = b[y >>> 2] >>> 24 - y % 4 * 8 & 255; _.push((A >>> 4).toString(16)), _.push((A & 15).toString(16)); } return _.join(""); }, /** * Converts a hex string to a word array. * * @param {string} hexStr The hex string. * * @return {WordArray} The word array. * * @static * * @example * * var wordArray = CryptoJS.enc.Hex.parse(hexString); */ parse: function(x) { for (var b = x.length, E = [], _ = 0; _ < b; _ += 2) E[_ >>> 3] |= parseInt(x.substr(_, 2), 16) << 24 - _ % 8 * 4; return new p.init(E, b / 2); } }, m = d.Latin1 = { /** * Converts a word array to a Latin1 string. * * @param {WordArray} wordArray The word array. * * @return {string} The Latin1 string. * * @static * * @example * * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray); */ stringify: function(x) { for (var b = x.words, E = x.sigBytes, _ = [], y = 0; y < E; y++) { var A = b[y >>> 2] >>> 24 - y % 4 * 8 & 255; _.push(String.fromCharCode(A)); } return _.join(""); }, /** * Converts a Latin1 string to a word array. * * @param {string} latin1Str The Latin1 string. * * @return {WordArray} The word array. * * @static * * @example * * var wordArray = CryptoJS.enc.Latin1.parse(latin1String); */ parse: function(x) { for (var b = x.length, E = [], _ = 0; _ < b; _++) E[_ >>> 2] |= (x.charCodeAt(_) & 255) << 24 - _ % 4 * 8; return new p.init(E, b); } }, l = d.Utf8 = { /** * Converts a word array to a UTF-8 string. * * @param {WordArray} wordArray The word array. * * @return {string} The UTF-8 string. * * @static * * @example * * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray); */ stringify: function(x) { try { return decodeURIComponent(escape(m.stringify(x))); } catch (b) { throw new Error("Malformed UTF-8 data"); } }, /** * Converts a UTF-8 string to a word array. * * @param {string} utf8Str The UTF-8 string. * * @return {WordArray} The word array. * * @static * * @example * * var wordArray = CryptoJS.enc.Utf8.parse(utf8String); */ parse: function(x) { return m.parse(unescape(encodeURIComponent(x))); } }, S = u.BufferedBlockAlgorithm = h.extend({ /** * Resets this block algorithm's data buffer to its initial state. * * @example * * bufferedBlockAlgorithm.reset(); */ reset: function() { this._data = new p.init(), this._nDataBytes = 0; }, /** * Adds new data to this block algorithm's buffer. * * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8. * * @example * * bufferedBlockAlgorithm._append('data'); * bufferedBlockAlgorithm._append(wordArray); */ _append: function(x) { typeof x == "string" && (x = l.parse(x)), this._data.concat(x), this._nDataBytes += x.sigBytes; }, /** * Processes available data blocks. * * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype. * * @param {boolean} doFlush Whether all blocks and partial blocks should be processed. * * @return {WordArray} The processed data. * * @example * * var processedData = bufferedBlockAlgorithm._process(); * var processedData = bufferedBlockAlgorithm._process(!!'flush'); */ _process: function(x) { var b, E = this._data, _ = E.words, y = E.sigBytes, A = this.blockSize, R = A * 4, M = y / R; x ? M = t.ceil(M) : M = t.max((M | 0) - this._minBufferSize, 0); var C = M * A, I = t.min(C * 4, y); if (C) { for (var P = 0; P < C; P += A) this._doProcessBlock(_, P); b = _.splice(0, C), E.sigBytes -= I; } return new p.init(b, I); }, /** * Creates a copy of this object. * * @return {Object} The clone. * * @example * * var clone = bufferedBlockAlgorithm.clone(); */ clone: function() { var x = h.clone.call(this); return x._data = this._data.clone(), x; }, _minBufferSize: 0 }); u.Hasher = S.extend({ /** * Configuration options. */ cfg: h.extend(), /** * Initializes a newly created hasher. * * @param {Object} cfg (Optional) The configuration options to use for this hash computation. * * @example * * var hasher = CryptoJS.algo.SHA256.create(); */ init: function(x) { this.cfg = this.cfg.extend(x), this.reset(); }, /** * Resets this hasher to its initial state. * * @example * * hasher.reset(); */ reset: function() { S.reset.call(this), this._doReset(); }, /** * Updates this hasher with a message. * * @param {WordArray|string} messageUpdate The message to append. * * @return {Hasher} This hasher. * * @example * * hasher.update('message'); * hasher.update(wordArray); */ update: function(x) { return this._append(x), this._process(), this; }, /** * Finalizes the hash computation. * Note that the finalize operation is effectively a destructive, read-once operation. * * @param {WordArray|string} messageUpdate (Optional) A final message update. * * @return {WordArray} The hash. * * @example * * var hash = hasher.finalize(); * var hash = hasher.finalize('message'); * var hash = hasher.finalize(wordArray); */ finalize: function(x) { x && this._append(x); var b = this._doFinalize(); return b; }, blockSize: 16, /** * Creates a shortcut function to a hasher's object interface. * * @param {Hasher} hasher The hasher to create a helper for. * * @return {Function} The shortcut function. * * @static * * @example * * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); */ _createHelper: function(x) { return function(b, E) { return new x.init(E).finalize(b); }; }, /** * Creates a shortcut function to the HMAC's object interface. * * @param {Hasher} hasher The hasher to use in this HMAC helper. * * @return {Function} The shortcut function. * * @static * * @example * * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); */ _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; }); }(Yi)), Yi.exports; } var Zi = { exports: {} }, ea; function Ci() { return ea || (ea = 1, function(r, a) { (function(e, t) { r.exports = t(ne()); })(ie, function(e) { return function(t) { var i = e, s = i.lib, n = s.Base, c = s.WordArray, o = i.x64 = {}; o.Word = n.extend({ /** * Initializes a newly created 64-bit word. * * @param {number} high The high 32 bits. * @param {number} low The low 32 bits. * * @example * * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607); */ init: function(u, h) { this.high = u, this.low = h; } /** * Bitwise NOTs this word. * * @return {X64Word} A new x64-Word object after negating. * * @example * * var negated = x64Word.not(); */ // not: function () { // var high = ~this.high; // var low = ~this.low; // return X64Word.create(high, low); // }, /** * Bitwise ANDs this word with the passed word. * * @param {X64Word} word The x64-Word to AND with this word. * * @return {X64Word} A new x64-Word object after ANDing. * * @example * * var anded = x64Word.and(anotherX64Word); */ // and: function (word) { // var high = this.high & word.high; // var low = this.low & word.low; // return X64Word.create(high, low); // }, /** * Bitwise ORs this word with the passed word. * * @param {X64Word} word The x64-Word to OR with this word. * * @return {X64Word} A new x64-Word object after ORing. * * @example * * var ored = x64Word.or(anotherX64Word); */ // or: function (word) { // var high = this.high | word.high; // var low = this.low | word.low; // return X64Word.create(high, low); // }, /** * Bitwise XORs this word with the passed word. * * @param {X64Word} word The x64-Word to XOR with this word. * * @return {X64Word} A new x64-Word object after XORing. * * @example * * var xored = x64Word.xor(anotherX64Word); */ // xor: function (word) { // var high = this.high ^ word.high; // var low = this.low ^ word.low; // return X64Word.create(high, low); // }, /** * Shifts this word n bits to the left. * * @param {number} n The number of bits to shift. * * @return {X64Word} A new x64-Word object after shifting. * * @example * * var shifted = x64Word.shiftL(25); */ // shiftL: function (n) { // if (n < 32) { // var high = (this.high << n) | (this.low >>> (32 - n)); // var low = this.low << n; // } else { // var high = this.low << (n - 32); // var low = 0; // } // return X64Word.create(high, low); // }, /** * Shifts this word n bits to the right. * * @param {number} n The number of bits to shift. * * @return {X64Word} A new x64-Word object after shifting. * * @example * * var shifted = x64Word.shiftR(7); */ // shiftR: function (n) { // if (n < 32) { // var low = (this.low >>> n) | (this.high << (32 - n)); // var high = this.high >>> n; // } else { // var low = this.high >>> (n - 32); // var high = 0; // } // return X64Word.create(high, low); // }, /** * Rotates this word n bits to the left. * * @param {number} n The number of bits to rotate. * * @return {X64Word} A new x64-Word object after rotating. * * @example * * var rotated = x64Word.rotL(25); */ // rotL: function (n) { // return this.shiftL(n).or(this.shiftR(64 - n)); // }, /** * Rotates this word n bits to the right. * * @param {number} n The number of bits to rotate. * * @return {X64Word} A new x64-Word object after rotating. * * @example * * var rotated = x64Word.rotR(7); */ // rotR: function (n) { // return this.shiftR(n).or(this.shiftL(64 - n)); // }, /** * Adds this word with the passed word. * * @param {X64Word} word The x64-Word to add with this word. * * @return {X64Word} A new x64-Word object after adding. * * @example * * var added = x64Word.add(anotherX64Word); */ // add: function (word) { // var low = (this.low + word.low) | 0; // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0; // var high = (this.high + word.high + carry) | 0; // return X64Word.create(high, low); // } }), o.WordArray = n.extend({ /** * Initializes a newly created word array. * * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects. * @param {number} sigBytes (Optional) The number of significant bytes in the words. * * @example * * var wordArray = CryptoJS.x64.WordArray.create(); * * var wordArray = CryptoJS.x64.WordArray.create([ * CryptoJS.x64.Word.create(0x00010203, 0x04050607), * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) * ]); * * var wordArray = CryptoJS.x64.WordArray.create([ * CryptoJS.x64.Word.create(0x00010203, 0x04050607), * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) * ], 10); */ init: function(u, h) { u = this.words = u || [], h != t ? this.sigBytes = h : this.sigBytes = u.length * 8; }, /** * Converts this 64-bit word array to a 32-bit word array. * * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array. * * @example * * var x32WordArray = x64WordArray.toX32(); */ 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); }, /** * Creates a copy of this word array. * * @return {X64WordArray} The clone. * * @example * * var clone = x64WordArray.clone(); */ clone: function() { for (var u = n.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; }); }(Zi)), Zi.exports; } var Qi = { exports: {} }, ta; function Vo() { return ta || (ta = 1, function(r, a) { (function(e, t) { r.exports = t(ne()); })(ie, function(e) { return function() { if (typeof ArrayBuffer == "function") { var t = e, i = t.lib, s = i.WordArray, n = 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; n.call(this, h, u); } else n.apply(this, arguments); }; c.prototype = s; } }(), e.lib.WordArray; }); }(Qi)), Qi.exports; } var er = { exports: {} }, ia; function Oo() { return ia || (ia = 1, function(r, a) { (function(e, t) { r.exports = t(ne()); })(ie, function(e) { return function() { var t = e, i = t.lib, s = i.WordArray, n = t.enc; n.Utf16 = n.Utf16BE = { /** * Converts a word array to a UTF-16 BE string. * * @param {WordArray} wordArray The word array. * * @return {string} The UTF-16 BE string. * * @static * * @example * * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray); */ 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(""); }, /** * Converts a UTF-16 BE string to a word array. * * @param {string} utf16Str The UTF-16 BE string. * * @return {WordArray} The word array. * * @static * * @example * * var wordArray = CryptoJS.enc.Utf16.parse(utf16String); */ 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); } }, n.Utf16LE = { /** * Converts a word array to a UTF-16 LE string. * * @param {WordArray} wordArray The word array. * * @return {string} The UTF-16 LE string. * * @static * * @example * * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray); */ 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(""); }, /** * Converts a UTF-16 LE string to a word array. * * @param {string} utf16Str The UTF-16 LE string. * * @return {WordArray} The word array. * * @static * * @example * * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str); */ 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; }); }(er)), er.exports; } var tr = { exports: {} }, ra; function Ot() { return ra || (ra = 1, function(r, a) { (function(e, t) { r.exports = t(ne()); })(ie, function(e) { return function() { var t = e, i = t.lib, s = i.WordArray, n = t.enc; n.Base64 = { /** * Converts a word array to a Base64 string. * * @param {WordArray} wordArray The word array. * * @return {string} The Base64 string. * * @static * * @example * * var base64String = CryptoJS.enc.Base64.stringify(wordArray); */ 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 * 0.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(""); }, /** * Converts a Base64 string to a word array. * * @param {string} base64Str The Base64 string. * * @return {WordArray} The word array. * * @static * * @example * * var wordArray = CryptoJS.enc.Base64.parse(base64String); */ 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; }); }(tr)), tr.exports; } var ir = { exports: {} }, sa; function Uo() { return sa || (sa = 1, function(r, a) { (function(e, t) { r.exports = t(ne()); })(ie, function(e) { return function() { var t = e, i = t.lib, s = i.WordArray, n = t.enc; n.Base64url = { /** * Converts a word array to a Base64url string. * * @param {WordArray} wordArray The word array. * * @param {boolean} urlSafe Whether to use url safe * * @return {string} The Base64url string. * * @static * * @example * * var base64String = CryptoJS.enc.Base64url.stringify(wordArray); */ 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 * 0.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(""); }, /** * Converts a Base64url string to a word array. * * @param {string} base64Str The Base64url string. * * @param {boolean} urlSafe Whether to use url safe * * @return {WordArray} The word array. * * @static * * @example * * var wordArray = CryptoJS.enc.Base64url.parse(base64String); */ 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; }); }(ir)), ir.exports; } var rr = { exports: {} }, aa; function Ut() { return aa || (aa = 1, function(r, a) { (function(e, t) { r.exports = t(ne()); })(ie, function(e) { return function(t) { var i = e, s = i.lib, n = 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 n.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, _ = l[S + 0], y = l[S + 1], A = l[S + 2], R = l[S + 3], M = l[S + 4], C = l[S + 5], I = l[S + 6], P = l[S + 7], B = l[S + 8], $ = l[S + 9], q = l[S + 10], X = l[S + 11], ae = l[S + 12], Q = l[S + 13], te = l[S + 14], ee = l[S + 15], k = E[0], L = E[1], F = E[2], N = E[3]; k = p(k, L, F, N, _, 7, u[0]), N = p(N, k, L, F, y, 12, u[1]), F = p(F, N, k, L, A, 17, u[2]), L = p(L, F, N, k, R, 22, u[3]), k = p(k, L, F, N, M, 7, u[4]), N = p(N, k, L, F, C, 12, u[5]), F = p(F, N, k, L, I, 17, u[6]), L = p(L, F, N, k, P, 22, u[7]), k = p(k, L, F, N, B, 7, u[8]), N = p(N, k, L, F, $, 12, u[9]), F = p(F, N, k, L, q, 17, u[10]), L = p(L, F, N, k, X, 22, u[11]), k = p(k, L, F, N, ae, 7, u[12]), N = p(N, k, L, F, Q, 12, u[13]), F = p(F, N, k, L, te, 17, u[14]), L = p(L, F, N, k, ee, 22, u[15]), k = d(k, L, F, N, y, 5, u[16]), N = d(N, k, L, F, I, 9, u[17]), F = d(F, N, k, L, X, 14, u[18]), L = d(L, F, N, k, _, 20, u[19]), k = d(k, L, F, N, C, 5, u[20]), N = d(N, k, L, F, q, 9, u[21]), F = d(F, N, k, L, ee, 14, u[22]), L = d(L, F, N, k, M, 20, u[23]), k = d(k, L, F, N, $, 5, u[24]), N = d(N, k, L, F, te, 9, u[25]), F = d(F, N, k, L, R, 14, u[26]), L = d(L, F, N, k, B, 20, u[27]), k = d(k, L, F, N, Q, 5, u[28]), N = d(N, k, L, F, A, 9, u[29]), F = d(F, N, k, L, P, 14, u[30]), L = d(L, F, N, k, ae, 20, u[31]), k = f(k, L, F, N, C, 4, u[32]), N = f(N, k, L, F, B, 11, u[33]), F = f(F, N, k, L, X, 16, u[34]), L = f(L, F, N, k, te, 23, u[35]), k = f(k, L, F, N, y, 4, u[36]), N = f(N, k, L, F, M, 11, u[37]), F = f(F, N, k, L, P, 16, u[38]), L = f(L, F, N, k, q, 23, u[39]), k = f(k, L, F, N, Q, 4, u[40]), N = f(N, k, L, F, _, 11, u[41]), F = f(F, N, k, L, R, 16, u[42]), L = f(L, F, N, k, I, 23, u[43]), k = f(k, L, F, N, $, 4, u[44]), N = f(N, k, L, F, ae, 11, u[45]), F = f(F, N, k, L, ee, 16, u[46]), L = f(L, F, N, k, A, 23, u[47]), k = m(k, L, F, N, _, 6, u[48]), N = m(N, k, L, F, P, 10, u[49]), F = m(F, N, k, L, te, 15, u[50]), L = m(L, F, N, k, C, 21, u[51]), k = m(k, L, F, N, ae, 6, u[52]), N = m(N, k, L, F, R, 10, u[53]), F = m(F, N, k, L, q, 15, u[54]), L = m(L, F, N, k, y, 21, u[55]), k = m(k, L, F, N, B, 6, u[56]), N = m(N, k, L, F, ee, 10, u[57]), F = m(F, N, k, L, I, 15, u[58]), L = m(L, F, N, k, Q, 21, u[59]), k = m(k, L, F, N, M, 6, u[60]), N = m(N, k, L, F, X, 10, u[61]), F = m(F, N, k, L, A, 15, u[62]), L = m(L, F, N, k, $, 21, u[63]), E[0] = E[0] + k | 0, E[1] = E[1] + L | 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 _ = this._hash, y = _.words, A = 0; A < 4; A++) { var R = y[A]; y[A] = (R << 8 | R >>> 24) & 16711935 | (R << 24 | R >>> 8) & 4278255360; } return _; }, clone: function() { var l = c.clone.call(this); return l._hash = this._hash.clone(), l; } }); function p(l, S, v, x, b, E, _) { var y = l + (S & v | ~S & x) + b + _; return (y << E | y >>> 32 - E) + S; } function d(l, S, v, x, b, E, _) { var y = l + (S & x | v & ~x) + b + _; return (y << E | y >>> 32 - E) + S; } function f(l, S, v, x, b, E, _) { var y = l + (S ^ v ^ x) + b + _; return (y << E | y >>> 32 - E) + S; } function m(l, S, v, x, b, E, _) { var y = l + (v ^ (S | ~x)) + b + _; return (y << E | y >>> 32 - E) + S; } i.MD5 = c._createHelper(h), i.HmacMD5 = c._createHmacHelper(h); }(Math), e.MD5; }); }(rr)), rr.exports; } var sr = { exports: {} }, na; function hn() { return na || (na = 1, function(r, a) { (function(e, t) { r.exports = t(ne()); })(ie, function(e) { return function() { var t = e, i = t.lib, s = i.WordArray, n = i.Hasher, c = t.algo, o = [], u = c.SHA1 = n.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 = n.clone.call(this); return h._hash = this._hash.clone(), h; } }); t.SHA1 = n._createHelper(u), t.HmacSHA1 = n._createHmacHelper(u); }(), e.SHA1; }); }(sr)), sr.exports; } var ar = { exports: {} }, oa; function Xr() { return oa || (oa = 1, function(r, a) { (function(e, t) { r.exports = t(ne()); })(ie, function(e) { return function(t) { var i = e, s = i.lib, n = 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 n.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], _ = l[5], y = l[6], A = l[7], R = 0; R < 64; R++) { if (R < 16) p[R] = f[m + R] | 0; else { var M = p[R - 15], C = (M << 25 | M >>> 7) ^ (M << 14 | M >>> 18) ^ M >>> 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 & _ ^ ~E & y, $ = S & v ^ S & x ^ v & x, q = (S << 30 | S >>> 2) ^ (S << 19 | S >>> 13) ^ (S << 10 | S >>> 22), X = (E << 26 | E >>> 6) ^ (E << 21 | E >>> 11) ^ (E << 7 | E >>> 25), ae = A + X + B + h[R] + p[R], Q = q + $; A = y, y = _, _ = E, E = b + ae | 0, b = x, x = v, v = S, S = ae + Q | 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] + _ | 0, l[6] = l[6] + y | 0, l[7] = l[7] + A | 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; }); }(ar)), ar.exports; } var nr = { exports: {} }, ca; function Ho() { return ca || (ca = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), Xr()); })(ie, function(e) { return function() { var t = e, i = t.lib, s = i.WordArray, n = t.algo, c = n.SHA256, o = n.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; }); }(nr)), nr.exports; } var or = { exports: {} }, ua; function dn() { return ua || (ua = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), Ci()); })(ie, function(e) { return function() { var t = e, i = t.lib, s = i.Hasher, n = t.x64, c = n.Word, o = n.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], _ = S[4], y = S[5], A = S[6], R = S[7], M = v.high, C = v.low, I = x.high, P = x.low, B = b.high, $ = b.low, q = E.high, X = E.low, ae = _.high, Q = _.low, te = y.high, ee = y.low, k = A.high, L = A.low, F = R.high, N = R.low, G = M, j = C, ce = I, Z = P, Ve = B, ze = $, Qe = q, et = X, xe = ae, ke = Q, ot = te, Ct = ee, Ht = k, Rt = L, Yt = F, It = N, Be = 0; Be < 80; Be++) { var Re, tt, wt = d[Be]; if (Be < 16) tt = wt.high = m[l + Be * 2] | 0, Re = wt.low = m[l + Be * 2 + 1] | 0; else { var gt = d[Be - 15], it = gt.high, ct = gt.low, ki = (it >>> 1 | ct << 31) ^ (it >>> 8 | ct << 24) ^ it >>> 7, ui = (ct >>> 1 | it << 31) ^ (ct >>> 8 | it << 24) ^ (ct >>> 7 | it << 25), hi = d[Be - 2], We = hi.high, mt = hi.low, di = (We >>> 19 | mt << 13) ^ (We << 3 | mt >>> 29) ^ We >>> 6, Zt = (mt >>> 19 | We << 13) ^ (mt << 3 | We >>> 29) ^ (mt >>> 6 | We << 26), us = d[Be - 7], Bn = us.high, Nn = us.low, hs = d[Be - 16], Mn = hs.high, ds = hs.low; Re = ui + Nn, tt = ki + Bn + (Re >>> 0 < ui >>> 0 ? 1 : 0), Re = Re + Zt, tt = tt + di + (Re >>> 0 < Zt >>> 0 ? 1 : 0), Re = Re + ds, tt = tt + Mn + (Re >>> 0 < ds >>> 0 ? 1 : 0), wt.high = tt, wt.low = Re; } var Ln = xe & ot ^ ~xe & Ht, ls = ke & Ct ^ ~ke & Rt, Fn = G & ce ^ G & Ve ^ ce & Ve, Vn = j & Z ^ j & ze ^ Z & ze, On = (G >>> 28 | j << 4) ^ (G << 30 | j >>> 2) ^ (G << 25 | j >>> 7), fs = (j >>> 28 | G << 4) ^ (j << 30 | G >>> 2) ^ (j << 25 | G >>> 7), Un = (xe >>> 14 | ke << 18) ^ (xe >>> 18 | ke << 14) ^ (xe << 23 | ke >>> 9), Hn = (ke >>> 14 | xe << 18) ^ (ke >>> 18 | xe << 14) ^ (ke << 23 | xe >>> 9), ps = p[Be], jn = ps.high, gs = ps.low, $e = It + Hn, St = Yt + Un + ($e >>> 0 < It >>> 0 ? 1 : 0), $e = $e + ls, St = St + Ln + ($e >>> 0 < ls >>> 0 ? 1 : 0), $e = $e + gs, St = St + jn + ($e >>> 0 < gs >>> 0 ? 1 : 0), $e = $e + Re, St = St + tt + ($e >>> 0 < Re >>> 0 ? 1 : 0), ms = fs + Vn, zn = On + Fn + (ms >>> 0 < fs >>> 0 ? 1 : 0); Yt = Ht, It = Rt, Ht = ot, Rt = Ct, ot = xe, Ct = ke, ke = et + $e | 0, xe = Qe + St + (ke >>> 0 < et >>> 0 ? 1 : 0) | 0, Qe = Ve, et = ze, Ve = ce, ze = Z, ce = G, Z = j, j = $e + ms | 0, G = St + zn + (j >>> 0 < $e >>> 0 ? 1 : 0) | 0; } C = v.low = C + j, v.high = M + G + (C >>> 0 < j >>> 0 ? 1 : 0), P = x.low = P + Z, x.high = I + ce + (P >>> 0 < Z >>> 0 ? 1 : 0), $ = b.low = $ + ze, b.high = B + Ve + ($ >>> 0 < ze >>> 0 ? 1 : 0), X = E.low = X + et, E.high = q + Qe + (X >>> 0 < et >>> 0 ? 1 : 0), Q = _.low = Q + ke, _.high = ae + xe + (Q >>> 0 < ke >>> 0 ? 1 : 0), ee = y.low = ee + Ct, y.high = te + ot + (ee >>> 0 < Ct >>> 0 ? 1 : 0), L = A.low = L + Rt, A.high = k + Ht + (L >>> 0 < Rt >>> 0 ? 1 : 0), N = R.low = N + It, R.high = F + Yt + (N >>> 0 < It >>> 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; }); }(or)), or.exports; } var cr = { exports: {} }, ha; function jo() { return ha || (ha = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), Ci(), dn()); })(ie, function(e) { return function() { var t = e, i = t.x64, s = i.Word, n = i.WordArray, c = t.algo, o = c.SHA512, u = c.SHA384 = o.extend({ _doReset: function() { this._hash = new n.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; }); }(cr)), cr.exports; } var ur = { exports: {} }, da; function zo() { return da || (da = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), Ci()); })(ie, function(e) { return function(t) { var i = e, s = i.lib, n = 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 _ = 1, y = 0; y < 24; y++) { for (var A = 0, R = 0, M = 0; M < 7; M++) { if (_ & 1) { var C = (1 << M) - 1; C < 32 ? R ^= 1 << C : A ^= 1 << C - 32; } _ & 128 ? _ = _ << 1 ^ 113 : _ <<= 1; } f[y] = u.create(A, R); } })(); var m = []; (function() { for (var S = 0; S < 25; S++) m[S] = u.create(); })(); var l = h.SHA3 = c.extend({ /** * Configuration options. * * @property {number} outputLength * The desired number of bits in the output hash. * Only values permitted are: 224, 256, 384, 512. * Default: 512 */ 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 _ = S[v + 2 * E], y = S[v + 2 * E + 1]; _ = (_ << 8 | _ >>> 24) & 16711935 | (_ << 24 | _ >>> 8) & 4278255360, y = (y << 8 | y >>> 24) & 16711935 | (y << 24 | y >>> 8) & 4278255360; var A = x[E]; A.high ^= y, A.low ^= _; } for (var R = 0; R < 24; R++) { for (var M = 0; M < 5; M++) { for (var C = 0, I = 0, P = 0; P < 5; P++) { var A = x[M + 5 * P]; C ^= A.high, I ^= A.low; } var B = m[M]; B.high = C, B.low = I; } for (var M = 0; M < 5; M++) for (var $ = m[(M + 4) % 5], q = m[(M + 1) % 5], X = q.high, ae = q.low, C = $.high ^ (X << 1 | ae >>> 31), I = $.low ^ (ae << 1 | X >>> 31), P = 0; P < 5; P++) { var A = x[M + 5 * P]; A.high ^= C, A.low ^= I; } for (var Q = 1; Q < 25; Q++) { var C, I, A = x[Q], te = A.high, ee = A.low, k = p[Q]; k < 32 ? (C = te << k | ee >>> 32 - k, I = ee << k | te >>> 32 - k) : (C = ee << k - 32 | te >>> 64 - k, I = te << k - 32 | ee >>> 64 - k); var L = m[d[Q]]; L.high = C, L.low = I; } var F = m[0], N = x[0]; F.high = N.high, F.low = N.low; for (var M = 0; M < 5; M++) for (var P = 0; P < 5; P++) { var Q = M + 5 * P, A = x[Q], G = m[Q], j = m[(M + 1) % 5 + 5 * P], ce = m[(M + 2) % 5 + 5 * P]; A.high = G.high ^ ~j.high & ce.high, A.low = G.low ^ ~j.low & ce.low; } var A = x[0], Z = f[R]; A.high ^= Z.high, A.low ^= Z.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, _ = this.cfg.outputLength / 8, y = _ / 8, A = [], R = 0; R < y; R++) { var M = E[R], C = M.high, I = M.low; C = (C << 8 | C >>> 24) & 16711935 | (C << 24 | C >>> 8) & 4278255360, I = (I << 8 | I >>> 24) & 16711935 | (I << 24 | I >>> 8) & 4278255360, A.push(I), A.push(C); } return new n.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; }); }(ur)), ur.exports; } var hr = { exports: {} }, la; function Wo() { return la || (la = 1, function(r, a) { (function(e, t) { r.exports = t(ne()); })(ie, function(e) { /** @preserve (c) 2012 by Cédric Mesnil. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 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. 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. */ return function(t) { var i = e, s = i.lib, n = s.WordArray, c = s.Hasher, o = i.algo, u = n.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 = n.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 = n.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 = n.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 = n.create([0, 1518500249, 1859775393, 2400959708, 2840853838]), m = n.create([1352829926, 1548603684, 1836072691, 2053994217, 0]), l = o.RIPEMD160 = c.extend({ _doReset: function() { this._hash = n.create([1732584193, 4023233417, 2562383102, 271733878, 3285377520]); }, _doProcessBlock: function(y, A) { for (var R = 0; R < 16; R++) { var M = A + R, C = y[M]; y[M] = (C << 8 | C >>> 24) & 16711935 | (C << 24 | C >>> 8) & 4278255360; } var I = this._hash.words, P = f.words, B = m.words, $ = u.words, q = h.words, X = p.words, ae = d.words, Q, te, ee, k, L, F, N, G, j, ce; F = Q = I[0], N = te = I[1], G = ee = I[2], j = k = I[3], ce = L = I[4]; for (var Z, R = 0; R < 80; R += 1) Z = Q + y[A + $[R]] | 0, R < 16 ? Z += S(te, ee, k) + P[0] : R < 32 ? Z += v(te, ee, k) + P[1] : R < 48 ? Z += x(te, ee, k) + P[2] : R < 64 ? Z += b(te, ee, k) + P[3] : Z += E(te, ee, k) + P[4], Z = Z | 0, Z = _(Z, X[R]), Z = Z + L | 0, Q = L, L = k, k = _(ee, 10), ee = te, te = Z, Z = F + y[A + q[R]] | 0, R < 16 ? Z += E(N, G, j) + B[0] : R < 32 ? Z += b(N, G, j) + B[1] : R < 48 ? Z += x(N, G, j) + B[2] : R < 64 ? Z += v(N, G, j) + B[3] : Z += S(N, G, j) + B[4], Z = Z | 0, Z = _(Z, ae[R]), Z = Z + ce | 0, F = ce, ce = j, j = _(G, 10), G = N, N = Z; Z = I[1] + ee + j | 0, I[1] = I[2] + k + ce | 0, I[2] = I[3] + L + F | 0, I[3] = I[4] + Q + N | 0, I[4] = I[0] + te + G | 0, I[0] = Z; }, _doFinalize: function() { var y = this._data, A = y.words, R = this._nDataBytes * 8, M = y.sigBytes * 8; A[M >>> 5] |= 128 << 24 - M % 32, A[(M + 64 >>> 9 << 4) + 14] = (R << 8 | R >>> 24) & 16711935 | (R << 24 | R >>> 8) & 4278255360, y.sigBytes = (A.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, A, R) { return y ^ A ^ R; } function v(y, A, R) { return y & A | ~y & R; } function x(y, A, R) { return (y | ~A) ^ R; } function b(y, A, R) { return y & R | A & ~R; } function E(y, A, R) { return y ^ (A | ~R); } function _(y, A) { return y << A | y >>> 32 - A; } i.RIPEMD160 = c._createHelper(l), i.HmacRIPEMD160 = c._createHmacHelper(l); }(), e.RIPEMD160; }); }(hr)), hr.exports; } var dr = { exports: {} }, fa; function Yr() { return fa || (fa = 1, function(r, a) { (function(e, t) { r.exports = t(ne()); })(ie, function(e) { (function() { var t = e, i = t.lib, s = i.Base, n = t.enc, c = n.Utf8, o = t.algo; o.HMAC = s.extend({ /** * Initializes a newly created HMAC. * * @param {Hasher} hasher The hash algorithm to use. * @param {WordArray|string} key The secret key. * * @example * * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key); */ 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(); }, /** * Resets this HMAC to its initial state. * * @example * * hmacHasher.reset(); */ reset: function() { var u = this._hasher; u.reset(), u.update(this._iKey); }, /** * Updates this HMAC with a message. * * @param {WordArray|string} messageUpdate The message to append. * * @return {HMAC} This HMAC instance. * * @example * * hmacHasher.update('message'); * hmacHasher.update(wordArray); */ update: function(u) { return this._hasher.update(u), this; }, /** * Finalizes the HMAC computation. * Note that the finalize operation is effectively a destructive, read-once operation. * * @param {WordArray|string} messageUpdate (Optional) A final message update. * * @return {WordArray} The HMAC. * * @example * * var hmac = hmacHasher.finalize(); * var hmac = hmacHasher.finalize('message'); * var hmac = hmacHasher.finalize(wordArray); */ finalize: function(u) { var h = this._hasher, p = h.finalize(u); h.reset(); var d = h.finalize(this._oKey.clone().concat(p)); return d; } }); })(); }); }(dr)), dr.exports; } var lr = { exports: {} }, pa; function $o() { return pa || (pa = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), Xr(), Yr()); })(ie, function(e) { return function() { var t = e, i = t.lib, s = i.Base, n = i.WordArray, c = t.algo, o = c.SHA256, u = c.HMAC, h = c.PBKDF2 = s.extend({ /** * Configuration options. * * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) * @property {Hasher} hasher The hasher to use. Default: SHA256 * @property {number} iterations The number of iterations to perform. Default: 250000 */ cfg: s.extend({ keySize: 128 / 32, hasher: o, iterations: 25e4 }), /** * Initializes a newly created key derivation function. * * @param {Object} cfg (Optional) The configuration options to use for the derivation. * * @example * * var kdf = CryptoJS.algo.PBKDF2.create(); * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 }); * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 }); */ init: function(p) { this.cfg = this.cfg.extend(p); }, /** * Computes the Password-Based Key Derivation Function 2. * * @param {WordArray|string} password The password. * @param {WordArray|string} salt A salt. * * @return {WordArray} The derived key. * * @example * * var key = kdf.compute(password, salt); */ compute: function(p, d) { for (var f = this.cfg, m = u.create(f.hasher, p), l = n.create(), S = n.create([1]), v = l.words, x = S.words, b = f.keySize, E = f.iterations; v.length < b; ) { var _ = m.update(d).finalize(S); m.reset(); for (var y = _.words, A = y.length, R = _, M = 1; M < E; M++) { R = m.finalize(R), m.reset(); for (var C = R.words, I = 0; I < A; I++) y[I] ^= C[I]; } l.concat(_), x[0]++; } return l.sigBytes = b * 4, l; } }); t.PBKDF2 = function(p, d, f) { return h.create(f).compute(p, d); }; }(), e.PBKDF2; }); }(lr)), lr.exports; } var fr = { exports: {} }, ga; function yt() { return ga || (ga = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), hn(), Yr()); })(ie, function(e) { return function() { var t = e, i = t.lib, s = i.Base, n = i.WordArray, c = t.algo, o = c.MD5, u = c.EvpKDF = s.extend({ /** * Configuration options. * * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) * @property {Hasher} hasher The hash algorithm to use. Default: MD5 * @property {number} iterations The number of iterations to perform. Default: 1 */ cfg: s.extend({ keySize: 128 / 32, hasher: o, iterations: 1 }), /** * Initializes a newly created key derivation function. * * @param {Object} cfg (Optional) The configuration options to use for the derivation. * * @example * * var kdf = CryptoJS.algo.EvpKDF.create(); * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 }); * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 }); */ init: function(h) { this.cfg = this.cfg.extend(h); }, /** * Derives a key from a password. * * @param {WordArray|string} password The password. * @param {WordArray|string} salt A salt. * * @return {WordArray} The derived key. * * @example * * var key = kdf.compute(password, salt); */ compute: function(h, p) { for (var d, f = this.cfg, m = f.hasher.create(), l = n.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; }); }(fr)), fr.exports; } var pr = { exports: {} }, ma; function ye() { return ma || (ma = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), yt()); })(ie, function(e) { e.lib.Cipher || function(t) { var i = e, s = i.lib, n = 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({ /** * Configuration options. * * @property {WordArray} iv The IV to use for this operation. */ cfg: n.extend(), /** * Creates this cipher in encryption mode. * * @param {WordArray} key The key. * @param {Object} cfg (Optional) The configuration options to use for this operation. * * @return {Cipher} A cipher instance. * * @static * * @example * * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); */ createEncryptor: function(C, I) { return this.create(this._ENC_XFORM_MODE, C, I); }, /** * Creates this cipher in decryption mode. * * @param {WordArray} key The key. * @param {Object} cfg (Optional) The configuration options to use for this operation. * * @return {Cipher} A cipher instance. * * @static * * @example * * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); */ createDecryptor: function(C, I) { return this.create(this._DEC_XFORM_MODE, C, I); }, /** * Initializes a newly created cipher. * * @param {number} xformMode Either the encryption or decryption transormation mode constant. * @param {WordArray} key The key. * @param {Object} cfg (Optional) The configuration options to use for this operation. * * @example * * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray }); */ init: function(C, I, P) { this.cfg = this.cfg.extend(P), this._xformMode = C, this._key = I, this.reset(); }, /** * Resets this cipher to its initial state. * * @example * * cipher.reset(); */ reset: function() { o.reset.call(this), this._doReset(); }, /** * Adds data to be encrypted or decrypted. * * @param {WordArray|string} dataUpdate The data to encrypt or decrypt. * * @return {WordArray} The data after processing. * * @example * * var encrypted = cipher.process('data'); * var encrypted = cipher.process(wordArray); */ process: function(C) { return this._append(C), this._process(); }, /** * Finalizes the encryption or decryption process. * Note that the finalize operation is effectively a destructive, read-once operation. * * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt. * * @return {WordArray} The data after final processing. * * @example * * var encrypted = cipher.finalize(); * var encrypted = cipher.finalize('data'); * var encrypted = cipher.finalize(wordArray); */ 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, /** * Creates shortcut functions to a cipher's object interface. * * @param {Cipher} cipher The cipher to create a helper for. * * @return {Object} An object with encrypt and decrypt shortcut functions. * * @static * * @example * * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); */ _createHelper: function() { function C(I) { return typeof I == "string" ? M : y; } return function(I) { return { encrypt: function(P, B, $) { return C(B).encrypt(I, P, B, $); }, decrypt: function(P, B, $) { return C(B).decrypt(I, P, B, $); } }; }; }() }); s.StreamCipher = f.extend({ _doFinalize: function() { var C = this._process(!0); return C; }, blockSize: 1 }); var m = i.mode = {}, l = s.BlockCipherMode = n.extend({ /** * Creates this mode for encryption. * * @param {Cipher} cipher A block cipher instance. * @param {Array} iv The IV words. * * @static * * @example * * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); */ createEncryptor: function(C, I) { return this.Encryptor.create(C, I); }, /** * Creates this mode for decryption. * * @param {Cipher} cipher A block cipher instance. * @param {Array} iv The IV words. * * @static * * @example * * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); */ createDecryptor: function(C, I) { return this.Decryptor.create(C, I); }, /** * Initializes a newly created mode. * * @param {Cipher} cipher A block cipher instance. * @param {Array} iv The IV words. * * @example * * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); */ init: function(C, I) { this._cipher = C, this._iv = I; } }), S = m.CBC = function() { var C = l.extend(); C.Encryptor = C.extend({ /** * Processes the data block at offset. * * @param {Array} words The data words to operate on. * @param {number} offset The offset where the block starts. * * @example * * mode.processBlock(data.words, offset); */ processBlock: function(P, B) { var $ = this._cipher, q = $.blockSize; I.call(this, P, B, q), $.encryptBlock(P, B), this._prevBlock = P.slice(B, B + q); } }), C.Decryptor = C.extend({ /** * Processes the data block at offset. * * @param {Array} words The data words to operate on. * @param {number} offset The offset where the block starts. * * @example * * mode.processBlock(data.words, offset); */ processBlock: function(P, B) { var $ = this._cipher, q = $.blockSize, X = P.slice(B, B + q); $.decryptBlock(P, B), I.call(this, P, B, q), this._prevBlock = X; } }); function I(P, B, $) { var q, X = this._iv; X ? (q = X, this._iv = t) : q = this._prevBlock; for (var ae = 0; ae < $; ae++) P[B + ae] ^= q[ae]; } return C; }(), v = i.pad = {}, x = v.Pkcs7 = { /** * Pads data using the algorithm defined in PKCS #5/7. * * @param {WordArray} data The data to pad. * @param {number} blockSize The multiple that the data should be padded to. * * @static * * @example * * CryptoJS.pad.Pkcs7.pad(wordArray, 4); */ pad: function(C, I) { for (var P = I * 4, B = P - C.sigBytes % P, $ = B << 24 | B << 16 | B << 8 | B, q = [], X = 0; X < B; X += 4) q.push($); var ae = c.create(q, B); C.concat(ae); }, /** * Unpads data that had been padded using the algorithm defined in PKCS #5/7. * * @param {WordArray} data The data to unpad. * * @static * * @example * * CryptoJS.pad.Pkcs7.unpad(wordArray); */ unpad: function(C) { var I = C.words[C.sigBytes - 1 >>> 2] & 255; C.sigBytes -= I; } }; s.BlockCipher = f.extend({ /** * Configuration options. * * @property {Mode} mode The block mode to use. Default: CBC * @property {Padding} padding The padding strategy to use. Default: Pkcs7 */ 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 = n.extend({ /** * Initializes a newly created cipher params object. * * @param {Object} cipherParams An object with any of the possible cipher parameters. * * @example * * var cipherParams = CryptoJS.lib.CipherParams.create({ * ciphertext: ciphertextWordArray, * key: keyWordArray, * iv: ivWordArray, * salt: saltWordArray, * algorithm: CryptoJS.algo.AES, * mode: CryptoJS.mode.CBC, * padding: CryptoJS.pad.PKCS7, * blockSize: 4, * formatter: CryptoJS.format.OpenSSL * }); */ init: function(C) { this.mixIn(C); }, /** * Converts this cipher params object to a string. * * @param {Format} formatter (Optional) The formatting strategy to use. * * @return {string} The stringified cipher params. * * @throws Error If neither the formatter nor the default formatter is set. * * @example * * var string = cipherParams + ''; * var string = cipherParams.toString(); * var string = cipherParams.toString(CryptoJS.format.OpenSSL); */ toString: function(C) { return (C || this.formatter).stringify(this); } }), E = i.format = {}, _ = E.OpenSSL = { /** * Converts a cipher params object to an OpenSSL-compatible string. * * @param {CipherParams} cipherParams The cipher params object. * * @return {string} The OpenSSL-compatible string. * * @static * * @example * * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); */ 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); }, /** * Converts an OpenSSL-compatible string to a cipher params object. * * @param {string} openSSLStr The OpenSSL-compatible string. * * @return {CipherParams} The cipher params object. * * @static * * @example * * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); */ 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 = n.extend({ /** * Configuration options. * * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL */ cfg: n.extend({ format: _ }), /** * Encrypts a message. * * @param {Cipher} cipher The cipher algorithm to use. * @param {WordArray|string} message The message to encrypt. * @param {WordArray} key The key. * @param {Object} cfg (Optional) The configuration options to use for this operation. * * @return {CipherParams} A cipher params object. * * @static * * @example * * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key); * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); */ encrypt: function(C, I, P, B) { B = this.cfg.extend(B); var $ = C.createEncryptor(P, B), q = $.finalize(I), X = $.cfg; return b.create({ ciphertext: q, key: P, iv: X.iv, algorithm: C, mode: X.mode, padding: X.padding, blockSize: C.blockSize, formatter: B.format }); }, /** * Decrypts serialized ciphertext. * * @param {Cipher} cipher The cipher algorithm to use. * @param {CipherParams|string} ciphertext The ciphertext to decrypt. * @param {WordArray} key The key. * @param {Object} cfg (Optional) The configuration options to use for this operation. * * @return {WordArray} The plaintext. * * @static * * @example * * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL }); * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL }); */ decrypt: function(C, I, P, B) { B = this.cfg.extend(B), I = this._parse(I, B.format); var $ = C.createDecryptor(P, B).finalize(I.ciphertext); return $; }, /** * Converts serialized ciphertext to CipherParams, * else assumed CipherParams already and returns ciphertext unchanged. * * @param {CipherParams|string} ciphertext The ciphertext. * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext. * * @return {CipherParams} The unserialized ciphertext. * * @static * * @example * * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format); */ _parse: function(C, I) { return typeof C == "string" ? I.parse(C, this) : C; } }), A = i.kdf = {}, R = A.OpenSSL = { /** * Derives a key and IV from a password. * * @param {string} password The password to derive from. * @param {number} keySize The size in words of the key to generate. * @param {number} ivSize The size in words of the IV to generate. * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly. * * @return {CipherParams} A cipher params object with the key, IV, and salt. * * @static * * @example * * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32); * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); */ execute: function(C, I, P, B, $) { if (B || (B = c.random(64 / 8)), $) var q = d.create({ keySize: I + P, hasher: $ }).compute(C, B); else var q = d.create({ keySize: I + P }).compute(C, B); var X = c.create(q.words.slice(I), P * 4); return q.sigBytes = I * 4, b.create({ key: q, iv: X, salt: B }); } }, M = s.PasswordBasedCipher = y.extend({ /** * Configuration options. * * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL */ cfg: y.cfg.extend({ kdf: R }), /** * Encrypts a message using a password. * * @param {Cipher} cipher The cipher algorithm to use. * @param {WordArray|string} message The message to encrypt. * @param {string} password The password. * @param {Object} cfg (Optional) The configuration options to use for this operation. * * @return {CipherParams} A cipher params object. * * @static * * @example * * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password'); * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL }); */ encrypt: function(C, I, P, B) { B = this.cfg.extend(B); var $ = B.kdf.execute(P, C.keySize, C.ivSize, B.salt, B.hasher); B.iv = $.iv; var q = y.encrypt.call(this, C, I, $.key, B); return q.mixIn($), q; }, /** * Decrypts serialized ciphertext using a password. * * @param {Cipher} cipher The cipher algorithm to use. * @param {CipherParams|string} ciphertext The ciphertext to decrypt. * @param {string} password The password. * @param {Object} cfg (Optional) The configuration options to use for this operation. * * @return {WordArray} The plaintext. * * @static * * @example * * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL }); * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL }); */ decrypt: function(C, I, P, B) { B = this.cfg.extend(B), I = this._parse(I, B.format); var $ = B.kdf.execute(P, C.keySize, C.ivSize, I.salt, B.hasher); B.iv = $.iv; var q = y.decrypt.call(this, C, I, $.key, B); return q; } }); }(); }); }(pr)), pr.exports; } var gr = { exports: {} }, Sa; function Ko() { return Sa || (Sa = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), ye()); })(ie, function(e) { return e.mode.CFB = function() { var t = e.lib.BlockCipherMode.extend(); t.Encryptor = t.extend({ processBlock: function(s, n) { var c = this._cipher, o = c.blockSize; i.call(this, s, n, o, c), this._prevBlock = s.slice(n, n + o); } }), t.Decryptor = t.extend({ processBlock: function(s, n) { var c = this._cipher, o = c.blockSize, u = s.slice(n, n + o); i.call(this, s, n, o, c), this._prevBlock = u; } }); function i(s, n, 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[n + p] ^= u[p]; } return t; }(), e.mode.CFB; }); }(gr)), gr.exports; } var mr = { exports: {} }, xa; function qo() { return xa || (xa = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), ye()); })(ie, function(e) { return e.mode.CTR = function() { var t = e.lib.BlockCipherMode.extend(), i = t.Encryptor = t.extend({ processBlock: function(s, n) { 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[n + d] ^= p[d]; } }); return t.Decryptor = i, t; }(), e.mode.CTR; }); }(mr)), mr.exports; } var Sr = { exports: {} }, va; function Jo() { return va || (va = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), ye()); })(ie, function(e) { /** @preserve * Counter block mode compatible with Dr Brian Gladman fileenc.c * derived from CryptoJS.mode.CTR * Jan Hruby jhruby.web@gmail.com */ return e.mode.CTRGladman = function() { var t = e.lib.BlockCipherMode.extend(); function i(c) { if ((c >> 24 & 255) === 255) { var o = c >> 16 & 255, u = c >> 8 & 255, h = c & 255; o === 255 ? (o = 0, u === 255 ? (u = 0, h === 255 ? h = 0 : ++h) : ++u) : ++o, c = 0, c += o << 16, c += u << 8, c += h; } else c += 1 << 24; return c; } function s(c) { return (c[0] = i(c[0])) === 0 && (c[1] = i(c[1])), c; } var n = t.Encryptor = t.extend({ processBlock: function(c, o) { var u = this._cipher, h = u.blockSize, p = this._iv, d = this._counter; p && (d = this._counter = p.slice(0), this._iv = void 0), s(d); var f = d.slice(0); u.encryptBlock(f, 0); for (var m = 0; m < h; m++) c[o + m] ^= f[m]; } }); return t.Decryptor = n, t; }(), e.mode.CTRGladman; }); }(Sr)), Sr.exports; } var xr = { exports: {} }, ba; function Go() { return ba || (ba = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), ye()); })(ie, function(e) { return e.mode.OFB = function() { var t = e.lib.BlockCipherMode.extend(), i = t.Encryptor = t.extend({ processBlock: function(s, n) { var c = this._cipher, o = c.blockSize, u = this._iv, h = this._keystream; u && (h = this._keystream = u.slice(0), this._iv = void 0), c.encryptBlock(h, 0); for (var p = 0; p < o; p++) s[n + p] ^= h[p]; } }); return t.Decryptor = i, t; }(), e.mode.OFB; }); }(xr)), xr.exports; } var vr = { exports: {} }, Ea; function Xo() { return Ea || (Ea = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), ye()); })(ie, function(e) { return e.mode.ECB = function() { var t = e.lib.BlockCipherMode.extend(); return t.Encryptor = t.extend({ processBlock: function(i, s) { this._cipher.encryptBlock(i, s); } }), t.Decryptor = t.extend({ processBlock: function(i, s) { this._cipher.decryptBlock(i, s); } }), t; }(), e.mode.ECB; }); }(vr)), vr.exports; } var br = { exports: {} }, _a; function Yo() { return _a || (_a = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), ye()); })(ie, function(e) { return e.pad.AnsiX923 = { pad: function(t, i) { var s = t.sigBytes, n = i * 4, c = n - s % n, o = s + c - 1; t.clamp(), t.words[o >>> 2] |= c << 24 - o % 4 * 8, t.sigBytes += c; }, unpad: function(t) { var i = t.words[t.sigBytes - 1 >>> 2] & 255; t.sigBytes -= i; } }, e.pad.Ansix923; }); }(br)), br.exports; } var Er = { exports: {} }, Aa; function Zo() { return Aa || (Aa = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), ye()); })(ie, function(e) { return e.pad.Iso10126 = { pad: function(t, i) { var s = i * 4, n = s - t.sigBytes % s; t.concat(e.lib.WordArray.random(n - 1)).concat(e.lib.WordArray.create([n << 24], 1)); }, unpad: function(t) { var i = t.words[t.sigBytes - 1 >>> 2] & 255; t.sigBytes -= i; } }, e.pad.Iso10126; }); }(Er)), Er.exports; } var _r = { exports: {} }, ya; function Qo() { return ya || (ya = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), ye()); })(ie, function(e) { return e.pad.Iso97971 = { pad: function(t, i) { t.concat(e.lib.WordArray.create([2147483648], 1)), e.pad.ZeroPadding.pad(t, i); }, unpad: function(t) { e.pad.ZeroPadding.unpad(t), t.sigBytes--; } }, e.pad.Iso97971; }); }(_r)), _r.exports; } var Ar = { exports: {} }, Ca; function e0() { return Ca || (Ca = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), ye()); })(ie, function(e) { return e.pad.ZeroPadding = { pad: function(t, i) { var s = i * 4; t.clamp(), t.sigBytes += s - (t.sigBytes % s || s); }, unpad: function(t) { for (var i = t.words, s = t.sigBytes - 1, s = t.sigBytes - 1; s >= 0; s--) if (i[s >>> 2] >>> 24 - s % 4 * 8 & 255) { t.sigBytes = s + 1; break; } } }, e.pad.ZeroPadding; }); }(Ar)), Ar.exports; } var yr = { exports: {} }, Ra; function t0() { return Ra || (Ra = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), ye()); })(ie, function(e) { return e.pad.NoPadding = { pad: function() { }, unpad: function() { } }, e.pad.NoPadding; }); }(yr)), yr.exports; } var Cr = { exports: {} }, Ia; function i0() { return Ia || (Ia = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), ye()); })(ie, function(e) { return function(t) { var i = e, s = i.lib, n = s.CipherParams, c = i.enc, o = c.Hex, u = i.format; u.Hex = { /** * Converts the ciphertext of a cipher params object to a hexadecimally encoded string. * * @param {CipherParams} cipherParams The cipher params object. * * @return {string} The hexadecimally encoded string. * * @static * * @example * * var hexString = CryptoJS.format.Hex.stringify(cipherParams); */ stringify: function(h) { return h.ciphertext.toString(o); }, /** * Converts a hexadecimally encoded ciphertext string to a cipher params object. * * @param {string} input The hexadecimally encoded string. * * @return {CipherParams} The cipher params object. * * @static * * @example * * var cipherParams = CryptoJS.format.Hex.parse(hexString); */ parse: function(h) { var p = o.parse(h); return n.create({ ciphertext: p }); } }; }(), e.format.Hex; }); }(Cr)), Cr.exports; } var Rr = { exports: {} }, wa; function r0() { return wa || (wa = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), Ot(), Ut(), yt(), ye()); })(ie, function(e) { return function() { var t = e, i = t.lib, s = i.BlockCipher, n = t.algo, c = [], o = [], u = [], h = [], p = [], d = [], f = [], m = [], l = [], S = []; (function() { for (var b = [], E = 0; E < 256; E++) E < 128 ? b[E] = E << 1 : b[E] = E << 1 ^ 283; for (var _ = 0, y = 0, E = 0; E < 256; E++) { var A = y ^ y << 1 ^ y << 2 ^ y << 3 ^ y << 4; A = A >>> 8 ^ A & 255 ^ 99, c[_] = A, o[A] = _; var R = b[_], M = b[R], C = b[M], I = b[A] * 257 ^ A * 16843008; u[_] = I << 24 | I >>> 8, h[_] = I << 16 | I >>> 16, p[_] = I << 8 | I >>> 24, d[_] = I; var I = C * 16843009 ^ M * 65537 ^ R * 257 ^ _ * 16843008; f[A] = I << 24 | I >>> 8, m[A] = I << 16 | I >>> 16, l[A] = I << 8 | I >>> 24, S[A] = I, _ ? (_ = R ^ b[b[b[C ^ R]]], y ^= b[b[y]]) : _ = y = 1; } })(); var v = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], x = n.AES = s.extend({ _doReset: function() { var b; if (!(this._nRounds && this._keyPriorReset === this._key)) { for (var E = this._keyPriorReset = this._key, _ = E.words, y = E.sigBytes / 4, A = this._nRounds = y + 6, R = (A + 1) * 4, M = this._keySchedule = [], C = 0; C < R; C++) C < y ? M[C] = _[C] : (b = M[C - 1], C % y ? y > 6 && C % y == 4 && (b = c[b >>> 24] << 24 | c[b >>> 16 & 255] << 16 | c[b >>> 8 & 255] << 8 | c[b & 255]) : (b = b << 8 | b >>> 24, b = c[b >>> 24] << 24 | c[b >>> 16 & 255] << 16 | c[b >>> 8 & 255] << 8 | c[b & 255], b ^= v[C / y | 0] << 24), M[C] = M[C - y] ^ b); for (var I = this._invKeySchedule = [], P = 0; P < R; P++) { var C = R - P; if (P % 4) var b = M[C]; else var b = M[C - 4]; P < 4 || C <= 4 ? I[P] = b : I[P] = f[c[b >>> 24]] ^ m[c[b >>> 16 & 255]] ^ l[c[b >>> 8 & 255]] ^ S[c[b & 255]]; } } }, encryptBlock: function(b, E) { this._doCryptBlock(b, E, this._keySchedule, u, h, p, d, c); }, decryptBlock: function(b, E) { var _ = b[E + 1]; b[E + 1] = b[E + 3], b[E + 3] = _, this._doCryptBlock(b, E, this._invKeySchedule, f, m, l, S, o); var _ = b[E + 1]; b[E + 1] = b[E + 3], b[E + 3] = _; }, _doCryptBlock: function(b, E, _, y, A, R, M, C) { for (var I = this._nRounds, P = b[E] ^ _[0], B = b[E + 1] ^ _[1], $ = b[E + 2] ^ _[2], q = b[E + 3] ^ _[3], X = 4, ae = 1; ae < I; ae++) { var Q = y[P >>> 24] ^ A[B >>> 16 & 255] ^ R[$ >>> 8 & 255] ^ M[q & 255] ^ _[X++], te = y[B >>> 24] ^ A[$ >>> 16 & 255] ^ R[q >>> 8 & 255] ^ M[P & 255] ^ _[X++], ee = y[$ >>> 24] ^ A[q >>> 16 & 255] ^ R[P >>> 8 & 255] ^ M[B & 255] ^ _[X++], k = y[q >>> 24] ^ A[P >>> 16 & 255] ^ R[B >>> 8 & 255] ^ M[$ & 255] ^ _[X++]; P = Q, B = te, $ = ee, q = k; } var Q = (C[P >>> 24] << 24 | C[B >>> 16 & 255] << 16 | C[$ >>> 8 & 255] << 8 | C[q & 255]) ^ _[X++], te = (C[B >>> 24] << 24 | C[$ >>> 16 & 255] << 16 | C[q >>> 8 & 255] << 8 | C[P & 255]) ^ _[X++], ee = (C[$ >>> 24] << 24 | C[q >>> 16 & 255] << 16 | C[P >>> 8 & 255] << 8 | C[B & 255]) ^ _[X++], k = (C[q >>> 24] << 24 | C[P >>> 16 & 255] << 16 | C[B >>> 8 & 255] << 8 | C[$ & 255]) ^ _[X++]; b[E] = Q, b[E + 1] = te, b[E + 2] = ee, b[E + 3] = k; }, keySize: 256 / 32 }); t.AES = s._createHelper(x); }(), e.AES; }); }(Rr)), Rr.exports; } var Ir = { exports: {} }, Da; function s0() { return Da || (Da = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), Ot(), Ut(), yt(), ye()); })(ie, function(e) { return function() { var t = e, i = t.lib, s = i.WordArray, n = i.BlockCipher, c = t.algo, o = [ 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4 ], u = [ 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32 ], h = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28], p = [ { 0: 8421888, 268435456: 32768, 536870912: 8421378, 805306368: 2, 1073741824: 512, 1342177280: 8421890, 1610612736: 8389122, 1879048192: 8388608, 2147483648: 514, 2415919104: 8389120, 2684354560: 33280, 2952790016: 8421376, 3221225472: 32770, 3489660928: 8388610, 3758096384: 0, 4026531840: 33282, 134217728: 0, 402653184: 8421890, 671088640: 33282, 939524096: 32768, 1207959552: 8421888, 1476395008: 512, 1744830464: 8421378, 2013265920: 2, 2281701376: 8389120, 2550136832: 33280, 2818572288: 8421376, 3087007744: 8389122, 3355443200: 8388610, 3623878656: 32770, 3892314112: 514, 4160749568: 8388608, 1: 32768, 268435457: 2, 536870913: 8421888, 805306369: 8388608, 1073741825: 8421378, 1342177281: 33280, 1610612737: 512, 1879048193: 8389122, 2147483649: 8421890, 2415919105: 8421376, 2684354561: 8388610, 2952790017: 33282, 3221225473: 514, 3489660929: 8389120, 3758096385: 32770, 4026531841: 0, 134217729: 8421890, 402653185: 8421376, 671088641: 8388608, 939524097: 512, 1207959553: 32768, 1476395009: 8388610, 1744830465: 2, 2013265921: 33282, 2281701377: 32770, 2550136833: 8389122, 2818572289: 514, 3087007745: 8421888, 3355443201: 8389120, 3623878657: 0, 3892314113: 33280, 4160749569: 8421378 }, { 0: 1074282512, 16777216: 16384, 33554432: 524288, 50331648: 1074266128, 67108864: 1073741840, 83886080: 1074282496, 100663296: 1073758208, 117440512: 16, 134217728: 540672, 150994944: 1073758224, 167772160: 1073741824, 184549376: 540688, 201326592: 524304, 218103808: 0, 234881024: 16400, 251658240: 1074266112, 8388608: 1073758208, 25165824: 540688, 41943040: 16, 58720256: 1073758224, 75497472: 1074282512, 92274688: 1073741824, 109051904: 524288, 125829120: 1074266128, 142606336: 524304, 159383552: 0, 176160768: 16384, 192937984: 1074266112, 209715200: 1073741840, 226492416: 540672, 243269632: 1074282496, 260046848: 16400, 268435456: 0, 285212672: 1074266128, 301989888: 1073758224, 318767104: 1074282496, 335544320: 1074266112, 352321536: 16, 369098752: 540688, 385875968: 16384, 402653184: 16400, 419430400: 524288, 436207616: 524304, 452984832: 1073741840, 469762048: 540672, 486539264: 1073758208, 503316480: 1073741824, 520093696: 1074282512, 276824064: 540688, 293601280: 524288, 310378496: 1074266112, 327155712: 16384, 343932928: 1073758208, 360710144: 1074282512, 377487360: 16, 394264576: 1073741824, 411041792: 1074282496, 427819008: 1073741840, 444596224: 1073758224, 461373440: 524304, 478150656: 0, 494927872: 16400, 511705088: 1074266128, 528482304: 540672 }, { 0: 260, 1048576: 0, 2097152: 67109120, 3145728: 65796, 4194304: 65540, 5242880: 67108868, 6291456: 67174660, 7340032: 67174400, 8388608: 67108864, 9437184: 67174656, 10485760: 65792, 11534336: 67174404, 12582912: 67109124, 13631488: 65536, 14680064: 4, 15728640: 256, 524288: 67174656, 1572864: 67174404, 2621440: 0, 3670016: 67109120, 4718592: 67108868, 5767168: 65536, 6815744: 65540, 7864320: 260, 8912896: 4, 9961472: 256, 11010048: 67174400, 12058624: 65796, 13107200: 65792, 14155776: 67109124, 15204352: 67174660, 16252928: 67108864, 16777216: 67174656, 17825792: 65540, 18874368: 65536, 19922944: 67109120, 20971520: 256, 22020096: 67174660, 23068672: 67108868, 24117248: 0, 25165824: 67109124, 26214400: 67108864, 27262976: 4, 28311552: 65792, 29360128: 67174400, 30408704: 260, 31457280: 65796, 32505856: 67174404, 17301504: 67108864, 18350080: 260, 19398656: 67174656, 20447232: 0, 21495808: 65540, 22544384: 67109120, 23592960: 256, 24641536: 67174404, 25690112: 65536, 26738688: 67174660, 27787264: 65796, 28835840: 67108868, 29884416: 67109124, 30932992: 67174400, 31981568: 4, 33030144: 65792 }, { 0: 2151682048, 65536: 2147487808, 131072: 4198464, 196608: 2151677952, 262144: 0, 327680: 4198400, 393216: 2147483712, 458752: 4194368, 524288: 2147483648, 589824: 4194304, 655360: 64, 720896: 2147487744, 786432: 2151678016, 851968: 4160, 917504: 4096, 983040: 2151682112, 32768: 2147487808, 98304: 64, 163840: 2151678016, 229376: 2147487744, 294912: 4198400, 360448: 2151682112, 425984: 0, 491520: 2151677952, 557056: 4096, 622592: 2151682048, 688128: 4194304, 753664: 4160, 819200: 2147483648, 884736: 4194368, 950272: 4198464, 1015808: 2147483712, 1048576: 4194368, 1114112: 4198400, 1179648: 2147483712, 1245184: 0, 1310720: 4160, 1376256: 2151678016, 1441792: 2151682048, 1507328: 2147487808, 1572864: 2151682112, 1638400: 2147483648, 1703936: 2151677952, 1769472: 4198464, 1835008: 2147487744, 1900544: 4194304, 1966080: 64, 2031616: 4096, 1081344: 2151677952, 1146880: 2151682112, 1212416: 0, 1277952: 4198400, 1343488: 4194368, 1409024: 2147483648, 1474560: 2147487808, 1540096: 64, 1605632: 2147483712, 1671168: 4096, 1736704: 2147487744, 1802240: 2151678016, 1867776: 4160, 1933312: 2151682048, 1998848: 4194304, 2064384: 4198464 }, { 0: 128, 4096: 17039360, 8192: 262144, 12288: 536870912, 16384: 537133184, 20480: 16777344, 24576: 553648256, 28672: 262272, 32768: 16777216, 36864: 537133056, 40960: 536871040, 45056: 553910400, 49152: 553910272, 53248: 0, 57344: 17039488, 61440: 553648128, 2048: 17039488, 6144: 553648256, 10240: 128, 14336: 17039360, 18432: 262144, 22528: 537133184, 26624: 553910272, 30720: 536870912, 34816: 537133056, 38912: 0, 43008: 553910400, 47104: 16777344, 51200: 536871040, 55296: 553648128, 59392: 16777216, 63488: 262272, 65536: 262144, 69632: 128, 73728: 536870912, 77824: 553648256, 81920: 16777344, 86016: 553910272, 90112: 537133184, 94208: 16777216, 98304: 553910400, 102400: 553648128, 106496: 17039360, 110592: 537133056, 114688: 262272, 118784: 536871040, 122880: 0, 126976: 17039488, 67584: 553648256, 71680: 16777216, 75776: 17039360, 79872: 537133184, 83968: 536870912, 88064: 17039488, 92160: 128, 96256: 553910272, 100352: 262272, 104448: 553910400, 108544: 0, 112640: 553648128, 116736: 16777344, 120832: 262144, 124928: 537133056, 129024: 536871040 }, { 0: 268435464, 256: 8192, 512: 270532608, 768: 270540808, 1024: 268443648, 1280: 2097152, 1536: 2097160, 1792: 268435456, 2048: 0, 2304: 268443656, 2560: 2105344, 2816: 8, 3072: 270532616, 3328: 2105352, 3584: 8200, 3840: 270540800, 128: 270532608, 384: 270540808, 640: 8, 896: 2097152, 1152: 2105352, 1408: 268435464, 1664: 268443648, 1920: 8200, 2176: 2097160, 2432: 8192, 2688: 268443656, 2944: 270532616, 3200: 0, 3456: 270540800, 3712: 2105344, 3968: 268435456, 4096: 268443648, 4352: 270532616, 4608: 270540808, 4864: 8200, 5120: 2097152, 5376: 268435456, 5632: 268435464, 5888: 2105344, 6144: 2105352, 6400: 0, 6656: 8, 6912: 270532608, 7168: 8192, 7424: 268443656, 7680: 270540800, 7936: 2097160, 4224: 8, 4480: 2105344, 4736: 2097152, 4992: 268435464, 5248: 268443648, 5504: 8200, 5760: 270540808, 6016: 270532608, 6272: 270540800, 6528: 270532616, 6784: 8192, 7040: 2105352, 7296: 2097160, 7552: 0, 7808: 268435456, 8064: 268443656 }, { 0: 1048576, 16: 33555457, 32: 1024, 48: 1049601, 64: 34604033, 80: 0, 96: 1, 112: 34603009, 128: 33555456, 144: 1048577, 160: 33554433, 176: 34604032, 192: 34603008, 208: 1025, 224: 1049600, 240: 33554432, 8: 34603009, 24: 0, 40: 33555457, 56: 34604032, 72: 1048576, 88: 33554433, 104: 33554432, 120: 1025, 136: 1049601, 152: 33555456, 168: 34603008, 184: 1048577, 200: 1024, 216: 34604033, 232: 1, 248: 1049600, 256: 33554432, 272: 1048576, 288: 33555457, 304: 34603009, 320: 1048577, 336: 33555456, 352: 34604032, 368: 1049601, 384: 1025, 400: 34604033, 416: 1049600, 432: 1, 448: 0, 464: 34603008, 480: 33554433, 496: 1024, 264: 1049600, 280: 33555457, 296: 34603009, 312: 1, 328: 33554432, 344: 1048576, 360: 1025, 376: 34604032, 392: 33554433, 408: 34603008, 424: 0, 440: 34604033, 456: 1049601, 472: 1024, 488: 33555456, 504: 1048577 }, { 0: 134219808, 1: 131072, 2: 134217728, 3: 32, 4: 131104, 5: 134350880, 6: 134350848, 7: 2048, 8: 134348800, 9: 134219776, 10: 133120, 11: 134348832, 12: 2080, 13: 0, 14: 134217760, 15: 133152, 2147483648: 2048, 2147483649: 134350880, 2147483650: 134219808, 2147483651: 134217728, 2147483652: 134348800, 2147483653: 133120, 2147483654: 133152, 2147483655: 32, 2147483656: 134217760, 2147483657: 2080, 2147483658: 131104, 2147483659: 134350848, 2147483660: 0, 2147483661: 134348832, 2147483662: 134219776, 2147483663: 131072, 16: 133152, 17: 134350848, 18: 32, 19: 2048, 20: 134219776, 21: 134217760, 22: 134348832, 23: 131072, 24: 0, 25: 131104, 26: 134348800, 27: 134219808, 28: 134350880, 29: 133120, 30: 2080, 31: 134217728, 2147483664: 131072, 2147483665: 2048, 2147483666: 134348832, 2147483667: 133152, 2147483668: 32, 2147483669: 134348800, 2147483670: 134217728, 2147483671: 134219808, 2147483672: 134350880, 2147483673: 134217760, 2147483674: 134219776, 2147483675: 0, 2147483676: 133120, 2147483677: 2080, 2147483678: 131104, 2147483679: 134350848 } ], d = [ 4160749569, 528482304, 33030144, 2064384, 129024, 8064, 504, 2147483679 ], f = c.DES = n.extend({ _doReset: function() { for (var v = this._key, x = v.words, b = [], E = 0; E < 56; E++) { var _ = o[E] - 1; b[E] = x[_ >>> 5] >>> 31 - _ % 32 & 1; } for (var y = this._subKeys = [], A = 0; A < 16; A++) { for (var R = y[A] = [], M = h[A], E = 0; E < 24; E++) R[E / 6 | 0] |= b[(u[E] - 1 + M) % 28] << 31 - E % 6, R[4 + (E / 6 | 0)] |= b[28 + (u[E + 24] - 1 + M) % 28] << 31 - E % 6; R[0] = R[0] << 1 | R[0] >>> 31; for (var E = 1; E < 7; E++) R[E] = R[E] >>> (E - 1) * 4 + 3; R[7] = R[7] << 5 | R[7] >>> 27; } for (var C = this._invSubKeys = [], E = 0; E < 16; E++) C[E] = y[15 - E]; }, encryptBlock: function(v, x) { this._doCryptBlock(v, x, this._subKeys); }, decryptBlock: function(v, x) { this._doCryptBlock(v, x, this._invSubKeys); }, _doCryptBlock: function(v, x, b) { this._lBlock = v[x], this._rBlock = v[x + 1], m.call(this, 4, 252645135), m.call(this, 16, 65535), l.call(this, 2, 858993459), l.call(this, 8, 16711935), m.call(this, 1, 1431655765); for (var E = 0; E < 16; E++) { for (var _ = b[E], y = this._lBlock, A = this._rBlock, R = 0, M = 0; M < 8; M++) R |= p[M][((A ^ _[M]) & d[M]) >>> 0]; this._lBlock = A, this._rBlock = y ^ R; } var C = this._lBlock; this._lBlock = this._rBlock, this._rBlock = C, m.call(this, 1, 1431655765), l.call(this, 8, 16711935), l.call(this, 2, 858993459), m.call(this, 16, 65535), m.call(this, 4, 252645135), v[x] = this._lBlock, v[x + 1] = this._rBlock; }, keySize: 64 / 32, ivSize: 64 / 32, blockSize: 64 / 32 }); function m(v, x) { var b = (this._lBlock >>> v ^ this._rBlock) & x; this._rBlock ^= b, this._lBlock ^= b << v; } function l(v, x) { var b = (this._rBlock >>> v ^ this._lBlock) & x; this._lBlock ^= b, this._rBlock ^= b << v; } t.DES = n._createHelper(f); var S = c.TripleDES = n.extend({ _doReset: function() { var v = this._key, x = v.words; if (x.length !== 2 && x.length !== 4 && x.length < 6) throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192."); var b = x.slice(0, 2), E = x.length < 4 ? x.slice(0, 2) : x.slice(2, 4), _ = x.length < 6 ? x.slice(0, 2) : x.slice(4, 6); this._des1 = f.createEncryptor(s.create(b)), this._des2 = f.createEncryptor(s.create(E)), this._des3 = f.createEncryptor(s.create(_)); }, encryptBlock: function(v, x) { this._des1.encryptBlock(v, x), this._des2.decryptBlock(v, x), this._des3.encryptBlock(v, x); }, decryptBlock: function(v, x) { this._des3.decryptBlock(v, x), this._des2.encryptBlock(v, x), this._des1.decryptBlock(v, x); }, keySize: 192 / 32, ivSize: 64 / 32, blockSize: 64 / 32 }); t.TripleDES = n._createHelper(S); }(), e.TripleDES; }); }(Ir)), Ir.exports; } var wr = { exports: {} }, Ta; function a0() { return Ta || (Ta = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), Ot(), Ut(), yt(), ye()); })(ie, function(e) { return function() { var t = e, i = t.lib, s = i.StreamCipher, n = t.algo, c = n.RC4 = s.extend({ _doReset: function() { for (var h = this._key, p = h.words, d = h.sigBytes, f = this._S = [], m = 0; m < 256; m++) f[m] = m; for (var m = 0, l = 0; m < 256; m++) { var S = m % d, v = p[S >>> 2] >>> 24 - S % 4 * 8 & 255; l = (l + f[m] + v) % 256; var x = f[m]; f[m] = f[l], f[l] = x; } this._i = this._j = 0; }, _doProcessBlock: function(h, p) { h[p] ^= o.call(this); }, keySize: 256 / 32, ivSize: 0 }); function o() { for (var h = this._S, p = this._i, d = this._j, f = 0, m = 0; m < 4; m++) { p = (p + 1) % 256, d = (d + h[p]) % 256; var l = h[p]; h[p] = h[d], h[d] = l, f |= h[(h[p] + h[d]) % 256] << 24 - m * 8; } return this._i = p, this._j = d, f; } t.RC4 = s._createHelper(c); var u = n.RC4Drop = c.extend({ /** * Configuration options. * * @property {number} drop The number of keystream words to drop. Default 192 */ cfg: c.cfg.extend({ drop: 192 }), _doReset: function() { c._doReset.call(this); for (var h = this.cfg.drop; h > 0; h--) o.call(this); } }); t.RC4Drop = s._createHelper(u); }(), e.RC4; }); }(wr)), wr.exports; } var Dr = { exports: {} }, Pa; function n0() { return Pa || (Pa = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), Ot(), Ut(), yt(), ye()); })(ie, function(e) { return function() { var t = e, i = t.lib, s = i.StreamCipher, n = t.algo, c = [], o = [], u = [], h = n.Rabbit = s.extend({ _doReset: function() { for (var d = this._key.words, f = this.cfg.iv, m = 0; m < 4; m++) d[m] = (d[m] << 8 | d[m] >>> 24) & 16711935 | (d[m] << 24 | d[m] >>> 8) & 4278255360; var l = this._X = [ d[0], d[3] << 16 | d[2] >>> 16, d[1], d[0] << 16 | d[3] >>> 16, d[2], d[1] << 16 | d[0] >>> 16, d[3], d[2] << 16 | d[1] >>> 16 ], S = this._C = [ d[2] << 16 | d[2] >>> 16, d[0] & 4294901760 | d[1] & 65535, d[3] << 16 | d[3] >>> 16, d[1] & 4294901760 | d[2] & 65535, d[0] << 16 | d[0] >>> 16, d[2] & 4294901760 | d[3] & 65535, d[1] << 16 | d[1] >>> 16, d[3] & 4294901760 | d[0] & 65535 ]; this._b = 0; for (var m = 0; m < 4; m++) p.call(this); for (var m = 0; m < 8; m++) S[m] ^= l[m + 4 & 7]; if (f) { var v = f.words, x = v[0], b = v[1], E = (x << 8 | x >>> 24) & 16711935 | (x << 24 | x >>> 8) & 4278255360, _ = (b << 8 | b >>> 24) & 16711935 | (b << 24 | b >>> 8) & 4278255360, y = E >>> 16 | _ & 4294901760, A = _ << 16 | E & 65535; S[0] ^= E, S[1] ^= y, S[2] ^= _, S[3] ^= A, S[4] ^= E, S[5] ^= y, S[6] ^= _, S[7] ^= A; for (var m = 0; m < 4; m++) p.call(this); } }, _doProcessBlock: function(d, f) { var m = this._X; p.call(this), c[0] = m[0] ^ m[5] >>> 16 ^ m[3] << 16, c[1] = m[2] ^ m[7] >>> 16 ^ m[5] << 16, c[2] = m[4] ^ m[1] >>> 16 ^ m[7] << 16, c[3] = m[6] ^ m[3] >>> 16 ^ m[1] << 16; for (var l = 0; l < 4; l++) c[l] = (c[l] << 8 | c[l] >>> 24) & 16711935 | (c[l] << 24 | c[l] >>> 8) & 4278255360, d[f + l] ^= c[l]; }, blockSize: 128 / 32, ivSize: 64 / 32 }); function p() { for (var d = this._X, f = this._C, m = 0; m < 8; m++) o[m] = f[m]; f[0] = f[0] + 1295307597 + this._b | 0, f[1] = f[1] + 3545052371 + (f[0] >>> 0 < o[0] >>> 0 ? 1 : 0) | 0, f[2] = f[2] + 886263092 + (f[1] >>> 0 < o[1] >>> 0 ? 1 : 0) | 0, f[3] = f[3] + 1295307597 + (f[2] >>> 0 < o[2] >>> 0 ? 1 : 0) | 0, f[4] = f[4] + 3545052371 + (f[3] >>> 0 < o[3] >>> 0 ? 1 : 0) | 0, f[5] = f[5] + 886263092 + (f[4] >>> 0 < o[4] >>> 0 ? 1 : 0) | 0, f[6] = f[6] + 1295307597 + (f[5] >>> 0 < o[5] >>> 0 ? 1 : 0) | 0, f[7] = f[7] + 3545052371 + (f[6] >>> 0 < o[6] >>> 0 ? 1 : 0) | 0, this._b = f[7] >>> 0 < o[7] >>> 0 ? 1 : 0; for (var m = 0; m < 8; m++) { var l = d[m] + f[m], S = l & 65535, v = l >>> 16, x = ((S * S >>> 17) + S * v >>> 15) + v * v, b = ((l & 4294901760) * l | 0) + ((l & 65535) * l | 0); u[m] = x ^ b; } d[0] = u[0] + (u[7] << 16 | u[7] >>> 16) + (u[6] << 16 | u[6] >>> 16) | 0, d[1] = u[1] + (u[0] << 8 | u[0] >>> 24) + u[7] | 0, d[2] = u[2] + (u[1] << 16 | u[1] >>> 16) + (u[0] << 16 | u[0] >>> 16) | 0, d[3] = u[3] + (u[2] << 8 | u[2] >>> 24) + u[1] | 0, d[4] = u[4] + (u[3] << 16 | u[3] >>> 16) + (u[2] << 16 | u[2] >>> 16) | 0, d[5] = u[5] + (u[4] << 8 | u[4] >>> 24) + u[3] | 0, d[6] = u[6] + (u[5] << 16 | u[5] >>> 16) + (u[4] << 16 | u[4] >>> 16) | 0, d[7] = u[7] + (u[6] << 8 | u[6] >>> 24) + u[5] | 0; } t.Rabbit = s._createHelper(h); }(), e.Rabbit; }); }(Dr)), Dr.exports; } var Tr = { exports: {} }, ka; function o0() { return ka || (ka = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), Ot(), Ut(), yt(), ye()); })(ie, function(e) { return function() { var t = e, i = t.lib, s = i.StreamCipher, n = t.algo, c = [], o = [], u = [], h = n.RabbitLegacy = s.extend({ _doReset: function() { var d = this._key.words, f = this.cfg.iv, m = this._X = [ d[0], d[3] << 16 | d[2] >>> 16, d[1], d[0] << 16 | d[3] >>> 16, d[2], d[1] << 16 | d[0] >>> 16, d[3], d[2] << 16 | d[1] >>> 16 ], l = this._C = [ d[2] << 16 | d[2] >>> 16, d[0] & 4294901760 | d[1] & 65535, d[3] << 16 | d[3] >>> 16, d[1] & 4294901760 | d[2] & 65535, d[0] << 16 | d[0] >>> 16, d[2] & 4294901760 | d[3] & 65535, d[1] << 16 | d[1] >>> 16, d[3] & 4294901760 | d[0] & 65535 ]; this._b = 0; for (var S = 0; S < 4; S++) p.call(this); for (var S = 0; S < 8; S++) l[S] ^= m[S + 4 & 7]; if (f) { var v = f.words, x = v[0], b = v[1], E = (x << 8 | x >>> 24) & 16711935 | (x << 24 | x >>> 8) & 4278255360, _ = (b << 8 | b >>> 24) & 16711935 | (b << 24 | b >>> 8) & 4278255360, y = E >>> 16 | _ & 4294901760, A = _ << 16 | E & 65535; l[0] ^= E, l[1] ^= y, l[2] ^= _, l[3] ^= A, l[4] ^= E, l[5] ^= y, l[6] ^= _, l[7] ^= A; for (var S = 0; S < 4; S++) p.call(this); } }, _doProcessBlock: function(d, f) { var m = this._X; p.call(this), c[0] = m[0] ^ m[5] >>> 16 ^ m[3] << 16, c[1] = m[2] ^ m[7] >>> 16 ^ m[5] << 16, c[2] = m[4] ^ m[1] >>> 16 ^ m[7] << 16, c[3] = m[6] ^ m[3] >>> 16 ^ m[1] << 16; for (var l = 0; l < 4; l++) c[l] = (c[l] << 8 | c[l] >>> 24) & 16711935 | (c[l] << 24 | c[l] >>> 8) & 4278255360, d[f + l] ^= c[l]; }, blockSize: 128 / 32, ivSize: 64 / 32 }); function p() { for (var d = this._X, f = this._C, m = 0; m < 8; m++) o[m] = f[m]; f[0] = f[0] + 1295307597 + this._b | 0, f[1] = f[1] + 3545052371 + (f[0] >>> 0 < o[0] >>> 0 ? 1 : 0) | 0, f[2] = f[2] + 886263092 + (f[1] >>> 0 < o[1] >>> 0 ? 1 : 0) | 0, f[3] = f[3] + 1295307597 + (f[2] >>> 0 < o[2] >>> 0 ? 1 : 0) | 0, f[4] = f[4] + 3545052371 + (f[3] >>> 0 < o[3] >>> 0 ? 1 : 0) | 0, f[5] = f[5] + 886263092 + (f[4] >>> 0 < o[4] >>> 0 ? 1 : 0) | 0, f[6] = f[6] + 1295307597 + (f[5] >>> 0 < o[5] >>> 0 ? 1 : 0) | 0, f[7] = f[7] + 3545052371 + (f[6] >>> 0 < o[6] >>> 0 ? 1 : 0) | 0, this._b = f[7] >>> 0 < o[7] >>> 0 ? 1 : 0; for (var m = 0; m < 8; m++) { var l = d[m] + f[m], S = l & 65535, v = l >>> 16, x = ((S * S >>> 17) + S * v >>> 15) + v * v, b = ((l & 4294901760) * l | 0) + ((l & 65535) * l | 0); u[m] = x ^ b; } d[0] = u[0] + (u[7] << 16 | u[7] >>> 16) + (u[6] << 16 | u[6] >>> 16) | 0, d[1] = u[1] + (u[0] << 8 | u[0] >>> 24) + u[7] | 0, d[2] = u[2] + (u[1] << 16 | u[1] >>> 16) + (u[0] << 16 | u[0] >>> 16) | 0, d[3] = u[3] + (u[2] << 8 | u[2] >>> 24) + u[1] | 0, d[4] = u[4] + (u[3] << 16 | u[3] >>> 16) + (u[2] << 16 | u[2] >>> 16) | 0, d[5] = u[5] + (u[4] << 8 | u[4] >>> 24) + u[3] | 0, d[6] = u[6] + (u[5] << 16 | u[5] >>> 16) + (u[4] << 16 | u[4] >>> 16) | 0, d[7] = u[7] + (u[6] << 8 | u[6] >>> 24) + u[5] | 0; } t.RabbitLegacy = s._createHelper(h); }(), e.RabbitLegacy; }); }(Tr)), Tr.exports; } var Pr = { exports: {} }, Ba; function c0() { return Ba || (Ba = 1, function(r, a) { (function(e, t, i) { r.exports = t(ne(), Ot(), Ut(), yt(), ye()); })(ie, function(e) { return function() { var t = e, i = t.lib, s = i.BlockCipher, n = t.algo; const c = 16, o = [ 608135816, 2242054355, 320440878, 57701188, 2752067618, 698298832, 137296536, 3964562569, 1160258022, 953160567, 3193202383, 887688300, 3232508343, 3380367581, 1065670069, 3041331479, 2450970073, 2306472731 ], u = [ [ 3509652390, 2564797868, 805139163, 3491422135, 3101798381, 1780907670, 3128725573, 4046225305, 614570311, 3012652279, 134345442, 2240740374, 1667834072, 1901547113, 2757295779, 4103290238, 227898511, 1921955416, 1904987480, 2182433518, 2069144605, 3260701109, 2620446009, 720527379, 3318853667, 677414384, 3393288472, 3101374703, 2390351024, 1614419982, 1822297739, 2954791486, 3608508353, 3174124327, 2024746970, 1432378464, 3864339955, 2857741204, 1464375394, 1676153920, 1439316330, 715854006, 3033291828, 289532110, 2706671279, 2087905683, 3018724369, 1668267050, 732546397, 1947742710, 3462151702, 2609353502, 2950085171, 1814351708, 2050118529, 680887927, 999245976, 1800124847, 3300911131, 1713906067, 1641548236, 4213287313, 1216130144, 1575780402, 4018429277, 3917837745, 3693486850, 3949271944, 596196993, 3549867205, 258830323, 2213823033, 772490370, 2760122372, 1774776394, 2652871518, 566650946, 4142492826, 1728879713, 2882767088, 1783734482, 3629395816, 2517608232, 2874225571, 1861159788, 326777828, 3124490320, 2130389656, 2716951837, 967770486, 1724537150, 2185432712, 2364442137, 1164943284, 2105845187, 998989502, 3765401048, 2244026483, 1075463327, 1455516326, 1322494562, 910128902, 469688178, 1117454909, 936433444, 3490320968, 3675253459, 1240580251, 122909385, 2157517691, 634681816, 4142456567, 3825094682, 3061402683, 2540495037, 79693498, 3249098678, 1084186820, 1583128258, 426386531, 1761308591, 1047286709, 322548459, 995290223, 1845252383, 2603652396, 3431023940, 2942221577, 3202600964, 3727903485, 1712269319, 422464435, 3234572375, 1170764815, 3523960633, 3117677531, 1434042557, 442511882, 3600875718, 1076654713, 1738483198, 4213154764, 2393238008, 3677496056, 1014306527, 4251020053, 793779912, 2902807211, 842905082, 4246964064, 1395751752, 1040244610, 2656851899, 3396308128, 445077038, 3742853595, 3577915638, 679411651, 2892444358, 2354009459, 1767581616, 3150600392, 3791627101, 3102740896, 284835224, 4246832056, 1258075500, 768725851, 2589189241, 3069724005, 3532540348, 1274779536, 3789419226, 2764799539, 1660621633, 3471099624, 4011903706, 913787905, 3497959166, 737222580, 2514213453, 2928710040, 3937242737, 1804850592, 3499020752, 2949064160, 2386320175, 2390070455, 2415321851, 4061277028, 2290661394, 2416832540, 1336762016, 1754252060, 3520065937, 3014181293, 791618072, 3188594551, 3933548030, 2332172193, 3852520463, 3043980520, 413987798, 3465142937, 3030929376, 4245938359, 2093235073, 3534596313, 375366246, 2157278981, 2479649556, 555357303, 3870105701, 2008414854, 3344188149, 4221384143, 3956125452, 2067696032, 3594591187, 2921233993, 2428461, 544322398, 577241275, 1471733935, 610547355, 4027169054, 1432588573, 1507829418, 2025931657, 3646575487, 545086370, 48609733, 2200306550, 1653985193, 298326376, 1316178497, 3007786442, 2064951626, 458293330, 2589141269, 3591329599, 3164325604, 727753846, 2179363840, 146436021, 1461446943, 4069977195, 705550613, 3059967265, 3887724982, 4281599278, 3313849956, 1404054877, 2845806497, 146425753, 1854211946 ], [ 1266315497, 3048417604, 3681880366, 3289982499, 290971e4, 1235738493, 2632868024, 2414719590, 3970600049, 1771706367, 1449415276, 3266420449, 422970021, 1963543593, 2690192192, 3826793022, 1062508698, 1531092325, 1804592342, 2583117782, 2714934279, 4024971509, 1294809318, 4028980673, 1289560198, 2221992742, 1669523910, 35572830, 157838143, 1052438473, 1016535060, 1802137761, 1753167236, 1386275462, 3080475397, 2857371447, 1040679964, 2145300060, 2390574316, 1461121720, 2956646967, 4031777805, 4028374788, 33600511, 2920084762, 1018524850, 629373528, 3691585981, 3515945977, 2091462646, 2486323059, 586499841, 988145025, 935516892, 3367335476, 2599673255, 2839830854, 265290510, 3972581182, 2759138881, 3795373465, 1005194799, 847297441, 406762289, 1314163512, 1332590856, 1866599683, 4127851711, 750260880, 613907577, 1450815602, 3165620655, 3734664991, 3650291728, 3012275730, 3704569646, 1427272223, 778793252, 1343938022, 2676280711, 2052605720, 1946737175, 3164576444, 3914038668, 3967478842, 3682934266, 1661551462, 3294938066, 4011595847, 840292616, 3712170807, 616741398, 312560963, 711312465, 1351876610, 322626781, 1910503582, 271666773, 2175563734, 1594956187, 70604529, 3617834859, 1007753275, 1495573769, 4069517037, 2549218298, 2663038764, 504708206, 2263041392, 3941167025, 2249088522, 1514023603, 1998579484, 1312622330, 694541497, 2582060303, 2151582166, 1382467621, 776784248, 2618340202, 3323268794, 2497899128, 2784771155, 503983604, 4076293799, 907881277, 423175695, 432175456, 1378068232, 4145222326, 3954048622, 3938656102, 3820766613, 2793130115, 2977904593, 26017576, 3274890735, 3194772133, 1700274565, 1756076034, 4006520079, 3677328699, 720338349, 1533947780, 354530856, 688349552, 3973924725, 1637815568, 332179504, 3949051286, 53804574, 2852348879, 3044236432, 1282449977, 3583942155, 3416972820, 4006381244, 1617046695, 2628476075, 3002303598, 1686838959, 431878346, 2686675385, 1700445008, 1080580658, 1009431731, 832498133, 3223435511, 2605976345, 2271191193, 2516031870, 1648197032, 4164389018, 2548247927, 300782431, 375919233, 238389289, 3353747414, 2531188641, 2019080857, 1475708069, 455242339, 2609103871, 448939670, 3451063019, 1395535956, 2413381860, 1841049896, 1491858159, 885456874, 4264095073, 4001119347, 1565136089, 3898914787, 1108368660, 540939232, 1173283510, 2745871338, 3681308437, 4207628240, 3343053890, 4016749493, 1699691293, 1103962373, 3625875870, 2256883143, 3830138730, 1031889488, 3479347698, 1535977030, 4236805024, 3251091107, 2132092099, 1774941330, 1199868427, 1452454533, 157007616, 2904115357, 342012276, 595725824, 1480756522, 206960106, 497939518, 591360097, 863170706, 2375253569, 3596610801, 1814182875, 2094937945, 3421402208, 1082520231, 3463918190, 2785509508, 435703966, 3908032597, 1641649973, 2842273706, 3305899714, 1510255612, 2148256476, 2655287854, 3276092548, 4258621189, 236887753, 3681803219, 274041037, 1734335097, 3815195456, 3317970021, 1899903192, 1026095262, 4050517792, 356393447, 2410691914, 3873677099, 3682840055 ], [ 3913112168, 2491498743, 4132185628, 2489919796, 1091903735, 1979897079, 3170134830, 3567386728, 3557303409, 857797738, 1136121015, 1342202287, 507115054, 2535736646, 337727348, 3213592640, 1301675037, 2528481711, 1895095763, 1721773893, 3216771564, 62756741, 2142006736, 835421444, 2531993523, 1442658625, 3659876326, 2882144922, 676362277, 1392781812, 170690266, 3921047035, 1759253602, 3611846912, 1745797284, 664899054, 1329594018, 3901205900, 3045908486, 2062866102, 2865634940, 3543621612, 3464012697, 1080764994, 553557557, 3656615353, 3996768171, 991055499, 499776247, 1265440854, 648242737, 3940784050, 980351604, 3713745714, 1749149687, 3396870395, 4211799374, 3640570775, 1161844396, 3125318951, 1431517754, 545492359, 4268468663, 3499529547, 1437099964, 2702547544, 3433638243, 2581715763, 2787789398, 1060185593, 1593081372, 2418618748, 4260947970, 69676912, 2159744348, 86519011, 2512459080, 3838209314, 1220612927, 3339683548, 133810670, 1090789135, 1078426020, 1569222167, 845107691, 3583754449, 4072456591, 1091646820, 628848692, 1613405280, 3757631651, 526609435, 236106946, 48312990, 2942717905, 3402727701, 1797494240, 859738849, 992217954, 4005476642, 2243076622, 3870952857, 3732016268, 765654824, 3490871365, 2511836413, 1685915746, 3888969200, 1414112111, 2273134842, 3281911079, 4080962846, 172450625, 2569994100, 980381355, 4109958455, 2819808352, 2716589560, 2568741196, 3681446669, 3329971472, 1835478071, 660984891, 3704678404, 4045999559, 3422617507, 3040415634, 1762651403, 1719377915, 3470491036, 2693910283, 3642056355, 3138596744, 1364962596, 2073328063, 1983633131, 926494387, 3423689081, 2150032023, 4096667949, 1749200295, 3328846651, 309677260, 2016342300, 1779581495, 3079819751, 111262694, 1274766160, 443224088, 298511866, 1025883608, 3806446537, 1145181785, 168956806, 3641502830, 3584813610, 1689216846, 3666258015, 3200248200, 1692713982, 2646376535, 4042768518, 1618508792, 1610833997, 3523052358, 4130873264, 2001055236, 3610705100, 2202168115, 4028541809, 2961195399, 1006657119, 2006996926, 3186142756, 1430667929, 3210227297, 1314452623, 4074634658, 4101304120, 2273951170, 1399257539, 3367210612, 3027628629, 1190975929, 2062231137, 2333990788, 2221543033, 2438960610, 1181637006, 548689776, 2362791313, 3372408396, 3104550113, 3145860560, 296247880, 1970579870, 3078560182, 3769228297, 1714227617, 3291629107, 3898220290, 166772364, 1251581989, 493813264, 448347421, 195405023, 2709975567, 677966185, 3703036547, 1463355134, 2715995803, 1338867538, 1343315457, 2802222074, 2684532164, 233230375, 2599980071, 2000651841, 3277868038, 1638401717, 4028070440, 3237316320, 6314154, 819756386, 300326615, 590932579, 1405279636, 3267499572, 3150704214, 2428286686, 3959192993, 3461946742, 1862657033, 1266418056, 963775037, 2089974820, 2263052895, 1917689273, 448879540, 3550394620, 3981727096, 150775221, 3627908307, 1303187396, 508620638, 2975983352, 2726630617, 1817252668, 1876281319, 1457606340, 908771278, 3720792119, 3617206836, 2455994898, 1729034894, 1080033504 ], [ 976866871, 3556439503, 2881648439, 1522871579, 1555064734, 1336096578, 3548522304, 2579274686, 3574697629, 3205460757, 3593280638, 3338716283, 3079412587, 564236357, 2993598910, 1781952180, 1464380207, 3163844217, 3332601554, 1699332808, 1393555694, 1183702653, 3581086237, 1288719814, 691649499, 2847557200, 2895455976, 3193889540, 2717570544, 1781354906, 1676643554, 2592534050, 3230253752, 1126444790, 2770207658, 2633158820, 2210423226, 2615765581, 2414155088, 3127139286, 673620729, 2805611233, 1269405062, 4015350505, 3341807571, 4149409754, 1057255273, 2012875353, 2162469141, 2276492801, 2601117357, 993977747, 3918593370, 2654263191, 753973209, 36408145, 2530585658, 25011837, 3520020182, 2088578344, 530523599, 2918365339, 1524020338, 1518925132, 3760827505, 3759777254, 1202760957, 3985898139, 3906192525, 674977740, 4174734889, 2031300136, 2019492241, 3983892565, 4153806404, 3822280332, 352677332, 2297720250, 60907813, 90501309, 3286998549, 1016092578, 2535922412, 2839152426, 457141659, 509813237, 4120667899, 652014361, 1966332200, 2975202805, 55981186, 2327461051, 676427537, 3255491064, 2882294119, 3433927263, 1307055953, 942726286, 933058658, 2468411793, 3933900994, 4215176142, 1361170020, 2001714738, 2830558078, 3274259782, 1222529897, 1679025792, 2729314320, 3714953764, 1770335741, 151462246, 3013232138, 1682292957, 1483529935, 471910574, 1539241949, 458788160, 3436315007, 1807016891, 3718408830, 978976581, 1043663428, 3165965781, 1927990952, 4200891579, 2372276910, 3208408903, 3533431907, 1412390302, 2931980059, 4132332400, 1947078029, 3881505623, 4168226417, 2941484381, 1077988104, 1320477388, 886195818, 18198404, 3786409e3, 2509781533, 112762804, 3463356488, 1866414978, 891333506, 18488651, 661792760, 1628790961, 3885187036, 3141171499, 876946877, 2693282273, 1372485963, 791857591, 2686433993, 3759982718, 3167212022, 3472953795, 2716379847, 445679433, 3561995674, 3504004811, 3574258232, 54117162, 3331405415, 2381918588, 3769707343, 4154350007, 1140177722, 4074052095, 668550556, 3214352940, 367459370, 261225585, 2610173221, 4209349473, 3468074219, 3265815641, 314222801, 3066103646, 3808782860, 282218597, 3406013506, 3773591054, 379116347, 1285071038, 846784868, 2669647154, 3771962079, 3550491691, 2305946142, 453669953, 1268987020, 3317592352, 3279303384, 3744833421, 2610507566, 3859509063, 266596637, 3847019092, 517658769, 3462560207, 3443424879, 370717030, 4247526661, 2224018117, 4143653529, 4112773975, 2788324899, 2477274417, 1456262402, 2901442914, 1517677493, 1846949527, 2295493580, 3734397586, 2176403920, 1280348187, 1908823572, 3871786941, 846861322, 1172426758, 3287448474, 3383383037, 1655181056, 3139813346, 901632758, 1897031941, 2986607138, 3066810236, 3447102507, 1393639104, 373351379, 950779232, 625454576, 3124240540, 4148612726, 2007998917, 544563296, 2244738638, 2330496472, 2058025392, 1291430526, 424198748, 50039436, 29584100, 3605783033, 2429876329, 2791104160, 1057563949, 3255363231, 3075367218, 3463963227, 1469046755, 985887462 ] ]; var h = { pbox: [], sbox: [] }; function p(S, v) { let x = v >> 24 & 255, b = v >> 16 & 255, E = v >> 8 & 255, _ = v & 255, y = S.sbox[0][x] + S.sbox[1][b]; return y = y ^ S.sbox[2][E], y = y + S.sbox[3][_], y; } function d(S, v, x) { let b = v, E = x, _; for (let y = 0; y < c; ++y) b = b ^ S.pbox[y], E = p(S, b) ^ E, _ = b, b = E, E = _; return _ = b, b = E, E = _, E = E ^ S.pbox[c], b = b ^ S.pbox[c + 1], { left: b, right: E }; } function f(S, v, x) { let b = v, E = x, _; for (let y = c + 1; y > 1; --y) b = b ^ S.pbox[y], E = p(S, b) ^ E, _ = b, b = E, E = _; return _ = b, b = E, E = _, E = E ^ S.pbox[1], b = b ^ S.pbox[0], { left: b, right: E }; } function m(S, v, x) { for (let A = 0; A < 4; A++) { S.sbox[A] = []; for (let R = 0; R < 256; R++) S.sbox[A][R] = u[A][R]; } let b = 0; for (let A = 0; A < c + 2; A++) S.pbox[A] = o[A] ^ v[b], b++, b >= x && (b = 0); let E = 0, _ = 0, y = 0; for (let A = 0; A < c + 2; A += 2) y = d(S, E, _), E = y.left, _ = y.right, S.pbox[A] = E, S.pbox[A + 1] = _; for (let A = 0; A < 4; A++) for (let R = 0; R < 256; R += 2) y = d(S, E, _), E = y.left, _ = y.right, S.sbox[A][R] = E, S.sbox[A][R + 1] = _; return !0; } var l = n.Blowfish = s.extend({ _doReset: function() { if (this._keyPriorReset !== this._key) { var S = this._keyPriorReset = this._key, v = S.words, x = S.sigBytes / 4; m(h, v, x); } }, encryptBlock: function(S, v) { var x = d(h, S[v], S[v + 1]); S[v] = x.left, S[v + 1] = x.right; }, decryptBlock: function(S, v) { var x = f(h, S[v], S[v + 1]); S[v] = x.left, S[v + 1] = x.right; }, blockSize: 64 / 32, keySize: 128 / 32, ivSize: 64 / 32 }); t.Blowfish = s._createHelper(l); }(), e.Blowfish; }); }(Pr)), Pr.exports; } (function(r, a) { (function(e, t, i) { r.exports = t(ne(), Ci(), Vo(), Oo(), Ot(), Uo(), Ut(), hn(), Xr(), Ho(), dn(), jo(), zo(), Wo(), Yr(), $o(), yt(), ye(), Ko(), qo(), Jo(), Go(), Xo(), Yo(), Zo(), Qo(), e0(), t0(), i0(), r0(), s0(), a0(), n0(), o0(), c0()); })(ie, function(e) { return e; }); })(un); var u0 = un.exports; const ai = /* @__PURE__ */ ko(u0); function h0(r) { return ai.MD5(r).toString().toUpperCase(); } function d0(r, a, e, t, i, s, n, c) { var o; let u = ""; s.set("x-log-apiversion", "0.6.0"), s.set("x-log-signaturemethod", "hmac-sha1"), u += r + ` ` + n + ` ` + ((o = s.get("Content-Type")) != null ? o : "") + ` ` + c + ` `; 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] + ` `).join(""); u += m; } catch (m) { } u += a, i.size > 0 && (u += "?"); try { u += [...i.entries()].sort(h).map((m) => m[0] + "=" + m[1]).join("&"); } catch (m) { } const d = ai.HmacSHA1(u, t).toString(ai.enc.Base64), f = "LOG " + e + ":" + d; return s.set("Authorization", f), s.set("x-log-date", c), f; } var l0 = (r, a, e) => new Promise((t, i) => { var s = (o) => { try { c(e.next(o)); } catch (u) { i(u); } }, n = (o) => { try { c(e.throw(o)); } catch (u) { i(u); } }, c = (o) => o.done ? t(o.value) : Promise.resolve(o.value).then(s, n); c((e = e.apply(r, a)).next()); }); function f0(r) { return l0(this, null, function* () { const a = /* @__PURE__ */ new Date(); if (r.refreshSTSTokenInterval || (r.refreshSTSTokenInterval = 3e5), !r.stsTokenFreshTime || +a - r.stsTokenFreshTime >= r.refreshSTSTokenInterval) { r.stsTokenFreshTime = a; try { yield r.refreshSTSToken(); } catch (e) { typeof console.error == "function" && console.error(`Some error occured during excuting refreshSTSToken, see: ` + e); } } return null; }); } var p0 = (r, a, e) => new Promise((t, i) => { var s = (o) => { try { c(e.next(o)); } catch (u) { i(u); } }, n = (o) => { try { c(e.throw(o)); } catch (u) { i(u); } }, c = (o) => o.done ? t(o.value) : Promise.resolve(o.value).then(s, n); c((e = e.apply(r, a)).next()); }); function Zr(r) { return { transString: function(a) { let e = {}, t = 0, i = !1; for (let s in a) { if ((s === "time" || s === "__time__") && typeof a[s] == "number") { t = a[s], i = !0; continue; } typeof a[s] == "object" ? e[s] = JSON.stringify(a[s]) : e[s] = String(a[s]); } return e.__time__ = i ? t : Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3), e; }, process: function(a, e) { return p0(this, null, function* () { yield f0(r); let t = a.slice(a.indexOf("/logstores")), i = e.length, s = h0(e), n = (/* @__PURE__ */ new Date()).toUTCString(), c = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map([ ["Content-Type", "application/json"], ["Content-MD5", s], ["x-log-bodyrawsize", i.toString()] ]); r.securityToken && o.set("x-acs-security-token", r.securityToken), d0("POST", t, r.accessKeyId, r.accessKeySecret, c, o, s, n); let u = Object.fromEntries(o); return { data: e, header: u }; }); } }; } typeof window != "undefined" && cn(window, "stsPlugin", Zr); var g0 = /d{1,4}|D{3,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|W{1,2}|[LlopSZN]|"[^"]*"|'[^']*'/g, m0 = /\b(?:[A-Z]{1,3}[A-Z][TC])(?:[-+]\d{4})?|((?:Australian )?(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time)\b/g, S0 = /[^-+\dA-Z]/g; function Qr(r, a, e, t) { if (arguments.length === 1 && typeof r == "string" && !/\d/.test(r) && (a = r, r = void 0), r = r || r === 0 ? r : /* @__PURE__ */ new Date(), r instanceof Date || (r = new Date(r)), isNaN(r)) throw TypeError("Invalid date"); a = String(Na[a] || a || Na.default); var i = a.slice(0, 4); (i === "UTC:" || i === "GMT:") && (a = a.slice(4), e = !0, i === "GMT:" && (t = !0)); var s = function() { return e ? "getUTC" : "get"; }, n = 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 x0(r); }, S = function() { return v0(r); }, v = { d: function() { return n(); }, dd: function() { return Ke(n()); }, ddd: function() { return Oe.dayNames[c()]; }, DDD: function() { return Ma({ y: u(), m: o(), d: n(), _: s(), dayName: Oe.dayNames[c()], short: !0 }); }, dddd: function() { return Oe.dayNames[c() + 7]; }, DDDD: function() { return Ma({ y: u(), m: o(), d: n(), _: s(), dayName: Oe.dayNames[c() + 7] }); }, m: function() { return o() + 1; }, mm: function() { return Ke(o() + 1); }, mmm: function() { return Oe.monthNames[o()]; }, mmmm: function() { return Oe.monthNames[o() + 12]; }, yy: function() { return String(u()).slice(2); }, yyyy: function() { return Ke(u(), 4); }, h: function() { return h() % 12 || 12; }, hh: function() { return Ke(h() % 12 || 12); }, H: function() { return h(); }, HH: function() { return Ke(h()); }, M: function() { return p(); }, MM: function() { return Ke(p()); }, s: function() { return d(); }, ss: function() { return Ke(d()); }, l: function() { return Ke(f(), 3); }, L: function() { return Ke(Math.floor(f() / 10)); }, t: function() { return h() < 12 ? Oe.timeNames[0] : Oe.timeNames[1]; }, tt: function() { return h() < 12 ? Oe.timeNames[2] : Oe.timeNames[3]; }, T: function() { return h() < 12 ? Oe.timeNames[4] : Oe.timeNames[5]; }, TT: function() { return h() < 12 ? Oe.timeNames[6] : Oe.timeNames[7]; }, Z: function() { return t ? "GMT" : e ? "UTC" : b0(r); }, o: function() { return (m() > 0 ? "-" : "+") + Ke(Math.floor(Math.abs(m()) / 60) * 100 + Math.abs(m()) % 60, 4); }, p: function() { return (m() > 0 ? "-" : "+") + Ke(Math.floor(Math.abs(m()) / 60), 2) + ":" + Ke(Math.floor(Math.abs(m()) % 60), 2); }, S: function() { return ["th", "st", "nd", "rd"][n() % 10 > 3 ? 0 : (n() % 100 - n() % 10 != 10) * n() % 10]; }, W: function() { return l(); }, WW: function() { return Ke(l()); }, N: function() { return S(); } }; return a.replace(g0, function(x) { return x in v ? v[x]() : x.slice(1, x.length - 1); }); } var Na = { default: "ddd mmm dd yyyy HH:MM:ss", shortDate: "m/d/yy", paddedShortDate: "mm/dd/yyyy", mediumDate: "mmm d, yyyy", longDate: "mmmm d, yyyy", fullDate: "dddd, mmmm d, yyyy", shortTime: "h:MM TT", mediumTime: "h:MM:ss TT", longTime: "h:MM:ss TT Z", isoDate: "yyyy-mm-dd", isoTime: "HH:MM:ss", isoDateTime: "yyyy-mm-dd'T'HH:MM:sso", isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'", expiresHeaderFormat: "ddd, dd mmm yyyy HH:MM:ss Z" }, Oe = { 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"] }, Ke = function(a) { var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2; return String(a).padStart(e, "0"); }, Ma = function(a) { var e = a.y, t = a.m, i = a.d, s = a._, n = a.dayName, c = a.short, o = c === void 0 ? !1 : c, u = /* @__PURE__ */ new Date(), h = /* @__PURE__ */ new Date(); h.setDate(h[s + "Date"]() - 1); var p = /* @__PURE__ */ 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" : n; }, x0 = function(a) { var e = new Date(a.getFullYear(), a.getMonth(), a.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); }, v0 = function(a) { var e = a.getDay(); return e === 0 && (e = 7), e; }, b0 = function(a) { return (String(a).match(m0) || [""]).pop().replace(S0, "").replace(/GMT\+0000/g, "UTC"); }; const { BrowserUtil: E0 } = le, jt = { EdgeHTML: "EdgeHTML", Blink: "Blink", Trident: "Trident", Gecko: "Gecko", WebKit: "WebKit" }, pi = (r, a) => { const e = a.match(r); return e && e.length > 0 && e[1] || ""; }, _0 = [ /* EdgeHTML */ { test: [/\sedg\//i, [/edg([ea]|ios)/i]], describe(r) { if (/\sedg\//i.test(r)) return { name: jt.Blink }; const e = pi(/edge\/(\d+(\.?_?\d+)+)/i, r); return { name: jt.EdgeHTML, version: e }; } }, /* Trident */ { test: [/trident/i], describe(r) { const a = { name: jt.Trident }, e = pi(/trident\/(\d+(\.?_?\d+)+)/i, r); return e && (a.version = e), a; } }, /* Gecko */ { test(r) { const a = /gecko/i.test(r), e = /like gecko/i.test(r); return a && !e; }, describe(r) { const a = { name: jt.Gecko }, e = pi(/gecko\/(\d+(\.?_?\d+)+)/i, r); return e && (a.version = e), a; } }, /* Blink */ { test: [/(apple)?webkit\/537\.36/i], describe() { return { name: jt.Blink }; } }, /* WebKit */ { test: [/(apple)?webkit/i], describe(r) { const a = { name: jt.WebKit }, e = pi(/webkit\/(\d+(\.?_?\d+)+)/i, r); return e && (a.version = e), a; } } ], es = (r, a) => r.find((e) => { if (typeof e.test == "function") return e.test(a); if (Array.isArray(e.test)) return e.test.some((t) => typeof t == "string" ? a.indexOf(t) > -1 : t instanceof RegExp ? t.test(a) : !1); }), A0 = () => { try { const r = navigator.userAgent || "", a = es(_0, r); if (a) { const e = a.describe(r); return `${e.name}/${e.version || E0.browserVersion}`; } } catch (r) { } return navigator.userAgent; }, y0 = [ { test: ["wow64", "win64", "x64"], describe() { return "amd64"; } }, { test: ["i686", "x86"], describe() { return "x86"; } }, { test: ["aarch64", "arm64"], describe() { return "arm64"; } }, { test: ["arm"], describe() { return "arm"; } } ], ln = () => { let r = "unknown"; try { const a = navigator.userAgent || "", e = es(y0, a); if (!e) return r; r = e.describe(a); } catch (a) { } return r; }, C0 = [ { 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, // Xiaomi POCO /\b; (\w+) build\/hm\1/i, // Xiaomi Hongmi 'numeric' models /\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i, // Xiaomi Hongmi /\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i, // Xiaomi Redmi /oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i, // Xiaomi Redmi 'numeric' models /\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i // Xiaomi Mi ], 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, // Google Pixel C /droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i // Google Pixel ], describe() { return "Google"; } }, { test: [ /(zte)[- ]([\w ]+?)(?: bui|\/|\))/i, /(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i // Alcatel/GeeksPhone/Nexian/Panasonic/Sony ], describe() { return "ZTE"; } }, { test: [/droid.+; (m[1-5] note) bui/i, /\bmz-([-\w]{2,})/i], describe() { return "Meizu"; } } ], R0 = () => { let r = "Unknown"; try { const a = navigator.userAgent || "", e = es(C0, a); if (!e) return r; r = e.describe(a); } catch (a) { } return r; }, { BrowserUtil: La, SystenUtil: Fa } = le, I0 = ln(), w0 = "woMMssV6jmyol9fr", D0 = 200, gi = 10 * 60 * 1e3, mi = { host: "cn-hangzhou.log.aliyuncs.com", // 所在地域的服务入口。例如cn-hangzhou.log.aliyuncs.com project: "alivc-aio", // Project名称。 logstore: "logger", // Logstore名称。 time: 10, // 发送日志的时间间隔,默认是10秒。 count: 10 // 发送日志的数量大小,默认是10条。 }; function kr() { return Qr(/* @__PURE__ */ new Date(), "HH:MM:ss.l"); } function Va() { return Qr(/* @__PURE__ */ new Date(), "isoDate"); } var fn = /* @__PURE__ */ ((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))(fn || {}); class T0 { constructor() { g(this, "tracker"); g(this, "slsPlugin"); g(this, "stsData"); g(this, "stsExpiration", Date.now()); g(this, "clientId", rt()); g(this, "bSesid", rt()); 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", (a) => w(this, null, function* () { if (!this.slsPlugin) return; this.logSequence += 1, a.unshift( this.getLogParams(710203, { log: `[${Va()} ${kr()}] [INF] beforeunload`, stat_log_seq: this.logSequence }) ); const e = `https://${mi.project}.${mi.host}/logstores/${mi.logstore}`, t = { __logs__: a.map((n) => this.slsPlugin.transString(n)) }, { data: i, header: s } = yield this.slsPlugin.process(e, JSON.stringify(t)); fetch(e, { keepalive: !0, method: "POST", headers: s, body: i }); })); g(this, "logMethod", (a, e = console.log) => (...t) => { let i = kr(); this.logLevel <= a && e(i, ...t); let s = He.paramArrayToString(t); a > 0 && this.addLog(s); }); // debug level message g(this, "d", this.logMethod(0, console.debug)); g(this, "i", this.logMethod( 1 /* INFO */ )); g(this, "w", this.logMethod(3, console.warn)); g(this, "e", this.logMethod(4, (...a) => { const [e, ...t] = a; console.error(e, "", t); })); g(this, "ev", this.logMethod( 2 /* API */ )); g(this, "a", this.logMethod(2, (...a) => { const [e, ...t] = a; if (t.length > 2) { const i = `${t[1]}`; i.startsWith("__g__") && console.group(`${i.substring(5)}_${t[2]}`); } console.log(e, ...t); })); g(this, "ar", this.logMethod(2, (...a) => { const [e, ...t] = a; console.log(e, ...t), t.length > 2 && `${t[1]}`.startsWith("__g__") && console.groupEnd(); })); g(this, "ae", this.logMethod(2, (...a) => { const [e, ...t] = a; console.error(e, "", ...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 = rt(), this.endReported = !0, this.logSequence = 0, this.appId = "", this.sessionId = ""; } startSTSUpdateTask() { return w(this, null, function* () { this.updateTaskTimer && clearTimeout(this.updateTaskTimer); try { const a = yield this.refreshSTSToken(); this.createTracker(a); } catch (a) { } this.updateTaskTimer = setTimeout(() => { this.startSTSUpdateTask(); }, gi); }); } refreshSTSToken() { return w(this, null, function* () { if (!this.stsData || this.stsExpiration <= Date.now() - gi) { const a = yield this.requestSTSToken(), e = new Date(a == null ? void 0 : a.Expiration).getTime() || 0, t = Date.now() + gi; this.stsExpiration = Math.max(e, t), this.stsData = a; } return this.stsData; }); } requestSTSToken() { const a = Date.now(), e = `${this.clientId}|${w0}|${a}`, i = { Action: "AssumeSlsRoleV2", AuthInfo: ai.MD5(e).toString(ai.enc.Hex), ClientId: this.clientId, BusinessType: "logger", AppVersion: "1.0", Version: "2017-03-14", AuthTimestamp: `${a}`, TerminalType: "web", DeviceModel: "", Format: "JSON", SignatureMethod: "HMAC-SHA1", SignatureVersion: "1.0", Timestamp: Qr(a, "isoUtcDateTime") // SignatureNonce: generateRandomString(64), }, n = `https://slsrole.alicdn.com/?${new URLSearchParams(i).toString()}`; return fetch(n).then((c) => c.json()).then((c) => JSON.parse(window.atob(c.SlsAuthResult))); } createTracker(a) { if (!this.tracker) { const e = { accessKeyId: a.AccessKeyId, accessKeySecret: a.AccessKeySecret, securityToken: a.SecurityToken, refreshSTSTokenInterval: gi, stsTokenFreshTime: void 0, refreshSTSToken: () => { this.refreshSTSToken().then((s) => { e.accessKeyId = s.AccessKeyId, e.accessKeySecret = s.AccessKeySecret, e.securityToken = s.SecurityToken; }).catch(() => { }); } }, t = new Gr(mi), i = Zr(e); t.useStsPlugin(i), this.slsPlugin = i, this.tracker = t, this.reportStartAndCache(); } } changeConfig(a) { a.logLevel !== void 0 && a.logLevel >= 0 && a.logLevel <= 5 && (this.logLevel = a.logLevel); } // set session id setSessionID(a, e) { !a || !e || (this.appId = a, this.sessionId = e, this.reportStartAndCache()); } reportStartAndCache() { if (!this.tracker || !this.sessionId) return; this.endReported = !1; const a = { task_btm_sec: 0, task_duration: 0, task_etm_sec: 0, task_type: "session" }, e = [ this.getLogParams(710201, a), this.getLogParams(710202, a) ]; this.tracker.sendBatchLogsImmediate(e), this.logCache.forEach((t) => { this.sendLog(t); }); } reportEnd(a = !1) { if (!this.tracker || !this.sessionId || this.endReported) { 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) ]; a ? this.sendLogBeforeUnload(t) : (this.tracker.sendBatchLogsImmediate(t), this.endReported = !0), this.reset(); } getLogParams(a, e) { return J({ appid: `${window.location.host}`, // 其他端是应用的包id,不是rtcsdk的appId appid_list: this.appId, // rtcsdk的appId appver: "", b_sesid: this.bSesid, // 与其他端对齐,用于该字段标记某个上传任务 biz_type: "rtc", cpu_info: I0, db: La.browserName, dm: La.browserVersion, install_uuid: this.clientId, logger_v: "0.0.1", os: Fa.systemName, osv: Fa.systemVersion, p_sesid: this.bSesid, // 与其他端对齐,用于该字段标记某个上传任务 sdk_version: yi, sdkname: "AliRTCSdk", stm: Date.now(), tar_pf: "web", traceid: this.sessionId, // 与其他端对齐,用于traceid标记某个会话 event_id: a }, e || {}); } sendLog(a) { if (!this.tracker || !this.sessionId) return; this.logSequence += 1; const e = this.getLogParams(710203, { log: a, stat_log_seq: this.logSequence }); this.tracker.send(e); } addLog(a) { const e = kr(), i = `[${Va()} ${e}] ${a}`; !this.sessionId || !this.tracker ? (this.logCache.push(i), this.logCache.length >= D0 && this.logCache.shift()) : this.sendLog(i); } } class O { static getLogger() { return this.logger || (this.logger = new T0()), this.logger; } static init() { this.getLogger().init(); } static destroy() { this.getLogger().destroy(); } static setLogLevel(a) { this.getLogger().changeConfig({ logLevel: a }); } static setSessionID(a, e) { this.getLogger().setSessionID(a, e); } static reportEnd() { this.getLogger().reportEnd(); } static interface(...a) { this.getLogger().a("[API]", ...a); } static interfaceResult(a, e, t, ...i) { t ? this.getLogger().ar("[ARE]", a, e, ...i) : this.getLogger().ae("[ARE]", a, e, ...i); } static event(...a) { this.getLogger().ev("[EVT]", ...a); } // debug static debug(...a) { this.getLogger().d("[DBG]", ...a); } // info static info(...a) { this.getLogger().i("[INF]", ...a); } // warning static warn(...a) { this.getLogger().w("[WARN]", ...a); } // error static error(...a) { this.getLogger().e("[ERR]", ...a); } } g(O, "logger"); const P0 = (r) => w(void 0, null, function* () { const a = new le.SupportUtil(); let e = { support: !1, detail: { isWebRTCSupported: a.checkMediaDevices() && a.checkWebRtcSupport(), isH264DecodeSupported: !1, isH264EncodeSupported: !1, isScreenShareSupported: !1, isSendMediaExtensionMsgSupported: !1, isBrowserSupported: !0 } }, t = !1; try { yield a.isSupport({ isReceiveVideo: !0 }), t = !0; } catch (i) { t = !1, e.detail.isBrowserSupported = a.checkBrowser({ errorCode: 0, message: "" }); } if (e.support = t, a.checkWebRtcSupport() && r !== "sendonly") { const i = yield a.checkH264Decode(); e.detail.isH264DecodeSupported = i, e.support = e.support && i; } if (a.checkWebRtcSupport() && r !== "recvonly") { const i = yield a.checkH264Encode(); e.detail.isH264EncodeSupported = i, e.support = e.support && i; } return e.detail.isScreenShareSupported = a.checkWebRtcSupport() && a.checkScreenCapture() && !le.SystenUtil.isAndroid && !le.SystenUtil.isIos, e.detail.isSendMediaExtensionMsgSupported = a.checkWebRtcSupport() && a.checkEncodedTransformSupport(), e; }), k0 = () => new le.SupportUtil().checkScreenCapture(); var be = /* @__PURE__ */ ((r) => (r[r.AliRtcSdkStreamTypeCapture = 0] = "AliRtcSdkStreamTypeCapture", r[r.AliRtcSdkStreamTypeScreen = 1] = "AliRtcSdkStreamTypeScreen", r))(be || {}), B0 = /* @__PURE__ */ ((r) => (r[r.PRE_PROCESSOR = 0] = "PRE_PROCESSOR", r[r.POST_PROCESSOR = 1] = "POST_PROCESSOR", r))(B0 || {}), Ri = /* @__PURE__ */ ((r) => (r[r.AUDIO = 0] = "AUDIO", r[r.VIDEO = 1] = "VIDEO", r[r.BOTH = 2] = "BOTH", r))(Ri || {}); class Gt extends De { constructor(e, t = be.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"); // 是否被清空,用于移除 Plugin 后重新添加强制执行 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; }); } // eslint-disable-next-line @ali/no-unused-vars clear(e) { this._hasCleared = !0, this.lastInputAudioTrack = void 0, this.lastInputVideoTrack = void 0, this.lastOutputAudioTrack = void 0, this.lastOutputVideoTrack = void 0; } } var bi = /* @__PURE__ */ ((r) => (r[r.LiveTranscodingSingle = 0] = "LiveTranscodingSingle", r[r.LiveTranscodingMix = 1] = "LiveTranscodingMix", r))(bi || {}), pn = /* @__PURE__ */ ((r) => (r[r.LiveTranscodingOrigin = 0] = "LiveTranscodingOrigin", r[r.LiveTranscodingAudio = 1] = "LiveTranscodingAudio", r[r.LiveTranscodingVideo = 2] = "LiveTranscodingVideo", r))(pn || {}), ni = /* @__PURE__ */ ((r) => (r[r.LiveTranscodingCamera = 0] = "LiveTranscodingCamera", r[r.LiveTranscodingShareScreen = 1] = "LiveTranscodingShareScreen", r))(ni || {}); const ii = { 0: "camera", 1: "shareScreen" }; var gn = /* @__PURE__ */ ((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))(gn || {}); const N0 = { 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 ts = /* @__PURE__ */ ((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))(ts || {}), Ei = /* @__PURE__ */ ((r) => (r[r.LiveTranscodingNoBody = 0] = "LiveTranscodingNoBody", r[r.LiveTranscodingBody = 1] = "LiveTranscodingBody", r))(Ei || {}), Ii = /* @__PURE__ */ ((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))(Ii || {}), mn = /* @__PURE__ */ ((r) => (r[r.LiveTranscodingOrigin = 0] = "LiveTranscodingOrigin", r[r.LiveTranscodingCrop = 1] = "LiveTranscodingCrop", r[r.LiveTranscodingFill = 2] = "LiveTranscodingFill", r))(mn || {}), is = /* @__PURE__ */ ((r) => (r[r.LiveTranscodingNormal = 0] = "LiveTranscodingNormal", r[r.LiveTranscodingVirtualBackground = 1] = "LiveTranscodingVirtualBackground", r))(is || {}), Sn = /* @__PURE__ */ ((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))(Sn || {}), ht = /* @__PURE__ */ ((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))(ht || {}), xn = /* @__PURE__ */ ((r) => (r[r.TrascodingPublishTaskStatusStart = 0] = "TrascodingPublishTaskStatusStart", r[r.TrascodingPublishTaskStatusUpdate = 1] = "TrascodingPublishTaskStatusUpdate", r[r.TrascodingPublishTaskStatusStop = 2] = "TrascodingPublishTaskStatusStop", r))(xn || {}), Ue = /* @__PURE__ */ ((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))(Ue || {}); const M0 = { 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 vn { //[1,2] constructor(a, e, t, i, s, n, c, o) { g(this, "videoWidth"); //(0-1920] g(this, "videoHeight"); //(0-1920] g(this, "videoFramerate", 20); //[1,60] g(this, "videoBitrate", 2e3); //[1kbps,10000kbps] g(this, "videoGop", 30); //[1,60] g(this, "audioSamplerate", ts.LiveTranscoding_HZ_44100); g(this, "audioBitrate", 500); //[8kbps,500kbps] g(this, "audioChannels", 1); this.videoWidth = a, this.videoHeight = e, t && (this.videoFramerate = t), i && (this.videoBitrate = i), s && (this.videoGop = s), n && (this.audioSamplerate = n), c && (this.audioBitrate = c), o && (this.audioChannels = o); } } const rs = (r) => ((r & 16711680) >> 16) + (r & 65280) + ((r & 255) << 16), Ye = (r = 0, a) => { if (a == 0) return 0; let e = r / a; return e < 0 && (e = 0), e > 1 && (e = 1), e; }; class Fr { constructor(a, e, t) { /*! 旁路模式 */ g(this, "mixMode", bi.LiveTranscodingSingle); /*! 路模式单路参数 */ g(this, "singleParam"); /*! 旁路模式混流参数 */ g(this, "mixParam"); a && (this.mixMode = a), e && (this.singleParam = e), t && (this.mixParam = t); } toJson(a, e, t, i, s) { const n = { appid: e.appId, channelid: e.channelId }; if (a === Ue.MPU_TASK_TRANSACTION_POLLING || a === Ue.MPU_TASK_TRANSACTION_LIST || a === Ue.MPU_TASK_TRANSACTION_ACKNOWLEDGE) return a === Ue.MPU_TASK_TRANSACTION_ACKNOWLEDGE && (n.messageid = s), n; if (n.taskid = t, a !== Ue.MPU_TASK_TRANSACTION_STOP) { if (n.mixmode = this.mixMode, i && (n.streamurl = i), this.mixMode === bi.LiveTranscodingSingle) { const c = this.singleParam; if (c) { n.streamtype = c.streamType, c.sourceType === ni.LiveTranscodingShareScreen ? n.sourcetype = ii[c.sourceType] : n.sourcetype = ii[ni.LiveTranscodingCamera]; const o = []; c.userId && o.push(c.userId), n.subspecusers = o; } } else if (a === Ue.MPU_TASK_TRANSACTION_START || a === Ue.MPU_TASK_TRANSACTION_UPDATE) { const c = this.mixParam; if (c) { c.taskProfile && (n.taskprofile = N0[c.taskProfile]); const o = c.encodeParam || new vn(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, n.encodeparam = p, n.backgrounds = c.backgrounds.map((f) => f.toJson(u, h)), n.watermarks = c.watermarks.map((f) => f.toJson(u, h)), n.clockwidgets = c.clockWidgets.map((f) => f.toJson(u, h)); const d = c.users.map((f) => f.userId); n.subspecusers = [...new Set(d)], n.layouts = [ { audiomixcount: c.users.length, panes: c.users.map( (f, m) => f.toJson(m, u, h, c.mediaProcessMode) ) } ], n.layoutids = ["0"], n.cropmode = c.cropMode, n.backgroundcolor = rs(c.backgroundColor), n.taskmode = c.mediaProcessMode; } } } return n; } } var pt = /* @__PURE__ */ ((r) => (r.pre = "pre", r.prod = "prod", r))(pt || {}), bt = /* @__PURE__ */ ((r) => (r.AliRtcSdkCommunication = "communication", r.AliRtcSdkInteractiveLive = "interactive_live", r.AliRtcSdkInteractiveWithLowLatencyLive = "cdn_live", r))(bt || {}), Nt = /* @__PURE__ */ ((r) => (r.AliRtcSdkInteractive = "interactive", r.AliRtcSdkLive = "live", r))(Nt || {}), dt = /* @__PURE__ */ ((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))(dt || {}), _e = /* @__PURE__ */ ((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))(_e || {}), ue = /* @__PURE__ */ ((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))(ue || {}), Wt = /* @__PURE__ */ ((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))(Wt || {}), ss = /* @__PURE__ */ ((r) => (r[r.AliRtcUserOfflineQuit = 0] = "AliRtcUserOfflineQuit", r[r.AliRtcUserOfflineDropped = 1] = "AliRtcUserOfflineDropped", r[r.AliRtcUserOfflineBecomeAudience = 2] = "AliRtcUserOfflineBecomeAudience", r))(ss || {}), Xt = /* @__PURE__ */ ((r) => (r[r.AliRtcAudioTrackNo = 0] = "AliRtcAudioTrackNo", r[r.AliRtcAudioTrackMic = 1] = "AliRtcAudioTrackMic", r[r.AliRtcAudioTrackDual = 2] = "AliRtcAudioTrackDual", r))(Xt || {}), se = /* @__PURE__ */ ((r) => (r[r.AliRtcVideoTrackNo = 0] = "AliRtcVideoTrackNo", r[r.AliRtcVideoTrackCamera = 1] = "AliRtcVideoTrackCamera", r[r.AliRtcVideoTrackScreen = 2] = "AliRtcVideoTrackScreen", r[r.AliRtcVideoTrackBoth = 3] = "AliRtcVideoTrackBoth", r))(se || {}), Y = /* @__PURE__ */ ((r) => (r[r.AliRtcStatePublishIdle = 0] = "AliRtcStatePublishIdle", r[r.AliRtcStateNoPublish = 1] = "AliRtcStateNoPublish", r[r.AliRtcStatePublishing = 2] = "AliRtcStatePublishing", r[r.AliRtcStatePublished = 3] = "AliRtcStatePublished", r))(Y || {}), he = /* @__PURE__ */ ((r) => (r[r.AliRtcStateSubscribeIdle = 0] = "AliRtcStateSubscribeIdle", r[r.AliRtcStateNoSubscribe = 1] = "AliRtcStateNoSubscribe", r[r.AliRtcStateSubscribing = 2] = "AliRtcStateSubscribing", r[r.AliRtcStateSubscribed = 3] = "AliRtcStateSubscribed", r))(he || {}), we = /* @__PURE__ */ ((r) => (r[r.AliRtcVideoStreamTypeNone = 0] = "AliRtcVideoStreamTypeNone", r[r.AliRtcVideoStreamTypeHigh = 1] = "AliRtcVideoStreamTypeHigh", r[r.AliRtcVideoStreamTypeLow = 2] = "AliRtcVideoStreamTypeLow", r))(we || {}), oi = /* @__PURE__ */ ((r) => (r[r.CAMERA_INVALID = -1] = "CAMERA_INVALID", r[r.CAMERA_REAR = 0] = "CAMERA_REAR", r[r.CAMERA_FRONT = 1] = "CAMERA_FRONT", r))(oi || {}); const Oa = 12, Ua = 5e3, $t = class $t extends De { constructor(e) { super(); g(this, "ws"); // websocket对象 g(this, "socketStatus", 0); // websocket当前的连接状态 g(this, "wsUrl", ""); // 建立连接时候使用的url g(this, "lastConnectStartTime", 0); // 上一次开始连接的时间 g(this, "maxConnectRetryCount", Oa); g(this, "connectRetryCount", 0); // 尝试重连了多少次 g(this, "gotErr", !1); g(this, "closedByInvoke", !0); // 是否调用 close() 关闭的 g(this, "isReconnecting", !1); g(this, "networkAvailableChecked", !0); g(this, "reconnectTimeoutId", 0); this.maxConnectRetryCount = e != null ? e : Oa, 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; } /** * 返回websocket连接的状态 */ get connectStatus() { return this.socketStatus; } /** * 开始连接 * @param wsUrl */ start(e) { this.wsUrl = e, this.initWebSocket(); } /** * 发送消息 * @param pkg */ 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(); } /** * 连接成功 * @param event */ onOpen(e) { O.info(`[${$t.logName}]`, "onOpen"), this.socketStatus = 2, this.connectRetryCount = 0, this.networkAvailableChecked = !1, this.closedByInvoke = !1, this.gotErr = !1, this.isReconnecting = !1, this.emit("onOpen", e); } /** * 收到消息 * @param event */ onMessage(e) { this.emit("onMessage", e); } /** * 收到错误 * @param event */ onError(e) { this.isReconnecting && this.emit("onReconnectFail", e), this.emit("onError", e), this.isReconnecting = !1, this.socketStatus !== 2 && He.isNetworkAvailable().then((t) => { t && console.error($t.logName, "onError, Network is available, token may be invalid"); }); } /** * 连接断开 * @param event */ onClose(e) { return w(this, null, function* () { if (this.closedByInvoke) { this.socketStatus = 0; return; } if (O.info( `[${$t.logName}]`, `onClose, code: ${e.code}, reason: ${e.reason}, status: ${status}, retryCount: ${this.connectRetryCount}` ), (yield He.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 >= Ua ? this.reconnect() : this.reconnectTimeoutId = window.setTimeout(() => { this.reconnect(); }, Ua)); this.socketStatus = 0, this.emit("onClose", e); }); } /** * 初始化websocket */ 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); } /** * 反初始化websocket */ 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); } }; /** * @ignore */ g($t, "logName", "Socket"); let Vr = $t; var ve = /* @__PURE__ */ ((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))(ve || {}); class L0 { constructor(a, e) { g(this, "authInfo"); g(this, "userName"); g(this, "seqIndex", 0); this.authInfo = a, this.userName = e; } get roleAuth() { if (this.authInfo.role) { const { timestamp: a, nonce: e, token: t, role: i } = this.authInfo; return { timestamp: a, nonce: e, token: t, tokenrole: i }; } } refreshAuthInfo(a) { this.authInfo = a; } getSeqIndex() { return this.seqIndex; } /** * 创建一个心跳包 * @returns */ createKeepAlivePackage() { return this.createBaseSendPackage( "keepalive" /* KEEPALIVE */ ); } /** * 创建一个用于发送入会消息的Package * @returns */ createJoinPackage() { let a = this.createBaseSendPackage( "joinchannel" /* JOINCHANNEL */ ); return a.header.displayName = this.userName, a.header.clientversion = He.getVersionNumber().toString(), a.header.platform = Xs, this.roleAuth && (a.data.auth = this.roleAuth), a; } /** * 创建一个用于发送离会消息的Package * @returns */ crateLeavePackage() { return this.createBaseSendPackage( "leavechannel" /* LEAVECHANNEL */ ); } createStatusPackage(a) { let e = this.createBaseSendPackage( "statusreport" /* STATUSREPORT */ ); return e.header.displayName = this.userName, e.data.status = a, e; } /** * 创建一个用于发送推流消息的Package * @returns */ createPublishPackage() { let a = this.createBaseSendPackage( "publish" /* PUBLISH */ ); return a.data.users = [{}], this.roleAuth && (a.data.auth = this.roleAuth), a; } createRoleUpdatePackage() { let a = this.createBaseSendPackage( "roleupdate" /* ROLEUPDATE */ ); return a.header.displayName = this.userName, a; } createReconnectPackage(a) { let e = this.createBaseSendPackage( "reconnect" /* RECONNECT */ ); return e.header.displayName = this.userName, e.header.clientversion = He.getVersionNumber().toString(), e.header.platform = Xs, e.data = J(J({}, e.data), a != null ? a : {}), this.roleAuth && (e.data.auth = this.roleAuth), e; } createRefreshUrlPackage() { let a = this.createBaseSendPackage( "refreshurl" /* REFRESHURL */ ); return a.header.displayName = this.userName, a; } /** * 创建一个Response包 * @param {string} tid Notify消息的tid * @param {MessageType} msgType 消息类型 * @returns {IResponse} */ createResponsePackage(a, e) { return { version: 1, code: 200, tid: a, msgtype: e }; } /** * * @param messageType * @returns */ createBaseSendPackage(a) { var t; return ++this.seqIndex, { version: 1, msgtype: a, tid: rt(), 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 = /* @__PURE__ */ ((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 F0 = 3e4, qe = class qe extends De { // 发送重连信令时,房间信令凭这些信息找回 session constructor(e, t, i, s, n, c) { super(); g(this, "authInfo"); // 登陆信息AliRtcAuthInfo g(this, "userName"); g(this, "channelProfile"); g(this, "clientRole"); g(this, "slsReporter"); g(this, "wsClient"); // websocket类 g(this, "packageCreater"); // 负责生成和解析业务信令数据包 g(this, "keepAliveTimer", 0); // 心跳包计时器 g(this, "packageCache", /* @__PURE__ */ new Map()); // 已经发送的消息缓存队列,没有回复则需要触发消息重发 g(this, "isFirstConnect", !0); // 是否是首次连接 g(this, "aliveChecker", 0); // 心跳检查定时器 g(this, "reconnectData"); this.authInfo = e, this.userName = t, this.packageCreater = new L0(e, t), this.channelProfile = i, this.clientRole = s, this.slsReporter = n, this.wsClient = new Vr(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; } /** * 开始连接信令 * @param roomserverurl */ 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); } /** * 透明通道消息上报 * @param status */ reportStatus(e) { let t = this.packageCreater.createStatusPackage(e); this.sendPackage(t); } /** * 发送推流消息 */ publish(e) { const o = e, { l1ip: t } = o, i = Dt(o, ["l1ip"]); let s = this.packageCreater.createPublishPackage(); s.data.users = [], s.data.l1ip = t, i.subscribe.signal = this.wsClient.connectUrl; const { tracks: n, resume: c } = i; n.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); } /** * 更新推拉流地址 * @param {RefreshInfo} info */ refreshUrl(e) { const t = this.packageCreater.createRefreshUrlPackage(); t.data = J(ut(J({}, t.data), { sessionid: t.header.sessionid }), e), this.sendPackage(t); } refreshAuthInfo(e) { this.authInfo = e, this.packageCreater.refreshAuthInfo(e); } /** * 关闭websocket连接,并销毁 */ 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(); } /** * 通过此方法发送数据到业务信令 * 此方法会自动保存发送的package,并做重发. * response包不要通过此方法发送 * @param pkg */ sendPackage(e) { [ve.KEEPALIVE, ve.RECONNECT, ve.JOINCHANNEL].includes(e.msgtype) || this.packageCache.set(e.tid, e), this.wsClient.send(e), e.msgtype !== ve.KEEPALIVE && this.slsReporter.reportRoomServerEvent(!0, e.msgtype, e.tid, e); } /** * 更新重连 payload * @param {ReconnectData} reconnectData */ updateReconnectData(e) { this.reconnectData = e; } /** * 收到websocket连接成功的消息 * ws连接建立成功后立刻发送join消息 */ onOpen() { if (O.info(`[${qe.logName}] onOpen`), this.isFirstConnect) { let e = this.packageCreater.createJoinPackage(); e.data.configure = { channelprofile: this.channelProfile }, (this.channelProfile === bt.AliRtcSdkInteractiveLive || this.channelProfile === bt.AliRtcSdkInteractiveWithLowLatencyLive) && (e.data.configure.clientrole = this.clientRole), this.sendPackage(e); } else { this.stopKeepAlive(); const e = this.packageCreater.createReconnectPackage(this.reconnectData); this.sendPackage(e); } } /** * 收到业务信令消息 * @param event */ 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) !== ve.KEEPALIVE && this.slsReporter.reportRoomServerEvent(!1, t.msgtype, t.tid, t); } catch (t) { O.warn(`[${qe.logName}] onMessage err`, t, e); } } /** * 收到错误消息 * @param event */ 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); } /** * 收到websocket断开消息 * @param event */ 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.")); } /** * 处理 Keepalive 心跳,加速判断网络异常 */ checkAlive() { window.clearTimeout(this.aliveChecker), this.aliveChecker = window.setTimeout(() => { O.info(`[${qe.logName}] not alive, reconnect`), this.stopKeepAlive(), this.emit("onReconnectStart"), this.wsClient.reconnect(); }, F0); } /** * 处理收到的业务信令 * @param response */ onRecvMessage(e) { switch (e.msgtype !== ve.KEEPALIVE && O.info(`[${qe.logName}] recv msg: ${e.msgtype}`), e.msgtype) { case ve.JOINCHANNEL: this.onJoinResult(e); break; case ve.KEEPALIVE: this.onKeepAliveRsp(); break; case ve.PUBLISH: this.onPublishResult(e); break; case ve.NOTIFYJOIN: this.onNotifyJoin(e); break; case ve.NOTIFYSTATUS: this.onNotifyStatus(e); break; case ve.LEAVECHANNEL: this.onLeaveResult(e); break; case ve.NOTIFYLEAVE: this.onNotifyLeave(e); break; case ve.NOTIFYPUBLISH: this.onNotifyPublish(e); break; case ve.STATUSREPORT: this.onStatusReport(e); break; case ve.BYE: this.onBye(e); break; case ve.ROLEUPDATE: this.onRoleUpdateResult(e); break; case ve.REFRESHURL: this.onRefreshUrlResult(e); break; case ve.RECONNECT: this.onReconnectResult(e); break; } } /** * 收到入会消息的response * @param response */ onJoinResult(e) { this.isFirstConnect = !1, this.emit("onJoinChannelResult", e); } /** * 收到离开消息的response * @param response */ onLeaveResult(e) { this.emit("onLeaveResult", e.code, e.tid); } /** * 收到publish消息的response * @param response */ onPublishResult(e) { this.emit("onPublishResult", e.code, e.tid, e.description); } /** * 收到roleUpdate消息的response * @param response */ onRoleUpdateResult(e) { this.emit("onRoleUpdateResult", e.code, e.tid, e.description); } /** * 收到 refreshurl 消息的response * @param response */ onRefreshUrlResult(e) { this.emit("onRefreshUrlResult", e); } /** * 收到重联消息的response * @param response */ 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(); } } /** * 收到业务信令下发的消息 * @param response */ 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); } /** * 收到业务信令下发的透明通道消息 * @param response */ 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); } /** * 收到远端用户离开的通知 * @param response */ 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); } /** * 收到远端用户推流的通知 * @param response */ 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); } /** * 收到statusreport的response * @param response */ onStatusReport(e) { this.emit("onStatusReport", e.code, e.tid, e.description); } /** * 收到被踢出频道的消息 * @param {any} response */ onBye(e) { this.stopKeepAlive(), this.emit("onBye", e.reason, e.description); } }; g(qe, "logName", "RSMessageCenter"); let Or = qe; const D = (r, a) => (e, t, i) => { const s = i.value; return i.value = function(...n) { var p; const c = `[${((p = e.constructor) == null ? void 0 : p.logName) || ""}]`, o = Date.now(); let u = []; if (r) try { u = r(n); } catch (d) { } O.interface(c, t, ...u); const h = s.apply(this, n); 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 (!(!a && !m)) { if (l) f = d; else if (m) f = d.message || ""; else if (a) if (d === void 0) f = ""; else try { f = a(d); } catch (v) { } else return; O.interfaceResult( c, t, !(m && l), `${Date.now() - o}ms`, f ); } }), h; }, i; }, H = (r) => r; var V0 = Object.defineProperty, O0 = Object.getOwnPropertyDescriptor, as = (r, a, e, t) => { for (var i = t > 1 ? void 0 : t ? O0(a, e) : a, s = r.length - 1, n; s >= 0; s--) (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i); return t && i && V0(a, e, i), i; }, Ne; const wi = (Ne = class extends De { 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"); // 重连房间信令的信息,在服务器宕机的时候,reconnect 成功 g(this, "roomServerUri", ""); this.channelProfile = e, this.clientRole = t, this.slsReporter = i, this.reconnectData = { role: { channelprofile: e, clientrole: t } }; const n = s === pt.pre ? vi.pre : vi.prod; this.roomServerUri = `wss://${n}/roomserver/v1/ws`; } /** * 更新重连数据 * @param {ReconnectData} reconnectData */ 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, n) => { const c = {}; this.authInfo = e, this.userName = t, this.messageCenter = new Or( e, t, this.channelProfile, this.clientRole, this.slsReporter, i ), this.initMessageCenter(), this.messageCenter.once("onJoinChannelResult", (u) => { var h, p, d; if (O.info(`[${Ne.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(), n(this.handleSignalError(u.code, u.reason, U.ERR_JOIN_CHANNEL_FAILED)); }), this.messageCenter.once("onAuthInvalid", () => { this.reset(), n(new V(U.ERR_JOIN_BAD_TOKEN, "join failed because authentication failed")); }), O.info( `[${Ne.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: rt() }; e.role && (o.tokenrole = e.role), c.est = Date.now(), this.messageCenter.start(this.roomServerUri + "?" + He.queryingParam(o)); }); }); } /** * 离开频道 * @returns */ leave() { return O.info("[roomsig] leave .."), new Promise((e, t) => { this.messageCenter ? (this.messageCenter.on("onLeaveResult", (i, s) => { O.info(`[${Ne.logName}]`, "recv leave response " + i), i === 200 ? (this.updateReconnectData(), this.reset(), e({ tid: s })) : t(this.handleSignalError(i, "leave error")); }), O.info(`[${Ne.logName}]`, "send leave request"), this.messageCenter.leave()) : (O.info(`[${Ne.logName}]`, "no message center, ok to leave"), e({ tid: "" })); }); } publish(e) { return new Promise((t, i) => { var s; this.messageCenter ? (this.messageCenter.once("onPublishResult", (n, c, o) => { O.info(`[${Ne.logName}]`, "recv pubish response " + n), n === 200 ? (this.updateReconnectData(ut(J({}, this.reconnectData), { publish: { users: [e] } })), t({ tid: c })) : i(this.handleSignalError(n, `publish error, ${o}`)); }), this.authInfo && (e.sessionid = (s = this.authInfo.sessionId) != null ? s : ""), e.callid || (e.callid = rt()), O.info( `[${Ne.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, n, c) => { var o, u; O.info(`[${Ne.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: n })) : i(this.handleSignalError(s, `role update error, ${c}`)); }), this.messageCenter.roleUpdate(e); }); } setChannelProfile(e) { this.channelProfile = e; } /** * 更新推流地址 */ refreshUrl(e) { return O.info(`[${Ne.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: n, description: c, data: o = {} } = s || {}; O.info("recv refresh url response " + n), n === 200 ? t(o) : i(this.handleSignalError(n, `refresh url error, ${c}`)); }), O.info("send refresh url request"), this.messageCenter.refreshUrl(e); }); } /** * 上报设备状态 * @param status */ reportStatus(e) { return O.info(`[${Ne.logName}]`, "reportStatus " + e), new Promise((t, i) => { this.messageCenter ? (this.messageCenter.once("onStatusReport", (s, n) => { s === 200 ? t() : i(new V(s, n)); }), 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)); }); } /** * 初始化MessageCenter,增加事件监听 */ initMessageCenter() { var e, t, i, s, n, 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); }), (n = this.messageCenter) == null || n.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"); }); } }, /** * @ignore */ g(Ne, "logName", "RoomServerSignaling"), Ne); as([ D() ], wi.prototype, "join", 1); as([ D() ], wi.prototype, "publish", 1); as([ D() ], wi.prototype, "roleUpdate", 1); let U0 = wi; const H0 = "https://pgw.rtn.aliyuncs.com", j0 = "https://gw.rtn.aliyuncs.com", Ha = 10 * 60 * 1e3, z0 = 12, ri = class ri extends De { 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: n, timestamp: c, sessionId: o, role: u } = this.authInfo; let h = j0; this.env === pt.pre && (h = H0); const p = `${h}/gslb/v1/stsupdate?appid=${e}&channelid=${t}&userid=${i}&nonce=${s}&token=${n}×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(`[${ri.logName}]`, "getToken", S, v); } else throw new Error(); this.slsReporter.reportSTSResult(200, d); }).catch((f) => { this.slsReporter.reportSTSResult(-1, d), O.error(`[${ri.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() + Ha * 1.5) / 1e3) < this.expiration && this.skipTime < z0) { this.skipTime += 1; return; } this.requestToken(); }, Ha); } clear() { this.timer && clearInterval(this.timer); } }; g(ri, "logName", "StsManager"); let Ur = ri; var W0 = Object.defineProperty, $0 = Object.getOwnPropertyDescriptor, K0 = (r, a, e, t) => { for (var i = t > 1 ? void 0 : t ? $0(a, e) : a, s = r.length - 1, n; s >= 0; s--) (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i); return t && i && W0(a, e, i), i; }; class ns extends De { 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 Ur(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; } /** * 向业务信令发送入会 * @param {AliRtcAuthInfo} authInfo * @returns */ join(e, t = e.userId, i, s) { return this.maxConnectRetryCount = i, this.userName = t, new Promise((n, c) => { this.signaling ? c(new V(U.ERR_JOIN_ALREADY_JOINED, "already joined")) : (O.info("[signalingmanager] create signaling"), this.signaling = new U0(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()), n(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); } /** * 向业务信令发送离会 * @returns */ 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((n) => { t(n); }).catch((n) => { i(n); })) : i(new V(U.ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL, "no signaling")); }); } /** * 通过透明通道发送设备状态 * @param {string} status * @returns */ 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")); }); } /** * 切换角色 * @param {AliRtcSdkClientRole} role * @returns */ 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); } }); } /** * 切换模式 * @param {AliRtcSdkChannelProfile} channelProfile */ setChannelProfile(e) { this.signaling ? this.signaling.setChannelProfile(e) : this.channelProfile = e; } /** * 更新推流url * @param {RefreshInfo} info * @returns */ 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 = J(J({}, 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, n, 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)), (n = this.signaling) == null || n.on("onNotifyPublish", this.onNotifyPublish.bind(this)), (c = this.signaling) == null || c.on("onBye", this.onBye.bind(this)), (o = this.signaling) == null || o.on("onReconnectStart", this.onReconnectStart.bind(this)), (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"); } /** * 收到远端用户入会消息 * @param {JoinInfo[]} users */ onNotifyJoin(e) { this.emit("onNotifyJoin", e); } /** * 收到远端用户的透明通道消息 * @param {RemoteUserStatus[]} users */ onNotifyStatus(e) { this.emit("onNotifyStatus", e); } /** * 收到远端用户的离会消息 * @param {LeaveInfo[]} users */ onNotifyLeave(e) { this.emit("onNotifyLeave", e); } /** * 收到远端用户推流状态变化消息 * @param {PublishInfo[]} users */ onNotifyPublish(e) { this.emit("onNotifyPublish", e); } /** * 收到被踢掉消息 * @param {string} reason * @param {string} description */ onBye(e, t) { this.emit("onBye", e, t); } /** * 收到连接失败消息 * @param {AliRtcError} err */ onConnectFail(e) { this.reset(), this.emit("onConnectFail", e); } /** * 收到网络异常消息 * @param {AliRtcError} err */ onNetworkError(e) { this.emit("onNetworkError", e); } /** * 收到网络异常消息 */ // eslint-disable-next-line @ali/no-unused-vars onAuthInvalid() { } onReconnectStart() { this.emit("onReconnectStart"); } /** * 收到重连成功消息 * @param {JoinInfo[]} users */ onReconnectSuccess(e) { this.emit("onReconnectSuccess", e); } /** * 收到重连失败消息 */ onReconnectFail(e) { this.emit("onReconnectFail", e); } /** * 收到错误消息 * @param {AliRtcError} err */ onError(e) { this.emit("onError", e); } } /** * @ignore */ g(ns, "logName", "SignalingManager"); K0([ D(H) ], ns.prototype, "publish", 1); function Kt() { } const Mt = class Mt { static getInstance() { var a; return Mt.instance || (Mt.instance = new AudioContext()), (a = Mt.instance.resume()) == null || a.then(Kt, Kt).catch(Kt), Mt.instance; } }; g(Mt, "instance"); let Ft = Mt; const _i = () => { var a; const r = Ft.getInstance(); r.state !== "running" && r.state !== "closed" && ((a = r.resume()) == null || a.then(Kt, Kt).catch(Kt)), window.removeEventListener("mousedown", _i), window.removeEventListener("touchstart", _i); }; window.addEventListener("mousedown", _i); window.addEventListener("touchstart", _i); function q0(r, a, e, t, i) { let s = t, n = 0, c; const o = r.createAnalyser(); o.fftSize = 256; const u = new Uint8Array(o.frequencyBinCount); a.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), n = d, i && i(d); }, s); }; return p(), { updateInterval: (d) => { h(), s = d, p(); }, getLevel: () => n, dispose: () => { h(), a.disconnect(), o.disconnect(); } }; } class J0 extends De { constructor() { super(); g(this, "audioContext"); g(this, "stream"); g(this, "sourceNode"); g(this, "analyser"); this.audioContext = Ft.getInstance(), this.stream = new MediaStream(); } getLevel() { return this.analyser ? this.analyser.getLevel() : 0; } /** * 开启监听 audio level 的变化 * * @param {MediaStreamTrack} track 音频轨 * @param {number} [interval=1000] 检测间隔,单位毫秒,默认 1000ms */ 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 = q0(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 bn extends De { 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 J0(); } get userId() { return this.uid; } get displayname() { return this.name; } createCallId() { this.callId || (this.callId = He.createCallid()); } setUserInfo(e, t) { this.uid = e, this.name = t; } refreshUserInfo(e) { this.uid = e; } /** * 获取音频 level */ getAudioLevel() { return this.audioLevelMonitor.getLevel(); } enableAudioVolumeIndication(e) { this.audioVolumeIndicationInterval = e; } /** * 销毁用户,清空数据 */ clear() { this.audioLevelMonitor.dispose(); } } class En { /** * 将设备状态转换成String通过同名通道发送出去 * @param status * @returns */ static getCurrentStatus(a) { let e = 0; a.micOpen && (e += 1), a.micInterrupted && (e += 2), a.cameraOpen && (e += 4), a.screenShare && (e += 128), a.audioDisable && (e += 8), a.videoDisable && (e += 16), a.screenDisable && (e += 256); let t = e.toString(16); for (; t.length < 16; ) t = "0" + t; return t; } /** * 解析收到的status值 * @param status */ static parseStatus(a) { let e = parseInt(a, 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 _n = "customVideoProfile", An = "customScreenProfile", Hr = { width: 1280, height: 720, frameRate: 30, maxBitrate: 2e3 }, ja = { width: 1920, height: 1080, frameRate: 30, maxBitrate: 2600 }; var ti = /* @__PURE__ */ ((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))(ti || {}); const G0 = { 1e4: _e.AliEngineLocalDeviceExceptionTypeUnknown, 2e4: _e.AliEngineLocalDeviceExceptionTypeUnknown, 10001: _e.AliEngineLocalDeviceExceptionTypeMicNotAvailable, 10002: _e.AliEngineLocalDeviceExceptionTypeMicAuthFail, 10003: _e.AliEngineLocalDeviceExceptionTypeMicOpenFail, 10005: _e.AliEngineLocalDeviceExceptionTypeCameraAuthFail, 10004: _e.AliEngineLocalDeviceExceptionTypeVideoDeviceException, 10006: _e.AliEngineLocalDeviceExceptionTypeCameraOpenFail, 10010: _e.AliEngineLocalDeviceExceptionTypeDisplayException, 10011: _e.AliEngineLocalDeviceExceptionTypeDisplayException, 10012: _e.AliEngineLocalDeviceExceptionTypeDisplayException, 10013: _e.AliEngineLocalDeviceExceptionTypeDisplayException, 10014: _e.AliEngineLocalDeviceExceptionTypeDisplayException, 10019: _e.AliEngineLocalDeviceExceptionTypeDisplayException }; var Je = /* @__PURE__ */ ((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))(Je || {}), Xe = /* @__PURE__ */ ((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))(Xe || {}); const X0 = (r) => r.getAudioTracks()[0]; function za(r) { var a; if (((a = r == null ? void 0 : r.nodeName) == null ? void 0 : a.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 jr(r) { var e; const a = []; if (Array.isArray(r)) r.forEach((t) => { try { a.push(za(t)); } catch (i) { } }); else if (typeof r == "string" || ((e = r == null ? void 0 : r.nodeName) == null ? void 0 : e.toLowerCase()) === "video") try { a.push(za(r)); } catch (t) { } return a; } function Et(r) { return new Promise((a) => setTimeout(a, r)); } function Wa(r, a, e = 1e3, t = (i) => !0) { return w(this, null, function* () { let i = 0, s; for (; i < a; ) try { return yield r(i); } catch (n) { if (i++, i >= a || !t(n)) throw n || s; yield new Promise((c) => setTimeout(c, e)); } }); } function Y0(r, a) { let e = 0; const t = []; for (; e < r.byteLength; ) { const i = Math.min(a, r.byteLength - e), s = r.slice(e, e + i); t.push(s), e += i; } return t; } function Z0(r) { var a, e; try { const t = new URL(r), [i, s] = t.pathname.slice(1).split("/"), n = /(\w+)(web\w{5}-\w{4}-\w{4}-\w{4}-\w{12})/.exec(s), c = n == null ? void 0 : n[1], o = n == null ? void 0 : n[2], u = new URLSearchParams(t.search), h = parseInt((e = (a = u.get("auth_key")) == null ? void 0 : a.split("-")[0]) != null ? e : "0") * 1e3; return { appId: i, channelId: c, sessionId: o, timeoutTs: h }; } catch (t) { return null; } } function $a(r, a) { let e = a; 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 yn = (r, a, e = !1) => { const t = () => (r.muted = !0, Promise.race([Et(500), r._playPromise || Promise.resolve()]).catch(() => { }).then(() => { let i; return e && r.srcObject === a ? i = Promise.resolve() : (r.load(), r.srcObject = a, i = r.play(), r._playPromise = i), i; })); return new Promise((i) => { if (le.BrowserUtil.isMicroMessenger) { const s = window.top !== window.self, n = window.WeixinJSBridge || window.top.WeixinJSBridge; n ? n.invoke("getNetworkType", {}, () => { i(t()); }) : (s ? window.top.document : document).addEventListener("WeixinJSBridgeReady", () => { n.invoke("getNetworkType", {}, () => { i(t()); }); }), setTimeout(() => { i(t()); }, 1e3); } else setTimeout(() => { i(t()); }, 0); }); }, at = (r) => { Promise.race([Et(100), r._playPromise || Promise.resolve()]).catch(() => { }).then(() => { r.srcObject = null, r._playPromise = void 0; }); }; var Cn = /* @__PURE__ */ ((r) => (r[r.AliEngineDataMsgNone = 0] = "AliEngineDataMsgNone", r[r.AliEngineDataMsgMusicProgress = 1] = "AliEngineDataMsgMusicProgress", r[r.AliEngineDataMsgCustom = 2] = "AliEngineDataMsgCustom", r))(Cn || {}); class Di { constructor(a, e, t, i = 0) { g(this, "msgType"); g(this, "msgId"); g(this, "protocolVersion"); g(this, "tlvVersion"); this.msgType = a, this.msgId = e, this.protocolVersion = t, this.tlvVersion = i; } build() { const a = new Uint8Array(4); return a.set(Uint8Array.from([this.protocolVersion, this.tlvVersion << 4 | this.msgType & 15]), 0), a.set(Uint16Array.from([this.msgId]), 2), a; } static parse(a) { const e = new DataView(a), t = e.getUint8(0), i = e.getUint8(1) >> 4, s = e.getUint8(1) & 15, n = e.getUint16(2); return new Di(s, n, t, i); } } const Pt = 5; class Si { constructor(a, e, t) { g(this, "_byteArray"); if (this._byteArray = new Uint8Array(0), a !== void 0 && e !== void 0 && t !== void 0) { const s = new Di(a, e, t).build(); this._byteArray = new Uint8Array(s.byteLength + this._byteArray.byteLength), this._byteArray.set(s, 0); } } write(a, e) { const t = this._byteArray, i = new ArrayBuffer(Pt), s = new DataView(i); s.setUint8(0, a), s.setUint32(1, e.byteLength); const n = new Uint8Array(t.byteLength + Pt + e.byteLength); n.set(t, 0), n.set(new Uint8Array(i), t.byteLength), n.set(new Uint8Array(e), t.byteLength + Pt), this._byteArray = n; } static parse(a) { const e = {}, t = new DataView(a); let i = 0; for (; i < a.byteLength; ) { const s = t.getUint8(i), n = t.getUint32(i + 1); if (i + Pt + n <= a.byteLength) { const c = a.slice(i + Pt, i + Pt + n); e[s] = c, i += Pt + n; } else break; } return e; } get buffer() { return this._byteArray.buffer; } } class ci { constructor(a = 0, e = !0, t = 1, i = !1, s = 0, n = !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 = n, this._isCompressed = c, this._signalType = o, this._payloadLength = a; } get fin() { return this._fin; } get hasExtension() { return this._hasExtension; } get version() { return this._version; } get frameType() { return this._frameType; } get isEncrypted() { return this._isEncrypted; } get isCompressed() { return this._isCompressed; } get signalType() { return this._signalType; } get payloadLength() { return this._payloadLength; } toBuffer() { const a = new ArrayBuffer(4), e = new DataView(a); return e.setUint8( 0, (this._fin ? 1 : 0) << 7 | (this._hasExtension ? 1 : 0) << 6 | this._version << 4 | this._frameType & 15 ), e.setUint8( 1, (this._isEncrypted ? 1 : 0) << 7 | (this._isCompressed ? 1 : 0) << 6 | this._signalType & 15 ), e.setUint16(2, this._payloadLength), a; } static parse(a) { const e = new DataView(a), t = e.getUint8(0) >> 7 === 1, i = (e.getUint8(0) & 64) >> 6 === 1, s = (e.getUint8(0) & 48) >> 4, n = 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 ci( h, t, n, i, s, c, o, u ); } } class Ti { constructor(a, e) { g(this, "_body"); g(this, "_header", new ci()); this._header = a, this._body = e; } get header() { return this._header; } get isFin() { return this._header.fin; } get body() { return this._body; } toGRTNBuffer() { const a = this._header.toBuffer(), e = this._body, t = new ArrayBuffer(4); new DataView(t).setUint8(0, 1 * Math.pow(2, 4)); const i = new Uint8Array(t.byteLength + a.byteLength + e.byteLength); return i.set(new Uint8Array(t), 0), i.set(new Uint8Array(a), t.byteLength), i.set(new Uint8Array(e), t.byteLength + a.byteLength), i.buffer; } static parse(a) { const e = a.slice(0, 4), t = ci.parse(e); let i = new ArrayBuffer(0); return a.byteLength - 4 >= t.payloadLength && (i = a.slice(4, 4 + t.payloadLength)), new Ti(t, i); } } const Br = (r) => { const a = r.byteLength, e = new DataView(r); let t = 0; for (let i = 0; i < a; i++) t = t * 256 + e.getUint8(i); return t; }; let Ka = 0; class qt { constructor(a, e = 0, t = 0, i = 0) { g(this, "data"); g(this, "networkTime"); g(this, "futureOrProgress"); g(this, "type"); this.data = a, this.type = e, this.networkTime = t, this.futureOrProgress = i; } toBuffer() { const a = new Si(0, 0, 0); a.write(1, Uint8Array.from([0]).buffer), a.write(2, Uint16Array.from([0]).buffer), Ka++, a.write(3, Uint32Array.from([Ka]).buffer); const e = new Si(); 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), a.write(30, e.buffer), a.buffer; } static parse(a) { if (!a || a.byteLength < 4) return; Di.parse(a.slice(0, 4)); const t = Si.parse(a.slice(4))[ 30 /* TLV_TAG_Music */ ]; if (!t) return; const i = Si.parse(t), s = i[ 2 /* TLV_TAG_Command */ ], n = i[ 3 /* TLV_TAG_FutureOrProgress */ ], c = i[ 4 /* TLV_TAG_NetworkTime */ ], o = i[ 5 /* TLV_TAG_UserMsg */ ]; if (o.byteLength !== 0) return new qt( o, Br(s), Br(c), Br(n) ); } } var Q0 = Object.defineProperty, ec = Object.getOwnPropertyDescriptor, me = (r, a, e, t) => { for (var i = t > 1 ? void 0 : t ? ec(a, e) : a, s = r.length - 1, n; s >= 0; s--) (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i); return t && i && Q0(a, e, i), i; }; const qa = 30; class Qt extends De { constructor() { super(); g(this, "_state"); g(this, "time"); this._state = Y.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)); } } var lt; const ge = (lt = class extends bn { constructor(e) { const { rtsManager: t, localStreamManager: i, slsReporter: s, signalingManager: n, 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"); // 本地流 track 信息 g(this, "publishId", rt()); 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"); // @ts-ignore g(this, "parameter", {}); g(this, "onTrackEnd", (e) => { this.emit(e); }); this.streamManager = i, this.signalingManager = n, this.slsReporter = s, this.parameter = o, this.streamManager.on("trackended", (u) => { this.onTrackEnd(u); }), this.streamManager.on("publishupdate", () => { this.publishUpdate(); }), this.audioPubState = new Qt(), this.audioPubState.on("change", (u, h, p) => { this.emit("audioPublishStateChanged", u, h, p); }), this.videoPubState = new Qt(), this.videoPubState.on("change", (u, h, p) => { this.emit("videoPublishStateChanged", u, h, p); }), this.videoSmallPubState = new Qt(), this.videoSmallPubState.on("change", (u, h, p) => { this.emit("dualStreamPublishStateChanged", u, h, p); }), this.screenPubState = new Qt(), this.screenPubState.on("change", (u, h, p) => { this.emit("screenPublishStateChanged", u, h, p); }), this.dataPubState = new Qt(), 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; } // 媒体信令层面上有 camera 流 get hasCameraTrackInMS() { var e; return !!((e = this.streamTracks) != null && e.find( ({ ssrc: t, type: i, msid: s }) => i === "video" && t && s === T.VideoLarge )); } get hasCameraDualTrackInMS() { var e; return !!((e = this.streamTracks) != null && e.find( ({ ssrc: t, type: i, msid: s }) => i === "video" && t && s === T.VideoSmall )); } // 媒体信令层面上有 screen 流 get hasScreenTrackInMS() { var e; return !!((e = this.streamTracks) != null && e.find(({ ssrc: t, type: i, msid: s }) => i === "video" && t && s === T.Screen)); } // 媒体信令层面上有 audio 流(主流) get hasAudioTrackInMS() { var e; return !!((e = this.streamTracks) != null && e.find(({ ssrc: t, type: i, msid: s }) => i === "audio" && t && s === T.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 || He.createCallid(), this.updatePubId(); } setVideoProfile(e) { return w(this, null, function* () { yield this.streamManager.setVideoProfile(_n, 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(An, e); }); } setCameraDirection(e) { if (e === oi.CAMERA_FRONT) this.streamManager.setCameraVideoConstraints({ facingMode: "user" }); else if (e === oi.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 = rt(); } 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* () { Ni(lt.prototype, this, "clear").call(this), this.stopPreview(), this.resetPreviewElements(), this.resetSecondayPreviewElements(), this.clearStream(), yield this.leave(), this.streamManager.cameraCaptureDisabled = !1; }); } resetElement(e) { this.previewElements.includes(e) && (at(e), this.previewElements.splice(this.previewElements.indexOf(e), 1)), this.screenPreviewElements.includes(e) && (at(e), this.screenPreviewElements.splice(this.screenPreviewElements.indexOf(e), 1)); } setPreviewElement(e) { const { videoElement: t, screen: i } = e; i ? this.screenPreviewElements.includes(t) || this.screenPreviewElements.push(t) : this.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 (n) { const c = n.errorCode; let o = U.ERR_CAMERA_OPEN_FAIL; throw c === ti.ERROR_DEVICE_AUDIODEVICE_NOTFOUND ? o = U.ERR_CAMERA_NOT_AVAILABLE : c === ti.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED && (o = U.ERR_CAMERA_AUTH_FAIL), new V(o, `camera open fail: ${n.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 n = s.errorCode; let c = U.ERR_MIC_OPEN_FAIL; throw n === ti.ERROR_DEVICE_AUDIODEVICE_NOTFOUND ? c = U.ERR_MIC_NOT_AVAILABLE : n === ti.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED && (c = U.ERR_MIC_AUTH_FAIL), new V(c, `mic open fail: ${s.message}`); } }); } setViewConfig(e, t) { if (!e) { t === se.AliRtcVideoTrackCamera ? this.stopPreview({ primary: !0, screen: !1 }) : this.stopPreview({ primary: !1, screen: !0 }); return; } if (![se.AliRtcVideoTrackCamera, se.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 === se.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 }); }); } /** * 预览本地流 * @param {PreviewConfig} previewParams * @returns {Promise} */ 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(`[${lt.logName}]`, "preview no stream founded"); return; } return yn(t, s.mediaStream), this.setPreviewElement(e), s.mediaStream; } catch (s) { const n = U.ERR_INNER; throw V.fromError(s, n, "preview failed"); } }); } /** * 在所有预览容器中预览当前流 * @param {boolean} screen 是否指定预览辅流 */ 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 n = this.previewElements[s]; yield this.preview({ videoElement: n }); } if (i && this.screenPreviewElements.length) for (let s = 0; s < this.screenPreviewElements.length; s++) { const n = this.screenPreviewElements[s]; yield this.preview({ videoElement: n, screen: !0 }); } }); } stopPreview(e) { const { videoElement: t, primary: i = !0, screen: s = !0 } = e || {}; if (!t) i && (this.previewElements.forEach((n) => { at(n); }), this.previewElements = []), s && (this.screenPreviewElements.forEach((n) => { at(n); }), this.screenPreviewElements = []); else { const n = this.previewElements.findIndex((c) => c === t); if (n >= 0) this.previewElements.splice(n, 1), at(t); else { const c = this.screenPreviewElements.findIndex((o) => o === t); c >= 0 && (this.screenPreviewElements.splice(c, 1), at(t)); } } } 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]; at(s); } else if (e.screen) for (let i = 0; i < this.screenPreviewElements.length; i++) { const s = this.screenPreviewElements[i]; at(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 = G0[t.errorCode]; throw i && (e.audio ? this.emit( "localDeviceException", dt.AliEngineLocalDeviceTypeMic, i, "" ) : e.video ? this.emit( "localDeviceException", dt.AliEngineLocalDeviceTypeCamera, i, "" ) : e.screen ? this.emit( "localDeviceException", dt.AliEngineLocalDeviceTypeDisplay, i, "" ) : this.emit( "localDeviceException", dt.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 n, c; if (!e && !t) return; if (e && !t) { const o = {}; return i === T.Audio ? o.audio = !0 : i === T.VideoLarge || i === T.VideoSmall ? (o.video = !0, o.vMsid = i) : i === T.Screen && (o.screen = !0), yield this.publishDeleteTracks(o); } const s = {}; if (t != null && t.hasVideo && (s.isScreen = i === T.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 = ((n = t.videoTrack) == null ? void 0 : n.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 = le.AudioProfileMap.get(e); this.slsReporter.reportPublishProfile(T.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 = le.VideoProfileMap.get(e); t && this.slsReporter.reportPublishProfile(T.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 = le.VideoProfileMap.get(e); t && this.slsReporter.reportPublishProfile(T.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 !== Y.AliRtcStatePublishing) { this.dataPubState.setState(Y.AliRtcStatePublishing); try { const e = yield this.rtsManager.publishAddDataChannel(this.url); e ? (this.updateDataChannel(e), this.dataPubState.setState(Y.AliRtcStatePublished)) : (this.dataPubState.setState(Y.AliRtcStateNoPublish), this.emit("publishDataError", new V(U.ERR_INNER, "publishDataError"))); } catch (e) { this.dataPubState.setState(Y.AliRtcStateNoPublish); } } }); } startPublish() { return w(this, arguments, function* (e = !1, t = nt.MANUAL) { var u; if (!this.joined) return; const i = this.streamManager.publishStreams, { audio: s, video: n, videoSmall: c, screen: o } = i; if (!s && !n && !c && !o) { O.event(`[${lt.logName}]`, "startPublish no stream founded"); return; } this.createCallId(); try { const h = (/* @__PURE__ */ new Date()).getTime(); s && this.audioPubState.setState(Y.AliRtcStatePublishing), n && this.videoPubState.setState(Y.AliRtcStatePublishing), c && this.videoSmallPubState.setState(Y.AliRtcStatePublishing), o && this.screenPubState.setState(Y.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[T.Audio] = p, this.reportAudioProfile()), c && (this.trackTraceIdMap[T.VideoSmall] = p), n && (this.trackTraceIdMap[T.VideoLarge] = p, this.reportVideoProfile()), o && (this.trackTraceIdMap[T.Screen] = p, this.reportScreenProfile()); const f = { type: xt.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(Y.AliRtcStatePublished), n && this.videoPubState.setState(Y.AliRtcStatePublished), c && this.videoSmallPubState.setState(Y.AliRtcStatePublished), o && this.screenPubState.setState(Y.AliRtcStatePublished); } catch (h) { throw s && this.audioPubState.setState(Y.AliRtcStateNoPublish), n && this.videoPubState.setState(Y.AliRtcStateNoPublish), c && this.videoSmallPubState.setState(Y.AliRtcStateNoPublish), o && this.screenPubState.setState(Y.AliRtcStateNoPublish), h; } }); } updateStreams() { return w(this, null, function* () { yield this.streamManager.updateStreams(); }); } publishUpdate(e) { return w(this, null, function* () { var n, c, o, u, h, p; if (!this._isPublishing) return; yield this.publishPromise; const t = this.streamManager.publishStreams; let i; const s = (/* @__PURE__ */ new Date()).getTime(); try { const d = (n = this.streamTracks) == null ? void 0 : n.find( ({ ssrc: E, type: _, msid: y }) => _ === "audio" && E && y === T.Audio ), f = yield this.compareAndPublish(d, t.audio, T.Audio); f && (i = f); const m = (c = this.streamTracks) == null ? void 0 : c.find( ({ ssrc: E, type: _, msid: y }) => _ === "video" && E && y === T.VideoLarge ), l = yield this.compareAndPublish(m, t.video, T.VideoLarge); l && (i = l); const S = (o = this.streamTracks) == null ? void 0 : o.find( ({ ssrc: E, type: _, msid: y }) => _ === "video" && E && y === T.VideoSmall ), v = yield this.compareAndPublish( S, t.videoSmall, T.VideoSmall ); v && (i = v); const x = (u = this.streamTracks) == null ? void 0 : u.find( ({ ssrc: E, type: _, msid: y }) => _ === "video" && E && y === T.Screen ), b = yield this.compareAndPublish(x, t.screen, T.Screen); if (b && (i = b), !i) if (e === nt.RECONNECT && this.rtsManager.publishingTracks.length > 0) { if ((h = this.parameter.data) != null && h.enablePubDataChannel) { const y = this.rtsManager.getDatachannelByMsid({ url: this.url, msid: T.Data }); this.updateDataChannel(y); } const E = this.rtsManager.publishingTracks.find(({ type: y }) => y === "video"), _ = this.rtsManager.publishingTracks.find(({ type: y }) => y === "audio"); (E || _) && (yield this.rtsManager.waitPublishSender( this.url, !E, E ? E.msid : _ == null ? void 0 : _.msid )), i = { type: xt.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 = Dt(c, ["tracks"]); s = ut(J({}, h), { tracks: [ ...u, { type: "data", msid: T.Data, ssrc: `${((o = this.callId) == null ? void 0 : o.length) > 8 ? this.callId.substring(0, 8) : "web"}${this.dc.datachannel.id || "0"}`, codec: "text" } ] }); } const n = yield this.signalingManager.publish(s); e.signaltid = n.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 n = (t == null ? void 0 : t.aMsid) === T.Audio, c = (t == null ? void 0 : t.vMsid) === T.VideoLarge, o = (t == null ? void 0 : t.vMsid) === T.VideoSmall, u = (t == null ? void 0 : t.vMsid) === T.Screen; n && this.audioPubState.setState(Y.AliRtcStatePublishing), c && this.videoPubState.setState(Y.AliRtcStatePublishing), o && this.videoSmallPubState.setState(Y.AliRtcStatePublishing), u && this.screenPubState.setState(Y.AliRtcStatePublishing); try { const h = yield this.rtsManager.publishAdd(this.url, e, this.callId, t, !1, !0); n && (this.audioPubState.setState(Y.AliRtcStatePublished), this.reportAudioProfile(), this.trackTraceIdMap[T.Audio] = h), c && (this.videoPubState.setState(Y.AliRtcStatePublished), this.reportVideoProfile(), this.trackTraceIdMap[T.VideoLarge] = h), o && (this.videoSmallPubState.setState(Y.AliRtcStatePublished), this.trackTraceIdMap[T.VideoSmall] = h), u && (this.screenPubState.setState(Y.AliRtcStatePublished), this.reportScreenProfile(), this.trackTraceIdMap[T.Screen] = h), this.streamTracks = this.rtsManager.publishingTracks; const p = { type: xt.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 (n && (this.audioPubState.setState(Y.AliRtcStateNoPublish), p = U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED), c && (this.videoPubState.setState(Y.AliRtcStateNoPublish), p = U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED), o && (this.videoSmallPubState.setState(Y.AliRtcStateNoPublish), p = U.ERR_SDK_PUBLISH_DUAL_STREAM_FAILED), u && (this.screenPubState.setState(Y.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 = (t == null ? void 0 : t.vMsid) === T.VideoLarge, s = (t == null ? void 0 : t.vMsid) === T.Screen; i && this.streamManager.setVideoProfile(void 0, void 0, !0), s && this.streamManager.setScreenProfile(void 0, void 0); const n = { type: xt.Replace, userid: this.userId, sessionid: "", pubid: this.publishId, displayname: this.name, subscribe: { signal: "", pullstreamurl: this.url }, callid: this.callId, tracks: this.streamTracks }; return this.reportSelfDeviceStatus(), n; } catch (i) { throw 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: xt.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(Y.AliRtcStateNoPublish), e.video && (e.vMsid === T.VideoSmall ? this.videoSmallPubState.setState(Y.AliRtcStateNoPublish) : this.videoPubState.setState(Y.AliRtcStateNoPublish)), e.screen && this.screenPubState.setState(Y.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(`[${lt.logName}]`, "publishStop", { url: this.url }); const e = (/* @__PURE__ */ new Date()).getTime(); try { const t = this.hasAudioTrackInMS, i = this.hasCameraTrackInMS, s = this.hasCameraDualTrackInMS, n = this.hasScreenTrackInMS; yield this.rtsManager.publishStop(this.url), t && this.audioPubState.setState(Y.AliRtcStateNoPublish), i && this.videoPubState.setState(Y.AliRtcStateNoPublish), s && this.videoSmallPubState.setState(Y.AliRtcStateNoPublish), n && this.screenPubState.setState(Y.AliRtcStateNoPublish), this.traceId = "", Object.keys(this.monitorDataCache).forEach((o) => { this.reportPublishMonitor(o); }), this.streamTracks = []; const c = { type: xt.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 = (/* @__PURE__ */ new Date()).getTime(); let t = { type: xt.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, n = this.hasCameraDualTrackInMS, c = this.hasScreenTrackInMS; yield this.rtsManager.unpublish(), this.streamTracks = [], this.stopStreamMonitor(), i && this.audioPubState.setState(Y.AliRtcStateNoPublish), s && this.videoPubState.setState(Y.AliRtcStateNoPublish), n && this.videoSmallPubState.setState(Y.AliRtcStateNoPublish), c && this.screenPubState.setState(Y.AliRtcStateNoPublish), this._isPublishing = !1, this.traceId = "", this.clearStream(); } return this.dc && (this.rtsManager.publishStopDataChannel(this.url, this.dc), this.dataPubState.setState(Y.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(Le.Local, this.getDeviceStatus()); } /** * 从localStream 中获取当前的设备状态 * @returns {string} */ getDeviceStatus() { var t, i, s, n; let e = { micOpen: !1, micInterrupted: !1, cameraOpen: !1, screenShare: !1, audioDisable: !0, videoDisable: !0, screenDisable: !0, backgroundMode: !1, accompanyPlaying: !1 }; return e.cameraOpen = this.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 || !((n = (s = this.streamManager.screenStreamInfo) == null ? void 0 : s.originVideoTrack) != null && n.enabled), En.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 === T.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 n; 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" && (n = 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 = Dt(t, ["_last"]); } ((i = this.candidateDataCache) == null ? void 0 : i.length) >= qa && this.reportNetwork(), n && (n._last = c, this.candidateDataCache.push(n)); 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 === T.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 = Dt(v, ["_last"]); } (l == null ? void 0 : l.length) >= qa && 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); }); } /** * 清除本地流 * @returns {void} */ clearStream() { this.streamManager.stop(), this.audioPubState.setState(Y.AliRtcStatePublishIdle), this.videoPubState.setState(Y.AliRtcStatePublishIdle), this.videoSmallPubState.setState(Y.AliRtcStatePublishIdle), this.screenPubState.setState(Y.AliRtcStatePublishIdle); } /** * 获取当前使用的摄像头 deviceId * @returns {string | undefined} */ getCurrentCameraDeviceId() { var e; return (e = this.streamManager.cameraStreamInfo.originVideoTrack) == null ? void 0 : e.getSettings().deviceId; } /** * 获取当前使用的摄像头 deviceId * @returns {string | undefined} */ 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 = Y0(t, 1156); i.forEach((n, c) => { const o = new Ti( new ci(n.byteLength, c === i.length - 1, c === 0 ? 1 : 0), n ); this.dc.send(o.toGRTNBuffer()); }); }); } getStats() { return w(this, null, function* () { const e = []; if (this.hasAudioTrackInMS) { const n = yield this.rtsManager.getPublishAudioStats(this.url); n && e.push({ stats: n, track: Xt.AliRtcAudioTrackMic }); } const t = []; if (this.hasCameraTrackInMS) { const n = yield this.rtsManager.getPublishVideoStats(this.url, T.VideoLarge); n && t.push({ track: se.AliRtcVideoTrackCamera, streamType: we.AliRtcVideoStreamTypeHigh, stats: n }); } if (this.hasCameraDualTrackInMS) { const n = yield this.rtsManager.getPublishVideoStats(this.url, T.VideoSmall); n && t.push({ track: se.AliRtcVideoTrackCamera, streamType: we.AliRtcVideoStreamTypeLow, stats: n }); } if (this.hasScreenTrackInMS) { const n = yield this.rtsManager.getPublishVideoStats(this.url, T.Screen); n && t.push({ track: se.AliRtcVideoTrackScreen, stats: n }); } let i; const s = yield this.rtsManager.getPCStats(); return s == null || s.forEach((n) => { n.type === "candidate-pair" && n.state === "succeeded" && (i = n); }), { audio: e, video: t, candidate: i }; }); } }, /** * @ignore */ g(lt, "logName", "LocalUser"), lt); me([ D() ], ge.prototype, "clearPublishState", 1); me([ D() ], ge.prototype, "clear", 1); me([ D(H) ], ge.prototype, "startDefaultCamera", 1); me([ D(H) ], ge.prototype, "startDefaultAudio", 1); me([ D() ], ge.prototype, "setViewConfig", 1); me([ D() ], ge.prototype, "startCameraCapture", 1); me([ D() ], ge.prototype, "stopCameraCapture", 1); me([ D() ], ge.prototype, "startAudioCapture", 1); me([ D() ], ge.prototype, "stopAudioCapture", 1); me([ D() ], ge.prototype, "stopPreview", 1); me([ D() ], ge.prototype, "resumePublish", 1); me([ D() ], ge.prototype, "createLocalStream", 1); me([ D() ], ge.prototype, "stopLocalStream", 1); me([ D(H) ], ge.prototype, "startPublish", 1); me([ D() ], ge.prototype, "updateStreams", 1); me([ D(H) ], ge.prototype, "publishUpdate", 1); me([ D(([r]) => [r]) ], ge.prototype, "syncPublishToRoomServer", 1); me([ D() ], ge.prototype, "refreshPushStreamUrl", 1); me([ D(([r, a, e]) => [JSON.stringify(e)]) ], ge.prototype, "publishAdd", 1); me([ D(([r, a]) => [JSON.stringify(a)]) ], ge.prototype, "publishReplace", 1); me([ D(H) ], ge.prototype, "publishDeleteTracks", 1); me([ D() ], ge.prototype, "publishStop", 1); me([ D() ], ge.prototype, "unPublish", 1); me([ D(([r, a, e]) => [r.length, a, e]) ], ge.prototype, "sendSEI", 1); let tc = ge; var vt = /* @__PURE__ */ ((r) => (r.OPUS = "opus", r.H264 = "H264", r.UNKNOWN = "", r))(vt || {}), re = /* @__PURE__ */ ((r) => (r[r.NotSubscribe = 0] = "NotSubscribe", r[r.Subscribing = 1] = "Subscribing", r[r.Subscribed = 2] = "Subscribed", r))(re || {}), Vt = /* @__PURE__ */ ((r) => (r.VideoTrackEnded = "videoTrackEnded", r.AudioTrackEnded = "audioTrackEnded", r.ScreenTrackEnded = "screenTrackEnded", r))(Vt || {}); const ic = (r) => { const a = new MediaStream(); return a.addTrack(r), a; }, Rn = (r) => w(void 0, null, function* () { return yield le.createStream({ custom: !0, mediaStream: r }); }), ei = (r) => w(void 0, null, function* () { const a = ic(r); return yield Rn(a); }), rc = (r) => { const { audio: a, video: e, screen: t } = r; if (e && t) throw new V(U.ERR_INNER, "create stream error, cannot create video && screen together"); return !(!e && !a && !t); }, sc = (r) => r === T.Audio || r === Jr.Audio, ac = (r) => r === T.VideoLarge || r === Jr.VideoLarge, nc = (r) => r === T.VideoSmall, oc = (r) => r === T.Screen, cc = (r) => r === T.Data; var uc = Object.defineProperty, hc = Object.getOwnPropertyDescriptor, dc = (r, a, e, t) => { for (var i = t > 1 ? void 0 : t ? hc(a, e) : a, s = r.length - 1, n; s >= 0; s--) (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i); return t && i && uc(a, e, i), i; }; class Ai extends De { constructor() { super(); g(this, "audioInfo", { subscribeState: re.NotSubscribe, ssrc: "", msid: "", pt: 0, red: 0, codec: vt.UNKNOWN }); g(this, "videoLargeInfo", { subscribeState: re.NotSubscribe, ssrc: "", msid: "", pt: 0, red: 0, codec: vt.UNKNOWN }); g(this, "videoSmallInfo", { subscribeState: re.NotSubscribe, ssrc: "", msid: "", pt: 0, red: 0, codec: vt.UNKNOWN }); g(this, "screenInfo", { subscribeState: re.NotSubscribe, ssrc: "", msid: "", pt: 0, red: 0, codec: vt.UNKNOWN }); g(this, "dataInfo", { subscribeState: re.NotSubscribe, ssrc: "", msid: "", pt: 0, red: 0, codec: vt.UNKNOWN }); g(this, "audioVolume", 1); g(this, "audioMuted", !1); g(this, "userStatus"); } /** * 远端流音频轨道信息 * @returns */ getAudioInfo() { return this.audioInfo; } /** * 远端流视频轨道信息 * @returns */ getVideoSmallInfo() { return this.videoSmallInfo; } /** * 远端流视频轨道信息 * @returns */ getVideoLargeInfo() { return this.videoLargeInfo; } /** * 远端流屏幕共享轨道信息 * @returns */ getScreenInfo() { return this.screenInfo; } getDataInfo() { return this.dataInfo; } get subscribingInfos() { return [this.audioInfo, this.videoLargeInfo, this.videoSmallInfo, this.screenInfo].filter( (e) => e.msid && e.subscribeState === re.Subscribed ); } get hasTrack() { return this.hasAudio || this.hasVideo || this.hasScreen || this.hasData; } /** * 远端流是否包含音频轨道 * @returns */ get hasAudio() { return this.audioInfo.ssrc !== ""; } /** * 远端流是否包含视频轨道 * @returns */ get hasVideo() { return this.videoLargeInfo.ssrc !== "" || this.videoSmallInfo.ssrc !== ""; } /** * 远端流是否包含视频大流轨道 * @returns */ get hasVideoLarge() { return this.videoLargeInfo.ssrc !== ""; } /** * 远端流是否包含视频小流轨道 * @returns */ get hasVideoSmall() { return this.videoSmallInfo.ssrc !== ""; } /** * 远端流是否包含屏幕共享轨道 * @returns */ get hasScreen() { return this.screenInfo.ssrc !== ""; } get hasData() { return this.dataInfo.ssrc !== ""; } /** * 是否订阅远端流音频轨道 * @returns */ get isAudioSubscribed() { return this.audioInfo.subscribeState === re.Subscribed; } get isAudioSubscribing() { return this.audioInfo.subscribeState === re.Subscribing; } /** * 是否订阅远端流视频轨道 * @returns */ get isVideoSubscribed() { return this.isVideoLargeSubscribed || this.isVideoSmallSubscribed; } get isVideoSubscribing() { return this.isVideoLargeSubscribing || this.isVideoSmallSubscribing; } /** * 是否订阅远端流视频大流轨道 * @returns */ get isVideoLargeSubscribed() { return this.videoLargeInfo.subscribeState === re.Subscribed; } get isVideoLargeSubscribing() { return this.videoLargeInfo.subscribeState === re.Subscribing; } /** * 是否订阅远端流视频小流轨道 * @returns */ get isVideoSmallSubscribed() { return this.videoSmallInfo.subscribeState === re.Subscribed; } get isVideoSmallSubscribing() { return this.videoSmallInfo.subscribeState === re.Subscribing; } /** * 是否订阅远端流屏幕共享轨道 * @returns */ get isScreenSubscribed() { return this.screenInfo.subscribeState === re.Subscribed; } get isScreenSubscribing() { return this.screenInfo.subscribeState === re.Subscribing; } get isDataSubscribed() { return this.dataInfo.subscribeState === re.Subscribed; } get isDataSubscribing() { return this.dataInfo.subscribeState === re.Subscribing; } get audioCodec() { return this.audioInfo.codec; } get videoCodec() { return this.hasVideoLarge ? this.videoLargeInfo.codec : this.hasVideoSmall ? this.videoSmallInfo.codec : this.hasScreen ? this.screenInfo.codec : vt.UNKNOWN; } get audioTrackInfo() { return this.hasAudio ? Xt.AliRtcAudioTrackMic : Xt.AliRtcAudioTrackNo; } get videoTrackInfo() { return this.hasVideo && this.hasScreen ? se.AliRtcVideoTrackBoth : this.hasVideo ? se.AliRtcVideoTrackCamera : this.hasScreen ? se.AliRtcVideoTrackScreen : se.AliRtcVideoTrackNo; } // 更新远端推流信息 updateTracks(e) { let t = "", i = "", s = "", n = "", c = ""; return e ? (e.forEach((o) => { var p; let u = vt.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); } sc(o.msid) ? (t = o.ssrc, this.audioInfo.msid = o.msid, this.audioInfo.codec = u, (h || this.audioInfo.ssrc !== t) && (this.audioInfo.subscribeState = re.NotSubscribe)) : nc(o.msid) ? (s = o.ssrc, this.videoSmallInfo.msid = o.msid, this.videoSmallInfo.codec = u, (h || this.videoSmallInfo.ssrc !== s) && (this.videoSmallInfo.subscribeState = re.NotSubscribe)) : ac(o.msid) ? (i = o.ssrc, this.videoLargeInfo.msid = o.msid, this.videoLargeInfo.codec = u, (h || this.videoLargeInfo.ssrc !== i) && (this.videoLargeInfo.subscribeState = re.NotSubscribe)) : oc(o.msid) ? (n = o.ssrc, this.screenInfo.msid = o.msid, this.screenInfo.codec = u, (h || this.screenInfo.ssrc !== n) && (this.screenInfo.subscribeState = re.NotSubscribe)) : cc(o.msid) && (c = o.ssrc, this.dataInfo.msid = o.msid, this.dataInfo.codec = u, (h || this.dataInfo.ssrc !== c) && (this.dataInfo.subscribeState = re.NotSubscribe)); }), this.updateRemoteTrackSsrc(t, i, s, n, c)) : this.updateRemoteTrackSsrc(t, i, s, n, c), {}; } updateRemoteTrackSsrc(e, t, i, s, n) { this.audioInfo.ssrc = e, this.videoSmallInfo.ssrc = i, this.videoLargeInfo.ssrc = t, this.screenInfo.ssrc = s, this.dataInfo.ssrc = n; } markRemoteTrackSubscribing(e) { return e.video && (e.vMsid === this.videoSmallInfo.msid && (this.videoSmallInfo.subscribeState = re.Subscribing), (e.vMsid === this.videoLargeInfo.msid || !e.vMsid) && (this.videoLargeInfo.subscribeState = re.Subscribing)), e.screen && (this.screenInfo.subscribeState = re.Subscribing), e.audio && (this.audioInfo.subscribeState = re.Subscribing), e.data && (this.dataInfo.subscribeState = re.Subscribing), { videoLargeInfo: this.videoLargeInfo, videoSmallInfo: this.videoSmallInfo }; } updateRemoteTrackSubState(e) { return e.video !== void 0 && ((e.vMsid === this.videoSmallInfo.msid || !e.vMsid) && (this.videoSmallInfo.subscribeState = e.video ? re.Subscribed : re.NotSubscribe), (e.vMsid === this.videoLargeInfo.msid || !e.vMsid) && (this.videoLargeInfo.subscribeState = e.video ? re.Subscribed : re.NotSubscribe)), e.screen !== void 0 && (this.screenInfo.subscribeState = e.screen ? re.Subscribed : re.NotSubscribe), e.audio !== void 0 && (this.audioInfo.subscribeState = e.audio ? re.Subscribed : re.NotSubscribe), e.data !== void 0 && (this.dataInfo.subscribeState = e.data ? re.Subscribed : re.NotSubscribe), { audioInfo: this.audioInfo, videoLargeInfo: this.videoLargeInfo, videoSmallInfo: this.videoSmallInfo, screenInfo: this.screenInfo, dataInfo: this.dataInfo }; } /** * 更新远端用户设备状态 * @param status * @returns {boolean} 状态改变返回true,否则返回false */ updateRemoteUserDeviceStatus(e) { let t = En.parseStatus(e); const { audioDisable: i, videoDisable: s, screenDisable: n } = t; return this.userStatus ? (this.userStatus.audioDisable != i && (this.userStatus.audioDisable = i, this.emit(Le.Remote, i ? oe.MuteAudio : oe.UnmuteAudio)), this.userStatus.videoDisable != s && (this.userStatus.videoDisable = s, this.emit(Le.Remote, s ? oe.MuteVideo : oe.UnmuteVideo)), this.userStatus.screenDisable != n && (this.userStatus.screenDisable = n, this.emit(Le.Remote, n ? oe.MuteScreen : oe.UnmuteScreen))) : (this.userStatus = t, this.emit(Le.Remote, i ? oe.MuteAudio : oe.UnmuteAudio), this.emit(Le.Remote, s ? oe.MuteVideo : oe.UnmuteVideo), this.emit(Le.Remote, n ? oe.MuteScreen : oe.UnmuteScreen)), !1; } } /** * @ignore */ g(Ai, "logName", "RemoteStreamInfo"); dc([ D() ], Ai.prototype, "updateRemoteTrackSubState", 1); class lc { constructor(a) { g(this, "remoteUser"); this.remoteUser = a; } get userId() { return this.remoteUser.userId; } get displayName() { return this.remoteUser.displayname; } get isMuteAudioPlaying() { return this.remoteUser.getAudioMuted(); } get hasAudio() { return this.remoteUser.hasAudioTrack; } get hasCamera() { return this.remoteUser.hasVideoTrack; } get hasCameraLarge() { return this.remoteUser.hasVideoLargeTrack; } get hasCameraSmall() { return this.remoteUser.hasVideoSmallTrack; } get hasScreenShare() { return this.remoteUser.hasScreenTrack; } get isAudioSubscribing() { return this.remoteUser.isAudioSubscribing; } get isVideoSubscribing() { return this.remoteUser.isVideoSubscribing; } get isVideoLargeSubscribing() { return this.remoteUser.isVideoLargeSubscribing; } get isVideoSmallSubscribing() { return this.remoteUser.isVideoSmallSubscribing; } get isScreenSubscribing() { return this.remoteUser.isScreenSubscribing; } get audioElement() { return this.remoteUser.getAudioElement(); } } var fc = Object.defineProperty, pc = Object.getOwnPropertyDescriptor, Te = (r, a, e, t) => { for (var i = t > 1 ? void 0 : t ? pc(a, e) : a, s = r.length - 1, n; s >= 0; s--) (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i); return t && i && fc(a, e, i), i; }; class zt extends De { constructor() { super(); g(this, "state"); g(this, "time"); g(this, "_enabled"); this.state = he.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 gc = 30; var Me; const Ce = (Me = class extends bn { constructor(e) { var f; const { userId: t, displayName: i, rtsManager: s, usersViewMap: n, 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", we.AliRtcVideoStreamTypeHigh); g(this, "audioMuted", !1); g(this, "playoutVolume", 1); g(this, "playoutGainNode"); g(this, "audioSubState"); g(this, "videoSubState"); g(this, "videoLargeSubState", new zt()); g(this, "videoSmallSubState", new zt()); g(this, "screenSubState"); // DataChannel 通道相关 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 = Ti.parse(e.slice(4)); let i; if (t.body) if (t.isFin) { if (this.dcMsgWaitingPieces.length > 0) { const n = this.dcMsgWaitingPieces.reduce( (c, o) => c + o.byteLength, t.body.byteLength ); try { const c = new ArrayBuffer(n); let o = 0; for (let h = 0; h < this.dcMsgWaitingPieces.length; h++) { const 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 = qt.parse(c); } catch (c) { } this.dcMsgWaitingPieces = [], i || (i = qt.parse(t.body)); } else i = qt.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 Ai(), this.remoteUserInfo = new lc(this), this.parameter = d, this.streamInfo.on(Le.Remote, (m) => { this.emit(Le.Remote, m, this.userId); }), this.signalingManager = o, this.viewMap = (f = n[t]) != null ? f : { cameraViews: [], screenViews: [] }, n[t] = this.viewMap, this.slsReporter = c, this.localUser = u, this.audioSubState = new zt(), this.audioSubState.on("change", (m, l, S) => { this.emit("audioSubscribeStateChanged", this.uid, m, l, S); }), this.videoSubState = new zt(), this.videoSubState.on("change", (m, l, S) => { this.emit("videoSubscribeStateChanged", this.uid, m, l, S); }), this.screenSubState = new zt(), this.screenSubState.on("change", (m, l, S) => { this.emit("screenSubscribeStateChanged", this.uid, m, l, S); }), this.dataSubState = new zt(), 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(de.User)); } setAudioMuted(e) { this.audioMuted = e, this.toggleAudio(!e); } getAudioElement() { return this.audioElement; } setPlayoutVolume(e) { if (this.playoutVolume = e, this.audioElement) if (this.parameter.enableAudioContextPlayoutVolume) if (this.playoutGainNode) this.playoutGainNode.gain.value = e; else { const t = this.audioElement.srcObject; if (t) { const i = Ft.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 !== se.AliRtcVideoTrackScreen && t !== se.AliRtcVideoTrackCamera) throw new V( U.ERR_INVALID_ARGUMENTS, "track is not AliRtcVideoTrackScreen or AliRtcVideoTrackCamera" ); e ? jr(e).forEach((s) => { s.setAttribute("playsinline", ""), le.BrowserUtil.isMicroMessenger && (s.setAttribute("x5-video-player-type", "h5-page"), s.setAttribute("x5-playsinline", ""), le.SystenUtil.isAndroid || le.SystenUtil.isIos && s.setAttribute("x-webkit-airplay", "allow")), t === se.AliRtcVideoTrackScreen ? this.viewMap.screenViews.push(s) : this.viewMap.cameraViews.push(s), this.play(s, t === se.AliRtcVideoTrackScreen); }) : (this.stopPlayAll(t === se.AliRtcVideoTrackScreen), t === se.AliRtcVideoTrackScreen ? this.viewMap.screenViews = [] : this.viewMap.cameraViews = []); } clear(e = !0) { return w(this, null, function* () { var t; this.subscribeStopDataChannel(), e && this.doStopSubscribe(this.streamUrl), Ni(Me.prototype, this, "clear").call(this), this.stopPlayAudio(), this.clearStream(), this.clearScreenStream(), this.playoutGainNode && (this.playoutGainNode.disconnect(), this.playoutGainNode = void 0, Ft.getInstance().removeEventListener("statechange", this.handleAudioContextSuspended)), (t = this.streamInfo) == null || t.removeAllListeners(Le.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 Ai()), (c = this.streamInfo) == null ? void 0 : c.updateTracks(s); }); } subscribe(s, n) { 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 || de.User, i))), e != null && e.data && this.subscribeDataChannel()); }); } subscribeProxy(e, t, i) { return w(this, null, function* () { var c, o, u, h; let s = (/* @__PURE__ */ new Date()).getTime(), n = ""; try { e.audio && this.audioSubState.setState(he.AliRtcStateSubscribing), e.video && (this.videoSubState.currentState === he.AliRtcStateSubscribeIdle || this.videoSubState.currentState === he.AliRtcStateNoSubscribe) && this.videoSubState.setState(he.AliRtcStateSubscribing), e.screen && this.screenSubState.setState(he.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), n = p.traceId || ""; const { stream: d } = p; if (e.audio) { this.trackTraceIdMap[T.Audio] = n; 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(he.AliRtcStateSubscribed), this.audioSubState.getEnabled() || this.toggleAudio(!1); } e.video && (this.videoSubState.setState(he.AliRtcStateSubscribed), e.vMsid === T.VideoSmall ? (this.trackTraceIdMap[T.VideoSmall] = n, this.videoSmallSubState.setState(he.AliRtcStateSubscribed)) : (this.trackTraceIdMap[T.VideoLarge] = n, this.videoLargeSubState.setState(he.AliRtcStateSubscribed)), this.videoSubState.getEnabled() || this.toggleVideo(!1), this.updateStream(d, this.isVideoLargeSubscribing && this.isVideoSmallSubscribing)), e.screen && (this.screenSubState.setState(he.AliRtcStateSubscribed), this.trackTraceIdMap[T.Screen] = n, this.videoSubState.getEnabled() || this.toggleScreen(!1), this.updateScreenStream(d)); const f = (/* @__PURE__ */ new Date()).getTime() - s; this.slsReporter.reportSubscribe( ((u = this.localUser) == null ? void 0 : u.callId) || "", this.callId, !!e.video && e.vMsid === T.VideoLarge, !!e.video && e.vMsid === T.VideoSmall, !!e.screen, !!e.audio, 0, "", f, { pctid: this.rtsManager.pcTraceId, subtid: n, ajsub: t === de.Join ? 1 : 0, url: this.streamUrl, est: s } ), this.startStreamMonitor(); } catch (p) { const d = (/* @__PURE__ */ new Date()).getTime() - s; e.audio && this.audioSubState.setState(he.AliRtcStateNoSubscribe), e.video && this.videoSubState.setState(he.AliRtcStateNoSubscribe), e.screen && this.screenSubState.setState(he.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 === T.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 === T.VideoLarge, !!e.video && e.vMsid === T.VideoSmall, !!e.screen, !!e.audio, f, "", d, { pctid: this.rtsManager.pcTraceId, subtid: "", ajsub: t === de.Join ? 1 : 0, url: this.streamUrl, est: s } ); const m = V.fromError(p, f); throw this.emit("remoteSubscribeError", m), m; } }); } /** * 移除对某些轨道的订阅 * @param {UnSubscribeOptions} options 取消订阅轨道配置 * @returns {Promise} */ subscribeDeleteTracks(e) { return w(this, null, function* () { const { audio: t, video: i, screen: s, data: n, vMsid: c } = e, o = []; (t || i || n) && 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(he.AliRtcStateNoSubscribe)), e.video === !0 && (s.video = !1, e.vMsid === T.VideoSmall ? (this.videoSmallSubState.setState(he.AliRtcStateNoSubscribe), (this.videoLargeSubState.currentState === he.AliRtcStateNoSubscribe || this.videoLargeSubState.currentState === he.AliRtcStateSubscribeIdle) && this.videoSubState.setState(he.AliRtcStateNoSubscribe)) : (this.videoLargeSubState.setState(he.AliRtcStateNoSubscribe), (this.videoSmallSubState.currentState === he.AliRtcStateNoSubscribe || this.videoSmallSubState.currentState === he.AliRtcStateSubscribeIdle) && this.videoSubState.setState(he.AliRtcStateNoSubscribe))), e.screen === !0 && (s.screen = !1, this.screenSubState.setState(he.AliRtcStateNoSubscribe)); const { callId: n, remoteCallid: c } = this, o = { callid: n, remoteCallid: c, remoteStream: i }; return e.audio && (this.audioLevelMonitor.stop(), this.stopPlayAudio(), this.audioTrack = void 0), this.streamInfo.updateRemoteTrackSubState({ audio: e.audio === !0 ? !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 = Ft.getInstance(); return e.state !== "running" && e.resume(), this.audioElement ? this.audioElement.play() : this.playAudio(); }); } resumeVideo(e) { return w(this, null, function* () { if (!e || e === se.AliRtcVideoTrackCamera || e === se.AliRtcVideoTrackBoth) return this.playAll(); if (!e || e === se.AliRtcVideoTrackScreen || e === se.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 = (/* @__PURE__ */ new Date()).getTime(); try { let n; e ? n = yield this.subscribeDeleteTracks(e) : n = yield this.doStopSubscribe(this.streamUrl), this.slsReporter.reportUnsubscribe( ((i = this.localUser) == null ? void 0 : i.callId) || (n == null ? void 0 : n.callid) || "", this.callId, (/* @__PURE__ */ new Date()).getTime() - t, 0, "" ); } catch (n) { throw this.slsReporter.reportUnsubscribe(((s = this.localUser) == null ? void 0 : s.callId) || "", this.callId, (/* @__PURE__ */ new Date()).getTime() - t, 0, ""), n; } }); } doStopSubscribe(e) { return w(this, null, function* () { var s, n, c, o; const { callId: t, remoteCallid: i } = this; if ((this.isAudioSubscribing || this.isVideoSubscribing || this.isScreenSubscribing) && e) try { this.stopStreamMonitor(), yield this.rtsManager.subscibeStop(e), this.restore(); const u = { callid: t, remoteCallid: i, remoteStream: this.stream }; return this.callId = "", u; } catch (u) { if (((o = (c = (n = (s = u == null ? void 0 : u.extraInfo) == null ? void 0 : s.parsedData) == null ? void 0 : n.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, n; if (e.mediaStream) { n = document.createElement("video"); const c = () => { O.event(`uid: ${this.userId} new mediaStream canplay`), n && n.removeEventListener("canplaythrough", c, !1), n = void 0, clearTimeout(s), i(!0); }; n.addEventListener("canplaythrough", c, !1), (n._playPromise || Promise.resolve()).then(() => { n && e.mediaStream && (n.srcObject = e.mediaStream); }); } else i(!0); s = window.setTimeout(() => { O.event(`uid: ${this.userId} new mediaStream timeout`), n = void 0, i(!0); }, 3e3); }), this.updateSubscribe(de.User)), this.stream = e, this.playAll(!1, t), !this.subscribed && e && (this.subscribed = !0), e.hasAudio && this.isAudioSubscribing && e.enableAudio(), e.hasVideo && this.isVideoSubscribing && e.enableVideo(); }); } updateScreenStream(e) { this.screenStream = e, this.playAll(!0), !this.subscribed && e && (this.subscribed = !0), e.hasVideo && this.isScreenSubscribing && e.enableVideo(); } clearStream() { var e; (e = this.stream) == null || e.stop(), this.stream = void 0; } clearScreenStream() { var e; (e = this.screenStream) == null || e.stop(), this.screenStream = void 0; } subscribeDataChannel() { if (this.dc) try { this.dc.dispose(), this.dcMsgWaitingPieces = [], this.dc.off("message", this.onDataChannelMessage), this.dc = void 0; } catch (e) { } !this.streamInfo.hasAudio && !this.streamInfo.hasVideo && !this.streamInfo.hasScreen || (this.dataSubState.setState(he.AliRtcStateSubscribing), this.rtsManager.subscribeAddDataChannel(this.streamUrl).then((e) => { if (e) { this.dataChannelConnected(e), this.dataSubState.setState(he.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(he.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(he.AliRtcStateNoSubscribe), this.dc = void 0, this.streamInfo.updateRemoteTrackSubState({ data: !1 }); } } getRetryOptions() { var i, s, n, 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) || T.Audio), this.wantSubVideo && ((n = this.streamInfo) != null && n.hasVideo) && (this.defaultVideoStreamType === we.AliRtcVideoStreamTypeLow && ((c = this.streamInfo) != null && c.hasVideoSmall) ? (e.video = !0, e.vMsid = T.VideoSmall) : (o = this.streamInfo) != null && o.hasVideoLarge && (e.video = !0, e.vMsid = ((u = this.streamInfo.getVideoLargeInfo()) == null ? void 0 : u.msid) || T.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 n, c, o, u, h, p, d, f, m, l, S, v, x, b, E, _, y; const t = Date.now(), i = {}, s = {}; if (this.wantSubAudio && !this.isAudioSubscribing && ((n = this.streamInfo) != null && n.hasAudio) ? (i.audio = !0, i.aMsid = ((c = this.streamInfo.getAudioInfo()) == null ? void 0 : c.msid) || T.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) || T.Audio), this.wantSubVideo && ((h = this.streamInfo) != null && h.hasVideo) ? (this.defaultVideoStreamType === we.AliRtcVideoStreamTypeLow && !this.isVideoSmallSubscribing && ((p = this.streamInfo) != null && p.hasVideoSmall) ? (i.video = !0, i.vMsid = T.VideoSmall) : !this.isVideoLargeSubscribing && ((d = this.streamInfo) != null && d.hasVideoLarge) && !(this.defaultVideoStreamType === we.AliRtcVideoStreamTypeLow && this.isVideoSmallSubscribing) && (i.video = !0, i.vMsid = ((f = this.streamInfo.getVideoLargeInfo()) == null ? void 0 : f.msid) || T.VideoLarge), this.defaultVideoStreamType === we.AliRtcVideoStreamTypeLow && this.isVideoLargeSubscribing && this.isVideoSmallSubscribing && this.streamInfo.hasVideoSmall ? (s.video = !0, s.vMsid = T.VideoLarge) : this.defaultVideoStreamType === we.AliRtcVideoStreamTypeHigh && this.isVideoLargeSubscribing && this.isVideoSmallSubscribing && (s.video = !0, s.vMsid = T.VideoSmall)) : (!this.wantSubVideo || !((m = this.streamInfo) != null && m.hasVideo)) && this.isVideoSubscribing && (s.video = !0, s.vMsid = this.streamInfo.isVideoSmallSubscribed || this.streamInfo.isVideoSmallSubscribing ? T.VideoSmall : ((l = this.streamInfo.getVideoLargeInfo()) == null ? void 0 : l.msid) || T.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) || !((_ = this.streamInfo) != null && _.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 === de.Reconnect) { if (O.event(`[${Me.logName}]`, "reconnect, try to resume"), this.streamInfo.hasData && !i.data) { const A = this.rtsManager.getDatachannelByMsid({ url: this.streamUrl, msid: this.streamInfo.getDataInfo().msid || T.Data }); this.dataChannelConnected(A); } if (this.streamInfo.hasAudio && !i.audio) { const A = this.rtsManager.getStreamByMsid({ url: this.streamUrl, aMsid: this.streamInfo.getAudioInfo().msid || T.Audio }).audioTrack; A && (this.audioTrack = A, this.playAudio()); } if (this.streamInfo.hasVideo && !i.video) { const A = this.rtsManager.getStreamByMsid({ url: this.streamUrl, vMsid: this.streamInfo.isVideoSmallSubscribed || this.streamInfo.isVideoSmallSubscribing ? T.VideoSmall : ((y = this.streamInfo.getVideoLargeInfo()) == null ? void 0 : y.msid) || T.VideoLarge }); A && A.mediaStream && (this.stream = A, this.playAll(!1)); } if (this.streamInfo.hasScreen && !i.screen) { const A = this.rtsManager.getStreamByMsid({ url: this.streamUrl, sMsid: this.streamInfo.getScreenInfo().msid || T.Screen }); A && A.mediaStream && (this.screenStream = A, 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 n; const s = (n = t === se.AliRtcVideoTrackScreen ? this.screenStream : this.stream) == null ? void 0 : n.mediaStream; e.srcObject === s && this.play(e, t === se.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 (le.SystenUtil.isIos && parseInt(le.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 || yn(e, s.mediaStream, i).catch((n) => { n.code === 20 || n.name === "AbortError" || this.handleVideoPlayFailded( e, t ? se.AliRtcVideoTrackScreen : se.AliRtcVideoTrackCamera ); }); } stopPlayAll(e = !1) { e ? this.viewMap.screenViews.forEach((t) => { at(t); }) : this.viewMap.cameraViews.forEach((t) => { at(t); }); } /** * 是否开启声音 * @param {boolean} enable * @returns {void} */ toggleAudio(e = !0) { this.audioSubState.setEnabled(e), this.audioElement && (this.audioElement.muted = !e); } /** * 是否开启画面 * @param {boolean} enable * @returns {void} */ toggleVideo(e = !0) { this.videoSubState.setEnabled(e), this.stream && (e ? this.stream.enableVideo() : this.stream.disableVideo()); } /** * 是否开启画面 * @param {boolean} enable * @returns {void} */ 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, n, c, o; const e = []; if (this.isAudioSubscribing) { const u = yield this.rtsManager.getSubscribeAudioStats(this.streamUrl); u && e.push({ uid: this.uid, track: Xt.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) || T.VideoLarge ); u && t.push({ uid: this.uid, track: se.AliRtcVideoTrackCamera, streamType: we.AliRtcVideoStreamTypeHigh, stats: u }); } if ((n = this.streamInfo) != null && n.isVideoSmallSubscribed) { const u = yield this.rtsManager.getSubscribeVideoStats( this.streamUrl, ((c = this.streamInfo.getVideoSmallInfo()) == null ? void 0 : c.msid) || T.VideoSmall ); u && t.push({ uid: this.uid, track: se.AliRtcVideoTrackCamera, streamType: we.AliRtcVideoStreamTypeLow, stats: u }); } if (this.isScreenSubscribing) { const u = yield this.rtsManager.getSubscribeVideoStats( this.streamUrl, ((o = this.streamInfo.getScreenInfo()) == null ? void 0 : o.msid) || T.Screen ); u && t.push({ uid: this.uid, track: se.AliRtcVideoTrackScreen, stats: u }); } return { audio: e, video: t }; }); } /** * 开启音量检测 * @param {number} interval 时间间隔 */ 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 n = i === T.Audio; n ? 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 = Dt(h, ["_last"]); } (o == null ? void 0 : o.length) >= gc && this.reportSubscribeMonitor(i), c._last = u, c._codec = t.codec, n && (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); }); } }, /** * @ignore */ g(Me, "logName", "RemoteUser"), Me); Te([ D() ], Ce.prototype, "clear", 1); Te([ D() ], Ce.prototype, "updateRemoteUserDeviceStatus", 1); Te([ D() ], Ce.prototype, "updateRemoteTracks", 1); Te([ D(H) ], Ce.prototype, "subscribe", 1); Te([ D() ], Ce.prototype, "subscribeProxy", 1); Te([ D(H) ], Ce.prototype, "subscribeDeleteProxy", 1); Te([ D() ], Ce.prototype, "restore", 1); Te([ D(H) ], Ce.prototype, "resumeAudio", 1); Te([ D(H) ], Ce.prototype, "stopSubscribe", 1); Te([ D(H) ], Ce.prototype, "doStopSubscribe", 1); Te([ D() ], Ce.prototype, "clearStream", 1); Te([ D() ], Ce.prototype, "clearScreenStream", 1); Te([ D() ], Ce.prototype, "updateSubscribe", 1); Te([ D() ], Ce.prototype, "playAudio", 1); Te([ D() ], Ce.prototype, "stopPlayAudio", 1); Te([ D((r, a, e) => [ typeof r == "string" ? r : r == null ? void 0 : r.nodeType, a, e ]) ], Ce.prototype, "play", 1); Te([ D() ], Ce.prototype, "stopPlayAll", 1); let mc = Ce; var _t = /* @__PURE__ */ ((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))(_t || {}); class Sc extends De { constructor() { super(...arguments); g(this, "plugins", /* @__PURE__ */ new Map()); } add(e, t) { if (this.plugins.has(e.name)) throw new V(_t.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(_t.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 xc = Object.defineProperty, vc = Object.getOwnPropertyDescriptor, Ee = (r, a, e, t) => { for (var i = t > 1 ? void 0 : t ? vc(a, e) : a, s = r.length - 1, n; s >= 0; s--) (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i); return t && i && xc(a, e, i), i; }; const Pi = ([r]) => { const { remoteUser: a, options: e } = r; return [`user(${a.userId})`, e]; }, Ja = 5, Ga = 17, Xa = 5e3; var Ae; const Se = (Ae = class extends De { 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 = le.createClient({ singlePcConfig: { usePcReconnect: !0 } }), this.addRTSListener(); } addRTSListener() { this.rts.on("connectStatusChange", (e) => { var t, i, s, n; if (O.event(`[${Ae.logName}]`, "rts connectStatusChange to:", e.status), e.status === Mi.CONNECT_STATUS_DISCONNECTED) this.dcReject && this.dcReject(), this.setConnected(!1), this.slsReporter.reportWarning("rts disconnected"), this.emit("disconnected"); else if (e.status === Mi.CONNECT_STATUS_RECONNECTING) this._rtsReconnecting = !0; else if (e.status === Mi.CONNECT_STATUS_CONNECTED) { const c = (n = (s = (i = (t = this.rts.commonController) == null ? void 0 : t.peerCore) == null ? void 0 : i.getSignal()) == null ? void 0 : s.getDatachannelCore()) == null ? void 0 : n.readyState; O.event(`[${Ae.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(`[${Ae.logName}]`, "rts reconnectFinish"); try { this.emit("connected", !0, this._rtsPeerConnectionType); } catch (e) { O.error(`[${Ae.logName}]`, "emit connected error:", e); } }), this.rts.on("datachannelStatusChange", (e) => { O.event(`[${Ae.logName}]`, "rts datachannelStatusChange to:", e.status), e.status === vs.DATACHANNEL_STATUS_OPEN ? this.dcResolve && this.dcResolve(!0) : e.status === vs.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(`[${Ae.logName}]`, "rts onError event:", e); }), this.rts.on("reconnect", (e) => { O.event(`[${Ae.logName}]`, "rts reconnect event:", e); }); } /** * 更新鉴权信息,传入一个新的带鉴权的 URL,RTS 会去除鉴权信息做更新 * @param newUrlWithAuth */ 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 n = s.findIndex((o) => o.mimeType === "audio/red"), c = s.findIndex((o) => o.mimeType === "audio/opus"); if (n > -1 && c > -1 && n > c) { const o = s[c]; s[c] = s[n], s[n] = 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 = le.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 : {}, n = {}; return e.hasAudio && (n.aMsid = [i != null ? i : T.Audio]), e.hasScreen && (n.vMsid = [T.Screen]), e.hasVideo && (n.vMsid = [s != null ? s : t != null && t.isScreen ? T.Screen : T.VideoLarge]), n; } updatePublishingTracks(e) { e && (this._publishingTracks = e.map(({ msid: t, from: i, ssrc: s, codec: n, type: c, trackId: o }) => ({ msid: t, from: i, type: c, ssrc: `${s}`, codec: n != null ? n : "", trackId: o }))); } httpPublish(n, c) { return w(this, arguments, function* (e, t, i = !1, s = nt.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(`[${Ae.logName}]`, "publishStream is null"), { traceId: "", l1ip: o }; const m = this.getPubMsid(h, { vMsid: f }); this.encodedInsertableStreams && (m.encodedInsertableStreams = !0), m.answerSdpHook = (_) => { const y = /\d+\.\d+\.\d+\.\d+(?=\s+1106|\s+8000)/.exec(_); return y != null && y[0] && (o = y[0]), _; }, (E = (b = this.parameter) == null ? void 0 : b.net) != null && E.useTCP && (m.tcpOnly = !0), m.retryTimes = Ga, m.retryInterval = Xa, this._rtsPeerConnectionType = "publish"; let l = !h.hasVideo, S = f, v = ""; this.startConnect(); const x = Date.now(); try { v = yield this.rts.publish($a(e), h, m); } catch (_) { 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 === T.VideoLarge), h.hasVideo && f === T.VideoSmall, h.hasVideo && f === T.Screen, h.hasAudio, (_ == null ? void 0 : _.errorCode) || -1, this.pcTraceId, "", x ), V.fromRtsError(_); } O.event(`[${Ae.logName}]`, "rts publish success", v), this.slsReporter.reportPublish( i, e, t, h.hasVideo && (!f || f === T.VideoLarge), h.hasVideo && f === T.VideoSmall, h.hasVideo && f === T.Screen, h.hasAudio, 0, v, v, x ), this.slsReporter.reportConnectionLatencyEvent( Je.HANDLE_PUB_TASK, Xe.START, t, v, u ), this.slsReporter.reportConnectionLatencyEvent( Je.HANDLE_PUB_TASK, Xe.END, t, v, Date.now() ); try { const _ = Date.now(); return this._pcTraceId = v, this.setConnected(!0), this._publishingTracks = this.rts.getPublishTrackInfoList(), p && (yield this.publishAdd( e, p, t, { vMsid: T.VideoSmall }, i ), l = !1, S = T.VideoSmall), d && (yield this.publishAdd( e, d, t, { vMsid: T.Screen }, i ), l = !1, S = T.Screen), yield this.waitPublishSender(e, l, S), this.slsReporter.reportPublishFirstPacket( i, t, x, _, this._localJoinTime, l ? T.Audio : m.vMsid, v || "", v || "", s ), { traceId: v, l1ip: o }; } catch (_) { throw this.setConnected(!1), V.fromError(_); } }); } waitPublishSender(e, t = !1, i) { return w(this, null, function* () { const s = (n, c) => { let o = 0; const u = () => (t ? this.rts.getPublishAudioStats(e, i) : this.rts.getPublishVideoStats(e, i)).then((p) => !(p.bytesSent > 0) && o < n ? (o++, new Promise((f) => setTimeout(() => f(u()), c))) : Promise.resolve()); return u(); }; return Promise.race([Et(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, n = !1, c = !1, o = nt.MANUAL) { var l, S, v, x, b, E, _, y; yield this.dcConnectingPromise; const f = Date.now(), m = this.getPubMsid(t, s); try { const A = yield Wa( (R) => w(this, null, function* () { return R > 0 && O.event(`[${Ae.logName}]`, `publishAdd retry times: ${R}`), this.isConnected ? (yield this.dcConnectingPromise, this.rts.publishAdd([ J({ url: e, stream: t, updateSourceStream: !1 }, m) ])) : Promise.reject(new V(U.ERR_INNER, "rts not connected")); }), Ja, 0, (R) => (R == null ? void 0 : R.errorCode) === 15006 ); if (A) { const R = Date.now(), [M] = A; return this.slsReporter.reportPublish( !1, e, i, ((l = m.vMsid) == null ? void 0 : l[0]) === T.VideoLarge, ((S = m.vMsid) == null ? void 0 : S[0]) === T.VideoSmall, ((v = m.vMsid) == null ? void 0 : v[0]) === T.Screen, ((x = m.aMsid) == null ? void 0 : x[0]) === T.Audio, 0, this.pcTraceId, M.traceId || "", f ), this.updatePublishingTracks(M.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( n, i, f, R, this._localJoinTime, (t.hasVideo ? s == null ? void 0 : s.vMsid : s == null ? void 0 : s.aMsid) || "", this.pcTraceId, M.traceId || "", o ), M.traceId || ""; } } catch (A) { throw this.slsReporter.reportPublish( !1, e, i, ((b = m.vMsid) == null ? void 0 : b[0]) === T.VideoLarge, ((E = m.vMsid) == null ? void 0 : E[0]) === T.VideoSmall, ((_ = m.vMsid) == null ? void 0 : _[0]) === T.Screen, ((y = m.aMsid) == null ? void 0 : y[0]) === T.Audio, (A == null ? void 0 : A.errorCode) || -1, this.pcTraceId, "", f ), A != null && A.errorCode ? V.fromRtsError(A) : V.fromError(A); } 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 === T.Audio)) == null ? void 0 : h.msid, s = (d = (p = this.publishingTracks) == null ? void 0 : p.find(({ msid: v }) => v === T.VideoLarge)) == null ? void 0 : d.msid, n = (m = (f = this.publishingTracks) == null ? void 0 : f.find(({ msid: v }) => v === T.Screen)) == null ? void 0 : m.msid, c = []; t.screen && n ? c.push(n) : t.video && c.push(t.vMsid || s); const o = []; t.audio && i && o.push(i), O.event(Ae.logName, "publishDelete", { streamUrl: e, aMsid: o, vMsid: c }); try { const [v] = (yield this.rts.publishDeleteTracks([ { url: e, aMsid: o, vMsid: c } ])) || []; return O.event(Ae.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: n } = i != null ? i : {}; try { const u = yield this.rts.publishReplaceTracks([ { url: e, stream: t, vMsid: s, aMsid: n } ]), [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: T.Data, msid: T.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; }); } /** * 获取 sub/subAdd config * @param {ISubscribeConfig | ISubConfigItem} options * @returns {Omit} */ 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) || T.Audio]), i.video ? i.vMsid ? s.vMsid = [i.vMsid] : e != null && e.hasVideoLarge ? s.vMsid = [(e == null ? void 0 : e.getVideoLargeInfo().msid) || T.VideoLarge] : e != null && e.hasVideoSmall ? s.vMsid = [(e == null ? void 0 : e.getVideoSmallInfo().msid) || T.VideoSmall] : s.vMsid = [T.VideoLarge] : i.screen && (s.vMsid = [(e == null ? void 0 : e.getScreenInfo().msid) || T.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 n = this.getSubConfig(t.streamInfo, i); if (this.encodedInsertableStreams && (n.encodedInsertableStreams = !0), (o = (c = this.parameter) == null ? void 0 : c.net) != null && o.useTCP && (n.tcpOnly = !0), (h = (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 && (n.mediaTimeout = f); } n.retryTimes = Ga, n.retryInterval = Xa, this._rtsPeerConnectionType = "subscribe"; try { this.startConnect(); const f = yield this.rts.subscribe($a(s), n); 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 n, c, o, u; const { remoteUser: t, options: i } = e, s = ut(J({ 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 Wa( (p) => w(this, null, function* () { return yield this.dcConnectingPromise, p > 0 && O.event(`[${Ae.logName}]`, `subscribeAdd retry times: ${p}`), this.isConnected ? this.rts.subscribeAdd([s]) : Promise.reject(); }), Ja, 0, // 仅超时重试 (p) => (p == null ? void 0 : p.errorCode) === 15006 ))[0]; } catch (h) { if (((u = (o = (c = (n = h == null ? void 0 : h.extraInfo) == null ? void 0 : n.parsedData) == null ? void 0 : c.streams) == null ? void 0 : o[0]) == null ? void 0 : u.res_code) === 508) return this.emit("subscribeexceeds"), null; throw V.fromRtsError(h); } }); } subscribeDelete(e) { return w(this, null, function* () { var n, c, o, u; const { remoteUser: t, options: i } = e, s = ut(J({ 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 = (n = h == null ? void 0 : h.extraInfo) == null ? void 0 : n.parsedData) == null ? void 0 : c.streams) == null ? void 0 : o[0]) == null ? void 0 : u.res_code) === 404) return; throw V.fromRtsError(h); } }); } subscibeStop(e) { return w(this, null, function* () { var t, i, s, n; try { yield this.rts.subscribeStop([ { url: e } ]); } catch (c) { if (((n = (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 : n.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: T.Data, msid: T.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(n, c) { return w(this, arguments, function* (e, t, i = !1, s = nt.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: T.Audio }, i ), h = !0, p = T.Audio, yield Et(100)), f && (o = yield this.publishAdd( e, f, t, { vMsid: T.VideoLarge }, i ), h = !1, p = T.VideoLarge, yield Et(100)), m && (o = yield this.publishAdd( e, m, t, { vMsid: T.VideoSmall }, i ), h = !1, p = T.VideoSmall, yield Et(100)), l && (o = yield this.publishAdd( e, l, t, { isScreen: !0, vMsid: T.Screen }, i ), h = !1, p = T.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 n = []; e.audio && n.push(e.aMsid || T.Audio), e.video ? n.push(e.vMsid || T.VideoLarge) : e.screen && n.push(T.Screen), n.forEach((c) => { this.slsReporter.reportConnectionLatencyEvent( Je.HANDLE_SUB_TASK, Xe.START, t, c, i, 0, s ), this.slsReporter.reportConnectionLatencyEvent( Je.HANDLE_SUB_TASK, Xe.END, t, c, Date.now(), 0, s ); }); } subscribe(e, t, i, s, n) { 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 = T.VideoLarge, m = o.video || o.screen, l = o.audio; o.video && o.vMsid ? f = o.vMsid : o.screen && (f = T.Screen); let S = 0, v = 0, x = 0; const E = ((_, y) => { let A = 0; const R = () => { let M; return l && !S && (M = this.rts.getSubscribeAudioStats(u.streamUrl).then((C) => { if (C.packetsReceived > 0) S = Date.now(); else if (!m) return A < _ ? (A++, new Promise((I) => setTimeout(() => I(R()), y))) : !1; return !0; })), m && !x && (M = this.rts.getSubscribeVideoStats(u.streamUrl, f).then((C) => { if (C.packetsReceived > 0 && (v = Date.now()), C.framesDecoded > 0) x = Date.now(); else return A < _ ? (A++, new Promise((I) => setTimeout(() => I(R()), y))) : (O.event(`[${Ae.logName}]`, u.userId, "尝试获取首帧数据失败"), !1); return !0; })), Promise.resolve(M); }; return R(); })(40, 100); return E.then(() => { v && this.slsReporter.reportSubscribeFirstPacket( t === de.Resume, i, s, f, { fprt: v - p, ifsprtc: x ? x - p : 0, ajsub: t === de.Join ? 1 : 0, pctid: this.pcTraceId, subtid: (h == null ? void 0 : h.traceId) || "", sstc: d - p } ), x && this.slsReporter.reportSubscribeFirstFrame( t === de.Resume, i, s, f, { fvfrt: x - p, fp2fftc: x - v, ajsub: t === de.Join ? 1 : 0, tffrtc: t === de.Join ? x - this.localJoinTime : x - n, pctid: this.pcTraceId, subtid: (h == null ? void 0 : h.traceId) || "", fvfdtc: x - p } ), S && (this.slsReporter.reportConnectionLatencyEvent( Je.FIRST_REMOTE, Xe.DECODED, i, T.Audio, S ), this.slsReporter.reportSubscribeFirstPacket( t === de.Resume, i, s, T.Audio, { fprt: S - p, ifsprtc: S - p, ajsub: t === de.Join ? 1 : 0, pctid: this.pcTraceId, subtid: (h == null ? void 0 : h.traceId) || "", sstc: d - p } )); }), c && (yield Promise.race([E, Et(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: T.VideoLarge, data: t, repeatCount: i, payloadType: s }); }); } }, /** * @ignore */ g(Ae, "logName", "RtsManager"), Ae); Ee([ D(H) ], Se.prototype, "startConnect", 1); Ee([ D() ], Se.prototype, "updatePublishingTracks", 1); Ee([ D(H, H) ], Se.prototype, "httpPublish", 1); Ee([ D(H, H) ], Se.prototype, "waitPublishSender", 1); Ee([ D(([r, a, e]) => [r, JSON.stringify(e)], H) ], Se.prototype, "publishAdd", 1); Ee([ D(H, H) ], Se.prototype, "publishDelete", 1); Ee([ D(([r, a, e]) => [r, JSON.stringify(e)]) ], Se.prototype, "publishReplace", 1); Ee([ D(H) ], Se.prototype, "publishStop", 1); Ee([ D(H) ], Se.prototype, "publishAddDataChannel", 1); Ee([ D(H) ], Se.prototype, "publishStopDataChannel", 1); Ee([ D() ], Se.prototype, "unpublish", 1); Ee([ D(Pi, ({ traceId: r }) => r) ], Se.prototype, "httpSubscribe", 1); Ee([ D(Pi, ({ traceId: r }) => r) ], Se.prototype, "subscribeAdd", 1); Ee([ D(Pi) ], Se.prototype, "subscribeDelete", 1); Ee([ D(H) ], Se.prototype, "subscibeStop", 1); Ee([ D(H) ], Se.prototype, "subscribeAddDataChannel", 1); Ee([ D(H) ], Se.prototype, "subscribeStopDatachannel", 1); Ee([ D(H) ], Se.prototype, "publish", 1); Ee([ D(Pi) ], Se.prototype, "subscribe", 1); Ee([ D() ], Se.prototype, "sendSEI", 1); let bc = Se; class Nr { constructor(a = Hr) { g(this, "defaultProfile"); g(this, "profile"); g(this, "profileMap", /* @__PURE__ */ new Map()); g(this, "audioProfile"); g(this, "contentHint"); this.defaultProfile = J({}, a); } updateProfile(a, e) { this.profileMap.set(a, J(J(J({}, this.defaultProfile), this.profileMap.get(a) || {}), e || {})), this.profile = a; } get videoProfile() { return this.profile; } updateAudioProfile(a) { this.audioProfile = a; } setContentHint(a, e) { e && (this.contentHint = e), this.contentHint && a && (a.contentHint = this.contentHint); } /** * 更新源流 Constraints * 更新 PeerConnectiong Sender 相关配置 * @param stream */ setVideoProfile(a, 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 && a && // iOS 上如果 track 状态为 ended,applyConstraints 会无返回 a.readyState === "live" && // @ts-ignore a.applyConstraints) try { yield a.applyConstraints(i); } catch (s) { } if (e) { const s = J({}, i); i.maxSendFrameRate && (s.frameRate = i.maxSendFrameRate), e == null || e.VideoProfileMap.set(this.profile, s), yield e.setVideoProfile(this.profile); } } }); } } class Ya extends De { 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", []); // 管理 Profile 相关配置 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: n } = e; s && ((c = this.originVideoTrack) == null || c.removeEventListener("ended", this.onVideoTrackEnded)), n && ((o = this.originAudioTrack) == null || o.removeEventListener("ended", this.onAudioTrackEnded)), this.type === be.AliRtcSdkStreamTypeScreen ? this.stop() : (s && ((u = this.originVideoTrack) == null || u.stop()), n && ((h = this.originAudioTrack) == null || h.stop())), s && (this.originVideoTrack = s, (p = this.originVideoTrack) == null || p.addEventListener("ended", this.onVideoTrackEnded), this.videoSource = t || Jt.Camera, this.updateVideoTrack(s)), n && (this.originAudioTrack = n, (d = this.originAudioTrack) == null || d.addEventListener("ended", this.onAudioTrackEnded), this.audioSource = i || xi.Microphone, this.updateAudioTrack(n)); }); } get currentProfile() { var e; return (e = this.profileManager) == null ? void 0 : e.profile; } get currentVideoTrack() { return this._targetVideoTrack; } get currentDualVideoTrack() { return this._targetDualVideoTrack; } get publishVideoStream() { return this._publishVideoStream; } get publishDualVideoStream() { return this._publishDualVideoStream; } get currentAudioTrack() { return this._targetAudioTrack; } get publishAudioStream() { return this._publishAudioStream; } get previewStream() { return this._previewStream; } /** * 更新 VideoTrack * @param videoTrack */ updateVideoTrack(e, t = !1) { return w(this, null, function* () { (this._targetVideoTrack !== e || t) && (this._targetVideoTrack = e); }); } /** * 更新 DualVideoTrack * @param videoTrack * @param force */ updateDualVideoTrack(e, t = !1) { return w(this, null, function* () { (this._targetDualVideoTrack !== e || t) && (this._targetDualVideoTrack = e); }); } /** * 更新 AudioTrack * @param audioTrack */ updateAudioTrack(e, t = !1) { return w(this, null, function* () { (this._targetAudioTrack !== e || t) && (this._targetAudioTrack = e); }); } /** * 设置音频流静音 * @param muted */ 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; } /** * 设置视频流静音 * @param muted */ 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, n, 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 ei(this._targetVideoTrack), this.setVideoMuted(this._videoMuted), (s = this.profileManager) == null || s.setVideoProfile(this.originVideoTrack, this._publishVideoStream, !0), (n = this.profileManager) == null || n.setContentHint(this._targetVideoTrack), this.previewStream ? (c = this.previewStream) == null || c.mergeStream(this._publishVideoStream) : this._previewStream = yield ei(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 ei(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 ei(this._targetAudioTrack), this.setAudioMuted(this._audioMuted), this.previewStream ? (f = this.previewStream) == null || f.mergeStream(this._publishAudioStream) : this._previewStream = yield ei(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(); } /** * 应该在执行完 plugin 后调用 * @param profileName * @param profileValue */ updateVideoProfile(e, t, i = !1) { return w(this, null, function* () { this._profileManager || (this._profileManager = new Nr( this.type === be.AliRtcSdkStreamTypeScreen ? ja : Hr )), e && this._profileManager.updateProfile(e, t), yield this._profileManager.setVideoProfile( this.originVideoTrack, this._publishVideoStream, i || this.type === be.AliRtcSdkStreamTypeScreen ); }); } get videoProfile() { var e; return (e = this.profileManager) == null ? void 0 : e.videoProfile; } setVideoContentHint(e) { this._profileManager || (this._profileManager = new Nr( this.type === be.AliRtcSdkStreamTypeScreen ? ja : Hr )), this._profileManager.setContentHint(this.currentVideoTrack, e); } /** * 应该在执行完 plugin 后调用 * @param profileName */ updateAudioProfile(e) { return w(this, null, function* () { this._profileManager || (this._profileManager = new Nr()), this._profileManager.updateAudioProfile(e); }); } /** * 复制视频 profile 到指定 LocalStream * @param publishStream */ cloneVideoProfile(e) { return w(this, null, function* () { var t; yield (t = this.profileManager) == null ? void 0 : t.setVideoProfile(void 0, e); }); } // 添加 plugin addPlugin(e) { const t = this.plugins.findIndex((i) => i.zIndex > e.zIndex); t > -1 ? this.plugins.splice(t, 0, e) : this.plugins.push(e); } // 移除 plugin removePlugin(e) { const t = this.plugins.indexOf(e); return t > -1 ? (e.clear(this), this.plugins.splice(t, 1), !0) : !1; } } var Ec = Object.defineProperty, _c = Object.getOwnPropertyDescriptor, st = (r, a, e, t) => { for (var i = t > 1 ? void 0 : t ? _c(a, e) : a, s = r.length - 1, n; s >= 0; s--) (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i); return t && i && Ec(a, e, i), i; }, At; const Ze = (At = class extends De { // 设置是否发布屏幕流 constructor(e, t) { super(); g(this, "pluginManager"); g(this, "slsReporter"); // 当前正在推流的流,只有在使用 HTTP 推流的时候才有值,用于设置 peerconnection 的参数 g(this, "publishingCameraVideoStream"); g(this, "publishingScreenVideoStream"); g(this, "cameraStreamInfo", new Ya(be.AliRtcSdkStreamTypeCapture)); g(this, "screenStreamInfo", new Ya(be.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(`[${At.logName}]`, "plugin added", s.name), !s.isSupported("6.14.6")) { console.warn(`${s.name} is not supported!!!`), s.emit("unsupported"); return; } try { yield s.init(); } catch (n) { s.emit("error", V.fromError(n, _t.AliRtcPluginErrorInitError)); } s.streamType === be.AliRtcSdkStreamTypeCapture && (this.cameraStreamInfo.addPlugin(s), yield this.cameraStreamInfo.process(this.streamInfos)), s.streamType === be.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"); }); } // 设置有效的 camera deviceId setAvailableCameraDeviceId() { return w(this, null, function* () { var e, t, i, s; if ((e = this.cameraStreamInfo.cameraVideoConstraints) != null && e.deviceId) { let n = (t = this.cameraStreamInfo.cameraVideoConstraints) == null ? void 0 : t.deviceId; const c = yield le.getCameraList(); c.find((o) => o.deviceId === n) || (n = (s = (i = c.find((o) => !!o.deviceId)) == null ? void 0 : i.deviceId) != null ? s : ""), this.cameraStreamInfo.cameraVideoConstraints.deviceId = n; } }); } // 设置有效的 microphone deviceId setAvailableMicrophoneDeviceId() { return w(this, null, function* () { var e, t, i, s; if ((e = this.cameraStreamInfo.micAudioConstraints) != null && e.deviceId) { let n = (t = this.cameraStreamInfo.micAudioConstraints) == null ? void 0 : t.deviceId; const c = yield le.getMicList(); c.find((o) => o.deviceId === n) || (n = (s = (i = c.find((o) => !!o.deviceId)) == null ? void 0 : i.deviceId) != null ? s : ""), this.cameraStreamInfo.micAudioConstraints.deviceId = n; } }); } createLocalStream(e) { return w(this, null, function* () { var p; const { screen: t, mediaStream: i, videoProfile: s, screenProfile: n } = e; let { video: c, audio: o } = e; const u = rc(e); let h; if (u) { i || (c === !0 && this.cameraStreamInfo.cameraVideoConstraints ? (yield this.setAvailableCameraDeviceId(), c = J({}, this.cameraStreamInfo.cameraVideoConstraints)) : typeof c == "object" && (yield this.setAvailableCameraDeviceId(), c = J(J({}, c), this.cameraStreamInfo.cameraVideoConstraints)), o === void 0 && this.audioCaptureDisabled ? o = !1 : o && (o === !0 && this.cameraStreamInfo.micAudioConstraints ? (yield this.setAvailableMicrophoneDeviceId(), o = J({}, this.cameraStreamInfo.micAudioConstraints)) : typeof o == "object" && (yield this.setAvailableMicrophoneDeviceId(), o = J(J({}, o), this.cameraStreamInfo.micAudioConstraints)), this._audioCaptureDisabled = !1)); const d = Date.now(); try { h = yield le.createStream({ audio: o, video: c, screen: t, custom: !!i, mediaStream: i, skipProfile: !0 }), O.info(`[${At.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, Jt.Screen, xi.Screen), yield this.setScreenProfile(n || An), this.setScreenContentHint(), this.publishingScreenVideoStream = void 0; else if (yield this.cameraStreamInfo.updateSource(h, Jt.Camera, xi.Microphone), h.hasVideo && (yield this.setVideoProfile(s || _n), this.setVideoContentHint(), this.publishingCameraVideoStream = void 0), h.hasAudio && typeof o == "boolean") { const f = this.cameraStreamInfo.audioProfile; f && (yield h.setAudioProfile(f)); } } return le.SystenUtil.isIos && le.SystenUtil.compareVersion("15.1") && !le.SystenUtil.compareVersion("15.2") && (yield Et(1e3)), yield this.updateStreams(), h; }); } stopLocalStream(e) { return w(this, null, function* () { const { screen: t, video: i, audio: s } = e != null ? e : {}; let n = !1; i && this.cameraStreamInfo.originVideoTrack && (n = !0, this.cameraStreamInfo.stopVideo(), this.publishingCameraVideoStream = void 0), s && this.cameraStreamInfo.originAudioTrack && (n = !0, this.cameraStreamInfo.stopAudio()), t && this.screenStreamInfo.originVideoTrack && (n = !0, this.screenStreamInfo.stop(), this.publishingScreenVideoStream = void 0, this.slsReporter.reportScreenStop(null)), n && (yield this.updateStreams()); }); } get publishStreams() { const { publishLocalVideoStreamEnabled: e, publishLocalAudioStreamEnabled: t, publishLocalScreenStreamEnabled: i } = this; return { video: e ? this.cameraStreamInfo.publishVideoStream : void 0, videoSmall: e ? this.cameraStreamInfo.publishDualVideoStream : void 0, audio: t ? this.cameraStreamInfo.publishAudioStream : void 0, screen: i ? this.screenStreamInfo.publishVideoStream : void 0 }; } createHTTPPublishStream() { return w(this, null, function* () { var o, u, h, p; let e, t = !1, i, s, n; const c = this.publishStreams; try { if (!c.audio && !c.video && !c.videoSmall && !c.screen) throw O.error(`[${At.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, n = c.screen) : (h = c.screen) != null && h.videoTrack && (i = T.Screen, d.addTrack((p = c.screen) == null ? void 0 : p.videoTrack), t = !0), e = yield Rn(d), t ? (this.screenStreamInfo.cloneVideoProfile(e), this.publishingScreenVideoStream = e) : (this.cameraStreamInfo.cloneVideoProfile(e), this.publishingCameraVideoStream = e); } catch (d) { } return { publishStream: e, videoSmallStream: s, screenStream: n, vMsid: i }; }); } stop() { this.cameraStreamInfo.stop(), this.screenStreamInfo.stop(), this.updateStreams(); } setVideoProfile(e, t, i = !1) { return w(this, null, function* () { yield this.cameraStreamInfo.updateVideoProfile(e, t, i), this.publishingCameraVideoStream && this.cameraStreamInfo.cloneVideoProfile(this.publishingCameraVideoStream); }); } setVideoContentHint(e) { this.cameraStreamInfo.setVideoContentHint(e); } setAudioProfile(e) { return w(this, null, function* () { var t; yield this.cameraStreamInfo.updateAudioProfile(e), yield (t = this.publishingCameraVideoStream) == null ? void 0 : t.setAudioProfile(e); }); } setScreenProfile(e, t) { return w(this, null, function* () { yield this.screenStreamInfo.updateVideoProfile(e, t), this.publishingScreenVideoStream && this.screenStreamInfo.cloneVideoProfile(this.publishingScreenVideoStream); }); } setScreenContentHint(e) { this.screenStreamInfo.setVideoContentHint(e); } setCameraVideoConstraints(e) { var t; this.cameraStreamInfo.cameraVideoConstraints = J(J({}, (t = this.cameraStreamInfo.cameraVideoConstraints) != null ? t : {}), e); } setMicAudioConstraints(e) { var t; this.cameraStreamInfo.micAudioConstraints = J(J({}, (t = this.cameraStreamInfo.micAudioConstraints) != null ? t : {}), e); } }, /** * @ignore */ g(At, "logName", "LocalStreamManager"), At); st([ D(([r]) => { const { audio: a, video: e, screen: t, custom: i, skipProfile: s, videoProfile: n, screenProfile: c } = r; return [ { audio: a, video: e, screen: t, custom: i, skipProfile: s, videoProfile: n, screenProfile: c } ]; }) ], Ze.prototype, "createLocalStream", 1); st([ D(H) ], Ze.prototype, "stopLocalStream", 1); st([ D() ], Ze.prototype, "createHTTPPublishStream", 1); st([ D() ], Ze.prototype, "stop", 1); st([ D(H) ], Ze.prototype, "setVideoProfile", 1); st([ D(H) ], Ze.prototype, "setVideoContentHint", 1); st([ D(H) ], Ze.prototype, "setAudioProfile", 1); st([ D(H) ], Ze.prototype, "setScreenProfile", 1); st([ D(H) ], Ze.prototype, "setScreenContentHint", 1); st([ D(H) ], Ze.prototype, "setCameraVideoConstraints", 1); st([ D(H) ], Ze.prototype, "setMicAudioConstraints", 1); let Ac = Ze; class yc extends Gt { constructor() { super("AliRtcScreenStandardize", be.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 n = this.canvas.getContext("2d"); n && n.clearRect(0, 0, i, s); } this.lastWidth = e, this.lastHeight = t; } shouldUpdate(e) { return this.hasScreenTrack !== (!!e.originVideoTrack && e.videoSource === Jt.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 n = (c = this.canvas) == null ? void 0 : c.getContext("2d"); if (this.canvas && n) { n.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 !== Jt.Screen) { this.clear(e), this.hasScreenTrack = !1; return; } const t = new MediaStreamTrackProcessor({ track: e.originVideoTrack }), i = new MediaStreamTrackGenerator({ kind: "video" }), s = new MediaStream([i]), n = this, c = new TransformStream({ transform(p, d) { return w(this, null, function* () { const f = yield n.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 Cc extends Gt { constructor() { super("blankAudio", be.AliRtcSdkStreamTypeCapture, Ri.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((n) => n.originVideoTrack || n.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 In { constructor(a) { g(this, "name", "COMMON"); this.name = a || this.name; } info(...a) { } warn(...a) { } print(a, ...e) { const t = a.toLowerCase(); t && console[t](`[${a}][${this.name}]`, ...e); } } g(In, "LEVEL", 0); class Rc { constructor() { g(this, "logger", new In("AudioMixer")); g(this, "audioContext", new AudioContext()); g(this, "audioDestination", this.audioContext.createMediaStreamDestination()); g(this, "audioTrack", X0(this.audioDestination.stream)); g(this, "sourceNodeMap", {}); } get sourceNodeList() { return Object.values(this.sourceNodeMap).map((a) => a.sourceNode).filter((a) => !!a); } get gainNodeList() { return Object.values(this.sourceNodeMap).map((a) => a.gainNode).filter((a) => !!a); } get sourceCount() { return this.sourceNodeList.length; } resume() { var a; return (a = this.audioContext) == null ? void 0 : a.resume(); } addTrack(a) { this.connectTrack(a); } hasTrack(a) { return !!this.sourceNodeMap[a]; } removeTrack(a) { const { sourceNode: e, gainNode: t } = this.sourceNodeMap[a] || {}; t == null || t.disconnect(), e == null || e.disconnect(), delete this.sourceNodeMap[a], e ? this.logger.info("SourceNode disconnected. Active source node:", this.sourceNodeList.length) : this.logger.warn(`SourceNode ${a} does not exit. Active source node: ${this.sourceNodeList.length}`); } getAudioTrack() { return this.audioTrack; } setVolume(a, e) { const { gainNode: t } = this.sourceNodeMap[e] || {}; t ? (this.logger.info(`Setting node(${e}) volume to ${this.scale(a)}`), t.gain.value = this.scale(a)) : this.logger.warn(`GainNode ${e} does not exit.`); } reset() { this.disconnectSourceNode(), this.sourceNodeMap = {}; } dispose() { var a; this.reset(), (a = this.audioTrack) == null || a.stop(), this.audioDestination.disconnect(), this.audioContext.close(); } /** * sourceNode -> gainNode -> destionationNode */ connectTrack(a) { if (!this.audioContext) return this.logger.warn("AudioContext not initialized"); let e = new MediaStream(); e.addTrack(a); const t = this.audioContext.createMediaStreamSource(e), i = this.audioContext.createGain(); i.gain.value = 1, t.connect(i), i.connect(this.audioDestination), this.sourceNodeMap[a.id] = { track: a, sourceNode: t, gainNode: i }, this.logger.info("New sourceNode connected. Active source node:", this.sourceNodeList.length); } disconnectSourceNode() { this.sourceNodeList.forEach((a) => a.disconnect()), this.gainNodeList.forEach((a) => a.disconnect()); } /** * volume [0-100] * scale to [0-1] */ scale(a) { return a / 100; } } const Ic = 4; class wc extends Gt { constructor() { super("audioMixer", be.AliRtcSdkStreamTypeCapture, Ri.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 n, c; if (e.type !== be.AliRtcSdkStreamTypeCapture) return !1; const i = t.find( (o) => o.type === be.AliRtcSdkStreamTypeCapture ), s = t.find( (o) => o.type === be.AliRtcSdkStreamTypeScreen ); return !(this.primaryAudioTrackId === ((n = i == null ? void 0 : i.currentAudioTrack) == null ? void 0 : n.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 === be.AliRtcSdkStreamTypeScreen ), s = e.currentAudioTrack, n = i == null ? void 0 : i.currentAudioTrack; if (!n && 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 Rc()), 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 && (n == null ? void 0 : n.id) !== this.screenAudioTrackId && ((o = this.audioMixer) == null || o.removeTrack(this.screenAudioTrackId)), n && !this.audioMixer.hasTrack(n == null ? void 0 : n.id) && this.audioMixer.addTrack(n), this.screenAudioTrackId = n == null ? void 0 : n.id, this.updateVolume(), e.updateAudioTrack(this.audioMixer.getAudioTrack()); }); } isValidVolume(e) { return e !== void 0 && e >= 0 && e <= Ic; } 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 os { constructor(a, 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 = a, this.originVideo = document.createElement("video"), this.originVideo.muted = !0, this.originVideo.autoplay = !0, this.originVideo.controls = !1, this.targetCanvas = document.createElement("canvas"), this.targetCanvas.width = this.targetWidth, this.targetCanvas.height = this.targetHeight; } updateOptions(a) { this.targetWidth = a.width, this.targetHeight = a.height, this.targetFrameRate = a.frameRate, this.targetCanvas.width = this.targetWidth, this.targetCanvas.height = this.targetHeight, this.resultTrack && this.resultTrack.applyConstraints({ frameRate: this.targetFrameRate }); } dispose() { } getVideoTrack() { return this.resultTrack || (this.resultTrack = this.targetCanvas.captureStream().getVideoTracks()[0], this.resultTrack.applyConstraints({ frameRate: this.targetFrameRate })), this.resultTrack; } cancelAnimation() { this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = void 0); } /** * 当原始比例跟用户设置的目标分辨率不一致时需要裁切到目标分辨率 * 效果类似:object-fit: cover */ getPositionAndSize(a, e, t, i) { const s = e / a, n = i / t; let c = t, o = i, u = 0, h = 0; return n > s ? (c = Math.round(o / s), u = Math.round((t - c) / 2)) : n < s && (o = Math.round(c * s), h = Math.round((i - o) / 2)), { x: u, y: h, width: c, height: o }; } } class Dc extends os { 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 Tc = ` attribute vec2 a_position; attribute vec2 a_texCoord; uniform vec2 u_resolution; varying vec2 v_texCoord; void main() { // convert the rectangle from pixels to 0.0 to 1.0 vec2 zeroToOne = a_position / u_resolution; // convert from 0->1 to 0->2 vec2 zeroToTwo = zeroToOne * 2.0; // convert from 0->2 to -1->+1 (clipspace) vec2 clipSpace = zeroToTwo - 1.0; gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); v_texCoord = a_texCoord; } `, Pc = ` precision mediump float; varying lowp vec2 v_texCoord; uniform sampler2D u_texture; void main() { gl_FragColor = texture2D(u_texture, v_texCoord); } `; function kc() { let r; try { const a = document.createElement("canvas"); a.width = 1, a.height = 1; const e = { alpha: !1, depth: !1, stencil: !1, antialias: !1, preferLowPowerToHighPerformance: !0 }; r = a.getContext("webgl2", e); } catch (a) { return !1; } return !!r; } function Bc(r) { const a = r.createTexture(); return r.bindTexture(r.TEXTURE_2D, a), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_S, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_T, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_MIN_FILTER, r.LINEAR), a; } function Za(r, a, e) { const t = r.createShader(a); if (!t) { console.error("create shader failed"); return; } return r.shaderSource(t, e), r.compileShader(t), r.getShaderParameter(t, r.COMPILE_STATUS) ? t : (console.error(`An error occurred compiling the shaders: ${r.getShaderInfoLog(t)}`), r.deleteShader(t), null); } function Nc(r, a, e) { const t = Za(r, r.VERTEX_SHADER, a), i = Za(r, r.FRAGMENT_SHADER, e), s = r.createProgram(); if (!(!s || !t || !i)) return r.attachShader(s, t), r.attachShader(s, i), r.linkProgram(s), r.getProgramParameter(s, r.LINK_STATUS) ? s : (console.error(`Unable to initialize the shader program: ${r.getProgramInfoLog(s)}`), null); } function Mc(r, a, e, t = 0, i = 0) { const s = r.createBuffer(); r.bindBuffer(r.ARRAY_BUFFER, s); const n = t, c = i, o = a + t, u = e + i, h = [n, c, o, c, n, u, n, u, o, c, o, u]; return r.bufferData(r.ARRAY_BUFFER, new Float32Array(h), r.STATIC_DRAW), s; } class Qa extends os { constructor(e, t) { super(e, t); g(this, "targetCtx"); g(this, "targetTexture"); g(this, "locationMap"); this.targetCtx = this.targetCanvas.getContext("webgl2"), this.locationMap = {}, this.startRender = this.startRender.bind(this), this.stopRender = this.startRender.bind(this), this.updateBuffer = this.updateBuffer.bind(this), this.initGL(), this.initStream(e); } static isSupport() { return kc(); } initGL() { const e = this.targetCtx; if (!e) return; this.targetTexture = Bc(e); const t = Nc(e, Tc, Pc); if (!t) { console.log("[ScalerWebGL] program is null."); return; } e.useProgram(t); const i = e.getAttribLocation(t, "a_position"), s = e.getAttribLocation(t, "a_texCoord"), n = e.getUniformLocation(t, "u_resolution"); if (!n) { console.log("[ScalerWebGL] resolutionLocation is null."); return; } const c = e.getUniformLocation(t, "u_texture"); if (!c) { console.log("[ScalerWebGL] textureLocation is null."); return; } this.locationMap = { program: t, positionLocation: i, texCoordLocation: s, resolutionLocation: n, textureLocation: c }, this.updateBuffer(); } initStream(e) { const t = new MediaStream(); t.addTrack(e), this.originVideo.srcObject = t, this.originVideo.play(), this.originVideo.addEventListener("canplay", this.startRender), this.originVideo.addEventListener("pause", this.stopRender), this.originVideo.addEventListener("ended", this.stopRender), this.originVideo.addEventListener("resize", this.updateBuffer); } startRender() { this.cancelAnimation(); const e = () => { this.targetCtx && (this.renderTexture(), !this.originVideo.paused && !this.originVideo.ended && (this.animationFrameId = requestAnimationFrame(e))); }; e(); } updateBuffer() { const e = this.targetCtx, t = this.locationMap.positionLocation, i = this.locationMap.texCoordLocation, s = this.locationMap.resolutionLocation; if (!e || !this.originVideo.videoWidth || !this.originVideo.videoHeight) return; const n = this.getPositionAndSize( this.originVideo.videoWidth, this.originVideo.videoHeight, this.targetWidth, this.targetHeight ), c = Mc(e, n.width, n.height, n.x, n.y); e.enableVertexAttribArray(t), e.bindBuffer(e.ARRAY_BUFFER, c), e.vertexAttribPointer(t, 2, e.FLOAT, !1, 0, 0), e.enableVertexAttribArray(i); const o = e.createBuffer(); e.bindBuffer(e.ARRAY_BUFFER, o), e.bufferData( e.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]), e.STATIC_DRAW ), e.bindBuffer(e.ARRAY_BUFFER, o), e.vertexAttribPointer(i, 2, e.FLOAT, !1, 0, 0), e.uniform2f(s, this.targetWidth, this.targetHeight); } renderTexture() { const e = this.targetTexture, t = this.targetCtx, i = this.locationMap.textureLocation; !e || !t || (t.bindTexture(t.TEXTURE_2D, e), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, this.originVideo), t.useProgram(this.locationMap.program), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, e), t.uniform1i(i, 0), t.viewport(0, 0, t.canvas.width, t.canvas.height), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), t.drawArrays(t.TRIANGLES, 0, 6)); } stopRender() { this.cancelAnimation(); } updateOptions(e) { super.updateOptions(e), this.updateBuffer(); } dispose() { this.stopRender(), this.originVideo.removeEventListener("play", this.startRender), this.originVideo.removeEventListener("pause", this.stopRender), this.originVideo.removeEventListener("ended", this.stopRender), this.originVideo.removeEventListener("resize", this.updateBuffer), this.originVideo.pause(), this.originVideo.srcObject = null; } } const Lc = ` var targetOptions={ width: 320, height: 180, ratio: 0.5625, interval: 66, }; var timer; var reader; var writer; function updateOptions(data) { targetOptions.width=data.width||320; targetOptions.height=data.height||180; targetOptions.ratio=targetOptions.height/targetOptions.width; targetOptions.interval=Math.floor(1000/data.frameRate)||66; } function postError(err, defaultMsg) { var msg=err ? err.message : ''; postMessage({ type: 'error', messge: msg || defaultMsg }); } function startLoop(data) { if(timer){ clearInterval(timer); } timer=setInterval(() => { reader.read().then(function (ret){ var videoFrame=ret.value; if(ret.done || !videoFrame) { return; } var vratio=videoFrame.displayHeight/videoFrame.displayWidth; var vw=videoFrame.displayWidth; var vh=videoFrame.displayHeight; var vx=0; var vy=0; if(targetOptions.ratio>vratio){ vw=Math.round(vh/targetOptions.ratio); vx=Math.round((videoFrame.displayWidth-vw)/2); }else if(targetOptions.ratio { for (var i = t > 1 ? void 0 : t ? Oc(a, e) : a, s = r.length - 1, n; s >= 0; s--) (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i); return t && i && Vc(a, e, i), i; }; class Pe extends De { 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", we.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 Sc(), this.localStreamManager = new Ac(this.pluginManager, this.slsReporter), this.rtsManager = new bc(this.localStreamManager, this.slsReporter, this.parameter), this.self = new tc({ rtsManager: this.rtsManager, localStreamManager: this.localStreamManager, slsReporter: this.slsReporter, signalingManager: this.signalingManager, pluginManager: this.pluginManager, audioVolumeIndicationInterval: this.audioVolumeIndicationInterval, parameter: this.parameter }), this.audioMixerPlugin = new wc(), this.pluginManager.add(this.audioMixerPlugin), this.dualVideoPlugin = new Fc("dualVideoPlugin"), k0() && this.pluginManager.add(new yc()); } addSignalingManagerListener() { this.signalingManager.on("onNotifyPublish", (e) => { e.forEach((t) => { var i; (i = t == null ? void 0 : t.tracks) == null || i.forEach((s) => { var n; if (s.msid === T.Audio && s.userdata) try { const c = JSON.parse(s.userdata); c.agent_instance && ((n = this.slsReporter) == null || n.setCustomFields({ ageniid: c.agent_instance })); } catch (c) { console.error("Failed to parse userdata:", c); } }); }), this.slsReporter.reportConnectionLatencyEvent(Je.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(de.User); }); } isWantSubVideo() { return this.wantSubVideo; } setWantSubVideo(e) { this.wantSubVideo = e, this.remoteUsers.forEach((t) => { t.setWantSubVideo(e), t.updateSubscribe(de.User); }); } isWantSubScreen() { return this.wantSubScreen; } setWantSubScreen(e) { this.wantSubScreen = e, this.remoteUsers.forEach((t) => { t.setWantSubScreen(e), t.updateSubscribe(de.User); }); } setRemoteDefaultVideoStreamType(e) { this.defaultStreamType = e, this.remoteUsers.forEach((t) => { t.setRemoteDefaultVideoStreamType(e); }); } setRemoteUserVideoStreamType(e, t) { var i; (i = this.getRemoteUser(e)) == null || i.setRemoteDefaultVideoStreamType(t); } setAudioMuted(e) { this.audioMuted = e, this.remoteUsers.forEach((t) => { t.setAudioMuted(e); }); } // 放置到这里是为了保证单个 view 只被一个地方引用 setLocalViewConfig(e, t) { var s; if (!e) return (s = this.publisher) == null ? void 0 : s.setViewConfig(null, t); const i = jr(e); i.length !== 0 && i.forEach((n) => { var c, o; (c = this.publisher) == null || c.resetElement(n), Object.values(this.usersViewMap).forEach(({ cameraViews: u = [], screenViews: h = [] }) => { u.includes(n) && u.splice(u.indexOf(n), 1), h.includes(n) && h.splice(h.indexOf(n), 1); }), (o = this.publisher) == null || o.setViewConfig(i, t); }); } // 放置到这里是为了保证单个 view 只被一个地方引用 setRemoteViewConfig(e, t, i) { var n, c; if (!t) return (n = this.userMap[e]) == null ? void 0 : n.setViewConfig(null, i); const s = jr(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: n } = t; return i || s || n; }); } /** * 处理远端用户推流状态变化 * @param {string} userId * @param {string} displayname * @param {string} callid * @param {string} pullStreamUrl * @param {TrackInfo[]} tracks * @returns {void} */ onRemotePublishStateChange(e) { var d; const { userid: t, callid: i, subscribe: s, pubid: n = "", 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, n, c), u.updateSubscribe(de.Publish), (h !== u.streamInfo.audioTrackInfo || p !== u.streamInfo.videoTrackInfo) && this.emit( "remoteTrackAvailableChange", t, u.streamInfo.audioTrackInfo, u.streamInfo.videoTrackInfo ); } /** 定期更新所有人的推拉流地址,便于重连 * @param pushStreamUrl 已有的推流地址,根据地址中的过期时间来设置定时器 * @private */ setTimeoutToUpdateAllStreamUrls(e) { var s; if (!e) return; let t = 59 * 60 * 1e3; const i = (s = Z0(e)) == null ? void 0 : s.timeoutTs; i && (t = i - Date.now() - 60 * 1e3), this.refreshUrlTimer = window.setTimeout(() => w(this, null, function* () { var c; const n = yield this.signalingManager.refreshUrl({ pushstreamurl: this.self.url, users: this.remoteUsers.map((o) => ({ userid: o.userId, subscribe: { pullstreamurl: o.streamUrl } })) }); n.pushstreamurl && (this.self.url = n.pushstreamurl), (c = n.users) == null || c.forEach((o) => { var h; const u = this.getRemoteUser(o.userid); u && ((h = o.subscribe) != null && h.pullstreamurl) && (u.streamUrl = o.subscribe.pullstreamurl); }), this.setTimeoutToUpdateAllStreamUrls(n.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 n = this.addUser(s, i.displayname, de.InRoom), { callid: c, subscribe: o, tracks: u } = i; n.updateRemoteTracks(c, (o == null ? void 0 : o.pullstreamurl) || "", "", u), this.emit( "remoteTrackAvailableChange", s, n.streamInfo.audioTrackInfo, n.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: n } = yield this.publisher.getStats(); i && i.length > 0 && this.emit("rtcLocalAudioStats", i), s && s.length > 0 && this.emit("rtcLocalVideoStats", s), n && this.emit("rtcStats", n); } const e = [], t = []; for (const i of this.remoteUsers) { const { audio: s, video: n } = yield i.getStats(); s && s.forEach((c) => { e.push(c); }), n && n.forEach((c) => { t.push(c); }); } e.length > 0 && this.emit("rtcRemoteAudioStats", e), t.length > 0 && this.emit("rtcRemoteVideoStats", t); }), 2e3); } stopStatsMonitor() { this.statsMonitorId && clearInterval(this.statsMonitorId); } addUser(e, t, i) { return this.userMap[e] || (this.userMap[e] = this.executeAddUser(e, t, i)), this.userMap[e]; } /** * 执行添加远端用户 * @param {string} userId * @param {string} displayName * @returns {RemoteUser} */ executeAddUser(e, t, i) { const s = new mc({ 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(Le.Remote, this.onRemoteDeviceStatusChange.bind(this)), s.on(oe.PullStreamStats, this.onRemoteStatReport.bind(this)), s.on(oe.RtsSubscribeExceeds, this.onSubscribeExceeds.bind(this)), s.on("audioSubscribeStateChanged", (n, c, o, u) => { this.emit("audioSubscribeStateChanged", n, c, o, u, this.channel || ""); }), s.on("videoSubscribeStateChanged", (n, c, o, u) => { this.emit("videoSubscribeStateChanged", n, c, o, u, this.channel || ""); }), s.on("screenSubscribeStateChanged", (n, c, o, u) => { this.emit("screenSubscribeStateChanged", n, c, o, u, this.channel || ""); }), s.on("dataSubscribeStateChanged", (n, c, o, u) => { this.emit("dataSubscribeStateChanged", n, c, o, u, this.channel || ""); }), s.on("remoteAudioAutoPlayFail", (n) => { this.emit("remoteAudioAutoPlayFail", n); }), s.on("remoteVideoAutoPlayFail", (n, c) => { this.emit("remoteVideoAutoPlayFail", n, c); }), s.on("remoteAudioPlayError", (n, c) => { this.emit("remoteAudioPlayError", n, c); }), s.on("remoteVideoPlayError", (n, c) => { this.emit("remoteVideoPlayError", n, c); }), s.on("remoteSubscribeError", (n) => { this.emit("remoteSubscribeError", n, s.userId); }), s.on("occurError", (n) => { this.emit("occurError", n, s.userId); }), s.on("remoteDataChannelMessage", (n, c) => { this.emit("remoteDataChannelMessage", n, 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; } /** * 远端用户设备状态变化 * @param {DeviceStatusChangeType} event * @param {string} userId */ onRemoteDeviceStatusChange(e, t) { e === oe.MuteAudio ? this.emit("userAudioMuted", t, !0) : e === oe.UnmuteAudio ? this.emit("userAudioMuted", t, !1) : e === oe.MuteVideo ? this.emit("userVideoMuted", t, !0) : e === oe.UnmuteVideo ? this.emit("userVideoMuted", t, !1) : e === oe.MuteScreen ? this.emit("userScreenMuted", t, !0) : e === oe.UnmuteScreen && this.emit("userScreenMuted", t, !1); } /** * 远端流数据采集上报 * @param {any} stat */ onRemoteStatReport(e, t, i) { this.emit(oe.PullStreamStats, e, t, i); } /** * rts 单 PC 订阅超限 */ onSubscribeExceeds(e, t) { this.emit(oe.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, de.Resume))); }); const n = Object.keys(this.userMap), c = []; return n.forEach((o) => { s[o] || c.push({ userid: o, reason: "", leavecode: ss.AliRtcUserOfflineQuit }); }), this.userMap = s, { joinList: t, leaveList: c, presentList: i }; } /** * 根据 userId 获取 RemoteUser * @param {string} userId * @returns {RemoteUser | undefined} */ getRemoteUser(e) { return this.userMap[e]; } /** * 更新远端用户设备信息 * @param {RemoteUserStatus} user * @returns {boolean} true: 用户状态改变 false: 用户状态没有改变 */ 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(de.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(de.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(de.User) : i.stopSubscribe({ screen: !0 }); } stopIndication() { this.indicationTimer && window.clearInterval(this.indicationTimer); } startIndication(e) { this.stopIndication(), this.indicationTimer = window.setInterval(() => { const t = this.remoteUsers.map((i) => ({ userId: i.userId, volume: i.getAudioLevel() || 0 })); t.unshift({ userId: "", // 空字符串代表是当前用户 volume: this.self.getAudioLevel() || 0 }), this.emit("audioVolume", t); }, e); } setEnableDualVideoStream(e, t) { if (!this.dualVideoPlugin) return; t && this.dualVideoPlugin.setOptions(t); const i = this.pluginManager.has(this.dualVideoPlugin.name); e ? !i && this.pluginManager.add(this.dualVideoPlugin) : i && this.pluginManager.remove(this.dualVideoPlugin.name); } setAudioVolume(e) { var t; (t = this.audioMixerPlugin) == null || t.setOptions(e); } enableAudioVolumeIndication(e) { this.audioVolumeIndicationInterval !== e && (this.audioVolumeIndicationInterval > 0 && e <= 0 && this.stopIndication(), e > 0 && this.startIndication(e), this.audioVolumeIndicationInterval = e, this.remoteUsers.forEach((t) => { t.enableAudioVolumeIndication(e); }), this.self.enableAudioVolumeIndication(e)); } setPlayoutVolume(e) { this.playoutVolume = e, this.remoteUsers.forEach((t) => { t.setPlayoutVolume(e); }); } refreshAuthInfo(e) { this.authInfo && (this.authInfo = J(J({}, 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, n; 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] = J(J({}, o), u) : this.parameter[c] = u; }), t.enableBlankAudio === !0 ? (this.blankAudioPlugin || (this.blankAudioPlugin = new Cc()), 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), (n = this.blankAudioPlugin) == null || n.clear(), this.blankAudioPlugin = void 0); } getParameter() { return JSON.stringify(this.parameter); } sendDataChannelMessage(e) { return this.self.sendDataChannelMessage(e); } } /** * @ignore */ g(Pe, "logName", "BizControl"); je([ D() ], Pe.prototype, "init", 1); je([ D() ], Pe.prototype, "leave", 1); je([ D() ], Pe.prototype, "clear", 1); je([ D(H) ], Pe.prototype, "addUser", 1); je([ D() ], Pe.prototype, "removeLeftUser", 1); je([ D() ], Pe.prototype, "updateUsers", 1); je([ D(H) ], Pe.prototype, "updateAudioWant", 1); je([ D(H) ], Pe.prototype, "updateVideoWant", 1); je([ D(H) ], Pe.prototype, "updateScreenWant", 1); je([ D() ], Pe.prototype, "stopIndication", 1); je([ D() ], Pe.prototype, "startIndication", 1); je([ D(H) ], Pe.prototype, "setEnableDualVideoStream", 1); je([ D(H) ], Pe.prototype, "setAudioVolume", 1); je([ D() ], Pe.prototype, "enableAudioVolumeIndication", 1); const Mr = (r) => w(void 0, null, function* () { const a = new Uint8Array(160).fill(170), e = new TextEncoder().encode(r), t = yield window.crypto.subtle.importKey( "raw", // 密钥格式 a, // 密钥数据 { name: "HMAC", hash: { name: "SHA-1" } }, // 算法详情 !1, // 不可导出密钥 ["sign"] // 可用操作 ), i = yield window.crypto.subtle.sign( "HMAC", t, e // 需要签名的数据 ); return Array.from(new Uint8Array(i)).map((s) => s.toString(16).padStart(2, "0")).join(""); }); class Uc { constructor(a) { g(this, "authInfo"); g(this, "slsReporter"); this.slsReporter = a; } doRequest(a, e) { var u; const t = this.authInfo; if (!t) return Promise.reject(ht.LiveTranscodingErrorInvalidParam); const i = "https://gw.rtn.aliyuncs.com", s = M0[a], n = { appid: t.appId, userid: t.userId, channelid: t.channelId, timestamp: t.timestamp, token: t.token, nonce: t.nonce ? t.nonce : "", requestid: He.createCallid(), tokensid: !1, session: (u = t.sessionId) != null ? u : He.createCallid() }, c = Object.keys(n).map((h) => `${h}=${encodeURIComponent(n[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(a) { this.authInfo = a; } clear() { this.authInfo = void 0; } startPublishLiveStream(a, e) { return w(this, null, function* () { if (!this.authInfo) return Promise.reject(ht.LiveTranscodingErrorInvalidParam); const t = yield Mr(a.split("?")[0]), i = Ue.MPU_TASK_TRANSACTION_UPDATE, s = e.toJson(i, this.authInfo, t, a); return this.doRequest(i, s); }); } startPublishLiveStreamWithTaskId(a, e) { return w(this, null, function* () { if (!this.authInfo) return Promise.reject(ht.LiveTranscodingErrorInvalidParam); const t = Ue.MPU_TASK_TRANSACTION_UPDATE, i = e.toJson(t, this.authInfo, a); return this.doRequest(t, i); }); } updatePublishLiveStream(a, e) { return w(this, null, function* () { if (!this.authInfo) return Promise.reject(ht.LiveTranscodingErrorInvalidParam); const t = yield Mr(a.split("?")[0]), i = Ue.MPU_TASK_TRANSACTION_UPDATE, s = e.toJson(i, this.authInfo, t, a); return this.doRequest(i, s); }); } updatePublishLiveStreamWithTaskId(a, e) { return w(this, null, function* () { if (!this.authInfo) return Promise.reject(ht.LiveTranscodingErrorInvalidParam); const t = Ue.MPU_TASK_TRANSACTION_UPDATE, i = e.toJson(t, this.authInfo, a); return this.doRequest(t, i); }); } stopPublishLiveStream(a) { return w(this, null, function* () { if (!this.authInfo) return Promise.reject(ht.LiveTranscodingErrorInvalidParam); const e = yield Mr(a.split("?")[0]), t = Ue.MPU_TASK_TRANSACTION_STOP, i = new Fr().toJson(t, this.authInfo, e, a); return this.doRequest(t, i); }); } stopPublishLiveStreamWithTaskId(a) { if (!this.authInfo) return Promise.reject(ht.LiveTranscodingErrorInvalidParam); const e = Ue.MPU_TASK_TRANSACTION_STOP, t = new Fr().toJson(e, this.authInfo, a); return this.doRequest(e, t); } refreshAuthInfo(a) { this.authInfo && this.setAuthInfo(J(J({}, this.authInfo), a)); } } class cs { /** * 检测是否是string类型 * @param {any} param * @returns true: 是string类型 false: 不是string类型 */ static checkString(a) { return typeof a == "string"; } /** * 检测是否是number类型 * @param {any} param * @returns true: 是number类型 false: 不是number类型 */ static checkNumber(a) { return typeof a == "number"; } /** * 检测是否是HtmlVideoElement * @param {any} param * @returns true: 是HtmlVideoElement false: 不是HtmlVideoElement */ static checkHtmlVideoElement(a) { return a && a.nodeName === "VIDEO"; } /** * 检测是否是HtmlAudioElement * @param {any} param * @returns true: 是HtmlAudioElement false: 不是HtmlAudioElement */ static checkHtmlAudioElement(a) { return a && a.nodeName === "AUDIO"; } /** * 检查AuthInfo的值是否规范 * @param {any} authInfo * @returns */ static checkAuthInfo(a) { if (!a) return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD, "no authInfo founded"); if (!a.appId) return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD, "no appId founded"); if (!a.channelId) return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD, "no channelId founded"); if (!a.userId) return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD, "no userId founded"); if (a.timestamp) { if (!cs.checkNumber(a.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 a.token ? null : new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD, "no token founded"); } /** * 检测是否是MediaStreamTrack类型 * @param {any} track * @returns */ static checkMediaStreamTrack(a) { return a instanceof MediaStreamTrack; } /** * 检查VideoProfile类型 * @param profile * @returns */ static checkVideoEncoderConfiguration(a) { return a && (a.width || a.height || a.frameRate || a.bitrateMax); } } class Hc { constructor(a) { 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 = a; } } class jc { constructor(a, e, t) { g(this, "userId"); g(this, "streamType"); g(this, "sourceType"); this.userId = a, this.streamType = e, this.sourceType = t; } } class zc { constructor(a, e, t, i = 0, s = 16777215, n = Ii.NOTO_SERIF_CJKSC_REGULAR) { g(this, "x"); g(this, "y"); g(this, "fontSize"); g(this, "zOrder"); g(this, "fontColor"); g(this, "fontType"); this.x = a, this.y = e, this.fontSize = t, this.zOrder = i, this.fontColor = s, this.fontType = n; } toJson(a, e) { return { x: Ye(this.x, a), y: Ye(this.y, e), fonttype: this.fontType, fontsize: this.fontSize, fontcolor: rs(this.fontColor), zorder: this.zOrder }; } } var wn = /* @__PURE__ */ ((r) => (r[r.NOT_DISPLAY = 0] = "NOT_DISPLAY", r[r.ALWAYS = 1] = "ALWAYS", r[r.WHEN_NO_VIDEO = 2] = "WHEN_NO_VIDEO", r))(wn || {}); class Dn { constructor(a, e, t, i, s, n = 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 = a, this.x = e, this.y = t, this.width = i, this.height = s, this.zOrder = n, this.alpha = c, this.display = o; } toJson(a, e) { return { url: this.url, alpha: this.alpha, display: this.display, x: Ye(this.x, a), y: Ye(this.y, e), width: Ye(this.width, a), height: Ye(this.height, e), zorder: this.zOrder }; } } g(Dn, "DisplayType", wn); class Wc { constructor(a, e, t, i, s = 0, n = 16777215, c = Ii.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 = a, this.x = e, this.y = t, this.fontSize = i, this.zOrder = s, this.fontColor = n, this.fontType = c; } toJson(a, e) { return { text: this.text, x: Ye(this.x, a), y: Ye(this.y, e), fonttype: this.fontType, fontsize: this.fontSize, fontcolor: rs(this.fontColor), zorder: this.zOrder }; } } class $c { constructor(a, e, t, i, s, n = 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", Ei.LiveTranscodingNoBody); g(this, "images", []); g(this, "texts", []); typeof a == "number" ? this.userId = a.toString() : this.userId = a, this.x = e, this.y = t, this.width = i, this.height = s, this.zOrder = n, c && (this.sourceType = c); } toJson(a, e, t, i) { const s = { paneid: a, 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((n) => n.toJson(e, t)), texts: this.texts.map((n) => n.toJson(e, t)) }; return this.sourceType && ii[this.sourceType] ? s.sourcetype = ii[this.sourceType] : s.sourcetype = ii[ni.LiveTranscodingCamera], this.segmentType && i === is.LiveTranscodingVirtualBackground ? s.segmenttype = this.segmentType : s.segmenttype = Ei.LiveTranscodingNoBody, s; } } const Lt = class Lt { constructor() { // 使用 static 声明实例 g(this, "ntpClock"); this.ntpClock = new le.Clock(); } static getInstance() { return Lt.instance || (Lt.instance = new Lt()), Lt.instance; } now() { return this.ntpClock.now(); } }; g(Lt, "instance"); let Wr = Lt; const Tn = () => Wr.getInstance(), { BrowserUtil: Lr, SystenUtil: tn } = le; class rn { 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 = Tn(); } createTracker() { if (!this.tracker && this.slsToken && this.param) { const a = this.slsToken; this.ossToken && (this.param.ossbn = this.ossToken.bucket_name, this.param.ossep = this.ossToken.region_endpoint); const e = new Gr({ host: a.region_endpoint, project: a.project, logstore: a.log_store_stats }), t = { accessKeyId: a.access_key_id, accessKeySecret: a.access_key_secret, securityToken: a.security_token, // 以下是一个 stsToken 刷新函数的简单示例 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 = Zr(t); e.useStsPlugin(i), this.tracker = e, this.msgCacheArr.forEach((s, n) => { var c, o; (o = this.tracker) == null || o.send(J(ut(J({}, this.param), { stat_log_id: `${((c = this.param) == null ? void 0 : c.sesid) || "nosession"}-${n}` }), s)); }), this.index = this.index + this.msgCacheArr.length, this.msgCacheArr = []; } } start(a) { this.initParam(a), this.createTracker(); } updateToken(a, e) { this.slsToken = a, this.ossToken = e, this.createTracker(); } /** * 断开连接 */ stop() { this.tracker = void 0, this.param = void 0, this.msgCacheArr = [], this.index = 0, this.stsOpt = void 0, this.slsToken = void 0, this.ossToken = void 0; } /** * 发送一条日志 * @param {any} log */ sendReport(a) { var t, i; a.tm = Date.now(); let e; try { e = JSON.parse( JSON.stringify(J(ut(J({ bt: Lr.browserName || "unknown", ntptm: this.ntpClock.now(), // NTP时间 ntpofs: this.ntpClock.now() - Date.now() }, this.param), { stat_log_id: `${((t = this.param) == null ? void 0 : t.sesid) || "nosession"}-${this.index}` }), a)) ); } catch (s) { } if (e) { if (!this.tracker) { this.msgCacheArr.push(e); return; } (i = this.tracker) == null || i.send(e), this.index++; } } /** * 初始化公共参数 */ initParam(a) { let e = ""; try { e = (localStorage == null ? void 0 : localStorage.getItem("AliRtcUUID")) || "", e || (e = rt(), localStorage == null || localStorage.setItem("AliRtcUUID", e)); } catch (t) { } this.param || (this.param = { apid: a.appId, usrid: a.userId, statsvrs: "0.6.1", evetid: 0, sesid: a.sessionId, sessionId: a.sessionId, channelid: a.channelId, usrn: a.userId, osn: tn.systemName, osv: tn.systemVersion, deb: R0(), den: A0(), udid: e, sdkvrs: yi, acs: "Unknown", cput: ln(), dm: `${window.location.protocol}//${window.location.host}`, // bt 需要保证不为空 bt: Lr.browserName, bv: Lr.browserVersion, envir: "PRODUCT", args: "", instid: rt() // SDK 的实例ID }); } } const fe = (r, a = 1, e = 6e4, t = 0) => { let i = r; return i || (i = 0), Math.min(e, Math.max(t, Math.round(i * a))); }, Ge = (r, a, e = 2e7, t = 0) => { let i = a; (!a || a < 0 || a > 1e4) && (i = 1e3); let s = r; return s || (s = 0), Math.min(e, Math.max(t, Math.round(s / (i / 1e3)))); }, kt = (r, a) => { if (a === 0 || !a) return "0.00"; let e = r; return (!e || e < 0) && (e = 0), (e / a * 100).toFixed(2); }, sn = (r) => r >= 0 && r <= 1 ? fe(Math.floor(32767 * r), 1, 32767) : 0, pe = (r, a) => { var t, i, s; let e = ((t = r._last) == null ? void 0 : t[a]) || 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[a]) || 0) - e; }, Kc = (r, a) => { var e, t, i; return (((e = r == null ? void 0 : r._source) == null ? void 0 : e[a]) || 0) - (((i = (t = r == null ? void 0 : r._last) == null ? void 0 : t._source) == null ? void 0 : i[a]) || 0); }, an = (r, a) => fe(pe(r, a), 1e3, 1e4), Bt = (r, a = 2e7) => fe(r, 1, a), si = class si { constructor(a) { g(this, "engine"); g(this, "logClient"); g(this, "authInfo"); g(this, "ntpClock"); g(this, "customFields", {}); this.logClient = new rn(), this.engine = a, this.ntpClock = Tn(); } static getLogClient() { return this.staticClient || (this.staticClient = new rn()), this.staticClient; } static reportOSSUpload(a, e, t = 0) { si.getLogClient().sendReport({ errmsg: `${e}/${a}.log`, errtype: t, evetid: 70017, sesid: a, sessionId: a, stat_log_id: `${a}-70017` }); } /** * 设置通用字段 * @param fields 字段键值对 */ setCustomFields(a) { this.customFields = J(J({}, this.customFields), a); } /** * 获取通用字段 * @param key 字段键 * @returns 字段值或undefined */ getCustomField(a) { return this.customFields[a]; } /** * 开始建立连接 * @param authInfo */ start(a) { this.authInfo = a, this.logClient.start(a); } updateToken(a, e) { this.logClient.updateToken(a, e), si.getLogClient().updateToken(a, e); } /** * 断开连接 */ stop() { this.logClient.stop(); } reportPublishMonitor(a, e, t, i, s) { if (!t || s.length <= 0) return; const n = t === T.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 = [], _ = [], y = [], A = [], R = [], M = [], C = []; try { if (s.forEach((I) => { var F, N, G, j, ce, Z; if (!I || !I.timestamp) return; const P = (F = I._last) != null && F.timestamp ? I.timestamp - I._last.timestamp : 1e3, B = pe(I, "bytesSent"), $ = pe(I, "headerBytesSent"), q = Ge(fe(B + $, 8, 2e7), P); o.push(q); const X = Ge(fe(B, 8, 2e7), P); u.push(X); const ae = Ge(fe($, 8, 2e7), P); h.push(ae); const Q = pe(I, "packetsSent"), te = Ge(Q, P); p.push(te); const ee = pe(I, "packetsLost"), k = Ge(ee, P); d.push(k); const L = kt(ee, Q); if (f.push(L), n) (N = I._source) != null && N.audioLevel && m.push(sn(I._source.audioLevel)), l.push(0); else { S.push(an(I, "totalEncodeTime")), v.push(Bt((G = I._source) == null ? void 0 : G.framesPerSecond, 100)), x.push(Bt((j = I._source) == null ? void 0 : j.framesPerSecond, 100)), b.push(Bt(I.framesPerSecond, 100)), E.push(Bt((ce = I._source) == null ? void 0 : ce.height, 4400)), _.push(Bt((Z = I._source) == null ? void 0 : Z.width, 7700)), y.push(Bt(I.frameHeight, 4400)), A.push(Bt(I.frameWidth, 7700)); const Ve = pe(I, "totalPacketSendDelay"); R.push(fe(Ve, 1 / (ee || 1), 2e3)); const ze = pe(I, "qpSum"); M.push(fe(ze, 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(","), n) { 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 = _.join(","), c.sh = y.join(","), c.sw = A.join(","), c.sd = R.join(","), c.aqp = M.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: a, args: this.data2String(J({ calid: a, tckid: t, traceid: e }, c)) }); } reportSubscribeMonitor(a, e, t, i, s) { if (!i || !s || s.length <= 0) return; const n = i === T.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 = [], _ = [], y = [], A = [], R = [], M = [], C = [], I = [], P = [], B = [], $ = [], q = [], X = [], ae = [], Q = [], te = [], ee = [], k = [], L = [], F = [], N = [], G = []; try { s.forEach((j) => { var tt, wt; if (!j || !j.timestamp) return; const ce = (tt = j._last) != null && tt.timestamp ? j.timestamp - j._last.timestamp : 1e3, Z = pe(j, "bytesReceived"), Ve = pe(j, "headerBytesReceived"), ze = Ge(fe(Z + Ve, 8, 2e7), ce); o.push(ze); const Qe = Ge(fe(Z, 8, 2e7), ce); u.push(Qe); const et = Ge(fe(Ve, 8, 2e7), ce); h.push(et); const xe = pe(j, "packetsReceived"), ke = Ge(xe, ce); p.push(ke); const ot = pe(j, "packetsLost"), Ct = Ge(ot, ce); d.push(Ct); const Ht = kt(ot, xe); f.push(Ht); const Rt = pe(j, "jitterBufferDelay"), Yt = pe(j, "jitterBufferEmittedCount"); if (j.jitterBufferDelay && j.jitterBufferEmittedCount) { const gt = fe(Rt, 1e3 / Yt, 1e4); m.push(gt); } else m.push(0); const It = pe(j, "fecPacketsReceived"); b.push(kt(It, xe)); const Be = pe(j, "retransmittedPacketsReceived"), Re = xe + ot - Be; if (S.push(kt(xe - Be, Re)), v.push(kt(ot, Re)), l.push(kt(Be, Re)), x.push(Re), N.push(0), G.push(""), n) { _.push(sn(j.audioLevel)); const gt = Kc(j, "synthesizedSamplesEvents"); y.push(gt); const it = an(j, "synthesizedSamplesDuration"); A.push(it); const ct = kt(it, ce); E.push(ct), R.push(0); } else { const gt = (wt = j._last) != null && wt.totalInterFrameDelay ? j.totalInterFrameDelay - j._last.totalInterFrameDelay : 0; M.push(fe(gt, 1e3 / (j.framesDecoded || 30), 500)), C.push(fe(j.framesPerSecond, 1, 100)), I.push(pe(j, "framesReceived")), F.push(pe(j, "framesRendered")), P.push(fe(j.frameHeight, 1, 4400)), B.push(fe(j.frameWidth, 1, 7700)); const it = pe(j, "totalProcessingDelay"); $.push(fe(it, 1e3 / (j.framesDecoded || 30), 12e4)); const ct = pe(j, "nackCount"); X.push(ct); const ki = pe(j, "pliCount"); q.push(ki); const ui = pe(j, "qpSum"); ae.push(fe(ui, 1 / (j.framesPerSecond || 1), 51)), Q.push(fe(j.framesDropped)); const hi = pe(j, "totalFreezesDuration"); te.push(fe(hi, 1e3, 3e4)); const We = pe(j, "jitterBufferEmittedCount"), mt = pe(j, "jitterBufferDelay"); mt && We ? ee.push(fe(mt, 1e3 / We, 3e4)) : ee.push(0); const di = pe(j, "jitterBufferTargetDelay"); di && We ? k.push(fe(di, 1e3 / We, 3e4)) : k.push(0); const Zt = pe(j, "jitterBufferMinimumDelay"); Zt && We ? L.push(fe(Zt, 1e3 / We, 3e4)) : L.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(","), n ? (c.er = E.join(","), c.aolevel = _.join(","), c.asrc = R.join(","), c.scnt = y.join(","), c.sdura = A.join(",")) : (c.dm = M.join(","), c.dfps = C.join(","), c.rfps = I.join(","), c.rh = P.join(","), c.rw = B.join(","), c.fpt = G.join(","), c.ns = X.join(","), c.pliss = q.join(","), c.aqp = ae.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 = te.join(","), c.cdm = ee.join(","), c.tdm = k.join(","), c.pdm = L.join(","), c.ofps = F.join(","), c.dfbd = Q.join(",")); } catch (j) { } this.log({ evetid: 10080, traceid: t, rmtid: e, calid: a, args: this.data2String(J({ calid: a, rmtid: e, tckid: i, traceid: t }, c)) }); } reportNetworkMonitor(a) { if (a.length <= 0) return; const e = [], t = [], i = [], s = [], n = [], c = [], o = [], u = [], h = [], p = []; a.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(fe(f.currentRoundTripTime, 1e3)), t.push(fe(f.availableOutgoingBitrate, 8, 2e8)), i.push(Ge(fe(f.bytesSent, 8, 2e7), l, 25e6)), s.push(Ge(fe(f.bytesReceived, 8, 2e7), l, 25e6)), n.push(0), c.push(0), m % 5 === 0 && (o.push(""), u.push(""), h.push(""), p.push("")); }); const d = { ctm: Math.floor(a[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(J({ asb: t.join(","), abms: n.join(","), vbms: c.join(",") }, d)) }), this.log({ evetid: 10081, args: this.data2String(J({}, d)) }); } /** * 加入房间成功埋点 * @param {number} joinTime * @param {number} result * @param {string} tid */ reportJoin(a, e, t = "") { var p, d; const { start: i, rs: s = 0, re: n = 0 } = e, c = Date.now() - i, o = n - s; let u = 0; s && (u = s - i); let h = 0; n && (h = n - s), this.log({ evetid: 10010, args: this.data2String({ sesid: ((p = this.authInfo) == null ? void 0 : p.sessionId) || "", joitm: c, rslt: a, 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 }) }); } /** * Join 链接细节 */ reportJoinConnection(a) { this.log({ evetid: 20002, args: this.data2String(J({ transretrynum: 0, ldnstc: 0, tcptc: 0, ssltc: 0, url: "" }, a)) }); } /** * 用户离开频道事件埋点 * @param {number} leaveTime * @param {number} result * @param {string} tid */ reportLeave(a, e, t) { this.log({ evetid: 10020, args: this.data2String({ lvetm: a, rslt: e, tid: t }) }); } /** * 推流事件上报 * @param {string} callid * @param {boolean} isLargeVideo * @param {boolean} isSmallVideo * @param {boolean} isScreenShare * @param {boolean} isAudio * @param {number} result * @param {string} tid * @param {number} pubTime */ reportPublish(a, e, t, i, s, n, c, o, u, h, p) { this.log({ evetid: a ? 10032 : 10030, calid: t, args: this.data2String({ calid: t, url: e, isvl: i ? 1 : 0, isvs: s ? 1 : 0, isvss: n ? 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, // TODO... 后续完善重试逻辑 pubretry: 0, pbrttimes: 0 }) }); } /** * 首包上报 * @param {string} callid * @param {number} startTime * @param {number} publishTime * @param {number} joinTime * @param {string} tckid * @param {string} pcTraceId * @param {string} traceId * @param {PublishReason} reason */ reportPublishFirstPacket(a, e, t, i, s, n, c, o, u) { const h = Date.now(); this.log({ evetid: a ? 10033 : 10031, calid: e, args: this.data2String({ calid: e, fpst: h - t, tckid: n, est: t, pctid: c, pubtid: o, totaltm: h - s, jorm: u === nt.JOIN_CHANNEL ? 1 : 0, cptc: 0, sptc: i - t, iptc: 0, ipc2fptc: 0, dctc: 0, patc: 0 }) }); } /** * 停止推流事件上报 * @param {string} callid * @param {number} unpubTime * @param {number} result * @param {string} tid */ reportUnpublish(a, e, t, i) { var s; this.log({ evetid: 10040, args: this.data2String({ calid: a, unpubtm: e, rslt: t, tid: i, sesid: ((s = this.authInfo) == null ? void 0 : s.sessionId) || "" }) }); } /** * 订阅事件埋点 * @param {string} callid * @param {string} remoteid * @param {boolean} isLargeVideo * @param {boolean} isSmallVideo * @param {boolean} isScreenShare * @param {boolean} isAudio * @param {number} result * @param {string} tid * @param {number} subTime */ reportSubscribe(a, e, t, i, s, n, c, o, u, h) { this.log({ evetid: 10050, calid: a, rmtid: e, args: this.data2String(J({ calid: a, rmtid: e, isvl: t ? 1 : 0, isvs: i ? 1 : 0, isvss: s ? 1 : 0, isaudio: n ? 1 : 0, rslt: c, tid: o, subtm: u, isvp: 0, isaplaying: 0, isad: 0, isdc: 0, subretry: 0, sbrttimes: 0 }, h)) }); } reportSubscribeFirstPacket(a, e, t, i, s) { this.log({ evetid: a ? 10054 : 10051, calid: e, rmtid: t, args: this.data2String(J({ calid: e, rmtid: t, tckid: i, cptc: 0, iptc: 0, ipc2fptc: 0, dctc: 0, patc: 0 }, s)) }); } reportSubscribeFirstFrame(a, e, t, i, s) { this.log({ evetid: a ? 10055 : 10052, calid: e, rmtid: t, args: this.data2String(J({ calid: e, rmtid: t, tckid: i }, s)) }), this.log({ evetid: a ? 10058 : 10057, args: this.data2String(J({ calid: e, rmtid: t, tckid: i }, s)) }); } /** * 停止订阅事件埋点 * @param {string} callid * @param {string} remoteid * @param {number} unsubTime * @param {number} result * @param {string} tid */ reportUnsubscribe(a, e, t, i, s) { this.log({ evetid: 10060, calid: a, args: this.data2String({ calid: a, rmtid: e, unsubtm: t, rslt: i, tid: s }) }); } reportMute(a, e, t) { this.log({ evetid: 11030, args: this.data2String({ calid: a, rmtid: "", enable: e ? 1 : 0, mt: t }) }); } /** * 更新角色埋点 * @param {string|undefined} or 旧的角色 * @param {string} nr 新的角色 */ reportRoleUpdate(a, e) { this.log({ evetid: 11040, args: this.data2String({ or: a || "", nr: e, ctm: Date.now(), rslt: 0 }) }); } /** * 更新角色埋点 * @param {string|undefined} or 旧的角色 * @param {string} nr 新的角色 */ reportRoleUpdateResult(a, e, t, i) { this.log({ evetid: 11041, args: this.data2String({ or: a || "", nr: e, ctm: t, rslt: i }) }); } /** * 设置camera videoprofile */ reportVideoProfile(a) { this.log({ evetid: 20074, args: this.data2String({ pf: a, tckid: "sophon_camera_large" }) }); } /** * 设置screenshare videoprofile */ reportScreenProfile(a) { this.log({ evetid: 20074, args: this.data2String({ pf: a, tckid: "sophon_screenshare" }) }); } /** * 错误事件埋点 * @param err */ reportError(a) { this.log({ evetid: 10091, args: this.data2String({ rslt: (a == null ? void 0 : a.code) || -1 }) }); } /** * 错误事件埋点 * @param err */ reportWarning(a) { this.log({ evetid: 10092, args: this.data2String({ rslt: -1, errmsg: a }) }); } reportRoomServerEvent(a, e, t, i) { this.log({ evetid: 20005, args: this.data2String({ calid: "", rmtid: "", rt: a ? 0 : 1, dr: a ? "s" : "r", mt: e, ri: t, cs: 1, srt: Date.now(), rspc: (i == null ? void 0 : i.code) || "", mc: JSON.stringify(i) }) }); } reportTranscodingError(a, e) { this.log({ evetid: 10101, args: this.data2String({ rslt: a, taskid: e }) }); } reportBye(a) { var e; this.log({ evetid: 10093, args: this.data2String({ rslt: a, sesid: ((e = this.authInfo) == null ? void 0 : e.sessionId) || "" }) }); } reportAudio(a, e, t) { var i; this.log({ evetid: 80013, args: this.data2String({ rslt: a ? -1 : 0, adm: 1, adt: 0, adr: a ? 2 : 0, acms: e, adrpn: t }) }), this.log({ evetid: 80014, args: this.data2String({ sesid: ((i = this.authInfo) == null ? void 0 : i.sessionId) || "", rslt: a ? -1 : 0, adm: 1, adt: 0, adr: a ? 2 : 0, acms: e, adrpn: t }) }); } reportScreen(a, e) { var t, i, s, n; this.log({ evetid: 90013, args: this.data2String({ rslt: a ? -1 : 0, vcms: e, vde: (t = a == null ? void 0 : a.code) != null ? t : -1, sesid: ((i = this.authInfo) == null ? void 0 : i.sessionId) || "" }) }), this.log({ evetid: 90014, args: this.data2String({ rslt: a ? -1 : 0, vcms: e, vde: (s = a == null ? void 0 : a.code) != null ? s : -1, sesid: ((n = this.authInfo) == null ? void 0 : n.sessionId) || "" }) }); } reportScreenStop(a) { this.log({ evetid: 90019, args: this.data2String({ rslt: a ? a.code || -1 : 0 }) }), this.log({ evetid: 90020, args: this.data2String({ rslt: a ? a.code || -1 : 0 }) }); } reportSwitchCamera(a) { var e; this.log({ evetid: 90025, args: this.data2String({ rslt: 0, td: a, sesid: ((e = this.authInfo) == null ? void 0 : e.sessionId) || "" }) }); } reportPublishProfile(a, e) { this.log({ evetid: 10201, args: this.data2String(J({ tckid: a }, e)) }); } reportSDKCreated(a) { this.log({ evetid: 70011, createtm: Date.now() - a, tm: a }); } reportJoinInvoked(a) { this.log({ evetid: 70012, jnnonce: a.nonce || "", jntoken: a.token || "", jntm: a.timestamp || "" }); } reportJoinResult(a) { this.log({ evetid: 70013, rslt: a ? a.code || -1 : 0, dnsrslt: 0 }); } reportSTSResult(a, e) { this.log({ evetid: 70014, rslt: a, asty: 1, reqtm: Date.now() - e }); } reportLeaveInvoked() { this.log({ evetid: 70015 /* LEAVE_INVOKED */ }); } reportSEIMessage(a, e, t, i, s) { this.log({ evetid: 40301, args: this.data2String({ tm: Date.now(), sei_pt: a, sei_len: e, sei_rep: t, sei_delay: i, sei_key: s }) }); } /** * 接通耗时事件(12001) * 用stage和status来区分接通过程中各个时间节点。 * @param state * @param status * @param calid * @param tckid */ reportConnectionLatencyEvent(a, e, t, i, s, n, c = !1) { const o = { ageniid: this.getCustomField("ageniid") }, u = J({ tm: s || Date.now(), ntptm: n || this.ntpClock.now(), stage: a, status: e, calid: t, tckid: i, cltp: 1, // AI场景profile:0,非ai场景;1,真人;2,机器人。 http: c ? 1 : 0 }, o); this.log({ evetid: 12001, args: this.data2String(u) }); } /** * 日志埋点 * 在埋点中增加tm字段,表示发生埋点的客户端本地时间 * @param {any} param 埋点内容 */ log(a) { a && (a.tm = (/* @__PURE__ */ new Date()).getTime(), O.debug("[ConsoleLogger]", "log", a), this.logClient.sendReport(a)); } /** * 将Object转换成string * @param {any} data * @returns {string} */ data2String(a) { let e = ""; for (let t in a) e.length && (e += "&"), e += t + "=" + a[t]; return e; } }; g(si, "staticClient"); let $r = si; var qc = Object.defineProperty, Jc = Object.getOwnPropertyDescriptor, W = (r, a, e, t) => { for (var i = t > 1 ? void 0 : t ? Jc(a, e) : a, s = r.length - 1, n; s >= 0; s--) (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i); return t && i && qc(a, e, i), i; }, K; const z = (K = class extends De { 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", ue.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 $r(this), this.channelProfile = bt.AliRtcSdkCommunication, this.clientRole = Nt.AliRtcSdkLive, this.liveTranscoding = new Uc(this.slsReporter), this.signalingManager = new ns( 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 Pe({ slsReporter: this.slsReporter, signalingManager: this.signalingManager }), this.addBizControlListeners(), this.addPublisherListeners(), this.slsReporter.reportConnectionLatencyEvent( Je.CREATE_ENGINE, Xe.START, "", "", t ), this.slsReporter.reportConnectionLatencyEvent( Je.CREATE_ENGINE, Xe.END, "", "", Date.now() ), this.slsReporter.reportSDKCreated(t); } static getSdkVersion() { return yi; } static setLogLevel(e) { O.setLogLevel(e); } /** * @brief 获取AliRtcEngine实例 * @param key key 可选参与,用于创建多个实例 * @details 该方法为同步调用,以单例的形式提供对象创建。 */ static getInstance(e) { return K._instance || (K._instance = new K(e)), K._instance; } destroy() { return w(this, null, function* () { K._instance = void 0, yield this.leaveChannel(), yield this.bizControl.clear(), O.destroy(); }); } /** * 获取当前频道号,已经入会成功返回频道号,否则返回undefined */ get channel() { return this.bizControl.channel; } /** * 获取当前用户的 userId,已经入会成功返回自己的 userId,否则返回 undefined */ 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 === bt.AliRtcSdkCommunication || this.clientRole === Nt.AliRtcSdkInteractive; } /** * 监听 Publisher 事件 */ addPublisherListeners() { var e, t, i, s, n, c, o, u, h, p; (e = this.publisher) == null || e.on(Le.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", dt.AliEngineLocalDeviceTypeCamera, _e.AliEngineLocalDeviceExceptionTypeCameraInterrupt, "" ); }), (i = this.publisher) == null || i.on(Vt.ScreenTrackEnded, () => { O.event("[Publisher] ScreenTrack Ended"), this.emit( "localDeviceException", dt.AliEngineLocalDeviceTypeDisplay, _e.AliEngineLocalDeviceExceptionTypeDisplayException, "" ); }), (s = this.publisher) == null || s.on(Vt.AudioTrackEnded, () => { O.event("[Publisher] AudioTrack Ended"), this.emit( "localDeviceException", dt.AliEngineLocalDeviceTypeMic, _e.AliEngineLocalDeviceExceptionTypeMicInterrupt, "" ); }), (n = this.publisher) == null || n.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(`[${K.logName}]`, "Occur Error", e, t), this.emit("onOccurError", e, t), this.emit("occurError", e, t); } /** * 监听 UM 事件 */ addBizControlListeners() { this.bizControl.rtsManager.on("connected", (e) => { var t; e && ((t = this.publisher) == null || t.publishUpdate(nt.RECONNECT), this.remoteUsers.forEach((i) => { i.updateSubscribe(de.Reconnect); })); }), this.bizControl.rtsManager.on("disconnected", () => w(this, null, function* () { O.event(`[${K.logName}]`, "RTS Disconnected"), (yield He.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((n) => n.streamUrl === e); s && this.emit("mediaExtensionMsgReceived", s.userId, i, t); }), this.bizControl.on(Le.Remote, (e, t) => { O.event(`[${K.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, n) => { this.emit("audioSubscribeStateChanged", e, t, i, s, n); }), this.bizControl.on("videoSubscribeStateChanged", (e, t, i, s, n) => { this.emit("videoSubscribeStateChanged", e, t, i, s, n); }), this.bizControl.on("screenSubscribeStateChanged", (e, t, i, s, n) => { this.emit("screenShareSubscribeStateChanged", e, t, i, s, n); }), this.bizControl.on("dataSubscribeStateChanged", (e, t, i, s, n) => { this.emit("dataSubscribeStateChanged", e, t, i, s, n); }), this.bizControl.on("userAudioMuted", (e, t) => { this.emit("userAudioMuted", e, t); }), this.bizControl.on("userVideoMuted", (e, t) => { this.emit("userVideoMuted", e, t); }), this.bizControl.on("userScreenMuted", (e, t) => { this.emit("userScreenMuted", e, t); }), this.bizControl.on("audioVolume", (e) => { this.emit("audioVolume", e); }), this.bizControl.on("remoteAudioAutoPlayFail", (e) => { this.emit("remoteAudioAutoPlayFail", e); }), this.bizControl.on("remoteVideoAutoPlayFail", (e, t) => { this.emit("remoteVideoAutoPlayFail", e, t); }), this.bizControl.on("remoteAudioPlayError", (e, t) => { this.emit("remoteAudioPlayError", e, t); }), this.bizControl.on("remoteVideoPlayError", (e, t) => { this.emit("remoteVideoPlayError", e, t); }), this.bizControl.on("rtcStats", (e) => { this.emit("rtcStats", e); }), this.bizControl.on("rtcLocalAudioStats", (e) => { this.emit("rtcLocalAudioStats", e); }), this.bizControl.on("rtcLocalVideoStats", (e) => { this.emit("rtcLocalVideoStats", e); }), this.bizControl.on("rtcRemoteAudioStats", (e) => { this.emit("rtcRemoteAudioStats", e); }), this.bizControl.on("rtcRemoteVideoStats", (e) => { this.emit("rtcRemoteVideoStats", e); }), this.bizControl.on("remoteSubscribeError", (e, t) => { this.occurError(e, t), this.slsReporter.reportError(e); }), this.bizControl.on("occurError", (e, t) => { this.occurError(e, t), this.slsReporter.reportError(e); }), this.bizControl.on("remoteDataChannelMessage", (e, t) => { this.emit("dataChannelMsg", e, t); }); } /** * 添加信令处理 * @returns {void} */ 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 = ue.AliRtcConnectionStatusFailed, this.emit( "connectionStatusChange", ue.AliRtcConnectionStatusFailed, Wt.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 = ue.AliRtcConnectionStatusReconnecting, this.emit( "connectionStatusChange", ue.AliRtcConnectionStatusReconnecting, Wt.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 = ue.AliRtcConnectionStatusDisconnected, (e = this.publisher) != null && e.isPublishing && ((t = this.publisher) == null || t.clearPublishState()), this.networkError = !1; } /** * 处理入会远程的用户 * @param {JoinInfo[]} users * @returns {void} */ handleUsersJoin(e) { e.forEach((t) => { const i = t.userid; if (i) { const s = this.bizControl.addUser(i, t.displayname, de.Join); O.event(`[${K.logName}]`, oe.UserJoined, s); } }); } /** * 本地用户设备状态变化,通过信令发送给其他人 * @param {string} status * @returns {void} */ onLocalDeviceStatusChange(e) { O.event(`[${K.logName}]`, Le.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 n = 1; try { yield new Promise((c, o) => { const u = setInterval(() => w(this, null, function* () { var h; n > 1 && (clearInterval(u), o()), n += 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( K.logName, "onNetworkRecovery", `rts isConnected: ${this.bizControl.rtsManager.isConnected}; rts isConnecting: ${this.bizControl.rtsManager.isConnecting}`, { users: e } ), !this.bizControl.rtsManager.isConnected && !this.bizControl.rtsManager.isConnecting ? (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 = ue.AliRtcConnectionStatusConnected, this.emit( "connectionStatusChange", ue.AliRtcConnectionStatusConnected, Wt.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(`[${K.logName}]`, "resumeSubList", { joinList: t, leaveList: i, presentList: s }), this.handleUsersJoin(t), i.forEach((n) => { O.event(K.logName, oe.UserLeft, n.userid, n.reason), this.emit("remoteUserOffLineNotify", n.userid, ss.AliRtcUserOfflineQuit); }); for (let n = 0; n < s.length; n++) { const c = s[n], o = c.userid, u = this.bizControl.getRemoteUser(o); this.bizControl.onRemotePublishStateChange(c), u == null || u.updateSubscribe(de.Resume); } } else for (let t = 0; t < this.remoteUsers.length; t++) { const i = this.remoteUsers[t]; try { i.restore(), i.updateSubscribe(de.Resume); } catch (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(de.Retry); }); } /** * 处理网络异常 * @param {AliRtcError} err * @returns {void} */ onNetworkError() { this.connectState === ue.AliRtcConnectionStatusConnected && (this.networkError || (this.connectState = ue.AliRtcConnectionStatusDisconnected, this.emit( "connectionStatusChange", ue.AliRtcConnectionStatusDisconnected, Wt.AliRtcConnectionChangedNetworkInterrupted )), this.networkError = !0); } /** * 处理错误 * @param {AliRtcError} err * @returns {void} */ onError(e) { this.slsReporter.reportError(e), O.event(K.logName, oe.Error, e); } setEnableDualVideoStream(e, t) { this.bizControl.setEnableDualVideoStream(e, t); } /** * 对本地流的操作预检查 */ // @ts-ignore hadPushStream(e) { if (!(this.publisher && e)) throw new V(U.ERR_INNER, "stream is not publishing"); } /** * 获取当前使用的麦克风 deviceId * @returns {string | undefined} */ getCurrentMicDeviceId() { var e; return (e = this.publisher) == null ? void 0 : e.getCurrentMicDeviceId(); } setChannelProfile(e) { if (![ ue.AliRtcConnectionStatusInit, ue.AliRtcConnectionStatusDisconnected, ue.AliRtcConnectionStatusFailed ].includes(this.connectState)) throw new V(U.ERR_INNER, "cannot set channel profile in call"); this.channelProfile = e, this.channelProfile === bt.AliRtcSdkCommunication && (this.clientRole = Nt.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(`[${K.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(`[${K.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 n = ((h = this.publisher) == null ? void 0 : h.publishStreams) || {}; if (Object.values(n).some((d) => d)) try { yield (p = this.publisher) == null ? void 0 : p.startPublish(!1, e); } catch (d) { const f = []; n != null && n.audio && f.push(U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED), n != null && n.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 === bt.AliRtcSdkCommunication) return; if (!Object.values(Nt).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 === Nt.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(nt.ROLE_CHANGE)) : yield this.signalingManager.setClientRole(e), this.clientRole = e; } catch (s) { throw s.code === 403 && this.emit("authInfoExpired"), s; } }); } /** * 获取用户角色 * @returns {AliRtcSdkClientRole} */ 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); } /** * 设定鉴权信息过期事件定时器 * @param expireTimestamp 鉴权信息过期时间 * @param serverTimestamp 入会时服务端时间 */ 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, n = 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; n || (n = s.userId); const c = { start: Date.now() }; let o = cs.checkAuthInfo(s); if (ue.AliRtcConnectionStatusInit === this.connectState || ue.AliRtcConnectionStatusDisconnected === this.connectState || ue.AliRtcConnectionStatusFailed === this.connectState) { if (s.sessionId = He.createCallid("web"), this.slsReporter.start(s), this.slsReporter.reportConnectionLatencyEvent( Je.JOIN, Xe.START, "", "", i ), this.connectState = ue.AliRtcConnectionStatusConnecting, o) throw this.connectState = ue.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, n, this.maxSignalingConnectRetryCount, c ), f = Date.now(); this.connectState = ue.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( Je.JOIN, Xe.SEND_SIG, "", "", p ), this.slsReporter.reportConnectionLatencyEvent( Je.JOIN, Xe.RECV_RST, "", "", f ), this.slsReporter.reportConnectionLatencyEvent(Je.JOIN, Xe.END, "", ""); } catch (p) { const d = (h = p.code) != null ? h : -1, f = p.reason || p.message || ""; throw this.connectState = ue.AliRtcConnectionStatusDisconnected, this.slsReporter.reportJoin(d, c, ""), this.slsReporter.reportJoinResult(p), new V(d, f); } this.currentRoleCanPublish && (yield this.startAndPublishDefaultDevices(nt.JOIN_CHANNEL)), this.remoteUsers.forEach((p) => { p.updateSubscribe(de.Join); }); } else { const p = new V(U.ERR_JOIN_ALREADY_JOINED, "already joined"); throw this.connectState === ue.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 = (/* @__PURE__ */ new Date()).getTime(); if (ue.AliRtcConnectionStatusConnected === this.connectState) try { let i; i = yield this.signalingManager.leave(), this.slsReporter.reportLeave((/* @__PURE__ */ new Date()).getTime() - e, 0, (t = i == null ? void 0 : i.tid) != null ? t : ""); } catch (i) { this.slsReporter.reportLeave( (/* @__PURE__ */ new Date()).getTime() - e, i.code, i.reason ); } else this.slsReporter.reportLeave(0, 0, ""); this.networkError = !1, this.connectState = ue.AliRtcConnectionStatusDisconnected, this.clearCheckAuthInfoTimer(), this.liveTranscoding.clear(), this.slsReporter.stop(), this.signalingManager.reset(), O.reportEnd(); }); } /** * 检查当前是否在频道中 * @returns {boolean} * - true:在频道中 * - false:不在频道中 */ isInCall() { return this.connectState === ue.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: n, token: c, role: o } = t, u = { userId: i, nonce: s, timestamp: n, 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; } }); } /** * 检查当前是否纯音频模式 * @returns {boolean} * - true:纯音频模式 * - false:音视频模式 */ isAudioOnly() { return this._audioOnlyMode; } publishLocalAudioStream(e) { return w(this, null, function* () { var t, i, s, n; (t = this.publisher) == null || t.setPublishLocalAudioStreamEnabled(e), this.connectState === ue.AliRtcConnectionStatusConnected && (e ? (i = this.publisher) != null && i.hasMicrophone ? yield (s = this.publisher) == null ? void 0 : s.updateStreams() : yield this.startAudioCapture() : yield (n = this.publisher) == null ? void 0 : n.publishUpdate()); }); } /** * @brief 查询是否设置推送音频流 * @return * - true: 已设置推送 * - false: 未设置推送 * @note SDK默认设置推送音频流,如果需要取消推送音频流,可以通过 {@link publishLocalAudioStream}方法设置为不推送 */ 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, n; (t = this.publisher) == null || t.setPublishLocalVideoStreamEnabled(e), this.connectState === ue.AliRtcConnectionStatusConnected && (e ? (i = this.publisher) != null && i.hasCamera ? yield (s = this.publisher) == null ? void 0 : s.updateStreams() : yield this.enableLocalVideo() : yield (n = this.publisher) == null ? void 0 : n.publishUpdate()); }); } /** * @brief 查询是否设置推送视频流 * @return * - true: 已设置推送 * - false: 未设置推送 * @note SDK默认设置推送视频流,如果需要取消推送视频流,可以通过 {@link publishLocalVideoStream} 方法设置为不推送 */ isLocalVideoStreamPublished() { var e, t; return (t = (e = this.publisher) == null ? void 0 : e.publishLocalVideoStreamEnabled) != null ? t : !0; } setRemoteDefaultVideoStreamType(e) { [we.AliRtcVideoStreamTypeHigh, we.AliRtcVideoStreamTypeLow].includes(e) && this.bizControl.setRemoteDefaultVideoStreamType(e); } setRemoteUserVideoStreamType(e, t) { [we.AliRtcVideoStreamTypeHigh, we.AliRtcVideoStreamTypeLow].includes(t) && this.bizControl.setRemoteUserVideoStreamType(e, t); } setDefaultSubscribeAllRemoteVideoStreams(e) { this.bizControl.setAutoSubVideo(e), this.bizControl.setAutoSubScreen(e); } subscribeAllRemoteVideoStreams(e) { this.bizControl.setWantSubVideo(e), this.bizControl.setWantSubScreen(e); } subscribeRemoteMediaStream(e, t, i, s) { const n = this.bizControl.getRemoteUser(e); if (!n) throw new V(U.ERR_INNER, `no remote user(${e}) founded`); i && (t === se.AliRtcVideoTrackScreen || t === se.AliRtcVideoTrackBoth) ? n.setWantSubScreen(!0) : n.setWantSubScreen(!1), i && (t === se.AliRtcVideoTrackCamera || t === se.AliRtcVideoTrackBoth) ? n.setWantSubVideo(!0) : n.setWantSubVideo(!1), n.setWantSubAudio(s), n.updateSubscribe(de.User); } resumeRemoteMediaStream(e, t) { const i = this.bizControl.getRemoteUser(e); i && i.resumeVideo(t); } /** * @brief 订阅目标频道,指定用户的流 * @param channelId 目标频道 * @param uid 用户ID,从App server分配的唯一标示符 * @param track 订阅的视频流类型 * @param sub_audio 是否订阅远端用户的音频流 * - true:订阅指定用户的音频流 * - false:停止订阅指定用户的音频流 * @param sub 是否订阅远端用户的流 * - true:订阅指定用户的流 * - false:停止订阅指定用户的流 */ // public subscribeRemoteDestChannelStream( // channelId: string, // uid: string, // track: AliRtcVideoTrack, // sub_audio: boolean, // sub: boolean // ) { // throw new Error('Method not implemented.'); // } /** * @brief 获取远端在线用户列表 * @return 当前频道内所有在线用户userid列表 * @note 若当前频道ChannelProfile设置为 {@link AliRtcSdkChannelProfile.AliRtcSdkInteractiveLive} 模式,只有设置角色为 {@link AliRtcSdkClientRole.AliRtcSdkInteractive} 的用户为在线用户,本方法不返回角色为 {@link AliRtcSdkClientRole.AliRtcSdkLive} 的用户 */ getOnlineRemoteUsers() { return this.bizControl.remoteUsers.map((e) => e.userId); } /** * @brief 查询远端用户状态 * @details 通过 uid 查询指定远端用户的状态信息. * @param uid 用户ID。从App server分配的唯一标示符 * @return 返回一个远端用户对象。详见{@link RemoteUser} */ getUserInfo(e) { var t; return (t = this.bizControl.getRemoteUser(e)) == null ? void 0 : t.remoteUserInfo; } /** * @brief 查询用户是否在线 * @param uid 用户ID,从App server分配的唯一标示符。不可为NULL * @return * - true: 用户在线 * - false: 用户不在线 * @note 根据特定的UserID,查询该用户是否在线。 */ 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: n } = e || {}; if (s || n) { t.screen = !0; const o = new MediaStream(); s && o.addTrack(s), n && o.addTrack(n), 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 n; const { frameRate: t, bitrate: i } = e, s = {}; t && (s.frameRate = t), i && (s.maxBitrate = i), yield (n = this.publisher) == null ? void 0 : n.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, n; (i = this.publisher) == null || i.setPublishLocalScreenStreamEnabled(e), this.connectState === ue.AliRtcConnectionStatusConnected && (e ? (s = this.publisher) != null && s.hasScreenShare ? yield this.publisher.updateStreams() : yield this.startScreenShare(t) : yield (n = this.publisher) == null ? void 0 : n.publishUpdate()); }); } /** * @brief 查询是否设置推送屏幕分享 * @return - true: 已设置推送 - false: 未设置推送 * @note SDK默认设置不推送屏幕分享,如果需要推送屏幕共享,可以通过{@link startScreenShare}方法开启屏幕共享推送 */ 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 ? oe.MuteAudio : oe.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, n, c; if (yield (i = this.publisher) == null ? void 0 : i.setMicrophoneDeviceId(e), !((s = this.publisher) != null && s.audioCaptureDisabled)) { if (t) { yield (n = this.publisher) == null ? void 0 : n.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, n; 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 === se.AliRtcVideoTrackCamera && ((s = this.publisher) != null && s.hasCamera) ? yield this.startPreview() : t === se.AliRtcVideoTrackScreen && ((n = this.publisher) != null && n.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: n } = u, c = Dt(u, ["cameraDirection", "deviceId", "bitrate", "maxSendFrameRate"]), o = J({}, c); s && (o.maxBitrate = s), n && (o.maxSendFrameRate = n), 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, n, 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 = (n = (s = this.publisher) == null ? void 0 : s.publishStreams) == null ? void 0 : n.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 ? oe.MuteVideo : oe.UnmuteVideo), (t = this.publisher) == null || t.muteLocalCamera(e); }); } muteLocalScreen(e) { return w(this, null, function* () { var t; this.isPublishing && this.onLocalDeviceStatusChange(e ? oe.MuteScreen : oe.UnmuteScreen), (t = this.publisher) == null || t.muteLocalScreen(e); }); } setRemoteViewConfig(e, t, i) { this.bizControl.setRemoteViewConfig(t, e, i); } /** * 检查camera是否打开 * @return {boolean} * - true: 摄像头已打开 * - false: 摄像头没有打开 * @note 该接口用于检查当前camera的状态 */ 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, n, 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" ? oi.CAMERA_FRONT : oi.CAMERA_REAR, this.slsReporter.reportSwitchCamera(((n = this.publisher) == null ? void 0 : n.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); } }); } /** * 获取摄像头设备ID * @return {string} 摄像头设备ID */ 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 }); }); } /** * @brief 获取当前用户或远端用户的视频轨道 * @param {AliRtcVideoTrackConfig} config 视频轨道配置 * @return {MediaStreamTrack} 视频轨道 * */ getVideoTrack(e) { return w(this, null, function* () { var n, c, o, u; const { userId: t, streamType: i } = e; if (!t) return i === be.AliRtcSdkStreamTypeCapture ? (n = this.publisher) == null ? void 0 : n.cameraTrack : (c = this.publisher) == null ? void 0 : c.screenTrack; const s = this.bizControl.getRemoteUser(t); return i === be.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); } /** * @brief 发送媒体扩展信息 * @details SDK提供了发送和接收媒体扩展信息的功能,接收端参考 {@link AliRtcEngineEventListener.mediaExtensionMsgReceived},使用场景: * - 使用媒体扩展信息传递时间戳,计算端到端的网络延迟,或者跟自身其他业务做数据同步 * - 使用媒体扩展信息传递描述信息。目前可以传递最多 4k Byte数据,可以用来传输少量数据,建议使用Json或者纯字符串; * - 内部使用SEI扩展协议来实现; * * @param message 媒体扩展信息,长度限制为最大4K字节 * @param repeatCount 重复次数,代表消息冗余度,用于防止网络丢包导致的消息丢失,-1为无限传输 * * @note 启用此能力会增加客户端性能开销,如有需求需要在加入房间之前调用 setEnableMediaExtensionMsg * @note 使用媒体扩展信息时需要复用音视频数据通道,因此必须控制自定义消息的发送频率和消息数据长度,使用限制如下: * - 每秒最多发送profile条消息,因为sei信息是放到h264/h265流中传输,有视频帧编码才能附加扩展信息; * - 为了不影响媒体数据的传输质量,自定义消息体长度限制为4k Byte,可以用来传输少量信息; * - sendMediaExtensionMsg函数中repeatCount参数为自定义消息冗余度,若大于1,则会发送多次, * - 防止网络丢包导致的消息丢失,此时房间里的其他人也会收到多次相同的消息,需要去重 * - 发送的自定义消息,在旁路直播时,房间里的订阅者也一样会收到 * - 同一时间只有一条MediaExtensionMsg在传输,多次调用sendMediaExtensionMsg,新调用的数据会覆盖前一次的数据; */ 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(); } /** * 美颜功能是否有效 * @return * - true: 美颜功能有效 * - false: 无效 */ isBeautyAvailable() { return this.bizControl.pluginManager.has("AliRtcBeauty"); } /** * 美颜功能是否开启 * @return * - true: 美颜功能已开启 * - false: 已关闭 */ isBeautyEnabled() { const e = this.bizControl.pluginManager.get("AliRtcBeauty"); if (!e) throw new V( _t.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( _t.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( _t.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( _t.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); } }, /** * @ignore */ g(K, "logName", "AliRtcEngine"), /** * @ignore */ g(K, "logError", !0), /** * 检查浏览器是否支持 WebRTC * @param {string} direction * @returns {Promise} */ g(K, "isSupported", P0), /** * 检查浏览器是否支持开启大小流 * @returns {boolean} */ g(K, "isDualVideoStreamSupported", zr.isSupport), /** * 获取摄像头列表 * @returns {Promise} */ g(K, "getCameraList", () => w(K, null, function* () { return (yield le.getCameraList()).filter((t) => t.deviceId); })), g(K, "getMicrophoneList", () => w(K, null, function* () { return (yield le.getMicList()).filter((t) => t.deviceId); })), g(K, "getSpeakerList", () => w(K, null, function* () { return (yield le.getSpeakerList()).filter((t) => t.deviceId); })), g(K, "_instance"), g(K, "AliRtcSdkChannelProfile", bt), g(K, "AliRtcSdkClientRole", Nt), g(K, "AliRtcVideoStreamType", we), g(K, "AliRtcVideoTrack", se), g(K, "AliRtcAudioTrack", Xt), g(K, "AliRtcPublishState", Y), g(K, "AliRtcSubscribeState", he), g(K, "AliRtcRawDataStreamType", be), g(K, "AliRtcLogLevel", fn), g(K, "AliRtcEngineLocalDeviceType", dt), g(K, "AliRtcEngineLocalDeviceExceptionType", _e), g(K, "AliRtcConnectionStatus", ue), g(K, "AliRtcConnectionStatusChangeReason", Wt), g(K, "AliRtcPlugin", Gt), g(K, "AliRtcPluginTrackType", Ri), g(K, "AliRtcLiveTranscodingParam", Fr), g(K, "AliRtcLiveTranscodingEncodeParam", vn), g(K, "AliRtcLiveTranscodingMixParam", Hc), g(K, "AliRtcLiveTranscodingSingleParam", jc), g(K, "AliRtcTranscodingClockWidget", zc), g(K, "AliRtcTranscodingImage", Dn), g(K, "AliRtcTranscodingText", Wc), g(K, "AliRtcTranscodingUser", $c), g(K, "AliRtcLiveTranscodingMixMode", bi), g(K, "AliRtcLiveTranscodingStreamType", pn), g(K, "AliRtcLiveTranscodingSourceType", ni), g(K, "AliRtcLiveTranscodingTaskProfile", gn), g(K, "AliRtcLiveTranscodingAudioSampleRate", ts), g(K, "AliRtcLiveTranscodingSegmentType", Ei), g(K, "AliRtcLiveTranscodingFontType", Ii), g(K, "AliRtcLiveTranscodingCropMode", mn), g(K, "AliRtcLiveTranscodingMediaProcessMode", is), g(K, "AliRtcLiveTranscodingState", Sn), g(K, "AliRtcLiveTranscodingErrorCode", ht), g(K, "AliRtcTrascodingPublishTaskStatus", xn), g(K, "AliRtcDataChannelMsg", qt), g(K, "AliRtcDataMsgType", Cn), g(K, "Plugin", Gt), K); W([ D() ], z.prototype, "destroy", 1); W([ D() ], z.prototype, "backToUnpublishStatus", 1); W([ D() ], z.prototype, "resumePublishForNetworkRecovery", 1); W([ D() ], z.prototype, "onNetworkRecovery", 1); W([ D() ], z.prototype, "resumeSubList", 1); W([ D(H) ], z.prototype, "retrySubscribe", 1); W([ D(H) ], z.prototype, "setEnableDualVideoStream", 1); W([ D(H) ], z.prototype, "setChannelProfile", 1); W([ D(H) ], z.prototype, "setClientRole", 1); W([ D(H) ], z.prototype, "setAudioOnlyMode", 1); W([ D() ], z.prototype, "clearCheckAuthInfoTimer", 1); W([ D(H) ], z.prototype, "joinChannel", 1); W([ D(H) ], z.prototype, "leaveChannel", 1); W([ D(H) ], z.prototype, "refreshAuthInfo", 1); W([ D(H) ], z.prototype, "publishLocalAudioStream", 1); W([ D(H) ], z.prototype, "setDefaultSubscribeAllRemoteAudioStreams", 1); W([ D(H) ], z.prototype, "subscribeAllRemoteAudioStreams", 1); W([ D(H) ], z.prototype, "subscribeRemoteAudioStream", 1); W([ D(H) ], z.prototype, "resumeRemoteAudioStream", 1); W([ D(H) ], z.prototype, "stopRemoteAudioPlay", 1); W([ D(H) ], z.prototype, "publishLocalVideoStream", 1); W([ D(H) ], z.prototype, "setRemoteDefaultVideoStreamType", 1); W([ D(H) ], z.prototype, "setRemoteUserVideoStreamType", 1); W([ D(H) ], z.prototype, "setDefaultSubscribeAllRemoteVideoStreams", 1); W([ D(H) ], z.prototype, "subscribeAllRemoteVideoStreams", 1); W([ D(H) ], z.prototype, "subscribeRemoteMediaStream", 1); W([ D(H) ], z.prototype, "resumeRemoteMediaStream", 1); W([ D(([r]) => [`${r == null ? void 0 : r.audio}`]) ], z.prototype, "startScreenShare", 1); W([ D() ], z.prototype, "stopScreenShare", 1); W([ D(H) ], z.prototype, "setScreenShareConfiguration", 1); W([ D(H) ], z.prototype, "setScreenShareContentHint", 1); W([ D() ], z.prototype, "publishLocalScreenShareStream", 1); W([ D(H) ], z.prototype, "setAudioShareVolume", 1); W([ D(H) ], z.prototype, "enableAudioVolumeIndication", 1); W([ D(H) ], z.prototype, "muteLocalMic", 1); W([ D(H) ], z.prototype, "muteRemoteAudioPlaying", 1); W([ D(H) ], z.prototype, "muteAllRemoteAudioPlaying", 1); W([ D(H) ], z.prototype, "startAudioCapture", 1); W([ D(H) ], z.prototype, "setAudioConstraints", 1); W([ D() ], z.prototype, "stopAudioCapture", 1); W([ D(H) ], z.prototype, "switchMicrophone", 1); W([ D(H) ], z.prototype, "setRecordingVolume", 1); W([ D(H) ], z.prototype, "setPlayoutVolume", 1); W([ D(H) ], z.prototype, "setRemoteAudioVolume", 1); W([ D(H) ], z.prototype, "setAudioProfile", 1); W([ D(H) ], z.prototype, "getAudioTrack", 1); W([ D(H) ], z.prototype, "setLocalViewConfig", 1); W([ D(H) ], z.prototype, "setCameraCapturerConfiguration", 1); W([ D(H) ], z.prototype, "setCameraCapturerContentHint", 1); W([ D(H) ], z.prototype, "enableLocalVideo", 1); W([ D(H) ], z.prototype, "muteLocalCamera", 1); W([ D(H) ], z.prototype, "muteLocalScreen", 1); W([ D(H) ], z.prototype, "setRemoteViewConfig", 1); W([ D(H) ], z.prototype, "switchCamera", 1); W([ D() ], z.prototype, "startPreview", 1); W([ D() ], z.prototype, "startPreviewScreen", 1); W([ D() ], z.prototype, "stopPreview", 1); W([ D() ], z.prototype, "stopPreviewScreen", 1); W([ D() ], z.prototype, "startPublishLiveStream", 1); W([ D() ], z.prototype, "updatePublishLiveStream", 1); W([ D() ], z.prototype, "updatePublishLiveStreamWithTaskId", 1); W([ D() ], z.prototype, "stopPublishLiveStream", 1); W([ D() ], z.prototype, "stopPublishLiveStreamWithTaskId", 1); W([ D(H) ], z.prototype, "setEnableMediaExtensionMsg", 1); W([ D(([r, a, e]) => [r.byteLength, a, e]) ], z.prototype, "sendMediaExtensionMsgEx", 1); W([ D(([r, a]) => [r.name || "", a]) ], z.prototype, "enablePlugin", 1); W([ D(H) ], z.prototype, "removePlugin", 1); W([ D(H) ], z.prototype, "setPluginOption", 1); W([ D(H) ], z.prototype, "getPluginOption", 1); W([ D(H) ], z.prototype, "setBeautyEffect", 1); W([ D(H) ], z.prototype, "enableBackgroundExchange", 1); W([ D(H) ], z.prototype, "enableBackgroundBlur", 1); W([ D(H) ], z.prototype, "setParameter", 1); W([ D(([r]) => { var a; return [(a = r.data) == null ? void 0 : a.byteLength]; }) ], z.prototype, "sendDataChannelMessage", 1); W([ D(H) ], z, "setLogLevel", 1); let Pn = z; var nn; const kn = new qr({ businessName: "imp-web-rtc", version: (nn = Pn.getSdkVersion()) != null ? nn : "unknown", env: "prod", disabled: window.AliRtcOptionsDisableProxy === !0 }); kn.setReady(); const Zc = kn.wrap(Pn); export { ue as AliRtcConnectionStatus, Wt as AliRtcConnectionStatusChangeReason, qt as AliRtcDataChannelMsg, Cn as AliRtcDataMsgType, _e as AliRtcEngineLocalDeviceExceptionType, dt as AliRtcEngineLocalDeviceType, U as AliRtcErrorCode, ts as AliRtcLiveTranscodingAudioSampleRate, mn as AliRtcLiveTranscodingCropMode, vn as AliRtcLiveTranscodingEncodeParam, ht as AliRtcLiveTranscodingErrorCode, Ii as AliRtcLiveTranscodingFontType, is as AliRtcLiveTranscodingMediaProcessMode, bi as AliRtcLiveTranscodingMixMode, Hc as AliRtcLiveTranscodingMixParam, Fr as AliRtcLiveTranscodingParam, Ei as AliRtcLiveTranscodingSegmentType, jc as AliRtcLiveTranscodingSingleParam, ni as AliRtcLiveTranscodingSourceType, Sn as AliRtcLiveTranscodingState, pn as AliRtcLiveTranscodingStreamType, gn as AliRtcLiveTranscodingTaskProfile, Ya as AliRtcLocalStreamInfo, fn as AliRtcLogLevel, Gt as AliRtcPlugin, Ri as AliRtcPluginTrackType, B0 as AliRtcPluginType, Y as AliRtcPublishState, be as AliRtcRawDataStreamType, lc as AliRtcRemoteUserInfo, bt as AliRtcSdkChannelProfile, Nt as AliRtcSdkClientRole, he as AliRtcSubscribeState, zc as AliRtcTranscodingClockWidget, Dn as AliRtcTranscodingImage, Wc as AliRtcTranscodingText, $c as AliRtcTranscodingUser, xn as AliRtcTrascodingPublishTaskStatus, we as AliRtcVideoStreamType, se as AliRtcVideoTrack, Zc as default };